From d5bc41a2497b8ccfc21fe4de9f48e3db3a21895c Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 25 Apr 2003 04:21:19 +0000 Subject: [PATCH] Fix problem where we would read 64 bits worth of pointer information, even on 32 bit targets! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5930 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/ExecutionEngine/Interpreter/Execution.cpp | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/ExecutionEngine/Interpreter/Execution.cpp b/lib/ExecutionEngine/Interpreter/Execution.cpp index 9d5166dab81..a14adafa0b6 100644 --- a/lib/ExecutionEngine/Interpreter/Execution.cpp +++ b/lib/ExecutionEngine/Interpreter/Execution.cpp @@ -6,12 +6,8 @@ #include "Interpreter.h" #include "ExecutionAnnotations.h" -#include "llvm/GlobalVariable.h" -#include "llvm/Function.h" -#include "llvm/iPHINode.h" -#include "llvm/iOther.h" -#include "llvm/iTerminators.h" -#include "llvm/iMemory.h" +#include "llvm/Module.h" +#include "llvm/Instructions.h" #include "llvm/DerivedTypes.h" #include "llvm/Constants.h" #include "llvm/Assembly/Writer.h" @@ -776,6 +772,7 @@ void Interpreter::executeLoadInst(LoadInst &I, ExecutionContext &SF) { case Type::ShortTyID: Result.UShortVal = (unsigned)Ptr->Untyped[0] | ((unsigned)Ptr->Untyped[1] << 8); break; + Load4BytesLittleEndian: case Type::FloatTyID: case Type::UIntTyID: case Type::IntTyID: Result.UIntVal = (unsigned)Ptr->Untyped[0] | @@ -783,10 +780,11 @@ void Interpreter::executeLoadInst(LoadInst &I, ExecutionContext &SF) { ((unsigned)Ptr->Untyped[2] << 16) | ((unsigned)Ptr->Untyped[3] << 24); break; + case Type::PointerTyID: if (getModule().has32BitPointers()) + goto Load4BytesLittleEndian; case Type::DoubleTyID: case Type::ULongTyID: - case Type::LongTyID: - case Type::PointerTyID: Result.ULongVal = (uint64_t)Ptr->Untyped[0] | + case Type::LongTyID: Result.ULongVal = (uint64_t)Ptr->Untyped[0] | ((uint64_t)Ptr->Untyped[1] << 8) | ((uint64_t)Ptr->Untyped[2] << 16) | ((uint64_t)Ptr->Untyped[3] << 24) | @@ -808,6 +806,7 @@ void Interpreter::executeLoadInst(LoadInst &I, ExecutionContext &SF) { case Type::ShortTyID: Result.UShortVal = (unsigned)Ptr->Untyped[1] | ((unsigned)Ptr->Untyped[0] << 8); break; + Load4BytesBigEndian: case Type::FloatTyID: case Type::UIntTyID: case Type::IntTyID: Result.UIntVal = (unsigned)Ptr->Untyped[3] | @@ -815,10 +814,11 @@ void Interpreter::executeLoadInst(LoadInst &I, ExecutionContext &SF) { ((unsigned)Ptr->Untyped[1] << 16) | ((unsigned)Ptr->Untyped[0] << 24); break; + case Type::PointerTyID: if (getModule().has32BitPointers()) + goto Load4BytesBigEndian; case Type::DoubleTyID: case Type::ULongTyID: - case Type::LongTyID: - case Type::PointerTyID: Result.ULongVal = (uint64_t)Ptr->Untyped[7] | + case Type::LongTyID: Result.ULongVal = (uint64_t)Ptr->Untyped[7] | ((uint64_t)Ptr->Untyped[6] << 8) | ((uint64_t)Ptr->Untyped[5] << 16) | ((uint64_t)Ptr->Untyped[4] << 24) |