diff --git a/clang/lib/Driver/ToolChains/AIX.cpp b/clang/lib/Driver/ToolChains/AIX.cpp --- a/clang/lib/Driver/ToolChains/AIX.cpp +++ b/clang/lib/Driver/ToolChains/AIX.cpp @@ -98,6 +98,25 @@ 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 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -795,11 +795,6 @@ } 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 --- 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'