mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-28 23:17:10 +00:00
Bitcode support for allocas with arbitrary array size types.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104915 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -2178,13 +2178,18 @@ bool BitcodeReader::ParseFunctionBody(Function *F) {
|
|||||||
InstructionList.push_back(I);
|
InstructionList.push_back(I);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case bitc::FUNC_CODE_INST_ALLOCA: { // ALLOCA: [instty, op, align]
|
case bitc::FUNC_CODE_INST_ALLOCA: { // ALLOCA: [instty, opty, op, align]
|
||||||
if (Record.size() < 3)
|
// For backward compatibility, tolerate a lack of an opty, and use i32.
|
||||||
|
// LLVM 3.0: Remove this.
|
||||||
|
if (Record.size() < 3 || Record.size() > 4)
|
||||||
return Error("Invalid ALLOCA record");
|
return Error("Invalid ALLOCA record");
|
||||||
|
unsigned OpNum = 0;
|
||||||
const PointerType *Ty =
|
const PointerType *Ty =
|
||||||
dyn_cast_or_null<PointerType>(getTypeByID(Record[0]));
|
dyn_cast_or_null<PointerType>(getTypeByID(Record[OpNum++]));
|
||||||
Value *Size = getFnValueByID(Record[1], Type::getInt32Ty(Context));
|
const Type *OpTy = Record.size() == 4 ? getTypeByID(Record[OpNum++]) :
|
||||||
unsigned Align = Record[2];
|
Type::getInt32Ty(Context);
|
||||||
|
Value *Size = getFnValueByID(Record[OpNum++], OpTy);
|
||||||
|
unsigned Align = Record[OpNum++];
|
||||||
if (!Ty || !Size) return Error("Invalid ALLOCA record");
|
if (!Ty || !Size) return Error("Invalid ALLOCA record");
|
||||||
I = new AllocaInst(Ty->getElementType(), Size, (1 << Align) >> 1);
|
I = new AllocaInst(Ty->getElementType(), Size, (1 << Align) >> 1);
|
||||||
InstructionList.push_back(I);
|
InstructionList.push_back(I);
|
||||||
|
@@ -1114,6 +1114,7 @@ static void WriteInstruction(const Instruction &I, unsigned InstID,
|
|||||||
case Instruction::Alloca:
|
case Instruction::Alloca:
|
||||||
Code = bitc::FUNC_CODE_INST_ALLOCA;
|
Code = bitc::FUNC_CODE_INST_ALLOCA;
|
||||||
Vals.push_back(VE.getTypeID(I.getType()));
|
Vals.push_back(VE.getTypeID(I.getType()));
|
||||||
|
Vals.push_back(VE.getTypeID(I.getOperand(0)->getType()));
|
||||||
Vals.push_back(VE.getValueID(I.getOperand(0))); // size.
|
Vals.push_back(VE.getValueID(I.getOperand(0))); // size.
|
||||||
Vals.push_back(Log2_32(cast<AllocaInst>(I).getAlignment())+1);
|
Vals.push_back(Log2_32(cast<AllocaInst>(I).getAlignment())+1);
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user