[llvm] [MergeFuncs] Don't introduce calls to {linkonce,weak}_odr functions. (PR #125050)
Steven Wu via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 31 12:48:54 PST 2025
================
@@ -891,8 +891,10 @@ bool MergeFunctions::writeThunkOrAlias(Function *F, Function *G) {
// Merge two equivalent functions. Upon completion, Function G is deleted.
void MergeFunctions::mergeTwoFunctions(Function *F, Function *G) {
- if (F->isInterposable()) {
- assert(G->isInterposable());
+ if (F->isInterposable() || G->hasWeakODRLinkage() ||
----------------
cachemeifyoucan wrote:
If I read correctly, this is going to happen with or without LTO, and having the prevailing symbol info doesn't help here. Creating the infinite loop is one thing, but having one call the other (if either of them is interposable) will break the runtime since providing a runtime replacement will cause either no replacement or replacing one function will cause replace both functions. In this case, you can only use the thunk to merge them.
So I think we just just check here:
```
if (F->isInterposable() || G->isInterposable())
```
https://github.com/llvm/llvm-project/pull/125050
More information about the llvm-commits
mailing list