From 98281a20503896349bd152e2dfe87435d3a6aada Mon Sep 17 00:00:00 2001 From: Nuno Lopes Date: Sun, 30 Dec 2012 16:25:48 +0000 Subject: convert a bunch of callers from DataLayout::getIndexedOffset() to GEP::accumulateConstantOffset(). The later API is nicer than the former, and is correct regarding wrap-around offsets (if anyone cares). There are a few more places left with duplicated code, which I'll remove soon. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171259 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/ExecutionEngine/ExecutionEngine.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'lib/ExecutionEngine/ExecutionEngine.cpp') diff --git a/lib/ExecutionEngine/ExecutionEngine.cpp b/lib/ExecutionEngine/ExecutionEngine.cpp index 21e0ad3fcd..c2a22e6b3f 100644 --- a/lib/ExecutionEngine/ExecutionEngine.cpp +++ b/lib/ExecutionEngine/ExecutionEngine.cpp @@ -21,6 +21,7 @@ #include "llvm/DerivedTypes.h" #include "llvm/ExecutionEngine/GenericValue.h" #include "llvm/Module.h" +#include "llvm/Operator.h" #include "llvm/Support/Debug.h" #include "llvm/Support/DynamicLibrary.h" #include "llvm/Support/ErrorHandling.h" @@ -555,11 +556,11 @@ GenericValue ExecutionEngine::getConstantValue(const Constant *C) { case Instruction::GetElementPtr: { // Compute the index GenericValue Result = getConstantValue(Op0); - SmallVector Indices(CE->op_begin()+1, CE->op_end()); - uint64_t Offset = TD->getIndexedOffset(Op0->getType(), Indices); + APInt Offset(TD->getPointerSizeInBits(), 0); + cast(CE)->accumulateConstantOffset(*TD, Offset); char* tmp = (char*) Result.PointerVal; - Result = PTOGV(tmp + Offset); + Result = PTOGV(tmp + Offset.getSExtValue()); return Result; } case Instruction::Trunc: { -- cgit v1.2.3