]> granicus.if.org Git - llvm/commitdiff
[Attributor] Use local linkage instead of internal
authorJohannes Doerfert <jdoerfert@anl.gov>
Mon, 7 Oct 2019 23:21:52 +0000 (23:21 +0000)
committerJohannes Doerfert <jdoerfert@anl.gov>
Mon, 7 Oct 2019 23:21:52 +0000 (23:21 +0000)
Local linkage is internal or private, and private is a specialization of
internal, so either is fine for all our "local linkage" queries.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373986 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Transforms/IPO/Attributor.h
lib/Transforms/IPO/Attributor.cpp
test/Transforms/FunctionAttrs/internal-noalias.ll

index 1811c233ebd9a8087dfd03ec548d036217cc6161..be41f82d7d0f9d355bec918d04582dcd3a538987 100644 (file)
@@ -810,8 +810,8 @@ struct Attributor {
   /// This will trigger the identification and initialization of attributes for
   /// \p F.
   void markLiveInternalFunction(const Function &F) {
-    assert(F.hasInternalLinkage() &&
-           "Only internal linkage is assumed dead initially.");
+    assert(F.hasLocalLinkage() &&
+           "Only local linkage is assumed dead initially.");
 
     identifyDefaultAbstractAttributes(const_cast<Function &>(F));
   }
index 6c389f33f732c9ab7177c2693baba481761c744c..0bd454d88658d5ff12946b1a139ae88ab288a5a6 100644 (file)
@@ -2081,7 +2081,7 @@ struct AAIsDeadImpl : public AAIsDead {
     for (const Instruction &I : BB)
       if (ImmutableCallSite ICS = ImmutableCallSite(&I))
         if (const Function *F = ICS.getCalledFunction())
-          if (F->hasInternalLinkage())
+          if (F->hasLocalLinkage())
             A.markLiveInternalFunction(*F);
   }
 
@@ -3933,7 +3933,7 @@ bool Attributor::checkForAllCallSites(
   if (!AssociatedFunction)
     return false;
 
-  if (RequireAllCallSites && !AssociatedFunction->hasInternalLinkage()) {
+  if (RequireAllCallSites && !AssociatedFunction->hasLocalLinkage()) {
     LLVM_DEBUG(
         dbgs()
         << "[Attributor] Function " << AssociatedFunction->getName()
@@ -4319,7 +4319,7 @@ ChangeStatus Attributor::run(Module &M) {
     // below fixpoint loop will identify and eliminate them.
     SmallVector<Function *, 8> InternalFns;
     for (Function &F : M)
-      if (F.hasInternalLinkage())
+      if (F.hasLocalLinkage())
         InternalFns.push_back(&F);
 
     bool FoundDeadFn = true;
@@ -4634,7 +4634,7 @@ static bool runAttributorOnModule(Module &M, AnalysisGetter &AG) {
 
     // We look at internal functions only on-demand but if any use is not a
     // direct call, we have to do it eagerly.
-    if (F.hasInternalLinkage()) {
+    if (F.hasLocalLinkage()) {
       if (llvm::all_of(F.uses(), [](const Use &U) {
             return ImmutableCallSite(U.getUser()) &&
                    ImmutableCallSite(U.getUser()).isCallee(&U);
index cc207031015fc28b34ed353b2aab984734e2f70c..9eec60b5e1e69d74f85cc6844887ab87213859b4 100644 (file)
@@ -8,9 +8,9 @@ entry:
   ret i32 %add
 }
 
-; CHECK: define internal i32 @noalias_args(i32* nocapture readonly %A, i32* noalias nocapture readonly %B)
+; CHECK: define private i32 @noalias_args(i32* nocapture readonly %A, i32* noalias nocapture readonly %B)
 
-define internal i32 @noalias_args(i32* %A, i32* %B) #0 {
+define private i32 @noalias_args(i32* %A, i32* %B) #0 {
 entry:
   %0 = load i32, i32* %A, align 4
   %1 = load i32, i32* %B, align 4