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,9 +98,10 @@ CmdArgs.push_back("-bnoentry"); } - // Specify PGO linker option without LTO - if (!D.isUsingLTO() && - (Args.hasFlag(options::OPT_fprofile_arcs, options::OPT_fno_profile_arcs, + // PGO instrumentation generates symbols belonging to special sections, and + // the linker needs to place all symbols in a particular section together in + // memory; the AIX linker does that under an 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) || @@ -115,7 +116,7 @@ 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))) + Args.hasArg(options::OPT_coverage)) CmdArgs.push_back("-bdbg:namedsects"); // Specify linker output file. diff --git a/clang/test/Driver/aix-ld.c b/clang/test/Driver/aix-ld.c --- a/clang/test/Driver/aix-ld.c +++ b/clang/test/Driver/aix-ld.c @@ -692,7 +692,7 @@ // CHECK-PGO-LTO: "-resource-dir" "[[RESOURCE_DIR:[^"]+]]" // CHECK-PGO-LTO: "-isysroot" "[[SYSROOT:[^"]+]]" // CHECK-PGO-LTO: "{{.*}}ld{{(.exe)?}}" -// CHECK-PGO-LTO-NOT: "-bdbg:namedsects" +// CHECK-PGO-LTO: "-bdbg:namedsects" // CHECK-PGO-LTO: "-b32" // CHECK-PGO-LTO: "-bpT:0x10000000" "-bpD:0x20000000" // CHECK-PGO-LTO: "[[SYSROOT]]/usr/lib{{/|\\\\}}crt0.o"