[llvm-branch-commits] [llvm] [llvm-dis] Add --opaque-pointers option to control whether to output typed or opaque pointers (PR #153011)

Karol Zwolak via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Aug 11 07:19:07 PDT 2025


https://github.com/karolzwolak created https://github.com/llvm/llvm-project/pull/153011

This adds a flag to explicitly control whether to disassemble with the typed or opaque pointers syntax. Without this patch even bytecode with typed pointers outputs IR with opaque pointers. This option is enabled by default, preserving the previous behavior if not specified. This is only relevant up to LLVM 16, as later versions don't support typed pointers at all.

>From 1886cd7f8c9264797682087c371828f8c825040f Mon Sep 17 00:00:00 2001
From: "Zwolak, Karol Marcin" <karol.marcin.zwolak at intel.com>
Date: Mon, 11 Aug 2025 15:42:45 +0200
Subject: [PATCH] [llvm-dis] Add --opaque-pointers option to control whether to
 output typed or opaque pointers

This adds a flag to explicitly control whether to disassemble with the typed or
opaque pointers syntax. Without this patch even bytecode with typed
pointers outputs IR with opaque pointers. This option is enabled by
default, preserving the previous behavior if not specified.
This is only relevant up to LLVM 16, as later versions don't support
typed pointers at all.
---
 llvm/tools/llvm-dis/llvm-dis.cpp | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/llvm/tools/llvm-dis/llvm-dis.cpp b/llvm/tools/llvm-dis/llvm-dis.cpp
index 4996fc12ae32a..1c7ad49a9e6a5 100644
--- a/llvm/tools/llvm-dis/llvm-dis.cpp
+++ b/llvm/tools/llvm-dis/llvm-dis.cpp
@@ -80,6 +80,10 @@ static cl::opt<bool> PrintThinLTOIndexOnly(
     cl::desc("Only read thinlto index and print the index as LLVM assembly."),
     cl::init(false), cl::Hidden, cl::cat(DisCategory));
 
+static cl::opt<bool> OpaquePointers("opaque-pointers",
+                                    cl::desc("Use opaque pointers"),
+                                    cl::init(true), cl::cat(DisCategory));
+
 namespace {
 
 static void printDebugLoc(const DebugLoc &DL, formatted_raw_ostream &OS) {
@@ -168,6 +172,7 @@ int main(int argc, char **argv) {
   cl::ParseCommandLineOptions(argc, argv, "llvm .bc -> .ll disassembler\n");
 
   LLVMContext Context;
+  Context.setOpaquePointers(OpaquePointers);
   Context.setDiagnosticHandler(
       std::make_unique<LLVMDisDiagnosticHandler>(argv[0]));
 



More information about the llvm-branch-commits mailing list