Proof-of-concept on how we may fix PIE indCall profile.
Here we create a getter for base address of .text and substract it's return value from recorded PC values. It converts them to static addresses, which then may be used to find the corresponding indirect call descriptions. The getter works by loading static address of __hot_end via leaq, then loading dynamic address via rip-relative leaq and returning the difference. I picked the end of text because it is the closest point of .text to the runtime library, which means it will almost certainly be within the reach of load instructions (important for future AArch64 support), and because __hot_end is easy to reuse.
Details
Diff Detail
Event Timeline
While this works on our server, i get the following error on my x86_64 laptop:
FAILED: CMakeFiles/bolt_rt_instr_osx.dir/instr.cpp.o /usr/bin/clang++ -I/home/denis/randomshit/build/tools/bolt/bolt_rt-bins -O3 -DNDEBUG -std=c++17 -target x86_64-apple-darwin19.6.0 -ffreestanding -fno-exceptions -fno-rtti -fno-stack-protector -mno-sse -fPIC -MD -MT CMakeFiles/bolt_rt_instr_osx.dir/instr.cpp.o -MF CMakeFiles/bolt_rt_instr_osx.dir/instr.cpp.o.d -o CMakeFiles/bolt_rt_instr_osx.dir/instr.cpp.o -c /home/denis/randomshit/llvm-project/bolt/runtime/instr.cpp In file included from /home/denis/randomshit/llvm-project/bolt/runtime/instr.cpp:44: /home/denis/randomshit/llvm-project/bolt/runtime/common.h:146:48: error: 32-bit absolute addressing is not supported in 64-bit mode __asm__ volatile("leaq __hot_end(%%rip), %0\n\t" ^ <inline asm>:2:2: note: instantiated into assembly here leaq __hot_end, %rcx ^
I don't get why it says 32-bit addressing when leaq is 64-bit instruction? Changing it to movq makes no difference, but it definetely has something to do with OSX which i know nothing about.
Turns out, the cause of the issue was getBaseAddress() being in the extern "C" block(it wasn't on the server). Although i still don't get why it had such effect. Also, sorry for all the edits - i just tried to make underscores work in the diff description, but apparently there is no way without backticks.
getBaseAddress -> getTextBaseAddress
Use movabsq to allow big addresses
Add a comment
Change test to no-pie to check if PIE is the issue. If the failure persists, it must be bash script.
Unfortunately i can't reproduce it locally so i have to poke it in random places.
Changing test to no-pie made no difference. Now i replace wait_file calls with sleeps and if it passes, the script is definitely the issue. Even though i have no idea why.
Okay, this is stupid: it seems debian in CI just lacks fuser command, or it's not in path. I couldn't see the error because of stderr redirection to /dev/null. Here i add more return code checks and we should get an error that fuser is not found. What should we do next?
- Use fuser -s instead of /dev/null redirection
- Fix wait_file.sh invoked with one extra argument
Thanks! I can start looking into this next week (and the week after it) during my shift.