[llvm-commits] [llvm] r111122 - in /llvm/trunk: lib/Transforms/Utils/SimplifyCFG.cpp test/Transforms/SimplifyCFG/indirectbr.ll
Dan Gohman
gohman at apple.com
Mon Aug 16 07:41:14 PDT 2010
Author: djg
Date: Mon Aug 16 09:41:14 2010
New Revision: 111122
URL: http://llvm.org/viewvc/llvm-project?rev=111122&view=rev
Log:
Instead, teach SimplifyCFG to trim non-address-taken blocks from
indirectbr destination lists.
Modified:
llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
llvm/trunk/test/Transforms/SimplifyCFG/indirectbr.ll
Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=111122&r1=111121&r2=111122&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Mon Aug 16 09:41:14 2010
@@ -2057,12 +2057,13 @@
return true;
}
}
- } else if (IndirectBrInst *IBI = dyn_cast<IndirectBrInst>(BB->getTerminator())) {
+ } else if (IndirectBrInst *IBI =
+ dyn_cast<IndirectBrInst>(BB->getTerminator())) {
// Eliminate redundant destinations.
SmallPtrSet<Value *, 8> Succs;
for (unsigned i = 0, e = IBI->getNumDestinations(); i != e; ++i) {
BasicBlock *Dest = IBI->getDestination(i);
- if (!Succs.insert(Dest)) {
+ if (!Dest->hasAddressTaken() || !Succs.insert(Dest)) {
Dest->removePredecessor(BB);
IBI->removeDestination(i);
--i; --e;
Modified: llvm/trunk/test/Transforms/SimplifyCFG/indirectbr.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyCFG/indirectbr.ll?rev=111122&r1=111121&r2=111122&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/SimplifyCFG/indirectbr.ll (original)
+++ llvm/trunk/test/Transforms/SimplifyCFG/indirectbr.ll Mon Aug 16 09:41:14 2010
@@ -49,3 +49,16 @@
ret void
}
+; SimplifyCFG should notice that BB0 does not have its address taken and
+; remove it from entry's successor list.
+
+; CHECK: indbrtest2
+; CHECK: entry:
+; CHECK-NEXT: unreachable
+
+define void @indbrtest2(i8* %t) {
+entry:
+ indirectbr i8* %t, [label %BB0, label %BB0]
+BB0:
+ ret void
+}
More information about the llvm-commits
mailing list