Open llongint opened 10 months ago
Thank you for a report. How did you build the input binary? It appears that you might be using GCC with function splitting which is causing the issue – please try rebuilding with -fno-reorder-blocks-and-partition
.
In the meantime, please share either the test case or the repro for the binary, this will aid in addressing the issue.
I compiled it with clang, and the issue might be due to adding the option -mllvm -enable-split-machine-functions=true. However, I think we should fix this problem ?
I'm trying to reproduce the issue as follows, but currently, I don't know how to mark the function 'func' as 'no-simple'. I'll continue trying when I have time.
// cold.c
__attribute__((noinline))
int func_cold(int num) {
__asm__ __volatile__(
"nop\n"
"nop\n"
:::);
return (num - num / 2 + 1) * ( num + num / 7);
}
__attribute__((noinline))
int func(int argc) {
__asm__ __volatile__(
"nop\n"
"nop\n"
:::);
if(argc < 4)
return func_cold(argc +100);
return 0;
}
int main(int argc, char *argv[]) {
return func(argc);
}
gcc cold.c -S -g -O0 -Wl,-q -no-pie
sed -i "s#func_cold#func.cold#g" cold.s
gcc cold.s -g -Wl,-q -no-pie -O0
./build/bin/llvm-bolt a.out -o a.inst -instrument -instrumentation-file=a.fdata --instrumentation-wait-forks -instrumentation-sleep-time=2 -instrumentation-no-counters-clear --instrumentation-binpath=a.inst
./a.inst
sed -n "/func/p" -i a.fdata
sed "s/$/000/g" -i a.fdata
./build/bin/llvm-bolt a.out -o a.opt --data=a.fdata --update-debug-sections
I compiled it with clang, and the issue might be due to adding the option -mllvm -enable-split-machine-functions=true. However, I think we should fix this problem ?
LLVM MachineFunction splitting is equivalent to GCC freorder-blocks-and-partition
. BOLT performs function splitting with more precise profile, so we recommend to disable it in the compiler.
I can reproduce with the simple command below:
My binary is too large to upload :(