[llvm] [llvm-jitlink] Make the -show-addrs option work without -check. (PR #175491)

Lang Hames via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 11 22:26:50 PST 2026


https://github.com/lhames created https://github.com/llvm/llvm-project/pull/175491

Ensures that the address scraping passes are added to the JIT linker pipeline if either of the -check or -show-addrs are passed. Prior to this commit we only considered -check, so passing -show-addrs on its own was printing an empty (unpopulated) symbol table.

>From 32c92843e96017c0526707bacc9cdaf094df4be7 Mon Sep 17 00:00:00 2001
From: Lang Hames <lhames at gmail.com>
Date: Mon, 12 Jan 2026 17:07:51 +1100
Subject: [PATCH] [llvm-jitlink] Make the -show-addrs option work without
 -check.

Ensures that the address scraping passes are added to the JIT linker pipeline
if either of the -check or -show-addrs are passed. Prior to this commit we only
considered -check, so passing -show-addrs on its own was printing an empty
(unpopulated) symbol table.
---
 .../Generic/llvm-jitlink-option-show-addrs.test    | 14 ++++++++++++++
 llvm/tools/llvm-jitlink/llvm-jitlink.cpp           |  2 +-
 2 files changed, 15 insertions(+), 1 deletion(-)
 create mode 100644 llvm/test/ExecutionEngine/JITLink/Generic/llvm-jitlink-option-show-addrs.test

diff --git a/llvm/test/ExecutionEngine/JITLink/Generic/llvm-jitlink-option-show-addrs.test b/llvm/test/ExecutionEngine/JITLink/Generic/llvm-jitlink-option-show-addrs.test
new file mode 100644
index 0000000000000..96635f57a09f9
--- /dev/null
+++ b/llvm/test/ExecutionEngine/JITLink/Generic/llvm-jitlink-option-show-addrs.test
@@ -0,0 +1,14 @@
+# RUN: llc -filetype=obj -o %t.o %S/Inputs/main-ret-0.ll
+# RUN: llvm-jitlink -noexec -show-addrs %t.o | FileCheck %s
+#
+# Check that the llvm-jitlink -show-addrs option reports an address for main.
+
+# Jitlink does not support ARM64 COFF files.
+# UNSUPPORTED: target=aarch64-{{.*}}-windows-{{.*}}
+
+# On MinGW targets, when compiling the main() function, it gets
+# an implicitly generated call to __main(), which is missing in
+# this context.
+# XFAIL: target={{.*}}-windows-gnu
+
+# CHECK: main{{.*}} target addr = 0x{{[[:xdigit:]]+}}, content:
\ No newline at end of file
diff --git a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
index 7732992f77cb3..3d3b030a0073f 100644
--- a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
+++ b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
@@ -1396,7 +1396,7 @@ void Session::modifyPassConfig(LinkGraph &G, PassConfiguration &PassConfig) {
   if (ShowLinkedFiles)
     outs() << "Linking " << G.getName() << "\n";
 
-  if (!CheckFiles.empty())
+  if (!CheckFiles.empty() || ShowAddrs)
     PassConfig.PostFixupPasses.push_back([this](LinkGraph &G) {
       if (ES.getTargetTriple().getObjectFormat() == Triple::ELF)
         return registerELFGraphInfo(*this, G);



More information about the llvm-commits mailing list