[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
This commit is contained in:
Nikita Popov
2022-12-13 11:58:06 +01:00
parent d8f91f2c1d
commit e45cf47923
64 changed files with 1151 additions and 1176 deletions

View File

@@ -2359,8 +2359,6 @@ Error BitcodeReader::parseTypeTableBody() {
if (!ResultTy ||
!PointerType::isValidElementType(ResultTy))
return error("Invalid type");
if (LLVM_UNLIKELY(!Context.hasSetOpaquePointersValue()))
Context.setOpaquePointers(false);
ContainedIDs.push_back(Record[0]);
ResultTy = PointerType::get(ResultTy, AddressSpace);
break;
@@ -2368,9 +2366,7 @@ Error BitcodeReader::parseTypeTableBody() {
case bitc::TYPE_CODE_OPAQUE_POINTER: { // OPAQUE_POINTER: [addrspace]
if (Record.size() != 1)
return error("Invalid opaque pointer record");
if (LLVM_UNLIKELY(!Context.hasSetOpaquePointersValue())) {
Context.setOpaquePointers(true);
} else if (Context.supportsTypedPointers())
if (Context.supportsTypedPointers())
return error(
"Opaque pointers are only supported in -opaque-pointers mode");
unsigned AddressSpace = Record[0];