Skip to content

Commit 2ea285d

Browse files
davemgreenIanWood1
authored andcommitted
[CostModel] Fix InlineSizeEstimatorAnalysis after llvm#135596
Fix a reference to getValue() being optional in InlineSizeEstimatorAnalysis, a file that is not included in the default build. A "warning: enumerated and non-enumerated type in conditional expression" warning is fixed in AMDGPU too.
1 parent 5f6349f commit 2ea285d

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

llvm/lib/Analysis/InlineSizeEstimatorAnalysis.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,9 @@ size_t getSize(Function &F, TargetTransformInfo &TTI) {
128128
size_t Ret = 0;
129129
for (const auto &BB : F)
130130
for (const auto &I : BB)
131-
Ret += *(TTI.getInstructionCost(
132-
&I, TargetTransformInfo::TargetCostKind::TCK_CodeSize).getValue());
131+
Ret += TTI.getInstructionCost(
132+
&I, TargetTransformInfo::TargetCostKind::TCK_CodeSize)
133+
.getValue();
133134
return Ret;
134135
}
135136

llvm/lib/Target/AMDGPU/AMDGPUSplitModule.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,9 @@ static CostType calculateFunctionCosts(GetTTIFn GetTTI, Module &M,
205205
TTI.getInstructionCost(&I, TargetTransformInfo::TCK_CodeSize);
206206
assert(Cost != InstructionCost::getMax());
207207
// Assume expensive if we can't tell the cost of an instruction.
208-
CostType CostVal = Cost.isValid() ? Cost.getValue()
209-
: TargetTransformInfo::TCC_Expensive;
208+
CostType CostVal = Cost.isValid()
209+
? Cost.getValue()
210+
: (CostType)TargetTransformInfo::TCC_Expensive;
210211
assert((FnCost + CostVal) >= FnCost && "Overflow!");
211212
FnCost += CostVal;
212213
}

0 commit comments

Comments
 (0)