[clang] [llvm] [MIPS][ISel] Fix musttail (PR #161860)

Eli Friedman via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 23 11:18:45 PST 2026


================
@@ -1577,15 +1577,28 @@ void CodeGenModule::Release() {
     } else if (getTriple().isMIPS()) {
       for (auto &I : MustTailCallUndefinedGlobals) {
         const FunctionDecl *FD = I.first;
-        const FunctionDecl *Definition = FD->getDefinition();
-        if (!Definition) {
-          getDiags().Report(I.second, diag::err_mips_impossible_musttail) << 1;
+        StringRef MangledName = getMangledName(GlobalDecl(FD));
+        llvm::GlobalValue *Entry = GetGlobalValue(MangledName);
+
+        if (!Entry) {
+          Visibility Vis = FD->getVisibility();
+          if (Vis == DefaultVisibility)
+            getDiags().Report(I.second, diag::err_mips_impossible_musttail)
+                << 1;
           continue;
         }
-        llvm::GlobalValue::LinkageTypes Linkage =
-            getFunctionLinkage(GlobalDecl(Definition));
-        if (!llvm::GlobalValue::isLocalLinkage(Linkage) &&
-            Definition->isExternallyVisible())
+
+        bool CalleeIsLocal;
+        if (Entry->isDeclarationForLinker()) {
+          bool HasLocalLinkage = Entry->hasLocalLinkage();
----------------
efriedma-quic wrote:

How can a declaration have local linkage?  If you try to declare something with local linkage without defining it, that should independently be an error.

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


More information about the llvm-commits mailing list