[PATCH] D106013: [Verifier] Require same signature for intrinsic calls
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 15 11:59:03 PDT 2021
nikic updated this revision to Diff 359080.
nikic added a comment.
Limit check to getIntrinsicID() for now.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D106013/new/
https://reviews.llvm.org/D106013
Files:
llvm/lib/IR/Verifier.cpp
llvm/test/Verifier/force-opaque-ptr.ll
Index: llvm/test/Verifier/force-opaque-ptr.ll
===================================================================
--- /dev/null
+++ llvm/test/Verifier/force-opaque-ptr.ll
@@ -0,0 +1,9 @@
+; RUN: not opt -passes=verify -force-opaque-pointers -S < %s 2>&1 | FileCheck %s
+
+declare i32 @llvm.umax.i32(i32, i32)
+
+define void @intrinsic_signature_mismatch() {
+; CHECK: Intrinsic called with incompatible signature
+ call i32 @llvm.umax.i32(i32 0)
+ ret void
+}
Index: llvm/lib/IR/Verifier.cpp
===================================================================
--- llvm/lib/IR/Verifier.cpp
+++ llvm/lib/IR/Verifier.cpp
@@ -3070,6 +3070,13 @@
Function *Callee =
dyn_cast<Function>(Call.getCalledOperand()->stripPointerCasts());
+ // TODO: This doesn't use isIntrinsic(), because some ObjCARC tests
+ // perform bitcasts on @llvm.objc.sendMsg intrinsics. Limit the check to
+ // intrinsics with an ID for now, as we already prevent taking their address.
+ if (Callee && Callee->getIntrinsicID())
+ Assert(Callee->getValueType() == FTy,
+ "Intrinsic called with incompatible signature", Call);
+
if (Attrs.hasFnAttribute(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: D106013.359080.patch
Type: text/x-patch
Size: 1300 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210715/d41f8e3b/attachment.bin>
More information about the llvm-commits
mailing list