[clang] [Clang][SYCL] Introduce clang-sycl-link-wrapper to link SYCL offloading device code (Part 1 of many) (PR #112245)

2024-10-14 Thread Joseph Huber via cfe-commits

https://github.com/jhuber6 commented:

First pass, I like the approach overall.

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


[clang] [Clang][SYCL] Introduce clang-sycl-link-wrapper to link SYCL offloading device code (Part 1 of many) (PR #112245)

2024-10-14 Thread Joseph Huber via cfe-commits

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


[clang] [Clang][SYCL] Introduce clang-sycl-link-wrapper to link SYCL offloading device code (Part 1 of many) (PR #112245)

2024-10-14 Thread Joseph Huber via cfe-commits


@@ -95,7 +95,19 @@ void SPIRV::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
 
+  // Use of --sycl-link will call the clang-sycl-link-wrapper instead of
+  // the default linker (spirv-link).
+  if (Args.hasArg(options::OPT_sycl_link))
+Linker = ToolChain.GetProgramPath("clang-sycl-link-wrapper");
   C.addCommand(std::make_unique(JA, *this, 
ResponseFileSupport::None(),
  Args.MakeArgString(Linker), CmdArgs,
  Inputs, Output));
 }
+
+SPIRVToolChain::SPIRVToolChain(const Driver &D, const llvm::Triple &Triple,
+   const ArgList &Args)
+: ToolChain(D, Triple, Args) {
+  NativeLLVMSupport = Args.hasArg(options::OPT_sycl_link);

jhuber6 wrote:

Okay I'm guessing this is to separate this from an existing SPIR-V link step? 
We could possibly put that in a different toolchain.

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


[clang] [HIP] Suport LLVM Driver (PR #112249)

2024-10-14 Thread Joseph Huber via cfe-commits


@@ -466,7 +467,7 @@ void HIP::constructGenerateObjFileFromHIPFatBinary(
"-o",  Output.getFilename(),
"-x",  "assembler",
ObjinFile, "-c"};
-  const char *Clang = Args.MakeArgString(C.getDriver().ClangExecutable);
   C.addCommand(std::make_unique(JA, T, ResponseFileSupport::None(),
- Clang, McArgs, Inputs, Output));
+ D.getClangProgramPath(), McArgs,

jhuber6 wrote:

Guess we don't need to `MakeArgString` because the lifetime of the Driver is 
for the whole compilation?

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


[clang] [HIP] Suport LLVM Driver (PR #112249)

2024-10-14 Thread Joseph Huber via cfe-commits

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


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


[clang] [llvm] [clang][aarch64] Add support for the MSVC qualifiers __ptr32, __ptr64, __sptr, __uptr for AArch64 (PR #111879)

2024-10-14 Thread Daniel Paoliello via cfe-commits

https://github.com/dpaoliello updated 
https://github.com/llvm/llvm-project/pull/111879

>From 0f2017d7b9d3a8b0d1eee21f25e22ace58a398cc Mon Sep 17 00:00:00 2001
From: "Daniel Paoliello (HE/HIM)" 
Date: Wed, 9 Oct 2024 16:47:57 -0700
Subject: [PATCH] [clang][aarch64] Add support for the MS qualifiers __ptr32,
 __ptr64, __sptr, __uptr for aarch64

---
 clang/lib/Basic/Targets/AArch64.cpp   | 22 +++---
 clang/lib/Basic/Targets/AArch64.h | 40 +++
 clang/test/CodeGen/aarch64-type-sizes.c   |  2 +-
 clang/test/CodeGen/coff-aarch64-type-sizes.c  |  2 +-
 clang/test/CodeGen/ms-mixed-ptr-sizes.c   | 19 +
 clang/test/CodeGen/target-data.c  |  6 +--
 llvm/lib/IR/AutoUpgrade.cpp   | 23 ++-
 .../Target/AArch64/AArch64TargetMachine.cpp   | 12 --
 .../Bitcode/DataLayoutUpgradeTest.cpp | 13 --
 9 files changed, 112 insertions(+), 27 deletions(-)

diff --git a/clang/lib/Basic/Targets/AArch64.cpp 
b/clang/lib/Basic/Targets/AArch64.cpp
index 61889861c9c803..b96fab978a3fcb 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -143,6 +143,8 @@ AArch64TargetInfo::AArch64TargetInfo(const llvm::Triple 
&Triple,
 IntMaxType = SignedLong;
   }
 
+  AddrSpaceMap = &ARM64AddrSpaceMap;
+
   // All AArch64 implementations support ARMv8 FP, which makes half a legal 
type.
   HasLegalHalfType = true;
   HalfArgsAndReturns = true;
@@ -1533,11 +1535,16 @@ AArch64leTargetInfo::AArch64leTargetInfo(const 
llvm::Triple &Triple,
 void AArch64leTargetInfo::setDataLayout() {
   if (getTriple().isOSBinFormatMachO()) {
 if(getTriple().isArch32Bit())
-  resetDataLayout("e-m:o-p:32:32-i64:64-i128:128-n32:64-S128-Fn32", "_");
+  resetDataLayout("e-m:o-p:32:32-p270:32:32-p271:32:32-p272:64:64-i64:64-"
+  "i128:128-n32:64-S128-Fn32",
+  "_");
 else
-  resetDataLayout("e-m:o-i64:64-i128:128-n32:64-S128-Fn32", "_");
+  resetDataLayout("e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-"
+  "n32:64-S128-Fn32",
+  "_");
   } else
-
resetDataLayout("e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32");
+resetDataLayout("e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-"
+"i64:64-i128:128-n32:64-S128-Fn32");
 }
 
 void AArch64leTargetInfo::getTargetDefines(const LangOptions &Opts,
@@ -1560,7 +1567,8 @@ void AArch64beTargetInfo::getTargetDefines(const 
LangOptions &Opts,
 
 void AArch64beTargetInfo::setDataLayout() {
   assert(!getTriple().isOSBinFormatMachO());
-  resetDataLayout("E-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32");
+  resetDataLayout("E-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-"
+  "i64:64-i128:128-n32:64-S128-Fn32");
 }
 
 WindowsARM64TargetInfo::WindowsARM64TargetInfo(const llvm::Triple &Triple,
@@ -1583,8 +1591,10 @@ WindowsARM64TargetInfo::WindowsARM64TargetInfo(const 
llvm::Triple &Triple,
 
 void WindowsARM64TargetInfo::setDataLayout() {
   resetDataLayout(Triple.isOSBinFormatMachO()
-  ? "e-m:o-i64:64-i128:128-n32:64-S128-Fn32"
-  : 
"e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128-Fn32",
+  ? "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:"
+"128-n32:64-S128-Fn32"
+  : 
"e-m:w-p270:32:32-p271:32:32-p272:64:64-p:64:64-i32:32-"
+"i64:64-i128:128-n32:64-S128-Fn32",
   Triple.isOSBinFormatMachO() ? "_" : "");
 }
 
diff --git a/clang/lib/Basic/Targets/AArch64.h 
b/clang/lib/Basic/Targets/AArch64.h
index 1226ce4d4355c2..16a02e102e045d 100644
--- a/clang/lib/Basic/Targets/AArch64.h
+++ b/clang/lib/Basic/Targets/AArch64.h
@@ -21,6 +21,34 @@
 namespace clang {
 namespace targets {
 
+enum AArch64AddrSpace { ptr32_sptr = 270, ptr32_uptr = 271, ptr64 = 272 };
+
+static const unsigned ARM64AddrSpaceMap[] = {
+0, // Default
+0, // opencl_global
+0, // opencl_local
+0, // opencl_constant
+0, // opencl_private
+0, // opencl_generic
+0, // opencl_global_device
+0, // opencl_global_host
+0, // cuda_device
+0, // cuda_constant
+0, // cuda_shared
+0, // sycl_global
+0, // sycl_global_device
+0, // sycl_global_host
+0, // sycl_local
+0, // sycl_private
+static_cast(AArch64AddrSpace::ptr32_sptr),
+static_cast(AArch64AddrSpace::ptr32_uptr),
+static_cast(AArch64AddrSpace::ptr64),
+0, // hlsl_groupshared
+// Wasm address space values for this target are dummy values,
+// as it is only enabled for Wasm targets.
+20, // wasm_funcref
+};
+
 class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public TargetInfo {
   virtual void setDataLayout() = 0;
   static const TargetInfo::GCCRegAlias GCCRegAliases[];
@@ -207,6 +235,18 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public 
TargetInf

[clang] [NFC] [MTE] Use aarch64-linux-android34 for globals test (PR #112050)

2024-10-14 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `openmp-s390x-linux` 
running on `systemz-1` while building `clang` at step 6 "test-openmp".

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


Here is the relevant piece of the build log for the reference

```
Step 6 (test-openmp) failure: test (failure)
 TEST 'libomp :: tasking/issue-94260-2.c' FAILED 

Exit Code: -11

Command Output (stdout):
--
# RUN: at line 1
/home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.build/./bin/clang 
-fopenmp   -I 
/home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.build/runtimes/runtimes-bins/openmp/runtime/src
 -I 
/home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.src/openmp/runtime/test 
-L 
/home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.build/runtimes/runtimes-bins/openmp/runtime/src
  -fno-omit-frame-pointer -mbackchain -I 
/home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.src/openmp/runtime/test/ompt
 
/home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.src/openmp/runtime/test/tasking/issue-94260-2.c
 -o 
/home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.build/runtimes/runtimes-bins/openmp/runtime/test/tasking/Output/issue-94260-2.c.tmp
 -lm -latomic && 
/home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.build/runtimes/runtimes-bins/openmp/runtime/test/tasking/Output/issue-94260-2.c.tmp
# executed command: 
/home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.build/./bin/clang 
-fopenmp -I 
/home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.build/runtimes/runtimes-bins/openmp/runtime/src
 -I 
/home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.src/openmp/runtime/test 
-L 
/home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.build/runtimes/runtimes-bins/openmp/runtime/src
 -fno-omit-frame-pointer -mbackchain -I 
/home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.src/openmp/runtime/test/ompt
 
/home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.src/openmp/runtime/test/tasking/issue-94260-2.c
 -o 
/home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.build/runtimes/runtimes-bins/openmp/runtime/test/tasking/Output/issue-94260-2.c.tmp
 -lm -latomic
# executed command: 
/home/uweigand/sandbox/buildbot/openmp-s390x-linux/llvm.build/runtimes/runtimes-bins/openmp/runtime/test/tasking/Output/issue-94260-2.c.tmp
# note: command had no output on stdout or stderr
# error: command failed with exit status: -11

--




```



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


[clang] [Clang] Allow all address spaces to be converted to the default (PR #112248)

2024-10-14 Thread Matt Arsenault via cfe-commits


@@ -721,7 +721,9 @@ class Qualifiers {
// to implicitly cast into the default address space.
(A == LangAS::Default &&
 (B == LangAS::cuda_constant || B == LangAS::cuda_device ||
- B == LangAS::cuda_shared));
+ B == LangAS::cuda_shared)) ||
+   // Otherwise, assume the default address space is compatible.
+   (A == LangAS::Default);

arsenm wrote:

Default is kind of broken, at least for OpenCL. Should avoid attaching any 
behavior to it 

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


[clang] [Headers] [ARM64EC] Fix extra tokens inside intrin0.h preprocessor directive (PR #112066)

2024-10-14 Thread Martin Storsjö via cfe-commits

mstorsjo wrote:

I think it's backport worthy. It's very small and has a near zero regression 
risk, and is a quite obvious fix. It might be a bit late for 19.1.2 which 
should be cut tomorrow, but should probably make it for 19.1.3.

Just add this PR to the right 19.x milestone and type a `/cherry-pick` comment 
here with the commit hash, and the bots should do the rest.

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


[clang] [flang] [clang][flang] Support -time in both clang and flang (PR #109165)

2024-10-14 Thread Tom Eccles via cfe-commits

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

Thanks for this!

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


[clang] [flang] [clang][flang] Support -time in both clang and flang (PR #109165)

2024-10-14 Thread Tom Eccles via cfe-commits

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


[clang] [flang] [clang][flang] Support -time in both clang and flang (PR #109165)

2024-10-14 Thread Tom Eccles via cfe-commits


@@ -194,11 +197,29 @@ int Compilation::ExecuteCommand(const Command &C,
   if (LogOnly)
 return 0;
 
+  // We don't use any timers or llvm::TimeGroup's because those are tied into
+  // the global static timer list which, in principle, could be cleared without
+  // us knowing about it.
+  llvm::TimeRecord StartTime;
+  if (getArgs().hasArg(options::OPT_time)) {
+StartTime = llvm::TimeRecord::getCurrentTime(true);

tblah wrote:

nit
```suggestion
StartTime = llvm::TimeRecord::getCurrentTime(/*Start=*/true);
```

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


[clang] [flang] [clang][flang] Support -time in both clang and flang (PR #109165)

2024-10-14 Thread Tom Eccles via cfe-commits


@@ -194,11 +197,29 @@ int Compilation::ExecuteCommand(const Command &C,
   if (LogOnly)
 return 0;
 
+  // We don't use any timers or llvm::TimeGroup's because those are tied into
+  // the global static timer list which, in principle, could be cleared without
+  // us knowing about it.
+  llvm::TimeRecord StartTime;
+  if (getArgs().hasArg(options::OPT_time)) {
+StartTime = llvm::TimeRecord::getCurrentTime(true);
+  }
+
   std::string Error;
   bool ExecutionFailed;
   int Res = C.Execute(Redirects, &Error, &ExecutionFailed);
   if (PostCallback)
 PostCallback(C, Res);
+
+  if (getArgs().hasArg(options::OPT_time)) {
+llvm::TimeRecord Time = llvm::TimeRecord::getCurrentTime(false);

tblah wrote:

nit
```suggestion
llvm::TimeRecord Time = llvm::TimeRecord::getCurrentTime(/*Start=*/false);
```

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


[clang] [llvm] [clang][aarch64] Add support for the MSVC qualifiers __ptr32, __ptr64, __sptr, __uptr for AArch64 (PR #111879)

2024-10-14 Thread Eli Friedman via cfe-commits


@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -triple x86_64-windows-msvc -fms-extensions -emit-llvm -O2 
< %s | FileCheck %s --check-prefixes=X64,ALL
 // RUN: %clang_cc1 -triple i386-pc-win32 -fms-extensions -emit-llvm -O2 < %s | 
FileCheck %s --check-prefixes=X86,ALL
+// RUN: %clang_cc1 -triple aarch64-windows-msvc -fms-extensions -emit-llvm -O2 
< %s | FileCheck %s --check-prefixes=AARCH64,ALL

efriedma-quic wrote:

Do we also need some tests in the backend?  I guess most things likely work 
because we already did most of the work for the aarch64_32 ABI, but I'd like to 
see some tests that the basics work (load/store/arguments/return values).

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


[clang] [llvm] [clang][aarch64] Add support for the MSVC qualifiers __ptr32, __ptr64, __sptr, __uptr for AArch64 (PR #111879)

2024-10-14 Thread Eli Friedman via cfe-commits


@@ -5570,15 +5583,7 @@ std::string llvm::UpgradeDataLayoutString(StringRef DL, 
StringRef TT) {
   if (!T.isX86())
 return Res;
 
-  // If the datalayout matches the expected format, add pointer size address
-  // spaces to the datalayout.
-  std::string AddrSpaces = "-p270:32:32-p271:32:32-p272:64:64";
-  if (StringRef Ref = Res; !Ref.contains(AddrSpaces)) {
-SmallVector Groups;
-Regex R("(e-m:[a-z](-p:32:32)?)(-[if]64:.*$)");
-if (R.match(Res, &Groups))
-  Res = (Groups[1] + AddrSpaces + Groups[3]).str();
-  }
+  AddPtr32Ptr64AddrSpaces();

efriedma-quic wrote:

If there isn't any existing code using the new address-spaces, autoupgrading 
like this should work smoothly, I think?  Need to make sure the autoupgraded 
string matches the new string, but otherwise should be fine.  (I remember last 
time we made major changes for x86, the 128-bit integer alignment change, it 
was sort of tricky, but the issue mostly wasn't the layout string itself.)



Having a dedicated address-space for __ptr64 is a little strange, but I guess 
if that's what we did on x86, there isn't really a reason to deviate.

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


[clang] [Headers] [ARM64EC] Fix extra tokens inside intrin0.h preprocessor directive (PR #112066)

2024-10-14 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `lldb-aarch64-ubuntu` 
running on `linaro-lldb-aarch64-ubuntu` while building `clang` at step 6 "test".

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


Here is the relevant piece of the build log for the reference

```
Step 6 (test) failure: build (failure)
...
PASS: lldb-unit :: Utility/./UtilityTests/5/8 (2029 of 2038)
PASS: lldb-unit :: ValueObject/./LLDBValueObjectTests/1/3 (2030 of 2038)
PASS: lldb-unit :: ValueObject/./LLDBValueObjectTests/2/3 (2031 of 2038)
PASS: lldb-unit :: tools/lldb-server/tests/./LLDBServerTests/0/2 (2032 of 2038)
PASS: lldb-unit :: tools/lldb-server/tests/./LLDBServerTests/1/2 (2033 of 2038)
PASS: lldb-unit :: Host/./HostTests/11/12 (2034 of 2038)
PASS: lldb-unit :: Target/./TargetTests/11/14 (2035 of 2038)
PASS: lldb-unit :: Host/./HostTests/3/12 (2036 of 2038)
PASS: lldb-unit :: Process/gdb-remote/./ProcessGdbRemoteTests/8/9 (2037 of 2038)
UNRESOLVED: lldb-api :: tools/lldb-server/TestLldbGdbServer.py (2038 of 2038)
 TEST 'lldb-api :: tools/lldb-server/TestLldbGdbServer.py' 
FAILED 
Script:
--
/usr/bin/python3.10 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/dotest.py
 -u CXXFLAGS -u CFLAGS --env ARCHIVER=/usr/local/bin/llvm-ar --env 
OBJCOPY=/usr/bin/llvm-objcopy --env 
LLVM_LIBS_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./lib --env 
LLVM_INCLUDE_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/include 
--env LLVM_TOOLS_DIR=/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin 
--arch aarch64 --build-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex 
--lldb-module-cache-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex/module-cache-lldb/lldb-api
 --clang-module-cache-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/lldb-test-build.noindex/module-cache-clang/lldb-api
 --executable /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/lldb 
--compiler /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/clang 
--dsymutil /home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin/dsymutil 
--make /usr/bin/make --llvm-tools-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./bin --lldb-obj-root 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/tools/lldb --lldb-libs-dir 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/./lib 
/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/llvm-project/lldb/test/API/tools/lldb-server
 -p TestLldbGdbServer.py
--
Exit Code: 1

Command Output (stdout):
--
lldb version 20.0.0git (https://github.com/llvm/llvm-project.git revision 
9bf68c2400e8966511332dfbf5c0f05e8a3300fa)
  clang revision 9bf68c2400e8966511332dfbf5c0f05e8a3300fa
  llvm revision 9bf68c2400e8966511332dfbf5c0f05e8a3300fa
Skipping the following test categories: ['libc++', 'dsym', 'gmodules', 
'debugserver', 'objc']

--
Command Output (stderr):
--
UNSUPPORTED: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_Hc_then_Csignal_signals_correct_thread_launch_debugserver 
(TestLldbGdbServer.LldbGdbServerTestCase) (test case does not fall in any 
category of interest for this run) 
PASS: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_Hc_then_Csignal_signals_correct_thread_launch_llgs 
(TestLldbGdbServer.LldbGdbServerTestCase)
PASS: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_Hg_fails_on_another_pid_llgs (TestLldbGdbServer.LldbGdbServerTestCase)
PASS: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_Hg_fails_on_minus_one_pid_llgs (TestLldbGdbServer.LldbGdbServerTestCase)
PASS: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_Hg_fails_on_zero_pid_llgs (TestLldbGdbServer.LldbGdbServerTestCase)
UNSUPPORTED: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_Hg_switches_to_3_threads_launch_debugserver 
(TestLldbGdbServer.LldbGdbServerTestCase) (test case does not fall in any 
category of interest for this run) 
PASS: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_Hg_switches_to_3_threads_launch_llgs 
(TestLldbGdbServer.LldbGdbServerTestCase)
UNSUPPORTED: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_P_and_p_thread_suffix_work_debugserver 
(TestLldbGdbServer.LldbGdbServerTestCase) (test case does not fall in any 
category of interest for this run) 
PASS: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_P_and_p_thread_suffix_work_llgs (TestLldbGdbServer.LldbGdbServerTestCase)
UNSUPPORTED: LLDB 
(/home/tcwg-buildbot/worker/lldb-aarch64-ubuntu/build/bin/clang-aarch64) :: 
test_P_writes_all_gpr_registers_debugserver 
(TestLldbGdbServer.LldbGdbServe

[clang] [Headers] [ARM64EC] Fix extra tokens inside intrin0.h preprocessor directive (PR #112066)

2024-10-14 Thread via cfe-commits

llvmbot wrote:


>I think it's backport worthy. It's very small and has a near zero regression 
>risk, and is a quite obvious fix. It might be a bit late for 19.1.2 which 
>should be cut tomorrow, but should probably make it for 19.1.3.
>
>Just add this PR to the right 19.x milestone and type a `/cherry-pick` comment 
>here with the commit hash, and the bots should do the rest.

Error: Command failed due to missing milestone.

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


[clang] [HIP] Suport LLVM Driver (PR #112249)

2024-10-14 Thread Joseph Huber via cfe-commits

jhuber6 wrote:

Thanks for fixing this, didn't even know the `getPrependArg` was something we 
supported. Sorry for the extra work.

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


[clang] [llvm] Add ifunc support for Windows on AArch64. (PR #111962)

2024-10-14 Thread Alexandros Lamprineas via cfe-commits


@@ -1505,6 +1505,10 @@ class TargetInfo : public TransferrableTargetInfo,
   bool supportsIFunc() const {
 if (getTriple().isOSBinFormatMachO())
   return true;
+if (getTriple().isOSWindows() && getTriple().isAArch64())
+  return true;
+if (getTriple().getArch() == llvm::Triple::ArchType::avr)

labrinea wrote:

Is this an unrelated change?

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


[clang] [llvm] Add ifunc support for Windows on AArch64. (PR #111962)

2024-10-14 Thread Alexandros Lamprineas via cfe-commits


@@ -0,0 +1,65 @@
+// RUN: %clang_cc1 -triple aarch64-pc-windows-msvc -emit-llvm -o - %s | 
FileCheck %s

labrinea wrote:

Is this test file specific to AArch64? If so is it worth adding an 'aarch64-' 
prefix to it?

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


[clang] [llvm] [llvm] Support llvm::Any across shared libraries on windows (PR #108051)

2024-10-14 Thread Thomas Fransham via cfe-commits

https://github.com/fsfod updated 
https://github.com/llvm/llvm-project/pull/108051

>From e39aee57ce8a98723f40f67ae33808bc6213c61d Mon Sep 17 00:00:00 2001
From: Thomas Fransham 
Date: Sat, 7 Sep 2024 15:53:09 +0100
Subject: [PATCH 1/4] [llvm] Support llvm::Any across shared libraries on
 windows in a limited form

Explicitly import and export Any::TypeId template instantiations for uses of 
llvm::Any
in the LLVM codebase to support LLVM Windows shared library builds.
This change is required to allow external code to use PassManager callbacks
including LLVM's own tests for it.
Remove the only use of llvm::Any for LoopNest that only existed in debug code 
and
there was no code creating Any
---
 llvm/include/llvm/Analysis/LazyCallGraph.h |  5 +
 llvm/include/llvm/IR/PassInstrumentation.h | 12 +++-
 llvm/lib/Analysis/LazyCallGraph.cpp|  4 
 llvm/lib/IR/PassInstrumentation.cpp|  6 ++
 llvm/lib/Transforms/Scalar/LoopPassManager.cpp |  2 --
 llvm/unittests/IR/PassBuilderCallbacksTest.cpp |  2 --
 6 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/llvm/include/llvm/Analysis/LazyCallGraph.h 
b/llvm/include/llvm/Analysis/LazyCallGraph.h
index e7fd18967d9bed..55060f506c3330 100644
--- a/llvm/include/llvm/Analysis/LazyCallGraph.h
+++ b/llvm/include/llvm/Analysis/LazyCallGraph.h
@@ -34,6 +34,7 @@
 #ifndef LLVM_ANALYSIS_LAZYCALLGRAPH_H
 #define LLVM_ANALYSIS_LAZYCALLGRAPH_H
 
+#include "llvm/ADT/Any.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/PointerIntPair.h"
@@ -1308,6 +1309,10 @@ class LazyCallGraphDOTPrinterPass
   static bool isRequired() { return true; }
 };
 
+#ifdef _WIN32
+extern template struct LLVM_TEMPLATE_ABI
+Any::TypeId;
+#endif
 } // end namespace llvm
 
 #endif // LLVM_ANALYSIS_LAZYCALLGRAPH_H
diff --git a/llvm/include/llvm/IR/PassInstrumentation.h 
b/llvm/include/llvm/IR/PassInstrumentation.h
index 9fcc2d5957a30c..c41c287f5f1e99 100644
--- a/llvm/include/llvm/IR/PassInstrumentation.h
+++ b/llvm/include/llvm/IR/PassInstrumentation.h
@@ -50,10 +50,11 @@
 #define LLVM_IR_PASSINSTRUMENTATION_H
 
 #include "llvm/ADT/Any.h"
+#include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/FunctionExtras.h"
 #include "llvm/ADT/SmallVector.h"
-#include "llvm/ADT/DenseMap.h"
 #include "llvm/IR/PassManager.h"
+#include "llvm/Support/Compiler.h"
 #include 
 #include 
 
@@ -61,6 +62,15 @@ namespace llvm {
 
 class PreservedAnalyses;
 class StringRef;
+class Module;
+class Loop;
+class Function;
+
+#ifdef _WIN32
+extern template struct LLVM_TEMPLATE_ABI Any::TypeId;
+extern template struct LLVM_TEMPLATE_ABI Any::TypeId;
+extern template struct LLVM_TEMPLATE_ABI Any::TypeId;
+#endif
 
 /// This class manages callbacks registration, as well as provides a way for
 /// PassInstrumentation to pass control to the registered callbacks.
diff --git a/llvm/lib/Analysis/LazyCallGraph.cpp 
b/llvm/lib/Analysis/LazyCallGraph.cpp
index e6bf8c9cbb289f..9d74bce98122bb 100644
--- a/llvm/lib/Analysis/LazyCallGraph.cpp
+++ b/llvm/lib/Analysis/LazyCallGraph.cpp
@@ -37,6 +37,10 @@ using namespace llvm;
 
 #define DEBUG_TYPE "lcg"
 
+#ifdef _WIN32
+template struct LLVM_EXPORT_TEMPLATE Any::TypeId;
+#endif
+
 void LazyCallGraph::EdgeSequence::insertEdgeInternal(Node &TargetN,
  Edge::Kind EK) {
   EdgeIndexMap.try_emplace(&TargetN, Edges.size());
diff --git a/llvm/lib/IR/PassInstrumentation.cpp 
b/llvm/lib/IR/PassInstrumentation.cpp
index 0c4e7698d9fa87..134990eee26988 100644
--- a/llvm/lib/IR/PassInstrumentation.cpp
+++ b/llvm/lib/IR/PassInstrumentation.cpp
@@ -17,6 +17,12 @@
 
 namespace llvm {
 
+#ifdef _WIN32
+template struct LLVM_EXPORT_TEMPLATE Any::TypeId;
+template struct LLVM_EXPORT_TEMPLATE Any::TypeId;
+template struct LLVM_EXPORT_TEMPLATE Any::TypeId;
+#endif
+
 void PassInstrumentationCallbacks::addClassToPassName(StringRef ClassName,
   StringRef PassName) {
   ClassToPassName.try_emplace(ClassName, PassName.str());
diff --git a/llvm/lib/Transforms/Scalar/LoopPassManager.cpp 
b/llvm/lib/Transforms/Scalar/LoopPassManager.cpp
index 5ef25c21162fe2..3b08d5889edb12 100644
--- a/llvm/lib/Transforms/Scalar/LoopPassManager.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopPassManager.cpp
@@ -273,8 +273,6 @@ PreservedAnalyses FunctionToLoopPassAdaptor::run(Function 
&F,
llvm::any_cast(&IR));
 const Loop **LPtr = llvm::any_cast(&IR);
 const Loop *L = LPtr ? *LPtr : nullptr;
-if (!L)
-  L = &llvm::any_cast(IR)->getOutermostLoop();
 assert(L && "Loop should be valid for printing");
 
 // Verify the loop structure and LCSSA form before visiting the loop.
diff --git a/llvm/unittests/IR/PassBuilderCallbacksTest.cpp 
b/llvm/unittests/IR/PassBuilderCallbacksTest.cpp
index 6230aed7b7119b..9aad6e3ca91255 100644
--- a/llvm/unittests/IR/PassBuilderCallbacksTest.cpp
+++ b/llvm/unittests/IR/PassBuilderCallbacksTest.cpp
@

[clang] [llvm] [llvm] Support llvm::Any across shared libraries on windows (PR #108051)

2024-10-14 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 39ac8b25cdca230509078d575d46c538bdf90e18 
d336c456a93b36b1a15fd1cbf1a80275b2704525 --extensions h,cpp -- 
clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h 
clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp 
llvm/include/llvm/Analysis/LazyCallGraph.h 
llvm/include/llvm/IR/PassInstrumentation.h llvm/lib/Analysis/LazyCallGraph.cpp 
llvm/lib/IR/PassInstrumentation.cpp 
llvm/lib/Transforms/Scalar/LoopPassManager.cpp 
llvm/unittests/IR/PassBuilderCallbacksTest.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h 
b/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h
index 8261dcf828..3d49a45a90 100644
--- a/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h
+++ b/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h
@@ -39,7 +39,7 @@ namespace clang {
 namespace dataflow {
 class NoopLattice;
 }
-}
+} // namespace clang
 
 namespace llvm {
 extern template struct CLANG_TEMPLATE_ABI

``




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


[clang-tools-extra] [llvm] [llvm] add support for mustache templating language (PR #105893)

2024-10-14 Thread Paul Kirth via cfe-commits


@@ -0,0 +1,713 @@
+//===-- Mustache.cpp 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "llvm/Support/Mustache.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/raw_ostream.h"
+#include 
+
+using namespace llvm;
+using namespace llvm::json;
+
+namespace llvm {
+namespace mustache {
+
+class Token {
+public:
+  enum class Type {
+Text,
+Variable,
+Partial,
+SectionOpen,
+SectionClose,
+InvertSectionOpen,
+UnescapeVariable,
+Comment,
+  };
+
+  Token(StringRef Str);
+
+  Token(StringRef RawBody, StringRef Str, char Identifier);
+
+  StringRef getTokenBody() const { return TokenBody; };
+
+  StringRef getRawBody() const { return RawBody; };
+
+  void setTokenBody(StringRef NewBody) { TokenBody = NewBody.str(); };
+
+  Accessor getAccessor() const { return Accessor; };
+
+  Type getType() const { return TokenType; };
+
+  void setIndentation(size_t NewIndentation) { Indentation = NewIndentation; };
+
+  size_t getIndentation() const { return Indentation; };
+
+  static Type getTokenType(char Identifier);
+
+private:
+  size_t Indentation;
+  Type TokenType;
+  // RawBody is the original string that was tokenized
+  SmallString<0> RawBody;
+  Accessor Accessor;
+  // TokenBody is the original string with the identifier removed
+  SmallString<0> TokenBody;
+};
+
+class ASTNode {
+public:
+  enum Type {
+Root,
+Text,
+Partial,
+Variable,
+UnescapeVariable,
+Section,
+InvertSection,
+  };
+
+  ASTNode() : T(Type::Root), ParentContext(nullptr) {};
+
+  ASTNode(StringRef Body, ASTNode *Parent)
+  : T(Type::Text), Body(Body), Parent(Parent), ParentContext(nullptr) {};
+
+  // Constructor for Section/InvertSection/Variable/UnescapeVariable
+  ASTNode(Type T, Accessor Accessor, ASTNode *Parent)
+  : T(T), Parent(Parent), Children({}), Accessor(Accessor),
+ParentContext(nullptr) {};
+
+  void addChild(ASTNode *Child) { Children.emplace_back(Child); };
+
+  void setBody(StringRef NewBody) { Body = NewBody; };
+
+  void setRawBody(StringRef NewBody) { RawBody = NewBody; };
+
+  void setIndentation(size_t NewIndentation) { Indentation = NewIndentation; };
+
+  void render(const llvm::json::Value &Data, llvm::raw_ostream &OS);
+
+  void setUpNode(llvm::BumpPtrAllocator &Alloc, StringMap &Partials,
+ StringMap &Lambdas,
+ StringMap &SectionLambdas,
+ DenseMap &Escapes);
+
+private:
+  void renderLambdas(const llvm::json::Value &Contexts, llvm::raw_ostream &OS,
+ Lambda &L);
+
+  void renderSectionLambdas(const llvm::json::Value &Contexts,
+llvm::raw_ostream &OS, SectionLambda &L);
+
+  void renderPartial(const llvm::json::Value &Contexts, llvm::raw_ostream &OS,
+ ASTNode *Partial);
+
+  void renderChild(const llvm::json::Value &Context, llvm::raw_ostream &OS);
+
+  const llvm::json::Value *findContext();
+
+  llvm::BumpPtrAllocator *Allocator;
+  StringMap *Partials;
+  StringMap *Lambdas;
+  StringMap *SectionLambdas;
+  DenseMap *Escapes;
+  Type T;
+  size_t Indentation = 0;
+  SmallString<0> RawBody;
+  SmallString<0> Body;
+  ASTNode *Parent;
+  std::vector Children;
+  const Accessor Accessor;
+  const llvm::json::Value *ParentContext;
+};
+
+// Custom stream to escape strings
+class EscapeStringStream : public raw_ostream {
+public:
+  explicit EscapeStringStream(llvm::raw_ostream &WrappedStream,
+  DenseMap &Escape)
+  : Escape(Escape), WrappedStream(WrappedStream) {
+SetUnbuffered();
+  }
+
+protected:
+  void write_impl(const char *Ptr, size_t Size) override {
+llvm::StringRef Data(Ptr, Size);
+for (char C : Data) {
+  auto It = Escape.find(C);
+  if (It != Escape.end())
+WrappedStream << It->getSecond();
+  else
+WrappedStream << C;
+}
+  }
+
+  uint64_t current_pos() const override { return WrappedStream.tell(); }
+
+private:
+  DenseMap &Escape;
+  llvm::raw_ostream &WrappedStream;
+};
+
+// Custom stream to add indentation used to for rendering partials
+class AddIndentationStringStream : public raw_ostream {
+public:
+  explicit AddIndentationStringStream(llvm::raw_ostream &WrappedStream,
+  size_t Indentation)
+  : Indentation(Indentation), WrappedStream(WrappedStream) {
+SetUnbuffered();
+  }
+
+protected:
+  void write_impl(const char *Ptr, size_t Size) override {
+llvm::StringRef Data(Ptr, Size);
+std::string Indent(Indentation, ' ');
+for (char C : Data) {
+  WrappedStream << C;
+  if (C == '\n')
+WrappedStream << Indent;
+}
+

[clang-tools-extra] [llvm] [llvm] add support for mustache templating language (PR #105893)

2024-10-14 Thread Paul Kirth via cfe-commits


@@ -0,0 +1,713 @@
+//===-- Mustache.cpp 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "llvm/Support/Mustache.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/raw_ostream.h"
+#include 
+
+using namespace llvm;
+using namespace llvm::json;
+
+namespace llvm {
+namespace mustache {
+
+class Token {
+public:
+  enum class Type {
+Text,
+Variable,
+Partial,
+SectionOpen,
+SectionClose,
+InvertSectionOpen,
+UnescapeVariable,
+Comment,
+  };
+
+  Token(StringRef Str);
+
+  Token(StringRef RawBody, StringRef Str, char Identifier);
+
+  StringRef getTokenBody() const { return TokenBody; };
+
+  StringRef getRawBody() const { return RawBody; };
+
+  void setTokenBody(StringRef NewBody) { TokenBody = NewBody.str(); };
+
+  Accessor getAccessor() const { return Accessor; };
+
+  Type getType() const { return TokenType; };
+
+  void setIndentation(size_t NewIndentation) { Indentation = NewIndentation; };
+
+  size_t getIndentation() const { return Indentation; };
+
+  static Type getTokenType(char Identifier);
+
+private:
+  size_t Indentation;
+  Type TokenType;
+  // RawBody is the original string that was tokenized
+  SmallString<0> RawBody;
+  Accessor Accessor;
+  // TokenBody is the original string with the identifier removed
+  SmallString<0> TokenBody;
+};
+
+class ASTNode {
+public:
+  enum Type {
+Root,
+Text,
+Partial,
+Variable,
+UnescapeVariable,
+Section,
+InvertSection,
+  };
+
+  ASTNode() : T(Type::Root), ParentContext(nullptr) {};
+
+  ASTNode(StringRef Body, ASTNode *Parent)
+  : T(Type::Text), Body(Body), Parent(Parent), ParentContext(nullptr) {};
+
+  // Constructor for Section/InvertSection/Variable/UnescapeVariable
+  ASTNode(Type T, Accessor Accessor, ASTNode *Parent)
+  : T(T), Parent(Parent), Children({}), Accessor(Accessor),
+ParentContext(nullptr) {};
+
+  void addChild(ASTNode *Child) { Children.emplace_back(Child); };
+
+  void setBody(StringRef NewBody) { Body = NewBody; };
+
+  void setRawBody(StringRef NewBody) { RawBody = NewBody; };
+
+  void setIndentation(size_t NewIndentation) { Indentation = NewIndentation; };
+
+  void render(const llvm::json::Value &Data, llvm::raw_ostream &OS);
+
+  void setUpNode(llvm::BumpPtrAllocator &Alloc, StringMap &Partials,
+ StringMap &Lambdas,
+ StringMap &SectionLambdas,
+ DenseMap &Escapes);
+
+private:
+  void renderLambdas(const llvm::json::Value &Contexts, llvm::raw_ostream &OS,
+ Lambda &L);
+
+  void renderSectionLambdas(const llvm::json::Value &Contexts,
+llvm::raw_ostream &OS, SectionLambda &L);
+
+  void renderPartial(const llvm::json::Value &Contexts, llvm::raw_ostream &OS,
+ ASTNode *Partial);
+
+  void renderChild(const llvm::json::Value &Context, llvm::raw_ostream &OS);
+
+  const llvm::json::Value *findContext();
+
+  llvm::BumpPtrAllocator *Allocator;
+  StringMap *Partials;
+  StringMap *Lambdas;
+  StringMap *SectionLambdas;
+  DenseMap *Escapes;
+  Type T;
+  size_t Indentation = 0;
+  SmallString<0> RawBody;
+  SmallString<0> Body;
+  ASTNode *Parent;
+  std::vector Children;
+  const Accessor Accessor;
+  const llvm::json::Value *ParentContext;
+};
+
+// Custom stream to escape strings
+class EscapeStringStream : public raw_ostream {
+public:
+  explicit EscapeStringStream(llvm::raw_ostream &WrappedStream,
+  DenseMap &Escape)
+  : Escape(Escape), WrappedStream(WrappedStream) {
+SetUnbuffered();
+  }
+
+protected:
+  void write_impl(const char *Ptr, size_t Size) override {
+llvm::StringRef Data(Ptr, Size);
+for (char C : Data) {
+  auto It = Escape.find(C);
+  if (It != Escape.end())
+WrappedStream << It->getSecond();
+  else
+WrappedStream << C;
+}
+  }
+
+  uint64_t current_pos() const override { return WrappedStream.tell(); }
+
+private:
+  DenseMap &Escape;
+  llvm::raw_ostream &WrappedStream;
+};
+
+// Custom stream to add indentation used to for rendering partials
+class AddIndentationStringStream : public raw_ostream {
+public:
+  explicit AddIndentationStringStream(llvm::raw_ostream &WrappedStream,
+  size_t Indentation)
+  : Indentation(Indentation), WrappedStream(WrappedStream) {
+SetUnbuffered();
+  }
+
+protected:
+  void write_impl(const char *Ptr, size_t Size) override {
+llvm::StringRef Data(Ptr, Size);
+std::string Indent(Indentation, ' ');
+for (char C : Data) {
+  WrappedStream << C;
+  if (C == '\n')
+WrappedStream << Indent;
+}
+

[clang-tools-extra] [llvm] [llvm] add support for mustache templating language (PR #105893)

2024-10-14 Thread Paul Kirth via cfe-commits


@@ -0,0 +1,567 @@
+//===-- Mustache.cpp 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "llvm/Support/Mustache.h"
+#include "llvm/Support/Error.h"
+#include 
+
+using namespace llvm;
+using namespace llvm::json;
+using namespace llvm::mustache;
+
+SmallString<0> escapeString(StringRef Input,
+DenseMap &Escape) {
+  SmallString<0> Output;
+  Output.reserve(Input.size());
+  for (char C : Input) {
+auto It = Escape.find(C);
+if (It != Escape.end())
+  Output += It->getSecond();
+else
+  Output += C;
+  }
+  return Output;
+}
+
+Accessor split(StringRef Str, char Delimiter) {
+  Accessor Tokens;
+  if (Str == ".") {
+Tokens.emplace_back(Str);
+return Tokens;
+  }
+  StringRef Ref(Str);
+  while (!Ref.empty()) {
+StringRef Part;
+std::tie(Part, Ref) = Ref.split(Delimiter);
+Tokens.emplace_back(Part.trim());
+  }
+  return Tokens;
+}
+
+void addIndentation(llvm::SmallString<0> &PartialStr, size_t IndentationSize) {
+  std::string Indent(IndentationSize, ' ');
+  llvm::SmallString<0> Result;
+  for (size_t I = 0; I < PartialStr.size(); ++I) {
+Result.push_back(PartialStr[I]);
+if (PartialStr[I] == '\n' && I < PartialStr.size() - 1)
+  Result.append(Indent);
+  }
+  PartialStr = Result;
+}
+
+Token::Token(StringRef RawBody, StringRef InnerBody, char Identifier)
+: RawBody(RawBody), TokenBody(InnerBody), Indentation(0) {
+  TokenType = getTokenType(Identifier);
+  if (TokenType == Type::Comment)
+return;
+
+  StringRef AccessorStr =
+  TokenType == Type::Variable ? InnerBody : InnerBody.substr(1);
+
+  Accessor = split(AccessorStr.trim(), '.');
+}
+
+Token::Token(StringRef Str)
+: TokenType(Type::Text), RawBody(Str), Accessor({}), TokenBody(Str),
+  Indentation(0) {}
+
+Token::Type Token::getTokenType(char Identifier) {
+  switch (Identifier) {
+  case '#':
+return Type::SectionOpen;
+  case '/':
+return Type::SectionClose;
+  case '^':
+return Type::InvertSectionOpen;
+  case '!':
+return Type::Comment;
+  case '>':
+return Type::Partial;
+  case '&':
+return Type::UnescapeVariable;
+  default:
+return Type::Variable;
+  }
+}
+
+// Function to check if there's no meaningful text behind
+bool noTextBehind(size_t Idx, const SmallVector &Tokens) {

ilovepi wrote:

I wonder if this would be easier to use if it was `hasTextBehind()`?

Plus the function can be `const`, right?
```suggestion
bool noTextBehind(size_t Idx, const SmallVector &Tokens)  const {
```

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


[clang-tools-extra] [llvm] [llvm] add support for mustache templating language (PR #105893)

2024-10-14 Thread Paul Kirth via cfe-commits


@@ -0,0 +1,567 @@
+//===-- Mustache.cpp 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "llvm/Support/Mustache.h"
+#include "llvm/Support/Error.h"
+#include 
+
+using namespace llvm;
+using namespace llvm::json;
+using namespace llvm::mustache;
+
+SmallString<0> escapeString(StringRef Input,
+DenseMap &Escape) {
+  SmallString<0> Output;
+  Output.reserve(Input.size());
+  for (char C : Input) {
+auto It = Escape.find(C);
+if (It != Escape.end())
+  Output += It->getSecond();
+else
+  Output += C;
+  }
+  return Output;
+}
+
+Accessor split(StringRef Str, char Delimiter) {
+  Accessor Tokens;
+  if (Str == ".") {
+Tokens.emplace_back(Str);
+return Tokens;
+  }
+  StringRef Ref(Str);
+  while (!Ref.empty()) {
+StringRef Part;
+std::tie(Part, Ref) = Ref.split(Delimiter);
+Tokens.emplace_back(Part.trim());
+  }
+  return Tokens;
+}
+
+void addIndentation(llvm::SmallString<0> &PartialStr, size_t IndentationSize) {
+  std::string Indent(IndentationSize, ' ');
+  llvm::SmallString<0> Result;
+  for (size_t I = 0; I < PartialStr.size(); ++I) {
+Result.push_back(PartialStr[I]);
+if (PartialStr[I] == '\n' && I < PartialStr.size() - 1)
+  Result.append(Indent);
+  }
+  PartialStr = Result;
+}
+
+Token::Token(StringRef RawBody, StringRef InnerBody, char Identifier)
+: RawBody(RawBody), TokenBody(InnerBody), Indentation(0) {
+  TokenType = getTokenType(Identifier);
+  if (TokenType == Type::Comment)
+return;
+
+  StringRef AccessorStr =
+  TokenType == Type::Variable ? InnerBody : InnerBody.substr(1);
+
+  Accessor = split(AccessorStr.trim(), '.');
+}
+
+Token::Token(StringRef Str)
+: TokenType(Type::Text), RawBody(Str), Accessor({}), TokenBody(Str),
+  Indentation(0) {}
+
+Token::Type Token::getTokenType(char Identifier) {
+  switch (Identifier) {
+  case '#':
+return Type::SectionOpen;
+  case '/':
+return Type::SectionClose;
+  case '^':
+return Type::InvertSectionOpen;
+  case '!':
+return Type::Comment;
+  case '>':
+return Type::Partial;
+  case '&':
+return Type::UnescapeVariable;
+  default:
+return Type::Variable;
+  }
+}
+
+// Function to check if there's no meaningful text behind
+bool noTextBehind(size_t Idx, const SmallVector &Tokens) {
+  if (Idx == 0)
+return false;
+
+  int PrevIdx = Idx - 1;
+  if (Tokens[PrevIdx].getType() != Token::Type::Text)
+return false;
+
+  const Token &PrevToken = Tokens[Idx - 1];
+  StringRef TokenBody = PrevToken.getRawBody().rtrim(" \t\v\t");
+  // We make an exception for when previous token is empty
+  // and the current token is the second token
+  // ex.
+  //  " {{#section}}A{{/section}}"
+  // the output of this is
+  //  "A"
+  return TokenBody.ends_with("\n") || (TokenBody.empty() && Idx == 1);
+}
+
+// Function to check if there's no meaningful text ahead
+bool noTextAhead(size_t Idx, const SmallVector &Tokens) {
+  if (Idx >= Tokens.size() - 1)
+return false;
+
+  int PrevIdx = Idx + 1;

ilovepi wrote:

```suggestion
  int NextIdx = Idx + 1;
```
This isn't Prev, right?

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


[clang-tools-extra] [clang-tidy] Fix a typo (PR #112283)

2024-10-14 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-tidy

Author: Konstantin Bogdanov (thevar1able)


Changes



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


2 Files Affected:

- (modified) 
clang-tools-extra/clang-tidy/bugprone/CrtpConstructorAccessibilityCheck.cpp 
(+1-1) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/bugprone/crtp-constructor-accessibility.cpp
 (+8-8) 


``diff
diff --git 
a/clang-tools-extra/clang-tidy/bugprone/CrtpConstructorAccessibilityCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/CrtpConstructorAccessibilityCheck.cpp
index 6175fcdfd229c3..8eaf54fe0088a4 100644
--- 
a/clang-tools-extra/clang-tidy/bugprone/CrtpConstructorAccessibilityCheck.cpp
+++ 
b/clang-tools-extra/clang-tidy/bugprone/CrtpConstructorAccessibilityCheck.cpp
@@ -165,7 +165,7 @@ void CrtpConstructorAccessibilityCheck::check(
 
 WithFriendHintIfNeeded(
 diag(Ctor->getLocation(),
- "%0 contructor allows the CRTP to be %select{inherited "
+ "%0 constructor allows the CRTP to be %select{inherited "
  "from|constructed}1 as a regular template class; consider making "
  "it private%select{| and declaring the derived class as friend}2")
 << Access << IsPublic << NeedsFriend
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/crtp-constructor-accessibility.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/crtp-constructor-accessibility.cpp
index cb41923df157cf..f33b8457cc8af5 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/crtp-constructor-accessibility.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/crtp-constructor-accessibility.cpp
@@ -26,7 +26,7 @@ template 
 class CRTP {
 public:
 CRTP() = default;
-// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: public contructor allows the 
CRTP to be constructed as a regular template class; consider making it private 
and declaring the derived class as friend 
[bugprone-crtp-constructor-accessibility]
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: public constructor allows the 
CRTP to be constructed as a regular template class; consider making it private 
and declaring the derived class as friend 
[bugprone-crtp-constructor-accessibility]
 // CHECK-FIXES: private:{{[[:space:]]*}}CRTP() = 
default;{{[[:space:]]*}}public:
 // CHECK-FIXES: friend T;
 };
@@ -39,7 +39,7 @@ template 
 class CRTP {
 public:
 CRTP(int) {}
-// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: public contructor allows the 
CRTP to be constructed as a regular template class; consider making it private 
and declaring the derived class as friend 
[bugprone-crtp-constructor-accessibility]
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: public constructor allows the 
CRTP to be constructed as a regular template class; consider making it private 
and declaring the derived class as friend 
[bugprone-crtp-constructor-accessibility]
 // CHECK-FIXES: private:{{[[:space:]]*}}CRTP(int) {}{{[[:space:]]*}}public:
 // CHECK-FIXES: friend T;
 };
@@ -52,10 +52,10 @@ template 
 class CRTP {
 public:
 CRTP(int) {}
-// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: public contructor allows the 
CRTP to be constructed as a regular template class; consider making it private 
and declaring the derived class as friend 
[bugprone-crtp-constructor-accessibility]
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: public constructor allows the 
CRTP to be constructed as a regular template class; consider making it private 
and declaring the derived class as friend 
[bugprone-crtp-constructor-accessibility]
 // CHECK-FIXES: private:{{[[:space:]]*}}CRTP(int) {}{{[[:space:]]*}}public:
 CRTP(float) {}
-// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: public contructor allows the 
CRTP to be constructed as a regular template class; consider making it private 
and declaring the derived class as friend 
[bugprone-crtp-constructor-accessibility]
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: public constructor allows the 
CRTP to be constructed as a regular template class; consider making it private 
and declaring the derived class as friend 
[bugprone-crtp-constructor-accessibility]
 // CHECK-FIXES: private:{{[[:space:]]*}}CRTP(float) 
{}{{[[:space:]]*}}public:
 
 // CHECK-FIXES: friend T;
@@ -70,13 +70,13 @@ template 
 class CRTP {
 protected:
 CRTP(int) {}
-// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: protected contructor allows 
the CRTP to be inherited from as a regular template class; consider making it 
private and declaring the derived class as friend 
[bugprone-crtp-constructor-accessibility]
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: protected constructor allows 
the CRTP to be inherited from as a regular template class; consider making it 
private and declaring the derived class as friend 
[bugprone-crtp-constructor-accessibility]
 // CHECK-FIXES: private:{{[[:space:]]*}}CRTP(int) 
{}{{[[:space:]]*}}prote

[clang-tools-extra] [clang-tidy] Fix a typo (PR #112283)

2024-10-14 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-tools-extra

Author: Konstantin Bogdanov (thevar1able)


Changes



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


2 Files Affected:

- (modified) 
clang-tools-extra/clang-tidy/bugprone/CrtpConstructorAccessibilityCheck.cpp 
(+1-1) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/bugprone/crtp-constructor-accessibility.cpp
 (+8-8) 


``diff
diff --git 
a/clang-tools-extra/clang-tidy/bugprone/CrtpConstructorAccessibilityCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/CrtpConstructorAccessibilityCheck.cpp
index 6175fcdfd229c3..8eaf54fe0088a4 100644
--- 
a/clang-tools-extra/clang-tidy/bugprone/CrtpConstructorAccessibilityCheck.cpp
+++ 
b/clang-tools-extra/clang-tidy/bugprone/CrtpConstructorAccessibilityCheck.cpp
@@ -165,7 +165,7 @@ void CrtpConstructorAccessibilityCheck::check(
 
 WithFriendHintIfNeeded(
 diag(Ctor->getLocation(),
- "%0 contructor allows the CRTP to be %select{inherited "
+ "%0 constructor allows the CRTP to be %select{inherited "
  "from|constructed}1 as a regular template class; consider making "
  "it private%select{| and declaring the derived class as friend}2")
 << Access << IsPublic << NeedsFriend
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/crtp-constructor-accessibility.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/crtp-constructor-accessibility.cpp
index cb41923df157cf..f33b8457cc8af5 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/crtp-constructor-accessibility.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/crtp-constructor-accessibility.cpp
@@ -26,7 +26,7 @@ template 
 class CRTP {
 public:
 CRTP() = default;
-// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: public contructor allows the 
CRTP to be constructed as a regular template class; consider making it private 
and declaring the derived class as friend 
[bugprone-crtp-constructor-accessibility]
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: public constructor allows the 
CRTP to be constructed as a regular template class; consider making it private 
and declaring the derived class as friend 
[bugprone-crtp-constructor-accessibility]
 // CHECK-FIXES: private:{{[[:space:]]*}}CRTP() = 
default;{{[[:space:]]*}}public:
 // CHECK-FIXES: friend T;
 };
@@ -39,7 +39,7 @@ template 
 class CRTP {
 public:
 CRTP(int) {}
-// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: public contructor allows the 
CRTP to be constructed as a regular template class; consider making it private 
and declaring the derived class as friend 
[bugprone-crtp-constructor-accessibility]
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: public constructor allows the 
CRTP to be constructed as a regular template class; consider making it private 
and declaring the derived class as friend 
[bugprone-crtp-constructor-accessibility]
 // CHECK-FIXES: private:{{[[:space:]]*}}CRTP(int) {}{{[[:space:]]*}}public:
 // CHECK-FIXES: friend T;
 };
@@ -52,10 +52,10 @@ template 
 class CRTP {
 public:
 CRTP(int) {}
-// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: public contructor allows the 
CRTP to be constructed as a regular template class; consider making it private 
and declaring the derived class as friend 
[bugprone-crtp-constructor-accessibility]
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: public constructor allows the 
CRTP to be constructed as a regular template class; consider making it private 
and declaring the derived class as friend 
[bugprone-crtp-constructor-accessibility]
 // CHECK-FIXES: private:{{[[:space:]]*}}CRTP(int) {}{{[[:space:]]*}}public:
 CRTP(float) {}
-// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: public contructor allows the 
CRTP to be constructed as a regular template class; consider making it private 
and declaring the derived class as friend 
[bugprone-crtp-constructor-accessibility]
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: public constructor allows the 
CRTP to be constructed as a regular template class; consider making it private 
and declaring the derived class as friend 
[bugprone-crtp-constructor-accessibility]
 // CHECK-FIXES: private:{{[[:space:]]*}}CRTP(float) 
{}{{[[:space:]]*}}public:
 
 // CHECK-FIXES: friend T;
@@ -70,13 +70,13 @@ template 
 class CRTP {
 protected:
 CRTP(int) {}
-// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: protected contructor allows 
the CRTP to be inherited from as a regular template class; consider making it 
private and declaring the derived class as friend 
[bugprone-crtp-constructor-accessibility]
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: protected constructor allows 
the CRTP to be inherited from as a regular template class; consider making it 
private and declaring the derived class as friend 
[bugprone-crtp-constructor-accessibility]
 // CHECK-FIXES: private:{{[[:space:]]*}}CRTP(int) 
{}{{[[:space:]]*

[clang-tools-extra] [clang-tidy] Fix a typo (PR #112283)

2024-10-14 Thread Konstantin Bogdanov via cfe-commits

https://github.com/thevar1able created 
https://github.com/llvm/llvm-project/pull/112283

None

>From 31e4d362b6466b101cdf896003c6c264786b3f2a Mon Sep 17 00:00:00 2001
From: Konstantin Bogdanov 
Date: Tue, 15 Oct 2024 01:21:21 +0200
Subject: [PATCH] Fix a typo

---
 .../CrtpConstructorAccessibilityCheck.cpp|  2 +-
 .../bugprone/crtp-constructor-accessibility.cpp  | 16 
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git 
a/clang-tools-extra/clang-tidy/bugprone/CrtpConstructorAccessibilityCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/CrtpConstructorAccessibilityCheck.cpp
index 6175fcdfd229c3..8eaf54fe0088a4 100644
--- 
a/clang-tools-extra/clang-tidy/bugprone/CrtpConstructorAccessibilityCheck.cpp
+++ 
b/clang-tools-extra/clang-tidy/bugprone/CrtpConstructorAccessibilityCheck.cpp
@@ -165,7 +165,7 @@ void CrtpConstructorAccessibilityCheck::check(
 
 WithFriendHintIfNeeded(
 diag(Ctor->getLocation(),
- "%0 contructor allows the CRTP to be %select{inherited "
+ "%0 constructor allows the CRTP to be %select{inherited "
  "from|constructed}1 as a regular template class; consider making "
  "it private%select{| and declaring the derived class as friend}2")
 << Access << IsPublic << NeedsFriend
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/crtp-constructor-accessibility.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/crtp-constructor-accessibility.cpp
index cb41923df157cf..f33b8457cc8af5 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/bugprone/crtp-constructor-accessibility.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/bugprone/crtp-constructor-accessibility.cpp
@@ -26,7 +26,7 @@ template 
 class CRTP {
 public:
 CRTP() = default;
-// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: public contructor allows the 
CRTP to be constructed as a regular template class; consider making it private 
and declaring the derived class as friend 
[bugprone-crtp-constructor-accessibility]
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: public constructor allows the 
CRTP to be constructed as a regular template class; consider making it private 
and declaring the derived class as friend 
[bugprone-crtp-constructor-accessibility]
 // CHECK-FIXES: private:{{[[:space:]]*}}CRTP() = 
default;{{[[:space:]]*}}public:
 // CHECK-FIXES: friend T;
 };
@@ -39,7 +39,7 @@ template 
 class CRTP {
 public:
 CRTP(int) {}
-// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: public contructor allows the 
CRTP to be constructed as a regular template class; consider making it private 
and declaring the derived class as friend 
[bugprone-crtp-constructor-accessibility]
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: public constructor allows the 
CRTP to be constructed as a regular template class; consider making it private 
and declaring the derived class as friend 
[bugprone-crtp-constructor-accessibility]
 // CHECK-FIXES: private:{{[[:space:]]*}}CRTP(int) {}{{[[:space:]]*}}public:
 // CHECK-FIXES: friend T;
 };
@@ -52,10 +52,10 @@ template 
 class CRTP {
 public:
 CRTP(int) {}
-// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: public contructor allows the 
CRTP to be constructed as a regular template class; consider making it private 
and declaring the derived class as friend 
[bugprone-crtp-constructor-accessibility]
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: public constructor allows the 
CRTP to be constructed as a regular template class; consider making it private 
and declaring the derived class as friend 
[bugprone-crtp-constructor-accessibility]
 // CHECK-FIXES: private:{{[[:space:]]*}}CRTP(int) {}{{[[:space:]]*}}public:
 CRTP(float) {}
-// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: public contructor allows the 
CRTP to be constructed as a regular template class; consider making it private 
and declaring the derived class as friend 
[bugprone-crtp-constructor-accessibility]
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: public constructor allows the 
CRTP to be constructed as a regular template class; consider making it private 
and declaring the derived class as friend 
[bugprone-crtp-constructor-accessibility]
 // CHECK-FIXES: private:{{[[:space:]]*}}CRTP(float) 
{}{{[[:space:]]*}}public:
 
 // CHECK-FIXES: friend T;
@@ -70,13 +70,13 @@ template 
 class CRTP {
 protected:
 CRTP(int) {}
-// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: protected contructor allows 
the CRTP to be inherited from as a regular template class; consider making it 
private and declaring the derived class as friend 
[bugprone-crtp-constructor-accessibility]
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: protected constructor allows 
the CRTP to be inherited from as a regular template class; consider making it 
private and declaring the derived class as friend 
[bugprone-crtp-constructor-accessibility]
 // CHECK-FIXES: private:{{[[:space:]]*}}CRTP(int) 

[clang-tools-extra] [clang-tidy] Fix a typo (PR #112283)

2024-10-14 Thread via cfe-commits

github-actions[bot] wrote:



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

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

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

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

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

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

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

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


[clang-tools-extra] [clangd] Add inlay hints for default function arguments (PR #95712)

2024-10-14 Thread Tor Shepherd via cfe-commits

torshepherd wrote:

Ok I found a couple of nontrivial issues that I took care of in the latest 
commit.

1. Using `DefaultArguments` required having parameter names set to true as 
well. I separated them so that both have a modality that works with or without 
the other. See screenshot for defaults w/out parameter names:

![image](https://github.com/user-attachments/assets/fb5a9608-33aa-41bb-bf2e-1fc4361ca0da)

2. Having newlines in the default definition caused `LF` to be displayed in the 
hints. I fixed this by just displaying `...` any time a default definition 
contains `\n`.
3. I was getting `Property DefaultArguments` is not allowed in `config.yaml`. 
Is this a schema issue? I wasn't able to find where to update this

Also, a couple of follow-up things I should do:
- Add support for default `Designators`. For instance,

```cpp
struct Foo { int a; int b = 2 };
Foo f{1}; // Currently shows 'Foo f{.a=1}', should show 'Foo f{.a=1, .b=2}'
```
- Add support for template args? such as `std::vector>` when user types `std::vector`. This could also fall 
under "add InlayHints for FTAD and CTAD", which may be a nongoal, idk
- Add a link to the source location of the definition (leveraging 
https://github.com/llvm/llvm-project/pull/85497)
- Do the formatting better. Basically, in some cases, collapsing newlines 
preserves the meaning of the code and therefore we should do that. However in 
other cases (comments for example), collapsing newlines makes the code 
gibberish (`3 // + 2` from the test case for example), and we should just show 
`...` instead.

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


[clang-tools-extra] [clangd] Add inlay hints for default function arguments (PR #95712)

2024-10-14 Thread Tor Shepherd via cfe-commits

https://github.com/torshepherd updated 
https://github.com/llvm/llvm-project/pull/95712

>From 2c9e7c16524b7ce3bf818e451279722dc45d3efc Mon Sep 17 00:00:00 2001
From: Tor Shepherd 
Date: Mon, 23 Sep 2024 23:12:23 -0400
Subject: [PATCH 1/5] just defaults

---
 clang-tools-extra/clangd/Config.h |  1 +
 clang-tools-extra/clangd/ConfigCompile.cpp|  6 +-
 clang-tools-extra/clangd/ConfigFragment.h |  3 +
 clang-tools-extra/clangd/ConfigYAML.cpp   |  5 +-
 clang-tools-extra/clangd/InlayHints.cpp   | 61 ++-
 clang-tools-extra/clangd/Protocol.cpp |  3 +
 clang-tools-extra/clangd/Protocol.h   |  9 +++
 .../clangd/unittests/InlayHintTests.cpp   | 29 +
 8 files changed, 112 insertions(+), 5 deletions(-)

diff --git a/clang-tools-extra/clangd/Config.h 
b/clang-tools-extra/clangd/Config.h
index 41143b9ebc8d27..6fb846aa99437f 100644
--- a/clang-tools-extra/clangd/Config.h
+++ b/clang-tools-extra/clangd/Config.h
@@ -148,6 +148,7 @@ struct Config {
 bool DeducedTypes = true;
 bool Designators = true;
 bool BlockEnd = false;
+bool DefaultArguments = false;
 // Limit the length of type names in inlay hints. (0 means no limit)
 uint32_t TypeNameLimit = 32;
   } InlayHints;
diff --git a/clang-tools-extra/clangd/ConfigCompile.cpp 
b/clang-tools-extra/clangd/ConfigCompile.cpp
index f32f674443ffeb..81bc68e4e93d89 100644
--- a/clang-tools-extra/clangd/ConfigCompile.cpp
+++ b/clang-tools-extra/clangd/ConfigCompile.cpp
@@ -43,7 +43,6 @@
 #include "llvm/Support/Regex.h"
 #include "llvm/Support/SMLoc.h"
 #include "llvm/Support/SourceMgr.h"
-#include 
 #include 
 #include 
 #include 
@@ -654,6 +653,11 @@ struct FragmentCompiler {
   Out.Apply.push_back([Value(**F.BlockEnd)](const Params &, Config &C) {
 C.InlayHints.BlockEnd = Value;
   });
+if (F.DefaultArguments)
+  Out.Apply.push_back(
+  [Value(**F.DefaultArguments)](const Params &, Config &C) {
+C.InlayHints.DefaultArguments = Value;
+  });
 if (F.TypeNameLimit)
   Out.Apply.push_back(
   [Value(**F.TypeNameLimit)](const Params &, Config &C) {
diff --git a/clang-tools-extra/clangd/ConfigFragment.h 
b/clang-tools-extra/clangd/ConfigFragment.h
index f3e51a9b6dbc4b..3a591e3062e355 100644
--- a/clang-tools-extra/clangd/ConfigFragment.h
+++ b/clang-tools-extra/clangd/ConfigFragment.h
@@ -331,6 +331,9 @@ struct Fragment {
 std::optional> Designators;
 /// Show defined symbol names at the end of a definition block.
 std::optional> BlockEnd;
+/// Show parameter names and default values of default arguments after all
+/// of the explicit arguments.
+std::optional> DefaultArguments;
 /// Limit the length of type name hints. (0 means no limit)
 std::optional> TypeNameLimit;
   };
diff --git a/clang-tools-extra/clangd/ConfigYAML.cpp 
b/clang-tools-extra/clangd/ConfigYAML.cpp
index 3e9b6a07d3b325..ed90e6d648b1c2 100644
--- a/clang-tools-extra/clangd/ConfigYAML.cpp
+++ b/clang-tools-extra/clangd/ConfigYAML.cpp
@@ -14,7 +14,6 @@
 #include "llvm/Support/YAMLParser.h"
 #include 
 #include 
-#include 
 
 namespace clang {
 namespace clangd {
@@ -264,6 +263,10 @@ class Parser {
   if (auto Value = boolValue(N, "BlockEnd"))
 F.BlockEnd = *Value;
 });
+Dict.handle("DefaultArguments", [&](Node &N) {
+  if (auto Value = boolValue(N, "DefaultArguments"))
+F.DefaultArguments = *Value;
+});
 Dict.handle("TypeNameLimit", [&](Node &N) {
   if (auto Value = uint32Value(N, "TypeNameLimit"))
 F.TypeNameLimit = *Value;
diff --git a/clang-tools-extra/clangd/InlayHints.cpp 
b/clang-tools-extra/clangd/InlayHints.cpp
index cd4f1931b3ce1d..72fa92a81ce800 100644
--- a/clang-tools-extra/clangd/InlayHints.cpp
+++ b/clang-tools-extra/clangd/InlayHints.cpp
@@ -11,9 +11,11 @@
 #include "Config.h"
 #include "HeuristicResolver.h"
 #include "ParsedAST.h"
+#include "Protocol.h"
 #include "SourceCode.h"
 #include "clang/AST/ASTDiagnostic.h"
 #include "clang/AST/Decl.h"
+#include "clang/AST/DeclBase.h"
 #include "clang/AST/DeclarationName.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/ExprCXX.h"
@@ -23,15 +25,22 @@
 #include "clang/AST/Type.h"
 #include "clang/Basic/Builtins.h"
 #include "clang/Basic/OperatorKinds.h"
+#include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
 #include "llvm/ADT/DenseSet.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/Support/Casting.h"
+#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/SaveAndRestore.h"
 #include "llvm/Support/ScopedPrinter.h"
 #include "llvm/Support/raw_ostream.h"
+#include 
+#include 
 #include 
 #include 
 
@@ -372,6 +381,25 @@ maybeDropCxxExplicitObjectParameters(ArrayRef Params) {
   return Params;
 }
 
+template

[clang] [Wunsafe-buffer-usage] False positives for & expression indexing constant size array (arr[anything & 0]) (PR #112284)

2024-10-14 Thread Malavika Samak via cfe-commits

https://github.com/malavikasamak created 
https://github.com/llvm/llvm-project/pull/112284

Do not warn when a constant sized array is indexed with an expression that 
contains bitwise and operation
involving constants and it always results in a bound safe access.

(rdar://136684050)

>From b557d1d8c323116a4ffcf5c9cec06bb4fb133f92 Mon Sep 17 00:00:00 2001
From: MalavikaSamak 
Date: Fri, 11 Oct 2024 12:24:58 -0700
Subject: [PATCH] [Wunsafe-buffer-usage] False positives for & expression
 indexing constant size array (arr[anything & 0])

(rdar://136684050)
---
 clang/lib/Analysis/UnsafeBufferUsage.cpp  | 45 +++
 .../warn-unsafe-buffer-usage-array.cpp| 14 ++
 2 files changed, 59 insertions(+)

diff --git a/clang/lib/Analysis/UnsafeBufferUsage.cpp 
b/clang/lib/Analysis/UnsafeBufferUsage.cpp
index 97f1c4f16b8f4c..cdfdcc17536391 100644
--- a/clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ b/clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -427,6 +427,45 @@ AST_MATCHER(ArraySubscriptExpr, isSafeArraySubscript) {
   //-  e. g. "Try harder to find a NamedDecl to point at in the note."
   //already duplicated
   //  - call both from Sema and from here
+  std::function
+  SafeMaskedAccess;
+  unsigned int RecLimit = 5;
+  llvm::APInt Max;
+  bool Initialized = false;
+
+  SafeMaskedAccess = [&](const Expr *exp, const ConstantArrayType *CATy,
+ unsigned int RecLimit) -> bool {
+if (RecLimit == 0)
+  return false;
+
+RecLimit--;
+
+if (const auto *IntLit = dyn_cast(exp)) {
+  const APInt ArrIdx = IntLit->getValue();
+  if (ArrIdx.isNonNegative() &&
+  ArrIdx.getLimitedValue() < CATy->getLimitedSize())
+return true;
+  if (!Initialized) {
+Max = ArrIdx;
+Initialized = true;
+  } else {
+Max = Max & ArrIdx.getLimitedValue();
+  }
+  if (Max.getLimitedValue() < CATy->getLimitedSize())
+return true;
+}
+
+if (const auto *BinEx = dyn_cast(exp)) {
+  if (SafeMaskedAccess(BinEx->getLHS()->IgnoreParenCasts(), CATy, 
RecLimit))
+return true;
+  else if (SafeMaskedAccess(BinEx->getRHS()->IgnoreParenCasts(), CATy,
+RecLimit))
+return true;
+}
+
+return false;
+  };
 
   const auto *BaseDRE =
   dyn_cast(Node.getBase()->IgnoreParenImpCasts());
@@ -446,6 +485,12 @@ AST_MATCHER(ArraySubscriptExpr, isSafeArraySubscript) {
 if (ArrIdx.isNonNegative() &&
 ArrIdx.getLimitedValue() < CATy->getLimitedSize())
   return true;
+  } else if (const auto *BinEx = dyn_cast(Node.getIdx())) {
+if (BinEx->getOpcode() != BO_And)
+  return false;
+
+Max.setAllBits();
+return SafeMaskedAccess(Node.getIdx(), CATy, RecLimit);
   }
 
   return false;
diff --git a/clang/test/SemaCXX/warn-unsafe-buffer-usage-array.cpp 
b/clang/test/SemaCXX/warn-unsafe-buffer-usage-array.cpp
index 8b2f103ec66708..e5a5ca57f66883 100644
--- a/clang/test/SemaCXX/warn-unsafe-buffer-usage-array.cpp
+++ b/clang/test/SemaCXX/warn-unsafe-buffer-usage-array.cpp
@@ -33,6 +33,20 @@ void constant_idx_safe0(unsigned idx) {
   buffer[0] = 0;
 }
 
+int array[10]; // expected-warning{{'array' is an unsafe buffer that does not 
perform bounds checks}}
+
+void masked_idx(unsigned long long idx) {
+  array[idx & 5] = 10; // no warning
+  array[idx & 11 & 5] = 3; // no warning
+  array[idx & 11] = 20; // expected-note{{used in buffer access here}} 
+}
+
+int array2[5];
+
+void mased_idx_false() {
+  array2[6 & 5];
+}
+
 void constant_idx_unsafe(unsigned idx) {
   int buffer[10];   // expected-warning{{'buffer' is an unsafe buffer that 
does not perform bounds checks}}
 // expected-note@-1{{change type of 'buffer' to 
'std::array' to label it for hardening}}

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


[clang] [Wunsafe-buffer-usage] False positives for & expression indexing constant size array (arr[anything & 0]) (PR #112284)

2024-10-14 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Malavika Samak (malavikasamak)


Changes

Do not warn when a constant sized array is indexed with an expression that 
contains bitwise and operation
involving constants and it always results in a bound safe access.

(rdar://136684050)

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


2 Files Affected:

- (modified) clang/lib/Analysis/UnsafeBufferUsage.cpp (+45) 
- (modified) clang/test/SemaCXX/warn-unsafe-buffer-usage-array.cpp (+14) 


``diff
diff --git a/clang/lib/Analysis/UnsafeBufferUsage.cpp 
b/clang/lib/Analysis/UnsafeBufferUsage.cpp
index 97f1c4f16b8f4c..cdfdcc17536391 100644
--- a/clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ b/clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -427,6 +427,45 @@ AST_MATCHER(ArraySubscriptExpr, isSafeArraySubscript) {
   //-  e. g. "Try harder to find a NamedDecl to point at in the note."
   //already duplicated
   //  - call both from Sema and from here
+  std::function
+  SafeMaskedAccess;
+  unsigned int RecLimit = 5;
+  llvm::APInt Max;
+  bool Initialized = false;
+
+  SafeMaskedAccess = [&](const Expr *exp, const ConstantArrayType *CATy,
+ unsigned int RecLimit) -> bool {
+if (RecLimit == 0)
+  return false;
+
+RecLimit--;
+
+if (const auto *IntLit = dyn_cast(exp)) {
+  const APInt ArrIdx = IntLit->getValue();
+  if (ArrIdx.isNonNegative() &&
+  ArrIdx.getLimitedValue() < CATy->getLimitedSize())
+return true;
+  if (!Initialized) {
+Max = ArrIdx;
+Initialized = true;
+  } else {
+Max = Max & ArrIdx.getLimitedValue();
+  }
+  if (Max.getLimitedValue() < CATy->getLimitedSize())
+return true;
+}
+
+if (const auto *BinEx = dyn_cast(exp)) {
+  if (SafeMaskedAccess(BinEx->getLHS()->IgnoreParenCasts(), CATy, 
RecLimit))
+return true;
+  else if (SafeMaskedAccess(BinEx->getRHS()->IgnoreParenCasts(), CATy,
+RecLimit))
+return true;
+}
+
+return false;
+  };
 
   const auto *BaseDRE =
   dyn_cast(Node.getBase()->IgnoreParenImpCasts());
@@ -446,6 +485,12 @@ AST_MATCHER(ArraySubscriptExpr, isSafeArraySubscript) {
 if (ArrIdx.isNonNegative() &&
 ArrIdx.getLimitedValue() < CATy->getLimitedSize())
   return true;
+  } else if (const auto *BinEx = dyn_cast(Node.getIdx())) {
+if (BinEx->getOpcode() != BO_And)
+  return false;
+
+Max.setAllBits();
+return SafeMaskedAccess(Node.getIdx(), CATy, RecLimit);
   }
 
   return false;
diff --git a/clang/test/SemaCXX/warn-unsafe-buffer-usage-array.cpp 
b/clang/test/SemaCXX/warn-unsafe-buffer-usage-array.cpp
index 8b2f103ec66708..e5a5ca57f66883 100644
--- a/clang/test/SemaCXX/warn-unsafe-buffer-usage-array.cpp
+++ b/clang/test/SemaCXX/warn-unsafe-buffer-usage-array.cpp
@@ -33,6 +33,20 @@ void constant_idx_safe0(unsigned idx) {
   buffer[0] = 0;
 }
 
+int array[10]; // expected-warning{{'array' is an unsafe buffer that does not 
perform bounds checks}}
+
+void masked_idx(unsigned long long idx) {
+  array[idx & 5] = 10; // no warning
+  array[idx & 11 & 5] = 3; // no warning
+  array[idx & 11] = 20; // expected-note{{used in buffer access here}} 
+}
+
+int array2[5];
+
+void mased_idx_false() {
+  array2[6 & 5];
+}
+
 void constant_idx_unsafe(unsigned idx) {
   int buffer[10];   // expected-warning{{'buffer' is an unsafe buffer that 
does not perform bounds checks}}
 // expected-note@-1{{change type of 'buffer' to 
'std::array' to label it for hardening}}

``




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


[clang] [Wunsafe-buffer-usage] False positives for & expression indexing constant size array (arr[anything & 0]) (PR #112284)

2024-10-14 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-analysis

Author: Malavika Samak (malavikasamak)


Changes

Do not warn when a constant sized array is indexed with an expression that 
contains bitwise and operation
involving constants and it always results in a bound safe access.

(rdar://136684050)

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


2 Files Affected:

- (modified) clang/lib/Analysis/UnsafeBufferUsage.cpp (+45) 
- (modified) clang/test/SemaCXX/warn-unsafe-buffer-usage-array.cpp (+14) 


``diff
diff --git a/clang/lib/Analysis/UnsafeBufferUsage.cpp 
b/clang/lib/Analysis/UnsafeBufferUsage.cpp
index 97f1c4f16b8f4c..cdfdcc17536391 100644
--- a/clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ b/clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -427,6 +427,45 @@ AST_MATCHER(ArraySubscriptExpr, isSafeArraySubscript) {
   //-  e. g. "Try harder to find a NamedDecl to point at in the note."
   //already duplicated
   //  - call both from Sema and from here
+  std::function
+  SafeMaskedAccess;
+  unsigned int RecLimit = 5;
+  llvm::APInt Max;
+  bool Initialized = false;
+
+  SafeMaskedAccess = [&](const Expr *exp, const ConstantArrayType *CATy,
+ unsigned int RecLimit) -> bool {
+if (RecLimit == 0)
+  return false;
+
+RecLimit--;
+
+if (const auto *IntLit = dyn_cast(exp)) {
+  const APInt ArrIdx = IntLit->getValue();
+  if (ArrIdx.isNonNegative() &&
+  ArrIdx.getLimitedValue() < CATy->getLimitedSize())
+return true;
+  if (!Initialized) {
+Max = ArrIdx;
+Initialized = true;
+  } else {
+Max = Max & ArrIdx.getLimitedValue();
+  }
+  if (Max.getLimitedValue() < CATy->getLimitedSize())
+return true;
+}
+
+if (const auto *BinEx = dyn_cast(exp)) {
+  if (SafeMaskedAccess(BinEx->getLHS()->IgnoreParenCasts(), CATy, 
RecLimit))
+return true;
+  else if (SafeMaskedAccess(BinEx->getRHS()->IgnoreParenCasts(), CATy,
+RecLimit))
+return true;
+}
+
+return false;
+  };
 
   const auto *BaseDRE =
   dyn_cast(Node.getBase()->IgnoreParenImpCasts());
@@ -446,6 +485,12 @@ AST_MATCHER(ArraySubscriptExpr, isSafeArraySubscript) {
 if (ArrIdx.isNonNegative() &&
 ArrIdx.getLimitedValue() < CATy->getLimitedSize())
   return true;
+  } else if (const auto *BinEx = dyn_cast(Node.getIdx())) {
+if (BinEx->getOpcode() != BO_And)
+  return false;
+
+Max.setAllBits();
+return SafeMaskedAccess(Node.getIdx(), CATy, RecLimit);
   }
 
   return false;
diff --git a/clang/test/SemaCXX/warn-unsafe-buffer-usage-array.cpp 
b/clang/test/SemaCXX/warn-unsafe-buffer-usage-array.cpp
index 8b2f103ec66708..e5a5ca57f66883 100644
--- a/clang/test/SemaCXX/warn-unsafe-buffer-usage-array.cpp
+++ b/clang/test/SemaCXX/warn-unsafe-buffer-usage-array.cpp
@@ -33,6 +33,20 @@ void constant_idx_safe0(unsigned idx) {
   buffer[0] = 0;
 }
 
+int array[10]; // expected-warning{{'array' is an unsafe buffer that does not 
perform bounds checks}}
+
+void masked_idx(unsigned long long idx) {
+  array[idx & 5] = 10; // no warning
+  array[idx & 11 & 5] = 3; // no warning
+  array[idx & 11] = 20; // expected-note{{used in buffer access here}} 
+}
+
+int array2[5];
+
+void mased_idx_false() {
+  array2[6 & 5];
+}
+
 void constant_idx_unsafe(unsigned idx) {
   int buffer[10];   // expected-warning{{'buffer' is an unsafe buffer that 
does not perform bounds checks}}
 // expected-note@-1{{change type of 'buffer' to 
'std::array' to label it for hardening}}

``




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


[clang] 6277465 - Reapply "[clang][CodeGen] Zero init unspecified fields in initializers in C" (#109898) (#110051)

2024-10-14 Thread via cfe-commits

Author: yabinc
Date: 2024-10-14T16:32:24-07:00
New Revision: 627746581b8fde4143533937130f420bbbdf9ddf

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

LOG: Reapply "[clang][CodeGen] Zero init unspecified fields in initializers in 
C" (#109898) (#110051)

This reverts commit d50eaac12f0cdfe27e942290942b06889ab12a8c. Also fixes
a bug calculating offsets for bit fields in the original patch.

Added: 
clang/test/CodeGen/linux-kernel-struct-union-initializer.c
clang/test/CodeGen/linux-kernel-struct-union-initializer2.c

Modified: 
clang/docs/LanguageExtensions.rst
clang/lib/CodeGen/CGExprAgg.cpp
clang/lib/CodeGen/CGExprConstant.cpp
clang/lib/CodeGen/CodeGenModule.h
clang/test/CodeGen/2008-07-22-bitfield-init-after-zero-len-array.c
clang/test/CodeGen/2008-08-07-AlignPadding1.c
clang/test/CodeGen/2009-06-14-anonymous-union-init.c
clang/test/CodeGen/64bit-swiftcall.c
clang/test/CodeGen/arm-swiftcall.c
clang/test/CodeGen/const-init.c
clang/test/CodeGen/decl.c
clang/test/CodeGen/designated-initializers.c
clang/test/CodeGen/ext-int.c
clang/test/CodeGen/flexible-array-init.c
clang/test/CodeGen/global-init.c
clang/test/CodeGen/init.c
clang/test/CodeGen/mingw-long-double.c
clang/test/CodeGen/mms-bitfields.c
clang/test/CodeGen/union-init2.c
clang/test/CodeGen/windows-swiftcall.c
clang/test/CodeGenObjC/designated-initializers.m

Removed: 




diff  --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index fe41742a25c642..10232ff41da15a 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -5883,3 +5883,26 @@ specify the starting offset to begin embedding from. The 
resources is treated
 as being empty if the specified offset is larger than the number of bytes in
 the resource. The offset will be applied *before* any ``limit`` parameters are
 applied.
+
+Union and aggregate initialization in C
+===
+
+In C23 (N2900), when an object is initialized from initializer ``= {}``, all
+elements of arrays, all members of structs, and the first members of unions are
+empty-initialized recursively. In addition, all padding bits are initialized to
+zero.
+
+Clang guarantees the following behaviors:
+
+* ``1:`` Clang supports initializer ``= {}`` mentioned above in all C
+  standards.
+
+* ``2:`` When unions are initialized from initializer ``= {}``, bytes outside
+  of the first members of unions are also initialized to zero.
+
+* ``3:`` When unions, structures and arrays are initialized from initializer
+  ``= { initializer-list }``, all members not explicitly initialized in
+  the initializer list are empty-initialized recursively. In addition, all
+  padding bits are initialized to zero.
+
+Currently, the above extension only applies to C source code, not C++.

diff  --git a/clang/lib/CodeGen/CGExprAgg.cpp b/clang/lib/CodeGen/CGExprAgg.cpp
index 74d4c5ea7bcaa4..2ad6587089f101 100644
--- a/clang/lib/CodeGen/CGExprAgg.cpp
+++ b/clang/lib/CodeGen/CGExprAgg.cpp
@@ -12,6 +12,7 @@
 
 #include "CGCXXABI.h"
 #include "CGObjCRuntime.h"
+#include "CGRecordLayout.h"
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
 #include "ConstantEmitter.h"
@@ -64,6 +65,9 @@ class AggExprEmitter : public StmtVisitor {
   void withReturnValueSlot(const Expr *E,
llvm::function_ref Fn);
 
+  void DoZeroInitPadding(uint64_t &PaddingStart, uint64_t PaddingEnd,
+ const FieldDecl *NextField);
+
 public:
   AggExprEmitter(CodeGenFunction &cgf, AggValueSlot Dest, bool IsResultUnused)
 : CGF(cgf), Builder(CGF.Builder), Dest(Dest),
@@ -1698,6 +1702,9 @@ void AggExprEmitter::VisitCXXParenListOrInitListExpr(
   // Prepare a 'this' for CXXDefaultInitExprs.
   CodeGenFunction::FieldConstructionScope FCS(CGF, Dest.getAddress());
 
+  const bool ZeroInitPadding =
+  CGF.CGM.shouldZeroInitPadding() && !Dest.isZeroed();
+
   if (record->isUnion()) {
 // Only initialize one field of a union. The field itself is
 // specified by the initializer list.
@@ -1722,16 +1729,27 @@ void AggExprEmitter::VisitCXXParenListOrInitListExpr(
 if (NumInitElements) {
   // Store the initializer into the field
   EmitInitializationToLValue(InitExprs[0], FieldLoc);
+  if (ZeroInitPadding) {
+uint64_t TotalSize = CGF.getContext().toBits(
+Dest.getPreferredSize(CGF.getContext(), DestLV.getType()));
+uint64_t FieldSize = CGF.getContext().getTypeSize(FieldLoc.getType());
+DoZeroInitPadding(FieldSize, TotalSize, nullptr);
+  }
 } else {
   // Default-initialize to null.
-  EmitNullInitializationToLValue(FieldLoc);
+  if (ZeroInitPadding)
+  

[clang] [clang] Generate note on declaration for nodiscard-related attributes (PR #112289)

2024-10-14 Thread Yihe Li via cfe-commits

https://github.com/Mick235711 created 
https://github.com/llvm/llvm-project/pull/112289

Currently, the following program
```cpp
[[nodiscard]] int fun() { return 1; }
[[deprecated]] int fun2() { return 2; }

int main()
{
fun(); fun2();
}
```
generates the following diagnostics on Clang trunk: ([Compiler 
Explorer](https://godbolt.org/z/48crWEoYY))
```cpp
:6:5: warning: ignoring return value of function declared with 
'nodiscard' attribute [-Wunused-result]
6 | fun(); fun2();
  | ^~~
:6:12: warning: 'fun2' is deprecated [-Wdeprecated-declarations]
6 | fun(); fun2();
  |^
:2:3: note: 'fun2' has been explicitly marked deprecated here
2 | [[deprecated]] int fun2() { return 2; }
  |   ^
2 warnings generated.
```
There seems to exist a discrepancy between `[[deprecated]]` and 
`[[nodiscard]]`. The former generates a warning on the usage of the function, 
together with a note on the declaration of the function. In contrast, the 
latter only generates a warning.

This PR tries to fix this discrepancy by additionally generating a note on the 
declaration of all `[[nodiscard]]`-related attributes (`nodiscard`, 
`warn_unused_result`, `pure`, and `const`). All 4 attributes generate a warning 
on ignoring the return value/constructor result on the trunk, and after this 
PR, all 4 attributes additionally generate a note. The above program will 
output the following diagnostics after this PR:
```cpp
test.cpp:6:5: warning: ignoring return value of function declared with 
'nodiscard' attribute [-Wunused-result]
6 | fun(); fun2();
  | ^~~
test.cpp:1:3: note: 'fun' has been explicitly marked nodiscard here
1 | [[nodiscard]] int fun() { return 1; }
  |   ^
test.cpp:6:12: warning: 'fun2' is deprecated [-Wdeprecated-declarations]
6 | fun(); fun2();
  |^
test.cpp:2:3: note: 'fun2' has been explicitly marked deprecated here
2 | [[deprecated]] int fun2() { return 2; }
  |   ^
2 warnings generated.
```

---
FIrst time contributor here who is not very familiar with Clang's 
infrastructure... Any comments and suggestions are welcome. No new test cases 
are added, as I felt that adding `expected-note`s on existing test cases 
already serves as testing for this PR.

>From 05e44dc97dcb351f719a5f2ce553c8af5aacfac7 Mon Sep 17 00:00:00 2001
From: Yihe Li 
Date: Tue, 15 Oct 2024 08:13:22 +0800
Subject: [PATCH] [clang] Generate note on declaration for nodiscard-related
 attributes

---
 clang/include/clang/AST/Expr.h|  5 +-
 .../clang/Basic/DiagnosticSemaKinds.td|  2 +
 clang/lib/AST/Expr.cpp| 10 +--
 clang/lib/Sema/SemaStmt.cpp   | 63 ---
 .../dcl.attr/dcl.attr.nodiscard/p2.cpp| 29 -
 .../dcl.attr/dcl.attr.nodiscard/p3.cpp|  2 +-
 .../test/OpenMP/declare_variant_messages.cpp  |  2 +-
 clang/test/Sema/c2x-nodiscard.c   | 12 ++--
 clang/test/Sema/unused-expr.c | 10 +--
 clang/test/SemaCXX/coroutines.cpp |  2 +-
 clang/test/SemaCXX/warn-unused-result.cpp | 26 
 .../SemaObjC/method-warn-unused-attribute.m   |  6 +-
 12 files changed, 98 insertions(+), 71 deletions(-)

diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index cbe62411d11bff..8f5679767529fd 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -3182,11 +3182,12 @@ class CallExpr : public Expr {
 
   /// Returns the WarnUnusedResultAttr that is either declared on the called
   /// function, or its return type declaration.
-  const Attr *getUnusedResultAttr(const ASTContext &Ctx) const;
+  std::pair
+  getUnusedResultAttr(const ASTContext &Ctx) const;
 
   /// Returns true if this call expression should warn on unused results.
   bool hasUnusedResultAttr(const ASTContext &Ctx) const {
-return getUnusedResultAttr(Ctx) != nullptr;
+return getUnusedResultAttr(Ctx).second != nullptr;
   }
 
   SourceLocation getRParenLoc() const { return RParenLoc; }
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index c709795e7b21d8..3f6e4c35146454 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -9290,6 +9290,8 @@ def warn_unused_result_typedef_unsupported_spelling : 
Warning<
 def warn_unused_volatile : Warning<
   "expression result unused; assign into a variable to force a volatile load">,
   InGroup>;
+def note_nodiscard_specified_here : Note<
+  "%0 has been explicitly marked %1 here">;
 
 def ext_cxx14_attr : Extension<
   "use of the %0 attribute is a C++14 extension">, InGroup;
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index 9ecbf121e3fc0d..b9450d6a61e57c 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -1616,22 +1616,24 @@ QualType CallExpr::getCallReturnType(const ASTContext 
&Ctx) const {
   ret

[clang] [clang] Generate note on declaration for nodiscard-related attributes (PR #112289)

2024-10-14 Thread via cfe-commits

github-actions[bot] wrote:



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

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

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

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

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

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

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

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


[clang] [clang] Generate note on declaration for nodiscard-related attributes (PR #112289)

2024-10-14 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Yihe Li (Mick235711)


Changes

Currently, the following program
```cpp
[[nodiscard]] int fun() { return 1; }
[[deprecated]] int fun2() { return 2; }

int main()
{
fun(); fun2();
}
```
generates the following diagnostics on Clang trunk: ([Compiler 
Explorer](https://godbolt.org/z/48crWEoYY))
```cpp
:6:5: warning: ignoring return value of function declared with 
'nodiscard' attribute [-Wunused-result]
6 | fun(); fun2();
  | ^~~
:6:12: warning: 'fun2' is deprecated [-Wdeprecated-declarations]
6 | fun(); fun2();
  |^
:2:3: note: 'fun2' has been explicitly marked deprecated here
2 | [[deprecated]] int fun2() { return 2; }
  |   ^
2 warnings generated.
```
There seems to exist a discrepancy between `[[deprecated]]` and 
`[[nodiscard]]`. The former generates a warning on the usage of the function, 
together with a note on the declaration of the function. In contrast, the 
latter only generates a warning.

This PR tries to fix this discrepancy by additionally generating a note on the 
declaration of all `[[nodiscard]]`-related attributes (`nodiscard`, 
`warn_unused_result`, `pure`, and `const`). All 4 attributes generate a warning 
on ignoring the return value/constructor result on the trunk, and after this 
PR, all 4 attributes additionally generate a note. The above program will 
output the following diagnostics after this PR:
```cpp
test.cpp:6:5: warning: ignoring return value of function declared with 
'nodiscard' attribute [-Wunused-result]
6 | fun(); fun2();
  | ^~~
test.cpp:1:3: note: 'fun' has been explicitly marked nodiscard here
1 | [[nodiscard]] int fun() { return 1; }
  |   ^
test.cpp:6:12: warning: 'fun2' is deprecated [-Wdeprecated-declarations]
6 | fun(); fun2();
  |^
test.cpp:2:3: note: 'fun2' has been explicitly marked deprecated here
2 | [[deprecated]] int fun2() { return 2; }
  |   ^
2 warnings generated.
```

---
FIrst time contributor here who is not very familiar with Clang's 
infrastructure... Any comments and suggestions are welcome. No new test cases 
are added, as I felt that adding `expected-note`s on existing test cases 
already serves as testing for this PR.

---

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


12 Files Affected:

- (modified) clang/include/clang/AST/Expr.h (+3-2) 
- (modified) clang/include/clang/Basic/DiagnosticSemaKinds.td (+2) 
- (modified) clang/lib/AST/Expr.cpp (+6-4) 
- (modified) clang/lib/Sema/SemaStmt.cpp (+42-21) 
- (modified) clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p2.cpp (+15-14) 
- (modified) clang/test/CXX/dcl.dcl/dcl.attr/dcl.attr.nodiscard/p3.cpp (+1-1) 
- (modified) clang/test/OpenMP/declare_variant_messages.cpp (+1-1) 
- (modified) clang/test/Sema/c2x-nodiscard.c (+6-6) 
- (modified) clang/test/Sema/unused-expr.c (+5-5) 
- (modified) clang/test/SemaCXX/coroutines.cpp (+1-1) 
- (modified) clang/test/SemaCXX/warn-unused-result.cpp (+13-13) 
- (modified) clang/test/SemaObjC/method-warn-unused-attribute.m (+3-3) 


``diff
diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index cbe62411d11bff..8f5679767529fd 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -3182,11 +3182,12 @@ class CallExpr : public Expr {
 
   /// Returns the WarnUnusedResultAttr that is either declared on the called
   /// function, or its return type declaration.
-  const Attr *getUnusedResultAttr(const ASTContext &Ctx) const;
+  std::pair
+  getUnusedResultAttr(const ASTContext &Ctx) const;
 
   /// Returns true if this call expression should warn on unused results.
   bool hasUnusedResultAttr(const ASTContext &Ctx) const {
-return getUnusedResultAttr(Ctx) != nullptr;
+return getUnusedResultAttr(Ctx).second != nullptr;
   }
 
   SourceLocation getRParenLoc() const { return RParenLoc; }
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index c709795e7b21d8..3f6e4c35146454 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -9290,6 +9290,8 @@ def warn_unused_result_typedef_unsupported_spelling : 
Warning<
 def warn_unused_volatile : Warning<
   "expression result unused; assign into a variable to force a volatile load">,
   InGroup>;
+def note_nodiscard_specified_here : Note<
+  "%0 has been explicitly marked %1 here">;
 
 def ext_cxx14_attr : Extension<
   "use of the %0 attribute is a C++14 extension">, InGroup;
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index 9ecbf121e3fc0d..b9450d6a61e57c 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -1616,22 +1616,24 @@ QualType CallExpr::getCallReturnType(const ASTContext 
&Ctx) const {
   return FnType->getReturnType();
 }
 
-const 

[clang] [Clang][SYCL] Introduce clang-sycl-link-wrapper to link SYCL offloading device code (Part 1 of many) (PR #112245)

2024-10-14 Thread Joseph Huber via cfe-commits


@@ -6728,7 +6728,10 @@ def fsycl : Flag<["-"], "fsycl">,
 def fno_sycl : Flag<["-"], "fno-sycl">,
   Visibility<[ClangOption, CLOption]>,
   Group, HelpText<"Disables SYCL kernels compilation for device">;
-
+def sycl_link : Flag<["--"], "sycl-link">, Flags<[HelpHidden]>,

jhuber6 wrote:

Why is this necessary? Shouldn't it do this automatically if we pass in `.o` 
files or use `-Xlinker foo.c`?

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


[clang] [Clang][SYCL] Introduce clang-sycl-link-wrapper to link SYCL offloading device code (Part 1 of many) (PR #112245)

2024-10-14 Thread Joseph Huber via cfe-commits


@@ -0,0 +1,528 @@
+//=-- clang-sycl-link-wrapper/ClangSYCLLinkWrapper.cpp - SYCL linker util --=//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===-===//
+//
+// This tool wraps around the sequence of steps required to link device code in
+// SYCL fat objects. SYCL device code linking requires a complex sequence of
+// steps that include linking of llvm bitcode files, linking device library
+// files with the fully linked source bitcode file(s), running several SYCL
+// specific post-link steps on the fully linked bitcode file(s), and finally
+// generating target-specific device code. This tool can be removed once SYCL
+// linking is ported to `ld.lld`.
+//
+//===-===//
+
+#include "clang/Basic/Version.h"
+
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/BinaryFormat/Magic.h"
+#include "llvm/Bitcode/BitcodeWriter.h"
+#include "llvm/CodeGen/CommandFlags.h"
+#include "llvm/IR/DiagnosticPrinter.h"
+#include "llvm/IRReader/IRReader.h"
+#include "llvm/LTO/LTO.h"
+#include "llvm/Object/Archive.h"
+#include "llvm/Object/ArchiveWriter.h"
+#include "llvm/Object/Binary.h"
+#include "llvm/Object/ELFObjectFile.h"
+#include "llvm/Object/IRObjectFile.h"
+#include "llvm/Object/ObjectFile.h"
+#include "llvm/Object/OffloadBinary.h"
+#include "llvm/Option/ArgList.h"
+#include "llvm/Option/OptTable.h"
+#include "llvm/Option/Option.h"
+#include "llvm/Remarks/HotnessThresholdParser.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FileOutputBuffer.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/InitLLVM.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/Program.h"
+#include "llvm/Support/Signals.h"
+#include "llvm/Support/StringSaver.h"
+#include "llvm/Support/TargetSelect.h"
+#include "llvm/Support/TimeProfiler.h"
+#include "llvm/Support/WithColor.h"
+
+using namespace llvm;
+using namespace llvm::opt;
+using namespace llvm::object;
+
+/// Save intermediary results.
+static bool SaveTemps = false;
+
+/// Print arguments without executing.
+static bool DryRun = false;
+
+/// Print verbose output.
+static bool Verbose = false;
+
+/// Filename of the output being created.
+static StringRef OutputFile;
+
+/// Directory to dump SPIR-V IR if requested by user.
+static SmallString<128> SPIRVDumpDir;
+
+static void printVersion(raw_ostream &OS) {
+  OS << clang::getClangToolFullVersion("clang-sycl-link-wrapper") << '\n';
+}
+
+/// The value of `argv[0]` when run.
+static const char *Executable;
+
+/// Temporary files to be cleaned up.
+static SmallVector> TempFiles;
+
+namespace {
+// Must not overlap with llvm::opt::DriverFlag.
+enum WrapperFlags { WrapperOnlyOption = (1 << 4) };
+
+enum ID {
+  OPT_INVALID = 0, // This is not an option ID.
+#define OPTION(...) LLVM_MAKE_OPT_ID(__VA_ARGS__),
+#include "SYCLLinkOpts.inc"
+  LastOption
+#undef OPTION
+};
+
+#define PREFIX(NAME, VALUE)
\
+  static constexpr StringLiteral NAME##_init[] = VALUE;
\
+  static constexpr ArrayRef NAME(NAME##_init,   
\
+std::size(NAME##_init) - 1);
+#include "SYCLLinkOpts.inc"
+#undef PREFIX
+
+static constexpr OptTable::Info InfoTable[] = {
+#define OPTION(...) LLVM_CONSTRUCT_OPT_INFO(__VA_ARGS__),
+#include "SYCLLinkOpts.inc"
+#undef OPTION
+};
+
+class WrapperOptTable : public opt::GenericOptTable {
+public:
+  WrapperOptTable() : opt::GenericOptTable(InfoTable) {}
+};
+
+const OptTable &getOptTable() {
+  static const WrapperOptTable *Table = []() {
+auto Result = std::make_unique();
+return Result.release();
+  }();
+  return *Table;
+}
+
+[[noreturn]] void reportError(Error E) {
+  outs().flush();
+  logAllUnhandledErrors(std::move(E), WithColor::error(errs(), Executable));
+  exit(EXIT_FAILURE);
+}
+
+std::string getMainExecutable(const char *Name) {
+  void *Ptr = (void *)(intptr_t)&getMainExecutable;
+  auto COWPath = sys::fs::getMainExecutable(Name, Ptr);
+  return sys::path::parent_path(COWPath).str();
+}
+
+Expected createTempFile(const ArgList &Args, const Twine &Prefix,
+   StringRef Extension) {
+  SmallString<128> OutputFile;
+  if (Args.hasArg(OPT_save_temps)) {
+// Generate a unique path name without creating a file
+sys::fs::createUniquePath(Prefix + "-%%." + Extension, OutputFile,
+  /*MakeAbsolute=*/false);
+  } else {
+if (std::error_code EC =
+sys::fs::createTemporaryFile(Prefix, Extension, OutputFile))
+  return createFileError(OutputFile, EC);
+  }
+
+  TempFiles.emplace_back(std::move(OutputFil

[clang] [Clang][SYCL] Introduce clang-sycl-link-wrapper to link SYCL offloading device code (Part 1 of many) (PR #112245)

2024-10-14 Thread Joseph Huber via cfe-commits




jhuber6 wrote:

Why do we need these? We can create empty bitcode files inside the tests using 
`clang`. (Also I'm wondering if there's an existing empty bitcode file).

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


[clang] [Clang][SYCL] Introduce clang-sycl-link-wrapper to link SYCL offloading device code (Part 1 of many) (PR #112245)

2024-10-14 Thread Joseph Huber via cfe-commits


@@ -95,7 +95,19 @@ void SPIRV::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
 
+  // Use of --sycl-link will call the clang-sycl-link-wrapper instead of
+  // the default linker (spirv-link).
+  if (Args.hasArg(options::OPT_sycl_link))
+Linker = ToolChain.GetProgramPath("clang-sycl-link-wrapper");

jhuber6 wrote:

I'm not sure I'd call this a wrapper since it doesn't really wrap around 
anything as far as I'm aware, it's more of a utility that creates a SYCL image 
from some LLVM-IR. Maybe just `linker`?

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


[clang] [Clang][SYCL] Introduce clang-sycl-link-wrapper to link SYCL offloading device code (Part 1 of many) (PR #112245)

2024-10-14 Thread Joseph Huber via cfe-commits


@@ -0,0 +1,528 @@
+//=-- clang-sycl-link-wrapper/ClangSYCLLinkWrapper.cpp - SYCL linker util --=//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===-===//
+//
+// This tool wraps around the sequence of steps required to link device code in
+// SYCL fat objects. SYCL device code linking requires a complex sequence of
+// steps that include linking of llvm bitcode files, linking device library
+// files with the fully linked source bitcode file(s), running several SYCL
+// specific post-link steps on the fully linked bitcode file(s), and finally
+// generating target-specific device code. This tool can be removed once SYCL
+// linking is ported to `ld.lld`.
+//
+//===-===//
+
+#include "clang/Basic/Version.h"
+
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/BinaryFormat/Magic.h"
+#include "llvm/Bitcode/BitcodeWriter.h"
+#include "llvm/CodeGen/CommandFlags.h"
+#include "llvm/IR/DiagnosticPrinter.h"
+#include "llvm/IRReader/IRReader.h"
+#include "llvm/LTO/LTO.h"
+#include "llvm/Object/Archive.h"
+#include "llvm/Object/ArchiveWriter.h"
+#include "llvm/Object/Binary.h"
+#include "llvm/Object/ELFObjectFile.h"
+#include "llvm/Object/IRObjectFile.h"
+#include "llvm/Object/ObjectFile.h"
+#include "llvm/Object/OffloadBinary.h"
+#include "llvm/Option/ArgList.h"
+#include "llvm/Option/OptTable.h"
+#include "llvm/Option/Option.h"
+#include "llvm/Remarks/HotnessThresholdParser.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FileOutputBuffer.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/InitLLVM.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/Program.h"
+#include "llvm/Support/Signals.h"
+#include "llvm/Support/StringSaver.h"
+#include "llvm/Support/TargetSelect.h"
+#include "llvm/Support/TimeProfiler.h"
+#include "llvm/Support/WithColor.h"
+
+using namespace llvm;
+using namespace llvm::opt;
+using namespace llvm::object;
+
+/// Save intermediary results.
+static bool SaveTemps = false;
+
+/// Print arguments without executing.
+static bool DryRun = false;
+
+/// Print verbose output.
+static bool Verbose = false;
+
+/// Filename of the output being created.
+static StringRef OutputFile;
+
+/// Directory to dump SPIR-V IR if requested by user.
+static SmallString<128> SPIRVDumpDir;
+
+static void printVersion(raw_ostream &OS) {
+  OS << clang::getClangToolFullVersion("clang-sycl-link-wrapper") << '\n';
+}
+
+/// The value of `argv[0]` when run.
+static const char *Executable;
+
+/// Temporary files to be cleaned up.
+static SmallVector> TempFiles;
+
+namespace {
+// Must not overlap with llvm::opt::DriverFlag.
+enum WrapperFlags { WrapperOnlyOption = (1 << 4) };
+
+enum ID {
+  OPT_INVALID = 0, // This is not an option ID.
+#define OPTION(...) LLVM_MAKE_OPT_ID(__VA_ARGS__),
+#include "SYCLLinkOpts.inc"
+  LastOption
+#undef OPTION
+};
+
+#define PREFIX(NAME, VALUE)
\
+  static constexpr StringLiteral NAME##_init[] = VALUE;
\
+  static constexpr ArrayRef NAME(NAME##_init,   
\
+std::size(NAME##_init) - 1);
+#include "SYCLLinkOpts.inc"
+#undef PREFIX
+
+static constexpr OptTable::Info InfoTable[] = {
+#define OPTION(...) LLVM_CONSTRUCT_OPT_INFO(__VA_ARGS__),
+#include "SYCLLinkOpts.inc"
+#undef OPTION
+};
+
+class WrapperOptTable : public opt::GenericOptTable {
+public:
+  WrapperOptTable() : opt::GenericOptTable(InfoTable) {}
+};
+
+const OptTable &getOptTable() {
+  static const WrapperOptTable *Table = []() {
+auto Result = std::make_unique();
+return Result.release();
+  }();
+  return *Table;
+}
+
+[[noreturn]] void reportError(Error E) {
+  outs().flush();
+  logAllUnhandledErrors(std::move(E), WithColor::error(errs(), Executable));
+  exit(EXIT_FAILURE);
+}
+
+std::string getMainExecutable(const char *Name) {
+  void *Ptr = (void *)(intptr_t)&getMainExecutable;
+  auto COWPath = sys::fs::getMainExecutable(Name, Ptr);
+  return sys::path::parent_path(COWPath).str();
+}
+
+Expected createTempFile(const ArgList &Args, const Twine &Prefix,
+   StringRef Extension) {
+  SmallString<128> OutputFile;
+  if (Args.hasArg(OPT_save_temps)) {
+// Generate a unique path name without creating a file
+sys::fs::createUniquePath(Prefix + "-%%." + Extension, OutputFile,
+  /*MakeAbsolute=*/false);
+  } else {
+if (std::error_code EC =
+sys::fs::createTemporaryFile(Prefix, Extension, OutputFile))
+  return createFileError(OutputFile, EC);
+  }
+
+  TempFiles.emplace_back(std::move(OutputFil

[clang] [Clang][SYCL] Introduce clang-sycl-link-wrapper to link SYCL offloading device code (Part 1 of many) (PR #112245)

2024-10-14 Thread Joseph Huber via cfe-commits


@@ -0,0 +1,530 @@
+//=-- clang-sycl-link-wrapper/ClangSYCLLinkWrapper.cpp - SYCL linker util --=//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===-===//
+//
+// This tool wraps around the sequence of steps required to link device code in
+// SYCL fat objects. SYCL device code linking requires a complex sequence of
+// steps that include linking of llvm bitcode files, linking device library
+// files with the fully linked source bitcode file(s), running several SYCL
+// specific post-link steps on the fully linked bitcode file(s), and finally
+// generating target-specific device code. This tool can be removed once SYCL
+// linking is ported to `ld.lld`.
+//
+//===-===//
+
+#include "clang/Basic/Version.h"
+
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/BinaryFormat/Magic.h"
+#include "llvm/Bitcode/BitcodeWriter.h"
+#include "llvm/CodeGen/CommandFlags.h"
+#include "llvm/IR/DiagnosticPrinter.h"
+#include "llvm/IRReader/IRReader.h"
+#include "llvm/LTO/LTO.h"
+#include "llvm/Object/Archive.h"
+#include "llvm/Object/ArchiveWriter.h"
+#include "llvm/Object/Binary.h"
+#include "llvm/Object/ELFObjectFile.h"
+#include "llvm/Object/IRObjectFile.h"
+#include "llvm/Object/ObjectFile.h"
+#include "llvm/Object/OffloadBinary.h"
+#include "llvm/Option/ArgList.h"
+#include "llvm/Option/OptTable.h"
+#include "llvm/Option/Option.h"
+#include "llvm/Remarks/HotnessThresholdParser.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FileOutputBuffer.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/InitLLVM.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/Program.h"
+#include "llvm/Support/Signals.h"
+#include "llvm/Support/StringSaver.h"
+#include "llvm/Support/TargetSelect.h"
+#include "llvm/Support/TimeProfiler.h"
+#include "llvm/Support/WithColor.h"
+
+using namespace llvm;
+using namespace llvm::opt;
+using namespace llvm::object;
+
+/// Save intermediary results.
+static bool SaveTemps = false;
+
+/// Print arguments without executing.
+static bool DryRun = false;
+
+/// Print verbose output.
+static bool Verbose = false;
+
+/// Filename of the output being created.
+static StringRef OutputFile;
+
+/// Directory to dump SPIR-V IR if requested by user.
+static SmallString<128> SPIRVDumpDir;
+
+static void printVersion(raw_ostream &OS) {
+  OS << clang::getClangToolFullVersion("clang-sycl-link-wrapper") << '\n';
+}
+
+/// The value of `argv[0]` when run.
+static const char *Executable;
+
+/// Temporary files to be cleaned up.
+static SmallVector> TempFiles;
+
+namespace {
+// Must not overlap with llvm::opt::DriverFlag.
+enum WrapperFlags { WrapperOnlyOption = (1 << 4) };
+
+enum ID {
+  OPT_INVALID = 0, // This is not an option ID.
+#define OPTION(...) LLVM_MAKE_OPT_ID(__VA_ARGS__),
+#include "SYCLLinkOpts.inc"
+  LastOption
+#undef OPTION
+};
+
+#define PREFIX(NAME, VALUE)
\
+  static constexpr StringLiteral NAME##_init[] = VALUE;
\
+  static constexpr ArrayRef NAME(NAME##_init,   
\
+std::size(NAME##_init) - 1);
+#include "SYCLLinkOpts.inc"
+#undef PREFIX
+
+static constexpr OptTable::Info InfoTable[] = {

jhuber6 wrote:

The thing that's special about this case is that it forwards arguments it 
doesn't understand via a flag. We could possibly make a utility for that.

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


[clang] [Clang] Allow all address spaces to be converted to the default (PR #112248)

2024-10-14 Thread Joseph Huber via cfe-commits


@@ -721,7 +721,9 @@ class Qualifiers {
// to implicitly cast into the default address space.
(A == LangAS::Default &&
 (B == LangAS::cuda_constant || B == LangAS::cuda_device ||
- B == LangAS::cuda_shared));
+ B == LangAS::cuda_shared)) ||
+   // Otherwise, assume the default address space is compatible.
+   (A == LangAS::Default);

jhuber6 wrote:

Yeah I noted  there's actually a case where OpenCL touches this for function 
pointers. I might just have the OpenCL language call a different version of 
this. Overall the other targets just allow any AS to decay to default and 
that's likely the behavior we want when not bound by OpenCL semantics.

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


[clang] [Headers] [ARM64EC] Fix extra tokens inside intrin0.h preprocessor directive (PR #112066)

2024-10-14 Thread via cfe-commits

llvmbot wrote:

/pull-request llvm/llvm-project#112258

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


[clang] [flang] [clang][flang] Support -time in both clang and flang (PR #109165)

2024-10-14 Thread Tarun Prabhu via cfe-commits

https://github.com/tarunprabhu updated 
https://github.com/llvm/llvm-project/pull/109165

>From 3b926fce8dbf42577adf54e80d3383a85b170e91 Mon Sep 17 00:00:00 2001
From: Tarun Prabhu 
Date: Wed, 18 Sep 2024 09:49:26 -0600
Subject: [PATCH 1/6] [clang][flang] Support -time in both clang and flang

The -time option prints timing information for the subcommands (compiler,
linker) in a format similar to that used by gcc/gfortran (we use more digits
of precision).

This partially addresses requests from #89888
---
 clang/include/clang/Driver/Options.td |  1 +
 clang/lib/Driver/Compilation.cpp  | 21 +
 clang/lib/Driver/Driver.cpp   |  3 +++
 clang/test/Driver/time.c  | 24 
 flang/test/Driver/time.f90| 22 ++
 5 files changed, 71 insertions(+)
 create mode 100644 clang/test/Driver/time.c
 create mode 100644 flang/test/Driver/time.f90

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index d306c751505e98..f7cce59105e17a 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5865,6 +5865,7 @@ def print_enabled_extensions : Flag<["-", "--"], 
"print-enabled-extensions">,
 def : Flag<["-"], "mcpu=help">, Alias;
 def : Flag<["-"], "mtune=help">, Alias;
 def time : Flag<["-"], "time">,
+  Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>,
   HelpText<"Time individual commands">;
 def traditional_cpp : Flag<["-", "--"], "traditional-cpp">,
   Visibility<[ClangOption, CC1Option]>,
diff --git a/clang/lib/Driver/Compilation.cpp b/clang/lib/Driver/Compilation.cpp
index ad077d5bbfa69a..aadaa236246a27 100644
--- a/clang/lib/Driver/Compilation.cpp
+++ b/clang/lib/Driver/Compilation.cpp
@@ -21,6 +21,9 @@
 #include "llvm/Option/OptSpecifier.h"
 #include "llvm/Option/Option.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Format.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/Timer.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/TargetParser/Triple.h"
 #include 
@@ -194,11 +197,29 @@ int Compilation::ExecuteCommand(const Command &C,
   if (LogOnly)
 return 0;
 
+  // We don't use any timers or llvm::TimeGroup's because those are tied into
+  // the global static timer list which, in principle, could be cleared without
+  // us knowing about it.
+  llvm::TimeRecord StartTime;
+  if (getArgs().hasArg(options::OPT_time)) {
+StartTime = llvm::TimeRecord::getCurrentTime(true);
+  }
+
   std::string Error;
   bool ExecutionFailed;
   int Res = C.Execute(Redirects, &Error, &ExecutionFailed);
   if (PostCallback)
 PostCallback(C, Res);
+
+  if (getArgs().hasArg(options::OPT_time)) {
+llvm::TimeRecord Time = llvm::TimeRecord::getCurrentTime(false);
+Time -= StartTime;
+llvm::StringRef Name = llvm::sys::path::filename(C.getExecutable());
+llvm::errs() << "# " << Name << " "
+ << llvm::format("%0.5f", Time.getUserTime()) << " "
+ << llvm::format("%0.5f", Time.getSystemTime()) << "\n";
+  }
+
   if (!Error.empty()) {
 assert(Res && "Error string set with 0 result code!");
 getDriver().Diag(diag::err_drv_command_failure) << Error;
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 9878a9dad78d40..15ae86bc479010 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -1318,6 +1318,9 @@ Compilation *Driver::BuildCompilation(ArrayRef ArgList) {
   // Ignore -pipe.
   Args.ClaimAllArgs(options::OPT_pipe);
 
+  // Ignore -time.
+  Args.ClaimAllArgs(options::OPT_time);
+
   // Extract -ccc args.
   //
   // FIXME: We need to figure out where this behavior should live. Most of it
diff --git a/clang/test/Driver/time.c b/clang/test/Driver/time.c
new file mode 100644
index 00..1e19f29ab76a32
--- /dev/null
+++ b/clang/test/Driver/time.c
@@ -0,0 +1,24 @@
+// The -time option prints timing information for the various subcommands in a
+// format similar to that used by gcc. When compiling and linking, this will
+// include the time to call clang-${LLVM_VERSION_MAJOR} and the linker. Since
+// the name of the linker could vary across platforms, and name of the compiler
+// could be something different, just check that whatever is printed to stderr
+// looks like timing information.
+
+// RUN: %clang -time -c -O3 -o /dev/null %s 2>&1 \
+// RUN: | FileCheck %s --check-prefix=COMPILE-ONLY
+// RUN: %clang -time -S -emit-llvm -O3 -o /dev/null %s 2>&1 \
+// RUN: | FileCheck %s --check-prefix=COMPILE-ONLY
+// RUN: %clang -time -S -O3 -o /dev/null %s 2>&1 \
+// RUN: | FileCheck %s --check-prefix=COMPILE-ONLY
+// RUN: %clang -time -O3 -o /dev/null %s 2>&1 \
+// RUN: | FileCheck %s --check-prefix=COMPILE-AND-LINK
+
+// COMPILE-ONLY: # {{.+}} {{[0-9]+(.[0-9]+)?}} {{[0-9]+(.[0-9]+)?}}
+
+// COMPILE-AND-LINK: # {{.+}} {{[0-9]+(.[0-9]+)?}} {{[0-9]+(.[0-9]+)?}}
+// COMPILE-AND-LINK: # {{.+}} {{[0-9]+(.[0

[clang] [flang] [clang][flang] Support -time in both clang and flang (PR #109165)

2024-10-14 Thread Tarun Prabhu via cfe-commits


@@ -194,11 +197,29 @@ int Compilation::ExecuteCommand(const Command &C,
   if (LogOnly)
 return 0;
 
+  // We don't use any timers or llvm::TimeGroup's because those are tied into
+  // the global static timer list which, in principle, could be cleared without
+  // us knowing about it.
+  llvm::TimeRecord StartTime;
+  if (getArgs().hasArg(options::OPT_time)) {
+StartTime = llvm::TimeRecord::getCurrentTime(true);

tarunprabhu wrote:

Done

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


[clang] [flang] [clang][flang] Support -time in both clang and flang (PR #109165)

2024-10-14 Thread Tarun Prabhu via cfe-commits


@@ -194,11 +197,29 @@ int Compilation::ExecuteCommand(const Command &C,
   if (LogOnly)
 return 0;
 
+  // We don't use any timers or llvm::TimeGroup's because those are tied into
+  // the global static timer list which, in principle, could be cleared without
+  // us knowing about it.
+  llvm::TimeRecord StartTime;
+  if (getArgs().hasArg(options::OPT_time)) {
+StartTime = llvm::TimeRecord::getCurrentTime(true);
+  }
+
   std::string Error;
   bool ExecutionFailed;
   int Res = C.Execute(Redirects, &Error, &ExecutionFailed);
   if (PostCallback)
 PostCallback(C, Res);
+
+  if (getArgs().hasArg(options::OPT_time)) {
+llvm::TimeRecord Time = llvm::TimeRecord::getCurrentTime(false);

tarunprabhu wrote:

Done

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


[clang] [HLSL] Collect explicit resource binding information (PR #111203)

2024-10-14 Thread Damyan Pepper via cfe-commits


@@ -4593,6 +4593,44 @@ def HLSLResourceBinding: InheritableAttr {
   let LangOpts = [HLSL];
   let Args = [StringArgument<"Slot">, StringArgument<"Space", 1>];
   let Documentation = [HLSLResourceBindingDocs];
+  let AdditionalMembers = [{
+  enum class RegisterType : unsigned { SRV, UAV, CBuffer, Sampler, C, I, 
Invalid };
+
+  RegisterType RegType;
+  unsigned SlotNumber;
+  unsigned SpaceNumber;
+  
+  // Size of the binding
+  // 0 == not set
+  //-1 == unbounded
+  int Size;
+
+  void setBinding(RegisterType RT, unsigned SlotNum, unsigned SpaceNum, 
int Size = 0) {
+RegType = RT;
+SlotNumber = SlotNum;
+SpaceNumber = SpaceNum;
+  }
+  RegisterType getRegisterType() {

damyanp wrote:

All of these getters should be `const`.

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


[clang] [HLSL] Collect explicit resource binding information (PR #111203)

2024-10-14 Thread Damyan Pepper via cfe-commits


@@ -4593,6 +4593,44 @@ def HLSLResourceBinding: InheritableAttr {
   let LangOpts = [HLSL];
   let Args = [StringArgument<"Slot">, StringArgument<"Space", 1>];
   let Documentation = [HLSLResourceBindingDocs];
+  let AdditionalMembers = [{
+  enum class RegisterType : unsigned { SRV, UAV, CBuffer, Sampler, C, I, 
Invalid };
+
+  RegisterType RegType;
+  unsigned SlotNumber;
+  unsigned SpaceNumber;
+  
+  // Size of the binding
+  // 0 == not set
+  //-1 == unbounded
+  int Size;
+
+  void setBinding(RegisterType RT, unsigned SlotNum, unsigned SpaceNum, 
int Size = 0) {
+RegType = RT;
+SlotNumber = SlotNum;
+SpaceNumber = SpaceNum;
+  }
+  RegisterType getRegisterType() {
+return RegType;
+  }
+  unsigned getSlotNumber() {
+return SlotNumber;
+  }
+  unsigned getSpaceNumber() {
+return SpaceNumber;
+  }
+  unsigned getSize() {
+assert(Size == -1 || Size > 0 && "size not set");
+return Size;
+  }
+  void setSize(int N) {
+assert(N == -1 || N > 0 && "unexpected size value");
+Size = N;
+  }
+  bool isSizeUnbounded() {
+return Size == -1;

damyanp wrote:

Presumably this should have the same assert as on line 4623.  Or could be 
written as `return getSize() == -1;`

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


[clang] [HLSL] Collect explicit resource binding information (PR #111203)

2024-10-14 Thread Damyan Pepper via cfe-commits


@@ -83,6 +81,49 @@ static RegisterType getRegisterType(StringRef Slot) {
   }
 }
 
+static ResourceClass getResourceClass(RegisterType RT) {
+  switch (RT) {
+  case RegisterType::SRV:
+return ResourceClass::SRV;
+  case RegisterType::UAV:
+return ResourceClass::UAV;
+  case RegisterType::CBuffer:
+return ResourceClass::CBuffer;
+  case RegisterType::Sampler:
+return ResourceClass::Sampler;
+  default:
+llvm_unreachable("unexpected RegisterType value");
+  }
+}
+
+DeclBindingInfo *ResourceBindings::addDeclBindingInfo(const VarDecl *VD,
+  ResourceClass ResClass,
+  int Size) {
+  assert(getDeclBindingInfo(VD, ResClass) == nullptr &&
+ "DeclBindingInfo already added");
+  if (DeclToBindingListIndex.find(VD) == DeclToBindingListIndex.end())
+DeclToBindingListIndex[VD] = BindingsList.size();

damyanp wrote:

I think this'll work and only do a single lookup into the map:

```suggestion
  DeclToBindingListIndex.try_emplace(BindingsList.size());
```

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


[clang] [HLSL] Collect explicit resource binding information (PR #111203)

2024-10-14 Thread Damyan Pepper via cfe-commits


@@ -4593,6 +4593,44 @@ def HLSLResourceBinding: InheritableAttr {
   let LangOpts = [HLSL];
   let Args = [StringArgument<"Slot">, StringArgument<"Space", 1>];
   let Documentation = [HLSLResourceBindingDocs];
+  let AdditionalMembers = [{
+  enum class RegisterType : unsigned { SRV, UAV, CBuffer, Sampler, C, I, 
Invalid };
+
+  RegisterType RegType;
+  unsigned SlotNumber;
+  unsigned SpaceNumber;
+  
+  // Size of the binding
+  // 0 == not set
+  //-1 == unbounded
+  int Size;

damyanp wrote:

I can't find anywhere that unconditionally initializes these values?

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


[clang] [HLSL] Collect explicit resource binding information (PR #111203)

2024-10-14 Thread Damyan Pepper via cfe-commits

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


[clang] [HLSL] Collect explicit resource binding information (PR #111203)

2024-10-14 Thread Damyan Pepper via cfe-commits


@@ -4593,6 +4593,44 @@ def HLSLResourceBinding: InheritableAttr {
   let LangOpts = [HLSL];
   let Args = [StringArgument<"Slot">, StringArgument<"Space", 1>];
   let Documentation = [HLSLResourceBindingDocs];
+  let AdditionalMembers = [{
+  enum class RegisterType : unsigned { SRV, UAV, CBuffer, Sampler, C, I, 
Invalid };
+
+  RegisterType RegType;
+  unsigned SlotNumber;
+  unsigned SpaceNumber;
+  
+  // Size of the binding
+  // 0 == not set
+  //-1 == unbounded
+  int Size;
+
+  void setBinding(RegisterType RT, unsigned SlotNum, unsigned SpaceNum, 
int Size = 0) {
+RegType = RT;
+SlotNumber = SlotNum;
+SpaceNumber = SpaceNum;
+  }
+  RegisterType getRegisterType() {
+return RegType;
+  }
+  unsigned getSlotNumber() {
+return SlotNumber;
+  }
+  unsigned getSpaceNumber() {
+return SpaceNumber;
+  }
+  unsigned getSize() {
+assert(Size == -1 || Size > 0 && "size not set");

damyanp wrote:

> "size not set"

This implies that maybe Size is meant to be initialized to some value that's < 
-1 in order to be able to tell that it isn't set - yet I don't see that 
happening anywhere.

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


[clang] [HLSL] Collect explicit resource binding information (PR #111203)

2024-10-14 Thread Damyan Pepper via cfe-commits


@@ -83,6 +81,49 @@ static RegisterType getRegisterType(StringRef Slot) {
   }
 }
 
+static ResourceClass getResourceClass(RegisterType RT) {
+  switch (RT) {
+  case RegisterType::SRV:
+return ResourceClass::SRV;
+  case RegisterType::UAV:
+return ResourceClass::UAV;
+  case RegisterType::CBuffer:
+return ResourceClass::CBuffer;
+  case RegisterType::Sampler:
+return ResourceClass::Sampler;
+  default:
+llvm_unreachable("unexpected RegisterType value");
+  }
+}
+
+DeclBindingInfo *ResourceBindings::addDeclBindingInfo(const VarDecl *VD,
+  ResourceClass ResClass,
+  int Size) {
+  assert(getDeclBindingInfo(VD, ResClass) == nullptr &&
+ "DeclBindingInfo already added");
+  if (DeclToBindingListIndex.find(VD) == DeclToBindingListIndex.end())
+DeclToBindingListIndex[VD] = BindingsList.size();
+  return &BindingsList.emplace_back(DeclBindingInfo(VD, ResClass, Size));

damyanp wrote:

```suggestion
  return &BindingsList.emplace_back(VD, ResClass, Size);
```

Or

```suggestion
  return &BindingsList.push_back(DeclBindingInfo(VD, ResClass, Size));
```


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


[clang] [HLSL] Collect explicit resource binding information (PR #111203)

2024-10-14 Thread Damyan Pepper via cfe-commits

https://github.com/damyanp commented:

I've looked through some of this and added some comments. I called out one 
place where there's some missing `const`s on members, but I think in general 
the code is not const correct and I didn't call out all the spots that I saw.

I have to admit I'm pretty confused about what the code is trying to do - the 
ratio of new code added to new tests / changes to the tests is a bit 
surprising. This means I can't look at the tests to try and understand what the 
code change is for, but it also points at maybe there being a testing gap.

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


[clang] [HLSL] Collect explicit resource binding information (PR #111203)

2024-10-14 Thread Damyan Pepper via cfe-commits


@@ -4593,6 +4593,44 @@ def HLSLResourceBinding: InheritableAttr {
   let LangOpts = [HLSL];
   let Args = [StringArgument<"Slot">, StringArgument<"Space", 1>];
   let Documentation = [HLSLResourceBindingDocs];
+  let AdditionalMembers = [{
+  enum class RegisterType : unsigned { SRV, UAV, CBuffer, Sampler, C, I, 
Invalid };
+
+  RegisterType RegType;
+  unsigned SlotNumber;
+  unsigned SpaceNumber;
+  
+  // Size of the binding
+  // 0 == not set
+  //-1 == unbounded
+  int Size;
+
+  void setBinding(RegisterType RT, unsigned SlotNum, unsigned SpaceNum, 
int Size = 0) {

damyanp wrote:

`Size` doesn't seem to be used.  Is it still required?

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


[clang] [HLSL] Collect explicit resource binding information (PR #111203)

2024-10-14 Thread Damyan Pepper via cfe-commits


@@ -4593,6 +4593,44 @@ def HLSLResourceBinding: InheritableAttr {
   let LangOpts = [HLSL];
   let Args = [StringArgument<"Slot">, StringArgument<"Space", 1>];
   let Documentation = [HLSLResourceBindingDocs];
+  let AdditionalMembers = [{
+  enum class RegisterType : unsigned { SRV, UAV, CBuffer, Sampler, C, I, 
Invalid };
+
+  RegisterType RegType;
+  unsigned SlotNumber;
+  unsigned SpaceNumber;
+  
+  // Size of the binding
+  // 0 == not set
+  //-1 == unbounded
+  int Size;

damyanp wrote:

It's suprising to me to see these member variables and the various accessors 
have the same visibility.  I'd expect something like the variables to be 
private and the accessors to be public.

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


[clang] [HLSL] Collect explicit resource binding information (PR #111203)

2024-10-14 Thread Damyan Pepper via cfe-commits


@@ -28,13 +28,62 @@ class AttributeCommonInfo;
 class IdentifierInfo;
 class ParsedAttr;
 class Scope;
+class VarDecl;
+
+using llvm::dxil::ResourceClass;
 
 // FIXME: This can be hidden (as static function in SemaHLSL.cpp) once we no
 // longer need to create builtin buffer types in HLSLExternalSemaSource.
 bool CreateHLSLAttributedResourceType(
 Sema &S, QualType Wrapped, ArrayRef AttrList,
 QualType &ResType, HLSLAttributedResourceLocInfo *LocInfo = nullptr);
 
+enum class BindingType : uint8_t { NotAssigned, Explicit, Implicit };
+
+// DeclBindingInfo struct stores information about required/assigned resource
+// binding onon a declaration for specific resource class.
+struct DeclBindingInfo {
+  const VarDecl *Decl;
+  ResourceClass ResClass;
+  int Size; // -1 == unbounded array
+  const HLSLResourceBindingAttr *Attr;
+  BindingType BindType;
+
+  DeclBindingInfo(const VarDecl *Decl, ResourceClass ResClass, int Size = 0,

damyanp wrote:

What does `Size==0` actually mean?  A zero sized array?

I'm wondering if `0` is actually a good default.  I notice that the only place 
this is called passes a value for Size anyway, so maybe it doesn't need default 
value.

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


[clang] [llvm] [clang][aarch64] Add support for the MSVC qualifiers __ptr32, __ptr64, __sptr, __uptr for AArch64 (PR #111879)

2024-10-14 Thread Daniel Paoliello via cfe-commits


@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -triple x86_64-windows-msvc -fms-extensions -emit-llvm -O2 
< %s | FileCheck %s --check-prefixes=X64,ALL
 // RUN: %clang_cc1 -triple i386-pc-win32 -fms-extensions -emit-llvm -O2 < %s | 
FileCheck %s --check-prefixes=X86,ALL
+// RUN: %clang_cc1 -triple aarch64-windows-msvc -fms-extensions -emit-llvm -O2 
< %s | FileCheck %s --check-prefixes=AARCH64,ALL

dpaoliello wrote:

Backend hasn't been implemented yet - I'll have a follow up PR with the changes 
and tests.

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


[clang] [llvm] [clang][aarch64] Add support for the MSVC qualifiers __ptr32, __ptr64, __sptr, __uptr for AArch64 (PR #111879)

2024-10-14 Thread Daniel Paoliello via cfe-commits

dpaoliello wrote:

> Need to make sure the autoupgraded string matches the new string, but 
> otherwise should be fine. (I remember last time we made major changes for 
> x86, the 128-bit integer alignment change, it was sort of tricky, but the 
> issue mostly wasn't the layout string itself.)

There are tests for this - I also hit an issue with an unrelated test due to 
data layout upgrading not working correctly, so I added this to the 
auto-upgrade tests as well.

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


[clang] [clang] Check null TypeSourceInfo in CreateUnaryExprOrTypeTraitExpr (PR #112111)

2024-10-14 Thread Andrew Sukach via cfe-commits

https://github.com/sookach updated 
https://github.com/llvm/llvm-project/pull/112111

>From 8c0527aae4542c7065c14e8f21d6ca37010a29a6 Mon Sep 17 00:00:00 2001
From: Andrew Sukach 
Date: Sat, 12 Oct 2024 19:47:30 -0400
Subject: [PATCH] [clang] Check for null TypeSourceInfo in
 Sema::CreateUnaryExprOrTypeTraitExpr

---
 clang/docs/ReleaseNotes.rst   |  7 +
 clang/lib/Sema/SemaExpr.cpp   |  3 +++
 .../unary-expr-or-type-trait-invalid.cpp  | 26 +++
 3 files changed, 36 insertions(+)
 create mode 100644 clang/test/SemaCXX/unary-expr-or-type-trait-invalid.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 763bc3ac159322..bd0a4c70c85c9d 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -683,6 +683,13 @@ New features
 Crash and bug fixes
 ^^^
 
+- Check for a null ``TypeSourceInfo *`` when creating a 
``UnaryExprOrTypeTraitExpr``.
+  Fixes (#GH111594)
+
+  Example code that no longer crashes:
+.. code-block:: c++
+  a() {struct b c (sizeof(b * [({ {tree->d* next)} 0
+
 Improvements
 
 
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 4e37385710af5e..b0bd216c5dc101 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -4629,6 +4629,9 @@ ExprResult 
Sema::CreateUnaryExprOrTypeTraitExpr(TypeSourceInfo *TInfo,
   TInfo->getType()->isVariablyModifiedType())
 TInfo = TransformToPotentiallyEvaluated(TInfo);
 
+  if (!TInfo)
+return ExprError();
+
   // C99 6.5.3.4p4: the type (an unsigned integer type) is size_t.
   return new (Context) UnaryExprOrTypeTraitExpr(
   ExprKind, TInfo, Context.getSizeType(), OpLoc, R.getEnd());
diff --git a/clang/test/SemaCXX/unary-expr-or-type-trait-invalid.cpp 
b/clang/test/SemaCXX/unary-expr-or-type-trait-invalid.cpp
new file mode 100644
index 00..bf7b6299078681
--- /dev/null
+++ b/clang/test/SemaCXX/unary-expr-or-type-trait-invalid.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+a() {struct b c (sizeof(b * [({ {tree->d* next)} 0
+
+// expected-error@3 {{a type specifier is required for all declarations}}
+// expected-error@3 {{use of undeclared identifier 'tree'; did you mean 
'true'?}}
+// expected-error@3 {{member reference type 'bool' is not a pointer}}
+// expected-error@3 {{expected ';' after expression}}
+// expected-error@3 {{use of undeclared identifier 'next'; did you mean 
'new'?}}
+// expected-error@3 {{expected expression}}
+// expected-error@3 {{expected ';' after expression}}
+// expected-error@26 {{expected '}'}}
+// expected-note@3 {{to match this '{'}}
+// expected-error@26 {{expected ')'}}
+// expected-note@3 {{to match this '('}}
+// expected-error@26 {{expected ']'}}
+// expected-note@3 {{to match this '['}}
+// expected-error@26 {{expected ')'}}
+// expected-note@3 {{to match this '('}}
+// expected-error@3 {{using declaration 'exp' instantiates to an empty pack}}
+// expected-error@3 {{variable has incomplete type 'struct b'}}
+// expected-note@3 {{forward declaration of 'b'}}
+// expected-error@3 {{expected ';' at end of declaration}}
+// expected-error@26 {{expected '}'}}
+// expected-note@3 {{to match this '{'}}
+// expected-warning@3 {{expression result unused}}

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


[clang-tools-extra] 3484ed9 - [docs][clang-tools-extra] Fix broken document link in ReleaseNotes.rst

2024-10-14 Thread via cfe-commits

Author: Nicolas van Kempen
Date: 2024-10-14T18:43:33-04:00
New Revision: 3484ed9325f30b56717a1b939af4c58dd07848e0

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

LOG: [docs][clang-tools-extra] Fix broken document link in ReleaseNotes.rst

Fixes the following error:
```
clang-tools-extra/docs/ReleaseNotes.rst:247: WARNING: unknown document: 
'clang-tidy/checks/readability/readability-identifier-naming' [ref.doc]
```

Added: 


Modified: 
clang-tools-extra/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index b07211ff1bcaab..6196b9e15d3fc5 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -245,7 +245,7 @@ Changes in existing checks
   remove `->`, when redundant `get()` is removed.
 
 - Improved :doc:`readability-identifier-naming
-  ` check to
+  ` check to
   validate ``namespace`` aliases.
 
 Removed checks



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


[clang-tools-extra] [clang-tidy] [docs] Replace _not_ in reserved-identifier.rst with *not* (PR #112162)

2024-10-14 Thread Nicolas van Kempen via cfe-commits

nicovank wrote:

Rebase past 3484ed9325f30b56717a1b939af4c58dd07848e0 for green CI.

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


[clang] [Clang] Allow all address spaces to be converted to the default (PR #112248)

2024-10-14 Thread Joseph Huber via cfe-commits

jhuber6 wrote:

> So overall I'm leaning against doing it as is; guarding it under some flavour 
> of `allow-relaxed-address-space-handling` or something that sounds better but 
> is still noisy enough to make it clear there's danger seems preferable, at 
> least to me.

A language option is reasonable if we don't want default behavior, though it 
does add a bit of magic to what is otherwise straightfoward on all the other 
standard targets.

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


[clang] [OpenACC] Implement 'loop' 'vector' clause (PR #112259)

2024-10-14 Thread Erich Keane via cfe-commits

https://github.com/erichkeane created 
https://github.com/llvm/llvm-project/pull/112259

The 'vector' clause specifies the iterations to be executed in vector or SIMD 
mode.  There are some limitations on which associated compute contexts may be 
associated with this and have arguments, but otherwise this is a fairly 
unrestricted clause.

It DOES have region limits like 'gang' and 'worker'.

>From 48e6540b70644bf37f331ed511a56bb7ec3f3aba Mon Sep 17 00:00:00 2001
From: erichkeane 
Date: Mon, 14 Oct 2024 09:12:20 -0700
Subject: [PATCH] [OpenACC] Implement 'loop' 'vector' clause

The 'vector' clause specifies the iterations to be executed in vector or
SIMD mode.  There are some limitations on which associated compute
contexts may be associated with this and have arguments, but otherwise
this is a fairly unrestricted clause.

It DOES have region limits like 'gang' and 'worker'.
---
 clang/include/clang/AST/OpenACCClause.h   |  42 +--
 .../clang/Basic/DiagnosticSemaKinds.td|   2 +-
 clang/include/clang/Basic/OpenACCClauses.def  |   1 +
 clang/include/clang/Sema/SemaOpenACC.h|   6 +
 clang/lib/AST/OpenACCClause.cpp   |  31 +-
 clang/lib/AST/StmtProfile.cpp |   6 +
 clang/lib/AST/TextNodeDumper.cpp  |   1 +
 clang/lib/Sema/SemaOpenACC.cpp| 146 +++-
 clang/lib/Sema/TreeTransform.h|  27 ++
 clang/lib/Serialization/ASTReader.cpp |   7 +-
 clang/lib/Serialization/ASTWriter.cpp |   9 +-
 .../AST/ast-print-openacc-loop-construct.cpp  |  75 
 clang/test/ParserOpenACC/parse-clauses.c  |  11 +-
 ...p-construct-auto_seq_independent-clauses.c |  15 +-
 .../loop-construct-device_type-clause.c   |   1 -
 .../SemaOpenACC/loop-construct-vector-ast.cpp | 346 ++
 .../loop-construct-vector-clause.cpp  | 136 +++
 clang/tools/libclang/CIndex.cpp   |   6 +
 18 files changed, 806 insertions(+), 62 deletions(-)
 create mode 100644 clang/test/SemaOpenACC/loop-construct-vector-ast.cpp
 create mode 100644 clang/test/SemaOpenACC/loop-construct-vector-clause.cpp

diff --git a/clang/include/clang/AST/OpenACCClause.h 
b/clang/include/clang/AST/OpenACCClause.h
index e8b8f477f91ae7..5ad4c336b6c531 100644
--- a/clang/include/clang/AST/OpenACCClause.h
+++ b/clang/include/clang/AST/OpenACCClause.h
@@ -119,32 +119,6 @@ class OpenACCSeqClause : public OpenACCClause {
   }
 };
 
-// Not yet implemented, but the type name is necessary for 'seq' diagnostics, 
so
-// this provides a basic, do-nothing implementation. We still need to add this
-// type to the visitors/etc, as well as get it to take its proper arguments.
-class OpenACCVectorClause : public OpenACCClause {
-protected:
-  OpenACCVectorClause(SourceLocation BeginLoc, SourceLocation EndLoc)
-  : OpenACCClause(OpenACCClauseKind::Vector, BeginLoc, EndLoc) {
-llvm_unreachable("Not yet implemented");
-  }
-
-public:
-  static bool classof(const OpenACCClause *C) {
-return C->getClauseKind() == OpenACCClauseKind::Vector;
-  }
-
-  static OpenACCVectorClause *
-  Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation 
EndLoc);
-
-  child_range children() {
-return child_range(child_iterator(), child_iterator());
-  }
-  const_child_range children() const {
-return const_child_range(const_child_iterator(), const_child_iterator());
-  }
-};
-
 /// Represents a clause that has a list of parameters.
 class OpenACCClauseWithParams : public OpenACCClause {
   /// Location of the '('.
@@ -531,6 +505,22 @@ class OpenACCWorkerClause : public 
OpenACCClauseWithSingleIntExpr {
  SourceLocation EndLoc);
 };
 
+class OpenACCVectorClause : public OpenACCClauseWithSingleIntExpr {
+protected:
+  OpenACCVectorClause(SourceLocation BeginLoc, SourceLocation LParenLoc,
+  Expr *IntExpr, SourceLocation EndLoc);
+
+public:
+  static bool classof(const OpenACCClause *C) {
+return C->getClauseKind() == OpenACCClauseKind::Vector;
+  }
+
+  static OpenACCVectorClause *Create(const ASTContext &Ctx,
+ SourceLocation BeginLoc,
+ SourceLocation LParenLoc, Expr *IntExpr,
+ SourceLocation EndLoc);
+};
+
 class OpenACCNumWorkersClause : public OpenACCClauseWithSingleIntExpr {
   OpenACCNumWorkersClause(SourceLocation BeginLoc, SourceLocation LParenLoc,
   Expr *IntExpr, SourceLocation EndLoc);
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index c709795e7b21d8..e78acc8dc8c57b 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -12702,7 +12702,7 @@ def err_acc_gang_dim_value
 def err_acc_num_arg_conflict
 : Error<"'num' argument to '%0' clause not allowed on a 'loop' construct "
 "associated with a 

[clang] [OpenACC] Implement 'loop' 'vector' clause (PR #112259)

2024-10-14 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Erich Keane (erichkeane)


Changes

The 'vector' clause specifies the iterations to be executed in vector or SIMD 
mode.  There are some limitations on which associated compute contexts may be 
associated with this and have arguments, but otherwise this is a fairly 
unrestricted clause.

It DOES have region limits like 'gang' and 'worker'.

---

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


18 Files Affected:

- (modified) clang/include/clang/AST/OpenACCClause.h (+16-26) 
- (modified) clang/include/clang/Basic/DiagnosticSemaKinds.td (+1-1) 
- (modified) clang/include/clang/Basic/OpenACCClauses.def (+1) 
- (modified) clang/include/clang/Sema/SemaOpenACC.h (+6) 
- (modified) clang/lib/AST/OpenACCClause.cpp (+27-4) 
- (modified) clang/lib/AST/StmtProfile.cpp (+6) 
- (modified) clang/lib/AST/TextNodeDumper.cpp (+1) 
- (modified) clang/lib/Sema/SemaOpenACC.cpp (+138-8) 
- (modified) clang/lib/Sema/TreeTransform.h (+27) 
- (modified) clang/lib/Serialization/ASTReader.cpp (+6-1) 
- (modified) clang/lib/Serialization/ASTWriter.cpp (+8-1) 
- (modified) clang/test/AST/ast-print-openacc-loop-construct.cpp (+75) 
- (modified) clang/test/ParserOpenACC/parse-clauses.c (+2-9) 
- (modified) 
clang/test/SemaOpenACC/loop-construct-auto_seq_independent-clauses.c (+4-11) 
- (modified) clang/test/SemaOpenACC/loop-construct-device_type-clause.c (-1) 
- (added) clang/test/SemaOpenACC/loop-construct-vector-ast.cpp (+346) 
- (added) clang/test/SemaOpenACC/loop-construct-vector-clause.cpp (+136) 
- (modified) clang/tools/libclang/CIndex.cpp (+6) 


``diff
diff --git a/clang/include/clang/AST/OpenACCClause.h 
b/clang/include/clang/AST/OpenACCClause.h
index e8b8f477f91ae7..5ad4c336b6c531 100644
--- a/clang/include/clang/AST/OpenACCClause.h
+++ b/clang/include/clang/AST/OpenACCClause.h
@@ -119,32 +119,6 @@ class OpenACCSeqClause : public OpenACCClause {
   }
 };
 
-// Not yet implemented, but the type name is necessary for 'seq' diagnostics, 
so
-// this provides a basic, do-nothing implementation. We still need to add this
-// type to the visitors/etc, as well as get it to take its proper arguments.
-class OpenACCVectorClause : public OpenACCClause {
-protected:
-  OpenACCVectorClause(SourceLocation BeginLoc, SourceLocation EndLoc)
-  : OpenACCClause(OpenACCClauseKind::Vector, BeginLoc, EndLoc) {
-llvm_unreachable("Not yet implemented");
-  }
-
-public:
-  static bool classof(const OpenACCClause *C) {
-return C->getClauseKind() == OpenACCClauseKind::Vector;
-  }
-
-  static OpenACCVectorClause *
-  Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation 
EndLoc);
-
-  child_range children() {
-return child_range(child_iterator(), child_iterator());
-  }
-  const_child_range children() const {
-return const_child_range(const_child_iterator(), const_child_iterator());
-  }
-};
-
 /// Represents a clause that has a list of parameters.
 class OpenACCClauseWithParams : public OpenACCClause {
   /// Location of the '('.
@@ -531,6 +505,22 @@ class OpenACCWorkerClause : public 
OpenACCClauseWithSingleIntExpr {
  SourceLocation EndLoc);
 };
 
+class OpenACCVectorClause : public OpenACCClauseWithSingleIntExpr {
+protected:
+  OpenACCVectorClause(SourceLocation BeginLoc, SourceLocation LParenLoc,
+  Expr *IntExpr, SourceLocation EndLoc);
+
+public:
+  static bool classof(const OpenACCClause *C) {
+return C->getClauseKind() == OpenACCClauseKind::Vector;
+  }
+
+  static OpenACCVectorClause *Create(const ASTContext &Ctx,
+ SourceLocation BeginLoc,
+ SourceLocation LParenLoc, Expr *IntExpr,
+ SourceLocation EndLoc);
+};
+
 class OpenACCNumWorkersClause : public OpenACCClauseWithSingleIntExpr {
   OpenACCNumWorkersClause(SourceLocation BeginLoc, SourceLocation LParenLoc,
   Expr *IntExpr, SourceLocation EndLoc);
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index c709795e7b21d8..e78acc8dc8c57b 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -12702,7 +12702,7 @@ def err_acc_gang_dim_value
 def err_acc_num_arg_conflict
 : Error<"'num' argument to '%0' clause not allowed on a 'loop' construct "
 "associated with a 'kernels' construct that has a "
-"'%select{num_gangs|num_workers}1' "
+"'%select{num_gangs|num_workers|vector_length}1' "
 "clause">;
 def err_acc_clause_in_clause_region
 : Error<"loop with a '%0' clause may not exist in the region of a '%1' "
diff --git a/clang/include/clang/Basic/OpenACCClauses.def 
b/clang/include/clang/Basic/OpenACCClauses.def
index 4c0b56dc13e625..c65ebed751cf14 10064

[clang] [OpenACC] Implement 'loop' 'vector' clause (PR #112259)

2024-10-14 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-modules

Author: Erich Keane (erichkeane)


Changes

The 'vector' clause specifies the iterations to be executed in vector or SIMD 
mode.  There are some limitations on which associated compute contexts may be 
associated with this and have arguments, but otherwise this is a fairly 
unrestricted clause.

It DOES have region limits like 'gang' and 'worker'.

---

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


18 Files Affected:

- (modified) clang/include/clang/AST/OpenACCClause.h (+16-26) 
- (modified) clang/include/clang/Basic/DiagnosticSemaKinds.td (+1-1) 
- (modified) clang/include/clang/Basic/OpenACCClauses.def (+1) 
- (modified) clang/include/clang/Sema/SemaOpenACC.h (+6) 
- (modified) clang/lib/AST/OpenACCClause.cpp (+27-4) 
- (modified) clang/lib/AST/StmtProfile.cpp (+6) 
- (modified) clang/lib/AST/TextNodeDumper.cpp (+1) 
- (modified) clang/lib/Sema/SemaOpenACC.cpp (+138-8) 
- (modified) clang/lib/Sema/TreeTransform.h (+27) 
- (modified) clang/lib/Serialization/ASTReader.cpp (+6-1) 
- (modified) clang/lib/Serialization/ASTWriter.cpp (+8-1) 
- (modified) clang/test/AST/ast-print-openacc-loop-construct.cpp (+75) 
- (modified) clang/test/ParserOpenACC/parse-clauses.c (+2-9) 
- (modified) 
clang/test/SemaOpenACC/loop-construct-auto_seq_independent-clauses.c (+4-11) 
- (modified) clang/test/SemaOpenACC/loop-construct-device_type-clause.c (-1) 
- (added) clang/test/SemaOpenACC/loop-construct-vector-ast.cpp (+346) 
- (added) clang/test/SemaOpenACC/loop-construct-vector-clause.cpp (+136) 
- (modified) clang/tools/libclang/CIndex.cpp (+6) 


``diff
diff --git a/clang/include/clang/AST/OpenACCClause.h 
b/clang/include/clang/AST/OpenACCClause.h
index e8b8f477f91ae7..5ad4c336b6c531 100644
--- a/clang/include/clang/AST/OpenACCClause.h
+++ b/clang/include/clang/AST/OpenACCClause.h
@@ -119,32 +119,6 @@ class OpenACCSeqClause : public OpenACCClause {
   }
 };
 
-// Not yet implemented, but the type name is necessary for 'seq' diagnostics, 
so
-// this provides a basic, do-nothing implementation. We still need to add this
-// type to the visitors/etc, as well as get it to take its proper arguments.
-class OpenACCVectorClause : public OpenACCClause {
-protected:
-  OpenACCVectorClause(SourceLocation BeginLoc, SourceLocation EndLoc)
-  : OpenACCClause(OpenACCClauseKind::Vector, BeginLoc, EndLoc) {
-llvm_unreachable("Not yet implemented");
-  }
-
-public:
-  static bool classof(const OpenACCClause *C) {
-return C->getClauseKind() == OpenACCClauseKind::Vector;
-  }
-
-  static OpenACCVectorClause *
-  Create(const ASTContext &Ctx, SourceLocation BeginLoc, SourceLocation 
EndLoc);
-
-  child_range children() {
-return child_range(child_iterator(), child_iterator());
-  }
-  const_child_range children() const {
-return const_child_range(const_child_iterator(), const_child_iterator());
-  }
-};
-
 /// Represents a clause that has a list of parameters.
 class OpenACCClauseWithParams : public OpenACCClause {
   /// Location of the '('.
@@ -531,6 +505,22 @@ class OpenACCWorkerClause : public 
OpenACCClauseWithSingleIntExpr {
  SourceLocation EndLoc);
 };
 
+class OpenACCVectorClause : public OpenACCClauseWithSingleIntExpr {
+protected:
+  OpenACCVectorClause(SourceLocation BeginLoc, SourceLocation LParenLoc,
+  Expr *IntExpr, SourceLocation EndLoc);
+
+public:
+  static bool classof(const OpenACCClause *C) {
+return C->getClauseKind() == OpenACCClauseKind::Vector;
+  }
+
+  static OpenACCVectorClause *Create(const ASTContext &Ctx,
+ SourceLocation BeginLoc,
+ SourceLocation LParenLoc, Expr *IntExpr,
+ SourceLocation EndLoc);
+};
+
 class OpenACCNumWorkersClause : public OpenACCClauseWithSingleIntExpr {
   OpenACCNumWorkersClause(SourceLocation BeginLoc, SourceLocation LParenLoc,
   Expr *IntExpr, SourceLocation EndLoc);
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index c709795e7b21d8..e78acc8dc8c57b 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -12702,7 +12702,7 @@ def err_acc_gang_dim_value
 def err_acc_num_arg_conflict
 : Error<"'num' argument to '%0' clause not allowed on a 'loop' construct "
 "associated with a 'kernels' construct that has a "
-"'%select{num_gangs|num_workers}1' "
+"'%select{num_gangs|num_workers|vector_length}1' "
 "clause">;
 def err_acc_clause_in_clause_region
 : Error<"loop with a '%0' clause may not exist in the region of a '%1' "
diff --git a/clang/include/clang/Basic/OpenACCClauses.def 
b/clang/include/clang/Basic/OpenACCClauses.def
index 4c0b56dc13e625..c65ebed751cf

[clang] [Clang] Allow all address spaces to be converted to the default (PR #112248)

2024-10-14 Thread Shilei Tian via cfe-commits

shiltian wrote:

I think the default AS is expected to be losslessly converted to other AS but 
not the other way around, though I understand it is not clearly stated in 
LangRef or other places and a lot of code just assumes it can.

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


[clang] Reapply "[Clang][Sema] Refactor collection of multi-level template argument lists (#106585, #111173)" (PR #111852)

2024-10-14 Thread Shafik Yaghmour via cfe-commits

shafik wrote:

It looks like this is linked to this crash: 
https://github.com/llvm/llvm-project/issues/11

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


[clang] [compiler-rt] [lld] [llvm] [Coverage][WebAssembly] Add initial support for WebAssembly/WASI (PR #111332)

2024-10-14 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `clang-ppc64le-rhel` 
running on `ppc64le-clang-rhel-test` while building 
`clang,compiler-rt,lld,llvm` at step 5 "build-unified-tree".

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


Here is the relevant piece of the build log for the reference

```
Step 5 (build-unified-tree) failure: build (failure)
...
170.755 [21/9/6251] Building CXX object 
tools/lld/wasm/CMakeFiles/lldWasm.dir/InputChunks.cpp.o
171.007 [21/8/6252] Building CXX object 
tools/lld/wasm/CMakeFiles/lldWasm.dir/Symbols.cpp.o
171.090 [21/7/6253] Building CXX object 
tools/lld/wasm/CMakeFiles/lldWasm.dir/OutputSections.cpp.o
171.258 [21/6/6254] Building CXX object 
tools/lld/wasm/CMakeFiles/lldWasm.dir/MapFile.cpp.o
172.094 [21/5/6255] Building CXX object 
tools/lld/wasm/CMakeFiles/lldWasm.dir/SymbolTable.cpp.o
174.237 [21/4/6256] Building CXX object 
tools/lld/wasm/CMakeFiles/lldWasm.dir/Driver.cpp.o
174.257 [21/3/6257] Building CXX object 
tools/lld/wasm/CMakeFiles/lldWasm.dir/SyntheticSections.cpp.o
174.264 [21/2/6258] Building CXX object 
tools/lld/wasm/CMakeFiles/lldWasm.dir/InputFiles.cpp.o
177.666 [21/1/6259] Building CXX object 
tools/lld/wasm/CMakeFiles/lldWasm.dir/Writer.cpp.o
177.743 [20/1/6260] Linking CXX shared library lib/liblldWasm.so.20.0git
FAILED: lib/liblldWasm.so.20.0git 
: && /home/docker/llvm-external-buildbots/clang.17.0.6/bin/clang++ 
--gcc-toolchain=/gcc-toolchain/usr -fPIC -fPIC -fno-semantic-interposition 
-fvisibility-inlines-hidden -Werror -Werror=date-time 
-Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter 
-Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic 
-Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion 
-Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color 
-ffunction-sections -fdata-sections -O3 -DNDEBUG  -Wl,-z,defs -Wl,-z,nodelete 
-Wl,--color-diagnostics   -Wl,--gc-sections -shared 
-Wl,-soname,liblldWasm.so.20.0git -o lib/liblldWasm.so.20.0git 
tools/lld/wasm/CMakeFiles/lldWasm.dir/Driver.cpp.o 
tools/lld/wasm/CMakeFiles/lldWasm.dir/InputChunks.cpp.o 
tools/lld/wasm/CMakeFiles/lldWasm.dir/InputFiles.cpp.o 
tools/lld/wasm/CMakeFiles/lldWasm.dir/LTO.cpp.o 
tools/lld/wasm/CMakeFiles/lldWasm.dir/MapFile.cpp.o 
tools/lld/wasm/CMakeFiles/lldWasm.dir/MarkLive.cpp.o 
tools/lld/wasm/CMakeFiles/lldWasm.dir/OutputSections.cpp.o 
tools/lld/wasm/CMakeFiles/lldWasm.dir/OutputSegment.cpp.o 
tools/lld/wasm/CMakeFiles/lldWasm.dir/Relocations.cpp.o 
tools/lld/wasm/CMakeFiles/lldWasm.dir/SymbolTable.cpp.o 
tools/lld/wasm/CMakeFiles/lldWasm.dir/Symbols.cpp.o 
tools/lld/wasm/CMakeFiles/lldWasm.dir/SyntheticSections.cpp.o 
tools/lld/wasm/CMakeFiles/lldWasm.dir/Writer.cpp.o 
tools/lld/wasm/CMakeFiles/lldWasm.dir/WriterUtils.cpp.o  
-Wl,-rpath,"\$ORIGIN/../lib:/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/lib:"
  lib/liblldCommon.so.20.0git  lib/libLLVMAArch64CodeGen.so.20.0git  
lib/libLLVMAArch64AsmParser.so.20.0git  
lib/libLLVMAArch64Disassembler.so.20.0git  lib/libLLVMAMDGPUCodeGen.so.20.0git  
lib/libLLVMAMDGPUAsmParser.so.20.0git  lib/libLLVMAMDGPUDisassembler.so.20.0git 
 lib/libLLVMARMCodeGen.so.20.0git  lib/libLLVMARMAsmParser.so.20.0git  
lib/libLLVMARMDisassembler.so.20.0git  lib/libLLVMAVRCodeGen.so.20.0git  
lib/libLLVMAVRAsmParser.so.20.0git  lib/libLLVMAVRDesc.so.20.0git  
lib/libLLVMAVRDisassembler.so.20.0git  lib/libLLVMAVRInfo.so.20.0git  
lib/libLLVMBPFCodeGen.so.20.0git  lib/libLLVMBPFAsmParser.so.20.0git  
lib/libLLVMBPFDesc.so.20.0git  lib/libLLVMBPFDisassembler.so.20.0git  
lib/libLLVMBPFInfo.so.20.0git  lib/libLLVMHexagonCodeGen.so.20.0git  
lib/libLLVMHexagonAsmParser.so.20.0git  
lib/libLLVMHexagonDisassembler.so.20.0git  lib/libLLVMLanaiCodeGen.so.20.0git  
lib/libLLVMLanaiAsmParser.so.20.0git  lib/libLLVMLanaiDisassembler.so.20.0git  
lib/libLLVMLoongArchCodeGen.so.20.0git  
lib/libLLVMLoongArchAsmParser.so.20.0git  
lib/libLLVMLoongArchDisassembler.so.20.0git  lib/libLLVMMipsCodeGen.so.20.0git  
lib/libLLVMMipsAsmParser.so.20.0git  lib/libLLVMMipsDesc.so.20.0git  
lib/libLLVMMipsDisassembler.so.20.0git  lib/libLLVMMipsInfo.so.20.0git  
lib/libLLVMMSP430CodeGen.so.20.0git  lib/libLLVMMSP430AsmParser.so.20.0git  
lib/libLLVMMSP430Desc.so.20.0git  lib/libLLVMMSP430Disassembler.so.20.0git  
lib/libLLVMMSP430Info.so.20.0git  lib/libLLVMNVPTXCodeGen.so.20.0git  
lib/libLLVMNVPTXDesc.so.20.0git  lib/libLLVMNVPTXInfo.so.20.0git  
lib/libLLVMPowerPCCodeGen.so.20.0git  lib/libLLVMPowerPCAsmParser.so.20.0git  
lib/libLLVMPowerPCDesc.so.20.0git  lib/libLLVMPowerPCDisassembler.so.20.0git  
lib/libLLVMPowerPCInfo.so.20.0git  lib/libLLVMRISCVCodeGen.so.20.0git  
lib/libLLVMRISCVAsmParser.so.20.0git  lib/libLLVMRISCVDisassembler.so.20.0git  
lib/libLLVMSpa

[clang] [llvm] [Inliner] Propagate more attributes to params when inlining (PR #91101)

2024-10-14 Thread via cfe-commits


@@ -1391,22 +1411,60 @@ static void AddParamAndFnBasicAttributes(const CallBase 
&CB,
 
   AttributeList AL = NewInnerCB->getAttributes();
   for (unsigned I = 0, E = InnerCB->arg_size(); I < E; ++I) {
-// Check if the underlying value for the parameter is an argument.
-const Value *UnderlyingV =
-getUnderlyingObject(InnerCB->getArgOperand(I));
-const Argument *Arg = dyn_cast(UnderlyingV);
-if (!Arg)
+// It's unsound or requires special handling to propagate
+// attributes to byval arguments. Even if CalledFunction
+// doesn't e.g. write to the argument (readonly), the call to
+// NewInnerCB may write to its by-value copy.
+if (AL.hasParamAttr(I, Attribute::ByVal))
   continue;
 
-if (AL.hasParamAttr(I, Attribute::ByVal))
-  // It's unsound to propagate memory attributes to byval arguments.
-  // Even if CalledFunction doesn't e.g. write to the argument,
-  // the call to NewInnerCB may write to its by-value copy.
+// Don't bother propagating attrs to constants.
+if (match(NewInnerCB->getArgOperand(I),
+  llvm::PatternMatch::m_ImmConstant()))
   continue;
 
-unsigned ArgNo = Arg->getArgNo();
+// Check if the underlying value for the parameter is an argument.
+const Argument *Arg = dyn_cast(InnerCB->getArgOperand(I));
+unsigned ArgNo;
+if (Arg) {
+  ArgNo = Arg->getArgNo();
+  // For dereferenceable, dereferenceable_or_null, align, etc...
+  // we don't want to propagate if the existing param has the same
+  // attribute with "better" constraints. So  remove from the
+  // new AL if the region of the existing param is larger than
+  // what we can propagate.
+  AttrBuilder NewAB{
+  Context, AttributeSet::get(Context, 
ValidExactParamAttrs[ArgNo])};
+  if (AL.getParamDereferenceableBytes(I) >
+  NewAB.getDereferenceableBytes())
+NewAB.removeAttribute(Attribute::Dereferenceable);
+  if (AL.getParamDereferenceableOrNullBytes(I) >
+  NewAB.getDereferenceableOrNullBytes())
+NewAB.removeAttribute(Attribute::DereferenceableOrNull);
+  if (AL.getParamAlignment(I).valueOrOne() >
+  NewAB.getAlignment().valueOrOne())
+NewAB.removeAttribute(Attribute::Alignment);
+  if (auto ExistingRange = AL.getParamRange(I)) {
+if (auto NewRange = NewAB.getRange()) {
+  ConstantRange CombinedRange =
+  ExistingRange->intersectWith(*NewRange);
+  NewAB.removeAttribute(Attribute::Range);
+  NewAB.addRangeAttr(CombinedRange);
+}
+  }

goldsteinn wrote:

Other than the bug with `ByVal`, I would say that in InstCombine or something 
we should remove redundant attrs from callbases rather than require yet more 
special case handling for callbase attrs.

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


[clang] [compiler-rt] [lld] [llvm] Revert "[Coverage][WebAssembly] Add initial support for WebAssembly/WASI" (PR #112274)

2024-10-14 Thread via cfe-commits

https://github.com/dpalermo created 
https://github.com/llvm/llvm-project/pull/112274

Reverts llvm/llvm-project#111332

Unable to build clang/flang with OpenMP this patch.  Results in:
https://lab.llvm.org/staging/#/builders/105/builds/6816

38.873 [112/2/7464] Linking CXX shared library lib/liblldWasm.so.20.0git
FAILED: lib/liblldWasm.so.20.0git 
...
/usr/bin/ld: tools/lld/wasm/CMakeFiles/lldWasm.dir/InputFiles.cpp.o: in 
function `lld::wasm::ObjFile::parse(bool)':
InputFiles.cpp:(.text._ZN3lld4wasm7ObjFile5parseEb+0x1250): undefined reference 
to `llvm::getInstrProfSectionName[abi:cxx11](llvm::InstrProfSectKind, 
llvm::Triple::ObjectFormatType, bool)'
/usr/bin/ld: InputFiles.cpp:(.text._ZN3lld4wasm7ObjFile5parseEb+0x14fb): 
undefined reference to 
`llvm::getInstrProfSectionName[abi:cxx11](llvm::InstrProfSectKind, 
llvm::Triple::ObjectFormatType, bool)'
collect2: error: ld returned 1 exit status



>From f173e127c135f88ea37aef26010583078063c202 Mon Sep 17 00:00:00 2001
From: dpalermo 
Date: Mon, 14 Oct 2024 16:41:25 -0500
Subject: [PATCH] =?UTF-8?q?Revert=20"[Coverage][WebAssembly]=20Add=20initi?=
 =?UTF-8?q?al=20support=20for=20WebAssembly/WASI=20(#11=E2=80=A6"?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This reverts commit d4efc3e097f40afbe8ae275150f49bb08fc04572.
---
 clang/lib/Driver/ToolChains/WebAssembly.cpp   |   2 -
 .../cmake/Modules/AllSupportedArchDefs.cmake  |   2 +-
 compiler-rt/cmake/config-ix.cmake |   2 +-
 compiler-rt/lib/profile/CMakeLists.txt|  24 -
 compiler-rt/lib/profile/GCDAProfiling.c   |   2 +-
 .../lib/profile/InstrProfilingPlatformLinux.c |   8 +-
 .../lib/profile/InstrProfilingPlatformOther.c |   3 +-
 compiler-rt/lib/profile/InstrProfilingPort.h  |   2 +-
 compiler-rt/lib/profile/InstrProfilingUtil.c  |  12 +--
 lld/test/wasm/custom-section-align.s  |  31 ---
 lld/wasm/InputChunks.h|  10 +-
 lld/wasm/InputFiles.cpp   |  18 +---
 lld/wasm/OutputSections.cpp   |   1 -
 .../Coverage/CoverageMappingReader.h  |  13 +--
 .../CodeGen/TargetLoweringObjectFileImpl.cpp  |   6 +-
 llvm/lib/MC/MCContext.cpp |   5 -
 .../Coverage/CoverageMappingReader.cpp|  87 +++---
 .../Instrumentation/InstrProfiling.cpp|   5 +-
 llvm/test/CodeGen/WebAssembly/profile.ll  |  47 --
 .../InstrProfiling/profiling.ll   |   7 +-
 .../llvm-cov/Inputs/binary-formats.v6.wasm32  | Bin 87781 -> 0 bytes
 .../Inputs/binary-formats.wasm.proftext   |   4 -
 llvm/test/tools/llvm-cov/binary-formats.c |   7 --
 23 files changed, 45 insertions(+), 253 deletions(-)
 delete mode 100644 lld/test/wasm/custom-section-align.s
 delete mode 100644 llvm/test/CodeGen/WebAssembly/profile.ll
 delete mode 100755 llvm/test/tools/llvm-cov/Inputs/binary-formats.v6.wasm32
 delete mode 100644 llvm/test/tools/llvm-cov/Inputs/binary-formats.wasm.proftext

diff --git a/clang/lib/Driver/ToolChains/WebAssembly.cpp 
b/clang/lib/Driver/ToolChains/WebAssembly.cpp
index 44a6894d30fb29..9aec11e69fde1d 100644
--- a/clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ b/clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -163,8 +163,6 @@ void wasm::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 AddRunTimeLibs(ToolChain, ToolChain.getDriver(), CmdArgs, Args);
   }
 
-  ToolChain.addProfileRTLibs(Args, CmdArgs);
-
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
 
diff --git a/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake 
b/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
index d00d39518104bf..809e9277156912 100644
--- a/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
+++ b/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
@@ -77,7 +77,7 @@ set(ALL_HWASAN_SUPPORTED_ARCH ${X86_64} ${ARM64} ${RISCV64})
 set(ALL_MEMPROF_SUPPORTED_ARCH ${X86_64})
 set(ALL_PROFILE_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} ${PPC32} 
${PPC64}
 ${MIPS32} ${MIPS64} ${S390X} ${SPARC} ${SPARCV9} ${HEXAGON}
-${RISCV32} ${RISCV64} ${LOONGARCH64} ${WASM32})
+${RISCV32} ${RISCV64} ${LOONGARCH64})
 set(ALL_CTX_PROFILE_SUPPORTED_ARCH ${X86_64})
 if (OS_NAME MATCHES "FreeBSD")
   set(ALL_TSAN_SUPPORTED_ARCH ${X86_64} ${MIPS64} ${ARM64})
diff --git a/compiler-rt/cmake/config-ix.cmake 
b/compiler-rt/cmake/config-ix.cmake
index a494e0532a50bc..a93a88a9205001 100644
--- a/compiler-rt/cmake/config-ix.cmake
+++ b/compiler-rt/cmake/config-ix.cmake
@@ -822,7 +822,7 @@ else()
 endif()
 
 if (PROFILE_SUPPORTED_ARCH AND NOT LLVM_USE_SANITIZER AND
-OS_NAME MATCHES 
"Darwin|Linux|FreeBSD|Windows|Android|Fuchsia|SunOS|NetBSD|AIX|WASI")
+OS_NAME MATCHES 
"Darwin|Linux|FreeBSD|Windows|Android|Fuchsia|SunOS|NetBSD|AIX")
   set(COMPILER_RT_HAS_PROFILE TRUE)
 else()
   set(COMPILER_RT_HAS_PROFILE FALSE)
diff --git a/compiler-rt/lib/profile/CMakeLists.txt 
b/compiler-rt/lib/profile/CMakeLists.txt

[clang] [compiler-rt] [lld] [llvm] Revert "[Coverage][WebAssembly] Add initial support for WebAssembly/WASI" (PR #112274)

2024-10-14 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-lld-wasm

@llvm/pr-subscribers-clang-driver

Author: None (dpalermo)


Changes

Reverts llvm/llvm-project#111332

Unable to build clang/flang with OpenMP this patch.  Results in:
https://lab.llvm.org/staging/#/builders/105/builds/6816

38.873 [112/2/7464] Linking CXX shared library lib/liblldWasm.so.20.0git
FAILED: lib/liblldWasm.so.20.0git 
...
/usr/bin/ld: tools/lld/wasm/CMakeFiles/lldWasm.dir/InputFiles.cpp.o: in 
function `lld::wasm::ObjFile::parse(bool)':
InputFiles.cpp:(.text._ZN3lld4wasm7ObjFile5parseEb+0x1250): undefined reference 
to `llvm::getInstrProfSectionName[abi:cxx11](llvm::InstrProfSectKind, 
llvm::Triple::ObjectFormatType, bool)'
/usr/bin/ld: InputFiles.cpp:(.text._ZN3lld4wasm7ObjFile5parseEb+0x14fb): 
undefined reference to 
`llvm::getInstrProfSectionName[abi:cxx11](llvm::InstrProfSectKind, 
llvm::Triple::ObjectFormatType, bool)'
collect2: error: ld returned 1 exit status



---

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


23 Files Affected:

- (modified) clang/lib/Driver/ToolChains/WebAssembly.cpp (-2) 
- (modified) compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake (+1-1) 
- (modified) compiler-rt/cmake/config-ix.cmake (+1-1) 
- (modified) compiler-rt/lib/profile/CMakeLists.txt (-24) 
- (modified) compiler-rt/lib/profile/GCDAProfiling.c (+1-1) 
- (modified) compiler-rt/lib/profile/InstrProfilingPlatformLinux.c (+4-4) 
- (modified) compiler-rt/lib/profile/InstrProfilingPlatformOther.c (+1-2) 
- (modified) compiler-rt/lib/profile/InstrProfilingPort.h (+1-1) 
- (modified) compiler-rt/lib/profile/InstrProfilingUtil.c (+4-8) 
- (removed) lld/test/wasm/custom-section-align.s (-31) 
- (modified) lld/wasm/InputChunks.h (+4-6) 
- (modified) lld/wasm/InputFiles.cpp (+2-16) 
- (modified) lld/wasm/OutputSections.cpp (-1) 
- (modified) llvm/include/llvm/ProfileData/Coverage/CoverageMappingReader.h 
(+2-11) 
- (modified) llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp (+1-5) 
- (modified) llvm/lib/MC/MCContext.cpp (-5) 
- (modified) llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp (+15-72) 
- (modified) llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp (+2-3) 
- (removed) llvm/test/CodeGen/WebAssembly/profile.ll (-47) 
- (modified) llvm/test/Instrumentation/InstrProfiling/profiling.ll (+6-1) 
- (removed) llvm/test/tools/llvm-cov/Inputs/binary-formats.v6.wasm32 () 
- (removed) llvm/test/tools/llvm-cov/Inputs/binary-formats.wasm.proftext (-4) 
- (modified) llvm/test/tools/llvm-cov/binary-formats.c (-7) 


``diff
diff --git a/clang/lib/Driver/ToolChains/WebAssembly.cpp 
b/clang/lib/Driver/ToolChains/WebAssembly.cpp
index 44a6894d30fb29..9aec11e69fde1d 100644
--- a/clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ b/clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -163,8 +163,6 @@ void wasm::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 AddRunTimeLibs(ToolChain, ToolChain.getDriver(), CmdArgs, Args);
   }
 
-  ToolChain.addProfileRTLibs(Args, CmdArgs);
-
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
 
diff --git a/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake 
b/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
index d00d39518104bf..809e9277156912 100644
--- a/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
+++ b/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
@@ -77,7 +77,7 @@ set(ALL_HWASAN_SUPPORTED_ARCH ${X86_64} ${ARM64} ${RISCV64})
 set(ALL_MEMPROF_SUPPORTED_ARCH ${X86_64})
 set(ALL_PROFILE_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} ${PPC32} 
${PPC64}
 ${MIPS32} ${MIPS64} ${S390X} ${SPARC} ${SPARCV9} ${HEXAGON}
-${RISCV32} ${RISCV64} ${LOONGARCH64} ${WASM32})
+${RISCV32} ${RISCV64} ${LOONGARCH64})
 set(ALL_CTX_PROFILE_SUPPORTED_ARCH ${X86_64})
 if (OS_NAME MATCHES "FreeBSD")
   set(ALL_TSAN_SUPPORTED_ARCH ${X86_64} ${MIPS64} ${ARM64})
diff --git a/compiler-rt/cmake/config-ix.cmake 
b/compiler-rt/cmake/config-ix.cmake
index a494e0532a50bc..a93a88a9205001 100644
--- a/compiler-rt/cmake/config-ix.cmake
+++ b/compiler-rt/cmake/config-ix.cmake
@@ -822,7 +822,7 @@ else()
 endif()
 
 if (PROFILE_SUPPORTED_ARCH AND NOT LLVM_USE_SANITIZER AND
-OS_NAME MATCHES 
"Darwin|Linux|FreeBSD|Windows|Android|Fuchsia|SunOS|NetBSD|AIX|WASI")
+OS_NAME MATCHES 
"Darwin|Linux|FreeBSD|Windows|Android|Fuchsia|SunOS|NetBSD|AIX")
   set(COMPILER_RT_HAS_PROFILE TRUE)
 else()
   set(COMPILER_RT_HAS_PROFILE FALSE)
diff --git a/compiler-rt/lib/profile/CMakeLists.txt 
b/compiler-rt/lib/profile/CMakeLists.txt
index ac1451c8ceed18..26178412967201 100644
--- a/compiler-rt/lib/profile/CMakeLists.txt
+++ b/compiler-rt/lib/profile/CMakeLists.txt
@@ -38,17 +38,6 @@ int main() {
 
 " COMPILER_RT_TARGET_HAS_FCNTL_LCK)
 
-CHECK_CXX_SOURCE_COMPILES("
-#include 
-
-int fd;
-int main() {
-  flock(fd, LOCK_EX);
-  return 0;
-}
-
-" COMPILER_RT_TARGET_HAS_FLOCK)
-
 CHECK_CXX_SOURCE_COMPILES("
 #include 
 int main() {
@@ -

[clang] [compiler-rt] [lld] [llvm] Revert "[Coverage][WebAssembly] Add initial support for WebAssembly/WASI" (PR #112274)

2024-10-14 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-webassembly

Author: None (dpalermo)


Changes

Reverts llvm/llvm-project#111332

Unable to build clang/flang with OpenMP this patch.  Results in:
https://lab.llvm.org/staging/#/builders/105/builds/6816

38.873 [112/2/7464] Linking CXX shared library lib/liblldWasm.so.20.0git
FAILED: lib/liblldWasm.so.20.0git 
...
/usr/bin/ld: tools/lld/wasm/CMakeFiles/lldWasm.dir/InputFiles.cpp.o: in 
function `lld::wasm::ObjFile::parse(bool)':
InputFiles.cpp:(.text._ZN3lld4wasm7ObjFile5parseEb+0x1250): undefined reference 
to `llvm::getInstrProfSectionName[abi:cxx11](llvm::InstrProfSectKind, 
llvm::Triple::ObjectFormatType, bool)'
/usr/bin/ld: InputFiles.cpp:(.text._ZN3lld4wasm7ObjFile5parseEb+0x14fb): 
undefined reference to 
`llvm::getInstrProfSectionName[abi:cxx11](llvm::InstrProfSectKind, 
llvm::Triple::ObjectFormatType, bool)'
collect2: error: ld returned 1 exit status



---

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


23 Files Affected:

- (modified) clang/lib/Driver/ToolChains/WebAssembly.cpp (-2) 
- (modified) compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake (+1-1) 
- (modified) compiler-rt/cmake/config-ix.cmake (+1-1) 
- (modified) compiler-rt/lib/profile/CMakeLists.txt (-24) 
- (modified) compiler-rt/lib/profile/GCDAProfiling.c (+1-1) 
- (modified) compiler-rt/lib/profile/InstrProfilingPlatformLinux.c (+4-4) 
- (modified) compiler-rt/lib/profile/InstrProfilingPlatformOther.c (+1-2) 
- (modified) compiler-rt/lib/profile/InstrProfilingPort.h (+1-1) 
- (modified) compiler-rt/lib/profile/InstrProfilingUtil.c (+4-8) 
- (removed) lld/test/wasm/custom-section-align.s (-31) 
- (modified) lld/wasm/InputChunks.h (+4-6) 
- (modified) lld/wasm/InputFiles.cpp (+2-16) 
- (modified) lld/wasm/OutputSections.cpp (-1) 
- (modified) llvm/include/llvm/ProfileData/Coverage/CoverageMappingReader.h 
(+2-11) 
- (modified) llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp (+1-5) 
- (modified) llvm/lib/MC/MCContext.cpp (-5) 
- (modified) llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp (+15-72) 
- (modified) llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp (+2-3) 
- (removed) llvm/test/CodeGen/WebAssembly/profile.ll (-47) 
- (modified) llvm/test/Instrumentation/InstrProfiling/profiling.ll (+6-1) 
- (removed) llvm/test/tools/llvm-cov/Inputs/binary-formats.v6.wasm32 () 
- (removed) llvm/test/tools/llvm-cov/Inputs/binary-formats.wasm.proftext (-4) 
- (modified) llvm/test/tools/llvm-cov/binary-formats.c (-7) 


``diff
diff --git a/clang/lib/Driver/ToolChains/WebAssembly.cpp 
b/clang/lib/Driver/ToolChains/WebAssembly.cpp
index 44a6894d30fb29..9aec11e69fde1d 100644
--- a/clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ b/clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -163,8 +163,6 @@ void wasm::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 AddRunTimeLibs(ToolChain, ToolChain.getDriver(), CmdArgs, Args);
   }
 
-  ToolChain.addProfileRTLibs(Args, CmdArgs);
-
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
 
diff --git a/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake 
b/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
index d00d39518104bf..809e9277156912 100644
--- a/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
+++ b/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
@@ -77,7 +77,7 @@ set(ALL_HWASAN_SUPPORTED_ARCH ${X86_64} ${ARM64} ${RISCV64})
 set(ALL_MEMPROF_SUPPORTED_ARCH ${X86_64})
 set(ALL_PROFILE_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} ${PPC32} 
${PPC64}
 ${MIPS32} ${MIPS64} ${S390X} ${SPARC} ${SPARCV9} ${HEXAGON}
-${RISCV32} ${RISCV64} ${LOONGARCH64} ${WASM32})
+${RISCV32} ${RISCV64} ${LOONGARCH64})
 set(ALL_CTX_PROFILE_SUPPORTED_ARCH ${X86_64})
 if (OS_NAME MATCHES "FreeBSD")
   set(ALL_TSAN_SUPPORTED_ARCH ${X86_64} ${MIPS64} ${ARM64})
diff --git a/compiler-rt/cmake/config-ix.cmake 
b/compiler-rt/cmake/config-ix.cmake
index a494e0532a50bc..a93a88a9205001 100644
--- a/compiler-rt/cmake/config-ix.cmake
+++ b/compiler-rt/cmake/config-ix.cmake
@@ -822,7 +822,7 @@ else()
 endif()
 
 if (PROFILE_SUPPORTED_ARCH AND NOT LLVM_USE_SANITIZER AND
-OS_NAME MATCHES 
"Darwin|Linux|FreeBSD|Windows|Android|Fuchsia|SunOS|NetBSD|AIX|WASI")
+OS_NAME MATCHES 
"Darwin|Linux|FreeBSD|Windows|Android|Fuchsia|SunOS|NetBSD|AIX")
   set(COMPILER_RT_HAS_PROFILE TRUE)
 else()
   set(COMPILER_RT_HAS_PROFILE FALSE)
diff --git a/compiler-rt/lib/profile/CMakeLists.txt 
b/compiler-rt/lib/profile/CMakeLists.txt
index ac1451c8ceed18..26178412967201 100644
--- a/compiler-rt/lib/profile/CMakeLists.txt
+++ b/compiler-rt/lib/profile/CMakeLists.txt
@@ -38,17 +38,6 @@ int main() {
 
 " COMPILER_RT_TARGET_HAS_FCNTL_LCK)
 
-CHECK_CXX_SOURCE_COMPILES("
-#include 
-
-int fd;
-int main() {
-  flock(fd, LOCK_EX);
-  return 0;
-}
-
-" COMPILER_RT_TARGET_HAS_FLOCK)
-
 CHECK_CXX_SOURCE_COMPILES("
 #include 
 int main() {
@@ -104,13 +93,6 @@ if(FUCH

[clang] [compiler-rt] [lld] [llvm] Revert "[Coverage][WebAssembly] Add initial support for WebAssembly/WASI" (PR #112274)

2024-10-14 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: None (dpalermo)


Changes

Reverts llvm/llvm-project#111332

Unable to build clang/flang with OpenMP this patch.  Results in:
https://lab.llvm.org/staging/#/builders/105/builds/6816

38.873 [112/2/7464] Linking CXX shared library lib/liblldWasm.so.20.0git
FAILED: lib/liblldWasm.so.20.0git 
...
/usr/bin/ld: tools/lld/wasm/CMakeFiles/lldWasm.dir/InputFiles.cpp.o: in 
function `lld::wasm::ObjFile::parse(bool)':
InputFiles.cpp:(.text._ZN3lld4wasm7ObjFile5parseEb+0x1250): undefined reference 
to `llvm::getInstrProfSectionName[abi:cxx11](llvm::InstrProfSectKind, 
llvm::Triple::ObjectFormatType, bool)'
/usr/bin/ld: InputFiles.cpp:(.text._ZN3lld4wasm7ObjFile5parseEb+0x14fb): 
undefined reference to 
`llvm::getInstrProfSectionName[abi:cxx11](llvm::InstrProfSectKind, 
llvm::Triple::ObjectFormatType, bool)'
collect2: error: ld returned 1 exit status



---

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


23 Files Affected:

- (modified) clang/lib/Driver/ToolChains/WebAssembly.cpp (-2) 
- (modified) compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake (+1-1) 
- (modified) compiler-rt/cmake/config-ix.cmake (+1-1) 
- (modified) compiler-rt/lib/profile/CMakeLists.txt (-24) 
- (modified) compiler-rt/lib/profile/GCDAProfiling.c (+1-1) 
- (modified) compiler-rt/lib/profile/InstrProfilingPlatformLinux.c (+4-4) 
- (modified) compiler-rt/lib/profile/InstrProfilingPlatformOther.c (+1-2) 
- (modified) compiler-rt/lib/profile/InstrProfilingPort.h (+1-1) 
- (modified) compiler-rt/lib/profile/InstrProfilingUtil.c (+4-8) 
- (removed) lld/test/wasm/custom-section-align.s (-31) 
- (modified) lld/wasm/InputChunks.h (+4-6) 
- (modified) lld/wasm/InputFiles.cpp (+2-16) 
- (modified) lld/wasm/OutputSections.cpp (-1) 
- (modified) llvm/include/llvm/ProfileData/Coverage/CoverageMappingReader.h 
(+2-11) 
- (modified) llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp (+1-5) 
- (modified) llvm/lib/MC/MCContext.cpp (-5) 
- (modified) llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp (+15-72) 
- (modified) llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp (+2-3) 
- (removed) llvm/test/CodeGen/WebAssembly/profile.ll (-47) 
- (modified) llvm/test/Instrumentation/InstrProfiling/profiling.ll (+6-1) 
- (removed) llvm/test/tools/llvm-cov/Inputs/binary-formats.v6.wasm32 () 
- (removed) llvm/test/tools/llvm-cov/Inputs/binary-formats.wasm.proftext (-4) 
- (modified) llvm/test/tools/llvm-cov/binary-formats.c (-7) 


``diff
diff --git a/clang/lib/Driver/ToolChains/WebAssembly.cpp 
b/clang/lib/Driver/ToolChains/WebAssembly.cpp
index 44a6894d30fb29..9aec11e69fde1d 100644
--- a/clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ b/clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -163,8 +163,6 @@ void wasm::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 AddRunTimeLibs(ToolChain, ToolChain.getDriver(), CmdArgs, Args);
   }
 
-  ToolChain.addProfileRTLibs(Args, CmdArgs);
-
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
 
diff --git a/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake 
b/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
index d00d39518104bf..809e9277156912 100644
--- a/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
+++ b/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
@@ -77,7 +77,7 @@ set(ALL_HWASAN_SUPPORTED_ARCH ${X86_64} ${ARM64} ${RISCV64})
 set(ALL_MEMPROF_SUPPORTED_ARCH ${X86_64})
 set(ALL_PROFILE_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} ${PPC32} 
${PPC64}
 ${MIPS32} ${MIPS64} ${S390X} ${SPARC} ${SPARCV9} ${HEXAGON}
-${RISCV32} ${RISCV64} ${LOONGARCH64} ${WASM32})
+${RISCV32} ${RISCV64} ${LOONGARCH64})
 set(ALL_CTX_PROFILE_SUPPORTED_ARCH ${X86_64})
 if (OS_NAME MATCHES "FreeBSD")
   set(ALL_TSAN_SUPPORTED_ARCH ${X86_64} ${MIPS64} ${ARM64})
diff --git a/compiler-rt/cmake/config-ix.cmake 
b/compiler-rt/cmake/config-ix.cmake
index a494e0532a50bc..a93a88a9205001 100644
--- a/compiler-rt/cmake/config-ix.cmake
+++ b/compiler-rt/cmake/config-ix.cmake
@@ -822,7 +822,7 @@ else()
 endif()
 
 if (PROFILE_SUPPORTED_ARCH AND NOT LLVM_USE_SANITIZER AND
-OS_NAME MATCHES 
"Darwin|Linux|FreeBSD|Windows|Android|Fuchsia|SunOS|NetBSD|AIX|WASI")
+OS_NAME MATCHES 
"Darwin|Linux|FreeBSD|Windows|Android|Fuchsia|SunOS|NetBSD|AIX")
   set(COMPILER_RT_HAS_PROFILE TRUE)
 else()
   set(COMPILER_RT_HAS_PROFILE FALSE)
diff --git a/compiler-rt/lib/profile/CMakeLists.txt 
b/compiler-rt/lib/profile/CMakeLists.txt
index ac1451c8ceed18..26178412967201 100644
--- a/compiler-rt/lib/profile/CMakeLists.txt
+++ b/compiler-rt/lib/profile/CMakeLists.txt
@@ -38,17 +38,6 @@ int main() {
 
 " COMPILER_RT_TARGET_HAS_FCNTL_LCK)
 
-CHECK_CXX_SOURCE_COMPILES("
-#include 
-
-int fd;
-int main() {
-  flock(fd, LOCK_EX);
-  return 0;
-}
-
-" COMPILER_RT_TARGET_HAS_FLOCK)
-
 CHECK_CXX_SOURCE_COMPILES("
 #include 
 int main() {
@@ -104,13 +93,6 @@ if(FUCHSIA OR UNIX)
 

[clang] [compiler-rt] [lld] [llvm] Revert "[Coverage][WebAssembly] Add initial support for WebAssembly/WASI" (PR #112274)

2024-10-14 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-pgo

Author: None (dpalermo)


Changes

Reverts llvm/llvm-project#111332

Unable to build clang/flang with OpenMP this patch.  Results in:
https://lab.llvm.org/staging/#/builders/105/builds/6816

38.873 [112/2/7464] Linking CXX shared library lib/liblldWasm.so.20.0git
FAILED: lib/liblldWasm.so.20.0git 
...
/usr/bin/ld: tools/lld/wasm/CMakeFiles/lldWasm.dir/InputFiles.cpp.o: in 
function `lld::wasm::ObjFile::parse(bool)':
InputFiles.cpp:(.text._ZN3lld4wasm7ObjFile5parseEb+0x1250): undefined reference 
to `llvm::getInstrProfSectionName[abi:cxx11](llvm::InstrProfSectKind, 
llvm::Triple::ObjectFormatType, bool)'
/usr/bin/ld: InputFiles.cpp:(.text._ZN3lld4wasm7ObjFile5parseEb+0x14fb): 
undefined reference to 
`llvm::getInstrProfSectionName[abi:cxx11](llvm::InstrProfSectKind, 
llvm::Triple::ObjectFormatType, bool)'
collect2: error: ld returned 1 exit status



---

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


23 Files Affected:

- (modified) clang/lib/Driver/ToolChains/WebAssembly.cpp (-2) 
- (modified) compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake (+1-1) 
- (modified) compiler-rt/cmake/config-ix.cmake (+1-1) 
- (modified) compiler-rt/lib/profile/CMakeLists.txt (-24) 
- (modified) compiler-rt/lib/profile/GCDAProfiling.c (+1-1) 
- (modified) compiler-rt/lib/profile/InstrProfilingPlatformLinux.c (+4-4) 
- (modified) compiler-rt/lib/profile/InstrProfilingPlatformOther.c (+1-2) 
- (modified) compiler-rt/lib/profile/InstrProfilingPort.h (+1-1) 
- (modified) compiler-rt/lib/profile/InstrProfilingUtil.c (+4-8) 
- (removed) lld/test/wasm/custom-section-align.s (-31) 
- (modified) lld/wasm/InputChunks.h (+4-6) 
- (modified) lld/wasm/InputFiles.cpp (+2-16) 
- (modified) lld/wasm/OutputSections.cpp (-1) 
- (modified) llvm/include/llvm/ProfileData/Coverage/CoverageMappingReader.h 
(+2-11) 
- (modified) llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp (+1-5) 
- (modified) llvm/lib/MC/MCContext.cpp (-5) 
- (modified) llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp (+15-72) 
- (modified) llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp (+2-3) 
- (removed) llvm/test/CodeGen/WebAssembly/profile.ll (-47) 
- (modified) llvm/test/Instrumentation/InstrProfiling/profiling.ll (+6-1) 
- (removed) llvm/test/tools/llvm-cov/Inputs/binary-formats.v6.wasm32 () 
- (removed) llvm/test/tools/llvm-cov/Inputs/binary-formats.wasm.proftext (-4) 
- (modified) llvm/test/tools/llvm-cov/binary-formats.c (-7) 


``diff
diff --git a/clang/lib/Driver/ToolChains/WebAssembly.cpp 
b/clang/lib/Driver/ToolChains/WebAssembly.cpp
index 44a6894d30fb29..9aec11e69fde1d 100644
--- a/clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ b/clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -163,8 +163,6 @@ void wasm::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 AddRunTimeLibs(ToolChain, ToolChain.getDriver(), CmdArgs, Args);
   }
 
-  ToolChain.addProfileRTLibs(Args, CmdArgs);
-
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
 
diff --git a/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake 
b/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
index d00d39518104bf..809e9277156912 100644
--- a/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
+++ b/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
@@ -77,7 +77,7 @@ set(ALL_HWASAN_SUPPORTED_ARCH ${X86_64} ${ARM64} ${RISCV64})
 set(ALL_MEMPROF_SUPPORTED_ARCH ${X86_64})
 set(ALL_PROFILE_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} ${PPC32} 
${PPC64}
 ${MIPS32} ${MIPS64} ${S390X} ${SPARC} ${SPARCV9} ${HEXAGON}
-${RISCV32} ${RISCV64} ${LOONGARCH64} ${WASM32})
+${RISCV32} ${RISCV64} ${LOONGARCH64})
 set(ALL_CTX_PROFILE_SUPPORTED_ARCH ${X86_64})
 if (OS_NAME MATCHES "FreeBSD")
   set(ALL_TSAN_SUPPORTED_ARCH ${X86_64} ${MIPS64} ${ARM64})
diff --git a/compiler-rt/cmake/config-ix.cmake 
b/compiler-rt/cmake/config-ix.cmake
index a494e0532a50bc..a93a88a9205001 100644
--- a/compiler-rt/cmake/config-ix.cmake
+++ b/compiler-rt/cmake/config-ix.cmake
@@ -822,7 +822,7 @@ else()
 endif()
 
 if (PROFILE_SUPPORTED_ARCH AND NOT LLVM_USE_SANITIZER AND
-OS_NAME MATCHES 
"Darwin|Linux|FreeBSD|Windows|Android|Fuchsia|SunOS|NetBSD|AIX|WASI")
+OS_NAME MATCHES 
"Darwin|Linux|FreeBSD|Windows|Android|Fuchsia|SunOS|NetBSD|AIX")
   set(COMPILER_RT_HAS_PROFILE TRUE)
 else()
   set(COMPILER_RT_HAS_PROFILE FALSE)
diff --git a/compiler-rt/lib/profile/CMakeLists.txt 
b/compiler-rt/lib/profile/CMakeLists.txt
index ac1451c8ceed18..26178412967201 100644
--- a/compiler-rt/lib/profile/CMakeLists.txt
+++ b/compiler-rt/lib/profile/CMakeLists.txt
@@ -38,17 +38,6 @@ int main() {
 
 " COMPILER_RT_TARGET_HAS_FCNTL_LCK)
 
-CHECK_CXX_SOURCE_COMPILES("
-#include 
-
-int fd;
-int main() {
-  flock(fd, LOCK_EX);
-  return 0;
-}
-
-" COMPILER_RT_TARGET_HAS_FLOCK)
-
 CHECK_CXX_SOURCE_COMPILES("
 #include 
 int main() {
@@ -104,13 +93,6 @@ if(FUCHSIA OR UNIX)
   

[clang] [compiler-rt] [lld] [llvm] Revert "[Coverage][WebAssembly] Add initial support for WebAssembly/WASI" (PR #112274)

2024-10-14 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-mc

Author: None (dpalermo)


Changes

Reverts llvm/llvm-project#111332

Unable to build clang/flang with OpenMP this patch.  Results in:
https://lab.llvm.org/staging/#/builders/105/builds/6816

38.873 [112/2/7464] Linking CXX shared library lib/liblldWasm.so.20.0git
FAILED: lib/liblldWasm.so.20.0git 
...
/usr/bin/ld: tools/lld/wasm/CMakeFiles/lldWasm.dir/InputFiles.cpp.o: in 
function `lld::wasm::ObjFile::parse(bool)':
InputFiles.cpp:(.text._ZN3lld4wasm7ObjFile5parseEb+0x1250): undefined reference 
to `llvm::getInstrProfSectionName[abi:cxx11](llvm::InstrProfSectKind, 
llvm::Triple::ObjectFormatType, bool)'
/usr/bin/ld: InputFiles.cpp:(.text._ZN3lld4wasm7ObjFile5parseEb+0x14fb): 
undefined reference to 
`llvm::getInstrProfSectionName[abi:cxx11](llvm::InstrProfSectKind, 
llvm::Triple::ObjectFormatType, bool)'
collect2: error: ld returned 1 exit status



---

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


23 Files Affected:

- (modified) clang/lib/Driver/ToolChains/WebAssembly.cpp (-2) 
- (modified) compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake (+1-1) 
- (modified) compiler-rt/cmake/config-ix.cmake (+1-1) 
- (modified) compiler-rt/lib/profile/CMakeLists.txt (-24) 
- (modified) compiler-rt/lib/profile/GCDAProfiling.c (+1-1) 
- (modified) compiler-rt/lib/profile/InstrProfilingPlatformLinux.c (+4-4) 
- (modified) compiler-rt/lib/profile/InstrProfilingPlatformOther.c (+1-2) 
- (modified) compiler-rt/lib/profile/InstrProfilingPort.h (+1-1) 
- (modified) compiler-rt/lib/profile/InstrProfilingUtil.c (+4-8) 
- (removed) lld/test/wasm/custom-section-align.s (-31) 
- (modified) lld/wasm/InputChunks.h (+4-6) 
- (modified) lld/wasm/InputFiles.cpp (+2-16) 
- (modified) lld/wasm/OutputSections.cpp (-1) 
- (modified) llvm/include/llvm/ProfileData/Coverage/CoverageMappingReader.h 
(+2-11) 
- (modified) llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp (+1-5) 
- (modified) llvm/lib/MC/MCContext.cpp (-5) 
- (modified) llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp (+15-72) 
- (modified) llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp (+2-3) 
- (removed) llvm/test/CodeGen/WebAssembly/profile.ll (-47) 
- (modified) llvm/test/Instrumentation/InstrProfiling/profiling.ll (+6-1) 
- (removed) llvm/test/tools/llvm-cov/Inputs/binary-formats.v6.wasm32 () 
- (removed) llvm/test/tools/llvm-cov/Inputs/binary-formats.wasm.proftext (-4) 
- (modified) llvm/test/tools/llvm-cov/binary-formats.c (-7) 


``diff
diff --git a/clang/lib/Driver/ToolChains/WebAssembly.cpp 
b/clang/lib/Driver/ToolChains/WebAssembly.cpp
index 44a6894d30fb29..9aec11e69fde1d 100644
--- a/clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ b/clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -163,8 +163,6 @@ void wasm::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 AddRunTimeLibs(ToolChain, ToolChain.getDriver(), CmdArgs, Args);
   }
 
-  ToolChain.addProfileRTLibs(Args, CmdArgs);
-
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
 
diff --git a/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake 
b/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
index d00d39518104bf..809e9277156912 100644
--- a/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
+++ b/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
@@ -77,7 +77,7 @@ set(ALL_HWASAN_SUPPORTED_ARCH ${X86_64} ${ARM64} ${RISCV64})
 set(ALL_MEMPROF_SUPPORTED_ARCH ${X86_64})
 set(ALL_PROFILE_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} ${PPC32} 
${PPC64}
 ${MIPS32} ${MIPS64} ${S390X} ${SPARC} ${SPARCV9} ${HEXAGON}
-${RISCV32} ${RISCV64} ${LOONGARCH64} ${WASM32})
+${RISCV32} ${RISCV64} ${LOONGARCH64})
 set(ALL_CTX_PROFILE_SUPPORTED_ARCH ${X86_64})
 if (OS_NAME MATCHES "FreeBSD")
   set(ALL_TSAN_SUPPORTED_ARCH ${X86_64} ${MIPS64} ${ARM64})
diff --git a/compiler-rt/cmake/config-ix.cmake 
b/compiler-rt/cmake/config-ix.cmake
index a494e0532a50bc..a93a88a9205001 100644
--- a/compiler-rt/cmake/config-ix.cmake
+++ b/compiler-rt/cmake/config-ix.cmake
@@ -822,7 +822,7 @@ else()
 endif()
 
 if (PROFILE_SUPPORTED_ARCH AND NOT LLVM_USE_SANITIZER AND
-OS_NAME MATCHES 
"Darwin|Linux|FreeBSD|Windows|Android|Fuchsia|SunOS|NetBSD|AIX|WASI")
+OS_NAME MATCHES 
"Darwin|Linux|FreeBSD|Windows|Android|Fuchsia|SunOS|NetBSD|AIX")
   set(COMPILER_RT_HAS_PROFILE TRUE)
 else()
   set(COMPILER_RT_HAS_PROFILE FALSE)
diff --git a/compiler-rt/lib/profile/CMakeLists.txt 
b/compiler-rt/lib/profile/CMakeLists.txt
index ac1451c8ceed18..26178412967201 100644
--- a/compiler-rt/lib/profile/CMakeLists.txt
+++ b/compiler-rt/lib/profile/CMakeLists.txt
@@ -38,17 +38,6 @@ int main() {
 
 " COMPILER_RT_TARGET_HAS_FCNTL_LCK)
 
-CHECK_CXX_SOURCE_COMPILES("
-#include 
-
-int fd;
-int main() {
-  flock(fd, LOCK_EX);
-  return 0;
-}
-
-" COMPILER_RT_TARGET_HAS_FLOCK)
-
 CHECK_CXX_SOURCE_COMPILES("
 #include 
 int main() {
@@ -104,13 +93,6 @@ if(FUCHSIA OR UNIX)

[clang] [compiler-rt] [lld] [llvm] Revert "[Coverage][WebAssembly] Add initial support for WebAssembly/WASI" (PR #112274)

2024-10-14 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-lld

Author: None (dpalermo)


Changes

Reverts llvm/llvm-project#111332

Unable to build clang/flang with OpenMP this patch.  Results in:
https://lab.llvm.org/staging/#/builders/105/builds/6816

38.873 [112/2/7464] Linking CXX shared library lib/liblldWasm.so.20.0git
FAILED: lib/liblldWasm.so.20.0git 
...
/usr/bin/ld: tools/lld/wasm/CMakeFiles/lldWasm.dir/InputFiles.cpp.o: in 
function `lld::wasm::ObjFile::parse(bool)':
InputFiles.cpp:(.text._ZN3lld4wasm7ObjFile5parseEb+0x1250): undefined reference 
to `llvm::getInstrProfSectionName[abi:cxx11](llvm::InstrProfSectKind, 
llvm::Triple::ObjectFormatType, bool)'
/usr/bin/ld: InputFiles.cpp:(.text._ZN3lld4wasm7ObjFile5parseEb+0x14fb): 
undefined reference to 
`llvm::getInstrProfSectionName[abi:cxx11](llvm::InstrProfSectKind, 
llvm::Triple::ObjectFormatType, bool)'
collect2: error: ld returned 1 exit status



---

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


23 Files Affected:

- (modified) clang/lib/Driver/ToolChains/WebAssembly.cpp (-2) 
- (modified) compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake (+1-1) 
- (modified) compiler-rt/cmake/config-ix.cmake (+1-1) 
- (modified) compiler-rt/lib/profile/CMakeLists.txt (-24) 
- (modified) compiler-rt/lib/profile/GCDAProfiling.c (+1-1) 
- (modified) compiler-rt/lib/profile/InstrProfilingPlatformLinux.c (+4-4) 
- (modified) compiler-rt/lib/profile/InstrProfilingPlatformOther.c (+1-2) 
- (modified) compiler-rt/lib/profile/InstrProfilingPort.h (+1-1) 
- (modified) compiler-rt/lib/profile/InstrProfilingUtil.c (+4-8) 
- (removed) lld/test/wasm/custom-section-align.s (-31) 
- (modified) lld/wasm/InputChunks.h (+4-6) 
- (modified) lld/wasm/InputFiles.cpp (+2-16) 
- (modified) lld/wasm/OutputSections.cpp (-1) 
- (modified) llvm/include/llvm/ProfileData/Coverage/CoverageMappingReader.h 
(+2-11) 
- (modified) llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp (+1-5) 
- (modified) llvm/lib/MC/MCContext.cpp (-5) 
- (modified) llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp (+15-72) 
- (modified) llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp (+2-3) 
- (removed) llvm/test/CodeGen/WebAssembly/profile.ll (-47) 
- (modified) llvm/test/Instrumentation/InstrProfiling/profiling.ll (+6-1) 
- (removed) llvm/test/tools/llvm-cov/Inputs/binary-formats.v6.wasm32 () 
- (removed) llvm/test/tools/llvm-cov/Inputs/binary-formats.wasm.proftext (-4) 
- (modified) llvm/test/tools/llvm-cov/binary-formats.c (-7) 


``diff
diff --git a/clang/lib/Driver/ToolChains/WebAssembly.cpp 
b/clang/lib/Driver/ToolChains/WebAssembly.cpp
index 44a6894d30fb29..9aec11e69fde1d 100644
--- a/clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ b/clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -163,8 +163,6 @@ void wasm::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
 AddRunTimeLibs(ToolChain, ToolChain.getDriver(), CmdArgs, Args);
   }
 
-  ToolChain.addProfileRTLibs(Args, CmdArgs);
-
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
 
diff --git a/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake 
b/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
index d00d39518104bf..809e9277156912 100644
--- a/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
+++ b/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
@@ -77,7 +77,7 @@ set(ALL_HWASAN_SUPPORTED_ARCH ${X86_64} ${ARM64} ${RISCV64})
 set(ALL_MEMPROF_SUPPORTED_ARCH ${X86_64})
 set(ALL_PROFILE_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} ${PPC32} 
${PPC64}
 ${MIPS32} ${MIPS64} ${S390X} ${SPARC} ${SPARCV9} ${HEXAGON}
-${RISCV32} ${RISCV64} ${LOONGARCH64} ${WASM32})
+${RISCV32} ${RISCV64} ${LOONGARCH64})
 set(ALL_CTX_PROFILE_SUPPORTED_ARCH ${X86_64})
 if (OS_NAME MATCHES "FreeBSD")
   set(ALL_TSAN_SUPPORTED_ARCH ${X86_64} ${MIPS64} ${ARM64})
diff --git a/compiler-rt/cmake/config-ix.cmake 
b/compiler-rt/cmake/config-ix.cmake
index a494e0532a50bc..a93a88a9205001 100644
--- a/compiler-rt/cmake/config-ix.cmake
+++ b/compiler-rt/cmake/config-ix.cmake
@@ -822,7 +822,7 @@ else()
 endif()
 
 if (PROFILE_SUPPORTED_ARCH AND NOT LLVM_USE_SANITIZER AND
-OS_NAME MATCHES 
"Darwin|Linux|FreeBSD|Windows|Android|Fuchsia|SunOS|NetBSD|AIX|WASI")
+OS_NAME MATCHES 
"Darwin|Linux|FreeBSD|Windows|Android|Fuchsia|SunOS|NetBSD|AIX")
   set(COMPILER_RT_HAS_PROFILE TRUE)
 else()
   set(COMPILER_RT_HAS_PROFILE FALSE)
diff --git a/compiler-rt/lib/profile/CMakeLists.txt 
b/compiler-rt/lib/profile/CMakeLists.txt
index ac1451c8ceed18..26178412967201 100644
--- a/compiler-rt/lib/profile/CMakeLists.txt
+++ b/compiler-rt/lib/profile/CMakeLists.txt
@@ -38,17 +38,6 @@ int main() {
 
 " COMPILER_RT_TARGET_HAS_FCNTL_LCK)
 
-CHECK_CXX_SOURCE_COMPILES("
-#include 
-
-int fd;
-int main() {
-  flock(fd, LOCK_EX);
-  return 0;
-}
-
-" COMPILER_RT_TARGET_HAS_FLOCK)
-
 CHECK_CXX_SOURCE_COMPILES("
 #include 
 int main() {
@@ -104,13 +93,6 @@ if(FUCHSIA OR UNIX)
   

[clang] [Clang] Instantiate Typedefs referenced by type alias deduction guides (PR #111804)

2024-10-14 Thread via cfe-commits

llvmbot wrote:

/pull-request llvm/llvm-project#112293

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


[clang] [flang] [flang] Link to libatomic with openmp and rtlib=libgcc (PR #112202)

2024-10-14 Thread Tom Eccles via cfe-commits

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

LGTM thanks!

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


[clang] [llvm] Update llvm::Registry to work for LLVM shared library builds on windows (PR #109024)

2024-10-14 Thread Thomas Fransham via cfe-commits

https://github.com/fsfod updated 
https://github.com/llvm/llvm-project/pull/109024

>From beef0d9f53f05c31041677101577929281e908b1 Mon Sep 17 00:00:00 2001
From: Thomas Fransham 
Date: Wed, 28 Aug 2024 16:08:52 +0100
Subject: [PATCH 1/8] Update llvm::Registry to work for LLVM shared library
 builds on windows

Windows doesn't implicitly import and merge exported symbols across shared 
libraries
like Linux does so we need to explicitly export/import each instantiation of 
llvm::Registry.
Updated LLVM_INSTANTIATE_REGISTRY macro to export Registry::add_node and
Registry::begin() and add extern template declarations for the all 
instantiations of llvm::Registry.
---
 clang/include/clang/Basic/ParsedAttrInfo.h|  5 +++
 .../clang/Frontend/FrontendPluginRegistry.h   |  5 +++
 llvm/include/llvm/CodeGen/GCMetadataPrinter.h |  2 +
 llvm/include/llvm/IR/GCStrategy.h |  2 +
 llvm/include/llvm/Support/Compiler.h  |  5 +++
 llvm/include/llvm/Support/Registry.h  | 43 ++-
 6 files changed, 42 insertions(+), 20 deletions(-)

diff --git a/clang/include/clang/Basic/ParsedAttrInfo.h 
b/clang/include/clang/Basic/ParsedAttrInfo.h
index fab5c6f1377d27..c87adabfcd200f 100644
--- a/clang/include/clang/Basic/ParsedAttrInfo.h
+++ b/clang/include/clang/Basic/ParsedAttrInfo.h
@@ -17,6 +17,7 @@
 
 #include "clang/Basic/AttrSubjectMatchRules.h"
 #include "clang/Basic/AttributeCommonInfo.h"
+#include "clang/Support/Compiler.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/Support/Registry.h"
 #include 
@@ -175,4 +176,8 @@ const std::list> 
&getAttributePluginInstances();
 
 } // namespace clang
 
+namespace llvm {
+extern template class CLANG_TEMPLATE_ABI llvm::Registry;
+} // namespace llvm
+
 #endif // LLVM_CLANG_BASIC_PARSEDATTRINFO_H
diff --git a/clang/include/clang/Frontend/FrontendPluginRegistry.h 
b/clang/include/clang/Frontend/FrontendPluginRegistry.h
index 810578534acb45..5eea9c2fd89a32 100644
--- a/clang/include/clang/Frontend/FrontendPluginRegistry.h
+++ b/clang/include/clang/Frontend/FrontendPluginRegistry.h
@@ -14,6 +14,7 @@
 #define LLVM_CLANG_FRONTEND_FRONTENDPLUGINREGISTRY_H
 
 #include "clang/Frontend/FrontendAction.h"
+#include "clang/Support/Compiler.h"
 #include "llvm/Support/Registry.h"
 
 namespace clang {
@@ -23,4 +24,8 @@ using FrontendPluginRegistry = 
llvm::Registry;
 
 } // namespace clang
 
+namespace llvm {
+extern template class CLANG_TEMPLATE_ABI Registry;
+} // namespace llvm
+
 #endif // LLVM_CLANG_FRONTEND_FRONTENDPLUGINREGISTRY_H
diff --git a/llvm/include/llvm/CodeGen/GCMetadataPrinter.h 
b/llvm/include/llvm/CodeGen/GCMetadataPrinter.h
index f9527c9f8752e9..9d421be8313f01 100644
--- a/llvm/include/llvm/CodeGen/GCMetadataPrinter.h
+++ b/llvm/include/llvm/CodeGen/GCMetadataPrinter.h
@@ -34,6 +34,8 @@ class StackMaps;
 /// defaults from Registry.
 using GCMetadataPrinterRegistry = Registry;
 
+extern template class LLVM_TEMPLATE_ABI Registry;
+
 /// GCMetadataPrinter - Emits GC metadata as assembly code.  Instances are
 /// created, managed, and owned by the AsmPrinter.
 class GCMetadataPrinter {
diff --git a/llvm/include/llvm/IR/GCStrategy.h 
b/llvm/include/llvm/IR/GCStrategy.h
index 3186465f001812..cbfbe23aaa0683 100644
--- a/llvm/include/llvm/IR/GCStrategy.h
+++ b/llvm/include/llvm/IR/GCStrategy.h
@@ -141,6 +141,8 @@ class GCStrategy {
 /// GCMetadataPrinterRegistery as well.
 using GCRegistry = Registry;
 
+extern template class LLVM_TEMPLATE_ABI Registry;
+
 /// Lookup the GCStrategy object associated with the given gc name.
 std::unique_ptr getGCStrategy(const StringRef Name);
 
diff --git a/llvm/include/llvm/Support/Compiler.h 
b/llvm/include/llvm/Support/Compiler.h
index 1d2d751d4dc11a..e893734b81fb7d 100644
--- a/llvm/include/llvm/Support/Compiler.h
+++ b/llvm/include/llvm/Support/Compiler.h
@@ -179,6 +179,7 @@
 #define LLVM_ABI
 #define LLVM_TEMPLATE_ABI
 #define LLVM_EXPORT_TEMPLATE
+#define LLVM_ABI_EXPORT
 #elif defined(_WIN32) && !defined(__MINGW32__)
 #if defined(LLVM_EXPORTS)
 #define LLVM_ABI __declspec(dllexport)
@@ -189,19 +190,23 @@
 #define LLVM_TEMPLATE_ABI __declspec(dllimport)
 #define LLVM_EXPORT_TEMPLATE
 #endif
+#define LLVM_ABI_EXPORT __declspec(dllexport)
 #elif defined(__ELF__) || defined(__MINGW32__) || defined(_AIX)
 #define LLVM_ABI LLVM_ATTRIBUTE_VISIBILITY_DEFAULT
 #define LLVM_TEMPLATE_ABI LLVM_ATTRIBUTE_VISIBILITY_DEFAULT
 #define LLVM_EXPORT_TEMPLATE
+#define LLVM_ABI_EXPORT LLVM_ATTRIBUTE_VISIBILITY_DEFAULT
 #elif defined(__MACH__) || defined(__WASM__)
 #define LLVM_ABI LLVM_ATTRIBUTE_VISIBILITY_DEFAULT
 #define LLVM_TEMPLATE_ABI
 #define LLVM_EXPORT_TEMPLATE
+#define LLVM_ABI_EXPORT LLVM_ATTRIBUTE_VISIBILITY_DEFAULT
 #endif
 #else
 #define LLVM_ABI
 #define LLVM_TEMPLATE_ABI
 #define LLVM_EXPORT_TEMPLATE
+#define LLVM_ABI_EXPORT
 #endif
 #define LLVM_C_ABI LLVM_ABI
 #endif
diff --git a/llvm/include/llvm/Support/Registry.h 
b/llvm/include/llvm/Support/Registry.h
index 5bb6a254a47f4c..2dcbe0f2a28208 100644
--- a/llvm/i

[clang] [clang] Check null TypeSourceInfo in CreateUnaryExprOrTypeTraitExpr (PR #112111)

2024-10-14 Thread Andrew Sukach via cfe-commits

https://github.com/sookach updated 
https://github.com/llvm/llvm-project/pull/112111

>From 8c0527aae4542c7065c14e8f21d6ca37010a29a6 Mon Sep 17 00:00:00 2001
From: Andrew Sukach 
Date: Sat, 12 Oct 2024 19:47:30 -0400
Subject: [PATCH 1/2] [clang] Check for null TypeSourceInfo in
 Sema::CreateUnaryExprOrTypeTraitExpr

---
 clang/docs/ReleaseNotes.rst   |  7 +
 clang/lib/Sema/SemaExpr.cpp   |  3 +++
 .../unary-expr-or-type-trait-invalid.cpp  | 26 +++
 3 files changed, 36 insertions(+)
 create mode 100644 clang/test/SemaCXX/unary-expr-or-type-trait-invalid.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 763bc3ac159322..bd0a4c70c85c9d 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -683,6 +683,13 @@ New features
 Crash and bug fixes
 ^^^
 
+- Check for a null ``TypeSourceInfo *`` when creating a 
``UnaryExprOrTypeTraitExpr``.
+  Fixes (#GH111594)
+
+  Example code that no longer crashes:
+.. code-block:: c++
+  a() {struct b c (sizeof(b * [({ {tree->d* next)} 0
+
 Improvements
 
 
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 4e37385710af5e..b0bd216c5dc101 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -4629,6 +4629,9 @@ ExprResult 
Sema::CreateUnaryExprOrTypeTraitExpr(TypeSourceInfo *TInfo,
   TInfo->getType()->isVariablyModifiedType())
 TInfo = TransformToPotentiallyEvaluated(TInfo);
 
+  if (!TInfo)
+return ExprError();
+
   // C99 6.5.3.4p4: the type (an unsigned integer type) is size_t.
   return new (Context) UnaryExprOrTypeTraitExpr(
   ExprKind, TInfo, Context.getSizeType(), OpLoc, R.getEnd());
diff --git a/clang/test/SemaCXX/unary-expr-or-type-trait-invalid.cpp 
b/clang/test/SemaCXX/unary-expr-or-type-trait-invalid.cpp
new file mode 100644
index 00..bf7b6299078681
--- /dev/null
+++ b/clang/test/SemaCXX/unary-expr-or-type-trait-invalid.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+a() {struct b c (sizeof(b * [({ {tree->d* next)} 0
+
+// expected-error@3 {{a type specifier is required for all declarations}}
+// expected-error@3 {{use of undeclared identifier 'tree'; did you mean 
'true'?}}
+// expected-error@3 {{member reference type 'bool' is not a pointer}}
+// expected-error@3 {{expected ';' after expression}}
+// expected-error@3 {{use of undeclared identifier 'next'; did you mean 
'new'?}}
+// expected-error@3 {{expected expression}}
+// expected-error@3 {{expected ';' after expression}}
+// expected-error@26 {{expected '}'}}
+// expected-note@3 {{to match this '{'}}
+// expected-error@26 {{expected ')'}}
+// expected-note@3 {{to match this '('}}
+// expected-error@26 {{expected ']'}}
+// expected-note@3 {{to match this '['}}
+// expected-error@26 {{expected ')'}}
+// expected-note@3 {{to match this '('}}
+// expected-error@3 {{using declaration 'exp' instantiates to an empty pack}}
+// expected-error@3 {{variable has incomplete type 'struct b'}}
+// expected-note@3 {{forward declaration of 'b'}}
+// expected-error@3 {{expected ';' at end of declaration}}
+// expected-error@26 {{expected '}'}}
+// expected-note@3 {{to match this '{'}}
+// expected-warning@3 {{expression result unused}}

>From f5021176aab58e6d2abaa92bdfb662a86266e6aa Mon Sep 17 00:00:00 2001
From: Andrew Sukach 
Date: Mon, 14 Oct 2024 17:40:25 -0400
Subject: [PATCH 2/2] [clang] Check null TypeSourceInfo in
 CreateUnaryExprOrTypeTraitExpr

---
 clang/docs/ReleaseNotes.rst | 4 
 1 file changed, 4 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index bd0a4c70c85c9d..7a93259700ea4d 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -686,10 +686,6 @@ Crash and bug fixes
 - Check for a null ``TypeSourceInfo *`` when creating a 
``UnaryExprOrTypeTraitExpr``.
   Fixes (#GH111594)
 
-  Example code that no longer crashes:
-.. code-block:: c++
-  a() {struct b c (sizeof(b * [({ {tree->d* next)} 0
-
 Improvements
 
 

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


[clang] [llvm] [clang][aarch64] Add support for the MSVC qualifiers __ptr32, __ptr64, __sptr, __uptr for AArch64 (PR #111879)

2024-10-14 Thread Eli Friedman via cfe-commits

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

LGTM

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


[clang] [compiler-rt] [lld] [llvm] [Coverage][WebAssembly] Add initial support for WebAssembly/WASI (PR #111332)

2024-10-14 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `bolt-x86_64-ubuntu-shared` 
running on `bolt-worker` while building `clang,compiler-rt,lld,llvm` at step 6 
"test-build-bolt-check-bolt".

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


Here is the relevant piece of the build log for the reference

```
Step 6 (test-build-bolt-check-bolt) failure: test (failure)
...
14.139 [366/18/1225] Building CXX object 
tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/ToolChains/PPCLinux.cpp.o
14.143 [365/18/1226] Building CXX object 
tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/ToolChains/InterfaceStubs.cpp.o
14.159 [364/18/1227] Building CXX object 
tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/ASTConsumers.cpp.o
14.159 [363/18/1228] Building CXX object 
tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/ToolChains/ZOS.cpp.o
14.177 [362/18/1229] Building CXX object 
tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/ToolChains/PPCFreeBSD.cpp.o
14.181 [361/18/1230] Building CXX object 
tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/Types.cpp.o
14.203 [360/18/1231] Building CXX object 
tools/lld/wasm/CMakeFiles/lldWasm.dir/Writer.cpp.o
14.208 [359/18/1232] Building CXX object 
tools/clang/lib/Driver/CMakeFiles/obj.clangDriver.dir/XRayArgs.cpp.o
14.216 [358/18/1233] Building CXX object 
tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/DiagnosticRenderer.cpp.o
14.264 [357/18/1234] Linking CXX shared library lib/liblldWasm.so.20.0git
FAILED: lib/liblldWasm.so.20.0git 
: && /usr/bin/c++ -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-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 -O3 -DNDEBUG  -Wl,-z,defs -Wl,-z,nodelete -fuse-ld=lld 
-Wl,--color-diagnostics   -Wl,--gc-sections -shared 
-Wl,-soname,liblldWasm.so.20.0git -o lib/liblldWasm.so.20.0git 
tools/lld/wasm/CMakeFiles/lldWasm.dir/Driver.cpp.o 
tools/lld/wasm/CMakeFiles/lldWasm.dir/InputChunks.cpp.o 
tools/lld/wasm/CMakeFiles/lldWasm.dir/InputFiles.cpp.o 
tools/lld/wasm/CMakeFiles/lldWasm.dir/LTO.cpp.o 
tools/lld/wasm/CMakeFiles/lldWasm.dir/MapFile.cpp.o 
tools/lld/wasm/CMakeFiles/lldWasm.dir/MarkLive.cpp.o 
tools/lld/wasm/CMakeFiles/lldWasm.dir/OutputSections.cpp.o 
tools/lld/wasm/CMakeFiles/lldWasm.dir/OutputSegment.cpp.o 
tools/lld/wasm/CMakeFiles/lldWasm.dir/Relocations.cpp.o 
tools/lld/wasm/CMakeFiles/lldWasm.dir/SymbolTable.cpp.o 
tools/lld/wasm/CMakeFiles/lldWasm.dir/Symbols.cpp.o 
tools/lld/wasm/CMakeFiles/lldWasm.dir/SyntheticSections.cpp.o 
tools/lld/wasm/CMakeFiles/lldWasm.dir/Writer.cpp.o 
tools/lld/wasm/CMakeFiles/lldWasm.dir/WriterUtils.cpp.o  
-Wl,-rpath,"\$ORIGIN/../lib:/home/worker/bolt-worker2/bolt-x86_64-ubuntu-shared/build/lib:"
  lib/liblldCommon.so.20.0git  lib/libLLVMX86CodeGen.so.20.0git  
lib/libLLVMX86AsmParser.so.20.0git  lib/libLLVMX86Desc.so.20.0git  
lib/libLLVMX86Disassembler.so.20.0git  lib/libLLVMX86Info.so.20.0git  
lib/libLLVMAArch64CodeGen.so.20.0git  lib/libLLVMAArch64AsmParser.so.20.0git  
lib/libLLVMAArch64Disassembler.so.20.0git  lib/libLLVMRISCVCodeGen.so.20.0git  
lib/libLLVMRISCVAsmParser.so.20.0git  lib/libLLVMRISCVDisassembler.so.20.0git  
lib/libLLVMLTO.so.20.0git  lib/libLLVMOption.so.20.0git  
lib/libLLVMPasses.so.20.0git  lib/libLLVMAArch64Desc.so.20.0git  
lib/libLLVMAArch64Info.so.20.0git  lib/libLLVMAArch64Utils.so.20.0git  
lib/libLLVMRISCVDesc.so.20.0git  lib/libLLVMRISCVInfo.so.20.0git  
lib/libLLVMObject.so.20.0git  lib/libLLVMMC.so.20.0git  
lib/libLLVMCore.so.20.0git  lib/libLLVMBinaryFormat.so.20.0git  
lib/libLLVMTargetParser.so.20.0git  lib/libLLVMSupport.so.20.0git  
lib/libLLVMDemangle.so.20.0git  
-Wl,-rpath-link,/home/worker/bolt-worker2/bolt-x86_64-ubuntu-shared/build/lib 
&& :
ld.lld: error: undefined symbol: 
llvm::getInstrProfSectionName[abi:cxx11](llvm::InstrProfSectKind, 
llvm::Triple::ObjectFormatType, bool)
>>> referenced by InputFiles.cpp
>>>   
>>> tools/lld/wasm/CMakeFiles/lldWasm.dir/InputFiles.cpp.o:(lld::wasm::ObjFile::parse(bool))
>>> referenced by InputFiles.cpp
>>>   
>>> tools/lld/wasm/CMakeFiles/lldWasm.dir/InputFiles.cpp.o:(lld::wasm::ObjFile::parse(bool))
collect2: error: ld returned 1 exit status
14.415 [357/17/1235] Building CXX object 
tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/DependencyGraph.cpp.o
14.539 [357/16/1236] Building CXX object 
tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/GeneratePCH.cpp.o
14.586 [357/15/1237] Building CXX object 
tools/clang/lib/Serialization/CMak

[clang] [llvm] [HLSL] Add handle initialization for simple resource declarations (PR #111207)

2024-10-14 Thread Damyan Pepper via cfe-commits


@@ -489,3 +494,100 @@ void CGHLSLRuntime::generateGlobalCtorDtorCalls() {
   GV->eraseFromParent();
   }
 }
+
+// Returns handle type of a resource, if the type is a resource
+// or an array of resources
+static const HLSLAttributedResourceType *findHandleTypeOnResource(QualType QT) 
{
+  // If the type is a resource class, the first field must
+  // be the resource handle of type HLSLAttributedResourceType
+  const clang::Type *Ty = QT->getUnqualifiedDesugaredType();
+  if (RecordDecl *RD = Ty->getAsCXXRecordDecl()) {
+if (!RD->fields().empty()) {
+  const auto &FirstFD = RD->fields().begin();
+  return dyn_cast(
+  FirstFD->getType().getTypePtr());
+}
+  }
+  return nullptr;
+}
+
+void CGHLSLRuntime::handleGlobalVarDefinition(const VarDecl *VD,
+  llvm::GlobalVariable *Var) {
+  // If the global variable has resource binding, add it to the list of globals
+  // that need resource binding initialization.
+  const HLSLResourceBindingAttr *RBA = VD->getAttr();
+  if (!RBA)
+return;
+
+  if (!findHandleTypeOnResource(VD->getType()))
+// FIXME: Only simple declarations of resources are supported for now.
+// Arrays of resources or resources in user defined classes are
+// not implemented yet.
+return;
+
+  ResourcesToBind.emplace_back(std::make_pair(VD, Var));
+}
+
+llvm::Function *CGHLSLRuntime::createResourceBindingInitFn() {
+  // No resources to bind
+  if (ResourcesToBind.empty())
+return nullptr;
+
+  LLVMContext &Ctx = CGM.getLLVMContext();
+
+  llvm::Function *InitResBindingsFunc =
+  llvm::Function::Create(llvm::FunctionType::get(CGM.VoidTy, false),
+ llvm::GlobalValue::InternalLinkage,
+ "_init_resource_bindings", CGM.getModule());
+
+  llvm::BasicBlock *EntryBB =
+  llvm::BasicBlock::Create(Ctx, "entry", InitResBindingsFunc);
+  CGBuilderTy Builder(CGM, Ctx);
+  const DataLayout &DL = CGM.getModule().getDataLayout();
+  Builder.SetInsertPoint(EntryBB);
+
+  for (auto I : ResourcesToBind) {

damyanp wrote:

```suggestion
  for (const auto &I : ResourcesToBind) {
```

Since ResourcesToBind's element type is a pair of pointers it probably doesn't 
make a real performance difference here, but whenever I see a `for (auto X : 
Foo)` pattern it rings alarm bells for me that someone might accidentally be 
copying values they didn't intend to copy, so I have to go look.

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


[clang] [llvm] [HLSL] Add handle initialization for simple resource declarations (PR #111207)

2024-10-14 Thread Damyan Pepper via cfe-commits


@@ -489,3 +494,100 @@ void CGHLSLRuntime::generateGlobalCtorDtorCalls() {
   GV->eraseFromParent();
   }
 }
+
+// Returns handle type of a resource, if the type is a resource
+// or an array of resources
+static const HLSLAttributedResourceType *findHandleTypeOnResource(QualType QT) 
{
+  // If the type is a resource class, the first field must
+  // be the resource handle of type HLSLAttributedResourceType
+  const clang::Type *Ty = QT->getUnqualifiedDesugaredType();
+  if (RecordDecl *RD = Ty->getAsCXXRecordDecl()) {
+if (!RD->fields().empty()) {
+  const auto &FirstFD = RD->fields().begin();
+  return dyn_cast(
+  FirstFD->getType().getTypePtr());
+}
+  }
+  return nullptr;
+}
+
+void CGHLSLRuntime::handleGlobalVarDefinition(const VarDecl *VD,
+  llvm::GlobalVariable *Var) {
+  // If the global variable has resource binding, add it to the list of globals
+  // that need resource binding initialization.
+  const HLSLResourceBindingAttr *RBA = VD->getAttr();
+  if (!RBA)
+return;
+
+  if (!findHandleTypeOnResource(VD->getType()))
+// FIXME: Only simple declarations of resources are supported for now.
+// Arrays of resources or resources in user defined classes are
+// not implemented yet.

damyanp wrote:

Is this case an assert on line 560?  Or is there something different about 
these two?

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


[clang] [llvm] [HLSL] Add handle initialization for simple resource declarations (PR #111207)

2024-10-14 Thread Damyan Pepper via cfe-commits


@@ -1121,6 +1121,11 @@ 
CodeGenFunction::GenerateCXXGlobalInitFunc(llvm::Function *Fn,
   if (Decls[i])
 EmitRuntimeCall(Decls[i]);
 
+if (getLangOpts().HLSL)
+  if (llvm::Function *ResInitFn =
+  CGM.getHLSLRuntime().createResourceBindingInitFn())

damyanp wrote:

Originally I asked: "What does it mean if `createResourceBindingInitFn` returns 
nullptr?" I asked this because I assumed that this function returning nullptr 
would indicate an error. I think it actually returns null if no function is 
needed? Wonder if this could be reflected in the name? Or maybe this is a 
common convention in this codebase?



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


[clang] [clang] Check null TypeSourceInfo in CreateUnaryExprOrTypeTraitExpr (PR #112111)

2024-10-14 Thread Andrew Sukach via cfe-commits

https://github.com/sookach updated 
https://github.com/llvm/llvm-project/pull/112111

>From d7a37cb7805d5ba982b8073c2485f16dec8a1eac Mon Sep 17 00:00:00 2001
From: Andrew Sukach 
Date: Sat, 12 Oct 2024 19:47:30 -0400
Subject: [PATCH] [clang] Check for null TypeSourceInfo in
 Sema::CreateUnaryExprOrTypeTraitExpr

---
 clang/docs/ReleaseNotes.rst   |  3 +++
 clang/lib/Sema/SemaExpr.cpp   |  3 +++
 .../unary-expr-or-type-trait-invalid.cpp  | 26 +++
 3 files changed, 32 insertions(+)
 create mode 100644 clang/test/SemaCXX/unary-expr-or-type-trait-invalid.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 763bc3ac159322..7a93259700ea4d 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -683,6 +683,9 @@ New features
 Crash and bug fixes
 ^^^
 
+- Check for a null ``TypeSourceInfo *`` when creating a 
``UnaryExprOrTypeTraitExpr``.
+  Fixes (#GH111594)
+
 Improvements
 
 
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 4e37385710af5e..b0bd216c5dc101 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -4629,6 +4629,9 @@ ExprResult 
Sema::CreateUnaryExprOrTypeTraitExpr(TypeSourceInfo *TInfo,
   TInfo->getType()->isVariablyModifiedType())
 TInfo = TransformToPotentiallyEvaluated(TInfo);
 
+  if (!TInfo)
+return ExprError();
+
   // C99 6.5.3.4p4: the type (an unsigned integer type) is size_t.
   return new (Context) UnaryExprOrTypeTraitExpr(
   ExprKind, TInfo, Context.getSizeType(), OpLoc, R.getEnd());
diff --git a/clang/test/SemaCXX/unary-expr-or-type-trait-invalid.cpp 
b/clang/test/SemaCXX/unary-expr-or-type-trait-invalid.cpp
new file mode 100644
index 00..bf7b6299078681
--- /dev/null
+++ b/clang/test/SemaCXX/unary-expr-or-type-trait-invalid.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+a() {struct b c (sizeof(b * [({ {tree->d* next)} 0
+
+// expected-error@3 {{a type specifier is required for all declarations}}
+// expected-error@3 {{use of undeclared identifier 'tree'; did you mean 
'true'?}}
+// expected-error@3 {{member reference type 'bool' is not a pointer}}
+// expected-error@3 {{expected ';' after expression}}
+// expected-error@3 {{use of undeclared identifier 'next'; did you mean 
'new'?}}
+// expected-error@3 {{expected expression}}
+// expected-error@3 {{expected ';' after expression}}
+// expected-error@26 {{expected '}'}}
+// expected-note@3 {{to match this '{'}}
+// expected-error@26 {{expected ')'}}
+// expected-note@3 {{to match this '('}}
+// expected-error@26 {{expected ']'}}
+// expected-note@3 {{to match this '['}}
+// expected-error@26 {{expected ')'}}
+// expected-note@3 {{to match this '('}}
+// expected-error@3 {{using declaration 'exp' instantiates to an empty pack}}
+// expected-error@3 {{variable has incomplete type 'struct b'}}
+// expected-note@3 {{forward declaration of 'b'}}
+// expected-error@3 {{expected ';' at end of declaration}}
+// expected-error@26 {{expected '}'}}
+// expected-note@3 {{to match this '{'}}
+// expected-warning@3 {{expression result unused}}

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


[clang] [llvm] [HLSL] Add handle initialization for simple resource declarations (PR #111207)

2024-10-14 Thread Damyan Pepper via cfe-commits


@@ -5622,6 +5622,9 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl 
*D,
 getCUDARuntime().handleVarRegistration(D, *GV);
   }
 
+  if (LangOpts.HLSL)
+getHLSLRuntime().handleGlobalVarDefinition(D, GV);

damyanp wrote:

Just checking you know that this has to work for non-globals as well? 
https://godbolt.org/z/MWzdTEb6q

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


[clang] [Clang][SYCL] Introduce clang-sycl-link-wrapper to link SYCL offloading device code (Part 1 of many) (PR #112245)

2024-10-14 Thread Arvind Sudarsanam via cfe-commits


@@ -0,0 +1,530 @@
+//=-- clang-sycl-link-wrapper/ClangSYCLLinkWrapper.cpp - SYCL linker util --=//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===-===//
+//
+// This tool wraps around the sequence of steps required to link device code in
+// SYCL fat objects. SYCL device code linking requires a complex sequence of
+// steps that include linking of llvm bitcode files, linking device library
+// files with the fully linked source bitcode file(s), running several SYCL
+// specific post-link steps on the fully linked bitcode file(s), and finally
+// generating target-specific device code. This tool can be removed once SYCL
+// linking is ported to `ld.lld`.
+//
+//===-===//
+
+#include "clang/Basic/Version.h"
+
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/BinaryFormat/Magic.h"
+#include "llvm/Bitcode/BitcodeWriter.h"
+#include "llvm/CodeGen/CommandFlags.h"
+#include "llvm/IR/DiagnosticPrinter.h"
+#include "llvm/IRReader/IRReader.h"
+#include "llvm/LTO/LTO.h"
+#include "llvm/Object/Archive.h"
+#include "llvm/Object/ArchiveWriter.h"
+#include "llvm/Object/Binary.h"
+#include "llvm/Object/ELFObjectFile.h"
+#include "llvm/Object/IRObjectFile.h"
+#include "llvm/Object/ObjectFile.h"
+#include "llvm/Object/OffloadBinary.h"
+#include "llvm/Option/ArgList.h"
+#include "llvm/Option/OptTable.h"
+#include "llvm/Option/Option.h"
+#include "llvm/Remarks/HotnessThresholdParser.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FileOutputBuffer.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/InitLLVM.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/Program.h"
+#include "llvm/Support/Signals.h"
+#include "llvm/Support/StringSaver.h"
+#include "llvm/Support/TargetSelect.h"
+#include "llvm/Support/TimeProfiler.h"
+#include "llvm/Support/WithColor.h"
+
+using namespace llvm;
+using namespace llvm::opt;
+using namespace llvm::object;
+
+/// Save intermediary results.
+static bool SaveTemps = false;
+
+/// Print arguments without executing.
+static bool DryRun = false;
+
+/// Print verbose output.
+static bool Verbose = false;
+
+/// Filename of the output being created.
+static StringRef OutputFile;
+
+/// Directory to dump SPIR-V IR if requested by user.
+static SmallString<128> SPIRVDumpDir;
+
+static void printVersion(raw_ostream &OS) {
+  OS << clang::getClangToolFullVersion("clang-sycl-link-wrapper") << '\n';
+}
+
+/// The value of `argv[0]` when run.
+static const char *Executable;
+
+/// Temporary files to be cleaned up.
+static SmallVector> TempFiles;
+
+namespace {
+// Must not overlap with llvm::opt::DriverFlag.
+enum WrapperFlags { WrapperOnlyOption = (1 << 4) };
+
+enum ID {
+  OPT_INVALID = 0, // This is not an option ID.
+#define OPTION(...) LLVM_MAKE_OPT_ID(__VA_ARGS__),
+#include "SYCLLinkOpts.inc"
+  LastOption
+#undef OPTION
+};
+
+#define PREFIX(NAME, VALUE)
\
+  static constexpr StringLiteral NAME##_init[] = VALUE;
\
+  static constexpr ArrayRef NAME(NAME##_init,   
\
+std::size(NAME##_init) - 1);
+#include "SYCLLinkOpts.inc"
+#undef PREFIX
+
+static constexpr OptTable::Info InfoTable[] = {

asudarsa wrote:

Most of the 'helper' routines getOptTable, createTempFile, etc are routines 
that have been borrowed from clang-linker-wrapper and clang-nvlink-wrapper. In 
an upcoming effort, we can try to create a single space for these routines to 
exist.

Thanks

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


[clang] [Clang][SYCL] Introduce clang-sycl-link-wrapper to link SYCL offloading device code (Part 1 of many) (PR #112245)

2024-10-14 Thread Arvind Sudarsanam via cfe-commits


@@ -0,0 +1,530 @@
+//=-- clang-sycl-link-wrapper/ClangSYCLLinkWrapper.cpp - SYCL linker util --=//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===-===//
+//
+// This tool wraps around the sequence of steps required to link device code in
+// SYCL fat objects. SYCL device code linking requires a complex sequence of
+// steps that include linking of llvm bitcode files, linking device library
+// files with the fully linked source bitcode file(s), running several SYCL
+// specific post-link steps on the fully linked bitcode file(s), and finally
+// generating target-specific device code. This tool can be removed once SYCL
+// linking is ported to `ld.lld`.
+//
+//===-===//
+
+#include "clang/Basic/Version.h"
+
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/BinaryFormat/Magic.h"
+#include "llvm/Bitcode/BitcodeWriter.h"
+#include "llvm/CodeGen/CommandFlags.h"
+#include "llvm/IR/DiagnosticPrinter.h"
+#include "llvm/IRReader/IRReader.h"
+#include "llvm/LTO/LTO.h"
+#include "llvm/Object/Archive.h"
+#include "llvm/Object/ArchiveWriter.h"
+#include "llvm/Object/Binary.h"
+#include "llvm/Object/ELFObjectFile.h"
+#include "llvm/Object/IRObjectFile.h"
+#include "llvm/Object/ObjectFile.h"
+#include "llvm/Object/OffloadBinary.h"
+#include "llvm/Option/ArgList.h"
+#include "llvm/Option/OptTable.h"
+#include "llvm/Option/Option.h"
+#include "llvm/Remarks/HotnessThresholdParser.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FileOutputBuffer.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/InitLLVM.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/Program.h"
+#include "llvm/Support/Signals.h"
+#include "llvm/Support/StringSaver.h"
+#include "llvm/Support/TargetSelect.h"
+#include "llvm/Support/TimeProfiler.h"
+#include "llvm/Support/WithColor.h"
+
+using namespace llvm;
+using namespace llvm::opt;
+using namespace llvm::object;
+
+/// Save intermediary results.
+static bool SaveTemps = false;
+
+/// Print arguments without executing.
+static bool DryRun = false;
+
+/// Print verbose output.
+static bool Verbose = false;
+
+/// Filename of the output being created.
+static StringRef OutputFile;
+
+/// Directory to dump SPIR-V IR if requested by user.
+static SmallString<128> SPIRVDumpDir;
+
+static void printVersion(raw_ostream &OS) {
+  OS << clang::getClangToolFullVersion("clang-sycl-link-wrapper") << '\n';
+}
+
+/// The value of `argv[0]` when run.
+static const char *Executable;
+
+/// Temporary files to be cleaned up.
+static SmallVector> TempFiles;
+
+namespace {
+// Must not overlap with llvm::opt::DriverFlag.
+enum WrapperFlags { WrapperOnlyOption = (1 << 4) };
+
+enum ID {
+  OPT_INVALID = 0, // This is not an option ID.
+#define OPTION(...) LLVM_MAKE_OPT_ID(__VA_ARGS__),
+#include "SYCLLinkOpts.inc"
+  LastOption
+#undef OPTION
+};
+
+#define PREFIX(NAME, VALUE)
\
+  static constexpr StringLiteral NAME##_init[] = VALUE;
\
+  static constexpr ArrayRef NAME(NAME##_init,   
\
+std::size(NAME##_init) - 1);
+#include "SYCLLinkOpts.inc"
+#undef PREFIX
+
+static constexpr OptTable::Info InfoTable[] = {
+#define OPTION(...) LLVM_CONSTRUCT_OPT_INFO(__VA_ARGS__),
+#include "SYCLLinkOpts.inc"
+#undef OPTION
+};
+
+class WrapperOptTable : public opt::GenericOptTable {
+public:
+  WrapperOptTable() : opt::GenericOptTable(InfoTable) {}
+};
+
+const OptTable &getOptTable() {
+  static const WrapperOptTable *Table = []() {
+auto Result = std::make_unique();
+return Result.release();
+  }();
+  return *Table;
+}
+
+[[noreturn]] void reportError(Error E) {
+  outs().flush();
+  logAllUnhandledErrors(std::move(E), WithColor::error(errs(), Executable));
+  exit(EXIT_FAILURE);
+}
+
+std::string getMainExecutable(const char *Name) {
+  void *Ptr = (void *)(intptr_t)&getMainExecutable;
+  auto COWPath = sys::fs::getMainExecutable(Name, Ptr);
+  return sys::path::parent_path(COWPath).str();
+}
+
+Expected createTempFile(const ArgList &Args, const Twine &Prefix,
+   StringRef Extension) {
+  SmallString<128> OutputFile;
+  if (Args.hasArg(OPT_save_temps)) {
+// Generate a unique path name without creating a file
+sys::fs::createUniquePath(Prefix + "-%%." + Extension, OutputFile,
+  /*MakeAbsolute=*/false);
+  } else {
+if (std::error_code EC =
+sys::fs::createTemporaryFile(Prefix, Extension, OutputFile))
+  return createFileError(OutputFile, EC);
+  }
+
+  TempFiles.emplace_back(std::move(OutputFil

[clang] [llvm] Add ifunc support for Windows on AArch64. (PR #111962)

2024-10-14 Thread Daniel Kiss via cfe-commits

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

>From 122864160f098392c4afd1728eb924e7e26e70d9 Mon Sep 17 00:00:00 2001
From: Daniel Kiss 
Date: Tue, 8 Oct 2024 22:58:37 +0200
Subject: [PATCH 1/3] Add ifuncs support for Windows.

---
 clang/include/clang/Basic/Attr.td |  5 +-
 clang/include/clang/Basic/AttrDocs.td |  6 +-
 clang/include/clang/Basic/TargetInfo.h|  4 ++
 clang/test/CodeGen/attr-ifunc.c   |  4 +-
 clang/test/CodeGen/ifunc-win.c| 69 +++
 clang/test/CodeGen/ifunc.c|  5 ++
 .../Target/AArch64/AArch64TargetMachine.cpp   |  6 ++
 7 files changed, 95 insertions(+), 4 deletions(-)
 create mode 100644 clang/test/CodeGen/ifunc-win.c

diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index ec3d6e0079f630..c0a540d3890487 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -477,6 +477,9 @@ def TargetELF : TargetSpec {
 def TargetELFOrMachO : TargetSpec {
   let ObjectFormats = ["ELF", "MachO"];
 }
+def TargetIFuncSupport : TargetSpec {
+  let CustomCode = [{ Target.supportsIFunc() }];
+}
 def TargetWindowsArm64EC : TargetSpec {
   let CustomCode = [{ Target.getTriple().isWindowsArm64EC() }];
 }
@@ -1847,7 +1850,7 @@ def IBOutletCollection : InheritableAttr {
   let Documentation = [Undocumented];
 }
 
-def IFunc : Attr, TargetSpecificAttr {
+def IFunc : Attr, TargetSpecificAttr {
   let Spellings = [GCC<"ifunc">];
   let Args = [StringArgument<"Resolver">];
   let Subjects = SubjectList<[Function]>;
diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index b1512e22ee2dd4..5179f30400345d 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -5800,8 +5800,10 @@ Not all targets support this attribute. ELF target 
support depends on both the
 linker and runtime linker, and is available in at least lld 4.0 and later,
 binutils 2.20.1 and later, glibc v2.11.1 and later, and FreeBSD 9.1 and later.
 Mach-O targets support it, but with slightly different semantics: the resolver
-is run at first call, instead of at load time by the runtime linker. Targets
-other than ELF and Mach-O currently do not support this attribute.
+is run at first call, instead of at load time by the runtime linker. Windows on
+AArch64 the ``ifunc`` is replaced with global function pointer and the call is
+replaced by an indirect call. The pointer is initialized by a contructor that
+calls the resolver. Other targets currently do not support this attribute.
   }];
 }
 
diff --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index 57783850606290..9d2d7be7cfbd78 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -1505,6 +1505,10 @@ class TargetInfo : public TransferrableTargetInfo,
   bool supportsIFunc() const {
 if (getTriple().isOSBinFormatMachO())
   return true;
+if (getTriple().isOSWindows() && getTriple().isAArch64())
+  return true;
+if (getTriple().getArch() == llvm::Triple::ArchType::avr)
+  return true;
 return getTriple().isOSBinFormatELF() &&
((getTriple().isOSLinux() && !getTriple().isMusl()) ||
 getTriple().isOSFreeBSD());
diff --git a/clang/test/CodeGen/attr-ifunc.c b/clang/test/CodeGen/attr-ifunc.c
index 24d66433ae090f..c9e70b17a83023 100644
--- a/clang/test/CodeGen/attr-ifunc.c
+++ b/clang/test/CodeGen/attr-ifunc.c
@@ -2,8 +2,10 @@
 // RUN: %clang_cc1 -triple x86_64-linux -verify -emit-llvm-only 
-DCHECK_ALIASES %s
 // RUN: %clang_cc1 -triple x86_64-linux -verify -emit-llvm-only %s
 // RUN: %clang_cc1 -triple x86_64-apple-macosx -verify -emit-llvm-only %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -verify -emit-llvm-only %s
+// RUN: %clang_cc1 -triple aarch64-pc-windows-msvcu -verify -emit-llvm-only %s
 
-#if defined(_WIN32)
+#if defined(_WIN32) && !defined(__aarch64__)
 void foo(void) {}
 void bar(void) __attribute__((ifunc("foo")));
 // expected-warning@-1 {{unknown attribute 'ifunc' ignored}}
diff --git a/clang/test/CodeGen/ifunc-win.c b/clang/test/CodeGen/ifunc-win.c
new file mode 100644
index 00..d8a94df90fc603
--- /dev/null
+++ b/clang/test/CodeGen/ifunc-win.c
@@ -0,0 +1,69 @@
+// RUN: %clang_cc1 -triple aarch64-pc-windows-msvc -emit-llvm -o - %s | 
FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-pc-windows-msvc -O2 -emit-llvm -o - %s | 
FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-pc-windows-msvc -fsanitize=thread -O2 
-emit-llvm -o - %s | FileCheck %s --check-prefix=SAN
+// RUN: %clang_cc1 -triple aarch64-pc-windows-msvc -fsanitize=address -O2 
-emit-llvm -o - %s | FileCheck %s --check-prefix=SAN
+
+/// The ifunc is emitted before its resolver.
+int foo(int) __attribute__ ((ifunc("foo_ifunc")));
+
+static int f1(int i) {
+  return i + 1;
+}
+
+static int f2(int i)

[clang] [llvm] Add ifunc support for Windows on AArch64. (PR #111962)

2024-10-14 Thread Daniel Kiss via cfe-commits

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


[clang] [Clang][SYCL] Introduce clang-sycl-link-wrapper to link SYCL offloading device code (Part 1 of many) (PR #112245)

2024-10-14 Thread Arvind Sudarsanam via cfe-commits

https://github.com/asudarsa updated 
https://github.com/llvm/llvm-project/pull/112245

>From eff4a0300336c4c106e1d293b19e795f5ccbabc1 Mon Sep 17 00:00:00 2001
From: Arvind Sudarsanam 
Date: Fri, 27 Sep 2024 13:03:12 -0700
Subject: [PATCH 1/2] [Clang][SYCL] Introduce clang-sycl-link-wrapper to link
 SYCL offloading device code

This PR is one of the many PRs in the SYCL upstreaming effort focusing on
device code linking during the SYCL offload compilation process.
RFC: 
https://discourse.llvm.org/t/rfc-offloading-design-for-sycl-offload-kind-and-spir-targets/74088

In this PR, we introduce a new tool that will be used to perform device code
linking for SYCL offload kind. It accepts SYCL device objects in LLVM IR bitcode
format and will generate a fully linked device object that can then be wrapped
and linked into the host object.

A primary use case for this tool is to perform device code linking for objects
with SYCL offload kind inside the clang-linker-wrapper.
It can also be invoked via clang driver as follows:

`clang --target=spirv64 --sycl-link input.bc`

Device code linking for SYCL offloading kind has a number of known quirks that
makes it difficult to use in a unified offloading setting.
Two of the primary issues are:
1. Several finalization steps are required to be run on the fully-linked LLVM
IR bitcode to gaurantee conformance to SYCL standards. This step is unique to
SYCL offloading compilation flow.
2. SPIR-V LLVM Translator tool is an extenal tool and hence SPIR-V IR code
generation cannot be done as part of LTO. This limitation will be lifted once
SPIR-V backend is available as a viable LLVM backend.

Hence, we introduce this new tool to provide a clean wrapper to perform SYCL
device linking.

Thanks

Signed-off-by: Arvind Sudarsanam 
---
 clang/docs/ClangSYCLLinkWrapper.rst   |  80 +++
 clang/docs/index.rst  |   1 +
 clang/include/clang/Driver/Options.td |   5 +-
 clang/lib/Driver/Driver.cpp   |   5 +
 clang/lib/Driver/ToolChains/SPIRV.cpp |  12 +
 clang/lib/Driver/ToolChains/SPIRV.h   |   5 +-
 clang/test/Driver/Inputs/libsycl-complex.bc   |   0
 clang/test/Driver/Inputs/libsycl-crt.bc   |   0
 .../Driver/clang-sycl-link-wrapper-test.cpp   |   9 +
 clang/test/Driver/sycl-link-spirv-target.cpp  |   7 +
 clang/tools/CMakeLists.txt|   1 +
 .../clang-sycl-link-wrapper/CMakeLists.txt|  28 +
 .../ClangSYCLLinkWrapper.cpp  | 530 ++
 .../clang-sycl-link-wrapper/SYCLLinkOpts.td   |  47 ++
 14 files changed, 727 insertions(+), 3 deletions(-)
 create mode 100644 clang/docs/ClangSYCLLinkWrapper.rst
 create mode 100644 clang/test/Driver/Inputs/libsycl-complex.bc
 create mode 100644 clang/test/Driver/Inputs/libsycl-crt.bc
 create mode 100644 clang/test/Driver/clang-sycl-link-wrapper-test.cpp
 create mode 100644 clang/test/Driver/sycl-link-spirv-target.cpp
 create mode 100644 clang/tools/clang-sycl-link-wrapper/CMakeLists.txt
 create mode 100644 clang/tools/clang-sycl-link-wrapper/ClangSYCLLinkWrapper.cpp
 create mode 100644 clang/tools/clang-sycl-link-wrapper/SYCLLinkOpts.td

diff --git a/clang/docs/ClangSYCLLinkWrapper.rst 
b/clang/docs/ClangSYCLLinkWrapper.rst
new file mode 100644
index 00..8ceb17f6af9d86
--- /dev/null
+++ b/clang/docs/ClangSYCLLinkWrapper.rst
@@ -0,0 +1,80 @@
+===
+Clang SYCL Link Wrapper
+===
+
+.. contents::
+   :local:
+
+.. _clang-sycl-link-wrapper:
+
+Introduction
+
+
+This tool works as a wrapper around the SYCL device code linking process.
+The purpose of this wrapper is to provide an interface to link SYCL device
+bitcode in LLVM IR format, SYCL device bitcode in SPIR-V IR format, and native
+binary objects, and then use the SPIR-V LLVM Translator tool on fully linked
+device objects to produce the final output.
+After the linking stage, the fully linked device code in LLVM IR format may
+undergo several SYCL-specific finalization steps before the SPIR-V code
+generation step.
+The wrapper will also support the Ahead-Of-Time (AOT) compilation flow. AOT
+compilation is the process of invoking the back-end at compile time to produce
+the final binary, as opposed to just-in-time (JIT) compilation when final code
+generation is deferred until application runtime.
+
+Device code linking for SYCL offloading has several known quirks that
+make it difficult to use in a unified offloading setting. Two of the primary
+issues are:
+1. Several finalization steps are required to be run on the fully linked LLVM
+IR bitcode to guarantee conformance to SYCL standards. This step is unique to
+the SYCL offloading compilation flow.
+2. The SPIR-V LLVM Translator tool is an external tool and hence SPIR-V IR code
+generation cannot be done as part of LTO. This limitation can be lifted once
+the SPIR-V backend is available as a viable LLVM backend.
+
+This tool has been proposed to work around these issu

[clang] [LinkerWrapper] Extract device archives if symbol is used on the host (PR #111921)

2024-10-14 Thread Joseph Huber via cfe-commits

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


[clang] [NvlinkWrapper] Use `-plugin-opt=mattr=` instead of a custom feature (PR #111712)

2024-10-14 Thread Joseph Huber via cfe-commits

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


[clang] [Headers] [ARM64EC] Fix extra tokens inside intrin0.h preprocessor directive (PR #112066)

2024-10-14 Thread Max Winkler via cfe-commits

MaxEW707 wrote:

@efriedma-quic What is the process for getting a fix into a milestone such as 
the upcoming 19.1.2 milestone. I read the docs on `cherry-pick` but I couldn't 
find any information about who decides what is considered suitable for a patch 
release.
I am going to defer to you if you think this is worthwhile for 19.1.2 and if so 
what are the next steps to make that happen.

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


  1   2   3   4   5   6   >