[PATCH] D119061: [Clang] noinline call site attribute

Dávid Bolvanský via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 14 12:47:50 PST 2022


xbolva00 added inline comments.


================
Comment at: clang/include/clang/Basic/AttrDocs.td:522
+  let Content = [{
+This function attribute suppresses the inlining of a function at the call sites
+of the function.
----------------
Feel free to suggest better wording :)


================
Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:4044
+def warn_function_stmt_attribute_precedence : Warning<
+  "statement attribute %0 has higher precedence than function attribute "
+  "'%select{always_inline|flatten}1'">,
----------------
Feel free to suggest better wording :)


================
Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:4045
+  "statement attribute %0 has higher precedence than function attribute "
+  "'%select{always_inline|flatten}1'">,
+  InGroup<IgnoredAttributes>;
----------------
Ideally this would be something like

"statement attribute %0 has higher precedence than function attribute %1"

but...


================
Comment at: clang/lib/Sema/SemaStmtAttr.cpp:231
+        S.Diag(St->getBeginLoc(), diag::warn_function_stmt_attribute_precedence)
+          << A << (Decl->hasAttr<AlwaysInlineAttr>() ? 0 : 1);
+  }
----------------
.. not sure how to get AttributeCommonInfo here so I could use "<< X".


================
Comment at: clang/test/CodeGen/attr-noinline.cpp:15-16
+// CHECK: call void @_Z1fbb({{.*}}) #[[NOINLINEATTR]]
+  [[clang::noinline]] [] { bar(); bar(); }(); // noinline only applies to the anonymous function call
+// CHECK: call void @"_ZZ3fooiENK3$_0clEv"(%class.anon* {{[^,]*}} %ref.tmp) #[[NOINLINEATTR]]
+  [[clang::noinline]] for (bar(); bar(); bar()) {}
----------------
aaron.ballman wrote:
> I'd also like to see the behavior tested with blocks and statement expressions.
> 
> Also, I'd like to see test cases where the call is "hidden" from the user's sight. e.g.,
> ```
> struct S {
>   friend bool operator==(const S &LHS, const S &RHS);
> };
> 
> void f(bool);
> 
> void func(const S &s1, const S &s2) {
>   [[clang::noinline]]f(s1 == s2); // Is operator==() then not inlined?
> }
> ```
Added as tests. Yes, not inlined.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119061/new/

https://reviews.llvm.org/D119061



More information about the cfe-commits mailing list