diff options
author | Torok Edwin <edwintorok@gmail.com> | 2009-01-24 11:30:49 +0000 |
---|---|---|
committer | Torok Edwin <edwintorok@gmail.com> | 2009-01-24 11:30:49 +0000 |
commit | 629e92b63b91aedfc8fc961b01ae53a1e6c1739f (patch) | |
tree | 85cae880ebf7c8b49d65c5474abac57ebd406572 | |
parent | 32ca8657b8c1ef21225370b7b7e159a92413bc6e (diff) |
void* is represented as pointer to empty struct {}.
Thus we need to check whether the struct is empty before trying to index into
it. This fixes PR3381.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62918 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index dd55d65e16..aed0867093 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -11170,6 +11170,8 @@ static Instruction *InstCombineStoreToCast(InstCombiner &IC, StoreInst &SI) { while (1) { if (const StructType *STy = dyn_cast<StructType>(SrcPTy)) { + if (!STy->getNumElements()) /* Void is represented as {} */ + break; NewGEPIndices.push_back(Zero); SrcPTy = STy->getElementType(0); } else if (const ArrayType *ATy = dyn_cast<ArrayType>(SrcPTy)) { |