]> granicus.if.org Git - llvm/commitdiff
[ConstantHoisting] Call cleanup() in ConstantHoistingPass::runImpl to avoid dangling...
authorFangrui Song <maskray@google.com>
Fri, 1 Mar 2019 05:27:01 +0000 (05:27 +0000)
committerFangrui Song <maskray@google.com>
Fri, 1 Mar 2019 05:27:01 +0000 (05:27 +0000)
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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@355174 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Transforms/Scalar/ConstantHoisting.h
lib/Transforms/Scalar/ConstantHoisting.cpp
test/Transforms/ConstantHoisting/X86/phi.ll

index 29311ca2dae14544b02a320f25748b7736d1d33b..f947dafb906fdc0f0731942ada1e152b3232fe04 100644 (file)
@@ -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)
index 27d4f67ccc0f6ea3697dcd2d6756e0fa6bb8a5c7..1af14ea73b8a7dc9851c51fd4f064ee91ae77d78 100644 (file)
@@ -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;
 }
 
index 086df14047037a5a5d3b7317e8f557516e2728e1..f9fba3ee26a55086927799f627cdf94b7652b343 100644 (file)
@@ -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"