llvm / llvm/llvm-project

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

Open
#184,098 1 comment 0 reactions 1 assignee Claimed by @vigbalu View on GitHub
llvm:optimizations
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

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](https://github.com/user-attachments/files/25682115/derivedlib.cpp)
[main.cpp](https://github.com/user-attachments/files/25682114/main.cpp)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.