[llvm-commits] [llvm] r123477 - /llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
Owen Anderson
resistor at mac.com
Sat Jan 15 20:36:59 PST 2011
On Jan 15, 2011, at 6:09 PM, Chris Lattner wrote:
>> + // A bitcast'd pointer implicitly points to the first field of a
>> + // struct. Insert implicity "gep @x, 0, 0, ..." until we get down
>> + // to the first concrete member.
>> + // FIXME: This could be extended to work for arrays as well.
>> + while (const StructType *STy = dyn_cast<StructType>(NewTy)) {
>> + NewTy = STy->getTypeAtIndex(0U);
>> +
>> + const IntegerType *IdxTy =
>> + IntegerType::get(NewTy->getContext(), 32);
>> + Constant *IdxZero = ConstantInt::get(IdxTy, 0, false);
>> + Constant * const IdxList[] = {IdxZero, IdxZero};
>> +
>> + Ptr = ConstantExpr::getGetElementPtr(Ptr, IdxList, 2);
>> + }
>> +
>> + if (!isa<PointerType>(NewTy)) return false;
>> + Val = ConstantExpr::getBitCast(Val, NewTy);
>> + }
>> +
>
> This code seems highly confused. If the thing being stored isn't a pointer, the final getBitCast call will abort.
Fixed in r123563.
--Owen
More information about the llvm-commits
mailing list