Skip to content

Commit 263232c

Browse files
committed
[KeyInstr] Remap cloned PHIs in BreakCriticalEdges
1 parent 5b29058 commit 263232c

File tree

3 files changed

+57
-0
lines changed

3 files changed

+57
-0
lines changed

llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,9 @@ bool llvm::SplitIndirectBrCriticalEdges(Function &F,
406406
// preds.
407407
ValueToValueMapTy VMap;
408408
BasicBlock *DirectSucc = CloneBasicBlock(Target, VMap, ".clone", &F);
409+
if (!VMap.AtomMap.empty())
410+
for (Instruction &I : *DirectSucc)
411+
RemapSourceAtom(&I, VMap);
409412

410413
BlockFrequency BlockFreqForDirectSucc;
411414
for (BasicBlock *Pred : OtherPreds) {
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
; RUN: opt -passes='require<profile-summary>,function(codegenprepare)' -S -mtriple=x86_64 < %s \
2+
; RUN: | FileCheck %s
3+
4+
;; Check debug locations are propagated onto new PHIs.
5+
6+
; CHECK: .split:
7+
; CHECK-NEXT: %merge = phi i32 [ poison, %while.body ], [ %dest.sroa.clone, %while.body.clone ], !dbg [[G1R1:!.*]]
8+
9+
; CHECK: while.body.clone:
10+
; CHECK-NEXT: %dest.sroa.clone = phi i32 [ %1, %.split ], [ poison, %if.else ], !dbg [[G2R1:!.*]]
11+
12+
; CHECK: [[G1R1]] = !DILocation(line: 1, column: 1, scope: !5, atomGroup: 1, atomRank: 1)
13+
; CHECK: [[G2R1]] = !DILocation(line: 1, column: 1, scope: !5, atomGroup: 2, atomRank: 1)
14+
15+
define void @test(i1 %c) !dbg !5 {
16+
entry:
17+
br label %if.else
18+
19+
if.else: ; preds = %if.else1, %entry
20+
br i1 %c, label %while.body, label %preheader
21+
22+
preheader: ; preds = %if.else
23+
br label %if.else1
24+
25+
if.then: ; preds = %if.else1
26+
unreachable
27+
28+
while.body: ; preds = %if.else1, %while.body, %if.else
29+
%dest.sroa = phi i32 [ %1, %while.body ], [ poison, %if.else1 ], [ poison, %if.else ], !dbg !12
30+
%0 = inttoptr i32 %dest.sroa to ptr
31+
%incdec.ptr = getelementptr inbounds i8, ptr %0, i32 -1
32+
%1 = ptrtoint ptr %incdec.ptr to i32
33+
store i8 0, ptr %incdec.ptr, align 1
34+
br label %while.body
35+
36+
if.else1: ; preds = %if.else1, %preheader
37+
indirectbr ptr poison, [label %if.then, label %while.body, label %if.else, label %if.else1]
38+
}
39+
40+
!llvm.dbg.cu = !{!0}
41+
!llvm.debugify = !{!2, !3}
42+
!llvm.module.flags = !{!4}
43+
44+
!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)
45+
!1 = !DIFile(filename: "test.ll", directory: "/")
46+
!2 = !{i32 11}
47+
!3 = !{i32 0}
48+
!4 = !{i32 2, !"Debug Info Version", i32 3}
49+
!5 = distinct !DISubprogram(name: "test", linkageName: "test", scope: null, file: !1, line: 1, type: !6, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0)
50+
!6 = !DISubroutineType(types: !7)
51+
!7 = !{}
52+
!12 = !DILocation(line: 1, column: 1, scope: !5, atomGroup: 1, atomRank: 1)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
if not "X86" in config.root.targets:
2+
config.unsupported = True

0 commit comments

Comments
 (0)