From a3b84168801916f78e2ce68dc13814db67f74a9e Mon Sep 17 00:00:00 2001 From: Philip Pfaffe Date: Mon, 10 Jul 2017 12:48:51 +0000 Subject: [PATCH] [PM] Fix r307532: Get rid of a dangling reference. Escaping lambda by-reference capture of local variable caused a dangling reference. llvm-svn: 307534 --- llvm/tools/opt/NewPMDriver.cpp | 46 ++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/llvm/tools/opt/NewPMDriver.cpp b/llvm/tools/opt/NewPMDriver.cpp index 9672ce7..0501e80 100644 --- a/llvm/tools/opt/NewPMDriver.cpp +++ b/llvm/tools/opt/NewPMDriver.cpp @@ -88,41 +88,43 @@ static cl::opt VectorizerStartEPPipeline( static void registerEPCallbacks(PassBuilder &PB, bool VerifyEachPass, bool DebugLogging) { if (!PeepholeEPPipeline.empty()) - PB.registerPeepholeEPCallback( - [&](FunctionPassManager &PM, PassBuilder::OptimizationLevel Level) { - return PB.parsePassPipeline(PM, PeepholeEPPipeline, VerifyEachPass, - DebugPM); - }); + PB.registerPeepholeEPCallback([&PB, VerifyEachPass, DebugLogging]( + FunctionPassManager &PM, PassBuilder::OptimizationLevel Level) { + return PB.parsePassPipeline(PM, PeepholeEPPipeline, VerifyEachPass, + DebugPM); + }); if (!LateLoopOptimizationsEPPipeline.empty()) PB.registerLateLoopOptimizationsEPCallback( - [&](LoopPassManager &PM, PassBuilder::OptimizationLevel Level) { + [&PB, VerifyEachPass, DebugLogging]( + LoopPassManager &PM, PassBuilder::OptimizationLevel Level) { return PB.parsePassPipeline(PM, LateLoopOptimizationsEPPipeline, VerifyEachPass, DebugPM); }); if (!LoopOptimizerEndEPPipeline.empty()) - PB.registerLoopOptimizerEndEPCallback( - [&](LoopPassManager &PM, PassBuilder::OptimizationLevel Level) { - return PB.parsePassPipeline(PM, LoopOptimizerEndEPPipeline, - VerifyEachPass, DebugPM); - }); + PB.registerLoopOptimizerEndEPCallback([&PB, VerifyEachPass, DebugLogging]( + LoopPassManager &PM, PassBuilder::OptimizationLevel Level) { + return PB.parsePassPipeline(PM, LoopOptimizerEndEPPipeline, + VerifyEachPass, DebugPM); + }); if (!ScalarOptimizerLateEPPipeline.empty()) PB.registerScalarOptimizerLateEPCallback( - [&](FunctionPassManager &PM, PassBuilder::OptimizationLevel Level) { + [&PB, VerifyEachPass, DebugLogging]( + FunctionPassManager &PM, PassBuilder::OptimizationLevel Level) { return PB.parsePassPipeline(PM, ScalarOptimizerLateEPPipeline, VerifyEachPass, DebugPM); }); if (!CGSCCOptimizerLateEPPipeline.empty()) - PB.registerCGSCCOptimizerLateEPCallback( - [&](CGSCCPassManager &PM, PassBuilder::OptimizationLevel Level) { - return PB.parsePassPipeline(PM, CGSCCOptimizerLateEPPipeline, - VerifyEachPass, DebugPM); - }); + PB.registerCGSCCOptimizerLateEPCallback([&PB, VerifyEachPass, DebugLogging]( + CGSCCPassManager &PM, PassBuilder::OptimizationLevel Level) { + return PB.parsePassPipeline(PM, CGSCCOptimizerLateEPPipeline, + VerifyEachPass, DebugPM); + }); if (!VectorizerStartEPPipeline.empty()) - PB.registerVectorizerStartEPCallback( - [&](FunctionPassManager &PM, PassBuilder::OptimizationLevel Level) { - return PB.parsePassPipeline(PM, VectorizerStartEPPipeline, - VerifyEachPass, DebugPM); - }); + PB.registerVectorizerStartEPCallback([&PB, VerifyEachPass, DebugLogging]( + FunctionPassManager &PM, PassBuilder::OptimizationLevel Level) { + return PB.parsePassPipeline(PM, VectorizerStartEPPipeline, VerifyEachPass, + DebugPM); + }); } bool llvm::runPassPipeline(StringRef Arg0, Module &M, TargetMachine *TM, -- 2.7.4