|
25 | 25 | #include "llvm/Transforms/IPO/PassManagerBuilder.h"
|
26 | 26 | #include "llvm/Transforms/IPO/AlwaysInliner.h"
|
27 | 27 | #include "llvm/Transforms/IPO/FunctionImport.h"
|
| 28 | +#include "llvm/Transforms/Utils/AddDiscriminators.h" |
28 | 29 | #include "llvm/Transforms/Utils/FunctionImportUtils.h"
|
29 | 30 | #include "llvm/LTO/LTO.h"
|
30 | 31 | #include "llvm-c/Transforms/PassManagerBuilder.h"
|
|
39 | 40 | #include "llvm/Transforms/Instrumentation/HWAddressSanitizer.h"
|
40 | 41 | #include "llvm/Transforms/Utils/CanonicalizeAliases.h"
|
41 | 42 | #include "llvm/Transforms/Utils/NameAnonGlobals.h"
|
| 43 | +#include "llvm/Transforms/Utils.h" |
42 | 44 |
|
43 | 45 | using namespace llvm;
|
44 | 46 |
|
@@ -523,21 +525,22 @@ extern "C" void LLVMRustDisposeTargetMachine(LLVMTargetMachineRef TM) {
|
523 | 525 | extern "C" void LLVMRustConfigurePassManagerBuilder(
|
524 | 526 | LLVMPassManagerBuilderRef PMBR, LLVMRustCodeGenOptLevel OptLevel,
|
525 | 527 | bool MergeFunctions, bool SLPVectorize, bool LoopVectorize, bool PrepareForThinLTO,
|
526 |
| - const char* PGOGenPath, const char* PGOUsePath) { |
| 528 | + const char* PGOGenPath, const char* PGOUsePath, const char* PGOSampleUsePath) { |
527 | 529 | unwrap(PMBR)->MergeFunctions = MergeFunctions;
|
528 | 530 | unwrap(PMBR)->SLPVectorize = SLPVectorize;
|
529 | 531 | unwrap(PMBR)->OptLevel = fromRust(OptLevel);
|
530 | 532 | unwrap(PMBR)->LoopVectorize = LoopVectorize;
|
531 | 533 | unwrap(PMBR)->PrepareForThinLTO = PrepareForThinLTO;
|
532 | 534 |
|
533 | 535 | if (PGOGenPath) {
|
534 |
| - assert(!PGOUsePath); |
| 536 | + assert(!PGOUsePath && !PGOSampleUsePath); |
535 | 537 | unwrap(PMBR)->EnablePGOInstrGen = true;
|
536 | 538 | unwrap(PMBR)->PGOInstrGen = PGOGenPath;
|
537 |
| - } |
538 |
| - if (PGOUsePath) { |
539 |
| - assert(!PGOGenPath); |
| 539 | + } else if (PGOUsePath) { |
| 540 | + assert(!PGOSampleUsePath); |
540 | 541 | unwrap(PMBR)->PGOInstrUse = PGOUsePath;
|
| 542 | + } else if (PGOSampleUsePath) { |
| 543 | + unwrap(PMBR)->PGOSampleUse = PGOSampleUsePath; |
541 | 544 | }
|
542 | 545 | }
|
543 | 546 |
|
@@ -759,6 +762,7 @@ LLVMRustOptimizeWithNewPassManager(
|
759 | 762 | LLVMRustSanitizerOptions *SanitizerOptions,
|
760 | 763 | const char *PGOGenPath, const char *PGOUsePath,
|
761 | 764 | bool InstrumentCoverage, bool InstrumentGCOV,
|
| 765 | + const char *PGOSampleUsePath, bool DebugInfoForProfiling, |
762 | 766 | void* LlvmSelfProfiler,
|
763 | 767 | LLVMRustSelfProfileBeforePassCallback BeforePassCallback,
|
764 | 768 | LLVMRustSelfProfileAfterPassCallback AfterPassCallback,
|
@@ -797,11 +801,19 @@ LLVMRustOptimizeWithNewPassManager(
|
797 | 801 |
|
798 | 802 | Optional<PGOOptions> PGOOpt;
|
799 | 803 | if (PGOGenPath) {
|
800 |
| - assert(!PGOUsePath); |
801 |
| - PGOOpt = PGOOptions(PGOGenPath, "", "", PGOOptions::IRInstr); |
| 804 | + assert(!PGOUsePath && !PGOSampleUsePath); |
| 805 | + PGOOpt = PGOOptions(PGOGenPath, "", "", PGOOptions::IRInstr, |
| 806 | + PGOOptions::NoCSAction, DebugInfoForProfiling); |
802 | 807 | } else if (PGOUsePath) {
|
803 |
| - assert(!PGOGenPath); |
804 |
| - PGOOpt = PGOOptions(PGOUsePath, "", "", PGOOptions::IRUse); |
| 808 | + assert(!PGOSampleUsePath); |
| 809 | + PGOOpt = PGOOptions(PGOUsePath, "", "", PGOOptions::IRUse, |
| 810 | + PGOOptions::NoCSAction, DebugInfoForProfiling); |
| 811 | + } else if (PGOSampleUsePath) { |
| 812 | + PGOOpt = PGOOptions(PGOSampleUsePath, "", "", PGOOptions::SampleUse, |
| 813 | + PGOOptions::NoCSAction, DebugInfoForProfiling); |
| 814 | + } else if (DebugInfoForProfiling) { |
| 815 | + PGOOpt = PGOOptions("", "", "", PGOOptions::NoAction, |
| 816 | + PGOOptions::NoCSAction, DebugInfoForProfiling); |
805 | 817 | }
|
806 | 818 |
|
807 | 819 | #if LLVM_VERSION_GE(12, 0) && !LLVM_VERSION_GE(13,0)
|
|
0 commit comments