[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.
This commit is contained in:
Anna Thomas 2022-03-11 16:47:40 -05:00
parent 46626bc873
commit a4aa97d578
1 changed files with 12 additions and 1 deletions

View File

@ -54,6 +54,16 @@ static cl::opt<int>
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<bool> 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<bool> 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);