diff options
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/FastISel.cpp')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/FastISel.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp b/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp index efbd98ec4e3..bf4121346fa 100644 --- a/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp @@ -513,7 +513,13 @@ bool FastISel::selectGetElementPtr(const User *I) { } Ty = StTy->getElementType(Field); } else { - Ty = cast<SequentialType>(Ty)->getElementType(); + if (Ty->isPointerTy()) { + // The only pointer type is for the very first index, + // therefore the next type is the source element type. + Ty = cast<GEPOperator>(I)->getSourceElementType(); + } else { + Ty = cast<SequentialType>(Ty)->getElementType(); + } // If this is a constant subscript, handle it quickly. if (const auto *CI = dyn_cast<ConstantInt>(Idx)) { |