Author: Jinsong Ji Date: 2021-09-29T02:00:11Z New Revision: 1e48951c736cb346df34605fc42a39ef6c349b29
URL: https://github.com/llvm/llvm-project/commit/1e48951c736cb346df34605fc42a39ef6c349b29 DIFF: https://github.com/llvm/llvm-project/commit/1e48951c736cb346df34605fc42a39ef6c349b29.diff LOG: [AIX] Enable PGO without LTO On AIX, we relied on LTO to merge the csects for profiling data/counter sections. AIX binder now get the namedcsect support to support the merging, so now we can enable PGO without LTO with the new binder. Reviewed By: Whitney Differential Revision: https://reviews.llvm.org/D110671 Added: Modified: clang/lib/Driver/ToolChains/AIX.cpp clang/lib/Driver/ToolChains/Clang.cpp clang/test/Driver/unsupported-option.c Removed: ################################################################################ diff --git a/clang/lib/Driver/ToolChains/AIX.cpp b/clang/lib/Driver/ToolChains/AIX.cpp index 2a380d9676003..5c82d6566497e 100644 --- a/clang/lib/Driver/ToolChains/AIX.cpp +++ b/clang/lib/Driver/ToolChains/AIX.cpp @@ -98,6 +98,25 @@ void aix::Linker::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back("-bnoentry"); } + // Specify PGO linker option + if ((Args.hasFlag(options::OPT_fprofile_arcs, options::OPT_fno_profile_arcs, + false) || + Args.hasFlag(options::OPT_fprofile_generate, + options::OPT_fno_profile_generate, false) || + Args.hasFlag(options::OPT_fprofile_generate_EQ, + options::OPT_fno_profile_generate, false) || + Args.hasFlag(options::OPT_fprofile_instr_generate, + options::OPT_fno_profile_instr_generate, false) || + Args.hasFlag(options::OPT_fprofile_instr_generate_EQ, + options::OPT_fno_profile_instr_generate, false) || + Args.hasFlag(options::OPT_fcs_profile_generate, + options::OPT_fno_profile_generate, false) || + Args.hasFlag(options::OPT_fcs_profile_generate_EQ, + options::OPT_fno_profile_generate, false) || + Args.hasArg(options::OPT_fcreate_profile) || + Args.hasArg(options::OPT_coverage))) + CmdArgs.push_back("-bdbg:namedcsects"); + // Specify linker output file. assert((Output.isFilename() || Output.isNothing()) && "Invalid output."); if (Output.isFilename()) { diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 7642692ced99b..23932bf9fd24e 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -795,11 +795,6 @@ static void addPGOAndCoverageFlags(const ToolChain &TC, Compilation &C, } if (TC.getTriple().isOSAIX()) { - if (PGOGenerateArg) - if (!D.isUsingLTO(false /*IsDeviceOffloadAction */) || - D.getLTOMode() != LTOK_Full) - D.Diag(clang::diag::err_drv_argument_only_allowed_with) - << PGOGenerateArg->getSpelling() << "-flto"; if (ProfileGenerateArg) D.Diag(diag::err_drv_unsupported_opt_for_target) << ProfileGenerateArg->getSpelling() << TC.getTriple().str(); diff --git a/clang/test/Driver/unsupported-option.c b/clang/test/Driver/unsupported-option.c index c263bb0b853c5..7594d0fc17eeb 100644 --- a/clang/test/Driver/unsupported-option.c +++ b/clang/test/Driver/unsupported-option.c @@ -14,14 +14,6 @@ // RUN: FileCheck %s --check-prefix=AIX-PROFILE-SAMPLE // AIX-PROFILE-SAMPLE: error: unsupported option '-fprofile-sample-use=' for target -// RUN: not %clang -fprofile-generate --target=powerpc-ibm-aix %s 2>&1 | \ -// RUN: FileCheck %s --check-prefix=AIX-PROFILE-LTO -// AIX-PROFILE-LTO: error: invalid argument '-fprofile-generate' only allowed with '-flto' - -// RUN: not %clang -fprofile-generate -flto=thin --target=powerpc64-ibm-aix %s 2>&1 | \ -// RUN: FileCheck %s --check-prefix=AIX-PROFILE-THINLTO -// AIX-PROFILE-THINLTO: error: invalid argument '-fprofile-generate' only allowed with '-flto' - // RUN: not %clang --target=powerpc-ibm-aix %s -mlong-double-128 2>&1 | \ // RUN: FileCheck %s --check-prefix=AIX-LONGDOUBLE128-ERR // AIX-LONGDOUBLE128-ERR: error: unsupported option '-mlong-double-128' for target 'powerpc-ibm-aix' _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits