pub fn LLVMRustModuleCost(M: ModuleRef) -> u64;
pub fn LLVMRustThinLTOAvailable() -> bool;
+ pub fn LLVMRustPGOAvailable() -> bool;
pub fn LLVMRustWriteThinBitcodeToFile(PMR: PassManagerRef,
M: ModuleRef,
BC: *const c_char) -> bool;
}
}
+ if (tcx.sess.opts.debugging_opts.pgo_gen.is_some() ||
+ !tcx.sess.opts.debugging_opts.pgo_use.is_empty()) &&
+ unsafe { !llvm::LLVMRustPGOAvailable() }
+ {
+ tcx.sess.fatal("this compiler's LLVM does not support PGO");
+ }
+
let crate_hash = tcx.crate_hash(LOCAL_CRATE);
let link_meta = link::build_link_meta(crate_hash);
#include "llvm-c/Transforms/PassManagerBuilder.h"
+#if LLVM_VERSION_GE(4, 0)
+#define PGO_AVAILABLE
+#endif
+
using namespace llvm;
using namespace llvm::legacy;
unwrap(PMBR)->SLPVectorize = SLPVectorize;
unwrap(PMBR)->OptLevel = fromRust(OptLevel);
unwrap(PMBR)->LoopVectorize = LoopVectorize;
+
+#ifdef PGO_AVAILABLE
if (PGOGenPath) {
assert(!PGOUsePath);
unwrap(PMBR)->EnablePGOInstrGen = true;
assert(!PGOGenPath);
unwrap(PMBR)->PGOInstrUse = PGOUsePath;
}
+#else
+ assert(!PGOGenPath && !PGOUsePath && "Should've caught earlier");
+#endif
}
// Unfortunately, the LLVM C API doesn't provide a way to set the `LibraryInfo`
#endif
}
+extern "C" bool
+LLVMRustPGOAvailable() {
+#ifdef PGO_AVAILABLE
+ return true;
+#else
+ return false;
+#endif
+}
+
#if LLVM_VERSION_GE(4, 0)
// Here you'll find an implementation of ThinLTO as used by the Rust compiler