aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target/Hexagon/HexagonCommonGEP.cpp
diff options
context:
space:
mode:
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;
}