Skip to content

Commit f4960da

Browse files
Revert "[Verifier] Reject va_start in non-variadic function (#88809)"
This reverts commit 61717c1. Failed a MLIR test
1 parent b0194d2 commit f4960da

File tree

5 files changed

+12
-15
lines changed

5 files changed

+12
-15
lines changed

llvm/lib/Analysis/Lint.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,10 @@ void Lint::visitCallBase(CallBase &I) {
350350
}
351351

352352
case Intrinsic::vastart:
353-
// vastart in non-varargs function is rejected by the verifier
353+
Check(I.getParent()->getParent()->isVarArg(),
354+
"Undefined behavior: va_start called in a non-varargs function",
355+
&I);
356+
354357
visitMemoryReference(I, MemoryLocation::getForArgument(&I, 0, TLI),
355358
std::nullopt, nullptr, MemRef::Read | MemRef::Write);
356359
break;

llvm/lib/IR/Verifier.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5798,11 +5798,6 @@ void Verifier::visitIntrinsicCall(Intrinsic::ID ID, CallBase &Call) {
57985798

57995799
break;
58005800
}
5801-
case Intrinsic::vastart: {
5802-
Check(Call.getFunction()->isVarArg(),
5803-
"va_start called in a non-varargs function");
5804-
break;
5805-
}
58065801
case Intrinsic::vector_reduce_and:
58075802
case Intrinsic::vector_reduce_or:
58085803
case Intrinsic::vector_reduce_xor:

llvm/test/CodeGen/AArch64/GlobalISel/vastart.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44

55
declare void @llvm.va_start(ptr)
6-
define void @test_va_start(ptr %list, ...) {
6+
define void @test_va_start(ptr %list) {
77
; CHECK-LABEL: name: test_va_start
88
; CHECK: [[LIST:%[0-9]+]]:_(p0) = COPY $x0
99
; CHECK-IOS: G_VASTART [[LIST]](p0) :: (store (s64) into %ir.list, align 1)

llvm/test/Other/lint.ll

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,13 @@ define void @0() nounwind {
124124
ret void
125125
}
126126

127+
; CHECK: va_start called in a non-varargs function
128+
declare void @llvm.va_start(ptr)
129+
define void @not_vararg(ptr %p) nounwind {
130+
call void @llvm.va_start(ptr %p)
131+
ret void
132+
}
133+
127134
; CHECK: Undefined behavior: Branch to non-blockaddress
128135
define void @use_indbr() {
129136
indirectbr ptr @foo, [label %block]

llvm/test/Verifier/variadic.ll

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)