[llvm-branch-commits] [lld] 2f23d4b - ReleaseNotes: add lld/ELF notes

2022-02-14 Thread Fangrui Song via llvm-branch-commits

Author: Fangrui Song
Date: 2022-02-14T11:13:11-08:00
New Revision: 2f23d4b0ac0aba4629fa484264b4e5b52bf774ca

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

LOG: ReleaseNotes: add lld/ELF notes

For the release/14.x branch.

Differential Revision: https://reviews.llvm.org/D119318

Added: 


Modified: 
lld/docs/ReleaseNotes.rst

Removed: 




diff  --git a/lld/docs/ReleaseNotes.rst b/lld/docs/ReleaseNotes.rst
index f611da428a8fe..ed4a374d579a3 100644
--- a/lld/docs/ReleaseNotes.rst
+++ b/lld/docs/ReleaseNotes.rst
@@ -30,30 +30,78 @@ ELF Improvements
   (`D107317 `_)
 * ``--why-extract`` has been added to query why archive members/lazy object 
files are extracted.
   (`D109572 `_)
-* ``e_entry`` no longer falls back to the address of ``.text`` if the entry 
symbol does not exist.
-  Instead, a value of 0 will be written.
-  (`D110014 `_)
 * If ``-Map`` is specified, ``--cref`` will be printed to the specified file.
   (`D114663 `_)
+* ``-z bti-report`` and ``-z cet-report`` are now supported.
+  (`D113901 `_)
+* ``--lto-pgo-warn-mismatch`` has been added.
+  (`D104431 `_)
+* Archives without an index (symbol table) are now supported and work with
+  ``--warn-backrefs``. One may build such an archive with ``llvm-ar rcS
+  [--thin]`` to save space.
+  (`D117284 `_)
+  The archive index may be `entirely ignored 
`
+  in a future release.
 * No longer deduplicate local symbol names at the default optimization level 
of ``-O1``.
   This results in a larger ``.strtab`` (usually less than 1%) but a faster link
-  time. Use optimization level ``-O2`` to restore the deduplication.
+  time. Use optimization level ``-O2`` to restore the deduplication. The 
``-O2``
+  deduplication may be dropped in the future to help parallel ``.symtab`` 
write.
+* In relocatable output, relocations to discarded symbols now use tombstone
+  values.
+  (`D116946 `_)
+* Orphan section placement now picks a more suitable segment. Previously the
+  algorithm might pick a readonly segment for a writable orphan section and 
make
+  the segment writable.
+  (`D111717 `_)
+* An empty output section moved by an ``INSERT`` comment now gets appropriate
+  flags.
+  (`D118529 `_)
+* Negation in a memory region attribute is now correctly handled.
+  (`D113771 `_)
+* ``--compress-debug-sections=zlib`` is now run in parallel. ``{clang,gcc} 
-gz`` link
+  actions are significantly faster.
+  (`D117853 `_)
+* "relocation out of range" diagnostics and a few uncommon diagnostics
+  now report an object file location beside a source file location.
+  (`D112518 `_)
+* The write of ``.rela.dyn`` and ``SHF_MERGE|SHF_STRINGS`` sections (e.g.
+  ``.debug_str``) is now run in parallel.
 
 Architecture specific changes:
 
+* The AArch64 port now supports adrp+ldr and adrp+add optimizations.
+  ``--no-relax`` can suppress the optimization.
+  (`D112063 `_)
+  (`D117614 `_)
 * The x86-32 port now supports TLSDESC (``-mtls-dialect=gnu2``).
   (`D112582 `_)
 * The x86-64 port now handles non-RAX/non-adjacent ``R_X86_64_GOTPC32_TLSDESC``
   and ``R_X86_64_TLSDESC_CALL`` (``-mtls-dialect=gnu2``).
   (`D114416 `_)
+* The x86-32 and x86-64 ports now support mixed TLSDESC and TLS GD, i.e. mixing
+  objects compiled with and without ``-mtls-dialect=gnu2`` referencing the same
+  TLS variable is now supported.
+  (`D114416 `_)
 * For x86-64, ``--no-relax`` now suppresses ``R_X86_64_GOTPCRELX`` and
   ``R_X86_64_REX_GOTPCRELX`` GOT optimization
   (`D113615 `_)
+* ``R_X86_64_PLTOFF64`` is now supported.
+  (`D112386 `_)
+* ``R_AARCH64_NONE``, ``R_PPC_NONE``, and ``R_PPC64_NONE`` in input REL
+  relocation sections are now supported.
 
 Breaking changes
 
 
-* ...
+* ``e_entry`` no longer falls back to the address of ``.text`` if the entry 
symbol does not exist.
+  Instead, a value of 0 will be written.
+  (`D110014 `_)
+* ``--lto-pseudo-probe-for-profiling`` has been removed. In LTO, the compiler
+  enables this feature automatically.
+  (`D110209 `_)
+* Use of

[llvm-branch-commits] [clang] 24bf96c - ReleaseNotes: add some clang notes

2022-02-14 Thread Fangrui Song via llvm-branch-commits

Author: Fangrui Song
Date: 2022-02-14T11:52:55-08:00
New Revision: 24bf96cda6cccaea4f0f95a2ce20df39a94c07ae

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

LOG: ReleaseNotes: add some clang notes

Added: 


Modified: 
clang/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index c8596fcfdc989..899165b842b58 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -85,6 +85,8 @@ New Compiler Flags
   allow silencing warnings about unused arguments for only a subset of
   the command line arguments, keeping potential warnings for other arguments
   outside of such a region.
+- ``-falign-loops=N`` (N is a power of 2) is now supported for non-LTO cases.
+  (`D106701 `_)
 
 Deprecated Compiler Flags
 -
@@ -116,9 +118,14 @@ Modified Compiler Flags
   - Armv9.1-A (``armv9.1-a``).
   - Armv9.2-A (``armv9.2-a``).
 
+- ``-r`` now implies ``-nostdlib`` for many toolchains, matching GCC.
+  (`D116843 `_)
+
 Removed Compiler Flags
 -
 
+- The legacy ``-gz=zlib-gnu`` and ``-Wa,--compress-debug-sections=zlib-gnu``
+  have been removed.
 - ``-fno-experimental-new-pass-manager`` has been removed.
   ``-flegacy-pass-manager`` can be used as a makeshift,
   Using the legacy pass manager for the optimization pipeline was deprecated in



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


[llvm-branch-commits] [llvm] 4384a21 - ReleaseNotes: mention removal of Intel MPX

2022-02-14 Thread Fangrui Song via llvm-branch-commits

Author: Fangrui Song
Date: 2022-02-14T12:00:05-08:00
New Revision: 4384a21fdcaa315a083db2b4b4bcd63b7e6555fc

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

LOG: ReleaseNotes: mention removal of Intel MPX

Added: 


Modified: 
llvm/docs/ReleaseNotes.rst

Removed: 




diff  --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst
index f513b620066a1..08ebd6c092f5f 100644
--- a/llvm/docs/ReleaseNotes.rst
+++ b/llvm/docs/ReleaseNotes.rst
@@ -113,6 +113,8 @@ Changes to the X86 Target
 During this release ...
 
 * Support for ``AVX512-FP16`` instructions has been added.
+* Removed incomplete support for Intel MPX.
+  (`D111517 `_)
 
 Changes to the AMDGPU Target
 -



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


[llvm-branch-commits] [llvm] ee75c76 - [Attributor][FIX] Honor alloca address space in AAPrivatizablePtr

2022-02-14 Thread Tom Stellard via llvm-branch-commits

Author: Johannes Doerfert
Date: 2022-02-14T14:09:14-08:00
New Revision: ee75c7698dc36178e60f030bbdfcbe060ced1984

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

LOG: [Attributor][FIX] Honor alloca address space in AAPrivatizablePtr

When we privatize a pointer (~argument promotion) we introduce new
private allocas as replacement. These need to be placed in the alloca
address space as later passes cannot properly deal with them otherwise.

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

(cherry picked from commit e39b41931264d9f774dbe151bb64f4b579cf1ee0)

Added: 
llvm/test/Transforms/Attributor/ArgumentPromotion/alloca-as.ll

Modified: 
llvm/lib/Transforms/IPO/AttributorAttributes.cpp

Removed: 




diff  --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp 
b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
index db2ba91bea589..4e4f768ed2cbd 100644
--- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
@@ -236,7 +236,8 @@ static Value *constructPointer(Type *ResTy, Type 
*PtrElemTy, Value *Ptr,
   }
 
   // Ensure the result has the requested type.
-  Ptr = IRB.CreateBitOrPointerCast(Ptr, ResTy, Ptr->getName() + ".cast");
+  Ptr = IRB.CreatePointerBitCastOrAddrSpaceCast(Ptr, ResTy,
+Ptr->getName() + ".cast");
 
   LLVM_DEBUG(dbgs() << "Constructed pointer: " << *Ptr << "\n");
   return Ptr;
