-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Revert "[flang] Fix seg fault CodeGenAction::executeAction()
(#78269)"
#78667
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@llvm/pr-subscribers-flang-driver Author: Kareem Ergawy (ergawy) ChangesThis reverts commit 99cae9a. Temporarily until I reproduce and fix a linker issue:
Full diff: https://github.com/llvm/llvm-project/pull/78667.diff 3 Files Affected:
diff --git a/flang/lib/Frontend/FrontendActions.cpp b/flang/lib/Frontend/FrontendActions.cpp
index 65c4df7388f97b2..74e3992d5ab62ba 100644
--- a/flang/lib/Frontend/FrontendActions.cpp
+++ b/flang/lib/Frontend/FrontendActions.cpp
@@ -1202,11 +1202,6 @@ void CodeGenAction::executeAction() {
if (!llvmModule)
generateLLVMIR();
- // If generating the LLVM module failed, abort! No need for further error
- // reporting since generateLLVMIR() does this already.
- if (!llvmModule)
- return;
-
// Set the triple based on the targetmachine (this comes compiler invocation
// and the command-line target option if specified, or the default if not
// given on the command-line).
diff --git a/flang/unittests/Frontend/CMakeLists.txt b/flang/unittests/Frontend/CMakeLists.txt
index 3bcc37bed7f6d11..79a394f161ed1ec 100644
--- a/flang/unittests/Frontend/CMakeLists.txt
+++ b/flang/unittests/Frontend/CMakeLists.txt
@@ -4,7 +4,6 @@ set(LLVM_LINK_COMPONENTS
)
add_flang_unittest(FlangFrontendTests
- CodeGenActionTest.cpp
CompilerInstanceTest.cpp
FrontendActionTest.cpp
)
diff --git a/flang/unittests/Frontend/CodeGenActionTest.cpp b/flang/unittests/Frontend/CodeGenActionTest.cpp
deleted file mode 100644
index 9d798c7678ad158..000000000000000
--- 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");
-}
|
ergawy
added a commit
to ergawy/llvm-project
that referenced
this pull request
Jan 19, 2024
llvm#78269)" (llvm#78667)" This reverts commit 4fc7506. Re-applies PR llvm#78269 and adds LLVM and MLIR dependencies that were missed in the PR. The missing libs were: `LLVMCore` & `MLIRIR`.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This reverts commit 99cae9a.
Temporarily until I reproduce and fix a linker issue: