llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
27.84k stars 11.47k forks source link

[llvm-bolt] `--runtime-instrumentation-lib` option can't correctly specify the path of instrumentation library #99772

Open lltsdyp opened 1 month ago

lltsdyp commented 1 month ago
$>llvm-bolt ./a.out -instrument -o a.tmp --runtime-instrumentation-lib=$HOME/bin/bolt/lib~/bolt-lib/libbolt_rt_instr.a
BOLT-INFO: Target architecture: aarch64
BOLT-INFO: BOLT version: e6c3289804a67ea0bb6a86fadbe454dd93b8d855
BOLT-INFO: first alloc address is 0x400000
BOLT-INFO: creating new program header table at address 0x600000, offset 0x200000
BOLT-INFO: enabling relocation mode
BOLT-INFO: forcing -jump-tables=move for instrumentation
BOLT-INFO: disabling -align-macro-fusion on non-x86 platform
BOLT-INFO: number of removed linker-inserted veneers: 0
BOLT-INFO: 0 out of 12 functions in the binary (0.0%) have non-empty execution profile
BOLT-INSTRUMENTER: Number of indirect call site descriptors: 1
BOLT-INSTRUMENTER: Number of indirect call target descriptors: 10
BOLT-INSTRUMENTER: Number of function descriptors: 9
BOLT-INSTRUMENTER: Number of branch counters: 3
BOLT-INSTRUMENTER: Number of ST leaf node counters: 11
BOLT-INSTRUMENTER: Number of direct call counters: 0
BOLT-INSTRUMENTER: Total number of counters: 14
BOLT-INSTRUMENTER: Total size of counters: 112 bytes (static alloc memory)
BOLT-INSTRUMENTER: Total size of string table emitted: 215 bytes in file
BOLT-INSTRUMENTER: Total size of descriptors: 1128 bytes in file
BOLT-INSTRUMENTER: Profile will be saved to file /tmp/prof.fdata
BOLT-INFO: Starting stub-insertion pass
BOLT-INFO: Inserted 0 stubs in the hot area and 0 stubs in the cold area. Shared 0 times, iterated 1 times.
BOLT-INFO: padding code to 0xa00000 to accommodate hot text
BOLT-ERROR: library not found: /home/lib~/bolt-lib/$HOME/bin/bolt/lib~/bolt-lib/libbolt_rt_instr.a

As you can see, I want llvm-bolt to use instrumentation library: $HOME/bin/bolt/lib~/bolt-lib/libbolt_rt_instr.a but it searched for /home/lib~/bolt-lib/$HOME/bin/bolt/lib~/bolt-lib/libbolt_rt_instr.a and failed.

I think there must be something wrong when processing command line options?

yota9 commented 1 month ago

Do you really have "lib~" directory? Try to pass "$HOME/bin/bolt/lib\~/bolt-lib/libbolt_rt_instr.a" (with \~)

lltsdyp commented 1 month ago

Do you really have "lib~" directory? Try to pass "$HOME/bin/bolt/lib~/bolt-lib/libbolt_rt_instr.a" (with ~)

Well, I think this option handles a full path in a wrong way: it simply append the value to a specific path. So I opened a pull request to help the option handle full paths correctly. And here is my PR https://github.com/llvm/llvm-project/issues/99772

lltsdyp commented 1 month ago

Oops, I paste a wrong URL. I apologize (lol) https://github.com/llvm/llvm-project/pull/99806