@@ -6748,8 +6749,8 @@ struct AAPrivatizablePtrArgument final : public 
AAPrivatizablePtrImpl {
 
 Type *PrivPtrType = PrivType->getPointerTo();
 if (Base->getType() != PrivPtrType)
-  Base = BitCastInst::CreateBitOrPointerCast(Base, PrivPtrType, "",
- ACS.getInstruction());
+  Base = BitCastInst::CreatePointerBitCastOrAddrSpaceCast(
+  Base, PrivPtrType, "", ACS.getInstruction());
 
 // Traverse the type, build GEPs and loads.
 if (auto *PrivStructType = dyn_cast(PrivType)) {
@@ -6816,14 +6817,16 @@ struct AAPrivatizablePtrArgument final : public 
AAPrivatizablePtrImpl {
 Function &ReplacementFn, Function::arg_iterator ArgIt) {
   BasicBlock &EntryBB = ReplacementFn.getEntryBlock();
   Instruction *IP = &*EntryBB.getFirstInsertionPt();
-  Instruction *AI = new AllocaInst(PrivatizableType.getValue(), 0,
+  const DataLayout &DL = IP->getModule()->getDataLayout();
+  unsigned AS = DL.getAllocaAddrSpace();
+  Instruction *AI = new AllocaInst(PrivatizableType.getValue(), AS,
Arg->getName() + ".priv", IP);
   createInitialization(PrivatizableType.getValue(), *AI, ReplacementFn,
ArgIt->getArgNo(), *IP);
 
   if (AI->getType() != Arg->getType())
-AI =
-BitCastInst::CreateBitOrPointerCast(AI, Arg->getType(), "", 
IP);
+AI = BitCastInst::CreatePointerBitCastOrAddrSpaceCast(
+AI, Arg->getType(), "", IP);
   Arg->replaceAllUsesWith(AI);
 
   for (CallInst *CI : TailCalls)

diff  --git a/llvm/test/Transforms/Attributor/ArgumentPromotion/alloca-as.ll 
b/llvm/test/Transforms/Attributor/ArgumentPromotion/alloca-as.ll
new file mode 100644
index 0..883e23f4eb865
--- /dev/null
+++ b/llvm/test/Transforms/Attributor/ArgumentPromotion/alloca-as.ll
@@ -0,0 +1,78 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 
UTC_ARGS: --function-signature --check-attributes --check-globals
+; RUN: opt -attributor -enable-new-pm=0 -attributor-manifest-internal  
-attributor-max-iterations-verify -attributor-annotate-decl-cs 
-attributor-max-iterations=3 -S < %s | FileCheck %s 
--check-prefixes=CHECK,NOT_CGSCC_NPM,NOT_CGSCC_OPM,NOT_TUNIT_NPM,IS__TUNIT,ISOPM,IS__TUNIT_OPM
+; RUN: opt -aa-pipeline=basic-aa -passes=attributor 
-attributor-manifest-internal  -attributor-max-iterations-verify 
-attributor-annotate-decl-cs -attributor-max-iterations=3 -S < %s | FileCheck 
%s 
--check-prefixes=CHECK,NOT_CGSCC_OPM,NOT_CGSCC_NPM,NOT_TUNIT_OPM,IS__TUNIT,ISNPM,IS__TUNIT_NPM
+; RUN: opt -attributor-cgscc -enable-new-pm=0 -attributor-manifest-internal  
-attributor-annotate-decl-cs -S < %s | FileCheck %s 
--check-prefixes=CHECK,NOT_TUNIT_NPM,NOT_TUNIT_OPM,NOT_CGSCC_NPM,IS__CGSCC,ISOPM,IS__CGSCC_OPM
+; RUN: opt -aa-pipeline=basic-aa -passes=attributor-cgscc 
-attributor-manifest-internal  -attributor-annotate-decl-cs -S < %s | FileCheck 
%s 
--check-prefixes=CHECK,NOT_TUNIT_NPM,NOT_TUNIT_OPM,NOT_CGSCC_OPM,IS__CGSCC,ISNPM,IS__CGSCC_NPM
+
+target datalayout = "A7"
+
+; Make sure we create allocas in AS 7 and cast them properly.
+
+define i32 @b

[llvm-branch-commits] [llvm] 66c59c0 - [X86] Only force FP usage in the presence of pushf/popf on Win64

2022-02-14 Thread Tom Stellard via llvm-branch-commits

Author: Reid Kleckner
Date: 2022-02-14T14:09:52-08:00
New Revision: 66c59c0e5bb7b0e89dc9e77a36be09c7f3cc8f5c

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

LOG: [X86] Only force FP usage in the presence of pushf/popf on Win64

This ensures that the Windows unwinder will work at every instruction
boundary, and allows other targets to read and write flags without
setting up a frame pointer.

Fixes GH-46875

Differential Revision: https://reviews.llvm.org/D119391

(cherry picked from commit f3481f43bbe2c8a24e74210d310cf3be291bf52d)

Added: 


Modified: 
llvm/lib/Target/X86/X86FrameLowering.cpp
llvm/test/CodeGen/X86/x86-64-flags-intrinsics.ll
llvm/test/CodeGen/X86/x86-flags-intrinsics.ll

Removed: 




diff  --git a/llvm/lib/Target/X86/X86FrameLowering.cpp 
b/llvm/lib/Target/X86/X86FrameLowering.cpp
index 51f2ced321bb7..0971a0e33f98b 100644
--- a/llvm/lib/Target/X86/X86FrameLowering.cpp
+++ b/llvm/lib/Target/X86/X86FrameLowering.cpp
@@ -99,7 +99,7 @@ bool X86FrameLowering::hasFP(const MachineFunction &MF) const 
{
   MF.getInfo()->hasPreallocatedCall() ||
   MF.callsUnwindInit() || MF.hasEHFunclets() || MF.callsEHReturn() ||
   MFI.hasStackMap() || MFI.hasPatchPoint() ||
-  MFI.hasCopyImplyingStackAdjustment());
+  (isWin64Prologue(MF) && MFI.hasCopyImplyingStackAdjustment()));
 }
 
 static unsigned getSUBriOpcode(bool IsLP64, int64_t Imm) {
@@ -1289,6 +1289,9 @@ bool X86FrameLowering::has128ByteRedZone(const 
MachineFunction& MF) const {
   return Is64Bit && !IsWin64CC && !Fn.hasFnAttribute(Attribute::NoRedZone);
 }
 
+/// Return true if we need to use the restricted Windows x64 prologue and
+/// epilogue code patterns that can be described with WinCFI (.seh_*
+/// directives).
 bool X86FrameLowering::isWin64Prologue(const MachineFunction &MF) const {
   return MF.getTarget().getMCAsmInfo()->usesWindowsCFI();
 }

diff  --git a/llvm/test/CodeGen/X86/x86-64-flags-intrinsics.ll 
b/llvm/test/CodeGen/X86/x86-64-flags-intrinsics.ll
index 2cc64685552df..5460f36fca670 100644
--- a/llvm/test/CodeGen/X86/x86-64-flags-intrinsics.ll
+++ b/llvm/test/CodeGen/X86/x86-64-flags-intrinsics.ll
@@ -1,37 +1,54 @@
-; RUN: llc -verify-machineinstrs < %s | FileCheck %s
-target triple = "x86_64-pc-win32"
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple x86_64-linux < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -mtriple x86_64-windows < %s | FileCheck %s 
--check-prefix=WIN64
 
 declare i64 @llvm.x86.flags.read.u64()
 declare void @llvm.x86.flags.write.u64(i64)
 
 define i64 @read_flags() {
+; CHECK-LABEL: read_flags:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:pushfq
+; CHECK-NEXT:popq %rax
+; CHECK-NEXT:retq
+;
+; WIN64-LABEL: read_flags:
+; WIN64:   # %bb.0: # %entry
+; WIN64-NEXT:pushq %rbp
+; WIN64-NEXT:.seh_pushreg %rbp
+; WIN64-NEXT:movq %rsp, %rbp
+; WIN64-NEXT:.seh_setframe %rbp, 0
+; WIN64-NEXT:.seh_endprologue
+; WIN64-NEXT:pushfq
+; WIN64-NEXT:popq %rax
+; WIN64-NEXT:popq %rbp
+; WIN64-NEXT:retq
+; WIN64-NEXT:.seh_endproc
 entry:
   %flags = call i64 @llvm.x86.flags.read.u64()
   ret i64 %flags
 }
 
-; CHECK-LABEL: read_flags:
-; CHECK:  pushq   %rbp
-; CHECK:  .seh_pushreg %rbp
-; CHECK:  movq%rsp, %rbp
-; CHECK:  .seh_setframe %rbp, 0
-; CHECK:  .seh_endprologue
-; CHECK-NEXT: pushfq
-; CHECK-NEXT: popq%rax
-; CHECK-NEXT: popq%rbp
-
 define void @write_flags(i64 %arg) {
+; CHECK-LABEL: write_flags:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:pushq %rdi
+; CHECK-NEXT:popfq
+; CHECK-NEXT:retq
+;
+; WIN64-LABEL: write_flags:
+; WIN64:   # %bb.0: # %entry
+; WIN64-NEXT:pushq %rbp
+; WIN64-NEXT:.seh_pushreg %rbp
+; WIN64-NEXT:movq %rsp, %rbp
+; WIN64-NEXT:.seh_setframe %rbp, 0
+; WIN64-NEXT:.seh_endprologue
+; WIN64-NEXT:pushq %rcx
+; WIN64-NEXT:popfq
+; WIN64-NEXT:popq %rbp
+; WIN64-NEXT:retq
+; WIN64-NEXT:.seh_endproc
 entry:
   call void @llvm.x86.flags.write.u64(i64 %arg)
   ret void
 }
-
-; CHECK-LABEL: write_flags:
-; CHECK:  pushq   %rbp
-; CHECK:  .seh_pushreg %rbp
-; CHECK:  movq%rsp, %rbp
-; CHECK:  .seh_setframe %rbp, 0
-; CHECK:  .seh_endprologue
-; CHECK-NEXT: pushq   %rcx
-; CHECK-NEXT: popfq
-; CHECK-NEXT: popq%rbp

diff  --git a/llvm/test/CodeGen/X86/x86-flags-intrinsics.ll 
b/llvm/test/CodeGen/X86/x86-flags-intrinsics.ll
index e2233aec22c7c..67cf0ef6e8b8f 100644
--- a/llvm/test/CodeGen/X86/x86-flags-intrinsics.ll
+++ b/llvm/test/CodeGen/X86/x86-flags-intrinsics.ll
@@ -1,6 +1,10 @@
 ; RUN: llc -verify-machineinstrs < %s | FileCheck %s
 target triple = "i686-pc-win32"
 
+; Che

[llvm-branch-commits] [llvm] 92f6212 - [test-release.sh] Add option to disable building clang-tools-extra during release testing.

2022-02-14 Thread Tom Stellard via llvm-branch-commits

Author: Amy Kwan
Date: 2022-02-14T14:10:19-08:00
New Revision: 92f6212d3cdbb13557520c5b7172e251f8736c52

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

LOG: [test-release.sh] Add option to disable building clang-tools-extra during 
release testing.

This patch adds an option (no-clang-tools) to disable building 
clang-tools-extra when
performing release testing. Prior to this patch, clang-tools-extra was built by 
default,
but on some platforms (such as AIX), clang-tools-extra is not supported, and so 
we do
not normally build it. Furthermore, this change should not change the 
invocation for
targets that build clang-tools-extra normally.

Differential Revision: https://reviews.llvm.org/D119520

(cherry picked from commit db691903d268d6d56f8a028de85aa2fc0c7d48e9)

Added: 


Modified: 
llvm/utils/release/test-release.sh

Removed: 




diff  --git a/llvm/utils/release/test-release.sh 
b/llvm/utils/release/test-release.sh
index 41c3f3af14221..5cb7f186c530c 100755
--- a/llvm/utils/release/test-release.sh
+++ b/llvm/utils/release/test-release.sh
@@ -29,6 +29,7 @@ do_debug="no"
 do_asserts="no"
 do_compare="yes"
 do_rt="yes"
+do_clang_tools="yes"
 do_libs="yes"
 do_libcxxabi="yes"
 do_libunwind="yes"
@@ -62,6 +63,7 @@ function usage() {
 echo " -configure-flags FLAGS  Extra flags to pass to the configure step."
 echo " -git-ref sha Use the specified git ref for testing instead 
of a release."
 echo " -no-rt   Disable check-out & build Compiler-RT"
+echo " -no-clang-tools  Disable check-out & build clang-tools-extra"
 echo " -no-libs Disable check-out & build 
libcxx/libcxxabi/libunwind"
 echo " -no-libcxxabiDisable check-out & build libcxxabi"
 echo " -no-libunwindDisable check-out & build libunwind"
@@ -144,6 +146,9 @@ while [ $# -gt 0 ]; do
 -no-libs )
 do_libs="no"
 ;;
+-no-clang-tools )
+do_clang_tools="no"
+;;
 -no-libcxxabi )
 do_libcxxabi="no"
 ;;
@@ -235,7 +240,10 @@ if [ -z "$NumJobs" ]; then
 fi
 
 # Projects list
-projects="llvm clang clang-tools-extra"
+projects="llvm clang"
+if [ $do_clang_tools = "yes" ]; then
+  projects="$projects clang-tools-extra"
+fi
 runtimes=""
 if [ $do_rt = "yes" ]; then
   runtimes="$runtimes compiler-rt"



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


[llvm-branch-commits] [llvm] ae88d88 - [SDAG] move x86 select-with-identity-constant fold behind a target hook; NFC

2022-02-14 Thread Tom Stellard via llvm-branch-commits

Author: Sanjay Patel
Date: 2022-02-14T14:10:53-08:00
New Revision: ae88d8844673fbe7a2b7550a8cd168c7bebca99d

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

LOG: [SDAG] move x86 select-with-identity-constant fold behind a target hook; 
NFC

This is no-functional-change-intended because only the
x86 target enables the TLI hook currently.

We can add fmul/fdiv opcodes to the switch similar to the
proposal D119111, but we don't need to make other changes
like enabling target-specific combines.

We can also add integer opcodes (add, or, shl, etc.) to
the switch because this function is called from all of the
generic binary opcodes.

The goal is to incrementally enable the profitable diffs
from D90113 while avoiding regressions.

Differential Revision: https://reviews.llvm.org/D119150

(cherry picked from commit a68e098024708cba7b37d6c5a27a4003e8944142)

Added: 


Modified: 
llvm/include/llvm/CodeGen/TargetLowering.h
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/lib/Target/X86/X86ISelLowering.h

Removed: 




diff  --git a/llvm/include/llvm/CodeGen/TargetLowering.h 
b/llvm/include/llvm/CodeGen/TargetLowering.h
index 3861648a5feba..de8b0e9cfd10b 100644
--- a/llvm/include/llvm/CodeGen/TargetLowering.h
+++ b/llvm/include/llvm/CodeGen/TargetLowering.h
@@ -2851,6 +2851,14 @@ class TargetLoweringBase {
 return false;
   }
 
+  /// Return true if pulling a binary operation into a select with an identity
+  /// constant is profitable. This is the inverse of an IR transform.
+  /// Example: X + (Cond ? Y : 0) --> Cond ? (X + Y) : X
+  virtual bool shouldFoldSelectWithIdentityConstant(unsigned BinOpcode,
+EVT VT) const {
+return false;
+  }
+
   /// Return true if it is beneficial to convert a load of a constant to
   /// just the constant itself.
   /// On some targets it might be more efficient to use a combination of

diff  --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp 
b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 041d7e5b4a4aa..6a36b7862ce95 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -2101,10 +2101,77 @@ static bool canFoldInAddressingMode(SDNode *N, SDNode 
*Use, SelectionDAG &DAG,
VT.getTypeForEVT(*DAG.getContext()), AS);
 }
 
+/// This inverts a canonicalization in IR that replaces a variable select arm
+/// with an identity constant. Codegen improves if we re-use the variable
+/// operand rather than load a constant. This can also be converted into a
+/// masked vector operation if the target supports it.
+static SDValue foldSelectWithIdentityConstant(SDNode *N, SelectionDAG &DAG,
+  bool ShouldCommuteOperands) {
+  // Match a select as operand 1. The identity constant that we are looking for
+  // is only valid as operand 1 of a non-commutative binop.
+  SDValue N0 = N->getOperand(0);
+  SDValue N1 = N->getOperand(1);
+  if (ShouldCommuteOperands)
+std::swap(N0, N1);
+
+  // TODO: Should this apply to scalar select too?
+  if (!N1.hasOneUse() || N1.getOpcode() != ISD::VSELECT)
+return SDValue();
+
+  unsigned Opcode = N->getOpcode();
+  EVT VT = N->getValueType(0);
+  SDValue Cond = N1.getOperand(0);
+  SDValue TVal = N1.getOperand(1);
+  SDValue FVal = N1.getOperand(2);
+
+  // TODO: The cases should match with IR's ConstantExpr::getBinOpIdentity().
+  // TODO: Target-specific opcodes could be added. Ex: "isCommutativeBinOp()".
+  // TODO: With fast-math (NSZ), allow the opposite-sign form of zero?
+  auto isIdentityConstantForOpcode = [](unsigned Opcode, SDValue V) {
+if (ConstantFPSDNode *C = isConstOrConstSplatFP(V)) {
+  switch (Opcode) {
+  case ISD::FADD: // X + -0.0 --> X
+return C->isZero() && C->isNegative();
+  case ISD::FSUB: // X - 0.0 --> X
+return C->isZero() && !C->isNegative();
+  }
+}
+return false;
+  };
+
+  // This transform increases uses of N0, so freeze it to be safe.
+  // binop N0, (vselect Cond, IDC, FVal) --> vselect Cond, N0, (binop N0, FVal)
+  if (isIdentityConstantForOpcode(Opcode, TVal)) {
+SDValue F0 = DAG.getFreeze(N0);
+SDValue NewBO = DAG.getNode(Opcode, SDLoc(N), VT, F0, FVal, N->getFlags());
+return DAG.getSelect(SDLoc(N), VT, Cond, F0, NewBO);
+  }
+  // binop N0, (vselect Cond, TVal, IDC) --> vselect Cond, (binop N0, TVal), N0
+  if (isIdentityConstantForOpcode(Opcode, FVal)) {
+SDValue F0 = DAG.getFreeze(N0);
+SDValue NewBO = DAG.getNode(Opcode, SDLoc(N), VT, F0, TVal, N->getFlags());
+return DAG.getSelect(SDLoc(N), VT, Cond, NewBO, F0);
+  }
+
+  return SDValue();
+}
+
 SDValue DAGCombi

[llvm-branch-commits] [clang-tools-extra] a42f1f8 - replace clang LLVM_ENABLE_PLUGINS -> CLANG_PLUGIN_SUPPORT in tests

2022-02-14 Thread Tom Stellard via llvm-branch-commits

Author: Jameson Nash
Date: 2022-02-14T14:11:28-08:00
New Revision: a42f1f88f1361bd010fbec932d70f698853488ec

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

LOG: replace clang LLVM_ENABLE_PLUGINS -> CLANG_PLUGIN_SUPPORT in tests

Ensure CLANG_PLUGIN_SUPPORT is compatible with llvm_add_library.
Fixes an issue noted in D00.

Differential Revision: https://reviews.llvm.org/D119199

(cherry picked from commit 76cad51ba700233d6e3492eddcbb466b6adbc2eb)

Added: 


Modified: 
clang-tools-extra/test/CMakeLists.txt
clang-tools-extra/test/lit.site.cfg.py.in
clang/CMakeLists.txt
clang/examples/AnnotateFunctions/CMakeLists.txt
clang/examples/Attribute/CMakeLists.txt
clang/examples/CallSuperAttribute/CMakeLists.txt
clang/examples/PluginsOrder/CMakeLists.txt
clang/examples/PrintFunctionNames/CMakeLists.txt
clang/lib/Analysis/plugins/CMakeLists.txt
clang/test/CMakeLists.txt
clang/test/lit.site.cfg.py.in
clang/tools/driver/CMakeLists.txt

Removed: 




diff  --git a/clang-tools-extra/test/CMakeLists.txt 
b/clang-tools-extra/test/CMakeLists.txt
index 9321457ae1a39..170e5f8bd197d 100644
--- a/clang-tools-extra/test/CMakeLists.txt
+++ b/clang-tools-extra/test/CMakeLists.txt
@@ -17,7 +17,7 @@ string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} 
CLANG_TOOLS_DIR ${LLVM_RUN
 
 llvm_canonicalize_cmake_booleans(
   CLANG_TIDY_ENABLE_STATIC_ANALYZER
-  LLVM_ENABLE_PLUGINS
+  CLANG_PLUGIN_SUPPORT
   LLVM_INSTALL_TOOLCHAIN_ONLY
   )
 
@@ -87,10 +87,19 @@ if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
   PLUGIN_TOOL clang-tidy
   DEPENDS clang-tidy-headers)
 
