Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit eee68ea

Browse files
majnemereddyb
authored andcommitted
[SimplifyCFG] Hoisting invalidates metadata
We forgot to remove optimization metadata when performing hosting during FoldTwoEntryPHINode. This fixes PR29163. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279980 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent c3eb3c7 commit eee68ea

File tree

2 files changed

+39
-2
lines changed

2 files changed

+39
-2
lines changed

lib/Transforms/Utils/SimplifyCFG.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2024,14 +2024,20 @@ static bool FoldTwoEntryPHINode(PHINode *PN, const TargetTransformInfo &TTI,
20242024

20252025
// Move all 'aggressive' instructions, which are defined in the
20262026
// conditional parts of the if's up to the dominating block.
2027-
if (IfBlock1)
2027+
if (IfBlock1) {
2028+
for (auto &I : *IfBlock1)
2029+
I.dropUnknownNonDebugMetadata();
20282030
DomBlock->getInstList().splice(InsertPt->getIterator(),
20292031
IfBlock1->getInstList(), IfBlock1->begin(),
20302032
IfBlock1->getTerminator()->getIterator());
2031-
if (IfBlock2)
2033+
}
2034+
if (IfBlock2) {
2035+
for (auto &I : *IfBlock2)
2036+
I.dropUnknownNonDebugMetadata();
20322037
DomBlock->getInstList().splice(InsertPt->getIterator(),
20332038
IfBlock2->getInstList(), IfBlock2->begin(),
20342039
IfBlock2->getTerminator()->getIterator());
2040+
}
20352041

20362042
while (PHINode *PN = dyn_cast<PHINode>(BB->begin())) {
20372043
// Change the PHI node into a select instruction.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
; RUN: opt -S -simplifycfg < %s | FileCheck %s
2+
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
3+
target triple = "x86_64-unknown-linux-gnu"
4+
5+
@GV = external constant i64*
6+
7+
define i64* @test1(i1 %cond, i8* %P) {
8+
entry:
9+
br i1 %cond, label %if, label %then
10+
11+
then:
12+
%bc = bitcast i8* %P to i64*
13+
br label %join
14+
15+
if:
16+
%load = load i64*, i64** @GV, align 8, !dereferenceable !0
17+
br label %join
18+
19+
join:
20+
%phi = phi i64* [ %bc, %then ], [ %load, %if ]
21+
ret i64* %phi
22+
}
23+
24+
; CHECK-LABEL: define i64* @test1(
25+
; CHECK: %[[bc:.*]] = bitcast i8* %P to i64*
26+
; CHECK: %[[load:.*]] = load i64*, i64** @GV, align 8{{$}}
27+
; CHECK: %[[phi:.*]] = select i1 %cond, i64* %[[load]], i64* %[[bc]]
28+
; CHECK: ret i64* %[[phi]]
29+
30+
31+
!0 = !{i64 8}

0 commit comments

Comments
 (0)