[all-commits] [llvm/llvm-project] 003c0b: [Clang] always_inline statement attribute

Dávid Bolvanský via All-commits all-commits at lists.llvm.org
Mon Mar 14 13:45:48 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 003c0b9307bc52605fc93c599dfe36849839ded5
      https://github.com/llvm/llvm-project/commit/003c0b9307bc52605fc93c599dfe36849839ded5
  Author: Dávid Bolvanský <david.bolvansky at gmail.com>
  Date:   2022-03-14 (Mon, 14 Mar 2022)

  Changed paths:
    M clang/include/clang/Basic/Attr.td
    M clang/include/clang/Basic/AttrDocs.td
    M clang/include/clang/Basic/DiagnosticSemaKinds.td
    M clang/lib/CodeGen/CGCall.cpp
    M clang/lib/CodeGen/CGStmt.cpp
    M clang/lib/CodeGen/CodeGenFunction.h
    M clang/lib/Sema/SemaStmtAttr.cpp
    A clang/test/CodeGen/attr-alwaysinline.cpp
    M clang/test/Parser/objc-implementation-attrs.m
    A clang/test/Sema/attr-alwaysinline.cpp

  Log Message:
  -----------
  [Clang] always_inline statement  attribute

Motivation:

```
int test(int x, int y) {
    int r = 0;
    [[clang::always_inline]] r += foo(x, y); // force compiler to inline this function here
    return r;
}
```

In 2018, @kuhar proposed "Introduce per-callsite inline intrinsics" in https://reviews.llvm.org/D51200 to solve this motivation case (and many others).

This patch solves this problem with call site attribute. "noinline" statement attribute already landed in D119061. Also, some LLVM Inliner fixes landed so call site attribute is stronger than function attribute.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D120717




More information about the All-commits mailing list