llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

IPRA: Enabling IPRA fails on certain workload, it is either crash or wrong result.

Open vigbalu opened this issue 9 months ago • 1 comments

When IPRA is enabled, caller-saved registers are used across function calls without save/restore. The IPRA pass looks for the unused caller-saved registers in the callee before using them in the caller.

However, for PLT calls, the register usage in the PLT stubs and the resolver function is not accounted for. This can lead to registers being overwritten during the resolver call, causing the original values of unsaved caller-saved registers to be lost.

Commands to reproduce the issue: clang++ -O1 -Wl,-mllvm -Wl,-enable-ipra=true -flto -fPIC -shared -o libd.so derivedlib.cc -fuse-ld=lld clang++ -O1 -Wl,-mllvm -Wl,-enable-ipra=true -flto -ld -L. main.c -fuse-ld=lld

RET VALUE = -2058063447(or something else) with IPRA whereas without IPRA "RET VALUE = 15107"

derivedlib.cpp main.cpp

vigbalu avatar Mar 02 '26 11:03 vigbalu

I have started working on it.

vigbalu avatar Mar 02 '26 11:03 vigbalu