[llvm] [WIP][GlobalOpt] Don't replace aliasee with alias that has weak linkage (PR #91483)

via llvm-commits llvm-commits at lists.llvm.org
Wed May 8 07:59:50 PDT 2024


https://github.com/DianQK created https://github.com/llvm/llvm-project/pull/91483

Fixes #91312.

>From 8af3cc9e33eacb1b70590dfb75660ec9a7c157fd Mon Sep 17 00:00:00 2001
From: DianQK <dianqk at dianqk.net>
Date: Wed, 8 May 2024 22:33:05 +0800
Subject: [PATCH] [GlobalOpt] Don't replace aliasee with alias that has weak
 linkage

---
 llvm/lib/Transforms/IPO/GlobalOpt.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/llvm/lib/Transforms/IPO/GlobalOpt.cpp b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
index c8c835115a992..b7c6d25657bc0 100644
--- a/llvm/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
@@ -2224,6 +2224,9 @@ static bool mayHaveOtherReferences(GlobalValue &GV, const LLVMUsed &U) {
 
 static bool hasUsesToReplace(GlobalAlias &GA, const LLVMUsed &U,
                              bool &RenameTarget) {
+  if (GA.isWeakForLinker())
+    return false;
+
   RenameTarget = false;
   bool Ret = false;
   if (hasUseOtherThanLLVMUsed(GA, U))



More information about the llvm-commits mailing list