Skip to content

Commit 422179d

Browse files
wsmosesnikic
authored andcommitted
[SimplifyCFG] Refine metadata handling during instruction hoisting (llvm#158448)
Co-authored-by: Nikita Popov <[email protected]> (cherry picked from commit c44e015)
1 parent 7b28655 commit 422179d

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

llvm/lib/Transforms/Utils/SimplifyCFG.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3034,7 +3034,7 @@ bool SimplifyCFGOpt::SpeculativelyExecuteBB(BranchInst *BI, BasicBlock *ThenBB,
30343034
if (!SpeculatedStoreValue || &I != SpeculatedStore) {
30353035
// Don't update the DILocation of dbg.assign intrinsics.
30363036
if (!isa<DbgAssignIntrinsic>(&I))
3037-
I.setDebugLoc(DebugLoc());
3037+
I.dropLocation();
30383038
}
30393039
I.dropUndefImplyingAttrsAndUnknownMetadata();
30403040

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
; RUN: opt -S -o - %s -passes=simplifycfg -simplifycfg-require-and-preserve-domtree=1 | FileCheck %s
2+
3+
4+
declare i1 @make_condition()
5+
6+
define i1 @specfn() readnone nounwind speculatable {
7+
ret i1 true
8+
}
9+
10+
; CHECK-LABEL: @test1(
11+
; CHECK: call i1 @specfn(), !dbg
12+
; CHECK: select i1
13+
define void @test1(i1 %cond) !dbg !6 {
14+
start:
15+
br i1 %cond, label %then, label %else, !dbg !9
16+
17+
then: ; preds = %start
18+
%sres = call i1 @specfn(), !dbg !8
19+
br label %else, !dbg !11
20+
21+
else: ; preds = %then, %start
22+
%phi = phi i1 [ %cond, %start ], [ %sres, %then ], !dbg !12
23+
ret void, !dbg !13
24+
}
25+
26+
!llvm.dbg.cu = !{!0}
27+
!llvm.debugify = !{!3, !4}
28+
!llvm.module.flags = !{!5}
29+
30+
!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
31+
!1 = !DIFile(filename: "test.ll", directory: "/")
32+
!2 = !{}
33+
!3 = !{i32 6}
34+
!4 = !{i32 0}
35+
!5 = !{i32 2, !"Debug Info Version", i32 3}
36+
!6 = distinct !DISubprogram(name: "test1", linkageName: "test1", scope: null, file: !1, line: 1, type: !7, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2)
37+
!7 = !DISubroutineType(types: !2)
38+
!8 = !DILocation(line: 1, column: 1, scope: !6)
39+
!9 = !DILocation(line: 2, column: 1, scope: !6)
40+
!10 = !DILocation(line: 3, column: 2, scope: !6)
41+
!11 = !DILocation(line: 4, column: 2, scope: !6)
42+
!12 = !DILocation(line: 5, column: 3, scope: !6)
43+
!13 = !DILocation(line: 6, column: 3, scope: !6)

0 commit comments

Comments
 (0)