Support -C passes in NewPM
And report an error if parsing the additional pass pipeline fails. Threading through the error accounts for most of the changes here.
This commit is contained in:
parent
5519cbfe33
commit
c2b15a6b64
9 changed files with 60 additions and 20 deletions
|
@ -736,7 +736,7 @@ struct LLVMRustSanitizerOptions {
|
|||
bool SanitizeHWAddressRecover;
|
||||
};
|
||||
|
||||
extern "C" void
|
||||
extern "C" LLVMRustResult
|
||||
LLVMRustOptimizeWithNewPassManager(
|
||||
LLVMModuleRef ModuleRef,
|
||||
LLVMTargetMachineRef TMRef,
|
||||
|
@ -750,7 +750,8 @@ LLVMRustOptimizeWithNewPassManager(
|
|||
bool InstrumentCoverage, bool InstrumentGCOV,
|
||||
void* LlvmSelfProfiler,
|
||||
LLVMRustSelfProfileBeforePassCallback BeforePassCallback,
|
||||
LLVMRustSelfProfileAfterPassCallback AfterPassCallback) {
|
||||
LLVMRustSelfProfileAfterPassCallback AfterPassCallback,
|
||||
const char *ExtraPasses, size_t ExtraPassesLen) {
|
||||
Module *TheModule = unwrap(ModuleRef);
|
||||
TargetMachine *TM = unwrap(TMRef);
|
||||
PassBuilder::OptimizationLevel OptLevel = fromRust(OptLevelRust);
|
||||
|
@ -1062,6 +1063,14 @@ LLVMRustOptimizeWithNewPassManager(
|
|||
}
|
||||
}
|
||||
|
||||
if (ExtraPassesLen) {
|
||||
if (auto Err = PB.parsePassPipeline(MPM, StringRef(ExtraPasses, ExtraPassesLen))) {
|
||||
std::string ErrMsg = toString(std::move(Err));
|
||||
LLVMRustSetLastError(ErrMsg.c_str());
|
||||
return LLVMRustResult::Failure;
|
||||
}
|
||||
}
|
||||
|
||||
if (NeedThinLTOBufferPasses) {
|
||||
MPM.addPass(CanonicalizeAliasesPass());
|
||||
MPM.addPass(NameAnonGlobalPass());
|
||||
|
@ -1072,6 +1081,7 @@ LLVMRustOptimizeWithNewPassManager(
|
|||
UpgradeCallsToIntrinsic(&*I++); // must be post-increment, as we remove
|
||||
|
||||
MPM.run(*TheModule, MAM);
|
||||
return LLVMRustResult::Success;
|
||||
}
|
||||
|
||||
// Callback to demangle function name
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue