From 19eb03106d6042a404f4943f3e9efc74da6865f6 Mon Sep 17 00:00:00 2001 From: Eduard Burtescu Date: Tue, 19 Jan 2016 17:28:00 +0000 Subject: [opaque pointer types] [NFC] GEP: replace get(Pointer)ElementType uses with get{Source,Result}ElementType. Summary: GEPOperator: provide getResultElementType alongside getSourceElementType. This is made possible by adding a result element type field to GetElementPtrConstantExpr, which GetElementPtrInst already has. GEP: replace get(Pointer)ElementType uses with get{Source,Result}ElementType. Reviewers: mjacob, dblaikie Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D16275 llvm-svn: 258145 --- llvm/lib/CodeGen/SelectionDAG/FastISel.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'llvm/lib/CodeGen/SelectionDAG/FastISel.cpp') 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(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(I)->getSourceElementType(); + } else { + Ty = cast(Ty)->getElementType(); + } // If this is a constant subscript, handle it quickly. if (const auto *CI = dyn_cast(Idx)) { -- cgit v1.2.3