Skip to content

Commit 431b996

Browse files
authored
[DebugInfo][SpeculativeExecution] Drop the debug location of the hoisted instruction (llvm#97384)
Fix llvm#97375 .
1 parent 73bfb65 commit 431b996

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

llvm/lib/Transforms/Scalar/SpeculativeExecution.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ bool SpeculativeExecutionPass::considerHoistingFromTo(
328328
++I;
329329
if (!NotHoisted.count(&*Current)) {
330330
Current->moveBefore(ToBlock.getTerminator());
331+
Current->dropLocation();
331332
}
332333
}
333334
return true;
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
; RUN: opt -S -passes=speculative-execution %s | FileCheck %s
2+
3+
; Check that SpeculativeExecution's considerHoistingFromTo() drops
4+
; the debug location of the hoisted instructions in a certain branch.
5+
6+
define void @ifThen() !dbg !5 {
7+
; CHECK-LABEL: define void @ifThen(
8+
; CHECK-SAME: ) !dbg [[DBG5:![0-9]+]] {
9+
; CHECK-NEXT: [[X:%.*]] = add i32 2, 3{{$}}
10+
;
11+
br i1 true, label %a, label %b, !dbg !8
12+
13+
a: ; preds = %0
14+
%x = add i32 2, 3, !dbg !9
15+
br label %b, !dbg !10
16+
17+
b: ; preds = %a, %0
18+
ret void, !dbg !11
19+
}
20+
21+
!llvm.dbg.cu = !{!0}
22+
!llvm.debugify = !{!2, !3}
23+
!llvm.module.flags = !{!4}
24+
25+
!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)
26+
!1 = !DIFile(filename: "main.ll", directory: "/")
27+
!2 = !{i32 4}
28+
!3 = !{i32 0}
29+
!4 = !{i32 2, !"Debug Info Version", i32 3}
30+
!5 = distinct !DISubprogram(name: "ifThen", linkageName: "ifThen", scope: null, file: !1, line: 1, type: !6, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0)
31+
!6 = !DISubroutineType(types: !7)
32+
!7 = !{}
33+
!8 = !DILocation(line: 1, column: 1, scope: !5)
34+
!9 = !DILocation(line: 2, column: 1, scope: !5)
35+
!10 = !DILocation(line: 3, column: 1, scope: !5)
36+
!11 = !DILocation(line: 4, column: 1, scope: !5)

0 commit comments

Comments
 (0)