From be1197c403b22291e35cbc5e96788860ceabd40c Mon Sep 17 00:00:00 2001 From: Sourabh Singh Tomar Date: Wed, 23 Sep 2020 18:02:49 +0530 Subject: [PATCH] [flang] Removed OpenMP lowering unittests These tests aren't adding much value and consensus has been reached for there removal. For more context, please refer to discussion in this revision: https://reviews.llvm.org/D87846 --- flang/unittests/CMakeLists.txt | 1 - flang/unittests/Lower/CMakeLists.txt | 13 ---- flang/unittests/Lower/OpenMPLoweringTest.cpp | 102 --------------------------- 3 files changed, 116 deletions(-) delete mode 100644 flang/unittests/Lower/CMakeLists.txt delete mode 100644 flang/unittests/Lower/OpenMPLoweringTest.cpp diff --git a/flang/unittests/CMakeLists.txt b/flang/unittests/CMakeLists.txt index c88e9fc..9f068fb 100644 --- a/flang/unittests/CMakeLists.txt +++ b/flang/unittests/CMakeLists.txt @@ -21,7 +21,6 @@ add_subdirectory(Optimizer) add_subdirectory(Decimal) add_subdirectory(Evaluate) add_subdirectory(Runtime) -add_subdirectory(Lower) if (FLANG_BUILD_NEW_DRIVER) add_subdirectory(Frontend) diff --git a/flang/unittests/Lower/CMakeLists.txt b/flang/unittests/Lower/CMakeLists.txt deleted file mode 100644 index 19535e8f..0000000 --- a/flang/unittests/Lower/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS) - -set(LIBS - MLIRLLVMIR - ${dialect_libs} -) - -add_flang_unittest(FlangLoweringOpenMPTests - OpenMPLoweringTest.cpp -) -target_link_libraries(FlangLoweringOpenMPTests - PRIVATE - ${LIBS}) diff --git a/flang/unittests/Lower/OpenMPLoweringTest.cpp b/flang/unittests/Lower/OpenMPLoweringTest.cpp deleted file mode 100644 index dc002ce..0000000 --- a/flang/unittests/Lower/OpenMPLoweringTest.cpp +++ /dev/null @@ -1,102 +0,0 @@ -//===- OpenMPLoweringTest.cpp -- OpenMPLowering unit tests ----------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include "gtest/gtest.h" -#include "mlir/Dialect/OpenMP/OpenMPDialect.h" -#include "mlir/IR/Builders.h" -#include "mlir/InitAllDialects.h" -#include "flang/Parser/parse-tree.h" -#include "llvm/Frontend/OpenMP/OMPConstants.h" - -class OpenMPLoweringTest : public testing::Test { -protected: - void SetUp() override { - ctx.loadDialect(); - mlir::registerAllDialects(ctx.getDialectRegistry()); - mlirOpBuilder.reset(new mlir::OpBuilder(&ctx)); - } - - void TearDown() override { mlirOpBuilder.reset(); } - - mlir::MLIRContext ctx; - std::unique_ptr mlirOpBuilder; -}; - -TEST_F(OpenMPLoweringTest, Barrier) { - // Construct a dummy parse tree node for `!OMP barrier`. - struct Fortran::parser::OmpSimpleStandaloneDirective barrierDirective( - llvm::omp::Directive::OMPD_barrier); - - // Check and lower the `!OMP barrier` node to `BarrierOp` operation of - // OpenMPDialect. - EXPECT_EQ(barrierDirective.v, llvm::omp::Directive::OMPD_barrier); - auto barrierOp = mlirOpBuilder->create( - mlirOpBuilder->getUnknownLoc()); - - EXPECT_EQ(barrierOp.getOperationName(), "omp.barrier"); - EXPECT_EQ(succeeded(barrierOp.verify()), true); -} - -TEST_F(OpenMPLoweringTest, TaskWait) { - // Construct a dummy parse tree node for `!OMP taskwait`. - struct Fortran::parser::OmpSimpleStandaloneDirective taskWaitDirective( - llvm::omp::Directive::OMPD_taskwait); - - // Check and lower the `!OMP taskwait` node to `TaskwaitOp` operation of - // OpenMPDialect. - EXPECT_EQ(taskWaitDirective.v, llvm::omp::Directive::OMPD_taskwait); - auto taskWaitOp = mlirOpBuilder->create( - mlirOpBuilder->getUnknownLoc()); - - EXPECT_EQ(taskWaitOp.getOperationName(), "omp.taskwait"); - EXPECT_EQ(succeeded(taskWaitOp.verify()), true); -} - -TEST_F(OpenMPLoweringTest, TaskYield) { - // Construct a dummy parse tree node for `!OMP taskyield`. - struct Fortran::parser::OmpSimpleStandaloneDirective taskYieldDirective( - llvm::omp::Directive::OMPD_taskyield); - - // Check and lower the `!OMP taskyield` node to `TaskYieldOp` operation of - // OpenMPDialect. - EXPECT_EQ(taskYieldDirective.v, llvm::omp::Directive::OMPD_taskyield); - auto taskYieldOp = mlirOpBuilder->create( - mlirOpBuilder->getUnknownLoc()); - - EXPECT_EQ(taskYieldOp.getOperationName(), "omp.taskyield"); - EXPECT_EQ(succeeded(taskYieldOp.verify()), true); -} - -TEST_F(OpenMPLoweringTest, EmptyParallel) { - // Construct a dummy parse tree node for `!OMP parallel`. - struct Fortran::parser::OmpSimpleStandaloneDirective parallelDirective( - llvm::omp::Directive::OMPD_parallel); - - // Check and lower the `!OMP parallel` node to `ParallelOp` operation of - // OpenMPDialect. - EXPECT_EQ(parallelDirective.v, llvm::omp::Directive::OMPD_parallel); - auto insertPt = mlirOpBuilder->saveInsertionPoint(); - llvm::ArrayRef argTy; - mlir::ValueRange range; - llvm::SmallVector operandSegmentSizes(6 /*Size=*/, 0 /*Value=*/); - // create and insert the operation. - auto parallelOp = mlirOpBuilder->create( - mlirOpBuilder->getUnknownLoc(), argTy, range); - parallelOp.setAttr(mlir::omp::ParallelOp::getOperandSegmentSizeAttr(), - mlirOpBuilder->getI32VectorAttr(operandSegmentSizes)); - parallelOp.getRegion().push_back(new mlir::Block{}); - auto &block = parallelOp.getRegion().back(); - mlirOpBuilder->setInsertionPointToStart(&block); - // ensure the block is well-formed. - mlirOpBuilder->create( - mlirOpBuilder->getUnknownLoc()); - mlirOpBuilder->restoreInsertionPoint(insertPt); - EXPECT_EQ(succeeded(parallelOp.verify()), true); -} - -// main() from gtest_main -- 2.7.4