mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-16 08:08:01 +00:00
Grab the LLVMContext and parent Module of SI ahead of the
point where SI can get deleted. This fixes a use of free'd memory. This fixes Externals/Povray. llvm-svn: 77285
This commit is contained in:
parent
0bcb94eeff
commit
361e911b89
@ -352,6 +352,8 @@ bool MemCpyOpt::processStore(StoreInst *SI, BasicBlock::iterator& BBI) {
|
||||
|
||||
TargetData &TD = getAnalysis<TargetData>();
|
||||
AliasAnalysis &AA = getAnalysis<AliasAnalysis>();
|
||||
LLVMContext &Context = SI->getContext();
|
||||
Module *M = SI->getParent()->getParent()->getParent();
|
||||
|
||||
// Okay, so we now have a single store that can be splatable. Scan to find
|
||||
// all subsequent stores of the same value to offset from the same pointer.
|
||||
@ -431,8 +433,7 @@ bool MemCpyOpt::processStore(StoreInst *SI, BasicBlock::iterator& BBI) {
|
||||
|
||||
if (MemSetF == 0) {
|
||||
const Type *Tys[] = {Type::Int64Ty};
|
||||
MemSetF = Intrinsic::getDeclaration(SI->getParent()->getParent()
|
||||
->getParent(), Intrinsic::memset,
|
||||
MemSetF = Intrinsic::getDeclaration(M, Intrinsic::memset,
|
||||
Tys, 1);
|
||||
}
|
||||
|
||||
@ -440,7 +441,7 @@ bool MemCpyOpt::processStore(StoreInst *SI, BasicBlock::iterator& BBI) {
|
||||
StartPtr = Range.StartPtr;
|
||||
|
||||
// Cast the start ptr to be i8* as memset requires.
|
||||
const Type *i8Ptr = SI->getContext().getPointerTypeUnqual(Type::Int8Ty);
|
||||
const Type *i8Ptr = Context.getPointerTypeUnqual(Type::Int8Ty);
|
||||
if (StartPtr->getType() != i8Ptr)
|
||||
StartPtr = new BitCastInst(StartPtr, i8Ptr, StartPtr->getName(),
|
||||
InsertPt);
|
||||
|
Loading…
Reference in New Issue
Block a user