Skip to content

Commit bec726f

Browse files
committed
[Verifier] Enforce elementtype attr for inline asm indirect constraints
This enforces the LangRef change from D116531 in the Verifier, now that clang and tests have been updated.
1 parent 6638303 commit bec726f

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

llvm/lib/IR/Verifier.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -2162,7 +2162,9 @@ void Verifier::verifyInlineAsmCall(const CallBase &Call) {
21622162
"Operand for indirect constraint must have pointer type",
21632163
&Call);
21642164

2165-
// TODO: Require elementtype attribute here.
2165+
Assert(Call.getAttributes().getParamElementType(ArgNo),
2166+
"Operand for indirect constraint must have elementtype attribute",
2167+
&Call);
21662168
} else {
21672169
Assert(!Call.paramHasAttr(ArgNo, Attribute::ElementType),
21682170
"Elementtype attribute can only be applied for indirect "

llvm/test/Verifier/inline-asm-indirect-operand.ll

+7
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ define void @not_indirect(i32* %p, i32* %x) {
2626
ret void
2727
}
2828

29+
; CHECK: Operand for indirect constraint must have elementtype attribute
30+
; CHECK-NEXT: call void asm "addl $1, $0", "=*rm,r"(i32* %p, i32 %x)
31+
define void @missing_elementtype(i32* %p, i32 %x) {
32+
call void asm "addl $1, $0", "=*rm,r"(i32* %p, i32 %x)
33+
ret void
34+
}
35+
2936
; CHECK: Operand for indirect constraint must have pointer type
3037
; CHECK-NEXT: invoke void asm "addl $1, $0", "=*rm,r"(i32 %p, i32 %x)
3138
define void @not_pointer_arg_invoke(i32 %p, i32 %x) personality i8* null {

0 commit comments

Comments
 (0)