Skip to content

Commit 53717ca

Browse files
committed
[IR] Remove -opaque-pointers option
The test migration to opaque pointers has finished, so we can finally drop typed pointer support from LLVM \o/ This removes the ability to disable typed pointers, as well as the -opaque-pointers option, but otherwise doesn't yet touch any API surface. I'll leave deprecation/removal of compatibility APIs to future changes. This also drops a few tests: These are either testing errors that only occur with typed pointers, or type linking behavior that, to the best of my knowledge, only applies to typed pointers. Note that this will break some tests in the experimental SPIRV backend, because the maintainers have failed to update their tests in a reasonable time-frame, despite multiple warnings. In accordance with our experimental target policy, this is not a blocking concern. This issue is tracked at #60133. Differential Revision: https://reviews.llvm.org/D155079
1 parent e5296c5 commit 53717ca

14 files changed

+12
-242
lines changed

llvm/docs/OpaquePointers.rst

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -276,27 +276,19 @@ supported.
276276
Transition State
277277
================
278278

279-
As of January 2023:
279+
As of July 2023:
280280

281-
Typed pointers are **not** supported on the ``main`` branch as a matter of
282-
policy. Fixes for typed pointer support are not accepted. Typed pointer
283-
support code may be removed without notice at any time.
281+
Typed pointers are **not** supported on the ``main`` branch.
284282

285-
However, tests are still in the process of being converted to opaque pointers.
286-
As such, care must be taken when actively removing typed pointer support, to
287-
avoid breaking remaining tests.
288-
289-
The following typed pointer functionality has already been removed:
283+
The following typed pointer functionality has been removed:
290284

291285
* The ``CLANG_ENABLE_OPAQUE_POINTERS`` cmake flag is no longer supported.
292286
* The ``-no-opaque-pointers`` cc1 clang flag is no longer supported.
287+
* The ``-opaque-pointers`` opt flag is no longer supported.
293288
* The ``-plugin-opt=no-opaque-pointers`` LTO flag is no longer supported.
294289
* C APIs that do not support opaque pointers (like ``LLVMBuildLoad``) are no
295290
longer supported.
296-
* Typed pointer IR and bitcode is implicitly upgraded to use opaque pointers,
297-
unless ``-opaque-pointers=0`` is passed.
298291

299292
The following typed pointer functionality is still to be removed:
300293

301-
* The ``-opaque-pointers=0`` opt flag.
302-
* Support for typed pointers in LLVM libraries.
294+
* Various APIs that are no longer relevant with opaque pointers.

llvm/docs/ReleaseNotes.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@ The new requirements are as follows:
5555
Changes to the LLVM IR
5656
----------------------
5757

58-
* Typed pointers are no longer supported. See the `opaque pointers
59-
<OpaquePointers.html>`__ documentation for migration instructions.
58+
* Typed pointers are no longer supported and the ``-opaque-pointers`` option
59+
has been removed. See the `opaque pointers <OpaquePointers.html>`__
60+
documentation for migration instructions.
6061

6162
* The ``nofpclass`` attribute was introduced. This allows more
6263
optimizations around special floating point value comparisons.

llvm/lib/IR/LLVMContext.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,9 +374,9 @@ std::unique_ptr<DiagnosticHandler> LLVMContext::getDiagnosticHandler() {
374374
}
375375

376376
void LLVMContext::setOpaquePointers(bool Enable) const {
377-
pImpl->setOpaquePointers(Enable);
377+
assert(Enable && "Cannot disable opaque pointers");
378378
}
379379

380380
bool LLVMContext::supportsTypedPointers() const {
381-
return !pImpl->getOpaquePointers();
381+
return false;
382382
}

llvm/lib/IR/LLVMContextImpl.cpp

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@
3333

3434
using namespace llvm;
3535

36-
static cl::opt<bool>
37-
OpaquePointersCL("opaque-pointers", cl::desc("Use opaque pointers"),
38-
cl::init(true));
39-
4036
LLVMContextImpl::LLVMContextImpl(LLVMContext &C)
4137
: DiagHandler(std::make_unique<DiagnosticHandler>()),
4238
VoidTy(C, Type::VoidTyID), LabelTy(C, Type::LabelTyID),
@@ -46,11 +42,7 @@ LLVMContextImpl::LLVMContextImpl(LLVMContext &C)
4642
X86_FP80Ty(C, Type::X86_FP80TyID), FP128Ty(C, Type::FP128TyID),
4743
PPC_FP128Ty(C, Type::PPC_FP128TyID), X86_MMXTy(C, Type::X86_MMXTyID),
4844
X86_AMXTy(C, Type::X86_AMXTyID), Int1Ty(C, 1), Int8Ty(C, 8),
49-
Int16Ty(C, 16), Int32Ty(C, 32), Int64Ty(C, 64), Int128Ty(C, 128) {
50-
if (OpaquePointersCL.getNumOccurrences()) {
51-
OpaquePointers = OpaquePointersCL;
52-
}
53-
}
45+
Int16Ty(C, 16), Int32Ty(C, 32), Int64Ty(C, 64), Int128Ty(C, 128) {}
5446

