mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-10-04 04:19:25 +00:00
Fix assert with GEP ptr vector indexing structs
Also fix it calculating the wrong value. The struct index is not a ConstantInt, so it was being interpreted as an array index. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188713 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -629,9 +629,19 @@ void llvm::ComputeMaskedBits(Value *V, APInt &KnownZero, APInt &KnownOne,
|
||||
Value *Index = I->getOperand(i);
|
||||
if (StructType *STy = dyn_cast<StructType>(*GTI)) {
|
||||
// Handle struct member offset arithmetic.
|
||||
if (!TD) return;
|
||||
const StructLayout *SL = TD->getStructLayout(STy);
|
||||
if (!TD)
|
||||
return;
|
||||
|
||||
// Handle case when index is vector zeroinitializer
|
||||
Constant *CIndex = cast<Constant>(Index);
|
||||
if (CIndex->isZeroValue())
|
||||
continue;
|
||||
|
||||
if (CIndex->getType()->isVectorTy())
|
||||
Index = CIndex->getSplatValue();
|
||||
|
||||
unsigned Idx = cast<ConstantInt>(Index)->getZExtValue();
|
||||
const StructLayout *SL = TD->getStructLayout(STy);
|
||||
uint64_t Offset = SL->getElementOffset(Idx);
|
||||
TrailZ = std::min<unsigned>(TrailZ,
|
||||
countTrailingZeros(Offset));
|
||||
|
Reference in New Issue
Block a user