[llvm] ff59a1c - [Verifier] Extend address taken check for unknown intrinsics
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 15 14:16:27 PDT 2021
Author: Nikita Popov
Date: 2021-07-15T23:16:14+02:00
New Revision: ff59a1cfe64c0b619c1a8e9ae14406a47897b98d
URL: https://github.com/llvm/llvm-project/commit/ff59a1cfe64c0b619c1a8e9ae14406a47897b98d
DIFF: https://github.com/llvm/llvm-project/commit/ff59a1cfe64c0b619c1a8e9ae14406a47897b98d.diff
LOG: [Verifier] Extend address taken check for unknown intrinsics
Intrinsics can only be called directly, taking their address is not
legal. This is currently only enforced for intrinsics that have an
ID, rather than all intrinsics. Adjust the check to cover all
intrinsics.
This came up in D106013.
Differential Revision: https://reviews.llvm.org/D106095
Added:
llvm/test/Verifier/intrinsic-addr-taken.ll
Modified:
llvm/lib/IR/Verifier.cpp
Removed:
################################################################################
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index 2c005c911b2ec..67ed73ff8f0e9 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -2521,7 +2521,7 @@ void Verifier::visitFunction(const Function &F) {
// direct call/invokes, never having its "address taken".
// Only do this if the module is materialized, otherwise we don't have all the
// uses.
- if (F.getIntrinsicID() && F.getParent()->isMaterialized()) {
+ if (F.isIntrinsic() && F.getParent()->isMaterialized()) {
const User *U;
if (F.hasAddressTaken(&U))
Assert(false, "Invalid user of intrinsic instruction!", U);
diff --git a/llvm/test/Verifier/intrinsic-addr-taken.ll b/llvm/test/Verifier/intrinsic-addr-taken.ll
new file mode 100644
index 0000000000000..630f5fe117fdf
--- /dev/null
+++ b/llvm/test/Verifier/intrinsic-addr-taken.ll
@@ -0,0 +1,9 @@
+; RUN: not llvm-as < %s 2>&1 | FileCheck %s
+
+declare i32 @llvm.umax.i32(i32, i32)
+declare i32 @llvm.my.custom.intrinsic()
+
+; CHECK: Invalid user of intrinsic instruction!
+ at g1 = global i32(i32, i32)* @llvm.umax.i32
+; CHECK: Invalid user of intrinsic instruction!
+ at g2 = global i32()* @llvm.my.custom.intrinsic
More information about the llvm-commits
mailing list