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
@@ -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
@@ -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
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
@@ -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
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
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
@@ -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
@@ -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
@@ -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
@@ -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
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
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
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
@@ -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
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
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:]]*
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)
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
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:

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
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)
+
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
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
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
@@ -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
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
@@ -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
@@ -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
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
@@ -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
@@ -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
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
@@ -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
@@ -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
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
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
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
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
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
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
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
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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
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
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