Skip to content

Revert "[flang][debug] Support mlir::NoneType." #113769

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
merged 1 commit into from
Oct 26, 2024

Conversation

jeanPerier
Copy link
Contributor

Reverts #113550

It turns out this causes compiler crashes with assumed-type arrays and -g.

Reproducer:

subroutine bug()
interface
  subroutine sub(a)
    type(*) :: a(*)
  end subroutine
end interface
  real :: x(10)
  call sub(x)
end subroutine

flang -g -c crashes with:

array types must have a base type
!18 = !DICompositeType(tag: DW_TAG_array_type, elements: !19)
error: failed to create the LLVM module

@jeanPerier jeanPerier requested a review from abidh October 26, 2024 19:33
@llvmbot llvmbot added flang Flang issues not falling into any other category flang:fir-hlfir labels Oct 26, 2024
@llvmbot
Copy link
Member

llvmbot commented Oct 26, 2024

@llvm/pr-subscribers-flang-fir-hlfir

Author: None (jeanPerier)

Changes

Reverts llvm/llvm-project#113550

It turns out this causes compiler crashes with assumed-type arrays and -g.

Reproducer:

subroutine bug()
interface
  subroutine sub(a)
    type(*) :: a(*)
  end subroutine
end interface
  real :: x(10)
  call sub(x)
end subroutine

flang -g -c crashes with:

array types must have a base type
!18 = !DICompositeType(tag: DW_TAG_array_type, elements: !19)
error: failed to create the LLVM module

Full diff: https://github.com/llvm/llvm-project/pull/113769.diff

2 Files Affected:

  • (modified) flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp (-2)
  • (removed) flang/test/Transforms/debug-none-type.fir (-14)
diff --git a/flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp b/flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp
index e387e27533a006..1ab6c76dae8eda 100644
--- a/flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp
+++ b/flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp
@@ -581,8 +581,6 @@ DebugTypeGenerator::convertType(mlir::Type Ty, mlir::LLVM::DIFileAttr fileAttr,
                                   /*genAssociated=*/false);
   } else if (auto vecTy = mlir::dyn_cast_or_null<fir::VectorType>(Ty)) {
     return convertVectorType(vecTy, fileAttr, scope, declOp);
-  } else if (mlir::isa<mlir::NoneType>(Ty)) {
-    return mlir::LLVM::DINullTypeAttr::get(context);
   } else if (auto boxTy = mlir::dyn_cast_or_null<fir::BoxType>(Ty)) {
     auto elTy = boxTy.getElementType();
     if (auto seqTy = mlir::dyn_cast_or_null<fir::SequenceType>(elTy))
diff --git a/flang/test/Transforms/debug-none-type.fir b/flang/test/Transforms/debug-none-type.fir
deleted file mode 100644
index 5eee6a63321904..00000000000000
--- a/flang/test/Transforms/debug-none-type.fir
+++ /dev/null
@@ -1,14 +0,0 @@
-// RUN: fir-opt --add-debug-info --mlir-print-debuginfo %s | FileCheck %s
-
-module attributes {dlti.dl_spec = #dlti.dl_spec<>} {
-  func.func private @_FortranAAssign(i8) -> none loc(#loc1)
-  func.func private @foo() -> !fir.ref<none>  loc(#loc2)
-}
-#loc1 = loc("test.f90":5:1)
-#loc2 = loc("test.f90":15:1)
-
-// CHECK: #[[INT8_TY:.*]] = #llvm.di_basic_type<tag = DW_TAG_base_type, name = "integer", sizeInBits = 8, encoding = DW_ATE_signed>
-// CHECK: #[[NONE_TY:.*]] = #llvm.di_null_type
-// CHECK: #[[REFNONE_TY:.*]] = #llvm.di_derived_type<tag = DW_TAG_pointer_type, name = "", baseType = #di_null_type{{.*}}>
-// CHECK: #llvm.di_subroutine_type<{{.*}}types = #[[NONE_TY]], #[[INT8_TY]]>
-// CHECK: #llvm.di_subroutine_type<{{.*}}types = #[[REFNONE_TY]]>

@jeanPerier
Copy link
Contributor Author

Since this was a small patch and the regressions impacts a lot of Fortran code, I am reverting now.

Note that this was not caught by LLVM bots running the Fortran tests in the llvm-test-suite because they are not run with -g.

@jeanPerier jeanPerier merged commit 64d7e45 into main Oct 26, 2024
6 of 8 checks passed
@jeanPerier jeanPerier deleted the revert-113550-none_type branch October 26, 2024 19:38
NoumanAmir657 pushed a commit to NoumanAmir657/llvm-project that referenced this pull request Nov 4, 2024
Reverts llvm#113550

It turns out this causes compiler crashes with assumed-type arrays and -g.
See llvm#113769 for a reproducer.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flang:fir-hlfir flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants