From 1c0cea6c1fc807794f0d785392e05b19d0c70210 Mon Sep 17 00:00:00 2001 From: Mark Seaborn Date: Mon, 9 Sep 2013 10:06:19 -0700 Subject: PNaCl bitcode: Change FORWARDTYPEREF to never use pointer types Before, FORWARDTYPEREFs used i8* type rather than i32 if they referenced an "alloca" instruction. Clean this up so that FORWARDTYPEREFs use i32 instead in this case. Note that this means that a forward-referenced "alloca" can be used via an ptrtoint+inttoptr, rather than a bitcast, but that's no problem. This is a step towards removing TYPE_CODE_POINTER from the types table, to simplify the PNaCl bitcode format. Rename NormalizeParamType() to NormalizeScalarType() to reflect that it's used in more cases; make it public. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3671 TEST=test/NaCl/Bitcode/*.ll Review URL: https://codereview.chromium.org/23719016 --- lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp') diff --git a/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp b/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp index 276d1d59b3..f5fd1ba0e7 100644 --- a/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp +++ b/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp @@ -1579,8 +1579,16 @@ bool NaClBitcodeReader::ParseFunctionBody(Function *F) { } // Non-void values get registered in the value table for future use. - if (I && !I->getType()->isVoidTy()) - ValueList.AssignValue(I, NextValueNo++); + if (I && !I->getType()->isVoidTy()) { + Value *NewVal = I; + if (GetPNaClVersion() >= 2 && + NewVal->getType()->isPointerTy() && + ValueList.getValueFwdRef(NextValueNo)) { + // Forward-referenced values cannot have pointer type. + NewVal = ConvertOpToScalar(NewVal, CurBBNo); + } + ValueList.AssignValue(NewVal, NextValueNo++); + } } OutOfRecordLoop: -- cgit v1.2.3-18-g5258