summaryrefslogtreecommitdiff
path: root/lib/CodeGen/CodeGenPrepare.cpp
diff options
context:
space:
mode:
authorJoey Gouly <joey.gouly@gmail.com>2014-05-13 15:42:45 +0000
committerJoey Gouly <joey.gouly@gmail.com>2014-05-13 15:42:45 +0000
commitfdae312e65f6bf6a419c03878e2780826c4e91a5 (patch)
tree3637b461b8f87d477b49a77202af4c4ffeb8365c /lib/CodeGen/CodeGenPrepare.cpp
parent73306ce39f2fe827894c140bcfce5f4b2fd3b0ec (diff)
downloadllvm-fdae312e65f6bf6a419c03878e2780826c4e91a5.tar.gz
llvm-fdae312e65f6bf6a419c03878e2780826c4e91a5.tar.bz2
llvm-fdae312e65f6bf6a419c03878e2780826c4e91a5.tar.xz
[CGP] r205941 changed the logic, so that a cast happens *before* 'Result' is
compared to 'AddrMode.BaseReg'. In the case that 'AddrMode.BaseReg' is nullptr, 'Result' will also be nullptr, so the cast causes an assertion. We should use dyn_cast_or_null here to check 'Result' is not null and it is an instruction. Bug found by Mats Petersson, and I reduced his IR to get a test case. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208705 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenPrepare.cpp')
-rw-r--r--lib/CodeGen/CodeGenPrepare.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/CodeGen/CodeGenPrepare.cpp b/lib/CodeGen/CodeGenPrepare.cpp
index d2559cf53d..a6d8a68588 100644
--- a/lib/CodeGen/CodeGenPrepare.cpp
+++ b/lib/CodeGen/CodeGenPrepare.cpp
@@ -2759,7 +2759,7 @@ 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.
- Instruction *I = dyn_cast<Instruction>(Result);
+ Instruction *I = dyn_cast_or_null<Instruction>(Result);
if (I && (Result != AddrMode.BaseReg))
I->eraseFromParent();
return false;