aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2012-01-11 12:20:08 +0000
committerDuncan Sands <baldrick@free.fr>2012-01-11 12:20:08 +0000
commit1876abe63edf0380aee3d0f3ad9cace3f7e6a042 (patch)
tree1403d07800bc0d0e70c5296610c2f4695f6c87ee /lib/VMCore
parente4bc80a14be77c232e1c4e1f30308a72d5cec05a (diff)
downloadexternal_llvm-1876abe63edf0380aee3d0f3ad9cace3f7e6a042.zip
external_llvm-1876abe63edf0380aee3d0f3ad9cace3f7e6a042.tar.gz
external_llvm-1876abe63edf0380aee3d0f3ad9cace3f7e6a042.tar.bz2
Don't try to create a GEP when the pointee type is unsized (such GEPs
are invalid). Fixes a crash on array1.C from the GCC testsuite when compiled with dragonegg. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147946 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r--lib/VMCore/ConstantFold.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/VMCore/ConstantFold.cpp b/lib/VMCore/ConstantFold.cpp
index 4d7a857..62ef25b 100644
--- a/lib/VMCore/ConstantFold.cpp
+++ b/lib/VMCore/ConstantFold.cpp
@@ -104,7 +104,8 @@ static Constant *FoldBitCast(Constant *V, Type *DestTy) {
// the first element. If so, return the appropriate GEP instruction.
if (PointerType *PTy = dyn_cast<PointerType>(V->getType()))
if (PointerType *DPTy = dyn_cast<PointerType>(DestTy))
- if (PTy->getAddressSpace() == DPTy->getAddressSpace()) {
+ if (PTy->getAddressSpace() == DPTy->getAddressSpace()
+ && DPTy->getElementType()->isSized()) {
SmallVector<Value*, 8> IdxList;
Value *Zero =
Constant::getNullValue(Type::getInt32Ty(DPTy->getContext()));