[llvm] bec726f - [Verifier] Enforce elementtype attr for inline asm indirect constraints

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 6 06:22:16 PST 2022


Author: Nikita Popov
Date: 2022-01-06T15:22:00+01:00
New Revision: bec726f5d20ecfdc4a1cd4076ddc6edb35a317e5

URL: https://github.com/llvm/llvm-project/commit/bec726f5d20ecfdc4a1cd4076ddc6edb35a317e5
DIFF: https://github.com/llvm/llvm-project/commit/bec726f5d20ecfdc4a1cd4076ddc6edb35a317e5.diff

LOG: [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.

Added: 
    

Modified: 
    llvm/lib/IR/Verifier.cpp
    llvm/test/Verifier/inline-asm-indirect-operand.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index 254d7b2fdff49..3ffc6e3729762 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -2162,7 +2162,9 @@ void Verifier::verifyInlineAsmCall(const CallBase &Call) {
              "Operand for indirect constraint must have pointer type",
              &Call);
 
-      // TODO: Require elementtype attribute here.
+      Assert(Call.getAttributes().getParamElementType(ArgNo),
+             "Operand for indirect constraint must have elementtype attribute",
+             &Call);
     } else {
       Assert(!Call.paramHasAttr(ArgNo, Attribute::ElementType),
              "Elementtype attribute can only be applied for indirect "

diff  --git a/llvm/test/Verifier/inline-asm-indirect-operand.ll b/llvm/test/Verifier/inline-asm-indirect-operand.ll
index 1f78c171dccb3..030fa2af6f18e 100644
--- a/llvm/test/Verifier/inline-asm-indirect-operand.ll
+++ b/llvm/test/Verifier/inline-asm-indirect-operand.ll
@@ -26,6 +26,13 @@ define void @not_indirect(i32* %p, i32* %x) {
   ret void
 }
 
+; 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
+}
+
 ; 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 {


        


More information about the llvm-commits mailing list