summaryrefslogtreecommitdiff
path: root/llvm/lib/Target/Hexagon/HexagonCommonGEP.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2020-07-26 19:36:28 +0000
committerDimitry Andric <dim@FreeBSD.org>2020-07-26 19:36:28 +0000
commitcfca06d7963fa0909f90483b42a6d7d194d01e08 (patch)
tree209fb2a2d68f8f277793fc8df46c753d31bc853b /llvm/lib/Target/Hexagon/HexagonCommonGEP.cpp
parent706b4fc47bbc608932d3b491ae19a3b9cde9497b (diff)
Notes
Diffstat (limited to 'llvm/lib/Target/Hexagon/HexagonCommonGEP.cpp')
-rw-r--r--llvm/lib/Target/Hexagon/HexagonCommonGEP.cpp15
1 files changed, 3 insertions, 12 deletions
diff --git a/llvm/lib/Target/Hexagon/HexagonCommonGEP.cpp b/llvm/lib/Target/Hexagon/HexagonCommonGEP.cpp
index 6d2aadb066cf..6a5192c866cc 100644
--- a/llvm/lib/Target/Hexagon/HexagonCommonGEP.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonCommonGEP.cpp
@@ -204,17 +204,7 @@ namespace {
Type *next_type(Type *Ty, Value *Idx) {
if (auto *PTy = dyn_cast<PointerType>(Ty))
return PTy->getElementType();
- // Advance the type.
- if (!Ty->isStructTy()) {
- Type *NexTy = cast<SequentialType>(Ty)->getElementType();
- return NexTy;
- }
- // Otherwise it is a struct type.
- ConstantInt *CI = dyn_cast<ConstantInt>(Idx);
- assert(CI && "Struct type with non-constant index");
- int64_t i = CI->getValue().getSExtValue();
- Type *NextTy = cast<StructType>(Ty)->getElementType(i);
- return NextTy;
+ return GetElementPtrInst::getTypeAtIndex(Ty, Idx);
}
raw_ostream &operator<< (raw_ostream &OS, const GepNode &GN) {
@@ -1302,7 +1292,8 @@ bool HexagonCommonGEP::runOnFunction(Function &F) {
#ifdef EXPENSIVE_CHECKS
// Run this only when expensive checks are enabled.
- verifyFunction(F);
+ if (verifyFunction(F, &dbgs()))
+ report_fatal_error("Broken function");
#endif
return true;
}