mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-12 03:32:10 +00:00
Short term fix for pr12270 before we change dominates to handle unreachable
code. While here, reduce indentation. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152803 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
847d3812ad
commit
2453dff96a
@ -4024,36 +4024,40 @@ bool ObjCARCContract::runOnFunction(Function &F) {
|
|||||||
Use &U = UI.getUse();
|
Use &U = UI.getUse();
|
||||||
unsigned OperandNo = UI.getOperandNo();
|
unsigned OperandNo = UI.getOperandNo();
|
||||||
++UI; // Increment UI now, because we may unlink its element.
|
++UI; // Increment UI now, because we may unlink its element.
|
||||||
if (Instruction *UserInst = dyn_cast<Instruction>(U.getUser()))
|
Instruction *UserInst = dyn_cast<Instruction>(U.getUser());
|
||||||
if (Inst != UserInst && DT->dominates(Inst, UserInst)) {
|
if (!UserInst)
|
||||||
Changed = true;
|
continue;
|
||||||
Instruction *Replacement = Inst;
|
// FIXME: dominates should return true for unreachable UserInst.
|
||||||
Type *UseTy = U.get()->getType();
|
if (!DT->isReachableFromEntry(UserInst->getParent()) ||
|
||||||
if (PHINode *PHI = dyn_cast<PHINode>(UserInst)) {
|
DT->dominates(Inst, UserInst)) {
|
||||||
// For PHI nodes, insert the bitcast in the predecessor block.
|
Changed = true;
|
||||||
unsigned ValNo =
|
Instruction *Replacement = Inst;
|
||||||
PHINode::getIncomingValueNumForOperand(OperandNo);
|
Type *UseTy = U.get()->getType();
|
||||||
BasicBlock *BB =
|
if (PHINode *PHI = dyn_cast<PHINode>(UserInst)) {
|
||||||
PHI->getIncomingBlock(ValNo);
|
// For PHI nodes, insert the bitcast in the predecessor block.
|
||||||
if (Replacement->getType() != UseTy)
|
unsigned ValNo =
|
||||||
Replacement = new BitCastInst(Replacement, UseTy, "",
|
PHINode::getIncomingValueNumForOperand(OperandNo);
|
||||||
&BB->back());
|
BasicBlock *BB =
|
||||||
for (unsigned i = 0, e = PHI->getNumIncomingValues();
|
PHI->getIncomingBlock(ValNo);
|
||||||
i != e; ++i)
|
if (Replacement->getType() != UseTy)
|
||||||
if (PHI->getIncomingBlock(i) == BB) {
|
Replacement = new BitCastInst(Replacement, UseTy, "",
|
||||||
// Keep the UI iterator valid.
|
&BB->back());
|
||||||
if (&PHI->getOperandUse(
|
for (unsigned i = 0, e = PHI->getNumIncomingValues();
|
||||||
PHINode::getOperandNumForIncomingValue(i)) ==
|
i != e; ++i)
|
||||||
&UI.getUse())
|
if (PHI->getIncomingBlock(i) == BB) {
|
||||||
++UI;
|
// Keep the UI iterator valid.
|
||||||
PHI->setIncomingValue(i, Replacement);
|
if (&PHI->getOperandUse(
|
||||||
}
|
PHINode::getOperandNumForIncomingValue(i)) ==
|
||||||
} else {
|
&UI.getUse())
|
||||||
if (Replacement->getType() != UseTy)
|
++UI;
|
||||||
Replacement = new BitCastInst(Replacement, UseTy, "", UserInst);
|
PHI->setIncomingValue(i, Replacement);
|
||||||
U.set(Replacement);
|
}
|
||||||
}
|
} else {
|
||||||
|
if (Replacement->getType() != UseTy)
|
||||||
|
Replacement = new BitCastInst(Replacement, UseTy, "", UserInst);
|
||||||
|
U.set(Replacement);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If Arg is a no-op casted pointer, strip one level of casts and
|
// If Arg is a no-op casted pointer, strip one level of casts and
|
||||||
|
15
test/Transforms/ObjCARC/pr12270.ll
Normal file
15
test/Transforms/ObjCARC/pr12270.ll
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
; RUN: opt -disable-output -objc-arc-contract %s
|
||||||
|
; test that we don't crash on unreachable code
|
||||||
|
%2 = type opaque
|
||||||
|
|
||||||
|
define void @_i_Test__foo(%2 *%x) {
|
||||||
|
entry:
|
||||||
|
unreachable
|
||||||
|
|
||||||
|
return: ; No predecessors!
|
||||||
|
%bar = bitcast %2* %x to i8*
|
||||||
|
%foo = call i8* @objc_autoreleaseReturnValue(i8* %bar) nounwind
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
declare i8* @objc_autoreleaseReturnValue(i8*)
|
Loading…
x
Reference in New Issue
Block a user