Skip to content

Commit 4614e5b

Browse files
committed
llvm-wrapper: adapt for LLVM API changes
Adapts the wrapper for llvm/llvm-project@516e301, where the constructor of PGOOptions gained a new FileSystem argument. Adapted to use the real file system, similarly to the changes inside of LLVM: llvm/llvm-project@516e301#diff-f409934ba27ad86494f3012324e9a3995b56e0743609ded7a387ba62bbf5edb0R236
1 parent 821b2a8 commit 4614e5b

File tree

1 file changed

+30
-8
lines changed

1 file changed

+30
-8
lines changed

compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp

+30-8
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
#include "llvm/Passes/StandardInstrumentations.h"
2222
#include "llvm/Support/CBindingWrapping.h"
2323
#include "llvm/Support/FileSystem.h"
24+
#if LLVM_VERSION_GE(17, 0)
25+
#include "llvm/Support/VirtualFileSystem.h"
26+
#endif
2427
#include "llvm/Support/Host.h"
2528
#if LLVM_VERSION_LT(14, 0)
2629
#include "llvm/Support/TargetRegistry.h"
@@ -651,21 +654,40 @@ LLVMRustOptimize(
651654
Optional<PGOOptions> PGOOpt;
652655
#else
653656
std::optional<PGOOptions> PGOOpt;
657+
#endif
658+
#if LLVM_VERSION_GE(17, 0)
659+
auto FS = vfs::getRealFileSystem();
654660
#endif
655661
if (PGOGenPath) {
656662
assert(!PGOUsePath && !PGOSampleUsePath);
657-
PGOOpt = PGOOptions(PGOGenPath, "", "", PGOOptions::IRInstr,
658-
PGOOptions::NoCSAction, DebugInfoForProfiling);
663+
PGOOpt = PGOOptions(PGOGenPath, "", "",
664+
#if LLVM_VERSION_GE(17, 0)
665+
FS,
666+
#endif
667+
PGOOptions::IRInstr, PGOOptions::NoCSAction,
668+
DebugInfoForProfiling);
659669
} else if (PGOUsePath) {
660670
assert(!PGOSampleUsePath);
661-
PGOOpt = PGOOptions(PGOUsePath, "", "", PGOOptions::IRUse,
662-
PGOOptions::NoCSAction, DebugInfoForProfiling);
671+
PGOOpt = PGOOptions(PGOUsePath, "", "",
672+
#if LLVM_VERSION_GE(17, 0)
673+
FS,
674+
#endif
675+
PGOOptions::IRUse, PGOOptions::NoCSAction,
676+
DebugInfoForProfiling);
663677
} else if (PGOSampleUsePath) {
664-
PGOOpt = PGOOptions(PGOSampleUsePath, "", "", PGOOptions::SampleUse,
665-
PGOOptions::NoCSAction, DebugInfoForProfiling);
678+
PGOOpt = PGOOptions(PGOSampleUsePath, "", "",
679+
#if LLVM_VERSION_GE(17, 0)
680+
FS,
681+
#endif
682+
PGOOptions::SampleUse, PGOOptions::NoCSAction,
683+
DebugInfoForProfiling);
666684
} else if (DebugInfoForProfiling) {
667-
PGOOpt = PGOOptions("", "", "", PGOOptions::NoAction,
668-
PGOOptions::NoCSAction, DebugInfoForProfiling);
685+
PGOOpt = PGOOptions("", "", "",
686+
#if LLVM_VERSION_GE(17, 0)
687+
FS,
688+
#endif
689+
PGOOptions::NoAction, PGOOptions::NoCSAction,
690+
DebugInfoForProfiling);
669691
}
670692

671693
PassBuilder PB(TM, PTO, PGOOpt, &PIC);

0 commit comments

Comments
 (0)