[PATCH] D136330: [Verifier] Relieve intrinsics parameter alignment size constrain

LuoYuanke via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 21 02:03:55 PDT 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rG6ade6d25110f: [Verifier] Relieve intrinsics parameter alignment size constrain (authored by LuoYuanke).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D136330/new/

https://reviews.llvm.org/D136330

Files:
  llvm/lib/IR/Verifier.cpp
  llvm/test/Verifier/param-align.ll
  llvm/test/Verifier/param-ret-align.ll


Index: llvm/test/Verifier/param-ret-align.ll
===================================================================
--- llvm/test/Verifier/param-ret-align.ll
+++ llvm/test/Verifier/param-ret-align.ll
@@ -1,6 +1,16 @@
 ; RUN: not llvm-as < %s 2>&1 | FileCheck %s
 
+; Large vector for intrinsics is valid
+; CHECK-NOT: llvm.fshr
+define dso_local <8192 x i32> @test_intrin(<8192 x i32> %l, <8192 x i32> %r, <8192 x i32> %amt) {
+entry:
+  %b = call <8192 x i32> @llvm.fshr.v8192i32(<8192 x i32> %l, <8192 x i32> %r, <8192 x i32> %amt)
+  ret <8192 x i32> %b
+}
+declare <8192 x i32> @llvm.fshr.v8192i32 (<8192 x i32> %l, <8192 x i32> %r, <8192 x i32> %amt)
+
 ; CHECK: Incorrect alignment of return type to called function!
+; CHECK: bar
 define dso_local void @foo() {
 entry:
   call <8192 x float> @bar()
Index: llvm/test/Verifier/param-align.ll
===================================================================
--- llvm/test/Verifier/param-align.ll
+++ llvm/test/Verifier/param-align.ll
@@ -1,6 +1,16 @@
 ; RUN: not llvm-as < %s 2>&1 | FileCheck %s
 
+; Large vector for intrinsics is valid
+; CHECK-NOT: llvm.fshr
+define dso_local <8192 x i32> @test_intrin(<8192 x i32> %l, <8192 x i32> %r, <8192 x i32> %amt) {
+entry:
+  %b = call <8192 x i32> @llvm.fshr.v8192i32(<8192 x i32> %l, <8192 x i32> %r, <8192 x i32> %amt)
+  ret <8192 x i32> %b
+}
+declare <8192 x i32> @llvm.fshr.v8192i32 (<8192 x i32> %l, <8192 x i32> %r, <8192 x i32> %amt)
+
 ; CHECK: Incorrect alignment of argument passed to called function!
+; CHECK: bar
 define dso_local void @foo(<8192 x float> noundef %vec) {
 entry:
   call void @bar(<8192 x float> %vec)
Index: llvm/lib/IR/Verifier.cpp
===================================================================
--- llvm/lib/IR/Verifier.cpp
+++ llvm/lib/IR/Verifier.cpp
@@ -3222,6 +3222,13 @@
   Check(verifyAttributeCount(Attrs, Call.arg_size()),
         "Attribute after last parameter!", Call);
 
+  Function *Callee =
+      dyn_cast<Function>(Call.getCalledOperand()->stripPointerCasts());
+  bool IsIntrinsic = Callee && Callee->isIntrinsic();
+  if (IsIntrinsic)
+    Check(Callee->getValueType() == FTy,
+          "Intrinsic called with incompatible signature", Call);
+
   auto VerifyTypeAlign = [&](Type *Ty, const Twine &Message) {
     if (!Ty->isSized())
       return;
@@ -3231,19 +3238,14 @@
           "Incorrect alignment of " + Message + " to called function!", Call);
   };
 
-  VerifyTypeAlign(FTy->getReturnType(), "return type");
-  for (unsigned i = 0, e = FTy->getNumParams(); i != e; ++i) {
-    Type *Ty = FTy->getParamType(i);
-    VerifyTypeAlign(Ty, "argument passed");
+  if (!IsIntrinsic) {
+    VerifyTypeAlign(FTy->getReturnType(), "return type");
+    for (unsigned i = 0, e = FTy->getNumParams(); i != e; ++i) {
+      Type *Ty = FTy->getParamType(i);
+      VerifyTypeAlign(Ty, "argument passed");
+    }
   }
 
-  Function *Callee =
-      dyn_cast<Function>(Call.getCalledOperand()->stripPointerCasts());
-  bool IsIntrinsic = Callee && Callee->isIntrinsic();
-  if (IsIntrinsic)
-    Check(Callee->getValueType() == FTy,
-          "Intrinsic called with incompatible signature", Call);
-
   if (Attrs.hasFnAttr(Attribute::Speculatable)) {
     // Don't allow speculatable on call sites, unless the underlying function
     // declaration is also speculatable.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136330.469511.patch
Type: text/x-patch
Size: 3326 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221021/25cb1a9a/attachment.bin>


More information about the llvm-commits mailing list