[NFC][StackSafety] Move out sort from the loop
authorVitaly Buka <vitalybuka@google.com>
Fri, 14 Aug 2020 11:17:08 +0000 (04:17 -0700)
committerVitaly Buka <vitalybuka@google.com>
Mon, 17 Aug 2020 10:30:14 +0000 (03:30 -0700)
llvm/lib/Analysis/StackSafetyAnalysis.cpp
llvm/test/Bitcode/thinlto-function-summary-paramaccess.ll

index 0a8a4cc..023a72d 100644 (file)
@@ -846,12 +846,14 @@ StackSafetyInfo::getParamAccesses(ModuleSummaryIndex &Index) const {
       Param.Calls.emplace_back(C.first.ParamNo,
                                Index.getOrInsertValueInfo(C.first.Callee),
                                C.second);
-      llvm::sort(Param.Calls, [](const FunctionSummary::ParamAccess::Call &L,
-                                 const FunctionSummary::ParamAccess::Call &R) {
-        return std::tie(L.ParamNo, L.Callee) < std::tie(R.ParamNo, R.Callee);
-      });
     }
   }
+  for (FunctionSummary::ParamAccess &Param : ParamAccesses) {
+    sort(Param.Calls, [](const FunctionSummary::ParamAccess::Call &L,
+                         const FunctionSummary::ParamAccess::Call &R) {
+      return std::tie(L.ParamNo, L.Callee) < std::tie(R.ParamNo, R.Callee);
+    });
+  }
   return ParamAccesses;
 }
 
index 3b53e73..8b6b0bb 100644 (file)
@@ -230,7 +230,7 @@ entry:
 }
 
 ; SSI-LABEL: for function 'CallMany2'
-; SSI: p[]: empty-set, @Callee(arg0, [-715,125))
+; SSI: p[]: empty-set, @Callee(arg0, [-715,125)), @Callee2(arg1, [-33,-32))
 ; BC-NEXT: <PARAM_ACCESS op0=0 op1=0 op2=0 op3=2 op4=0 op5=[[CALLEE]] op6=1431 op7=250 op8=1 op9=[[CALLEE2:-?[0-9]+]] op10=67 op11=65/>
 ; BC-NEXT: <PERMODULE
 ; DIS-DAG: = gv: (name: "CallMany2", summaries: {{.*}} calls: ((callee: ^{{.*}}), (callee: ^{{.*}})), params: ((param: 0, offset: [0, -1], calls: ((callee: ^{{.*}}, param: 0, offset: [-715, 124]), (callee: ^{{.*}}, param: 1, offset: [-33, -33]))))))) ; guid = 16654048340802466690