aboutsummaryrefslogtreecommitdiff
path: root/llvm/utils/UpdateTestChecks/common.py
diff options
context:
space:
mode:
authorMomchil Velikov <momchil.velikov@arm.com>2025-01-13 11:24:05 +0000
committerGitHub <noreply@github.com>2025-01-13 11:24:05 +0000
commit5315f3f8cb8f562ec39f57f2fce79c8e017595f9 (patch)
tree5b2d99ab214d4129456368879c5dd77c9601d4c0 /llvm/utils/UpdateTestChecks/common.py
parent795e35a653b977bf637d1d049423adc8a63cd20d (diff)
downloadllvm-5315f3f8cb8f562ec39f57f2fce79c8e017595f9.zip
llvm-5315f3f8cb8f562ec39f57f2fce79c8e017595f9.tar.gz
llvm-5315f3f8cb8f562ec39f57f2fce79c8e017595f9.tar.bz2
Handle leading underscores in update_cc_test_checks.py (#121800)
For some ABIs `update_cc_test_checks.py` is unable to generate tests because of the mismatch between the mangled function names reported by clang's `-asd-dump` and the function names in LLVM IR. This patch fixes it by striping the leading underscore from the mangled name for global functions if the data layout string says they have one.
Diffstat (limited to 'llvm/utils/UpdateTestChecks/common.py')
-rw-r--r--llvm/utils/UpdateTestChecks/common.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/llvm/utils/UpdateTestChecks/common.py b/llvm/utils/UpdateTestChecks/common.py
index e1cc02e..1a875c2 100644
--- a/llvm/utils/UpdateTestChecks/common.py
+++ b/llvm/utils/UpdateTestChecks/common.py
@@ -557,6 +557,10 @@ UTC_ADVERT = "NOTE: Assertions have been autogenerated by "
UTC_AVOID = "NOTE: Do not autogenerate"
UNUSED_NOTE = "NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:"
+DATA_LAYOUT_RE = re.compile(
+ r"target\s+datalayout\s+=\s+\"(?P<layout>.+)\"$", flags=(re.M | re.S)
+)
+
OPT_FUNCTION_RE = re.compile(
r"^(\s*;\s*Function\sAttrs:\s(?P<attrs>[\w\s():,]+?))?\s*define\s+(?P<funcdef_attrs_and_ret>[^@]*)@(?P<func>[\w.$-]+?)\s*"
r"(?P<args_and_sig>\((\)|(.*?[\w.-]+?)\))[^{]*\{)\n(?P<body>.*?)^\}$",
@@ -651,6 +655,18 @@ def get_triple_from_march(march):
return "x86"
+def get_globals_name_prefix(raw_tool_output):
+ m = DATA_LAYOUT_RE.search(raw_tool_output)
+ if not m:
+ return None
+ data_layout = m.group("layout")
+ idx = data_layout.find("m:")
+ if idx < 0:
+ return None
+ ch = data_layout[idx + 2]
+ return "_" if ch == "o" or ch == "x" else None
+
+
def apply_filters(line, filters):
has_filter = False
for f in filters: