[Inlining] Add a clang option to limit inlining of functions

Add the clang option -finline-max-stacksize=<N> to suppress inlining
of functions whose stack size exceeds the given value.

Reviewed By: aeubanks

Differential Revision: https://reviews.llvm.org/D131986
This commit is contained in:
Wolfgang Pieb
2022-07-05 09:15:33 -07:00
parent a48ff68888
commit 8564e2fea5
6 changed files with 25 additions and 0 deletions

View File

@@ -2372,6 +2372,9 @@ void CodeGenModule::SetFunctionAttributes(GlobalDecl GD, llvm::Function *F,
if (getLangOpts().OpenMP && FD->hasAttr<OMPDeclareSimdDeclAttr>())
getOpenMPRuntime().emitDeclareSimdFunction(FD, F);
if (CodeGenOpts.InlineMaxStackSize != UINT_MAX)
F->addFnAttr("inline-max-stacksize", llvm::utostr(CodeGenOpts.InlineMaxStackSize));
if (const auto *CB = FD->getAttr<CallbackAttr>()) {
// Annotate the callback behavior as metadata:
// - The callback callee (as argument number).