Fix a nasty bug that was causing miscompilation of global variables
authorChris Lattner <sabre@nondot.org>
Sun, 23 Oct 2005 23:54:56 +0000 (23:54 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 23 Oct 2005 23:54:56 +0000 (23:54 +0000)
on big endian 32-bit targets in some cases (e.g. PPC).  This fixes several
PPC JIT failures.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23914 91177308-0d34-0410-b5e6-96231b3b80d8

lib/ExecutionEngine/ExecutionEngine.cpp

index 36f7d2fdfc4e078f170d04d3eb29031a78fbdc3c..d8bd8f44aa34c6ffd97602da715896f24c58d255 100644 (file)
@@ -189,7 +189,10 @@ GenericValue ExecutionEngine::getConstantValue(const Constant *C) {
       uint64_t Offset =
         TD->getIndexedOffset(CE->getOperand(0)->getType(), Indexes);
 
-      Result.LongVal += Offset;
+      if (getTargetData().getPointerSize() == 4)
+        Result.IntVal += Offset;
+      else
+        Result.LongVal += Offset;
       return Result;
     }
     case Instruction::Cast: {