aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/InlineCost.cpp
diff options
context:
space:
mode:
authorKirill Naumov <knaumov@azul.com>2020-04-29 21:59:20 +0000
committerKirill Naumov <knaumov@azul.com>2020-04-29 22:00:51 +0000
commit0fa793e798701358e42b1c289b28206bde028427 (patch)
treea9f13f5fe2ca007fdabbfb7ba06dafc6af491e1b /llvm/lib/Analysis/InlineCost.cpp
parent5439582781f3e975ca4e5fa9ba71202eb7c3aaad (diff)
downloadllvm-0fa793e798701358e42b1c289b28206bde028427.zip
llvm-0fa793e798701358e42b1c289b28206bde028427.tar.gz
llvm-0fa793e798701358e42b1c289b28206bde028427.tar.bz2
Revert "[InlineCost] Addressing a very strict assert check in CostAnnotationWriter::emitInstructionAnnot"
This reverts commit 66947d05fd193bb8948943a62455d617974f2012.
Diffstat (limited to 'llvm/lib/Analysis/InlineCost.cpp')
-rw-r--r--llvm/lib/Analysis/InlineCost.cpp49
1 files changed, 23 insertions, 26 deletions
diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp
index ce9f030..42f8fec 100644
--- a/llvm/lib/Analysis/InlineCost.cpp
+++ b/llvm/lib/Analysis/InlineCost.cpp
@@ -54,8 +54,8 @@ static cl::opt<int>
cl::ZeroOrMore,
cl::desc("Default amount of inlining to perform"));
-static cl::opt<bool> PrintDebugInstructionDeltas(
- "print-instruction-deltas", cl::Hidden, cl::init(false),
+static cl::opt<bool> PrintDebugInstructionDeltas("print-instruction-deltas",
+ cl::Hidden, cl::init(false),
cl::desc("Prints deltas of cost and threshold per instruction"));
static cl::opt<int> InlineThreshold(
@@ -132,10 +132,10 @@ class CostAnnotationWriter : public AssemblyAnnotationWriter {
public:
// This DenseMap stores the delta change in cost and threshold after
// accounting for the given instruction.
- DenseMap<const Instruction *, InstructionCostDetail> CostThresholdMap;
+ DenseMap <const Instruction *, InstructionCostDetail> CostThresholdMap;
virtual void emitInstructionAnnot(const Instruction *I,
- formatted_raw_ostream &OS);
+ formatted_raw_ostream &OS);
};
class CallAnalyzer : public InstVisitor<CallAnalyzer, bool> {
@@ -590,7 +590,7 @@ class InlineCostCallAnalyzer final : public CallAnalyzer {
// This function is called to store the initial cost of inlining before
// the given instruction was assessed.
if (!PrintDebugInstructionDeltas)
- return;
+ return ;
Writer.CostThresholdMap[I].CostBefore = Cost;
Writer.CostThresholdMap[I].ThresholdBefore = Threshold;
}
@@ -599,7 +599,7 @@ class InlineCostCallAnalyzer final : public CallAnalyzer {
// This function is called to find new values of cost and threshold after
// the instruction has been assessed.
if (!PrintDebugInstructionDeltas)
- return;
+ return ;
Writer.CostThresholdMap[I].CostAfter = Cost;
Writer.CostThresholdMap[I].ThresholdAfter = Threshold;
}
@@ -727,24 +727,22 @@ void CallAnalyzer::disableSROAForArg(AllocaInst *SROAArg) {
disableLoadElimination();
}
-void CostAnnotationWriter::emitInstructionAnnot(const Instruction *I,
- formatted_raw_ostream &OS) {
- // The cost of inlining of the given instruction is printed always.
- // The threshold delta is printed only when it is non-zero. It happens
- // when we decided to give a bonus at a particular instruction.
- if (CostThresholdMap.count(I) == 0) {
- OS << "; No analysis for the instruction\n";
- return;
- }
- const auto &Record = CostThresholdMap[I];
- OS << "; cost before = " << Record.CostBefore
- << ", cost after = " << Record.CostAfter
- << ", threshold before = " << Record.ThresholdBefore
- << ", threshold after = " << Record.ThresholdAfter << ", ";
- OS << "cost delta = " << Record.getCostDelta();
- if (Record.hasThresholdChanged())
- OS << ", threshold delta = " << Record.getThresholdDelta();
- OS << "\n";
+void CostAnnotationWriter::emitInstructionAnnot(
+ const Instruction *I, formatted_raw_ostream &OS) {
+ // The cost of inlining of the given instruction is printed always.
+ // The threshold delta is printed only when it is non-zero. It happens
+ // when we decided to give a bonus at a particular instruction.
+ assert(CostThresholdMap.count(I) > 0 &&
+ "Expected each instruction to have an instruction annotation");
+ const auto &Record = CostThresholdMap[I];
+ OS << "; cost before = " << Record.CostBefore
+ << ", cost after = " << Record.CostAfter
+ << ", threshold before = " << Record.ThresholdBefore
+ << ", threshold after = " << Record.ThresholdAfter << ", ";
+ OS << "cost delta = " << Record.getCostDelta();
+ if (Record.hasThresholdChanged())
+ OS << ", threshold delta = " << Record.getThresholdDelta();
+ OS << "\n";
}
/// If 'V' maps to a SROA candidate, disable SROA for it.
@@ -806,8 +804,7 @@ bool CallAnalyzer::isGEPFree(GetElementPtrInst &GEP) {
else
Operands.push_back(*I);
return TargetTransformInfo::TCC_Free ==
- TTI.getUserCost(&GEP, Operands,
- TargetTransformInfo::TCK_SizeAndLatency);
+ TTI.getUserCost(&GEP, Operands, TargetTransformInfo::TCK_SizeAndLatency);
}
bool CallAnalyzer::visitAlloca(AllocaInst &I) {