[flang-commits] [flang] [flang] Follow up #192674 Add INLINEALWAYS Directive (PR #194313)
via flang-commits
flang-commits at lists.llvm.org
Mon Apr 27 01:29:27 PDT 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-fir-hlfir
Author: Jack Styles (Stylie777)
<details>
<summary>Changes</summary>
Following some post merge review comments, this updates the work done in #<!-- -->192674 based on feedback. It fixes some formatting that was not conforming, fixes Typo's and updates the new warning's for Semantics checks.
---
Full diff: https://github.com/llvm/llvm-project/pull/194313.diff
5 Files Affected:
- (modified) flang/lib/Lower/Bridge.cpp (+1-1)
- (modified) flang/lib/Parser/unparse.cpp (+3-3)
- (modified) flang/lib/Semantics/resolve-names.cpp (+3-2)
- (modified) flang/test/Lower/inlinealways-directive.f90 (+2-2)
- (modified) flang/test/Semantics/inlinealways-directive01.f90 (+3-3)
``````````diff
diff --git a/flang/lib/Lower/Bridge.cpp b/flang/lib/Lower/Bridge.cpp
index 94f371d03079c..91e6c452269b7 100644
--- a/flang/lib/Lower/Bridge.cpp
+++ b/flang/lib/Lower/Bridge.cpp
@@ -3569,7 +3569,7 @@ class FirConverter : public Fortran::lower::AbstractConverter {
if (currentFunctionUnit && !currentFunctionUnit->isMainProgram()) {
const std::string symName =
currentFunctionUnit->getSubprogramSymbol().name().ToString();
- if (dir.v->ToString() == symName) {
+ if (dir.v.value().ToString() == symName) {
func->setAttr("llvm.always_inline", builder->getUnitAttr());
}
}
diff --git a/flang/lib/Parser/unparse.cpp b/flang/lib/Parser/unparse.cpp
index b980a51d3f249..41f3370ffa5e0 100644
--- a/flang/lib/Parser/unparse.cpp
+++ b/flang/lib/Parser/unparse.cpp
@@ -1908,11 +1908,11 @@ class UnparseVisitor {
Word("!DIR$ NOINLINE");
},
[&](const CompilerDirective::IVDep &) { Word("!DIR$ IVDEP"); },
- [&](const CompilerDirective::InlineAlways &InlineAlways) {
+ [&](const CompilerDirective::InlineAlways &inlineAlways) {
Word("!DIR$ INLINEALWAYS");
- if (InlineAlways.v.has_value()) {
+ if (inlineAlways.v.has_value()) {
Word(" ");
- Word(InlineAlways.v->ToString());
+ Word(inlineAlways.v->ToString());
}
},
[&](const CompilerDirective::Simd &) { Word("!DIR$ SIMD"); },
diff --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp
index 3d42208688497..07903fce75432 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -10492,11 +10492,12 @@ void ResolveNamesVisitor::Post(const parser::CompilerDirective &x) {
Symbol *sym{currScope().symbol()};
if (!sym || !sym->has<SubprogramDetails>()) {
Say(x.source,
- "!DIR$ INLINEALWAYS directive with name must appear in a subroutine or function"_err_en_US);
+ "!DIR$ INLINEALWAYS directive with name must appear in a subprogram"_err_en_US);
}
if (inlineAlways->v->ToString() != sym->name().ToString()) {
context().Warn(common::UsageWarning::IgnoredDirective, x.source,
- "INLINEALWAYS name does not match the subroutine or function name"_warn_en_US);
+ "INLINEALWAYS name %s does not match the subprogram name %s"_warn_en_US,
+ inlineAlways->v->ToString(), sym->name().ToString());
}
} else if (context().ShouldWarn(common::UsageWarning::IgnoredDirective)) {
Say(x.source, "Unrecognized compiler directive was ignored"_warn_en_US)
diff --git a/flang/test/Lower/inlinealways-directive.f90 b/flang/test/Lower/inlinealways-directive.f90
index befca5a9824c8..fba16a51628a0 100644
--- a/flang/test/Lower/inlinealways-directive.f90
+++ b/flang/test/Lower/inlinealways-directive.f90
@@ -23,7 +23,7 @@ function test_func1()
function test_func2()
!DIR$ INLINEALWAYS wrong_func
end function
-! CHCEK: func.func @_QPtest_func2() -> f32 {
+! CHECK: func.func @_QPtest_func2() -> f32 {
integer function test_func3() result(res)
res = 10
@@ -40,5 +40,5 @@ subroutine test()
result = 0
!DIR$ INLINEALWAYS
result = test_func3()
-! CHCEK: %[[.*]] = fir.call @_QPtest_func3() fastmath<contract> {inline_attr = #fir.inline_attrs<always_inline>} : () -> i32
+! CHECK: fir.call @_QPtest_func3() fastmath<contract> {inline_attr = #fir.inline_attrs<always_inline>} : () -> i32
end subroutine
diff --git a/flang/test/Semantics/inlinealways-directive01.f90 b/flang/test/Semantics/inlinealways-directive01.f90
index e4e569e9e4362..b390d7aa21e96 100644
--- a/flang/test/Semantics/inlinealways-directive01.f90
+++ b/flang/test/Semantics/inlinealways-directive01.f90
@@ -2,16 +2,16 @@
! RUN: %python %S/test_errors.py %s %flang_fc1
module m
-! ERROR: !DIR$ INLINEALWAYS directive with name must appear in a subroutine or function
+! ERROR: !DIR$ INLINEALWAYS directive with name must appear in a subprogram
!DIR$ INLINEALWAYS m
end module
subroutine test_subroutine()
-! WARNING: INLINEALWAYS name does not match the subroutine or function name [-Wignored-directive]
+! WARNING: INLINEALWAYS name wrong_subroutine does not match the subprogram name test_subroutine [-Wignored-directive]
!DIR$ INLINEALWAYS wrong_subroutine
end subroutine
function test_func()
-! WARNING: INLINEALWAYS name does not match the subroutine or function name [-Wignored-directive]
+! WARNING: INLINEALWAYS name wrong_func does not match the subprogram name test_func [-Wignored-directive]
!DIR$ INLINEALWAYS wrong_func
end function
``````````
</details>
https://github.com/llvm/llvm-project/pull/194313
More information about the flang-commits
mailing list