forked from OSchip/llvm-project
Avoid memory leakage by having caller construct the APInt for the
destination value of LoadValueFromMemory. llvm-svn: 34883
This commit is contained in:
parent
c3bfe13ed5
commit
00919f5769
|
@ -578,9 +578,9 @@ Store4BytesLittleEndian:
|
||||||
|
|
||||||
/// FIXME: document
|
/// FIXME: document
|
||||||
///
|
///
|
||||||
GenericValue ExecutionEngine::LoadValueFromMemory(GenericValue *Ptr,
|
void ExecutionEngine::LoadValueFromMemory(GenericValue &Result,
|
||||||
|
GenericValue *Ptr,
|
||||||
const Type *Ty) {
|
const Type *Ty) {
|
||||||
GenericValue Result;
|
|
||||||
if (getTargetData()->isLittleEndian()) {
|
if (getTargetData()->isLittleEndian()) {
|
||||||
switch (Ty->getTypeID()) {
|
switch (Ty->getTypeID()) {
|
||||||
case Type::IntegerTyID: {
|
case Type::IntegerTyID: {
|
||||||
|
@ -605,7 +605,7 @@ GenericValue ExecutionEngine::LoadValueFromMemory(GenericValue *Ptr,
|
||||||
((uint64_t)Ptr->Untyped[6] << 48) |
|
((uint64_t)Ptr->Untyped[6] << 48) |
|
||||||
((uint64_t)Ptr->Untyped[7] << 56);
|
((uint64_t)Ptr->Untyped[7] << 56);
|
||||||
} else
|
} else
|
||||||
Result.APIntVal = new APInt(BitWidth, BitWidth/64, (uint64_t*)Ptr);
|
*(Result.APIntVal) = APInt(BitWidth, BitWidth/64, (uint64_t*)Ptr);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Load4BytesLittleEndian:
|
Load4BytesLittleEndian:
|
||||||
|
@ -657,7 +657,7 @@ GenericValue ExecutionEngine::LoadValueFromMemory(GenericValue *Ptr,
|
||||||
((uint64_t)Ptr->Untyped[1] << 48) |
|
((uint64_t)Ptr->Untyped[1] << 48) |
|
||||||
((uint64_t)Ptr->Untyped[0] << 56);
|
((uint64_t)Ptr->Untyped[0] << 56);
|
||||||
} else
|
} else
|
||||||
Result.APIntVal = new APInt(BitWidth, BitWidth/64, (uint64_t*)Ptr);
|
*(Result.APIntVal) = APInt(BitWidth, BitWidth/64, (uint64_t*)Ptr);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Load4BytesBigEndian:
|
Load4BytesBigEndian:
|
||||||
|
@ -686,7 +686,6 @@ GenericValue ExecutionEngine::LoadValueFromMemory(GenericValue *Ptr,
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// InitializeMemory - Recursive function to apply a Constant value into the
|
// InitializeMemory - Recursive function to apply a Constant value into the
|
||||||
|
|
Loading…
Reference in New Issue