diff options
author | Dale Johannesen <dalej@apple.com> | 2009-07-14 00:45:38 +0000 |
---|---|---|
committer | Dale Johannesen <dalej@apple.com> | 2009-07-14 00:45:38 +0000 |
commit | 4458ab0d83c33a649c61355a4d80e94014193856 (patch) | |
tree | e0a43bf94fd3e8633ca24eb61cc7e77289180c5d /lib/Transforms/Scalar/SimplifyCFGPass.cpp | |
parent | d9ef1a860e01321cacbd57b6f7c154f399c813d4 (diff) | |
download | external_llvm-4458ab0d83c33a649c61355a4d80e94014193856.zip external_llvm-4458ab0d83c33a649c61355a4d80e94014193856.tar.gz external_llvm-4458ab0d83c33a649c61355a4d80e94014193856.tar.bz2 |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75571 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/SimplifyCFGPass.cpp')
-rw-r--r-- | lib/Transforms/Scalar/SimplifyCFGPass.cpp | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/lib/Transforms/Scalar/SimplifyCFGPass.cpp b/lib/Transforms/Scalar/SimplifyCFGPass.cpp index f6cffdd..155d5d8 100644 --- a/lib/Transforms/Scalar/SimplifyCFGPass.cpp +++ b/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())) |