[clang] [llvm] [X86][MC] Added support for -msse2avx option in llvm-mc (PR #96860)

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


@@ -3745,7 +3749,27 @@ bool X86AsmParser::ParseInstruction(ParseInstructionInfo 
&Info, StringRef Name,
   return false;
 }
 
+static void replaceSSE2AVXOpcode(MCInst &Inst) {
+  ArrayRef Table{X86SSE2AVXTable};
+  unsigned Opcode = Inst.getOpcode();
+  const auto I = llvm::lower_bound(Table, Opcode);
+  if (I != Table.end() && I->OldOpc == Opcode)
+Inst.setOpcode(I->NewOpc);
+
+  if (X86::isBLENDVPD(Opcode) || X86::isBLENDVPS(Opcode) ||
+  X86::isPBLENDVB(Opcode)) {
+unsigned RegNo = Inst.getOperand(2).getReg();
+Inst.addOperand(MCOperand::createReg(RegNo));
+  }
+}
+
 bool X86AsmParser::processInstruction(MCInst &Inst, const OperandVector &Ops) {
+  // When "-msse2avx" option is enabled replaceSSE2AVXOpcode method will
+  // replace SSE instruction with equivalent AVX instruction using mapping 
given
+  // in table GET_X86_SSE2AVX_TABLE

MaskRay wrote:

Agree. `if (X86::isBLENDVPD(Opcode) || X86::isBLENDVPS(Opcode) || ..`  needs a 
comment.

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] Added support for -msse2avx option in llvm-mc (PR #96860)

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

https://github.com/MaskRay edited 
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] Added support for -msse2avx option in llvm-mc (PR #96860)

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


@@ -5186,6 +5187,10 @@ def mrelax_all : Flag<["-"], "mrelax-all">, 
Group,
   Visibility<[ClangOption, CC1Option, CC1AsOption]>,
   HelpText<"(integrated-as) Relax all machine instructions">,
   MarshallingInfoFlag>;
+def msse2avx : Flag<["-"], "msse2avx">, Group,

MaskRay wrote:

This needs `TargetSpecific` Flags so that `--target=aarch64 -msse2avx` will 
error

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] Added support for -msse2avx option in llvm-mc (PR #96860)

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


@@ -0,0 +1,3 @@
+// RUN: %clang -### -c -march=x86-64 -msse2avx %s 2>&1 | FileCheck %s

MaskRay wrote:

Merge this into `sse2avx.c` using `-x assembler`

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] [mlir] Don't emit relax relocs like R_X86_64_REX_GOTPCRELX on X86 target for OPENMP internal vars. (PR #75564)

2024-07-11 Thread via cfe-commits

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


[clang] e0d66c2 - [C++20] [Modules] Allow export redeclarations within language linkage

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

Author: Chuanqi Xu
Date: 2024-07-12T13:55:56+08:00
New Revision: e0d66c242462d63d99a5324f9799ae5f84f2d84f

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

LOG: [C++20] [Modules] Allow export redeclarations within language linkage

Close https://github.com/llvm/llvm-project/issues/98583

Currently, clang will reject the following code:

```
export module mod;
extern "C++" void func();
export extern "C++" {
void func();
}
```

while both MSVC and GCC accept it. Although clang's behavior matches the
current wording, from the discussion, the consensus is that we should
accept the above example from the intention. Since the intention to not
allow export redeclaration which is not exported is to make the linkage
clear. But it doesn't matter with the declarations within global module.

Added: 
clang/test/Modules/export-redecl-in-language-linkage.cppm

Modified: 
clang/lib/Sema/SemaDecl.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index e3377bef2adeb..80b5a8cd4bae6 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -1676,6 +1676,15 @@ bool Sema::CheckRedeclarationExported(NamedDecl *New, 
NamedDecl *Old) {
   if (IsOldExported)
 return false;
 
+  // If the Old declaration are not attached to named modules
+  // and the New declaration are attached to global module.
+  // It should be fine to allow the export since it doesn't change
+  // the linkage of declarations. See
+  // https://github.com/llvm/llvm-project/issues/98583 for details.
+  if (!Old->isInNamedModule() && New->getOwningModule() &&
+  New->getOwningModule()->isImplicitGlobalModule())
+return false;
+
   assert(IsNewExported);
 
   auto Lk = Old->getFormalLinkage();

diff  --git a/clang/test/Modules/export-redecl-in-language-linkage.cppm 
b/clang/test/Modules/export-redecl-in-language-linkage.cppm
new file mode 100644
index 0..c6a4932f5b071
--- /dev/null
+++ b/clang/test/Modules/export-redecl-in-language-linkage.cppm
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -std=c++20 %s -verify -fsyntax-only
+
+// expected-no-diagnostics
+export module mod;
+extern "C++" void func();
+export extern "C++" {
+void func();
+}



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][driver] Fix -print-libgcc-file-name on Darwin platforms (PR #98325)

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


@@ -0,0 +1,27 @@
+// RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name \
+// RUN: --target=armv7em-apple-darwin \
+// RUN: -resource-dir=%S/Inputs/resource_dir 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-HARD_STATIC %s
+// CHECK-CLANGRT-HARD_STATIC: libclang_rt.hard_static.a
+
+// RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name \
+// RUN: --target=armv7em-apple-darwin -msoft-float \
+// RUN: -resource-dir=%S/Inputs/resource_dir 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-SOFT_STATIC %s
+// CHECK-CLANGRT-SOFT_STATIC: libclang_rt.soft_static.a
+
+// RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name \
+// RUN: --target=armv7em-apple-darwin -fPIC \
+// RUN: -resource-dir=%S/Inputs/resource_dir 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-HARD_PIC %s
+// CHECK-CLANGRT-HARD_PIC: libclang_rt.hard_pic.a
+
+// RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name \
+// RUN: --target=armv7em-apple-darwin -msoft-float -fPIC \
+// RUN: -resource-dir=%S/Inputs/resource_dir 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-CLANGRT-SOFT_PIC %s
+// CHECK-CLANGRT-SOFT_PIC: libclang_rt.soft_pic.a
+
+// FIXME: -print-libgcc-file-name is using the default toolchain
+//so the tests above do not give the right answer yet.
+// XFAIL: *

MaskRay wrote:

We don't usually add `XFAIL: *` tests unless there is a plan to fix it. Are you 
going to fix it?

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


[clang] d384267 - [NFC] [Modules] Introduce 'DeclBase::isInNamedModule' interface

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

Author: Chuanqi Xu
Date: 2024-07-12T13:35:56+08:00
New Revision: d384267ad0d5494832f7f53b888c3968b7e688a8

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

LOG: [NFC] [Modules] Introduce 'DeclBase::isInNamedModule' interface

This patch introduces DeclBase::isInNamedModule API to ease the use
of modules slightly.

Added: 


Modified: 
clang/include/clang/AST/DeclBase.h
clang/lib/AST/Decl.cpp
clang/lib/AST/DeclBase.cpp
clang/lib/Sema/SemaDecl.cpp

Removed: 




diff  --git a/clang/include/clang/AST/DeclBase.h 
b/clang/include/clang/AST/DeclBase.h
index 06ffc2ce09b89..6c711cfe7927b 100644
--- a/clang/include/clang/AST/DeclBase.h
+++ b/clang/include/clang/AST/DeclBase.h
@@ -673,6 +673,9 @@ class alignas(8) Decl {
   /// Whether this declaration comes from explicit global module.
   bool isFromExplicitGlobalModule() const;
 
+  /// Whether this declaration comes from a named module.
+  bool isInNamedModule() const;
+
   /// Return true if this declaration has an attribute which acts as
   /// definition of the entity, such as 'alias' or 'ifunc'.
   bool hasDefiningAttr() const;

diff  --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index ecccab08cbaab..490c4a2fc525c 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -1181,13 +1181,6 @@ Linkage NamedDecl::getLinkageInternal() const {
   .getLinkage();
 }
 
-/// Determine whether D is attached to a named module.
-static bool isInNamedModule(const NamedDecl *D) {
-  if (auto *M = D->getOwningModule())
-return M->isNamedModule();
-  return false;
-}
-
 static bool isExportedFromModuleInterfaceUnit(const NamedDecl *D) {
   // FIXME: Handle isModulePrivate.
   switch (D->getModuleOwnershipKind()) {
@@ -1197,7 +1190,7 @@ static bool isExportedFromModuleInterfaceUnit(const 
NamedDecl *D) {
 return false;
   case Decl::ModuleOwnershipKind::Visible:
   case Decl::ModuleOwnershipKind::VisibleWhenImported:
-return isInNamedModule(D);
+return D->isInNamedModule();
   }
   llvm_unreachable("unexpected module ownership kind");
 }
@@ -1215,7 +1208,7 @@ Linkage NamedDecl::getFormalLinkage() const {
   // [basic.namespace.general]/p2
   //   A namespace is never attached to a named module and never has a name 
with
   //   module linkage.
-  if (isInNamedModule(this) && InternalLinkage == Linkage::External &&
+  if (isInNamedModule() && InternalLinkage == Linkage::External &&
   !isExportedFromModuleInterfaceUnit(
   cast(this->getCanonicalDecl())) &&
   !isa(this))

diff  --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp
index eef946e3aea2e..ef2c57e6204dc 100644
--- a/clang/lib/AST/DeclBase.cpp
+++ b/clang/lib/AST/DeclBase.cpp
@@ -1145,6 +1145,10 @@ bool Decl::isFromExplicitGlobalModule() const {
   return getOwningModule() && getOwningModule()->isExplicitGlobalModule();
 }
 
+bool Decl::isInNamedModule() const {
+  return getOwningModule() && getOwningModule()->isNamedModule();
+}
+
 static Decl::Kind getKind(const Decl *D) { return D->getKind(); }
 static Decl::Kind getKind(const DeclContext *DC) { return DC->getDeclKind(); }
 

diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 66eeaa8e6f777..e3377bef2adeb 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -10094,7 +10094,7 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, 
DeclContext *DC,
 // check at the end of the TU (or when the PMF starts) to see that we
 // have a definition at that point.
 if (isInline && !D.isFunctionDefinition() && getLangOpts().CPlusPlus20 &&
-NewFD->hasOwningModule() && NewFD->getOwningModule()->isNamedModule()) 
{
+NewFD->isInNamedModule()) {
   PendingInlineFuncDecls.insert(NewFD);
 }
   }



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Fix parsing of invalid type-requirement (PR #98545)

2024-07-11 Thread Younan Zhang via cfe-commits

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

Thanks! This makes sense to me.
(Curiously GCC and MSVC seem to defer the check until the evaluation. However, 
I don't think we have to do that in this patch anyway.)

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


[clang] [Clang] Fix parsing of invalid type-requirement (PR #98545)

2024-07-11 Thread Younan Zhang via cfe-commits

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


[clang] [Clang] Fix parsing of invalid type-requirement (PR #98545)

2024-07-11 Thread Younan Zhang via cfe-commits


@@ -11698,6 +11698,13 @@ Sema::ActOnTypenameType(Scope *S, SourceLocation 
TypenameLoc,
 // Construct a dependent template specialization type.
 assert(DTN && "dependent template has non-dependent name?");
 assert(DTN->getQualifier() == SS.getScopeRep());
+

zyn0217 wrote:

nit: it would be clearer if we add a comment saying that a typename-specifier 
can only be followed by an identifier/simple-template-id. (Maybe quote 
https://eel.is/c++draft/temp.res.general#nt:typename-specifier?)

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


[clang] [Clang][Parse] Fix ambiguity with nested-name-specifiers that may declarative (PR #96364)

2024-07-11 Thread Matheus Izvekov via cfe-commits

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


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


[clang] [HLSL] Split out resource class data from resource attribute (PR #98419)

2024-07-11 Thread Damyan Pepper via cfe-commits


@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -o - %s -verify
+
+// expected-error@+1{{'resource_class' attribute takes one argument}}
+struct [[hlsl::resource_class()]] Eg1 {
+  int i;  
+};
+
+Eg1 e1;
+
+// expected-error@+1{{invalid resource class 'gibberish' used; expected 'SRV', 
'UAV', 'CBuffer', or 'Sampler'}}
+struct [[hlsl::resource_class(gibberish)]] Eg2 {
+  int i;  
+};
+
+Eg2 e2;
+
+RWBuffer In : register(u1);
+
+
+[numthreads(1,1,1)]
+void main() {
+  In[0] = e1.i + e2.i;
+}

damyanp wrote:

Sounds like it is trying to do codegen, which I think we don't need for these 
tests?

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


[clang] [clang-format] Fix a bug in TCAS_Leave using tabs for indentation (PR #98427)

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

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`openmp-offload-sles-build-only` running on `rocm-worker-hw-04-sles` while 
building `clang` at step 8 "Add check check-llvm".

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

Here is the relevant piece of the build log for the reference:
```
Step 8 (Add check check-llvm) failure: test (failure)
 TEST 'LLVM :: 
ExecutionEngine/OrcLazy/multiple-compile-threads-basic.ll' FAILED 

Exit Code: 2

Command Output (stderr):
--
RUN: at line 1: 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/lli 
-jit-kind=orc-lazy -compile-threads=2 -thread-entry hello 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/llvm/test/ExecutionEngine/OrcLazy/multiple-compile-threads-basic.ll
 | 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/FileCheck 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/llvm/test/ExecutionEngine/OrcLazy/multiple-compile-threads-basic.ll
+ 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/FileCheck 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/llvm/test/ExecutionEngine/OrcLazy/multiple-compile-threads-basic.ll
+ /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/lli 
-jit-kind=orc-lazy -compile-threads=2 -thread-entry hello 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/llvm/test/ExecutionEngine/OrcLazy/multiple-compile-threads-basic.ll
lli: 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/llvm/include/llvm/ExecutionEngine/Orc/SymbolStringPool.h:282:
 llvm::orc::SymbolStringPool::~SymbolStringPool(): Assertion `Pool.empty() && 
"Dangling references at pool destruction time"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and 
include the crash backtrace.
Stack dump:
0.  Program arguments: 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/lli 
-jit-kind=orc-lazy -compile-threads=2 -thread-entry hello 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/llvm/test/ExecutionEngine/OrcLazy/multiple-compile-threads-basic.ll
 #0 0x016852d8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) 
(/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/lli+0x16852d8)
 #1 0x016827ec SignalHandler(int) Signals.cpp:0:0
 #2 0x7f904d34d910 __restore_rt (/lib64/libpthread.so.0+0x16910)
 #3 0x7f904cc7bd2b raise (/lib64/libc.so.6+0x4ad2b)
 #4 0x7f904cc7d3e5 abort (/lib64/libc.so.6+0x4c3e5)
 #5 0x7f904cc73c6a __assert_fail_base (/lib64/libc.so.6+0x42c6a)
 #6 0x7f904cc73cf2 (/lib64/libc.so.6+0x42cf2)
 #7 0x007b2c9b 
(/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/lli+0x7b2c9b)
 #8 0x01218e21 
llvm::orc::ExecutorProcessControl::~ExecutorProcessControl() 
(/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/lli+0x1218e21)
 #9 0x01218fc4 
llvm::orc::SelfExecutorProcessControl::~SelfExecutorProcessControl() 
(/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/lli+0x1218fc4)
#10 0x01150329 llvm::orc::ExecutionSession::~ExecutionSession() 
(/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/lli+0x1150329)
#11 0x011b31a9 llvm::orc::LLJIT::~LLJIT() 
(/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/lli+0x11b31a9)
#12 0x011b32b4 llvm::orc::LLLazyJIT::~LLLazyJIT() 
(/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/lli+0x11b32b4)
#13 0x007bc4b6 runOrcJIT(char const*) 
(/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/lli+0x7bc4b6)
#14 0x007489bb main 
(/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/lli+0x7489bb)
#15 0x7f904cc6624d __libc_start_main (/lib64/libc.so.6+0x3524d)
#16 0x007aa04a _start 
/home/abuild/rpmbuild/BUILD/glibc-2.31/csu/../sysdeps/x86_64/start.S:122:0
FileCheck error: '' is empty.
FileCheck command line:  
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/FileCheck 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/llvm/test/ExecutionEngine/OrcLazy/multiple-compile-threads-basic.ll

--




```

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


[clang] [llvm] [X86][MC] Added support for -msse2avx option in llvm-mc (PR #96860)

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

https://github.com/KanRobert deleted 
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] Added support for -msse2avx option in llvm-mc (PR #96860)

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


@@ -3745,7 +3749,27 @@ bool X86AsmParser::ParseInstruction(ParseInstructionInfo 
&Info, StringRef Name,
   return false;
 }
 
+static void replaceSSE2AVXOpcode(MCInst &Inst) {
+  ArrayRef Table{X86SSE2AVXTable};
+  unsigned Opcode = Inst.getOpcode();
+  const auto I = llvm::lower_bound(Table, Opcode);
+  if (I != Table.end() && I->OldOpc == Opcode)
+Inst.setOpcode(I->NewOpc);

KanRobert wrote:

return true;

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] Added support for -msse2avx option in llvm-mc (PR #96860)

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


@@ -3745,7 +3749,27 @@ bool X86AsmParser::ParseInstruction(ParseInstructionInfo 
&Info, StringRef Name,
   return false;
 }
 
+static void replaceSSE2AVXOpcode(MCInst &Inst) {
+  ArrayRef Table{X86SSE2AVXTable};
+  unsigned Opcode = Inst.getOpcode();
+  const auto I = llvm::lower_bound(Table, Opcode);
+  if (I != Table.end() && I->OldOpc == Opcode)
+Inst.setOpcode(I->NewOpc);
+
+  if (X86::isBLENDVPD(Opcode) || X86::isBLENDVPS(Opcode) ||
+  X86::isPBLENDVB(Opcode)) {
+unsigned RegNo = Inst.getOperand(2).getReg();
+Inst.addOperand(MCOperand::createReg(RegNo));
+  }
+}
+
 bool X86AsmParser::processInstruction(MCInst &Inst, const OperandVector &Ops) {
+  // When "-msse2avx" option is enabled replaceSSE2AVXOpcode method will
+  // replace SSE instruction with equivalent AVX instruction using mapping 
given
+  // in table GET_X86_SSE2AVX_TABLE
+  if (MCOptions.X86Sse2Avx)
+replaceSSE2AVXOpcode(Inst);

KanRobert wrote:

This function should have a boolean return value, so that we can early bail out.

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] [clang-format] Fix a bug in TCAS_Leave using tabs for indentation (PR #98427)

2024-07-11 Thread Owen Pan via cfe-commits

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


[clang] dcf6b7a - [clang-format] Fix a bug in TCAS_Leave using tabs for indentation (#98427)

2024-07-11 Thread via cfe-commits

Author: Owen Pan
Date: 2024-07-11T19:36:42-07:00
New Revision: dcf6b7a8ea9a9be04dd66d20e4a7c55cd0f50a11

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

LOG: [clang-format] Fix a bug in TCAS_Leave using tabs for indentation (#98427)

Fixes #92530.

Added: 


Modified: 
clang/lib/Format/WhitespaceManager.cpp
clang/unittests/Format/FormatTestComments.cpp

Removed: 




diff  --git a/clang/lib/Format/WhitespaceManager.cpp 
b/clang/lib/Format/WhitespaceManager.cpp
index 50531aee9d597..a31874a7c3195 100644
--- a/clang/lib/Format/WhitespaceManager.cpp
+++ b/clang/lib/Format/WhitespaceManager.cpp
@@ -1116,7 +1116,7 @@ void WhitespaceManager::alignTrailingComments() {
   // leave the comments.
   if (RestoredLineLength >= Style.ColumnLimit && Style.ColumnLimit > 0)
 break;
-  C.Spaces = OriginalSpaces;
+  C.Spaces = C.NewlinesBefore > 0 ? C.Tok->OriginalColumn : OriginalSpaces;
   continue;
 }
 

diff  --git a/clang/unittests/Format/FormatTestComments.cpp 
b/clang/unittests/Format/FormatTestComments.cpp
index 3e75707a9faec..8f84d59cbb2e2 100644
--- a/clang/unittests/Format/FormatTestComments.cpp
+++ b/clang/unittests/Format/FormatTestComments.cpp
@@ -3145,6 +3145,23 @@ TEST_F(FormatTestComments, AlignTrailingCommentsLeave) {
"int bar = 1234;   // This is a very long comment\n"
"  // which is wrapped arround.",
Style));
+
+  Style = getLLVMStyle();
+  Style.AlignTrailingComments.Kind = FormatStyle::TCAS_Leave;
+  Style.TabWidth = 2;
+  Style.UseTab = FormatStyle::UT_ForIndentation;
+  verifyNoChange("{\n"
+ "\t// f\n"
+ "\tf();\n"
+ "\n"
+ "\t// g\n"
+ "\tg();\n"
+ "\t{\n"
+ "\t\t// h();  // h\n"
+ "\t\tfoo();  // foo\n"
+ "\t}\n"
+ "}",
+ Style);
 }
 
 TEST_F(FormatTestComments, DontAlignNamespaceComments) {



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [X86][MC] Added support for -msse2avx option in llvm-mc (PR #96860)

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


@@ -140,6 +141,10 @@ 
llvm::mc::RegisterMCTargetOptionsFlags::RegisterMCTargetOptionsFlags() {
   cl::init(true));
   MCBINDOPT(X86RelaxRelocations);
 
+  static cl::opt X86Sse2Avx(
+  "x86-sse2avx", cl::desc("Convert SSE Instructions to AVX Instructions"));

KanRobert wrote:

Use the same help info as driver and GNU assembler.

Specify that the assembler should encode SSE instructions with VEX prefix

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] Added support for -msse2avx option in llvm-mc (PR #96860)

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


@@ -8367,6 +8369,9 @@ void ClangAs::AddX86TargetArgs(const ArgList &Args,
   addX86AlignBranchArgs(getToolChain().getDriver(), Args, CmdArgs,
 /*IsLTO=*/false);
 
+  if (Args.hasArg(options::OPT_msse2avx))
+Args.AddLastArg(CmdArgs, options::OPT_msse2avx);
+

KanRobert wrote:

Remove this?

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] Added support for -msse2avx option in llvm-mc (PR #96860)

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


@@ -3745,7 +3749,27 @@ bool X86AsmParser::ParseInstruction(ParseInstructionInfo 
&Info, StringRef Name,
   return false;
 }
 
+static void replaceSSE2AVXOpcode(MCInst &Inst) {
+  ArrayRef Table{X86SSE2AVXTable};
+  unsigned Opcode = Inst.getOpcode();
+  const auto I = llvm::lower_bound(Table, Opcode);
+  if (I != Table.end() && I->OldOpc == Opcode)
+Inst.setOpcode(I->NewOpc);
+
+  if (X86::isBLENDVPD(Opcode) || X86::isBLENDVPS(Opcode) ||
+  X86::isPBLENDVB(Opcode)) {
+unsigned RegNo = Inst.getOperand(2).getReg();
+Inst.addOperand(MCOperand::createReg(RegNo));
+  }
+}
+
 bool X86AsmParser::processInstruction(MCInst &Inst, const OperandVector &Ops) {
+  // When "-msse2avx" option is enabled replaceSSE2AVXOpcode method will
+  // replace SSE instruction with equivalent AVX instruction using mapping 
given
+  // in table GET_X86_SSE2AVX_TABLE
+  if (MCOptions.X86Sse2Avx)
+replaceSSE2AVXOpcode(Inst);

KanRobert wrote:

```suggestion
convertSSEToAVX(Inst);
```

convert A to B
replace A with B

Remove the Opcode suffix b./c it's misleading. We also add new operands to the 
instruction for some cases.

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] Added support for -msse2avx option in llvm-mc (PR #96860)

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


@@ -3745,7 +3749,27 @@ bool X86AsmParser::ParseInstruction(ParseInstructionInfo 
&Info, StringRef Name,
   return false;
 }
 
+static void replaceSSE2AVXOpcode(MCInst &Inst) {
+  ArrayRef Table{X86SSE2AVXTable};
+  unsigned Opcode = Inst.getOpcode();
+  const auto I = llvm::lower_bound(Table, Opcode);
+  if (I != Table.end() && I->OldOpc == Opcode)
+Inst.setOpcode(I->NewOpc);
+
+  if (X86::isBLENDVPD(Opcode) || X86::isBLENDVPS(Opcode) ||
+  X86::isPBLENDVB(Opcode)) {
+unsigned RegNo = Inst.getOperand(2).getReg();
+Inst.addOperand(MCOperand::createReg(RegNo));
+  }
+}
+
 bool X86AsmParser::processInstruction(MCInst &Inst, const OperandVector &Ops) {
+  // When "-msse2avx" option is enabled replaceSSE2AVXOpcode method will
+  // replace SSE instruction with equivalent AVX instruction using mapping 
given
+  // in table GET_X86_SSE2AVX_TABLE

KanRobert wrote:

Drop this comment. The code is self-explained and the comment is confusing. (We 
have different options names for the sse2avx opt, so it's strange to mention 
the driver option only. And the table name is not called GET_X86_SSE2AVX_TABLE.)

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] [CUDA][HIP] Fix template static member (PR #98580)

2024-07-11 Thread Yaxun Liu via cfe-commits

yxsamliu wrote:

sorry for the trouble. It is the same change but rebased to main branch.

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


[clang] [CUDA][HIP] Fix template static member (PR #98580)

2024-07-11 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Yaxun (Sam) Liu (yxsamliu)


Changes

Should check host/device attributes before emitting static member of template 
instantiation.

Fixes: https://github.com/llvm/llvm-project/issues/98151

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


2 Files Affected:

- (modified) clang/lib/CodeGen/CodeGenModule.cpp (+2-1) 
- (added) clang/test/CodeGenCUDA/template-class-static-member.cu (+50) 


``diff
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 6c10b4a2edef8..599e20634bf72 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -5935,7 +5935,8 @@ static void 
ReplaceUsesOfNonProtoTypeWithRealFunction(llvm::GlobalValue *Old,
 
 void CodeGenModule::HandleCXXStaticMemberVarInstantiation(VarDecl *VD) {
   auto DK = VD->isThisDeclarationADefinition();
-  if (DK == VarDecl::Definition && VD->hasAttr())
+  if ((DK == VarDecl::Definition && VD->hasAttr()) ||
+  (LangOpts.CUDA && !shouldEmitCUDAGlobalVar(VD)))
 return;
 
   TemplateSpecializationKind TSK = VD->getTemplateSpecializationKind();
diff --git a/clang/test/CodeGenCUDA/template-class-static-member.cu 
b/clang/test/CodeGenCUDA/template-class-static-member.cu
new file mode 100644
index 0..d790d2dea66ba
--- /dev/null
+++ b/clang/test/CodeGenCUDA/template-class-static-member.cu
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device \
+// RUN:   -emit-llvm -o - -x hip %s | FileCheck -check-prefix=DEV %s
+
+// RUN: %clang_cc1 -triple x86_64-gnu-linux -std=c++11 \
+// RUN:   -emit-llvm -o - -x hip %s | FileCheck -check-prefix=HOST %s
+
+// Negative tests.
+
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device \
+// RUN:   -emit-llvm -o - -x hip %s | FileCheck -check-prefix=DEV-NEG %s
+
+#include "Inputs/cuda.h"
+
+template 
+class A {
+static int h_member;
+__device__ static int d_member;
+__constant__ static int c_member;
+__managed__ static int m_member;
+const static int const_member = 0;
+};
+
+template 
+int A::h_member;
+
+template 
+__device__ int A::d_member;
+
+template 
+__constant__ int A::c_member;
+
+template 
+__managed__ int A::m_member;
+
+template 
+const int A::const_member;
+
+template class A;
+
+//DEV-DAG: @_ZN1AIiE8d_memberE = internal addrspace(1) global i32 0, comdat, 
align 4
+//DEV-DAG: @_ZN1AIiE8c_memberE = internal addrspace(4) global i32 0, comdat, 
align 4
+//DEV-DAG: @_ZN1AIiE8m_memberE = internal addrspace(1) externally_initialized 
global ptr addrspace(1) null
+//DEV-DAG: @_ZN1AIiE12const_memberE = internal addrspace(4) constant i32 0, 
comdat, align 4
+//DEV-NEG-NOT: @_ZN1AIiE8h_memberE
+
+//HOST-DAG: @_ZN1AIiE8h_memberE = weak_odr global i32 0, comdat, align 4
+//HOST-DAG: @_ZN1AIiE8d_memberE = internal global i32 undef, comdat, align 4
+//HOST-DAG: @_ZN1AIiE8c_memberE = internal global i32 undef, comdat, align 4
+//HOST-DAG: @_ZN1AIiE8m_memberE = internal externally_initialized global ptr 
null
+//HOST-DAG: @_ZN1AIiE12const_memberE = weak_odr constant i32 0, comdat, align 4

``




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


[clang] [CUDA][HIP] Fix template static member (PR #98580)

2024-07-11 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-codegen

Author: Yaxun (Sam) Liu (yxsamliu)


Changes

Should check host/device attributes before emitting static member of template 
instantiation.

Fixes: https://github.com/llvm/llvm-project/issues/98151

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


2 Files Affected:

- (modified) clang/lib/CodeGen/CodeGenModule.cpp (+2-1) 
- (added) clang/test/CodeGenCUDA/template-class-static-member.cu (+50) 


``diff
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 6c10b4a2edef8..599e20634bf72 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -5935,7 +5935,8 @@ static void 
ReplaceUsesOfNonProtoTypeWithRealFunction(llvm::GlobalValue *Old,
 
 void CodeGenModule::HandleCXXStaticMemberVarInstantiation(VarDecl *VD) {
   auto DK = VD->isThisDeclarationADefinition();
-  if (DK == VarDecl::Definition && VD->hasAttr())
+  if ((DK == VarDecl::Definition && VD->hasAttr()) ||
+  (LangOpts.CUDA && !shouldEmitCUDAGlobalVar(VD)))
 return;
 
   TemplateSpecializationKind TSK = VD->getTemplateSpecializationKind();
diff --git a/clang/test/CodeGenCUDA/template-class-static-member.cu 
b/clang/test/CodeGenCUDA/template-class-static-member.cu
new file mode 100644
index 0..d790d2dea66ba
--- /dev/null
+++ b/clang/test/CodeGenCUDA/template-class-static-member.cu
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device \
+// RUN:   -emit-llvm -o - -x hip %s | FileCheck -check-prefix=DEV %s
+
+// RUN: %clang_cc1 -triple x86_64-gnu-linux -std=c++11 \
+// RUN:   -emit-llvm -o - -x hip %s | FileCheck -check-prefix=HOST %s
+
+// Negative tests.
+
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device \
+// RUN:   -emit-llvm -o - -x hip %s | FileCheck -check-prefix=DEV-NEG %s
+
+#include "Inputs/cuda.h"
+
+template 
+class A {
+static int h_member;
+__device__ static int d_member;
+__constant__ static int c_member;
+__managed__ static int m_member;
+const static int const_member = 0;
+};
+
+template 
+int A::h_member;
+
+template 
+__device__ int A::d_member;
+
+template 
+__constant__ int A::c_member;
+
+template 
+__managed__ int A::m_member;
+
+template 
+const int A::const_member;
+
+template class A;
+
+//DEV-DAG: @_ZN1AIiE8d_memberE = internal addrspace(1) global i32 0, comdat, 
align 4
+//DEV-DAG: @_ZN1AIiE8c_memberE = internal addrspace(4) global i32 0, comdat, 
align 4
+//DEV-DAG: @_ZN1AIiE8m_memberE = internal addrspace(1) externally_initialized 
global ptr addrspace(1) null
+//DEV-DAG: @_ZN1AIiE12const_memberE = internal addrspace(4) constant i32 0, 
comdat, align 4
+//DEV-NEG-NOT: @_ZN1AIiE8h_memberE
+
+//HOST-DAG: @_ZN1AIiE8h_memberE = weak_odr global i32 0, comdat, align 4
+//HOST-DAG: @_ZN1AIiE8d_memberE = internal global i32 undef, comdat, align 4
+//HOST-DAG: @_ZN1AIiE8c_memberE = internal global i32 undef, comdat, align 4
+//HOST-DAG: @_ZN1AIiE8m_memberE = internal externally_initialized global ptr 
null
+//HOST-DAG: @_ZN1AIiE12const_memberE = weak_odr constant i32 0, comdat, align 4

``




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


[clang] [CUDA][HIP] Fix template static member (PR #98580)

2024-07-11 Thread Yaxun Liu via cfe-commits

https://github.com/yxsamliu created 
https://github.com/llvm/llvm-project/pull/98580

Should check host/device attributes before emitting static member of template 
instantiation.

Fixes: https://github.com/llvm/llvm-project/issues/98151

>From ba7ab88308c5af2e1c5e6c841524a932c42afeb2 Mon Sep 17 00:00:00 2001
From: "Yaxun (Sam) Liu" 
Date: Thu, 11 Jul 2024 13:32:54 -0400
Subject: [PATCH] [CUDA][HIP] Fix template static member

Should check host/device attributes before emitting static member
of template instantiation.

Fixes: https://github.com/llvm/llvm-project/issues/98151
---
 clang/lib/CodeGen/CodeGenModule.cpp   |  3 +-
 .../template-class-static-member.cu   | 50 +++
 2 files changed, 52 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/CodeGenCUDA/template-class-static-member.cu

diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 6c10b4a2edef8..599e20634bf72 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -5935,7 +5935,8 @@ static void 
ReplaceUsesOfNonProtoTypeWithRealFunction(llvm::GlobalValue *Old,
 
 void CodeGenModule::HandleCXXStaticMemberVarInstantiation(VarDecl *VD) {
   auto DK = VD->isThisDeclarationADefinition();
-  if (DK == VarDecl::Definition && VD->hasAttr())
+  if ((DK == VarDecl::Definition && VD->hasAttr()) ||
+  (LangOpts.CUDA && !shouldEmitCUDAGlobalVar(VD)))
 return;
 
   TemplateSpecializationKind TSK = VD->getTemplateSpecializationKind();
diff --git a/clang/test/CodeGenCUDA/template-class-static-member.cu 
b/clang/test/CodeGenCUDA/template-class-static-member.cu
new file mode 100644
index 0..d790d2dea66ba
--- /dev/null
+++ b/clang/test/CodeGenCUDA/template-class-static-member.cu
@@ -0,0 +1,50 @@
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device \
+// RUN:   -emit-llvm -o - -x hip %s | FileCheck -check-prefix=DEV %s
+
+// RUN: %clang_cc1 -triple x86_64-gnu-linux -std=c++11 \
+// RUN:   -emit-llvm -o - -x hip %s | FileCheck -check-prefix=HOST %s
+
+// Negative tests.
+
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device \
+// RUN:   -emit-llvm -o - -x hip %s | FileCheck -check-prefix=DEV-NEG %s
+
+#include "Inputs/cuda.h"
+
+template 
+class A {
+static int h_member;
+__device__ static int d_member;
+__constant__ static int c_member;
+__managed__ static int m_member;
+const static int const_member = 0;
+};
+
+template 
+int A::h_member;
+
+template 
+__device__ int A::d_member;
+
+template 
+__constant__ int A::c_member;
+
+template 
+__managed__ int A::m_member;
+
+template 
+const int A::const_member;
+
+template class A;
+
+//DEV-DAG: @_ZN1AIiE8d_memberE = internal addrspace(1) global i32 0, comdat, 
align 4
+//DEV-DAG: @_ZN1AIiE8c_memberE = internal addrspace(4) global i32 0, comdat, 
align 4
+//DEV-DAG: @_ZN1AIiE8m_memberE = internal addrspace(1) externally_initialized 
global ptr addrspace(1) null
+//DEV-DAG: @_ZN1AIiE12const_memberE = internal addrspace(4) constant i32 0, 
comdat, align 4
+//DEV-NEG-NOT: @_ZN1AIiE8h_memberE
+
+//HOST-DAG: @_ZN1AIiE8h_memberE = weak_odr global i32 0, comdat, align 4
+//HOST-DAG: @_ZN1AIiE8d_memberE = internal global i32 undef, comdat, align 4
+//HOST-DAG: @_ZN1AIiE8c_memberE = internal global i32 undef, comdat, align 4
+//HOST-DAG: @_ZN1AIiE8m_memberE = internal externally_initialized global ptr 
null
+//HOST-DAG: @_ZN1AIiE12const_memberE = weak_odr constant i32 0, comdat, align 4

___
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-11 Thread Yuxuan Chen via cfe-commits

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

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

---
 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   | 84 +++
 ...a-attribute-supported-attributes-list.test |  1 +
 llvm/include/llvm/IR/Intrinsics.td|  3 +
 .../lib/Transforms/Coroutines/CoroCleanup.cpp |  9 +-
 llvm/lib/Transforms/Coroutines/CoroElide.cpp  | 58 -
 llvm/lib/Transforms/Coroutines/Coroutines.cpp |  1 +
 .../coro-elide-structured-concurrency.ll  | 64 ++
 25 files changed, 496 insertions(+), 134 deletions(-)
 create mode 100644 clang/test/CodeGenCoroutines/Inputs/utility.h
 create mode 100644 clang/test/CodeGenCoroutines/coro-structured-concurrency.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 : public CoroutineSuspendExpr {
 public:
   CoawaitExpr(SourceLocation CoawaitLoc, Expr *Operand, Expr *Common,
   Expr *Ready, Expr *Suspend, Expr *Resume,
-  OpaqueValueExpr *OpaqueValue, bool IsImplicit = false)
+  OpaqueValueExpr *CommonExprOpaqueValue, bool IsImplicit = false)
   : CoroutineSuspendExpr(CoawaitExprClass, CoawaitLoc, Operand, Common,
- Ready, Suspend, Resume, OpaqueValue) {
+ Ready, Suspend, Resume, CommonExprOpaqueValue) {
 CoawaitBits.IsImplicit = IsImplicit;
   }
 
@@ -5275,9 +5285,9 @@ class CoyieldExpr : public CoroutineSuspendExpr {
 public:
   CoyieldExpr(SourceLocation CoyieldLoc, Expr *Operand, Expr *Common,
   Expr *Ready, Expr *Suspend, Expr *Resume,
-  OpaqueValueExpr *OpaqueValue)
+  OpaqueValueExpr *CommonExprOpaqueValue)
   : CoroutineSuspendExpr(CoyieldExprClass, CoyieldLoc, Operand, Common,
-  

[clang] [CUDA][HIP][NFC] add CodeGenModule::shouldEmitCUDAGlobalVar (PR #98543)

2024-07-11 Thread Yaxun Liu via cfe-commits

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


[clang] 90abdf8 - [CUDA][HIP][NFC] add CodeGenModule::shouldEmitCUDAGlobalVar (#98543)

2024-07-11 Thread via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2024-07-11T21:52:04-04:00
New Revision: 90abdf83e273586a43e1270e5f0a11de5cc35383

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

LOG: [CUDA][HIP][NFC] add CodeGenModule::shouldEmitCUDAGlobalVar (#98543)

Extract the logic whether to emit a global var based on CUDA/HIP
host/device related attributes to CodeGenModule::shouldEmitCUDAGlobalVar
to be used by other places.

Added: 


Modified: 
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/CodeGen/CodeGenModule.h

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 5c810cd332185..6c10b4a2edef8 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -3702,6 +3702,19 @@ template  static bool 
hasImplicitAttr(const ValueDecl *D) {
   return D->isImplicit();
 }
 
+bool CodeGenModule::shouldEmitCUDAGlobalVar(const VarDecl *Global) const {
+  assert(LangOpts.CUDA && "Should not be called by non-CUDA languages");
+  // We need to emit host-side 'shadows' for all global
+  // device-side variables because the CUDA runtime needs their
+  // size and host-side address in order to provide access to
+  // their device-side incarnations.
+  return !LangOpts.CUDAIsDevice || Global->hasAttr() ||
+ Global->hasAttr() ||
+ Global->hasAttr() ||
+ Global->getType()->isCUDADeviceBuiltinSurfaceType() ||
+ Global->getType()->isCUDADeviceBuiltinTextureType();
+}
+
 void CodeGenModule::EmitGlobal(GlobalDecl GD) {
   const auto *Global = cast(GD.getDecl());
 
@@ -3726,36 +3739,27 @@ void CodeGenModule::EmitGlobal(GlobalDecl GD) {
   // Non-constexpr non-lambda implicit host device functions are not emitted
   // unless they are used on device side.
   if (LangOpts.CUDA) {
-if (LangOpts.CUDAIsDevice) {
+assert((isa(Global) || isa(Global)) &&
+   "Expected Variable or Function");
+if (const auto *VD = dyn_cast(Global)) {
+  if (!shouldEmitCUDAGlobalVar(VD))
+return;
+} else if (LangOpts.CUDAIsDevice) {
   const auto *FD = dyn_cast(Global);
   if ((!Global->hasAttr() ||
-   (LangOpts.OffloadImplicitHostDeviceTemplates && FD &&
+   (LangOpts.OffloadImplicitHostDeviceTemplates &&
 hasImplicitAttr(FD) &&
 hasImplicitAttr(FD) && !FD->isConstexpr() &&
 !isLambdaCallOperator(FD) &&
 !getContext().CUDAImplicitHostDeviceFunUsedByDevice.count(FD))) &&
   !Global->hasAttr() &&
-  !Global->hasAttr() &&
-  !Global->hasAttr() &&
-  !Global->getType()->isCUDADeviceBuiltinSurfaceType() &&
-  !Global->getType()->isCUDADeviceBuiltinTextureType() &&
   !(LangOpts.HIPStdPar && isa(Global) &&
 !Global->hasAttr()))
 return;
-} else {
-  // We need to emit host-side 'shadows' for all global
-  // device-side variables because the CUDA runtime needs their
-  // size and host-side address in order to provide access to
-  // their device-side incarnations.
-
-  // So device-only functions are the only things we skip.
-  if (isa(Global) && !Global->hasAttr() &&
-  Global->hasAttr())
-return;
-
-  assert((isa(Global) || isa(Global)) &&
- "Expected Variable or Function");
-}
+  // Device-only functions are the only things we skip.
+} else if (!Global->hasAttr() &&
+   Global->hasAttr())
+  return;
   }
 
   if (LangOpts.OpenMP) {

diff  --git a/clang/lib/CodeGen/CodeGenModule.h 
b/clang/lib/CodeGen/CodeGenModule.h
index 585c4ea697fea..caa3786c033b5 100644
--- a/clang/lib/CodeGen/CodeGenModule.h
+++ b/clang/lib/CodeGen/CodeGenModule.h
@@ -563,6 +563,9 @@ class CodeGenModule : public CodeGenTypeCache {
 
   bool isTriviallyRecursive(const FunctionDecl *F);
   bool shouldEmitFunction(GlobalDecl GD);
+  // Whether a global variable should be emitted by CUDA/HIP host/device
+  // related attributes.
+  bool shouldEmitCUDAGlobalVar(const VarDecl *VD) const;
   bool shouldOpportunisticallyEmitVTables();
   /// Map used to be sure we don't emit the same CompoundLiteral twice.
   llvm::DenseMap



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Ensure the method scope at the late parsing of noexcept specifiers (PR #98023)

2024-07-11 Thread Younan Zhang via cfe-commits

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


[clang] f52a467 - [Clang] Ensure the method scope at the late parsing of noexcept specifiers (#98023)

2024-07-11 Thread via cfe-commits

Author: Younan Zhang
Date: 2024-07-12T09:51:46+08:00
New Revision: f52a4679e683807d699e105a6139a5a91401667f

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

LOG: [Clang] Ensure the method scope at the late parsing of noexcept specifiers 
(#98023)

Previously, we only pushed the function scope once we entered the
function definition, whereas tryCaptureVariable() requires at least one
function scope available when ParmVarDecls being captured have been
owned by a function. This led to problems parsing the noexcept
specifiers, as the DeclRefExprs inside them were improperly computed.

Fixes https://github.com/llvm/llvm-project/issues/97453

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Parse/ParseCXXInlineMethods.cpp
clang/test/SemaCXX/cxx0x-noexcept-expression.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index be2f06766a755..e68398c167a23 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1011,7 +1011,7 @@ Bug Fixes to C++ Support
 - Fixed a type constraint substitution issue involving a generic lambda 
expression. (#GH93821)
 - Fix a crash caused by improper use of ``__array_extent``. (#GH80474)
 - Fixed several bugs in capturing variables within unevaluated contexts. 
(#GH63845), (#GH67260), (#GH69307),
-  (#GH88081), (#GH89496), (#GH90669) and (#GH91633).
+  (#GH88081), (#GH89496), (#GH90669), (#GH91633) and (#GH97453).
 - Fixed a crash in constraint instantiation under nested lambdas with 
dependent parameters.
 - Fixed handling of brace ellison when building deduction guides. (#GH64625), 
(#GH83368).
 - Clang now instantiates local constexpr functions eagerly for constant 
evaluators. (#GH35052), (#GH94849)

diff  --git a/clang/lib/Parse/ParseCXXInlineMethods.cpp 
b/clang/lib/Parse/ParseCXXInlineMethods.cpp
index 943ce0fdde3a3..9ccbbf9a7d5d0 100644
--- a/clang/lib/Parse/ParseCXXInlineMethods.cpp
+++ b/clang/lib/Parse/ParseCXXInlineMethods.cpp
@@ -511,11 +511,28 @@ void 
Parser::ParseLexedMethodDeclaration(LateParsedMethodDeclaration &LM) {
 //   and the end of the function-definition, member-declarator, or
 //   declarator.
 CXXMethodDecl *Method;
+FunctionDecl *FunctionToPush;
 if (FunctionTemplateDecl *FunTmpl
   = dyn_cast(LM.Method))
-  Method = dyn_cast(FunTmpl->getTemplatedDecl());
+  FunctionToPush = FunTmpl->getTemplatedDecl();
 else
-  Method = dyn_cast(LM.Method);
+  FunctionToPush = cast(LM.Method);
+Method = dyn_cast(FunctionToPush);
+
+// Push a function scope so that tryCaptureVariable() can properly visit
+// function scopes involving function parameters that are referenced inside
+// the noexcept specifier e.g. through a lambda expression.
+// Example:
+// struct X {
+//   void ICE(int val) noexcept(noexcept([val]{}));
+// };
+// Setup the CurScope to match the function DeclContext - we have such
+// assumption in IsInFnTryBlockHandler().
+ParseScope FnScope(this, Scope::FnScope);
+Sema::ContextRAII FnContext(Actions, FunctionToPush,
+/*NewThisContext=*/false);
+Sema::FunctionScopeRAII PopFnContext(Actions);
+Actions.PushFunctionScope();
 
 Sema::CXXThisScopeRAII ThisScope(
 Actions, Method ? Method->getParent() : nullptr,

diff  --git a/clang/test/SemaCXX/cxx0x-noexcept-expression.cpp 
b/clang/test/SemaCXX/cxx0x-noexcept-expression.cpp
index b9aeffbf034b2..a01edc77e02af 100644
--- a/clang/test/SemaCXX/cxx0x-noexcept-expression.cpp
+++ b/clang/test/SemaCXX/cxx0x-noexcept-expression.cpp
@@ -157,3 +157,21 @@ void f5() {
   // expected-error@-1 {{no member named 'non_existent' in 'typeid_::X'}}
 }
 } // namespace typeid_
+
+namespace GH97453 {
+
+struct UnconstrainedCtor {
+  int value_;
+
+  template 
+  constexpr UnconstrainedCtor(T value) noexcept(noexcept(value_ = value))
+  : value_(static_cast(value)) {}
+};
+
+UnconstrainedCtor U(42);
+
+struct X {
+  void ICE(int that) noexcept(noexcept([that]() {}));
+};
+
+} // namespace GH97453



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Ensure the method scope at the late parsing of noexcept specifiers (PR #98023)

2024-07-11 Thread Younan Zhang via cfe-commits

https://github.com/zyn0217 updated 
https://github.com/llvm/llvm-project/pull/98023

>From 74d7184777e977ab3e83bfcae7e08e550ef32a39 Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Mon, 8 Jul 2024 21:28:30 +0800
Subject: [PATCH 1/5] [Clang] Ensure the method scope at the late parsing of
 noexcept specifiers

---
 clang/docs/ReleaseNotes.rst   |  2 +-
 clang/lib/Parse/ParseCXXInlineMethods.cpp | 15 +--
 .../expr/expr.prim/expr.prim.general/p3-0x.cpp|  5 +++--
 clang/test/CodeGenCXX/mangle-exception-spec.cpp   | 11 +++
 clang/test/SemaCXX/cxx0x-noexcept-expression.cpp  |  8 
 5 files changed, 36 insertions(+), 5 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 838cb69f647ee..b521de4515e1f 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -958,7 +958,7 @@ Bug Fixes to C++ Support
 - Fixed a type constraint substitution issue involving a generic lambda 
expression. (#GH93821)
 - Fix a crash caused by improper use of ``__array_extent``. (#GH80474)
 - Fixed several bugs in capturing variables within unevaluated contexts. 
(#GH63845), (#GH67260), (#GH69307),
-  (#GH88081), (#GH89496), (#GH90669) and (#GH91633).
+  (#GH88081), (#GH89496), (#GH90669), (#GH91633) and (#GH97453).
 - Fixed handling of brace ellison when building deduction guides. (#GH64625), 
(#GH83368).
 - Clang now instantiates local constexpr functions eagerly for constant 
evaluators. (#GH35052), (#GH94849)
 - Fixed a failed assertion when attempting to convert an integer representing 
the difference
diff --git a/clang/lib/Parse/ParseCXXInlineMethods.cpp 
b/clang/lib/Parse/ParseCXXInlineMethods.cpp
index 943ce0fdde3a3..faab9c6b19caa 100644
--- a/clang/lib/Parse/ParseCXXInlineMethods.cpp
+++ b/clang/lib/Parse/ParseCXXInlineMethods.cpp
@@ -511,11 +511,13 @@ void 
Parser::ParseLexedMethodDeclaration(LateParsedMethodDeclaration &LM) {
 //   and the end of the function-definition, member-declarator, or
 //   declarator.
 CXXMethodDecl *Method;
+FunctionDecl *FunctionToPush;
 if (FunctionTemplateDecl *FunTmpl
   = dyn_cast(LM.Method))
-  Method = dyn_cast(FunTmpl->getTemplatedDecl());
+  FunctionToPush = FunTmpl->getTemplatedDecl();
 else
-  Method = dyn_cast(LM.Method);
+  FunctionToPush = cast(LM.Method);
+Method = dyn_cast(FunctionToPush);
 
 Sema::CXXThisScopeRAII ThisScope(
 Actions, Method ? Method->getParent() : nullptr,
@@ -529,6 +531,15 @@ void 
Parser::ParseLexedMethodDeclaration(LateParsedMethodDeclaration &LM) {
 ExprResult NoexceptExpr;
 CachedTokens *ExceptionSpecTokens;
 
+// Push a function scope so that tryCaptureVariable() can properly visit
+// function scopes involving function parameters that are referenced inside
+// the noexcept specifier e.g. through a lambda expression.
+// Example:
+// struct X {
+//   void ICE(int val) noexcept(noexcept([val]{}));
+// };
+Sema::SynthesizedFunctionScope Scope(Actions, FunctionToPush);
+
 ExceptionSpecificationType EST
   = tryParseExceptionSpecification(/*Delayed=*/false, SpecificationRange,
DynamicExceptions,
diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.general/p3-0x.cpp 
b/clang/test/CXX/expr/expr.prim/expr.prim.general/p3-0x.cpp
index b59cc175a1976..d50d05d17ab7a 100644
--- a/clang/test/CXX/expr/expr.prim/expr.prim.general/p3-0x.cpp
+++ b/clang/test/CXX/expr/expr.prim/expr.prim.general/p3-0x.cpp
@@ -113,8 +113,9 @@ namespace Static {
 static auto g() -> decltype(this->m); // expected-error{{'this' cannot be 
used in a static member function declaration}}
 
 static int h();
-
-static int i() noexcept(noexcept(m + 2)); // expected-error{{'this' cannot 
be implicitly used in a static member function declaration}}
+
+// The use of 'm' doesn't constitute an ODR use, so we don't have a reason 
to reject it.
+static int i() noexcept(noexcept(m + 2));
   };
 
   auto X1::h() -> decltype(m) { return 0; } // expected-error{{'this' cannot 
be implicitly used in a static member function declaration}}
diff --git a/clang/test/CodeGenCXX/mangle-exception-spec.cpp 
b/clang/test/CodeGenCXX/mangle-exception-spec.cpp
index 15f7a8b6cb504..1bc268e1b6ca4 100644
--- a/clang/test/CodeGenCXX/mangle-exception-spec.cpp
+++ b/clang/test/CodeGenCXX/mangle-exception-spec.cpp
@@ -47,3 +47,14 @@ template auto i<>(int()) -> int (*)();
 // CHECK-CXX11: define {{.*}} @_Z1iIJfEEPDwiDpT_EFivEPS2_(
 // CHECK-CXX17: define {{.*}} @_Z1iIJfEEPDwiDpT_EFivES3_(
 template auto i(int()) -> int (*)();
+
+template 
+struct X1 {
+  T m;
+  static void j(int (X1::*)() noexcept(noexcept(m + 2)));
+};
+
+void foo() {
+  // CHECK-CXX17: call {{.*}} @_ZN2X1IiE1jEMS0_DoFivE(
+  X1::j(nullptr);
+}
diff --git a/clang/test/SemaCXX/cxx0x-noexcept-expression.cpp 
b/clang/test/SemaCXX/cxx0x-noexcept-expression.cpp
index c616a77f36619..53d2

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

2024-07-11 Thread Younan Zhang via cfe-commits

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

Thank you!

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] [Concepts] Avoid substituting into constraints for invalid TemplateDecls (PR #75697)

2024-07-11 Thread Younan Zhang via cfe-commits

zyn0217 wrote:

Hmmm, actually I'm thinking about whether we can move the check to somewhere in 
Parser so that these don't end up in the evaluation function.

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


[clang] [compiler-rt] [nsan] Add shared runtime (PR #98415)

2024-07-11 Thread via cfe-commits

dyung wrote:

> It still fails to build after a git pull
> 
> ```
> ninja -C build
> ninja: Entering directory `build'
> [1/1] Linking CXX shared library 
> lib/clang/19/lib/x86_64-unknown-linux-gnu/libclang_rt.nsan.so
> FAILED: lib/clang/19/lib/x86_64-unknown-linux-gnu/libclang_rt.nsan.so
> : && /afs/cern.ch/user/i/innocent/w5/bin/g++ -fPIC -fPIC 
> -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time 
> -fno-lifetime-dse -Wall -Wextra -Wno-unused-parameter -Wwrite-strings 
> -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long 
> -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-nonnull 
> -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move 
> -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment 
> -Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color 
> -ffunction-sections -fdata-sections -Wall -Wno-unused-parameter -O3 -DNDEBUG  
> -Wl,-z,defs -Wl,-z,nodelete   -m64 -nodefaultlibs -Wl,-z,text -nostdlib++ 
> -Wl,--version-script,/data/user/innocent/llvm-project/build/projects/compiler-rt/lib/nsan/clang_rt.nsan-dynamic-x86_64.vers
>  -shared -Wl,-soname,libclang_rt.nsan.so -o 
> lib/clang/19/lib/x86_64-unknown-linux-gnu/libclang_rt.nsan.so 
> projects/compiler-rt/lib/interception/CMakeFiles/RTInterception.x86_64.dir/interception_linux.cpp.o
>  
> projects/compiler-rt/lib/interception/CMakeFiles/RTInterception.x86_64.dir/interception_mac.cpp.o
>  
> projects/compiler-rt/lib/interception/CMakeFiles/RTInterception.x86_64.dir/interception_win.cpp.o
>  
> projects/compiler-rt/lib/interception/CMakeFiles/RTInterception.x86_64.dir/interception_type_test.cpp.o
>  
> projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_allocator.cpp.o
>  
> projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_common.cpp.o
>  
> projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_deadlock_detector1.cpp.o
>  
> projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_deadlock_detector2.cpp.o
>  
> projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_errno.cpp.o
>  
> projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_file.cpp.o
>  
> projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_flags.cpp.o
>  
> projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_flag_parser.cpp.o
>  
> projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_fuchsia.cpp.o
>  
> projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_libc.cpp.o
>  
> projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_libignore.cpp.o
>  
> projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_linux.cpp.o
>  
> projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_linux_s390.cpp.o
>  
> projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_mac.cpp.o
>  
> projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_mutex.cpp.o
>  
> projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_netbsd.cpp.o
>  
> projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_platform_limits_freebsd.cpp.o
>  
> projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_platform_limits_linux.cpp.o
>  
> projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_platform_limits_netbsd.cpp.o
>  
> projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_platform_limits_posix.cpp.o
>  
> projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_platform_limits_solaris.cpp.o
>  
> projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_posix.cpp.o
>  
> projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_printf.cpp.o
>  
> projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_procmaps_common.cpp.o
>  
> projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_procmaps_bsd.cpp.o
>  
> projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_procmaps_fuchsia.cpp.o
>  
> projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_procmaps_linux.cpp.o
>  
> projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.x86_64.dir/sanitizer_procmaps_mac.cpp.o
>  
> projects/compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitiz

[clang] [Clang][Parse] Fix ambiguity with nested-name-specifiers that may declarative (PR #96364)

2024-07-11 Thread Krystian Stasiowski via cfe-commits

https://github.com/sdkrystian updated 
https://github.com/llvm/llvm-project/pull/96364

>From ade60c6468cf3aa0b862734d403dffa2733afe3c Mon Sep 17 00:00:00 2001
From: Krystian Stasiowski 
Date: Wed, 12 Jun 2024 14:14:26 -0400
Subject: [PATCH 1/3] [Clang][Parse] Fix ambiguity with nested-name-specifiers
 that may be declarative

---
 clang/include/clang/Lex/Preprocessor.h| 14 +++-
 clang/include/clang/Parse/Parser.h| 13 ++-
 clang/lib/Lex/PPCaching.cpp   | 39 -
 clang/lib/Parse/ParseCXXInlineMethods.cpp | 41 +
 clang/lib/Parse/ParseDecl.cpp | 83 ---
 clang/lib/Parse/ParseExprCXX.cpp  | 10 +--
 .../CXX/dcl.decl/dcl.meaning/dcl.mptr/p2.cpp  | 64 ++
 clang/test/CXX/temp/temp.res/p3.cpp   | 10 +--
 8 files changed, 178 insertions(+), 96 deletions(-)
 create mode 100644 clang/test/CXX/dcl.decl/dcl.meaning/dcl.mptr/p2.cpp

diff --git a/clang/include/clang/Lex/Preprocessor.h 
b/clang/include/clang/Lex/Preprocessor.h
index be3334b980746..6c6275e29706a 100644
--- a/clang/include/clang/Lex/Preprocessor.h
+++ b/clang/include/clang/Lex/Preprocessor.h
@@ -1160,6 +1160,9 @@ class Preprocessor {
   /// invoked (at which point the last position is popped).
   std::vector BacktrackPositions;
 
+  std::vector>
+  UnannotatedBacktrackPositions;
+
   /// True if \p Preprocessor::SkipExcludedConditionalBlock() is running.
   /// This is used to guard against calling this function recursively.
   ///
@@ -1722,7 +1725,7 @@ class Preprocessor {
   /// at some point after EnableBacktrackAtThisPos. If you don't, caching of
   /// tokens will continue indefinitely.
   ///
-  void EnableBacktrackAtThisPos();
+  void EnableBacktrackAtThisPos(bool Unannotated = false);
 
   /// Disable the last EnableBacktrackAtThisPos call.
   void CommitBacktrackedTokens();
@@ -1733,7 +1736,11 @@ class Preprocessor {
 
   /// True if EnableBacktrackAtThisPos() was called and
   /// caching of tokens is on.
+
   bool isBacktrackEnabled() const { return !BacktrackPositions.empty(); }
+  bool isUnannotatedBacktrackEnabled() const {
+return !UnannotatedBacktrackPositions.empty();
+  }
 
   /// Lex the next token for this preprocessor.
   void Lex(Token &Result);
@@ -1841,8 +1848,9 @@ class Preprocessor {
   void RevertCachedTokens(unsigned N) {
 assert(isBacktrackEnabled() &&
"Should only be called when tokens are cached for backtracking");
-assert(signed(CachedLexPos) - signed(N) >= 
signed(BacktrackPositions.back())
- && "Should revert tokens up to the last backtrack position, not 
more");
+assert(signed(CachedLexPos) - signed(N) >=
+   signed(BacktrackPositions.back() >> 1) &&
+   "Should revert tokens up to the last backtrack position, not more");
 assert(signed(CachedLexPos) - signed(N) >= 0 &&
"Corrupted backtrack positions ?");
 CachedLexPos -= N;
diff --git a/clang/include/clang/Parse/Parser.h 
b/clang/include/clang/Parse/Parser.h
index b4f5270a35956..99b7306c9b2ac 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -1033,7 +1033,7 @@ class Parser : public CodeCompletionHandler {
 bool isActive;
 
   public:
-explicit TentativeParsingAction(Parser &p)
+explicit TentativeParsingAction(Parser &p, bool Unannotated = false)
 : P(p), PrevPreferredType(P.PreferredType) {
   PrevTok = P.Tok;
   PrevTentativelyDeclaredIdentifierCount =
@@ -1041,7 +1041,7 @@ class Parser : public CodeCompletionHandler {
   PrevParenCount = P.ParenCount;
   PrevBracketCount = P.BracketCount;
   PrevBraceCount = P.BraceCount;
-  P.PP.EnableBacktrackAtThisPos();
+  P.PP.EnableBacktrackAtThisPos(Unannotated);
   isActive = true;
 }
 void Commit() {
@@ -1072,13 +1072,11 @@ class Parser : public CodeCompletionHandler {
   class RevertingTentativeParsingAction
   : private Parser::TentativeParsingAction {
   public:
-RevertingTentativeParsingAction(Parser &P)
-: Parser::TentativeParsingAction(P) {}
+using TentativeParsingAction::TentativeParsingAction;
+
 ~RevertingTentativeParsingAction() { Revert(); }
   };
 
-  class UnannotatedTentativeParsingAction;
-
   /// ObjCDeclContextSwitch - An object used to switch context from
   /// an objective-c decl context to its enclosing decl context and
   /// back.
@@ -1979,7 +1977,8 @@ class Parser : public CodeCompletionHandler {
   CXXScopeSpec &SS, ParsedType ObjectType, bool ObjectHasErrors,
   bool EnteringContext, bool *MayBePseudoDestructor = nullptr,
   bool IsTypename = false, const IdentifierInfo **LastII = nullptr,
-  bool OnlyNamespace = false, bool InUsingDeclaration = false);
+  bool OnlyNamespace = false, bool InUsingDeclaration = false,
+  bool Disambiguation = false);
 
   
//======//
   // C++11 5.1.2: Lambda expr

[clang] [Clang][AST] Move NamespaceDecl bits to DeclContext (PR #98567)

2024-07-11 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Krystian Stasiowski (sdkrystian)


Changes

Currently, `NamespaceDecl` has a member `AnonOrFirstNamespaceAndFlags` which 
stores a few pieces of data:
- a bit indicating whether the namespace was declared `inline`, and
- a bit indicating whether the namespace was declared as a 
_nested-namespace-definition_, and
- a pointer a `NamespaceDecl` that either stores:
  - a pointer to the first declaration of that namespace if the declaration is 
no the first declaration, or
  - a pointer to the unnamed namespace that inhabits the namespace otherwise.

`Redeclarable` already stores a pointer to the first declaration of an entity, 
so it's unnecessary to store this in `NamespaceDecl`. `DeclContext` has 8 bytes 
in which various bitfields can be stored for a declaration, so it's not 
necessary to store these in `NamespaceDecl` either. We only need to store a 
pointer to the unnamed namespace that inhabits the first declaration of a 
namespace. This patch moves the two bits currently stored in `NamespaceDecl` to 
`DeclContext`, and only stores a pointer to the unnamed namespace that inhabits 
a namespace in the first declaration of that namespace. Since 
`getOriginalNamespace` always returns the same `NamespaceDecl` as 
`getFirstDecl`, this function is removed to avoid confusion.

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


12 Files Affected:

- (modified) clang/include/clang/AST/Decl.h (+14-53) 
- (modified) clang/include/clang/AST/DeclBase.h (+24) 
- (modified) clang/lib/AST/ASTContext.cpp (+4-4) 
- (modified) clang/lib/AST/DeclBase.cpp (+1-2) 
- (modified) clang/lib/AST/DeclCXX.cpp (+4-27) 
- (modified) clang/lib/AST/ItaniumMangle.cpp (+1-1) 
- (modified) clang/lib/AST/JSONNodeDumper.cpp (+2-3) 
- (modified) clang/lib/AST/TextNodeDumper.cpp (+2-2) 
- (modified) clang/lib/Sema/SemaCodeComplete.cpp (+1-1) 
- (modified) clang/lib/Sema/SemaLookup.cpp (+1-1) 
- (modified) clang/lib/Serialization/ASTReaderDecl.cpp (+2-14) 
- (modified) clang/lib/Serialization/ASTWriterDecl.cpp (+1-1) 


``diff
diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h
index 5957f14098363..561a9d872acfb 100644
--- a/clang/include/clang/AST/Decl.h
+++ b/clang/include/clang/AST/Decl.h
@@ -542,12 +542,9 @@ class LabelDecl : public NamedDecl {
 };
 
 /// Represent a C++ namespace.
-class NamespaceDecl : public NamedDecl, public DeclContext,
-  public Redeclarable
-{
-
-  enum Flags : unsigned { F_Inline = 1 << 0, F_Nested = 1 << 1 };
-
+class NamespaceDecl : public NamedDecl,
+  public DeclContext,
+  public Redeclarable {
   /// The starting location of the source range, pointing
   /// to either the namespace or the inline keyword.
   SourceLocation LocStart;
@@ -555,12 +552,8 @@ class NamespaceDecl : public NamedDecl, public DeclContext,
   /// The ending location of the source range.
   SourceLocation RBraceLoc;
 
-  /// A pointer to either the anonymous namespace that lives just inside
-  /// this namespace or to the first namespace in the chain (the latter case
-  /// only when this is not the first in the chain), along with a
-  /// boolean value indicating whether this is an inline namespace.
-  llvm::PointerIntPair
-  AnonOrFirstNamespaceAndFlags;
+  /// The unnamed namespace that inhabits this namespace, if any.
+  NamespaceDecl *AnonymousNamespace = nullptr;
 
   NamespaceDecl(ASTContext &C, DeclContext *DC, bool Inline,
 SourceLocation StartLoc, SourceLocation IdLoc,
@@ -607,35 +600,19 @@ class NamespaceDecl : public NamedDecl, public 
DeclContext,
   }
 
   /// Returns true if this is an inline namespace declaration.
-  bool isInline() const {
-return AnonOrFirstNamespaceAndFlags.getInt() & F_Inline;
-  }
+  bool isInline() const { return NamespaceDeclBits.IsInline; }
 
   /// Set whether this is an inline namespace declaration.
-  void setInline(bool Inline) {
-unsigned F = AnonOrFirstNamespaceAndFlags.getInt();
-if (Inline)
-  AnonOrFirstNamespaceAndFlags.setInt(F | F_Inline);
-else
-  AnonOrFirstNamespaceAndFlags.setInt(F & ~F_Inline);
-  }
+  void setInline(bool Inline) { NamespaceDeclBits.IsInline = Inline; }
 
   /// Returns true if this is a nested namespace declaration.
   /// \code
   /// namespace outer::nested { }
   /// \endcode
-  bool isNested() const {
-return AnonOrFirstNamespaceAndFlags.getInt() & F_Nested;
-  }
+  bool isNested() const { return NamespaceDeclBits.IsNested; }
 
   /// Set whether this is a nested namespace declaration.
-  void setNested(bool Nested) {
-unsigned F = AnonOrFirstNamespaceAndFlags.getInt();
-if (Nested)
-  AnonOrFirstNamespaceAndFlags.setInt(F | F_Nested);
-else
-  AnonOrFirstNamespaceAndFlags.setInt(F & ~F_Nested);
-  }
+  void setNested(bool Nested) { NamespaceDeclBits.IsNested = Nested; }
 
   /// Returns true if the inline qualifier for \c Name is

[clang] [Clang][AST] Move NamespaceDecl bits to DeclContext (PR #98567)

2024-07-11 Thread Krystian Stasiowski via cfe-commits

https://github.com/sdkrystian created 
https://github.com/llvm/llvm-project/pull/98567

Currently, `NamespaceDecl` has a member `AnonOrFirstNamespaceAndFlags` which 
stores a few pieces of data:
- a bit indicating whether the namespace was declared `inline`, and
- a bit indicating whether the namespace was declared as a 
_nested-namespace-definition_, and
- a pointer a `NamespaceDecl` that either stores:
  - a pointer to the first declaration of that namespace if the declaration is 
no the first declaration, or
  - a pointer to the unnamed namespace that inhabits the namespace otherwise.

`Redeclarable` already stores a pointer to the first declaration of an entity, 
so it's unnecessary to store this in `NamespaceDecl`. `DeclContext` has 8 bytes 
in which various bitfields can be stored for a declaration, so it's not 
necessary to store these in `NamespaceDecl` either. We only need to store a 
pointer to the unnamed namespace that inhabits the first declaration of a 
namespace. This patch moves the two bits currently stored in `NamespaceDecl` to 
`DeclContext`, and only stores a pointer to the unnamed namespace that inhabits 
a namespace in the first declaration of that namespace. Since 
`getOriginalNamespace` always returns the same `NamespaceDecl` as 
`getFirstDecl`, this function is removed to avoid confusion.

>From 63a9c69cc5c4d6f8048918addfb01de6dc212524 Mon Sep 17 00:00:00 2001
From: Krystian Stasiowski 
Date: Thu, 20 Jun 2024 11:44:53 -0400
Subject: [PATCH] [Clang][AST] Move NamespaceDecl bits to DeclContext

---
 clang/include/clang/AST/Decl.h| 67 +--
 clang/include/clang/AST/DeclBase.h| 24 
 clang/lib/AST/ASTContext.cpp  |  8 +--
 clang/lib/AST/DeclBase.cpp|  3 +-
 clang/lib/AST/DeclCXX.cpp | 31 ++-
 clang/lib/AST/ItaniumMangle.cpp   |  2 +-
 clang/lib/AST/JSONNodeDumper.cpp  |  5 +-
 clang/lib/AST/TextNodeDumper.cpp  |  4 +-
 clang/lib/Sema/SemaCodeComplete.cpp   |  2 +-
 clang/lib/Sema/SemaLookup.cpp |  2 +-
 clang/lib/Serialization/ASTReaderDecl.cpp | 16 +-
 clang/lib/Serialization/ASTWriterDecl.cpp |  2 +-
 12 files changed, 57 insertions(+), 109 deletions(-)

diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h
index 5957f14098363..561a9d872acfb 100644
--- a/clang/include/clang/AST/Decl.h
+++ b/clang/include/clang/AST/Decl.h
@@ -542,12 +542,9 @@ class LabelDecl : public NamedDecl {
 };
 
 /// Represent a C++ namespace.
-class NamespaceDecl : public NamedDecl, public DeclContext,
-  public Redeclarable
-{
-
-  enum Flags : unsigned { F_Inline = 1 << 0, F_Nested = 1 << 1 };
-
+class NamespaceDecl : public NamedDecl,
+  public DeclContext,
+  public Redeclarable {
   /// The starting location of the source range, pointing
   /// to either the namespace or the inline keyword.
   SourceLocation LocStart;
@@ -555,12 +552,8 @@ class NamespaceDecl : public NamedDecl, public DeclContext,
   /// The ending location of the source range.
   SourceLocation RBraceLoc;
 
-  /// A pointer to either the anonymous namespace that lives just inside
-  /// this namespace or to the first namespace in the chain (the latter case
-  /// only when this is not the first in the chain), along with a
-  /// boolean value indicating whether this is an inline namespace.
-  llvm::PointerIntPair
-  AnonOrFirstNamespaceAndFlags;
+  /// The unnamed namespace that inhabits this namespace, if any.
+  NamespaceDecl *AnonymousNamespace = nullptr;
 
   NamespaceDecl(ASTContext &C, DeclContext *DC, bool Inline,
 SourceLocation StartLoc, SourceLocation IdLoc,
@@ -607,35 +600,19 @@ class NamespaceDecl : public NamedDecl, public 
DeclContext,
   }
 
   /// Returns true if this is an inline namespace declaration.
-  bool isInline() const {
-return AnonOrFirstNamespaceAndFlags.getInt() & F_Inline;
-  }
+  bool isInline() const { return NamespaceDeclBits.IsInline; }
 
   /// Set whether this is an inline namespace declaration.
-  void setInline(bool Inline) {
-unsigned F = AnonOrFirstNamespaceAndFlags.getInt();
-if (Inline)
-  AnonOrFirstNamespaceAndFlags.setInt(F | F_Inline);
-else
-  AnonOrFirstNamespaceAndFlags.setInt(F & ~F_Inline);
-  }
+  void setInline(bool Inline) { NamespaceDeclBits.IsInline = Inline; }
 
   /// Returns true if this is a nested namespace declaration.
   /// \code
   /// namespace outer::nested { }
   /// \endcode
-  bool isNested() const {
-return AnonOrFirstNamespaceAndFlags.getInt() & F_Nested;
-  }
+  bool isNested() const { return NamespaceDeclBits.IsNested; }
 
   /// Set whether this is a nested namespace declaration.
-  void setNested(bool Nested) {
-unsigned F = AnonOrFirstNamespaceAndFlags.getInt();
-if (Nested)
-  AnonOrFirstNamespaceAndFlags.setInt(F | F_Nested);
-else
-  AnonOrFirstNamespaceAndFlags.setInt(F &

[clang] [clang][deps] Don't treat ObjC method args as module directives (PR #97654)

2024-07-11 Thread Argyrios Kyrtzidis via cfe-commits


@@ -970,6 +970,26 @@ ort \
   EXPECT_EQ(Directives[1].Kind, cxx_export_module_decl);
 }
 
+TEST(MinimizeSourceToDependencyDirectivesTest, ObjCMethodArgs) {
+  SmallVector Out;
+  SmallVector Tokens;
+  SmallVector Directives;
+
+  StringRef Source = R"(
+@interface SomeObjcClass
+  - (void)func:(int)otherData
+  module:(int)module
+  import:(int)import;
+@end
+  )";
+
+  ASSERT_FALSE(
+  minimizeSourceToDependencyDirectives(Source, Out, Tokens, Directives));
+  // `module :` and `import :` not followed by an identifier are not treated as
+  // directive lines because they can be method argument decls.
+  EXPECT_EQ(Directives.size(), 2u); // 2 for the EOF tokens.

akyrtzi wrote:

This would be a bit more clear if you checked against the `Out` variable, which 
contains a "pretty-printed" string of the directives that were found, something 
like this:

```
TEST(MinimizeSourceToDependencyDirectivesTest, ObjCMethodArgs) {
  SmallVector Out;

  StringRef Source = R"(
@interface SomeObjcClass
  - (void)func:(int)otherData
  module:(int)module
  import:(int)import;
@end
  )";

  ASSERT_FALSE(minimizeSourceToDependencyDirectives(Source, Out));
  // `module :` and `import :` not followed by an identifier are not treated as
  // directive lines because they can be method argument decls.
  EXPECT_STREQ("", Out.data());
}
```

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


[clang] [HLSL] Split out resource class data from resource attribute (PR #98419)

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


@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -o - %s -verify
+
+// expected-error@+1{{'resource_class' attribute takes one argument}}
+struct [[hlsl::resource_class()]] Eg1 {
+  int i;  
+};
+
+Eg1 e1;
+
+// expected-error@+1{{invalid resource class 'gibberish' used; expected 'SRV', 
'UAV', 'CBuffer', or 'Sampler'}}
+struct [[hlsl::resource_class(gibberish)]] Eg2 {
+  int i;  
+};
+
+Eg2 e2;
+
+RWBuffer In : register(u1);
+
+
+[numthreads(1,1,1)]
+void main() {
+  In[0] = e1.i + e2.i;
+}

bob80905 wrote:

DxilTranslateMetadata::runOnModule calls dxil::createEntryMD, which has an 
assert that triggers if the target environment is not a library or invalid, and 
there is not exactly one entry in the EntryList.
Seems pretty reasonable, there should be exactly one entry point for non-lib 
targets.

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


[clang] [Clang][Parse] Fix ambiguity with nested-name-specifiers that may declarative (PR #96364)

2024-07-11 Thread Krystian Stasiowski via cfe-commits

https://github.com/sdkrystian updated 
https://github.com/llvm/llvm-project/pull/96364

>From ade60c6468cf3aa0b862734d403dffa2733afe3c Mon Sep 17 00:00:00 2001
From: Krystian Stasiowski 
Date: Wed, 12 Jun 2024 14:14:26 -0400
Subject: [PATCH 1/2] [Clang][Parse] Fix ambiguity with nested-name-specifiers
 that may be declarative

---
 clang/include/clang/Lex/Preprocessor.h| 14 +++-
 clang/include/clang/Parse/Parser.h| 13 ++-
 clang/lib/Lex/PPCaching.cpp   | 39 -
 clang/lib/Parse/ParseCXXInlineMethods.cpp | 41 +
 clang/lib/Parse/ParseDecl.cpp | 83 ---
 clang/lib/Parse/ParseExprCXX.cpp  | 10 +--
 .../CXX/dcl.decl/dcl.meaning/dcl.mptr/p2.cpp  | 64 ++
 clang/test/CXX/temp/temp.res/p3.cpp   | 10 +--
 8 files changed, 178 insertions(+), 96 deletions(-)
 create mode 100644 clang/test/CXX/dcl.decl/dcl.meaning/dcl.mptr/p2.cpp

diff --git a/clang/include/clang/Lex/Preprocessor.h 
b/clang/include/clang/Lex/Preprocessor.h
index be3334b980746..6c6275e29706a 100644
--- a/clang/include/clang/Lex/Preprocessor.h
+++ b/clang/include/clang/Lex/Preprocessor.h
@@ -1160,6 +1160,9 @@ class Preprocessor {
   /// invoked (at which point the last position is popped).
   std::vector BacktrackPositions;
 
+  std::vector>
+  UnannotatedBacktrackPositions;
+
   /// True if \p Preprocessor::SkipExcludedConditionalBlock() is running.
   /// This is used to guard against calling this function recursively.
   ///
@@ -1722,7 +1725,7 @@ class Preprocessor {
   /// at some point after EnableBacktrackAtThisPos. If you don't, caching of
   /// tokens will continue indefinitely.
   ///
-  void EnableBacktrackAtThisPos();
+  void EnableBacktrackAtThisPos(bool Unannotated = false);
 
   /// Disable the last EnableBacktrackAtThisPos call.
   void CommitBacktrackedTokens();
@@ -1733,7 +1736,11 @@ class Preprocessor {
 
   /// True if EnableBacktrackAtThisPos() was called and
   /// caching of tokens is on.
+
   bool isBacktrackEnabled() const { return !BacktrackPositions.empty(); }
+  bool isUnannotatedBacktrackEnabled() const {
+return !UnannotatedBacktrackPositions.empty();
+  }
 
   /// Lex the next token for this preprocessor.
   void Lex(Token &Result);
@@ -1841,8 +1848,9 @@ class Preprocessor {
   void RevertCachedTokens(unsigned N) {
 assert(isBacktrackEnabled() &&
"Should only be called when tokens are cached for backtracking");
-assert(signed(CachedLexPos) - signed(N) >= 
signed(BacktrackPositions.back())
- && "Should revert tokens up to the last backtrack position, not 
more");
+assert(signed(CachedLexPos) - signed(N) >=
+   signed(BacktrackPositions.back() >> 1) &&
+   "Should revert tokens up to the last backtrack position, not more");
 assert(signed(CachedLexPos) - signed(N) >= 0 &&
"Corrupted backtrack positions ?");
 CachedLexPos -= N;
diff --git a/clang/include/clang/Parse/Parser.h 
b/clang/include/clang/Parse/Parser.h
index b4f5270a35956..99b7306c9b2ac 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -1033,7 +1033,7 @@ class Parser : public CodeCompletionHandler {
 bool isActive;
 
   public:
-explicit TentativeParsingAction(Parser &p)
+explicit TentativeParsingAction(Parser &p, bool Unannotated = false)
 : P(p), PrevPreferredType(P.PreferredType) {
   PrevTok = P.Tok;
   PrevTentativelyDeclaredIdentifierCount =
@@ -1041,7 +1041,7 @@ class Parser : public CodeCompletionHandler {
   PrevParenCount = P.ParenCount;
   PrevBracketCount = P.BracketCount;
   PrevBraceCount = P.BraceCount;
-  P.PP.EnableBacktrackAtThisPos();
+  P.PP.EnableBacktrackAtThisPos(Unannotated);
   isActive = true;
 }
 void Commit() {
@@ -1072,13 +1072,11 @@ class Parser : public CodeCompletionHandler {
   class RevertingTentativeParsingAction
   : private Parser::TentativeParsingAction {
   public:
-RevertingTentativeParsingAction(Parser &P)
-: Parser::TentativeParsingAction(P) {}
+using TentativeParsingAction::TentativeParsingAction;
+
 ~RevertingTentativeParsingAction() { Revert(); }
   };
 
-  class UnannotatedTentativeParsingAction;
-
   /// ObjCDeclContextSwitch - An object used to switch context from
   /// an objective-c decl context to its enclosing decl context and
   /// back.
@@ -1979,7 +1977,8 @@ class Parser : public CodeCompletionHandler {
   CXXScopeSpec &SS, ParsedType ObjectType, bool ObjectHasErrors,
   bool EnteringContext, bool *MayBePseudoDestructor = nullptr,
   bool IsTypename = false, const IdentifierInfo **LastII = nullptr,
-  bool OnlyNamespace = false, bool InUsingDeclaration = false);
+  bool OnlyNamespace = false, bool InUsingDeclaration = false,
+  bool Disambiguation = false);
 
   
//======//
   // C++11 5.1.2: Lambda expr

[clang] [libcxx] [llvm] Reapply "[Clang] Implement resolution for CWG1835 (#92957)" (PR #98547)

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

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`openmp-offload-libc-amdgpu-runtime` running on `omp-vega20-1` while building 
`clang,libcxx,llvm` at step 10 "Add check check-offload".

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

Here is the relevant piece of the build log for the reference:
```
Step 10 (Add check check-offload) failure: 1200 seconds without output running 
[b'ninja', b'-j 32', b'check-offload'], attempting to kill
...
PASS: libomptarget :: x86_64-pc-linux-gnu-LTO :: offloading/test_libc.cpp (776 
of 786)
PASS: libomptarget :: x86_64-pc-linux-gnu-LTO :: offloading/bug49779.cpp (777 
of 786)
PASS: libomptarget :: x86_64-pc-linux-gnu-LTO :: offloading/bug50022.cpp (778 
of 786)
PASS: libomptarget :: x86_64-pc-linux-gnu-LTO :: offloading/bug53727.cpp (779 
of 786)
PASS: libomptarget :: x86_64-pc-linux-gnu-LTO :: offloading/wtime.c (780 of 786)
PASS: libomptarget :: x86_64-pc-linux-gnu :: offloading/bug49021.cpp (781 of 
786)
PASS: libomptarget :: x86_64-pc-linux-gnu :: 
offloading/std_complex_arithmetic.cpp (782 of 786)
PASS: libomptarget :: x86_64-pc-linux-gnu-LTO :: 
offloading/complex_reduction.cpp (783 of 786)
PASS: libomptarget :: x86_64-pc-linux-gnu-LTO :: 
offloading/std_complex_arithmetic.cpp (784 of 786)
PASS: libomptarget :: x86_64-pc-linux-gnu-LTO :: offloading/bug49021.cpp (785 
of 786)
command timed out: 1200 seconds without output running [b'ninja', b'-j 32', 
b'check-offload'], attempting to kill
process killed by signal 9
program finished with exit code -1
elapsedTime=1228.515257

```

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


[clang] [Clang][Parse] Fix ambiguity with nested-name-specifiers that may declarative (PR #96364)

2024-07-11 Thread Krystian Stasiowski via cfe-commits

https://github.com/sdkrystian updated 
https://github.com/llvm/llvm-project/pull/96364

>From 29f2e6e418d61de15453dbfca77ede0126b6d384 Mon Sep 17 00:00:00 2001
From: Krystian Stasiowski 
Date: Wed, 12 Jun 2024 14:14:26 -0400
Subject: [PATCH 1/2] [Clang][Parse] Fix ambiguity with nested-name-specifiers
 that may be declarative

---
 clang/include/clang/Lex/Preprocessor.h| 14 +++-
 clang/include/clang/Parse/Parser.h| 13 ++-
 clang/lib/Lex/PPCaching.cpp   | 39 -
 clang/lib/Parse/ParseCXXInlineMethods.cpp | 41 +
 clang/lib/Parse/ParseDecl.cpp | 83 ---
 clang/lib/Parse/ParseExprCXX.cpp  | 10 +--
 .../CXX/dcl.decl/dcl.meaning/dcl.mptr/p2.cpp  | 64 ++
 clang/test/CXX/temp/temp.res/p3.cpp   | 10 +--
 8 files changed, 178 insertions(+), 96 deletions(-)
 create mode 100644 clang/test/CXX/dcl.decl/dcl.meaning/dcl.mptr/p2.cpp

diff --git a/clang/include/clang/Lex/Preprocessor.h 
b/clang/include/clang/Lex/Preprocessor.h
index be3334b980746..6c6275e29706a 100644
--- a/clang/include/clang/Lex/Preprocessor.h
+++ b/clang/include/clang/Lex/Preprocessor.h
@@ -1160,6 +1160,9 @@ class Preprocessor {
   /// invoked (at which point the last position is popped).
   std::vector BacktrackPositions;
 
+  std::vector>
+  UnannotatedBacktrackPositions;
+
   /// True if \p Preprocessor::SkipExcludedConditionalBlock() is running.
   /// This is used to guard against calling this function recursively.
   ///
@@ -1722,7 +1725,7 @@ class Preprocessor {
   /// at some point after EnableBacktrackAtThisPos. If you don't, caching of
   /// tokens will continue indefinitely.
   ///
-  void EnableBacktrackAtThisPos();
+  void EnableBacktrackAtThisPos(bool Unannotated = false);
 
   /// Disable the last EnableBacktrackAtThisPos call.
   void CommitBacktrackedTokens();
@@ -1733,7 +1736,11 @@ class Preprocessor {
 
   /// True if EnableBacktrackAtThisPos() was called and
   /// caching of tokens is on.
+
   bool isBacktrackEnabled() const { return !BacktrackPositions.empty(); }
+  bool isUnannotatedBacktrackEnabled() const {
+return !UnannotatedBacktrackPositions.empty();
+  }
 
   /// Lex the next token for this preprocessor.
   void Lex(Token &Result);
@@ -1841,8 +1848,9 @@ class Preprocessor {
   void RevertCachedTokens(unsigned N) {
 assert(isBacktrackEnabled() &&
"Should only be called when tokens are cached for backtracking");
-assert(signed(CachedLexPos) - signed(N) >= 
signed(BacktrackPositions.back())
- && "Should revert tokens up to the last backtrack position, not 
more");
+assert(signed(CachedLexPos) - signed(N) >=
+   signed(BacktrackPositions.back() >> 1) &&
+   "Should revert tokens up to the last backtrack position, not more");
 assert(signed(CachedLexPos) - signed(N) >= 0 &&
"Corrupted backtrack positions ?");
 CachedLexPos -= N;
diff --git a/clang/include/clang/Parse/Parser.h 
b/clang/include/clang/Parse/Parser.h
index b4f5270a35956..99b7306c9b2ac 100644
--- a/clang/include/clang/Parse/Parser.h
+++ b/clang/include/clang/Parse/Parser.h
@@ -1033,7 +1033,7 @@ class Parser : public CodeCompletionHandler {
 bool isActive;
 
   public:
-explicit TentativeParsingAction(Parser &p)
+explicit TentativeParsingAction(Parser &p, bool Unannotated = false)
 : P(p), PrevPreferredType(P.PreferredType) {
   PrevTok = P.Tok;
   PrevTentativelyDeclaredIdentifierCount =
@@ -1041,7 +1041,7 @@ class Parser : public CodeCompletionHandler {
   PrevParenCount = P.ParenCount;
   PrevBracketCount = P.BracketCount;
   PrevBraceCount = P.BraceCount;
-  P.PP.EnableBacktrackAtThisPos();
+  P.PP.EnableBacktrackAtThisPos(Unannotated);
   isActive = true;
 }
 void Commit() {
@@ -1072,13 +1072,11 @@ class Parser : public CodeCompletionHandler {
   class RevertingTentativeParsingAction
   : private Parser::TentativeParsingAction {
   public:
-RevertingTentativeParsingAction(Parser &P)
-: Parser::TentativeParsingAction(P) {}
+using TentativeParsingAction::TentativeParsingAction;
+
 ~RevertingTentativeParsingAction() { Revert(); }
   };
 
-  class UnannotatedTentativeParsingAction;
-
   /// ObjCDeclContextSwitch - An object used to switch context from
   /// an objective-c decl context to its enclosing decl context and
   /// back.
@@ -1979,7 +1977,8 @@ class Parser : public CodeCompletionHandler {
   CXXScopeSpec &SS, ParsedType ObjectType, bool ObjectHasErrors,
   bool EnteringContext, bool *MayBePseudoDestructor = nullptr,
   bool IsTypename = false, const IdentifierInfo **LastII = nullptr,
-  bool OnlyNamespace = false, bool InUsingDeclaration = false);
+  bool OnlyNamespace = false, bool InUsingDeclaration = false,
+  bool Disambiguation = false);
 
   
//======//
   // C++11 5.1.2: Lambda expr

[clang] [clang][deps] Don't treat ObjC method args as module directives (PR #97654)

2024-07-11 Thread Michael Spencer via cfe-commits

Bigcheese wrote:

Updated the test to be a unit test.

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


[clang] [clang][deps] Don't treat ObjC method args as module directives (PR #97654)

2024-07-11 Thread Michael Spencer via cfe-commits

https://github.com/Bigcheese updated 
https://github.com/llvm/llvm-project/pull/97654

>From 1e8ecb546c3519488050a2c1abe22bb0ecbb8495 Mon Sep 17 00:00:00 2001
From: Michael Spencer 
Date: Wed, 10 Jul 2024 17:02:39 -0700
Subject: [PATCH] [clang][deps] Don't treat ObjC method args as module
 directives

`import:(type)name` is a method argument decl in ObjC, but the C++20
preprocessing rules say this is a preprocessing line.

Because the dependency directive scanner is not language dependent,
this patch extends the C++20 rule to exclude `module :` (which is
never a valid module decl anyway), and `import :` that is not followed
by an identifier.

This is ok to do because in C++20 mode the compiler will later error
on lines like this anyway, and the dependencies the scanner returns
are still correct.
---
 clang/lib/Lex/DependencyDirectivesScanner.cpp | 13 +++-
 .../Lex/DependencyDirectivesScannerTest.cpp   | 20 +++
 2 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Lex/DependencyDirectivesScanner.cpp 
b/clang/lib/Lex/DependencyDirectivesScanner.cpp
index 57652be8244b4..8a020d0e95fe3 100644
--- a/clang/lib/Lex/DependencyDirectivesScanner.cpp
+++ b/clang/lib/Lex/DependencyDirectivesScanner.cpp
@@ -660,7 +660,18 @@ bool Scanner::lexModule(const char *&First, const char 
*const End) {
   // an import.
 
   switch (*First) {
-  case ':':
+  case ':': {
+// `module :` is never the start of a valid module declaration.
+if (Id == "module") {
+  skipLine(First, End);
+  return false;
+}
+// `import:(type)name` is a valid ObjC method decl, so check one more 
token.
+(void)lexToken(First, End);
+if (!tryLexIdentifierOrSkipLine(First, End))
+  return false;
+break;
+  }
   case '<':
   case '"':
 break;
diff --git a/clang/unittests/Lex/DependencyDirectivesScannerTest.cpp 
b/clang/unittests/Lex/DependencyDirectivesScannerTest.cpp
index 94af9688a96e2..96b8cbc3888f5 100644
--- a/clang/unittests/Lex/DependencyDirectivesScannerTest.cpp
+++ b/clang/unittests/Lex/DependencyDirectivesScannerTest.cpp
@@ -970,6 +970,26 @@ ort \
   EXPECT_EQ(Directives[1].Kind, cxx_export_module_decl);
 }
 
+TEST(MinimizeSourceToDependencyDirectivesTest, ObjCMethodArgs) {
+  SmallVector Out;
+  SmallVector Tokens;
+  SmallVector Directives;
+
+  StringRef Source = R"(
+@interface SomeObjcClass
+  - (void)func:(int)otherData
+  module:(int)module
+  import:(int)import;
+@end
+  )";
+
+  ASSERT_FALSE(
+  minimizeSourceToDependencyDirectives(Source, Out, Tokens, Directives));
+  // `module :` and `import :` not followed by an identifier are not treated as
+  // directive lines because they can be method argument decls.
+  EXPECT_EQ(Directives.size(), 2u); // 2 for the EOF tokens.
+}
+
 TEST(MinimizeSourceToDependencyDirectivesTest, TokensBeforeEOF) {
   SmallString<128> Out;
 

___
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-11 Thread Yuxuan Chen via cfe-commits

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

>From 4e4bcdc19268543a8348736dede46d8f8cad0066 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]]

---
 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   | 84 +++
 ...a-attribute-supported-attributes-list.test |  1 +
 llvm/include/llvm/IR/Intrinsics.td|  3 +
 .../lib/Transforms/Coroutines/CoroCleanup.cpp |  9 +-
 llvm/lib/Transforms/Coroutines/CoroElide.cpp  | 58 -
 llvm/lib/Transforms/Coroutines/Coroutines.cpp |  1 +
 .../coro-elide-structured-concurrency.ll  | 64 ++
 25 files changed, 496 insertions(+), 134 deletions(-)
 create mode 100644 clang/test/CodeGenCoroutines/Inputs/utility.h
 create mode 100644 clang/test/CodeGenCoroutines/coro-structured-concurrency.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 : public CoroutineSuspendExpr {
 public:
   CoawaitExpr(SourceLocation CoawaitLoc, Expr *Operand, Expr *Common,
   Expr *Ready, Expr *Suspend, Expr *Resume,
-  OpaqueValueExpr *OpaqueValue, bool IsImplicit = false)
+  OpaqueValueExpr *CommonExprOpaqueValue, bool IsImplicit = false)
   : CoroutineSuspendExpr(CoawaitExprClass, CoawaitLoc, Operand, Common,
- Ready, Suspend, Resume, OpaqueValue) {
+ Ready, Suspend, Resume, CommonExprOpaqueValue) {
 CoawaitBits.IsImplicit = IsImplicit;
   }
 
@@ -5275,9 +5285,9 @@ class CoyieldExpr : public CoroutineSuspendExpr {
 public:
   CoyieldExpr(SourceLocation CoyieldLoc, Expr *Operand, Expr *Common,
   Expr *Ready, Expr *Suspend, Expr *Resume,
-  OpaqueValueExpr *OpaqueValue)
+  OpaqueValueExpr *CommonExprOpaqueValue)
   : CoroutineSuspendExpr(CoyieldExprClass, CoyieldLoc, Operand, Common,
-  

[clang] [clang] Support --sysroot= for ${arch}-windows-msvc targets (PR #96417)

2024-07-11 Thread via cfe-commits

trcrsired wrote:

@zmodem 

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


[clang] [clang] Support --sysroot= for ${arch}-windows-msvc targets (PR #96417)

2024-07-11 Thread via cfe-commits

https://github.com/trcrsired updated 
https://github.com/llvm/llvm-project/pull/96417

>From 4dc119b77c04ac04c2ca71b8ae07f42c7da84fb6 Mon Sep 17 00:00:00 2001
From: trcrsired 
Date: Sun, 23 Jun 2024 00:07:19 -0400
Subject: [PATCH] Support --sysroot= for ${arch}-windows-msvc targets

I think it is possible to use the same rule for msvc targets with
--target= and --sysroot=

See Repository:
https://github.com/trcrsired/windows-msvc-sysroot

Add sysroot support for msvc

MSVC.cpp needs getDriver before using D

add stl in parser for -stdlib=

Add Vcruntime to runtime list and unwind list

MSVC add default runtime lib type and default unwind lib type

add a msvc sysroot test

use %S instead of /foo

Fix test for msvc-sysroot

Also add a pesudo implementation for WebAssembly and
maybe Microsoft STL could be ported to more targets in the future

Fix the toggle of wasm that prevents -stdlib=stl passed into

Avoid clang-formatting in MSVC.cpp

Add some comments to ToolChain

avoid indent the if block

Add back space before winsysroot line

use  instead of arch in the comment

remove FIXME for libc++ since we have added the logic here

Remove MSVC.h formatting

Remove default cases in WebAssembly

add back the empty line before the Sysroot line

fix msvc-sysroot typo for libc++ loongarch

Fix : missing in CST_Stl case
---
 clang/include/clang/Driver/ToolChain.h  |  11 +-
 clang/lib/Driver/ToolChain.cpp  |  10 ++
 clang/lib/Driver/ToolChains/MSVC.cpp| 128 +++-
 clang/lib/Driver/ToolChains/MSVC.h  |  15 +++
 clang/lib/Driver/ToolChains/WebAssembly.cpp |  25 
 clang/lib/Driver/ToolChains/WebAssembly.h   |   2 +
 clang/test/Driver/msvc-sysroot.cpp  |  81 +
 clang/test/Driver/wasm-toolchain.cpp|  12 ++
 8 files changed, 279 insertions(+), 5 deletions(-)
 create mode 100644 clang/test/Driver/msvc-sysroot.cpp

diff --git a/clang/include/clang/Driver/ToolChain.h 
b/clang/include/clang/Driver/ToolChain.h
index ece1384d5d3c0..a7483a89d9ff1 100644
--- a/clang/include/clang/Driver/ToolChain.h
+++ b/clang/include/clang/Driver/ToolChain.h
@@ -94,19 +94,22 @@ class ToolChain {
   using path_list = SmallVector;
 
   enum CXXStdlibType {
-CST_Libcxx,
-CST_Libstdcxx
+CST_Libcxx, // LLVM libc++
+CST_Libstdcxx,  // GNU libstdc++
+CST_Stl,  // MSVC STL
   };
 
   enum RuntimeLibType {
 RLT_CompilerRT,
-RLT_Libgcc
+RLT_Libgcc,
+RLT_Vcruntime
   };
 
   enum UnwindLibType {
 UNW_None,
 UNW_CompilerRT,
-UNW_Libgcc
+UNW_Libgcc,
+UNW_Vcruntime
   };
 
   enum class UnwindTableLevel {
diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 85ae4d2a26fee..be800ffd8a84d 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -1101,6 +1101,8 @@ ToolChain::RuntimeLibType ToolChain::GetRuntimeLibType(
 runtimeLibType = ToolChain::RLT_CompilerRT;
   else if (LibName == "libgcc")
 runtimeLibType = ToolChain::RLT_Libgcc;
+  else if (LibName == "vcruntime")
+runtimeLibType = ToolChain::RLT_Vcruntime;
   else if (LibName == "platform")
 runtimeLibType = GetDefaultRuntimeLibType();
   else {
@@ -1139,6 +1141,8 @@ ToolChain::UnwindLibType ToolChain::GetUnwindLibType(
 unwindLibType = ToolChain::UNW_CompilerRT;
   } else if (LibName == "libgcc")
 unwindLibType = ToolChain::UNW_Libgcc;
+  else if (LibName == "vcruntime")
+unwindLibType = ToolChain::UNW_Vcruntime;
   else {
 if (A)
   getDriver().Diag(diag::err_drv_invalid_unwindlib_name)
@@ -1162,6 +1166,8 @@ ToolChain::CXXStdlibType 
ToolChain::GetCXXStdlibType(const ArgList &Args) const{
 cxxStdlibType = ToolChain::CST_Libcxx;
   else if (LibName == "libstdc++")
 cxxStdlibType = ToolChain::CST_Libstdcxx;
+  else if (LibName == "stl")
+cxxStdlibType = ToolChain::CST_Stl;
   else if (LibName == "platform")
 cxxStdlibType = GetDefaultCXXStdlibType();
   else {
@@ -1300,6 +1306,10 @@ void ToolChain::AddCXXStdlibLibArgs(const ArgList &Args,
   case ToolChain::CST_Libstdcxx:
 CmdArgs.push_back("-lstdc++");
 break;
+
+  case ToolChain::CST_Stl:
+// MSVC STL does not need to add -l
+break;
   }
 }
 
diff --git a/clang/lib/Driver/ToolChains/MSVC.cpp 
b/clang/lib/Driver/ToolChains/MSVC.cpp
index ca266e3e1d1d3..ad89003ed1c33 100644
--- a/clang/lib/Driver/ToolChains/MSVC.cpp
+++ b/clang/lib/Driver/ToolChains/MSVC.cpp
@@ -90,6 +90,16 @@ void visualstudio::Linker::ConstructJob(Compilation &C, 
const JobAction &JA,
 CmdArgs.push_back("-defaultlib:oldnames");
   }
 
+  auto SysRoot = TC.getDriver().SysRoot;
+  if (!SysRoot.empty()) {
+// If we have --sysroot, then we ignore all other setings
+// libpath is $SYSROOT/lib and $SYSROOT/lib/${ARCH}-unknown-windows-msvc
+const std::string MultiarchTriple =
+TC.getMultiarchTriple(TC.getDriver(), TC.getTriple(), SysRoot);
+std::string SysRootLib = "-libpath:" + SysRoot + "/lib";
+CmdArgs.pu

[clang] [HLSL] Split out resource class data from resource attribute (PR #98419)

2024-07-11 Thread Damyan Pepper via cfe-commits


@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -o - %s -verify
+
+// expected-error@+1{{'resource_class' attribute takes one argument}}
+struct [[hlsl::resource_class()]] Eg1 {
+  int i;  
+};
+
+Eg1 e1;
+
+// expected-error@+1{{invalid resource class 'gibberish' used; expected 'SRV', 
'UAV', 'CBuffer', or 'Sampler'}}
+struct [[hlsl::resource_class(gibberish)]] Eg2 {
+  int i;  
+};
+
+Eg2 e2;
+
+RWBuffer In : register(u1);
+
+
+[numthreads(1,1,1)]
+void main() {
+  In[0] = e1.i + e2.i;
+}

damyanp wrote:

Is that assert valid? Wondering if adding the entry point is working around 
some other bug that should be fixed.

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


[clang] [clang][CGRecordLayout] Remove dependency on isZeroSize (PR #96422)

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

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


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


[clang] [clang][X86] Add __cpuidex function to cpuid.h (PR #97785)

2024-07-11 Thread Aiden Grossman via cfe-commits

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


[clang] 1cafde2 - [clang][X86] Add __cpuidex function to cpuid.h (#97785)

2024-07-11 Thread via cfe-commits

Author: Aiden Grossman
Date: 2024-07-11T15:57:37-07:00
New Revision: 1cafde234865cdcd37311dcd77d3ef9a3e12f177

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

LOG: [clang][X86] Add __cpuidex function to cpuid.h (#97785)

MSVC has a __cpuidex function implemented to call the underlying cpuid
instruction which accepts a leaf, subleaf, and data array that the
output data is written into. This patch adds this functionality into
clang under the cpuid.h header. This also makes clang match GCC's
behavior. GCC has had __cpuidex in its cpuid.h since 2020.

This is another attempt to land https://reviews.llvm.org/D158348.

Added: 
clang/test/Headers/__cpuidex_conflict.c

Modified: 
clang/lib/Headers/cpuid.h
clang/test/Headers/cpuid.c

Removed: 




diff  --git a/clang/lib/Headers/cpuid.h b/clang/lib/Headers/cpuid.h
index bb7692efb78ff..82d995f1b966a 100644
--- a/clang/lib/Headers/cpuid.h
+++ b/clang/lib/Headers/cpuid.h
@@ -339,4 +339,13 @@ static __inline int __get_cpuid_count (unsigned int __leaf,
 return 1;
 }
 
+// In some configurations, __cpuidex is defined as a builtin (primarily
+// -fms-extensions) which will conflict with the __cpuidex definition below.
+#if !(__has_builtin(__cpuidex))
+static __inline void __cpuidex(int __cpu_info[4], int __leaf, int __subleaf) {
+  __cpuid_count(__leaf, __subleaf, __cpu_info[0], __cpu_info[1], __cpu_info[2],
+__cpu_info[3]);
+}
+#endif
+
 #endif /* __CPUID_H */

diff  --git a/clang/test/Headers/__cpuidex_conflict.c 
b/clang/test/Headers/__cpuidex_conflict.c
new file mode 100644
index 0..8687a6aa2f897
--- /dev/null
+++ b/clang/test/Headers/__cpuidex_conflict.c
@@ -0,0 +1,22 @@
+// Make sure that __cpuidex in cpuid.h doesn't conflict with the MS
+// extensions built in by ensuring compilation succeeds:
+// RUN: %clang_cc1 %s -ffreestanding -fms-extensions -fms-compatibility \
+// RUN:  -fms-compatibility-version=19.00 -triple x86_64-pc-windows-msvc 
-emit-llvm -o -
+// %clang_cc1 %s -ffreestanding -triple x86_64-w64-windows-gnu -fms-extensions 
-emit-llvm -o -
+// RUN: %clang_cc1 %s -ffreestanding -fopenmp -fopenmp-is-target-device 
-aux-triple x86_64-unknown-linux-gnu
+
+typedef __SIZE_TYPE__ size_t;
+
+// We declare __cpuidex here as where the buitlin should be exposed (MSVC), the
+// declaration is in , but  is not available from all the
+// targets that are being tested here.
+void __cpuidex (int[4], int, int);
+
+#include 
+
+int cpuid_info[4];
+
+void test_cpuidex(unsigned level, unsigned count) {
+  __cpuidex(cpuid_info, level, count);
+}
+

diff  --git a/clang/test/Headers/cpuid.c b/clang/test/Headers/cpuid.c
index 7e485495c1066..6ed12eca7a61d 100644
--- a/clang/test/Headers/cpuid.c
+++ b/clang/test/Headers/cpuid.c
@@ -6,14 +6,19 @@
 
 // CHECK-64: {{.*}} call { i32, i32, i32, i32 } asm "  xchgq  %rbx,${1:q}\0A 
cpuid\0A xchgq %rbx,${1:q}", 
"={ax},=r,={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %{{[a-z0-9]+}})
 // CHECK-64: {{.*}} call { i32, i32, i32, i32 } asm "  xchgq  %rbx,${1:q}\0A  
cpuid\0A  xchgq  %rbx,${1:q}", 
"={ax},=r,={cx},={dx},0,2,~{dirflag},~{fpsr},~{flags}"(i32 %{{[a-z0-9]+}}, i32 
%{{[a-z0-9]+}})
+// CHECK-64: {{.*}} call { i32, i32, i32, i32 } asm "  xchgq  %rbx,${1:q}\0A  
cpuid\0A  xchgq  %rbx,${1:q}", 
"={ax},=r,={cx},={dx},0,2,~{dirflag},~{fpsr},~{flags}"(i32 %{{[a-z0-9]+}}, i32 
%{{[a-z0-9]+}})
 
 // CHECK-32: {{.*}} call { i32, i32, i32, i32 } asm "cpuid", 
"={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %{{[a-z0-9]+}})
 // CHECK-32: {{.*}} call { i32, i32, i32, i32 } asm "cpuid", 
"={ax},={bx},={cx},={dx},0,2,~{dirflag},~{fpsr},~{flags}"(i32 %{{[a-z0-9]+}}, 
i32 %{{[a-z0-9]+}})
+// CHECK-32: {{.*}} call { i32, i32, i32, i32 } asm "cpuid", 
"={ax},={bx},={cx},={dx},0,2,~{dirflag},~{fpsr},~{flags}"(i32 %{{[a-z0-9]+}}, 
i32 %{{[a-z0-9]+}})
 
 unsigned eax0, ebx0, ecx0, edx0;
 unsigned eax1, ebx1, ecx1, edx1;
 
+int cpuid_info[4];
+
 void test_cpuid(unsigned level, unsigned count) {
   __cpuid(level, eax1, ebx1, ecx1, edx1);
   __cpuid_count(level, count, eax0, ebx0, ecx0, edx0);
+  __cpuidex(cpuid_info, level, count);
 }



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Clang: convert `__m64` intrinsics to unconditionally use SSE2 instead of MMX. (PR #96540)

2024-07-11 Thread James Y Knight via cfe-commits

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


[clang] [clang][X86] Add __cpuidex function to cpuid.h (PR #97785)

2024-07-11 Thread Aiden Grossman via cfe-commits

https://github.com/boomanaiden154 updated 
https://github.com/llvm/llvm-project/pull/97785

>From 38325cbf03e5013056dfc1b7939ec7c9738f9fe2 Mon Sep 17 00:00:00 2001
From: Aiden Grossman 
Date: Sat, 19 Aug 2023 13:37:21 -0700
Subject: [PATCH 1/2] [clang][X86] Add __cpuidex function to cpuid.h

MSVC has a __cpuidex function implemented to call the underlying cpuid
instruction which accepts a leaf, subleaf, and data array that the output
data is written into. This patch adds this functionality into clang
under the cpuid.h header. This also makes clang match GCC's behavior.
GCC has had __cpuidex in its cpuid.h since 2020.

This patch diverges from the gcc behavior slightly bynot marking
__cpuidex as static. If __cpuidex is marked as static, then this differs
from the signature used by MSVC (or at least what clang uses for MSVC),
which can cause include ordering issues if intrin.h (which contains a
declaration for __cpuidex) occurs before cpuid.h is included.
---
 clang/lib/Headers/cpuid.h   | 10 ++
 clang/test/Headers/__cpuidex_conflict.c | 22 ++
 clang/test/Headers/cpuid.c  |  5 +
 3 files changed, 37 insertions(+)
 create mode 100644 clang/test/Headers/__cpuidex_conflict.c

diff --git a/clang/lib/Headers/cpuid.h b/clang/lib/Headers/cpuid.h
index bb7692efb78ff..cd55410cda8b7 100644
--- a/clang/lib/Headers/cpuid.h
+++ b/clang/lib/Headers/cpuid.h
@@ -339,4 +339,14 @@ static __inline int __get_cpuid_count (unsigned int __leaf,
 return 1;
 }
 
+// In some configurations, __cpuidex is defined as a builtin (primarily
+// -fms-extensions) which will conflict with the __cpuidex definition below.
+#if !(__has_builtin(__cpuidex))
+static __inline void __cpuidex (int __cpu_info[4], int __leaf, int __subleaf)
+{
+  __cpuid_count(__leaf, __subleaf, __cpu_info[0], __cpu_info[1], __cpu_info[2],
+__cpu_info[3]);
+}
+#endif
+
 #endif /* __CPUID_H */
diff --git a/clang/test/Headers/__cpuidex_conflict.c 
b/clang/test/Headers/__cpuidex_conflict.c
new file mode 100644
index 0..8687a6aa2f897
--- /dev/null
+++ b/clang/test/Headers/__cpuidex_conflict.c
@@ -0,0 +1,22 @@
+// Make sure that __cpuidex in cpuid.h doesn't conflict with the MS
+// extensions built in by ensuring compilation succeeds:
+// RUN: %clang_cc1 %s -ffreestanding -fms-extensions -fms-compatibility \
+// RUN:  -fms-compatibility-version=19.00 -triple x86_64-pc-windows-msvc 
-emit-llvm -o -
+// %clang_cc1 %s -ffreestanding -triple x86_64-w64-windows-gnu -fms-extensions 
-emit-llvm -o -
+// RUN: %clang_cc1 %s -ffreestanding -fopenmp -fopenmp-is-target-device 
-aux-triple x86_64-unknown-linux-gnu
+
+typedef __SIZE_TYPE__ size_t;
+
+// We declare __cpuidex here as where the buitlin should be exposed (MSVC), the
+// declaration is in , but  is not available from all the
+// targets that are being tested here.
+void __cpuidex (int[4], int, int);
+
+#include 
+
+int cpuid_info[4];
+
+void test_cpuidex(unsigned level, unsigned count) {
+  __cpuidex(cpuid_info, level, count);
+}
+
diff --git a/clang/test/Headers/cpuid.c b/clang/test/Headers/cpuid.c
index 7e485495c1066..6ed12eca7a61d 100644
--- a/clang/test/Headers/cpuid.c
+++ b/clang/test/Headers/cpuid.c
@@ -6,14 +6,19 @@
 
 // CHECK-64: {{.*}} call { i32, i32, i32, i32 } asm "  xchgq  %rbx,${1:q}\0A 
cpuid\0A xchgq %rbx,${1:q}", 
"={ax},=r,={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %{{[a-z0-9]+}})
 // CHECK-64: {{.*}} call { i32, i32, i32, i32 } asm "  xchgq  %rbx,${1:q}\0A  
cpuid\0A  xchgq  %rbx,${1:q}", 
"={ax},=r,={cx},={dx},0,2,~{dirflag},~{fpsr},~{flags}"(i32 %{{[a-z0-9]+}}, i32 
%{{[a-z0-9]+}})
+// CHECK-64: {{.*}} call { i32, i32, i32, i32 } asm "  xchgq  %rbx,${1:q}\0A  
cpuid\0A  xchgq  %rbx,${1:q}", 
"={ax},=r,={cx},={dx},0,2,~{dirflag},~{fpsr},~{flags}"(i32 %{{[a-z0-9]+}}, i32 
%{{[a-z0-9]+}})
 
 // CHECK-32: {{.*}} call { i32, i32, i32, i32 } asm "cpuid", 
"={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %{{[a-z0-9]+}})
 // CHECK-32: {{.*}} call { i32, i32, i32, i32 } asm "cpuid", 
"={ax},={bx},={cx},={dx},0,2,~{dirflag},~{fpsr},~{flags}"(i32 %{{[a-z0-9]+}}, 
i32 %{{[a-z0-9]+}})
+// CHECK-32: {{.*}} call { i32, i32, i32, i32 } asm "cpuid", 
"={ax},={bx},={cx},={dx},0,2,~{dirflag},~{fpsr},~{flags}"(i32 %{{[a-z0-9]+}}, 
i32 %{{[a-z0-9]+}})
 
 unsigned eax0, ebx0, ecx0, edx0;
 unsigned eax1, ebx1, ecx1, edx1;
 
+int cpuid_info[4];
+
 void test_cpuid(unsigned level, unsigned count) {
   __cpuid(level, eax1, ebx1, ecx1, edx1);
   __cpuid_count(level, count, eax0, ebx0, ecx0, edx0);
+  __cpuidex(cpuid_info, level, count);
 }

>From 2afb49b803f291015f5049b811065b80858c07be Mon Sep 17 00:00:00 2001
From: Aiden Grossman 
Date: Thu, 11 Jul 2024 22:53:06 +
Subject: [PATCH 2/2] Format

---
 clang/lib/Headers/cpuid.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/clang/lib/Headers/cpuid.h b/clang/lib/Headers/cpuid.h
index cd55410cda8b7..82d995f1b966a 100644
--- a/clang/lib/Headers/cpuid.h
+++ b/c

[clang] [clang][X86] Add __cpuidex function to cpuid.h (PR #97785)

2024-07-11 Thread Aiden Grossman via cfe-commits

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


[clang] [libcxx] [llvm] Reapply "[Clang] Implement resolution for CWG1835 (#92957)" (PR #98547)

2024-07-11 Thread Krystian Stasiowski via cfe-commits

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


[clang-tools-extra] [clang-doc] Improve performance by adding a short circuit (PR #96809)

2024-07-11 Thread via cfe-commits

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

>From 7733243a7b9660ce2bcbd43f6219314fcd1e4a73 Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Wed, 26 Jun 2024 14:20:03 -0400
Subject: [PATCH 1/9] [clang-doc] add short circuit in mapper

---
 clang-tools-extra/clang-doc/Mapper.cpp| 21 +++
 clang-tools-extra/clang-doc/Mapper.h  |  3 +++
 .../clang-doc/Representation.cpp  |  8 +++
 clang-tools-extra/clang-doc/Representation.h  |  7 +--
 .../clang-doc/tool/ClangDocMain.cpp   | 13 ++--
 5 files changed, 40 insertions(+), 12 deletions(-)

diff --git a/clang-tools-extra/clang-doc/Mapper.cpp 
b/clang-tools-extra/clang-doc/Mapper.cpp
index bb8b7952980ac..ba6311e85a2ee 100644
--- a/clang-tools-extra/clang-doc/Mapper.cpp
+++ b/clang-tools-extra/clang-doc/Mapper.cpp
@@ -17,6 +17,11 @@
 namespace clang {
 namespace doc {
 
+
+static std::unordered_set USRVisited;
+
+static llvm::sys::Mutex USRVisitedGuard;
+
 void MapASTVisitor::HandleTranslationUnit(ASTContext &Context) {
   TraverseDecl(Context.getTranslationUnitDecl());
 }
@@ -34,6 +39,17 @@ template  bool MapASTVisitor::mapDecl(const T 
*D) {
   // If there is an error generating a USR for the decl, skip this decl.
   if (index::generateUSRForDecl(D, USR))
 return true;
+
+  // Prevent Visiting USR twice
+  {
+std::lock_guard Guard(USRVisitedGuard);
+std::string Visited = USR.str().str();
+if (USRVisited.count(Visited)) {
+  return true;
+}
+USRVisited.insert(Visited);
+  }
+
   bool IsFileInRootDir;
   llvm::SmallString<128> File =
   getFile(D, D->getASTContext(), CDCtx.SourceRoot, IsFileInRootDir);
@@ -41,6 +57,11 @@ template  bool MapASTVisitor::mapDecl(const T 
*D) {
getLine(D, D->getASTContext()), File,
IsFileInRootDir, CDCtx.PublicOnly);
 
+  // Bitcode
+  if (CDCtx.NoBitcode) {
+return true;
+  }
+
   // A null in place of I indicates that the serializer is skipping this decl
   // for some reason (e.g. we're only reporting public decls).
   if (I.first)
diff --git a/clang-tools-extra/clang-doc/Mapper.h 
b/clang-tools-extra/clang-doc/Mapper.h
index cedde935ab743..1da7a66f1471a 100644
--- a/clang-tools-extra/clang-doc/Mapper.h
+++ b/clang-tools-extra/clang-doc/Mapper.h
@@ -20,6 +20,8 @@
 #include "Representation.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/Tooling/Execution.h"
+#include "llvm/Support/Mutex.h"
+#include 
 
 using namespace clang::comments;
 using namespace clang::tooling;
@@ -53,6 +55,7 @@ class MapASTVisitor : public 
clang::RecursiveASTVisitor,
 const ASTContext &Context) const;
 
   ClangDocContext CDCtx;
+
 };
 
 } // namespace doc
diff --git a/clang-tools-extra/clang-doc/Representation.cpp 
b/clang-tools-extra/clang-doc/Representation.cpp
index 2afff2929cf79..1ac662b4dd3d2 100644
--- a/clang-tools-extra/clang-doc/Representation.cpp
+++ b/clang-tools-extra/clang-doc/Representation.cpp
@@ -366,13 +366,13 @@ void Index::sort() {
 
 ClangDocContext::ClangDocContext(tooling::ExecutionContext *ECtx,
  StringRef ProjectName, bool PublicOnly,
- StringRef OutDirectory, StringRef SourceRoot,
- StringRef RepositoryUrl,
+ bool NoBitcode, StringRef OutDirectory,
+ StringRef SourceRoot, StringRef RepositoryUrl,
  std::vector UserStylesheets,
  std::vector JsScripts)
 : ECtx(ECtx), ProjectName(ProjectName), PublicOnly(PublicOnly),
-  OutDirectory(OutDirectory), UserStylesheets(UserStylesheets),
-  JsScripts(JsScripts) {
+  NoBitcode(NoBitcode), OutDirectory(OutDirectory),
+  UserStylesheets(UserStylesheets), JsScripts(JsScripts) {
   llvm::SmallString<128> SourceRootDir(SourceRoot);
   if (SourceRoot.empty())
 // If no SourceRoot was provided the current path is used as the default
diff --git a/clang-tools-extra/clang-doc/Representation.h 
b/clang-tools-extra/clang-doc/Representation.h
index a6b144eb7fa2a..00f4f722f8b5a 100644
--- a/clang-tools-extra/clang-doc/Representation.h
+++ b/clang-tools-extra/clang-doc/Representation.h
@@ -480,12 +480,15 @@ mergeInfos(std::vector> &Values);
 struct ClangDocContext {
   ClangDocContext() = default;
   ClangDocContext(tooling::ExecutionContext *ECtx, StringRef ProjectName,
-  bool PublicOnly, StringRef OutDirectory, StringRef 
SourceRoot,
-  StringRef RepositoryUrl,
+  bool NoBitcode, bool PublicOnly, StringRef OutDirectory,
+  StringRef SourceRoot, StringRef RepositoryUrl,
   std::vector UserStylesheets,
   std::vector JsScripts);
+
+  llvm::StringMap>> Infos;
   tooling::ExecutionContext *ECtx;
   std::string Proj

[clang-tools-extra] [clang-doc] Improve performance by adding a short circuit (PR #96809)

2024-07-11 Thread via cfe-commits

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

>From 7733243a7b9660ce2bcbd43f6219314fcd1e4a73 Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Wed, 26 Jun 2024 14:20:03 -0400
Subject: [PATCH 1/8] [clang-doc] add short circuit in mapper

---
 clang-tools-extra/clang-doc/Mapper.cpp| 21 +++
 clang-tools-extra/clang-doc/Mapper.h  |  3 +++
 .../clang-doc/Representation.cpp  |  8 +++
 clang-tools-extra/clang-doc/Representation.h  |  7 +--
 .../clang-doc/tool/ClangDocMain.cpp   | 13 ++--
 5 files changed, 40 insertions(+), 12 deletions(-)

diff --git a/clang-tools-extra/clang-doc/Mapper.cpp 
b/clang-tools-extra/clang-doc/Mapper.cpp
index bb8b7952980ac..ba6311e85a2ee 100644
--- a/clang-tools-extra/clang-doc/Mapper.cpp
+++ b/clang-tools-extra/clang-doc/Mapper.cpp
@@ -17,6 +17,11 @@
 namespace clang {
 namespace doc {
 
+
+static std::unordered_set USRVisited;
+
+static llvm::sys::Mutex USRVisitedGuard;
+
 void MapASTVisitor::HandleTranslationUnit(ASTContext &Context) {
   TraverseDecl(Context.getTranslationUnitDecl());
 }
@@ -34,6 +39,17 @@ template  bool MapASTVisitor::mapDecl(const T 
*D) {
   // If there is an error generating a USR for the decl, skip this decl.
   if (index::generateUSRForDecl(D, USR))
 return true;
+
+  // Prevent Visiting USR twice
+  {
+std::lock_guard Guard(USRVisitedGuard);
+std::string Visited = USR.str().str();
+if (USRVisited.count(Visited)) {
+  return true;
+}
+USRVisited.insert(Visited);
+  }
+
   bool IsFileInRootDir;
   llvm::SmallString<128> File =
   getFile(D, D->getASTContext(), CDCtx.SourceRoot, IsFileInRootDir);
@@ -41,6 +57,11 @@ template  bool MapASTVisitor::mapDecl(const T 
*D) {
getLine(D, D->getASTContext()), File,
IsFileInRootDir, CDCtx.PublicOnly);
 
+  // Bitcode
+  if (CDCtx.NoBitcode) {
+return true;
+  }
+
   // A null in place of I indicates that the serializer is skipping this decl
   // for some reason (e.g. we're only reporting public decls).
   if (I.first)
diff --git a/clang-tools-extra/clang-doc/Mapper.h 
b/clang-tools-extra/clang-doc/Mapper.h
index cedde935ab743..1da7a66f1471a 100644
--- a/clang-tools-extra/clang-doc/Mapper.h
+++ b/clang-tools-extra/clang-doc/Mapper.h
@@ -20,6 +20,8 @@
 #include "Representation.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/Tooling/Execution.h"
+#include "llvm/Support/Mutex.h"
+#include 
 
 using namespace clang::comments;
 using namespace clang::tooling;
@@ -53,6 +55,7 @@ class MapASTVisitor : public 
clang::RecursiveASTVisitor,
 const ASTContext &Context) const;
 
   ClangDocContext CDCtx;
+
 };
 
 } // namespace doc
diff --git a/clang-tools-extra/clang-doc/Representation.cpp 
b/clang-tools-extra/clang-doc/Representation.cpp
index 2afff2929cf79..1ac662b4dd3d2 100644
--- a/clang-tools-extra/clang-doc/Representation.cpp
+++ b/clang-tools-extra/clang-doc/Representation.cpp
@@ -366,13 +366,13 @@ void Index::sort() {
 
 ClangDocContext::ClangDocContext(tooling::ExecutionContext *ECtx,
  StringRef ProjectName, bool PublicOnly,
- StringRef OutDirectory, StringRef SourceRoot,
- StringRef RepositoryUrl,
+ bool NoBitcode, StringRef OutDirectory,
+ StringRef SourceRoot, StringRef RepositoryUrl,
  std::vector UserStylesheets,
  std::vector JsScripts)
 : ECtx(ECtx), ProjectName(ProjectName), PublicOnly(PublicOnly),
-  OutDirectory(OutDirectory), UserStylesheets(UserStylesheets),
-  JsScripts(JsScripts) {
+  NoBitcode(NoBitcode), OutDirectory(OutDirectory),
+  UserStylesheets(UserStylesheets), JsScripts(JsScripts) {
   llvm::SmallString<128> SourceRootDir(SourceRoot);
   if (SourceRoot.empty())
 // If no SourceRoot was provided the current path is used as the default
diff --git a/clang-tools-extra/clang-doc/Representation.h 
b/clang-tools-extra/clang-doc/Representation.h
index a6b144eb7fa2a..00f4f722f8b5a 100644
--- a/clang-tools-extra/clang-doc/Representation.h
+++ b/clang-tools-extra/clang-doc/Representation.h
@@ -480,12 +480,15 @@ mergeInfos(std::vector> &Values);
 struct ClangDocContext {
   ClangDocContext() = default;
   ClangDocContext(tooling::ExecutionContext *ECtx, StringRef ProjectName,
-  bool PublicOnly, StringRef OutDirectory, StringRef 
SourceRoot,
-  StringRef RepositoryUrl,
+  bool NoBitcode, bool PublicOnly, StringRef OutDirectory,
+  StringRef SourceRoot, StringRef RepositoryUrl,
   std::vector UserStylesheets,
   std::vector JsScripts);
+
+  llvm::StringMap>> Infos;
   tooling::ExecutionContext *ECtx;
   std::string Proj

[clang] [HLSL] Split out resource class data from resource attribute (PR #98419)

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


@@ -437,6 +437,33 @@ void SemaHLSL::handleShaderAttr(Decl *D, const ParsedAttr 
&AL) {
 D->addAttr(NewAttr);
 }
 
+void SemaHLSL::handleResourceClassAttr(Decl *D, const ParsedAttr &AL) {
+  if (!AL.isArgIdent(0)) {
+Diag(AL.getLoc(), diag::err_attribute_argument_type)
+<< AL << AANT_ArgumentIdentifier;
+return;
+  }
+
+  IdentifierLoc *Loc = AL.getArgAsIdent(0);
+  StringRef ResourceClassTypeStrRef = Loc->Ident->getName();
+  SourceLocation ArgLoc = Loc->Loc;
+
+  // Validate.
+  llvm::dxil::ResourceClass RC;
+  bool succ = HLSLResourceClassAttr::ConvertStrToResourceClass(
+  ResourceClassTypeStrRef, RC);
+  if (!succ) {
+Diag(ArgLoc, diag::warn_attribute_type_not_supported)
+<< "ResourceClass" << ResourceClassTypeStrRef;
+return;
+  }
+
+  HLSLResourceClassAttr *NewAttr =
+  HLSLResourceClassAttr::Create(getASTContext(), RC, ArgLoc);
+  if (NewAttr)

bob80905 wrote:

I don't think it can be null on further inspection, though I did copy this code 
form the resource binding attr block. I'll remove this unneeded if check.

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


[clang] [clang][CGRecordLayout] Remove dependency on isZeroSize (PR #96422)

2024-07-11 Thread Michael Buch via cfe-commits

https://github.com/Michael137 updated 
https://github.com/llvm/llvm-project/pull/96422

>From 07e603f7afc98e5af31962a5b1f44f4e4c079ebb Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Fri, 21 Jun 2024 12:15:07 +0100
Subject: [PATCH 01/16] [clang][CGRecordLayout] Remove dependency on isZeroSize

This is a follow-up from the conversation starting at
https://github.com/llvm/llvm-project/pull/93809#issuecomment-2173729801

The root problem that motivated the change are external AST
sources that compute `ASTRecordLayout`s themselves instead of
letting Clang compute them from the AST. One such examples is
LLDB using DWARF to get the definitive offsets and sizes of C++
structures. Such layouts should be considered correct (modulo
buggy DWARF), but various assertions and lowering logic around
the `CGRecordLayoutBuilder` relies on the AST having
`[[no_unique_address]]` attached to them. This is a layout-altering
attribute which is not encoded in DWARF. This causes us LLDB to trip
over the various LLVM<->Clang layout consistency checks. There has been
precedent for avoiding such layout-altering attributes to affect
lowering with externally-provided layouts (e.g., packed structs).

This patch proposes to replace the `isZeroSize` checks in
`CGRecordLayoutBuilder` (which roughly means "empty field
with [[no_unique_address]]") with checks for
`CodeGen::isEmptyField`/`CodeGen::isEmptyRecord`.
---
 clang/lib/CodeGen/ABIInfoImpl.cpp |  6 ++---
 clang/lib/CodeGen/ABIInfoImpl.h   |  6 ++---
 clang/lib/CodeGen/CGExpr.cpp  |  3 ++-
 clang/lib/CodeGen/CGRecordLayoutBuilder.cpp   | 14 ++--
 clang/test/CodeGen/X86/x86_64-vaarg.c |  3 ++-
 clang/test/CodeGen/debug-info-packed-struct.c |  2 +-
 clang/test/CodeGen/paren-list-agg-init.cpp| 15 +
 .../CodeGenCXX/2011-12-19-init-list-ctor.cpp  |  6 ++---
 clang/test/CodeGenCXX/auto-var-init.cpp   | 10 -
 .../test/CodeGenCXX/bitfield-access-empty.cpp | 16 +++---
 clang/test/CodeGenCXX/class-layout.cpp|  2 +-
 clang/test/CodeGenCXX/compound-literals.cpp   |  2 +-
 clang/test/CodeGenCXX/exceptions.cpp  |  7 +++---
 .../lambda-deterministic-captures.cpp |  4 +---
 clang/test/CodeGenCXX/ms_struct.cpp   |  4 +---
 clang/test/CodeGenCXX/partial-destruction.cpp | 11 --
 clang/test/CodeGenCXX/pr18962.cpp |  5 ++---
 clang/test/CodeGenCXX/references.cpp  |  4 +---
 clang/test/CodeGenCXX/temporaries.cpp | 12 +-
 clang/test/CodeGenObjCXX/lambda-to-block.mm   |  9 
 clang/test/OpenMP/irbuilder_for_iterator.cpp  | 10 -
 clang/test/OpenMP/irbuilder_for_rangefor.cpp  | 14 +---
 .../test/OpenMP/task_member_call_codegen.cpp  | 22 ---
 clang/test/Sema/ms_class_layout.cpp   | 14 ++--
 24 files changed, 85 insertions(+), 116 deletions(-)

diff --git a/clang/lib/CodeGen/ABIInfoImpl.cpp 
b/clang/lib/CodeGen/ABIInfoImpl.cpp
index e9a26abb77837..92fcc3bc2c5f4 100644
--- a/clang/lib/CodeGen/ABIInfoImpl.cpp
+++ b/clang/lib/CodeGen/ABIInfoImpl.cpp
@@ -248,7 +248,7 @@ Address CodeGen::emitMergePHI(CodeGenFunction &CGF, Address 
Addr1,
   return Address(PHI, Addr1.getElementType(), Align);
 }
 
-bool CodeGen::isEmptyField(ASTContext &Context, const FieldDecl *FD,
+bool CodeGen::isEmptyField(const ASTContext &Context, const FieldDecl *FD,
bool AllowArrays, bool AsIfNoUniqueAddr) {
   if (FD->isUnnamedBitField())
 return true;
@@ -289,8 +289,8 @@ bool CodeGen::isEmptyField(ASTContext &Context, const 
FieldDecl *FD,
   return isEmptyRecord(Context, FT, AllowArrays, AsIfNoUniqueAddr);
 }
 
-bool CodeGen::isEmptyRecord(ASTContext &Context, QualType T, bool AllowArrays,
-bool AsIfNoUniqueAddr) {
+bool CodeGen::isEmptyRecord(const ASTContext &Context, QualType T,
+bool AllowArrays, bool AsIfNoUniqueAddr) {
   const RecordType *RT = T->getAs();
   if (!RT)
 return false;
diff --git a/clang/lib/CodeGen/ABIInfoImpl.h b/clang/lib/CodeGen/ABIInfoImpl.h
index 92986fb431646..e3f373e39c35a 100644
--- a/clang/lib/CodeGen/ABIInfoImpl.h
+++ b/clang/lib/CodeGen/ABIInfoImpl.h
@@ -126,15 +126,15 @@ Address emitMergePHI(CodeGenFunction &CGF, Address Addr1,
 /// is an unnamed bit-field or an (array of) empty record(s). If
 /// AsIfNoUniqueAddr is true, then C++ record fields are considered empty if
 /// the [[no_unique_address]] attribute would have made them empty.
-bool isEmptyField(ASTContext &Context, const FieldDecl *FD, bool AllowArrays,
-  bool AsIfNoUniqueAddr = false);
+bool isEmptyField(const ASTContext &Context, const FieldDecl *FD,
+  bool AllowArrays, bool AsIfNoUniqueAddr = false);
 
 /// isEmptyRecord - Return true iff a structure contains only empty
 /// fields. Note that a structure with a flexible array member is not
 /// considered empty. If AsIfNoUniqueAddr is true, then C++

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

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

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

>From 4e4bcdc19268543a8348736dede46d8f8cad0066 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]]

---
 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   | 84 +++
 ...a-attribute-supported-attributes-list.test |  1 +
 llvm/include/llvm/IR/Intrinsics.td|  3 +
 .../lib/Transforms/Coroutines/CoroCleanup.cpp |  9 +-
 llvm/lib/Transforms/Coroutines/CoroElide.cpp  | 58 -
 llvm/lib/Transforms/Coroutines/Coroutines.cpp |  1 +
 .../coro-elide-structured-concurrency.ll  | 64 ++
 25 files changed, 496 insertions(+), 134 deletions(-)
 create mode 100644 clang/test/CodeGenCoroutines/Inputs/utility.h
 create mode 100644 clang/test/CodeGenCoroutines/coro-structured-concurrency.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 : public CoroutineSuspendExpr {
 public:
   CoawaitExpr(SourceLocation CoawaitLoc, Expr *Operand, Expr *Common,
   Expr *Ready, Expr *Suspend, Expr *Resume,
-  OpaqueValueExpr *OpaqueValue, bool IsImplicit = false)
+  OpaqueValueExpr *CommonExprOpaqueValue, bool IsImplicit = false)
   : CoroutineSuspendExpr(CoawaitExprClass, CoawaitLoc, Operand, Common,
- Ready, Suspend, Resume, OpaqueValue) {
+ Ready, Suspend, Resume, CommonExprOpaqueValue) {
 CoawaitBits.IsImplicit = IsImplicit;
   }
 
@@ -5275,9 +5285,9 @@ class CoyieldExpr : public CoroutineSuspendExpr {
 public:
   CoyieldExpr(SourceLocation CoyieldLoc, Expr *Operand, Expr *Common,
   Expr *Ready, Expr *Suspend, Expr *Resume,
-  OpaqueValueExpr *OpaqueValue)
+  OpaqueValueExpr *CommonExprOpaqueValue)
   : CoroutineSuspendExpr(CoyieldExprClass, CoyieldLoc, Operand, Common,
-  

[clang] [HLSL] Split out resource class data from resource attribute (PR #98419)

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


@@ -115,12 +115,19 @@ struct BuiltinTypeDeclBuilder {
 return addMemberVariable("h", Ty, Access);
   }
 
-  BuiltinTypeDeclBuilder &annotateResourceClass(ResourceClass RC,
-ResourceKind RK, bool IsROV) {
+  BuiltinTypeDeclBuilder &annotateHLSLResource(ResourceKind RK, bool IsROV) {
 if (Record->isCompleteDefinition())
   return *this;
-Record->addAttr(HLSLResourceAttr::CreateImplicit(Record->getASTContext(),
- RC, RK, IsROV));
+Record->addAttr(
+HLSLResourceAttr::CreateImplicit(Record->getASTContext(), RK, IsROV));
+return *this;
+  }
+
+  BuiltinTypeDeclBuilder &annotateHLSLResourceClass(ResourceClass RC) {
+if (Record->isCompleteDefinition())
+  return *this;
+Record->addAttr(
+HLSLResourceClassAttr::CreateImplicit(Record->getASTContext(), RC));

bogner wrote:

It's probably simpler to just keep the one `annotateResourceClass` function and 
add all of the attributes we want there.

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


[clang] [HLSL] Split out resource class data from resource attribute (PR #98419)

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


@@ -437,6 +437,33 @@ void SemaHLSL::handleShaderAttr(Decl *D, const ParsedAttr 
&AL) {
 D->addAttr(NewAttr);
 }
 
+void SemaHLSL::handleResourceClassAttr(Decl *D, const ParsedAttr &AL) {
+  if (!AL.isArgIdent(0)) {
+Diag(AL.getLoc(), diag::err_attribute_argument_type)
+<< AL << AANT_ArgumentIdentifier;
+return;
+  }
+
+  IdentifierLoc *Loc = AL.getArgAsIdent(0);
+  StringRef ResourceClassTypeStrRef = Loc->Ident->getName();
+  SourceLocation ArgLoc = Loc->Loc;
+
+  // Validate.
+  llvm::dxil::ResourceClass RC;
+  bool succ = HLSLResourceClassAttr::ConvertStrToResourceClass(
+  ResourceClassTypeStrRef, RC);
+  if (!succ) {

bogner wrote:

This reads more simply if you just test the result of the function in the if 
condition. Also, you probably don't need quite that verbose of a name for the 
identifier, so I'd probably write this like:
```c++
  if (!HLSLResourceClassAttr::ConvertStrToResourceClass(Identifier, RC)) {
```

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


[clang] [HLSL] Split out resource class data from resource attribute (PR #98419)

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


@@ -437,6 +437,33 @@ void SemaHLSL::handleShaderAttr(Decl *D, const ParsedAttr 
&AL) {
 D->addAttr(NewAttr);
 }
 
+void SemaHLSL::handleResourceClassAttr(Decl *D, const ParsedAttr &AL) {
+  if (!AL.isArgIdent(0)) {
+Diag(AL.getLoc(), diag::err_attribute_argument_type)
+<< AL << AANT_ArgumentIdentifier;
+return;
+  }
+
+  IdentifierLoc *Loc = AL.getArgAsIdent(0);
+  StringRef ResourceClassTypeStrRef = Loc->Ident->getName();
+  SourceLocation ArgLoc = Loc->Loc;
+
+  // Validate.
+  llvm::dxil::ResourceClass RC;
+  bool succ = HLSLResourceClassAttr::ConvertStrToResourceClass(
+  ResourceClassTypeStrRef, RC);
+  if (!succ) {
+Diag(ArgLoc, diag::warn_attribute_type_not_supported)
+<< "ResourceClass" << ResourceClassTypeStrRef;
+return;
+  }
+
+  HLSLResourceClassAttr *NewAttr =
+  HLSLResourceClassAttr::Create(getASTContext(), RC, ArgLoc);
+  if (NewAttr)

bogner wrote:

Can `HLSLResourceClassAttr::Create(...)` fail? Does it actually make sense to 
check if `NewAttr` is null here?

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


[clang] [flang] [mlir] Add basic -mtune support (PR #98517)

2024-07-11 Thread Andrzej Warzyński via cfe-commits

https://github.com/banach-space approved this pull request.


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


[clang] [HLSL] add loop unroll (PR #93879)

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

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


[clang] 92fc1eb - [HLSL] add loop unroll (#93879)

2024-07-11 Thread via cfe-commits

Author: Farzon Lotfi
Date: 2024-07-11T17:08:13-04:00
New Revision: 92fc1eb0c1ae3813f2ac9208e2c74207aae9d23f

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

LOG: [HLSL] add loop unroll (#93879)

spec: https://github.com/microsoft/hlsl-specs/pull/263

- `Attr.td` - Define the HLSL loop attribute hints (unroll and loop)
- `AttrDocs.td` - Add documentation for unroll and loop
- `CGLoopInfo.cpp` - Add codegen for HLSL unroll that maps to clang
unroll expectations
- `ParseStmt.cpp` - For statements if HLSL define DeclSpecAttrs via
MaybeParseMicrosoftAttributes
- `SemaStmtAttr.cpp` - Add the HLSL loop unroll handeling

resolves #70114

dxc examples: 
- for loop: https://hlsl.godbolt.org/z/8EK6Pa139
- while loop:  https://hlsl.godbolt.org/z/ebr5MvEcK
- do while: https://hlsl.godbolt.org/z/be8cedoTs 

Documentation:

![Screenshot_20240531_143000](https://github.com/llvm/llvm-project/assets/1802579/9da9df9b-68a6-49eb-9d4f-e080aa2eff7f)

Added: 
clang/test/CodeGenHLSL/loops/unroll.hlsl
clang/test/SemaHLSL/Loops/unroll.hlsl

Modified: 
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/AttrDocs.td
clang/lib/CodeGen/CGLoopInfo.cpp
clang/lib/Parse/ParseStmt.cpp
clang/lib/Sema/SemaStmtAttr.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index d2d9dd24536cb..6d80f0a0a6586 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -4172,6 +4172,18 @@ def LoopHint : Attr {
   let HasCustomParsing = 1;
 }
 
+/// The HLSL loop attributes
+def HLSLLoopHint: StmtAttr {
+  /// [unroll(directive)]
+  /// [loop]
+  let Spellings = [Microsoft<"unroll">, Microsoft<"loop">];
+  let Args = [UnsignedArgument<"directive", /*opt*/1>];
+  let Subjects = SubjectList<[ForStmt, WhileStmt, DoStmt],
+  ErrorDiag, "'for', 'while', and 'do' 
statements">;
+  let LangOpts = [HLSL];
+  let Documentation = [HLSLLoopHintDocs, HLSLUnrollHintDocs];
+}
+
 def CapturedRecord : InheritableAttr {
   // This attribute has no spellings as it is only ever created implicitly.
   let Spellings = [];

diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index ab4bd003541fa..09cf4f80bd999 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -7343,6 +7343,100 @@ where shaders must be compiled into a library and 
linked at runtime.
   }];
 }
 
+def HLSLLoopHintDocs : Documentation {
+  let Category = DocCatStmt;
+  let Heading = "[loop]";
+  let Content = [{
+The ``[loop]`` directive allows loop optimization hints to be
+specified for the subsequent loop. The directive allows unrolling to
+be disabled and is not compatible with [unroll(x)]. 
+
+Specifying the parameter, ``[loop]``, directs the
+unroller to not unroll the loop. 
+
+.. code-block:: hlsl
+
+  [loop]
+  for (...) {
+...
+  }
+
+.. code-block:: hlsl
+
+  [loop]
+  while (...) {
+...
+  }
+
+.. code-block:: hlsl
+
+  [loop]
+  do {
+...
+  } while (...)
+
+See `hlsl loop extensions 
`_
+for details.
+  }];
+}
+
+def HLSLUnrollHintDocs : Documentation {
+  let Category = DocCatStmt;
+  let Heading = "[unroll(x)], [unroll]";
+  let Content = [{
+Loop unrolling optimization hints can be specified with ``[unroll(x)]``
+. The attribute is placed immediately before a for, while,
+or do-while.
+Specifying the parameter, ``[unroll(_value_)]``, directs the
+unroller to unroll the loop ``_value_`` times. Note: [unroll(x)] is not 
compatible with [loop].
+
+.. code-block:: hlsl
+
+  [unroll(4)]
+  for (...) {
+...
+  }
+
+.. code-block:: hlsl
+
+  [unroll]
+  for (...) {
+...
+  }
+
+.. code-block:: hlsl
+
+  [unroll(4)]
+  while (...) {
+...
+  }
+
+.. code-block:: hlsl
+
+  [unroll]
+  while (...) {
+...
+  }
+
+.. code-block:: hlsl
+
+  [unroll(4)]
+  do {
+...
+  } while (...)
+
+.. code-block:: hlsl
+
+  [unroll]
+  do {
+...
+  } while (...)
+
+See `hlsl loop extensions 
`_
+for details.
+  }];
+}
+
 def ClangRandomizeLayoutDocs : Documentation {
   let Category = DocCatDecl;
   let Heading = "randomize_layout, no_randomize_layout";
@@ -7402,7 +7496,8 @@ b for constant buffer views (CBV).
 
 Register space is specified in the format ``space[number]`` and defaults to 
``space0`` if omitted.
 Here're resource binding examples with and without space:
-.. code-block:: c++
+
+.. code-block:: hlsl
 
   RWBuffer Uav : register(u3, space1);
   Buffer Buf : register(t1);
@@ -7420,7 +7515,7 @@ A subcomponent is a register number, which is an integer. 
A component i

[clang] [HLSL] add loop unroll (PR #93879)

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

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


[clang] [llvm] [AArch64] Make user-visible Arm architecture version strings consistent (PR #98550)

2024-07-11 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-clang

@llvm/pr-subscribers-clang-driver

Author: Jonathan Thackray (jthackray)


Changes

Textual strings for architecture feature flags have not been consistently 
written,
so there are a wide variety of styles, capitalisation, etc. and some are missing
information. I have tidied this up mechanically for AArch64, so that the output 
of
`--print-enabled-extensions` looks much more consistent, since it's 
user-visible.

---

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


90 Files Affected:

- (modified) clang/test/Driver/print-enabled-extensions/aarch64-a64fx.c 
(+14-14) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-ampere1.c 
(+31-31) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-ampere1a.c 
(+31-31) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-ampere1b.c 
(+31-31) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-apple-a10.c 
(+7-7) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-apple-a11.c 
(+13-13) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-apple-a12.c 
(+17-17) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-apple-a13.c 
(+27-27) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-apple-a14.c 
(+30-30) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-apple-a15.c 
(+31-31) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-apple-a16.c 
(+31-31) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-apple-a17.c 
(+31-31) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-apple-a7.c 
(+2-2) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-apple-m4.c 
(+31-31) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-armv8-a.c 
(+1-1) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-armv8-r.c 
(+21-21) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-armv8.1-a.c 
(+7-7) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-armv8.2-a.c 
(+11-11) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-armv8.3-a.c 
(+15-15) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-armv8.4-a.c 
(+25-25) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-armv8.5-a.c 
(+28-28) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-armv8.6-a.c 
(+29-29) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-armv8.7-a.c 
(+29-29) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-armv8.8-a.c 
(+29-29) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-armv8.9-a.c 
(+30-30) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-armv9-a.c 
(+29-29) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-armv9.1-a.c 
(+30-30) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-armv9.2-a.c 
(+30-30) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-armv9.3-a.c 
(+30-30) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-armv9.4-a.c 
(+31-31) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-armv9.5-a.c 
(+31-31) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-carmel.c 
(+12-12) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-cortex-a34.c 
(+3-3) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-cortex-a35.c 
(+3-3) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-cortex-a510.c 
(+30-30) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-cortex-a520.c 
(+31-31) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-cortex-a520ae.c 
(+31-31) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-cortex-a53.c 
(+3-3) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-cortex-a55.c 
(+13-13) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-cortex-a57.c 
(+3-3) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-cortex-a65.c 
(+13-13) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-cortex-a65ae.c 
(+13-13) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-cortex-a710.c 
(+30-30) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-cortex-a715.c 
(+30-30) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-cortex-a72.c 
(+3-3) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-cortex-a720.c 
(+31-31) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-cortex-a720ae.c 
(+31-31) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-cortex-a725.c 
(+31-31) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-cortex-a73.c 
(+3-3) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-cortex-a75.c 
(+13-13) 
- (modified) clang/test/Driver/print-enabled-e

[clang] [llvm] [AArch64] Make user-visible Arm architecture version strings consistent (PR #98550)

2024-07-11 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-aarch64

Author: Jonathan Thackray (jthackray)


Changes

Textual strings for architecture feature flags have not been consistently 
written,
so there are a wide variety of styles, capitalisation, etc. and some are missing
information. I have tidied this up mechanically for AArch64, so that the output 
of
`--print-enabled-extensions` looks much more consistent, since it's 
user-visible.

---

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


90 Files Affected:

- (modified) clang/test/Driver/print-enabled-extensions/aarch64-a64fx.c 
(+14-14) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-ampere1.c 
(+31-31) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-ampere1a.c 
(+31-31) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-ampere1b.c 
(+31-31) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-apple-a10.c 
(+7-7) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-apple-a11.c 
(+13-13) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-apple-a12.c 
(+17-17) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-apple-a13.c 
(+27-27) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-apple-a14.c 
(+30-30) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-apple-a15.c 
(+31-31) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-apple-a16.c 
(+31-31) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-apple-a17.c 
(+31-31) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-apple-a7.c 
(+2-2) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-apple-m4.c 
(+31-31) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-armv8-a.c 
(+1-1) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-armv8-r.c 
(+21-21) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-armv8.1-a.c 
(+7-7) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-armv8.2-a.c 
(+11-11) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-armv8.3-a.c 
(+15-15) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-armv8.4-a.c 
(+25-25) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-armv8.5-a.c 
(+28-28) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-armv8.6-a.c 
(+29-29) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-armv8.7-a.c 
(+29-29) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-armv8.8-a.c 
(+29-29) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-armv8.9-a.c 
(+30-30) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-armv9-a.c 
(+29-29) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-armv9.1-a.c 
(+30-30) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-armv9.2-a.c 
(+30-30) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-armv9.3-a.c 
(+30-30) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-armv9.4-a.c 
(+31-31) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-armv9.5-a.c 
(+31-31) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-carmel.c 
(+12-12) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-cortex-a34.c 
(+3-3) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-cortex-a35.c 
(+3-3) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-cortex-a510.c 
(+30-30) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-cortex-a520.c 
(+31-31) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-cortex-a520ae.c 
(+31-31) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-cortex-a53.c 
(+3-3) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-cortex-a55.c 
(+13-13) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-cortex-a57.c 
(+3-3) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-cortex-a65.c 
(+13-13) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-cortex-a65ae.c 
(+13-13) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-cortex-a710.c 
(+30-30) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-cortex-a715.c 
(+30-30) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-cortex-a72.c 
(+3-3) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-cortex-a720.c 
(+31-31) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-cortex-a720ae.c 
(+31-31) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-cortex-a725.c 
(+31-31) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-cortex-a73.c 
(+3-3) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-cortex-a75.c 
(+13-13) 
- (modified) clang/test/Driver/print-enabled-extensions/aarch64-cortex

[clang] [flang] [flang] Add -fhermetic-module-files (PR #98083)

2024-07-11 Thread Peter Klausler via cfe-commits

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


[clang] 6598795 - [flang] Add -fhermetic-module-files (#98083)

2024-07-11 Thread via cfe-commits

Author: Peter Klausler
Date: 2024-07-11T14:02:44-07:00
New Revision: 65987954d9903e4fa3dfbf1ccac9d942d4af1fbb

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

LOG: [flang] Add -fhermetic-module-files (#98083)

Module files emitted by this Fortran compiler are valid Fortran source
files. Symbols that are USE-associated into modules are represented in
their module files with USE statements and special comments with hash
codes in them to ensure that those USE statements resolve to the same
modules that were used to build the module when its module file was
generated.

This scheme prevents unchecked module file growth in large applications
by not emitting USE-associated symbols redundantly. This problem can be
especially bad when derived type definitions must be repeated in the
module files of their clients, and the clients of those modules, and so
on. However, this scheme has the disadvantage that clients of modules
must be compiled with dependent modules in the module search path.

This new -fhermetic-module-files option causes module file output to be
free of dependences on any non-intrinsic module files; dependent modules
are instead emitted as part of the module file, rather than being
USE-associated. It is intended for top level library module files that
are shipped with binary libraries when it is not convenient to collect
and ship their dependent module files as well.

Fixes https://github.com/llvm/llvm-project/issues/97398.

Added: 
flang/test/Semantics/modfile65.f90

Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Flang.cpp
flang/include/flang/Frontend/CompilerInvocation.h
flang/include/flang/Semantics/semantics.h
flang/lib/Frontend/CompilerInvocation.cpp
flang/lib/Frontend/FrontendAction.cpp
flang/lib/Semantics/mod-file.cpp
flang/lib/Semantics/mod-file.h
flang/lib/Semantics/semantics.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index a4859149bbfe3..f1e8cb87e5321 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -6687,6 +6687,9 @@ defm stack_arrays : BoolOptionWithoutMarshalling<"f", 
"stack-arrays",
 defm loop_versioning : BoolOptionWithoutMarshalling<"f", 
"version-loops-for-stride",
   PosFlag,
NegFlag>;
+
+def fhermetic_module_files : Flag<["-"], "fhermetic-module-files">, 
Group,
+  HelpText<"Emit hermetic module files (no nested USE association)">;
 } // let Visibility = [FC1Option, FlangOption]
 
 def J : JoinedOrSeparate<["-"], "J">,

diff  --git a/clang/lib/Driver/ToolChains/Flang.cpp 
b/clang/lib/Driver/ToolChains/Flang.cpp
index ee8292a508f93..939d89bb1e2fe 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -35,18 +35,26 @@ static void addDashXForInput(const ArgList &Args, const 
InputInfo &Input,
 
 void Flang::addFortranDialectOptions(const ArgList &Args,
  ArgStringList &CmdArgs) const {
-  Args.addAllArgs(
-  CmdArgs, {options::OPT_ffixed_form, options::OPT_ffree_form,
-options::OPT_ffixed_line_length_EQ, options::OPT_fopenacc,
-options::OPT_finput_charset_EQ, options::OPT_fimplicit_none,
-options::OPT_fno_implicit_none, options::OPT_fbackslash,
-options::OPT_fno_backslash, 
options::OPT_flogical_abbreviations,
-options::OPT_fno_logical_abbreviations,
-options::OPT_fxor_operator, options::OPT_fno_xor_operator,
-options::OPT_falternative_parameter_statement,
-options::OPT_fdefault_real_8, options::OPT_fdefault_integer_8,
-options::OPT_fdefault_double_8, options::OPT_flarge_sizes,
-options::OPT_fno_automatic});
+  Args.addAllArgs(CmdArgs, {options::OPT_ffixed_form,
+options::OPT_ffree_form,
+options::OPT_ffixed_line_length_EQ,
+options::OPT_fopenacc,
+options::OPT_finput_charset_EQ,
+options::OPT_fimplicit_none,
+options::OPT_fno_implicit_none,
+options::OPT_fbackslash,
+options::OPT_fno_backslash,
+options::OPT_flogical_abbreviations,
+options::OPT_fno_logical_abbreviations,
+options::OPT_fxor_operator,
+options::OPT_fno_xor_operator,
+options::OPT_falternative_parameter_statement,
+options::OPT_fdefault_real_8,
+options::OPT_

[clang] [C2y] Add documentation to conform to WG14 N3262; NFC (PR #98146)

2024-07-11 Thread John McCall via cfe-commits

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


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


[clang] [libcxx] [llvm] Reapply "[Clang] Implement resolution for CWG1835 (#92957)" (PR #98547)

2024-07-11 Thread Krystian Stasiowski via cfe-commits

sdkrystian wrote:

@chapuni This fixes the Ubuntu-20.04 g++ build issues you brought up in #98252.

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


[clang] [libcxx] [llvm] Reapply "[Clang] Implement resolution for CWG1835 (#92957)" (PR #98547)

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

https://github.com/Endilll commented:

Changes to DR tests look good.

https://github.com/llvm/llvm-project/pull/98547
___
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-11 Thread Fangrui Song via cfe-commits

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

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

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] [libcxx] [llvm] Reapply "[Clang] Implement resolution for CWG1835 (#92957)" (PR #98547)

2024-07-11 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-libcxx

Author: Krystian Stasiowski (sdkrystian)


Changes

Reapplies #92957, fixing an instance where the `template` keyword was 
missing prior to a dependent name in `llvm/ADT/ArrayRef.h`. An 
_alias-declaration_ is used to work around [a bug affecting GCC releases before 
11.1]](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94799) which rejects the 
use of the `template` keyword prior to the _nested-name-specifier_ in the class 
member access (godbolt example [here](https://godbolt.org/z/nEzbnPqbP)).

---

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


47 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+3) 
- (modified) clang/include/clang/AST/ExprCXX.h (+49-43) 
- (modified) clang/include/clang/AST/Stmt.h (+8-7) 
- (modified) clang/include/clang/AST/UnresolvedSet.h (+4) 
- (modified) clang/include/clang/Basic/DiagnosticParseKinds.td (+1-3) 
- (modified) clang/include/clang/Parse/Parser.h (+5-9) 
- (modified) clang/include/clang/Sema/DeclSpec.h (+8) 
- (modified) clang/include/clang/Sema/Lookup.h (+6-2) 
- (modified) clang/include/clang/Sema/Sema.h (+22-32) 
- (modified) clang/lib/AST/ASTImporter.cpp (+9-3) 
- (modified) clang/lib/AST/ExprCXX.cpp (+40-27) 
- (modified) clang/lib/AST/ItaniumMangle.cpp (+15-24) 
- (modified) clang/lib/Parse/ParseExpr.cpp (+3-4) 
- (modified) clang/lib/Parse/ParseExprCXX.cpp (+50-45) 
- (modified) clang/lib/Sema/SemaCXXScopeSpec.cpp (+91-104) 
- (modified) clang/lib/Sema/SemaCoroutine.cpp (+2-2) 
- (modified) clang/lib/Sema/SemaDeclCXX.cpp (+23-24) 
- (modified) clang/lib/Sema/SemaExpr.cpp (+1-1) 
- (modified) clang/lib/Sema/SemaExprMember.cpp (+33-41) 
- (modified) clang/lib/Sema/SemaOverload.cpp (+5-7) 
- (modified) clang/lib/Sema/SemaStmtAsm.cpp (+5-3) 
- (modified) clang/lib/Sema/SemaTemplate.cpp (+105-113) 
- (modified) clang/lib/Sema/SemaTemplateInstantiate.cpp (+7-10) 
- (modified) clang/lib/Sema/TreeTransform.h (+131-198) 
- (modified) clang/lib/Serialization/ASTReaderStmt.cpp (+32-31) 
- (modified) clang/lib/Serialization/ASTWriterStmt.cpp (+25-18) 
- (modified) 
clang/test/CXX/basic/basic.lookup/basic.lookup.classref/p1-cxx11.cpp (+9-5) 
- (modified) clang/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp 
(+9-5) 
- (added) 
clang/test/CXX/basic/basic.lookup/basic.lookup.qual/basic.lookup.qual.general/p3-example3.cpp
 (+27) 
- (added) 
clang/test/CXX/basic/basic.lookup/basic.lookup.qual/basic.lookup.qual.general/p3.cpp
 (+98) 
- (modified) clang/test/CXX/class.derived/class.member.lookup/p8.cpp (+2-2) 
- (modified) clang/test/CXX/drs/cwg1xx.cpp (+4-4) 
- (added) clang/test/CXX/temp/temp.names/p3-23.cpp (+237) 
- (modified) clang/test/CXX/temp/temp.res/p3.cpp (+1-1) 
- (modified) clang/test/FixIt/fixit.cpp (+2-2) 
- (modified) clang/test/Misc/warning-flags.c (+1-1) 
- (modified) clang/test/Parser/cxx2a-concepts-requires-expr.cpp (+1-1) 
- (modified) clang/test/SemaCXX/cxx0x-noexcept-expression.cpp (+3-3) 
- (modified) clang/test/SemaCXX/pseudo-destructors.cpp (+9-9) 
- (modified) clang/test/SemaCXX/static-assert-cxx17.cpp (+1-1) 
- (modified) clang/test/SemaTemplate/dependent-base-classes.cpp (+10-10) 
- (modified) clang/test/SemaTemplate/dependent-template-recover.cpp (+6-6) 
- (modified) clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp (+1-1) 
- (modified) clang/test/SemaTemplate/template-id-expr.cpp (+7-7) 
- (modified) clang/test/SemaTemplate/typename-specifier-3.cpp (+1-1) 
- (modified) libcxx/include/regex (+1-1) 
- (modified) llvm/include/llvm/ADT/ArrayRef.h (+5-2) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index d5446f7fd92cc..be2f06766a755 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -310,6 +310,9 @@ Resolutions to C++ Defect Reports
 - Clang now considers ``noexcept(typeid(expr))`` more carefully, instead of 
always assuming that ``std::bad_typeid`` can be thrown.
   (`CWG2191: Incorrect result for noexcept(typeid(v)) 
`_).
 
+- Clang now correctly implements lookup for the terminal name of a 
member-qualified nested-name-specifier.
+  (`CWG1835: Dependent member lookup before < 
`_).
+
 C Language Changes
 --
 
diff --git a/clang/include/clang/AST/ExprCXX.h 
b/clang/include/clang/AST/ExprCXX.h
index c2feac525c1ea..edaea6fe27cc3 100644
--- a/clang/include/clang/AST/ExprCXX.h
+++ b/clang/include/clang/AST/ExprCXX.h
@@ -3676,9 +3676,9 @@ class CXXUnresolvedConstructExpr final
 /// an implicit access if a qualifier is provided.
 class CXXDependentScopeMemberExpr final
 : public Expr,
-  private llvm::TrailingObjects {
+  private llvm::TrailingObjects<
+  CXXDependentScopeMemberExpr, NestedNameSpecifierLoc, DeclAccessPair,
+  ASTTemplateKWAndArgsInfo, TemplateArgumentLoc> {
   friend class ASTStmtReader;
   

[clang] [libcxx] [llvm] Reapply "[Clang] Implement resolution for CWG1835 (#92957)" (PR #98547)

2024-07-11 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-modules

Author: Krystian Stasiowski (sdkrystian)


Changes

Reapplies #92957, fixing an instance where the `template` keyword was 
missing prior to a dependent name in `llvm/ADT/ArrayRef.h`. An 
_alias-declaration_ is used to work around [a bug affecting GCC releases before 
11.1]](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94799) which rejects the 
use of the `template` keyword prior to the _nested-name-specifier_ in the class 
member access (godbolt example [here](https://godbolt.org/z/nEzbnPqbP)).

---

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


47 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+3) 
- (modified) clang/include/clang/AST/ExprCXX.h (+49-43) 
- (modified) clang/include/clang/AST/Stmt.h (+8-7) 
- (modified) clang/include/clang/AST/UnresolvedSet.h (+4) 
- (modified) clang/include/clang/Basic/DiagnosticParseKinds.td (+1-3) 
- (modified) clang/include/clang/Parse/Parser.h (+5-9) 
- (modified) clang/include/clang/Sema/DeclSpec.h (+8) 
- (modified) clang/include/clang/Sema/Lookup.h (+6-2) 
- (modified) clang/include/clang/Sema/Sema.h (+22-32) 
- (modified) clang/lib/AST/ASTImporter.cpp (+9-3) 
- (modified) clang/lib/AST/ExprCXX.cpp (+40-27) 
- (modified) clang/lib/AST/ItaniumMangle.cpp (+15-24) 
- (modified) clang/lib/Parse/ParseExpr.cpp (+3-4) 
- (modified) clang/lib/Parse/ParseExprCXX.cpp (+50-45) 
- (modified) clang/lib/Sema/SemaCXXScopeSpec.cpp (+91-104) 
- (modified) clang/lib/Sema/SemaCoroutine.cpp (+2-2) 
- (modified) clang/lib/Sema/SemaDeclCXX.cpp (+23-24) 
- (modified) clang/lib/Sema/SemaExpr.cpp (+1-1) 
- (modified) clang/lib/Sema/SemaExprMember.cpp (+33-41) 
- (modified) clang/lib/Sema/SemaOverload.cpp (+5-7) 
- (modified) clang/lib/Sema/SemaStmtAsm.cpp (+5-3) 
- (modified) clang/lib/Sema/SemaTemplate.cpp (+105-113) 
- (modified) clang/lib/Sema/SemaTemplateInstantiate.cpp (+7-10) 
- (modified) clang/lib/Sema/TreeTransform.h (+131-198) 
- (modified) clang/lib/Serialization/ASTReaderStmt.cpp (+32-31) 
- (modified) clang/lib/Serialization/ASTWriterStmt.cpp (+25-18) 
- (modified) 
clang/test/CXX/basic/basic.lookup/basic.lookup.classref/p1-cxx11.cpp (+9-5) 
- (modified) clang/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp 
(+9-5) 
- (added) 
clang/test/CXX/basic/basic.lookup/basic.lookup.qual/basic.lookup.qual.general/p3-example3.cpp
 (+27) 
- (added) 
clang/test/CXX/basic/basic.lookup/basic.lookup.qual/basic.lookup.qual.general/p3.cpp
 (+98) 
- (modified) clang/test/CXX/class.derived/class.member.lookup/p8.cpp (+2-2) 
- (modified) clang/test/CXX/drs/cwg1xx.cpp (+4-4) 
- (added) clang/test/CXX/temp/temp.names/p3-23.cpp (+237) 
- (modified) clang/test/CXX/temp/temp.res/p3.cpp (+1-1) 
- (modified) clang/test/FixIt/fixit.cpp (+2-2) 
- (modified) clang/test/Misc/warning-flags.c (+1-1) 
- (modified) clang/test/Parser/cxx2a-concepts-requires-expr.cpp (+1-1) 
- (modified) clang/test/SemaCXX/cxx0x-noexcept-expression.cpp (+3-3) 
- (modified) clang/test/SemaCXX/pseudo-destructors.cpp (+9-9) 
- (modified) clang/test/SemaCXX/static-assert-cxx17.cpp (+1-1) 
- (modified) clang/test/SemaTemplate/dependent-base-classes.cpp (+10-10) 
- (modified) clang/test/SemaTemplate/dependent-template-recover.cpp (+6-6) 
- (modified) clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp (+1-1) 
- (modified) clang/test/SemaTemplate/template-id-expr.cpp (+7-7) 
- (modified) clang/test/SemaTemplate/typename-specifier-3.cpp (+1-1) 
- (modified) libcxx/include/regex (+1-1) 
- (modified) llvm/include/llvm/ADT/ArrayRef.h (+5-2) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index d5446f7fd92cc..be2f06766a755 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -310,6 +310,9 @@ Resolutions to C++ Defect Reports
 - Clang now considers ``noexcept(typeid(expr))`` more carefully, instead of 
always assuming that ``std::bad_typeid`` can be thrown.
   (`CWG2191: Incorrect result for noexcept(typeid(v)) 
`_).
 
+- Clang now correctly implements lookup for the terminal name of a 
member-qualified nested-name-specifier.
+  (`CWG1835: Dependent member lookup before < 
`_).
+
 C Language Changes
 --
 
diff --git a/clang/include/clang/AST/ExprCXX.h 
b/clang/include/clang/AST/ExprCXX.h
index c2feac525c1ea..edaea6fe27cc3 100644
--- a/clang/include/clang/AST/ExprCXX.h
+++ b/clang/include/clang/AST/ExprCXX.h
@@ -3676,9 +3676,9 @@ class CXXUnresolvedConstructExpr final
 /// an implicit access if a qualifier is provided.
 class CXXDependentScopeMemberExpr final
 : public Expr,
-  private llvm::TrailingObjects {
+  private llvm::TrailingObjects<
+  CXXDependentScopeMemberExpr, NestedNameSpecifierLoc, DeclAccessPair,
+  ASTTemplateKWAndArgsInfo, TemplateArgumentLoc> {
   friend class ASTStmtRead

[clang] [Concepts] Avoid substituting into constraints for invalid TemplateDecls (PR #75697)

2024-07-11 Thread via cfe-commits

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


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


[clang] [Concepts] Avoid substituting into constraints for invalid TemplateDecls (PR #75697)

2024-07-11 Thread via cfe-commits

cor3ntin wrote:

@zyn0217 This fell under the cracks, I'm sorry.
I think this is good enough as is

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


[clang] [clang] Implement gcc_struct attribute on Itanium targets (PR #71148)

2024-07-11 Thread Dan Klishch via cfe-commits

DanShaders wrote:

Fair enough

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


[clang] [clang] Implement gcc_struct attribute on Itanium targets (PR #71148)

2024-07-11 Thread Dan Klishch via cfe-commits

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


[clang-tools-extra] [libc] Update libc namespace clang-tidy checks (PR #98424)

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

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


[clang-tools-extra] a074f88 - [libc] Update libc namespace clang-tidy checks (#98424)

2024-07-11 Thread via cfe-commits

Author: Paul Kirth
Date: 2024-07-11T13:36:07-07:00
New Revision: a074f8869563cb5b296732e0e8af46dcdc286ae5

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

LOG: [libc] Update libc namespace clang-tidy checks (#98424)

This patch updates the clang-tidy checks for llvm-libc to ensure that
the namespace macro used to declare the libc namespace is updated from
LIBC_NAMESPACE to LIBC_NAMESPACE_DECL which by default has hidden
visibility.

Co-authored-by: Prabhu Rajesakeran 

Added: 


Modified: 
clang-tools-extra/clang-tidy/llvmlibc/CalleeNamespaceCheck.cpp
clang-tools-extra/clang-tidy/llvmlibc/ImplementationInNamespaceCheck.cpp
clang-tools-extra/clang-tidy/llvmlibc/NamespaceConstants.h

clang-tools-extra/docs/clang-tidy/checks/llvmlibc/implementation-in-namespace.rst

clang-tools-extra/test/clang-tidy/checkers/llvmlibc/implementation-in-namespace.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/llvmlibc/CalleeNamespaceCheck.cpp 
b/clang-tools-extra/clang-tidy/llvmlibc/CalleeNamespaceCheck.cpp
index af977bff70f7c..caa19c595823f 100644
--- a/clang-tools-extra/clang-tidy/llvmlibc/CalleeNamespaceCheck.cpp
+++ b/clang-tools-extra/clang-tidy/llvmlibc/CalleeNamespaceCheck.cpp
@@ -51,7 +51,7 @@ void CalleeNamespaceCheck::check(const 
MatchFinder::MatchResult &Result) {
   // __llvm_libc, we're good.
   const auto *NS = dyn_cast(getOutermostNamespace(FuncDecl));
   if (NS && Result.SourceManager->isMacroBodyExpansion(NS->getLocation()) &&
-  NS->getName().starts_with(RequiredNamespaceStart))
+  NS->getName().starts_with(RequiredNamespaceRefStart))
 return;
 
   const DeclarationName &Name = FuncDecl->getDeclName();
@@ -62,7 +62,7 @@ void CalleeNamespaceCheck::check(const 
MatchFinder::MatchResult &Result) {
   diag(UsageSiteExpr->getBeginLoc(),
"%0 must resolve to a function declared "
"within the namespace defined by the '%1' macro")
-  << FuncDecl << RequiredNamespaceMacroName;
+  << FuncDecl << RequiredNamespaceRefMacroName;
 
   diag(FuncDecl->getLocation(), "resolves to this declaration",
clang::DiagnosticIDs::Note);

diff  --git 
a/clang-tools-extra/clang-tidy/llvmlibc/ImplementationInNamespaceCheck.cpp 
b/clang-tools-extra/clang-tidy/llvmlibc/ImplementationInNamespaceCheck.cpp
index ae9819ed97502..bb436e4d12a30 100644
--- a/clang-tools-extra/clang-tidy/llvmlibc/ImplementationInNamespaceCheck.cpp
+++ b/clang-tools-extra/clang-tidy/llvmlibc/ImplementationInNamespaceCheck.cpp
@@ -30,20 +30,35 @@ void ImplementationInNamespaceCheck::check(
   const auto *MatchedDecl =
   Result.Nodes.getNodeAs("child_of_translation_unit");
   const auto *NS = dyn_cast(MatchedDecl);
+
+  // LLVM libc declarations should be inside of a non-anonymous namespace.
   if (NS == nullptr || NS->isAnonymousNamespace()) {
 diag(MatchedDecl->getLocation(),
  "declaration must be enclosed within the '%0' namespace")
-<< RequiredNamespaceMacroName;
+<< RequiredNamespaceDeclMacroName;
 return;
   }
+
+  // Enforce that the namespace is the result of macro expansion
   if (Result.SourceManager->isMacroBodyExpansion(NS->getLocation()) == false) {
 diag(NS->getLocation(), "the outermost namespace should be the '%0' macro")
-<< RequiredNamespaceMacroName;
+<< RequiredNamespaceDeclMacroName;
 return;
   }
-  if (NS->getName().starts_with(RequiredNamespaceStart) == false) {
+
+  // We want the macro to have [[gnu::visibility("hidden")]] as a prefix, but
+  // visibility is just an attribute in the AST construct, so we check that
+  // instead.
+  if (NS->getVisibility() != Visibility::HiddenVisibility) {
 diag(NS->getLocation(), "the '%0' macro should start with '%1'")
-<< RequiredNamespaceMacroName << RequiredNamespaceStart;
+<< RequiredNamespaceDeclMacroName << RequiredNamespaceDeclStart;
+return;
+  }
+
+  // Lastly, make sure the namespace name actually has the __llvm_libc prefix
+  if (NS->getName().starts_with(RequiredNamespaceRefStart) == false) {
+diag(NS->getLocation(), "the '%0' macro expansion should start with '%1'")
+<< RequiredNamespaceDeclMacroName << RequiredNamespaceRefStart;
 return;
   }
 }

diff  --git a/clang-tools-extra/clang-tidy/llvmlibc/NamespaceConstants.h 
b/clang-tools-extra/clang-tidy/llvmlibc/NamespaceConstants.h
index 7d4120085b866..83908a7875d03 100644
--- a/clang-tools-extra/clang-tidy/llvmlibc/NamespaceConstants.h
+++ b/clang-tools-extra/clang-tidy/llvmlibc/NamespaceConstants.h
@@ -10,7 +10,11 @@
 
 namespace clang::tidy::llvm_libc {
 
-const static llvm::StringRef RequiredNamespaceStart = "__llvm_libc";
-const static llvm::StringRef RequiredNamespaceMacroName = "LIBC_NAMESPACE";
+const static llvm::StringRef RequiredName

[clang] [clang] Implement gcc_struct attribute on Itanium targets (PR #71148)

2024-07-11 Thread Dan Klishch via cfe-commits

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


[clang] Add __builtin_fma16. (PR #97424)

2024-07-11 Thread Zahira Ammarguellat via cfe-commits

https://github.com/zahiraam updated 
https://github.com/llvm/llvm-project/pull/97424

>From 417d72fdd88fddbd843ff3c19681a07e680852c7 Mon Sep 17 00:00:00 2001
From: Zahira Ammarguellat 
Date: Tue, 2 Jul 2024 07:41:42 -0700
Subject: [PATCH 1/2] Add __builtin_fma16.

---
 clang/include/clang/Basic/Builtins.td  | 6 ++
 clang/lib/CodeGen/CGBuiltin.cpp| 1 +
 clang/test/CodeGen/X86/math-builtins.c | 6 +-
 clang/test/CodeGen/constrained-math-builtins.c | 3 ++-
 4 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/clang/include/clang/Basic/Builtins.td 
b/clang/include/clang/Basic/Builtins.td
index f5b15cf90d1f8..3de13d1d22c95 100644
--- a/clang/include/clang/Basic/Builtins.td
+++ b/clang/include/clang/Basic/Builtins.td
@@ -203,6 +203,12 @@ def FmaF16F128 : Builtin, F16F128MathTemplate {
   let Prototype = "T(T, T, T)";
 }
 
+def Fmaf16 : Builtin, F16F128MathTemplate {
+  let Spellings = ["__builtin_fmaf16"];
+  let Attributes = [FunctionWithBuiltinPrefix, NoThrow, 
ConstIgnoringErrnoAndExceptions];
+  let Prototype = "T(T, T, T)";
+}
+
 def FmaxF16F128 : Builtin, F16F128MathTemplate {
   let Spellings = ["__builtin_fmax"];
   let Attributes = [FunctionWithBuiltinPrefix, NoThrow, Const, Constexpr];
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index ed37267efe715..326a43a33a0ff 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -2587,6 +2587,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
   case Builtin::BI__builtin_fma:
   case Builtin::BI__builtin_fmaf:
   case Builtin::BI__builtin_fmal:
+  case Builtin::BI__builtin_fmaf16:
   case Builtin::BIfma:
   case Builtin::BIfmaf:
   case Builtin::BIfmal: {
diff --git a/clang/test/CodeGen/X86/math-builtins.c 
b/clang/test/CodeGen/X86/math-builtins.c
index 1e0f129b98610..d26db19574051 100644
--- a/clang/test/CodeGen/X86/math-builtins.c
+++ b/clang/test/CodeGen/X86/math-builtins.c
@@ -364,27 +364,31 @@ __builtin_floor(f);  __builtin_floorf(f); 
__builtin_floorl(f); __builtin
 // HAS_ERRNO: declare x86_fp80 @llvm.floor.f80(x86_fp80) [[READNONE_INTRINSIC]]
 // HAS_ERRNO: declare fp128 @llvm.floor.f128(fp128) [[READNONE_INTRINSIC]]
 
-__builtin_fma(f,f,f);__builtin_fmaf(f,f,f);   
__builtin_fmal(f,f,f); __builtin_fmaf128(f,f,f);
+__builtin_fma(f,f,f);__builtin_fmaf(f,f,f);   
__builtin_fmal(f,f,f); __builtin_fmaf128(f,f,f);  __builtin_fmaf16(f,f,f);
 
 // NO__ERRNO: declare double @llvm.fma.f64(double, double, double) 
[[READNONE_INTRINSIC]]
 // NO__ERRNO: declare float @llvm.fma.f32(float, float, float) 
[[READNONE_INTRINSIC]]
 // NO__ERRNO: declare x86_fp80 @llvm.fma.f80(x86_fp80, x86_fp80, x86_fp80) 
[[READNONE_INTRINSIC]]
 // NO__ERRNO: declare fp128 @llvm.fma.f128(fp128, fp128, fp128) 
[[READNONE_INTRINSIC]]
+// NO__ERRONO: declare half @llvm.fma.f16(half, half, half) 
[[READNONE_INTRINSIC]]
 // HAS_ERRNO: declare double @fma(double noundef, double noundef, double 
noundef) [[NOT_READNONE]]
 // HAS_ERRNO: declare float @fmaf(float noundef, float noundef, float noundef) 
[[NOT_READNONE]]
 // HAS_ERRNO: declare x86_fp80 @fmal(x86_fp80 noundef, x86_fp80 noundef, 
x86_fp80 noundef) [[NOT_READNONE]]
 // HAS_ERRNO: declare fp128 @fmaf128(fp128 noundef, fp128 noundef, fp128 
noundef) [[NOT_READNONE]]
+// HAS_ERRNO: declare half @fmaf16(half noundef, half noundef, half noundef) 
[[NOT_READNONE]]
 
 // On GNU or Win, fma never sets errno, so we can convert to the intrinsic.
 
 // HAS_ERRNO_GNU: declare double @llvm.fma.f64(double, double, double) 
[[READNONE_INTRINSIC:#[0-9]+]]
 // HAS_ERRNO_GNU: declare float @llvm.fma.f32(float, float, float) 
[[READNONE_INTRINSIC]]
 // HAS_ERRNO_GNU: declare x86_fp80 @llvm.fma.f80(x86_fp80, x86_fp80, x86_fp80) 
[[READNONE_INTRINSIC]]
+// HAS_ERRNO_GNU: declare half @llvm.fma.f16(half, half, half) 
[[READNONE_INTRINSIC]]
 
 // HAS_ERRNO_WIN: declare double @llvm.fma.f64(double, double, double) 
[[READNONE_INTRINSIC:#[0-9]+]]
 // HAS_ERRNO_WIN: declare float @llvm.fma.f32(float, float, float) 
[[READNONE_INTRINSIC]]
 // Long double is just double on win, so no f80 use/declaration.
 // HAS_ERRNO_WIN-NOT: declare x86_fp80 @llvm.fma.f80(x86_fp80, x86_fp80, 
x86_fp80)
+// HAS_ERRNO_WIN: declare half @llvm.fma.f16(half, half, half) 
[[READNONE_INTRINSIC]]
 
 __builtin_fmax(f,f);   __builtin_fmaxf(f,f);  __builtin_fmaxl(f,f); 
__builtin_fmaxf128(f,f);
 
diff --git a/clang/test/CodeGen/constrained-math-builtins.c 
b/clang/test/CodeGen/constrained-math-builtins.c
index 6cc3a10a1e794..42c9e3c5008a3 100644
--- a/clang/test/CodeGen/constrained-math-builtins.c
+++ b/clang/test/CodeGen/constrained-math-builtins.c
@@ -78,12 +78,13 @@ void foo(double *d, float f, float *fp, long double *l, int 
*i, const char *c, _
 // CHECK: call x86_fp80 @llvm.experimental.constrained.floor.f80(x86_fp80 
%{{.*}}, metadata !"fpexcept.strict")
 // CHECK: call fp128 @llvm.experimenta

[clang] [clang] Stub out gcc_struct attribute (PR #71148)

2024-07-11 Thread Martin Storsjö via cfe-commits

mstorsjo wrote:

> Ping @MaskRay
> 
> Changes in the force-push:
> 
> * rebased on top of main;
> * moved `defaultsToMsStruct` to `ASTContext` since it also depends on 
> auxiliary target.

Please update the subject of the PR - this doesn't stub out the attribute, it 
implements it, if I understand things correctly?

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


[clang] [C2y] Claim partial conformance to WG14 N3244 (PR #98525)

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

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

LGTM

https://github.com/llvm/llvm-project/pull/98525
___
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-11 Thread Yuxuan Chen via cfe-commits

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

>From 9f6d1cce5e6ba693e9d6bd125e19b3c653ee96dd 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]]

---
 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   | 84 +++
 ...a-attribute-supported-attributes-list.test |  1 +
 llvm/include/llvm/IR/Intrinsics.td|  3 +
 .../lib/Transforms/Coroutines/CoroCleanup.cpp |  9 +-
 llvm/lib/Transforms/Coroutines/CoroElide.cpp  | 58 -
 llvm/lib/Transforms/Coroutines/Coroutines.cpp |  1 +
 .../coro-elide-structured-concurrency.ll  | 64 ++
 25 files changed, 496 insertions(+), 134 deletions(-)
 create mode 100644 clang/test/CodeGenCoroutines/Inputs/utility.h
 create mode 100644 clang/test/CodeGenCoroutines/coro-structured-concurrency.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 : public CoroutineSuspendExpr {
 public:
   CoawaitExpr(SourceLocation CoawaitLoc, Expr *Operand, Expr *Common,
   Expr *Ready, Expr *Suspend, Expr *Resume,
-  OpaqueValueExpr *OpaqueValue, bool IsImplicit = false)
+  OpaqueValueExpr *CommonExprOpaqueValue, bool IsImplicit = false)
   : CoroutineSuspendExpr(CoawaitExprClass, CoawaitLoc, Operand, Common,
- Ready, Suspend, Resume, OpaqueValue) {
+ Ready, Suspend, Resume, CommonExprOpaqueValue) {
 CoawaitBits.IsImplicit = IsImplicit;
   }
 
@@ -5275,9 +5285,9 @@ class CoyieldExpr : public CoroutineSuspendExpr {
 public:
   CoyieldExpr(SourceLocation CoyieldLoc, Expr *Operand, Expr *Common,
   Expr *Ready, Expr *Suspend, Expr *Resume,
-  OpaqueValueExpr *OpaqueValue)
+  OpaqueValueExpr *CommonExprOpaqueValue)
   : CoroutineSuspendExpr(CoyieldExprClass, CoyieldLoc, Operand, Common,
-  

[clang] [C2y] Claim partial conformance to WG14 N3244 (PR #98525)

2024-07-11 Thread Aaron Ballman via cfe-commits


@@ -0,0 +1,65 @@
+// RUN: %clang_cc1 -std=c2y %s -verify -Wno-gnu-alignof-expression
+
+/* WG14 N3244: Partial
+ * Slay Some Earthly Demons I
+ *
+ * NB: the committee adopted:
+ *   Annex J Item 21 (including additional change) -- no, we lack explicit 
documentation
+ *   Annex J Item 56 -- yes
+ *   Annex J Item 57 Option 1 -- yes
+ *   Annex J Item 67 -- no
+ *   Annex J Item 69 (alternative wording for semantics) -- no
+ */
+
+void reg_array(void) {
+  // Decay of an array with the register storage class specifier has gone from
+  // explicit undefined behavior to be implementation defined instead. Clang
+  // does not support this.
+  register int array[10];
+  (void)sizeof(array); // okay
+  int *vp = array;// expected-error {{address of register variable 
requested}}
+  int val = array[0]; // expected-error {{address of register variable 
requested}}
+}
+
+struct F;  // expected-note {{forward declaration of 'struct F'}}
+void incomplete_no_linkage(struct F); // okay
+void incomplete_no_linkage(struct F f) { // expected-error {{variable has 
incomplete type 'struct F'}}
+  struct G g; // expected-error {{variable has incomplete type 'struct G'}} \
+ expected-note {{forward declaration of 'struct G'}}
+  int i[];// expected-error {{definition of variable with array type needs 
an explicit size or an initializer}}
+}
+
+void block_scope_non_extern_func_decl(void) {
+  static void f(void); // expected-error {{function declared in block scope 
cannot have 'static' storage class}}
+  extern void g(void); // okay
+  __private_extern__ void h(void); // okay
+}
+
+// FIXME: this function should be diagnosed as it is never defined in the TU.
+extern inline void never_defined_extern_inline(void);
+
+// While this declaration is fine because the function is defined within the 
TU.
+extern inline void is_defined_extern_inline(void);
+extern inline void is_defined_extern_inline(void) {}
+
+int NoAlignmentOnOriginalDecl;
+// FIXME: the original declaration has no alignment specifier, so the
+// declaration below should be diagnosed due to the incompatible alignment
+// specifier.
+_Alignas(8) int NoAlignmentOnOriginalDecl;
+_Static_assert(_Alignof(NoAlignmentOnOriginalDecl) == 8, "");
+
+_Alignas(8) int AlignmentOnOriginalDecl;
+// FIXME: this should be accepted because the redeclaration has no alignment
+// specifier.
+int AlignmentOnOriginalDecl; // expected-error {{'_Alignas' must be specified 
on definition if it is specified on any declaration}}
+_Static_assert(_Alignof(AlignmentOnOriginalDecl) == 8, "");
+
+long long CompatibleAlignment;
+_Static_assert(_Alignof(CompatibleAlignment) == _Alignof(long long), "");
+_Alignas(_Alignof(long long)) long long CompatibleAlignment; // Okay, 
alignment is the same as the implied alignment
+
+_Alignas(_Alignof(long long)) long long CompatibleAlignment2;
+// FIXME: this should be accepted because the redeclaration has no alignment
+// specifier.
+long long CompatibleAlignment2; // expected-error {{'_Alignas' must be 
specified on definition if it is specified on any declaration}}

AaronBallman wrote:

Sure! I could also add some explicitly incompatible alignments as well.

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


[clang] [HLSL] Split out resource class data from resource attribute (PR #98419)

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


@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -x hlsl -ast-dump -o 
- %s | FileCheck %s
+
+
+// CHECK: -HLSLResourceClassAttr 0x{{[0-9a-f]+}} <> SRV
+struct [[hlsl::resource_class(SRV)]] Eg1 {

bogner wrote:

Ah, I hadn't noticed the "struct" subject on the attr definition. It's probably 
ok for now, but it'll definitely need to change.

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


[clang] [HLSL] Split out resource class data from resource attribute (PR #98419)

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


@@ -7,7 +7,7 @@ struct [[hlsl::resource_class()]] Eg1 {
 
 Eg1 e1;
 
-// expected-error@+1{{invalid resource class 'gibberish' used; expected 'SRV', 
'UAV', 'CBuffer', or 'Sampler'}}
+// expected-warning@+1{{ResourceClass attribute argument not supported: 
gibberish}}

bob80905 wrote:

The attribute never gets added, so yes, it is accurate to view this warning as 
a declaration that the attribute is ignored. This is the exact same behavior as 
attaching an HLSL Shader attribute with an invalid argument.
If something requires the attribute to be present, an error would be emitted, 
but if there is no such requirement, I think compilation could succeed.

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


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

2024-07-11 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Haojian Wu (hokein)


Changes

Split out the deduction guide related code from SemaTemplate.cpp to a dedicated 
file.

These code has grown significantly, and moving it to a separate file will 
improve code organization.

---

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


4 Files Affected:

- (modified) clang/include/clang/Sema/Sema.h (+32-15) 
- (modified) clang/lib/Sema/CMakeLists.txt (+1) 
- (modified) clang/lib/Sema/SemaTemplate.cpp (+1-1380) 
- (added) clang/lib/Sema/SemaTemplateDeductionGuide.cpp (+1438) 


``diff
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 57994f4033922..48dff1b76cc57 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -560,13 +560,14 @@ class Sema final : public SemaBase {
   // 23. Statement Attribute Handling (SemaStmtAttr.cpp)
   // 24. C++ Templates (SemaTemplate.cpp)
   // 25. C++ Template Argument Deduction (SemaTemplateDeduction.cpp)
-  // 26. C++ Template Instantiation (SemaTemplateInstantiate.cpp)
-  // 27. C++ Template Declaration Instantiation
+  // 26. C++ Template Deduction Guide (SemaTemplateDeductionGuide.cpp)
+  // 27. C++ Template Instantiation (SemaTemplateInstantiate.cpp)
+  // 28. C++ Template Declaration Instantiation
   // (SemaTemplateInstantiateDecl.cpp)
-  // 28. C++ Variadic Templates (SemaTemplateVariadic.cpp)
-  // 29. Constraints and Concepts (SemaConcept.cpp)
-  // 30. Types (SemaType.cpp)
-  // 31. FixIt Helpers (SemaFixItUtils.cpp)
+  // 29. C++ Variadic Templates (SemaTemplateVariadic.cpp)
+  // 30. Constraints and Concepts (SemaConcept.cpp)
+  // 31. Types (SemaType.cpp)
+  // 32. FixIt Helpers (SemaFixItUtils.cpp)
 
   /// \name Semantic Analysis
   /// Implementations are in Sema.cpp
@@ -11356,6 +11357,10 @@ class Sema final : public SemaBase {
   bool &IsMemberSpecialization, bool &Invalid,
   bool SuppressDiagnostic = false);
 
+  /// Returns the template parameter list with all default template argument
+  /// information.
+  TemplateParameterList *GetTemplateParameterList(TemplateDecl *TD);
+
   DeclResult CheckClassTemplate(
   Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc,
   CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc,
@@ -12019,15 +12024,6 @@ class Sema final : public SemaBase {
  unsigned TemplateDepth,
  const Expr *Constraint);
 
-  /// Declare implicit deduction guides for a class template if we've
-  /// not already done so.
-  void DeclareImplicitDeductionGuides(TemplateDecl *Template,
-  SourceLocation Loc);
-
-  FunctionTemplateDecl *DeclareAggregateDeductionGuideFromInitList(
-  TemplateDecl *Template, MutableArrayRef ParamTypes,
-  SourceLocation Loc);
-
   /// Find the failed Boolean condition within a given Boolean
   /// constant expression, and describe it with a string.
   std::pair findFailedBooleanCondition(Expr *Cond);
@@ -12580,6 +12576,27 @@ class Sema final : public SemaBase {
   //
   //
 
+  /// \name C++ Template Deduction Guide
+  /// Implementations are in SemaTemplateDeductionGuide.cpp
+  ///@{
+
+  /// Declare implicit deduction guides for a class template if we've
+  /// not already done so.
+  void DeclareImplicitDeductionGuides(TemplateDecl *Template,
+  SourceLocation Loc);
+
+  FunctionTemplateDecl *DeclareAggregateDeductionGuideFromInitList(
+  TemplateDecl *Template, MutableArrayRef ParamTypes,
+  SourceLocation Loc);
+
+  ///@}
+
+  //
+  //
+  // -
+  //
+  //
+
   /// \name C++ Template Instantiation
   /// Implementations are in SemaTemplateInstantiate.cpp
   ///@{
diff --git a/clang/lib/Sema/CMakeLists.txt b/clang/lib/Sema/CMakeLists.txt
index 980a83d4431aa..5934c8c30daf9 100644
--- a/clang/lib/Sema/CMakeLists.txt
+++ b/clang/lib/Sema/CMakeLists.txt
@@ -82,6 +82,7 @@ add_clang_library(clangSema
   SemaSystemZ.cpp
   SemaTemplate.cpp
   SemaTemplateDeduction.cpp
+  SemaTemplateDeductionGuide.cpp
   SemaTemplateInstantiate.cpp
   SemaTemplateInstantiateDecl.cpp
   SemaTemplateVariadic.cpp
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 29d668e4fd8d7..bb8ec9738f260 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -1764,7 +1764,7 @@ static void SetNestedNameSpecifier(Sema &S, TagDecl *T,
 
 // Returns the template parameter list with all default template argument
 // information.
-static TemplateParameterList *GetTemplateParameterList(TemplateDecl *TD) {
+TemplateParameterList *Sema::GetTemplateParameterList(TemplateDecl *TD) {
   // Make sure we get the template parameter list from the most
   // recent declarat

[clang] [flang] [mlir] Add basic -mtune support (PR #98517)

2024-07-11 Thread Alexis Perry-Holby via cfe-commits

https://github.com/AlexisPerry updated 
https://github.com/llvm/llvm-project/pull/98517

>From 2e26f0f66f070cd0b684531efc63e63e2e584dfa Mon Sep 17 00:00:00 2001
From: Alexis Perry-Holby 
Date: Thu, 11 Jul 2024 12:51:39 -0600
Subject: [PATCH 1/2] Add basic -mtune support

Initial implementation for the -mtune flag in Flang.
---
 clang/include/clang/Driver/Options.td |  7 +++---
 clang/lib/Driver/ToolChains/Flang.cpp | 10 +++-
 flang/include/flang/Frontend/TargetOptions.h  |  3 +++
 flang/include/flang/Lower/Bridge.h|  6 ++---
 .../flang/Optimizer/CodeGen/CGPasses.td   |  4 +++
 .../include/flang/Optimizer/CodeGen/Target.h  | 21 ++--
 .../Optimizer/Dialect/Support/FIRContext.h|  7 ++
 .../flang/Optimizer/Transforms/Passes.td  |  5 +++-
 flang/lib/Frontend/CompilerInvocation.cpp |  4 +++
 flang/lib/Frontend/FrontendActions.cpp|  3 ++-
 flang/lib/Lower/Bridge.cpp|  3 ++-
 flang/lib/Optimizer/CodeGen/CodeGen.cpp   |  6 -
 flang/lib/Optimizer/CodeGen/Target.cpp| 11 
 flang/lib/Optimizer/CodeGen/TargetRewrite.cpp | 12 -
 flang/lib/Optimizer/CodeGen/TypeConverter.cpp |  3 ++-
 .../Optimizer/Dialect/Support/FIRContext.cpp  | 18 +
 flang/test/Driver/tune-cpu-fir.f90| 25 +++
 flang/test/Lower/tune-cpu-llvm.f90|  8 ++
 flang/tools/bbc/bbc.cpp   |  3 ++-
 flang/tools/tco/tco.cpp   |  4 +++
 flang/unittests/Optimizer/FIRContextTest.cpp  |  5 +++-
 mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td   |  1 +
 mlir/lib/Target/LLVMIR/ModuleImport.cpp   |  5 
 mlir/lib/Target/LLVMIR/ModuleTranslation.cpp  |  3 +++
 mlir/test/Target/LLVMIR/Import/tune-cpu.ll| 16 
 mlir/test/Target/LLVMIR/tune-cpu.mlir | 14 +++
 26 files changed, 190 insertions(+), 17 deletions(-)
 create mode 100644 flang/test/Driver/tune-cpu-fir.f90
 create mode 100644 flang/test/Lower/tune-cpu-llvm.f90
 create mode 100644 mlir/test/Target/LLVMIR/Import/tune-cpu.ll
 create mode 100644 mlir/test/Target/LLVMIR/tune-cpu.mlir

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index cfb37b3c5b474..8d49a4708aaf0 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5436,6 +5436,7 @@ def module_file_info : Flag<["-"], "module-file-info">, 
Flags<[]>,
   HelpText<"Provide information about a particular module file">;
 def mthumb : Flag<["-"], "mthumb">, Group;
 def mtune_EQ : Joined<["-"], "mtune=">, Group,
+  Visibility<[ClangOption, FlangOption]>,
   HelpText<"Only supported on AArch64, PowerPC, RISC-V, SPARC, SystemZ, and 
X86">;
 def multi__module : Flag<["-"], "multi_module">;
 def multiply__defined__unused : Separate<["-"], "multiply_defined_unused">;
@@ -6760,9 +6761,6 @@ def emit_hlfir : Flag<["-"], "emit-hlfir">, 
Group,
 
 let Visibility = [CC1Option, CC1AsOption] in {
 
-def tune_cpu : Separate<["-"], "tune-cpu">,
-  HelpText<"Tune for a specific cpu type">,
-  MarshallingInfoString>;
 def target_abi : Separate<["-"], "target-abi">,
   HelpText<"Target a particular ABI type">,
   MarshallingInfoString>;
@@ -6789,6 +6787,9 @@ def darwin_target_variant_triple : Separate<["-"], 
"darwin-target-variant-triple
 
 let Visibility = [CC1Option, CC1AsOption, FC1Option] in {
 
+def tune_cpu : Separate<["-"], "tune-cpu">,
+  HelpText<"Tune for a specific cpu type">,
+  MarshallingInfoString>;
 def target_cpu : Separate<["-"], "target-cpu">,
   HelpText<"Target a specific cpu type">,
   MarshallingInfoString>;
diff --git a/clang/lib/Driver/ToolChains/Flang.cpp 
b/clang/lib/Driver/ToolChains/Flang.cpp
index ee8292a508f93..7e42bad258cc6 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -15,6 +15,7 @@
 #include "llvm/Frontend/Debug/Options.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
+#include "llvm/TargetParser/Host.h"
 #include "llvm/TargetParser/RISCVISAInfo.h"
 #include "llvm/TargetParser/RISCVTargetParser.h"
 
@@ -411,6 +412,13 @@ void Flang::addTargetOptions(const ArgList &Args,
   }
 
   // TODO: Add target specific flags, ABI, mtune option etc.
+  if (const Arg *A = Args.getLastArg(options::OPT_mtune_EQ)) {
+CmdArgs.push_back("-tune-cpu");
+if (A->getValue() == StringRef{"native"})
+  CmdArgs.push_back(Args.MakeArgString(llvm::sys::getHostCPUName()));
+else
+  CmdArgs.push_back(A->getValue());
+  }
 }
 
 void Flang::addOffloadOptions(Compilation &C, const InputInfoList &Inputs,
@@ -807,7 +815,7 @@ void Flang::ConstructJob(Compilation &C, const JobAction 
&JA,
   case CodeGenOptions::FramePointerKind::None:
 FPKeepKindStr = "-mframe-pointer=none";
 break;
-   case CodeGenOptions::FramePointerKind::Reserved:
+  case CodeGenOptions::FramePointerKind::Reserved:
 FPKeepKindStr = "-mframe-pointer=reserved";
 break;
   case 

[clang] The pragma STDC CX_LIMITED_RANGE ON should have precedence. (PR #98520)

2024-07-11 Thread Zahira Ammarguellat via cfe-commits

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


[clang] [HLSL] Split out resource class data from resource attribute (PR #98419)

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

https://github.com/bob80905 updated 
https://github.com/llvm/llvm-project/pull/98419

>From b740aa9da3baf4fbd32b5a2c59d70bf2f224f700 Mon Sep 17 00:00:00 2001
From: Joshua Batista 
Date: Wed, 10 Jul 2024 17:10:26 -0700
Subject: [PATCH 1/6] split out resource class data from resource attr, add
 some prelim diags and tests

---
 clang/include/clang/Basic/Attr.td | 19 +---
 .../clang/Basic/DiagnosticSemaKinds.td|  1 +
 clang/include/clang/Sema/SemaHLSL.h   |  1 +
 clang/lib/CodeGen/CGHLSLRuntime.cpp   | 12 +++---
 clang/lib/Sema/HLSLExternalSemaSource.cpp | 34 +++
 clang/lib/Sema/SemaDeclAttr.cpp   |  3 ++
 clang/lib/Sema/SemaHLSL.cpp   | 43 +++
 clang/test/AST/HLSL/RWBuffer-AST.hlsl |  6 ++-
 .../ParserHLSL/hlsl_resource_class_attr.hlsl  | 37 
 .../hlsl_resource_class_attr_error.hlsl   | 23 ++
 10 files changed, 149 insertions(+), 30 deletions(-)
 create mode 100644 clang/test/ParserHLSL/hlsl_resource_class_attr.hlsl
 create mode 100644 clang/test/ParserHLSL/hlsl_resource_class_attr_error.hlsl

diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index d2d9dd24536cb..74efff54254c1 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -4549,11 +4549,7 @@ def HLSLResource : InheritableAttr {
   let Spellings = [];
   let Subjects = SubjectList<[Struct]>;
   let LangOpts = [HLSL];
-  let Args = [
-EnumArgument<"ResourceClass", "llvm::hlsl::ResourceClass",
- /*is_string=*/0, ["SRV", "UAV", "CBuffer", "Sampler"],
- ["SRV", "UAV", "CBuffer", "Sampler"],
- /*opt=*/0, /*fake=*/0, /*isExternalType=*/1>,
+  let Args = [
 EnumArgument<
 "ResourceKind", "llvm::hlsl::ResourceKind",
 /*is_string=*/0,
@@ -4577,6 +4573,19 @@ def HLSLResource : InheritableAttr {
   let Documentation = [InternalOnly];
 }
 
+def HLSLResourceClass : InheritableAttr {
+  let Spellings = [CXX11<"hlsl", "resource_class">];
+  let Subjects = SubjectList<[Struct]>;
+  let LangOpts = [HLSL];
+  let Args = [
+   EnumArgument<"ResourceClass", "llvm::hlsl::ResourceClass",
+/*is_string=*/true, ["SRV", "UAV", "CBuffer", 
"Sampler"],
+["SRV", "UAV", "CBuffer", "Sampler"],
+/*opt=*/0, /*fake=*/0, /*isExternalType=*/1>
+  ];
+  let Documentation = [InternalOnly];
+}
+
 def HLSLGroupSharedAddressSpace : TypeAttr {
   let Spellings = [CustomKeyword<"groupshared">];
   let Subjects = SubjectList<[Var]>;
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 940f9ac226ca8..a460179334edf 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -12313,6 +12313,7 @@ def err_hlsl_missing_semantic_annotation : Error<
 def err_hlsl_init_priority_unsupported : Error<
   "initializer priorities are not supported in HLSL">;
 
+def err_hlsl_unsupported_resource_class : Error<"invalid resource class '%0' 
used; expected 'SRV', 'UAV', 'CBuffer', or 'Sampler'">;
 def err_hlsl_unsupported_register_type : Error<"invalid resource class 
specifier '%0' used; expected 'b', 's', 't', or 'u'">;
 def err_hlsl_unsupported_register_number : Error<"register number should be an 
integer">;
 def err_hlsl_expected_space : Error<"invalid space specifier '%0' used; 
expected 'space' followed by an integer, like space1">;
diff --git a/clang/include/clang/Sema/SemaHLSL.h 
b/clang/include/clang/Sema/SemaHLSL.h
index 4d6958a1be3e5..2ddbee67c414b 100644
--- a/clang/include/clang/Sema/SemaHLSL.h
+++ b/clang/include/clang/Sema/SemaHLSL.h
@@ -56,6 +56,7 @@ class SemaHLSL : public SemaBase {
   void handleSV_DispatchThreadIDAttr(Decl *D, const ParsedAttr &AL);
   void handlePackOffsetAttr(Decl *D, const ParsedAttr &AL);
   void handleShaderAttr(Decl *D, const ParsedAttr &AL);
+  void handleResourceClassAttr(Decl *D, const ParsedAttr &AL);
   void handleResourceBindingAttr(Decl *D, const ParsedAttr &AL);
   void handleParamModifierAttr(Decl *D, const ParsedAttr &AL);
 
diff --git a/clang/lib/CodeGen/CGHLSLRuntime.cpp 
b/clang/lib/CodeGen/CGHLSLRuntime.cpp
index 55ba21ae2ba69..9902203d3fae1 100644
--- a/clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ b/clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -280,13 +280,15 @@ void CGHLSLRuntime::annotateHLSLResource(const VarDecl 
*D, GlobalVariable *GV) {
   const auto *RD = Ty->getAsCXXRecordDecl();
   if (!RD)
 return;
-  const auto *Attr = RD->getAttr();
-  if (!Attr)
+  const auto *HLSLResAttr = RD->getAttr();
+  const auto *HLSLResClassAttr = RD->getAttr();
+  if (!HLSLResAttr || !HLSLResClassAttr)
 return;
 
-  llvm::hlsl::ResourceClass RC = Attr->getResourceClass();
-  llvm::hlsl::ResourceKind RK = Attr->getResourceKind();
-  bool IsROV = Attr->getIsROV();
+  llv

[clang] [NFC][Clang] Move set functions out BranchProtectionInfo. (PR #98451)

2024-07-11 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff bf4167fd1d06ff68da2cbea210a4ccfa045694d3 
6c3f68439fd102070f183a77b7d58d49f399b43c --extensions h,cpp -- 
clang/include/clang/Basic/TargetInfo.h clang/lib/CodeGen/TargetInfo.cpp 
clang/lib/CodeGen/TargetInfo.h clang/lib/CodeGen/Targets/AArch64.cpp 
clang/lib/CodeGen/Targets/ARM.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp
index a9e4ff2a82..38faa50cf1 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -215,8 +215,7 @@ void TargetCodeGenInfo::setBranchProtectionFnAttributes(
 }
 
 void TargetCodeGenInfo::setBranchProtectionFnAttributes(
-const TargetInfo::BranchProtectionInfo &BPI,
-llvm::AttrBuilder &FuncAttrs) {
+const TargetInfo::BranchProtectionInfo &BPI, llvm::AttrBuilder &FuncAttrs) 
{
   if (BPI.SignReturnAddr != LangOptions::SignReturnAddressScopeKind::None) {
 FuncAttrs.addAttribute("sign-return-address", BPI.getSignReturnAddrStr());
 FuncAttrs.addAttribute("sign-return-address-key", BPI.getSignKeyStr());

``




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


[clang] [NFC][Clang] Move set functions out BranchProtectionInfo. (PR #98451)

2024-07-11 Thread Daniel Kiss via cfe-commits

DanielKristofKiss wrote:

 #83277 needs the `setBranchProtectionFnAttributes` function but that call is 
from a static function so let's make it static.

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


[clang] [NFC][Clang] Move set functions out BranchProtectionInfo. (PR #98451)

2024-07-11 Thread Daniel Kiss via cfe-commits

https://github.com/DanielKristofKiss updated 
https://github.com/llvm/llvm-project/pull/98451

>From 2ffaf35f09be03e7374bde3d97ee798b01e7e3d1 Mon Sep 17 00:00:00 2001
From: Daniel Kiss 
Date: Thu, 11 Jul 2024 10:29:24 +0200
Subject: [PATCH 1/5] [NFC][Clang] Move setfunctions of BranchProtectionInfo.

Move the to TargetCodeGenInfo.
Refactor of #98329
---
 clang/include/clang/Basic/TargetInfo.h | 23 ---
 clang/lib/CodeGen/TargetInfo.cpp   | 23 +++
 clang/lib/CodeGen/TargetInfo.h |  9 -
 clang/lib/CodeGen/Targets/AArch64.cpp  |  2 +-
 clang/lib/CodeGen/Targets/ARM.cpp  |  4 ++--
 5 files changed, 34 insertions(+), 27 deletions(-)

diff --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index cf7628553647c..a58fb5f979272 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -32,9 +32,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSet.h"
 #include "llvm/Frontend/OpenMP/OMPGridValues.h"
-#include "llvm/IR/Attributes.h"
 #include "llvm/IR/DerivedTypes.h"
-#include "llvm/IR/Function.h"
 #include "llvm/Support/DataTypes.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/VersionTuple.h"
@@ -1410,7 +1408,6 @@ class TargetInfo : public TransferrableTargetInfo,
 bool BranchProtectionPAuthLR;
 bool GuardedControlStack;
 
-  protected:
 const char *getSignReturnAddrStr() const {
   switch (SignReturnAddr) {
   case LangOptions::SignReturnAddressScopeKind::None:
@@ -1433,7 +1430,6 @@ class TargetInfo : public TransferrableTargetInfo,
   llvm_unreachable("Unexpected SignReturnAddressKeyKind");
 }
 
-  public:
 BranchProtectionInfo()
 : SignReturnAddr(LangOptions::SignReturnAddressScopeKind::None),
   SignKey(LangOptions::SignReturnAddressKeyKind::AKey),
@@ -1454,25 +1450,6 @@ class TargetInfo : public TransferrableTargetInfo,
   BranchProtectionPAuthLR = LangOpts.BranchProtectionPAuthLR;
   GuardedControlStack = LangOpts.GuardedControlStack;
 }
-
-void setFnAttributes(llvm::Function &F) {
-  llvm::AttrBuilder FuncAttrs(F.getContext());
-  setFnAttributes(FuncAttrs);
-  F.addFnAttrs(FuncAttrs);
-}
-
-void setFnAttributes(llvm::AttrBuilder &FuncAttrs) {
-  if (SignReturnAddr != LangOptions::SignReturnAddressScopeKind::None) {
-FuncAttrs.addAttribute("sign-return-address", getSignReturnAddrStr());
-FuncAttrs.addAttribute("sign-return-address-key", getSignKeyStr());
-  }
-  if (BranchTargetEnforcement)
-FuncAttrs.addAttribute("branch-target-enforcement");
-  if (BranchProtectionPAuthLR)
-FuncAttrs.addAttribute("branch-protection-pauth-lr");
-  if (GuardedControlStack)
-FuncAttrs.addAttribute("guarded-control-stack");
-}
   };
 
   /// Determine if the Architecture in this TargetInfo supports branch
diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp
index 60224d458f6a2..9ccf0dea9a738 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -19,6 +19,7 @@
 #include "clang/CodeGen/CGFunctionInfo.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/Twine.h"
+#include "llvm/IR/Function.h"
 #include "llvm/IR/Type.h"
 #include "llvm/Support/raw_ostream.h"
 
@@ -206,6 +207,28 @@ llvm::Value *TargetCodeGenInfo::createEnqueuedBlockKernel(
   return F;
 }
 
+void TargetCodeGenInfo::setFnAttributes(
+const TargetInfo::BranchProtectionInfo &BPI, llvm::Function &F) const {
+  llvm::AttrBuilder FuncAttrs(F.getContext());
+  setFnAttributes(BPI, FuncAttrs);
+  F.addFnAttrs(FuncAttrs);
+}
+
+void TargetCodeGenInfo::setFnAttributes(
+const TargetInfo::BranchProtectionInfo &BPI,
+llvm::AttrBuilder &FuncAttrs) const {
+  if (BPI.SignReturnAddr != LangOptions::SignReturnAddressScopeKind::None) {
+FuncAttrs.addAttribute("sign-return-address", BPI.getSignReturnAddrStr());
+FuncAttrs.addAttribute("sign-return-address-key", BPI.getSignKeyStr());
+  }
+  if (BPI.BranchTargetEnforcement)
+FuncAttrs.addAttribute("branch-target-enforcement");
+  if (BPI.BranchProtectionPAuthLR)
+FuncAttrs.addAttribute("branch-protection-pauth-lr");
+  if (BPI.GuardedControlStack)
+FuncAttrs.addAttribute("guarded-control-stack");
+}
+
 namespace {
 class DefaultTargetCodeGenInfo : public TargetCodeGenInfo {
 public:
diff --git a/clang/lib/CodeGen/TargetInfo.h b/clang/lib/CodeGen/TargetInfo.h
index f242d9e36ed40..78c2f94508f8e 100644
--- a/clang/lib/CodeGen/TargetInfo.h
+++ b/clang/lib/CodeGen/TargetInfo.h
@@ -15,11 +15,12 @@
 #define LLVM_CLANG_LIB_CODEGEN_TARGETINFO_H
 
 #include "CGBuilder.h"
-#include "CodeGenModule.h"
 #include "CGValue.h"
+#include "CodeGenModule.h"
 #include "clang/AST/Type.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/SyncScope.h"
+#include "clang/Basic/TargetInfo.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/Str

  1   2   3   4   >