5547
LLVMContextImpl::~LLVMContextImpl() {
5648
// NOTE: We need to delete the contents of OwnedModules, but Module's dtor
@@ -250,15 +242,3 @@ OptPassGate &LLVMContextImpl::getOptPassGate() const {
250242
void LLVMContextImpl::setOptPassGate(OptPassGate& OPG) {
251243
this->OPG = &OPG;
252244
}
253-
254-
bool LLVMContextImpl::getOpaquePointers() {
255-
if (LLVM_UNLIKELY(!OpaquePointers))
256-
OpaquePointers = OpaquePointersCL;
257-
return *OpaquePointers;
258-
}
259-
260-
void LLVMContextImpl::setOpaquePointers(bool OP) {
261-
assert((!OpaquePointers || *OpaquePointers == OP) &&
262-
"Cannot change opaque pointers mode once set");
263-
OpaquePointers = OP;
264-
}

llvm/lib/IR/LLVMContextImpl.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1633,14 +1633,6 @@ class LLVMContextImpl {
16331633
/// The lifetime of the object must be guaranteed to extend as long as the
16341634
/// LLVMContext is used by compilation.
16351635
void setOptPassGate(OptPassGate &);
1636-
1637-
// TODO: clean up the following after we no longer support non-opaque pointer
1638-
// types.
1639-
bool getOpaquePointers();
1640-
void setOpaquePointers(bool OP);
1641-
1642-
private:
1643-
std::optional<bool> OpaquePointers;
16441636
};
16451637

16461638
} // end namespace llvm

llvm/lib/IR/Type.cpp

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -798,24 +798,12 @@ PointerType *PointerType::get(Type *EltTy, unsigned AddressSpace) {
798798
assert(EltTy && "Can't get a pointer to <null> type!");
799799
assert(isValidElementType(EltTy) && "Invalid type for pointer element!");
800800

801-
LLVMContextImpl *CImpl = EltTy->getContext().pImpl;
802-
803801
// Automatically convert typed pointers to opaque pointers.
804-
if (CImpl->getOpaquePointers())
805-
return get(EltTy->getContext(), AddressSpace);
806-
807-
PointerType *&Entry =
808-
CImpl->LegacyPointerTypes[std::make_pair(EltTy, AddressSpace)];
809-
810-
if (!Entry)
811-
Entry = new (CImpl->Alloc) PointerType(EltTy, AddressSpace);
812-
return Entry;
802+
return get(EltTy->getContext(), AddressSpace);
813803
}
814804

815805
PointerType *PointerType::get(LLVMContext &C, unsigned AddressSpace) {
816806
LLVMContextImpl *CImpl = C.pImpl;
817-
assert(CImpl->getOpaquePointers() &&
818-
"Can only create opaque pointers in opaque pointer mode");
819807

820808
// Since AddressSpace #0 is the common case, we special case it.
821809
PointerType *&Entry = AddressSpace == 0 ? CImpl->AS0PointerType

llvm/test/Assembler/ptr-outside-opaque-pointers-mode.ll

Lines changed: 0 additions & 7 deletions
This file was deleted.

llvm/test/Bitcode/opaque-ptr.ll

Lines changed: 0 additions & 10 deletions
This file was deleted.

llvm/test/LTO/X86/Inputs/type-mapping-bug4_0.ll

Lines changed: 0 additions & 11 deletions
This file was deleted.

llvm/test/LTO/X86/Inputs/type-mapping-bug4_1.ll

Lines changed: 0 additions & 55 deletions
This file was deleted.

llvm/test/LTO/X86/type-mapping-bug4.ll

Lines changed: 0 additions & 76 deletions
This file was deleted.

llvm/test/Linker/Inputs/type-unique-name.ll

Lines changed: 0 additions & 5 deletions
This file was deleted.

llvm/test/Linker/type-unique-name.ll

Lines changed: 0 additions & 13 deletions
This file was deleted.

llvm/test/Other/mixed-opaque-ptrs.ll

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)