[llvm] [llvm-gsymutil] Fix dumping of call sites for merged functions (PR #119759)

Ellis Hoag via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 13 11:46:47 PST 2024


================
@@ -0,0 +1,1525 @@
+## Test that reconstructs a dSYM file from YAML and generates a gsym from it. The gsym has callsite info and merged functions.
+
+# RUN: split-file %s %t
+# RUN: yaml2obj %t/merged_callsites.dSYM.yaml -o %t/merged_callsites.dSYM
+
+# RUN: llvm-gsymutil --convert=%t/merged_callsites.dSYM --merged-functions --callsites-yaml-file=%t/callsites.yaml -o %t/call_sites_dSYM.gsym
+
+# Dump the GSYM file and check the output for callsite information
+# RUN: llvm-gsymutil %t/call_sites_dSYM.gsym | FileCheck --check-prefix=CHECK-MERGED-CALLSITES %s
+
+# CHECK-MERGED-CALLSITES:      FunctionInfo @ 0x[[#%x,FUNC4_1:]]: [0x[[#%x,FUNC4_1_START:]] - 0x[[#%x,FUNC4_1_END:]]) "function4_copy1"
+# CHECK-MERGED-CALLSITES:      ++ Merged FunctionInfos[0]:
+# CHECK-MERGED-CALLSITES-NEXT:     [0x[[#%x,FUNC4_2_START:]] - 0x[[#%x,FUNC4_2_END:]]) "function4_copy2"
+ 
+# CHECK-MERGED-CALLSITES:      FunctionInfo @ 0x[[#%x,FUNC3_1:]]: [0x[[#%x,FUNC3_1_START:]] - 0x[[#%x,FUNC3_1_END:]]) "function3_copy1"
+# CHECK-MERGED-CALLSITES:      CallSites (by relative return offset):
+# CHECK-MERGED-CALLSITES-NEXT:   0x[[#%.4x,]] Flags[None] MatchRegex[function4_copy1]
+# CHECK-MERGED-CALLSITES:      ++ Merged FunctionInfos[0]:
+# CHECK-MERGED-CALLSITES-NEXT:     [0x[[#%x,FUNC3_2_START:]] - 0x[[#%x,FUNC3_2_END:]]) "function3_copy2"
+# CHECK-MERGED-CALLSITES:          CallSites (by relative return offset):
+# CHECK-MERGED-CALLSITES-NEXT:       0x[[#%.4x,]] Flags[None] MatchRegex[function4_copy2]
+ 
+# CHECK-MERGED-CALLSITES:      FunctionInfo @ 0x[[#%x,FUNC2_1:]]: [0x[[#%x,FUNC2_1_START:]] - 0x[[#%x,FUNC2_1_END:]]) "function2_copy1"
+# CHECK-MERGED-CALLSITES:      CallSites (by relative return offset):
+# CHECK-MERGED-CALLSITES-NEXT:   0x[[#%.4x,]] Flags[None] MatchRegex[function3_copy1]
+# CHECK-MERGED-CALLSITES:      ++ Merged FunctionInfos[0]:
+# CHECK-MERGED-CALLSITES-NEXT:     [0x[[#%x,FUNC2_2_START:]] - 0x[[#%x,FUNC2_2_END:]]) "function2_copy2"
+# CHECK-MERGED-CALLSITES:          CallSites (by relative return offset):
+# CHECK-MERGED-CALLSITES-NEXT:       0x[[#%.4x,]] Flags[None] MatchRegex[function3_copy1]
+ 
+# CHECK-MERGED-CALLSITES:      FunctionInfo @ 0x[[#%x,FUNC1:]]: [0x[[#%x,FUNC1_START:]] - 0x[[#%x,FUNC1_END:]]) "function1"
+# CHECK-MERGED-CALLSITES:      CallSites (by relative return offset):
+# CHECK-MERGED-CALLSITES-NEXT:   0x[[#%.4x,]] Flags[None] MatchRegex[function2_copy1]
+ 
+# CHECK-MERGED-CALLSITES:      FunctionInfo @ 0x[[#%x,MAIN:]]: [0x[[#%x,MAIN_START:]] - 0x[[#%x,MAIN_END:]]) "main"
+# CHECK-MERGED-CALLSITES:      CallSites (by relative return offset):
+# CHECK-MERGED-CALLSITES-NEXT:   0x[[#%.4x,]] Flags[None] MatchRegex[function1]
+# CHECK-MERGED-CALLSITES-NEXT:   0x[[#%.4x,]] Flags[None] MatchRegex[function2_copy2]
+# CHECK-MERGED-CALLSITES-NEXT:   0x[[#%.4x,]] Flags[None] MatchRegex[function4_copy2]
+# CHECK-MERGED-CALLSITES-NEXT:   0x[[#%.4x,]] Flags[None] MatchRegex[function3_copy2]
+# CHECK-MERGED-CALLSITES-NEXT:   0x[[#%.4x,]] Flags[None] MatchRegex[function2_copy1]
+
+
+#--- repro-script.sh
+#!/bin/bash
+set -ex
+
+# Set TOOLCHAIN_DIR to point to the llvm bin directory
+TOOLCHAIN_DIR="llvm-project/build/Debug/bin"  # Replace with the actual path to your LLVM bin directory
+SCRIPT_DIR="$(cd "$(dirname "$0")"; pwd)"
+OUT_DIR="$SCRIPT_DIR/out"
+cd $SCRIPT_DIR
+rm -rf "$OUT_DIR" && mkdir -p "$OUT_DIR"
----------------
ellishg wrote:

We recently have a framework, [`llvm/utils/update_test_body.py`](https://llvm.org/docs/TestingGuide.html#elaborated-tests), to autogenerate test bodies that can do what this script is doing.



https://github.com/llvm/llvm-project/pull/119759


More information about the llvm-commits mailing list