Skip to content

Commit e45cf47

Browse files
committed
[Bitcode] Remove auto-detection for typed pointers
Always read bitcode according to the -opaque-pointers mode. Do not perform auto-detection to implicitly switch to typed pointers. This is a step towards removing typed pointer support, and also eliminates the class of problems where linking may fail if a typed pointer module is loaded before an opaque pointer module. (The latest place where this was encountered is D139924, but this has previously been fixed in other places doing bitcode linking as well.) Differential Revision: https://reviews.llvm.org/D139940
1 parent d8f91f2 commit e45cf47

File tree

64 files changed

+1151
-1176
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+1151
-1176
lines changed

llvm/docs/OpaquePointers.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,10 +287,12 @@ The following typed pointer functionality has already been removed:
287287
* The ``CLANG_ENABLE_OPAQUE_POINTERS`` cmake flag is no longer supported.
288288
* C APIs that do not support opaque pointers (like ``LLVMBuildLoad``) are no
289289
longer supported.
290+
* Typed pointer bitcode is implicitly upgraded to use opaque pointers, unless
291+
``-opaque-pointers=0`` is passed.
290292

291293
The following typed pointer functionality is still to be removed:
292294

293295
* The ``-no-opaque-pointers`` cc1 flag, ``-opaque-pointers=0`` opt flag and
294296
``-plugin-opt=no-opaque-pointers`` lto flag.
295-
* Auto-detection of typed pointers in bitcode and textual IR.
297+
* Auto-detection of typed pointers in textual IR.
296298
* Support for typed pointers in LLVM libraries.

