[clang] [Clang] Diagnose conflict between always_inline/noinline attributes (PR #215173)
Kenzo Tjandra via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 12 20:36:06 PDT 2026
================
@@ -779,10 +779,10 @@ void CodeGenFunction::EmitLabelStmt(const LabelStmt &S) {
}
void CodeGenFunction::EmitAttributedStmt(const AttributedStmt &S) {
- bool nomerge = false;
- bool noinline = false;
- bool alwaysinline = false;
- bool noconvergent = false;
+ bool nomerge = InNoMergeAttributedStmt;
+ bool noinline = InNoInlineAttributedStmt;
+ bool alwaysinline = InAlwaysInlineAttributedStmt;
+ bool noconvergent = InNoConvergentAttributedStmt;
StringRef amdgpuAVMode;
----------------
ketjandr wrote:
Hmm, I do find it hard to find a scenario where `musttail` should be consumed by a `CallExpr` other than the one inside the following `ReturnStmt`. Even if we have, for example
```
[[musttail]]
return outer_fn(({
[[always_inline]]
inner_fn();
}));
```
the correct behavior should have the musttail attribute point only to `ouster_fn()` via `MustTailCall`, and it shouldn’t recklessly propagate to any `CallExpr` inside like `inner_fn()`. And even if we propagate musttail inside here, something like `CE == MustTailCall` when setting the actual flag on a `CallExpr` ensures that that musttail is only bound to `outer_fn()` and nothing else. So I think it would be “more correct” to leave `musttail == nullptr` as is for every recursive call. Do you have a scenario in mind?
As for the other stuff, I'm not sure how to test those as well. For example, `[[atomic]]` seems to operate differently from `nomerge/alwaysinline`. What tests do you have in mind?
https://github.com/llvm/llvm-project/pull/215173
More information about the cfe-commits
mailing list