Skip to content

Commit ec1d0dd

Browse files
authored
Merge pull request rust-lang#155 from vext01/unsupported-allocas
Alloca serialisation tweaks.
2 parents 0c1f0d1 + 71604e2 commit ec1d0dd

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

llvm/lib/YkIR/YkIRWriter.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,18 @@ class YkIRWriter {
450450

451451
void serialiseAllocaInst(AllocaInst *I, FuncLowerCtxt &FLCtxt, unsigned BBIdx,
452452
unsigned &InstIdx) {
453+
// We don't yet support:
454+
// - the `inalloca` keyword.
455+
// - non-zero address spaces.
456+
// - dynamic alloca (because stackmaps can't handle them).
457+
// - allocating an array with more than SIZE_MAX elements.
458+
if ((I->isUsedWithInAlloca()) || (I->getAddressSpace() != 0) ||
459+
(!isa<Constant>(I->getArraySize())) ||
460+
cast<ConstantInt>(I->getArraySize())->getValue().ugt(SIZE_MAX)) {
461+
serialiseUnimplementedInstruction(I, FLCtxt, BBIdx, InstIdx);
462+
return;
463+
}
464+
453465
// opcode:
454466
serialiseOpcode(OpCodeAlloca);
455467

@@ -458,9 +470,12 @@ class YkIRWriter {
458470

459471
// number of objects to allocate
460472
ConstantInt *CI = cast<ConstantInt>(I->getArraySize());
461-
// XXX guard cast
473+
static_assert(sizeof(size_t) <= sizeof(uint64_t));
462474
OutStreamer.emitSizeT(CI->getZExtValue());
463475

476+
// align:
477+
OutStreamer.emitInt64(I->getAlign().value());
478+
464479
FLCtxt.updateVLMap(I, InstIdx);
465480
InstIdx++;
466481
}

0 commit comments

Comments
 (0)