Skip to content

Commit b848c42

Browse files
committed
[KeyInstr][debugify] Add --debugify-atoms to add key instructions metadata
1 parent eeb24e3 commit b848c42

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

llvm/lib/Transforms/Utils/Debugify.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ using namespace llvm;
3535

3636
namespace {
3737

38+
cl::opt<bool> ApplyAtomGroups("debugify-atoms", cl::init(false));
39+
3840
cl::opt<bool> Quiet("debugify-quiet",
3941
cl::desc("Suppress verbose debugify output"));
4042

@@ -142,8 +144,13 @@ bool llvm::applyDebugifyMetadata(
142144

143145
for (BasicBlock &BB : F) {
144146
// Attach debug locations.
145-
for (Instruction &I : BB)
146-
I.setDebugLoc(DILocation::get(Ctx, NextLine++, 1, SP));
147+
for (Instruction &I : BB) {
148+
uint64_t AtomGroup = ApplyAtomGroups ? NextLine : 0;
149+
uint8_t AtomRank = ApplyAtomGroups ? 1 : 0;
150+
uint64_t Line = NextLine++;
151+
I.setDebugLoc(DILocation::get(Ctx, Line, 1, SP, nullptr, false,
152+
AtomGroup, AtomRank));
153+
}
147154

148155
if (DebugifyLevel < Level::LocationsAndVariables)
149156
continue;

llvm/test/DebugInfo/debugify.ll

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
; RUN: opt -passes=debugify -S -o - < %s | FileCheck %s
22
; RUN: opt -passes=debugify -S -o - < %s | FileCheck %s
33

4+
; RUN: opt -passes=debugify --debugify-atoms -S -o - < %s \
5+
; RUN: | FileCheck %s -check-prefixes=CHECK-ATOMS
6+
47
; RUN: opt -passes=debugify,debugify -S -o - < %s 2>&1 | \
58
; RUN: FileCheck %s -check-prefix=CHECK-REPEAT
69
; RUN: opt -passes=debugify,debugify -S -o - < %s 2>&1 | \
@@ -101,6 +104,13 @@ define i32 @boom() {
101104
; CHECK-DAG: ![[musttail]] = !DILocation(line: 5, column: 1
102105
; CHECK-DAG: ![[musttailRes]] = !DILocation(line: 6, column: 1
103106

107+
; CHECK-ATOMS-DAG: !DILocation(line: 1{{.*}}, atomGroup: 1, atomRank: 1
108+
; CHECK-ATOMS-DAG: !DILocation(line: 2{{.*}}, atomGroup: 2, atomRank: 1
109+
; CHECK-ATOMS-DAG: !DILocation(line: 3{{.*}}, atomGroup: 3, atomRank: 1
110+
; CHECK-ATOMS-DAG: !DILocation(line: 4{{.*}}, atomGroup: 4, atomRank: 1
111+
; CHECK-ATOMS-DAG: !DILocation(line: 5{{.*}}, atomGroup: 5, atomRank: 1
112+
; CHECK-ATOMS-DAG: !DILocation(line: 6{{.*}}, atomGroup: 6, atomRank: 1
113+
104114
; --- DILocalVariables
105115
; CHECK-DAG: ![[TY32:.*]] = !DIBasicType(name: "ty32", size: 32, encoding: DW_ATE_unsigned)
106116
; CHECK-DAG: !DILocalVariable(name: "1", scope: {{.*}}, file: {{.*}}, line: 1, type: ![[TY32]])

0 commit comments

Comments
 (0)