summaryrefslogtreecommitdiffstats
path: root/polly/lib/CodeGen
diff options
context:
space:
mode:
authorTobias Grosser <tobias@grosser.es>2017-08-19 23:03:45 +0000
committerTobias Grosser <tobias@grosser.es>2017-08-19 23:03:45 +0000
commit904111898305cae263179964cb2a689d27ff6512 (patch)
tree08d57207efb345f6a4f709d76fb99233bfe8ddd4 /polly/lib/CodeGen
parenta0319bb434cb7ca1cac3c210f995d4418b15078d (diff)
downloadbcm5719-llvm-904111898305cae263179964cb2a689d27ff6512.tar.gz
bcm5719-llvm-904111898305cae263179964cb2a689d27ff6512.zip
[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
Diffstat (limited to 'polly/lib/CodeGen')
-rw-r--r--polly/lib/CodeGen/ManagedMemoryRewrite.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/polly/lib/CodeGen/ManagedMemoryRewrite.cpp b/polly/lib/CodeGen/ManagedMemoryRewrite.cpp
index 95f9d7dceed..989b5f40147 100644
--- a/polly/lib/CodeGen/ManagedMemoryRewrite.cpp
+++ b/polly/lib/CodeGen/ManagedMemoryRewrite.cpp
@@ -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;
OpenPOWER on IntegriCloud