[llvm] [AIX]export function descriptor symbols related to template functions. (PR #101920)

Chen Zheng via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 5 19:02:19 PDT 2024


https://github.com/chenzheng1030 updated https://github.com/llvm/llvm-project/pull/101920

>From d879fb6a28b23171784d06846d4850beb583a655 Mon Sep 17 00:00:00 2001
From: Chen Zheng <czhengsz at cn.ibm.com>
Date: Sun, 4 Aug 2024 23:32:05 -0400
Subject: [PATCH 1/2] [AIX]export function descriptor symbols related to
 template funcionts.

---
 llvm/utils/extract_symbols.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/llvm/utils/extract_symbols.py b/llvm/utils/extract_symbols.py
index 10fdf14acd158..19a3066deec73 100755
--- a/llvm/utils/extract_symbols.py
+++ b/llvm/utils/extract_symbols.py
@@ -484,5 +484,9 @@ def parse_tool_path(parser, tool, val):
         outfile = sys.stdout
     for k, v in list(symbol_defs.items()):
         template = get_template_name(k, args.mangling)
+        # On AIX, "template" functions starting with "_" are actually function
+        # descriptors which are data symbols. Export these data symbols.
+        if template and platform.system() == "AIX" and k.startswith("_"):
+            template = None
         if v == 1 and (not template or template in template_instantiation_refs):
             print(k, file=outfile)

>From cfc464425015fa62d5b983ebf9571c282fdbc9c7 Mon Sep 17 00:00:00 2001
From: Chen Zheng <czhengsz at cn.ibm.com>
Date: Mon, 5 Aug 2024 21:57:53 -0400
Subject: [PATCH 2/2] address comments

---
 llvm/utils/extract_symbols.py | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/llvm/utils/extract_symbols.py b/llvm/utils/extract_symbols.py
index 19a3066deec73..7fb77f458c5ab 100755
--- a/llvm/utils/extract_symbols.py
+++ b/llvm/utils/extract_symbols.py
@@ -140,7 +140,7 @@ def should_keep_itanium_symbol(symbol, calling_convention_decoration):
     if not symbol.startswith("_") and not symbol.startswith("."):
         return symbol
     # Discard manglings that aren't nested names
-    match = re.match("_Z(T[VTIS])?(N.+)", symbol)
+    match = re.match("\.?_Z(T[VTIS])?(N.+)", symbol)
     if not match:
         return None
     # Demangle the name. If the name is too complex then we don't need to keep
@@ -323,7 +323,7 @@ def get_template_name(sym, mangling):
         if mangling == "microsoft":
             names = parse_microsoft_mangling(sym)
         else:
-            match = re.match("_Z(T[VTIS])?(N.+)", sym)
+            match = re.match("\.?_Z(T[VTIS])?(N.+)", sym)
             if match:
                 names, _ = parse_itanium_nested_name(match.group(2))
             else:
@@ -483,10 +483,9 @@ def parse_tool_path(parser, tool, val):
     else:
         outfile = sys.stdout
     for k, v in list(symbol_defs.items()):
+        # On AIX, export function descriptors instead of function entries.
+        if platform.system() == "AIX" and k.startswith("."):
+          continue
         template = get_template_name(k, args.mangling)
-        # On AIX, "template" functions starting with "_" are actually function
-        # descriptors which are data symbols. Export these data symbols.
-        if template and platform.system() == "AIX" and k.startswith("_"):
-            template = None
         if v == 1 and (not template or template in template_instantiation_refs):
             print(k, file=outfile)



More information about the llvm-commits mailing list