[opaque pointer type] Bitcode support for explicit type parameter on GEP.
Like r230414, add bitcode support including backwards compatibility, for an explicit type parameter to GEP. At the suggestion of Duncan I tried coalescing the two older bitcodes into a single new bitcode, though I did hit a wrinkle: I couldn't figure out how to create an explicit abbreviation for a record with a variable number of arguments (the indicies to the gep). This means the discriminator between inbounds and non-inbounds gep is a full variable-length field I believe? Is my understanding correct? Is there a way to create such an abbreviation? Should I just use two bitcodes as before? Reviewers: dexonsmith Differential Revision: http://reviews.llvm.org/D7736 llvm-svn: 230415
This commit is contained in:
@@ -3062,9 +3062,22 @@ std::error_code BitcodeReader::ParseFunctionBody(Function *F) {
|
||||
InstructionList.push_back(I);
|
||||
break;
|
||||
}
|
||||
case bitc::FUNC_CODE_INST_INBOUNDS_GEP:
|
||||
case bitc::FUNC_CODE_INST_GEP: { // GEP: [n x operands]
|
||||
case bitc::FUNC_CODE_INST_INBOUNDS_GEP_OLD:
|
||||
case bitc::FUNC_CODE_INST_GEP_OLD:
|
||||
case bitc::FUNC_CODE_INST_GEP: { // GEP: type, [n x operands]
|
||||
unsigned OpNum = 0;
|
||||
|
||||
Type *Ty;
|
||||
bool InBounds;
|
||||
|
||||
if (BitCode == bitc::FUNC_CODE_INST_GEP) {
|
||||
InBounds = Record[OpNum++];
|
||||
Ty = getTypeByID(Record[OpNum++]);
|
||||
} else {
|
||||
InBounds = BitCode == bitc::FUNC_CODE_INST_INBOUNDS_GEP_OLD;
|
||||
Ty = nullptr;
|
||||
}
|
||||
|
||||
Value *BasePtr;
|
||||
if (getValueTypePair(Record, OpNum, NextValueNo, BasePtr))
|
||||
return Error("Invalid record");
|
||||
@@ -3078,8 +3091,9 @@ std::error_code BitcodeReader::ParseFunctionBody(Function *F) {
|
||||
}
|
||||
|
||||
I = GetElementPtrInst::Create(BasePtr, GEPIdx);
|
||||
assert(!Ty || Ty == cast<GetElementPtrInst>(I)->getSourceElementType());
|
||||
InstructionList.push_back(I);
|
||||
if (BitCode == bitc::FUNC_CODE_INST_INBOUNDS_GEP)
|
||||
if (InBounds)
|
||||
cast<GetElementPtrInst>(I)->setIsInBounds(true);
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user