[LangRef] Require elementtype attribute for indirect inline asm operands
Indirect inline asm operands may require the materialization of a
memory access according to the pointer element type. As this will
no longer be available with opaque pointers, we require it to be
explicitly annotated using the elementtype attribute, for example:
define void @test(i32* %p, i32 %x) {
call void asm "addl $1, $0", "=*rm,r"(i32* elementtype(i32) %p, i32 %x)
ret void
}
This patch only includes the LangRef change and Verifier updates to
allow adding the elementtype attribute in this position. It does not
yet enforce this, as this will require changes on the clang side
(and test updates) first.
Something I'm a bit unsure about is whether we really need the
elementtype for all indirect constraints, rather than only indirect
register constraints. I think indirect memory constraints might not
strictly need it (though the backend code is written in a way that
does require it). I think it's okay to just make this a general
requirement though, as this means we don't need to carefully deal
with multiple or alternative constraints. In addition, I believe
that MemorySanitizer benefits from having the element type even in
cases where it may not be strictly necessary for normal lowering
(https://github.com/llvm/llvm-project/blob/cd2b050fa4995b75b9c36fae16c0d9f105b67585/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp#L4066).
Differential Revision: https://reviews.llvm.org/D116531
2022-01-03 18:44:39 +08:00
|
|
|
; RUN: not llvm-as < %s -o /dev/null 2>&1 | FileCheck %s
|
|
|
|
|
|
|
|
define void @okay(i32* %p, i32 %x) {
|
|
|
|
call void asm "addl $1, $0", "=*rm,r"(i32* elementtype(i32) %p, i32 %x)
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK: Attribute 'elementtype' type does not match parameter!
|
|
|
|
; CHECK-NEXT: call void asm "addl $1, $0", "=*rm,r"(i32* elementtype(i64) %p, i32 %x)
|
|
|
|
define void @wrong_element_type(i32* %p, i32 %x) {
|
|
|
|
call void asm "addl $1, $0", "=*rm,r"(i32* elementtype(i64) %p, i32 %x)
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK: Operand for indirect constraint must have pointer type
|
|
|
|
; CHECK-NEXT: call void asm "addl $1, $0", "=*rm,r"(i32 %p, i32 %x)
|
|
|
|
define void @not_pointer_arg(i32 %p, i32 %x) {
|
|
|
|
call void asm "addl $1, $0", "=*rm,r"(i32 %p, i32 %x)
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK: Elementtype attribute can only be applied for indirect constraints
|
2022-01-06 19:10:58 +08:00
|
|
|
; CHECK-NEXT: call void asm "addl $1, $0", "=*rm,r"(i32* elementtype(i32) %p, i32* elementtype(i32) %x)
|
[LangRef] Require elementtype attribute for indirect inline asm operands
Indirect inline asm operands may require the materialization of a
memory access according to the pointer element type. As this will
no longer be available with opaque pointers, we require it to be
explicitly annotated using the elementtype attribute, for example:
define void @test(i32* %p, i32 %x) {
call void asm "addl $1, $0", "=*rm,r"(i32* elementtype(i32) %p, i32 %x)
ret void
}
This patch only includes the LangRef change and Verifier updates to
allow adding the elementtype attribute in this position. It does not
yet enforce this, as this will require changes on the clang side
(and test updates) first.
Something I'm a bit unsure about is whether we really need the
elementtype for all indirect constraints, rather than only indirect
register constraints. I think indirect memory constraints might not
strictly need it (though the backend code is written in a way that
does require it). I think it's okay to just make this a general
requirement though, as this means we don't need to carefully deal
with multiple or alternative constraints. In addition, I believe
that MemorySanitizer benefits from having the element type even in
cases where it may not be strictly necessary for normal lowering
(https://github.com/llvm/llvm-project/blob/cd2b050fa4995b75b9c36fae16c0d9f105b67585/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp#L4066).
Differential Revision: https://reviews.llvm.org/D116531
2022-01-03 18:44:39 +08:00
|
|
|
define void @not_indirect(i32* %p, i32* %x) {
|
2022-01-06 19:10:58 +08:00
|
|
|
call void asm "addl $1, $0", "=*rm,r"(i32* elementtype(i32) %p, i32* elementtype(i32) %x)
|
[LangRef] Require elementtype attribute for indirect inline asm operands
Indirect inline asm operands may require the materialization of a
memory access according to the pointer element type. As this will
no longer be available with opaque pointers, we require it to be
explicitly annotated using the elementtype attribute, for example:
define void @test(i32* %p, i32 %x) {
call void asm "addl $1, $0", "=*rm,r"(i32* elementtype(i32) %p, i32 %x)
ret void
}
This patch only includes the LangRef change and Verifier updates to
allow adding the elementtype attribute in this position. It does not
yet enforce this, as this will require changes on the clang side
(and test updates) first.
Something I'm a bit unsure about is whether we really need the
elementtype for all indirect constraints, rather than only indirect
register constraints. I think indirect memory constraints might not
strictly need it (though the backend code is written in a way that
does require it). I think it's okay to just make this a general
requirement though, as this means we don't need to carefully deal
with multiple or alternative constraints. In addition, I believe
that MemorySanitizer benefits from having the element type even in
cases where it may not be strictly necessary for normal lowering
(https://github.com/llvm/llvm-project/blob/cd2b050fa4995b75b9c36fae16c0d9f105b67585/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp#L4066).
Differential Revision: https://reviews.llvm.org/D116531
2022-01-03 18:44:39 +08:00
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2022-01-06 22:17:35 +08:00
|
|
|
; CHECK: Operand for indirect constraint must have elementtype attribute
|
|
|
|
; CHECK-NEXT: call void asm "addl $1, $0", "=*rm,r"(i32* %p, i32 %x)
|
|
|
|
define void @missing_elementtype(i32* %p, i32 %x) {
|
|
|
|
call void asm "addl $1, $0", "=*rm,r"(i32* %p, i32 %x)
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
[LangRef] Require elementtype attribute for indirect inline asm operands
Indirect inline asm operands may require the materialization of a
memory access according to the pointer element type. As this will
no longer be available with opaque pointers, we require it to be
explicitly annotated using the elementtype attribute, for example:
define void @test(i32* %p, i32 %x) {
call void asm "addl $1, $0", "=*rm,r"(i32* elementtype(i32) %p, i32 %x)
ret void
}
This patch only includes the LangRef change and Verifier updates to
allow adding the elementtype attribute in this position. It does not
yet enforce this, as this will require changes on the clang side
(and test updates) first.
Something I'm a bit unsure about is whether we really need the
elementtype for all indirect constraints, rather than only indirect
register constraints. I think indirect memory constraints might not
strictly need it (though the backend code is written in a way that
does require it). I think it's okay to just make this a general
requirement though, as this means we don't need to carefully deal
with multiple or alternative constraints. In addition, I believe
that MemorySanitizer benefits from having the element type even in
cases where it may not be strictly necessary for normal lowering
(https://github.com/llvm/llvm-project/blob/cd2b050fa4995b75b9c36fae16c0d9f105b67585/llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp#L4066).
Differential Revision: https://reviews.llvm.org/D116531
2022-01-03 18:44:39 +08:00
|
|
|
; CHECK: Operand for indirect constraint must have pointer type
|
|
|
|
; CHECK-NEXT: invoke void asm "addl $1, $0", "=*rm,r"(i32 %p, i32 %x)
|
|
|
|
define void @not_pointer_arg_invoke(i32 %p, i32 %x) personality i8* null {
|
|
|
|
invoke void asm "addl $1, $0", "=*rm,r"(i32 %p, i32 %x)
|
|
|
|
to label %cont unwind label %lpad
|
|
|
|
|
|
|
|
lpad:
|
|
|
|
%lp = landingpad i32
|
|
|
|
cleanup
|
|
|
|
ret void
|
|
|
|
|
|
|
|
cont:
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; CHECK: Operand for indirect constraint must have pointer type
|
|
|
|
; CHECK-NEXT: callbr void asm "addl $1, $0", "=*rm,r"(i32 %p, i32 %x)
|
|
|
|
define void @not_pointer_arg_callbr(i32 %p, i32 %x) {
|
|
|
|
callbr void asm "addl $1, $0", "=*rm,r"(i32 %p, i32 %x)
|
|
|
|
to label %cont []
|
|
|
|
|
|
|
|
cont:
|
|
|
|
ret void
|
|
|
|
}
|