summaryrefslogtreecommitdiffstats
path: root/llvm/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
commit0bf46b536397f4e4b50ba928f5120d27dc0f1ea5 (patch)
treeb08cc1a0f28a4fa4d9936be9117f0b24c922cbf7 /llvm/lib/VMCore
parent9bc48e521518407efb7910ac81be022cf66c91f6 (diff)
downloadbcm5719-llvm-0bf46b536397f4e4b50ba928f5120d27dc0f1ea5.tar.gz
bcm5719-llvm-0bf46b536397f4e4b50ba928f5120d27dc0f1ea5.zip
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. llvm-svn: 147946
Diffstat (limited to 'llvm/lib/VMCore')
-rw-r--r--llvm/lib/VMCore/ConstantFold.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/VMCore/ConstantFold.cpp b/llvm/lib/VMCore/ConstantFold.cpp
index 4d7a857de5c..62ef25b6430 100644
--- a/llvm/lib/VMCore/ConstantFold.cpp
+++ b/llvm/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()));
OpenPOWER on IntegriCloud