forked from OSchip/llvm-project
[ManagedMemoryRewrite] Make pass more robust and fix memory issue
Instead of using Twines and temporary expressions, we do string manipulation through a std::string. This resolves a memory corruption issue, which likely was caused by twines loosing their underlying string too soon. llvm-svn: 311264
This commit is contained in:
parent
a0319bb434
commit
9041118983
|
@ -218,13 +218,15 @@ replaceGlobalArray(Module &M, const DataLayout &DL, GlobalVariable &Array,
|
|||
// At this point, we have committed to replacing this array.
|
||||
ReplacedGlobals.insert(&Array);
|
||||
|
||||
std::string NewName = (Array.getName() + Twine(".toptr")).str();
|
||||
std::string NewName = Array.getName();
|
||||
NewName += ".toptr";
|
||||
GlobalVariable *ReplacementToArr =
|
||||
cast<GlobalVariable>(M.getOrInsertGlobal(NewName, ElemPtrTy));
|
||||
ReplacementToArr->setInitializer(ConstantPointerNull::get(ElemPtrTy));
|
||||
|
||||
Function *PollyMallocManaged = getOrCreatePollyMallocManaged(M);
|
||||
Twine FnName = Array.getName() + ".constructor";
|
||||
std::string FnName = Array.getName();
|
||||
FnName += ".constructor";
|
||||
PollyIRBuilder Builder(M.getContext());
|
||||
FunctionType *Ty = FunctionType::get(Builder.getVoidTy(), false);
|
||||
const GlobalValue::LinkageTypes Linkage = Function::ExternalLinkage;
|
||||
|
|
Loading…
Reference in New Issue