================
@@ -0,0 +1,78 @@
+// -fkeep-inline-functions has an effect without optimization, although it is
+// primarily useful with optimization enabled.
+
+// RUN: %clang_cc1 -O2 -fkeep-inline-functions -emit-llvm %s -o - -triple 
x86_64-unknown-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 -O0 -fkeep-inline-functions -emit-llvm %s -o - -triple 
x86_64-unknown-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 -O2 -fkeep-inline-functions -emit-llvm %s -o - -triple 
powerpc64-ibm-aix-xcoff | FileCheck %s
+// RUN: %clang_cc1 -O0 -fkeep-inline-functions -emit-llvm %s -o - -triple 
powerpc64-ibm-aix-xcoff | FileCheck %s
+
+// -fkeep-inline-functions retains inline function definitions available in
+// this translation unit. Definitions emitted with available_externally
+// linkage are excluded.
+
+// Retained:
+//   f1  explicit inline and referenced
+//   f2  static inline
+//   f3  constexpr (implicit inline)
+//   f4  in-class member definition (implicit inline)
+//   f7  explicit inline and unreferenced
+//   f8  explicitly instantiated inline template
+//   TestCtorDtor implicitly inline constructor/destructor variants.
+
+//   Also exercises the GlobalDecl construction path in MustBeEmitted() for
+//   constructors/destructors. Without the special handling, debug builds hit
+//   the GlobalDecl(FunctionDecl*) assertion.
+
+// Not retained:
+//   f5  non-inline
+//   f6  GNU extern inline
+//   f9  extern template specialization
+
+inline int f1(int x) { return x + 1; }
+
+static inline int f2(int x) { return x + 2; }
+
+constexpr int f3(int x) { return x + 3; }
+
+struct S {
+  int f4() { return 4; }
+};
+
+int f5(int x) { return x + 5; }
+
+__attribute__((gnu_inline)) extern inline int f6(int x) { return x + 6; }
----------------
hubert-reinterpretcast wrote:

For variety (and to reflect usage in C++-only code), as `extern` is not needed 
on top of `gnu_inline` for GNU extern inline semantics under C++, let's omit it:
```suggestion
__attribute__((gnu_inline)) inline int f6(int x) { return x + 6; }
```

https://github.com/llvm/llvm-project/pull/218533
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to