[flang][debug] Support fir::ReferenceType.#113480
Merged
Conversation
Member
|
@llvm/pr-subscribers-flang-fir-hlfir Author: Abid Qadeer (abidh) ChangesFull diff: https://github.com/llvm/llvm-project/pull/113480.diff 2 Files Affected:
diff --git a/flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp b/flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp
index 71e534b4f2e2a3..84f7873a9fd009 100644
--- a/flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp
+++ b/flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp
@@ -511,6 +511,11 @@ DebugTypeGenerator::convertType(mlir::Type Ty, mlir::LLVM::DIFileAttr fileAttr,
/*hasDescriptor=*/false);
} else if (auto recTy = mlir::dyn_cast_or_null<fir::RecordType>(Ty)) {
return convertRecordType(recTy, fileAttr, scope, declOp);
+ } else if (auto refTy = mlir::dyn_cast_if_present<fir::ReferenceType>(Ty)) {
+ auto elTy = refTy.getEleTy();
+ return convertPointerLikeType(elTy, fileAttr, scope, declOp,
+ /*genAllocated=*/false,
+ /*genAssociated=*/false);
} 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-ref-type.fir b/flang/test/Transforms/debug-ref-type.fir
new file mode 100644
index 00000000000000..2b3af485385d8a
--- /dev/null
+++ b/flang/test/Transforms/debug-ref-type.fir
@@ -0,0 +1,10 @@
+// RUN: fir-opt --add-debug-info --mlir-print-debuginfo %s | FileCheck %s
+
+module attributes {dlti.dl_spec = #dlti.dl_spec<>} {
+ func.func private @_FortranAioBeginExternalListOutput(i8) -> !fir.ref<i8> loc(#loc1)
+}
+#loc1 = loc("test.f90":5:1)
+
+// CHECK: #[[INT8_TY:.*]] = #llvm.di_basic_type<tag = DW_TAG_base_type, name = "integer", sizeInBits = 8, encoding = DW_ATE_signed>
+// CHECK: #[[REF_TY:.*]] = #llvm.di_derived_type<tag = DW_TAG_pointer_type, name = "", baseType = #[[INT8_TY]]{{.*}}>
+// CHECK: #llvm.di_subroutine_type<{{.*}}types = #[[REF_TY]], #[[INT8_TY]]>
|
jeanPerier
approved these changes
Oct 24, 2024
| @@ -0,0 +1,10 @@ | |||
| // RUN: fir-opt --add-debug-info --mlir-print-debuginfo %s | FileCheck %s | |||
|
|
|||
Contributor
There was a problem hiding this comment.
Could you also verify the handling of !fir.ref<none>?
This will for instance be generated for the signature of foo after the abtsract-result pass:
subroutine test()
use iso_c_binding, only : c_ptr
interface
function foo() bind(c)
import :: c_ptr
type(c_ptr) foo
end function
end interface
call bar(foo())
end subroutine
func.func private @foo() -> !fir.ref<none> attributes {fir.bindc_name = "foo", fir.proc_attrs = #fir.proc_attrs<bind_c>}
Contributor
Author
There was a problem hiding this comment.
Thanks for your review. Currently mlir::NoneType is not handled and a place holder integer type gets generated for it. I have a small PR ready to add its support and I will add the !fir.ref<none> check in that.
Closed
NoumanAmir657
pushed a commit
to NoumanAmir657/llvm-project
that referenced
this pull request
Nov 4, 2024
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
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.
No description provided.