[llvm] dd8cf37 - [NFC] Minimal refactor of TTI to avoid clangsa complaint

Markus Lavin via llvm-commits llvm-commits at lists.llvm.org
Tue May 3 01:47:47 PDT 2022


Author: Markus Lavin
Date: 2022-05-03T10:43:48+02:00
New Revision: dd8cf372c54fdb654d1a7e7578460eb95e6531f9

URL: https://github.com/llvm/llvm-project/commit/dd8cf372c54fdb654d1a7e7578460eb95e6531f9
DIFF: https://github.com/llvm/llvm-project/commit/dd8cf372c54fdb654d1a7e7578460eb95e6531f9.diff

LOG: [NFC] Minimal refactor of TTI to avoid clangsa complaint

Differential Revision: https://reviews.llvm.org/D124754

Added: 
    

Modified: 
    llvm/include/llvm/Analysis/TargetTransformInfoImpl.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
index 9111b74d81ac2..df0a2491b6ff5 100644
--- a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
+++ b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
@@ -986,8 +986,6 @@ class TargetTransformInfoImplCRTPBase : public TargetTransformInfoImplBase {
     }
 
     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 @@ class TargetTransformInfoImplCRTPBase : public TargetTransformInfoImplBase {
     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();


        


More information about the llvm-commits mailing list