[llvm-commits] [llvm] r84936 - in /llvm/trunk: lib/Analysis/ConstantFolding.cpp test/Transforms/ConstProp/loads.ll
Chris Lattner
sabre at nondot.org
Fri Oct 23 22:27:28 PDT 2009
Fixed in r84993, thanks!
On Oct 23, 2009, at 5:06 AM, Duncan Sands wrote:
> Hi Chris,
>
>> + if (isa<ConstantAggregateZero>(C) || isa<UndefValue>(C))
>> + return true;
>
> here you use that RawBytes is zero initialized, but that requirement
> is not documented.
>
>> + CurPtr[i] = (unsigned char)(Val >> ByteOffset * 8);
>
> You should probably bracket ByteOffset * 8 for weenies like me who
> don't know C precedence rules.
>
>> + if (ConstantFP *CFP = dyn_cast<ConstantFP>(C)) {
>> + if (CFP->getType()->isDoubleTy()) {
>> + C = ConstantExpr::getBitCast(C, Type::getInt64Ty(C-
>> >getContext()));
>> + return ReadDataFromGlobal(C, ByteOffset, CurPtr, BytesLeft,
>> TD);
>> + }
>> + if (CFP->getType()->isFloatTy()){
>> + C = ConstantExpr::getBitCast(C, Type::getInt32Ty(C-
>> >getContext()));
>> + return ReadDataFromGlobal(C, ByteOffset, CurPtr, BytesLeft,
>> TD);
>> + }
>
> Probably you should return false here.
>
>> + }
>
>> + GlobalVariable *GV = dyn_cast<GlobalVariable>(GVal);
>> + if (!GV || !GV->isConstant() || !GV->hasInitializer() ||
>> + !GV->hasDefinitiveInitializer() ||
>> + !GV->getInitializer()->getType()->isSized())
>> + return 0;
>
> Testing hasDefinitiveInitializer also tests hasInitializer.
>
> Ciao,
>
> Duncan.
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list