Skip to content

Commit 1c8e128

Browse files
committed
IR verifier check and test
1 parent 18b324e commit 1c8e128

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
@@ -5894,6 +5894,12 @@ void Verifier::visitIntrinsicCall(Intrinsic::ID ID, CallBase &Call) {
58945894
Check(cast<ConstantInt>(Call.getArgOperand(3))->getZExtValue() < 2,
58955895
"cache type argument to llvm.prefetch must be 0-1", Call);
58965896
break;
5897+
case Intrinsic::reloc_none: {
5898+
Check(isa<MDString>(
5899+
cast<MetadataAsValue>(Call.getArgOperand(0))->getMetadata()),
5900+
"llvm.reloc.none argument must be a metadata string", &Call);
5901+
break;
5902+
}
58975903
case Intrinsic::stackprotector:
58985904
Check(isa<AllocaInst>(Call.getArgOperand(1)->stripPointerCasts()),
58995905
"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)