Author: Fangrui Song Date: 2022-12-10T10:15:29Z New Revision: d9bef74a212b502271eb8fa6a0a8714126e88b2b
URL: https://github.com/llvm/llvm-project/commit/d9bef74a212b502271eb8fa6a0a8714126e88b2b DIFF: https://github.com/llvm/llvm-project/commit/d9bef74a212b502271eb8fa6a0a8714126e88b2b.diff LOG: [Driver] -fstack-size-section: pass -stack-size-section to backend for LTO The option does not change IR but affect object file generation. Without a backend option the option is a no-op for in-process ThinLTO. The problem is known and there are many options similar to -fstack-size-section. That said, -fstack-size-section has relatively wider adoption, so it probably makes sense to have custom code for it. Close https://github.com/llvm/llvm-project/issues/59424 Added: Modified: clang/lib/Driver/ToolChains/CommonArgs.cpp clang/test/Driver/stack-size-section.c Removed: ################################################################################ diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index 6f975ef5b9222..47f5ff2429eef 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -773,6 +773,11 @@ void tools::addLTOOptions(const ToolChain &ToolChain, const ArgList &Args, D.Diag(clang::diag::warn_drv_fjmc_for_elf_only); } + if (Args.hasFlag(options::OPT_fstack_size_section, + options::OPT_fno_stack_size_section, false)) + CmdArgs.push_back( + Args.MakeArgString(Twine(PluginOptPrefix) + "-stack-size-section")); + // Setup statistics file output. SmallString<128> StatsFile = getStatsFileName(Args, Output, Input, D); if (!StatsFile.empty()) diff --git a/clang/test/Driver/stack-size-section.c b/clang/test/Driver/stack-size-section.c index b99b1409bef45..71b9f85692b99 100644 --- a/clang/test/Driver/stack-size-section.c +++ b/clang/test/Driver/stack-size-section.c @@ -12,4 +12,10 @@ // RUN: %clang -target x86_64-unknown -fno-stack-size-section -fstack-size-section %s -### 2>&1 \ // RUN: | FileCheck %s --check-prefix=CHECK-PRESENT +// RUN: %clang -### --target=x86_64-linux-gnu -flto -fstack-size-section %s 2>&1 | FileCheck %s --check-prefix=LTO +// RUN: %clang -### --target=x86_64-linux-gnu -flto -fstack-size-section -fno-stack-size-section %s 2>&1 | FileCheck %s --check-prefix=LTO-NO + +// LTO: "-plugin-opt=-stack-size-section" +// LTO-NO-NOT: "-plugin-opt=-stack-size-section" + int foo() { return 42; } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits