[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 13:41:07 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:

I see, it is rely on ODR to assume if the replacement happens, it is functionally equivalent so it is safe.

Maybe it is safer to replace all references of `isInterposable()` in this pass with the stricter definition here that includes ODR.

https://github.com/llvm/llvm-project/pull/125050


More information about the llvm-commits mailing list