<div dir="ltr">Reverted.</div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jul 10, 2018 at 11:33 AM, Evgenii Stepanov <span dir="ltr"><<a href="mailto:eugeni.stepanov@gmail.com" target="_blank">eugeni.stepanov@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>this has created new memory leaks:</div><div><a href="http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap/builds/6289/steps/check-llvm%20asan/logs/stdio" target="_blank">http://lab.llvm.org:8011/<wbr>builders/sanitizer-x86_64-<wbr>linux-bootstrap/builds/6289/<wbr>steps/check-llvm%20asan/logs/<wbr>stdio</a><br></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jul 10, 2018 at 3:45 AM, Florian Hahn via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: fhahn<br>
Date: Tue Jul 10 03:45:46 2018<br>
New Revision: 336653<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=336653&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject?rev=336653&view=rev</a><br>
Log:<br>
[VPlan] Add VPlanTestBase.h with helper class to build VPlan for tests.<br>
<br>
Reviewers: dcaballe, hsaito, rengolin<br>
<br>
Reviewed By: dcaballe<br>
<br>
Differential Revision: <a href="https://reviews.llvm.org/D49032" rel="noreferrer" target="_blank">https://reviews.llvm.org/D4903<wbr>2</a><br>
<br>
Added:<br>
llvm/trunk/unittests/Transform<wbr>s/Vectorize/VPlanTestBase.h<br>
Modified:<br>
llvm/trunk/unittests/Transform<wbr>s/Vectorize/VPlanHCFGTest.cpp<br>
<br>
Modified: llvm/trunk/unittests/Transform<wbr>s/Vectorize/VPlanHCFGTest.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Transforms/Vectorize/VPlanHCFGTest.cpp?rev=336653&r1=336652&r2=336653&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/llvm/trunk/unittests/Tra<wbr>nsforms/Vectorize/VPlanHCFGTes<wbr>t.cpp?rev=336653&r1=336652&r2=<wbr>336653&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/unittests/Transform<wbr>s/Vectorize/VPlanHCFGTest.cpp (original)<br>
+++ llvm/trunk/unittests/Transform<wbr>s/Vectorize/VPlanHCFGTest.cpp Tue Jul 10 03:45:46 2018<br>
@@ -8,35 +8,16 @@<br>
//===------------------------<wbr>------------------------------<wbr>----------------===//<br>
<br>
#include "../lib/Transforms/Vectorize/V<wbr>Plan.h"<br>
-#include "../lib/Transforms/Vectorize/V<wbr>PlanHCFGBuilder.h"<br>
#include "../lib/Transforms/Vectorize/V<wbr>PlanHCFGTransforms.h"<br>
-#include "llvm/AsmParser/Parser.h"<br>
-#include "llvm/IR/Dominators.h"<br>
+#include "VPlanTestBase.h"<br>
#include "gtest/gtest.h"<br>
<br>
namespace llvm {<br>
namespace {<br>
<br>
-class VPlanHCFGTest : public testing::Test {<br>
-protected:<br>
- std::unique_ptr<DominatorTree> DT;<br>
- std::unique_ptr<LoopInfo> LI;<br>
-<br>
- VPlanHCFGTest() {}<br>
-<br>
- VPlanPtr doBuildPlan(BasicBlock *LoopHeader) {<br>
- DT.reset(new DominatorTree(*LoopHeader->get<wbr>Parent()));<br>
- LI.reset(new LoopInfo(*DT));<br>
-<br>
- auto Plan = llvm::make_unique<VPlan>();<br>
- VPlanHCFGBuilder HCFGBuilder(LI->getLoopFor(Loo<wbr>pHeader), LI.get());<br>
- HCFGBuilder.buildHierarchicalC<wbr>FG(*Plan.get());<br>
- return Plan;<br>
- }<br>
-};<br>
+class VPlanHCFGTest : public VPlanTestBase {};<br>
<br>
TEST_F(VPlanHCFGTest, testBuildHCFGInnerLoop) {<br>
- LLVMContext Ctx;<br>
const char *ModuleString =<br>
"define void @f(i32* %A, i64 %N) {\n"<br>
"entry:\n"<br>
@@ -54,12 +35,11 @@ TEST_F(VPlanHCFGTest, testBuildHCFGInner<br>
" ret void\n"<br>
"}\n";<br>
<br>
- SMDiagnostic Err;<br>
- std::unique_ptr<Module> M = parseAssemblyString(ModuleStri<wbr>ng, Err, Ctx);<br>
+ Module &M = parseModule(ModuleString);<br>
<br>
- Function *F = M->getFunction("f");<br>
+ Function *F = M.getFunction("f");<br>
BasicBlock *LoopHeader = F->getEntryBlock().getSingleSu<wbr>ccessor();<br>
- auto Plan = doBuildPlan(LoopHeader);<br>
+ auto Plan = buildHCFG(LoopHeader);<br>
<br>
VPBasicBlock *Entry = Plan->getEntry()->getEntryBasi<wbr>cBlock();<br>
EXPECT_NE(nullptr, Entry->getSingleSuccessor());<br>
@@ -115,7 +95,6 @@ TEST_F(VPlanHCFGTest, testBuildHCFGInner<br>
}<br>
<br>
TEST_F(VPlanHCFGTest, testVPInstructionToVPRecipesIn<wbr>ner) {<br>
- LLVMContext Ctx;<br>
const char *ModuleString =<br>
"define void @f(i32* %A, i64 %N) {\n"<br>
"entry:\n"<br>
@@ -133,12 +112,11 @@ TEST_F(VPlanHCFGTest, testVPInstructionT<br>
" ret void\n"<br>
"}\n";<br>
<br>
- SMDiagnostic Err;<br>
- std::unique_ptr<Module> M = parseAssemblyString(ModuleStri<wbr>ng, Err, Ctx);<br>
+ Module &M = parseModule(ModuleString);<br>
<br>
- Function *F = M->getFunction("f");<br>
+ Function *F = M.getFunction("f");<br>
BasicBlock *LoopHeader = F->getEntryBlock().getSingleSu<wbr>ccessor();<br>
- auto Plan = doBuildPlan(LoopHeader);<br>
+ auto Plan = buildHCFG(LoopHeader);<br>
<br>
LoopVectorizationLegality::In<wbr>ductionList Inductions;<br>
SmallPtrSet<Instruction *, 1> DeadInstructions;<br>
<br>
Added: llvm/trunk/unittests/Transform<wbr>s/Vectorize/VPlanTestBase.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Transforms/Vectorize/VPlanTestBase.h?rev=336653&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/llvm/trunk/unittests/Tra<wbr>nsforms/Vectorize/VPlanTestBas<wbr>e.h?rev=336653&view=auto</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/unittests/Transform<wbr>s/Vectorize/VPlanTestBase.h (added)<br>
+++ llvm/trunk/unittests/Transform<wbr>s/Vectorize/VPlanTestBase.h Tue Jul 10 03:45:46 2018<br>
@@ -0,0 +1,68 @@<br>
+//===- llvm/unittest/Transforms/Vecto<wbr>rize/VPlanTestBase.h -----------------===//<br>
+//<br>
+// The LLVM Compiler Infrastructure<br>
+//<br>
+// This file is distributed under the University of Illinois Open Source<br>
+// License. See LICENSE.TXT for details.<br>
+//<br>
+//===------------------------<wbr>------------------------------<wbr>----------------===//<br>
+/// \file<br>
+/// This file defines a VPlanTestBase class, which provides helpers to parse<br>
+/// a LLVM IR string and create VPlans given a loop entry block.<br>
+//===------------------------<wbr>------------------------------<wbr>----------------===//<br>
+#ifndef LLVM_UNITTESTS_TRANSFORMS_VECT<wbr>ORIZE_VPLANTESTBASE_H<br>
+#define LLVM_UNITTESTS_TRANSFORMS_VECT<wbr>ORIZE_VPLANTESTBASE_H<br>
+<br>
+#include "../lib/Transforms/Vectorize/V<wbr>Plan.h"<br>
+#include "../lib/Transforms/Vectorize/V<wbr>PlanHCFGBuilder.h"<br>
+#include "llvm/Analysis/LoopInfo.h"<br>
+#include "llvm/AsmParser/Parser.h"<br>
+#include "llvm/IR/Dominators.h"<br>
+#include "llvm/Support/SourceMgr.h"<br>
+#include "gtest/gtest.h"<br>
+<br>
+namespace llvm {<br>
+<br>
+/// Helper class to create a module from an assembly string and VPlans for a<br>
+/// given loop entry block.<br>
+class VPlanTestBase : public testing::Test {<br>
+protected:<br>
+ std::unique_ptr<DominatorTree> DT;<br>
+ std::unique_ptr<LoopInfo> LI;<br>
+ std::unique_ptr<Module> M;<br>
+ std::unique_ptr<LLVMContext> Ctx;<br>
+<br>
+ VPlanTestBase() : Ctx(new LLVMContext) {}<br>
+ ~VPlanTestBase() {<br>
+ LI.release();<br>
+ DT.release();<br>
+ M.release();<br>
+ // We need to release objects depending on Ctx first.<br>
+ Ctx.release();<br>
+ }<br>
+<br>
+ Module &parseModule(const char *ModuleString) {<br>
+ SMDiagnostic Err;<br>
+ M = parseAssemblyString(ModuleStri<wbr>ng, Err, *Ctx);<br>
+ EXPECT_TRUE(M);<br>
+ return *M;<br>
+ }<br>
+<br>
+ void doAnalysis(Function &F) {<br>
+ DT.reset(new DominatorTree(F));<br>
+ LI.reset(new LoopInfo(*DT));<br>
+ }<br>
+<br>
+ VPlanPtr buildHCFG(BasicBlock *LoopHeader) {<br>
+ doAnalysis(*LoopHeader->getPa<wbr>rent());<br>
+<br>
+ auto Plan = llvm::make_unique<VPlan>();<br>
+ VPlanHCFGBuilder HCFGBuilder(LI->getLoopFor(Loo<wbr>pHeader), LI.get());<br>
+ HCFGBuilder.buildHierarchicalC<wbr>FG(*Plan.get());<br>
+ return Plan;<br>
+ }<br>
+};<br>
+<br>
+} // namespace llvm<br>
+<br>
+#endif // LLVM_UNITTESTS_TRANSFORMS_VECT<wbr>ORIZE_VPLANTESTBASE_H<br>
<br>
<br>
______________________________<wbr>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>