Skip to content

Commit c44e015

Browse files
wsmosesnikic
andauthored
[SimplifyCFG] Refine metadata handling during instruction hoisting (#158448)
Co-authored-by: Nikita Popov <[email protected]>
1 parent 1e3dd5e commit c44e015

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
@@ -3392,7 +3392,7 @@ bool SimplifyCFGOpt::speculativelyExecuteBB(BranchInst *BI,
33923392
// hoisting above.
33933393
for (auto &I : make_early_inc_range(*ThenBB)) {
33943394
if (!SpeculatedStoreValue || &I != SpeculatedStore) {
3395-
I.setDebugLoc(DebugLoc::getDropped());
3395+
I.dropLocation();
33963396
}
33973397
I.dropUBImplyingAttrsAndMetadata();
33983398

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)