[Verifier] Require same signature for intrinsic calls
authorNikita Popov <nikita.ppv@gmail.com>
Wed, 14 Jul 2021 20:21:06 +0000 (22:21 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Fri, 16 Jul 2021 16:33:16 +0000 (18:33 +0200)
commit4d188a6524083ef79dae910215d4b34fad595358
treeeb445e790e4382e7bfa53fb9fe19e8ce23d43bee
parent1a7cddb0ea63a8413504c8ebdd3a65ba03343d0f
[Verifier] Require same signature for intrinsic calls

As suggested on D105733, this adds a verifier rule that calls to
intrinsics must match the signature of the intrinsic.

Without opaque pointers this is automatically enforced for all
calls, because the pointer types need to match. If the signatures
don't match, a pointer bitcast has to be inserted. For intrinsics
in particular, such bitcasts are not legal, because the address of
intrinsics cannot be taken.

With opaque pointers, there are no more pointer bitcasts, so it's
generally possible for the call and the callee signature to differ.
However, for intrinsics we still want to enforce that the signatures
must match, the same as was done before through the address taken
check.

We can't enforce this more generally for non-intrinsics, because
calls with mismatched signatures at the very least can legally
occur in unreachable code, and might also be valid in some other
cases, depending on how exactly the signatures differ.

Differential Revision: https://reviews.llvm.org/D106013
llvm/lib/IR/Verifier.cpp
llvm/test/Verifier/force-opaque-ptr.ll [new file with mode: 0644]