aboutsummaryrefslogtreecommitdiff
path: root/flang/unittests/Frontend/CodeGenActionTest.cpp
diff options
context:
space:
mode:
authorKareem Ergawy <kareem.ergawy@amd.com>2024-01-19 05:30:29 +0100
committerGitHub <noreply@github.com>2024-01-19 05:30:29 +0100
commit4fc75062745eb5232ea60c37b9ffe61177efa12a (patch)
tree5cb7966f85396a350a72a6d5fd4240e71ecd9d16 /flang/unittests/Frontend/CodeGenActionTest.cpp
parent1f61507401995b434a0720d3f9869659466d9b31 (diff)
downloadllvm-4fc75062745eb5232ea60c37b9ffe61177efa12a.zip
llvm-4fc75062745eb5232ea60c37b9ffe61177efa12a.tar.gz
llvm-4fc75062745eb5232ea60c37b9ffe61177efa12a.tar.bz2
Revert "[flang] Fix seg fault `CodeGenAction::executeAction()` (#78269)" (#78667)
This reverts commit 99cae9a44fca4cfbd6ee82f196051cbdf6571fa1. Temporarily until I reproduce and fix a linker issue: ``` FAILED: tools/flang/unittests/Frontend/FlangFrontendTests ... /usr/bin/ld: tools/flang/unittests/Frontend/CMakeFiles/FlangFrontendTests.dir/CodeGenActionTest.cpp.o: undefined reference to symbol '_ZN4llvm11LLVMContextC1Ev' /usr/bin/ld: /work1/omp-nightly/build/git/trunk18.0/build/llvm-project/lib/libLLVMCore.so.18git: error adding symbols: DSO missing from command line ```
Diffstat (limited to 'flang/unittests/Frontend/CodeGenActionTest.cpp')
-rw-r--r--flang/unittests/Frontend/CodeGenActionTest.cpp109
1 files changed, 0 insertions, 109 deletions
diff --git a/flang/unittests/Frontend/CodeGenActionTest.cpp b/flang/unittests/Frontend/CodeGenActionTest.cpp
deleted file mode 100644
index 9d798c7..0000000
--- a/flang/unittests/Frontend/CodeGenActionTest.cpp
+++ /dev/null
@@ -1,109 +0,0 @@
-//===- unittests/Frontend/CodeGenActionTest.cpp --- FrontendAction 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
-//
-//===----------------------------------------------------------------------===//
-//
-// Unit tests for CodeGenAction.
-//
-//===----------------------------------------------------------------------===//
-
-#include "mlir/IR/Builders.h"
-#include "flang/Frontend/CompilerInstance.h"
-#include "flang/Frontend/FrontendActions.h"
-#include "flang/Frontend/TextDiagnosticPrinter.h"
-
-#include "gtest/gtest.h"
-
-#include <memory>
-
-using namespace Fortran::frontend;
-
-namespace test {
-class DummyDialect : public ::mlir::Dialect {
- explicit DummyDialect(::mlir::MLIRContext *context)
- : ::mlir::Dialect(getDialectNamespace(), context,
- ::mlir::TypeID::get<DummyDialect>()) {
- initialize();
- }
-
- void initialize();
- friend class ::mlir::MLIRContext;
-
-public:
- ~DummyDialect() override = default;
- static constexpr ::llvm::StringLiteral getDialectNamespace() {
- return ::llvm::StringLiteral("dummy");
- }
-};
-
-namespace dummy {
-class FakeOp : public ::mlir::Op<FakeOp> {
-public:
- using Op::Op;
-
- static llvm::StringRef getOperationName() { return "dummy.fake"; }
-
- static ::llvm::ArrayRef<::llvm::StringRef> getAttributeNames() { return {}; }
-
- static void build(
- ::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState) {}
-};
-} // namespace dummy
-} // namespace test
-
-MLIR_DECLARE_EXPLICIT_TYPE_ID(::test::DummyDialect)
-MLIR_DEFINE_EXPLICIT_TYPE_ID(::test::DummyDialect)
-
-namespace test {
-
-void DummyDialect::initialize() { addOperations<::test::dummy::FakeOp>(); }
-} // namespace test
-
-// A test CodeGenAction to verify that we gracefully handle failure to convert
-// from MLIR to LLVM IR.
-class LLVMConversionFailureCodeGenAction : public CodeGenAction {
-public:
- LLVMConversionFailureCodeGenAction()
- : CodeGenAction(BackendActionTy::Backend_EmitLL) {
- mlirCtx = std::make_unique<mlir::MLIRContext>();
- mlirCtx->loadDialect<test::DummyDialect>();
-
- mlir::Location loc(mlir::UnknownLoc::get(mlirCtx.get()));
- mlirModule =
- std::make_unique<mlir::ModuleOp>(mlir::ModuleOp::create(loc, "mod"));
-
- mlir::OpBuilder builder(mlirCtx.get());
- builder.setInsertionPointToStart(&mlirModule->getRegion().front());
- // Create a fake op to trip conversion to LLVM.
- builder.create<test::dummy::FakeOp>(loc);
-
- llvmCtx = std::make_unique<llvm::LLVMContext>();
- }
-};
-
-TEST(CodeGenAction, GracefullyHandleLLVMConversionFailure) {
- std::string diagnosticOutput;
- llvm::raw_string_ostream diagnosticsOS(diagnosticOutput);
- auto diagPrinter = std::make_unique<Fortran::frontend::TextDiagnosticPrinter>(
- diagnosticsOS, new clang::DiagnosticOptions());
-
- CompilerInstance ci;
- ci.createDiagnostics(diagPrinter.get(), /*ShouldOwnClient=*/false);
- ci.setInvocation(std::make_shared<CompilerInvocation>());
- ci.setOutputStream(std::make_unique<llvm::raw_null_ostream>());
- ci.getInvocation().getCodeGenOpts().OptimizationLevel = 0;
-
- FrontendInputFile file("/dev/null", InputKind());
-
- LLVMConversionFailureCodeGenAction action;
- action.setInstance(&ci);
- action.setCurrentInput(file);
-
- consumeError(action.execute());
- ASSERT_EQ(diagnosticsOS.str(),
- "error: Lowering to LLVM IR failed\n"
- "error: failed to create the LLVM module\n");
-}