[llvm] r205941 - Fix to support properly cleaning up failed address sinking against constants
Jim Grosbach
grosbach at apple.com
Wed Apr 9 17:27:46 PDT 2014
Author: grosbach
Date: Wed Apr 9 19:27:45 2014
New Revision: 205941
URL: http://llvm.org/viewvc/llvm-project?rev=205941&view=rev
Log:
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 at apple.com>
Modified:
llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp
Modified: llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp?rev=205941&r1=205940&r2=205941&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp (original)
+++ llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp Wed Apr 9 19:27:45 2014
@@ -2459,8 +2459,9 @@ bool CodeGenPrepare::OptimizeMemoryInst(
// 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)
More information about the llvm-commits
mailing list