+  if(CLANG_BUILT_STANDALONE)
+# LLVMHello library is needed below
+if (EXISTS ${LLVM_MAIN_SRC_DIR}/lib/Transforms/Hello
+   AND NOT TARGET LLVMHello)
+  add_subdirectory(${LLVM_MAIN_SRC_DIR}/lib/Transforms/Hello
+lib/Transforms/Hello)
+endif()
+  endif()
+
   if(TARGET CTTestTidyModule)
   list(APPEND CLANG_TOOLS_TEST_DEPS CTTestTidyModule LLVMHello)
   target_include_directories(CTTestTidyModule PUBLIC BEFORE 
"${CLANG_TOOLS_SOURCE_DIR}")
-  if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
+  if(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN))
 set(LLVM_LINK_COMPONENTS
   Support
 )

diff  --git a/clang-tools-extra/test/lit.site.cfg.py.in 
b/clang-tools-extra/test/lit.site.cfg.py.in
index e7db0e2ef2cb8..d30e6664816b7 100644
--- a/clang-tools-extra/test/lit.site.cfg.py.in
+++ b/clang-tools-extra/test/lit.site.cfg.py.in
@@ -12,7 +12,7 @@ config.clang_libs_dir = "@SHLIBDIR@"
 config.python_executable = "@Python3_EXECUTABLE@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.clang_tidy_staticanalyzer = @CLANG_TIDY_ENABLE_STATIC_ANALYZER@
-config.has_plugins = @LLVM_ENABLE_PLUGINS@ & ~@LLVM_INSTALL_TOOLCHAIN_ONLY@
+config.has_plugins = @CLANG_PLUGIN_SUPPORT@ & ~@LLVM_INSTALL_TOOLCHAIN_ONLY@
 
 # Support substitution of the tools and libs dirs with user parameters. This is
 # used when we can't determine the tool dir at configuration time.

diff  --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index 1cc9bacf4e5eb..4225c028e1794 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -476,6 +476,10 @@ add_definitions( -D_GNU_SOURCE )
 option(CLANG_BUILD_TOOLS
   "Build the Clang tools. If OFF, just generate build targets." ON)
 
+CMAKE_DEPENDENT_OPTION(CLANG_PLUGIN_SUPPORT
+  "Build clang with plugin support" ON
+  "LLVM_ENABLE_PLUGINS OR LLVM_EXPORT_SYMBOLS_FOR_PLUGINS" OFF)
+
 option(CLANG_ENABLE_ARCMT "Build ARCMT." ON)
 option(CLANG_ENABLE_STATIC_ANALYZER
   "Include static analyzer in clang binary." ON)

