From 8564e2fea559c58fecab3c7c01acf498bbe7820a Mon Sep 17 00:00:00 2001 From: Wolfgang Pieb Date: Tue, 5 Jul 2022 09:15:33 -0700 Subject: [Inlining] Add a clang option to limit inlining of functions Add the clang option -finline-max-stacksize= to suppress inlining of functions whose stack size exceeds the given value. Reviewed By: aeubanks Differential Revision: https://reviews.llvm.org/D131986 --- clang/lib/CodeGen/CodeGenModule.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'clang/lib/CodeGen/CodeGenModule.cpp') diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 0921008e254c..639285540c0a 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -2372,6 +2372,9 @@ void CodeGenModule::SetFunctionAttributes(GlobalDecl GD, llvm::Function *F, if (getLangOpts().OpenMP && FD->hasAttr()) getOpenMPRuntime().emitDeclareSimdFunction(FD, F); + if (CodeGenOpts.InlineMaxStackSize != UINT_MAX) + F->addFnAttr("inline-max-stacksize", llvm::utostr(CodeGenOpts.InlineMaxStackSize)); + if (const auto *CB = FD->getAttr()) { // Annotate the callback behavior as metadata: // - The callback callee (as argument number). -- cgit v1.2.3