aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/Function.cpp
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2021-09-04 12:18:52 +0200
committerNikita Popov <nikita.ppv@gmail.com>2021-09-10 15:18:23 +0200
commit90ec6dff860f4ec9cb89041b6e2a671cc3ce8f47 (patch)
tree528bae899726bf83d398961132e11457f7854f6f /llvm/lib/IR/Function.cpp
parent745f82b8d909db1bee8282742acb97f09c68f194 (diff)
[OpaquePtr] Forbid mixing typed and opaque pointers
Currently, opaque pointers are supported in two forms: The -force-opaque-pointers mode, where all pointers are opaque and typed pointers do not exist. And as a simple ptr type that can coexist with typed pointers. This patch removes support for the mixed mode. You either get typed pointers, or you get opaque pointers, but not both. In the (current) default mode, using ptr is forbidden. In -opaque-pointers mode, all pointers are opaque. The motivation here is that the mixed mode introduces additional issues that don't exist in fully opaque mode. D105155 is an example of a design problem. Looking at D109259, it would probably need additional work to support mixed mode (e.g. to generate GEPs for typed base but opaque result). Mixed mode will also end up inserting many casts between i8* and ptr, which would require significant additional work to consistently avoid. I don't think the mixed mode is particularly valuable, as it doesn't align with our end goal. The only thing I've found it to be moderately useful for is adding some opaque pointer tests in between typed pointer tests, but I think we can live without that. Differential Revision: https://reviews.llvm.org/D109290
Diffstat (limited to 'llvm/lib/IR/Function.cpp')
-rw-r--r--llvm/lib/IR/Function.cpp12
1 files changed, 2 insertions, 10 deletions
diff --git a/llvm/lib/IR/Function.cpp b/llvm/lib/IR/Function.cpp
index 9ec5a46a0204..ef3bc1cee44c 100644
--- a/llvm/lib/IR/Function.cpp
+++ b/llvm/lib/IR/Function.cpp
@@ -1446,11 +1446,6 @@ static bool matchIntrinsicType(
if (!PT->isOpaque())
return matchIntrinsicType(PT->getElementType(), Infos, ArgTys,
DeferredChecks, IsDeferredCheck);
- // If typed pointers are supported, do not allow using opaque pointer in
- // place of fixed pointer type. This would make the intrinsic signature
- // non-unique.
- if (Ty->getContext().supportsTypedPointers())
- return true;
// Consume IIT descriptors relating to the pointer element type.
while (Infos.front().Kind == IITDescriptor::Pointer)
Infos = Infos.slice(1);
@@ -1568,11 +1563,8 @@ static bool matchIntrinsicType(
if (!ThisArgType || !ReferenceType)
return true;
- if (!ThisArgType->isOpaque())
- return ThisArgType->getElementType() != ReferenceType->getElementType();
- // If typed pointers are supported, do not allow opaque pointer to ensure
- // uniqueness.
- return Ty->getContext().supportsTypedPointers();
+ return !ThisArgType->isOpaqueOrPointeeTypeMatches(
+ ReferenceType->getElementType());
}
case IITDescriptor::VecOfAnyPtrsToElt: {
unsigned RefArgNumber = D.getRefArgNumber();