mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-07 12:28:24 +00:00
Fix SimplifyCFG/2006-10-19-UncondDiv.ll by disabling a bad xform.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31061 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -323,7 +323,14 @@ static Value *GetIfCondition(BasicBlock *BB,
|
||||
static bool DominatesMergePoint(Value *V, BasicBlock *BB,
|
||||
std::set<Instruction*> *AggressiveInsts) {
|
||||
Instruction *I = dyn_cast<Instruction>(V);
|
||||
if (!I) return true; // Non-instructions all dominate instructions.
|
||||
if (!I) {
|
||||
// Non-instructions all dominate instructions, but not all constantexprs
|
||||
// can be executed unconditionally.
|
||||
if (ConstantExpr *C = dyn_cast<ConstantExpr>(V))
|
||||
if (C->canTrap())
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
BasicBlock *PBB = I->getParent();
|
||||
|
||||
// We don't want to allow weird loops that might have the "if condition" in
|
||||
@@ -1297,6 +1304,15 @@ bool llvm::SimplifyCFG(BasicBlock *BB) {
|
||||
if (FVPN->getParent() == FalseSucc)
|
||||
FalseValue = FVPN->getIncomingValueForBlock(BI->getParent());
|
||||
|
||||
// In order for this transformation to be safe, we must be able to
|
||||
// unconditionally execute both operands to the return. This is
|
||||
// normally the case, but we could have a potentially-trapping
|
||||
// constant expression that prevents this transformation from being
|
||||
// safe.
|
||||
if ((!isa<ConstantExpr>(TrueValue) ||
|
||||
!cast<ConstantExpr>(TrueValue)->canTrap()) &&
|
||||
(!isa<ConstantExpr>(TrueValue) ||
|
||||
!cast<ConstantExpr>(TrueValue)->canTrap())) {
|
||||
TrueSucc->removePredecessor(BI->getParent());
|
||||
FalseSucc->removePredecessor(BI->getParent());
|
||||
|
||||
@@ -1323,6 +1339,7 @@ bool llvm::SimplifyCFG(BasicBlock *BB) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (UnwindInst *UI = dyn_cast<UnwindInst>(BB->begin())) {
|
||||
// Check to see if the first instruction in this block is just an unwind.
|
||||
// If so, replace any invoke instructions which use this as an exception
|
||||
|
Reference in New Issue
Block a user