PGO: refactor such that there can be IR-based and frontend-based PGO.

This commit is contained in:
Johan Engelen 2017-12-28 14:11:33 +01:00
parent 07b7abefa4
commit 3ec79179b4
13 changed files with 94 additions and 49 deletions

View file

@ -9,6 +9,7 @@
#include "errors.h"
#include "driver/cl_options.h"
#include "driver/cl_options_instrumentation.h"
#include "driver/cl_options_sanitizers.h"
#include "driver/exe_path.h"
#include "driver/tool.h"
@ -329,7 +330,7 @@ void ArgsBuilder::build(llvm::StringRef outputPath,
}
// Link with profile-rt library when generating an instrumented binary.
if (global.params.genInstrProf) {
if (opts::isInstrumentingForPGO()) {
#if LDC_LLVM_VER >= 308
if (global.params.targetTriple->isOSLinux()) {
// For Linux, explicitly define __llvm_profile_runtime as undefined
@ -386,7 +387,7 @@ void ArgsBuilder::build(llvm::StringRef outputPath,
// instrumented binary. The runtime relies on magic sections, which
// would be stripped by gc-section on older version of ld, see bug:
// https://sourceware.org/bugzilla/show_bug.cgi?id=19161
if (!opts::disableLinkerStripDead && !global.params.genInstrProf) {
if (!opts::disableLinkerStripDead && !opts::isInstrumentingForPGO()) {
addLdFlag("--gc-sections");
}
}