[llvm] [flang][runtime] Optimize Descriptor::FixedStride() (PR #151755)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 1 16:50:46 PDT 2025
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff HEAD~1 HEAD --extensions cpp,h -- flang-rt/unittests/Runtime/Descriptor.cpp flang-rt/include/flang-rt/runtime/descriptor.h flang-rt/lib/runtime/derived.cpp flang-rt/lib/runtime/descriptor.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/flang-rt/include/flang-rt/runtime/descriptor.h b/flang-rt/include/flang-rt/runtime/descriptor.h
index 023807d89..abd668e27 100644
--- a/flang-rt/include/flang-rt/runtime/descriptor.h
+++ b/flang-rt/include/flang-rt/runtime/descriptor.h
@@ -181,7 +181,8 @@ public:
const SubscriptValue *extent = nullptr,
ISO::CFI_attribute_t attribute = CFI_attribute_other);
- RT_API_ATTRS void UncheckedScalarEstablish(const typeInfo::DerivedType &, void *);
+ RT_API_ATTRS void UncheckedScalarEstablish(
+ const typeInfo::DerivedType &, void *);
// To create a descriptor for a derived type the caller
// must provide non-null dt argument.
diff --git a/flang-rt/lib/runtime/derived.cpp b/flang-rt/lib/runtime/derived.cpp
index 6b8987c58..2dddf079f 100644
--- a/flang-rt/lib/runtime/derived.cpp
+++ b/flang-rt/lib/runtime/derived.cpp
@@ -456,11 +456,13 @@ RT_API_ATTRS int DestroyTicket::Continue(WorkQueue &workQueue) {
SkipToNextComponent();
} else if (fixedStride_) {
// faster path, no need for subscripts, can reuse descriptor
- char *p{instance_.OffsetElement<char>(elementAt_ * *fixedStride_ + component_->offset())};
+ char *p{instance_.OffsetElement<char>(
+ elementAt_ * *fixedStride_ + component_->offset())};
Descriptor &compDesc{componentDescriptor_.descriptor()};
const typeInfo::DerivedType &compType{*componentDerived};
compDesc.UncheckedScalarEstablish(compType, p);
- for (std::size_t j{elementAt_}; j < elements_; ++j, p += *fixedStride_) {
+ for (std::size_t j{elementAt_}; j < elements_;
+ ++j, p += *fixedStride_) {
compDesc.set_base_addr(p);
++elementAt_;
if (int status{workQueue.BeginDestroy(
@@ -479,7 +481,8 @@ RT_API_ATTRS int DestroyTicket::Continue(WorkQueue &workQueue) {
instance_.ElementComponent<char>(subscripts_, component_->offset()),
component_->rank(), extents);
Advance();
- if (int status{workQueue.BeginDestroy(compDesc, compType, /*finalize=*/false)};
+ if (int status{
+ workQueue.BeginDestroy(compDesc, compType, /*finalize=*/false)};
status != StatOk) {
return status;
}
diff --git a/flang-rt/lib/runtime/descriptor.cpp b/flang-rt/lib/runtime/descriptor.cpp
index 75cf2be62..fde4baa6a 100644
--- a/flang-rt/lib/runtime/descriptor.cpp
+++ b/flang-rt/lib/runtime/descriptor.cpp
@@ -100,7 +100,8 @@ RT_API_ATTRS void Descriptor::Establish(const typeInfo::DerivedType &dt,
new (Addendum()) DescriptorAddendum{&dt};
}
-RT_API_ATTRS void Descriptor::UncheckedScalarEstablish(const typeInfo::DerivedType &dt, void *p) {
+RT_API_ATTRS void Descriptor::UncheckedScalarEstablish(
+ const typeInfo::DerivedType &dt, void *p) {
auto elementBytes{static_cast<std::size_t>(dt.sizeInBytes())};
ISO::EstablishDescriptor(
&raw_, p, CFI_attribute_other, CFI_type_struct, elementBytes, 0, nullptr);
``````````
</details>
https://github.com/llvm/llvm-project/pull/151755
More information about the llvm-commits
mailing list