[PATCH] D86301: [Verifier] Additional check for get.active.lane.mask

Sjoerd Meijer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 20 09:15:49 PDT 2020


SjoerdMeijer created this revision.
SjoerdMeijer added reviewers: efriedma, samparker, dmgreen.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.
SjoerdMeijer requested review of this revision.

Adapt the verifier checks for get.active.lane.mask to the new semantics as proposed in D86147 <https://reviews.llvm.org/D86147>.
I.e., we expect second argument `%n` to be greater than 0, so check that.


https://reviews.llvm.org/D86301

Files:
  llvm/lib/IR/Verifier.cpp
  llvm/test/Verifier/get-active-lane-mask.ll


Index: llvm/test/Verifier/get-active-lane-mask.ll
===================================================================
--- llvm/test/Verifier/get-active-lane-mask.ll
+++ llvm/test/Verifier/get-active-lane-mask.ll
@@ -1,21 +1,31 @@
 ; RUN: not llvm-as < %s -o /dev/null 2>&1 | FileCheck %s
 
-declare <4 x i32> @llvm.get.active.lane.mask.v4i32.i32(i32, i32)
 
-define <4 x i32> @t1(i32 %IV, i32 %BTC) {
+define <4 x i32> @t1(i32 %IV, i32 %TC) {
 ; CHECK:      get_active_lane_mask: element type is not i1
-; CHECK-NEXT: %res = call <4 x i32> @llvm.get.active.lane.mask.v4i32.i32(i32 %IV, i32 %BTC)
+; CHECK-NEXT: %res = call <4 x i32> @llvm.get.active.lane.mask.v4i32.i32(i32 %IV, i32 %TC)
 
-  %res = call <4 x i32> @llvm.get.active.lane.mask.v4i32.i32(i32 %IV, i32 %BTC)
+  %res = call <4 x i32> @llvm.get.active.lane.mask.v4i32.i32(i32 %IV, i32 %TC)
   ret <4 x i32> %res
 }
 
-declare i32 @llvm.get.active.lane.mask.i32.i32(i32, i32)
-
-define i32 @t2(i32 %IV, i32 %BTC) {
+define i32 @t2(i32 %IV, i32 %TC) {
 ; CHECK:      Intrinsic has incorrect return type!
 ; CHECK-NEXT: i32 (i32, i32)* @llvm.get.active.lane.mask.i32.i32
 
-  %res = call i32 @llvm.get.active.lane.mask.i32.i32(i32 %IV, i32 %BTC)
+  %res = call i32 @llvm.get.active.lane.mask.i32.i32(i32 %IV, i32 %TC)
   ret i32 %res
 }
+
+define <4 x i1> @t3(i32 %IV) {
+; CHECK:      get_active_lane_mask: operand #2 must be greater than 0
+; CHECK-NEXT: %res = call <4 x i1> @llvm.get.active.lane.mask.v4i1.i32(i32 %IV, i32 0)
+
+  %res = call <4 x i1> @llvm.get.active.lane.mask.v4i1.i32(i32 %IV, i32 0)
+  ret <4 x i1> %res
+}
+
+declare <4 x i32> @llvm.get.active.lane.mask.v4i32.i32(i32, i32)
+declare i32 @llvm.get.active.lane.mask.i32.i32(i32, i32)
+declare <4 x i1> @llvm.get.active.lane.mask.v4i1.i32(i32, i32)
+
Index: llvm/lib/IR/Verifier.cpp
===================================================================
--- llvm/lib/IR/Verifier.cpp
+++ llvm/lib/IR/Verifier.cpp
@@ -4836,6 +4836,9 @@
     auto *ElemTy = Call.getType()->getScalarType();
     Assert(ElemTy->isIntegerTy(1), "get_active_lane_mask: element type is not "
            "i1", Call);
+    if (auto *TripCount = dyn_cast<ConstantInt>(Call.getArgOperand(1)))
+      Assert(TripCount->getZExtValue() > 0, "get_active_lane_mask: operand #2 "
+             "must be greater than 0", Call);
     break;
   }
   case Intrinsic::masked_load: {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D86301.286838.patch
Type: text/x-patch
Size: 2373 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200820/04a02bc2/attachment.bin>


More information about the llvm-commits mailing list