mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-21 03:32:21 +00:00
[opaque pointer type] Encode the allocated type of an alloca rather than its pointer result type.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235998 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
2a7841dd4d
commit
e48ac32ea2
@ -4022,21 +4022,28 @@ std::error_code BitcodeReader::ParseFunctionBody(Function *F) {
|
|||||||
case bitc::FUNC_CODE_INST_ALLOCA: { // ALLOCA: [instty, opty, op, align]
|
case bitc::FUNC_CODE_INST_ALLOCA: { // ALLOCA: [instty, opty, op, align]
|
||||||
if (Record.size() != 4)
|
if (Record.size() != 4)
|
||||||
return Error("Invalid record");
|
return Error("Invalid record");
|
||||||
PointerType *Ty =
|
|
||||||
dyn_cast_or_null<PointerType>(getTypeByID(Record[0]));
|
|
||||||
Type *OpTy = getTypeByID(Record[1]);
|
|
||||||
Value *Size = getFnValueByID(Record[2], OpTy);
|
|
||||||
uint64_t AlignRecord = Record[3];
|
uint64_t AlignRecord = Record[3];
|
||||||
const uint64_t InAllocaMask = uint64_t(1) << 5;
|
const uint64_t InAllocaMask = uint64_t(1) << 5;
|
||||||
|
const uint64_t ExplicitTypeMask = uint64_t(1) << 6;
|
||||||
|
const uint64_t FlagMask = InAllocaMask | ExplicitTypeMask;
|
||||||
bool InAlloca = AlignRecord & InAllocaMask;
|
bool InAlloca = AlignRecord & InAllocaMask;
|
||||||
|
Type *Ty = getTypeByID(Record[0]);
|
||||||
|
if ((AlignRecord & ExplicitTypeMask) == 0) {
|
||||||
|
auto *PTy = dyn_cast_or_null<PointerType>(Ty);
|
||||||
|
if (!PTy)
|
||||||
|
return Error("Old-style alloca with a non-pointer type");
|
||||||
|
Ty = PTy->getElementType();
|
||||||
|
}
|
||||||
|
Type *OpTy = getTypeByID(Record[1]);
|
||||||
|
Value *Size = getFnValueByID(Record[2], OpTy);
|
||||||
unsigned Align;
|
unsigned Align;
|
||||||
if (std::error_code EC =
|
if (std::error_code EC =
|
||||||
parseAlignmentValue(AlignRecord & ~InAllocaMask, Align)) {
|
parseAlignmentValue(AlignRecord & ~FlagMask, Align)) {
|
||||||
return EC;
|
return EC;
|
||||||
}
|
}
|
||||||
if (!Ty || !Size)
|
if (!Ty || !Size)
|
||||||
return Error("Invalid record");
|
return Error("Invalid record");
|
||||||
AllocaInst *AI = new AllocaInst(Ty->getElementType(), Size, Align);
|
AllocaInst *AI = new AllocaInst(Ty, Size, Align);
|
||||||
AI->setUsedWithInAlloca(InAlloca);
|
AI->setUsedWithInAlloca(InAlloca);
|
||||||
I = AI;
|
I = AI;
|
||||||
InstructionList.push_back(I);
|
InstructionList.push_back(I);
|
||||||
|
@ -1870,15 +1870,16 @@ 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()));
|
const AllocaInst &AI = cast<AllocaInst>(I);
|
||||||
|
Vals.push_back(VE.getTypeID(AI.getAllocatedType()));
|
||||||
Vals.push_back(VE.getTypeID(I.getOperand(0)->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.
|
||||||
const AllocaInst &AI = cast<AllocaInst>(I);
|
|
||||||
unsigned AlignRecord = Log2_32(AI.getAlignment()) + 1;
|
unsigned AlignRecord = Log2_32(AI.getAlignment()) + 1;
|
||||||
assert(Log2_32(Value::MaximumAlignment) + 1 < 1 << 5 &&
|
assert(Log2_32(Value::MaximumAlignment) + 1 < 1 << 5 &&
|
||||||
"not enough bits for maximum alignment");
|
"not enough bits for maximum alignment");
|
||||||
assert(AlignRecord < 1 << 5 && "alignment greater than 1 << 64");
|
assert(AlignRecord < 1 << 5 && "alignment greater than 1 << 64");
|
||||||
AlignRecord |= AI.isUsedWithInAlloca() << 5;
|
AlignRecord |= AI.isUsedWithInAlloca() << 5;
|
||||||
|
AlignRecord |= 1 << 6;
|
||||||
Vals.push_back(AlignRecord);
|
Vals.push_back(AlignRecord);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user