Skip to content

Commit 6ade6d2

Browse files
committed
[Verifier] Relieve intrinsics parameter alignment size constrain
In D121898 we restrict parameter alignment size in IR since DAGISel only have 4 bits to hold the alignment value. However intrinsics won't be lowered to call instruction, so we can remove the constrain for intrinsics. Differential Revision: https://reviews.llvm.org/D136330
1 parent 6790292 commit 6ade6d2

File tree

3 files changed

+33
-11
lines changed

3 files changed

+33
-11
lines changed

llvm/lib/IR/Verifier.cpp

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3222,6 +3222,13 @@ void Verifier::visitCallBase(CallBase &Call) {
32223222
Check(verifyAttributeCount(Attrs, Call.arg_size()),
32233223
"Attribute after last parameter!", Call);
32243224

3225+
Function *Callee =
3226+
dyn_cast<Function>(Call.getCalledOperand()->stripPointerCasts());
3227+
bool IsIntrinsic = Callee && Callee->isIntrinsic();
3228+
if (IsIntrinsic)
3229+
Check(Callee->getValueType() == FTy,
3230+
"Intrinsic called with incompatible signature", Call);
3231+
32253232
auto VerifyTypeAlign = [&](Type *Ty, const Twine &Message) {
32263233
if (!Ty->isSized())
32273234
return;
@@ -3231,19 +3238,14 @@ void Verifier::visitCallBase(CallBase &Call) {
32313238
"Incorrect alignment of " + Message + " to called function!", Call);
32323239
};
32333240

3234-
VerifyTypeAlign(FTy->getReturnType(), "return type");
3235-
for (unsigned i = 0, e = FTy->getNumParams(); i != e; ++i) {
3236-
Type *Ty = FTy->getParamType(i);
3237-
VerifyTypeAlign(Ty, "argument passed");
3241+
if (!IsIntrinsic) {
3242+
VerifyTypeAlign(FTy->getReturnType(), "return type");
3243+
for (unsigned i = 0, e = FTy->getNumParams(); i != e; ++i) {
3244+
Type *Ty = FTy->getParamType(i);
3245+
VerifyTypeAlign(Ty, "argument passed");
3246+
}
32383247
}
32393248

3240-
Function *Callee =
3241-
dyn_cast<Function>(Call.getCalledOperand()->stripPointerCasts());
3242-
bool IsIntrinsic = Callee && Callee->isIntrinsic();
3243-
if (IsIntrinsic)
3244-
Check(Callee->getValueType() == FTy,
3245-
"Intrinsic called with incompatible signature", Call);
3246-
32473249
if (Attrs.hasFnAttr(Attribute::Speculatable)) {
32483250
// Don't allow speculatable on call sites, unless the underlying function
32493251
// declaration is also speculatable.

llvm/test/Verifier/param-align.ll

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
; RUN: not llvm-as < %s 2>&1 | FileCheck %s
22

3+
; Large vector for intrinsics is valid
4+
; CHECK-NOT: llvm.fshr
5+
define dso_local <8192 x i32> @test_intrin(<8192 x i32> %l, <8192 x i32> %r, <8192 x i32> %amt) {
6+
entry:
7+
%b = call <8192 x i32> @llvm.fshr.v8192i32(<8192 x i32> %l, <8192 x i32> %r, <8192 x i32> %amt)
8+
ret <8192 x i32> %b
9+
}
10+
declare <8192 x i32> @llvm.fshr.v8192i32 (<8192 x i32> %l, <8192 x i32> %r, <8192 x i32> %amt)
11+
312
; CHECK: Incorrect alignment of argument passed to called function!
13+
; CHECK: bar
414
define dso_local void @foo(<8192 x float> noundef %vec) {
515
entry:
616
call void @bar(<8192 x float> %vec)

llvm/test/Verifier/param-ret-align.ll

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
; RUN: not llvm-as < %s 2>&1 | FileCheck %s
22

3+
; Large vector for intrinsics is valid
4+
; CHECK-NOT: llvm.fshr
5+
define dso_local <8192 x i32> @test_intrin(<8192 x i32> %l, <8192 x i32> %r, <8192 x i32> %amt) {
6+
entry:
7+
%b = call <8192 x i32> @llvm.fshr.v8192i32(<8192 x i32> %l, <8192 x i32> %r, <8192 x i32> %amt)
8+
ret <8192 x i32> %b
9+
}
10+
declare <8192 x i32> @llvm.fshr.v8192i32 (<8192 x i32> %l, <8192 x i32> %r, <8192 x i32> %amt)
11+
312
; CHECK: Incorrect alignment of return type to called function!
13+
; CHECK: bar
414
define dso_local void @foo() {
515
entry:
616
call <8192 x float> @bar()

0 commit comments

Comments
 (0)