diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2007-03-06 03:41:50 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2007-03-06 03:41:50 +0000 |
commit | 7553c341354c7790cebda40ea0d647f9d204544b (patch) | |
tree | b72315aaa1f96490a1109397f49bb47635335baa /lib/ExecutionEngine/Interpreter/Execution.cpp | |
parent | 124294bc59dab9ec57fd7072cec574a4464ec59f (diff) | |
download | external_llvm-7553c341354c7790cebda40ea0d647f9d204544b.zip external_llvm-7553c341354c7790cebda40ea0d647f9d204544b.tar.gz external_llvm-7553c341354c7790cebda40ea0d647f9d204544b.tar.bz2 |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34954 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ExecutionEngine/Interpreter/Execution.cpp')
-rw-r--r-- | lib/ExecutionEngine/Interpreter/Execution.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/ExecutionEngine/Interpreter/Execution.cpp b/lib/ExecutionEngine/Interpreter/Execution.cpp index 76104b9..4a0c589 100644 --- a/lib/ExecutionEngine/Interpreter/Execution.cpp +++ b/lib/ExecutionEngine/Interpreter/Execution.cpp @@ -1058,7 +1058,11 @@ GenericValue Interpreter::executeIntToPtrInst(Value *SrcVal, const Type *DstTy, 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; } |