Nikita Popov 472c79ca52
[IR] Check that arguments of naked function are not used (#104757)
Verify that the arguments of a naked function are not used. They can
only be referenced via registers/stack in inline asm, not as IR values.
Doing so will result in assertion failures in the backend.

There's probably more that we should verify, though I'm not completely
sure what the constraints are (would it be correct to require that naked
functions are exactly an inline asm call + unreachable, or is more
allowed?)

Fixes https://github.com/llvm/llvm-project/issues/104718.
2024-08-20 09:29:05 +02:00

9 lines
216 B
LLVM

; RUN: not llvm-as %s -o /dev/null 2>&1 | FileCheck %s
; CHECK: cannot use argument of naked function
define void @test(ptr %ptr) naked {
getelementptr i8, ptr %ptr, i64 1
call void @llvm.trap()
unreachable
}