Skip to content

Commit a7eb3cb

Browse files
committed
A few more checks for gc.statepoints in the Verifier
This is simply a grab bag of unrelated checks: - A statepoint call can't be marked readonly or readnone - We don't currently support inline asm or varadic target functions. Both could be supported, but don't currently work. - I forgot to check that the number of call arguments actually matched the wrapped callee in my previous change. Included here. llvm-svn: 223322
1 parent 12084a2 commit a7eb3cb

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

llvm/lib/IR/Verifier.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2562,12 +2562,21 @@ void Verifier::visitIntrinsicFunctionCall(Intrinsic::ID ID, CallInst &CI) {
25622562
break;
25632563

25642564
case Intrinsic::experimental_gc_statepoint: {
2565+
Assert1(!CI.doesNotAccessMemory() &&
2566+
!CI.onlyReadsMemory(),
2567+
"gc.statepoint must read and write memory to preserve "
2568+
"reordering restrictions required by safepoint semantics", &CI);
2569+
Assert1(!CI.isInlineAsm(),
2570+
"gc.statepoint support for inline assembly unimplemented", &CI);
2571+
25652572
const Value *Target = CI.getArgOperand(0);
25662573
const PointerType *PT = dyn_cast<PointerType>(Target->getType());
25672574
Assert2(PT && PT->getElementType()->isFunctionTy(),
25682575
"gc.statepoint callee must be of function pointer type",
25692576
&CI, Target);
25702577
FunctionType *TargetFuncType = cast<FunctionType>(PT->getElementType());
2578+
Assert1(!TargetFuncType->isVarArg(),
2579+
"gc.statepoint support for var arg functions not implemented", &CI);
25712580

25722581
const Value *NumCallArgsV = CI.getArgOperand(1);
25732582
Assert1(isa<ConstantInt>(NumCallArgsV),
@@ -2577,6 +2586,8 @@ void Verifier::visitIntrinsicFunctionCall(Intrinsic::ID ID, CallInst &CI) {
25772586
Assert1(NumCallArgs >= 0,
25782587
"gc.statepoint number of arguments to underlying call "
25792588
"must be positive", &CI);
2589+
Assert1(NumCallArgs == (int)TargetFuncType->getNumParams(),
2590+
"gc.statepoint mismatch in number of call args", &CI);
25802591

25812592
const Value *Unused = CI.getArgOperand(2);
25822593
Assert1(isa<ConstantInt>(Unused) &&

0 commit comments

Comments
 (0)