llvm/lib/Bitcode/Reader/BitcodeReader.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2359,18 +2359,14 @@ Error BitcodeReader::parseTypeTableBody() {
23592359
if (!ResultTy ||
23602360
!PointerType::isValidElementType(ResultTy))
23612361
return error("Invalid type");
2362-
if (LLVM_UNLIKELY(!Context.hasSetOpaquePointersValue()))
2363-
Context.setOpaquePointers(false);
23642362
ContainedIDs.push_back(Record[0]);
23652363
ResultTy = PointerType::get(ResultTy, AddressSpace);
23662364
break;
23672365
}
23682366
case bitc::TYPE_CODE_OPAQUE_POINTER: { // OPAQUE_POINTER: [addrspace]
23692367
if (Record.size() != 1)
23702368
return error("Invalid opaque pointer record");
2371-
if (LLVM_UNLIKELY(!Context.hasSetOpaquePointersValue())) {
2372-
Context.setOpaquePointers(true);
2373-
} else if (Context.supportsTypedPointers())
2369+
if (Context.supportsTypedPointers())
23742370
return error(
23752371
"Opaque pointers are only supported in -opaque-pointers mode");
23762372
unsigned AddressSpace = Record[0];
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

llvm/test/Bitcode/alloca-addrspace.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
target datalayout = "A2"
44

5-
; CHECK-LABEL: define i8 addrspace(2)* @alloca_addrspace_2() {
5+
; CHECK-LABEL: define ptr addrspace(2) @alloca_addrspace_2() {
66
; CHECK: %alloca = alloca i8, align 1, addrspace(2)
77
define i8 addrspace(2)* @alloca_addrspace_2() {
88
%alloca = alloca i8, addrspace(2)
99
ret i8 addrspace(2)* %alloca
1010
}
1111

12-
; CHECK-LABEL: define i8 addrspace(5)* @alloca_addrspace_5() {
12+
; CHECK-LABEL: define ptr addrspace(5) @alloca_addrspace_5() {
1313
; CHECK: %alloca = alloca i8, align 1, addrspace(5)
1414
define i8 addrspace(5)* @alloca_addrspace_5() {
1515
%alloca = alloca i8, addrspace(5)

llvm/test/Bitcode/arm-intrinsics.ll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
; RUN: llvm-dis < %S/arm-intrinsics.bc | FileCheck %s
22

33
define void @f(i32* %p) {
4-
; CHECK: call i32 @llvm.arm.ldrex.p0i32(i32* elementtype(i32)
4+
; CHECK: call i32 @llvm.arm.ldrex.p0(ptr elementtype(i32)
55
%a = call i32 @llvm.arm.ldrex.p0i32(i32* %p)
6-
; CHECK: call i32 @llvm.arm.strex.p0i32(i32 0, i32* elementtype(i32)
6+
; CHECK: call i32 @llvm.arm.strex.p0(i32 0, ptr elementtype(i32)
77
%c = call i32 @llvm.arm.strex.p0i32(i32 0, i32* %p)
88

9-
; CHECK: call i32 @llvm.arm.ldaex.p0i32(i32* elementtype(i32)
9+
; CHECK: call i32 @llvm.arm.ldaex.p0(ptr elementtype(i32)
1010
%a2 = call i32 @llvm.arm.ldaex.p0i32(i32* %p)
11-
; CHECK: call i32 @llvm.arm.stlex.p0i32(i32 0, i32* elementtype(i32)
11+
; CHECK: call i32 @llvm.arm.stlex.p0(i32 0, ptr elementtype(i32)
1212
%c2 = call i32 @llvm.arm.stlex.p0i32(i32 0, i32* %p)
1313
ret void
1414
}

llvm/test/Bitcode/atomic-no-syncscope.ll

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
; Backwards compatibility test: make sure we can process bitcode without
44
; synchronization scope names encoded in it.
55

6-
; CHECK: load atomic i32, i32* %x unordered, align 4
7-
; CHECK: load atomic volatile i32, i32* %x syncscope("singlethread") acquire, align 4
8-
; CHECK: store atomic i32 3, i32* %x release, align 4
9-
; CHECK: store atomic volatile i32 3, i32* %x syncscope("singlethread") monotonic, align 4
10-
; CHECK: cmpxchg i32* %x, i32 1, i32 0 syncscope("singlethread") monotonic monotonic
11-
; CHECK: cmpxchg volatile i32* %x, i32 0, i32 1 acq_rel acquire
12-
; CHECK: cmpxchg i32* %x, i32 42, i32 0 acq_rel monotonic
13-
; CHECK: cmpxchg weak i32* %x, i32 13, i32 0 seq_cst monotonic
14-
; CHECK: atomicrmw add i32* %x, i32 10 seq_cst
15-
; CHECK: atomicrmw volatile xchg i32* %x, i32 10 monotonic
6+
; CHECK: load atomic i32, ptr %x unordered, align 4
7+
; CHECK: load atomic volatile i32, ptr %x syncscope("singlethread") acquire, align 4
8+
; CHECK: store atomic i32 3, ptr %x release, align 4
9+
; CHECK: store atomic volatile i32 3, ptr %x syncscope("singlethread") monotonic, align 4
10+
; CHECK: cmpxchg ptr %x, i32 1, i32 0 syncscope("singlethread") monotonic monotonic
11+
; CHECK: cmpxchg volatile ptr %x, i32 0, i32 1 acq_rel acquire
12+
; CHECK: cmpxchg ptr %x, i32 42, i32 0 acq_rel monotonic
13+
; CHECK: cmpxchg weak ptr %x, i32 13, i32 0 seq_cst monotonic
14+
; CHECK: atomicrmw add ptr %x, i32 10 seq_cst
15+
; CHECK: atomicrmw volatile xchg ptr %x, i32 10 monotonic
1616
; CHECK: fence syncscope("singlethread") release
1717
; CHECK: fence seq_cst

llvm/test/Bitcode/atomic.ll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33

44
define void @test_cmpxchg(i32* %addr, i32 %desired, i32 %new) {
55
cmpxchg i32* %addr, i32 %desired, i32 %new seq_cst seq_cst
6-
; CHECK: cmpxchg i32* %addr, i32 %desired, i32 %new seq_cst seq_cst
6+
; CHECK: cmpxchg ptr %addr, i32 %desired, i32 %new seq_cst seq_cst
77

88
cmpxchg volatile i32* %addr, i32 %desired, i32 %new seq_cst monotonic
9-
; CHECK: cmpxchg volatile i32* %addr, i32 %desired, i32 %new seq_cst monotonic
9+
; CHECK: cmpxchg volatile ptr %addr, i32 %desired, i32 %new seq_cst monotonic
1010

1111
cmpxchg weak i32* %addr, i32 %desired, i32 %new acq_rel acquire
12-
; CHECK: cmpxchg weak i32* %addr, i32 %desired, i32 %new acq_rel acquire
12+
; CHECK: cmpxchg weak ptr %addr, i32 %desired, i32 %new acq_rel acquire
1313

1414
cmpxchg weak volatile i32* %addr, i32 %desired, i32 %new syncscope("singlethread") release monotonic
15-
; CHECK: cmpxchg weak volatile i32* %addr, i32 %desired, i32 %new syncscope("singlethread") release monotonic
15+
; CHECK: cmpxchg weak volatile ptr %addr, i32 %desired, i32 %new syncscope("singlethread") release monotonic
1616

1717
ret void
1818
}

0 commit comments

Comments
 (0)