summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp
diff options
context:
space:
mode:
authorDale Johannesen <dalej@apple.com>2009-07-14 00:45:38 +0000
committerDale Johannesen <dalej@apple.com>2009-07-14 00:45:38 +0000
commit85ae7480d91f082f8a5e5e33f98d3f1aa33dd1f8 (patch)
treee852c75af1a7bd3845a6f6529d9d3c1d648828e0 /llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp
parentc057f417d8d852303d9744d9558b792c1c014818 (diff)
downloadbcm5719-llvm-85ae7480d91f082f8a5e5e33f98d3f1aa33dd1f8.tar.gz
bcm5719-llvm-85ae7480d91f082f8a5e5e33f98d3f1aa33dd1f8.zip
Don't delete asm's just because their inputs are undefined;
xor R, R is a common and valid idiom for zeroing a register, for example. llvm-svn: 75571
Diffstat (limited to 'llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp25
1 files changed, 17 insertions, 8 deletions
diff --git a/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp b/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp
index f6cffdd0ef4..155d5d81e30 100644
--- a/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp
+++ b/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp
@@ -109,6 +109,8 @@ static bool MarkAliveBlocks(BasicBlock *BB,
if (!Reachable.insert(BB))
continue;
+ bool AsmFound = false;
+ StoreInst *UndefStore = 0;
// Do a quick scan of the basic block, turning any obviously unreachable
// instructions into LLVM unreachable insts. The instruction combining pass
// canonicalizes unreachable insts into stores to null or undef.
@@ -125,20 +127,27 @@ static bool MarkAliveBlocks(BasicBlock *BB,
}
break;
}
+ if (isa<InlineAsm>(CI->getOperand(0)))
+ AsmFound = true;
}
if (StoreInst *SI = dyn_cast<StoreInst>(BBI)) {
Value *Ptr = SI->getOperand(1);
-
- if (isa<UndefValue>(Ptr) ||
- (isa<ConstantPointerNull>(Ptr) &&
- cast<PointerType>(Ptr->getType())->getAddressSpace() == 0)) {
- ChangeToUnreachable(SI, Context);
- Changed = true;
- break;
- }
+
+ if ((isa<UndefValue>(Ptr) ||
+ (isa<ConstantPointerNull>(Ptr) &&
+ cast<PointerType>(Ptr->getType())->getAddressSpace() == 0)) &&
+ !UndefStore)
+ UndefStore = SI;
}
}
+ // We can't delete asm's just because their inputs are undefined;
+ // xor R, R is a common idiom for zeroing a register, for example.
+ // Assume user knows what he is doing.
+ if (UndefStore && !AsmFound) {
+ ChangeToUnreachable(UndefStore, Context);
+ Changed = true;
+ }
// Turn invokes that call 'nounwind' functions into ordinary calls.
if (InvokeInst *II = dyn_cast<InvokeInst>(BB->getTerminator()))
OpenPOWER on IntegriCloud