@@ -38,7 +38,7 @@ static cl::opt<unsigned> GlobalMergingMaxParams(
3838 cl::init(std::numeric_limits<unsigned >::max()), cl::Hidden);
3939static cl::opt<bool > GlobalMergingSkipNoParams (
4040 " global-merging-skip-no-params" ,
41- cl::desc (" Skip merging functions with no parameters." ), cl::init(false ),
41+ cl::desc (" Skip merging functions with no parameters." ), cl::init(true ),
4242 cl::Hidden);
4343static cl::opt<double > GlobalMergingInstOverhead (
4444 " global-merging-inst-overhead" ,
@@ -181,6 +181,11 @@ static bool isProfitable(
181181 unsigned ParamCount = UniqueHashVals.size ();
182182 if (ParamCount > GlobalMergingMaxParams)
183183 return false ;
184+ // Theoretically, if ParamCount is 0, it results in identical code folding
185+ // (ICF), which we can skip merging here since the linker already handles
186+ // ICF. This pass would otherwise introduce unnecessary thunks that are
187+ // merely direct jumps. However, enabling this could be beneficial depending
188+ // on downstream passes, so we provide an option for it.
184189 if (GlobalMergingSkipNoParams && ParamCount == 0 )
185190 return false ;
186191 Cost += ParamCount * GlobalMergingParamOverhead + GlobalMergingCallOverhead;
0 commit comments