summaryrefslogtreecommitdiffstats
path: root/llvm/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
commit12a8bf09d0751b9ed05595809879de783ceba58d (patch)
tree799ce699ac2fcca239c27cad79195aec0f1f3b76 /llvm/lib/CodeGen/CodeGenPrepare.cpp
parent2e7eceb317927ade7e14233d8356c7a011380c0a (diff)
downloadbcm5719-llvm-12a8bf09d0751b9ed05595809879de783ceba58d.tar.gz
bcm5719-llvm-12a8bf09d0751b9ed05595809879de783ceba58d.zip
[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. llvm-svn: 208705
Diffstat (limited to 'llvm/lib/CodeGen/CodeGenPrepare.cpp')
-rw-r--r--llvm/lib/CodeGen/CodeGenPrepare.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp
index d2559cf53d2..a6d8a68588d 100644
--- a/llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ b/llvm/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;
OpenPOWER on IntegriCloud