[PATCH] D125751: [llvm-nm] Always use opaque pointers (PR55506)

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 18 00:46:27 PDT 2022


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc4c01e4e4e38: [llvm-nm] Always use opaque pointers (PR55506) (authored by nikic).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D125751/new/

https://reviews.llvm.org/D125751

Files:
  llvm/test/tools/llvm-nm/opaque-pointers.ll
  llvm/tools/llvm-nm/llvm-nm.cpp


Index: llvm/tools/llvm-nm/llvm-nm.cpp
===================================================================
--- llvm/tools/llvm-nm/llvm-nm.cpp
+++ llvm/tools/llvm-nm/llvm-nm.cpp
@@ -2254,7 +2254,11 @@
   if (error(BufferOrErr.getError(), Filename))
     return SymbolList;
 
+  // Always enable opaque pointers, to handle archives with mixed typed and
+  // opaque pointer bitcode files gracefully. As we're only reading symbols,
+  // the used pointer types don't matter.
   LLVMContext Context;
+  Context.setOpaquePointers(true);
   LLVMContext *ContextPtr = NoLLVMBitcode ? nullptr : &Context;
   Expected<std::unique_ptr<Binary>> BinaryOrErr =
       createBinary(BufferOrErr.get()->getMemBufferRef(), ContextPtr);
Index: llvm/test/tools/llvm-nm/opaque-pointers.ll
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-nm/opaque-pointers.ll
@@ -0,0 +1,13 @@
+; RUN: llvm-as -opaque-pointers=0 < %s > %t.typed.bc
+; RUN: llvm-as -opaque-pointers=1 < %s > %t.opaque.bc
+; RUN: llvm-ar cr %t.a %t.typed.bc %t.opaque.bc
+; RUN: llvm-nm --just-symbol-name %t.a | FileCheck %s
+
+; CHECK-LABEL: typed.bc:
+; CHECK: test
+; CHECK-LABEL: opaque.bc:
+; CHECK: test
+
+define void @test() {
+  ret void
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125751.430259.patch
Type: text/x-patch
Size: 1252 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220518/744cd1b8/attachment.bin>


More information about the llvm-commits mailing list