llvm.org GIT mirror llvm / 55a421f
Roundtrip the inalloca bit on allocas through bitcode This was an oversight in the original support. As it is, I stuffed this bit into the alignment. The alignment is stored in log2 form, so it doesn't need more than 5 bits, given that Value::MaximumAlignment is 1 << 29. Reviewers: nicholas Differential Revision: http://reviews.llvm.org/D3943 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213118 91177308-0d34-0410-b5e6-96231b3b80d8 Reid Kleckner 6 years ago
4 changed file(s) with 35 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
289289 FUNC_CODE_INST_PHI = 16, // PHI: [ty, val0,bb0, ...]
290290 // 17 is unused.
291291 // 18 is unused.
292 FUNC_CODE_INST_ALLOCA = 19, // ALLOCA: [instty, op, align]
292 FUNC_CODE_INST_ALLOCA = 19, // ALLOCA: [instty, opty, op, align]
293293 FUNC_CODE_INST_LOAD = 20, // LOAD: [opty, op, align, vol]
294294 // 21 is unused.
295295 // 22 is unused.
28882888 dyn_cast_or_null(getTypeByID(Record[0]));
28892889 Type *OpTy = getTypeByID(Record[1]);
28902890 Value *Size = getFnValueByID(Record[2], OpTy);
2891 unsigned Align = Record[3];
2891 unsigned AlignRecord = Record[3];
2892 bool InAlloca = AlignRecord & (1 << 5);
2893 unsigned Align = AlignRecord & ((1 << 5) - 1);
28922894 if (!Ty || !Size)
28932895 return Error(InvalidRecord);
2894 I = new AllocaInst(Ty->getElementType(), Size, (1 << Align) >> 1);
2896 AllocaInst *AI = new AllocaInst(Ty->getElementType(), Size, (1 << Align) >> 1);
2897 AI->setUsedWithInAlloca(InAlloca);
2898 I = AI;
28952899 InstructionList.push_back(I);
28962900 break;
28972901 }
14301430 break;
14311431 }
14321432
1433 case Instruction::Alloca:
1433 case Instruction::Alloca: {
14341434 Code = bitc::FUNC_CODE_INST_ALLOCA;
14351435 Vals.push_back(VE.getTypeID(I.getType()));
14361436 Vals.push_back(VE.getTypeID(I.getOperand(0)->getType()));
14371437 Vals.push_back(VE.getValueID(I.getOperand(0))); // size.
1438 Vals.push_back(Log2_32(cast(I).getAlignment())+1);
1439 break;
1438 const AllocaInst &AI = cast(I);
1439 unsigned AlignRecord = Log2_32(AI.getAlignment()) + 1;
1440 assert(Log2_32(Value::MaximumAlignment) + 1 < 1 << 5 &&
1441 "not enough bits for maximum alignment");
1442 assert(AlignRecord < 1 << 5 && "alignment greater than 1 << 64");
1443 AlignRecord |= AI.isUsedWithInAlloca() << 5;
1444 Vals.push_back(AlignRecord);
1445 break;
1446 }
14401447
14411448 case Instruction::Load:
14421449 if (cast(I).isAtomic()) {
0 ; RUN: llvm-as < %s | llvm-dis | FileCheck %s
1
2 ; inalloca should roundtrip.
3
4 define void @foo(i32* inalloca %args) {
5 ret void
6 }
7 ; CHECK-LABEL: define void @foo(i32* inalloca %args)
8
9 define void @bar() {
10 ; Use the maximum alignment, since we stuff our bit with alignment.
11 %args = alloca inalloca i32, align 536870912
12 call void @foo(i32* inalloca %args)
13 ret void
14 }
15 ; CHECK-LABEL: define void @bar() {
16 ; CHECK: %args = alloca inalloca i32, align 536870912
17 ; CHECK: call void @foo(i32* inalloca %args)