Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[KeyInstr][debugify] Add --debugify-atoms to add key instructions metadata #133483

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 6, 2025

Conversation

OCHyams
Copy link
Contributor

@OCHyams OCHyams commented Mar 28, 2025

No description provided.

Copy link
Contributor Author

OCHyams commented Mar 28, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@llvmbot
Copy link
Member

llvmbot commented Mar 28, 2025

@llvm/pr-subscribers-llvm-transforms

@llvm/pr-subscribers-debuginfo

Author: Orlando Cazalet-Hyams (OCHyams)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/133483.diff

2 Files Affected:

  • (modified) llvm/lib/Transforms/Utils/Debugify.cpp (+9-2)
  • (modified) llvm/test/DebugInfo/debugify.ll (+10)
diff --git a/llvm/lib/Transforms/Utils/Debugify.cpp b/llvm/lib/Transforms/Utils/Debugify.cpp
index e6b5e267d192b..02c7d7f2f10ed 100644
--- a/llvm/lib/Transforms/Utils/Debugify.cpp
+++ b/llvm/lib/Transforms/Utils/Debugify.cpp
@@ -35,6 +35,8 @@ using namespace llvm;
 
 namespace {
 
+cl::opt<bool> ApplyAtomGroups("debugify-atoms", cl::init(false));
+
 cl::opt<bool> Quiet("debugify-quiet",
                     cl::desc("Suppress verbose debugify output"));
 
@@ -142,8 +144,13 @@ bool llvm::applyDebugifyMetadata(
 
     for (BasicBlock &BB : F) {
       // Attach debug locations.
-      for (Instruction &I : BB)
-        I.setDebugLoc(DILocation::get(Ctx, NextLine++, 1, SP));
+      for (Instruction &I : BB) {
+        uint64_t AtomGroup = ApplyAtomGroups ? NextLine : 0;
+        uint8_t AtomRank = ApplyAtomGroups ? 1 : 0;
+        uint64_t Line = NextLine++;
+        I.setDebugLoc(DILocation::get(Ctx, Line, 1, SP, nullptr, false,
+                                      AtomGroup, AtomRank));
+      }
 
       if (DebugifyLevel < Level::LocationsAndVariables)
         continue;
diff --git a/llvm/test/DebugInfo/debugify.ll b/llvm/test/DebugInfo/debugify.ll
index 191015f825933..269a301ce830c 100644
--- a/llvm/test/DebugInfo/debugify.ll
+++ b/llvm/test/DebugInfo/debugify.ll
@@ -1,6 +1,9 @@
 ; RUN: opt -passes=debugify -S -o - < %s | FileCheck %s
 ; RUN: opt -passes=debugify -S -o - < %s | FileCheck %s
 
+; RUN: opt -passes=debugify --debugify-atoms -S -o - < %s \
+; RUN: | FileCheck %s -check-prefixes=CHECK-ATOMS
+
 ; RUN: opt -passes=debugify,debugify -S -o - < %s 2>&1 | \
 ; RUN:   FileCheck %s -check-prefix=CHECK-REPEAT
 ; RUN: opt -passes=debugify,debugify -S -o - < %s 2>&1 | \
@@ -101,6 +104,13 @@ define i32 @boom() {
 ; CHECK-DAG: ![[musttail]] = !DILocation(line: 5, column: 1
 ; CHECK-DAG: ![[musttailRes]] = !DILocation(line: 6, column: 1
 
+; CHECK-ATOMS-DAG: !DILocation(line: 1{{.*}}, atomGroup: 1, atomRank: 1
+; CHECK-ATOMS-DAG: !DILocation(line: 2{{.*}}, atomGroup: 2, atomRank: 1
+; CHECK-ATOMS-DAG: !DILocation(line: 3{{.*}}, atomGroup: 3, atomRank: 1
+; CHECK-ATOMS-DAG: !DILocation(line: 4{{.*}}, atomGroup: 4, atomRank: 1
+; CHECK-ATOMS-DAG: !DILocation(line: 5{{.*}}, atomGroup: 5, atomRank: 1
+; CHECK-ATOMS-DAG: !DILocation(line: 6{{.*}}, atomGroup: 6, atomRank: 1
+
 ; --- DILocalVariables
 ; CHECK-DAG: ![[TY32:.*]] = !DIBasicType(name: "ty32", size: 32, encoding: DW_ATE_unsigned)
 ; CHECK-DAG: !DILocalVariable(name: "1", scope: {{.*}}, file: {{.*}}, line: 1, type: ![[TY32]])

Copy link
Member

@jmorse jmorse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@OCHyams OCHyams force-pushed the users/OCHyams/ki-llvm-simplifycfg branch 2 times, most recently from 0b2929c to 791863e Compare May 6, 2025 13:45
Base automatically changed from users/OCHyams/ki-llvm-simplifycfg to main May 6, 2025 14:03
@OCHyams OCHyams force-pushed the users/OCHyams/ki-llvm-debugify branch from b848c42 to 4a943f2 Compare May 6, 2025 14:05
@OCHyams OCHyams merged commit a363cca into main May 6, 2025
6 of 9 checks passed
@OCHyams OCHyams deleted the users/OCHyams/ki-llvm-debugify branch May 6, 2025 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants