mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-26 12:20:42 +00:00
Allow readonly functions to unwind exceptions. Teach
the optimizers about this. For example, a readonly function with no uses cannot be removed unless it is also marked nounwind. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71071 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -164,17 +164,15 @@ bool llvm::isInstructionTriviallyDead(Instruction *I) {
|
||||
|
||||
// We don't want debug info removed by anything this general.
|
||||
if (isa<DbgInfoIntrinsic>(I)) return false;
|
||||
|
||||
if (!I->mayWriteToMemory())
|
||||
return true;
|
||||
|
||||
// Special case intrinsics that "may write to memory" but can be deleted when
|
||||
// dead.
|
||||
if (!I->mayHaveSideEffects()) return true;
|
||||
|
||||
// Special case intrinsics that "may have side effects" but can be deleted
|
||||
// when dead.
|
||||
if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(I))
|
||||
// Safe to delete llvm.stacksave if dead.
|
||||
if (II->getIntrinsicID() == Intrinsic::stacksave)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -230,7 +228,7 @@ llvm::RecursivelyDeleteDeadPHINode(PHINode *PN) {
|
||||
SmallPtrSet<PHINode *, 4> PHIs;
|
||||
PHIs.insert(PN);
|
||||
for (Instruction *J = cast<Instruction>(*PN->use_begin());
|
||||
J->hasOneUse() && !J->mayWriteToMemory();
|
||||
J->hasOneUse() && !J->mayHaveSideEffects();
|
||||
J = cast<Instruction>(*J->use_begin()))
|
||||
// If we find a PHI more than once, we're on a cycle that
|
||||
// won't prove fruitful.
|
||||
|
||||
Reference in New Issue
Block a user