[llvm-commits] CVS: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp

Reid Spencer reid at x10sys.com
Mon Mar 5 19:42:08 PST 2007



Changes in directory llvm/lib/ExecutionEngine/Interpreter:

Execution.cpp updated: 1.173 -> 1.174
---
Log message:

Fix a bug in IntToPtr. Truncating to 64-bits only works if the integer
is larger. Adjust so that it truncates to pointer width, only if necessary.


---
Diffs of the changes:  (+5 -1)

 Execution.cpp |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletion(-)


Index: llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
diff -u llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.173 llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.174
--- llvm/lib/ExecutionEngine/Interpreter/Execution.cpp:1.173	Mon Mar  5 21:09:31 2007
+++ llvm/lib/ExecutionEngine/Interpreter/Execution.cpp	Mon Mar  5 21:41:50 2007
@@ -1058,7 +1058,11 @@
   GenericValue Dest, Src = getOperandValue(SrcVal, SF);
   assert(isa<PointerType>(DstTy) && "Invalid PtrToInt instruction");
 
-  Dest.PointerVal = (PointerTy) Src.IntVal.trunc(64).getZExtValue();
+  uint32_t PtrSize = TD.getPointerSize();
+  if (PtrSize != Src.IntVal.getBitWidth())
+    Src.IntVal = Src.IntVal.trunc(PtrSize);
+
+  Dest.PointerVal = (PointerTy) Src.IntVal.getZExtValue();
   return Dest;
 }
 






More information about the llvm-commits mailing list