From f5147ef0b997cfd18f7e16efbaeeac98afdc55ab Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Mon, 1 Jun 2015 03:09:34 +0000 Subject: [opaque pointer type] Explicitly store the pointee type of the result of a GEP Alternatively, this type could be derived on-demand whenever getResultElementType is called - if someone thinks that's the better choice (simple time/space tradeoff), I'm happy to give it a go. llvm-svn: 238716 --- llvm/lib/IR/Instructions.cpp | 3 ++- llvm/lib/Transforms/Utils/ValueMapper.cpp | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'llvm/lib') diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp index 332df4804da..1478bffe7c3 100644 --- a/llvm/lib/IR/Instructions.cpp +++ b/llvm/lib/IR/Instructions.cpp @@ -1249,7 +1249,8 @@ GetElementPtrInst::GetElementPtrInst(const GetElementPtrInst &GEPI) OperandTraits::op_end(this) - GEPI.getNumOperands(), GEPI.getNumOperands()), - SourceElementType(GEPI.SourceElementType) { + SourceElementType(GEPI.SourceElementType), + ResultElementType(GEPI.ResultElementType) { std::copy(GEPI.op_begin(), GEPI.op_end(), op_begin()); SubclassOptionalData = GEPI.SubclassOptionalData; } diff --git a/llvm/lib/Transforms/Utils/ValueMapper.cpp b/llvm/lib/Transforms/Utils/ValueMapper.cpp index cac80accc32..8c72641da9e 100644 --- a/llvm/lib/Transforms/Utils/ValueMapper.cpp +++ b/llvm/lib/Transforms/Utils/ValueMapper.cpp @@ -400,8 +400,11 @@ void llvm::RemapInstruction(Instruction *I, ValueToValueMapTy &VMap, } if (auto *AI = dyn_cast(I)) AI->setAllocatedType(TypeMapper->remapType(AI->getAllocatedType())); - if (auto *GEP = dyn_cast(I)) + if (auto *GEP = dyn_cast(I)) { GEP->setSourceElementType( TypeMapper->remapType(GEP->getSourceElementType())); + GEP->setResultElementType( + TypeMapper->remapType(GEP->getResultElementType())); + } I->mutateType(TypeMapper->remapType(I->getType())); } -- cgit v1.2.3