From a4aa97d57849113a7ccf60a156ee24b5da88e5d5 Mon Sep 17 00:00:00 2001 From: Anna Thomas Date: Fri, 11 Mar 2022 16:47:40 -0500 Subject: [PATCH] [InlineCost] Add cl::opt for target attributes compatibility check. NFC This patch adds a CL option for avoiding the attribute compatibility check between caller and callee in TTI. TTI attribute compatibility checks for target CPU and target features. In our downstream compiler, this attribute always remains the same between callee and caller. By avoiding the addition of this attribute to each of our inline candidate (and then checking them here during inline cost), we save some compile time. The option is kept false, so this change is an NFC upstream. --- llvm/lib/Analysis/InlineCost.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp index b0fae1b..f14a824 100644 --- a/llvm/lib/Analysis/InlineCost.cpp +++ b/llvm/lib/Analysis/InlineCost.cpp @@ -54,6 +54,16 @@ static cl::opt cl::ZeroOrMore, cl::desc("Default amount of inlining to perform")); +// We introduce this option since there is a minor compile-time win by avoiding +// addition of TTI attributes (target-features in particular) to inline +// candidates when they are guaranteed to be the same as top level methods in +// some use cases. If we avoid adding the attribute, we need an option to avoid +// checking these attributes. +static cl::opt IgnoreTTIInlineCompatible( + "ignore-tti-inline-compatible", cl::Hidden, cl::init(false), + cl::desc("Ignore TTI attributes compatibility check between callee/caller " + "during inline cost calculation")); + static cl::opt PrintInstructionComments( "print-instruction-comments", cl::Hidden, cl::init(false), cl::desc("Prints comments for instruction based on inline cost analysis")); @@ -2754,7 +2764,8 @@ static bool functionsHaveCompatibleAttributes( // object, and always returns the same object (which is overwritten on each // GetTLI call). Therefore we copy the first result. auto CalleeTLI = GetTLI(*Callee); - return TTI.areInlineCompatible(Caller, Callee) && + return (IgnoreTTIInlineCompatible || + TTI.areInlineCompatible(Caller, Callee)) && GetTLI(*Caller).areInlineCompatible(CalleeTLI, InlineCallerSupersetNoBuiltin) && AttributeFuncs::areInlineCompatible(*Caller, *Callee); -- 2.7.4