[PATCH] D124754: Minimal refactor of TargetTransformInfoImpl.h to avoid Clang Static Analyser's core.CallAndMessage (NFC)
Markus Lavin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon May 2 02:21:50 PDT 2022
markus created this revision.
markus added reviewers: samparker, greened.
Herald added a project: All.
markus requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Don't expose OpTy way earlier than needed and we don't have the problem of having to assign nullptr if we are looking at the wrong type of instruction.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D124754
Files:
llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
Index: llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
===================================================================
--- llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
+++ llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
@@ -986,8 +986,6 @@
}
Type *Ty = U->getType();
- Type *OpTy =
- U->getNumOperands() == 1 ? U->getOperand(0)->getType() : nullptr;
unsigned Opcode = Operator::getOpcode(U);
auto *I = dyn_cast<Instruction>(U);
switch (Opcode) {
@@ -1059,9 +1057,11 @@
case Instruction::FPExt:
case Instruction::SExt:
case Instruction::ZExt:
- case Instruction::AddrSpaceCast:
+ case Instruction::AddrSpaceCast: {
+ Type *OpTy = U->getOperand(0)->getType();
return TargetTTI->getCastInstrCost(
Opcode, Ty, OpTy, TTI::getCastContextHint(I), CostKind, I);
+ }
case Instruction::Store: {
auto *SI = cast<StoreInst>(U);
Type *ValTy = U->getOperand(0)->getType();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124754.426360.patch
Type: text/x-patch
Size: 982 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220502/bf944db7/attachment.bin>
More information about the llvm-commits
mailing list