[polly] r311264 - [ManagedMemoryRewrite] Make pass more robust and fix memory issue
Tobias Grosser via llvm-commits
llvm-commits at lists.llvm.org
Sat Aug 19 16:03:45 PDT 2017
Author: grosser
Date: Sat Aug 19 16:03:45 2017
New Revision: 311264
URL: http://llvm.org/viewvc/llvm-project?rev=311264&view=rev
Log:
[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.
Modified:
polly/trunk/lib/CodeGen/ManagedMemoryRewrite.cpp
Modified: polly/trunk/lib/CodeGen/ManagedMemoryRewrite.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/ManagedMemoryRewrite.cpp?rev=311264&r1=311263&r2=311264&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/ManagedMemoryRewrite.cpp (original)
+++ polly/trunk/lib/CodeGen/ManagedMemoryRewrite.cpp Sat Aug 19 16:03:45 2017
@@ -218,13 +218,15 @@ replaceGlobalArray(Module &M, const Data
// 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;
More information about the llvm-commits
mailing list