[llvm] r309621 - Update phi nodes in LowerTypeTests control flow simplification
Peter Collingbourne via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 31 13:43:07 PDT 2017
Author: pcc
Date: Mon Jul 31 13:43:07 2017
New Revision: 309621
URL: http://llvm.org/viewvc/llvm-project?rev=309621&view=rev
Log:
Update phi nodes in LowerTypeTests control flow simplification
D33925 added a control flow simplification for -O2 --lto-O0 builds that
manually splits blocks and reassigns conditional branches but does not
correctly update phi nodes. If the else case being branched to had
incoming phi nodes the control-flow simplification would leave phi nodes
in that BB with an unhandled predecessor.
Patch by Vlad Tsyrklevich!
Differential Revision: https://reviews.llvm.org/D36012
Added:
llvm/trunk/test/Transforms/LowerTypeTests/simplify_phi.ll
Modified:
llvm/trunk/lib/Transforms/IPO/LowerTypeTests.cpp
Modified: llvm/trunk/lib/Transforms/IPO/LowerTypeTests.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/LowerTypeTests.cpp?rev=309621&r1=309620&r2=309621&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/LowerTypeTests.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/LowerTypeTests.cpp Mon Jul 31 13:43:07 2017
@@ -634,6 +634,10 @@ Value *LowerTypeTestsModule::lowerTypeTe
Br->getMetadata(LLVMContext::MD_prof));
ReplaceInstWithInst(InitialBB->getTerminator(), NewBr);
+ // Update phis in Else resulting from InitialBB being split
+ for (auto &Phi : Else->phis())
+ Phi.addIncoming(Phi.getIncomingValueForBlock(Then), InitialBB);
+
IRBuilder<> ThenB(CI);
return createBitSetTest(ThenB, TIL, BitOffset);
}
Added: llvm/trunk/test/Transforms/LowerTypeTests/simplify_phi.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LowerTypeTests/simplify_phi.ll?rev=309621&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/LowerTypeTests/simplify_phi.ll (added)
+++ llvm/trunk/test/Transforms/LowerTypeTests/simplify_phi.ll Mon Jul 31 13:43:07 2017
@@ -0,0 +1,20 @@
+; Ensure that LowerTypeTests control flow simplification correctly handle phi nodes.
+; RUN: opt -S -lowertypetests -lowertypetests-summary-action=import -lowertypetests-read-summary=%S/Inputs/import.yaml < %s | FileCheck %s
+
+target datalayout = "e-p:64:64"
+
+declare i1 @llvm.type.test(i8* %ptr, metadata %bitset) nounwind readnone
+
+; CHECK: define i1 @bytearray7(i8* [[p:%.*]])
+define i1 @bytearray7(i8* %p) {
+ %x = call i1 @llvm.type.test(i8* %p, metadata !"bytearray7")
+ br i1 %x, label %t, label %f
+
+t:
+ br label %f
+
+f:
+ ; CHECK: %test = phi i1 [ false, %{{[0-9]+}} ], [ true, %t ], [ false, %0 ]
+ %test = phi i1 [ false, %0 ], [ true, %t ]
+ ret i1 %test
+}
More information about the llvm-commits
mailing list