[llvm] [CGData] Global Merge Functions (PR #112671)
Zhaoxuan Jiang via llvm-commits
llvm-commits at lists.llvm.org
Sun Nov 17 01:25:40 PST 2024
================
@@ -117,7 +149,38 @@ static void removeIdenticalIndexPair(
SF->IndexOperandHashMap->erase(Pair);
}
-void StableFunctionMap::finalize() {
+static bool isProfitable(
+ const SmallVector<std::unique_ptr<StableFunctionMap::StableFunctionEntry>>
+ &SFS) {
+ unsigned StableFunctionCount = SFS.size();
+ if (StableFunctionCount < GlobalMergingMinMerges)
+ return false;
+
+ unsigned InstCount = SFS[0]->InstCount;
+ if (InstCount < GlobalMergingMinInstrs)
+ return false;
+
+ unsigned ParamCount = SFS[0]->IndexOperandHashMap->size();
+ if (ParamCount > GlobalMergingMaxParams)
+ return false;
+
+ unsigned Benefit = InstCount * (StableFunctionCount - 1);
+ unsigned Cost =
+ (GlobalMergingParamOverhead * ParamCount + GlobalMergingCallOverhead) *
----------------
nocchijiang wrote:
Also FYI the implementation that comes with this PR is not passing all the existing Swift repo tests despite lowering `GlobalMergingParamOverhead` to `0` to force merges to happen.
https://github.com/llvm/llvm-project/pull/112671
More information about the llvm-commits
mailing list