[PATCH] D115632: [IR] Make VPIntrinsic::getDeclarationForParams() opaque pointer compatible
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 13 06:35:28 PST 2021
nikic created this revision.
nikic added reviewers: opaque-pointers, simoll, hussainjk, craig.topper.
Herald added subscribers: dexonsmith, hiraditya.
nikic requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
The vp.load and vp.gather intrinsics require the intrinsic return type to determine the correct function signature. With opaque pointers, it cannot be derived from the parameter pointee types.
https://reviews.llvm.org/D115632
Files:
llvm/include/llvm/IR/IntrinsicInst.h
llvm/lib/IR/IntrinsicInst.cpp
llvm/unittests/IR/VPIntrinsicTest.cpp
Index: llvm/unittests/IR/VPIntrinsicTest.cpp
===================================================================
--- llvm/unittests/IR/VPIntrinsicTest.cpp
+++ llvm/unittests/IR/VPIntrinsicTest.cpp
@@ -272,7 +272,7 @@
ASSERT_NE(F.getIntrinsicID(), Intrinsic::not_intrinsic);
auto *NewDecl = VPIntrinsic::getDeclarationForParams(
- OutM.get(), F.getIntrinsicID(), Values);
+ OutM.get(), F.getIntrinsicID(), FuncTy->getReturnType(), Values);
ASSERT_TRUE(NewDecl);
// Check that 'old decl' == 'new decl'.
Index: llvm/lib/IR/IntrinsicInst.cpp
===================================================================
--- llvm/lib/IR/IntrinsicInst.cpp
+++ llvm/lib/IR/IntrinsicInst.cpp
@@ -468,6 +468,7 @@
}
Function *VPIntrinsic::getDeclarationForParams(Module *M, Intrinsic::ID VPID,
+ Type *ReturnType,
ArrayRef<Value *> Params) {
assert(isVPIntrinsic(VPID) && "not a VP intrinsic");
Function *VPFunc;
@@ -486,22 +487,15 @@
break;
case Intrinsic::vp_load:
VPFunc = Intrinsic::getDeclaration(
- M, VPID,
- {Params[0]->getType()->getPointerElementType(), Params[0]->getType()});
+ M, VPID, {ReturnType, Params[0]->getType()});
break;
case Intrinsic::vp_gather:
VPFunc = Intrinsic::getDeclaration(
- M, VPID,
- {VectorType::get(cast<VectorType>(Params[0]->getType())
- ->getElementType()
- ->getPointerElementType(),
- cast<VectorType>(Params[0]->getType())),
- Params[0]->getType()});
+ M, VPID, {ReturnType, Params[0]->getType()});
break;
case Intrinsic::vp_store:
VPFunc = Intrinsic::getDeclaration(
- M, VPID,
- {Params[1]->getType()->getPointerElementType(), Params[1]->getType()});
+ M, VPID, {Params[0]->getType(), Params[1]->getType()});
break;
case Intrinsic::vp_scatter:
VPFunc = Intrinsic::getDeclaration(
Index: llvm/include/llvm/IR/IntrinsicInst.h
===================================================================
--- llvm/include/llvm/IR/IntrinsicInst.h
+++ llvm/include/llvm/IR/IntrinsicInst.h
@@ -390,8 +390,10 @@
class VPIntrinsic : public IntrinsicInst {
public:
/// \brief Declares a llvm.vp.* intrinsic in \p M that matches the parameters
- /// \p Params.
+ /// \p Params. Additionally, the load and gather intrinsics require
+ /// \p ReturnType to be specified.
static Function *getDeclarationForParams(Module *M, Intrinsic::ID,
+ Type *ReturnType,
ArrayRef<Value *> Params);
static Optional<unsigned> getMaskParamPos(Intrinsic::ID IntrinsicID);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D115632.393872.patch
Type: text/x-patch
Size: 2804 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211213/6b440b64/attachment.bin>
More information about the llvm-commits
mailing list