diff options
author | Jim Grosbach <grosbach@apple.com> | 2014-04-10 00:27:45 +0000 |
---|---|---|
committer | Jim Grosbach <grosbach@apple.com> | 2014-04-10 00:27:45 +0000 |
commit | 83b44e1e219db7084d274fda4ce0e909bb0ddee0 (patch) | |
tree | 44e8c7be051d07a76e211f4f78d90b4d5ad35ab2 /llvm/lib/CodeGen/CodeGenPrepare.cpp | |
parent | 576f8cf19fd70aa8254cb8ff16a39c110e744ce1 (diff) | |
download | bcm5719-llvm-83b44e1e219db7084d274fda4ce0e909bb0ddee0.tar.gz bcm5719-llvm-83b44e1e219db7084d274fda4ce0e909bb0ddee0.zip |
Fix to support properly cleaning up failed address sinking against constants
As it turns out the source of the sunkaddr can be a constant, in which case
there is not an instruction to delete, causing the cleanup code introduced in
r204833 to crash. This patch adds a dynamic check to ensure the deleted value is
in fact an instruction and not a constant.
Patch by Louis Gerbarg <lgg@apple.com>
llvm-svn: 205941
Diffstat (limited to 'llvm/lib/CodeGen/CodeGenPrepare.cpp')
-rw-r--r-- | llvm/lib/CodeGen/CodeGenPrepare.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp index e82a30617d2..9765485b5d5 100644 --- a/llvm/lib/CodeGen/CodeGenPrepare.cpp +++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp @@ -2459,8 +2459,9 @@ bool CodeGenPrepare::OptimizeMemoryInst(Instruction *MemoryInst, Value *Addr, // the original IR value was tossed in favor of a constant back when // the AddrMode was created we need to bail out gracefully if widths // do not match instead of extending it. - if (Result != AddrMode.BaseReg) - cast<Instruction>(Result)->eraseFromParent(); + Instruction *I = dyn_cast<Instruction>(Result); + if (I && (Result != AddrMode.BaseReg)) + I->eraseFromParent(); return false; } if (AddrMode.Scale != 1) |