Skip to content

Commit b0511cc

Browse files
committed
Fix original-di script, add tests
1 parent 4aef7c8 commit b0511cc

File tree

5 files changed

+157
-5
lines changed

5 files changed

+157
-5
lines changed
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
<html>
2+
<head>
3+
<style>
4+
table, th, td {
5+
border: 1px solid black;
6+
}
7+
table.center {
8+
margin-left: auto;
9+
margin-right: auto;
10+
}
11+
</style>
12+
</head>
13+
<body>
14+
<table>
15+
<caption><b>Location Bugs found by the Debugify</b></caption>
16+
<tr>
17+
<th>File</th>
18+
<th>LLVM Pass Name</th>
19+
<th>LLVM IR Instruction</th>
20+
<th>Function Name</th>
21+
<th>Basic Block Name</th>
22+
<th>Action</th>
23+
<th>Origin</th>
24+
</tr>
25+
</tr>
26+
<tr>
27+
<td>test.ll</td>
28+
<td>LoopVectorizePass</td>
29+
<td>add</td>
30+
<td>fn</td>
31+
<td>no-name</td>
32+
<td>not-generate</td>
33+
<td><details><summary>View Origin StackTrace</summary><pre>Stack Trace 0:
34+
#0 0x00005895d035c935 llvm::DbgLocOrigin::DbgLocOrigin(bool) /tmp/llvm-project/llvm/lib/IR/DebugLoc.cpp:22:9
35+
#1 0x00005895d03af013 llvm::DILocAndCoverageTracking::DILocAndCoverageTracking() /tmp/llvm-project/llvm/include/llvm/IR/DebugLoc.h:90:11
36+
#2 0x00005895d03af013 llvm::DebugLoc::DebugLoc() /tmp/llvm-project/llvm/include/llvm/IR/DebugLoc.h:133:5
37+
#3 0x00005895d03af013 llvm::Instruction::Instruction(llvm::Type*, unsigned int, llvm::User::AllocInfo, llvm::InsertPosition) /tmp/llvm-project/llvm/lib/IR/Instruction.cpp:37:14
38+
#4 0x00005895d06862b5 llvm::PHINode::PHINode(llvm::Type*, unsigned int, llvm::Twine const&, llvm::InsertPosition) /tmp/llvm-project/llvm/include/llvm/IR/Instructions.h:0:9
39+
#5 0x00005895d06862b5 llvm::PHINode::Create(llvm::Type*, unsigned int, llvm::Twine const&, llvm::InsertPosition) /tmp/llvm-project/llvm/include/llvm/IR/Instructions.h:2651:9
40+
#6 0x00005895d06862b5 llvm::InstCombinerImpl::foldPHIArgGEPIntoPHI(llvm::PHINode&) /tmp/llvm-project/llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp:617:9
41+
#7 0x00005895d0688fe0 llvm::InstCombinerImpl::visitPHINode(llvm::PHINode&) /tmp/llvm-project/llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp:1456:22
42+
#8 0x00005895d05cd21f llvm::InstCombinerImpl::run() /tmp/llvm-project/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp:5327:22
43+
#9 0x00005895d05d067e combineInstructionsOverFunction(llvm::Function&, llvm::InstructionWorklist&, llvm::AAResults*, llvm::AssumptionCache&, llvm::TargetLibraryInfo&, llvm::TargetTransformInfo&, llvm::DominatorTree&, llvm::OptimizationRemarkEmitter&, llvm::BlockFrequencyInfo*, llvm::BranchProbabilityInfo*, llvm::ProfileSummaryInfo*, llvm::InstCombineOptions const&) /tmp/llvm-project/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp:5643:31
44+
#10 0x00005895d05cf9a9 llvm::InstCombinePass::run(llvm::Function&, llvm::AnalysisManager&) /tmp/llvm-project/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp:5706:8
45+
#11 0x00005895d107d07d llvm::detail::PassModel>::run(llvm::Function&, llvm::AnalysisManager&) /tmp/llvm-project/llvm/include/llvm/IR/PassManagerInternal.h:91:5
46+
#12 0x00005895d04204a7 llvm::PassManager>::run(llvm::Function&, llvm::AnalysisManager&) /tmp/llvm-project/llvm/include/llvm/IR/PassManagerImpl.h:85:8
47+
#13 0x00005895ce4cb09d llvm::detail::PassModel>, llvm::AnalysisManager>::run(llvm::Function&, llvm::AnalysisManager&) /tmp/llvm-project/llvm/include/llvm/IR/PassManagerInternal.h:91:5
48+
#14 0x00005895cfae2865 llvm::CGSCCToFunctionPassAdaptor::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) /tmp/llvm-project/llvm/lib/Analysis/CGSCCPassManager.cpp:0:38
49+
#15 0x00005895ce4cad5d llvm::detail::PassModel, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) /tmp/llvm-project/llvm/include/llvm/IR/PassManagerInternal.h:91:5
50+
#16 0x00005895cfade813 llvm::PassManager, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) /tmp/llvm-project/llvm/lib/Analysis/CGSCCPassManager.cpp:93:12
51+
#17 0x00005895d1e3968d llvm::detail::PassModel, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>, llvm::AnalysisManager, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) /tmp/llvm-project/llvm/include/llvm/IR/PassManagerInternal.h:91:5
52+
#18 0x00005895cfae1224 llvm::DevirtSCCRepeatedPass::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) /tmp/llvm-project/llvm/lib/Analysis/CGSCCPassManager.cpp:0:38
53+
#19 0x00005895d1e5067d llvm::detail::PassModel, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) /tmp/llvm-project/llvm/include/llvm/IR/PassManagerInternal.h:91:5</pre></details></td>
54+
</tr>
55+
<tr>
56+
</table>
57+
<br>
58+
<table>
59+
<caption><b>Summary of Location Bugs</b></caption>
60+
<tr>
61+
<th>LLVM Pass Name</th>
62+
<th>Number of bugs</th>
63+
</tr>
64+
<tr>
65+
<td>LoopVectorizePass</td>
66+
<td>1</td>
67+
</tr>
68+
<tr>
69+
</table>
70+
<br>
71+
<br>
72+
<table>
73+
<caption><b>SP Bugs found by the Debugify</b></caption>
74+
<tr>
75+
<th>File</th>
76+
<th>LLVM Pass Name</th>
77+
<th>Function Name</th>
78+
<th>Action</th>
79+
</tr>
80+
<tr>
81+
<td colspan='4'> No bugs found </td>
82+
</tr>
83+
</table>
84+
<br>
85+
<table>
86+
<caption><b>Summary of SP Bugs</b></caption>
87+
<tr>
88+
<th>LLVM Pass Name</th>
89+
<th>Number of bugs</th>
90+
</tr>
91+
<tr>
92+
<tr>
93+
<td colspan='2'> No bugs found </td>
94+
</tr>
95+
</table>
96+
<br>
97+
<br>
98+
<table>
99+
<caption><b>Variable Location Bugs found by the Debugify</b></caption>
100+
<tr>
101+
<th>File</th>
102+
<th>LLVM Pass Name</th>
103+
<th>Variable</th>
104+
<th>Function</th>
105+
<th>Action</th>
106+
</tr>
107+
<tr>
108+
<td colspan='4'> No bugs found </td>
109+
</tr>
110+
</table>
111+
<br>
112+
<table>
113+
<caption><b>Summary of Variable Location Bugs</b></caption>
114+
<tr>
115+
<th>LLVM Pass Name</th>
116+
<th>Number of bugs</th>
117+
</tr>
118+
<tr>
119+
<tr>
120+
<td colspan='2'> No bugs found </td>
121+
</tr>
122+
</table>
123+
</body>
124+
</html>

