[llvm] 46216aa - [OpaquePointers][BitcodeReader] Enable -opaque-pointers if we see an opaque pointer type
Arthur Eubanks via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 21 09:19:33 PDT 2022
Author: Arthur Eubanks
Date: 2022-03-21T09:19:26-07:00
New Revision: 46216aa97729aa994dce79e75cd25707fb4b7874
URL: https://github.com/llvm/llvm-project/commit/46216aa97729aa994dce79e75cd25707fb4b7874
DIFF: https://github.com/llvm/llvm-project/commit/46216aa97729aa994dce79e75cd25707fb4b7874.diff
LOG: [OpaquePointers][BitcodeReader] Enable -opaque-pointers if we see an opaque pointer type
This allows us to more easily test opaque pointers e.g. in the case of
ThinLTO where we only have to pass -opaque-pointers to the frontend.
Reviewed By: #opaque-pointers, nikic
Differential Revision: https://reviews.llvm.org/D122048
Added:
Modified:
llvm/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/test/Other/force-opaque-ptrs.ll
Removed:
################################################################################
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index afe18c556cdaa..034fa5832ba84 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -1883,7 +1883,9 @@ Error BitcodeReader::parseTypeTableBody() {
case bitc::TYPE_CODE_OPAQUE_POINTER: { // OPAQUE_POINTER: [addrspace]
if (Record.size() != 1)
return error("Invalid opaque pointer record");
- if (Context.supportsTypedPointers())
+ if (LLVM_UNLIKELY(!Context.hasSetOpaquePointersValue())) {
+ Context.enableOpaquePointers();
+ } else if (Context.supportsTypedPointers())
return error(
"Opaque pointers are only supported in -opaque-pointers mode");
unsigned AddressSpace = Record[0];
diff --git a/llvm/test/Other/force-opaque-ptrs.ll b/llvm/test/Other/force-opaque-ptrs.ll
index d963c7072e207..4f33169b56da3 100644
--- a/llvm/test/Other/force-opaque-ptrs.ll
+++ b/llvm/test/Other/force-opaque-ptrs.ll
@@ -1,6 +1,7 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature
; RUN: llvm-as --opaque-pointers < %s | llvm-dis --opaque-pointers | FileCheck %s
; RUN: llvm-as < %s | llvm-dis --opaque-pointers | FileCheck %s
+; RUN: llvm-as --opaque-pointers < %s | llvm-dis | FileCheck %s
; RUN: opt --opaque-pointers < %s -S | FileCheck %s
; RUN: verify-uselistorder --opaque-pointers < %s
More information about the llvm-commits
mailing list