mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-28 14:36:34 +00:00
Instead, teach SimplifyCFG to trim non-address-taken blocks from
indirectbr destination lists. llvm-svn: 111122
This commit is contained in:
parent
8ed4d1646e
commit
9178d0792f
@ -2057,12 +2057,13 @@ bool SimplifyCFGOpt::run(BasicBlock *BB) {
|
||||
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;
|
||||
|
@ -49,3 +49,16 @@ BB0:
|
||||
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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user