[PATCH] D109290: [OpaquePtr] Forbid mixing typed and opaque pointers

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 5 08:02:52 PDT 2021


nikic created this revision.
nikic added a reviewer: opaque-pointers.
Herald added subscribers: ormris, dexonsmith, hiraditya, jgravelle-google, sbc100, dschuff.
nikic requested review of this revision.
Herald added subscribers: llvm-commits, aheejin.
Herald added a project: LLVM.

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.

I would like to propose that we remove 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 <https://reviews.llvm.org/D105155> is an example of a design problem. Looking at D109259 <https://reviews.llvm.org/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 invert 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.

(This depends on D109282 <https://reviews.llvm.org/D109282> and a fix for constexpr GEPs to failures when switching existing tests to specify `-opaque-pointers`.)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D109290

Files:
  llvm/include/llvm/AsmParser/LLParser.h
  llvm/lib/AsmParser/LLLexer.cpp
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/IR/Function.cpp
  llvm/lib/IR/LLVMContext.cpp
  llvm/lib/IR/LLVMContextImpl.cpp
  llvm/lib/IR/LLVMContextImpl.h
  llvm/lib/IR/Type.cpp
  llvm/test/Assembler/invalid-opaque-ptr-addrspace.ll
  llvm/test/Assembler/invalid-opaque-ptr-double-addrspace.ll
  llvm/test/Assembler/invalid-opaque-ptr.ll
  llvm/test/Assembler/opaque-ptr-cmpxchg.ll
  llvm/test/Assembler/opaque-ptr.ll
  llvm/test/Assembler/ptr-outside-opaque-pointers-mode.ll
  llvm/test/Assembler/remangle-intrinsic-opaque-ptr.ll
  llvm/test/CodeGen/BPF/CORE/intrinsic-array.ll
  llvm/test/CodeGen/Hexagon/atomic-opaque-basic.ll
  llvm/test/CodeGen/WebAssembly/add-prototypes-opaque-ptrs.ll
  llvm/test/CodeGen/WebAssembly/function-bitcasts.ll
  llvm/test/CodeGen/WebAssembly/main-declaration.ll
  llvm/test/Instrumentation/SanitizerCoverage/opaque-ptr.ll
  llvm/test/Instrumentation/SanitizerCoverage/stack-depth-variable-declared-by-user.ll
  llvm/test/Other/force-opaque-ptrs-typed-dis.ll
  llvm/test/Other/force-opaque-ptrs.ll
  llvm/test/Transforms/DeadStoreElimination/OverwriteStoreBegin.ll
  llvm/test/Transforms/DeadStoreElimination/opaque-ptr.ll
  llvm/test/Transforms/InstCombine/opaque-ptr.ll
  llvm/test/Transforms/LoadStoreVectorizer/X86/opaque-ptr.ll
  llvm/test/Transforms/LoopStrengthReduce/opaque-ptr.ll
  llvm/test/Transforms/LoopVectorize/opaque-ptr.ll
  llvm/test/Transforms/MemCpyOpt/memset-memcpy-redundant-memset.ll
  llvm/test/Transforms/MemCpyOpt/no-libcalls.ll
  llvm/test/Transforms/MemCpyOpt/opaque-ptr.ll
  llvm/test/Transforms/SLPVectorizer/X86/opaque-ptr.ll
  llvm/test/Transforms/SimplifyCFG/speculate-store-opaque-pointer.ll
  llvm/test/Transforms/SimplifyCFG/speculate-store.ll
  llvm/test/Verifier/force-opaque-ptr.ll
  llvm/test/Verifier/musttail-invalid.ll
  llvm/test/Verifier/opaque-ptr-invalid.ll
  llvm/test/Verifier/opaque-ptr.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109290.370799.patch
Type: text/x-patch
Size: 47199 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210905/b5ef037c/attachment-0001.bin>


More information about the llvm-commits mailing list