Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 38b230a

Browse filesBrowse files
committed
Propagate DebugLocs on phis in BreakCriticalEdges
1 parent fc2ec06 commit 38b230a
Copy full SHA for 38b230a

File tree

2 files changed

+52
-0
lines changed
Filter options

2 files changed

+52
-0
lines changed

‎llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp

Copy file name to clipboardExpand all lines: llvm/lib/Transforms/Utils/BreakCriticalEdges.cpp
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,13 +454,16 @@ bool llvm::SplitIndirectBrCriticalEdges(Function &F,
454454
PHINode *NewIndPHI = PHINode::Create(IndPHI->getType(), 1, "ind", InsertPt);
455455
NewIndPHI->addIncoming(IndPHI->getIncomingValueForBlock(IBRPred),
456456
IBRPred);
457+
NewIndPHI->setDebugLoc(IndPHI->getDebugLoc());
457458

458459
// Create a PHI in the body block, to merge the direct and indirect
459460
// predecessors.
460461
PHINode *MergePHI = PHINode::Create(IndPHI->getType(), 2, "merge");
461462
MergePHI->insertBefore(MergeInsert);
462463
MergePHI->addIncoming(NewIndPHI, Target);
463464
MergePHI->addIncoming(DirPHI, DirectSucc);
465+
MergePHI->applyMergedLocation(DirPHI->getDebugLoc(),
466+
IndPHI->getDebugLoc());
464467

465468
IndPHI->replaceAllUsesWith(MergePHI);
466469
IndPHI->eraseFromParent();
+49Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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 [[DBG:!.*]]
8+
9+
; CHECK: while.body.clone:
10+
; CHECK-NEXT: %dest.sroa.clone = phi i32 [ %1, %.split ], [ poison, %if.else ], !dbg [[DBG]]
11+
12+
define void @test(i1 %c) !dbg !5 {
13+
entry:
14+
br label %if.else
15+
16+
if.else: ; preds = %if.else1, %entry
17+
br i1 %c, label %while.body, label %preheader
18+
19+
preheader: ; preds = %if.else
20+
br label %if.else1
21+
22+
if.then: ; preds = %if.else1
23+
unreachable
24+
25+
while.body: ; preds = %if.else1, %while.body, %if.else
26+
%dest.sroa = phi i32 [ %1, %while.body ], [ poison, %if.else1 ], [ poison, %if.else ], !dbg !8
27+
%0 = inttoptr i32 %dest.sroa to ptr
28+
%incdec.ptr = getelementptr inbounds i8, ptr %0, i32 -1
29+
%1 = ptrtoint ptr %incdec.ptr to i32
30+
store i8 0, ptr %incdec.ptr, align 1
31+
br label %while.body
32+
33+
if.else1: ; preds = %if.else1, %preheader
34+
indirectbr ptr poison, [label %if.then, label %while.body, label %if.else, label %if.else1]
35+
}
36+
37+
!llvm.dbg.cu = !{!0}
38+
!llvm.debugify = !{!2, !3}
39+
!llvm.module.flags = !{!4}
40+
41+
!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)
42+
!1 = !DIFile(filename: "test.ll", directory: "/")
43+
!2 = !{i32 11}
44+
!3 = !{i32 0}
45+
!4 = !{i32 2, !"Debug Info Version", i32 3}
46+
!5 = distinct !DISubprogram(name: "test", linkageName: "test", scope: null, file: !1, line: 1, type: !6, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0)
47+
!6 = !DISubroutineType(types: !7)
48+
!7 = !{}
49+
!8 = !DILocation(line: 1, column: 1, scope: !5)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.