llvm/test/tools/llvm-original-di-preservation/Inputs/expected-skipped.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,15 @@
128128
<td>drop</td>
129129
</tr>
130130
<tr>
131+
</tr>
132+
<tr>
133+
<td>wrstabs.c</td>
134+
<td>Simplify the CFG</td>
135+
<td>tindex</td>
136+
<td>stab_bool_type</td>
137+
<td>drop</td>
138+
</tr>
139+
<tr>
131140
</tr>
132141
<tr>
133142
<td>prdbg.c</td>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"file":"test.ll", "pass":"LoopVectorizePass", "bugs": [[{"action":"not-generate","bb-name":"no-name","fn-name":"fn","instr":"add","metadata":"DILocation", "origin": "Stack Trace 0:\n #0 0x00005895d035c935 llvm::DbgLocOrigin::DbgLocOrigin(bool) /tmp/llvm-project/llvm/lib/IR/DebugLoc.cpp:22:9\n #1 0x00005895d03af013 llvm::DILocAndCoverageTracking::DILocAndCoverageTracking() /tmp/llvm-project/llvm/include/llvm/IR/DebugLoc.h:90:11\n #2 0x00005895d03af013 llvm::DebugLoc::DebugLoc() /tmp/llvm-project/llvm/include/llvm/IR/DebugLoc.h:133:5\n #3 0x00005895d03af013 llvm::Instruction::Instruction(llvm::Type*, unsigned int, llvm::User::AllocInfo, llvm::InsertPosition) /tmp/llvm-project/llvm/lib/IR/Instruction.cpp:37:14\n #4 0x00005895d06862b5 llvm::PHINode::PHINode(llvm::Type*, unsigned int, llvm::Twine const&, llvm::InsertPosition) /tmp/llvm-project/llvm/include/llvm/IR/Instructions.h:0:9\n #5 0x00005895d06862b5 llvm::PHINode::Create(llvm::Type*, unsigned int, llvm::Twine const&, llvm::InsertPosition) /tmp/llvm-project/llvm/include/llvm/IR/Instructions.h:2651:9\n #6 0x00005895d06862b5 llvm::InstCombinerImpl::foldPHIArgGEPIntoPHI(llvm::PHINode&) /tmp/llvm-project/llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp:617:9\n #7 0x00005895d0688fe0 llvm::InstCombinerImpl::visitPHINode(llvm::PHINode&) /tmp/llvm-project/llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp:1456:22\n #8 0x00005895d05cd21f llvm::InstCombinerImpl::run() /tmp/llvm-project/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp:5327:22\n #9 0x00005895d05d067e combineInstructionsOverFunction(llvm::Function&, llvm::InstructionWorklist&, llvm::AAResults*, llvm::AssumptionCache&, llvm::TargetLibraryInfo&, llvm::TargetTransformInfo&, llvm::DominatorTree&, llvm::OptimizationRemarkEmitter&, llvm::BlockFrequencyInfo*, llvm::BranchProbabilityInfo*, llvm::ProfileSummaryInfo*, llvm::InstCombineOptions const&) /tmp/llvm-project/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp:5643:31\n#10 0x00005895d05cf9a9 llvm::InstCombinePass::run(llvm::Function&, llvm::AnalysisManager&) /tmp/llvm-project/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp:5706:8\n#11 0x00005895d107d07d llvm::detail::PassModel>::run(llvm::Function&, llvm::AnalysisManager&) /tmp/llvm-project/llvm/include/llvm/IR/PassManagerInternal.h:91:5\n#12 0x00005895d04204a7 llvm::PassManager>::run(llvm::Function&, llvm::AnalysisManager&) /tmp/llvm-project/llvm/include/llvm/IR/PassManagerImpl.h:85:8\n#13 0x00005895ce4cb09d llvm::detail::PassModel>, llvm::AnalysisManager>::run(llvm::Function&, llvm::AnalysisManager&) /tmp/llvm-project/llvm/include/llvm/IR/PassManagerInternal.h:91:5\n#14 0x00005895cfae2865 llvm::CGSCCToFunctionPassAdaptor::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) /tmp/llvm-project/llvm/lib/Analysis/CGSCCPassManager.cpp:0:38\n#15 0x00005895ce4cad5d llvm::detail::PassModel, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) /tmp/llvm-project/llvm/include/llvm/IR/PassManagerInternal.h:91:5\n#16 0x00005895cfade813 llvm::PassManager, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) /tmp/llvm-project/llvm/lib/Analysis/CGSCCPassManager.cpp:93:12\n#17 0x00005895d1e3968d llvm::detail::PassModel, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>, llvm::AnalysisManager, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) /tmp/llvm-project/llvm/include/llvm/IR/PassManagerInternal.h:91:5\n#18 0x00005895cfae1224 llvm::DevirtSCCRepeatedPass::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) /tmp/llvm-project/llvm/lib/Analysis/CGSCCPassManager.cpp:0:38\n#19 0x00005895d1e5067d llvm::detail::PassModel, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) /tmp/llvm-project/llvm/include/llvm/IR/PassManagerInternal.h:91:5"}]]}

