[llvm] r268317 - Revert "ThinLTO: do not import function whose linkage prevents inlining."

Mehdi Amini via llvm-commits llvm-commits at lists.llvm.org
Mon May 2 15:26:04 PDT 2016


Author: mehdi_amini
Date: Mon May  2 17:26:04 2016
New Revision: 268317

URL: http://llvm.org/viewvc/llvm-project?rev=268317&view=rev
Log:
Revert "ThinLTO: do not import function whose linkage prevents inlining."

This reverts commit r268315, the tests are not passing.

From: Mehdi Amini <mehdi.amini at apple.com>

Modified:
    llvm/trunk/include/llvm/IR/GlobalValue.h
    llvm/trunk/lib/Transforms/IPO/FunctionImport.cpp
    llvm/trunk/test/Transforms/FunctionImport/Inputs/funcimport.ll
    llvm/trunk/test/Transforms/FunctionImport/funcimport.ll

Modified: llvm/trunk/include/llvm/IR/GlobalValue.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/GlobalValue.h?rev=268317&r1=268316&r2=268317&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/GlobalValue.h (original)
+++ llvm/trunk/include/llvm/IR/GlobalValue.h Mon May  2 17:26:04 2016
@@ -124,7 +124,26 @@ private:
   /// non-equivalent at link time. For example, if a function has weak linkage
   /// then the code defining it may be replaced by different code.
   bool mayBeOverridden() const {
-    return isMayBeOverriddenLinkage(getLinkage());
+    switch (getLinkage()) {
+    case WeakAnyLinkage:
+    case LinkOnceAnyLinkage:
+    case CommonLinkage:
+    case ExternalWeakLinkage:
+      return true;
+
+    case AvailableExternallyLinkage:
+    case LinkOnceODRLinkage:
+    case WeakODRLinkage:
+      // The above three cannot be overridden but can be de-refined.
+
+    case ExternalLinkage:
+    case AppendingLinkage:
+    case InternalLinkage:
+    case PrivateLinkage:
+      return false;
+    }
+
+    llvm_unreachable("Fully covered switch above!");
   }
 
 protected:
@@ -266,31 +285,6 @@ public:
     return Linkage == CommonLinkage;
   }
 
-  /// Whether the definition of this global may be replaced by something
-  /// non-equivalent at link time. For example, if a function has weak linkage
-  /// then the code defining it may be replaced by different code.
-  static bool isMayBeOverriddenLinkage(LinkageTypes Linkage) {
-    switch (Linkage) {
-    case WeakAnyLinkage:
-    case LinkOnceAnyLinkage:
-    case CommonLinkage:
-    case ExternalWeakLinkage:
-      return true;
-
-    case AvailableExternallyLinkage:
-    case LinkOnceODRLinkage:
-    case WeakODRLinkage:
-    // The above three cannot be overridden but can be de-refined.
-
-    case ExternalLinkage:
-    case AppendingLinkage:
-    case InternalLinkage:
-    case PrivateLinkage:
-      return false;
-    }
-    llvm_unreachable("Fully covered switch above!");
-  }
-
   /// Whether the definition of this global may be discarded if it is not used
   /// in its compilation unit.
   static bool isDiscardableIfUnused(LinkageTypes Linkage) {

Modified: llvm/trunk/lib/Transforms/IPO/FunctionImport.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/FunctionImport.cpp?rev=268317&r1=268316&r2=268317&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/FunctionImport.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/FunctionImport.cpp Mon May  2 17:26:04 2016
@@ -156,8 +156,8 @@ selectCallee(const ModuleSummaryIndex &I
       CalleeSummaryList,
       [&](const std::unique_ptr<GlobalValueSummary> &SummaryPtr) {
         auto *GVSummary = SummaryPtr.get();
-        if (GlobalValue::isMayBeOverriddenLinkage(GVSummary->linkage()))
-          // There is no point in importing these, we can't inline them
+        if (GlobalValue::isWeakAnyLinkage(GVSummary->linkage()))
+          // There is no point in importing weak symbols, we can't inline them
           return false;
         if (auto *AS = dyn_cast<AliasSummary>(GVSummary)) {
           GVSummary = &AS->getAliasee();

Modified: llvm/trunk/test/Transforms/FunctionImport/Inputs/funcimport.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/FunctionImport/Inputs/funcimport.ll?rev=268317&r1=268316&r2=268317&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/FunctionImport/Inputs/funcimport.ll (original)
+++ llvm/trunk/test/Transforms/FunctionImport/Inputs/funcimport.ll Mon May  2 17:26:04 2016
@@ -75,11 +75,6 @@ entry:
   ret void
 }
 
-define linkonce void @linkoncefunc2() #0 {
-entry:
-  ret void
-}
-
 define internal i32 @staticfunc() #0 {
 entry:
   ret i32 1

Modified: llvm/trunk/test/Transforms/FunctionImport/funcimport.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/FunctionImport/funcimport.ll?rev=268317&r1=268316&r2=268317&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/FunctionImport/funcimport.ll (original)
+++ llvm/trunk/test/Transforms/FunctionImport/funcimport.ll Mon May  2 17:26:04 2016
@@ -28,7 +28,6 @@ entry:
   call void (...) @setfuncptr()
   call void (...) @callfuncptr()
   call void (...) @weakfunc()
-  call void (...) @linkoncefunc2()
   call void (...) @referencelargelinkonce()
   ret i32 0
 }
@@ -95,10 +94,6 @@ declare void @referencelargelinkonce(...
 ; CHECK-DAG: declare void @weakfunc(...)
 declare void @weakfunc(...) #1
 
-; Won't import linkonce func
-; CHECK-DAG: declare void @linkoncefunc2(...)
-declare void @linkoncefunc2(...) #1
-
 ; INSTLIMDEF-DAG: Import funcwithpersonality
 ; INSTLIMDEF-DAG: define available_externally hidden void @funcwithpersonality.llvm.{{.*}}() personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
 ; INSTLIM5-DAG: declare hidden void @funcwithpersonality.llvm.{{.*}}()




More information about the llvm-commits mailing list