diff options
Diffstat (limited to 'contrib/llvm-project/llvm/lib/Transforms/Scalar/SpeculativeExecution.cpp')
-rw-r--r-- | contrib/llvm-project/llvm/lib/Transforms/Scalar/SpeculativeExecution.cpp | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/contrib/llvm-project/llvm/lib/Transforms/Scalar/SpeculativeExecution.cpp b/contrib/llvm-project/llvm/lib/Transforms/Scalar/SpeculativeExecution.cpp index c78185f2a6ad..dfa30418ea01 100644 --- a/contrib/llvm-project/llvm/lib/Transforms/Scalar/SpeculativeExecution.cpp +++ b/contrib/llvm-project/llvm/lib/Transforms/Scalar/SpeculativeExecution.cpp @@ -210,8 +210,8 @@ bool SpeculativeExecutionPass::runOnBasicBlock(BasicBlock &B) { return false; } -static unsigned ComputeSpeculationCost(const Instruction *I, - const TargetTransformInfo &TTI) { +static InstructionCost ComputeSpeculationCost(const Instruction *I, + const TargetTransformInfo &TTI) { switch (Operator::getOpcode(I)) { case Instruction::GetElementPtr: case Instruction::Add: @@ -255,7 +255,8 @@ static unsigned ComputeSpeculationCost(const Instruction *I, return TTI.getUserCost(I, TargetTransformInfo::TCK_SizeAndLatency); default: - return UINT_MAX; // Disallow anything not explicitly listed. + return InstructionCost::getInvalid(); // Disallow anything not explicitly + // listed. } } @@ -265,11 +266,13 @@ bool SpeculativeExecutionPass::considerHoistingFromTo( const auto AllPrecedingUsesFromBlockHoisted = [&NotHoisted](const User *U) { // Debug variable has special operand to check it's not hoisted. if (const auto *DVI = dyn_cast<DbgVariableIntrinsic>(U)) { - if (const auto *I = - dyn_cast_or_null<Instruction>(DVI->getVariableLocation())) - if (NotHoisted.count(I) == 0) - return true; - return false; + return all_of(DVI->location_ops(), [&NotHoisted](Value *V) { + if (const auto *I = dyn_cast_or_null<Instruction>(V)) { + if (NotHoisted.count(I) == 0) + return true; + } + return false; + }); } // Usially debug label instrinsic corresponds to label in LLVM IR. In these @@ -288,11 +291,11 @@ bool SpeculativeExecutionPass::considerHoistingFromTo( return true; }; - unsigned TotalSpeculationCost = 0; + InstructionCost TotalSpeculationCost = 0; unsigned NotHoistedInstCount = 0; for (const auto &I : FromBlock) { - const unsigned Cost = ComputeSpeculationCost(&I, *TTI); - if (Cost != UINT_MAX && isSafeToSpeculativelyExecute(&I) && + const InstructionCost Cost = ComputeSpeculationCost(&I, *TTI); + if (Cost.isValid() && isSafeToSpeculativelyExecute(&I) && AllPrecedingUsesFromBlockHoisted(&I)) { TotalSpeculationCost += Cost; if (TotalSpeculationCost > SpecExecMaxSpeculationCost) @@ -340,7 +343,6 @@ PreservedAnalyses SpeculativeExecutionPass::run(Function &F, if (!Changed) return PreservedAnalyses::all(); PreservedAnalyses PA; - PA.preserve<GlobalsAA>(); PA.preserveSet<CFGAnalyses>(); return PA; } |