llvm/test/tools/llvm-original-di-preservation/basic.test

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
RUN: %llvm-original-di-preservation %p/Inputs/sample.json %t.html | FileCheck %s
22
RUN: diff -w %p/Inputs/expected-sample.html %t.html
3+
CHECK: The {{.+}}.html generated.
34
CHECK-NOT: Skipped lines:
45

56
RUN: %llvm-original-di-preservation %p/Inputs/corrupted.json %t2.html | FileCheck %s -check-prefix=CORRUPTED
@@ -9,5 +10,8 @@ CORRUPTED: Skipped bugs: 1
910

1011
RUN: %llvm-original-di-preservation -compress %p/Inputs/sample.json %t3.html | FileCheck %s -check-prefix=COMPRESSED
1112
RUN: diff -w %p/Inputs/expected-compressed.html %t3.html
13+
COMPRESSED: The {{.+}}.html generated.
1214
COMPRESSED-NOT: Skipped lines:
1315

16+
RUN: %llvm-original-di-preservation %p/Inputs/origin.json %t4.html | FileCheck %s
17+
RUN: diff -w %p/Inputs/expected-origin.html %t4.html

llvm/utils/llvm-original-di-preservation.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def __init__(self, origin, action, bb_name, fn_name, instr):
2121
self.instr = instr
2222

