OSDN Git Service

[CGP] r205941 changed the logic, so that a cast happens *before* 'Result' is
authorJoey Gouly <joey.gouly@gmail.com>
Tue, 13 May 2014 15:42:45 +0000 (15:42 +0000)
committerJoey Gouly <joey.gouly@gmail.com>
Tue, 13 May 2014 15:42:45 +0000 (15:42 +0000)
commitfdae312e65f6bf6a419c03878e2780826c4e91a5
tree3637b461b8f87d477b49a77202af4c4ffeb8365c
parent73306ce39f2fe827894c140bcfce5f4b2fd3b0ec
[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
lib/CodeGen/CodeGenPrepare.cpp
test/CodeGen/X86/codegen-prepare-crash.ll [new file with mode: 0644]