X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FAnalysis%2FConstantFolding.cpp;h=cd8d52c1c465beb5a6d5b64575631f4167a5b371;hb=4dbe200b2d3da0dfd1c788c9650b8b8075c241aa;hp=243611053c2965e4dbe9dad38329d7f13579b1cf;hpb=bd1801b5553c8be3960255a92738464e0010b6f6;p=oota-llvm.git diff --git a/lib/Analysis/ConstantFolding.cpp b/lib/Analysis/ConstantFolding.cpp index 243611053c2..cd8d52c1c46 100644 --- a/lib/Analysis/ConstantFolding.cpp +++ b/lib/Analysis/ConstantFolding.cpp @@ -54,7 +54,7 @@ static Constant *FoldBitCast(Constant *C, const Type *DestTy, // vector so the code below can handle it uniformly. if (isa(C) || isa(C)) { Constant *Ops = C; // don't take the address of C! - return FoldBitCast(ConstantVector::get(&Ops, 1), DestTy, TD); + return FoldBitCast(ConstantVector::get(Ops), DestTy, TD); } // If this is a bitcast from constant vector -> vector, fold it. @@ -167,7 +167,7 @@ static Constant *FoldBitCast(Constant *C, const Type *DestTy, } } - return ConstantVector::get(Result.data(), Result.size()); + return ConstantVector::get(Result); } @@ -340,6 +340,13 @@ static bool ReadDataFromGlobal(Constant *C, uint64_t ByteOffset, return true; } + if (ConstantExpr *CE = dyn_cast(C)) { + if (CE->getOpcode() == Instruction::IntToPtr && + CE->getOperand(0)->getType() == TD.getIntPtrType(CE->getContext())) + return ReadDataFromGlobal(CE->getOperand(0), ByteOffset, CurPtr, + BytesLeft, TD); + } + // Otherwise, unknown initializer type. return false; }