Skip to content

Commit 312f688

Browse files
committed
IR verifier check and test
1 parent f439cb6 commit 312f688

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

llvm/lib/IR/Verifier.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5933,6 +5933,12 @@ void Verifier::visitIntrinsicCall(Intrinsic::ID ID, CallBase &Call) {
59335933
Check(cast<ConstantInt>(Call.getArgOperand(3))->getZExtValue() < 2,
59345934
"cache type argument to llvm.prefetch must be 0-1", Call);
59355935
break;
5936+
case Intrinsic::reloc_none: {
5937+
Check(isa<MDString>(
5938+
cast<MetadataAsValue>(Call.getArgOperand(0))->getMetadata()),
5939+
"llvm.reloc.none argument must be a metadata string", &Call);
5940+
break;
5941+
}
59365942
case Intrinsic::stackprotector:
59375943
Check(isa<AllocaInst>(Call.getArgOperand(1)->stripPointerCasts()),
59385944
"llvm.stackprotector parameter #2 must resolve to an alloca.", Call);

llvm/test/Verifier/reloc_none.ll

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
; RUN: not opt -S -passes=verify 2>&1 < %s | FileCheck %s
2+
3+
; CHECK: llvm.reloc.none argument must be a metadata string
4+
; CHECK-NEXT: call void @llvm.reloc.none(metadata !0)
5+
6+
define void @test_reloc_none_bad_arg() {
7+
call void @llvm.reloc.none(metadata !0)
8+
ret void
9+
}
10+
11+
declare void @llvm.reloc.none(metadata)
12+
13+
!0 = !{}

0 commit comments

Comments
 (0)