[llvm] r355174 - [ConstantHoisting] Call cleanup() in ConstantHoistingPass::runImpl to avoid dangling elements in ConstIntInfoVec for new PM
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 28 21:27:02 PST 2019
Author: maskray
Date: Thu Feb 28 21:27:01 2019
New Revision: 355174
URL: http://llvm.org/viewvc/llvm-project?rev=355174&view=rev
Log:
[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
Modified:
llvm/trunk/include/llvm/Transforms/Scalar/ConstantHoisting.h
llvm/trunk/lib/Transforms/Scalar/ConstantHoisting.cpp
llvm/trunk/test/Transforms/ConstantHoisting/X86/phi.ll
Modified: llvm/trunk/include/llvm/Transforms/Scalar/ConstantHoisting.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Scalar/ConstantHoisting.h?rev=355174&r1=355173&r2=355174&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Transforms/Scalar/ConstantHoisting.h (original)
+++ llvm/trunk/include/llvm/Transforms/Scalar/ConstantHoisting.h Thu Feb 28 21:27:01 2019
@@ -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)
Modified: llvm/trunk/lib/Transforms/Scalar/ConstantHoisting.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/ConstantHoisting.cpp?rev=355174&r1=355173&r2=355174&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/ConstantHoisting.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/ConstantHoisting.cpp Thu Feb 28 21:27:01 2019
@@ -114,8 +114,6 @@ public:
AU.addRequired<TargetTransformInfoWrapperPass>();
}
- void releaseMemory() override { Impl.releaseMemory(); }
-
private:
ConstantHoistingPass Impl;
};
@@ -947,6 +945,8 @@ bool ConstantHoistingPass::runImpl(Funct
// Cleanup dead instructions.
deleteDeadCastInst();
+ cleanup();
+
return MadeChange;
}
Modified: llvm/trunk/test/Transforms/ConstantHoisting/X86/phi.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/ConstantHoisting/X86/phi.ll?rev=355174&r1=355173&r2=355174&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/ConstantHoisting/X86/phi.ll (original)
+++ llvm/trunk/test/Transforms/ConstantHoisting/X86/phi.ll Thu Feb 28 21:27:01 2019
@@ -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"
More information about the llvm-commits
mailing list