[PATCH] D101264: [IR] Optimize mayBeDerefined for known interposable linkages. NFC

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 25 12:26:17 PDT 2021


MaskRay created this revision.
MaskRay added reviewers: dblaikie, serge-sans-paille.
Herald added a subscriber: dexonsmith.
MaskRay requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

For weak/linkonce/common/extern_weak (they are also interposable by default), just return true.
For internal/private/appending, there cannot be different copies, just return false.
Only for external, we need to call `isInterposable`: if it is dso_local, the
definition resolves to a symbol within the same linkage, and we can consider its
definition as exact; otherwise the definition is not exact.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101264

Files:
  llvm/include/llvm/IR/GlobalValue.h


Index: llvm/include/llvm/IR/GlobalValue.h
===================================================================
--- llvm/include/llvm/IR/GlobalValue.h
+++ llvm/include/llvm/IR/GlobalValue.h
@@ -127,19 +127,23 @@
   /// time.
   bool mayBeDerefined() const {
     switch (getLinkage()) {
-    case WeakODRLinkage:
-    case LinkOnceODRLinkage:
-    case AvailableExternallyLinkage:
-      return true;
-
     case WeakAnyLinkage:
     case LinkOnceAnyLinkage:
     case CommonLinkage:
     case ExternalWeakLinkage:
-    case ExternalLinkage:
-    case AppendingLinkage:
+
+    // The three cannot be overridden but can be de-refined.
+    case WeakODRLinkage:
+    case LinkOnceODRLinkage:
+    case AvailableExternallyLinkage:
+      return true;
+
     case InternalLinkage:
     case PrivateLinkage:
+    case AppendingLinkage:
+      return false;
+
+    case ExternalLinkage:
       return isInterposable();
     }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101264.340378.patch
Type: text/x-patch
Size: 920 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210425/688b0e0a/attachment.bin>


More information about the llvm-commits mailing list