diff options
author | Fangrui Song <maskray@google.com> | 2019-03-01 05:27:01 +0000 |
---|---|---|
committer | Fangrui Song <maskray@google.com> | 2019-03-01 05:27:01 +0000 |
commit | f4b25f700a4c555711a746befe7ca3a6e93e621d (patch) | |
tree | a3e5a3324d182408bddcb33ddbc18a0f179f7945 | |
parent | 7507208a9adfebcd950aacd223bcae2c1283896f (diff) | |
download | bcm5719-llvm-f4b25f700a4c555711a746befe7ca3a6e93e621d.tar.gz bcm5719-llvm-f4b25f700a4c555711a746befe7ca3a6e93e621d.zip |
[ConstantHoisting] Call cleanup() in ConstantHoistingPass::runImpl to avoid dangling elements in ConstIntInfoVec for new PM
Summary:
ConstIntInfoVec contains elements extracted from the previous function.
In new PM, releaseMemory() is not called and the dangling elements can
cause segfault in findConstantInsertionPoint.
Rename releaseMemory() to cleanup() to deliver the idea that it is
mandatory and call cleanup() in ConstantHoistingPass::runImpl to fix
this.
Reviewers: ormris, zzheng, dmgreen, wmi
Reviewed By: ormris, wmi
Subscribers: llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D58589
llvm-svn: 355174
-rw-r--r-- | llvm/include/llvm/Transforms/Scalar/ConstantHoisting.h | 2 | ||||
-rw-r--r-- | llvm/lib/Transforms/Scalar/ConstantHoisting.cpp | 4 | ||||
-rw-r--r-- | llvm/test/Transforms/ConstantHoisting/X86/phi.ll | 1 |
3 files changed, 4 insertions, 3 deletions
diff --git a/llvm/include/llvm/Transforms/Scalar/ConstantHoisting.h b/llvm/include/llvm/Transforms/Scalar/ConstantHoisting.h index 29311ca2dae..f947dafb906 100644 --- a/llvm/include/llvm/Transforms/Scalar/ConstantHoisting.h +++ b/llvm/include/llvm/Transforms/Scalar/ConstantHoisting.h @@ -126,7 +126,7 @@ public: bool runImpl(Function &F, TargetTransformInfo &TTI, DominatorTree &DT, BlockFrequencyInfo *BFI, BasicBlock &Entry); - void releaseMemory() { + void cleanup() { ClonedCastMap.clear(); ConstIntCandVec.clear(); for (auto MapEntry : ConstGEPCandMap) diff --git a/llvm/lib/Transforms/Scalar/ConstantHoisting.cpp b/llvm/lib/Transforms/Scalar/ConstantHoisting.cpp index 27d4f67ccc0..1af14ea73b8 100644 --- a/llvm/lib/Transforms/Scalar/ConstantHoisting.cpp +++ b/llvm/lib/Transforms/Scalar/ConstantHoisting.cpp @@ -114,8 +114,6 @@ public: AU.addRequired<TargetTransformInfoWrapperPass>(); } - void releaseMemory() override { Impl.releaseMemory(); } - private: ConstantHoistingPass Impl; }; @@ -947,6 +945,8 @@ bool ConstantHoistingPass::runImpl(Function &Fn, TargetTransformInfo &TTI, // Cleanup dead instructions. deleteDeadCastInst(); + cleanup(); + return MadeChange; } diff --git a/llvm/test/Transforms/ConstantHoisting/X86/phi.ll b/llvm/test/Transforms/ConstantHoisting/X86/phi.ll index 086df140470..f9fba3ee26a 100644 --- a/llvm/test/Transforms/ConstantHoisting/X86/phi.ll +++ b/llvm/test/Transforms/ConstantHoisting/X86/phi.ll @@ -1,4 +1,5 @@ ; RUN: opt -S -consthoist < %s | FileCheck %s +; RUN: opt -S -passes=consthoist < %s | FileCheck %s target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-apple-macosx10.9.0" |