2323
def __str__(self):
24-
return self.action + self.bb_name + self.fn_name + self.instr + self.origin
24+
return self.action + self.bb_name + self.fn_name + self.instr
2525

2626

2727
class DISPBug:
@@ -80,15 +80,25 @@ def generate_html_report(
8080
table_title_di_loc
8181
)
8282

83+
# If any DILocation bug has an origin stack trace, we emit an extra column in the table, which we must therefore
84+
# determine up-front.
85+
has_origin_col = any(
86+
x.origin is not None
87+
for per_file_bugs in di_location_bugs.values()
88+
for per_pass_bugs in per_file_bugs.values()
89+
for x in per_pass_bugs
90+
)
91+
8392
header_di_loc = [
8493
"File",
8594
"LLVM Pass Name",
8695
"LLVM IR Instruction",
8796
"Function Name",
8897
"Basic Block Name",
8998
"Action",
90-
"Origin",
9199
]
100+
if has_origin_col:
101+
header_di_loc.append("Origin")
92102

93103
for column in header_di_loc:
94104
table_di_loc += " <th>{0}</th>\n".format(column.strip())
@@ -114,9 +124,13 @@ def generate_html_report(
114124
row.append(x.fn_name)
115125
row.append(x.bb_name)
116126
row.append(x.action)
117-
row.append(
118-
f"<details><summary>View Origin StackTrace</summary><pre>{x.origin}</pre></details>"
119-
)
127+
if has_origin_col:
128+
if x.origin is not None:
129+
row.append(
130+
f"<details><summary>View Origin StackTrace</summary><pre>{x.origin}</pre></details>"
131+
)
132+
else:
133+
row.append("")
120134
row.append(" </tr>\n")
121135
# Dump the bugs info into the table.
122136
for column in row:

0 commit comments

Comments
 (0)