[llvm] [IR] `replaceUsesWith` when aliasing a GV and the use is `dso_local_equivalent` (PR #220336)

Teresa Johnson via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 1 13:53:31 PDT 2026


================
@@ -2130,34 +2130,25 @@ Value *DSOLocalEquivalent::handleOperandChangeImpl(Value *From, Value *To) {
   assert(From == getGlobalValue() && "Changing value does not match operand.");
   assert(isa<Constant>(To) && "Can only replace the operands with a constant");
 
-  // The replacement is with another global value.
-  if (const auto *ToObj = dyn_cast<GlobalValue>(To)) {
-    if (DSOLocalEquivalent *NewEquiv =
-            getContext().pImpl->DSOLocalEquivalents.lookup(ToObj))
-      return llvm::ConstantExpr::getBitCast(NewEquiv, getType());
-  }
-
   // If the argument is replaced with a null value, just replace this constant
   // with a null value.
   if (isa<ConstantPointerNull>(To))
     return To;
 
-  // The replacement could be a bitcast or an alias to another function. We can
-  // replace it with a bitcast to the dso_local_equivalent of that function.
-  auto *Func = cast<Function>(To->stripPointerCastsAndAliases());
+  GlobalValue *GV = cast<GlobalValue>(To->stripPointerCasts());
----------------
teresajohnson wrote:

Also maybe restore a modified version of the original comment that was removed?

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


More information about the llvm-commits mailing list