[clang] [clang] Refactor: Move CTAD code from SemaTemplate.cpp to a dedicated file, NFC (PR #98524)

2024-07-15 Thread Vlad Serebrennikov via cfe-commits

Endilll wrote:

LGTM

https://github.com/llvm/llvm-project/pull/98524
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Emit constraint intrinsics for arc and hyperbolic trig clang builtins (PR #98949)

2024-07-15 Thread Farzon Lotfi via cfe-commits

https://github.com/farzonl updated 
https://github.com/llvm/llvm-project/pull/98949

>From 3c31554214d642c8b3ce8b17739d68445adc81d5 Mon Sep 17 00:00:00 2001
From: Farzon Lotfi 
Date: Mon, 15 Jul 2024 15:39:14 -0400
Subject: [PATCH 1/2] [clang] Emit constraint intrinsics for arc and hyperbolic
 trig clang builtins

- `Builtins.td` - Add f16 support for libm arc and hyperbolic trig functions
- `CGBuiltin.cpp` - Emit constraint intrinsics for trig clang builtins

This change is part of an implementation of 
https://github.com/llvm/llvm-project/issues/87367's investigation on supporting 
IEEE math operations as intrinsics.
Which was discussed in this RFC:
https://discourse.llvm.org/t/rfc-all-the-math-intrinsics/78294

This change adds wasm lowering cases for `acos`, `asin`, `atan`, `cosh`, 
`sinh`, and `tanh`.

https://github.com/llvm/llvm-project/issues/70079
https://github.com/llvm/llvm-project/issues/70080
https://github.com/llvm/llvm-project/issues/70081
https://github.com/llvm/llvm-project/issues/70083
https://github.com/llvm/llvm-project/issues/70084
https://github.com/llvm/llvm-project/issues/95966

Note this PR needs Merge after:
- #98937
- #98755
---
 clang/include/clang/Basic/Builtins.td | 36 -
 clang/lib/CodeGen/CGBuiltin.cpp   | 66 +
 clang/test/CodeGen/X86/math-builtins.c| 48 ++--
 .../test/CodeGen/constrained-math-builtins.c  | 41 +++
 clang/test/CodeGen/math-libcalls.c| 73 ++-
 clang/test/CodeGenOpenCL/builtins-f16.cl  | 18 +
 6 files changed, 204 insertions(+), 78 deletions(-)

diff --git a/clang/include/clang/Basic/Builtins.td 
b/clang/include/clang/Basic/Builtins.td
index f5b15cf90d1f8..4133f6ff40cf3 100644
--- a/clang/include/clang/Basic/Builtins.td
+++ b/clang/include/clang/Basic/Builtins.td
@@ -83,11 +83,11 @@ class BitInt_Long_LongLongTemplate :
 // - _Constant: Argument has to constant-fold to an integer constant expression
 
 // __fp16 and __float128 builtin variants of libc/libm functions.
-def AcosF128 : Builtin {
-  let Spellings = ["__builtin_acosf128"];
+def AcosF16F128 : Builtin, F16F128MathTemplate {
+  let Spellings = ["__builtin_acos"];
   let Attributes = [FunctionWithBuiltinPrefix, NoThrow,
 ConstIgnoringErrnoAndExceptions];
-  let Prototype = "__float128(__float128)";
+  let Prototype = "T(T)";
 }
 
 def AcoshF128 : Builtin {
@@ -97,11 +97,11 @@ def AcoshF128 : Builtin {
   let Prototype = "__float128(__float128)";
 }
 
-def AsinF128 : Builtin {
-  let Spellings = ["__builtin_asinf128"];
+def AsinF16F128 : Builtin, F16F128MathTemplate {
+  let Spellings = ["__builtin_asin"];
   let Attributes = [FunctionWithBuiltinPrefix, NoThrow,
 ConstIgnoringErrnoAndExceptions];
-  let Prototype = "__float128(__float128)";
+  let Prototype = "T(T)";
 }
 
 def AsinhF128 : Builtin {
@@ -111,11 +111,11 @@ def AsinhF128 : Builtin {
   let Prototype = "__float128(__float128)";
 }
 
-def AtanF128 : Builtin {
-  let Spellings = ["__builtin_atanf128"];
+def AtanF16F128 : Builtin, F16F128MathTemplate {
+  let Spellings = ["__builtin_atan"];
   let Attributes = [FunctionWithBuiltinPrefix, NoThrow,
 ConstIgnoringErrnoAndExceptions];
-  let Prototype = "__float128(__float128)";
+  let Prototype = "T(T)";
 }
 
 def AtanhF128 : Builtin {
@@ -143,10 +143,10 @@ def CosF16F128 : Builtin, F16F128MathTemplate {
   let Prototype = "T(T)";
 }
 
-def CoshF128 : Builtin {
-  let Spellings = ["__builtin_coshf128"];
+def CoshF16F128 : Builtin, F16F128MathTemplate {
+  let Spellings = ["__builtin_cosh"];
   let Attributes = [FunctionWithBuiltinPrefix, NoThrow, 
ConstIgnoringErrnoAndExceptions];
-  let Prototype = "__float128(__float128)";
+  let Prototype = "T(T)";
 }
 
 def ErfF128 : Builtin {
@@ -468,11 +468,11 @@ def SinF16F128 : Builtin, F16F128MathTemplate {
   let Prototype = "T(T)";
 }
 
-def SinhF128 : Builtin {
-  let Spellings = ["__builtin_sinhf128"];
+def SinhF16F128 : Builtin, F16F128MathTemplate {
+  let Spellings = ["__builtin_sinh"];
   let Attributes = [FunctionWithBuiltinPrefix, NoThrow,
 ConstIgnoringErrnoAndExceptions];
-  let Prototype = "__float128(__float128)";
+  let Prototype = "T(T)";
 }
 
 def SqrtF16F128 : Builtin, F16F128MathTemplate {
@@ -489,11 +489,11 @@ def TanF16F128 : Builtin, F16F128MathTemplate {
   let Prototype = "T(T)";
 }
 
-def TanhF128 : Builtin {
-  let Spellings = ["__builtin_tanhf128"];
+def TanhF16F128 : Builtin, F16F128MathTemplate {
+  let Spellings = ["__builtin_tanh"];
   let Attributes = [FunctionWithBuiltinPrefix, NoThrow,
 ConstIgnoringErrnoAndExceptions];
-  let Prototype = "__float128(__float128)";
+  let Prototype = "T(T)";
 }
 
 def TgammaF128 : Builtin {
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index a54fa7bf87aad..d78efb2217931 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -264

[clang] [PAC][clang] Enhance preprocessor ptrauth tests (PR #98862)

2024-07-15 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `sanitizer-x86_64-linux` 
running on `sanitizer-buildbot2` while building `clang` at step 2 "annotate".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/66/builds/1535

Here is the relevant piece of the build log for the reference:
```
Step 2 (annotate) failure: 'python 
../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py'
 (failure)
...
llvm-lit: 
/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/fuzzer/lit.cfg.py:36:
 note: lsan feature available
llvm-lit: 
/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/fuzzer/lit.cfg.py:45:
 note: msan feature unavailable
llvm-lit: 
/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/fuzzer/lit.cfg.py:60:
 note: linux feature available
llvm-lit: 
/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/fuzzer/lit.cfg.py:36:
 note: lsan feature available
llvm-lit: 
/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/fuzzer/lit.cfg.py:48:
 note: msan feature available
llvm-lit: 
/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/fuzzer/lit.cfg.py:60:
 note: linux feature available
llvm-lit: 
/b/sanitizer-x86_64-linux/build/llvm-project/llvm/utils/lit/lit/main.py:72: 
note: The test suite configuration requested an individual test timeout of 0 
seconds but a timeout of 900 seconds was requested on the command line. Forcing 
timeout to be 900 seconds.
-- Testing: 10001 tests, 88 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..
TIMEOUT: SanitizerCommon-hwasan-x86_64-Linux :: Posix/fork_threaded.c (10001 of 
10001)
 TEST 'SanitizerCommon-hwasan-x86_64-Linux :: 
Posix/fork_threaded.c' FAILED 
Exit Code: -9
Timeout: Reached timeout of 900 seconds

Command Output (stderr):
--
RUN: at line 1: /b/sanitizer-x86_64-linux/build/build_default/./bin/clang  
-gline-tables-only -fsanitize=hwaddress -fuse-ld=lld 
-fsanitize-hwaddress-experimental-aliasing  -m64 -funwind-tables  
-I/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test -ldl -O0 
/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.c
 -o 
/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/hwasan-x86_64-Linux/Posix/Output/fork_threaded.c.tmp
 && env HWASAN_OPTIONS=die_after_fork=0  
/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/hwasan-x86_64-Linux/Posix/Output/fork_threaded.c.tmp
+ /b/sanitizer-x86_64-linux/build/build_default/./bin/clang -gline-tables-only 
-fsanitize=hwaddress -fuse-ld=lld -fsanitize-hwaddress-experimental-aliasing 
-m64 -funwind-tables 
-I/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test -ldl -O0 
/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/sanitizer_common/TestCases/Posix/fork_threaded.c
 -o 
/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/hwasan-x86_64-Linux/Posix/Output/fork_threaded.c.tmp
+ env HWASAN_OPTIONS=die_after_fork=0 
/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/hwasan-x86_64-Linux/Posix/Output/fork_threaded.c.tmp
==3178000==ERROR: HWAddressSanitizer: tag-mismatch on address 0x48140280 at 
pc 0x5bb1addeca87
READ of size 155 at 0x48140280 tags: 05/00 (ptr/mem) in thread T1

=
==3181993==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 568 byte(s) in 3 object(s) allocated from:
#0 0x5bb1adde11c8 in malloc 
/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/lib/hwasan/hwasan_allocation_functions.cpp:151:3
#1 0x5bb1adf3899e in operator new(unsigned long) llvm-link
#2 0x5bb1addd76b4 in _start 
(/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/hwasan-x86_64-Linux/Posix/Output/fork_threaded.c.tmp+0xee6b4)

Direct leak of 204 byte(s) in 1 object(s) allocated from:
#0 0x5bb1adde0d0d in calloc 
/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/lib/hwasan/hwasan_allocation_functions.cpp:127:3
#1 0x5bb1adec14bd in llvm::safe_calloc(unsigned long, unsigned long) 
llvm-link
#2 0x5bb1addd76b4 in _start 
(/b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/hwasan-x86_64-Linux/Posix/Output/fork_threaded.c.tmp+0xee6b4)

Indirect leak of 1752 byte(s) in 42 object(s) allocated from:
#0 0x5bb1adde06c9 in aligned_alloc 
/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/lib/hwasan/hwasan_allocation_functions.cpp:58:3
#1 0x5bb1adecedc7 in llvm::allocate_buffer(unsigned long, unsigned long) 
llvm-link

Indirect leak of 780 byte(s) in 1 object(s) allocated from:
#0 0x5bb1adde0d0d in calloc 
/b/sanitizer-x86_64-linux/buil

[clang] [clang-tools-extra] [clang-tidy] Fix false in unnecessary-value-param inside templates (PR #98488)

2024-07-15 Thread Dmitry Polukhin via cfe-commits

https://github.com/dmpolukhin updated 
https://github.com/llvm/llvm-project/pull/98488

>From a05c4ca2c2e61653e7bd8d3a2f5faa6b86daa615 Mon Sep 17 00:00:00 2001
From: Dmitry Polukhin 
Date: Thu, 11 Jul 2024 07:01:49 -0700
Subject: [PATCH 1/3] [clang-tidy] Fix false in unnecessary-value-param inside
 templates

Summary:
If callExpr is type dependent, there is no way to analyze individual arguments
until template specialization. Before this diff only calls with dependent
callees were skipped so unnecessary-value-param was processing arguments that
had non-dependent type that gave false positives because the call was not fully
resolved till specialization. So now instead of checking type dependent callee,
the whole expression will be checked for type dependent.

Test Plan: check-clang-tools
---
 .../performance/unnecessary-value-param.cpp   | 34 +++
 clang/lib/Analysis/ExprMutationAnalyzer.cpp   |  9 +++--
 2 files changed, 38 insertions(+), 5 deletions(-)

diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-value-param.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-value-param.cpp
index d578eedd94a39..b1696ad3c3d59 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-value-param.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-value-param.cpp
@@ -2,6 +2,31 @@
 
 // CHECK-FIXES: #include 
 
+namespace std {
+template 
+struct remove_reference;
+
+template 
+struct remove_reference {
+  typedef _Tp type;
+};
+
+template 
+struct remove_reference<_Tp &> {
+  typedef _Tp type;
+};
+
+template 
+struct remove_reference<_Tp &&> {
+  typedef _Tp type;
+};
+
+template 
+constexpr typename std::remove_reference<_Tp>::type &&move(_Tp &&__t) {
+  return static_cast::type &&>(__t);
+}
+} // namespace std
+
 struct ExpensiveToCopyType {
   const ExpensiveToCopyType & constReference() const {
 return *this;
@@ -402,3 +427,12 @@ int templateSpecializationFunction(ExpensiveToCopyType E) {
   // CHECK-FIXES-NOT: int templateSpecializationFunction(const 
ExpensiveToCopyType& E) {
   return 0;
 }
+
+struct B {
+  static void bar(ExpensiveMovableType a, ExpensiveMovableType b);
+};
+
+template 
+void NegativeCallWithDependentAndNondependentArgs(ExpensiveMovableType a, T b) 
{
+B::bar(std::move(a), b);
+}
diff --git a/clang/lib/Analysis/ExprMutationAnalyzer.cpp 
b/clang/lib/Analysis/ExprMutationAnalyzer.cpp
index 3b3782fa1db9a..70a1d7b52ffe9 100644
--- a/clang/lib/Analysis/ExprMutationAnalyzer.cpp
+++ b/clang/lib/Analysis/ExprMutationAnalyzer.cpp
@@ -404,15 +404,14 @@ ExprMutationAnalyzer::Analyzer::findDirectMutation(const 
Expr *Exp) {
 memberExpr(hasObjectExpression(canResolveToExpr(Exp,
   nonConstReferenceType());
   const auto NotInstantiated = unless(hasDeclaration(isInstantiated()));
-  const auto TypeDependentCallee =
-  callee(expr(anyOf(unresolvedLookupExpr(), unresolvedMemberExpr(),
-cxxDependentScopeMemberExpr(),
-hasType(templateTypeParmType()), isTypeDependent(;
 
   const auto AsNonConstRefArg = anyOf(
   callExpr(NonConstRefParam, NotInstantiated),
   cxxConstructExpr(NonConstRefParam, NotInstantiated),
-  callExpr(TypeDependentCallee, hasAnyArgument(canResolveToExpr(Exp))),
+  // If the call is type-dependent, we can't properly process any
+  // argument because required type conversions and implicit casts
+  // will be inserted only after specialization.
+  callExpr(isTypeDependent(), hasAnyArgument(canResolveToExpr(Exp))),
   cxxUnresolvedConstructExpr(hasAnyArgument(canResolveToExpr(Exp))),
   // Previous False Positive in the following Code:
   // `template  void f() { int i = 42; new Type(i); }`

>From dbcdb0655318b7ba674cf00c7a9da9917a056102 Mon Sep 17 00:00:00 2001
From: Dmitry Polukhin 
Date: Thu, 11 Jul 2024 07:35:21 -0700
Subject: [PATCH 2/3] Apply git-clang-format

---
 clang/lib/Analysis/ExprMutationAnalyzer.cpp | 34 ++---
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/clang/lib/Analysis/ExprMutationAnalyzer.cpp 
b/clang/lib/Analysis/ExprMutationAnalyzer.cpp
index 70a1d7b52ffe9..6d726ae44104e 100644
--- a/clang/lib/Analysis/ExprMutationAnalyzer.cpp
+++ b/clang/lib/Analysis/ExprMutationAnalyzer.cpp
@@ -405,23 +405,23 @@ ExprMutationAnalyzer::Analyzer::findDirectMutation(const 
Expr *Exp) {
   nonConstReferenceType());
   const auto NotInstantiated = unless(hasDeclaration(isInstantiated()));
 
-  const auto AsNonConstRefArg = anyOf(
-  callExpr(NonConstRefParam, NotInstantiated),
-  cxxConstructExpr(NonConstRefParam, NotInstantiated),
-  // If the call is type-dependent, we can't properly process any
-  // argument because required type conversions and implicit casts
-  // will be inserted only after specialization.
-  callExpr(isTypeDependent(), hasAnyArgument(canResolveToExpr(Exp))),
-

[clang] [llvm] [DirectX] Start documenting DXIL Resource handling (PR #90553)

2024-07-15 Thread Justin Bogner via cfe-commits

bogner wrote:

Just noticed that this was missing the change I had locally for updating the 
load and store operations to reflect the two different buffer types. I've 
pushed that in the latest update.

https://github.com/llvm/llvm-project/pull/90553
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Introduce 'clang-nvlink-wrapper' to work around 'nvlink' (PR #96561)

2024-07-15 Thread Joseph Huber via cfe-commits

jhuber6 wrote:

Ping

https://github.com/llvm/llvm-project/pull/96561
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Bounds Safety][NFC] Add `SemaBoundsSafety` class and move existing Sema checks there (PR #98954)

2024-07-15 Thread Henrik G. Olsson via cfe-commits

https://github.com/hnrklssn approved this pull request.

LGTM, might want to give the rest some time to have a look though

https://github.com/llvm/llvm-project/pull/98954
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Introduce 'clang-nvlink-wrapper' to work around 'nvlink' (PR #96561)

2024-07-15 Thread Justin Lebar via cfe-commits

jlebar wrote:

@Artem-B 

https://github.com/llvm/llvm-project/pull/96561
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] clang: Relax LangOpts checks when lexing quoted numbers during preprocessing (PR #95798)

2024-07-15 Thread Jan Svoboda via cfe-commits


@@ -2068,7 +2068,8 @@ bool Lexer::LexNumericConstant(Token &Result, const char 
*CurPtr) {
   }
 
   // If we have a digit separator, continue.
-  if (C == '\'' && (LangOpts.CPlusPlus14 || LangOpts.C23)) {
+  if (C == '\'' &&
+  (LangOpts.CPlusPlus14 || LangOpts.C23 || ParsingPreprocessorDirective)) {

jansvoboda11 wrote:

We've been trying to avoid specializing Clang itself for dependency scanning. 
Instead, we have introduced generic feature flags that the scanner uses to 
tweak the compiler behavior. I think this is better for layering and also 
forces us to name those features, making the code self-documenting. People 
working on Clang don't have to wonder what's dependency scanning and why it 
needs to lex numeric literals differently; they just see there's a feature flag 
named `AllowLiteralDigitSeparator` that just makes sense in that context. You 
can still dive deeper and find that it's the scanner that enables that feature 
of course.

So I'm not a fan of introducing `LanguageOpts::ScanningDependencies`.

https://github.com/llvm/llvm-project/pull/95798
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [Clang][Coroutines] Introducing the `[[clang::coro_inplace_task]]` attribute (PR #94693)

2024-07-15 Thread Yuxuan Chen via cfe-commits

https://github.com/yuxuanchen1997 updated 
https://github.com/llvm/llvm-project/pull/94693

>From bcd6e4ffa3941c9151647f03e559f1fe48f8941d Mon Sep 17 00:00:00 2001
From: Yuxuan Chen 
Date: Tue, 4 Jun 2024 23:22:00 -0700
Subject: [PATCH] [Clang] Introduce [[clang::coro_inplace_task]]

Implement noalloc copy

add CoroAnnotationElidePass
---
 clang/include/clang/AST/ExprCXX.h |  26 ++--
 clang/include/clang/Basic/Attr.td |   8 ++
 clang/include/clang/Basic/AttrDocs.td |  19 +++
 clang/lib/CodeGen/CGBlocks.cpp|   5 +-
 clang/lib/CodeGen/CGCUDARuntime.cpp   |   5 +-
 clang/lib/CodeGen/CGCUDARuntime.h |   8 +-
 clang/lib/CodeGen/CGCXXABI.h  |  10 +-
 clang/lib/CodeGen/CGClass.cpp |  16 +--
 clang/lib/CodeGen/CGCoroutine.cpp |  30 +++--
 clang/lib/CodeGen/CGExpr.cpp  |  41 +++---
 clang/lib/CodeGen/CGExprCXX.cpp   |  60 +
 clang/lib/CodeGen/CodeGenFunction.h   |  64 ++
 clang/lib/CodeGen/ItaniumCXXABI.cpp   |  16 +--
 clang/lib/CodeGen/MicrosoftCXXABI.cpp |  18 +--
 clang/lib/Sema/SemaCoroutine.cpp  |  58 -
 clang/lib/Serialization/ASTReaderStmt.cpp |  10 +-
 clang/lib/Serialization/ASTWriterStmt.cpp |   3 +-
 clang/test/CodeGenCoroutines/Inputs/utility.h |  13 ++
 .../coro-structured-concurrency.cpp   |  87 +
 ...a-attribute-supported-attributes-list.test |   1 +
 llvm/include/llvm/IR/Instruction.h|   4 +
 .../Coroutines/CoroAnnotationElide.h  |  34 +
 llvm/lib/IR/Metadata.cpp  |  16 +++
 llvm/lib/Passes/PassBuilder.cpp   |   1 +
 llvm/lib/Passes/PassBuilderPipelines.cpp  |   3 +-
 llvm/lib/Passes/PassRegistry.def  |   1 +
 llvm/lib/Transforms/Coroutines/CMakeLists.txt |   1 +
 .../Coroutines/CoroAnnotationElide.cpp| 117 ++
 llvm/lib/Transforms/Coroutines/CoroInternal.h |   4 +
 llvm/lib/Transforms/Coroutines/CoroSplit.cpp  |  81 ++--
 llvm/lib/Transforms/Coroutines/Coroutines.cpp |  28 +
 llvm/test/Other/new-pm-defaults.ll|   1 +
 .../Other/new-pm-thinlto-postlink-defaults.ll |   1 +
 .../new-pm-thinlto-postlink-pgo-defaults.ll   |   1 +
 ...-pm-thinlto-postlink-samplepgo-defaults.ll |   1 +
 .../Other/new-pm-thinlto-prelink-defaults.ll  |   1 +
 .../new-pm-thinlto-prelink-pgo-defaults.ll|   1 +
 ...w-pm-thinlto-prelink-samplepgo-defaults.ll |   1 +
 .../coro-elide-structured-concurrency.ll  |  77 
 39 files changed, 734 insertions(+), 138 deletions(-)
 create mode 100644 clang/test/CodeGenCoroutines/Inputs/utility.h
 create mode 100644 clang/test/CodeGenCoroutines/coro-structured-concurrency.cpp
 create mode 100644 
llvm/include/llvm/Transforms/Coroutines/CoroAnnotationElide.h
 create mode 100644 llvm/lib/Transforms/Coroutines/CoroAnnotationElide.cpp
 create mode 100644 
llvm/test/Transforms/Coroutines/coro-elide-structured-concurrency.ll

diff --git a/clang/include/clang/AST/ExprCXX.h 
b/clang/include/clang/AST/ExprCXX.h
index c2feac525c1ea..0cf62aee41b66 100644
--- a/clang/include/clang/AST/ExprCXX.h
+++ b/clang/include/clang/AST/ExprCXX.h
@@ -5082,7 +5082,8 @@ class CoroutineSuspendExpr : public Expr {
   enum SubExpr { Operand, Common, Ready, Suspend, Resume, Count };
 
   Stmt *SubExprs[SubExpr::Count];
-  OpaqueValueExpr *OpaqueValue = nullptr;
+  OpaqueValueExpr *CommonExprOpaqueValue = nullptr;
+  OpaqueValueExpr *InplaceCallOpaqueValue = nullptr;
 
 public:
   // These types correspond to the three C++ 'await_suspend' return variants
@@ -5090,10 +5091,10 @@ class CoroutineSuspendExpr : public Expr {
 
   CoroutineSuspendExpr(StmtClass SC, SourceLocation KeywordLoc, Expr *Operand,
Expr *Common, Expr *Ready, Expr *Suspend, Expr *Resume,
-   OpaqueValueExpr *OpaqueValue)
+   OpaqueValueExpr *CommonExprOpaqueValue)
   : Expr(SC, Resume->getType(), Resume->getValueKind(),
  Resume->getObjectKind()),
-KeywordLoc(KeywordLoc), OpaqueValue(OpaqueValue) {
+KeywordLoc(KeywordLoc), CommonExprOpaqueValue(CommonExprOpaqueValue) {
 SubExprs[SubExpr::Operand] = Operand;
 SubExprs[SubExpr::Common] = Common;
 SubExprs[SubExpr::Ready] = Ready;
@@ -5128,7 +5129,16 @@ class CoroutineSuspendExpr : public Expr {
   }
 
   /// getOpaqueValue - Return the opaque value placeholder.
-  OpaqueValueExpr *getOpaqueValue() const { return OpaqueValue; }
+  OpaqueValueExpr *getCommonExprOpaqueValue() const {
+return CommonExprOpaqueValue;
+  }
+
+  OpaqueValueExpr *getInplaceCallOpaqueValue() const {
+return InplaceCallOpaqueValue;
+  }
+  void setInplaceCallOpaqueValue(OpaqueValueExpr *E) {
+InplaceCallOpaqueValue = E;
+  }
 
   Expr *getReadyExpr() const {
 return static_cast(SubExprs[SubExpr::Ready]);
@@ -5194,9 +5204,9 @@ class CoawaitExpr : publ

[clang] [Clang] Refactor uses of in SemaOverload.cpp (PR #98965)

2024-07-15 Thread via cfe-commits

https://github.com/vortex73 created 
https://github.com/llvm/llvm-project/pull/98965

None

>From 60a51d9150fa3f31c3eab89e1f1da3b30d190b48 Mon Sep 17 00:00:00 2001
From: Vortex 
Date: Tue, 16 Jul 2024 03:01:14 +0530
Subject: [PATCH] [Clang] Refactor uses of  in SemaOverload.cpp

---
 clang/lib/Sema/SemaOverload.cpp | 28 +---
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 074062ebbb594..1275d311b21a8 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -46,6 +46,7 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/Casting.h"
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -9994,8 +9995,9 @@ 
Sema::AddArgumentDependentLookupCandidates(DeclarationName Name,
CandEnd = CandidateSet.end();
Cand != CandEnd; ++Cand)
 if (Cand->Function) {
-  Fns.erase(Cand->Function);
-  if (FunctionTemplateDecl *FunTmpl = Cand->Function->getPrimaryTemplate())
+  FunctionDecl *CandFunc = Cand->Function;
+  Fns.erase(CandFunc);
+  if (FunctionTemplateDecl *FunTmpl = CandFunc->getPrimaryTemplate())
 Fns.erase(FunTmpl);
 }
 
@@ -11349,8 +11351,7 @@ static void DiagnoseBadConversion(Sema &S, 
OverloadCandidate *Cand,
 }
   }
 
-  if (TakingCandidateAddress &&
-  !checkAddressOfCandidateIsAvailable(S, Cand->Function))
+  if (TakingCandidateAddress && !checkAddressOfCandidateIsAvailable(S, Fn))
 return;
 
   // Emit the generic diagnostic and, optionally, add the hints to it.
@@ -11376,6 +11377,7 @@ static void DiagnoseBadConversion(Sema &S, 
OverloadCandidate *Cand,
 /// over a candidate in any candidate set.
 static bool CheckArityMismatch(Sema &S, OverloadCandidate *Cand,
unsigned NumArgs, bool IsAddressOf = false) {
+  assert(Cand->Function && "Candidate is required to be a function.");
   FunctionDecl *Fn = Cand->Function;
   unsigned MinParams = Fn->getMinRequiredExplicitArguments() +
((IsAddressOf && !Fn->isStatic()) ? 1 : 0);
@@ -11780,6 +11782,7 @@ static void DiagnoseBadDeduction(Sema &S, 
OverloadCandidate *Cand,
 /// CUDA: diagnose an invalid call across targets.
 static void DiagnoseBadTarget(Sema &S, OverloadCandidate *Cand) {
   FunctionDecl *Caller = S.getCurFunctionDecl(/*AllowLambda=*/true);
+  assert(Cand->Function && "Candidate must be a Function.");
   FunctionDecl *Callee = Cand->Function;
 
   CUDAFunctionTarget CallerTarget = S.CUDA().IdentifyTarget(Caller),
@@ -11837,6 +11840,7 @@ static void DiagnoseBadTarget(Sema &S, 
OverloadCandidate *Cand) {
 }
 
 static void DiagnoseFailedEnableIfAttr(Sema &S, OverloadCandidate *Cand) {
+  assert(Cand->Function && "Candidate must be a function");
   FunctionDecl *Callee = Cand->Function;
   EnableIfAttr *Attr = static_cast(Cand->DeductionFailure.Data);
 
@@ -11846,11 +11850,13 @@ static void DiagnoseFailedEnableIfAttr(Sema &S, 
OverloadCandidate *Cand) {
 }
 
 static void DiagnoseFailedExplicitSpec(Sema &S, OverloadCandidate *Cand) {
-  ExplicitSpecifier ES = ExplicitSpecifier::getFromDecl(Cand->Function);
+  assert(Cand->Function && "Candidate must be a function");
+  Function *CandFunc = Cand->Function;
+  ExplicitSpecifier ES = ExplicitSpecifier::getFromDecl(CandFunc);
   assert(ES.isExplicit() && "not an explicit candidate");
 
   unsigned Kind;
-  switch (Cand->Function->getDeclKind()) {
+  switch (CandFunc->getDeclKind()) {
   case Decl::Kind::CXXConstructor:
 Kind = 0;
 break;
@@ -11858,7 +11864,7 @@ static void DiagnoseFailedExplicitSpec(Sema &S, 
OverloadCandidate *Cand) {
 Kind = 1;
 break;
   case Decl::Kind::CXXDeductionGuide:
-Kind = Cand->Function->isImplicit() ? 0 : 2;
+Kind = CandFunc->isImplicit() ? 0 : 2;
 break;
   default:
 llvm_unreachable("invalid Decl");
@@ -11868,7 +11874,7 @@ static void DiagnoseFailedExplicitSpec(Sema &S, 
OverloadCandidate *Cand) {
   // (particularly an out-of-class definition) will typically lack the
   // 'explicit' specifier.
   // FIXME: This is probably a good thing to do for all 'candidate' notes.
-  FunctionDecl *First = Cand->Function->getFirstDecl();
+  FunctionDecl *First = CandFunc->getFirstDecl();
   if (FunctionDecl *Pattern = First->getTemplateInstantiationPattern())
 First = Pattern->getFirstDecl();
 
@@ -11937,6 +11943,7 @@ static void NoteFunctionCandidate(Sema &S, 
OverloadCandidate *Cand,
   unsigned NumArgs,
   bool TakingCandidateAddress,
   LangAS CtorDestAS = LangAS::Default) {
+  assert(Cand->Function && "Candidate must be a function");
   FunctionDecl *Fn = Cand->Function;
   if (shouldSkipNotingLambdaConversionDecl(Fn))
 return;
@@ -11951,8 +11958,7 @@ static void NoteFunctionCandidate(Sema &S, 
OverloadCandidate *Cand,
   // Skip implicit member functions wh

[clang] [Clang] Refactor uses of in SemaOverload.cpp (PR #98965)

2024-07-15 Thread via cfe-commits

github-actions[bot] wrote:



Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be
notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this 
page.

If this is not working for you, it is probably because you do not have write
permissions for the repository. In which case you can instead tag reviewers by
name in a comment by using `@` followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review
by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate
is once a week. Please remember that you are asking for valuable time from 
other developers.

If you have further questions, they may be answered by the [LLVM GitHub User 
Guide](https://llvm.org/docs/GitHub.html).

You can also ask questions in a comment on this PR, on the [LLVM 
Discord](https://discord.com/invite/xS7Z362) or on the 
[forums](https://discourse.llvm.org/).

https://github.com/llvm/llvm-project/pull/98965
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Bounds Safety][NFC] Add `SemaBoundsSafety` class and move existing Sema checks there (PR #98954)

2024-07-15 Thread Vlad Serebrennikov via cfe-commits


@@ -0,0 +1,42 @@
+//=== SemaBoundsSafety.h - Bounds Safety specific routines-*- C++ 
-*---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+/// \file
+/// This file declares semantic analysis functions specific to 
`-fbounds-safety`
+/// (Bounds Safety) and also its attributes when used without `-fbounds-safety`
+/// (e.g. `counted_by`)
+///
+//===--===//
+
+#ifndef LLVM_CLANG_SEMA_SEMABOUNDSSAFETY_H
+#define LLVM_CLANG_SEMA_SEMABOUNDSSAFETY_H
+
+#include "clang/Sema/SemaBase.h"
+#include "llvm/ADT/SmallVector.h"
+
+namespace clang {
+class CountAttributedType;

Endilll wrote:

I think only half of those forward declarations are really needed in the header.

https://github.com/llvm/llvm-project/pull/98954
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Bounds Safety][NFC] Add `SemaBoundsSafety` class and move existing Sema checks there (PR #98954)

2024-07-15 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll requested changes to this pull request.

Unfortunately, I think this should be held off until we have a bigger picture 
for the future of `Sema`. I'll elaborate below.

If you take a close look at the existing set of `Sema` parts, it's almost 
entirely comprised of other languages or language extensions (from C and C++ 
standpoint) and backends. They were considered natural enough to be split off 
`Sema`, which, among other things, means that it's easy to explain their place 
in the big picture, like I did in the previous sentence.

I drove the effort to split `Sema`, and it has stalled, because it's not clear 
what to do with what's left there. We had several offline discussions, but we 
didn't find a solution that would substantially improve status quo.

I don't think this patch makes it easier to explain people where things are in 
this codebase, because (I think) `counted_by` is a declaration attribute, and 
we already have place for them. Having only one function also makes it a very 
small part of `Sema`, which doesn't sound compelling. A bigger picture this 
fits in would be a compelling argument (like it was for small backend parts), 
but to my knowledge there's none. Coming up with one and getting maintainers on 
board is certainly out of scope of this PR, so don't feel obligated to do that. 
Hopefully I'll get back to this whole topic later.

CC @AaronBallman 

https://github.com/llvm/llvm-project/pull/98954
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Bounds Safety][NFC] Add `SemaBoundsSafety` class and move existing Sema checks there (PR #98954)

2024-07-15 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll edited 
https://github.com/llvm/llvm-project/pull/98954
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Bounds Safety][NFC] Add `SemaBoundsSafety` class and move existing Sema checks there (PR #98954)

2024-07-15 Thread Henrik G. Olsson via cfe-commits

hnrklssn wrote:

> If you take a close look at the existing set of `Sema` parts, it's almost 
> entirely comprised of other languages or language extensions (from C and C++ 
> standpoint) and backends. They were considered natural enough to be split off 
> `Sema`, which, among other things, means that it's easy to explain their 
> place in the big picture, like I did in the previous sentence.

I don't have a strong opinion on whether this should be split up, but I just 
wanted to point out that `-fbounds-safety` is also a language extension, so it 
does kind of fit your description of other things separated out. It's currently 
in the process of being upstreamed which is why it's small, but it'd be easier 
to split now than wait until it's reached a certain size, if we do want to 
split it eventually.

https://github.com/llvm/llvm-project/pull/98954
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [clang-tidy] Fix false in unnecessary-value-param inside templates (PR #98488)

2024-07-15 Thread Piotr Zegar via cfe-commits

https://github.com/PiotrZSL commented:

Release notes entry is missing.

https://github.com/llvm/llvm-project/pull/98488
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Refactor uses of in SemaOverload.cpp (PR #98965)

2024-07-15 Thread via cfe-commits

https://github.com/vortex73 updated 
https://github.com/llvm/llvm-project/pull/98965

>From 60a51d9150fa3f31c3eab89e1f1da3b30d190b48 Mon Sep 17 00:00:00 2001
From: Vortex 
Date: Tue, 16 Jul 2024 03:01:14 +0530
Subject: [PATCH 1/3] [Clang] Refactor uses of  in SemaOverload.cpp

---
 clang/lib/Sema/SemaOverload.cpp | 28 +---
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 074062ebbb594..1275d311b21a8 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -46,6 +46,7 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/Casting.h"
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -9994,8 +9995,9 @@ 
Sema::AddArgumentDependentLookupCandidates(DeclarationName Name,
CandEnd = CandidateSet.end();
Cand != CandEnd; ++Cand)
 if (Cand->Function) {
-  Fns.erase(Cand->Function);
-  if (FunctionTemplateDecl *FunTmpl = Cand->Function->getPrimaryTemplate())
+  FunctionDecl *CandFunc = Cand->Function;
+  Fns.erase(CandFunc);
+  if (FunctionTemplateDecl *FunTmpl = CandFunc->getPrimaryTemplate())
 Fns.erase(FunTmpl);
 }
 
@@ -11349,8 +11351,7 @@ static void DiagnoseBadConversion(Sema &S, 
OverloadCandidate *Cand,
 }
   }
 
-  if (TakingCandidateAddress &&
-  !checkAddressOfCandidateIsAvailable(S, Cand->Function))
+  if (TakingCandidateAddress && !checkAddressOfCandidateIsAvailable(S, Fn))
 return;
 
   // Emit the generic diagnostic and, optionally, add the hints to it.
@@ -11376,6 +11377,7 @@ static void DiagnoseBadConversion(Sema &S, 
OverloadCandidate *Cand,
 /// over a candidate in any candidate set.
 static bool CheckArityMismatch(Sema &S, OverloadCandidate *Cand,
unsigned NumArgs, bool IsAddressOf = false) {
+  assert(Cand->Function && "Candidate is required to be a function.");
   FunctionDecl *Fn = Cand->Function;
   unsigned MinParams = Fn->getMinRequiredExplicitArguments() +
((IsAddressOf && !Fn->isStatic()) ? 1 : 0);
@@ -11780,6 +11782,7 @@ static void DiagnoseBadDeduction(Sema &S, 
OverloadCandidate *Cand,
 /// CUDA: diagnose an invalid call across targets.
 static void DiagnoseBadTarget(Sema &S, OverloadCandidate *Cand) {
   FunctionDecl *Caller = S.getCurFunctionDecl(/*AllowLambda=*/true);
+  assert(Cand->Function && "Candidate must be a Function.");
   FunctionDecl *Callee = Cand->Function;
 
   CUDAFunctionTarget CallerTarget = S.CUDA().IdentifyTarget(Caller),
@@ -11837,6 +11840,7 @@ static void DiagnoseBadTarget(Sema &S, 
OverloadCandidate *Cand) {
 }
 
 static void DiagnoseFailedEnableIfAttr(Sema &S, OverloadCandidate *Cand) {
+  assert(Cand->Function && "Candidate must be a function");
   FunctionDecl *Callee = Cand->Function;
   EnableIfAttr *Attr = static_cast(Cand->DeductionFailure.Data);
 
@@ -11846,11 +11850,13 @@ static void DiagnoseFailedEnableIfAttr(Sema &S, 
OverloadCandidate *Cand) {
 }
 
 static void DiagnoseFailedExplicitSpec(Sema &S, OverloadCandidate *Cand) {
-  ExplicitSpecifier ES = ExplicitSpecifier::getFromDecl(Cand->Function);
+  assert(Cand->Function && "Candidate must be a function");
+  Function *CandFunc = Cand->Function;
+  ExplicitSpecifier ES = ExplicitSpecifier::getFromDecl(CandFunc);
   assert(ES.isExplicit() && "not an explicit candidate");
 
   unsigned Kind;
-  switch (Cand->Function->getDeclKind()) {
+  switch (CandFunc->getDeclKind()) {
   case Decl::Kind::CXXConstructor:
 Kind = 0;
 break;
@@ -11858,7 +11864,7 @@ static void DiagnoseFailedExplicitSpec(Sema &S, 
OverloadCandidate *Cand) {
 Kind = 1;
 break;
   case Decl::Kind::CXXDeductionGuide:
-Kind = Cand->Function->isImplicit() ? 0 : 2;
+Kind = CandFunc->isImplicit() ? 0 : 2;
 break;
   default:
 llvm_unreachable("invalid Decl");
@@ -11868,7 +11874,7 @@ static void DiagnoseFailedExplicitSpec(Sema &S, 
OverloadCandidate *Cand) {
   // (particularly an out-of-class definition) will typically lack the
   // 'explicit' specifier.
   // FIXME: This is probably a good thing to do for all 'candidate' notes.
-  FunctionDecl *First = Cand->Function->getFirstDecl();
+  FunctionDecl *First = CandFunc->getFirstDecl();
   if (FunctionDecl *Pattern = First->getTemplateInstantiationPattern())
 First = Pattern->getFirstDecl();
 
@@ -11937,6 +11943,7 @@ static void NoteFunctionCandidate(Sema &S, 
OverloadCandidate *Cand,
   unsigned NumArgs,
   bool TakingCandidateAddress,
   LangAS CtorDestAS = LangAS::Default) {
+  assert(Cand->Function && "Candidate must be a function");
   FunctionDecl *Fn = Cand->Function;
   if (shouldSkipNotingLambdaConversionDecl(Fn))
 return;
@@ -11951,8 +11958,7 @@ static void NoteFunctionCandidate(Sema &S, 
OverloadCandidate *Cand,
   // Skip implicit member functions when

[clang-tools-extra] [clang-doc] add enum test (PR #97679)

2024-07-15 Thread via cfe-commits

https://github.com/PeterChou1 updated 
https://github.com/llvm/llvm-project/pull/97679

>From b5e0335199541225a1b0eb5eaf661cd4df55dbd7 Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Thu, 4 Jul 2024 01:14:11 -0400
Subject: [PATCH 1/6] [clang-doc] add enum test

---
 clang-tools-extra/test/clang-doc/enum.cpp | 38 +++
 1 file changed, 38 insertions(+)
 create mode 100644 clang-tools-extra/test/clang-doc/enum.cpp

diff --git a/clang-tools-extra/test/clang-doc/enum.cpp 
b/clang-tools-extra/test/clang-doc/enum.cpp
new file mode 100644
index 0..2f25eaf4e44e2
--- /dev/null
+++ b/clang-tools-extra/test/clang-doc/enum.cpp
@@ -0,0 +1,38 @@
+// RUN: clang-doc --format=html --doxygen --output=%t/docs 
--executor=standalone %s
+// RUN: clang-doc --format=md --doxygen --output=%t/docs --executor=standalone 
%s
+// RUN: FileCheck %s -input-file=%t/docs/GlobalNamespace/index.html 
-check-prefix=HTML-INDEX
+// RUN: FileCheck %s -input-file=%t/docs/GlobalNamespace/index.md 
-check-prefix=MD-INDEX
+
+/**
+ * @brief For specifying RGB colors
+ */
+enum Color {
+  Red, // Red enums
+  Green, // Green enums
+  Blue // Blue enums
+};
+
+// HTML-INDEX: Global Namespace
+// HTML-INDEX: Enums
+// HTML-INDEX: 
+// HTML-INDEX:   enum Color
+// HTML-INDEX:   
+// HTML-INDEX: Red
+// HTML-INDEX: Green
+// HTML-INDEX: Blue
+// HTML-INDEX:   
+// HTML-INDEX:   Defined at line 11 of file 
{{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp
+// HTML-INDEX:   
+// HTML-INDEX: 
+// HTML-INDEX:   
+// HTML-INDEX: 
+
+// MD-INDEX: # Global Namespace
+// MD-INDEX: ## Enums
+// MD-INDEX: | enum Color |
+// MD-INDEX: --
+// MD-INDEX: | Red |
+// MD-INDEX: | Green |
+// MD-INDEX: | Blue |
+// MD-INDEX: *Defined at 
{{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp#11*
+// MD-INDEX: **brief** For specifying RGB colors
\ No newline at end of file

>From c10f9d42c26e6d26833a35824216529ab25e7fe8 Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Thu, 4 Jul 2024 01:53:19 -0400
Subject: [PATCH 2/6] [clang-doc] update defined at line

---
 clang-tools-extra/test/clang-doc/enum.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang-tools-extra/test/clang-doc/enum.cpp 
b/clang-tools-extra/test/clang-doc/enum.cpp
index 2f25eaf4e44e2..1e7dd6e4c5b0c 100644
--- a/clang-tools-extra/test/clang-doc/enum.cpp
+++ b/clang-tools-extra/test/clang-doc/enum.cpp
@@ -21,7 +21,7 @@ enum Color {
 // HTML-INDEX: Green
 // HTML-INDEX: Blue
 // HTML-INDEX:   
-// HTML-INDEX:   Defined at line 11 of file 
{{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp
+// HTML-INDEX:   Defined at line 9 of file 
{{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp
 // HTML-INDEX:   
 // HTML-INDEX: 
 // HTML-INDEX:   

>From 8709091091b0ca889ca7911e06b7a4dae61a3581 Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Thu, 4 Jul 2024 02:06:08 -0400
Subject: [PATCH 3/6] [clang-doc] fix lines

---
 clang-tools-extra/test/clang-doc/enum.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang-tools-extra/test/clang-doc/enum.cpp 
b/clang-tools-extra/test/clang-doc/enum.cpp
index 1e7dd6e4c5b0c..5a1452788a55f 100644
--- a/clang-tools-extra/test/clang-doc/enum.cpp
+++ b/clang-tools-extra/test/clang-doc/enum.cpp
@@ -34,5 +34,5 @@ enum Color {
 // MD-INDEX: | Red |
 // MD-INDEX: | Green |
 // MD-INDEX: | Blue |
-// MD-INDEX: *Defined at 
{{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp#11*
+// MD-INDEX: *Defined at 
{{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp#9*
 // MD-INDEX: **brief** For specifying RGB colors
\ No newline at end of file

>From cd98a8cc662527e1488be17a2963874eb3267409 Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Fri, 12 Jul 2024 07:03:34 -0400
Subject: [PATCH 4/6] [clang-doc] address pr comments

---
 clang-tools-extra/test/clang-doc/enum.cpp | 34 ++-
 1 file changed, 14 insertions(+), 20 deletions(-)

diff --git a/clang-tools-extra/test/clang-doc/enum.cpp 
b/clang-tools-extra/test/clang-doc/enum.cpp
index 5a1452788a55f..fcc05477903ff 100644
--- a/clang-tools-extra/test/clang-doc/enum.cpp
+++ b/clang-tools-extra/test/clang-doc/enum.cpp
@@ -1,31 +1,25 @@
-// RUN: clang-doc --format=html --doxygen --output=%t/docs 
--executor=standalone %s
-// RUN: clang-doc --format=md --doxygen --output=%t/docs --executor=standalone 
%s
-// RUN: FileCheck %s -input-file=%t/docs/GlobalNamespace/index.html 
-check-prefix=HTML-INDEX
-// RUN: FileCheck %s -input-file=%t/docs/GlobalNamespace/index.md 
-check-prefix=MD-INDEX
+// RUN: rm -rf %t && mkdir -p %t
+// RUN: clang-doc --format=html --doxygen --output=%t --executor=standalone %s
+// RUN: clang-doc --format=md --doxygen --output=%t --executor=standalone %s
+// RUN: FileCheck %s < %t/GlobalNamespace/index.html -check-prefix=HTML-INDEX
+// RUN: FileCheck %s < %t/GlobalNamespace/index.md -check-prefix=MD-INDEX
 
 /**

[clang] [Clang] Refactor uses of in SemaOverload.cpp (PR #98965)

2024-07-15 Thread via cfe-commits

https://github.com/vortex73 edited 
https://github.com/llvm/llvm-project/pull/98965
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Refactor uses of in SemaOverload.cpp (PR #98965)

2024-07-15 Thread via cfe-commits

https://github.com/vortex73 ready_for_review 
https://github.com/llvm/llvm-project/pull/98965
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-doc] add enum test (PR #97679)

2024-07-15 Thread via cfe-commits

https://github.com/PeterChou1 updated 
https://github.com/llvm/llvm-project/pull/97679

>From b5e0335199541225a1b0eb5eaf661cd4df55dbd7 Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Thu, 4 Jul 2024 01:14:11 -0400
Subject: [PATCH 1/6] [clang-doc] add enum test

---
 clang-tools-extra/test/clang-doc/enum.cpp | 38 +++
 1 file changed, 38 insertions(+)
 create mode 100644 clang-tools-extra/test/clang-doc/enum.cpp

diff --git a/clang-tools-extra/test/clang-doc/enum.cpp 
b/clang-tools-extra/test/clang-doc/enum.cpp
new file mode 100644
index 0..2f25eaf4e44e2
--- /dev/null
+++ b/clang-tools-extra/test/clang-doc/enum.cpp
@@ -0,0 +1,38 @@
+// RUN: clang-doc --format=html --doxygen --output=%t/docs 
--executor=standalone %s
+// RUN: clang-doc --format=md --doxygen --output=%t/docs --executor=standalone 
%s
+// RUN: FileCheck %s -input-file=%t/docs/GlobalNamespace/index.html 
-check-prefix=HTML-INDEX
+// RUN: FileCheck %s -input-file=%t/docs/GlobalNamespace/index.md 
-check-prefix=MD-INDEX
+
+/**
+ * @brief For specifying RGB colors
+ */
+enum Color {
+  Red, // Red enums
+  Green, // Green enums
+  Blue // Blue enums
+};
+
+// HTML-INDEX: Global Namespace
+// HTML-INDEX: Enums
+// HTML-INDEX: 
+// HTML-INDEX:   enum Color
+// HTML-INDEX:   
+// HTML-INDEX: Red
+// HTML-INDEX: Green
+// HTML-INDEX: Blue
+// HTML-INDEX:   
+// HTML-INDEX:   Defined at line 11 of file 
{{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp
+// HTML-INDEX:   
+// HTML-INDEX: 
+// HTML-INDEX:   
+// HTML-INDEX: 
+
+// MD-INDEX: # Global Namespace
+// MD-INDEX: ## Enums
+// MD-INDEX: | enum Color |
+// MD-INDEX: --
+// MD-INDEX: | Red |
+// MD-INDEX: | Green |
+// MD-INDEX: | Blue |
+// MD-INDEX: *Defined at 
{{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp#11*
+// MD-INDEX: **brief** For specifying RGB colors
\ No newline at end of file

>From c10f9d42c26e6d26833a35824216529ab25e7fe8 Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Thu, 4 Jul 2024 01:53:19 -0400
Subject: [PATCH 2/6] [clang-doc] update defined at line

---
 clang-tools-extra/test/clang-doc/enum.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang-tools-extra/test/clang-doc/enum.cpp 
b/clang-tools-extra/test/clang-doc/enum.cpp
index 2f25eaf4e44e2..1e7dd6e4c5b0c 100644
--- a/clang-tools-extra/test/clang-doc/enum.cpp
+++ b/clang-tools-extra/test/clang-doc/enum.cpp
@@ -21,7 +21,7 @@ enum Color {
 // HTML-INDEX: Green
 // HTML-INDEX: Blue
 // HTML-INDEX:   
-// HTML-INDEX:   Defined at line 11 of file 
{{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp
+// HTML-INDEX:   Defined at line 9 of file 
{{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp
 // HTML-INDEX:   
 // HTML-INDEX: 
 // HTML-INDEX:   

>From 8709091091b0ca889ca7911e06b7a4dae61a3581 Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Thu, 4 Jul 2024 02:06:08 -0400
Subject: [PATCH 3/6] [clang-doc] fix lines

---
 clang-tools-extra/test/clang-doc/enum.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang-tools-extra/test/clang-doc/enum.cpp 
b/clang-tools-extra/test/clang-doc/enum.cpp
index 1e7dd6e4c5b0c..5a1452788a55f 100644
--- a/clang-tools-extra/test/clang-doc/enum.cpp
+++ b/clang-tools-extra/test/clang-doc/enum.cpp
@@ -34,5 +34,5 @@ enum Color {
 // MD-INDEX: | Red |
 // MD-INDEX: | Green |
 // MD-INDEX: | Blue |
-// MD-INDEX: *Defined at 
{{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp#11*
+// MD-INDEX: *Defined at 
{{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp#9*
 // MD-INDEX: **brief** For specifying RGB colors
\ No newline at end of file

>From cd98a8cc662527e1488be17a2963874eb3267409 Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Fri, 12 Jul 2024 07:03:34 -0400
Subject: [PATCH 4/6] [clang-doc] address pr comments

---
 clang-tools-extra/test/clang-doc/enum.cpp | 34 ++-
 1 file changed, 14 insertions(+), 20 deletions(-)

diff --git a/clang-tools-extra/test/clang-doc/enum.cpp 
b/clang-tools-extra/test/clang-doc/enum.cpp
index 5a1452788a55f..fcc05477903ff 100644
--- a/clang-tools-extra/test/clang-doc/enum.cpp
+++ b/clang-tools-extra/test/clang-doc/enum.cpp
@@ -1,31 +1,25 @@
-// RUN: clang-doc --format=html --doxygen --output=%t/docs 
--executor=standalone %s
-// RUN: clang-doc --format=md --doxygen --output=%t/docs --executor=standalone 
%s
-// RUN: FileCheck %s -input-file=%t/docs/GlobalNamespace/index.html 
-check-prefix=HTML-INDEX
-// RUN: FileCheck %s -input-file=%t/docs/GlobalNamespace/index.md 
-check-prefix=MD-INDEX
+// RUN: rm -rf %t && mkdir -p %t
+// RUN: clang-doc --format=html --doxygen --output=%t --executor=standalone %s
+// RUN: clang-doc --format=md --doxygen --output=%t --executor=standalone %s
+// RUN: FileCheck %s < %t/GlobalNamespace/index.html -check-prefix=HTML-INDEX
+// RUN: FileCheck %s < %t/GlobalNamespace/index.md -check-prefix=MD-INDEX
 
 /**

[clang] [Clang] Refactor uses of in SemaOverload.cpp (PR #98965)

2024-07-15 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Narayan (vortex73)


Changes

- [ ] adds checks to called functions containing `Cand->Function` as an 
argument.
- [ ] Assigned `Cand->Function` as a `FunctionDecl*` to enhance readablity.
Solves: #98769 and #98942

---
Full diff: https://github.com/llvm/llvm-project/pull/98965.diff


1 Files Affected:

- (modified) clang/lib/Sema/SemaOverload.cpp (+23-13) 


``diff
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 074062ebbb594..b68e54b9caa5b 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -46,6 +46,7 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/Casting.h"
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -9994,8 +9995,9 @@ 
Sema::AddArgumentDependentLookupCandidates(DeclarationName Name,
CandEnd = CandidateSet.end();
Cand != CandEnd; ++Cand)
 if (Cand->Function) {
-  Fns.erase(Cand->Function);
-  if (FunctionTemplateDecl *FunTmpl = Cand->Function->getPrimaryTemplate())
+  FunctionDecl *CandFunc = Cand->Function;
+  Fns.erase(CandFunc);
+  if (FunctionTemplateDecl *FunTmpl = CandFunc->getPrimaryTemplate())
 Fns.erase(FunTmpl);
 }
 
@@ -11349,8 +11351,7 @@ static void DiagnoseBadConversion(Sema &S, 
OverloadCandidate *Cand,
 }
   }
 
-  if (TakingCandidateAddress &&
-  !checkAddressOfCandidateIsAvailable(S, Cand->Function))
+  if (TakingCandidateAddress && !checkAddressOfCandidateIsAvailable(S, Fn))
 return;
 
   // Emit the generic diagnostic and, optionally, add the hints to it.
@@ -11376,6 +11377,7 @@ static void DiagnoseBadConversion(Sema &S, 
OverloadCandidate *Cand,
 /// over a candidate in any candidate set.
 static bool CheckArityMismatch(Sema &S, OverloadCandidate *Cand,
unsigned NumArgs, bool IsAddressOf = false) {
+  assert(Cand->Function && "Candidate is required to be a function.");
   FunctionDecl *Fn = Cand->Function;
   unsigned MinParams = Fn->getMinRequiredExplicitArguments() +
((IsAddressOf && !Fn->isStatic()) ? 1 : 0);
@@ -11466,8 +11468,10 @@ static void DiagnoseArityMismatch(Sema &S, NamedDecl 
*Found, Decl *D,
 /// Arity mismatch diagnosis specific to a function overload candidate.
 static void DiagnoseArityMismatch(Sema &S, OverloadCandidate *Cand,
   unsigned NumFormalArgs) {
+assert(Cand->Function && "Candidate must be a function");
+FunctionDecl *Fn = Cand->Function;
   if (!CheckArityMismatch(S, Cand, NumFormalArgs, Cand->TookAddressOfOverload))
-DiagnoseArityMismatch(S, Cand->FoundDecl, Cand->Function, NumFormalArgs,
+DiagnoseArityMismatch(S, Cand->FoundDecl, Fn, NumFormalArgs,
   Cand->TookAddressOfOverload);
 }
 
@@ -11767,19 +11771,22 @@ static void DiagnoseBadDeduction(Sema &S, NamedDecl 
*Found, Decl *Templated,
 static void DiagnoseBadDeduction(Sema &S, OverloadCandidate *Cand,
  unsigned NumArgs,
  bool TakingCandidateAddress) {
+assert(Cand->Function && "Candidate must be a function");
+FunctionDecl *Fn = Cand->Function;
   TemplateDeductionResult TDK = Cand->DeductionFailure.getResult();
   if (TDK == TemplateDeductionResult::TooFewArguments ||
   TDK == TemplateDeductionResult::TooManyArguments) {
 if (CheckArityMismatch(S, Cand, NumArgs))
   return;
   }
-  DiagnoseBadDeduction(S, Cand->FoundDecl, Cand->Function, // pattern
+  DiagnoseBadDeduction(S, Cand->FoundDecl, Fn, // pattern
Cand->DeductionFailure, NumArgs, 
TakingCandidateAddress);
 }
 
 /// CUDA: diagnose an invalid call across targets.
 static void DiagnoseBadTarget(Sema &S, OverloadCandidate *Cand) {
   FunctionDecl *Caller = S.getCurFunctionDecl(/*AllowLambda=*/true);
+  assert(Cand->Function && "Candidate must be a Function.");
   FunctionDecl *Callee = Cand->Function;
 
   CUDAFunctionTarget CallerTarget = S.CUDA().IdentifyTarget(Caller),
@@ -11837,6 +11844,7 @@ static void DiagnoseBadTarget(Sema &S, 
OverloadCandidate *Cand) {
 }
 
 static void DiagnoseFailedEnableIfAttr(Sema &S, OverloadCandidate *Cand) {
+  assert(Cand->Function && "Candidate must be a function");
   FunctionDecl *Callee = Cand->Function;
   EnableIfAttr *Attr = static_cast(Cand->DeductionFailure.Data);
 
@@ -11846,11 +11854,13 @@ static void DiagnoseFailedEnableIfAttr(Sema &S, 
OverloadCandidate *Cand) {
 }
 
 static void DiagnoseFailedExplicitSpec(Sema &S, OverloadCandidate *Cand) {
-  ExplicitSpecifier ES = ExplicitSpecifier::getFromDecl(Cand->Function);
+  assert(Cand->Function && "Candidate must be a function");
+  Function *CandFunc = Cand->Function;
+  ExplicitSpecifier ES = ExplicitSpecifier::getFromDecl(CandFunc);
   assert(ES.isExplicit() && "not an explicit candidate");
 
   unsigned Kind;
-  switch (Cand->Function->getDeclKind()) {
+  switch

[clang] [llvm] [Clang][Coroutines] Introducing the `[[clang::coro_inplace_task]]` attribute (PR #94693)

2024-07-15 Thread Yuxuan Chen via cfe-commits

https://github.com/yuxuanchen1997 updated 
https://github.com/llvm/llvm-project/pull/94693

>From 4f9596fa73a1ffd56ca34e4c36f7f048e1a0 Mon Sep 17 00:00:00 2001
From: Yuxuan Chen 
Date: Tue, 4 Jun 2024 23:22:00 -0700
Subject: [PATCH] [Clang] Introduce [[clang::coro_inplace_task]]

Implement noalloc copy

add CoroAnnotationElidePass
---
 clang/include/clang/AST/ExprCXX.h |  26 ++--
 clang/include/clang/Basic/Attr.td |   8 ++
 clang/include/clang/Basic/AttrDocs.td |  19 +++
 clang/lib/CodeGen/CGBlocks.cpp|   5 +-
 clang/lib/CodeGen/CGCUDARuntime.cpp   |   5 +-
 clang/lib/CodeGen/CGCUDARuntime.h |   8 +-
 clang/lib/CodeGen/CGCXXABI.h  |  10 +-
 clang/lib/CodeGen/CGClass.cpp |  16 +--
 clang/lib/CodeGen/CGCoroutine.cpp |  30 +++--
 clang/lib/CodeGen/CGExpr.cpp  |  41 +++---
 clang/lib/CodeGen/CGExprCXX.cpp   |  60 +
 clang/lib/CodeGen/CodeGenFunction.h   |  64 ++
 clang/lib/CodeGen/ItaniumCXXABI.cpp   |  16 +--
 clang/lib/CodeGen/MicrosoftCXXABI.cpp |  18 +--
 clang/lib/Sema/SemaCoroutine.cpp  |  58 -
 clang/lib/Serialization/ASTReaderStmt.cpp |  10 +-
 clang/lib/Serialization/ASTWriterStmt.cpp |   3 +-
 clang/test/CodeGenCoroutines/Inputs/utility.h |  13 ++
 .../coro-structured-concurrency.cpp   |  87 +
 ...a-attribute-supported-attributes-list.test |   1 +
 llvm/include/llvm/IR/Instruction.h|   4 +
 .../Coroutines/CoroAnnotationElide.h  |  34 +
 llvm/lib/IR/Metadata.cpp  |  16 +++
 llvm/lib/Passes/PassBuilder.cpp   |   1 +
 llvm/lib/Passes/PassBuilderPipelines.cpp  |   3 +-
 llvm/lib/Passes/PassRegistry.def  |   1 +
 llvm/lib/Transforms/Coroutines/CMakeLists.txt |   1 +
 .../Coroutines/CoroAnnotationElide.cpp| 117 ++
 llvm/lib/Transforms/Coroutines/CoroInternal.h |   4 +
 llvm/lib/Transforms/Coroutines/CoroSplit.cpp  |  81 ++--
 llvm/lib/Transforms/Coroutines/Coroutines.cpp |  27 
 llvm/test/Other/new-pm-defaults.ll|   1 +
 .../Other/new-pm-thinlto-postlink-defaults.ll |   1 +
 .../new-pm-thinlto-postlink-pgo-defaults.ll   |   1 +
 ...-pm-thinlto-postlink-samplepgo-defaults.ll |   1 +
 .../Other/new-pm-thinlto-prelink-defaults.ll  |   1 +
 .../new-pm-thinlto-prelink-pgo-defaults.ll|   1 +
 ...w-pm-thinlto-prelink-samplepgo-defaults.ll |   1 +
 .../coro-elide-structured-concurrency.ll  |  77 
 39 files changed, 733 insertions(+), 138 deletions(-)
 create mode 100644 clang/test/CodeGenCoroutines/Inputs/utility.h
 create mode 100644 clang/test/CodeGenCoroutines/coro-structured-concurrency.cpp
 create mode 100644 
llvm/include/llvm/Transforms/Coroutines/CoroAnnotationElide.h
 create mode 100644 llvm/lib/Transforms/Coroutines/CoroAnnotationElide.cpp
 create mode 100644 
llvm/test/Transforms/Coroutines/coro-elide-structured-concurrency.ll

diff --git a/clang/include/clang/AST/ExprCXX.h 
b/clang/include/clang/AST/ExprCXX.h
index c2feac525c1ea..0cf62aee41b66 100644
--- a/clang/include/clang/AST/ExprCXX.h
+++ b/clang/include/clang/AST/ExprCXX.h
@@ -5082,7 +5082,8 @@ class CoroutineSuspendExpr : public Expr {
   enum SubExpr { Operand, Common, Ready, Suspend, Resume, Count };
 
   Stmt *SubExprs[SubExpr::Count];
-  OpaqueValueExpr *OpaqueValue = nullptr;
+  OpaqueValueExpr *CommonExprOpaqueValue = nullptr;
+  OpaqueValueExpr *InplaceCallOpaqueValue = nullptr;
 
 public:
   // These types correspond to the three C++ 'await_suspend' return variants
@@ -5090,10 +5091,10 @@ class CoroutineSuspendExpr : public Expr {
 
   CoroutineSuspendExpr(StmtClass SC, SourceLocation KeywordLoc, Expr *Operand,
Expr *Common, Expr *Ready, Expr *Suspend, Expr *Resume,
-   OpaqueValueExpr *OpaqueValue)
+   OpaqueValueExpr *CommonExprOpaqueValue)
   : Expr(SC, Resume->getType(), Resume->getValueKind(),
  Resume->getObjectKind()),
-KeywordLoc(KeywordLoc), OpaqueValue(OpaqueValue) {
+KeywordLoc(KeywordLoc), CommonExprOpaqueValue(CommonExprOpaqueValue) {
 SubExprs[SubExpr::Operand] = Operand;
 SubExprs[SubExpr::Common] = Common;
 SubExprs[SubExpr::Ready] = Ready;
@@ -5128,7 +5129,16 @@ class CoroutineSuspendExpr : public Expr {
   }
 
   /// getOpaqueValue - Return the opaque value placeholder.
-  OpaqueValueExpr *getOpaqueValue() const { return OpaqueValue; }
+  OpaqueValueExpr *getCommonExprOpaqueValue() const {
+return CommonExprOpaqueValue;
+  }
+
+  OpaqueValueExpr *getInplaceCallOpaqueValue() const {
+return InplaceCallOpaqueValue;
+  }
+  void setInplaceCallOpaqueValue(OpaqueValueExpr *E) {
+InplaceCallOpaqueValue = E;
+  }
 
   Expr *getReadyExpr() const {
 return static_cast(SubExprs[SubExpr::Ready]);
@@ -5194,9 +5204,9 @@ class CoawaitExpr : publi

[clang] [Clang] Refactor uses of `Cand->Function` in SemaOverload.cpp (PR #98965)

2024-07-15 Thread via cfe-commits

https://github.com/vortex73 edited 
https://github.com/llvm/llvm-project/pull/98965
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Bounds Safety][NFC] Add `SemaBoundsSafety` class and move existing Sema checks there (PR #98954)

2024-07-15 Thread Vlad Serebrennikov via cfe-commits

Endilll wrote:

> > If you take a close look at the existing set of `Sema` parts, it's almost 
> > entirely comprised of other languages or language extensions (from C and 
> > C++ standpoint) and backends. They were considered natural enough to be 
> > split off `Sema`, which, among other things, means that it's easy to 
> > explain their place in the big picture, like I did in the previous sentence.
> 
> I don't have a strong opinion on whether this should be split up, but I just 
> wanted to point out that `-fbounds-safety` is also a language extension, so 
> it does kind of fit your description of other things separated out.

"Extension" is definitely quite broad. What I meant are (basically) languages 
that are based off C or C++. Would you argue that `-fbounds-safety` fits into a 
set of OpenMP, OpenACC, CUDA, HLSL, Objective-C, and Swift?

> It's currently in the process of being upstreamed which is why it's small, 
> but it'd be easier to split now than wait until it's reached a certain size, 
> if we do want to split it eventually.

I did that a lot with other parts of `Sema`, and it's not that hard, unless it 
grows comparable to `SemaExprCXX.cpp` (which I consider unlikely to happen). 
I'd rather see this being upstreamed into the existing `Sema` structure as it 
has been planned all along, and use it as an input for the design of further 
`Sema` splitting, rather than committing today that `SemaBoundsSafety` is going 
to be a thing.

https://github.com/llvm/llvm-project/pull/98954
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-doc] add enum test (PR #97679)

2024-07-15 Thread via cfe-commits

https://github.com/PeterChou1 updated 
https://github.com/llvm/llvm-project/pull/97679

>From b5e0335199541225a1b0eb5eaf661cd4df55dbd7 Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Thu, 4 Jul 2024 01:14:11 -0400
Subject: [PATCH 1/6] [clang-doc] add enum test

---
 clang-tools-extra/test/clang-doc/enum.cpp | 38 +++
 1 file changed, 38 insertions(+)
 create mode 100644 clang-tools-extra/test/clang-doc/enum.cpp

diff --git a/clang-tools-extra/test/clang-doc/enum.cpp 
b/clang-tools-extra/test/clang-doc/enum.cpp
new file mode 100644
index 0..2f25eaf4e44e2
--- /dev/null
+++ b/clang-tools-extra/test/clang-doc/enum.cpp
@@ -0,0 +1,38 @@
+// RUN: clang-doc --format=html --doxygen --output=%t/docs 
--executor=standalone %s
+// RUN: clang-doc --format=md --doxygen --output=%t/docs --executor=standalone 
%s
+// RUN: FileCheck %s -input-file=%t/docs/GlobalNamespace/index.html 
-check-prefix=HTML-INDEX
+// RUN: FileCheck %s -input-file=%t/docs/GlobalNamespace/index.md 
-check-prefix=MD-INDEX
+
+/**
+ * @brief For specifying RGB colors
+ */
+enum Color {
+  Red, // Red enums
+  Green, // Green enums
+  Blue // Blue enums
+};
+
+// HTML-INDEX: Global Namespace
+// HTML-INDEX: Enums
+// HTML-INDEX: 
+// HTML-INDEX:   enum Color
+// HTML-INDEX:   
+// HTML-INDEX: Red
+// HTML-INDEX: Green
+// HTML-INDEX: Blue
+// HTML-INDEX:   
+// HTML-INDEX:   Defined at line 11 of file 
{{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp
+// HTML-INDEX:   
+// HTML-INDEX: 
+// HTML-INDEX:   
+// HTML-INDEX: 
+
+// MD-INDEX: # Global Namespace
+// MD-INDEX: ## Enums
+// MD-INDEX: | enum Color |
+// MD-INDEX: --
+// MD-INDEX: | Red |
+// MD-INDEX: | Green |
+// MD-INDEX: | Blue |
+// MD-INDEX: *Defined at 
{{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp#11*
+// MD-INDEX: **brief** For specifying RGB colors
\ No newline at end of file

>From c10f9d42c26e6d26833a35824216529ab25e7fe8 Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Thu, 4 Jul 2024 01:53:19 -0400
Subject: [PATCH 2/6] [clang-doc] update defined at line

---
 clang-tools-extra/test/clang-doc/enum.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang-tools-extra/test/clang-doc/enum.cpp 
b/clang-tools-extra/test/clang-doc/enum.cpp
index 2f25eaf4e44e2..1e7dd6e4c5b0c 100644
--- a/clang-tools-extra/test/clang-doc/enum.cpp
+++ b/clang-tools-extra/test/clang-doc/enum.cpp
@@ -21,7 +21,7 @@ enum Color {
 // HTML-INDEX: Green
 // HTML-INDEX: Blue
 // HTML-INDEX:   
-// HTML-INDEX:   Defined at line 11 of file 
{{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp
+// HTML-INDEX:   Defined at line 9 of file 
{{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp
 // HTML-INDEX:   
 // HTML-INDEX: 
 // HTML-INDEX:   

>From 8709091091b0ca889ca7911e06b7a4dae61a3581 Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Thu, 4 Jul 2024 02:06:08 -0400
Subject: [PATCH 3/6] [clang-doc] fix lines

---
 clang-tools-extra/test/clang-doc/enum.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang-tools-extra/test/clang-doc/enum.cpp 
b/clang-tools-extra/test/clang-doc/enum.cpp
index 1e7dd6e4c5b0c..5a1452788a55f 100644
--- a/clang-tools-extra/test/clang-doc/enum.cpp
+++ b/clang-tools-extra/test/clang-doc/enum.cpp
@@ -34,5 +34,5 @@ enum Color {
 // MD-INDEX: | Red |
 // MD-INDEX: | Green |
 // MD-INDEX: | Blue |
-// MD-INDEX: *Defined at 
{{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp#11*
+// MD-INDEX: *Defined at 
{{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp#9*
 // MD-INDEX: **brief** For specifying RGB colors
\ No newline at end of file

>From cd98a8cc662527e1488be17a2963874eb3267409 Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Fri, 12 Jul 2024 07:03:34 -0400
Subject: [PATCH 4/6] [clang-doc] address pr comments

---
 clang-tools-extra/test/clang-doc/enum.cpp | 34 ++-
 1 file changed, 14 insertions(+), 20 deletions(-)

diff --git a/clang-tools-extra/test/clang-doc/enum.cpp 
b/clang-tools-extra/test/clang-doc/enum.cpp
index 5a1452788a55f..fcc05477903ff 100644
--- a/clang-tools-extra/test/clang-doc/enum.cpp
+++ b/clang-tools-extra/test/clang-doc/enum.cpp
@@ -1,31 +1,25 @@
-// RUN: clang-doc --format=html --doxygen --output=%t/docs 
--executor=standalone %s
-// RUN: clang-doc --format=md --doxygen --output=%t/docs --executor=standalone 
%s
-// RUN: FileCheck %s -input-file=%t/docs/GlobalNamespace/index.html 
-check-prefix=HTML-INDEX
-// RUN: FileCheck %s -input-file=%t/docs/GlobalNamespace/index.md 
-check-prefix=MD-INDEX
+// RUN: rm -rf %t && mkdir -p %t
+// RUN: clang-doc --format=html --doxygen --output=%t --executor=standalone %s
+// RUN: clang-doc --format=md --doxygen --output=%t --executor=standalone %s
+// RUN: FileCheck %s < %t/GlobalNamespace/index.html -check-prefix=HTML-INDEX
+// RUN: FileCheck %s < %t/GlobalNamespace/index.md -check-prefix=MD-INDEX
 
 /**

[clang] [llvm] [Clang][Coroutines] Introducing the `[[clang::coro_inplace_task]]` attribute (PR #94693)

2024-07-15 Thread Yuxuan Chen via cfe-commits

https://github.com/yuxuanchen1997 updated 
https://github.com/llvm/llvm-project/pull/94693

>From 23051f31dc3f6f2e0ba29a69cbba0668c6248f48 Mon Sep 17 00:00:00 2001
From: Yuxuan Chen 
Date: Tue, 4 Jun 2024 23:22:00 -0700
Subject: [PATCH] [Clang] Introduce [[clang::coro_inplace_task]]

Implement noalloc copy

add CoroAnnotationElidePass
---
 clang/include/clang/AST/ExprCXX.h |  26 ++--
 clang/include/clang/Basic/Attr.td |   8 ++
 clang/include/clang/Basic/AttrDocs.td |  19 +++
 clang/lib/CodeGen/CGBlocks.cpp|   5 +-
 clang/lib/CodeGen/CGCUDARuntime.cpp   |   5 +-
 clang/lib/CodeGen/CGCUDARuntime.h |   8 +-
 clang/lib/CodeGen/CGCXXABI.h  |  10 +-
 clang/lib/CodeGen/CGClass.cpp |  16 +--
 clang/lib/CodeGen/CGCoroutine.cpp |  30 +++--
 clang/lib/CodeGen/CGExpr.cpp  |  41 +++---
 clang/lib/CodeGen/CGExprCXX.cpp   |  60 +
 clang/lib/CodeGen/CodeGenFunction.h   |  64 ++
 clang/lib/CodeGen/ItaniumCXXABI.cpp   |  16 +--
 clang/lib/CodeGen/MicrosoftCXXABI.cpp |  18 +--
 clang/lib/Sema/SemaCoroutine.cpp  |  58 -
 clang/lib/Serialization/ASTReaderStmt.cpp |  10 +-
 clang/lib/Serialization/ASTWriterStmt.cpp |   3 +-
 clang/test/CodeGenCoroutines/Inputs/utility.h |  13 ++
 .../coro-annotate-must-elide.cpp  |  87 +
 ...a-attribute-supported-attributes-list.test |   1 +
 llvm/include/llvm/IR/Instruction.h|   4 +
 .../Coroutines/CoroAnnotationElide.h  |  34 +
 llvm/lib/IR/Metadata.cpp  |  16 +++
 llvm/lib/Passes/PassBuilder.cpp   |   1 +
 llvm/lib/Passes/PassBuilderPipelines.cpp  |   3 +-
 llvm/lib/Passes/PassRegistry.def  |   1 +
 llvm/lib/Transforms/Coroutines/CMakeLists.txt |   1 +
 .../Coroutines/CoroAnnotationElide.cpp| 117 ++
 llvm/lib/Transforms/Coroutines/CoroInternal.h |   4 +
 llvm/lib/Transforms/Coroutines/CoroSplit.cpp  |  81 ++--
 llvm/lib/Transforms/Coroutines/Coroutines.cpp |  27 
 llvm/test/Other/new-pm-defaults.ll|   1 +
 .../Other/new-pm-thinlto-postlink-defaults.ll |   1 +
 .../new-pm-thinlto-postlink-pgo-defaults.ll   |   1 +
 ...-pm-thinlto-postlink-samplepgo-defaults.ll |   1 +
 .../Other/new-pm-thinlto-prelink-defaults.ll  |   1 +
 .../new-pm-thinlto-prelink-pgo-defaults.ll|   1 +
 ...w-pm-thinlto-prelink-samplepgo-defaults.ll |   1 +
 .../Coroutines/coro-transform-must-elide.ll   |  77 
 39 files changed, 733 insertions(+), 138 deletions(-)
 create mode 100644 clang/test/CodeGenCoroutines/Inputs/utility.h
 create mode 100644 clang/test/CodeGenCoroutines/coro-annotate-must-elide.cpp
 create mode 100644 
llvm/include/llvm/Transforms/Coroutines/CoroAnnotationElide.h
 create mode 100644 llvm/lib/Transforms/Coroutines/CoroAnnotationElide.cpp
 create mode 100644 llvm/test/Transforms/Coroutines/coro-transform-must-elide.ll

diff --git a/clang/include/clang/AST/ExprCXX.h 
b/clang/include/clang/AST/ExprCXX.h
index c2feac525c1ea..0cf62aee41b66 100644
--- a/clang/include/clang/AST/ExprCXX.h
+++ b/clang/include/clang/AST/ExprCXX.h
@@ -5082,7 +5082,8 @@ class CoroutineSuspendExpr : public Expr {
   enum SubExpr { Operand, Common, Ready, Suspend, Resume, Count };
 
   Stmt *SubExprs[SubExpr::Count];
-  OpaqueValueExpr *OpaqueValue = nullptr;
+  OpaqueValueExpr *CommonExprOpaqueValue = nullptr;
+  OpaqueValueExpr *InplaceCallOpaqueValue = nullptr;
 
 public:
   // These types correspond to the three C++ 'await_suspend' return variants
@@ -5090,10 +5091,10 @@ class CoroutineSuspendExpr : public Expr {
 
   CoroutineSuspendExpr(StmtClass SC, SourceLocation KeywordLoc, Expr *Operand,
Expr *Common, Expr *Ready, Expr *Suspend, Expr *Resume,
-   OpaqueValueExpr *OpaqueValue)
+   OpaqueValueExpr *CommonExprOpaqueValue)
   : Expr(SC, Resume->getType(), Resume->getValueKind(),
  Resume->getObjectKind()),
-KeywordLoc(KeywordLoc), OpaqueValue(OpaqueValue) {
+KeywordLoc(KeywordLoc), CommonExprOpaqueValue(CommonExprOpaqueValue) {
 SubExprs[SubExpr::Operand] = Operand;
 SubExprs[SubExpr::Common] = Common;
 SubExprs[SubExpr::Ready] = Ready;
@@ -5128,7 +5129,16 @@ class CoroutineSuspendExpr : public Expr {
   }
 
   /// getOpaqueValue - Return the opaque value placeholder.
-  OpaqueValueExpr *getOpaqueValue() const { return OpaqueValue; }
+  OpaqueValueExpr *getCommonExprOpaqueValue() const {
+return CommonExprOpaqueValue;
+  }
+
+  OpaqueValueExpr *getInplaceCallOpaqueValue() const {
+return InplaceCallOpaqueValue;
+  }
+  void setInplaceCallOpaqueValue(OpaqueValueExpr *E) {
+InplaceCallOpaqueValue = E;
+  }
 
   Expr *getReadyExpr() const {
 return static_cast(SubExprs[SubExpr::Ready]);
@@ -5194,9 +5204,9 @@ class CoawaitExpr : public CoroutineS

[clang] [clang-tools-extra] [clang-tidy] Fix false in unnecessary-value-param inside templates (PR #98488)

2024-07-15 Thread Dmitry Polukhin via cfe-commits

https://github.com/dmpolukhin updated 
https://github.com/llvm/llvm-project/pull/98488

>From a05c4ca2c2e61653e7bd8d3a2f5faa6b86daa615 Mon Sep 17 00:00:00 2001
From: Dmitry Polukhin 
Date: Thu, 11 Jul 2024 07:01:49 -0700
Subject: [PATCH 1/4] [clang-tidy] Fix false in unnecessary-value-param inside
 templates

Summary:
If callExpr is type dependent, there is no way to analyze individual arguments
until template specialization. Before this diff only calls with dependent
callees were skipped so unnecessary-value-param was processing arguments that
had non-dependent type that gave false positives because the call was not fully
resolved till specialization. So now instead of checking type dependent callee,
the whole expression will be checked for type dependent.

Test Plan: check-clang-tools
---
 .../performance/unnecessary-value-param.cpp   | 34 +++
 clang/lib/Analysis/ExprMutationAnalyzer.cpp   |  9 +++--
 2 files changed, 38 insertions(+), 5 deletions(-)

diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-value-param.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-value-param.cpp
index d578eedd94a39..b1696ad3c3d59 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-value-param.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-value-param.cpp
@@ -2,6 +2,31 @@
 
 // CHECK-FIXES: #include 
 
+namespace std {
+template 
+struct remove_reference;
+
+template 
+struct remove_reference {
+  typedef _Tp type;
+};
+
+template 
+struct remove_reference<_Tp &> {
+  typedef _Tp type;
+};
+
+template 
+struct remove_reference<_Tp &&> {
+  typedef _Tp type;
+};
+
+template 
+constexpr typename std::remove_reference<_Tp>::type &&move(_Tp &&__t) {
+  return static_cast::type &&>(__t);
+}
+} // namespace std
+
 struct ExpensiveToCopyType {
   const ExpensiveToCopyType & constReference() const {
 return *this;
@@ -402,3 +427,12 @@ int templateSpecializationFunction(ExpensiveToCopyType E) {
   // CHECK-FIXES-NOT: int templateSpecializationFunction(const 
ExpensiveToCopyType& E) {
   return 0;
 }
+
+struct B {
+  static void bar(ExpensiveMovableType a, ExpensiveMovableType b);
+};
+
+template 
+void NegativeCallWithDependentAndNondependentArgs(ExpensiveMovableType a, T b) 
{
+B::bar(std::move(a), b);
+}
diff --git a/clang/lib/Analysis/ExprMutationAnalyzer.cpp 
b/clang/lib/Analysis/ExprMutationAnalyzer.cpp
index 3b3782fa1db9a..70a1d7b52ffe9 100644
--- a/clang/lib/Analysis/ExprMutationAnalyzer.cpp
+++ b/clang/lib/Analysis/ExprMutationAnalyzer.cpp
@@ -404,15 +404,14 @@ ExprMutationAnalyzer::Analyzer::findDirectMutation(const 
Expr *Exp) {
 memberExpr(hasObjectExpression(canResolveToExpr(Exp,
   nonConstReferenceType());
   const auto NotInstantiated = unless(hasDeclaration(isInstantiated()));
-  const auto TypeDependentCallee =
-  callee(expr(anyOf(unresolvedLookupExpr(), unresolvedMemberExpr(),
-cxxDependentScopeMemberExpr(),
-hasType(templateTypeParmType()), isTypeDependent(;
 
   const auto AsNonConstRefArg = anyOf(
   callExpr(NonConstRefParam, NotInstantiated),
   cxxConstructExpr(NonConstRefParam, NotInstantiated),
-  callExpr(TypeDependentCallee, hasAnyArgument(canResolveToExpr(Exp))),
+  // If the call is type-dependent, we can't properly process any
+  // argument because required type conversions and implicit casts
+  // will be inserted only after specialization.
+  callExpr(isTypeDependent(), hasAnyArgument(canResolveToExpr(Exp))),
   cxxUnresolvedConstructExpr(hasAnyArgument(canResolveToExpr(Exp))),
   // Previous False Positive in the following Code:
   // `template  void f() { int i = 42; new Type(i); }`

>From dbcdb0655318b7ba674cf00c7a9da9917a056102 Mon Sep 17 00:00:00 2001
From: Dmitry Polukhin 
Date: Thu, 11 Jul 2024 07:35:21 -0700
Subject: [PATCH 2/4] Apply git-clang-format

---
 clang/lib/Analysis/ExprMutationAnalyzer.cpp | 34 ++---
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/clang/lib/Analysis/ExprMutationAnalyzer.cpp 
b/clang/lib/Analysis/ExprMutationAnalyzer.cpp
index 70a1d7b52ffe9..6d726ae44104e 100644
--- a/clang/lib/Analysis/ExprMutationAnalyzer.cpp
+++ b/clang/lib/Analysis/ExprMutationAnalyzer.cpp
@@ -405,23 +405,23 @@ ExprMutationAnalyzer::Analyzer::findDirectMutation(const 
Expr *Exp) {
   nonConstReferenceType());
   const auto NotInstantiated = unless(hasDeclaration(isInstantiated()));
 
-  const auto AsNonConstRefArg = anyOf(
-  callExpr(NonConstRefParam, NotInstantiated),
-  cxxConstructExpr(NonConstRefParam, NotInstantiated),
-  // If the call is type-dependent, we can't properly process any
-  // argument because required type conversions and implicit casts
-  // will be inserted only after specialization.
-  callExpr(isTypeDependent(), hasAnyArgument(canResolveToExpr(Exp))),
-

[clang-tools-extra] [clang-doc] add enum test (PR #97679)

2024-07-15 Thread via cfe-commits


@@ -0,0 +1,121 @@
+// RUN: rm -rf %t && mkdir -p %t
+// RUN: clang-doc --format=html --doxygen --output=%t --executor=standalone %s
+// RUN: clang-doc --format=md --doxygen --output=%t --executor=standalone %s
+// RUN: FileCheck %s < %t/GlobalNamespace/index.html -check-prefix=HTML-INDEX
+// RUN: FileCheck %s < %t/GlobalNamespace/Animals.html 
-check-prefix=HTML-ANIMAL
+// RUN: FileCheck %s < %t/Vehicles/index.html -check-prefix=HTML-VEHICLES
+// RUN: FileCheck %s < %t/GlobalNamespace/index.md -check-prefix=MD-INDEX
+// RUN: FileCheck %s < %t/GlobalNamespace/Animals.md -check-prefix=MD-ANIMAL
+// RUN: FileCheck %s < %t/Vehicles/index.md -check-prefix=MD-VEHICLES
+
+
+/**
+ * @brief For specifying RGB colors
+ */
+enum Color {
+  Red, // Red
+  Green, // Green
+  Blue // Blue
+};
+
+/**
+ * @brief Shape Types
+ */
+enum Shapes {

PeterChou1 wrote:

I did not know that enum classes were a thing, I thought you meant enum 
embedded in a class, I've update the code

https://github.com/llvm/llvm-project/pull/97679
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Introduce Frontend Attribute [[clang::coro_inplace_task]] (PR #98971)

2024-07-15 Thread Yuxuan Chen via cfe-commits

https://github.com/yuxuanchen1997 created 
https://github.com/llvm/llvm-project/pull/98971

This patch is the frontend implementation of the coroutine elide improvement 
project detailed in this discourse post: 
https://discourse.llvm.org/t/language-extension-for-better-more-deterministic-halo-for-c-coroutines/80044/7

This patch proposes a C++ struct/class attribute 
`[[clang::coro_inplace_task]]`. This notion of inplace task gives developers 
and library authors a certainty that coroutine heap elision happens in a 
predictable way. 

Originally, after we lower a coroutine to LLVM IR, CoroElide is responsible for 
analysis of whether an elision can happen. Take this as an example:
```
Task foo();
Task bar() {
  co_await foo();
}
```
For CoroElide to happen, the ramp function of `foo` must be inlined into `bar`. 
This inlining happens after `foo` has been split but `bar` is usually still a 
presplit coroutine. If `foo` is indeed a coroutine, the inlined `coro.id` 
intrinsics of `foo` is visible within `bar`. CoroElide then runs an analysis to 
figure out whether the SSA value of `coro.begin()` of `foo` gets destroyed 
before `bar` terminates. 

`Task` types are rarely simple enough for the destroy logic of the task to 
reference the SSA value from `coro.begin()` directly. Hence, the pass is very 
ineffective for even the most trivial C++ Task types. Improving CoroElide by 
implementing more powerful analyses is possible, however it doesn't give us the 
predictability when we expect elision to happen. 

The approach we want to take with this language extension generally originates 
from the philosophy that library implementations of `Task` types has the 
control over the structured concurrency guarantees we demand for elision to 
happen. That is, the lifetime for the callee's frame is shorter to that of the 
caller. 

The ``[[clang::coro_inplace_task]]`` is a class attribute which can be applied 
to a coroutine return type.

When a coroutine function that returns such a type calls another coroutine 
function, the compiler performs heap allocation elision when the following 
conditions are all met:
- callee coroutine function returns a type that is annotated with 
``[[clang::coro_inplace_task]]``.
- The callee coroutine function is inlined.
- In caller coroutine, the return value of the callee is a prvalue that is 
immediately `co_await`ed.

>From the C++ perspective, it makes sense because we can ensure the lifetime of 
>elided callee cannot exceed that of the caller if we can guarantee that the 
>caller coroutine is never destroyed earlier than the callee coroutine. This is 
>not generally true for any C++ programs. However, the library that implements 
>`Task` types and executors may provide this guarantee to the compiler, 
>providing the user with certainty that HALO will work on their programs. 

After this patch, when compiling coroutines that return a type with such 
attribute, the frontend checks that the type of the operand of `co_await` 
expressions (not `operator co_await`). If it's also attributed with 
`[[clang::coro_inplace_task]]`, the FE emits metadata on the call or invoke 
instruction as a hint for a later middle end pass to elide the elision. 

The original patch version is https://github.com/llvm/llvm-project/pull/94693 
and as suggested, the patch is split into frontend and middle end solutions 
into two patches. The middle end patch can be found at [[PR number]].

>From 527ae72e273a331c97c9ba656e5e9d84cf9fde61 Mon Sep 17 00:00:00 2001
From: Yuxuan Chen 
Date: Tue, 4 Jun 2024 23:22:00 -0700
Subject: [PATCH] [Clang] Introduce [[clang::coro_inplace_task]]

Implement noalloc copy

add CoroAnnotationElidePass
---
 clang/include/clang/AST/ExprCXX.h | 26 --
 clang/include/clang/Basic/Attr.td |  8 ++
 clang/include/clang/Basic/AttrDocs.td | 19 
 clang/lib/CodeGen/CGBlocks.cpp|  5 +-
 clang/lib/CodeGen/CGCUDARuntime.cpp   |  5 +-
 clang/lib/CodeGen/CGCUDARuntime.h |  8 +-
 clang/lib/CodeGen/CGCXXABI.h  | 10 +--
 clang/lib/CodeGen/CGClass.cpp | 16 ++--
 clang/lib/CodeGen/CGCoroutine.cpp | 30 +--
 clang/lib/CodeGen/CGExpr.cpp  | 41 +
 clang/lib/CodeGen/CGExprCXX.cpp   | 60 +++--
 clang/lib/CodeGen/CodeGenFunction.h   | 64 --
 clang/lib/CodeGen/ItaniumCXXABI.cpp   | 16 ++--
 clang/lib/CodeGen/MicrosoftCXXABI.cpp | 18 ++--
 clang/lib/Sema/SemaCoroutine.cpp  | 58 -
 clang/lib/Serialization/ASTReaderStmt.cpp | 10 ++-
 clang/lib/Serialization/ASTWriterStmt.cpp |  3 +-
 clang/test/CodeGenCoroutines/Inputs/utility.h | 13 +++
 .../coro-annotate-must-elide.cpp  | 87 +++
 ...a-attribute-supported-attributes-list.test |  1 +
 20 files changed, 369 insertions(+), 129 deletions(-)
 create mode 100644 clang/test/CodeGenCoroutines/Inputs/utility.h
 cre

[clang] [Clang] Introduce Frontend Attribute [[clang::coro_inplace_task]] (PR #98971)

2024-07-15 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Yuxuan Chen (yuxuanchen1997)


Changes

This patch is the frontend implementation of the coroutine elide improvement 
project detailed in this discourse post: 
https://discourse.llvm.org/t/language-extension-for-better-more-deterministic-halo-for-c-coroutines/80044/7

This patch proposes a C++ struct/class attribute 
`[[clang::coro_inplace_task]]`. This notion of inplace task gives developers 
and library authors a certainty that coroutine heap elision happens in a 
predictable way. 

Originally, after we lower a coroutine to LLVM IR, CoroElide is responsible for 
analysis of whether an elision can happen. Take this as an example:
```
Task foo();
Task bar() {
  co_await foo();
}
```
For CoroElide to happen, the ramp function of `foo` must be inlined into `bar`. 
This inlining happens after `foo` has been split but `bar` is usually still a 
presplit coroutine. If `foo` is indeed a coroutine, the inlined `coro.id` 
intrinsics of `foo` is visible within `bar`. CoroElide then runs an analysis to 
figure out whether the SSA value of `coro.begin()` of `foo` gets destroyed 
before `bar` terminates. 

`Task` types are rarely simple enough for the destroy logic of the task to 
reference the SSA value from `coro.begin()` directly. Hence, the pass is very 
ineffective for even the most trivial C++ Task types. Improving CoroElide by 
implementing more powerful analyses is possible, however it doesn't give us the 
predictability when we expect elision to happen. 

The approach we want to take with this language extension generally originates 
from the philosophy that library implementations of `Task` types has the 
control over the structured concurrency guarantees we demand for elision to 
happen. That is, the lifetime for the callee's frame is shorter to that of the 
caller. 

The ``[[clang::coro_inplace_task]]`` is a class attribute which can be applied 
to a coroutine return type.

When a coroutine function that returns such a type calls another coroutine 
function, the compiler performs heap allocation elision when the following 
conditions are all met:
- callee coroutine function returns a type that is annotated with 
``[[clang::coro_inplace_task]]``.
- The callee coroutine function is inlined.
- In caller coroutine, the return value of the callee is a prvalue that is 
immediately `co_await`ed.

>From the C++ perspective, it makes sense because we can ensure the lifetime of 
>elided callee cannot exceed that of the caller if we can guarantee that the 
>caller coroutine is never destroyed earlier than the callee coroutine. This is 
>not generally true for any C++ programs. However, the library that implements 
>`Task` types and executors may provide this guarantee to the compiler, 
>providing the user with certainty that HALO will work on their programs. 

After this patch, when compiling coroutines that return a type with such 
attribute, the frontend checks that the type of the operand of `co_await` 
expressions (not `operator co_await`). If it's also attributed with 
`[[clang::coro_inplace_task]]`, the FE emits metadata on the call or invoke 
instruction as a hint for a later middle end pass to elide the elision. 

The original patch version is https://github.com/llvm/llvm-project/pull/94693 
and as suggested, the patch is split into frontend and middle end solutions 
into two patches. The middle end patch can be found at [[PR number]].

---

Patch is 50.45 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/98971.diff


20 Files Affected:

- (modified) clang/include/clang/AST/ExprCXX.h (+18-8) 
- (modified) clang/include/clang/Basic/Attr.td (+8) 
- (modified) clang/include/clang/Basic/AttrDocs.td (+19) 
- (modified) clang/lib/CodeGen/CGBlocks.cpp (+3-2) 
- (modified) clang/lib/CodeGen/CGCUDARuntime.cpp (+3-2) 
- (modified) clang/lib/CodeGen/CGCUDARuntime.h (+5-3) 
- (modified) clang/lib/CodeGen/CGCXXABI.h (+5-5) 
- (modified) clang/lib/CodeGen/CGClass.cpp (+6-10) 
- (modified) clang/lib/CodeGen/CGCoroutine.cpp (+21-9) 
- (modified) clang/lib/CodeGen/CGExpr.cpp (+25-16) 
- (modified) clang/lib/CodeGen/CGExprCXX.cpp (+33-27) 
- (modified) clang/lib/CodeGen/CodeGenFunction.h (+37-27) 
- (modified) clang/lib/CodeGen/ItaniumCXXABI.cpp (+9-7) 
- (modified) clang/lib/CodeGen/MicrosoftCXXABI.cpp (+10-8) 
- (modified) clang/lib/Sema/SemaCoroutine.cpp (+56-2) 
- (modified) clang/lib/Serialization/ASTReaderStmt.cpp (+8-2) 
- (modified) clang/lib/Serialization/ASTWriterStmt.cpp (+2-1) 
- (added) clang/test/CodeGenCoroutines/Inputs/utility.h (+13) 
- (added) clang/test/CodeGenCoroutines/coro-annotate-must-elide.cpp (+87) 
- (modified) clang/test/Misc/pragma-attribute-supported-attributes-list.test 
(+1) 


``diff
diff --git a/clang/include/clang/AST/ExprCXX.h 
b/clang/include/clang/AST/ExprCXX.h
index c2feac525c1ea..0cf62aee41b66 100644
--- a/clang/include/clang/AST/ExprCXX.h
+++ b/clang/include/clang/AST/ExprCXX.h
@@ -5

[clang] [llvm] Finish deleting the le32/le64 targets (PR #98497)

2024-07-15 Thread Steven Johnson via cfe-commits

steven-johnson wrote:

Unfortunately, this utterly breaks Halide, which was in fact relying on both of 
these targets.

https://github.com/llvm/llvm-project/pull/98497
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Finish deleting the le32/le64 targets (PR #98497)

2024-07-15 Thread Steven Johnson via cfe-commits

steven-johnson wrote:

> LGTM! That partial Le32/Leb64 restore was to give Halide some time.

I understand that you want these gone, but the fact of the matter is that 
Halide isn't ready for this change, and so the next integrate of LLVM into 
google3 will break the world. We urgently need these features (or something 
like them).

https://github.com/llvm/llvm-project/pull/98497
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [LLVM] Perform HALO on "coro_must_elide" coroutines (PR #98974)

2024-07-15 Thread Yuxuan Chen via cfe-commits

https://github.com/yuxuanchen1997 created 
https://github.com/llvm/llvm-project/pull/98974

This patch is the middle end implementation for the coroutine HALO improvement 
project published on discourse: 
https://discourse.llvm.org/t/language-extension-for-better-more-deterministic-halo-for-c-coroutines/80044/7

Previously CoroElide depends on inlining, and its analysis does not work very 
well with code generated by the C++ frontend due the existence of many 
customization points. There has been issue reported to upstream how ineffective 
the original CoroElide was in real world applications. 

For C++ users, this set of patches aim to fix this problem by providing library 
authors and users deterministic HALO behaviour for some well-behaved coroutine 
`Task` types. The stack begins with a library side attribute on the `Task` 
class that guarantees no unstructured concurrency when coroutines are awaited 
directly with `co_await`ed as a prvalue. This attribute on Task types gives us 
lifetime guarantees and makes C++ FE capable to telling the ME which coroutine 
calls are elidable. We convey such information from FE through metadata 
`!annotation !{!"coro_must_elide"}`.

This patch modifies CoroSplit to create a variant of the coroutine ramp 
function that 1) does not use heap allocated frame, instead take an additional 
parameter as the pointer to the frame. Such parameter is attributed with 
`dereferenceble` and `align` to convey size and align requirements for the 
frame. 2) always stores cleanup instead of destroy address for `coro.destroy()` 
actions. 

Additionally, we have a new pass that runs right after CoroSplit to find usages 
of the callee coroutine annotated `!{!"coro_must_elide"}` in presplit coroutine 
callers, allocates the frame on its "stack", transform those usages to call the 
`noalloc` ramp function variant. 

(note I put quotes on the word "stack" here, because for presplit coroutine, 
any alloca will be spilled into the frame when it's being split)

The C++ Frontend attribute implementation that works with this change can be 
found at https://github.com/llvm/llvm-project/pull/98971

>From 527ae72e273a331c97c9ba656e5e9d84cf9fde61 Mon Sep 17 00:00:00 2001
From: Yuxuan Chen 
Date: Tue, 4 Jun 2024 23:22:00 -0700
Subject: [PATCH 1/2] [Clang] Introduce [[clang::coro_inplace_task]]

Implement noalloc copy

add CoroAnnotationElidePass
---
 clang/include/clang/AST/ExprCXX.h | 26 --
 clang/include/clang/Basic/Attr.td |  8 ++
 clang/include/clang/Basic/AttrDocs.td | 19 
 clang/lib/CodeGen/CGBlocks.cpp|  5 +-
 clang/lib/CodeGen/CGCUDARuntime.cpp   |  5 +-
 clang/lib/CodeGen/CGCUDARuntime.h |  8 +-
 clang/lib/CodeGen/CGCXXABI.h  | 10 +--
 clang/lib/CodeGen/CGClass.cpp | 16 ++--
 clang/lib/CodeGen/CGCoroutine.cpp | 30 +--
 clang/lib/CodeGen/CGExpr.cpp  | 41 +
 clang/lib/CodeGen/CGExprCXX.cpp   | 60 +++--
 clang/lib/CodeGen/CodeGenFunction.h   | 64 --
 clang/lib/CodeGen/ItaniumCXXABI.cpp   | 16 ++--
 clang/lib/CodeGen/MicrosoftCXXABI.cpp | 18 ++--
 clang/lib/Sema/SemaCoroutine.cpp  | 58 -
 clang/lib/Serialization/ASTReaderStmt.cpp | 10 ++-
 clang/lib/Serialization/ASTWriterStmt.cpp |  3 +-
 clang/test/CodeGenCoroutines/Inputs/utility.h | 13 +++
 .../coro-annotate-must-elide.cpp  | 87 +++
 ...a-attribute-supported-attributes-list.test |  1 +
 20 files changed, 369 insertions(+), 129 deletions(-)
 create mode 100644 clang/test/CodeGenCoroutines/Inputs/utility.h
 create mode 100644 clang/test/CodeGenCoroutines/coro-annotate-must-elide.cpp

diff --git a/clang/include/clang/AST/ExprCXX.h 
b/clang/include/clang/AST/ExprCXX.h
index c2feac525c1ea..0cf62aee41b66 100644
--- a/clang/include/clang/AST/ExprCXX.h
+++ b/clang/include/clang/AST/ExprCXX.h
@@ -5082,7 +5082,8 @@ class CoroutineSuspendExpr : public Expr {
   enum SubExpr { Operand, Common, Ready, Suspend, Resume, Count };
 
   Stmt *SubExprs[SubExpr::Count];
-  OpaqueValueExpr *OpaqueValue = nullptr;
+  OpaqueValueExpr *CommonExprOpaqueValue = nullptr;
+  OpaqueValueExpr *InplaceCallOpaqueValue = nullptr;
 
 public:
   // These types correspond to the three C++ 'await_suspend' return variants
@@ -5090,10 +5091,10 @@ class CoroutineSuspendExpr : public Expr {
 
   CoroutineSuspendExpr(StmtClass SC, SourceLocation KeywordLoc, Expr *Operand,
Expr *Common, Expr *Ready, Expr *Suspend, Expr *Resume,
-   OpaqueValueExpr *OpaqueValue)
+   OpaqueValueExpr *CommonExprOpaqueValue)
   : Expr(SC, Resume->getType(), Resume->getValueKind(),
  Resume->getObjectKind()),
-KeywordLoc(KeywordLoc), OpaqueValue(OpaqueValue) {
+KeywordLoc(KeywordLoc), CommonExprOpaqueValue(CommonExprOpaqueValue) {
 SubExprs[SubExpr:

[clang] [llvm] [LLVM] Perform HALO on "coro_must_elide" coroutines (PR #98974)

2024-07-15 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-modules

Author: Yuxuan Chen (yuxuanchen1997)


Changes

This patch is the middle end implementation for the coroutine HALO improvement 
project published on discourse: 
https://discourse.llvm.org/t/language-extension-for-better-more-deterministic-halo-for-c-coroutines/80044/7

Previously CoroElide depends on inlining, and its analysis does not work very 
well with code generated by the C++ frontend due the existence of many 
customization points. There has been issue reported to upstream how ineffective 
the original CoroElide was in real world applications. 

For C++ users, this set of patches aim to fix this problem by providing library 
authors and users deterministic HALO behaviour for some well-behaved coroutine 
`Task` types. The stack begins with a library side attribute on the `Task` 
class that guarantees no unstructured concurrency when coroutines are awaited 
directly with `co_await`ed as a prvalue. This attribute on Task types gives us 
lifetime guarantees and makes C++ FE capable to telling the ME which coroutine 
calls are elidable. We convey such information from FE through metadata 
`!annotation !{!"coro_must_elide"}`.

This patch modifies CoroSplit to create a variant of the coroutine ramp 
function that 1) does not use heap allocated frame, instead take an additional 
parameter as the pointer to the frame. Such parameter is attributed with 
`dereferenceble` and `align` to convey size and align requirements for the 
frame. 2) always stores cleanup instead of destroy address for `coro.destroy()` 
actions. 

Additionally, we have a new pass that runs right after CoroSplit to find usages 
of the callee coroutine annotated `!{!"coro_must_elide"}` in presplit coroutine 
callers, allocates the frame on its "stack", transform those usages to call the 
`noalloc` ramp function variant. 

(note I put quotes on the word "stack" here, because for presplit coroutine, 
any alloca will be spilled into the frame when it's being split)

The C++ Frontend attribute implementation that works with this change can be 
found at https://github.com/llvm/llvm-project/pull/98971

---

Patch is 75.86 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/98974.diff


39 Files Affected:

- (modified) clang/include/clang/AST/ExprCXX.h (+18-8) 
- (modified) clang/include/clang/Basic/Attr.td (+8) 
- (modified) clang/include/clang/Basic/AttrDocs.td (+19) 
- (modified) clang/lib/CodeGen/CGBlocks.cpp (+3-2) 
- (modified) clang/lib/CodeGen/CGCUDARuntime.cpp (+3-2) 
- (modified) clang/lib/CodeGen/CGCUDARuntime.h (+5-3) 
- (modified) clang/lib/CodeGen/CGCXXABI.h (+5-5) 
- (modified) clang/lib/CodeGen/CGClass.cpp (+6-10) 
- (modified) clang/lib/CodeGen/CGCoroutine.cpp (+21-9) 
- (modified) clang/lib/CodeGen/CGExpr.cpp (+25-16) 
- (modified) clang/lib/CodeGen/CGExprCXX.cpp (+33-27) 
- (modified) clang/lib/CodeGen/CodeGenFunction.h (+37-27) 
- (modified) clang/lib/CodeGen/ItaniumCXXABI.cpp (+9-7) 
- (modified) clang/lib/CodeGen/MicrosoftCXXABI.cpp (+10-8) 
- (modified) clang/lib/Sema/SemaCoroutine.cpp (+56-2) 
- (modified) clang/lib/Serialization/ASTReaderStmt.cpp (+8-2) 
- (modified) clang/lib/Serialization/ASTWriterStmt.cpp (+2-1) 
- (added) clang/test/CodeGenCoroutines/Inputs/utility.h (+13) 
- (added) clang/test/CodeGenCoroutines/coro-annotate-must-elide.cpp (+87) 
- (modified) clang/test/Misc/pragma-attribute-supported-attributes-list.test 
(+1) 
- (modified) llvm/include/llvm/IR/Instruction.h (+4) 
- (added) llvm/include/llvm/Transforms/Coroutines/CoroAnnotationElide.h (+34) 
- (modified) llvm/lib/IR/Metadata.cpp (+16) 
- (modified) llvm/lib/Passes/PassBuilder.cpp (+1) 
- (modified) llvm/lib/Passes/PassBuilderPipelines.cpp (+2-1) 
- (modified) llvm/lib/Passes/PassRegistry.def (+1) 
- (modified) llvm/lib/Transforms/Coroutines/CMakeLists.txt (+1) 
- (added) llvm/lib/Transforms/Coroutines/CoroAnnotationElide.cpp (+117) 
- (modified) llvm/lib/Transforms/Coroutines/CoroInternal.h (+4) 
- (modified) llvm/lib/Transforms/Coroutines/CoroSplit.cpp (+73-8) 
- (modified) llvm/lib/Transforms/Coroutines/Coroutines.cpp (+27) 
- (modified) llvm/test/Other/new-pm-defaults.ll (+1) 
- (modified) llvm/test/Other/new-pm-thinlto-postlink-defaults.ll (+1) 
- (modified) llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll (+1) 
- (modified) llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll (+1) 
- (modified) llvm/test/Other/new-pm-thinlto-prelink-defaults.ll (+1) 
- (modified) llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll (+1) 
- (modified) llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll (+1) 
- (added) llvm/test/Transforms/Coroutines/coro-transform-must-elide.ll (+77) 


``diff
diff --git a/clang/include/clang/AST/ExprCXX.h 
b/clang/include/clang/AST/ExprCXX.h
index c2feac525c1ea..0cf62aee41b66 100644
--- a/clang/include/clang/AST/ExprCXX.h
+++ b/clang/include/clang/AST/ExprCXX.h
@@ -5082,7 +5082,8 @@ class CoroutineSu

[clang] [Clang] Introduce Frontend Attribute [[clang::coro_inplace_task]] (PR #98971)

2024-07-15 Thread Yuxuan Chen via cfe-commits

https://github.com/yuxuanchen1997 edited 
https://github.com/llvm/llvm-project/pull/98971
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Introduce Frontend Attribute [[clang::coro_inplace_task]] (PR #98971)

2024-07-15 Thread Yuxuan Chen via cfe-commits

https://github.com/yuxuanchen1997 edited 
https://github.com/llvm/llvm-project/pull/98971
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [Clang][Coroutines] Introducing the `[[clang::coro_inplace_task]]` attribute (PR #94693)

2024-07-15 Thread Yuxuan Chen via cfe-commits

yuxuanchen1997 wrote:

Closing this PR as we are discussing on 
https://discourse.llvm.org/t/language-extension-for-better-more-deterministic-halo-for-c-coroutines/

and as suggested this PR is split into a FE PR 
https://github.com/llvm/llvm-project/pull/98971 and a ME PR 
https://github.com/llvm/llvm-project/pull/98974

https://github.com/llvm/llvm-project/pull/94693
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [Clang][Coroutines] Introducing the `[[clang::coro_inplace_task]]` attribute (PR #94693)

2024-07-15 Thread Yuxuan Chen via cfe-commits

https://github.com/yuxuanchen1997 closed 
https://github.com/llvm/llvm-project/pull/94693
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] C++20 Coroutines: Introduce Frontend Attribute [[clang::coro_inplace_task]] (PR #98971)

2024-07-15 Thread Yuxuan Chen via cfe-commits

https://github.com/yuxuanchen1997 edited 
https://github.com/llvm/llvm-project/pull/98971
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [LLVM][Coroutines] Perform HALO on "coro_must_elide" coroutines (PR #98974)

2024-07-15 Thread Yuxuan Chen via cfe-commits

https://github.com/yuxuanchen1997 edited 
https://github.com/llvm/llvm-project/pull/98974
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Introduce 'clang-nvlink-wrapper' to work around 'nvlink' (PR #96561)

2024-07-15 Thread Artem Belevich via cfe-commits

https://github.com/Artem-B edited 
https://github.com/llvm/llvm-project/pull/96561
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Introduce 'clang-nvlink-wrapper' to work around 'nvlink' (PR #96561)

2024-07-15 Thread Artem Belevich via cfe-commits


@@ -0,0 +1,64 @@
+
+Clang nvlink Wrapper
+
+
+.. contents::
+   :local:
+
+.. _clang-nvlink-wrapper:
+
+Introduction
+
+
+This tools works as a wrapper around the NVIDIA ``nvlink`` linker. The purpose 
+of this wrapper is to provide an interface similar to the ``ld.lld`` linker 
+while still relying on NVIDIA's proprietary linker to produce the final 
output. 
+Features include, static archive (.a) linking, LTO, and accepting files ending 
+in ``.o`` without error.
+
+Usage
+=
+
+This tool can be used with the following options. Any arguments not intended
+only for the linker wrapper will be forwarded to ``nvlink``.
+
+.. code-block:: console
+
+  OVERVIEW: A utility that wraps around the NVIDIA 'nvlink' linker.
+  This enables static linking and LTO handling for NVPTX targets.
+
+  USAGE: clang-nvlink-wrapper [options] 
+
+  OPTIONS:
+--archSpecify the 'sm_' name of the target architecture.
+--cuda-path=Set the system CUDA path
+--dry-runPrint generated commands without running.
+--feature Specify the '+ptx' freature to use for LTO.
+-g   Specify that this was a debug compile.
+-help-hidden Display all available options
+-helpDisplay available options (--help-hidden for more)
+-L  Add  to the library search path
+-l  Search for library 
+-mllvm  Arguments passed to LLVM, including Clang 
invocations, for which the '-mllvm' prefix is preserved. Use '-mllvm --help' 
for a list of options.
+-o Path to file to write output
+--plugin-opt=jobs=
+ Number of LTO codegen partitions
+--plugin-opt=lto-partitions=
+ Number of LTO codegen partitions
+--plugin-opt=O
+ Optimization level for LTO
+--plugin-opt=thinlto
+ Enable the thin-lto backend
+--plugin-opt= Options passed to LLVM, not including the Clang 
invocation. Use '--plugin-opt=--help' for a list of options.
+--save-temps Save intermediate results
+--versionDisplay the version number and exit
+-v   Print verbose information
+
+Example
+===
+
+This tool is intended to be invoked when targeting the NVPTX toolchain 
directly. 

Artem-B wrote:

Does it mean "intended to be invoked **only** from direct compilation targeting 
NVPTX" ? Or do you foresee other potential use cases? 

https://github.com/llvm/llvm-project/pull/96561
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Introduce 'clang-nvlink-wrapper' to work around 'nvlink' (PR #96561)

2024-07-15 Thread Artem Belevich via cfe-commits


@@ -0,0 +1,776 @@
+//===-- clang-nvlink-wrapper/ClangNVLinkWrapper.cpp - NVIDIA linker util 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===-===//
+//
+// This tool wraps around the NVIDIA linker called 'nvlink'. The NVIDIA linker
+// is required to create NVPTX applications, but does not support common
+// features like LTO or archives. This utility wraps around the tool to cover
+// its deficiencies. This tool can be removed once NVIDIA improves their linker
+// or ports it to `ld.lld`.
+//
+//===-===//
+
+#include "clang/Basic/Version.h"
+
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/BinaryFormat/Magic.h"
+#include "llvm/Bitcode/BitcodeWriter.h"
+#include "llvm/CodeGen/CommandFlags.h"
+#include "llvm/IR/DiagnosticPrinter.h"
+#include "llvm/LTO/LTO.h"
+#include "llvm/Object/Archive.h"
+#include "llvm/Object/ArchiveWriter.h"
+#include "llvm/Object/Binary.h"
+#include "llvm/Object/ELFObjectFile.h"
+#include "llvm/Object/IRObjectFile.h"
+#include "llvm/Object/ObjectFile.h"
+#include "llvm/Object/OffloadBinary.h"
+#include "llvm/Option/ArgList.h"
+#include "llvm/Option/OptTable.h"
+#include "llvm/Option/Option.h"
+#include "llvm/Remarks/HotnessThresholdParser.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FileOutputBuffer.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/InitLLVM.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/Program.h"
+#include "llvm/Support/Signals.h"
+#include "llvm/Support/StringSaver.h"
+#include "llvm/Support/TargetSelect.h"
+#include "llvm/Support/WithColor.h"
+
+using namespace llvm;
+using namespace llvm::opt;
+using namespace llvm::object;
+
+// Various tools (e.g., llc and opt) duplicate this series of declarations for
+// options related to passes and remarks.
+static cl::opt RemarksWithHotness(
+"pass-remarks-with-hotness",
+cl::desc("With PGO, include profile count in optimization remarks"),
+cl::Hidden);
+
+static cl::opt, false, remarks::HotnessThresholdParser>
+RemarksHotnessThreshold(
+"pass-remarks-hotness-threshold",
+cl::desc("Minimum profile count required for "
+ "an optimization remark to be output. "
+ "Use 'auto' to apply the threshold from profile summary."),
+cl::value_desc("N or 'auto'"), cl::init(0), cl::Hidden);
+
+static cl::opt
+RemarksFilename("pass-remarks-output",
+cl::desc("Output filename for pass remarks"),
+cl::value_desc("filename"));
+
+static cl::opt
+RemarksPasses("pass-remarks-filter",
+  cl::desc("Only record optimization remarks from passes whose 
"
+   "names match the given regular expression"),
+  cl::value_desc("regex"));
+
+static cl::opt RemarksFormat(
+"pass-remarks-format",
+cl::desc("The format used for serializing remarks (default: YAML)"),
+cl::value_desc("format"), cl::init("yaml"));
+
+static cl::list
+PassPlugins("load-pass-plugin",
+cl::desc("Load passes from plugin library"));
+
+static cl::opt PassPipeline(
+"passes",
+cl::desc(
+"A textual description of the pass pipeline. To have analysis passes "
+"available before a certain pass, add 'require'. "
+"'-passes' overrides the pass pipeline (but not all effects) from "
+"specifying '--opt-level=O?' (O2 is the default) to "
+"clang-linker-wrapper.  Be sure to include the corresponding "
+"'default' in '-passes'."));
+static cl::alias PassPipeline2("p", cl::aliasopt(PassPipeline),
+   cl::desc("Alias for -passes"));
+
+static void printVersion(raw_ostream &OS) {
+  OS << clang::getClangToolFullVersion("clang-nvlink-wrapper") << '\n';
+}
+
+/// The value of `argv[0]` when run.
+static const char *Executable;
+
+/// Temporary files to be cleaned up.
+static SmallVector> TempFiles;
+
+/// Codegen flags for LTO backend.
+static codegen::RegisterCodeGenFlags CodeGenFlags;
+
+namespace {
+// Must not overlap with llvm::opt::DriverFlag.
+enum WrapperFlags { WrapperOnlyOption = (1 << 4) };
+
+enum ID {
+  OPT_INVALID = 0, // This is not an option ID.
+#define OPTION(...) LLVM_MAKE_OPT_ID(__VA_ARGS__),
+#include "NVLinkOpts.inc"
+  LastOption
+#undef OPTION
+};
+
+#define PREFIX(NAME, VALUE)
\
+  static constexpr StringLiteral NAME##_init[] = VALUE;
\
+  static constexpr ArrayRef NAME(NAME##_init,   
\
+std::size(NAME##_init) - 1);
+#include "NVLi

[clang] [Clang] Introduce 'clang-nvlink-wrapper' to work around 'nvlink' (PR #96561)

2024-07-15 Thread Artem Belevich via cfe-commits


@@ -0,0 +1,776 @@
+//===-- clang-nvlink-wrapper/ClangNVLinkWrapper.cpp - NVIDIA linker util 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===-===//
+//
+// This tool wraps around the NVIDIA linker called 'nvlink'. The NVIDIA linker
+// is required to create NVPTX applications, but does not support common
+// features like LTO or archives. This utility wraps around the tool to cover
+// its deficiencies. This tool can be removed once NVIDIA improves their linker
+// or ports it to `ld.lld`.
+//
+//===-===//
+
+#include "clang/Basic/Version.h"
+
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/BinaryFormat/Magic.h"
+#include "llvm/Bitcode/BitcodeWriter.h"
+#include "llvm/CodeGen/CommandFlags.h"
+#include "llvm/IR/DiagnosticPrinter.h"
+#include "llvm/LTO/LTO.h"
+#include "llvm/Object/Archive.h"
+#include "llvm/Object/ArchiveWriter.h"
+#include "llvm/Object/Binary.h"
+#include "llvm/Object/ELFObjectFile.h"
+#include "llvm/Object/IRObjectFile.h"
+#include "llvm/Object/ObjectFile.h"
+#include "llvm/Object/OffloadBinary.h"
+#include "llvm/Option/ArgList.h"
+#include "llvm/Option/OptTable.h"
+#include "llvm/Option/Option.h"
+#include "llvm/Remarks/HotnessThresholdParser.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FileOutputBuffer.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/InitLLVM.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/Program.h"
+#include "llvm/Support/Signals.h"
+#include "llvm/Support/StringSaver.h"
+#include "llvm/Support/TargetSelect.h"
+#include "llvm/Support/WithColor.h"
+
+using namespace llvm;
+using namespace llvm::opt;
+using namespace llvm::object;
+
+// Various tools (e.g., llc and opt) duplicate this series of declarations for
+// options related to passes and remarks.
+static cl::opt RemarksWithHotness(
+"pass-remarks-with-hotness",
+cl::desc("With PGO, include profile count in optimization remarks"),
+cl::Hidden);
+
+static cl::opt, false, remarks::HotnessThresholdParser>
+RemarksHotnessThreshold(
+"pass-remarks-hotness-threshold",
+cl::desc("Minimum profile count required for "
+ "an optimization remark to be output. "
+ "Use 'auto' to apply the threshold from profile summary."),
+cl::value_desc("N or 'auto'"), cl::init(0), cl::Hidden);
+
+static cl::opt
+RemarksFilename("pass-remarks-output",
+cl::desc("Output filename for pass remarks"),
+cl::value_desc("filename"));
+
+static cl::opt
+RemarksPasses("pass-remarks-filter",
+  cl::desc("Only record optimization remarks from passes whose 
"
+   "names match the given regular expression"),
+  cl::value_desc("regex"));
+
+static cl::opt RemarksFormat(
+"pass-remarks-format",
+cl::desc("The format used for serializing remarks (default: YAML)"),
+cl::value_desc("format"), cl::init("yaml"));
+
+static cl::list
+PassPlugins("load-pass-plugin",
+cl::desc("Load passes from plugin library"));
+
+static cl::opt PassPipeline(
+"passes",
+cl::desc(
+"A textual description of the pass pipeline. To have analysis passes "
+"available before a certain pass, add 'require'. "
+"'-passes' overrides the pass pipeline (but not all effects) from "
+"specifying '--opt-level=O?' (O2 is the default) to "
+"clang-linker-wrapper.  Be sure to include the corresponding "
+"'default' in '-passes'."));
+static cl::alias PassPipeline2("p", cl::aliasopt(PassPipeline),
+   cl::desc("Alias for -passes"));
+
+static void printVersion(raw_ostream &OS) {
+  OS << clang::getClangToolFullVersion("clang-nvlink-wrapper") << '\n';
+}
+
+/// The value of `argv[0]` when run.
+static const char *Executable;
+
+/// Temporary files to be cleaned up.
+static SmallVector> TempFiles;
+
+/// Codegen flags for LTO backend.
+static codegen::RegisterCodeGenFlags CodeGenFlags;
+
+namespace {
+// Must not overlap with llvm::opt::DriverFlag.
+enum WrapperFlags { WrapperOnlyOption = (1 << 4) };
+
+enum ID {
+  OPT_INVALID = 0, // This is not an option ID.
+#define OPTION(...) LLVM_MAKE_OPT_ID(__VA_ARGS__),
+#include "NVLinkOpts.inc"
+  LastOption
+#undef OPTION
+};
+
+#define PREFIX(NAME, VALUE)
\
+  static constexpr StringLiteral NAME##_init[] = VALUE;
\
+  static constexpr ArrayRef NAME(NAME##_init,   
\
+std::size(NAME##_init) - 1);
+#include "NVLi

[clang] [Clang] Introduce 'clang-nvlink-wrapper' to work around 'nvlink' (PR #96561)

2024-07-15 Thread Artem Belevich via cfe-commits

https://github.com/Artem-B commented:

First batch of comments on the patch -- I only got till about the middle of 
ClangNVLinkWrapper.cpp. Will continue reviewing tomorrow.

https://github.com/llvm/llvm-project/pull/96561
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Introduce 'clang-nvlink-wrapper' to work around 'nvlink' (PR #96561)

2024-07-15 Thread Artem Belevich via cfe-commits


@@ -0,0 +1,776 @@
+//===-- clang-nvlink-wrapper/ClangNVLinkWrapper.cpp - NVIDIA linker util 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===-===//
+//
+// This tool wraps around the NVIDIA linker called 'nvlink'. The NVIDIA linker
+// is required to create NVPTX applications, but does not support common
+// features like LTO or archives. This utility wraps around the tool to cover
+// its deficiencies. This tool can be removed once NVIDIA improves their linker
+// or ports it to `ld.lld`.
+//
+//===-===//
+
+#include "clang/Basic/Version.h"
+
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/BinaryFormat/Magic.h"
+#include "llvm/Bitcode/BitcodeWriter.h"
+#include "llvm/CodeGen/CommandFlags.h"
+#include "llvm/IR/DiagnosticPrinter.h"
+#include "llvm/LTO/LTO.h"
+#include "llvm/Object/Archive.h"
+#include "llvm/Object/ArchiveWriter.h"
+#include "llvm/Object/Binary.h"
+#include "llvm/Object/ELFObjectFile.h"
+#include "llvm/Object/IRObjectFile.h"
+#include "llvm/Object/ObjectFile.h"
+#include "llvm/Object/OffloadBinary.h"
+#include "llvm/Option/ArgList.h"
+#include "llvm/Option/OptTable.h"
+#include "llvm/Option/Option.h"
+#include "llvm/Remarks/HotnessThresholdParser.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FileOutputBuffer.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/InitLLVM.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/Program.h"
+#include "llvm/Support/Signals.h"
+#include "llvm/Support/StringSaver.h"
+#include "llvm/Support/TargetSelect.h"
+#include "llvm/Support/WithColor.h"
+
+using namespace llvm;
+using namespace llvm::opt;
+using namespace llvm::object;
+
+// Various tools (e.g., llc and opt) duplicate this series of declarations for
+// options related to passes and remarks.
+static cl::opt RemarksWithHotness(
+"pass-remarks-with-hotness",
+cl::desc("With PGO, include profile count in optimization remarks"),
+cl::Hidden);
+
+static cl::opt, false, remarks::HotnessThresholdParser>
+RemarksHotnessThreshold(
+"pass-remarks-hotness-threshold",
+cl::desc("Minimum profile count required for "
+ "an optimization remark to be output. "
+ "Use 'auto' to apply the threshold from profile summary."),
+cl::value_desc("N or 'auto'"), cl::init(0), cl::Hidden);
+
+static cl::opt
+RemarksFilename("pass-remarks-output",
+cl::desc("Output filename for pass remarks"),
+cl::value_desc("filename"));
+
+static cl::opt
+RemarksPasses("pass-remarks-filter",
+  cl::desc("Only record optimization remarks from passes whose 
"
+   "names match the given regular expression"),
+  cl::value_desc("regex"));
+
+static cl::opt RemarksFormat(
+"pass-remarks-format",
+cl::desc("The format used for serializing remarks (default: YAML)"),
+cl::value_desc("format"), cl::init("yaml"));
+
+static cl::list
+PassPlugins("load-pass-plugin",
+cl::desc("Load passes from plugin library"));
+
+static cl::opt PassPipeline(
+"passes",
+cl::desc(
+"A textual description of the pass pipeline. To have analysis passes "
+"available before a certain pass, add 'require'. "
+"'-passes' overrides the pass pipeline (but not all effects) from "
+"specifying '--opt-level=O?' (O2 is the default) to "
+"clang-linker-wrapper.  Be sure to include the corresponding "
+"'default' in '-passes'."));
+static cl::alias PassPipeline2("p", cl::aliasopt(PassPipeline),
+   cl::desc("Alias for -passes"));
+
+static void printVersion(raw_ostream &OS) {
+  OS << clang::getClangToolFullVersion("clang-nvlink-wrapper") << '\n';
+}
+
+/// The value of `argv[0]` when run.
+static const char *Executable;
+
+/// Temporary files to be cleaned up.
+static SmallVector> TempFiles;
+
+/// Codegen flags for LTO backend.
+static codegen::RegisterCodeGenFlags CodeGenFlags;
+
+namespace {
+// Must not overlap with llvm::opt::DriverFlag.
+enum WrapperFlags { WrapperOnlyOption = (1 << 4) };
+
+enum ID {
+  OPT_INVALID = 0, // This is not an option ID.
+#define OPTION(...) LLVM_MAKE_OPT_ID(__VA_ARGS__),
+#include "NVLinkOpts.inc"
+  LastOption
+#undef OPTION
+};
+
+#define PREFIX(NAME, VALUE)
\
+  static constexpr StringLiteral NAME##_init[] = VALUE;
\
+  static constexpr ArrayRef NAME(NAME##_init,   
\
+std::size(NAME##_init) - 1);
+#include "NVLi

[clang] [Clang] Introduce 'clang-nvlink-wrapper' to work around 'nvlink' (PR #96561)

2024-07-15 Thread Artem Belevich via cfe-commits


@@ -0,0 +1,64 @@
+
+Clang nvlink Wrapper
+
+
+.. contents::
+   :local:
+
+.. _clang-nvlink-wrapper:
+
+Introduction
+
+
+This tools works as a wrapper around the NVIDIA ``nvlink`` linker. The purpose 
+of this wrapper is to provide an interface similar to the ``ld.lld`` linker 
+while still relying on NVIDIA's proprietary linker to produce the final 
output. 
+Features include, static archive (.a) linking, LTO, and accepting files ending 
+in ``.o`` without error.

Artem-B wrote:

This is written from a standpoint of someone already familiar with nvlink 
quirks. For the rest of the world "support fo static linking with .a and object 
files ending in .o" will be somewhat baffling. "Isn't how things already work?"

I'd rephrase it a bit along the lines of. "nvlink has a number of known quirks 
that make its use in a unified HIP/CUDA/OpenMP compilation pipeline 
problematic" followed by the list of those quirks. The wrapper isolates those 
differences and presents an interface close enough to ld.lld to simplify the 
integration.

Does it make sense?

https://github.com/llvm/llvm-project/pull/96561
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Introduce 'clang-nvlink-wrapper' to work around 'nvlink' (PR #96561)

2024-07-15 Thread Joseph Huber via cfe-commits


@@ -0,0 +1,64 @@
+
+Clang nvlink Wrapper
+
+
+.. contents::
+   :local:
+
+.. _clang-nvlink-wrapper:
+
+Introduction
+
+
+This tools works as a wrapper around the NVIDIA ``nvlink`` linker. The purpose 
+of this wrapper is to provide an interface similar to the ``ld.lld`` linker 
+while still relying on NVIDIA's proprietary linker to produce the final 
output. 
+Features include, static archive (.a) linking, LTO, and accepting files ending 
+in ``.o`` without error.

jhuber6 wrote:

Yep, that's fair. I'll try to rewrite it to be more clear.

https://github.com/llvm/llvm-project/pull/96561
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Introduce 'clang-nvlink-wrapper' to work around 'nvlink' (PR #96561)

2024-07-15 Thread Joseph Huber via cfe-commits


@@ -0,0 +1,64 @@
+
+Clang nvlink Wrapper
+
+
+.. contents::
+   :local:
+
+.. _clang-nvlink-wrapper:
+
+Introduction
+
+
+This tools works as a wrapper around the NVIDIA ``nvlink`` linker. The purpose 
+of this wrapper is to provide an interface similar to the ``ld.lld`` linker 
+while still relying on NVIDIA's proprietary linker to produce the final 
output. 
+Features include, static archive (.a) linking, LTO, and accepting files ending 
+in ``.o`` without error.
+
+Usage
+=
+
+This tool can be used with the following options. Any arguments not intended
+only for the linker wrapper will be forwarded to ``nvlink``.
+
+.. code-block:: console
+
+  OVERVIEW: A utility that wraps around the NVIDIA 'nvlink' linker.
+  This enables static linking and LTO handling for NVPTX targets.
+
+  USAGE: clang-nvlink-wrapper [options] 
+
+  OPTIONS:
+--archSpecify the 'sm_' name of the target architecture.
+--cuda-path=Set the system CUDA path
+--dry-runPrint generated commands without running.
+--feature Specify the '+ptx' freature to use for LTO.
+-g   Specify that this was a debug compile.
+-help-hidden Display all available options
+-helpDisplay available options (--help-hidden for more)
+-L  Add  to the library search path
+-l  Search for library 
+-mllvm  Arguments passed to LLVM, including Clang 
invocations, for which the '-mllvm' prefix is preserved. Use '-mllvm --help' 
for a list of options.
+-o Path to file to write output
+--plugin-opt=jobs=
+ Number of LTO codegen partitions
+--plugin-opt=lto-partitions=
+ Number of LTO codegen partitions
+--plugin-opt=O
+ Optimization level for LTO
+--plugin-opt=thinlto
+ Enable the thin-lto backend
+--plugin-opt= Options passed to LLVM, not including the Clang 
invocation. Use '--plugin-opt=--help' for a list of options.
+--save-temps Save intermediate results
+--versionDisplay the version number and exit
+-v   Print verbose information
+
+Example
+===
+
+This tool is intended to be invoked when targeting the NVPTX toolchain 
directly. 

jhuber6 wrote:

I mean this as a stand-in for `--target=nvptx64-nvidia-cuda`, which is what 
direct compilation uses, as does the `clang-linker-wrapper` to generate the 
link job. So, it's pretty much just a way to say "This is for times when the 
NVPTX toolchain needs a functional linker".

https://github.com/llvm/llvm-project/pull/96561
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Introduce 'clang-nvlink-wrapper' to work around 'nvlink' (PR #96561)

2024-07-15 Thread Joseph Huber via cfe-commits


@@ -0,0 +1,776 @@
+//===-- clang-nvlink-wrapper/ClangNVLinkWrapper.cpp - NVIDIA linker util 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===-===//
+//
+// This tool wraps around the NVIDIA linker called 'nvlink'. The NVIDIA linker
+// is required to create NVPTX applications, but does not support common
+// features like LTO or archives. This utility wraps around the tool to cover
+// its deficiencies. This tool can be removed once NVIDIA improves their linker
+// or ports it to `ld.lld`.
+//
+//===-===//
+
+#include "clang/Basic/Version.h"
+
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/BinaryFormat/Magic.h"
+#include "llvm/Bitcode/BitcodeWriter.h"
+#include "llvm/CodeGen/CommandFlags.h"
+#include "llvm/IR/DiagnosticPrinter.h"
+#include "llvm/LTO/LTO.h"
+#include "llvm/Object/Archive.h"
+#include "llvm/Object/ArchiveWriter.h"
+#include "llvm/Object/Binary.h"
+#include "llvm/Object/ELFObjectFile.h"
+#include "llvm/Object/IRObjectFile.h"
+#include "llvm/Object/ObjectFile.h"
+#include "llvm/Object/OffloadBinary.h"
+#include "llvm/Option/ArgList.h"
+#include "llvm/Option/OptTable.h"
+#include "llvm/Option/Option.h"
+#include "llvm/Remarks/HotnessThresholdParser.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FileOutputBuffer.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/InitLLVM.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/Program.h"
+#include "llvm/Support/Signals.h"
+#include "llvm/Support/StringSaver.h"
+#include "llvm/Support/TargetSelect.h"
+#include "llvm/Support/WithColor.h"
+
+using namespace llvm;
+using namespace llvm::opt;
+using namespace llvm::object;
+
+// Various tools (e.g., llc and opt) duplicate this series of declarations for
+// options related to passes and remarks.
+static cl::opt RemarksWithHotness(
+"pass-remarks-with-hotness",
+cl::desc("With PGO, include profile count in optimization remarks"),
+cl::Hidden);
+
+static cl::opt, false, remarks::HotnessThresholdParser>
+RemarksHotnessThreshold(
+"pass-remarks-hotness-threshold",
+cl::desc("Minimum profile count required for "
+ "an optimization remark to be output. "
+ "Use 'auto' to apply the threshold from profile summary."),
+cl::value_desc("N or 'auto'"), cl::init(0), cl::Hidden);
+
+static cl::opt
+RemarksFilename("pass-remarks-output",
+cl::desc("Output filename for pass remarks"),
+cl::value_desc("filename"));
+
+static cl::opt
+RemarksPasses("pass-remarks-filter",
+  cl::desc("Only record optimization remarks from passes whose 
"
+   "names match the given regular expression"),
+  cl::value_desc("regex"));
+
+static cl::opt RemarksFormat(
+"pass-remarks-format",
+cl::desc("The format used for serializing remarks (default: YAML)"),
+cl::value_desc("format"), cl::init("yaml"));
+
+static cl::list
+PassPlugins("load-pass-plugin",
+cl::desc("Load passes from plugin library"));
+
+static cl::opt PassPipeline(
+"passes",
+cl::desc(
+"A textual description of the pass pipeline. To have analysis passes "
+"available before a certain pass, add 'require'. "
+"'-passes' overrides the pass pipeline (but not all effects) from "
+"specifying '--opt-level=O?' (O2 is the default) to "
+"clang-linker-wrapper.  Be sure to include the corresponding "
+"'default' in '-passes'."));
+static cl::alias PassPipeline2("p", cl::aliasopt(PassPipeline),
+   cl::desc("Alias for -passes"));
+
+static void printVersion(raw_ostream &OS) {
+  OS << clang::getClangToolFullVersion("clang-nvlink-wrapper") << '\n';
+}
+
+/// The value of `argv[0]` when run.
+static const char *Executable;
+
+/// Temporary files to be cleaned up.
+static SmallVector> TempFiles;
+
+/// Codegen flags for LTO backend.
+static codegen::RegisterCodeGenFlags CodeGenFlags;
+
+namespace {
+// Must not overlap with llvm::opt::DriverFlag.
+enum WrapperFlags { WrapperOnlyOption = (1 << 4) };
+
+enum ID {
+  OPT_INVALID = 0, // This is not an option ID.
+#define OPTION(...) LLVM_MAKE_OPT_ID(__VA_ARGS__),
+#include "NVLinkOpts.inc"
+  LastOption
+#undef OPTION
+};
+
+#define PREFIX(NAME, VALUE)
\
+  static constexpr StringLiteral NAME##_init[] = VALUE;
\
+  static constexpr ArrayRef NAME(NAME##_init,   
\
+std::size(NAME##_init) - 1);
+#include "NVLi

[clang] [Clang] Introduce 'clang-nvlink-wrapper' to work around 'nvlink' (PR #96561)

2024-07-15 Thread Joseph Huber via cfe-commits


@@ -0,0 +1,776 @@
+//===-- clang-nvlink-wrapper/ClangNVLinkWrapper.cpp - NVIDIA linker util 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===-===//
+//
+// This tool wraps around the NVIDIA linker called 'nvlink'. The NVIDIA linker
+// is required to create NVPTX applications, but does not support common
+// features like LTO or archives. This utility wraps around the tool to cover
+// its deficiencies. This tool can be removed once NVIDIA improves their linker
+// or ports it to `ld.lld`.
+//
+//===-===//
+
+#include "clang/Basic/Version.h"
+
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/BinaryFormat/Magic.h"
+#include "llvm/Bitcode/BitcodeWriter.h"
+#include "llvm/CodeGen/CommandFlags.h"
+#include "llvm/IR/DiagnosticPrinter.h"
+#include "llvm/LTO/LTO.h"
+#include "llvm/Object/Archive.h"
+#include "llvm/Object/ArchiveWriter.h"
+#include "llvm/Object/Binary.h"
+#include "llvm/Object/ELFObjectFile.h"
+#include "llvm/Object/IRObjectFile.h"
+#include "llvm/Object/ObjectFile.h"
+#include "llvm/Object/OffloadBinary.h"
+#include "llvm/Option/ArgList.h"
+#include "llvm/Option/OptTable.h"
+#include "llvm/Option/Option.h"
+#include "llvm/Remarks/HotnessThresholdParser.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FileOutputBuffer.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/InitLLVM.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/Program.h"
+#include "llvm/Support/Signals.h"
+#include "llvm/Support/StringSaver.h"
+#include "llvm/Support/TargetSelect.h"
+#include "llvm/Support/WithColor.h"
+
+using namespace llvm;
+using namespace llvm::opt;
+using namespace llvm::object;
+
+// Various tools (e.g., llc and opt) duplicate this series of declarations for
+// options related to passes and remarks.
+static cl::opt RemarksWithHotness(
+"pass-remarks-with-hotness",
+cl::desc("With PGO, include profile count in optimization remarks"),
+cl::Hidden);
+
+static cl::opt, false, remarks::HotnessThresholdParser>
+RemarksHotnessThreshold(
+"pass-remarks-hotness-threshold",
+cl::desc("Minimum profile count required for "
+ "an optimization remark to be output. "
+ "Use 'auto' to apply the threshold from profile summary."),
+cl::value_desc("N or 'auto'"), cl::init(0), cl::Hidden);
+
+static cl::opt
+RemarksFilename("pass-remarks-output",
+cl::desc("Output filename for pass remarks"),
+cl::value_desc("filename"));
+
+static cl::opt
+RemarksPasses("pass-remarks-filter",
+  cl::desc("Only record optimization remarks from passes whose 
"
+   "names match the given regular expression"),
+  cl::value_desc("regex"));
+
+static cl::opt RemarksFormat(
+"pass-remarks-format",
+cl::desc("The format used for serializing remarks (default: YAML)"),
+cl::value_desc("format"), cl::init("yaml"));
+
+static cl::list
+PassPlugins("load-pass-plugin",
+cl::desc("Load passes from plugin library"));
+
+static cl::opt PassPipeline(
+"passes",
+cl::desc(
+"A textual description of the pass pipeline. To have analysis passes "
+"available before a certain pass, add 'require'. "
+"'-passes' overrides the pass pipeline (but not all effects) from "
+"specifying '--opt-level=O?' (O2 is the default) to "
+"clang-linker-wrapper.  Be sure to include the corresponding "
+"'default' in '-passes'."));
+static cl::alias PassPipeline2("p", cl::aliasopt(PassPipeline),
+   cl::desc("Alias for -passes"));
+
+static void printVersion(raw_ostream &OS) {
+  OS << clang::getClangToolFullVersion("clang-nvlink-wrapper") << '\n';
+}
+
+/// The value of `argv[0]` when run.
+static const char *Executable;
+
+/// Temporary files to be cleaned up.
+static SmallVector> TempFiles;
+
+/// Codegen flags for LTO backend.
+static codegen::RegisterCodeGenFlags CodeGenFlags;
+
+namespace {
+// Must not overlap with llvm::opt::DriverFlag.
+enum WrapperFlags { WrapperOnlyOption = (1 << 4) };
+
+enum ID {
+  OPT_INVALID = 0, // This is not an option ID.
+#define OPTION(...) LLVM_MAKE_OPT_ID(__VA_ARGS__),
+#include "NVLinkOpts.inc"
+  LastOption
+#undef OPTION
+};
+
+#define PREFIX(NAME, VALUE)
\
+  static constexpr StringLiteral NAME##_init[] = VALUE;
\
+  static constexpr ArrayRef NAME(NAME##_init,   
\
+std::size(NAME##_init) - 1);
+#include "NVLi

[clang] [Clang] Introduce 'clang-nvlink-wrapper' to work around 'nvlink' (PR #96561)

2024-07-15 Thread Joseph Huber via cfe-commits


@@ -0,0 +1,776 @@
+//===-- clang-nvlink-wrapper/ClangNVLinkWrapper.cpp - NVIDIA linker util 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===-===//
+//
+// This tool wraps around the NVIDIA linker called 'nvlink'. The NVIDIA linker
+// is required to create NVPTX applications, but does not support common
+// features like LTO or archives. This utility wraps around the tool to cover
+// its deficiencies. This tool can be removed once NVIDIA improves their linker
+// or ports it to `ld.lld`.
+//
+//===-===//
+
+#include "clang/Basic/Version.h"
+
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/BinaryFormat/Magic.h"
+#include "llvm/Bitcode/BitcodeWriter.h"
+#include "llvm/CodeGen/CommandFlags.h"
+#include "llvm/IR/DiagnosticPrinter.h"
+#include "llvm/LTO/LTO.h"
+#include "llvm/Object/Archive.h"
+#include "llvm/Object/ArchiveWriter.h"
+#include "llvm/Object/Binary.h"
+#include "llvm/Object/ELFObjectFile.h"
+#include "llvm/Object/IRObjectFile.h"
+#include "llvm/Object/ObjectFile.h"
+#include "llvm/Object/OffloadBinary.h"
+#include "llvm/Option/ArgList.h"
+#include "llvm/Option/OptTable.h"
+#include "llvm/Option/Option.h"
+#include "llvm/Remarks/HotnessThresholdParser.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FileOutputBuffer.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/InitLLVM.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/Program.h"
+#include "llvm/Support/Signals.h"
+#include "llvm/Support/StringSaver.h"
+#include "llvm/Support/TargetSelect.h"
+#include "llvm/Support/WithColor.h"
+
+using namespace llvm;
+using namespace llvm::opt;
+using namespace llvm::object;
+
+// Various tools (e.g., llc and opt) duplicate this series of declarations for
+// options related to passes and remarks.
+static cl::opt RemarksWithHotness(
+"pass-remarks-with-hotness",
+cl::desc("With PGO, include profile count in optimization remarks"),
+cl::Hidden);
+
+static cl::opt, false, remarks::HotnessThresholdParser>
+RemarksHotnessThreshold(
+"pass-remarks-hotness-threshold",
+cl::desc("Minimum profile count required for "
+ "an optimization remark to be output. "
+ "Use 'auto' to apply the threshold from profile summary."),
+cl::value_desc("N or 'auto'"), cl::init(0), cl::Hidden);
+
+static cl::opt
+RemarksFilename("pass-remarks-output",
+cl::desc("Output filename for pass remarks"),
+cl::value_desc("filename"));
+
+static cl::opt
+RemarksPasses("pass-remarks-filter",
+  cl::desc("Only record optimization remarks from passes whose 
"
+   "names match the given regular expression"),
+  cl::value_desc("regex"));
+
+static cl::opt RemarksFormat(
+"pass-remarks-format",
+cl::desc("The format used for serializing remarks (default: YAML)"),
+cl::value_desc("format"), cl::init("yaml"));
+
+static cl::list
+PassPlugins("load-pass-plugin",
+cl::desc("Load passes from plugin library"));
+
+static cl::opt PassPipeline(
+"passes",
+cl::desc(
+"A textual description of the pass pipeline. To have analysis passes "
+"available before a certain pass, add 'require'. "
+"'-passes' overrides the pass pipeline (but not all effects) from "
+"specifying '--opt-level=O?' (O2 is the default) to "
+"clang-linker-wrapper.  Be sure to include the corresponding "
+"'default' in '-passes'."));
+static cl::alias PassPipeline2("p", cl::aliasopt(PassPipeline),
+   cl::desc("Alias for -passes"));
+
+static void printVersion(raw_ostream &OS) {
+  OS << clang::getClangToolFullVersion("clang-nvlink-wrapper") << '\n';
+}
+
+/// The value of `argv[0]` when run.
+static const char *Executable;
+
+/// Temporary files to be cleaned up.
+static SmallVector> TempFiles;
+
+/// Codegen flags for LTO backend.
+static codegen::RegisterCodeGenFlags CodeGenFlags;
+
+namespace {
+// Must not overlap with llvm::opt::DriverFlag.
+enum WrapperFlags { WrapperOnlyOption = (1 << 4) };
+
+enum ID {
+  OPT_INVALID = 0, // This is not an option ID.
+#define OPTION(...) LLVM_MAKE_OPT_ID(__VA_ARGS__),
+#include "NVLinkOpts.inc"
+  LastOption
+#undef OPTION
+};
+
+#define PREFIX(NAME, VALUE)
\
+  static constexpr StringLiteral NAME##_init[] = VALUE;
\
+  static constexpr ArrayRef NAME(NAME##_init,   
\
+std::size(NAME##_init) - 1);
+#include "NVLi

[clang] [Clang] Introduce 'clang-nvlink-wrapper' to work around 'nvlink' (PR #96561)

2024-07-15 Thread Joseph Huber via cfe-commits

jhuber6 wrote:

> First batch of comments on the patch -- I only got till about the middle of 
> ClangNVLinkWrapper.cpp. Will continue reviewing tomorrow.

Appreciate it. Sorry about dropping a huge patch like this on you.

https://github.com/llvm/llvm-project/pull/96561
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Implement resource binding type prefix mismatch diagnostic infrastructure (PR #97103)

2024-07-15 Thread Joshua Batista via cfe-commits


@@ -1,9 +1,10 @@
 // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -o - 
-fsyntax-only %s -verify
 
-// expected-error@+1 {{invalid resource class specifier 'c' used; expected 
'b', 's', 't', or 'u'}}
-float a : register(c0, space1);
+// valid, The register keyword in this statement isn't binding a resource, 
rather it is
+// specifying a constant register binding offset within the $Globals cbuffer, 
which is legacy behavior from DX9.
+float a : register(c0);

bob80905 wrote:

No worries, added the test case along with the error it produced. Treating 
groupshared variables as `other`.
Also added some test cases for basic types inside arrays.

https://github.com/llvm/llvm-project/pull/97103
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Finish deleting the le32/le64 targets (PR #98497)

2024-07-15 Thread Eli Friedman via cfe-commits

efriedma-quic wrote:

It looks like the removal missed a few bits: PNaClABIBuiltinVaList and 
clang/lib/CodeGen/Targets/PNaCl.cpp weren't removed.

> Unfortunately, this utterly breaks Halide, which was in fact relying on both 
> of these targets.

We can temporarily revert this, but we aren't going to leave the orphaned 
remains of PNaCl in-tree forever.  If you need a "halide" target long-term, 
please write up a proposal on Discourse describing exactly what bits you need, 
why you need them, relevant test coverage in-tree and out-of-tree, and a 
proposed code owner for those bits.

https://github.com/llvm/llvm-project/pull/98497
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Finish deleting the le32/le64 targets (PR #98497)

2024-07-15 Thread Fangrui Song via cfe-commits

MaskRay wrote:

It seems that Halide (https://github.com/halide/Halide/pull/5934), an important 
user, still needs generic 32-bit 64-bit Clang targets.
The removed le32/le64 targets fulfilled this need.
(This change broke my internal users. Sorry that I did not realize that 
Halide#5934 was closed without an actual fix @abadams).

@AaronBallman Are you comfortable with bring back le32/le64 temporarily?
The few occurrences in `bitfield-*` don't serve useful testing purposes, and 
they can be removed if they feel like eyesore.


https://github.com/llvm/llvm-project/pull/98497
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Finish deleting the le32/le64 targets (PR #98497)

2024-07-15 Thread Andrew Adams via cfe-commits

abadams wrote:

Our actual need is for a stable and user-friendly way to write fragments of 
mostly-target-agnostic llvm IR.

We concat these with other fragments and give it an actual target triple later. 
This lets us assemble a target-specific Halide runtime dynamically by mixing 
and matching some number of these fragments. Compiling these fragments for all 
possible target triples we support instead of a generic one would multiply our 
code size and compile time by the (large) number of possible target triples we 
can emit. Not using fragments at all and compiling a runtime in a more 
conventional way would be a combinatorial amount of code, because there are a 
lot of combinations. Writing generic .ll directly is possible, and we do a 
little of that for very low-level things, but writing in C++ and compiling via 
clang to le64/32 is more stable and much more pleasant due to the abstractions 
that C++ provides. We just have to be careful to not do things like have 
structs that would have different layouts on different platforms. 

If there's a better way to do all this, let us know. Does no other project have 
a need for "generic" llvm IR without any target-specific annotations on it yet?

https://github.com/llvm/llvm-project/pull/98497
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Add deprecation warning for `-Ofast` driver option (PR #98736)

2024-07-15 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll updated 
https://github.com/llvm/llvm-project/pull/98736

>From 44b4a682f2b3d7e140f7b1bd124e7aabdbf439ad Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Sat, 13 Jul 2024 13:10:25 +0300
Subject: [PATCH 1/2] [clang] Add deprecation warning for `-Ofast` driver
 option

---
 clang/docs/ReleaseNotes.rst| 3 +++
 clang/include/clang/Basic/DiagnosticDriverKinds.td | 3 +++
 clang/include/clang/Basic/DiagnosticGroups.td  | 2 ++
 clang/include/clang/Driver/Options.td  | 3 ++-
 clang/lib/Driver/ToolChains/Clang.cpp  | 2 ++
 clang/test/Driver/Ofast.c  | 4 
 6 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index ceead8c362e9c..2f5f40f355901 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -470,6 +470,9 @@ New Compiler Flags
 Deprecated Compiler Flags
 -
 
+- ``-Ofast`` is deprecated in favor of ``-O3``, possibly combined with 
``-ffast-math``.
+  See `RFC `_ for 
details.
+
 Modified Compiler Flags
 ---
 - Added a new diagnostic flag ``-Wreturn-mismatch`` which is grouped under
diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 359c0de7f811c..3857f2f3a33ce 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -442,6 +442,9 @@ def warn_drv_deprecated_arg : Warning<
 def warn_drv_deprecated_arg_no_relaxed_template_template_args : Warning<
   "argument '-fno-relaxed-template-template-args' is deprecated">,
   InGroup;
+def warn_drv_deprecated_arg_ofast : Warning<
+  "argument '-Ofast' is deprecated; use '-O3', possibly with '-ffast-math'">,
+  InGroup;
 def warn_drv_deprecated_custom : Warning<
   "argument '%0' is deprecated, %1">, InGroup;
 def warn_drv_assuming_mfloat_abi_is : Warning<
diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 2241f8481484e..d7dba76a0fcf8 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -103,6 +103,7 @@ def EnumConversion : DiagGroup<"enum-conversion",
 EnumFloatConversion,
 EnumCompareConditional]>;
 def DeprecatedNoRelaxedTemplateTemplateArgs : 
DiagGroup<"deprecated-no-relaxed-template-template-args">;
+def DeprecatedOFast : DiagGroup<"deprecated-ofast">;
 def ObjCSignedCharBoolImplicitIntConversion :
   DiagGroup<"objc-signed-char-bool-implicit-int-conversion">;
 def Shorten64To32 : DiagGroup<"shorten-64-to-32">;
@@ -228,6 +229,7 @@ def Deprecated : DiagGroup<"deprecated", 
[DeprecatedAnonEnumEnumConversion,
   DeprecatedPragma,
   DeprecatedRegister,
   
DeprecatedNoRelaxedTemplateTemplateArgs,
+  DeprecatedOFast,
   DeprecatedThisCapture,
   DeprecatedType,
   DeprecatedVolatile,
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index f1e8cb87e5321..269790476c1c3 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -931,7 +931,8 @@ def O : Joined<["-"], "O">, Group,
 def O_flag : Flag<["-"], "O">, Visibility<[ClangOption, CC1Option, FC1Option]>,
   Alias, AliasArgs<["1"]>;
 def Ofast : Joined<["-"], "Ofast">, Group,
-  Visibility<[ClangOption, CC1Option, FlangOption]>;
+  Visibility<[ClangOption, CC1Option, FlangOption]>,
+  HelpText<"Deprecated; use -O3, possibly with -ffast-math">;
 def P : Flag<["-"], "P">,
   Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>,
   Group,
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index bc21d03a627b9..33e7152343171 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -5712,6 +5712,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
  options::OPT_fno_zero_initialized_in_bss);
 
   bool OFastEnabled = isOptimizationLevelFast(Args);
+  if (OFastEnabled)
+D.Diag(diag::warn_drv_deprecated_arg_ofast);
   // If -Ofast is the optimization level, then -fstrict-aliasing should be
   // enabled.  This alias option is being used to simplify the hasFlag logic.
   OptSpecifier StrictAliasingAliasOption =
diff --git a/clang/test/Driver/Ofast.c b/clang/test/Driver/Ofast.c
index 8b7f2217eca2f..f5a2aabe257f1 100644
--- a/clang/test/Driver/Ofast.c
+++ b/clang/test/Driver/Ofast.c
@@ -10,6 +10,7 @@
 // RUN: %clang -Ofast -fno-stric

[clang] [llvm] Finish deleting the le32/le64 targets (PR #98497)

2024-07-15 Thread Eli Friedman via cfe-commits

efriedma-quic wrote:

There is no such thing as "generic" LLVM IR, in general: so many 
target-specific aspects of C have to be directly encoded into the IR, so 
there's no way to actually make it generic.  In this respect, the "le32/le64" 
targets aren't really any more generic than any other target; they encode their 
own specific assumptions, and they're not ABI-compatible with code generated 
for any other target.  The closest you can get to being "generic" is picking a 
target that's intended to be compiled to other targets, like SPIRV/wasm/etc.

So the question is, why specifically use the PNaCl targets, instead of just 
using the existing Arm or wasm targets?

https://github.com/llvm/llvm-project/pull/98497
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Add deprecation warning for `-Ofast` driver option (PR #98736)

2024-07-15 Thread Vlad Serebrennikov via cfe-commits


@@ -442,6 +442,9 @@ def warn_drv_deprecated_arg : Warning<
 def warn_drv_deprecated_arg_no_relaxed_template_template_args : Warning<
   "argument '-fno-relaxed-template-template-args' is deprecated">,
   InGroup;
+def warn_drv_deprecated_arg_ofast : Warning<
+  "argument '-Ofast' is deprecated; use '-O3', possibly with '-ffast-math'">,

Endilll wrote:

I think @mizvekov raised a good point, so I tried to take it into account.
@jyknight @AaronBallman What do you think of the new wording (`use '-O3 -ffast 
math' instead, or just '-O3' if you don't intend to enable non-conforming 
optimizations`)?

https://github.com/llvm/llvm-project/pull/98736
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][ExtractAPI][NFC] Remove some nullptr dereference problems (PR #98914)

2024-07-15 Thread via cfe-commits

https://github.com/QuietMisdreavus approved this pull request.


https://github.com/llvm/llvm-project/pull/98914
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Add deprecation warning for `-Ofast` driver option (PR #98736)

2024-07-15 Thread Vlad Serebrennikov via cfe-commits


@@ -470,6 +470,9 @@ New Compiler Flags
 Deprecated Compiler Flags
 -
 
+- ``-Ofast`` is deprecated in favor of ``-O3``, possibly combined with 
``-ffast-math``.

Endilll wrote:

Fixed. Thank you!

https://github.com/llvm/llvm-project/pull/98736
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Add deprecation warning for `-Ofast` driver option (PR #98736)

2024-07-15 Thread Vlad Serebrennikov via cfe-commits


@@ -10,6 +10,7 @@
 // RUN: %clang -Ofast -fno-strict-aliasing -### %s 2>&1 | FileCheck 
-check-prefix=CHECK-OFAST-NO-STRICT-ALIASING %s
 // RUN: %clang -Ofast -fno-vectorize -### %s 2>&1 | FileCheck 
-check-prefix=CHECK-OFAST-NO-VECTORIZE %s
 
+// CHECK-OFAST: warning: argument '-Ofast' is deprecated; use '-O3', possibly 
with '-ffast-math'

Endilll wrote:

Added `CHECK-NOT` test.

https://github.com/llvm/llvm-project/pull/98736
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Add deprecation warning for `-Ofast` driver option (PR #98736)

2024-07-15 Thread Vlad Serebrennikov via cfe-commits


@@ -931,7 +931,8 @@ def O : Joined<["-"], "O">, Group,
 def O_flag : Flag<["-"], "O">, Visibility<[ClangOption, CC1Option, FC1Option]>,
   Alias, AliasArgs<["1"]>;
 def Ofast : Joined<["-"], "Ofast">, Group,
-  Visibility<[ClangOption, CC1Option, FlangOption]>;
+  Visibility<[ClangOption, CC1Option, FlangOption]>,
+  HelpText<"Deprecated; use -O3, possibly with -ffast-math">;

Endilll wrote:

I changed the wording, so this is no longer applicable.

https://github.com/llvm/llvm-project/pull/98736
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Add deprecation warning for `-Ofast` driver option (PR #98736)

2024-07-15 Thread Vlad Serebrennikov via cfe-commits


@@ -931,7 +931,8 @@ def O : Joined<["-"], "O">, Group,
 def O_flag : Flag<["-"], "O">, Visibility<[ClangOption, CC1Option, FC1Option]>,
   Alias, AliasArgs<["1"]>;
 def Ofast : Joined<["-"], "Ofast">, Group,
-  Visibility<[ClangOption, CC1Option, FlangOption]>;
+  Visibility<[ClangOption, CC1Option, FlangOption]>,
+  HelpText<"Deprecated; use -O3, possibly with -ffast-math">;

Endilll wrote:

(But I made sure to put arguments in quotes)

https://github.com/llvm/llvm-project/pull/98736
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Emit constraint intrinsics for arc and hyperbolic trig clang builtins (PR #98949)

2024-07-15 Thread Eli Friedman via cfe-commits

https://github.com/efriedma-quic approved this pull request.

LGTM

https://github.com/llvm/llvm-project/pull/98949
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-doc] add nested namespace test case (PR #97681)

2024-07-15 Thread via cfe-commits

https://github.com/PeterChou1 updated 
https://github.com/llvm/llvm-project/pull/97681

>From f9d5cc074e4b65a92703bd09e62696a29fed1237 Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Thu, 4 Jul 2024 01:31:13 -0400
Subject: [PATCH 1/6] [clang-doc] add nested naemspace

---
 .../test/clang-doc/namespace.cpp  | 340 ++
 1 file changed, 340 insertions(+)
 create mode 100644 clang-tools-extra/test/clang-doc/namespace.cpp

diff --git a/clang-tools-extra/test/clang-doc/namespace.cpp 
b/clang-tools-extra/test/clang-doc/namespace.cpp
new file mode 100644
index 0..6fb91c9aa3c51
--- /dev/null
+++ b/clang-tools-extra/test/clang-doc/namespace.cpp
@@ -0,0 +1,340 @@
+// RUN: clang-doc --format=html --output=%t/docs --executor=standalone %s
+// RUN: clang-doc --format=md --output=%t/docs --executor=standalone %s
+// RUN: FileCheck %s -input-file=%t/docs/index_json.js -check-prefix=JSON-INDEX
+// RUN: FileCheck %s -input-file=%t/docs/@nonymous_namespace/AnonClass.html 
-check-prefix=HTML-ANON-CLASS
+// RUN: FileCheck %s -input-file=%t/docs/@nonymous_namespace/index.html 
-check-prefix=HTML-ANON-INDEX
+// RUN: FileCheck %s 
-input-file=%t/docs/AnotherNamespace/ClassInAnotherNamespace.html 
-check-prefix=HTML-ANOTHER-CLASS
+// RUN: FileCheck %s -input-file=%t/docs/AnotherNamespace/index.html 
-check-prefix=HTML-ANOTHER-INDEX
+// RUN: FileCheck %s -input-file=%t/docs/GlobalNamespace/index.html 
-check-prefix=HTML-GLOBAL-INDEX
+// RUN: FileCheck %s 
-input-file=%t/docs/PrimaryNamespace/NestedNamespace/ClassInNestedNamespace.html
 -check-prefix=HTML-NESTED-CLASS
+// RUN: FileCheck %s 
-input-file=%t/docs/PrimaryNamespace/NestedNamespace/index.html 
-check-prefix=HTML-NESTED-INDEX
+// RUN: FileCheck %s -input-file=%t/docs/PrimaryNamespace/index.html 
-check-prefix=HTML-PRIMARY-INDEX
+// RUN: FileCheck %s 
-input-file=%t/docs/PrimaryNamespace/ClassInPrimaryNamespace.html 
-check-prefix=HTML-PRIMARY-CLASS
+// RUN: FileCheck %s -input-file=%t/docs/@nonymous_namespace/AnonClass.md 
-check-prefix=MD-ANON-CLASS
+// RUN: FileCheck %s -input-file=%t/docs/@nonymous_namespace/index.md 
-check-prefix=MD-ANON-INDEX
+// RUN: FileCheck %s 
-input-file=%t/docs/AnotherNamespace/ClassInAnotherNamespace.md 
-check-prefix=MD-ANOTHER-CLASS
+// RUN: FileCheck %s -input-file=%t/docs/AnotherNamespace/index.md 
-check-prefix=MD-ANOTHER-INDEX
+// RUN: FileCheck %s -input-file=%t/docs/GlobalNamespace/index.md 
-check-prefix=MD-GLOBAL-INDEX
+// RUN: FileCheck %s 
-input-file=%t/docs/PrimaryNamespace/NestedNamespace/ClassInNestedNamespace.md 
-check-prefix=MD-NESTED-CLASS
+// RUN: FileCheck %s 
-input-file=%t/docs/PrimaryNamespace/NestedNamespace/index.md 
-check-prefix=MD-NESTED-INDEX
+// RUN: FileCheck %s -input-file=%t/docs/PrimaryNamespace/index.md 
-check-prefix=MD-PRIMARY-INDEX
+// RUN: FileCheck %s 
-input-file=%t/docs/PrimaryNamespace/ClassInPrimaryNamespace.md 
-check-prefix=MD-PRIMARY-CLASS
+// RUN: FileCheck %s -input-file=%t/docs/all_files.md 
-check-prefix=MD-ALL-FILES
+// RUN: FileCheck %s -input-file=%t/docs/index.md -check-prefix=MD-INDEX
+
+// Anonymous Namespace
+namespace
+{
+void anonFunction() {}
+class AnonClass {};
+}
+
+// Primary Namespace
+namespace PrimaryNamespace {
+// Function in PrimaryNamespace
+void functionInPrimaryNamespace() {}
+
+// Class in PrimaryNamespace
+class ClassInPrimaryNamespace {};
+
+// Nested namespace
+namespace NestedNamespace {
+// Function in NestedNamespace
+void functionInNestedNamespace() {}
+// Class in NestedNamespace
+class ClassInNestedNamespace {};
+}
+}
+
+// AnotherNamespace
+namespace AnotherNamespace {
+// Function in AnotherNamespace
+void functionInAnotherNamespace() {}
+// Class in AnotherNamespace
+class ClassInAnotherNamespace {};
+}
+
+// JSON-INDEX: async function LoadIndex() {
+// JSON-INDEX-NEXT: return{
+// JSON-INDEX-NEXT:   "USR": "{{([0-9A-F]{40})}}",
+// JSON-INDEX-NEXT:   "Name": "",
+// JSON-INDEX-NEXT:   "RefType": "default",
+// JSON-INDEX-NEXT:   "Path": "",
+// JSON-INDEX-NEXT:   "Children": [
+// JSON-INDEX-NEXT: {
+// JSON-INDEX-NEXT:   "USR": "{{([0-9A-F]{40})}}",
+// JSON-INDEX-NEXT:   "Name": "@nonymous_namespace",
+// JSON-INDEX-NEXT:   "RefType": "namespace",
+// JSON-INDEX-NEXT:   "Path": "@nonymous_namespace",
+// JSON-INDEX-NEXT:   "Children": [
+// JSON-INDEX-NEXT: {
+// JSON-INDEX-NEXT:   "USR": "{{([0-9A-F]{40})}}",
+// JSON-INDEX-NEXT:   "Name": "AnonClass",
+// JSON-INDEX-NEXT:   "RefType": "record",
+// JSON-INDEX-NEXT:   "Path": "@nonymous_namespace",
+// JSON-INDEX-NEXT:   "Children": []
+// JSON-INDEX-NEXT: }
+// JSON-INDEX-NEXT:   ]
+// JSON-INDEX-NEXT: },
+// JSON-INDEX-NEXT: {
+// JSON-INDEX-NEXT:   "USR": "{{([0-9A-F]{40})}}",
+// JSON-INDEX-NEXT:   "Name": "AnotherNamespace",
+// JSON-INDEX-NEXT:   "RefType": "namespace",
+

[clang] [clang] Add deprecation warning for `-Ofast` driver option (PR #98736)

2024-07-15 Thread Fangrui Song via cfe-commits


@@ -442,6 +442,9 @@ def warn_drv_deprecated_arg : Warning<
 def warn_drv_deprecated_arg_no_relaxed_template_template_args : Warning<
   "argument '-fno-relaxed-template-template-args' is deprecated">,
   InGroup;
+def warn_drv_deprecated_arg_ofast : Warning<
+  "argument '-Ofast' is deprecated; use '-O3', possibly with '-ffast-math'">,

MaskRay wrote:

> use '-O3 -ffast math' instead, or just '-O3' if you don't intend to enable 
> non-conforming optimizations

This message LGTM.

https://github.com/llvm/llvm-project/pull/98736
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-doc] add enum test (PR #97679)

2024-07-15 Thread via cfe-commits

https://github.com/PeterChou1 updated 
https://github.com/llvm/llvm-project/pull/97679

>From b5e0335199541225a1b0eb5eaf661cd4df55dbd7 Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Thu, 4 Jul 2024 01:14:11 -0400
Subject: [PATCH 1/5] [clang-doc] add enum test

---
 clang-tools-extra/test/clang-doc/enum.cpp | 38 +++
 1 file changed, 38 insertions(+)
 create mode 100644 clang-tools-extra/test/clang-doc/enum.cpp

diff --git a/clang-tools-extra/test/clang-doc/enum.cpp 
b/clang-tools-extra/test/clang-doc/enum.cpp
new file mode 100644
index 0..2f25eaf4e44e2
--- /dev/null
+++ b/clang-tools-extra/test/clang-doc/enum.cpp
@@ -0,0 +1,38 @@
+// RUN: clang-doc --format=html --doxygen --output=%t/docs 
--executor=standalone %s
+// RUN: clang-doc --format=md --doxygen --output=%t/docs --executor=standalone 
%s
+// RUN: FileCheck %s -input-file=%t/docs/GlobalNamespace/index.html 
-check-prefix=HTML-INDEX
+// RUN: FileCheck %s -input-file=%t/docs/GlobalNamespace/index.md 
-check-prefix=MD-INDEX
+
+/**
+ * @brief For specifying RGB colors
+ */
+enum Color {
+  Red, // Red enums
+  Green, // Green enums
+  Blue // Blue enums
+};
+
+// HTML-INDEX: Global Namespace
+// HTML-INDEX: Enums
+// HTML-INDEX: 
+// HTML-INDEX:   enum Color
+// HTML-INDEX:   
+// HTML-INDEX: Red
+// HTML-INDEX: Green
+// HTML-INDEX: Blue
+// HTML-INDEX:   
+// HTML-INDEX:   Defined at line 11 of file 
{{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp
+// HTML-INDEX:   
+// HTML-INDEX: 
+// HTML-INDEX:   
+// HTML-INDEX: 
+
+// MD-INDEX: # Global Namespace
+// MD-INDEX: ## Enums
+// MD-INDEX: | enum Color |
+// MD-INDEX: --
+// MD-INDEX: | Red |
+// MD-INDEX: | Green |
+// MD-INDEX: | Blue |
+// MD-INDEX: *Defined at 
{{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp#11*
+// MD-INDEX: **brief** For specifying RGB colors
\ No newline at end of file

>From c10f9d42c26e6d26833a35824216529ab25e7fe8 Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Thu, 4 Jul 2024 01:53:19 -0400
Subject: [PATCH 2/5] [clang-doc] update defined at line

---
 clang-tools-extra/test/clang-doc/enum.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang-tools-extra/test/clang-doc/enum.cpp 
b/clang-tools-extra/test/clang-doc/enum.cpp
index 2f25eaf4e44e2..1e7dd6e4c5b0c 100644
--- a/clang-tools-extra/test/clang-doc/enum.cpp
+++ b/clang-tools-extra/test/clang-doc/enum.cpp
@@ -21,7 +21,7 @@ enum Color {
 // HTML-INDEX: Green
 // HTML-INDEX: Blue
 // HTML-INDEX:   
-// HTML-INDEX:   Defined at line 11 of file 
{{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp
+// HTML-INDEX:   Defined at line 9 of file 
{{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp
 // HTML-INDEX:   
 // HTML-INDEX: 
 // HTML-INDEX:   

>From 8709091091b0ca889ca7911e06b7a4dae61a3581 Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Thu, 4 Jul 2024 02:06:08 -0400
Subject: [PATCH 3/5] [clang-doc] fix lines

---
 clang-tools-extra/test/clang-doc/enum.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang-tools-extra/test/clang-doc/enum.cpp 
b/clang-tools-extra/test/clang-doc/enum.cpp
index 1e7dd6e4c5b0c..5a1452788a55f 100644
--- a/clang-tools-extra/test/clang-doc/enum.cpp
+++ b/clang-tools-extra/test/clang-doc/enum.cpp
@@ -34,5 +34,5 @@ enum Color {
 // MD-INDEX: | Red |
 // MD-INDEX: | Green |
 // MD-INDEX: | Blue |
-// MD-INDEX: *Defined at 
{{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp#11*
+// MD-INDEX: *Defined at 
{{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp#9*
 // MD-INDEX: **brief** For specifying RGB colors
\ No newline at end of file

>From cd98a8cc662527e1488be17a2963874eb3267409 Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Fri, 12 Jul 2024 07:03:34 -0400
Subject: [PATCH 4/5] [clang-doc] address pr comments

---
 clang-tools-extra/test/clang-doc/enum.cpp | 34 ++-
 1 file changed, 14 insertions(+), 20 deletions(-)

diff --git a/clang-tools-extra/test/clang-doc/enum.cpp 
b/clang-tools-extra/test/clang-doc/enum.cpp
index 5a1452788a55f..fcc05477903ff 100644
--- a/clang-tools-extra/test/clang-doc/enum.cpp
+++ b/clang-tools-extra/test/clang-doc/enum.cpp
@@ -1,31 +1,25 @@
-// RUN: clang-doc --format=html --doxygen --output=%t/docs 
--executor=standalone %s
-// RUN: clang-doc --format=md --doxygen --output=%t/docs --executor=standalone 
%s
-// RUN: FileCheck %s -input-file=%t/docs/GlobalNamespace/index.html 
-check-prefix=HTML-INDEX
-// RUN: FileCheck %s -input-file=%t/docs/GlobalNamespace/index.md 
-check-prefix=MD-INDEX
+// RUN: rm -rf %t && mkdir -p %t
+// RUN: clang-doc --format=html --doxygen --output=%t --executor=standalone %s
+// RUN: clang-doc --format=md --doxygen --output=%t --executor=standalone %s
+// RUN: FileCheck %s < %t/GlobalNamespace/index.html -check-prefix=HTML-INDEX
+// RUN: FileCheck %s < %t/GlobalNamespace/index.md -check-prefix=MD-INDEX
 
 /**

[clang] [llvm] Finish deleting the le32/le64 targets (PR #98497)

2024-07-15 Thread Andrew Adams via cfe-commits

abadams wrote:

We were advised to use the pnacl targets at the time the code was written.  
We're trying wasm now.

The IR can be generic if you use a subset of C that excludes all the things 
that vary across the targets you care about. For cases we really can't avoid it 
(e.g. win32 calling convention stuff for direct3d), we compile that one 
fragment with a few different target triples.

https://github.com/llvm/llvm-project/pull/98497
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-doc] add nested namespace test case (PR #97681)

2024-07-15 Thread via cfe-commits

PeterChou1 wrote:

> To clarify my earlier comment, FileCheck is just matching text on the input 
> based on the check lines. So in this cases the LINE directive should just 
> affect what text will be accepted when doin matching. It won’t try to match 
> the lines to the position in the file being checked.
> 
> If you run into problems, post the errors here, as we can probably help 
> diagnose them.

My bad I think I was mistaken in how the @LINE directive worked initially I 
think i Fixed up the pr so that it works with it now

https://github.com/llvm/llvm-project/pull/97681
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Fix self-capturing `__block` variables (PR #89475)

2024-07-15 Thread via cfe-commits


@@ -2764,6 +2794,9 @@ void CodeGenFunction::emitByrefStructureInit(const 
AutoVarEmission &emission) {
 auto layoutInfo = CGM.getObjCRuntime().BuildByrefLayout(CGM, type);
 storeHeaderField(layoutInfo, getPointerSize(), "byref.layout");
   }
+
+  if (emission.NeedsInitOnHeap)
+emitByrefInitOnHeap(pointer);

ille-apple wrote:

Ping.

https://github.com/llvm/llvm-project/pull/89475
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Add deprecation warning for `-Ofast` driver option (PR #98736)

2024-07-15 Thread Fangrui Song via cfe-commits


@@ -10,31 +10,36 @@
 // RUN: %clang -Ofast -fno-strict-aliasing -### %s 2>&1 | FileCheck 
-check-prefix=CHECK-OFAST-NO-STRICT-ALIASING %s
 // RUN: %clang -Ofast -fno-vectorize -### %s 2>&1 | FileCheck 
-check-prefix=CHECK-OFAST-NO-VECTORIZE %s
 
+// CHECK-OFAST: argument '-Ofast' is deprecated; use '-O3 -ffast-math' 
instead, or just '-O3' if you do not intend to enable non-conforming 
optimizations
 // CHECK-OFAST: -cc1
 // CHECK-OFAST-NOT: -relaxed-aliasing
 // CHECK-OFAST: -ffast-math
 // CHECK-OFAST: -Ofast
 // CHECK-OFAST: -vectorize-loops
 
+// CHECK-OFAST-O2-NOT: argument '-Ofast' is deprecated; use '-O3 -ffast-math' 
instead, or just '-O3' if you do not intend to enable non-conforming 
optimizations

MaskRay wrote:

`clang -### -Werror` exits with 1 in case of errors 
(https://reviews.llvm.org/D156363). A lot of `CHECK-NOT: warning: ...` patterns 
can be replaced with `-### -Werror`

https://github.com/llvm/llvm-project/pull/98736
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Finish deleting the le32/le64 targets (PR #98497)

2024-07-15 Thread Steven Johnson via cfe-commits

steven-johnson wrote:

> We're trying wasm now.

This looked promising in our GitHub tests, but for reasons that aren't clear 
(yet), ~everything compiled this way inside google3 resulted in linker errors 
(missing symbols).

https://github.com/llvm/llvm-project/pull/98497
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 864478c - [Clang] Disallow explicit object parameters in more contexts (#89078)

2024-07-15 Thread via cfe-commits

Author: Sirraide
Date: 2024-07-16T01:55:11+02:00
New Revision: 864478cc74f5e258f86014886df16aa8d393bcc6

URL: 
https://github.com/llvm/llvm-project/commit/864478cc74f5e258f86014886df16aa8d393bcc6
DIFF: 
https://github.com/llvm/llvm-project/commit/864478cc74f5e258f86014886df16aa8d393bcc6.diff

LOG: [Clang] Disallow explicit object parameters in more contexts (#89078)

This diagnoses explicit object parameters in more contexts
where they aren’t supposed to appear in (e.g. function pointer
types, non-function member decls, etc.) [dcl.fct]

This fixes #85992.

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaType.cpp
clang/test/SemaCXX/cxx2b-deducing-this.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index a34f109ba21ce..969856a8f978c 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1038,6 +1038,8 @@ Bug Fixes to C++ Support
 - Fix a crash when parsing an invalid type-requirement in a requires 
expression. (#GH51868)
 - Fix parsing of built-in type-traits such as ``__is_pointer`` in libstdc++ 
headers. (#GH95598)
 - Fixed failed assertion when resolving context of defaulted comparison method 
outside of struct. (#GH96043).
+- Clang now diagnoses explicit object parameters in member pointers and other 
contexts where they should not appear.
+  Fixes (#GH85992).
 
 Bug Fixes to AST Handling
 ^

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 0ea3677355169..52ff4b026a60e 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7577,6 +7577,8 @@ def err_explicit_object_lambda_ambiguous_base : Error<
 def err_explicit_object_lambda_inaccessible_base : Error<
   "invalid explicit object parameter type %0 in lambda with capture; "
   "the type must derive publicly from the lambda">;
+def err_explicit_object_parameter_invalid: Error<
+  "an explicit object parameter can only appear as the first parameter of a 
member function">;
 
 def err_ref_qualifier_overload : Error<
   "cannot overload a member function %select{without a ref-qualifier|with "

diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 17c4ba99c03f5..f24912cde275a 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -11258,6 +11258,34 @@ void 
Sema::CheckExplicitObjectMemberFunction(Declarator &D,
 D.setInvalidType();
   }
 
+  // Friend declarations require some care. Consider:
+  //
+  // namespace N {
+  // struct A{};
+  // int f(A);
+  // }
+  //
+  // struct S {
+  //   struct T {
+  // int f(this T);
+  //   };
+  //
+  //   friend int T::f(this T); // Allow this.
+  //   friend int f(this S);// But disallow this.
+  //   friend int N::f(this A); // And disallow this.
+  // };
+  //
+  // Here, it seems to suffice to check whether the scope
+  // specifier designates a class type.
+  if (D.getDeclSpec().isFriendSpecified() &&
+  !isa_and_present(
+  computeDeclContext(D.getCXXScopeSpec( {
+Diag(ExplicitObjectParam->getBeginLoc(),
+ diag::err_explicit_object_parameter_nonmember)
+<< D.getSourceRange() << /*non-member=*/2 << IsLambda;
+D.setInvalidType();
+  }
+
   if (IsLambda && FTI.hasMutableQualifier()) {
 Diag(ExplicitObjectParam->getBeginLoc(),
  diag::err_explicit_object_parameter_mutable)
@@ -11268,10 +11296,8 @@ void 
Sema::CheckExplicitObjectMemberFunction(Declarator &D,
 return;
 
   if (!DC || !DC->isRecord()) {
-Diag(ExplicitObjectParam->getLocation(),
- diag::err_explicit_object_parameter_nonmember)
-<< D.getSourceRange() << /*non-member=*/2 << IsLambda;
-D.setInvalidType();
+assert(D.isInvalidType() && "Explicit object parameter in non-member "
+"should have been diagnosed already");
 return;
   }
 

diff  --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 46166e44d17bd..baac1fe4f2407 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -4762,6 +4762,61 @@ static TypeSourceInfo 
*GetFullTypeForDeclarator(TypeProcessingState &state,
   // Check for auto functions and trailing return type and adjust the
   // return type accordingly.
   if (!D.isInvalidType()) {
+auto IsClassType = [&](CXXScopeSpec &SS) {
+  // If there already was an problem with the scope, don’t issue 
another
+  // error about the explicit object parameter.
+  return SS.isInvalid() ||
+ isa_and_present(S.computeDeclContext(SS));
+};
+
+// C++23 [dcl.fct]p6:
+//
+// An explicit-object-parameter-declaration 

[clang] [Clang] Disallow explicit object parameters in more contexts (PR #89078)

2024-07-15 Thread via cfe-commits

https://github.com/Sirraide closed 
https://github.com/llvm/llvm-project/pull/89078
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [Coverage][MC/DC] Show uncoverable and unreachable conditions (PR #94137)

2024-07-15 Thread via cfe-commits

https://github.com/Lambdaris updated 
https://github.com/llvm/llvm-project/pull/94137

>From 23669f721d056d6e4961e2572e438e5c1f91cab1 Mon Sep 17 00:00:00 2001
From: Lambdaris 
Date: Sun, 2 Jun 2024 10:19:31 +0800
Subject: [PATCH 1/3] [coverage] Mark branches with either counter is zero as
 folded

---
 clang/lib/CodeGen/CoverageMappingGen.cpp  | 27 +
 .../CoverageMapping/branch-constfolded.cpp| 40 +--
 clang/test/CoverageMapping/if.cpp |  4 +-
 clang/test/CoverageMapping/macro-expansion.c  | 10 ++---
 .../test/CoverageMapping/mcdc-scratch-space.c |  4 +-
 .../CoverageMapping/mcdc-system-headers.cpp   |  4 +-
 .../ProfileData/Coverage/CoverageMapping.h|  4 +-
 .../ProfileData/Coverage/CoverageMapping.cpp  |  4 +-
 .../test/tools/llvm-cov/branch-c-general.test | 12 +++---
 9 files changed, 61 insertions(+), 48 deletions(-)

diff --git a/clang/lib/CodeGen/CoverageMappingGen.cpp 
b/clang/lib/CodeGen/CoverageMappingGen.cpp
index 67a9caf8b4ec4..fb9da1a72f8dd 100644
--- a/clang/lib/CodeGen/CoverageMappingGen.cpp
+++ b/clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -1099,9 +1099,13 @@ struct CounterCoverageMappingBuilder
   }
 
   /// Determine whether the given condition can be constant folded.
-  bool ConditionFoldsToBool(const Expr *Cond) {
+  bool ConditionFoldsToBool(const Expr *Cond, bool &ResultBool) {
 Expr::EvalResult Result;
-return (Cond->EvaluateAsInt(Result, CVM.getCodeGenModule().getContext()));
+if (Cond->EvaluateAsInt(Result, CVM.getCodeGenModule().getContext())) {
+  ResultBool = Result.Val.getInt().getBoolValue();
+  return true;
+}
+return false;
   }
 
   /// Create a Branch Region around an instrumentable condition for coverage
@@ -1128,15 +1132,22 @@ struct CounterCoverageMappingBuilder
 BranchParams = mcdc::BranchParameters{ID, Conds};
 
   // If a condition can fold to true or false, the corresponding branch
-  // will be removed.  Create a region with both counters hard-coded to
-  // zero. This allows us to visualize them in a special way.
+  // will be removed. Create a region with the relative counter hard-coded
+  // to zero. This allows us to visualize them in a special way.
   // Alternatively, we can prevent any optimization done via
   // constant-folding by ensuring that ConstantFoldsToSimpleInteger() in
   // CodeGenFunction.c always returns false, but that is very heavy-handed.
-  if (ConditionFoldsToBool(C))
-popRegions(pushRegion(Counter::getZero(), getStart(C), getEnd(C),
-  Counter::getZero(), BranchParams));
-  else
+  bool ConstantBool = false;
+  if (ConditionFoldsToBool(C, ConstantBool)) {
+if (ConstantBool) {
+  popRegions(pushRegion(TrueCnt, getStart(C), getEnd(C),
+Counter::getZero(), BranchParams));
+} else {
+  popRegions(pushRegion(Counter::getZero(), getStart(C), getEnd(C),
+FalseCnt, BranchParams));
+}
+
+  } else
 // Otherwise, create a region with the True counter and False counter.
 popRegions(pushRegion(TrueCnt, getStart(C), getEnd(C), FalseCnt,
   BranchParams));
diff --git a/clang/test/CoverageMapping/branch-constfolded.cpp 
b/clang/test/CoverageMapping/branch-constfolded.cpp
index 1e7e32808e838..a2ac1c1eacd28 100644
--- a/clang/test/CoverageMapping/branch-constfolded.cpp
+++ b/clang/test/CoverageMapping/branch-constfolded.cpp
@@ -5,94 +5,94 @@
 
 // CHECK-LABEL: _Z6fand_0b:
 bool fand_0(bool a) {  // MCDC: Decision,File 0, [[@LINE+1]]:10 -> 
[[@LINE+1]]:20 = M:3, C:2
-  return false && a;   // CHECK: Branch,File 0, [[@LINE]]:10 -> 
[[@LINE]]:15 = 0, 0
+  return false && a;   // CHECK: Branch,File 0, [[@LINE]]:10 -> 
[[@LINE]]:15 = 0, (#0 - #1)
 }  // CHECK: Branch,File 0, [[@LINE-1]]:19 -> 
[[@LINE-1]]:20 = #2, (#1 - #2)
 
 // CHECK-LABEL: _Z6fand_1b:
 bool fand_1(bool a) {  // MCDC: Decision,File 0, [[@LINE+1]]:10 -> 
[[@LINE+1]]:19 = M:3, C:2
   return a && true;// CHECK: Branch,File 0, [[@LINE]]:10 -> 
[[@LINE]]:11 = #1, (#0 - #1)
-}  // CHECK: Branch,File 0, [[@LINE-1]]:15 -> 
[[@LINE-1]]:19 = 0, 0
+}  // CHECK: Branch,File 0, [[@LINE-1]]:15 -> 
[[@LINE-1]]:19 = #2, 0
 
 // CHECK-LABEL: _Z6fand_2bb:
 bool fand_2(bool a, bool b) {// MCDC: Decision,File 0, [[@LINE+1]]:10 -> 
[[@LINE+1]]:25 = M:4, C:3
-  return false && a && b;  // CHECK: Branch,File 0, [[@LINE]]:10 -> 
[[@LINE]]:15 = 0, 0
+  return false && a && b;  // CHECK: Branch,File 0, [[@LINE]]:10 -> 
[[@LINE]]:15 = 0, (#0 - #3)
 }  // CHECK: Branch,File 0, [[@LINE-1]]:19 -> 
[[@LINE-1]]:20 = #4, (#3 - #4)
// CHECK: Branch,File 0, [[@LINE-2]]:24 -> 
[[@LINE-2]]:25 = #2, (#1 - #2)
 
 // CHECK-LABEL: _Z6fand_3bb:
 bool fand_3(bool a, bool 

[clang] [llvm] [Coverage][MC/DC] Show uncoverable and unreachable conditions (PR #94137)

2024-07-15 Thread via cfe-commits

https://github.com/Lambdaris edited 
https://github.com/llvm/llvm-project/pull/94137
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] IR: Store the default subtarget info in named metadata instead of the context. (PR #98673)

2024-07-15 Thread Jessica Clarke via cfe-commits


@@ -1240,11 +1240,22 @@ void IRLinker::linkNamedMDNodes() {
 if (IsPerformingImport && NMD.getName() == "llvm.stats")
   continue;
 
+// Default subtarget info is only intended to be used before LTO and
+// shouldn't be present after merging because the default subtargets may be
+// different. Even if they were the same we wouldn't want to keep them to
+// avoid introducing bugs that would only occur when merging modules with
+// different subtarget info.
+if (NMD.getName() == "llvm.subtarget.info")

jrtc27 wrote:

This seems to be an overly simplistic take. Downstream we need a subset of the 
target features during LTO, and it wouldn't surprise me if there are cases 
upstream that could benefit from it too.

https://github.com/llvm/llvm-project/pull/98673
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-doc] add enum test (PR #97679)

2024-07-15 Thread Paul Kirth via cfe-commits


@@ -0,0 +1,121 @@
+// RUN: rm -rf %t && mkdir -p %t
+// RUN: clang-doc --format=html --doxygen --output=%t --executor=standalone %s
+// RUN: clang-doc --format=md --doxygen --output=%t --executor=standalone %s
+// RUN: FileCheck %s < %t/GlobalNamespace/index.html -check-prefix=HTML-INDEX
+// RUN: FileCheck %s < %t/GlobalNamespace/Animals.html 
-check-prefix=HTML-ANIMAL
+// RUN: FileCheck %s < %t/Vehicles/index.html -check-prefix=HTML-VEHICLES
+// RUN: FileCheck %s < %t/GlobalNamespace/index.md -check-prefix=MD-INDEX
+// RUN: FileCheck %s < %t/GlobalNamespace/Animals.md -check-prefix=MD-ANIMAL
+// RUN: FileCheck %s < %t/Vehicles/index.md -check-prefix=MD-VEHICLES
+
+
+/**
+ * @brief For specifying RGB colors
+ */
+enum Color {
+  Red, // Red
+  Green, // Green
+  Blue // Blue
+};
+
+/**
+ * @brief Shape Types
+ */
+enum Shapes {

ilovepi wrote:

yeah, those cases are distinct, so its good to have both.


https://github.com/llvm/llvm-project/pull/97679
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Add deprecation warning for `-Ofast` driver option (PR #98736)

2024-07-15 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll updated 
https://github.com/llvm/llvm-project/pull/98736

>From 44b4a682f2b3d7e140f7b1bd124e7aabdbf439ad Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Sat, 13 Jul 2024 13:10:25 +0300
Subject: [PATCH 1/3] [clang] Add deprecation warning for `-Ofast` driver
 option

---
 clang/docs/ReleaseNotes.rst| 3 +++
 clang/include/clang/Basic/DiagnosticDriverKinds.td | 3 +++
 clang/include/clang/Basic/DiagnosticGroups.td  | 2 ++
 clang/include/clang/Driver/Options.td  | 3 ++-
 clang/lib/Driver/ToolChains/Clang.cpp  | 2 ++
 clang/test/Driver/Ofast.c  | 4 
 6 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index ceead8c362e9c..2f5f40f355901 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -470,6 +470,9 @@ New Compiler Flags
 Deprecated Compiler Flags
 -
 
+- ``-Ofast`` is deprecated in favor of ``-O3``, possibly combined with 
``-ffast-math``.
+  See `RFC `_ for 
details.
+
 Modified Compiler Flags
 ---
 - Added a new diagnostic flag ``-Wreturn-mismatch`` which is grouped under
diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 359c0de7f811c..3857f2f3a33ce 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -442,6 +442,9 @@ def warn_drv_deprecated_arg : Warning<
 def warn_drv_deprecated_arg_no_relaxed_template_template_args : Warning<
   "argument '-fno-relaxed-template-template-args' is deprecated">,
   InGroup;
+def warn_drv_deprecated_arg_ofast : Warning<
+  "argument '-Ofast' is deprecated; use '-O3', possibly with '-ffast-math'">,
+  InGroup;
 def warn_drv_deprecated_custom : Warning<
   "argument '%0' is deprecated, %1">, InGroup;
 def warn_drv_assuming_mfloat_abi_is : Warning<
diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 2241f8481484e..d7dba76a0fcf8 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -103,6 +103,7 @@ def EnumConversion : DiagGroup<"enum-conversion",
 EnumFloatConversion,
 EnumCompareConditional]>;
 def DeprecatedNoRelaxedTemplateTemplateArgs : 
DiagGroup<"deprecated-no-relaxed-template-template-args">;
+def DeprecatedOFast : DiagGroup<"deprecated-ofast">;
 def ObjCSignedCharBoolImplicitIntConversion :
   DiagGroup<"objc-signed-char-bool-implicit-int-conversion">;
 def Shorten64To32 : DiagGroup<"shorten-64-to-32">;
@@ -228,6 +229,7 @@ def Deprecated : DiagGroup<"deprecated", 
[DeprecatedAnonEnumEnumConversion,
   DeprecatedPragma,
   DeprecatedRegister,
   
DeprecatedNoRelaxedTemplateTemplateArgs,
+  DeprecatedOFast,
   DeprecatedThisCapture,
   DeprecatedType,
   DeprecatedVolatile,
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index f1e8cb87e5321..269790476c1c3 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -931,7 +931,8 @@ def O : Joined<["-"], "O">, Group,
 def O_flag : Flag<["-"], "O">, Visibility<[ClangOption, CC1Option, FC1Option]>,
   Alias, AliasArgs<["1"]>;
 def Ofast : Joined<["-"], "Ofast">, Group,
-  Visibility<[ClangOption, CC1Option, FlangOption]>;
+  Visibility<[ClangOption, CC1Option, FlangOption]>,
+  HelpText<"Deprecated; use -O3, possibly with -ffast-math">;
 def P : Flag<["-"], "P">,
   Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>,
   Group,
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index bc21d03a627b9..33e7152343171 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -5712,6 +5712,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
  options::OPT_fno_zero_initialized_in_bss);
 
   bool OFastEnabled = isOptimizationLevelFast(Args);
+  if (OFastEnabled)
+D.Diag(diag::warn_drv_deprecated_arg_ofast);
   // If -Ofast is the optimization level, then -fstrict-aliasing should be
   // enabled.  This alias option is being used to simplify the hasFlag logic.
   OptSpecifier StrictAliasingAliasOption =
diff --git a/clang/test/Driver/Ofast.c b/clang/test/Driver/Ofast.c
index 8b7f2217eca2f..f5a2aabe257f1 100644
--- a/clang/test/Driver/Ofast.c
+++ b/clang/test/Driver/Ofast.c
@@ -10,6 +10,7 @@
 // RUN: %clang -Ofast -fno-stric

[clang-tools-extra] [clang-doc] add enum test (PR #97679)

2024-07-15 Thread Paul Kirth via cfe-commits

https://github.com/ilovepi approved this pull request.

LGTM, modulo some nits. I do think you may want to have a separate prefix for 
the lines, but if you change `--check-prefix=` to 
`--check-prefixes=HTML-ANIMAL,HTML-ANIMAL-LINE`, you should be able to check 
them w/o having to rewrite everything. Plus keeping the LINE comments right 
after the source line makes it a lot easier to keep the tests stable.

https://github.com/llvm/llvm-project/pull/97679
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-doc] add enum test (PR #97679)

2024-07-15 Thread Paul Kirth via cfe-commits


@@ -0,0 +1,128 @@
+// RUN: rm -rf %t && mkdir -p %t
+// RUN: clang-doc --format=html --doxygen --output=%t --executor=standalone %s
+// RUN: clang-doc --format=md --doxygen --output=%t --executor=standalone %s
+// RUN: FileCheck %s < %t/GlobalNamespace/index.html -check-prefix=HTML-INDEX
+// RUN: FileCheck %s < %t/GlobalNamespace/Animals.html 
-check-prefix=HTML-ANIMAL
+// RUN: FileCheck %s < %t/Vehicles/index.html -check-prefix=HTML-VEHICLES
+// RUN: FileCheck %s < %t/GlobalNamespace/index.md -check-prefix=MD-INDEX
+// RUN: FileCheck %s < %t/GlobalNamespace/Animals.md -check-prefix=MD-ANIMAL
+// RUN: FileCheck %s < %t/Vehicles/index.md -check-prefix=MD-VEHICLES
+
+
+
+// MD-INDEX: # Global Namespace
+// MD-INDEX: ## Enums
+// MD-INDEX: | enum Color |
+// MD-INDEX: --
+// MD-INDEX: | Red |
+// MD-INDEX: | Green |
+// MD-INDEX: | Blue |
+// MD-INDEX: *Defined at 
{{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp#[[@LINE+13]]*
+// MD-INDEX: **brief** For specifying RGB colors

ilovepi wrote:

This is a lot better, but maybe its better to move this and the HTML line check 
below the LINE you want to check and then do

```
enum Color {
// MD-INDEX: *Defined at 
{{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp#[[@LINE-1]]*
// HTML-INDEX: Defined at line [[@LINE-2]] of file 
{{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp
```
Any remaining checks can go below the class, or these line checks could be 
MD-INDEX-LINE & HTML-INDEX-LINE, and you can list 2 prefixes to check, then 
only the 2 line checks would be out of order w/ the rest. WDYT?

https://github.com/llvm/llvm-project/pull/97679
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-doc] add enum test (PR #97679)

2024-07-15 Thread Paul Kirth via cfe-commits

https://github.com/ilovepi edited 
https://github.com/llvm/llvm-project/pull/97679
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-doc] add enum test (PR #97679)

2024-07-15 Thread Paul Kirth via cfe-commits


@@ -0,0 +1,128 @@
+// RUN: rm -rf %t && mkdir -p %t
+// RUN: clang-doc --format=html --doxygen --output=%t --executor=standalone %s
+// RUN: clang-doc --format=md --doxygen --output=%t --executor=standalone %s
+// RUN: FileCheck %s < %t/GlobalNamespace/index.html -check-prefix=HTML-INDEX
+// RUN: FileCheck %s < %t/GlobalNamespace/Animals.html 
-check-prefix=HTML-ANIMAL
+// RUN: FileCheck %s < %t/Vehicles/index.html -check-prefix=HTML-VEHICLES
+// RUN: FileCheck %s < %t/GlobalNamespace/index.md -check-prefix=MD-INDEX
+// RUN: FileCheck %s < %t/GlobalNamespace/Animals.md -check-prefix=MD-ANIMAL
+// RUN: FileCheck %s < %t/Vehicles/index.md -check-prefix=MD-VEHICLES
+
+

ilovepi wrote:

nit: extra newlines

https://github.com/llvm/llvm-project/pull/97679
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] IR: Store the default subtarget info in named metadata instead of the context. (PR #98673)

2024-07-15 Thread via cfe-commits


@@ -1240,11 +1240,22 @@ void IRLinker::linkNamedMDNodes() {
 if (IsPerformingImport && NMD.getName() == "llvm.stats")
   continue;
 
+// Default subtarget info is only intended to be used before LTO and
+// shouldn't be present after merging because the default subtargets may be
+// different. Even if they were the same we wouldn't want to keep them to
+// avoid introducing bugs that would only occur when merging modules with
+// different subtarget info.
+if (NMD.getName() == "llvm.subtarget.info")

pcc wrote:

Such cases should use a separate field, such as the e_flags field that I 
suggested in [the Discourse 
thread](https://discourse.llvm.org/t/functions-generated-by-function-createwithdefaultattr-should-respect-target-features/79838/11).
 That would more cleanly implement the semantics that the target actually 
wants. The metadata that I'm adding here is intended as a generic description 
of the singular default target CPU/features, and since that's not a concept 
that exists generically after LTO it gets removed from the IR at that point.

https://github.com/llvm/llvm-project/pull/98673
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-doc] add nested namespace test case (PR #97681)

2024-07-15 Thread Paul Kirth via cfe-commits

https://github.com/ilovepi edited 
https://github.com/llvm/llvm-project/pull/97681
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-doc] add nested namespace test case (PR #97681)

2024-07-15 Thread Paul Kirth via cfe-commits


@@ -0,0 +1,274 @@
+// RUN: rm -rf %t && mkdir -p %t
+// RUN: clang-doc --format=html --output=%t --executor=standalone %s
+// RUN: clang-doc --format=md --output=%t --executor=standalone %s
+// RUN: FileCheck %s < %t/index_json.js -check-prefix=JSON-INDEX
+// RUN: FileCheck %s < %t/@nonymous_namespace/AnonClass.html 
-check-prefix=HTML-ANON-CLASS
+// RUN: FileCheck %s < %t/@nonymous_namespace/index.html 
-check-prefix=HTML-ANON-INDEX
+// RUN: FileCheck %s < %t/AnotherNamespace/ClassInAnotherNamespace.html 
-check-prefix=HTML-ANOTHER-CLASS
+// RUN: FileCheck %s < %t/AnotherNamespace/index.html 
-check-prefix=HTML-ANOTHER-INDEX
+// RUN: FileCheck %s < %t/GlobalNamespace/index.html 
-check-prefix=HTML-GLOBAL-INDEX
+// RUN: FileCheck %s < 
%t/PrimaryNamespace/NestedNamespace/ClassInNestedNamespace.html 
-check-prefix=HTML-NESTED-CLASS
+// RUN: FileCheck %s < %t/PrimaryNamespace/NestedNamespace/index.html 
-check-prefix=HTML-NESTED-INDEX
+// RUN: FileCheck %s < %t/PrimaryNamespace/index.html 
-check-prefix=HTML-PRIMARY-INDEX
+// RUN: FileCheck %s < %t/PrimaryNamespace/ClassInPrimaryNamespace.html 
-check-prefix=HTML-PRIMARY-CLASS
+// RUN: FileCheck %s < %t/@nonymous_namespace/AnonClass.md 
-check-prefix=MD-ANON-CLASS
+// RUN: FileCheck %s < %t/@nonymous_namespace/index.md 
-check-prefix=MD-ANON-INDEX
+// RUN: FileCheck %s < %t/AnotherNamespace/ClassInAnotherNamespace.md 
-check-prefix=MD-ANOTHER-CLASS
+// RUN: FileCheck %s < %t/AnotherNamespace/index.md 
-check-prefix=MD-ANOTHER-INDEX
+// RUN: FileCheck %s < %t/GlobalNamespace/index.md 
-check-prefix=MD-GLOBAL-INDEX
+// RUN: FileCheck %s < 
%t/PrimaryNamespace/NestedNamespace/ClassInNestedNamespace.md 
-check-prefix=MD-NESTED-CLASS
+// RUN: FileCheck %s < %t/PrimaryNamespace/NestedNamespace/index.md 
-check-prefix=MD-NESTED-INDEX
+// RUN: FileCheck %s < %t/PrimaryNamespace/index.md 
-check-prefix=MD-PRIMARY-INDEX
+// RUN: FileCheck %s < %t/PrimaryNamespace/ClassInPrimaryNamespace.md 
-check-prefix=MD-PRIMARY-CLASS
+// RUN: FileCheck %s < %t/all_files.md -check-prefix=MD-ALL-FILES
+// RUN: FileCheck %s < %t/index.md -check-prefix=MD-INDEX
+
+// MD-ANON-INDEX: # namespace @nonymous_namespace
+// MD-ANON-INDEX:  Anonymous Namespace
+// MD-ANON-INDEX: ## Records
+// MD-ANON-INDEX: * [AnonClass](AnonClass.md)
+// MD-ANON-INDEX: ## Functions
+// MD-ANON-INDEX: ### anonFunction
+// MD-ANON-INDEX: *void anonFunction()*
+// MD-ANON-INDEX: *Defined at 
{{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp#[[@LINE+15]]*
+
+// HTML-ANON-INDEX: namespace @nonymous_namespace
+// HTML-ANON-INDEX:  Anonymous Namespace
+// HTML-ANON-INDEX: Records
+// HTML-ANON-INDEX: AnonClass
+// HTML-ANON-INDEX: Functions
+// HTML-ANON-INDEX: anonFunction
+// HTML-ANON-INDEX: void anonFunction()
+// HTML-ANON-INDEX: Defined at line [[@LINE+6]] of file 
{{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp

ilovepi wrote:

As mentioned in your other PR, lets check these right after the line they're 
checking, and use a `*-LINE` tag to check these w/ `--check-prefixes`.  That 
should prevent instability in the test due to more test checks getting added. 
Once that's done for all these tests, this will probably be good to go, modulo 
some nits.

https://github.com/llvm/llvm-project/pull/97681
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-doc] add nested namespace test case (PR #97681)

2024-07-15 Thread Paul Kirth via cfe-commits


@@ -0,0 +1,274 @@
+// RUN: rm -rf %t && mkdir -p %t
+// RUN: clang-doc --format=html --output=%t --executor=standalone %s
+// RUN: clang-doc --format=md --output=%t --executor=standalone %s
+// RUN: FileCheck %s < %t/index_json.js -check-prefix=JSON-INDEX
+// RUN: FileCheck %s < %t/@nonymous_namespace/AnonClass.html 
-check-prefix=HTML-ANON-CLASS
+// RUN: FileCheck %s < %t/@nonymous_namespace/index.html 
-check-prefix=HTML-ANON-INDEX
+// RUN: FileCheck %s < %t/AnotherNamespace/ClassInAnotherNamespace.html 
-check-prefix=HTML-ANOTHER-CLASS
+// RUN: FileCheck %s < %t/AnotherNamespace/index.html 
-check-prefix=HTML-ANOTHER-INDEX
+// RUN: FileCheck %s < %t/GlobalNamespace/index.html 
-check-prefix=HTML-GLOBAL-INDEX
+// RUN: FileCheck %s < 
%t/PrimaryNamespace/NestedNamespace/ClassInNestedNamespace.html 
-check-prefix=HTML-NESTED-CLASS
+// RUN: FileCheck %s < %t/PrimaryNamespace/NestedNamespace/index.html 
-check-prefix=HTML-NESTED-INDEX
+// RUN: FileCheck %s < %t/PrimaryNamespace/index.html 
-check-prefix=HTML-PRIMARY-INDEX
+// RUN: FileCheck %s < %t/PrimaryNamespace/ClassInPrimaryNamespace.html 
-check-prefix=HTML-PRIMARY-CLASS
+// RUN: FileCheck %s < %t/@nonymous_namespace/AnonClass.md 
-check-prefix=MD-ANON-CLASS
+// RUN: FileCheck %s < %t/@nonymous_namespace/index.md 
-check-prefix=MD-ANON-INDEX
+// RUN: FileCheck %s < %t/AnotherNamespace/ClassInAnotherNamespace.md 
-check-prefix=MD-ANOTHER-CLASS
+// RUN: FileCheck %s < %t/AnotherNamespace/index.md 
-check-prefix=MD-ANOTHER-INDEX
+// RUN: FileCheck %s < %t/GlobalNamespace/index.md 
-check-prefix=MD-GLOBAL-INDEX
+// RUN: FileCheck %s < 
%t/PrimaryNamespace/NestedNamespace/ClassInNestedNamespace.md 
-check-prefix=MD-NESTED-CLASS
+// RUN: FileCheck %s < %t/PrimaryNamespace/NestedNamespace/index.md 
-check-prefix=MD-NESTED-INDEX
+// RUN: FileCheck %s < %t/PrimaryNamespace/index.md 
-check-prefix=MD-PRIMARY-INDEX
+// RUN: FileCheck %s < %t/PrimaryNamespace/ClassInPrimaryNamespace.md 
-check-prefix=MD-PRIMARY-CLASS
+// RUN: FileCheck %s < %t/all_files.md -check-prefix=MD-ALL-FILES
+// RUN: FileCheck %s < %t/index.md -check-prefix=MD-INDEX
+
+// MD-ANON-INDEX: # namespace @nonymous_namespace
+// MD-ANON-INDEX:  Anonymous Namespace
+// MD-ANON-INDEX: ## Records
+// MD-ANON-INDEX: * [AnonClass](AnonClass.md)
+// MD-ANON-INDEX: ## Functions
+// MD-ANON-INDEX: ### anonFunction
+// MD-ANON-INDEX: *void anonFunction()*
+// MD-ANON-INDEX: *Defined at 
{{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp#[[@LINE+15]]*
+
+// HTML-ANON-INDEX: namespace @nonymous_namespace
+// HTML-ANON-INDEX:  Anonymous Namespace
+// HTML-ANON-INDEX: Records
+// HTML-ANON-INDEX: AnonClass
+// HTML-ANON-INDEX: Functions
+// HTML-ANON-INDEX: anonFunction
+// HTML-ANON-INDEX: void anonFunction()
+// HTML-ANON-INDEX: Defined at line [[@LINE+6]] of file 
{{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp
+
+// Anonymous Namespace
+namespace
+{
+

ilovepi wrote:

nit: extra newline.

https://github.com/llvm/llvm-project/pull/97681
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clang-doc] add nested namespace test case (PR #97681)

2024-07-15 Thread Paul Kirth via cfe-commits

https://github.com/ilovepi approved this pull request.

LGTM, once the LINE checks are in a more stable position w/ their own prefixes, 
and a couple of nits on whitespace.

https://github.com/llvm/llvm-project/pull/97681
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] bddab51 - [X86][MC,Driver] Support -msse2avx to encode SSE instruction with VEX prefix (#96860)

2024-07-15 Thread via cfe-commits

Author: JaydeepChauhan14
Date: 2024-07-16T09:40:45+08:00
New Revision: bddab518db003f7c5ce9014e9ebd932fb7a85d2f

URL: 
https://github.com/llvm/llvm-project/commit/bddab518db003f7c5ce9014e9ebd932fb7a85d2f
DIFF: 
https://github.com/llvm/llvm-project/commit/bddab518db003f7c5ce9014e9ebd932fb7a85d2f.diff

LOG: [X86][MC,Driver] Support -msse2avx to encode SSE instruction with VEX 
prefix (#96860)

For GCC compatibility
https://gcc.gnu.org/onlinedocs/gcc-14.1.0/gcc/x86-Options.html.

Added: 
clang/test/Driver/msse2avx.c
llvm/test/MC/AsmParser/sse2avx-att.s

Modified: 
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Clang.cpp
clang/tools/driver/cc1as_main.cpp
llvm/include/llvm/MC/MCTargetOptions.h
llvm/include/llvm/MC/MCTargetOptionsCommandFlags.h
llvm/lib/MC/MCTargetOptionsCommandFlags.cpp
llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
llvm/utils/TableGen/X86InstrMappingEmitter.cpp
llvm/utils/TableGen/X86ManualInstrMapping.def

Removed: 




diff  --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index f1ddd2276e816..f671b780bcbeb 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -38,6 +38,7 @@ VALUE_CODEGENOPT(Name, Bits, Default)
 CODEGENOPT(DisableIntegratedAS, 1, 0) ///< -no-integrated-as
 CODEGENOPT(Crel, 1, 0) ///< -Wa,--crel
 CODEGENOPT(RelaxELFRelocations, 1, 1) ///< -Wa,-mrelax-relocations={yes,no}
+CODEGENOPT(SSE2AVX  , 1, 0)   ///< -msse2avx
 CODEGENOPT(AsmVerbose, 1, 0) ///< -dA, -fverbose-asm.
 CODEGENOPT(PreserveAsmComments, 1, 1) ///< -dA, -fno-preserve-as-comments.
 CODEGENOPT(AssumeSaneOperatorNew , 1, 1) ///< implicit __attribute__((malloc)) 
operator new

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index be177dc38bcf1..234958f4eb382 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5179,6 +5179,13 @@ def mvx : Flag<["-"], "mvx">, Group;
 def mno_vx : Flag<["-"], "mno-vx">, Group;
 } // let Flags = [TargetSpecific]
 
+let Flags = [TargetSpecific] in {
+def msse2avx : Flag<["-"], "msse2avx">, Group,
+  Visibility<[ClangOption, CC1Option, CC1AsOption]>,
+  HelpText<"Specify that the assembler should encode SSE instructions with VEX 
prefix">,
+  MarshallingInfoFlag>;
+} // let Flags = [TargetSpecific]
+
 defm zvector : BoolFOption<"zvector",
   LangOpts<"ZVector">, DefaultFalse,
   PosFlag&1 | FileCheck 
 %s
+// RUN: %clang -### -c -march=x86-64 -x assembler -Xassembler -msse2avx %s 
2>&1 | FileCheck %s
+
+// CHECK: "-msse2avx"
+
+// RUN: not %clang -### -c --target=aarch64 -march=armv8a -msse2avx %s 2>&1 | 
FileCheck --check-prefix=ERR %s
+// ERR:   error: unsupported option '-msse2avx' for target 'aarch64'

diff  --git a/clang/tools/driver/cc1as_main.cpp 
b/clang/tools/driver/cc1as_main.cpp
index 4e0aa1450563e..ec93f092713f5 100644
--- a/clang/tools/driver/cc1as_main.cpp
+++ b/clang/tools/driver/cc1as_main.cpp
@@ -98,6 +98,8 @@ struct AssemblerInvocation {
   LLVM_PREFERRED_TYPE(bool)
   unsigned RelaxELFRelocations : 1;
   LLVM_PREFERRED_TYPE(bool)
+  unsigned SSE2AVX : 1;
+  LLVM_PREFERRED_TYPE(bool)
   unsigned Dwarf64 : 1;
   unsigned DwarfVersion;
   std::string DwarfDebugFlags;
@@ -197,6 +199,7 @@ struct AssemblerInvocation {
 ShowInst = 0;
 ShowEncoding = 0;
 RelaxAll = 0;
+SSE2AVX = 0;
 NoExecStack = 0;
 FatalWarnings = 0;
 NoWarn = 0;
@@ -288,6 +291,7 @@ bool 
AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts,
   }
 
   Opts.RelaxELFRelocations = !Args.hasArg(OPT_mrelax_relocations_no);
+  Opts.SSE2AVX = Args.hasArg(OPT_msse2avx);
   if (auto *DwarfFormatArg = Args.getLastArg(OPT_gdwarf64, OPT_gdwarf32))
 Opts.Dwarf64 = DwarfFormatArg->getOption().matches(OPT_gdwarf64);
   Opts.DwarfVersion = getLastArgIntValue(Args, OPT_dwarf_version_EQ, 2, Diags);
@@ -437,6 +441,7 @@ static bool ExecuteAssemblerImpl(AssemblerInvocation &Opts,
   MCOptions.MCSaveTempLabels = Opts.SaveTemporaryLabels;
   MCOptions.Crel = Opts.Crel;
   MCOptions.X86RelaxRelocations = Opts.RelaxELFRelocations;
+  MCOptions.X86Sse2Avx = Opts.SSE2AVX;
   MCOptions.CompressDebugSections = Opts.CompressDebugSections;
   MCOptions.AsSecureLogFile = Opts.AsSecureLogFile;
 

diff  --git a/llvm/include/llvm/MC/MCTargetOptions.h 
b/llvm/include/llvm/MC/MCTargetOptions.h
index 98317712250bf..899299fd15246 100644
--- a/llvm/include/llvm/MC/MCTargetOptions.h
+++ b/llvm/include/llvm/MC/MCTargetOptions.h
@@ -68,6 +68,8 @@ class MCTargetOptions {
   // ELF.
   bool X86RelaxRelocations = true;
 
+  bool X86Sse2Avx = false;
+
   EmitDwarfUnwindType EmitDwarfUnwind;
 
   int DwarfVersion = 0;

diff  --git a/llvm/include/llvm/MC/MCTargetOptionsCommandFlags.h 
b/llvm/include/llvm/MC/

[clang] [llvm] [X86][MC,Driver] Support -msse2avx to encode SSE instruction with VEX prefix (PR #96860)

2024-07-15 Thread Shengchen Kan via cfe-commits

https://github.com/KanRobert closed 
https://github.com/llvm/llvm-project/pull/96860
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [X86][MC,Driver] Support -msse2avx to encode SSE instruction with VEX prefix (PR #96860)

2024-07-15 Thread via cfe-commits

github-actions[bot] wrote:



@JaydeepChauhan14 Congratulations on having your first Pull Request (PR) merged 
into the LLVM Project!

Your changes will be combined with recent changes from other authors, then 
tested
by our [build bots](https://lab.llvm.org/buildbot/). If there is a problem with 
a build, you may receive a report in an email or a comment on this PR.

Please check whether problems have been caused by your change specifically, as
the builds can include changes from many authors. It is not uncommon for your
change to be included in a build that fails due to someone else's changes, or
infrastructure issues.

How to do this, and the rest of the post-merge process, is covered in detail 
[here](https://llvm.org/docs/MyFirstTypoFix.html#myfirsttypofix-issues-after-landing-your-pr).

If your change does cause a problem, it may be reverted, or you can revert it 
yourself.
This is a normal part of [LLVM 
development](https://llvm.org/docs/DeveloperPolicy.html#patch-reversion-policy).
 You can fix your changes and open a new PR to merge them again.

If you don't get any reports, no action is required from you. Your changes are 
working as expected, well done!


https://github.com/llvm/llvm-project/pull/96860
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clangd] [C++20] [Modules] Introduce initial support for C++20 Modules (PR #66462)

2024-07-15 Thread Chuanqi Xu via cfe-commits

ChuanqiXu9 wrote:

@Arthapz @guijiyang thanks for reporting. But could you try to give feedbacks 
to that repo instead of this page. I feel this page it too long now. (My 
browser needs seconds to load it). And this page is indeed not a good place to 
track that.

---

@guijiyang  it looks like the reason why it can't works is that the clang tools 
can't handle with MSVC's option '/ifcOutput' and '/interface' . It may be 
better if you can compile your project with clang.exe on Windows and use a 
compile commands from that. And also, as far as I know, clang can't compile std 
module from MSSTL. Then clangd can't handle that too. Maybe we  have to need to 
wait for clang to compile std module from STL.

---

@Arthapz For the first error, it says the module unit doesn't declare that 
module. Maybe it will helpful to check that. For the second error, it should be 
a inconsistent configuration in the clangd side. 
https://clang.llvm.org/docs/StandardCPlusPlusModules.html#object-definition-consistency.
 We skipped ODR check by default in clang but it looks like we forgot it in 
clangd.

https://github.com/llvm/llvm-project/pull/66462
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [C++20] [Modules] [Itanium ABI] Generate the vtable in the module unit of dynamic classes (PR #75912)

2024-07-15 Thread Chuanqi Xu via cfe-commits

ChuanqiXu9 wrote:

> 
> > (FWIW, check some of the recent modules changes @ChuanqiXu9 has been 
> > working on to see that reviewer bandwidth here is pretty thin (& my 
> > experience in LLVM in general, including clang, is that reviewer bandwidth 
> > is pretty thin - though it is something we should address & I do think it 
> > might be time to change LLVM's post-commit review policy, but I think it'll 
> > be a substantial amount of work))
> 
> If you feel bandwidth for modules is pretty thin, I put myself available as a 
> reviewer, so feel free to ping me. I may not have a lot of time available for 
> fully reviewing big patches, but I can certainly help with the smaller 
> patches such as this one.

Thanks. I'll try to add you for future reviewings.

> > > That's a pretty substantial policy change to propose, and this probably 
> > > isn't the place to propose/discuss it. If that's your intent, probably 
> > > best to take that up on discord.
> 
> I am not proposing a policy change. I believe the current policy is aimed at 
> giving an escape hatch for projects which there is basically one or two 
> active developers. I am pointing out that I believe we don't need for that 
> escape hatch to apply to any parts of clang currently.

To be honest, this is not what I feel at least for coroutines and modules for a 
long time. I had multiple experience that some patches doesn't get reviewed for 
months. I still believe it will work better if I can push some simple patches 
directly.

https://github.com/llvm/llvm-project/pull/75912
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 578cf72 - [RISCV] Add support for getHostCPUFeatures using hwprobe (#94352)

2024-07-15 Thread via cfe-commits

Author: Yingwei Zheng
Date: 2024-07-16T10:11:39+08:00
New Revision: 578cf724de56e6c6768859bb1b6a597ee5d14ea0

URL: 
https://github.com/llvm/llvm-project/commit/578cf724de56e6c6768859bb1b6a597ee5d14ea0
DIFF: 
https://github.com/llvm/llvm-project/commit/578cf724de56e6c6768859bb1b6a597ee5d14ea0.diff

LOG: [RISCV] Add support for getHostCPUFeatures using hwprobe (#94352)

This patch adds support for `sys::getHostCPUFeatures` using the RISC-V
hardware probing interface.
References:
+ Loongarch patch:
https://github.com/llvm/llvm-project/commit/e53f41c39f3eb5052965c720d2cb517d2945fd12
+ asm/hwprobe.h:
https://github.com/torvalds/linux/blob/2ab79514109578fc4b6df90633d500cf281eb689/arch/riscv/include/uapi/asm/hwprobe.h
+ glibc support:
https://inbox.sourceware.org/glibc-cvs/20240301151728.ad5963858...@sourceware.org/T/#Z2e.:..:20240301151728.AD5963858C53::40sourceware.org:1sysdeps:unix:sysv:linux:riscv:sys:hwprobe.h
+ __NR_riscv_hwprobe syscall tutorial:
https://github.com/cyyself/hwprobe
+ hwprobe docs: https://docs.kernel.org/arch/riscv/hwprobe.html

-

Co-authored-by: Yangyu Chen 

Added: 


Modified: 
clang/lib/Driver/ToolChains/Arch/RISCV.cpp
llvm/docs/ReleaseNotes.rst
llvm/lib/TargetParser/Host.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp 
b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
index c3f0251c80750..149a31f58e75d 100644
--- a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -310,8 +310,24 @@ std::string riscv::getRISCVArch(const llvm::opt::ArgList 
&Args,
   // 2. Get march (isa string) based on `-mcpu=`
   if (const Arg *A = Args.getLastArg(options::OPT_mcpu_EQ)) {
 StringRef CPU = A->getValue();
-if (CPU == "native")
+if (CPU == "native") {
   CPU = llvm::sys::getHostCPUName();
+  // If the target cpu is unrecognized, use target features.
+  if (CPU.starts_with("generic")) {
+auto FeatureMap = llvm::sys::getHostCPUFeatures();
+// hwprobe may be unavailable on older Linux versions.
+if (!FeatureMap.empty()) {
+  std::vector Features;
+  for (auto &F : FeatureMap)
+Features.push_back(((F.second ? "+" : "-") + F.first()).str());
+  auto ParseResult = llvm::RISCVISAInfo::parseFeatures(
+  Triple.isRISCV32() ? 32 : 64, Features);
+  if (ParseResult)
+return (*ParseResult)->toString();
+}
+  }
+}
+
 StringRef MArch = llvm::RISCV::getMArchFromMcpu(CPU);
 // Bypass if target cpu's default march is empty.
 if (MArch != "")

diff  --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst
index 55b3b486d705d..f803a7bb134c4 100644
--- a/llvm/docs/ReleaseNotes.rst
+++ b/llvm/docs/ReleaseNotes.rst
@@ -203,6 +203,7 @@ Changes to the RISC-V Backend
 * Ztso is no longer experimental.
 * The WCH / Nanjing Qinheng Microelectronics QingKe "XW" compressed opcodes are
   supported under the name "Xwchc".
+* ``-mcpu=native`` now detects available features with hwprobe (RISC-V 
Hardware Probing Interface) on Linux 6.4 or later.
 
 Changes to the WebAssembly Backend
 --

diff  --git a/llvm/lib/TargetParser/Host.cpp b/llvm/lib/TargetParser/Host.cpp
index 8d5ad91839bc4..82c1731f58f0a 100644
--- a/llvm/lib/TargetParser/Host.cpp
+++ b/llvm/lib/TargetParser/Host.cpp
@@ -452,7 +452,7 @@ StringRef sys::detail::getHostCPUNameForRISCV(StringRef 
ProcCpuinfoContent) {
   return StringSwitch(UArch)
   .Case("sifive,u74-mc", "sifive-u74")
   .Case("sifive,bullet0", "sifive-u74")
-  .Default("generic");
+  .Default("");
 }
 
 StringRef sys::detail::getHostCPUNameForBPF() {
@@ -1573,8 +1573,10 @@ StringRef sys::getHostCPUName() {
 #if defined(__linux__)
   std::unique_ptr P = getProcCpuinfoContent();
   StringRef Content = P ? P->getBuffer() : "";
-  return detail::getHostCPUNameForRISCV(Content);
-#else
+  StringRef Name = detail::getHostCPUNameForRISCV(Content);
+  if (!Name.empty())
+return Name;
+#endif
 #if __riscv_xlen == 64
   return "generic-rv64";
 #elif __riscv_xlen == 32
@@ -1582,7 +1584,6 @@ StringRef sys::getHostCPUName() {
 #else
 #error "Unhandled value of __riscv_xlen"
 #endif
-#endif
 }
 #elif defined(__sparc__)
 #if defined(__linux__)
@@ -2006,6 +2007,76 @@ const StringMap sys::getHostCPUFeatures() {
 
   return Features;
 }
+#elif defined(__linux__) && defined(__riscv)
+// struct riscv_hwprobe
+struct RISCVHwProbe {
+  int64_t Key;
+  uint64_t Value;
+};
+const StringMap sys::getHostCPUFeatures() {
+  RISCVHwProbe Query[]{{/*RISCV_HWPROBE_KEY_BASE_BEHAVIOR=*/3, 0},
+   {/*RISCV_HWPROBE_KEY_IMA_EXT_0=*/4, 0}};
+  int Ret = syscall(/*__NR_riscv_hwprobe=*/258, /*pairs=*/Query,
+/*pair_count=*/std::size(Query), /*cpu_count=*/0,
+/*cpus=*/0, /*flags=*/0);
+  if (Ret != 0)
+return {}

[clang] [llvm] [RISCV] Add support for getHostCPUFeatures using hwprobe (PR #94352)

2024-07-15 Thread Yingwei Zheng via cfe-commits

https://github.com/dtcxzyw closed 
https://github.com/llvm/llvm-project/pull/94352
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [AIX] Add -msave-reg-params to save arguments to stack (PR #97524)

2024-07-15 Thread Chen Zheng via cfe-commits

https://github.com/chenzheng1030 approved this pull request.

LGTM. Thanks for adding this support.

https://github.com/llvm/llvm-project/pull/97524
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   3   4   5   >