diff  --git a/clang/examples/AnnotateFunctions/CMakeLists.txt 
b/clang/examples/AnnotateFunctions/CMakeLists.txt
index e9850b64f08d7..e6541f7cc62a6 100644
--- a/clang/examples/AnnotateFunctions/CMakeLists.txt
+++ b/clang/examples/AnnotateFunctions/CMakeLists.txt
@@ -1,6 +1,6 @@
 add_llvm_library(AnnotateFunctions MODULE AnnotateFunctions.cpp PLUGIN_TOOL 
clang)
 
-if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
+if(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN))
   set(LLVM_LINK_COMPONENTS
 Support
   )

diff  --git a/clang/examples/Attribute/CMakeLists.txt 
b/clang/examples/Attribute/CMakeLists.txt
index 42f04f5039bc7..5392ac0df1703 100644
--- a/clang/examples/Attribute/CMakeLists.txt
+++ b/clang/examples/Attribute/CMakeLists.txt
@@ -1,6 +1,6 @@
 add_llvm_library(Attribute MODULE Attribute.cpp PLUGIN_TOOL clang)
 
-if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
+if(CLANG_PLUGIN_SUPPORT AND (WIN32 OR CYGWIN))
   target_link_libraries(Attribute PRIVATE
 clangAST
 clangBasic

diff  --git a/clang/examples/CallSuperAttribute/CMakeLists.txt 
b/clang/examples/CallSuperAttribute/CMakeLists.txt
index 922f0cfa797a8..f4284adf289e3 100644

[llvm-branch-commits] [clang] 67e0b64 - [clang-format] Honour "// clang-format off" when using QualifierOrder.

2022-02-14 Thread Tom Stellard via llvm-branch-commits

Author: Marek Kurdej
Date: 2022-02-14T14:12:07-08:00
New Revision: 67e0b64c0e6c769126b354b39bc5fa3f5d9d73d1

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

LOG: [clang-format] Honour "// clang-format off" when using QualifierOrder.

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

Reviewed By: MyDeveloperDay, HazardyKnusperkeks, owenpan

Differential Revision: https://reviews.llvm.org/D119218

(cherry picked from commit e329b5866f1732f5c24cf2ae96479971f7101914)

Added: 


Modified: 
clang/lib/Format/QualifierAlignmentFixer.cpp
clang/unittests/Format/QualifierFixerTest.cpp

Removed: 




diff  --git a/clang/lib/Format/QualifierAlignmentFixer.cpp 
b/clang/lib/Format/QualifierAlignmentFixer.cpp
index b3a4684bead1a..0142a6c08ed30 100644
--- a/clang/lib/Format/QualifierAlignmentFixer.cpp
+++ b/clang/lib/Format/QualifierAlignmentFixer.cpp
@@ -396,6 +396,10 @@ LeftRightQualifierAlignmentFixer::analyze(
 
   for (AnnotatedLine *Line : AnnotatedLines) {
 FormatToken *First = Line->First;
+assert(First);
+if (First->Finalized)
+  continue;
+
 const auto *Last = Line->Last;
 
 for (const auto *Tok = First; Tok && Tok != Last && Tok->Next;

diff  --git a/clang/unittests/Format/QualifierFixerTest.cpp 
b/clang/unittests/Format/QualifierFixerTest.cpp
index 0517de2820d9d..14f09d875e6be 100755
--- a/clang/unittests/Format/QualifierFixerTest.cpp
+++ b/clang/unittests/Format/QualifierFixerTest.cpp
@@ -858,5 +858,27 @@ TEST_F(QualifierFixerTest, QualifierTemplates) {
Style);
 }
 
+TEST_F(QualifierFixerTest, DisableRegions) {
+  FormatStyle Style = getLLVMStyle();
+  Style.QualifierAlignment = FormatStyle::QAS_Custom;
+  Style.QualifierOrder = {"inline", "static", "const", "type"};
+
+  ReplacementCount = 0;
+  verifyFormat("// clang-format off\n"
+   "int const inline static a = 0;\n"
+   "// clang-format on\n",
+   Style);
+  EXPECT_EQ(ReplacementCount, 0);
+  verifyFormat("// clang-format off\n"
+   "int const inline static a = 0;\n"
+   "// clang-format on\n"
+   "inline static const int a = 0;\n",
+   "// clang-format off\n"
+   "int const inline static a = 0;\n"
+   "// clang-format on\n"
+   "int const inline static a = 0;\n",
+   Style);
+}
+
 } // namespace format
 } // namespace clang



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


[llvm-branch-commits] [clang] 8b3ba44 - [OpenCL] Test -fdeclare-opencl-builtins with CL3 and CLC++2021

2022-02-14 Thread Tom Stellard via llvm-branch-commits

Author: Sven van Haastregt
Date: 2022-02-14T14:12:35-08:00
New Revision: 8b3ba440a2f0e7539574395d9bed209646d341e4

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

LOG: [OpenCL] Test -fdeclare-opencl-builtins with CL3 and CLC++2021

But only test in combination with -finclude-default-header, as the
headerless tests may be dropped soon.

(cherry picked from commit e0e6f3a6a2e13ee11b014ca45a48997e78d3efc5)

Added: 


Modified: 
clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl

Removed: 




diff  --git a/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl 
b/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
index 8c5863987be68..d1a4f72837260 100644
--- a/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
+++ b/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
@@ -4,8 +4,10 @@
 // RUN: %clang_cc1 %s -triple spir -verify -pedantic -Wconversion -Werror 
-fsyntax-only -cl-std=CL1.2 -fdeclare-opencl-builtins -finclude-default-header
 // RUN: %clang_cc1 %s -triple spir -verify -pedantic -Wconversion -Werror 
-fsyntax-only -cl-std=CL2.0 -fdeclare-opencl-builtins -DNO_HEADER
 // RUN: %clang_cc1 %s -triple spir -verify -pedantic -Wconversion -Werror 
-fsyntax-only -cl-std=CL2.0 -fdeclare-opencl-builtins -finclude-default-header
+// RUN: %clang_cc1 %s -triple spir -verify -pedantic -Wconversion -Werror 
-fsyntax-only -cl-std=CL3.0 -fdeclare-opencl-builtins -finclude-default-header
 // RUN: %clang_cc1 %s -triple spir -verify -pedantic -Wconversion -Werror 
-fsyntax-only -cl-std=CLC++ -fdeclare-opencl-builtins -DNO_HEADER
 // RUN: %clang_cc1 %s -triple spir -verify -pedantic -Wconversion -Werror 
-fsyntax-only -cl-std=CLC++ -fdeclare-opencl-builtins -finclude-default-header
+// RUN: %clang_cc1 %s -triple spir -verify -pedantic -Wconversion -Werror 
-fsyntax-only -cl-std=CLC++2021 -fdeclare-opencl-builtins 
-finclude-default-header
 // RUN: %clang_cc1 %s -triple spir -verify -pedantic -Wconversion -Werror 
-fsyntax-only -cl-std=CL2.0 -fdeclare-opencl-builtins -finclude-default-header 
-cl-ext=-cl_khr_fp64 -DNO_FP64
 
 // Test the -fdeclare-opencl-builtins option.  This is not a completeness



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


[llvm-branch-commits] [clang] 865a18c - [OpenCL] Move OpenCL 2.0 atomics into multiclass; NFC

2022-02-14 Thread Tom Stellard via llvm-branch-commits

Author: Sven van Haastregt
Date: 2022-02-14T14:12:35-08:00
New Revision: 865a18c94d50b6bd79c31e05a5c142846182c998

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

LOG: [OpenCL] Move OpenCL 2.0 atomics into multiclass; NFC

This is in preparation for adding the OpenCL 3.0 builtins with named
address space arguments.

(cherry picked from commit 31fa3a4d44316fd36e11f92729ea9596ee3bf3f8)

Added: 


Modified: 
clang/lib/Sema/OpenCLBuiltins.td

Removed: 




diff  --git a/clang/lib/Sema/OpenCLBuiltins.td 
b/clang/lib/Sema/OpenCLBuiltins.td
index 516653681331e..08f8630a67e22 100644
--- a/clang/lib/Sema/OpenCLBuiltins.td
+++ b/clang/lib/Sema/OpenCLBuiltins.td
@@ -1040,6 +1040,8 @@ let Extension = FuncExtOpenCLCxx in {
   }
 }
 
