diff options
| author | Simon Pilgrim <llvm-dev@redking.me.uk> | 2019-05-05 20:23:45 +0000 |
|---|---|---|
| committer | Simon Pilgrim <llvm-dev@redking.me.uk> | 2019-05-05 20:23:45 +0000 |
| commit | 8c0ab999d355939a521d08254e41b717c75f3ff7 (patch) | |
| tree | 7341b9ae068ea9df96e87aaff52b898486beca81 | |
| parent | addc90e4e830f5bf76862f567e545b11aefbde81 (diff) | |
| download | bcm5719-llvm-8c0ab999d355939a521d08254e41b717c75f3ff7.tar.gz bcm5719-llvm-8c0ab999d355939a521d08254e41b717c75f3ff7.zip | |
[TargetLowering] getValueType - use dyn_cast directly to find VectorType. NFCI.
Matches what we do in other getValueType functions and fixes a null dereference warning in scan-build.
Also cleans up the rest of the function - use auto and standardize the variable names.
llvm-svn: 360000
| -rw-r--r-- | llvm/include/llvm/CodeGen/TargetLowering.h | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/llvm/include/llvm/CodeGen/TargetLowering.h b/llvm/include/llvm/CodeGen/TargetLowering.h index ba7989de8ac..1724afcd57e 100644 --- a/llvm/include/llvm/CodeGen/TargetLowering.h +++ b/llvm/include/llvm/CodeGen/TargetLowering.h @@ -1164,21 +1164,20 @@ public: EVT getValueType(const DataLayout &DL, Type *Ty, bool AllowUnknown = false) const { // Lower scalar pointers to native pointer types. - if (PointerType *PTy = dyn_cast<PointerType>(Ty)) + if (auto *PTy = dyn_cast<PointerType>(Ty)) return getPointerTy(DL, PTy->getAddressSpace()); - if (Ty->isVectorTy()) { - VectorType *VTy = cast<VectorType>(Ty); - Type *Elm = VTy->getElementType(); + if (auto *VTy = dyn_cast<VectorType>(Ty)) { + Type *EltTy = VTy->getElementType(); // Lower vectors of pointers to native pointer types. - if (PointerType *PT = dyn_cast<PointerType>(Elm)) { - EVT PointerTy(getPointerTy(DL, PT->getAddressSpace())); - Elm = PointerTy.getTypeForEVT(Ty->getContext()); + if (auto *PTy = dyn_cast<PointerType>(EltTy)) { + EVT PointerTy(getPointerTy(DL, PTy->getAddressSpace())); + EltTy = PointerTy.getTypeForEVT(Ty->getContext()); } - - return EVT::getVectorVT(Ty->getContext(), EVT::getEVT(Elm, false), - VTy->getNumElements()); + return EVT::getVectorVT(Ty->getContext(), EVT::getEVT(EltTy, false), + VTy->getNumElements()); } + return EVT::getEVT(Ty, AllowUnknown); } |

