diff options
Diffstat (limited to 'llvm/lib/Analysis/ConstantFolding.cpp')
-rw-r--r-- | llvm/lib/Analysis/ConstantFolding.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp index 2b7a438..b58f9b2 100644 --- a/llvm/lib/Analysis/ConstantFolding.cpp +++ b/llvm/lib/Analysis/ConstantFolding.cpp @@ -432,6 +432,10 @@ bool ReadDataFromGlobal(Constant *C, uint64_t ByteOffset, unsigned char *CurPtr, assert(ByteOffset <= DL.getTypeAllocSize(C->getType()) && "Out of range access"); + // Reading type padding, return zero. + if (ByteOffset >= DL.getTypeStoreSize(C->getType())) + return true; + // If this element is zero or undefined, we can just return since *CurPtr is // zero initialized. if (isa<ConstantAggregateZero>(C) || isa<UndefValue>(C)) |