+// OpenCL v2.0 s6.13.11 - Atomic Functions.
+
 // An atomic builtin with 2 additional _explicit variants.
 multiclass BuiltinAtomicExplicit Types> {
   // Without explicit MemoryOrder or MemoryScope.
@@ -1052,31 +1054,29 @@ multiclass BuiltinAtomicExplicit Types> {
   def : Builtin;
 }
 
-// OpenCL v2.0 s6.13.11 - Atomic Functions.
-let MinVersion = CL20 in {
-  def : Builtin<"atomic_work_item_fence", [Void, MemFenceFlags, MemoryOrder, 
MemoryScope]>;
-
+// OpenCL 2.0 atomic functions that have a pointer argument in a given address 
space.
+multiclass OpenCL2Atomics {
   foreach TypePair = [[AtomicInt, Int], [AtomicUInt, UInt],
   [AtomicLong, Long], [AtomicULong, ULong],
   [AtomicFloat, Float], [AtomicDouble, Double]] in {
 def : Builtin<"atomic_init",
-[Void, PointerType, GenericAS>, 
TypePair[1]]>;
+[Void, PointerType, addrspace>, 
TypePair[1]]>;
 defm : BuiltinAtomicExplicit<"atomic_store",
-[Void, PointerType, GenericAS>, 
TypePair[1]]>;
+[Void, PointerType, addrspace>, 
TypePair[1]]>;
 defm : BuiltinAtomicExplicit<"atomic_load",
-[TypePair[1], PointerType, GenericAS>]>;
+[TypePair[1], PointerType, addrspace>]>;
 defm : BuiltinAtomicExplicit<"atomic_exchange",
-[TypePair[1], PointerType, GenericAS>, 
TypePair[1]]>;
+[TypePair[1], PointerType, addrspace>, 
TypePair[1]]>;
 foreach Variant = ["weak", "strong"] in {
   def : Builtin<"atomic_compare_exchange_" # Variant,
-  [Bool, PointerType, GenericAS>,
-   PointerType, TypePair[1]]>;
+  [Bool, PointerType, addrspace>,
+   PointerType, TypePair[1]]>;
   def : Builtin<"atomic_compare_exchange_" # Variant # "_explicit",
-  [Bool, PointerType, GenericAS>,
-   PointerType, TypePair[1], MemoryOrder, 
MemoryOrder]>;
+  [Bool, PointerType, addrspace>,
+   PointerType, TypePair[1], MemoryOrder, 
MemoryOrder]>;
   def : Builtin<"atomic_compare_exchange_" # Variant # "_explicit",
-  [Bool, PointerType, GenericAS>,
-   PointerType, TypePair[1], MemoryOrder, 
MemoryOrder, MemoryScope]>;
+  [Bool, PointerType, addrspace>,
+   PointerType, TypePair[1], MemoryOrder, 
MemoryOrder, MemoryScope]>;
 }
   }
 
@@ -1085,22 +1085,28 @@ let MinVersion = CL20 in {
   [AtomicUIntPtr, UIntPtr, PtrDiff]] in {
 foreach ModOp = ["add", "sub"] in {
   defm : BuiltinAtomicExplicit<"atomic_fetch_" # ModOp,
-  [TypePair[1], PointerType, GenericAS>, 
TypePair[2]]>;
+  [TypePair[1], PointerType, addrspace>, 
TypePair[2]]>;
 }
   }
   foreach TypePair = [[AtomicInt, Int, Int], [AtomicUInt, UInt, UInt],
   [AtomicLong, Long, Long], [AtomicULong, ULong, ULong]] 
in {
 foreach ModOp = ["or", "xor", "and", "min", "max"] in {
   defm : BuiltinAtomicExplicit<"atomic_fetch_" # ModOp,
-  [TypePair[1], PointerType, GenericAS>, 
TypePair[2]]>;
+  [TypePair[1], PointerType, addrspace>, 
TypePair[2]]>;
 }
   }
 
   defm : BuiltinAtomicExplicit<"atomic_flag_clear",
-  [Void, PointerType, GenericAS>]>;
+  [Void, PointerType, addrspace>]>;
 
   defm : BuiltinAtomicExplicit<"atomic_flag_test_and_set",
-  [Bool, PointerType, GenericAS>]>;
+  [Bool, PointerType, addrspace>]>;
+}
+
+let MinVersion = CL20 in {
+  def : Builtin<"atomic_work_item_fence", [Void, MemFenceFlags, MemoryOrder, 
MemoryScope]>;
+
+  defm : OpenCL2Atomics;
 }
 
 // The functionality added by cl_ext_float_atomics extension



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


[llvm-branch-commits] [clang] 174dffb - [OpenCL] Move most _explicit atomics into multiclass; NFC

2022-02-14 Thread Tom Stellard via llvm-branch-commits

Author: Sven van Haastregt
Date: 2022-02-14T14:12:35-08:00
New Revision: 174dffbae24fbad842603c1d32d3c70c0b9783ae

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

LOG: [OpenCL] Move most _explicit atomics into multiclass; NFC

This will simplify future conditionalization for OpenCL 3.0
optionality of atomic features.

The only set of atomic functions not using the multiclass is
atomic_compare_exchange_strong/weak, as these don't fit the common
pattern due to having 2 MemoryOrder arguments.

(cherry picked from commit d97a4dfea6c2781494f6fe54ce265128f5c08dc2)

Added: 


Modified: 
clang/lib/Sema/OpenCLBuiltins.td

Removed: 




diff  --git a/clang/lib/Sema/OpenCLBuiltins.td 
b/clang/lib/Sema/OpenCLBuiltins.td
index cd704ba2df13d..516653681331e 100644
--- a/clang/lib/Sema/OpenCLBuiltins.td
+++ b/clang/lib/Sema/OpenCLBuiltins.td
@@ -1040,6 +1040,18 @@ let Extension = FuncExtOpenCLCxx in {
   }
 }
 
+// An atomic builtin with 2 additional _explicit variants.
+multiclass BuiltinAtomicExplicit Types> {
+  // Without explicit MemoryOrder or MemoryScope.
+  def : Builtin;
+
+  // With an explicit MemoryOrder argument.
+  def : Builtin;
+
+  // With explicit MemoryOrder and MemoryScope arguments.
+  def : Builtin;
+}
+
 // OpenCL v2.0 s6.13.11 - Atomic Functions.
 let MinVersion = CL20 in {
   def : Builtin<"atomic_work_item_fence", [Void, MemFenceFlags, MemoryOrder, 
MemoryScope]>;
@@ -1049,24 +1061,12 @@ let MinVersion = CL20 in {
   [AtomicFloat, Float], [AtomicDouble, Double]] in {
 def : Builtin<"atomic_init",
 [Void, PointerType, GenericAS>, 
TypePair[1]]>;
-def : Builtin<"atomic_store",
+defm : BuiltinAtomicExplicit<"atomic_store",
 [Void, PointerType, GenericAS>, 
TypePair[1]]>;
-def : Builtin<"atomic_store_explicit",
-[Void, PointerType, GenericAS>, TypePair[1], 
MemoryOrder]>;
-def : Builtin<"atomic_store_explicit",
-[Void, PointerType, GenericAS>, TypePair[1], 
MemoryOrder, MemoryScope]>;
-def : Builtin<"atomic_load",
+defm : BuiltinAtomicExplicit<"atomic_load",
 [TypePair[1], PointerType, GenericAS>]>;
-def : Builtin<"atomic_load_explicit",
-[TypePair[1], PointerType, GenericAS>, 
MemoryOrder]>;
-def : Builtin<"atomic_load_explicit",
-[TypePair[1], PointerType, GenericAS>, 
MemoryOrder, MemoryScope]>;
-def : Builtin<"atomic_exchange",
+defm : BuiltinAtomicExplicit<"atomic_exchange",
 [TypePair[1], PointerType, GenericAS>, 
TypePair[1]]>;
-def : Builtin<"atomic_exchange_explicit",
-[TypePair[1], PointerType, GenericAS>, 
TypePair[1], MemoryOrder]>;
-def : Builtin<"atomic_exchange_explicit",
-[TypePair[1], PointerType, GenericAS>, 
TypePair[1], MemoryOrder, MemoryScope]>;
 foreach Variant = ["weak", "strong"] in {
   def : Builtin<"atomic_compare_exchange_" # Variant,
   [Bool, PointerType, GenericAS>,
@@ -1084,249 +1084,125 @@ let MinVersion = CL20 in {
   [AtomicLong, Long, Long], [AtomicULong, ULong, ULong],
   [AtomicUIntPtr, UIntPtr, PtrDiff]] in {
 foreach ModOp = ["add", "sub"] in {
-  def : Builtin<"atomic_fetch_" # ModOp,
+  defm : BuiltinAtomicExplicit<"atomic_fetch_" # ModOp,
   [TypePair[1], PointerType, GenericAS>, 
TypePair[2]]>;
-  def : Builtin<"atomic_fetch_" # ModOp # "_explicit",
-  [TypePair[1], PointerType, GenericAS>, 
TypePair[2], MemoryOrder]>;
-  def : Builtin<"atomic_fetch_" # ModOp # "_explicit",
-  [TypePair[1], PointerType, GenericAS>, 
TypePair[2], MemoryOrder, MemoryScope]>;
 }
   }
   foreach TypePair = [[AtomicInt, Int, Int], [AtomicUInt, UInt, UInt],
   [AtomicLong, Long, Long], [AtomicULong, ULong, ULong]] 
in {
 foreach ModOp = ["or", "xor", "and", "min", "max"] in {
-  def : Builtin<"atomic_fetch_" # ModOp,
+  defm : BuiltinAtomicExplicit<"atomic_fetch_" # ModOp,
   [TypePair[1], PointerType, GenericAS>, 
TypePair[2]]>;
-  def : Builtin<"atomic_fetch_" # ModOp # "_explicit",
-  [TypePair[1], PointerType, GenericAS>, 
TypePair[2], MemoryOrder]>;
-  def : Builtin<"atomic_fetch_" # ModOp # "_explicit",
-  [TypePair[1], PointerType, GenericAS>, 
TypePair[2], MemoryOrder, MemoryScope]>;
 }
   }
 
-  def : Builtin<"atomic_flag_clear",
+  defm : BuiltinAtomicExplicit<"atomic_flag_clear",
   [Void, PointerType, GenericAS>]>;
-  def : Builtin<"atomic_flag_clear_explicit",
-  [Void, PointerType, GenericAS>, MemoryOrder]>;
-  def : Builtin<"atomic_flag_clear_explicit",
-  [Void, PointerType, GenericAS>, MemoryOrder, 
MemoryScope]>;
 
-  def : Builtin<"atomic_flag_test_and_set",
+  defm : BuiltinAtomicExplicit<"atomic_fla

[llvm-branch-commits] [clang] 8426097 - [OpenCL] Fix atomic_fetch_add/sub with half type

2022-02-14 Thread Tom Stellard via llvm-branch-commits

Author: Sven van Haastregt
Date: 2022-02-14T14:12:35-08:00
New Revision: 84260978cbf52485d9347e20386fda6bb82df763

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

LOG: [OpenCL] Fix atomic_fetch_add/sub with half type

An error in the tablegen description affects the declarations
provided by `-fdeclare-opencl-builtins` for `atomic_fetch_add` and
`atomic_fetch_sub`.

The atomic argument should be an atomic_half, not an atomic_float.

(cherry picked from commit fe690587bedb23dec2753549d4216059a7f894a1)

Added: 


Modified: 
clang/lib/Sema/OpenCLBuiltins.td

Removed: 




diff  --git a/clang/lib/Sema/OpenCLBuiltins.td 
b/clang/lib/Sema/OpenCLBuiltins.td
index 08f8630a67e22..60a05f95fbec8 100644
--- a/clang/lib/Sema/OpenCLBuiltins.td
+++ b/clang/lib/Sema/OpenCLBuiltins.td
@@ -1138,7 +1138,7 @@ let MinVersion = CL20 in {
   foreach ModOp = ["add", "sub"] in {
 let Extension = FuncExtFloatAtomicsFp16GlobalAdd in {
   defm : BuiltinAtomicExplicit<"atomic_fetch_" # ModOp,
-  [Half, PointerType, GlobalAS>, Half]>;
+  [Half, PointerType, GlobalAS>, Half]>;
 }
 let Extension = FuncExtFloatAtomicsFp32GlobalAdd in {
   defm : BuiltinAtomicExplicit<"atomic_fetch_" # ModOp,
@@ -1150,7 +1150,7 @@ let MinVersion = CL20 in {
 }
 let Extension = FuncExtFloatAtomicsFp16LocalAdd in {
   defm : BuiltinAtomicExplicit<"atomic_fetch_" # ModOp,
-  [Half, PointerType, LocalAS>, Half]>;
+  [Half, PointerType, LocalAS>, Half]>;
 }
 let Extension = FuncExtFloatAtomicsFp32LocalAdd in {
   defm : BuiltinAtomicExplicit<"atomic_fetch_" # ModOp,
@@ -1162,7 +1162,7 @@ let MinVersion = CL20 in {
 }
 let Extension = FuncExtFloatAtomicsFp16GenericAdd in {
   defm : BuiltinAtomicExplicit<"atomic_fetch_" # ModOp,
-  [Half, PointerType, GenericAS>, Half]>;
+  [Half, PointerType, GenericAS>, Half]>;
 }
 let Extension = FuncExtFloatAtomicsFp32GenericAdd in {
   defm : BuiltinAtomicExplicit<"atomic_fetch_" # ModOp,



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


[llvm-branch-commits] [clang] f4c48b2 - [OpenCL] Refactor cl_ext_float_atomics declarations; NFC

2022-02-14 Thread Tom Stellard via llvm-branch-commits

Author: Sven van Haastregt
Date: 2022-02-14T14:12:35-08:00
New Revision: f4c48b2015cb3045962695b6e9e9fa7545b2895b

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

LOG: [OpenCL] Refactor cl_ext_float_atomics declarations; NFC

Reduce the amount of repetition in the declarations by leveraging more
TableGen constructs.  This is in preparation for adding the OpenCL 3.0
atomics feature optionality.

(cherry picked from commit 8d37043520f57e63e032c9d0ba4cba8701a3cd35)

Added: 


Modified: 
clang/lib/Sema/OpenCLBuiltins.td

Removed: 




diff  --git a/clang/lib/Sema/OpenCLBuiltins.td 
b/clang/lib/Sema/OpenCLBuiltins.td
index 60a05f95fbec8..4d36df352d5ec 100644
--- a/clang/lib/Sema/OpenCLBuiltins.td
+++ b/clang/lib/Sema/OpenCLBuiltins.td
@@ -90,27 +90,27 @@ def FuncExtOpenCLCNamedAddressSpaceBuiltins : 
FunctionExtension<"__opencl_c_name
 def FuncExtOpenCLCPipes  : 
FunctionExtension<"__opencl_c_pipes">;
 def FuncExtOpenCLCWGCollectiveFunctions  : 
FunctionExtension<"__opencl_c_work_group_collective_functions">;
 def FuncExtOpenCLCReadWriteImages: 
FunctionExtension<"__opencl_c_read_write_images">;
-def FuncExtFloatAtomicsFp16GlobalLoadStore  : 
FunctionExtension<"cl_ext_float_atomics 
__opencl_c_ext_fp16_global_atomic_load_store">;
-def FuncExtFloatAtomicsFp16LocalLoadStore   : 
FunctionExtension<"cl_ext_float_atomics 
__opencl_c_ext_fp16_local_atomic_load_store">;
-def FuncExtFloatAtomicsFp16GenericLoadStore : 
FunctionExtension<"cl_ext_float_atomics 
__opencl_c_ext_fp16_global_atomic_load_store 
__opencl_c_ext_fp16_local_atomic_load_store">;
-def FuncExtFloatAtomicsFp16GlobalAdd : 
FunctionExtension<"cl_ext_float_atomics __opencl_c_ext_fp16_global_atomic_add">;
-def FuncExtFloatAtomicsFp32GlobalAdd : 
FunctionExtension<"cl_ext_float_atomics __opencl_c_ext_fp32_global_atomic_add">;
-def FuncExtFloatAtomicsFp64GlobalAdd : 
FunctionExtension<"cl_ext_float_atomics __opencl_c_ext_fp64_global_atomic_add">;
-def FuncExtFloatAtomicsFp16LocalAdd  : 
FunctionExtension<"cl_ext_float_atomics __opencl_c_ext_fp16_local_atomic_add">;
-def FuncExtFloatAtomicsFp32LocalAdd  : 
FunctionExtension<"cl_ext_float_atomics __opencl_c_ext_fp32_local_atomic_add">;
-def FuncExtFloatAtomicsFp64LocalAdd  : 
FunctionExtension<"cl_ext_float_atomics __opencl_c_ext_fp64_local_atomic_add">;
-def FuncExtFloatAtomicsFp16GenericAdd: 
FunctionExtension<"cl_ext_float_atomics __opencl_c_ext_fp16_local_atomic_add 
__opencl_c_ext_fp16_global_atomic_add">;
-def FuncExtFloatAtomicsFp32GenericAdd: 
FunctionExtension<"cl_ext_float_atomics __opencl_c_ext_fp32_local_atomic_add 
__opencl_c_ext_fp32_global_atomic_add">;
-def FuncExtFloatAtomicsFp64GenericAdd: 
FunctionExtension<"cl_ext_float_atomics __opencl_c_ext_fp64_local_atomic_add 
__opencl_c_ext_fp64_global_atomic_add">;
-def FuncExtFloatAtomicsFp16GlobalMinMax  : 
FunctionExtension<"cl_ext_float_atomics 
__opencl_c_ext_fp16_global_atomic_min_max">;
-def FuncExtFloatAtomicsFp32GlobalMinMax  : 
FunctionExtension<"cl_ext_float_atomics 
__opencl_c_ext_fp32_global_atomic_min_max">;
-def FuncExtFloatAtomicsFp64GlobalMinMax  : 
FunctionExtension<"cl_ext_float_atomics 
__opencl_c_ext_fp64_global_atomic_min_max">;
-def FuncExtFloatAtomicsFp16LocalMinMax   : 
FunctionExtension<"cl_ext_float_atomics 
__opencl_c_ext_fp16_local_atomic_min_max">;
-def FuncExtFloatAtomicsFp32LocalMinMax   : 
FunctionExtension<"cl_ext_float_atomics 
__opencl_c_ext_fp32_local_atomic_min_max">;
-def FuncExtFloatAtomicsFp64LocalMinMax   : 
FunctionExtension<"cl_ext_float_atomics 
__opencl_c_ext_fp64_local_atomic_min_max">;
-def FuncExtFloatAtomicsFp16GenericMinMax : 
FunctionExtension<"cl_ext_float_atomics 
__opencl_c_ext_fp16_local_atomic_min_max 
__opencl_c_ext_fp16_global_atomic_min_max">;
-def FuncExtFloatAtomicsFp32GenericMinMax : 
FunctionExtension<"cl_ext_float_atomics 
__opencl_c_ext_fp32_local_atomic_min_max 
__opencl_c_ext_fp32_global_atomic_min_max">;
-def FuncExtFloatAtomicsFp64GenericMinMax : 
FunctionExtension<"cl_ext_float_atomics 
__opencl_c_ext_fp64_local_atomic_min_max 
__opencl_c_ext_fp64_global_atomic_min_max">;
+def FuncExtFloatAtomicsFp16GlobalASLoadStore  : 
FunctionExtension<"cl_ext_float_atomics 
__opencl_c_ext_fp16_global_atomic_load_store">;
+def FuncExtFloatAtomicsFp16LocalASLoadStore   : 
FunctionExtension<"cl_ext_float_atomics 
__opencl_c_ext_fp16_local_atomic_load_store">;
+def FuncExtFloatAtomicsFp16GenericASLoadStore : 
FunctionExtension<"cl_ext_float_atomics 
__opencl_c_ext_fp16_global_atomic_load_store 
__opencl_c_ext_fp16_local_atomic_load_store">;
+def FuncExtFloatAtomicsFp16GlobalASAdd: 
FunctionExtension<"cl_ext_float_atomics __opencl_c_ext_fp16_global_atomic_add">;
+def FuncExtFloatAtomicsFp32GlobalASAdd

[llvm-branch-commits] [clang] fa24d7e - [OpenCL] Add OpenCL 3.0 atomics to -fdeclare-opencl-builtins

2022-02-14 Thread Tom Stellard via llvm-branch-commits

Author: Sven van Haastregt
Date: 2022-02-14T14:12:35-08:00
New Revision: fa24d7e3e0ea67d53b7057e07d5bc7e75ffda9ba

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

LOG: [OpenCL] Add OpenCL 3.0 atomics to -fdeclare-opencl-builtins

Add the atomic overloads for the `global` and `local` address spaces,
which are new in OpenCL 3.0.  Ensure the preexisting `generic`
overloads are guarded by the generic address space feature macro.

Ensure a subset of the atomic builtins are guarded by the
`__opencl_c_atomic_order_seq_cst` and `__opencl_c_atomic_scope_device`
feature macros, and enable those macros for SPIR/SPIR-V targets in
`opencl-c-base.h`.

Also guard the `cl_ext_float_atomics` builtins with the atomic order
and scope feature macros.

Differential Revision: https://reviews.llvm.org/D119420

(cherry picked from commit 50f8abb9f40a6c4974ec71e760773a711732648f)

Added: 


Modified: 
clang/lib/Headers/opencl-c-base.h
clang/lib/Sema/OpenCLBuiltins.td
clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl

Removed: 




diff  --git a/clang/lib/Headers/opencl-c-base.h 
b/clang/lib/Headers/opencl-c-base.h
index ad276dc0f6aae..5191c41bcd057 100644
--- a/clang/lib/Headers/opencl-c-base.h
+++ b/clang/lib/Headers/opencl-c-base.h
@@ -67,6 +67,8 @@
 #if (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300)
 // For the SPIR and SPIR-V target all features are supported.
 #if defined(__SPIR__) || defined(__SPIRV__)
+#define __opencl_c_atomic_order_seq_cst 1
+#define __opencl_c_atomic_scope_device 1
 #define __opencl_c_atomic_scope_all_devices 1
 #define __opencl_c_read_write_images 1
 #endif // defined(__SPIR__)

diff  --git a/clang/lib/Sema/OpenCLBuiltins.td 
b/clang/lib/Sema/OpenCLBuiltins.td
index 4d36df352d5ec..ab30553005729 100644
--- a/clang/lib/Sema/OpenCLBuiltins.td
+++ b/clang/lib/Sema/OpenCLBuiltins.td
@@ -57,6 +57,23 @@ class FunctionExtension : 
AbstractExtension<_Ext>;
 // disabled.
 class TypeExtension : AbstractExtension<_Ext>;
 
+// Concatenate zero or more space-separated extensions in NewExts to Base and
+// return the resulting FunctionExtension in ret.
+class concatExtension {
+  FunctionExtension ret = FunctionExtension<
+!cond(
+  // Return Base extension if NewExts is empty,
+  !empty(NewExts) : Base.ExtName,
+
+  // otherwise, return NewExts if Base extension is empty,
+  !empty(Base.ExtName) : NewExts,
+
+  // otherwise, concatenate NewExts to Base.
+  true : Base.ExtName # " " # NewExts
+)
+  >;
+}
+
 // TypeExtension definitions.
 def NoTypeExt   : TypeExtension<"">;
 def Fp16TypeExt : TypeExtension<"cl_khr_fp16">;
@@ -1043,40 +1060,57 @@ let Extension = FuncExtOpenCLCxx in {
 // OpenCL v2.0 s6.13.11 - Atomic Functions.
 
 // An atomic builtin with 2 additional _explicit variants.
-multiclass BuiltinAtomicExplicit Types> {
+multiclass BuiltinAtomicExplicit Types, 
FunctionExtension BaseExt> {
   // Without explicit MemoryOrder or MemoryScope.
-  def : Builtin;
+  let Extension = concatExtension.ret in {
+def : Builtin;
+  }
 
   // With an explicit MemoryOrder argument.
-  def : Builtin;
+  let Extension = concatExtension.ret in {
+def : Builtin;
+  }
 
   // With explicit MemoryOrder and MemoryScope arguments.
-  def : Builtin;
+  let Extension = BaseExt in {
+def : Builtin;
+  }
 }
 
 // OpenCL 2.0 atomic functions that have a pointer argument in a given address 
space.
-multiclass OpenCL2Atomics {
+multiclass OpenCL2Atomics {
   foreach TypePair = [[AtomicInt, Int], [AtomicUInt, UInt],
   [AtomicLong, Long], [AtomicULong, ULong],
   [AtomicFloat, Float], [AtomicDouble, Double]] in {
 def : Builtin<"atomic_init",
 [Void, PointerType, addrspace>, 
TypePair[1]]>;
 defm : BuiltinAtomicExplicit<"atomic_store",
-[Void, PointerType, addrspace>, 
TypePair[1]]>;
+[Void, PointerType, addrspace>, 
TypePair[1]], BaseExt>;
 defm : BuiltinAtomicExplicit<"atomic_load",
-[TypePair[1], PointerType, addrspace>]>;
+[TypePair[1], PointerType, addrspace>], 
BaseExt>;
 defm : BuiltinAtomicExplicit<"atomic_exchange",
-[TypePair[1], PointerType, addrspace>, 
TypePair[1]]>;
+[TypePair[1], PointerType, addrspace>, 
TypePair[1]], BaseExt>;
 foreach Variant = ["weak", "strong"] in {
-  def : Builtin<"atomic_compare_exchange_" # Variant,
-  [Bool, PointerType, addrspace>,
-   PointerType, TypePair[1]]>;
-  def : Builtin<"atomic_compare_exchange_" # Variant # "_explicit",
-  [Bool, PointerType, addrspace>,
-   PointerType, TypePair[1], MemoryOrder, 
MemoryOrder]>;
-  def : Builtin<"atomic_compare_exchange_" # Variant # "_explicit",
-  [Bool, PointerType, addrspace>,
-  

[llvm-branch-commits] [clang] 95dd9c5 - [OpenCL] Add support of language builtins for OpenCL C 3.0

2022-02-14 Thread Tom Stellard via llvm-branch-commits

Author: Anton Zabaznov
Date: 2022-02-14T14:13:04-08:00
New Revision: 95dd9c5f2a0642260c5351d860757c4b8abe4537

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

LOG: [OpenCL] Add support of language builtins for OpenCL C 3.0

OpenCL C 3.0 introduces optionality to some builtins, in particularly
to those which are conditionally supported with pipe, device enqueue
and generic address space features.

The idea is to conditionally support such builtins depending on the language 
options
being set for a certain feature. This allows users to define functions with 
names
of those optional builtins in OpenCL (as such names are not reserved).

Reviewed By: Anastasia

Differential Revision: https://reviews.llvm.org/D118605

(cherry picked from commit bee4bd70f76952b2c6296feb46a087b497322376)

Added: 


Modified: 
clang/include/clang/Basic/Builtins.def
clang/include/clang/Basic/Builtins.h
clang/lib/Basic/Builtins.cpp
clang/test/CodeGenOpenCL/cl20-device-side-enqueue.cl
clang/test/CodeGenOpenCL/pipe_types.cl
clang/test/CodeGenOpenCL/to_addr_builtin.cl
clang/test/SemaOpenCL/cl20-device-side-enqueue.cl
clang/test/SemaOpenCL/clang-builtin-version.cl
clang/test/SemaOpenCL/to_addr_builtin.cl

Removed: 




diff  --git a/clang/include/clang/Basic/Builtins.def 
b/clang/include/clang/Basic/Builtins.def
index d2cb14d2fd8cc..a17d2e59f5d8b 100644
--- a/clang/include/clang/Basic/Builtins.def
+++ b/clang/include/clang/Basic/Builtins.def
@@ -1625,50 +1625,50 @@ LANGBUILTIN(__builtin_coro_suspend, "cIb", "n", 
COR_LANG)
 
 // OpenCL v2.0 s6.13.16, s9.17.3.5 - Pipe functions.
 // We need the generic prototype, since the packet type could be anything.
-LANGBUILTIN(read_pipe, "i.", "tn", OCLC20_LANG)
-LANGBUILTIN(write_pipe, "i.", "tn", OCLC20_LANG)
+LANGBUILTIN(read_pipe, "i.", "tn", OCL_PIPE)
+LANGBUILTIN(write_pipe, "i.", "tn", OCL_PIPE)
 
-LANGBUILTIN(reserve_read_pipe, "i.", "tn", OCLC20_LANG)
-LANGBUILTIN(reserve_write_pipe, "i.", "tn", OCLC20_LANG)
+LANGBUILTIN(reserve_read_pipe, "i.", "tn", OCL_PIPE)
+LANGBUILTIN(reserve_write_pipe, "i.", "tn", OCL_PIPE)
 
-LANGBUILTIN(commit_write_pipe, "v.", "tn", OCLC20_LANG)
-LANGBUILTIN(commit_read_pipe, "v.", "tn", OCLC20_LANG)
+LANGBUILTIN(commit_write_pipe, "v.", "tn", OCL_PIPE)
+LANGBUILTIN(commit_read_pipe, "v.", "tn", OCL_PIPE)
 
-LANGBUILTIN(sub_group_reserve_read_pipe, "i.", "tn", OCLC20_LANG)
-LANGBUILTIN(sub_group_reserve_write_pipe, "i.", "tn", OCLC20_LANG)
+LANGBUILTIN(sub_group_reserve_read_pipe, "i.", "tn", OCL_PIPE)
+LANGBUILTIN(sub_group_reserve_write_pipe, "i.", "tn", OCL_PIPE)
 
-LANGBUILTIN(sub_group_commit_read_pipe, "v.", "tn", OCLC20_LANG)
-LANGBUILTIN(sub_group_commit_write_pipe, "v.", "tn", OCLC20_LANG)
+LANGBUILTIN(sub_group_commit_read_pipe, "v.", "tn", OCL_PIPE)
+LANGBUILTIN(sub_group_commit_write_pipe, "v.", "tn", OCL_PIPE)
 
-LANGBUILTIN(work_group_reserve_read_pipe, "i.", "tn", OCLC20_LANG)
-LANGBUILTIN(work_group_reserve_write_pipe, "i.", "tn", OCLC20_LANG)
+LANGBUILTIN(work_group_reserve_read_pipe, "i.", "tn", OCL_PIPE)
+LANGBUILTIN(work_group_reserve_write_pipe, "i.", "tn", OCL_PIPE)
 
-LANGBUILTIN(work_group_commit_read_pipe, "v.", "tn", OCLC20_LANG)
-LANGBUILTIN(work_group_commit_write_pipe, "v.", "tn", OCLC20_LANG)
+LANGBUILTIN(work_group_commit_read_pipe, "v.", "tn", OCL_PIPE)
+LANGBUILTIN(work_group_commit_write_pipe, "v.", "tn", OCL_PIPE)
 
-LANGBUILTIN(get_pipe_num_packets, "Ui.", "tn", OCLC20_LANG)
-LANGBUILTIN(get_pipe_max_packets, "Ui.", "tn", OCLC20_LANG)
+LANGBUILTIN(get_pipe_num_packets, "Ui.", "tn", OCL_PIPE)
+LANGBUILTIN(get_pipe_max_packets, "Ui.", "tn", OCL_PIPE)
 
 // OpenCL v2.0 s6.13.17 - Enqueue kernel functions.
 // Custom builtin check allows to perform special check of passed block 
arguments.
-LANGBUILTIN(enqueue_kernel, "i.", "tn", OCLC20_LANG)
-LANGBUILTIN(get_kernel_work_group_size, "Ui.", "tn", OCLC20_LANG)
-LANGBUILTIN(get_kernel_preferred_work_group_size_multiple, "Ui.", "tn", 
OCLC20_LANG)
-LANGBUILTIN(get_kernel_max_sub_group_size_for_ndrange, "Ui.", "tn", 
OCLC20_LANG)
-LANGBUILTIN(get_kernel_sub_group_count_for_ndrange, "Ui.", "tn", OCLC20_LANG)
+LANGBUILTIN(enqueue_kernel, "i.", "tn", OCL_DSE)
+LANGBUILTIN(get_kernel_work_group_size, "Ui.", "tn", OCL_DSE)
+LANGBUILTIN(get_kernel_preferred_work_group_size_multiple, "Ui.", "tn", 
OCL_DSE)
+LANGBUILTIN(get_kernel_max_sub_group_size_for_ndrange, "Ui.", "tn", OCL_DSE)
+LANGBUILTIN(get_kernel_sub_group_count_for_ndrange, "Ui.", "tn", OCL_DSE)
 
 // OpenCL v2.0 s6.13.9 - Address space qualifier functions.
 // FIXME: Pointer parameters of OpenCL builtins should have their address space
 // requirement defined.
-LANGBUILTIN(to_global, "v*v*", "tn", OCLC20_LANG)
-LANGBUILTIN(to_local, "v*v*", "tn", OCLC20_LANG)
-LANGBUILTI

[llvm-branch-commits] [clang] 200390c - [clang] [MinGW] Recognize -lcrtdll as a library replacing -lmsvcrt

2022-02-14 Thread Tom Stellard via llvm-branch-commits

Author: Martin Storsjö
Date: 2022-02-14T14:13:29-08:00
New Revision: 200390c3c17196b9c0f34453eeb85175015b2283

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

LOG: [clang] [MinGW] Recognize -lcrtdll as a library replacing -lmsvcrt

Differential Revision: https://reviews.llvm.org/D119234

(cherry picked from commit 079b6d02d1f52301e2d3276fadba822bf87b75b2)

Added: 


Modified: 
clang/lib/Driver/ToolChains/MinGW.cpp
clang/test/Driver/mingw-msvcrt.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/MinGW.cpp 
b/clang/lib/Driver/ToolChains/MinGW.cpp
index 0501f97374044..ceeaa79bc2021 100644
--- a/clang/lib/Driver/ToolChains/MinGW.cpp
+++ b/clang/lib/Driver/ToolChains/MinGW.cpp
@@ -86,7 +86,9 @@ void tools::MinGW::Linker::AddLibGCC(const ArgList &Args,
   CmdArgs.push_back("-lmoldname");
   CmdArgs.push_back("-lmingwex");
   for (auto Lib : Args.getAllArgValues(options::OPT_l))
-if (StringRef(Lib).startswith("msvcr") || 
StringRef(Lib).startswith("ucrt"))
+if (StringRef(Lib).startswith("msvcr") ||
+StringRef(Lib).startswith("ucrt") ||
+StringRef(Lib).startswith("crtdll"))
   return;
   CmdArgs.push_back("-lmsvcrt");
 }

diff  --git a/clang/test/Driver/mingw-msvcrt.c 
b/clang/test/Driver/mingw-msvcrt.c
index bb4813ca33a5a..48a30d8469cb6 100644
--- a/clang/test/Driver/mingw-msvcrt.c
+++ b/clang/test/Driver/mingw-msvcrt.c
@@ -2,6 +2,7 @@
 // RUN: %clang -v -target i686-pc-windows-gnu -lmsvcr120 -### %s 2>&1 | 
FileCheck -check-prefix=CHECK_MSVCR120 %s
 // RUN: %clang -v -target i686-pc-windows-gnu -lucrtbase -### %s 2>&1 | 
FileCheck -check-prefix=CHECK_UCRTBASE %s
 // RUN: %clang -v -target i686-pc-windows-gnu -lucrt -### %s 2>&1 | FileCheck 
-check-prefix=CHECK_UCRT %s
+// RUN: %clang -v -target i686-pc-windows-gnu -lcrtdll -### %s 2>&1 | 
FileCheck -check-prefix=CHECK_CRTDLL %s
 
 // CHECK_DEFAULT: "-lmingwex" "-lmsvcrt" "-ladvapi32"
 // CHECK_DEFAULT-SAME: "-lmsvcrt" "-lkernel32" "{{.*}}crtend.o"
@@ -11,3 +12,5 @@
 // CHECK_UCRTBASE-SAME: "-lmingwex" "-ladvapi32"
 // CHECK_UCRT: "-lucrt"
 // CHECK_UCRT-SAME: "-lmingwex" "-ladvapi32"
+// CHECK_CRTDLL: "-lcrtdll"
+// CHECK_CRTDLL-SAME: "-lmingwex" "-ladvapi32"



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


[llvm-branch-commits] [clang] 7bb1dfe - [OpenCL] Adjust diagnostic for subgroup support.

2022-02-14 Thread Tom Stellard via llvm-branch-commits

Author: Anton Zabaznov
Date: 2022-02-14T14:13:04-08:00
New Revision: 7bb1dfeeba8779ab9740cf05f01198ed7ce41277

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

LOG: [OpenCL] Adjust diagnostic for subgroup support.

OpenCL C 3.0 __opencl_c_subgroups feature is slightly different
then other equivalent features and extensions (fp64 and 3d image writes):
OpenCL C 3.0 device can support the extension but not the feature.
cl_khr_subgroups requires subgroup independent forward progress.

This patch adjusts the check which is used when translating language
builtins to check either the extension or feature is supported.

Reviewed By: Anastasia

Differential Revision: https://reviews.llvm.org/D118999

(cherry picked from commit bfb1a33bec7c88170b0809b8a7c9cb860e7cc19b)

Added: 


Modified: 
clang/lib/Sema/SemaChecking.cpp
clang/test/SemaOpenCL/cl20-device-side-enqueue.cl

Removed: 




diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index dfbf4cdc89cb9..69dcc3f37 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -1042,9 +1042,15 @@ static bool checkOpenCLBlockArgs(Sema &S, Expr 
*BlockArg) {
 }
 
 static bool checkOpenCLSubgroupExt(Sema &S, CallExpr *Call) {
-  if (!S.getOpenCLOptions().isSupported("cl_khr_subgroups", S.getLangOpts())) {
+  // OpenCL device can support extension but not the feature as extension
+  // requires subgroup independent forward progress, but subgroup independent
+  // forward progress is optional in OpenCL C 3.0 __opencl_c_subgroups feature.
+  if (!S.getOpenCLOptions().isSupported("cl_khr_subgroups", S.getLangOpts()) &&
+  !S.getOpenCLOptions().isSupported("__opencl_c_subgroups",
+S.getLangOpts())) {
 S.Diag(Call->getBeginLoc(), diag::err_opencl_requires_extension)
-<< 1 << Call->getDirectCallee() << "cl_khr_subgroups";
+<< 1 << Call->getDirectCallee()
+<< "cl_khr_subgroups or __opencl_c_subgroups";
 return true;
   }
   return false;

diff  --git a/clang/test/SemaOpenCL/cl20-device-side-enqueue.cl 
b/clang/test/SemaOpenCL/cl20-device-side-enqueue.cl
index 9c375b2603ac1..344297ebbe0ca 100644
--- a/clang/test/SemaOpenCL/cl20-device-side-enqueue.cl
+++ b/clang/test/SemaOpenCL/cl20-device-side-enqueue.cl
@@ -4,7 +4,7 @@
 // RUN: %clang_cc1 %s -cl-std=CL2.0 -triple "spir64-unknown-unknown" -verify 
-pedantic -fsyntax-only -Wconversion -DWCONV -DQUALS=
 // RUN: %clang_cc1 %s -cl-std=CL2.0 -triple "spir64-unknown-unknown" -verify 
-pedantic -fsyntax-only -Wconversion -DWCONV -DQUALS="const volatile"
 // RUN: %clang_cc1 %s -cl-std=CL3.0 -triple "spir-unknown-unknown" -verify 
-pedantic -fsyntax-only -DB32 -DQUALS=
-// RUN: %clang_cc1 %s -cl-std=CL3.0 -triple "spir-unknown-unknown" -verify 
-pedantic -fsyntax-only -DB32 -DQUALS= -cl-ext=-cl_khr_subgroups
+// RUN: %clang_cc1 %s -cl-std=CL3.0 -triple "spir-unknown-unknown" -verify 
-pedantic -fsyntax-only -DB32 -DQUALS= 
-cl-ext=-cl_khr_subgroups,-__opencl_c_subgroups
 // RUN: %clang_cc1 %s -cl-std=CL3.0 -triple "spir-unknown-unknown" -verify 
-pedantic -fsyntax-only -DB32 -DQUALS="const volatile"
 // RUN: %clang_cc1 %s -cl-std=CL3.0 -triple "spir64-unknown-unknown" -verify 
-pedantic -fsyntax-only -Wconversion -DWCONV -DQUALS=
 // RUN: %clang_cc1 %s -cl-std=CL3.0 -triple "spir64-unknown-unknown" -verify 
-pedantic -fsyntax-only -Wconversion -DWCONV -DQUALS="const volatile"
@@ -241,12 +241,12 @@ kernel void bar(global unsigned int *buf)
 kernel void foo1(global unsigned int *buf)
 {
   ndrange_t n;
-  buf[0] = get_kernel_max_sub_group_size_for_ndrange(n, ^(){}); // 
expected-error {{use of declaration 'get_kernel_max_sub_group_size_for_ndrange' 
requires cl_khr_subgroups support}}
+  buf[0] = get_kernel_max_sub_group_size_for_ndrange(n, ^(){}); // 
expected-error {{use of declaration 'get_kernel_max_sub_group_size_for_ndrange' 
requires cl_khr_subgroups or __opencl_c_subgroups support}}
 }
 
 kernel void bar1(global unsigned int *buf)
 {
   ndrange_t n;
-  buf[0] = get_kernel_sub_group_count_for_ndrange(n, ^(){}); // expected-error 
{{use of declaration 'get_kernel_sub_group_count_for_ndrange' requires 
cl_khr_subgroups support}}
+  buf[0] = get_kernel_sub_group_count_for_ndrange(n, ^(){}); // expected-error 
{{use of declaration 'get_kernel_sub_group_count_for_ndrange' requires 
cl_khr_subgroups or __opencl_c_subgroups support}}
 }
 #endif // ifdef cl_khr_subgroups



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


[llvm-branch-commits] [llvm] f0b442c - [release] Use a supported way of building libc++ when building the documentation

2022-02-14 Thread Louis Dionne via llvm-branch-commits

Author: Louis Dionne
Date: 2022-02-14T18:06:42-05:00
New Revision: f0b442c8ac58bbd40489defd2f3d65ff0b02b09c

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

LOG: [release] Use a supported way of building libc++ when building the 
documentation

Instead of using the deprecated LLVM_ENABLE_PROJECTS build, use the
default runtimes build. This is just as fast, but it's supported.

Differential Revision: https://reviews.llvm.org/D119275

(cherry picked from commit f34f7dfe3a3d8a6ec2c582f5672c3ca37d9aed7c)

Added: 


Modified: 
llvm/utils/release/build-docs.sh

Removed: 




diff  --git a/llvm/utils/release/build-docs.sh 
b/llvm/utils/release/build-docs.sh
index 8b12a4526e13..6d416e4830e6 100755
--- a/llvm/utils/release/build-docs.sh
+++ b/llvm/utils/release/build-docs.sh
@@ -90,7 +90,7 @@ if [ -n "$release" ]; then
 fi
 
 cmake -G Ninja $srcdir -B $builddir \
-   
-DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;lld;libcxx;polly;flang" \
+   
-DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;lld;polly;flang" \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_DOXYGEN=ON \
-DLLVM_ENABLE_SPHINX=ON \
@@ -102,7 +102,6 @@ ninja -C $builddir \
docs-clang-html \
docs-clang-tools-html \
docs-flang-html \
-   docs-libcxx-html \
docs-lld-html \
docs-llvm-html \
docs-polly-html \
@@ -113,6 +112,13 @@ ninja -C $builddir \
doxygen-mlir \
doxygen-polly
 
+cmake -G Ninja $srcdir/../runtimes -B $builddir/runtimes-doc \
+   -DLLVM_ENABLE_RUNTIMES="libcxx" \
+   -DLLVM_ENABLE_SPHINX=ON \
+   -DSPHINX_WARNINGS_AS_ERRORS=OFF
+
+ninja -C $builddir/runtimes-doc \
+   docs-libcxx-html \
 
 package_doxygen llvm .
 package_doxygen clang tools/clang
@@ -121,7 +127,13 @@ package_doxygen flang tools/flang
 
 html_dir=$builddir/html-export/
 
-for d in docs/ tools/clang/docs/ tools/lld/docs/ tools/clang/tools/extra/docs/ 
projects/libcxx/docs/ tools/polly/docs/ tools/flang/docs/; do
+for d in docs/ tools/clang/docs/ tools/lld/docs/ tools/clang/tools/extra/docs/ 
tools/polly/docs/ tools/flang/docs/; do
   mkdir -p $html_dir/$d
   mv $builddir/$d/html/* $html_dir/$d/
 done
+
+# Keep the documentation for the runtimes under /projects/ to avoid breaking 
existing links.
+for d in libcxx/docs/; do
+  mkdir -p $html_dir/projects/$d
+  mv $builddir/runtimes-doc/$d/html/* $html_dir/projects/$d/
+done



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