[PATCH] D106773: [clang-format] Fix aligning with linebreaks #2

2021-07-26 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius accepted this revision.
curdeius added a comment.
This revision is now accepted and ready to land.

LGTM! That was quick! Thanks.
Please wait for @baramin to validate the fix before landing.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106773/new/

https://reviews.llvm.org/D106773

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


[PATCH] D105191: [Clang][OpenMP] Add support for Static Device Libraries

2021-07-26 Thread Saiyedul Islam via Phabricator via cfe-commits
saiislam updated this revision to Diff 361590.
saiislam added a comment.
Herald added a subscriber: ormris.

1. Simplified the nested loop to look for repeated SDLs.
2. Minimized creation of std::string in favour of StringRef wherever possible.
3. Added test cases


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105191/new/

https://reviews.llvm.org/D105191

Files:
  clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/CommonArgs.h
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/test/Driver/Inputs/hip_dev_lib/lib/libFatArchive.a
  clang/test/Driver/Inputs/hip_dev_lib/libFatArchive.a
  clang/test/Driver/fat_archive.cpp
  clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Index: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -1060,7 +1060,6 @@
 /// @link https://clang.llvm.org/docs/ClangOffloadBundler.html#bundle-entry-id
 bool isCodeObjectCompatible(OffloadTargetInfo &CodeObjectInfo,
 OffloadTargetInfo &TargetInfo) {
-
   // Compatible in case of exact match.
   if (CodeObjectInfo == TargetInfo) {
 DEBUG_WITH_TYPE(
@@ -1158,7 +1157,6 @@
 
   Error ArchiveErr = Error::success();
   auto ChildEnd = Archive->child_end();
-
   /// Iterate over all bundled code object files in the input archive.
   for (auto ArchiveIter = Archive->child_begin(ArchiveErr);
ArchiveIter != ChildEnd; ++ArchiveIter) {
Index: clang/test/Driver/fat_archive.cpp
===
--- /dev/null
+++ clang/test/Driver/fat_archive.cpp
@@ -0,0 +1,69 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: amdgpu-registered-target
+
+// Test succeeds if no linked error i.e. all external symbols in the archive
+// could be resolved correctly.
+// RUN: env LIBRARY_PATH=%T/../../../../../runtimes/runtimes-bins/openmp/libomptarget %clang -O2 -target x86_64-pc-linux-gnu -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx906 %s -L%S/Inputs/hip_dev_lib -lFatArchive -o - | FileCheck %s -check-prefix=LINKERROR
+// LINKERROR-NOT: error: linker command failed with exit code 1
+
+// Given a FatArchive, clang-offload-bundler should be called to create a
+// device specific archive, which should be passed to llvm-link.
+// RUN: env LIBRARY_PATH=%T/../../../../../runtimes/runtimes-bins/openmp/libomptarget %clang -O2 -### -target x86_64-pc-linux-gnu -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx906 %s -L%S/Inputs/hip_dev_lib -lFatArchive 2>&1 | FileCheck %s
+// CHECK: clang{{.*}}"-cc1" "-triple" "x86_64-pc-linux-gnu"{{.*}}"-o" "[[HOSTOBJ:.*.o]]" "-x" "ir"{{.*}}
+// CHECK: clang{{.*}}"-cc1"{{.*}}"-triple" "amdgcn-amd-amdhsa"{{.*}}"-emit-llvm-bc"{{.*}}"-target-cpu" "gfx906"{{.*}}"-o" "[[HOSTBC:.*.bc]]" "-x" "c++"{{.*}}.cpp
+// CHECK: clang-offload-bundler" "-unbundle" "-type=a" "-inputs={{.*}}/Inputs/hip_dev_lib/libFatArchive.a" "-targets=openmp-amdgcn-amd-amdhsa--gfx906" "-outputs=[[DEVICESPECIFICARCHIVE:.*.a]]" "-allow-missing-bundles"
+// CHECK: llvm-link{{.*}}"[[HOSTBC]]" "[[DEVICESPECIFICARCHIVE]]" "-o" "{{.*}}-gfx906-linked-{{.*}}.bc"
+// CHECK: ld.lld"{{.*}}" "-L{{.*}}/Inputs/hip_dev_lib" "{{.*}}"[[HOSTOBJ]]" "-lFatArchive" "{{.*}}" "-lomp{{.*}}-lomptarget"
+// expected-no-diagnostics
+
+// Tests for linker and loader errors in case external symbols are not found in
+// the FatArchive.
+// RUN: env LIBRARY_PATH=%T/../../../../../runtimes/runtimes-bins/openmp/libomptarget not %clang -O2 -target x86_64-pc-linux-gnu -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx906 %s -L%S/Inputs/hip_dev_lib -lFatArchive -DUNDEF=1 2>&1 | FileCheck %s -check-prefix=UNDEFSYM
+// UNDEFSYM: ld.lld: error: undefined symbol: func_3v
+// UNDEFSYM: error: linker command failed with exit code 1
+
+#ifndef HEADER
+#define HEADER
+
+#define N 10
+
+#pragma omp declare target
+// Functions defined in Fat Archive.
+extern "C" void func_1v(float *in, float *out, unsigned);
+extern "C" void func_2v(float *in, float *out, unsigned);
+
+#ifdef UNDEF
+// Function not defined in the fat archive.
+extern "C" void func_3v(float *in, float *out, unsigned);
+#endif
+
+#pragma omp end declare target
+
+int main() {
+  float a[N], t1[N], t2[N], sum = 0;
+  unsigned i;
+
+#pragma omp parallel for
+  for (i = 0; i < N; ++i) {
+a[i] = i;
+  }
+
+  func_1v(a, t1, N); // Returns t1[i] = a[i] + 2
+  func_2v(a, t2, N); // Returns t2[i] = a[i] - 2
+
+#ifdef UNDEF
+  func_3v(a, t2, N); // Should throw an error here
+#endif
+
+#pragma omp parallel for reduction(+ \
+   : sum)
+  for (

[PATCH] D105191: [Clang][OpenMP] Add support for Static Device Libraries

2021-07-26 Thread Saiyedul Islam via Phabricator via cfe-commits
saiislam updated this revision to Diff 361591.
saiislam added a comment.

Couple of wrong files got added in the last commit.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105191/new/

https://reviews.llvm.org/D105191

Files:
  clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/CommonArgs.h
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/test/Driver/Inputs/hip_dev_lib/libFatArchive.a
  clang/test/Driver/fat_archive.cpp

Index: clang/test/Driver/fat_archive.cpp
===
--- /dev/null
+++ clang/test/Driver/fat_archive.cpp
@@ -0,0 +1,69 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: amdgpu-registered-target
+
+// Test succeeds if no linked error i.e. all external symbols in the archive
+// could be resolved correctly.
+// RUN: env LIBRARY_PATH=%T/../../../../../runtimes/runtimes-bins/openmp/libomptarget %clang -O2 -target x86_64-pc-linux-gnu -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx906 %s -L%S/Inputs/hip_dev_lib -lFatArchive -o - | FileCheck %s -check-prefix=LINKERROR
+// LINKERROR-NOT: error: linker command failed with exit code 1
+
+// Given a FatArchive, clang-offload-bundler should be called to create a
+// device specific archive, which should be passed to llvm-link.
+// RUN: env LIBRARY_PATH=%T/../../../../../runtimes/runtimes-bins/openmp/libomptarget %clang -O2 -### -target x86_64-pc-linux-gnu -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx906 %s -L%S/Inputs/hip_dev_lib -lFatArchive 2>&1 | FileCheck %s
+// CHECK: clang{{.*}}"-cc1" "-triple" "x86_64-pc-linux-gnu"{{.*}}"-o" "[[HOSTOBJ:.*.o]]" "-x" "ir"{{.*}}
+// CHECK: clang{{.*}}"-cc1"{{.*}}"-triple" "amdgcn-amd-amdhsa"{{.*}}"-emit-llvm-bc"{{.*}}"-target-cpu" "gfx906"{{.*}}"-o" "[[HOSTBC:.*.bc]]" "-x" "c++"{{.*}}.cpp
+// CHECK: clang-offload-bundler" "-unbundle" "-type=a" "-inputs={{.*}}/Inputs/hip_dev_lib/libFatArchive.a" "-targets=openmp-amdgcn-amd-amdhsa--gfx906" "-outputs=[[DEVICESPECIFICARCHIVE:.*.a]]" "-allow-missing-bundles"
+// CHECK: llvm-link{{.*}}"[[HOSTBC]]" "[[DEVICESPECIFICARCHIVE]]" "-o" "{{.*}}-gfx906-linked-{{.*}}.bc"
+// CHECK: ld.lld"{{.*}}" "-L{{.*}}/Inputs/hip_dev_lib" "{{.*}}"[[HOSTOBJ]]" "-lFatArchive" "{{.*}}" "-lomp{{.*}}-lomptarget"
+// expected-no-diagnostics
+
+// Tests for linker and loader errors in case external symbols are not found in
+// the FatArchive.
+// RUN: env LIBRARY_PATH=%T/../../../../../runtimes/runtimes-bins/openmp/libomptarget not %clang -O2 -target x86_64-pc-linux-gnu -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx906 %s -L%S/Inputs/hip_dev_lib -lFatArchive -DUNDEF=1 2>&1 | FileCheck %s -check-prefix=UNDEFSYM
+// UNDEFSYM: ld.lld: error: undefined symbol: func_3v
+// UNDEFSYM: error: linker command failed with exit code 1
+
+#ifndef HEADER
+#define HEADER
+
+#define N 10
+
+#pragma omp declare target
+// Functions defined in Fat Archive.
+extern "C" void func_1v(float *in, float *out, unsigned);
+extern "C" void func_2v(float *in, float *out, unsigned);
+
+#ifdef UNDEF
+// Function not defined in the fat archive.
+extern "C" void func_3v(float *in, float *out, unsigned);
+#endif
+
+#pragma omp end declare target
+
+int main() {
+  float a[N], t1[N], t2[N], sum = 0;
+  unsigned i;
+
+#pragma omp parallel for
+  for (i = 0; i < N; ++i) {
+a[i] = i;
+  }
+
+  func_1v(a, t1, N); // Returns t1[i] = a[i] + 2
+  func_2v(a, t2, N); // Returns t2[i] = a[i] - 2
+
+#ifdef UNDEF
+  func_3v(a, t2, N); // Should throw an error here
+#endif
+
+#pragma omp parallel for reduction(+ \
+   : sum)
+  for (i = 0; i < N; ++i)
+sum += a[i] - (t1[i] - t2[i]);
+
+  if (!sum)
+return 0;
+  return sum;
+}
+
+#endif
\ No newline at end of file
Index: clang/lib/Driver/ToolChains/Cuda.cpp
===
--- clang/lib/Driver/ToolChains/Cuda.cpp
+++ clang/lib/Driver/ToolChains/Cuda.cpp
@@ -632,6 +632,9 @@
 CmdArgs.push_back(CubinF);
   }
 
+  AddStaticDeviceLibs(C, *this, JA, Inputs, Args, CmdArgs, "nvptx", GPUArch,
+  false, false);
+
   const char *Exec =
   Args.MakeArgString(getToolChain().GetProgramPath("nvlink"));
   C.addCommand(std::make_unique(
@@ -754,6 +757,8 @@
 std::string BitcodeSuffix = "nvptx-" + GpuArch.str();
 addOpenMPDeviceRTL(getDriver(), DriverArgs, CC1Args, BitcodeSuffix,
getTriple());
+AddStaticDeviceLibs(getDriver(), DriverArgs, CC1Args, "nvptx", GpuArch,
+/* bitcode SDL?*/ true, /* PostClang Link? */ true);
   }
 }
 
Index: clang/lib/Driver/ToolChains/CommonArgs.h
===
--- clang/lib/Driver/ToolChain

[PATCH] D94098: [Clang][AArch64] Inline assembly support for the ACLE type 'data512_t'.

2021-07-26 Thread Alexandros Lamprineas via Phabricator via cfe-commits
labrinea added a comment.

ping


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94098/new/

https://reviews.llvm.org/D94098

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


[PATCH] D106773: [clang-format] Fix aligning with linebreaks #2

2021-07-26 Thread Alexey Utkin via Phabricator via cfe-commits
baramin added a comment.

LGTM!
It solves my problem.
Thanks!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106773/new/

https://reviews.llvm.org/D106773

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


[PATCH] D106262: [clang][analyzer] Use generic note tag in alpha.unix.Stream .

2021-07-26 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:236-242
+  const BugMessageMap BugMessages = {
+  {&BT_FileNull, "Assuming opening the stream fails here"},
+  {&BT_UseAfterClose, "Stream closed here"},
+  {&BT_UseAfterOpenFailed, "Assuming opening the stream fails here"},
+  {&BT_IndeterminatePosition, "Assuming this stream operation fails"},
+  {&BT_StreamEof, "Assuming stream reaches end-of-file here"},
+  {&BT_ResourceLeak, "Stream opened here"}};

Szelethus wrote:
> Well this looks odd: for both `BT_StreamEof` AND `BT_IndeterminatePosition` 
> we want to display a `NoteTag` for a failed `fseek`, for one you print 
> "Assuming stream reaches end-of-file here", for the other, "Assuming this 
> stream operation fails". This seems to contradict your comment in the fseek 
> evaluating function:
> 
> ```
> If fseek failed, assume that the file position becomes indeterminate in any 
> case.
> ```
> 
> Also, these `BugTypes` should be responsible for the *error message*, not the 
> `NoteTag` message. I'd prefer if we mapped an enum to these strings 
> (`NoteTagMsgKind`?), pass that as well to `constructNoteTag`, and allow the 
> caller to decide that for which `BugTypes` the `NoteTag` is worth displaying 
> for.
> 
> I think such a 4-argument `constructNoteTag` would capture best what we want 
> here.
It is still unclear how to model the `fseek` (and other functions). (But this 
is not a problem for this patch.) We can do it according the POSIX or C 
standard, or just by the experience that a `fseek` may fail with EOF or 
`ferror` or none of them. The standards are not exact but do not mention that 
`fseek` should cause the indeterminate flag to be set at all, or that `fseek` 
can cause `feof` state.



Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:236-242
+  const BugMessageMap BugMessages = {
+  {&BT_FileNull, "Assuming opening the stream fails here"},
+  {&BT_UseAfterClose, "Stream closed here"},
+  {&BT_UseAfterOpenFailed, "Assuming opening the stream fails here"},
+  {&BT_IndeterminatePosition, "Assuming this stream operation fails"},
+  {&BT_StreamEof, "Assuming stream reaches end-of-file here"},
+  {&BT_ResourceLeak, "Stream opened here"}};

balazske wrote:
> Szelethus wrote:
> > Well this looks odd: for both `BT_StreamEof` AND `BT_IndeterminatePosition` 
> > we want to display a `NoteTag` for a failed `fseek`, for one you print 
> > "Assuming stream reaches end-of-file here", for the other, "Assuming this 
> > stream operation fails". This seems to contradict your comment in the fseek 
> > evaluating function:
> > 
> > ```
> > If fseek failed, assume that the file position becomes indeterminate in any 
> > case.
> > ```
> > 
> > Also, these `BugTypes` should be responsible for the *error message*, not 
> > the `NoteTag` message. I'd prefer if we mapped an enum to these strings 
> > (`NoteTagMsgKind`?), pass that as well to `constructNoteTag`, and allow the 
> > caller to decide that for which `BugTypes` the `NoteTag` is worth 
> > displaying for.
> > 
> > I think such a 4-argument `constructNoteTag` would capture best what we 
> > want here.
> It is still unclear how to model the `fseek` (and other functions). (But this 
> is not a problem for this patch.) We can do it according the POSIX or C 
> standard, or just by the experience that a `fseek` may fail with EOF or 
> `ferror` or none of them. The standards are not exact but do not mention that 
> `fseek` should cause the indeterminate flag to be set at all, or that `fseek` 
> can cause `feof` state.
The message for a NoteTag depends on the bug type and at this state the bug 
type is sufficient to determine the note message. Because it is possible to add 
multiple bug types to a NoteTag, passing a custom message to it can be done 
only by passing a BugType->Message map to the note tag. This may be unnecessary 
complexity for the current use case.



Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:387-391
+  /// Create a NoteTag to display a note if a later bug report is generated.
+  /// The `BT` should contain all bug types that could be caused by the
+  /// operation at this location.
+  /// If later on the path a problematic event (reported bug) happens with the
+  /// same type, the last place is found with a note tag with that bug type.

Szelethus wrote:
> How about:
> 
> Create a `NoteTag` describing an stream operation (whether stream opening 
> succeeds or fails, stream reaches EOF, etc).
> As not all operations are interesting for all types of stream bugs (the 
> stream being at an indeterminate file position is irrelevant to whether it 
> leaks or not), callers can specify in `BT` for which `BugType`s should this 
> note be displayed for.
> Only the `NoteTag` closest to the error location will be added to the bug 
>

[PATCH] D105191: [Clang][OpenMP] Add support for Static Device Libraries

2021-07-26 Thread Saiyedul Islam via Phabricator via cfe-commits
saiislam marked 5 inline comments as done.
saiislam added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:7674-7687
+StringRef GPUArchName;
+if ((CurKind == Action::OFK_OpenMP)) {
+  // Extract GPUArch from -march argument in TC argument list.
+  for (uint ArgIndex = 0; ArgIndex < TCArgs.size(); ArgIndex++) {
+StringRef ArchStr = StringRef(TCArgs.getArgString(ArgIndex));
+auto Arch = ArchStr.startswith_insensitive("-march=");
+if (Arch) {

It will be replaced with a method invocation to get GPUArch in an upcoming 
patch to support multi-architecture compilation.



Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:1689
+   : "lib" + libname + "-" + archname + "-" + gpuname,
+  "a");
+

grokos wrote:
> "a" --> ".a" (add a dot)
"a" is second argument of GetTemporayPath and doesn't the prefix "."


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105191/new/

https://reviews.llvm.org/D105191

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


[PATCH] D105819: [analyzer] MallocChecker: Add a visitor to leave a note on functions that could have, but did not change ownership on leaked memory

2021-07-26 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

Ping


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105819/new/

https://reviews.llvm.org/D105819

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


[PATCH] D91950: [clang-format] Add BreakBeforeInlineASMColon configuration

2021-07-26 Thread Anastasiia Lukianenko via Phabricator via cfe-commits
anastasiia_lukianenko added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:3800
+  FormatStyle Style = getLLVMStyle();
+  Style.BreakBeforeInlineASMColon = true;
   verifyFormat(

HazardyKnusperkeks wrote:
> I already gave my go in the past, but now I have to wonder, why are you 
> setting this to `true` here? Does this mean before your change clang-format 
> did behave as if the option is `true`? If that's the case please set the 
> default also to `true`. If the old behavior is neither `true` nor `false` we 
> have to find something different.
Old behavior is neither true nor false. As I understand, the behavior was doing 
break only in case when the string length is longer than column limit.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91950/new/

https://reviews.llvm.org/D91950

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


[PATCH] D93373: [Flang][Openmp] Upgrade TASKGROUP construct to 5.0.

2021-07-26 Thread Chirag Khandelwal via Phabricator via cfe-commits
AMDChirag updated this revision to Diff 361597.
AMDChirag added a comment.

Rebase to current main branch


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93373/new/

https://reviews.llvm.org/D93373

Files:
  clang/test/OpenMP/master_taskloop_simd_ast_print.cpp
  clang/test/OpenMP/parallel_master_taskloop_simd_ast_print.cpp
  clang/test/OpenMP/taskloop_simd_ast_print.cpp
  flang/lib/Semantics/resolve-directives.cpp
  flang/lib/Semantics/resolve-names.cpp
  flang/test/Semantics/omp-taskgroup01.f90
  llvm/include/llvm/Frontend/OpenMP/OMP.td

Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -473,8 +473,8 @@
 }
 def OMP_TaskGroup : Directive<"taskgroup"> {
   let allowedClauses = [
-VersionedClause,
-VersionedClause
+VersionedClause,
+VersionedClause
   ];
 }
 def OMP_Flush : Directive<"flush"> {
Index: flang/test/Semantics/omp-taskgroup01.f90
===
--- /dev/null
+++ flang/test/Semantics/omp-taskgroup01.f90
@@ -0,0 +1,47 @@
+! RUN: %S/test_errors.sh %s %t %flang -fopenmp
+use omp_lib
+  implicit none
+  integer :: xyz, abc
+  real :: reduction_var
+  !$omp parallel num_threads(4)
+!$omp single
+  print *, "The"
+!$omp taskgroup
+  !$omp task
+  print *, "almighty"
+  !$omp end task
+  !$omp task
+  print *, "sun"
+  !$omp end task
+!$omp end taskgroup
+!$omp end single
+  !$omp end parallel
+
+  !$omp parallel private(xyz)
+!$omp taskgroup allocate(xyz)
+  !$omp task
+print *, "The "
+!$omp taskgroup allocate(omp_large_cap_mem_space: abc)
+  !$omp task
+  print *, "almighty sun"
+  !$omp end task
+!$omp end taskgroup
+  !$omp end task
+!$omp end taskgroup
+  !$omp end parallel
+
+  !ERROR: PRIVATE clause is not allowed on the TASKGROUP directive
+  !$omp taskgroup private(abc)
+  !$omp end taskgroup
+
+  !$omp parallel
+!$omp task
+  !$omp taskgroup task_reduction(+ : reduction_var)
+  print *, "The "
+!$omp taskgroup task_reduction(.or. : reduction_var) task_reduction(.and. : reduction_var)
+  print *, "almighty sun"
+!$omp end taskgroup
+  !$omp end taskgroup
+!$omp end task
+  !$omp end parallel
+end program
\ No newline at end of file
Index: flang/lib/Semantics/resolve-names.cpp
===
--- flang/lib/Semantics/resolve-names.cpp
+++ flang/lib/Semantics/resolve-names.cpp
@@ -1288,6 +1288,7 @@
   case llvm::omp::Directive::OMPD_target_data:
   case llvm::omp::Directive::OMPD_master:
   case llvm::omp::Directive::OMPD_ordered:
+  case llvm::omp::Directive::OMPD_taskgroup:
 return false;
   default:
 return true;
Index: flang/lib/Semantics/resolve-directives.cpp
===
--- flang/lib/Semantics/resolve-directives.cpp
+++ flang/lib/Semantics/resolve-directives.cpp
@@ -1069,12 +1069,12 @@
   case llvm::omp::Directive::OMPD_target:
   case llvm::omp::Directive::OMPD_target_data:
   case llvm::omp::Directive::OMPD_task:
+  case llvm::omp::Directive::OMPD_taskgroup:
   case llvm::omp::Directive::OMPD_teams:
   case llvm::omp::Directive::OMPD_workshare:
   case llvm::omp::Directive::OMPD_parallel_workshare:
   case llvm::omp::Directive::OMPD_target_teams:
   case llvm::omp::Directive::OMPD_target_parallel:
-  case llvm::omp::Directive::OMPD_taskgroup:
 PushContext(beginDir.source, beginDir.v);
 break;
   default:
Index: clang/test/OpenMP/taskloop_simd_ast_print.cpp
===
--- clang/test/OpenMP/taskloop_simd_ast_print.cpp
+++ clang/test/OpenMP/taskloop_simd_ast_print.cpp
@@ -1,13 +1,13 @@
-// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -ast-print %s | FileCheck %s --check-prefix CHECK --check-prefix OMP45
-// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s --check-prefix CHECK --check-prefix OMP45
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=50 -DOMP5 -ast-print %s | FileCheck %s --check-prefix CHECK --check-prefix OMP50
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -DOMP5 -x c++ -std=c++11 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -DOMP5 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s --check-prefix CHECK --check-prefix OMP50
 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=50 -ast-print %s -DOMP5 | FileCheck %s --check-prefix CHECK --check-prefix OMP50
 // RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c++ -std=c++11 -emit-pch -o %t %s -DOMP5
 // RUN: %

[PATCH] D93373: [Flang][Openmp] Upgrade TASKGROUP construct to 5.0.

2021-07-26 Thread Chirag Khandelwal via Phabricator via cfe-commits
AMDChirag updated this revision to Diff 361598.
AMDChirag added a comment.

Removed parent line in summary, it was not longer relevant and caused build 
failures.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93373/new/

https://reviews.llvm.org/D93373

Files:
  clang/test/OpenMP/master_taskloop_simd_ast_print.cpp
  clang/test/OpenMP/parallel_master_taskloop_simd_ast_print.cpp
  clang/test/OpenMP/taskloop_simd_ast_print.cpp
  flang/lib/Semantics/resolve-directives.cpp
  flang/lib/Semantics/resolve-names.cpp
  flang/test/Semantics/omp-taskgroup01.f90
  llvm/include/llvm/Frontend/OpenMP/OMP.td

Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -473,8 +473,8 @@
 }
 def OMP_TaskGroup : Directive<"taskgroup"> {
   let allowedClauses = [
-VersionedClause,
-VersionedClause
+VersionedClause,
+VersionedClause
   ];
 }
 def OMP_Flush : Directive<"flush"> {
Index: flang/test/Semantics/omp-taskgroup01.f90
===
--- /dev/null
+++ flang/test/Semantics/omp-taskgroup01.f90
@@ -0,0 +1,47 @@
+! RUN: %S/test_errors.sh %s %t %flang -fopenmp
+use omp_lib
+  implicit none
+  integer :: xyz, abc
+  real :: reduction_var
+  !$omp parallel num_threads(4)
+!$omp single
+  print *, "The"
+!$omp taskgroup
+  !$omp task
+  print *, "almighty"
+  !$omp end task
+  !$omp task
+  print *, "sun"
+  !$omp end task
+!$omp end taskgroup
+!$omp end single
+  !$omp end parallel
+
+  !$omp parallel private(xyz)
+!$omp taskgroup allocate(xyz)
+  !$omp task
+print *, "The "
+!$omp taskgroup allocate(omp_large_cap_mem_space: abc)
+  !$omp task
+  print *, "almighty sun"
+  !$omp end task
+!$omp end taskgroup
+  !$omp end task
+!$omp end taskgroup
+  !$omp end parallel
+
+  !ERROR: PRIVATE clause is not allowed on the TASKGROUP directive
+  !$omp taskgroup private(abc)
+  !$omp end taskgroup
+
+  !$omp parallel
+!$omp task
+  !$omp taskgroup task_reduction(+ : reduction_var)
+  print *, "The "
+!$omp taskgroup task_reduction(.or. : reduction_var) task_reduction(.and. : reduction_var)
+  print *, "almighty sun"
+!$omp end taskgroup
+  !$omp end taskgroup
+!$omp end task
+  !$omp end parallel
+end program
\ No newline at end of file
Index: flang/lib/Semantics/resolve-names.cpp
===
--- flang/lib/Semantics/resolve-names.cpp
+++ flang/lib/Semantics/resolve-names.cpp
@@ -1288,6 +1288,7 @@
   case llvm::omp::Directive::OMPD_target_data:
   case llvm::omp::Directive::OMPD_master:
   case llvm::omp::Directive::OMPD_ordered:
+  case llvm::omp::Directive::OMPD_taskgroup:
 return false;
   default:
 return true;
Index: flang/lib/Semantics/resolve-directives.cpp
===
--- flang/lib/Semantics/resolve-directives.cpp
+++ flang/lib/Semantics/resolve-directives.cpp
@@ -1069,12 +1069,12 @@
   case llvm::omp::Directive::OMPD_target:
   case llvm::omp::Directive::OMPD_target_data:
   case llvm::omp::Directive::OMPD_task:
+  case llvm::omp::Directive::OMPD_taskgroup:
   case llvm::omp::Directive::OMPD_teams:
   case llvm::omp::Directive::OMPD_workshare:
   case llvm::omp::Directive::OMPD_parallel_workshare:
   case llvm::omp::Directive::OMPD_target_teams:
   case llvm::omp::Directive::OMPD_target_parallel:
-  case llvm::omp::Directive::OMPD_taskgroup:
 PushContext(beginDir.source, beginDir.v);
 break;
   default:
Index: clang/test/OpenMP/taskloop_simd_ast_print.cpp
===
--- clang/test/OpenMP/taskloop_simd_ast_print.cpp
+++ clang/test/OpenMP/taskloop_simd_ast_print.cpp
@@ -1,13 +1,13 @@
-// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -ast-print %s | FileCheck %s --check-prefix CHECK --check-prefix OMP45
-// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s --check-prefix CHECK --check-prefix OMP45
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=50 -DOMP5 -ast-print %s | FileCheck %s --check-prefix CHECK --check-prefix OMP50
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -DOMP5 -x c++ -std=c++11 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -DOMP5 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s --check-prefix CHECK --check-prefix OMP50
 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=50 -ast-print %s -DOMP5 | FileCheck %s --check-prefix CHECK --check-prefix OMP50
 // RUN: %clang_cc1 -fopenmp -fopenmp-version=

[PATCH] D91950: [clang-format] Add BreakBeforeInlineASMColon configuration

2021-07-26 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks requested changes to this revision.
HazardyKnusperkeks added a comment.
This revision now requires changes to proceed.

Then I am sorry that I've missed that before. But you need to change your 
`bool` to an `enum` and also model the current behavior, so that there is no 
change in formatting without adapting the `.clang-format`. A option names maybe 
`Always`, `Never`, and `OnlyMultiline`?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91950/new/

https://reviews.llvm.org/D91950

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


[clang-tools-extra] 0a3c796 - Revert "Revert D106562 "[clangd] Get rid of arg adjusters in CommandMangler""

2021-07-26 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2021-07-26T11:13:22+02:00
New Revision: 0a3c7960cba15b57f679159c2bb4d20d10b86a5c

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

LOG: Revert "Revert D106562 "[clangd] Get rid of arg adjusters in 
CommandMangler""

This reverts commit 2aa0cf19e7fe17c9eb5eb2555e10184061b933f1.
Get rid of reference to the temporary.

Added: 


Modified: 
clang-tools-extra/clangd/CompileCommands.cpp
clang-tools-extra/clangd/CompileCommands.h
clang-tools-extra/clangd/Compiler.cpp
clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
clang-tools-extra/clangd/unittests/CompilerTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/CompileCommands.cpp 
b/clang-tools-extra/clangd/CompileCommands.cpp
index e749720b83a13..ffc66303c9fc4 100644
--- a/clang-tools-extra/clangd/CompileCommands.cpp
+++ b/clang-tools-extra/clangd/CompileCommands.cpp
@@ -12,6 +12,8 @@
 #include "clang/Driver/Options.h"
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Tooling/ArgumentsAdjusters.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Option/Option.h"
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/Debug.h"
@@ -20,6 +22,7 @@
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Program.h"
+#include 
 #include 
 #include 
 
@@ -202,14 +205,9 @@ void CommandMangler::adjust(std::vector &Cmd) 
const {
 return false;
   };
 
-  // clangd should not write files to disk, including dependency files
-  // requested on the command line.
-  Cmd = tooling::getClangStripDependencyFileAdjuster()(Cmd, "");
-  // Strip plugin related command line arguments. Clangd does
-  // not support plugins currently. Therefore it breaks if
-  // compiler tries to load plugins.
-  Cmd = tooling::getStripPluginsAdjuster()(Cmd, "");
-  Cmd = tooling::getClangSyntaxOnlyAdjuster()(Cmd, "");
+  llvm::erase_if(Cmd, [](llvm::StringRef Elem) {
+return Elem.startswith("--save-temps") || Elem.startswith("-save-temps");
+  });
 
   std::vector ToAppend;
   if (ResourceDir && !Has("-resource-dir"))
@@ -223,8 +221,8 @@ void CommandMangler::adjust(std::vector &Cmd) 
const {
   }
 
   if (!ToAppend.empty()) {
-Cmd = tooling::getInsertArgumentAdjuster(
-std::move(ToAppend), tooling::ArgumentInsertPosition::END)(Cmd, "");
+Cmd.insert(llvm::find(Cmd, "--"), 
std::make_move_iterator(ToAppend.begin()),
+   std::make_move_iterator(ToAppend.end()));
   }
 
   if (!Cmd.empty()) {

diff  --git a/clang-tools-extra/clangd/CompileCommands.h 
b/clang-tools-extra/clangd/CompileCommands.h
index 6e958d271c87b..759472413fdaf 100644
--- a/clang-tools-extra/clangd/CompileCommands.h
+++ b/clang-tools-extra/clangd/CompileCommands.h
@@ -25,6 +25,10 @@ namespace clangd {
 //  - forcing the use of clangd's builtin headers rather than clang's
 //  - resolving argv0 as cc1 expects
 //  - injecting -isysroot flags on mac as the system clang does
+// FIXME: This is currently not used in all code paths that create invocations.
+// Make use of these adjusters and buildCompilerInvocation in clangd-indexer as
+// well. It should be possible to hook it up by overriding RunInvocation in
+// FrontendActionFactory.
 struct CommandMangler {
   // Absolute path to clang.
   llvm::Optional ClangPath;

diff  --git a/clang-tools-extra/clangd/Compiler.cpp 
b/clang-tools-extra/clangd/Compiler.cpp
index a7e48934ddaf2..f2fb4489f105a 100644
--- a/clang-tools-extra/clangd/Compiler.cpp
+++ b/clang-tools-extra/clangd/Compiler.cpp
@@ -64,6 +64,7 @@ buildCompilerInvocation(const ParseInputs &Inputs, 
clang::DiagnosticConsumer &D,
   // our compiler invocation set-up doesn't seem to work with it (leading
   // assertions in VerifyDiagnosticConsumer).
   CI->getDiagnosticOpts().VerifyDiagnostics = false;
+  CI->getDiagnosticOpts().ShowColors = false;
 
   // Disable any dependency outputting, we don't want to generate files or 
write
   // to stdout/stderr.
@@ -90,6 +91,12 @@ buildCompilerInvocation(const ParseInputs &Inputs, 
clang::DiagnosticConsumer &D,
   CI->getHeaderSearchOpts().ModuleFormat =
   PCHContainerOperations().getRawReader().getFormat().str();
 
+  CI->getFrontendOpts().Plugins.clear();
+  CI->getFrontendOpts().AddPluginActions.clear();
+  CI->getFrontendOpts().PluginArgs.clear();
+  CI->getFrontendOpts().ProgramAction = frontend::ParseSyntaxOnly;
+  CI->getFrontendOpts().ActionName.clear();
+
   return CI;
 }
 

diff  --git a/clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp 
b/clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
index 7fb2ae7664fa7..f5727305b465c 100644
--- a/clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
+++ b/clang-tools-extra/clangd/unittests/C

[clang-tools-extra] e9274af - Revert "[clangd] Avoid range-loop init-list lifetime subtleties."

2021-07-26 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2021-07-26T11:38:47+02:00
New Revision: e9274af7189333d1f50e47098d9ae30522d7193f

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

LOG: Revert "[clangd] Avoid range-loop init-list lifetime subtleties."

This reverts commit 253b8145dedbe8d10792f44b4af7f52dbecd527f.

This doesn't actually fix anything - I should stop guessing.
See https://github.com/clangd/clangd/issues/800 for update

Added: 


Modified: 
clang-tools-extra/clangd/GlobalCompilationDatabase.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp 
b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
index 73f19abaeb9d..d830190bfdfd 100644
--- a/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
+++ b/clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
@@ -276,7 +276,7 @@ bool 
DirectoryBasedGlobalCompilationDatabase::DirectoryCache::load(
   // For these, we know the files they read and cache their metadata so we can
   // cheaply validate whether they've changed, and hot-reload if they have.
   // (As a bonus, these are also VFS-clean)!
-  struct {
+  struct CDBFile {
 CachedFile *File;
 // Wrapper for {Fixed,JSON}CompilationDatabase::loadFromBuffer.
 llvm::function_ref(
@@ -284,12 +284,10 @@ bool 
DirectoryBasedGlobalCompilationDatabase::DirectoryCache::load(
 /*Data*/ llvm::StringRef,
 /*ErrorMsg*/ std::string &)>
 Parser;
-  } Files[] = {
-  {&CompileCommandsJson, parseJSON},
-  {&BuildCompileCommandsJson, parseJSON},
-  {&CompileFlagsTxt, parseFixed},
   };
-  for (const auto &Entry : Files) {
+  for (const auto &Entry : {CDBFile{&CompileCommandsJson, parseJSON},
+CDBFile{&BuildCompileCommandsJson, parseJSON},
+CDBFile{&CompileFlagsTxt, parseFixed}}) {
 bool Active = ActiveCachedFile == Entry.File;
 auto Loaded = Entry.File->load(FS, Active);
 switch (Loaded.Result) {



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


[PATCH] D93373: [Flang][Openmp] Upgrade TASKGROUP construct to 5.0.

2021-07-26 Thread Chirag Khandelwal via Phabricator via cfe-commits
AMDChirag updated this revision to Diff 361605.
AMDChirag added a comment.

Minor test fix


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93373/new/

https://reviews.llvm.org/D93373

Files:
  clang/test/OpenMP/master_taskloop_simd_ast_print.cpp
  clang/test/OpenMP/parallel_master_taskloop_simd_ast_print.cpp
  clang/test/OpenMP/taskloop_simd_ast_print.cpp
  flang/lib/Semantics/resolve-directives.cpp
  flang/lib/Semantics/resolve-names.cpp
  flang/test/Semantics/omp-taskgroup01.f90
  llvm/include/llvm/Frontend/OpenMP/OMP.td

Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -473,8 +473,8 @@
 }
 def OMP_TaskGroup : Directive<"taskgroup"> {
   let allowedClauses = [
-VersionedClause,
-VersionedClause
+VersionedClause,
+VersionedClause
   ];
 }
 def OMP_Flush : Directive<"flush"> {
Index: flang/test/Semantics/omp-taskgroup01.f90
===
--- /dev/null
+++ flang/test/Semantics/omp-taskgroup01.f90
@@ -0,0 +1,47 @@
+! RUN: %S/test_errors.sh %s %t %flang -fopenmp
+use omp_lib
+  implicit none
+  integer :: xyz, abc
+  real :: reduction_var
+  !$omp parallel num_threads(4)
+!$omp single
+  print *, "The"
+!$omp taskgroup
+  !$omp task
+  print *, "almighty"
+  !$omp end task
+  !$omp task
+  print *, "sun"
+  !$omp end task
+!$omp end taskgroup
+!$omp end single
+  !$omp end parallel
+
+  !$omp parallel private(xyz)
+!$omp taskgroup allocate(xyz)
+  !$omp task
+print *, "The "
+!$omp taskgroup allocate(omp_large_cap_mem_space: abc)
+  !$omp task
+  print *, "almighty sun"
+  !$omp end task
+!$omp end taskgroup
+  !$omp end task
+!$omp end taskgroup
+  !$omp end parallel
+
+  !ERROR: PRIVATE clause is not allowed on the TASKGROUP directive
+  !$omp taskgroup private(abc)
+  !$omp end taskgroup
+
+  !$omp parallel
+!$omp task
+  !$omp taskgroup task_reduction(+ : reduction_var)
+  print *, "The "
+!$omp taskgroup task_reduction(.or. : reduction_var) task_reduction(.and. : reduction_var)
+  print *, "almighty sun"
+!$omp end taskgroup
+  !$omp end taskgroup
+!$omp end task
+  !$omp end parallel
+end program
\ No newline at end of file
Index: flang/lib/Semantics/resolve-names.cpp
===
--- flang/lib/Semantics/resolve-names.cpp
+++ flang/lib/Semantics/resolve-names.cpp
@@ -1288,6 +1288,7 @@
   case llvm::omp::Directive::OMPD_target_data:
   case llvm::omp::Directive::OMPD_master:
   case llvm::omp::Directive::OMPD_ordered:
+  case llvm::omp::Directive::OMPD_taskgroup:
 return false;
   default:
 return true;
Index: flang/lib/Semantics/resolve-directives.cpp
===
--- flang/lib/Semantics/resolve-directives.cpp
+++ flang/lib/Semantics/resolve-directives.cpp
@@ -1069,12 +1069,12 @@
   case llvm::omp::Directive::OMPD_target:
   case llvm::omp::Directive::OMPD_target_data:
   case llvm::omp::Directive::OMPD_task:
+  case llvm::omp::Directive::OMPD_taskgroup:
   case llvm::omp::Directive::OMPD_teams:
   case llvm::omp::Directive::OMPD_workshare:
   case llvm::omp::Directive::OMPD_parallel_workshare:
   case llvm::omp::Directive::OMPD_target_teams:
   case llvm::omp::Directive::OMPD_target_parallel:
-  case llvm::omp::Directive::OMPD_taskgroup:
 PushContext(beginDir.source, beginDir.v);
 break;
   default:
Index: clang/test/OpenMP/taskloop_simd_ast_print.cpp
===
--- clang/test/OpenMP/taskloop_simd_ast_print.cpp
+++ clang/test/OpenMP/taskloop_simd_ast_print.cpp
@@ -1,13 +1,13 @@
-// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -ast-print %s | FileCheck %s --check-prefix CHECK --check-prefix OMP45
-// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s --check-prefix CHECK --check-prefix OMP45
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=50 -DOMP5 -ast-print %s | FileCheck %s --check-prefix CHECK --check-prefix OMP50
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -DOMP5 -x c++ -std=c++11 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -DOMP5 -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s --check-prefix CHECK --check-prefix OMP50
 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=50 -ast-print %s -DOMP5 | FileCheck %s --check-prefix CHECK --check-prefix OMP50
 // RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c++ -std=c++11 -emit-pch -o %t %s -DOMP5
 // RUN: %clang_cc1 -fope

[PATCH] D106785: [C++4OpenCL] Introduces __remove_address_space utility

2021-07-26 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna created this revision.
Topotuna added a reviewer: Anastasia.
Herald added subscribers: ldrumm, yaxunl.
Topotuna requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This change provides a way to conveniently declare types that have
address space qualifiers removed.

Since OpenCL adds address spaces implicitly even when they are not
specified in source, it is useful to allow deriving address space
unqualified types.

Fixes llvm.org/PR45326


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106785

Files:
  clang/docs/LanguageExtensions.rst
  clang/lib/Headers/opencl-c-base.h
  clang/test/CodeGenOpenCLCXX/remove-address-space.clcpp


Index: clang/test/CodeGenOpenCLCXX/remove-address-space.clcpp
===
--- /dev/null
+++ clang/test/CodeGenOpenCLCXX/remove-address-space.clcpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 %s -cl-std=clc++ -fdeclare-opencl-builtins 
-finclude-default-header
+
+template
+struct is_same {
+  static const bool value = false;
+};
+
+template
+struct is_same {
+  static const bool value = true;
+};
+
+void test_remove_address_space() {
+  static_assert(is_same<__remove_address_space<__generic int>::type, 
int>::value,
+"__generic address space not removed by 
__remove_address_space");
+  static_assert(is_same<__remove_address_space<__global char>::type, 
char>::value,
+"__global address space not removed by 
__remove_address_space");
+  static_assert(is_same<__remove_address_space<__private ulong>::type, 
ulong>::value,
+"__private address space not removed by 
__remove_address_space");
+  static_assert(is_same<__remove_address_space<__local short>::type, 
short>::value,
+"__local address space not removed by __remove_address_space");
+  static_assert(is_same<__remove_address_space<__constant int3>::type, 
int3>::value,
+"__constant address space not removed by 
__remove_address_space");
+  static_assert(is_same<__remove_address_space::type, const volatile int>::value,
+"non-address-space qualifiers inappropriately removed by 
__remove_address_space");
+}
Index: clang/lib/Headers/opencl-c-base.h
===
--- clang/lib/Headers/opencl-c-base.h
+++ clang/lib/Headers/opencl-c-base.h
@@ -565,6 +565,26 @@
 #define as_intptr_t(x) __builtin_astype((x), intptr_t)
 #define as_uintptr_t(x) __builtin_astype((x), uintptr_t)
 
+// C++ for OpenCL - __remove_address_space
+#if defined(__OPENCL_CPP_VERSION__)
+template  struct __remove_address_space { using type = _Tp; };
+template  struct __remove_address_space<__generic _Tp> {
+  using type = _Tp;
+};
+template  struct __remove_address_space<__global _Tp> {
+  using type = _Tp;
+};
+template  struct __remove_address_space<__private _Tp> {
+  using type = _Tp;
+};
+template  struct __remove_address_space<__local _Tp> {
+  using type = _Tp;
+};
+template  struct __remove_address_space<__constant _Tp> {
+  using type = _Tp;
+};
+#endif
+
 // OpenCL v1.1 s6.9, v1.2/2.0 s6.10 - Function qualifiers
 
 #define __kernel_exec(X, typen) __kernel \
Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -1961,6 +1961,28 @@
 global OnlySL *d,
   );
 
+Address space removal
+-
+
+``__remove_address_space`` allows to derive types in C++ for OpenCL
+that have address space qualifiers removed, as described in `C++ for
+OpenCL v1.0 s2.3.12
+`_.
+
+**Example of Use**:
+
+.. code-block:: c++
+
+  template
+  void foo(T *par){
+__private __remove_address_space var3;
+  }
+
+  void bar(){
+__global int* ptr;
+foo(ptr);
+  }
+
 Legacy 1.x atomics with generic address space
 -
 


Index: clang/test/CodeGenOpenCLCXX/remove-address-space.clcpp
===
--- /dev/null
+++ clang/test/CodeGenOpenCLCXX/remove-address-space.clcpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 %s -cl-std=clc++ -fdeclare-opencl-builtins -finclude-default-header
+
+template
+struct is_same {
+  static const bool value = false;
+};
+
+template
+struct is_same {
+  static const bool value = true;
+};
+
+void test_remove_address_space() {
+  static_assert(is_same<__remove_address_space<__generic int>::type, int>::value,
+"__generic address space not removed by __remove_address_space");
+  static_assert(is_same<__remove_address_space<__global char>::type, char>::value,
+"__global address space not removed by __remove_address_space");
+  static_assert(is_same<__remove_address_space<__private ulong>::type, ulong>::value,
+"__private address space 

[PATCH] D106785: [C++4OpenCL] Introduces __remove_address_space utility

2021-07-26 Thread Justas Janickas via Phabricator via cfe-commits
Topotuna added a comment.

Change to `LanguageExtensions.rst` assumes there is a section about the utility 
on official C++ for OpenCL documentation. However, it is not yet documented


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106785/new/

https://reviews.llvm.org/D106785

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


[PATCH] D106530: [PowerPC] Change altivec indexed load/store builtins argument type

2021-07-26 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai accepted this revision.
nemanjai added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks for fixing this.
I am just curious, was this revealed from a real world test that used an offset 
that is so large that it doesn't fit into 32 bits?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106530/new/

https://reviews.llvm.org/D106530

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


[PATCH] D105168: [RISCV] Unify the arch string parsing logic to RISCVISAInfo.

2021-07-26 Thread Fraser Cormack via Phabricator via cfe-commits
frasercrmck added inline comments.



Comment at: llvm/lib/Support/RISCVISAInfo.cpp:127
+
+bool RISCVISAInfo::isSupportedExtensionFeature(StringRef Ext) {
+  bool IsExperimental = stripExperimentalPrefix(Ext);

This looks like a `find_if` if that'd make it any simpler.



Comment at: llvm/lib/Support/RISCVISAInfo.cpp:147
+unsigned MinorVersion) {
+  for (auto const &SupportedExtensionInfo :
+   filterSupportedExtensionInfosByName(Ext)) {

This also looks like a `find_if`



Comment at: llvm/lib/Support/RISCVISAInfo.cpp:231
+  size_t RHSLen = RHS.length();
+  int LHSRank, RHSRank;
+  if (LHSLen == 1 && RHSLen != 1)

Not sure why these need to be declared up here.



Comment at: llvm/lib/Support/RISCVISAInfo.cpp:310
+errc::invalid_argument,
+"Failed to parsing major version number for extension '" + Ext + "'");
+

`Failed to parse ...`



Comment at: llvm/lib/Support/RISCVISAInfo.cpp:315
+errc::invalid_argument,
+"Failed to parsing minor version number for extension '" + Ext + "'");
+

`Failed to parse`



Comment at: llvm/lib/Support/RISCVISAInfo.cpp:359
+}
+// return true;
+return Error::success();

Commented-out code



Comment at: llvm/lib/Support/RISCVISAInfo.cpp:414
+  // RISC-V ISA strings must be lowercase.
+  if (llvm::any_of(Arch, [](char C) { return isupper(C); })) {
+return createStringError(errc::invalid_argument,

I think you can just have `if (llvm::any_of(Arch, isupper))` here.



Comment at: llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp:2036
+for (auto Feature : RISCVFeatureKV) {
+  if (llvm::RISCVISAInfo::isSupportedExtensionFeature(Feature.Key)) {
+clearFeatureBits(Feature.Value, Feature.Key);

Don't need `{}` here



Comment at: llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp:2055
+
+for (auto Feature : RISCVFeatureKV) {
+  if (ISAInfo.hasExtension(Feature.Key)) {

Don't need `{}` here either


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105168/new/

https://reviews.llvm.org/D105168

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


[PATCH] D106787: [clang][driver] NFC: Move InputInfo.h from lib to include

2021-07-26 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added reviewers: Bigcheese, dexonsmith.
Herald added subscribers: frasercrmck, kerbowa, luismarques, apazos, 
sameer.abuasal, usaxena95, s.egerton, Jim, kadircet, jocewei, PkmX, the_o, 
brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, niosHD, 
sabuasal, simoncook, johnrusso, rbar, asb, nhaehnle, jvesely, dylanmckay.
jansvoboda11 requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang.

Moving `InputInfo.h` from `lib/Driver/` into `include/Driver` to be able to 
expose it in an API consumed from outside of `clangDriver`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106787

Files:
  clang/include/clang/Driver/InputInfo.h
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/InputInfo.h
  clang/lib/Driver/Job.cpp
  clang/lib/Driver/Tool.cpp
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
  clang/lib/Driver/ToolChains/AVR.cpp
  clang/lib/Driver/ToolChains/AVR.h
  clang/lib/Driver/ToolChains/Ananas.cpp
  clang/lib/Driver/ToolChains/BareMetal.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CloudABI.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/CommonArgs.h
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/lib/Driver/ToolChains/HIP.cpp
  clang/lib/Driver/ToolChains/Hexagon.cpp
  clang/lib/Driver/ToolChains/MSP430.cpp
  clang/lib/Driver/ToolChains/MSP430.h
  clang/lib/Driver/ToolChains/MinGW.cpp
  clang/lib/Driver/ToolChains/Minix.cpp
  clang/lib/Driver/ToolChains/NaCl.cpp
  clang/lib/Driver/ToolChains/RISCVToolchain.cpp

Index: clang/lib/Driver/ToolChains/RISCVToolchain.cpp
===
--- clang/lib/Driver/ToolChains/RISCVToolchain.cpp
+++ clang/lib/Driver/ToolChains/RISCVToolchain.cpp
@@ -8,8 +8,8 @@
 
 #include "RISCVToolchain.h"
 #include "CommonArgs.h"
-#include "InputInfo.h"
 #include "clang/Driver/Compilation.h"
+#include "clang/Driver/InputInfo.h"
 #include "clang/Driver/Options.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Support/FileSystem.h"
Index: clang/lib/Driver/ToolChains/NaCl.cpp
===
--- clang/lib/Driver/ToolChains/NaCl.cpp
+++ clang/lib/Driver/ToolChains/NaCl.cpp
@@ -7,11 +7,11 @@
 //===--===//
 
 #include "NaCl.h"
-#include "InputInfo.h"
 #include "CommonArgs.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Driver.h"
 #include "clang/Driver/DriverDiagnostic.h"
+#include "clang/Driver/InputInfo.h"
 #include "clang/Driver/Options.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Support/Path.h"
Index: clang/lib/Driver/ToolChains/Minix.cpp
===
--- clang/lib/Driver/ToolChains/Minix.cpp
+++ clang/lib/Driver/ToolChains/Minix.cpp
@@ -8,9 +8,9 @@
 
 #include "Minix.h"
 #include "CommonArgs.h"
-#include "InputInfo.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Driver.h"
+#include "clang/Driver/InputInfo.h"
 #include "clang/Driver/Options.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Support/VirtualFileSystem.h"
Index: clang/lib/Driver/ToolChains/MinGW.cpp
===
--- clang/lib/Driver/ToolChains/MinGW.cpp
+++ clang/lib/Driver/ToolChains/MinGW.cpp
@@ -7,12 +7,12 @@
 //===--===//
 
 #include "MinGW.h"
-#include "InputInfo.h"
 #include "CommonArgs.h"
 #include "clang/Config/config.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Driver.h"
 #include "clang/Driver/DriverDiagnostic.h"
+#include "clang/Driver/InputInfo.h"
 #include "clang/Driver/Options.h"
 #include "clang/Driver/SanitizerArgs.h"
 #include "llvm/Option/ArgList.h"
Index: clang/lib/Driver/ToolChains/MSP430.h
===
--- clang/lib/Driver/ToolChains/MSP430.h
+++ clang/lib/Driver/ToolChains/MSP430.h
@@ -10,9 +10,9 @@
 #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_MSP430_H
 
 #include "Gnu.h"
-#include "InputInfo.h"
 #include "clang/Driver/Driver.h"
 #include "clang/Driver/DriverDiagnostic.h"
+#include "clang/Driver/InputInfo.h"
 #include "clang/Driver/Tool.h"
 #include "clang/Driver/ToolChain.h"
 #include "llvm/ADT/StringRef.h"
Index: clang/lib/Driver/ToolChains/MSP430.cpp
===
--- clang/lib/Driver/ToolChains/MSP430.cpp
+++ clang/lib/Driver/ToolChains/MSP430.cpp
@@ -9,8 +9,8 @@
 #include "MSP430.h"
 #include "CommonArgs.h"
 #include "Gnu.h"
-#include "InputInfo.h"
 #include "clang/Driver/Compilation.h"
+#include "clang/Driver/InputInfo.h"
 #include "clang/Driver/Multilib.h"
 #include "clang/Driver/Options.h"
 #inc

[PATCH] D102488: [clang][deps] Prune unused header search paths

2021-07-26 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 planned changes to this revision.
jansvoboda11 added a comment.

After speaking with @dexonsmith, the laziness is probably not necessary when 
dealing with a short bit vector. I'll also explore using `llvm::BitVector` 
instead of `std::vector`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102488/new/

https://reviews.llvm.org/D102488

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


[PATCH] D106788: [clang][driver] NFC: Expose InputInfo in Job instead of plain filenames

2021-07-26 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added reviewers: Bigcheese, dexonsmith, arphaman.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch exposes `InputInfo` in `Job` instead of plain filenames. This is 
useful in a follow-up patch that uses this to recognize `-cc1` commands 
interesting for Clang tooling.

Depends on D106787 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106788

Files:
  clang/include/clang/Driver/Job.h
  clang/lib/Driver/Job.cpp
  clang/unittests/Driver/ToolChainTest.cpp


Index: clang/unittests/Driver/ToolChainTest.cpp
===
--- clang/unittests/Driver/ToolChainTest.cpp
+++ clang/unittests/Driver/ToolChainTest.cpp
@@ -321,13 +321,13 @@
   const JobList &Jobs = CC->getJobs();
 
   const auto &CmdCompile = Jobs.getJobs().front();
-  const auto &InFile = CmdCompile->getInputFilenames().front();
+  const auto &InFile = CmdCompile->getInputInfos().front().getFilename();
   EXPECT_STREQ(InFile, "foo.cpp");
   auto ObjFile = CmdCompile->getOutputFilenames().front();
   EXPECT_TRUE(StringRef(ObjFile).endswith(".o"));
 
   const auto &CmdLink = Jobs.getJobs().back();
-  const auto LinkInFile = CmdLink->getInputFilenames().front();
+  const auto LinkInFile = CmdLink->getInputInfos().front().getFilename();
   EXPECT_EQ(ObjFile, LinkInFile);
   auto ExeFile = CmdLink->getOutputFilenames().front();
   EXPECT_EQ("a.out", ExeFile);
Index: clang/lib/Driver/Job.cpp
===
--- clang/lib/Driver/Job.cpp
+++ clang/lib/Driver/Job.cpp
@@ -43,7 +43,7 @@
   Executable(Executable), Arguments(Arguments) {
   for (const auto &II : Inputs)
 if (II.isFilename())
-  InputFilenames.push_back(II.getFilename());
+  InputInfoList.push_back(II);
   for (const auto &II : Outputs)
 if (II.isFilename())
   OutputFilenames.push_back(II.getFilename());
@@ -237,9 +237,10 @@
 }
   }
 
-  auto Found = llvm::find_if(InputFilenames,
- [&Arg](StringRef IF) { return IF == Arg; });
-  if (Found != InputFilenames.end() &&
+  auto Found = llvm::find_if(InputInfoList, [&Arg](const InputInfo &II) {
+return II.getFilename() == Arg;
+  });
+  if (Found != InputInfoList.end() &&
   (i == 0 || StringRef(Args[i - 1]) != "-main-file-name")) {
 // Replace the input file name with the crashinfo's file name.
 OS << ' ';
@@ -302,8 +303,8 @@
 
 void Command::PrintFileNames() const {
   if (PrintInputFilenames) {
-for (const char *Arg : InputFilenames)
-  llvm::outs() << llvm::sys::path::filename(Arg) << "\n";
+for (const auto &Arg : InputInfoList)
+  llvm::outs() << llvm::sys::path::filename(Arg.getFilename()) << "\n";
 llvm::outs().flush();
   }
 }
Index: clang/include/clang/Driver/Job.h
===
--- clang/include/clang/Driver/Job.h
+++ clang/include/clang/Driver/Job.h
@@ -10,6 +10,7 @@
 #define LLVM_CLANG_DRIVER_JOB_H
 
 #include "clang/Basic/LLVM.h"
+#include "clang/Driver/InputInfo.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SmallVector.h"
@@ -119,8 +120,8 @@
   /// argument, which will be the executable).
   llvm::opt::ArgStringList Arguments;
 
-  /// The list of program arguments which are inputs.
-  llvm::opt::ArgStringList InputFilenames;
+  /// The list of program inputs.
+  std::vector InputInfoList;
 
   /// The list of program arguments which are outputs. May be empty.
   std::vector OutputFilenames;
@@ -207,9 +208,7 @@
 
   const llvm::opt::ArgStringList &getArguments() const { return Arguments; }
 
-  const llvm::opt::ArgStringList &getInputFilenames() const {
-return InputFilenames;
-  }
+  const std::vector &getInputInfos() const { return InputInfoList; }
 
   const std::vector &getOutputFilenames() const {
 return OutputFilenames;


Index: clang/unittests/Driver/ToolChainTest.cpp
===
--- clang/unittests/Driver/ToolChainTest.cpp
+++ clang/unittests/Driver/ToolChainTest.cpp
@@ -321,13 +321,13 @@
   const JobList &Jobs = CC->getJobs();
 
   const auto &CmdCompile = Jobs.getJobs().front();
-  const auto &InFile = CmdCompile->getInputFilenames().front();
+  const auto &InFile = CmdCompile->getInputInfos().front().getFilename();
   EXPECT_STREQ(InFile, "foo.cpp");
   auto ObjFile = CmdCompile->getOutputFilenames().front();
   EXPECT_TRUE(StringRef(ObjFile).endswith(".o"));
 
   const auto &CmdLink = Jobs.getJobs().back();
-  const auto LinkInFile = CmdLink->getInputFilenames().front();
+  const auto LinkInFile = CmdLink->getInputInfos().front().getFilename();
   EXPECT_EQ(ObjFile, LinkInFile);
   auto ExeFile = CmdLink->getOutputFilenames().front();
   EXPECT_EQ("a

[PATCH] D106789: [clang][Driver] Expose driver mode detection logic

2021-07-26 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
kadircet requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Also use it in other places that performed it on their own.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106789

Files:
  clang/include/clang/Driver/Driver.h
  clang/lib/Driver/Driver.cpp
  clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
  clang/tools/driver/driver.cpp

Index: clang/tools/driver/driver.cpp
===
--- clang/tools/driver/driver.cpp
+++ clang/tools/driver/driver.cpp
@@ -360,7 +360,6 @@
 return 1;
 
   llvm::InitializeAllTargets();
-  auto TargetAndMode = ToolChain::getTargetAndModeFromProgramName(Args[0]);
 
   llvm::BumpPtrAllocator A;
   llvm::StringSaver Saver(A);
@@ -372,13 +371,8 @@
   // have to manually search for a --driver-mode=cl argument the hard way.
   // Finally, our -cc1 tools don't care which tokenization mode we use because
   // response files written by clang will tokenize the same way in either mode.
-  bool ClangCLMode = false;
-  if (StringRef(TargetAndMode.DriverMode).equals("--driver-mode=cl") ||
-  llvm::find_if(Args, [](const char *F) {
-return F && strcmp(F, "--driver-mode=cl") == 0;
-  }) != Args.end()) {
-ClangCLMode = true;
-  }
+  bool ClangCLMode =
+  getDriverMode(Args[0], llvm::makeArrayRef(Args).slice(1)).equals("cl");
   enum { Default, POSIX, Windows } RSPQuoting = Default;
   for (const char *F : Args) {
 if (strcmp(F, "--rsp-quoting=posix") == 0)
@@ -490,6 +484,7 @@
 
   Driver TheDriver(Path, llvm::sys::getDefaultTargetTriple(), Diags);
   SetInstallDir(Args, TheDriver, CanonicalPrefixes);
+  auto TargetAndMode = ToolChain::getTargetAndModeFromProgramName(Args[0]);
   TheDriver.setTargetAndMode(TargetAndMode);
 
   insertTargetAndModeArgs(TargetAndMode, Args, SavedStrings);
Index: clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
===
--- clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
+++ clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
@@ -43,9 +43,11 @@
 //===--===//
 
 #include "clang/Basic/LangStandard.h"
+#include "clang/Driver/Driver.h"
 #include "clang/Driver/Options.h"
 #include "clang/Driver/Types.h"
 #include "clang/Tooling/CompilationDatabase.h"
+#include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringExtras.h"
@@ -134,8 +136,7 @@
   bool ClangCLMode;
 
   TransferableCommand(CompileCommand C)
-  : Cmd(std::move(C)), Type(guessType(Cmd.Filename)),
-ClangCLMode(checkIsCLMode(Cmd.CommandLine)) {
+  : Cmd(std::move(C)), Type(guessType(Cmd.Filename)) {
 std::vector OldArgs = std::move(Cmd.CommandLine);
 Cmd.CommandLine.clear();
 
@@ -145,6 +146,10 @@
   SmallVector TmpArgv;
   for (const std::string &S : OldArgs)
 TmpArgv.push_back(S.c_str());
+  ClangCLMode = !TmpArgv.empty() &&
+driver::getDriverMode(TmpArgv.front(),
+  llvm::makeArrayRef(TmpArgv).slice(1))
+.equals("cl");
   ArgList = {TmpArgv.begin(), TmpArgv.end()};
 }
 
@@ -246,19 +251,6 @@
   }
 
 private:
-  // Determine whether the given command line is intended for the CL driver.
-  static bool checkIsCLMode(ArrayRef CmdLine) {
-// First look for --driver-mode.
-for (StringRef S : llvm::reverse(CmdLine)) {
-  if (S.consume_front("--driver-mode="))
-return S == "cl";
-}
-
-// Otherwise just check the clang executable file name.
-return !CmdLine.empty() &&
-   llvm::sys::path::stem(CmdLine.front()).endswith_insensitive("cl");
-  }
-
   // Map the language from the --std flag to that of the -x flag.
   static types::ID toType(Language Lang) {
 switch (Lang) {
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -63,6 +63,7 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSet.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Config/llvm-config.h"
@@ -168,28 +169,9 @@
   ResourceDir = GetResourcesPath(ClangExecutable, CLANG_RESOURCE_DIR);
 }
 
-void Driver::ParseDriverMode(StringRef ProgramName,
- ArrayRef Args) {
-  if (ClangNameParts.isEmpty())
-ClangNameParts = ToolChain::getTargetAndModeFromProgramName(ProgramName);
-  setDriverModeFromOption(ClangNameParts.DriverMode);
-
-  for (const char *ArgPtr : Args) {
-// Ignore nullptrs, they are the response file's EOL markers.
-if (ArgPtr == nullptr)
-  continue;
-const String

[PATCH] D105695: [clang][tooling] Accept Clang invocations with multiple jobs

2021-07-26 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 361626.
jansvoboda11 added a comment.

Also ignore cc1 jobs that have inputs that are not source files.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105695/new/

https://reviews.llvm.org/D105695

Files:
  clang/include/clang/Tooling/Tooling.h
  clang/lib/Tooling/Tooling.cpp
  clang/test/Tooling/clang-check-offload.cpp
  clang/unittests/Tooling/ToolingTest.cpp

Index: clang/unittests/Tooling/ToolingTest.cpp
===
--- clang/unittests/Tooling/ToolingTest.cpp
+++ clang/unittests/Tooling/ToolingTest.cpp
@@ -9,6 +9,8 @@
 #include "clang/AST/ASTConsumer.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclGroup.h"
+#include "clang/Driver/Compilation.h"
+#include "clang/Driver/Driver.h"
 #include "clang/Frontend/ASTUnit.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/FrontendAction.h"
@@ -18,6 +20,7 @@
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Host.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/TargetRegistry.h"
 #include "llvm/Support/TargetSelect.h"
@@ -258,6 +261,98 @@
   EXPECT_TRUE(Consumer.SawSourceManager);
 }
 
+namespace {
+/// Overlays the real filesystem with the given VFS and returns the result.
+llvm::IntrusiveRefCntPtr
+overlayRealFS(llvm::IntrusiveRefCntPtr VFS) {
+  auto RFS = llvm::vfs::getRealFileSystem();
+  auto OverlayFS = llvm::makeIntrusiveRefCnt(RFS);
+  OverlayFS->pushOverlay(VFS);
+  return OverlayFS;
+}
+
+struct CommandLineExtractorTest : public ::testing::Test {
+  llvm::IntrusiveRefCntPtr InMemoryFS;
+  llvm::IntrusiveRefCntPtr Diags;
+  driver::Driver Driver;
+
+public:
+  CommandLineExtractorTest()
+  : InMemoryFS(new llvm::vfs::InMemoryFileSystem),
+Diags(CompilerInstance::createDiagnostics(new DiagnosticOptions)),
+Driver("clang", llvm::sys::getDefaultTargetTriple(), *Diags,
+   "clang LLVM compiler", overlayRealFS(InMemoryFS)) {}
+
+  void addFile(StringRef Name, StringRef Content) {
+InMemoryFS->addFile(Name, 0, llvm::MemoryBuffer::getMemBuffer(Content));
+  }
+
+  const llvm::opt::ArgStringList *
+  extractCC1Arguments(llvm::ArrayRef Argv) {
+const std::unique_ptr Compilation(
+Driver.BuildCompilation(llvm::makeArrayRef(Argv)));
+
+return getCC1Arguments(Diags.get(), Compilation.get());
+  }
+};
+} // namespace
+
+TEST_F(CommandLineExtractorTest, AcceptOffloading) {
+  addFile("test.c", "int main() {}\n");
+  const char *Args[] = {"clang", "-target",  "arm64-apple-macosx11.0.0",
+"-x","hip",  "test.c",
+"-nogpulib", "-nogpuinc"};
+  EXPECT_NE(extractCC1Arguments(Args), nullptr);
+}
+
+TEST_F(CommandLineExtractorTest, AcceptOffloadingCompile) {
+  addFile("test.c", "int main() {}\n");
+  const char *Args[] = {"clang",  "-target",   "arm64-apple-macosx11.0.0",
+"-c", "-x","hip",
+"test.c", "-nogpulib", "-nogpuinc"};
+  EXPECT_NE(extractCC1Arguments(Args), nullptr);
+}
+
+TEST_F(CommandLineExtractorTest, AcceptOffloadingSyntaxOnly) {
+  addFile("test.c", "int main() {}\n");
+  const char *Args[] = {
+  "clang", "-target",   "arm64-apple-macosx11.0.0",
+  "-fsyntax-only", "-x","hip",
+  "test.c","-nogpulib", "-nogpuinc"};
+  EXPECT_NE(extractCC1Arguments(Args), nullptr);
+}
+
+TEST_F(CommandLineExtractorTest, AcceptExternalAssembler) {
+  addFile("test.c", "int main() {}\n");
+  const char *Args[] = {
+  "clang", "-target", "arm64-apple-macosx11.0.0", "-fno-integrated-as",
+  "-c","test.c"};
+  EXPECT_NE(extractCC1Arguments(Args), nullptr);
+}
+
+TEST_F(CommandLineExtractorTest, AcceptEmbedBitcode) {
+  addFile("test.c", "int main() {}\n");
+  const char *Args[] = {"clang", "-target", "arm64-apple-macosx11.0.0",
+"-c","-fembed-bitcode", "test.c"};
+  EXPECT_NE(extractCC1Arguments(Args), nullptr);
+}
+
+TEST_F(CommandLineExtractorTest, RejectMultipleArchitectures) {
+  addFile("test.c", "int main() {}\n");
+  const char *Args[] = {"clang", "-target", "arm64-apple-macosx11.0.0",
+"-arch", "x86_64",  "-arch",
+"arm64", "-c",  "test.c"};
+  EXPECT_EQ(extractCC1Arguments(Args), nullptr);
+}
+
+TEST_F(CommandLineExtractorTest, RejectMultipleInputFiles) {
+  addFile("one.c", "void one() {}\n");
+  addFile("two.c", "void two() {}\n");
+  const char *Args[] = {"clang", "-target", "arm64-apple-macosx11.0.0",
+"-c","one.c",   "two.c"};
+  EXPECT_EQ(extractCC1Arguments(Args), nullptr);
+}
+
 struct VerifyEndCallback : public SourceFileCallbacks {
   VerifyEndCallback() : BeginCalled(0), EndCalled(0), Matched(false) {}
   bool handleBeginSource(CompilerInstance &CI) override {
Inde

[PATCH] D105695: [clang][tooling] Accept Clang invocations with multiple jobs

2021-07-26 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 requested review of this revision.
jansvoboda11 added a comment.

Requesting re-review, since there are two changes:

- `-cc1` commands that don't read a source file are ignored (e.g. jobs 
generated by `-fembed-bitcode`),
- test now have `-target arm64-apple-macosx11.0.0` to ensure things work 
platforms that don't have external assembler.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105695/new/

https://reviews.llvm.org/D105695

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


[PATCH] D105695: [clang][tooling] Accept Clang invocations with multiple jobs

2021-07-26 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 361630.
jansvoboda11 added a comment.

Formatting


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105695/new/

https://reviews.llvm.org/D105695

Files:
  clang/include/clang/Tooling/Tooling.h
  clang/lib/Tooling/Tooling.cpp
  clang/test/Tooling/clang-check-offload.cpp
  clang/unittests/Tooling/ToolingTest.cpp

Index: clang/unittests/Tooling/ToolingTest.cpp
===
--- clang/unittests/Tooling/ToolingTest.cpp
+++ clang/unittests/Tooling/ToolingTest.cpp
@@ -9,6 +9,8 @@
 #include "clang/AST/ASTConsumer.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclGroup.h"
+#include "clang/Driver/Compilation.h"
+#include "clang/Driver/Driver.h"
 #include "clang/Frontend/ASTUnit.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/FrontendAction.h"
@@ -18,6 +20,7 @@
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Host.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/TargetRegistry.h"
 #include "llvm/Support/TargetSelect.h"
@@ -258,6 +261,98 @@
   EXPECT_TRUE(Consumer.SawSourceManager);
 }
 
+namespace {
+/// Overlays the real filesystem with the given VFS and returns the result.
+llvm::IntrusiveRefCntPtr
+overlayRealFS(llvm::IntrusiveRefCntPtr VFS) {
+  auto RFS = llvm::vfs::getRealFileSystem();
+  auto OverlayFS = llvm::makeIntrusiveRefCnt(RFS);
+  OverlayFS->pushOverlay(VFS);
+  return OverlayFS;
+}
+
+struct CommandLineExtractorTest : public ::testing::Test {
+  llvm::IntrusiveRefCntPtr InMemoryFS;
+  llvm::IntrusiveRefCntPtr Diags;
+  driver::Driver Driver;
+
+public:
+  CommandLineExtractorTest()
+  : InMemoryFS(new llvm::vfs::InMemoryFileSystem),
+Diags(CompilerInstance::createDiagnostics(new DiagnosticOptions)),
+Driver("clang", llvm::sys::getDefaultTargetTriple(), *Diags,
+   "clang LLVM compiler", overlayRealFS(InMemoryFS)) {}
+
+  void addFile(StringRef Name, StringRef Content) {
+InMemoryFS->addFile(Name, 0, llvm::MemoryBuffer::getMemBuffer(Content));
+  }
+
+  const llvm::opt::ArgStringList *
+  extractCC1Arguments(llvm::ArrayRef Argv) {
+const std::unique_ptr Compilation(
+Driver.BuildCompilation(llvm::makeArrayRef(Argv)));
+
+return getCC1Arguments(Diags.get(), Compilation.get());
+  }
+};
+} // namespace
+
+TEST_F(CommandLineExtractorTest, AcceptOffloading) {
+  addFile("test.c", "int main() {}\n");
+  const char *Args[] = {"clang", "-target",  "arm64-apple-macosx11.0.0",
+"-x","hip",  "test.c",
+"-nogpulib", "-nogpuinc"};
+  EXPECT_NE(extractCC1Arguments(Args), nullptr);
+}
+
+TEST_F(CommandLineExtractorTest, AcceptOffloadingCompile) {
+  addFile("test.c", "int main() {}\n");
+  const char *Args[] = {"clang",  "-target",   "arm64-apple-macosx11.0.0",
+"-c", "-x","hip",
+"test.c", "-nogpulib", "-nogpuinc"};
+  EXPECT_NE(extractCC1Arguments(Args), nullptr);
+}
+
+TEST_F(CommandLineExtractorTest, AcceptOffloadingSyntaxOnly) {
+  addFile("test.c", "int main() {}\n");
+  const char *Args[] = {
+  "clang", "-target",   "arm64-apple-macosx11.0.0",
+  "-fsyntax-only", "-x","hip",
+  "test.c","-nogpulib", "-nogpuinc"};
+  EXPECT_NE(extractCC1Arguments(Args), nullptr);
+}
+
+TEST_F(CommandLineExtractorTest, AcceptExternalAssembler) {
+  addFile("test.c", "int main() {}\n");
+  const char *Args[] = {
+  "clang", "-target", "arm64-apple-macosx11.0.0", "-fno-integrated-as",
+  "-c","test.c"};
+  EXPECT_NE(extractCC1Arguments(Args), nullptr);
+}
+
+TEST_F(CommandLineExtractorTest, AcceptEmbedBitcode) {
+  addFile("test.c", "int main() {}\n");
+  const char *Args[] = {"clang", "-target", "arm64-apple-macosx11.0.0",
+"-c","-fembed-bitcode", "test.c"};
+  EXPECT_NE(extractCC1Arguments(Args), nullptr);
+}
+
+TEST_F(CommandLineExtractorTest, RejectMultipleArchitectures) {
+  addFile("test.c", "int main() {}\n");
+  const char *Args[] = {"clang", "-target", "arm64-apple-macosx11.0.0",
+"-arch", "x86_64",  "-arch",
+"arm64", "-c",  "test.c"};
+  EXPECT_EQ(extractCC1Arguments(Args), nullptr);
+}
+
+TEST_F(CommandLineExtractorTest, RejectMultipleInputFiles) {
+  addFile("one.c", "void one() {}\n");
+  addFile("two.c", "void two() {}\n");
+  const char *Args[] = {"clang", "-target", "arm64-apple-macosx11.0.0",
+"-c","one.c",   "two.c"};
+  EXPECT_EQ(extractCC1Arguments(Args), nullptr);
+}
+
 struct VerifyEndCallback : public SourceFileCallbacks {
   VerifyEndCallback() : BeginCalled(0), EndCalled(0), Matched(false) {}
   bool handleBeginSource(CompilerInstance &CI) override {
Index: clang/test/Tooling/clang-check-offload.cpp

[PATCH] D106757: [PowerPC] Implement partial vector ld/st builtins for XL compatibility

2021-07-26 Thread Lei Huang via Phabricator via cfe-commits
lei added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:15133
+bool IsLE = getTarget().isLittleEndian();
+auto StoreSubVec = [&](unsigned Width, unsigned Offset, unsigned EltNo) {
+  switch (Width) {

I find the nested switch to be a bit confusing at first.  Maybe it can be done 
a bit diff?
```
auto StoreSubVec ...
   if (Width==16) {
   }
   switch (Width) {
  default:  ...
  case :
  //set the ConvTy, NumElts for non-16byte widths
   }
// code to handle non-16 byte stores
}
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106757/new/

https://reviews.llvm.org/D106757

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


[PATCH] D103385: [clang-tidy] bugprone-forwarding-reference-overload: support non-type template parameters

2021-07-26 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D103385#2900967 , @jwtowner wrote:

> It should be good to go. I do not have commit access so feel free to commit. 
> Thanks!

Thanks! What name and email address would you like me to use for patch 
attribution?




Comment at: 
clang-tools-extra/docs/clang-tidy/checks/bugprone-forwarding-reference-overload.rst:34
+  template,A&&...>,int> = 0>
+  explicit Person(A&&... a) {}

jwtowner wrote:
> aaron.ballman wrote:
> > 
> The reason I didn't put the spaces in here was that I was trying to match the 
> style above for `enable_if_t,void>`. I can add a space after 
> the comma there as well.
Ah, good call. The way it is now is good for me. Thank you!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D103385/new/

https://reviews.llvm.org/D103385

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


[PATCH] D105191: [Clang][OpenMP] Add support for Static Device Libraries

2021-07-26 Thread Saiyedul Islam via Phabricator via cfe-commits
saiislam updated this revision to Diff 361633.
saiislam marked 2 inline comments as done.
saiislam added a comment.

Added instructions to generate a fat archive and reduced the size of attached 
libFatArchive.a used for testing.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105191/new/

https://reviews.llvm.org/D105191

Files:
  clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/CommonArgs.h
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/test/Driver/Inputs/hip_dev_lib/libFatArchive.a
  clang/test/Driver/fat_archive.cpp

Index: clang/test/Driver/fat_archive.cpp
===
--- /dev/null
+++ clang/test/Driver/fat_archive.cpp
@@ -0,0 +1,91 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: amdgpu-registered-target
+
+// See the steps to create a fat archive near the end of the file.
+
+// Test succeeds if no linked error i.e. all external symbols in the archive
+// could be resolved correctly.
+// RUN: env LIBRARY_PATH=%T/../../../../../runtimes/runtimes-bins/openmp/libomptarget %clang -O2 -target x86_64-pc-linux-gnu -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx906 %s -L%S/Inputs/hip_dev_lib -lFatArchive -o - | FileCheck %s -check-prefix=LINKERROR
+// LINKERROR-NOT: error: linker command failed with exit code 1
+
+// Given a FatArchive, clang-offload-bundler should be called to create a
+// device specific archive, which should be passed to llvm-link.
+// RUN: env LIBRARY_PATH=%T/../../../../../runtimes/runtimes-bins/openmp/libomptarget %clang -O2 -### -target x86_64-pc-linux-gnu -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx906 %s -L%S/Inputs/hip_dev_lib -lFatArchive 2>&1 | FileCheck %s
+// CHECK: clang{{.*}}"-cc1" "-triple" "x86_64-pc-linux-gnu"{{.*}}"-o" "[[HOSTOBJ:.*.o]]" "-x" "ir"{{.*}}
+// CHECK: clang{{.*}}"-cc1"{{.*}}"-triple" "amdgcn-amd-amdhsa"{{.*}}"-emit-llvm-bc"{{.*}}"-target-cpu" "gfx906"{{.*}}"-o" "[[HOSTBC:.*.bc]]" "-x" "c++"{{.*}}.cpp
+// CHECK: clang-offload-bundler" "-unbundle" "-type=a" "-inputs={{.*}}/Inputs/hip_dev_lib/libFatArchive.a" "-targets=openmp-amdgcn-amd-amdhsa--gfx906" "-outputs=[[DEVICESPECIFICARCHIVE:.*.a]]" "-allow-missing-bundles"
+// CHECK: llvm-link{{.*}}"[[HOSTBC]]" "[[DEVICESPECIFICARCHIVE]]" "-o" "{{.*}}-gfx906-linked-{{.*}}.bc"
+// CHECK: ld.lld"{{.*}}" "-L{{.*}}/Inputs/hip_dev_lib" "{{.*}}"[[HOSTOBJ]]" "-lFatArchive" "{{.*}}" "-lomp{{.*}}-lomptarget"
+// expected-no-diagnostics
+
+// Tests for linker and loader errors in case external symbols are not found in
+// the FatArchive.
+// RUN: env LIBRARY_PATH=%T/../../../../../runtimes/runtimes-bins/openmp/libomptarget not %clang -O2 -target x86_64-pc-linux-gnu -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa -march=gfx906 %s -L%S/Inputs/hip_dev_lib -lFatArchive -DMISSING=1 2>&1 | FileCheck %s -check-prefix=MISSINGSYM
+// MISSINGSYM: ld.lld: error: undefined symbol: func_missing
+// MISSINGSYM: error: linker command failed with exit code 1
+
+#ifndef HEADER
+#define HEADER
+
+#define N 10
+
+#pragma omp declare target
+// Functions defined in Fat Archive.
+extern "C" void func_present(float *, float *, unsigned);
+
+#ifdef MISSING
+// Function not defined in the fat archive.
+extern "C" void func_missing(float *, float *, unsigned);
+#endif
+
+#pragma omp end declare target
+
+int main() {
+  float in[N], out[N], sum = 0;
+  unsigned i;
+
+#pragma omp parallel for
+  for (i = 0; i < N; ++i) {
+in[i] = i;
+  }
+
+  func_present(in, out, N); // Returns out[i] = a[i] * 0
+
+#ifdef MISSING
+  func_missing(in, out, N); // Should throw an error here
+#endif
+
+#pragma omp parallel for reduction(+ \
+   : sum)
+  for (i = 0; i < N; ++i)
+sum += out[i];
+
+  if (!sum)
+return 0;
+  return sum;
+}
+
+#endif
+
+/
+   Steps to create Fat Archive (libFatArchive.a) 
+*
+* File: func_1.c 
+void func_present(float* in, float* out, unsigned n){
+  unsigned i;
+  #pragma omp target teams distribute parallel for map(to: in[0:n]) map(from: out[0:n])
+  for(i=0; i(
@@ -754,6 +757,8 @@
 std::string BitcodeSuffix = "nvptx-" + GpuArch.str();
 addOpenMPDeviceRTL(getDriver(), DriverArgs, CC1Args, BitcodeSuffix,
getTriple());
+AddStaticDeviceLibs(getDriver(), DriverArgs, CC1Args, "nvptx", GpuArch,
+/* bitcode SDL?*/ true, /* PostClang Link? */ true);
   }
 }
 
Index: clang/lib/Driver/ToolChains/CommonArgs.h
===
--- clang/lib/Driver/ToolChains/CommonArgs.h
+++ clang/lib/Driver/ToolChains/CommonArgs.h
@@ -49

[PATCH] D106577: [clang] Define __STDC_ISO_10646__

2021-07-26 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D106577#2902091 , @jyknight wrote:

> In D106577#2901654 , @rsmith wrote:
>
>> I think this patch as it stands would cause problems with libc 
>> implementations that put their `#define` somewhere other than than 
>> `stdc-predef.h` (eg, older versions of glibc that put it in `features.h` or 
>> other standard libraries that put it in `yvals.h`) due to the macro 
>> redefinition with a conflicting expansion. Such implementations are 
>> non-conforming but certainly exist. Likewise it could break the build for 
>> the same reason if we start implicitly including `stdc-predef.h` at some 
>> point. So I think that blindly predefining this macro will prove problematic 
>> in at least some circumstances.
>
> I don't understand what problem you expect to see here. We already suppress 
> -Wmacro-redefined [which this falls under] for system headers -- doesn't that 
> suffice?

I'd like to hear more about this as well, FWIW. I think we get all the benefits 
you describe by defining the macro in the frontend and letting the macro 
suppression work if there's a conflicting definition from a system header.

Btw @cor3ntin, it looks like you've got some failing test cases that need to be 
looked at:

https://reviews.llvm.org/harbormaster/unit/view/898745/
https://reviews.llvm.org/harbormaster/unit/view/898763/


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106577/new/

https://reviews.llvm.org/D106577

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


[PATCH] D106790: prfchwintrin.h: Make _m_prefetchw take a pointer to volatile (PR49124)

2021-07-26 Thread Hans Wennborg via Phabricator via cfe-commits
hans created this revision.
hans added reviewers: thakis, rnk.
hans requested review of this revision.
Herald added a project: clang.

For some reason, Microsoft declares _m_prefetch to take a const void*, but 
_m_prefetchw to take a /volatile/ const void*.

I can't think of any downside to just casting away the volatile here? (Besides 
having to suppress the warning in a somewhat ugly way.)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106790

Files:
  clang/lib/Headers/prfchwintrin.h


Index: clang/lib/Headers/prfchwintrin.h
===
--- clang/lib/Headers/prfchwintrin.h
+++ clang/lib/Headers/prfchwintrin.h
@@ -47,9 +47,12 @@
 /// \param __P
 ///A pointer specifying the memory address to be prefetched.
 static __inline__ void __attribute__((__always_inline__, __nodebug__))
-_m_prefetchw(void *__P)
+_m_prefetchw(volatile const void *__P)
 {
-  __builtin_prefetch (__P, 1, 3 /* _MM_HINT_T0 */);
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wcast-qual"
+  __builtin_prefetch ((const void*)__P, 1, 3 /* _MM_HINT_T0 */);
+#pragma clang diagnostic pop
 }
 
 #endif /* __PRFCHWINTRIN_H */


Index: clang/lib/Headers/prfchwintrin.h
===
--- clang/lib/Headers/prfchwintrin.h
+++ clang/lib/Headers/prfchwintrin.h
@@ -47,9 +47,12 @@
 /// \param __P
 ///A pointer specifying the memory address to be prefetched.
 static __inline__ void __attribute__((__always_inline__, __nodebug__))
-_m_prefetchw(void *__P)
+_m_prefetchw(volatile const void *__P)
 {
-  __builtin_prefetch (__P, 1, 3 /* _MM_HINT_T0 */);
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wcast-qual"
+  __builtin_prefetch ((const void*)__P, 1, 3 /* _MM_HINT_T0 */);
+#pragma clang diagnostic pop
 }
 
 #endif /* __PRFCHWINTRIN_H */
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106577: [clang] Define __STDC_ISO_10646__

2021-07-26 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 361639.
cor3ntin added a comment.
Herald added a project: clang-tools-extra.

Fix tests.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106577/new/

https://reviews.llvm.org/D106577

Files:
  clang-tools-extra/test/pp-trace/pp-trace-macro.cpp
  clang/lib/Basic/Targets/OSTargets.h
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/test/Preprocessor/init-aarch64.c
  clang/test/Preprocessor/init-x86.c
  clang/test/Preprocessor/init.c

Index: clang/test/Preprocessor/init.c
===
--- clang/test/Preprocessor/init.c
+++ clang/test/Preprocessor/init.c
@@ -284,6 +284,7 @@
 // RUN: %clang_cc1 -dM -fwchar-type=short -fno-signed-wchar -triple=x86_64-unknown-windows-cygnus -E /dev/null | FileCheck -match-full-lines -check-prefix SHORTWCHAR %s
 //
 // SHORTWCHAR: #define __SIZEOF_WCHAR_T__ 2
+// SHORTWCHAR-NOT: #define __STDC_ISO_10646__
 // SHORTWCHAR: #define __WCHAR_MAX__ 65535
 // SHORTWCHAR: #define __WCHAR_TYPE__ unsigned short
 // SHORTWCHAR: #define __WCHAR_WIDTH__ 16
@@ -292,6 +293,7 @@
 // RUN: %clang_cc1 -E -dM -fwchar-type=int -triple=x86_64-unknown-unknown < /dev/null | FileCheck -match-full-lines -check-prefix SHORTWCHAR2 %s
 //
 // SHORTWCHAR2: #define __SIZEOF_WCHAR_T__ 4
+// SHORTWCHAR2: #define __STDC_ISO_10646__ 202012L
 // SHORTWCHAR2: #define __WCHAR_WIDTH__ 32
 // Other definitions vary from platform to platform
 
@@ -1739,6 +1741,7 @@
 // WEBASSEMBLY-NOT:#define __STDC_NO_COMPLEX__
 // WEBASSEMBLY-NOT:#define __STDC_NO_VLA__
 // WEBASSEMBLY-NOT:#define __STDC_NO_THREADS__
+// WEBASSEMBLY-NEXT:#define __STDC_ISO_10646__ 202012L
 // WEBASSEMBLY-NEXT:#define __STDC_UTF_16__ 1
 // WEBASSEMBLY-NEXT:#define __STDC_UTF_32__ 1
 // WEBASSEMBLY-NEXT:#define __STDC_VERSION__ 201710L
@@ -2310,6 +2313,7 @@
 // RISCV32: #define __SIZE_TYPE__ unsigned int
 // RISCV32: #define __SIZE_WIDTH__ 32
 // RISCV32: #define __STDC_HOSTED__ 0
+// RISCV32: #define __STDC_ISO_10646__ 202012L
 // RISCV32: #define __STDC_UTF_16__ 1
 // RISCV32: #define __STDC_UTF_32__ 1
 // RISCV32: #define __STDC_VERSION__ 201710L
@@ -2517,6 +2521,7 @@
 // RISCV64: #define __SIZE_TYPE__ long unsigned int
 // RISCV64: #define __SIZE_WIDTH__ 64
 // RISCV64: #define __STDC_HOSTED__ 0
+// RISCV64: #define __STDC_ISO_10646__ 202012L
 // RISCV64: #define __STDC_UTF_16__ 1
 // RISCV64: #define __STDC_UTF_32__ 1
 // RISCV64: #define __STDC_VERSION__ 201710L
Index: clang/test/Preprocessor/init-x86.c
===
--- clang/test/Preprocessor/init-x86.c
+++ clang/test/Preprocessor/init-x86.c
@@ -1199,7 +1199,7 @@
 // X86_64-CLOUDABI:#define __SSE_MATH__ 1
 // X86_64-CLOUDABI:#define __SSE__ 1
 // X86_64-CLOUDABI:#define __STDC_HOSTED__ 0
-// X86_64-CLOUDABI:#define __STDC_ISO_10646__ 201206L
+// X86_64-CLOUDABI:#define __STDC_ISO_10646__ 202012L
 // X86_64-CLOUDABI:#define __STDC_UTF_16__ 1
 // X86_64-CLOUDABI:#define __STDC_UTF_32__ 1
 // X86_64-CLOUDABI:#define __STDC_VERSION__ 201710L
Index: clang/test/Preprocessor/init-aarch64.c
===
--- clang/test/Preprocessor/init-aarch64.c
+++ clang/test/Preprocessor/init-aarch64.c
@@ -235,6 +235,7 @@
 // AARCH64_CXX: #define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16UL
 // AARCH64_CXX: #define __STDCPP_THREADS__ 1
 // AARCH64-NEXT: #define __STDC_HOSTED__ 1
+// AARCH64: #define __STDC_ISO_10646__ 202012L
 // AARCH64-NEXT: #define __STDC_UTF_16__ 1
 // AARCH64-NEXT: #define __STDC_UTF_32__ 1
 // AARCH64_C: #define __STDC_VERSION__ 201710L
@@ -648,6 +649,7 @@
 // AARCH64-MSVC: #define __SIZE_TYPE__ long long unsigned int
 // AARCH64-MSVC: #define __SIZE_WIDTH__ 64
 // AARCH64-MSVC: #define __STDC_HOSTED__ 0
+// AARCH64-MSVC-NOT: #define __STDC_ISO_10646__
 // AARCH64-MSVC: #define __STDC_UTF_16__ 1
 // AARCH64-MSVC: #define __STDC_UTF_32__ 1
 // AARCH64-MSVC: #define __STDC_VERSION__ 201710L
Index: clang/lib/Frontend/InitPreprocessor.cpp
===
--- clang/lib/Frontend/InitPreprocessor.cpp
+++ clang/lib/Frontend/InitPreprocessor.cpp
@@ -427,6 +427,16 @@
   Builder.defineMacro("__STDC_UTF_16__", "1");
   Builder.defineMacro("__STDC_UTF_32__", "1");
 
+  // Because Clang only supports UTF-32 or UTF-16 as the
+  // wide execution encoding, any platform that doesn't use
+  // short wchar_t can represent the entire Unicode code space.
+  // Unicode 13 was released in December 2020, which is why we're
+  // expanding to 202012L. Note that new Unicode versions are
+  // *very* unlikely to cause Clang to need to remove the
+  // predefined macro.
+  if (TI.getWCharWidth() >= 32)
+Builder.defineMacro("__STDC_ISO_10646__", "202012L");
+
   if (LangOpts.ObjC)
 Builder.defineMacro("__OBJC__");
 
Index: clang/lib/Basic/Targets/OSTargets.h
===
--

[PATCH] D104198: [Matrix] Add documentation for compound assignment and type conversion of matrix types

2021-07-26 Thread Saurabh Jha via Phabricator via cfe-commits
SaurabhJha added a comment.

@fhahn addressed your broadcast comment. Would you prefer that I create the 
initialisation implementation patch before we get this in?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104198/new/

https://reviews.llvm.org/D104198

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


[PATCH] D106339: Add support to generate Sphinx DOCX documentation

2021-07-26 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

I remember that we even converted some `*.md` to `*.rst` to remove the number 
of supported documentation formats, so I agree that adding support the even 
less used `*.docx` may not be the proper direction.

Thanks for splitting this off.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106339/new/

https://reviews.llvm.org/D106339

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


Re: [PATCH] D104198: [Matrix] Add documentation for compound assignment and type conversion of matrix types

2021-07-26 Thread Saurabh Jha via cfe-commits
Sorry, commented on incorrect patch.

On Mon, Jul 26, 2021 at 2:34 PM Saurabh Jha via Phabricator <
revi...@reviews.llvm.org> wrote:

> SaurabhJha added a comment.
>
> @fhahn addressed your broadcast comment. Would you prefer that I create
> the initialisation implementation patch before we get this in?
>
>
> Repository:
>   rG LLVM Github Monorepo
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D104198/new/
>
> https://reviews.llvm.org/D104198
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106688: [AIX] Pass the -b option to linker on AIX

2021-07-26 Thread Anjan Kumar via Phabricator via cfe-commits
anjankgk added a comment.

Gentle ping..


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106688/new/

https://reviews.llvm.org/D106688

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


[PATCH] D106791: [clang-cl] Expose -fmodules and related flags in the driver (PR43391)

2021-07-26 Thread Hans Wennborg via Phabricator via cfe-commits
hans created this revision.
hans added reviewers: thakis, rnk.
Herald added a subscriber: dang.
hans requested review of this revision.
Herald added a project: clang.

I don't know how well this works with clang-cl, but people want to try it out, 
and I think we want to make it work, so exposing the flags seems reasonable.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106791

Files:
  clang/include/clang/Driver/Options.td
  clang/test/Driver/cl-options.c


Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -710,6 +710,23 @@
 // RUN: -fcs-profile-generate \
 // RUN: -fcs-profile-generate=dir \
 // RUN: -ftime-trace \
+// RUN: -fmodules \
+// RUN: -fno-modules \
+// RUN: -fimplicit-module-maps \
+// RUN: -fmodule-maps \
+// RUN: -fmodule-name=foo \
+// RUN: -fmodule-implementation-of \
+// RUN: -fsystem-module \
+// RUN: -fmodule-map-file=foo \
+// RUN: -fmodule-file=foo \
+// RUN: -fmodules-ignore-macro=foo \
+// RUN: -fmodules-strict-decluse \
+// RUN: -fmodules-decluse \
+// RUN: -fno-modules-decluse \
+// RUN: -fmodules-search-all \
+// RUN: -fno-modules-search-all \
+// RUN: -fimplicit-modules \
+// RUN: -fno-implicit-modules \
 // RUN: -ftrivial-auto-var-init=zero \
 // RUN: 
-enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang \
 // RUN: --version \
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2139,7 +2139,7 @@
   "debug info for types in an object file built from this PCH and do not 
generate them elsewhere">;
 
 def fimplicit_module_maps : Flag <["-"], "fimplicit-module-maps">, 
Group,
-  Flags<[NoXarchOption, CC1Option]>,
+  Flags<[NoXarchOption, CC1Option, CoreOption]>,
   HelpText<"Implicitly search the file system for module map files.">,
   MarshallingInfoFlag>;
 def fmodules_ts : Flag <["-"], "fmodules-ts">, Group,
@@ -2148,42 +2148,43 @@
 defm modules : BoolFOption<"modules",
   LangOpts<"Modules">, Default,
   PosFlag,
-  NegFlag, BothFlags<[NoXarchOption]>>;
-def fmodule_maps : Flag <["-"], "fmodule-maps">, Alias;
+  NegFlag, BothFlags<[NoXarchOption, CoreOption]>>;
+def fmodule_maps : Flag <["-"], "fmodule-maps">, Flags<[CoreOption]>, 
Alias;
 def fmodule_name_EQ : Joined<["-"], "fmodule-name=">, Group,
-  Flags<[NoXarchOption,CC1Option]>, MetaVarName<"">,
+  Flags<[NoXarchOption,CC1Option,CoreOption]>, MetaVarName<"">,
   HelpText<"Specify the name of the module to build">,
   MarshallingInfoString>;
 def fmodule_implementation_of : Separate<["-"], "fmodule-implementation-of">,
-  Flags<[CC1Option]>, Alias;
-def fsystem_module : Flag<["-"], "fsystem-module">, Flags<[CC1Option]>,
+  Flags<[CC1Option,CoreOption]>, Alias;
+def fsystem_module : Flag<["-"], "fsystem-module">, 
Flags<[CC1Option,CoreOption]>,
   HelpText<"Build this module as a system module. Only used with 
-emit-module">,
   MarshallingInfoFlag>;
 def fmodule_map_file : Joined<["-"], "fmodule-map-file=">,
-  Group, Flags<[NoXarchOption,CC1Option]>, MetaVarName<"">,
+  Group, Flags<[NoXarchOption,CC1Option,CoreOption]>, 
MetaVarName<"">,
   HelpText<"Load this module map file">,
   MarshallingInfoStringVector>;
 def fmodule_file : Joined<["-"], "fmodule-file=">,
-  Group, Flags<[NoXarchOption,CC1Option]>, 
MetaVarName<"[=]">,
+  Group, Flags<[NoXarchOption,CC1Option,CoreOption]>, 
MetaVarName<"[=]">,
   HelpText<"Specify the mapping of module name to precompiled module file, or 
load a module file if name is omitted.">;
-def fmodules_ignore_macro : Joined<["-"], "fmodules-ignore-macro=">, 
Group, Flags<[CC1Option]>,
+def fmodules_ignore_macro : Joined<["-"], "fmodules-ignore-macro=">, 
Group,
+  Flags<[CC1Option,CoreOption]>,
   HelpText<"Ignore the definition of the given macro when building and loading 
modules">;
 def fmodules_strict_decluse : Flag <["-"], "fmodules-strict-decluse">, 
Group,
-  Flags<[NoXarchOption,CC1Option]>,
+  Flags<[NoXarchOption,CC1Option,CoreOption]>,
   HelpText<"Like -fmodules-decluse but requires all headers to be in modules">,
   MarshallingInfoFlag>;
 defm modules_decluse : BoolFOption<"modules-decluse",
   LangOpts<"ModulesDeclUse">, Default,
   PosFlag,
-  NegFlag, BothFlags<[NoXarchOption]>>;
+  NegFlag, BothFlags<[NoXarchOption,CoreOption]>>;
 defm modules_search_all : BoolFOption<"modules-search-all",
   LangOpts<"ModulesSearchAll">, DefaultFalse,
   PosFlag,
-  NegFlag, BothFlags<[NoXarchOption, CC1Option]>>,
+  NegFlag, BothFlags<[NoXarchOption, CC1Option,CoreOption]>>,
   ShouldParseIf;
 defm implicit_modules : BoolFOption<"implicit-modules",
   LangOpts<"ImplicitModules">, DefaultTrue,
-  NegFlag, PosFlag, 
BothFlags<[NoXarchOption]>>;
+  NegFlag, PosFlag, 
BothFlags<[NoXarchOpt

[PATCH] D106394: [clang][pp] adds '#pragma include_instead'

2021-07-26 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!




Comment at: clang/include/clang/Basic/DiagnosticLexKinds.td:304
+
+def pp_pragma_include_instead_not_sysheader : Error<
+  "'#pragma clang include_instead' cannot be used outside of system headers">,

cjdb wrote:
> aaron.ballman wrote:
> > Can you prefix the diagnostic identifiers with `err_`? We're not super 
> > consistent in this file, but it's helpful when reading the use of the 
> > diagnostic to know whether it's an error or not.
> I've replaced `pp` with `err` since `pragma` implies "preprocessor" and don't 
> really think it adds much more value. `err` on the other hand is useful?
SGTM, thanks!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106394/new/

https://reviews.llvm.org/D106394

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


[clang] 8160016 - [OpenCL] Change default standard version to CL1.2

2021-07-26 Thread Anastasia Stulova via cfe-commits

Author: Anastasia Stulova
Date: 2021-07-26T15:04:34+01:00
New Revision: 81600160b3f926746d02c52003d81180941fe9d0

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

LOG: [OpenCL] Change default standard version to CL1.2

Set default version for OpenCL C to 1.2. This means that the
absence of any standard flag will be equivalent to passing
'-cl-std=CL1.2'.

Note that this patch also fixes incorrect version check for
the pointer to pointer kernel arguments diagnostic and
atomic test.

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

Added: 


Modified: 
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Sema/SemaDecl.cpp
clang/test/CodeGenOpenCL/spir_version.cl
clang/test/Parser/opencl-atomics-cl20.cl
clang/test/Parser/opencl-cl20.cl
clang/test/Parser/opencl-storage-class.cl
clang/test/Preprocessor/predefined-macros.c
clang/test/SemaOpenCL/fp64-fp16-options.cl
clang/test/SemaOpenCL/func.cl

Removed: 




diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index a8f25fa7c11c4..d545e9358f048 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -3088,7 +3088,7 @@ void CompilerInvocation::setLangDefaults(LangOptions 
&Opts, InputKind IK,
 case Language::LLVM_IR:
   llvm_unreachable("Invalid input kind!");
 case Language::OpenCL:
-  LangStd = LangStandard::lang_opencl10;
+  LangStd = LangStandard::lang_opencl12;
   break;
 case Language::OpenCLCXX:
   LangStd = LangStandard::lang_openclcpp;

diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index b25c3650b1607..205f580003029 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -8819,7 +8819,7 @@ static void checkIsValidOpenCLKernelParameter(
 // OpenCL v3.0 s6.11.a:
 // A kernel function argument cannot be declared as a pointer to a pointer
 // type. [...] This restriction only applies to OpenCL C 1.2 or below.
-if (S.getLangOpts().OpenCLVersion < 120 &&
+if (S.getLangOpts().OpenCLVersion <= 120 &&
 !S.getLangOpts().OpenCLCPlusPlus) {
   S.Diag(Param->getLocation(), diag::err_opencl_ptrptr_kernel_param);
   D.setInvalidType();

diff  --git a/clang/test/CodeGenOpenCL/spir_version.cl 
b/clang/test/CodeGenOpenCL/spir_version.cl
index 39893de0f56d0..b0fa0c2355af9 100644
--- a/clang/test/CodeGenOpenCL/spir_version.cl
+++ b/clang/test/CodeGenOpenCL/spir_version.cl
@@ -1,14 +1,13 @@
-// RUN: %clang_cc1 %s -triple "spir-unknown-unknown" -emit-llvm -o - | 
FileCheck %s --check-prefix=CHECK-SPIR-CL10
+// RUN: %clang_cc1 %s -triple "spir-unknown-unknown" -emit-llvm -o - 
-cl-std=CL1.0 | FileCheck %s --check-prefix=CHECK-SPIR-CL10
 // RUN: %clang_cc1 %s -triple "spir-unknown-unknown" -emit-llvm -o - 
-cl-std=CL1.2 | FileCheck %s --check-prefix=CHECK-SPIR-CL12
 // RUN: %clang_cc1 %s -triple "spir-unknown-unknown" -emit-llvm -o - 
-cl-std=CL2.0 | FileCheck %s --check-prefix=CHECK-SPIR-CL20
-// RUN: %clang_cc1 %s -triple "spir64-unknown-unknown" -emit-llvm -o - | 
FileCheck %s --check-prefix=CHECK-SPIR-CL10
+// RUN: %clang_cc1 %s -triple "spir64-unknown-unknown" -emit-llvm -o - 
-cl-std=CL1.0 | FileCheck %s --check-prefix=CHECK-SPIR-CL10
 // RUN: %clang_cc1 %s -triple "spir64-unknown-unknown" -emit-llvm -o - 
-cl-std=CL1.2 | FileCheck %s --check-prefix=CHECK-SPIR-CL12
 // RUN: %clang_cc1 %s -triple "spir64-unknown-unknown" -emit-llvm -o - 
-cl-std=CL2.0 | FileCheck %s --check-prefix=CHECK-SPIR-CL20
 
-
 // RUN: %clang_cc1 %s -triple "spir64-unknown-unknown" -emit-llvm -o - 
-cl-std=clc++ | FileCheck %s --check-prefix=CHECK-SPIR-CL20
 
-// RUN: %clang_cc1 %s -triple "amdgcn--amdhsa" -emit-llvm -o - | FileCheck %s 
--check-prefix=CHECK-AMDGCN-CL10
+// RUN: %clang_cc1 %s -triple "amdgcn--amdhsa" -emit-llvm -o - -cl-std=CL1.0 | 
FileCheck %s --check-prefix=CHECK-AMDGCN-CL10
 // RUN: %clang_cc1 %s -triple "amdgcn--amdhsa" -emit-llvm -o - -cl-std=CL1.2 | 
FileCheck %s --check-prefix=CHECK-AMDGCN-CL12
 // RUN: %clang_cc1 %s -triple "amdgcn--amdhsa" -emit-llvm -o - -cl-std=CL2.0 | 
FileCheck %s --check-prefix=CHECK-AMDGCN-CL20
 

diff  --git a/clang/test/Parser/opencl-atomics-cl20.cl 
b/clang/test/Parser/opencl-atomics-cl20.cl
index c3f86b6a44c49..50866dd61591e 100644
--- a/clang/test/Parser/opencl-atomics-cl20.cl
+++ b/clang/test/Parser/opencl-atomics-cl20.cl
@@ -4,7 +4,7 @@
 // RUN: %clang_cc1 %s -triple spir64-unknown-unknown -verify -fsyntax-only 
-cl-std=CLC++
 // RUN: %clang_cc1 %s -triple spir64-unknown-unknown -verify -fsyntax-only 
-cl-std=CL2.0 -cl-ext=-cl_khr_int64_base_atomics
 
-#if defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= CL_VERSION_1_2
+#if defined(__OPENCL_CPP_VERSION__) |

[PATCH] D106504: [OpenCL] Change default standard version to CL1.2

2021-07-26 Thread Anastasia Stulova via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG81600160b3f9: [OpenCL] Change default standard version to 
CL1.2 (authored by Anastasia).
Herald added a subscriber: ldrumm.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106504/new/

https://reviews.llvm.org/D106504

Files:
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/test/CodeGenOpenCL/spir_version.cl
  clang/test/Parser/opencl-atomics-cl20.cl
  clang/test/Parser/opencl-cl20.cl
  clang/test/Parser/opencl-storage-class.cl
  clang/test/Preprocessor/predefined-macros.c
  clang/test/SemaOpenCL/fp64-fp16-options.cl
  clang/test/SemaOpenCL/func.cl

Index: clang/test/SemaOpenCL/func.cl
===
--- clang/test/SemaOpenCL/func.cl
+++ clang/test/SemaOpenCL/func.cl
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -triple spir-unknown-unknown
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -triple spir-unknown-unknown -DFUNCPTREXT
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -triple spir-unknown-unknown -DVARARGEXT
+// RUN: %clang_cc1 %s -cl-std=CL1.0 -verify -pedantic -fsyntax-only -triple spir-unknown-unknown
+// RUN: %clang_cc1 %s -cl-std=CL1.0 -verify -pedantic -fsyntax-only -triple spir-unknown-unknown -DFUNCPTREXT
+// RUN: %clang_cc1 %s -cl-std=CL1.0 -verify -pedantic -fsyntax-only -triple spir-unknown-unknown -DVARARGEXT
 
 #ifdef FUNCPTREXT
 #pragma OPENCL EXTENSION __cl_clang_function_pointers : enable
Index: clang/test/SemaOpenCL/fp64-fp16-options.cl
===
--- clang/test/SemaOpenCL/fp64-fp16-options.cl
+++ clang/test/SemaOpenCL/fp64-fp16-options.cl
@@ -1,30 +1,30 @@
-// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL1.0
 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL1.1
 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -fsyntax-only -cl-std=CL1.1 -DNOPEDANTIC
 // RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-std=CL1.2 -DFP64
 
 // Test with a target not supporting fp64.
-// RUN: %clang_cc1 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -DNOFP64 -DNOFP16
+// RUN: %clang_cc1 %s -cl-std=CL1.0 -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -DNOFP64 -DNOFP16
 // RUN: %clang_cc1 -cl-std=CL3.0 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -DNOFP64 -DNOFP16
 
 // Test with some extensions enabled or disabled by cmd-line args
 //
 // Target does not support fp64 and fp16 - override it
-// RUN: %clang_cc1 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=+cl_khr_fp64,+cl_khr_fp16
+// RUN: %clang_cc1 %s -cl-std=CL1.0 -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=+cl_khr_fp64,+cl_khr_fp16
 //
 // Disable or enable all extensions
-// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-all -DNOFP64 -DNOFP16
-// RUN: %clang_cc1 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=+all
-// RUN: %clang_cc1 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=+all,-cl_khr_fp64 -DNOFP64
-// RUN: %clang_cc1 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=-all,+cl_khr_fp64 -DNOFP16
+// RUN: %clang_cc1 %s -cl-std=CL1.0 -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-all -DNOFP64 -DNOFP16
+// RUN: %clang_cc1 %s -cl-std=CL1.0 -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=+all
+// RUN: %clang_cc1 %s -cl-std=CL1.0 -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=+all,-cl_khr_fp64 -DNOFP64
+// RUN: %clang_cc1 %s -cl-std=CL1.0 -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=-all,+cl_khr_fp64 -DNOFP16
 // RUN: %clang_cc1 -cl-std=CL3.0 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-all -DNOFP64 -DNOFP16
 // RUN: %clang_cc1 -cl-std=CL3.0 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=+all -DFP64
 // RUN: %clang_cc1 -cl-std=CL3.0 %s -triple r600-unknown-unknown -target-cpu r600 -verify -pedantic -fsyntax-only -cl-ext=+all,-__opencl_c_fp64,-cl_khr_fp64 -DNOFP64
 //
 // Concatenating
-// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyntax-only -cl-ext=-cl_khr_fp64 -cl-ext=+cl_khr_fp64
-// RUN: %clang_cc1 %s -triple spir-unknown-unknown -verify -pedantic -fsyn

[PATCH] D106757: [PowerPC] Implement partial vector ld/st builtins for XL compatibility

2021-07-26 Thread Amy Kwan via Phabricator via cfe-commits
amyk added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:15111
+if (IsLE) {
+  Constant *Zero = llvm::Constant::getNullValue(ResTy);
+  SmallVector Consts;

Maybe we can pull out this line and do the following:
```
Constant *Zero = llvm::Constant::getNullValue(IsLE ? ResTy : 
AllElts->getType());
```



Comment at: clang/test/CodeGen/builtins-ppc-ld-st-rmb.c:1
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// REQUIRES: powerpc-registered-target

nemanjai wrote:
> The test case is quite verbose but the checks were produced by the script so 
> it should be easy to maintain. The reason I added so many checks is that the 
> produce code is very dependent on:
> - endianness
> - CPU
> - the number of bytes (in the store case)
The test is pretty verbose already, but do you think it is necessary to add 
checks for AIX, or is having just the Linux ones fine?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106757/new/

https://reviews.llvm.org/D106757

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


[PATCH] D106748: [OpenCL] Add support of __opencl_c_pipes feature macro.

2021-07-26 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticCommonKinds.td:154
   "'%2' %select{type qualifier|storage class specifier}3">;
+def err_opencl_type_specifier_requires : Error<
+  "%select{type qualifier|storage class specifier}0 '%1' requires "

If possible I would prefer to unify the diagnostics. How about something like:

```
'%2' %select{type qualifier|storage class specifier}3 is unsupported in 
%select{OpenCL C|C++ for OpenCL}0 version %1
```

then where we print the diagnostic we can special case OpenCL 3.0 to also print 
additionally the feature information. FYI we could add the special case for 
OpenCL 3.0 later on in a separate patch and for now just reuse the diagnostic 
as is. Then this patch could still go into release 13 although a bit tight but 
doable.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106748/new/

https://reviews.llvm.org/D106748

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


[PATCH] D106789: [clang][Driver] Expose driver mode detection logic

2021-07-26 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 361646.
kadircet added a comment.

- Preserve no diagnostic behaviour in case of an empty driver.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106789/new/

https://reviews.llvm.org/D106789

Files:
  clang/include/clang/Driver/Driver.h
  clang/lib/Driver/Driver.cpp
  clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
  clang/tools/driver/driver.cpp

Index: clang/tools/driver/driver.cpp
===
--- clang/tools/driver/driver.cpp
+++ clang/tools/driver/driver.cpp
@@ -360,7 +360,6 @@
 return 1;
 
   llvm::InitializeAllTargets();
-  auto TargetAndMode = ToolChain::getTargetAndModeFromProgramName(Args[0]);
 
   llvm::BumpPtrAllocator A;
   llvm::StringSaver Saver(A);
@@ -372,13 +371,8 @@
   // have to manually search for a --driver-mode=cl argument the hard way.
   // Finally, our -cc1 tools don't care which tokenization mode we use because
   // response files written by clang will tokenize the same way in either mode.
-  bool ClangCLMode = false;
-  if (StringRef(TargetAndMode.DriverMode).equals("--driver-mode=cl") ||
-  llvm::find_if(Args, [](const char *F) {
-return F && strcmp(F, "--driver-mode=cl") == 0;
-  }) != Args.end()) {
-ClangCLMode = true;
-  }
+  bool ClangCLMode =
+  getDriverMode(Args[0], llvm::makeArrayRef(Args).slice(1)).equals("cl");
   enum { Default, POSIX, Windows } RSPQuoting = Default;
   for (const char *F : Args) {
 if (strcmp(F, "--rsp-quoting=posix") == 0)
@@ -490,6 +484,7 @@
 
   Driver TheDriver(Path, llvm::sys::getDefaultTargetTriple(), Diags);
   SetInstallDir(Args, TheDriver, CanonicalPrefixes);
+  auto TargetAndMode = ToolChain::getTargetAndModeFromProgramName(Args[0]);
   TheDriver.setTargetAndMode(TargetAndMode);
 
   insertTargetAndModeArgs(TargetAndMode, Args, SavedStrings);
Index: clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
===
--- clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
+++ clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
@@ -43,9 +43,11 @@
 //===--===//
 
 #include "clang/Basic/LangStandard.h"
+#include "clang/Driver/Driver.h"
 #include "clang/Driver/Options.h"
 #include "clang/Driver/Types.h"
 #include "clang/Tooling/CompilationDatabase.h"
+#include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringExtras.h"
@@ -134,8 +136,7 @@
   bool ClangCLMode;
 
   TransferableCommand(CompileCommand C)
-  : Cmd(std::move(C)), Type(guessType(Cmd.Filename)),
-ClangCLMode(checkIsCLMode(Cmd.CommandLine)) {
+  : Cmd(std::move(C)), Type(guessType(Cmd.Filename)) {
 std::vector OldArgs = std::move(Cmd.CommandLine);
 Cmd.CommandLine.clear();
 
@@ -145,6 +146,10 @@
   SmallVector TmpArgv;
   for (const std::string &S : OldArgs)
 TmpArgv.push_back(S.c_str());
+  ClangCLMode = !TmpArgv.empty() &&
+driver::getDriverMode(TmpArgv.front(),
+  llvm::makeArrayRef(TmpArgv).slice(1))
+.equals("cl");
   ArgList = {TmpArgv.begin(), TmpArgv.end()};
 }
 
@@ -246,19 +251,6 @@
   }
 
 private:
-  // Determine whether the given command line is intended for the CL driver.
-  static bool checkIsCLMode(ArrayRef CmdLine) {
-// First look for --driver-mode.
-for (StringRef S : llvm::reverse(CmdLine)) {
-  if (S.consume_front("--driver-mode="))
-return S == "cl";
-}
-
-// Otherwise just check the clang executable file name.
-return !CmdLine.empty() &&
-   llvm::sys::path::stem(CmdLine.front()).endswith_insensitive("cl");
-  }
-
   // Map the language from the --std flag to that of the -x flag.
   static types::ID toType(Language Lang) {
 switch (Lang) {
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -63,6 +63,7 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSet.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Config/llvm-config.h"
@@ -168,28 +169,11 @@
   ResourceDir = GetResourcesPath(ClangExecutable, CLANG_RESOURCE_DIR);
 }
 
-void Driver::ParseDriverMode(StringRef ProgramName,
- ArrayRef Args) {
-  if (ClangNameParts.isEmpty())
-ClangNameParts = ToolChain::getTargetAndModeFromProgramName(ProgramName);
-  setDriverModeFromOption(ClangNameParts.DriverMode);
-
-  for (const char *ArgPtr : Args) {
-// Ignore nullptrs, they are the response file's EOL markers.
-if (ArgPtr == nullptr)
-  continue;
-const StringRef Arg = ArgPtr;
-setDriverModeFromO

[clang] 4761321 - [Analyzer][solver][NFC] print constraints deterministically (ordered by their string representation)

2021-07-26 Thread Gabor Marton via cfe-commits

Author: Gabor Marton
Date: 2021-07-26T16:27:23+02:00
New Revision: 4761321d49db01dce1e308f900add033cc26fb47

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

LOG: [Analyzer][solver][NFC] print constraints deterministically (ordered by 
their string representation)

This change is an extension to D103967 where I added dump methods for
(dis)equality classes of the State. There, the (dis)equality classes and their
contents are dumped in an ordered fashion, they are ordered based on their
string representation. This is very useful once we start to use FileCheck to
test the State dump in certain tests.

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

Added: 


Modified: 
clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp 
b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
index de86fc685b075..69554576bdb2e 100644
--- a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -2630,6 +2630,13 @@ void RangeConstraintManager::printJson(raw_ostream &Out, 
ProgramStateRef State,
   printDisequalities(Out, State, NL, Space, IsDot);
 }
 
+static std::string toString(const SymbolRef &Sym) {
+  std::string S;
+  llvm::raw_string_ostream O(S);
+  Sym->dumpToStream(O);
+  return O.str();
+}
+
 void RangeConstraintManager::printConstraints(raw_ostream &Out,
   ProgramStateRef State,
   const char *NL,
@@ -2643,25 +2650,32 @@ void 
RangeConstraintManager::printConstraints(raw_ostream &Out,
 return;
   }
 
-  ++Space;
-  Out << '[' << NL;
-  bool First = true;
+  std::map OrderedConstraints;
   for (std::pair P : Constraints) {
 SymbolSet ClassMembers = P.first.getClassMembers(State);
+for (const SymbolRef &ClassMember : ClassMembers) {
+  bool insertion_took_place;
+  std::tie(std::ignore, insertion_took_place) =
+  OrderedConstraints.insert({toString(ClassMember), P.second});
+  assert(insertion_took_place &&
+ "two symbols should not have the same dump");
+}
+  }
 
-// We can print the same constraint for every class member.
-for (SymbolRef ClassMember : ClassMembers) {
-  if (First) {
-First = false;
-  } else {
-Out << ',';
-Out << NL;
-  }
-  Indent(Out, Space, IsDot)
-  << "{ \"symbol\": \"" << ClassMember << "\", \"range\": \"";
-  P.second.dump(Out);
-  Out << "\" }";
+  ++Space;
+  Out << '[' << NL;
+  bool First = true;
+  for (std::pair P : OrderedConstraints) {
+if (First) {
+  First = false;
+} else {
+  Out << ',';
+  Out << NL;
 }
+Indent(Out, Space, IsDot)
+<< "{ \"symbol\": \"" << P.first << "\", \"range\": \"";
+P.second.dump(Out);
+Out << "\" }";
   }
   Out << NL;
 
@@ -2669,13 +2683,6 @@ void 
RangeConstraintManager::printConstraints(raw_ostream &Out,
   Indent(Out, Space, IsDot) << "]," << NL;
 }
 
-static std::string toString(const SymbolRef &Sym) {
-  std::string S;
-  llvm::raw_string_ostream O(S);
-  Sym->dumpToStream(O);
-  return O.str();
-}
-
 static std::string toString(ProgramStateRef State, EquivalenceClass Class) {
   SymbolSet ClassMembers = Class.getClassMembers(State);
   llvm::SmallVector ClassMembersSorted(ClassMembers.begin(),



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


[PATCH] D106642: [Analyzer][solver][NFC] print constraints deterministically (ordered by their string representation)

2021-07-26 Thread Gabor Marton via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4761321d49db: [Analyzer][solver][NFC] print constraints 
deterministically (ordered by their… (authored by martong).

Changed prior to commit:
  https://reviews.llvm.org/D106642?vs=361142&id=361648#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106642/new/

https://reviews.llvm.org/D106642

Files:
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp


Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -2630,6 +2630,13 @@
   printDisequalities(Out, State, NL, Space, IsDot);
 }
 
+static std::string toString(const SymbolRef &Sym) {
+  std::string S;
+  llvm::raw_string_ostream O(S);
+  Sym->dumpToStream(O);
+  return O.str();
+}
+
 void RangeConstraintManager::printConstraints(raw_ostream &Out,
   ProgramStateRef State,
   const char *NL,
@@ -2643,25 +2650,32 @@
 return;
   }
 
-  ++Space;
-  Out << '[' << NL;
-  bool First = true;
+  std::map OrderedConstraints;
   for (std::pair P : Constraints) {
 SymbolSet ClassMembers = P.first.getClassMembers(State);
+for (const SymbolRef &ClassMember : ClassMembers) {
+  bool insertion_took_place;
+  std::tie(std::ignore, insertion_took_place) =
+  OrderedConstraints.insert({toString(ClassMember), P.second});
+  assert(insertion_took_place &&
+ "two symbols should not have the same dump");
+}
+  }
 
-// We can print the same constraint for every class member.
-for (SymbolRef ClassMember : ClassMembers) {
-  if (First) {
-First = false;
-  } else {
-Out << ',';
-Out << NL;
-  }
-  Indent(Out, Space, IsDot)
-  << "{ \"symbol\": \"" << ClassMember << "\", \"range\": \"";
-  P.second.dump(Out);
-  Out << "\" }";
+  ++Space;
+  Out << '[' << NL;
+  bool First = true;
+  for (std::pair P : OrderedConstraints) {
+if (First) {
+  First = false;
+} else {
+  Out << ',';
+  Out << NL;
 }
+Indent(Out, Space, IsDot)
+<< "{ \"symbol\": \"" << P.first << "\", \"range\": \"";
+P.second.dump(Out);
+Out << "\" }";
   }
   Out << NL;
 
@@ -2669,13 +2683,6 @@
   Indent(Out, Space, IsDot) << "]," << NL;
 }
 
-static std::string toString(const SymbolRef &Sym) {
-  std::string S;
-  llvm::raw_string_ostream O(S);
-  Sym->dumpToStream(O);
-  return O.str();
-}
-
 static std::string toString(ProgramStateRef State, EquivalenceClass Class) {
   SymbolSet ClassMembers = Class.getClassMembers(State);
   llvm::SmallVector ClassMembersSorted(ClassMembers.begin(),


Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -2630,6 +2630,13 @@
   printDisequalities(Out, State, NL, Space, IsDot);
 }
 
+static std::string toString(const SymbolRef &Sym) {
+  std::string S;
+  llvm::raw_string_ostream O(S);
+  Sym->dumpToStream(O);
+  return O.str();
+}
+
 void RangeConstraintManager::printConstraints(raw_ostream &Out,
   ProgramStateRef State,
   const char *NL,
@@ -2643,25 +2650,32 @@
 return;
   }
 
-  ++Space;
-  Out << '[' << NL;
-  bool First = true;
+  std::map OrderedConstraints;
   for (std::pair P : Constraints) {
 SymbolSet ClassMembers = P.first.getClassMembers(State);
+for (const SymbolRef &ClassMember : ClassMembers) {
+  bool insertion_took_place;
+  std::tie(std::ignore, insertion_took_place) =
+  OrderedConstraints.insert({toString(ClassMember), P.second});
+  assert(insertion_took_place &&
+ "two symbols should not have the same dump");
+}
+  }
 
-// We can print the same constraint for every class member.
-for (SymbolRef ClassMember : ClassMembers) {
-  if (First) {
-First = false;
-  } else {
-Out << ',';
-Out << NL;
-  }
-  Indent(Out, Space, IsDot)
-  << "{ \"symbol\": \"" << ClassMember << "\", \"range\": \"";
-  P.second.dump(Out);
-  Out << "\" }";
+  ++Space;
+  Out << '[' << NL;
+  bool First = true;
+  for (std::pair P : OrderedConstraints) {
+if (First) {
+  First = false;
+} else {
+  Out << ',';
+  Out << NL;
 }
+Indent(Out, Space, IsDot)
+<< "{ \"symbol\": \"" << P.first << "\", \"range\": \"";
+P.second.dump(Out);
+Out << "\" }";
   }
   Out << NL;
 
@@ -2669,13 +2683,6 @@
   Indent(Out, Space

[PATCH] D106642: [Analyzer][solver][NFC] print constraints deterministically (ordered by their string representation)

2021-07-26 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

In D106642#2900397 , @NoQ wrote:

> Thanks!
>
> You got me thinking whether two symbols can have the same dump. We definitely 
> don't want this to happen but there's also no reason to believe it doesn't, 
> given that this wouldn't affect any actual behavior or any tests. Can we add 
> an assert here that the symbol is always freshly added? In this case we'd at 
> least know when that happens.

Thanks for the review! I've added an assertion to check that a symbol's dump is 
unique.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106642/new/

https://reviews.llvm.org/D106642

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


[PATCH] D106748: [OpenCL] Add support of __opencl_c_pipes feature macro.

2021-07-26 Thread Anton Zabaznov via Phabricator via cfe-commits
azabaznov added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticCommonKinds.td:154
   "'%2' %select{type qualifier|storage class specifier}3">;
+def err_opencl_type_specifier_requires : Error<
+  "%select{type qualifier|storage class specifier}0 '%1' requires "

Anastasia wrote:
> If possible I would prefer to unify the diagnostics. How about something like:
> 
> ```
> '%2' %select{type qualifier|storage class specifier}3 is unsupported in 
> %select{OpenCL C|C++ for OpenCL}0 version %1
> ```
> 
> then where we print the diagnostic we can special case OpenCL 3.0 to also 
> print additionally the feature information. FYI we could add the special case 
> for OpenCL 3.0 later on in a separate patch and for now just reuse the 
> diagnostic as is. Then this patch could still go into release 13 although a 
> bit tight but doable.
This is actually the way how clang provides diagnostic now 
(https://godbolt.org/z/9P6PWdE5M):

```
OpenCL C version 3.0 does not support the 'generic' type qualifier
```
Here I just wanted to unify cases for `pipe` and `generic` since they both 
require OpenCL C 2.0 or later with a feature. Do you think it makes sense?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106748/new/

https://reviews.llvm.org/D106748

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


[PATCH] D106792: [clang-tidy] Always open files using UTF-8 encoding

2021-07-26 Thread Andy Yankovsky via Phabricator via cfe-commits
werat created this revision.
Herald added a subscriber: xazax.hun.
werat requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

The encoding used for opening files depends on the OS and might be different
from UTF-8 (e.g. on Windows it can be CP-1252). The documentation files use
UTF-8 and might be incompatible with other encodings. For example, right now
`clang-tools-extra/docs/clang-tidy/checks/abseil-no-internal-dependencies.rst`
has non-ASCII quotes and running `add_new_check.py` fails on Windows, because
it tries to read the file with incompatible encoding.

Use `io.open` for compatibility with both Python 2 and Python 3.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106792

Files:
  clang-tools-extra/clang-tidy/add_new_check.py
  clang-tools-extra/clang-tidy/rename_check.py


Index: clang-tools-extra/clang-tidy/rename_check.py
===
--- clang-tools-extra/clang-tidy/rename_check.py
+++ clang-tools-extra/clang-tidy/rename_check.py
@@ -10,9 +10,15 @@
 
 import argparse
 import glob
+import io
 import os
 import re
 
+# The documentation files are using UTF-8, however on Windows the default
+# encoding might be different (e.g. CP-1252). Force UTF-8 for all files.
+def open(*args, **kwargs):
+  kwargs.setdefault("encoding", "utf8")
+  return io.open(*args, **kwargs)
 
 def replaceInFileRegex(fileName, sFrom, sTo):
   if sFrom == sTo:
Index: clang-tools-extra/clang-tidy/add_new_check.py
===
--- clang-tools-extra/clang-tidy/add_new_check.py
+++ clang-tools-extra/clang-tidy/add_new_check.py
@@ -11,10 +11,16 @@
 from __future__ import print_function
 
 import argparse
+import io
 import os
 import re
 import sys
 
+# The documentation files are using UTF-8, however on Windows the default
+# encoding might be different (e.g. CP-1252). Force UTF-8 for all files.
+def open(*args, **kwargs):
+  kwargs.setdefault("encoding", "utf8")
+  return io.open(*args, **kwargs)
 
 # Adapts the module's CMakelist file. Returns 'True' if it could add a new
 # entry and 'False' if the entry already existed.


Index: clang-tools-extra/clang-tidy/rename_check.py
===
--- clang-tools-extra/clang-tidy/rename_check.py
+++ clang-tools-extra/clang-tidy/rename_check.py
@@ -10,9 +10,15 @@
 
 import argparse
 import glob
+import io
 import os
 import re
 
+# The documentation files are using UTF-8, however on Windows the default
+# encoding might be different (e.g. CP-1252). Force UTF-8 for all files.
+def open(*args, **kwargs):
+  kwargs.setdefault("encoding", "utf8")
+  return io.open(*args, **kwargs)
 
 def replaceInFileRegex(fileName, sFrom, sTo):
   if sFrom == sTo:
Index: clang-tools-extra/clang-tidy/add_new_check.py
===
--- clang-tools-extra/clang-tidy/add_new_check.py
+++ clang-tools-extra/clang-tidy/add_new_check.py
@@ -11,10 +11,16 @@
 from __future__ import print_function
 
 import argparse
+import io
 import os
 import re
 import sys
 
+# The documentation files are using UTF-8, however on Windows the default
+# encoding might be different (e.g. CP-1252). Force UTF-8 for all files.
+def open(*args, **kwargs):
+  kwargs.setdefault("encoding", "utf8")
+  return io.open(*args, **kwargs)
 
 # Adapts the module's CMakelist file. Returns 'True' if it could add a new
 # entry and 'False' if the entry already existed.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106793: [OpenMP] Add a driver flag to enable the new device runtime library

2021-07-26 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 created this revision.
jhuber6 added reviewers: jdoerfert, tianshilei1992.
Herald added subscribers: dexonsmith, dang, kerbowa, guansong, yaxunl, 
nhaehnle, jvesely.
jhuber6 requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

This patch adds a driver flag to optinally enable the new device runtime
bitcode library. This allows users to enable the new experimental runtime
before it becomes the default in the future.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106793

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
  clang/lib/Driver/ToolChains/Cuda.cpp


Index: clang/lib/Driver/ToolChains/Cuda.cpp
===
--- clang/lib/Driver/ToolChains/Cuda.cpp
+++ clang/lib/Driver/ToolChains/Cuda.cpp
@@ -751,7 +751,13 @@
   return;
 }
 
-std::string BitcodeSuffix = "nvptx-" + GpuArch.str();
+std::string BitcodeSuffix;
+if (DriverArgs.hasFlag(options::OPT_fopenmp_target_new_runtime,
+   options::OPT_fno_openmp_target_new_runtime, false))
+  BitcodeSuffix = "new-nvptx-" + GpuArch.str();
+else
+  BitcodeSuffix = "nvptx-" + GpuArch.str();
+
 addOpenMPDeviceRTL(getDriver(), DriverArgs, CC1Args, BitcodeSuffix,
getTriple());
   }
Index: clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
===
--- clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
+++ clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
@@ -222,7 +222,14 @@
 
   if (DriverArgs.hasArg(options::OPT_nogpulib))
 return;
-  std::string BitcodeSuffix = "amdgcn-" + GPUArch;
+
+  std::string BitcodeSuffix;
+  if (DriverArgs.hasFlag(options::OPT_fopenmp_target_new_runtime,
+ options::OPT_fno_openmp_target_new_runtime, false))
+BitcodeSuffix = "new-amdgcn-" + GPUArch;
+  else
+BitcodeSuffix = "amdgcn-" + GPUArch;
+
   addOpenMPDeviceRTL(getDriver(), DriverArgs, CC1Args, BitcodeSuffix,
  getTriple());
 }
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2373,6 +2373,10 @@
   Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
 def fopenmp_cuda_teams_reduction_recs_num_EQ : Joined<["-"], 
"fopenmp-cuda-teams-reduction-recs-num=">, Group,
   Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
+defm openmp_target_new_runtime: BoolFOption<"openmp-target-new-runtime",
+  LangOpts<"OpenMPTargetNewRuntime">, DefaultFalse,
+  PosFlag,
+  NegFlag>;
 defm openmp_optimistic_collapse : BoolFOption<"openmp-optimistic-collapse",
   LangOpts<"OpenMPOptimisticCollapse">, DefaultFalse,
   PosFlag, NegFlag, 
BothFlags<[NoArgumentUnused, HelpHidden]>>;
Index: clang/include/clang/Basic/LangOptions.def
===
--- clang/include/clang/Basic/LangOptions.def
+++ clang/include/clang/Basic/LangOptions.def
@@ -240,6 +240,7 @@
 LANGOPT(OpenMPCUDANumSMs  , 32, 0, "Number of SMs for CUDA devices.")
 LANGOPT(OpenMPCUDABlocksPerSM  , 32, 0, "Number of blocks per SM for CUDA 
devices.")
 LANGOPT(OpenMPCUDAReductionBufNum , 32, 1024, "Number of the reduction records 
in the intermediate reduction buffer used for the teams reductions.")
+LANGOPT(OpenMPTargetNewRuntime , 1, 0, "Use the new bitcode library for OpenMP 
offloading")
 LANGOPT(OpenMPOptimisticCollapse  , 1, 0, "Use at most 32 bits to represent 
the collapsed loop nest counter.")
 LANGOPT(RenderScript  , 1, 0, "RenderScript")
 


Index: clang/lib/Driver/ToolChains/Cuda.cpp
===
--- clang/lib/Driver/ToolChains/Cuda.cpp
+++ clang/lib/Driver/ToolChains/Cuda.cpp
@@ -751,7 +751,13 @@
   return;
 }
 
-std::string BitcodeSuffix = "nvptx-" + GpuArch.str();
+std::string BitcodeSuffix;
+if (DriverArgs.hasFlag(options::OPT_fopenmp_target_new_runtime,
+   options::OPT_fno_openmp_target_new_runtime, false))
+  BitcodeSuffix = "new-nvptx-" + GpuArch.str();
+else
+  BitcodeSuffix = "nvptx-" + GpuArch.str();
+
 addOpenMPDeviceRTL(getDriver(), DriverArgs, CC1Args, BitcodeSuffix,
getTriple());
   }
Index: clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
===
--- clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
+++ clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
@@ -222,7 +222,14 @@
 
   if (DriverArgs.hasArg(options::OPT_nogpulib))
 return;
-  std::string BitcodeSuffix = "amdgcn-" + GPUArch;
+
+  std::string BitcodeSuffix;
+  if (DriverArgs.hasFlag(options::OPT_fopenmp_target_new_runtime,
+ options::OPT_fno_openmp_targ

[PATCH] D106793: [OpenMP] Add a driver flag to enable the new device runtime library

2021-07-26 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

We need a driver test.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106793/new/

https://reviews.llvm.org/D106793

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


[PATCH] D106748: [OpenCL] Add support of __opencl_c_pipes feature macro.

2021-07-26 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticCommonKinds.td:154
   "'%2' %select{type qualifier|storage class specifier}3">;
+def err_opencl_type_specifier_requires : Error<
+  "%select{type qualifier|storage class specifier}0 '%1' requires "

azabaznov wrote:
> Anastasia wrote:
> > If possible I would prefer to unify the diagnostics. How about something 
> > like:
> > 
> > ```
> > '%2' %select{type qualifier|storage class specifier}3 is unsupported in 
> > %select{OpenCL C|C++ for OpenCL}0 version %1
> > ```
> > 
> > then where we print the diagnostic we can special case OpenCL 3.0 to also 
> > print additionally the feature information. FYI we could add the special 
> > case for OpenCL 3.0 later on in a separate patch and for now just reuse the 
> > diagnostic as is. Then this patch could still go into release 13 although a 
> > bit tight but doable.
> This is actually the way how clang provides diagnostic now 
> (https://godbolt.org/z/9P6PWdE5M):
> 
> ```
> OpenCL C version 3.0 does not support the 'generic' type qualifier
> ```
> Here I just wanted to unify cases for `pipe` and `generic` since they both 
> require OpenCL C 2.0 or later with a feature. Do you think it makes sense?
I think what you are trying to do makes perfect sense i.e. we should improve 
the diagnostic for sure. But I think we should avoid duplication with 
`err_opencl_type_specifier_requires` like you have done in 
https://reviews.llvm.org/D106260#change-jk5JS8iu1irq

But improving the diagnostic can perfectly be done as a separate step later on.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106748/new/

https://reviews.llvm.org/D106748

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


[PATCH] D106789: [clang][Driver] Expose driver mode detection logic

2021-07-26 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 361656.
kadircet added a comment.

- Rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106789/new/

https://reviews.llvm.org/D106789

Files:
  clang/include/clang/Driver/Driver.h
  clang/lib/Driver/Driver.cpp
  clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
  clang/tools/driver/driver.cpp

Index: clang/tools/driver/driver.cpp
===
--- clang/tools/driver/driver.cpp
+++ clang/tools/driver/driver.cpp
@@ -360,7 +360,6 @@
 return 1;
 
   llvm::InitializeAllTargets();
-  auto TargetAndMode = ToolChain::getTargetAndModeFromProgramName(Args[0]);
 
   llvm::BumpPtrAllocator A;
   llvm::StringSaver Saver(A);
@@ -372,13 +371,8 @@
   // have to manually search for a --driver-mode=cl argument the hard way.
   // Finally, our -cc1 tools don't care which tokenization mode we use because
   // response files written by clang will tokenize the same way in either mode.
-  bool ClangCLMode = false;
-  if (StringRef(TargetAndMode.DriverMode).equals("--driver-mode=cl") ||
-  llvm::find_if(Args, [](const char *F) {
-return F && strcmp(F, "--driver-mode=cl") == 0;
-  }) != Args.end()) {
-ClangCLMode = true;
-  }
+  bool ClangCLMode =
+  getDriverMode(Args[0], llvm::makeArrayRef(Args).slice(1)).equals("cl");
   enum { Default, POSIX, Windows } RSPQuoting = Default;
   for (const char *F : Args) {
 if (strcmp(F, "--rsp-quoting=posix") == 0)
@@ -490,6 +484,7 @@
 
   Driver TheDriver(Path, llvm::sys::getDefaultTargetTriple(), Diags);
   SetInstallDir(Args, TheDriver, CanonicalPrefixes);
+  auto TargetAndMode = ToolChain::getTargetAndModeFromProgramName(Args[0]);
   TheDriver.setTargetAndMode(TargetAndMode);
 
   insertTargetAndModeArgs(TargetAndMode, Args, SavedStrings);
Index: clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
===
--- clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
+++ clang/lib/Tooling/InterpolatingCompilationDatabase.cpp
@@ -43,9 +43,11 @@
 //===--===//
 
 #include "clang/Basic/LangStandard.h"
+#include "clang/Driver/Driver.h"
 #include "clang/Driver/Options.h"
 #include "clang/Driver/Types.h"
 #include "clang/Tooling/CompilationDatabase.h"
+#include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringExtras.h"
@@ -134,8 +136,7 @@
   bool ClangCLMode;
 
   TransferableCommand(CompileCommand C)
-  : Cmd(std::move(C)), Type(guessType(Cmd.Filename)),
-ClangCLMode(checkIsCLMode(Cmd.CommandLine)) {
+  : Cmd(std::move(C)), Type(guessType(Cmd.Filename)) {
 std::vector OldArgs = std::move(Cmd.CommandLine);
 Cmd.CommandLine.clear();
 
@@ -145,6 +146,10 @@
   SmallVector TmpArgv;
   for (const std::string &S : OldArgs)
 TmpArgv.push_back(S.c_str());
+  ClangCLMode = !TmpArgv.empty() &&
+driver::getDriverMode(TmpArgv.front(),
+  llvm::makeArrayRef(TmpArgv).slice(1))
+.equals("cl");
   ArgList = {TmpArgv.begin(), TmpArgv.end()};
 }
 
@@ -246,19 +251,6 @@
   }
 
 private:
-  // Determine whether the given command line is intended for the CL driver.
-  static bool checkIsCLMode(ArrayRef CmdLine) {
-// First look for --driver-mode.
-for (StringRef S : llvm::reverse(CmdLine)) {
-  if (S.consume_front("--driver-mode="))
-return S == "cl";
-}
-
-// Otherwise just check the clang executable file name.
-return !CmdLine.empty() &&
-   llvm::sys::path::stem(CmdLine.front()).endswith_insensitive("cl");
-  }
-
   // Map the language from the --std flag to that of the -x flag.
   static types::ID toType(Language Lang) {
 switch (Lang) {
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -63,6 +63,7 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSet.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Config/llvm-config.h"
@@ -168,28 +169,11 @@
   ResourceDir = GetResourcesPath(ClangExecutable, CLANG_RESOURCE_DIR);
 }
 
-void Driver::ParseDriverMode(StringRef ProgramName,
- ArrayRef Args) {
-  if (ClangNameParts.isEmpty())
-ClangNameParts = ToolChain::getTargetAndModeFromProgramName(ProgramName);
-  setDriverModeFromOption(ClangNameParts.DriverMode);
-
-  for (const char *ArgPtr : Args) {
-// Ignore nullptrs, they are the response file's EOL markers.
-if (ArgPtr == nullptr)
-  continue;
-const StringRef Arg = ArgPtr;
-setDriverModeFromOption(Arg);
-  }
-}
-
-void Driver::setDriverModeFromO

[PATCH] D106794: Revert "Revert "[clangd] Canonicalize compile flags before applying edits""

2021-07-26 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: usaxena95, arphaman.
kadircet requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

Set driver mode before parsing arglist.

Depends on D106789 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106794

Files:
  clang-tools-extra/clangd/CompileCommands.cpp
  clang-tools-extra/clangd/test/did-change-configuration-params.test
  clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
  clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp

Index: clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
===
--- clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
+++ clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
@@ -11,6 +11,8 @@
 #include "TestFS.h"
 #include "support/Context.h"
 
+#include "clang/Tooling/ArgumentsAdjusters.h"
+#include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/ScopeExit.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/FileSystem.h"
@@ -165,13 +167,15 @@
 for (char &C : Arg)
   C = llvm::toUpper(C);
 });
-Cfg.CompileFlags.Edits.push_back(
-[](std::vector &Argv) { Argv.push_back("--hello"); });
+Cfg.CompileFlags.Edits.push_back([](std::vector &Argv) {
+  Argv = tooling::getInsertArgumentAdjuster("--hello")(Argv, "");
+});
 WithContextValue WithConfig(Config::Key, std::move(Cfg));
 Mangler.adjust(Cmd);
   }
-  // Edits are applied in given order and before other mangling.
-  EXPECT_THAT(Cmd, ElementsAre(_, "FOO.CC", "--hello"));
+  // Edits are applied in given order and before other mangling and they always
+  // go before filename.
+  EXPECT_THAT(Cmd, ElementsAre(_, "--hello", "--", "FOO.CC"));
 }
 
 static std::string strip(llvm::StringRef Arg, llvm::StringRef Argv) {
@@ -342,6 +346,27 @@
   EXPECT_EQ(Expected, printArgv(Args));
 }
 
+TEST(CommandMangler, InputsAfterDashDash) {
+  const auto Mangler = CommandMangler::forTests();
+  {
+std::vector Args = {"clang", "/Users/foo.cc"};
+Mangler.adjust(Args);
+EXPECT_THAT(llvm::makeArrayRef(Args).take_back(2),
+ElementsAre("--", "/Users/foo.cc"));
+EXPECT_THAT(llvm::makeArrayRef(Args).drop_back(2),
+Not(Contains("/Users/foo.cc")));
+  }
+  // In CL mode /U triggers an undef operation, hence `/Users/foo.cc` shouldn't
+  // be interpreted as a file.
+  {
+std::vector Args = {"clang", "--driver-mode=cl", "bar.cc",
+ "/Users/foo.cc"};
+Mangler.adjust(Args);
+EXPECT_THAT(llvm::makeArrayRef(Args).take_back(2),
+ElementsAre("--", "bar.cc"));
+EXPECT_THAT(llvm::makeArrayRef(Args).drop_back(2), Not(Contains("bar.cc")));
+  }
+}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
===
--- clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
+++ clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp
@@ -133,8 +133,9 @@
   Opts.ContextProvider = [](PathRef P) {
 Config C;
 if (P.endswith("foo.cpp"))
-  C.CompileFlags.Edits.push_back(
-  [](std::vector &Argv) { Argv.push_back("-Done=two"); });
+  C.CompileFlags.Edits.push_back([](std::vector &Argv) {
+Argv = tooling::getInsertArgumentAdjuster("-Done=two")(Argv, "");
+  });
 if (P.endswith("baz.cpp"))
   C.Index.Background = Config::BackgroundPolicy::Skip;
 return Context::current().derive(Config::Key, std::move(C));
Index: clang-tools-extra/clangd/test/did-change-configuration-params.test
===
--- clang-tools-extra/clangd/test/did-change-configuration-params.test
+++ clang-tools-extra/clangd/test/did-change-configuration-params.test
@@ -48,7 +48,7 @@
 #
 # ERR: ASTWorker building file {{.*}}foo.c version 0 with command
 # ERR: [{{.*}}clangd-test2]
-# ERR: clang -c foo.c -Wall -Werror
+# ERR: clang -c -Wall -Werror {{.*}} -- foo.c
 ---
 {"jsonrpc":"2.0","id":5,"method":"shutdown"}
 ---
Index: clang-tools-extra/clangd/CompileCommands.cpp
===
--- clang-tools-extra/clangd/CompileCommands.cpp
+++ clang-tools-extra/clangd/CompileCommands.cpp
@@ -9,11 +9,16 @@
 #include "CompileCommands.h"
 #include "Config.h"
 #include "support/Logger.h"
+#include "support/Trace.h"
+#include "clang/Driver/Driver.h"
 #include "clang/Driver/Options.h"
+#include "clang/Driver/ToolChain.h"
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Tooling/ArgumentsAdjusters.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Option/ArgLis

[PATCH] D106757: [PowerPC] Implement partial vector ld/st builtins for XL compatibility

2021-07-26 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai updated this revision to Diff 361658.
nemanjai added a comment.

Cleaned up some of the control flow.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106757/new/

https://reviews.llvm.org/D106757

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/altivec.h
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-ppc-xlcompat-pwr8.c

Index: clang/test/CodeGen/builtins-ppc-xlcompat-pwr8.c
===
--- clang/test/CodeGen/builtins-ppc-xlcompat-pwr8.c
+++ clang/test/CodeGen/builtins-ppc-xlcompat-pwr8.c
@@ -44,3 +44,13 @@
 // CHECK-NOPWR8: error: this builtin is only valid on POWER8 or later CPUs
   return __builtin_ppc_stbcx(c_addr, c);
 }
+
+vector unsigned char test_ldrmb(char *ptr) {
+  // CHECK-NOPWR8: error: this builtin is only valid on POWER8 or later CPUs
+  return __builtin_vsx_ldrmb(ptr, 14);
+}
+
+void test_strmbb(char *ptr, vector unsigned char data) {
+  // CHECK-NOPWR8: error: this builtin is only valid on POWER8 or later CPUs
+  __builtin_vsx_strmb(ptr, 14, data);
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -3440,6 +3440,11 @@
   case PPC::BI__builtin_ppc_lbarx:
 return SemaFeatureCheck(*this, TheCall, "isa-v207-instructions",
 diag::err_ppc_builtin_only_on_arch, "8");
+  case PPC::BI__builtin_vsx_ldrmb:
+  case PPC::BI__builtin_vsx_strmb:
+return SemaFeatureCheck(*this, TheCall, "isa-v207-instructions",
+diag::err_ppc_builtin_only_on_arch, "8") ||
+   SemaBuiltinConstantArgRange(TheCall, 1, 1, 16);
 #define CUSTOM_BUILTIN(Name, Intr, Types, Acc) \
   case PPC::BI__builtin_##Name: \
 return SemaBuiltinPPCMMACall(TheCall, Types);
Index: clang/lib/Headers/altivec.h
===
--- clang/lib/Headers/altivec.h
+++ clang/lib/Headers/altivec.h
@@ -3143,6 +3143,15 @@
 #endif
 #endif
 
+#if defined(__POWER9_VECTOR__) && defined(__powerpc64__)
+#define __vec_ldrmb(PTR, CNT) vec_xl_len_r((const unsigned char *)(PTR), (CNT))
+#define __vec_strmb(PTR, CNT, VAL) \
+  vec_xst_len_r((VAL), (unsigned char *)(PTR), (CNT))
+#else
+#define __vec_ldrmb __builtin_vsx_ldrmb
+#define __vec_strmb __builtin_vsx_strmb
+#endif
+
 /* vec_cpsgn */
 
 #ifdef __VSX__
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -15069,6 +15069,143 @@
 llvm::Function *F = CGM.getIntrinsic(ID);
 return Builder.CreateCall(F, Ops, "");
   }
+  case PPC::BI__builtin_vsx_ldrmb: {
+// Essentially boils down to performing an unaligned VMX load sequence so
+// as to avoid crossing a page boundary and then shuffling the elements
+// into the right side of the vector register.
+int64_t NumBytes = cast(Ops[1])->getZExtValue();
+llvm::Type *ResTy = ConvertType(E->getType());
+bool IsLE = getTarget().isLittleEndian();
+
+// If the user wants the entire vector, just load the entire vector.
+if (NumBytes == 16) {
+  Value *BC = Builder.CreateBitCast(Ops[0], ResTy->getPointerTo());
+  Value *LD = Builder.CreateLoad(Address(BC, CharUnits::fromQuantity(1)));
+  if (!IsLE)
+return LD;
+
+  // Reverse the bytes on LE.
+  SmallVector RevMask;
+  for (int Idx = 0; Idx < 16; Idx++)
+RevMask.push_back(15 - Idx);
+  return Builder.CreateShuffleVector(LD, LD, RevMask);
+}
+
+llvm::Function *Lvx = CGM.getIntrinsic(Intrinsic::ppc_altivec_lvx);
+llvm::Function *Lvs = CGM.getIntrinsic(IsLE ? Intrinsic::ppc_altivec_lvsr
+: Intrinsic::ppc_altivec_lvsl);
+llvm::Function *Vperm = CGM.getIntrinsic(Intrinsic::ppc_altivec_vperm);
+Value *HiMem = Builder.CreateGEP(
+Int8Ty, Ops[0], ConstantInt::get(Ops[1]->getType(), NumBytes - 1));
+Value *LoLd = Builder.CreateCall(Lvx, Ops[0], "ld.lo");
+Value *HiLd = Builder.CreateCall(Lvx, HiMem, "ld.hi");
+Value *Mask1 = Builder.CreateCall(Lvs, Ops[0], "mask1");
+
+Ops.clear();
+Ops.push_back(IsLE ? HiLd : LoLd);
+Ops.push_back(IsLE ? LoLd : HiLd);
+Ops.push_back(Mask1);
+Value *AllElts = Builder.CreateCall(Vperm, Ops, "shuffle1");
+Constant *Zero = llvm::Constant::getNullValue(IsLE ? ResTy : AllElts->getType());
+
+if (IsLE) {
+  SmallVector Consts;
+  for (int Idx = 0; Idx < 16; Idx++) {
+int Val = (NumBytes - Idx - 1 >= 0) ? (NumBytes - Idx - 1)
+: 16 - (NumBytes - Idx);
+Consts.push_back(Val);
+  }
+  return Builder.CreateShuffleVector(Builder.Create

[clang] 3274cdc - [Clang][OpenMP] Remove the mandatory flush for capture for OpenMP 5.1

2021-07-26 Thread Shilei Tian via cfe-commits

Author: Shilei Tian
Date: 2021-07-26T11:00:44-04:00
New Revision: 3274cdc83ecdf2af569ad4f564d55d0e43b1072e

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

LOG: [Clang][OpenMP] Remove the mandatory flush for capture for OpenMP 5.1

In OpenMP 5.1:
> If the `write` or `update` clause is specifieded, the atomic operation is not 
> an atomic conditional update for which the comparison fails, and the 
> effective memory ordering is `release`, `acq_rel`, or `seq_cst`, the strong 
> flush on entry to the atomic operation is also a release flush. If the `read` 
> or `update` clause is specified and the effective memory ordering is 
> `acquire`, `acq_rel`, or `seq_cst` then the strong flush on exit from the 
> atomic operation is also an acquire flush.

In OpenMP 5.0:
> If the `write`, `update`, or **`capture`** clause is specified and the 
> `release`, `acq_rel`, or `seq_cst` clause is specified then the strong flush 
> on entry to the atomic operation is also a release flush. If the `read` or 
> `capture` clause is specified and the `acquire`, `acq_rel`, or `seq_cst` 
> clause is specified then the strong flush on exit from the atomic operation 
> is also an acquire flush.

>From my understanding, in OpenMP 5.1, `capture` is removed from the 
>requirement for flush, therefore we don't have to enforce it.

Reviewed By: ABataev

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

Added: 


Modified: 
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/test/OpenMP/atomic_capture_codegen.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp 
b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index 486b48bca0a62..1f913590339f8 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -5725,32 +5725,35 @@ static void emitOMPAtomicCaptureExpr(CodeGenFunction 
&CGF,
   // Emit post-update store to 'v' of old/new 'x' value.
   CGF.emitOMPSimpleStore(VLValue, NewVVal, NewVValType, Loc);
   CGF.CGM.getOpenMPRuntime().checkAndEmitLastprivateConditional(CGF, V);
-  // OpenMP, 2.17.7, atomic Construct
-  // If the write, update, or capture clause is specified and the release,
-  // acq_rel, or seq_cst clause is specified then the strong flush on entry to
-  // the atomic operation is also a release flush.
-  // If the read or capture clause is specified and the acquire, acq_rel, or
-  // seq_cst clause is specified then the strong flush on exit from the atomic
-  // operation is also an acquire flush.
-  switch (AO) {
-  case llvm::AtomicOrdering::Release:
-CGF.CGM.getOpenMPRuntime().emitFlush(CGF, llvm::None, Loc,
- llvm::AtomicOrdering::Release);
-break;
-  case llvm::AtomicOrdering::Acquire:
-CGF.CGM.getOpenMPRuntime().emitFlush(CGF, llvm::None, Loc,
- llvm::AtomicOrdering::Acquire);
-break;
-  case llvm::AtomicOrdering::AcquireRelease:
-  case llvm::AtomicOrdering::SequentiallyConsistent:
-CGF.CGM.getOpenMPRuntime().emitFlush(CGF, llvm::None, Loc,
- llvm::AtomicOrdering::AcquireRelease);
-break;
-  case llvm::AtomicOrdering::Monotonic:
-break;
-  case llvm::AtomicOrdering::NotAtomic:
-  case llvm::AtomicOrdering::Unordered:
-llvm_unreachable("Unexpected ordering.");
+  // OpenMP 5.1 removes the required flush for capture clause.
+  if (CGF.CGM.getLangOpts().OpenMP < 51) {
+// OpenMP, 2.17.7, atomic Construct
+// If the write, update, or capture clause is specified and the release,
+// acq_rel, or seq_cst clause is specified then the strong flush on entry 
to
+// the atomic operation is also a release flush.
+// If the read or capture clause is specified and the acquire, acq_rel, or
+// seq_cst clause is specified then the strong flush on exit from the 
atomic
+// operation is also an acquire flush.
+switch (AO) {
+case llvm::AtomicOrdering::Release:
+  CGF.CGM.getOpenMPRuntime().emitFlush(CGF, llvm::None, Loc,
+   llvm::AtomicOrdering::Release);
+  break;
+case llvm::AtomicOrdering::Acquire:
+  CGF.CGM.getOpenMPRuntime().emitFlush(CGF, llvm::None, Loc,
+   llvm::AtomicOrdering::Acquire);
+  break;
+case llvm::AtomicOrdering::AcquireRelease:
+case llvm::AtomicOrdering::SequentiallyConsistent:
+  CGF.CGM.getOpenMPRuntime().emitFlush(
+  CGF, llvm::None, Loc, llvm::AtomicOrdering::AcquireRelease);
+  break;
+case llvm::AtomicOrdering::Monotonic:
+  break;
+case llvm::AtomicOrdering::NotAtomic:
+case llvm::AtomicOrdering::Unordered:
+  llvm_unreachable("Unexpected ordering.");
+}
   }
 }
 

diff  --git a/clang/test/OpenMP/atomic_capture

[PATCH] D100768: [Clang][OpenMP] Remove the mandatory flush for capture for OpenMP 5.1

2021-07-26 Thread Shilei Tian via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3274cdc83ecd: [Clang][OpenMP] Remove the mandatory flush for 
capture for OpenMP 5.1 (authored by tianshilei1992).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100768/new/

https://reviews.llvm.org/D100768

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/test/OpenMP/atomic_capture_codegen.cpp

Index: clang/test/OpenMP/atomic_capture_codegen.cpp
===
--- clang/test/OpenMP/atomic_capture_codegen.cpp
+++ clang/test/OpenMP/atomic_capture_codegen.cpp
@@ -1,11 +1,19 @@
 
 // RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -target-cpu core2 -fopenmp -x c -emit-llvm %s -o - | FileCheck %s
 // RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -target-cpu core2 -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -target-cpu core2 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -target-cpu core2 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix=CHECK --check-prefix=CHECK-50 %s
 
 // RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -target-cpu core2 -fopenmp-simd -x c -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
 // RUN: %clang_cc1 -fopenmp-simd -x c -triple x86_64-apple-darwin10 -target-cpu core2 -emit-pch -o %t %s
 // RUN: %clang_cc1 -fopenmp-simd -x c -triple x86_64-apple-darwin10 -target-cpu core2 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+
+// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -target-cpu core2 -fopenmp -fopenmp-version=51 -x c -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=51 -x c -triple x86_64-apple-darwin10 -target-cpu core2 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=51 -x c -triple x86_64-apple-darwin10 -target-cpu core2 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+
+// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -target-cpu core2 -fopenmp-simd -fopenmp-version=51 -x c -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=51 -x c -triple x86_64-apple-darwin10 -target-cpu core2 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=51 -x c -triple x86_64-apple-darwin10 -target-cpu core2 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
 // SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
 // expected-no-diagnostics
 #ifndef HEADER
@@ -343,7 +351,7 @@
 // CHECK: [[IM_CAST:%.+]] = fptrunc double [[NEW_IM]] to float
 // CHECK: store float [[RE_CAST]], float* getelementptr inbounds ({ float, float }, { float, float }* @{{.+}}, i32 0, i32 0),
 // CHECK: store float [[IM_CAST]], float* getelementptr inbounds ({ float, float }, { float, float }* @{{.+}}, i32 0, i32 1),
-// CHECK: call{{.*}} @__kmpc_flush(
+// CHECK-50: call{{.*}} @__kmpc_flush(
 #pragma omp atomic capture seq_cst
   {cdx = cdx - cdv; cfv = cdx;}
 // CHECK: [[BV:%.+]] = load i8, i8* @{{.+}}
@@ -393,7 +401,7 @@
 // CHECK: br i1 [[SUCCESS_FAIL]], label %[[EXIT:.+]], label %[[CONT]]
 // CHECK: [[EXIT]]
 // CHECK: store i8 [[NEW]], i8* @{{.+}},
-// CHECK: call{{.*}} @__kmpc_flush(
+// CHECK-50: call{{.*}} @__kmpc_flush(
 #pragma omp atomic capture, seq_cst
   {cx = cx >> ucv; cv = cx;}
 // CHECK: [[SV:%.+]]  = load i16, i16* @{{.+}},
@@ -436,7 +444,7 @@
 // CHECK: [[OLD:%.+]] = atomicrmw or i32* @{{.+}}, i32 [[EXPR]] seq_cst, align 4
 // CHECK: [[DESIRED:%.+]] = or i32 [[EXPR]], [[OLD]]
 // CHECK: store i32 [[DESIRED]], i32* @{{.+}},
-// CHECK: call{{.*}} @__kmpc_flush(
+// CHECK-50: call{{.*}} @__kmpc_flush(
 #pragma omp atomic seq_cst, capture
   {uix = iv | uix; uiv = uix;}
 // CHECK: [[EXPR:%.+]] = load i32, i32* @{{.+}}
@@ -904,7 +912,7 @@
 // CHECK: [[EXIT]]
 // CHECK: [[NEW_VAL:%.+]] = trunc i64 [[CONV]] to i32
 // CHECK: store i32 [[NEW_VAL]], i32* @{{.+}},
-// CHECK: call{{.*}} @__kmpc_flush(
+// CHECK-50: call{{.*}} @__kmpc_flush(
 #pragma omp atomic capture release
   {bfx4.b /= ldv; iv = bfx4.b;}
 // CHECK: [[EXPR:%.+]] = load x86_fp80, x86_fp80* @{{.+}}
@@ -937,7 +945,7 @@
 // CHECK: [[EXIT]]
 // CHECK: [[NEW_VAL_I32:%.+]] = trunc i64 [[NEW_VAL]] to i32
 // CHECK: store i32 [[NEW_VAL_I32]], i32* @{{.+}},
-// CHECK: call{{.*}} @__kmpc_flush(
+// CHECK-50: call{{.*}} @__kmpc_flush(
 #pragma omp atomic capture acquire
   iv = bfx4_packed.b += ldv;
 // CHECK: load i64, i64*
@@ -963,7 +971,7 @@
 // CHECK: br i1 [[FAIL_SUCCESS]], label %[[EXIT:.+]], label %[[CONT]]
 // CHECK: [[EXIT]]
 // CHECK: store float [[X]], float* @{{.+}},
-// CHECK: call{{.*}} @__kmpc_flush(
+// CHECK-50: call{{.*}} @__kmpc_flush(
 #pragma omp atomic capture acq_rel
   {fv = float2x.x; float2x.x = ulv - float2x.x;}
 // CHECK: [[

[PATCH] D106793: [OpenMP] Add a driver flag to enable the new device runtime library

2021-07-26 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 361667.
jhuber6 added a comment.

Adding test


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106793/new/

https://reviews.llvm.org/D106793

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/test/Driver/Inputs/libomptarget/libomptarget-new-nvptx-sm_35.bc
  clang/test/Driver/openmp-offload-gpu.c


Index: clang/test/Driver/openmp-offload-gpu.c
===
--- clang/test/Driver/openmp-offload-gpu.c
+++ clang/test/Driver/openmp-offload-gpu.c
@@ -154,6 +154,11 @@
 // RUN:   -Xopenmp-target -march=sm_35 
--cuda-path=%S/Inputs/CUDA_102/usr/local/cuda \
 // RUN:   -fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 
2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-BCLIB %s
+/// Check with the new runtime enabled
+// RUN:   env LIBRARY_PATH=%S/Inputs/libomptarget %clang -### -fopenmp=libomp 
-fopenmp-targets=nvptx64-nvidia-cuda \
+// RUN:   -Xopenmp-target -march=sm_35 
--cuda-path=%S/Inputs/CUDA_102/usr/local/cuda \
+// RUN:   -fopenmp-relocatable-target -fopenmp-target-new-runtime -save-temps 
-no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-BCLIB-NEW %s
 /// The user can override default detection using 
--libomptarget-nvptx-bc-path=.
 // RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
 // RUN:   
--libomptarget-nvptx-bc-path=%S/Inputs/libomptarget/libomptarget-nvptx-test.bc \
@@ -162,6 +167,7 @@
 // RUN:   | FileCheck -check-prefix=CHK-BCLIB-USER %s
 
 // CHK-BCLIB: 
clang{{.*}}-triple{{.*}}nvptx64-nvidia-cuda{{.*}}-mlink-builtin-bitcode{{.*}}libomptarget-nvptx-sm_35.bc
+// CHK-BCLIB-NEW: 
clang{{.*}}-triple{{.*}}nvptx64-nvidia-cuda{{.*}}-mlink-builtin-bitcode{{.*}}libomptarget-new-nvptx-sm_35.bc
 // CHK-BCLIB-USER: 
clang{{.*}}-triple{{.*}}nvptx64-nvidia-cuda{{.*}}-mlink-builtin-bitcode{{.*}}libomptarget-nvptx-test.bc
 // CHK-BCLIB-NOT: {{error:|warning:}}
 
Index: clang/test/Driver/Inputs/libomptarget/libomptarget-new-nvptx-sm_35.bc
===
--- /dev/null
+++ clang/test/Driver/Inputs/libomptarget/libomptarget-new-nvptx-sm_35.bc
@@ -0,0 +1 @@
+
Index: clang/lib/Driver/ToolChains/Cuda.cpp
===
--- clang/lib/Driver/ToolChains/Cuda.cpp
+++ clang/lib/Driver/ToolChains/Cuda.cpp
@@ -751,7 +751,13 @@
   return;
 }
 
-std::string BitcodeSuffix = "nvptx-" + GpuArch.str();
+std::string BitcodeSuffix;
+if (DriverArgs.hasFlag(options::OPT_fopenmp_target_new_runtime,
+   options::OPT_fno_openmp_target_new_runtime, false))
+  BitcodeSuffix = "new-nvptx-" + GpuArch.str();
+else
+  BitcodeSuffix = "nvptx-" + GpuArch.str();
+
 addOpenMPDeviceRTL(getDriver(), DriverArgs, CC1Args, BitcodeSuffix,
getTriple());
   }
Index: clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
===
--- clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
+++ clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
@@ -222,7 +222,14 @@
 
   if (DriverArgs.hasArg(options::OPT_nogpulib))
 return;
-  std::string BitcodeSuffix = "amdgcn-" + GPUArch;
+
+  std::string BitcodeSuffix;
+  if (DriverArgs.hasFlag(options::OPT_fopenmp_target_new_runtime,
+ options::OPT_fno_openmp_target_new_runtime, false))
+BitcodeSuffix = "new-amdgcn-" + GPUArch;
+  else
+BitcodeSuffix = "amdgcn-" + GPUArch;
+
   addOpenMPDeviceRTL(getDriver(), DriverArgs, CC1Args, BitcodeSuffix,
  getTriple());
 }
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2373,6 +2373,10 @@
   Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
 def fopenmp_cuda_teams_reduction_recs_num_EQ : Joined<["-"], 
"fopenmp-cuda-teams-reduction-recs-num=">, Group,
   Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
+defm openmp_target_new_runtime: BoolFOption<"openmp-target-new-runtime",
+  LangOpts<"OpenMPTargetNewRuntime">, DefaultFalse,
+  PosFlag,
+  NegFlag>;
 defm openmp_optimistic_collapse : BoolFOption<"openmp-optimistic-collapse",
   LangOpts<"OpenMPOptimisticCollapse">, DefaultFalse,
   PosFlag, NegFlag, 
BothFlags<[NoArgumentUnused, HelpHidden]>>;
Index: clang/include/clang/Basic/LangOptions.def
===
--- clang/include/clang/Basic/LangOptions.def
+++ clang/include/clang/Basic/LangOptions.def
@@ -240,6 +240,7 @@
 LANGOPT(OpenMPCUDANumSMs  , 32, 0, "Number of SMs for CUDA devices.")
 LANGOPT(OpenMPCUDABlocksPerSM  , 32, 0, "Number of blocks per SM for CUDA 
devices.")

[PATCH] D106796: [clangd] Record remote index usage

2021-07-26 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: usaxena95, arphaman.
kadircet requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

This is a gauage metric that sets particular remote-index instances as
used. It should enable accumulation of multiple streams to see number of clangd
processes making use of remote index, broken down by remote index address.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106796

Files:
  clang-tools-extra/clangd/tool/ClangdMain.cpp


Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -561,10 +561,13 @@
 std::unique_ptr
 loadExternalIndex(const Config::ExternalIndexSpec &External,
   AsyncTaskRunner *Tasks) {
+  static const trace::Metric RemoteIndexUsed("used_remote_index",
+ trace::Metric::Value, "address");
   switch (External.Kind) {
   case Config::ExternalIndexSpec::None:
 break;
   case Config::ExternalIndexSpec::Server:
+RemoteIndexUsed.record(1, External.Location);
 log("Associating {0} with remote index at {1}.", External.MountPoint,
 External.Location);
 return remote::getClient(External.Location, External.MountPoint);


Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -561,10 +561,13 @@
 std::unique_ptr
 loadExternalIndex(const Config::ExternalIndexSpec &External,
   AsyncTaskRunner *Tasks) {
+  static const trace::Metric RemoteIndexUsed("used_remote_index",
+ trace::Metric::Value, "address");
   switch (External.Kind) {
   case Config::ExternalIndexSpec::None:
 break;
   case Config::ExternalIndexSpec::Server:
+RemoteIndexUsed.record(1, External.Location);
 log("Associating {0} with remote index at {1}.", External.MountPoint,
 External.Location);
 return remote::getClient(External.Location, External.MountPoint);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106732: Support macro deprecation #pragma clang deprecated

2021-07-26 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Thank you for working on this, I think it's really useful functionality!




Comment at: clang/docs/LanguageExtensions.rst:3875
+   #define MIN(x, y) x < y ? x : y
+   #pragma clang deprecated("MIN", "use std::min instead")
+

Rather than use a string literal, did you consider using an unexpanded 
identifier token?



Comment at: clang/include/clang/Basic/DiagnosticLexKinds.td:523-524
+// - #pragma deprecate(...)
+def err_pragma_deprecated_expected :
+  Error<"expected '%0' in #pragma clang deprecate">;
+def warn_pragma_deprecated_not_a_macro :

We have an existing diagnostic for this -- `diag::err_expected`.



Comment at: clang/include/clang/Basic/DiagnosticLexKinds.td:526
+def warn_pragma_deprecated_not_a_macro :
+  ExtWarn<"'%0' is not a defined macro for #pragma clang deprecate">,
+  InGroup;

I think we should consider reusing (and renaming) `err_pp_visibility_non_macro` 
for this purpose. I think it should be an error  to try to deprecate a macro 
that doesn't exist because that feels like a really confusing situation for 
programmers (what does it mean?), but I don't feel strongly. However, I don't 
think this is an `ExtWarn` situation (pragmas are a bit weird; when I took a 
look, we're wildly inconsistent here) because we wouldn't issue a "blah is a 
Clang extension" warning about it.



Comment at: clang/include/clang/Basic/DiagnosticLexKinds.td:528-533
+def warn_pragma_deprecated_macro_use :
+  ExtWarn<"macro '%0' has been marked as deprecated">,
+  InGroup;
+def warn_pragma_deprecated_macro_use_msg :
+  ExtWarn<"macro '%0' has been marked as deprecated: %1">,
+  InGroup;

Can you get away with something along these lines so we only use a single 
diagnostic message?



Comment at: clang/include/clang/Basic/IdentifierTable.h:127
+
+  // 24 bits left in a 64-bit word.
 

I come up with the same number as you did. Thank you for updating this!



Comment at: clang/include/clang/Lex/Preprocessor.h:2391
 
+  void addMacroDeprecationMsg(IdentifierInfo *II, std::string Msg) {
+MacroDeprecationMsgs.insert(std::make_pair(II, Msg));





Comment at: clang/lib/Lex/PPMacroExpansion.cpp:478
+  Diag(Identifier, diag::warn_pragma_deprecated_macro_use)
+  << Identifier.getIdentifierInfo()->getName();
+else





Comment at: clang/lib/Lex/PPMacroExpansion.cpp:481
+  Diag(Identifier, diag::warn_pragma_deprecated_macro_use_msg)
+  << Identifier.getIdentifierInfo()->getName() << MsgEntry->second;
+  }





Comment at: clang/lib/Lex/Pragma.cpp:1914
 
+/// "\#pragma deprecate()"
+///





Comment at: clang/lib/Lex/Pragma.cpp:1918
+/// \code
+///   #pragma clang deprecate(MACRO_NAME)
+/// \endcode

The syntax looks off here, it doesn't mention the message.



Comment at: clang/lib/Lex/Pragma.cpp:1939
+
+if (!II->hasMacroDefinition() || !II->hadMacroDefinition()) {
+  PP.Diag(Tok, diag::warn_pragma_deprecated_not_a_macro) << II->getName();

Can you explain why you're looking for a macro that's been undefined? I'm 
wondering what the expectations are for code like:
```
#define FOO 12
#undef FOO
#pragma clang deprecated("FOO")
```
The user can't expand `FOO`, so there's nothing there to deprecate. But if a 
user later does `#define FOO 42`, it's not clear to me that we *should* 
diagnose use of `FOO` as being deprecated at that point. Once the macro is 
undefined, that signals at least some intent "I'm done with this identifier as 
a macro" and so the deprecation seems like it should perhaps not hold?



Comment at: clang/test/Lexer/deprecate-macro.c:1
+// RUN: not %clang_cc1 -Wdeprecated %s -fsyntax-only
+

Without the -verify, this doesn't test the expected diagnostics. Also, I don't 
think you need `not` there once you're verifying the results.



Comment at: clang/test/Lexer/deprecate-macro.c:35
+#endif
+
+int main(int argc, char** argv) {

Some other useful test cases:
```
#define frobble 1
#pragma clang deprecated("frobble")

#undef frobble // Expect no diagnostics here

#define bobble 1
#pragma clang deprecated("bobble")

#define bobble 1 // Do we expect a diagnostic here?
#define frobble 1 // How about here given that this was undefined?
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106732/new/

https://reviews.llvm.org/D106732

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


[PATCH] D106713: Thread safety analysis: Warn when demoting locks on back edges

2021-07-26 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

This seems reasonable to me, but I leave it to @delesley for the final sign-off.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106713/new/

https://reviews.llvm.org/D106713

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


[PATCH] D106005: [Docs] Define matrix initialisation in MatrixTypes documentation

2021-07-26 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added a comment.

In D106005#2896080 , @SaurabhJha 
wrote:

> In D106005#2895716 , @fhahn wrote:
>
>> Thank you very much for working on this! Are you planning on implementing 
>> the new specification as well? It would probably be good to land the update 
>> to the spec in close succession to the implementation, to avoid confusing 
>> users.
>
> Yes, that's my plan. Once this is in, I will start working on the 
> implementation right away.

Ok cool! I think the latest version looks good (modulo making sure the new 
lines are limited to 80 chars per line). @rjmccall can you think of any 
scenarios where defining initializers with one expression and broadcasting them 
might cause issues?

With respect to ordering the patches, I think it would be good to put up a 
patch implementing the newly added parts, commit it and then land the patch 
that adds it to the docs. WDYT?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106005/new/

https://reviews.llvm.org/D106005

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


[PATCH] D106277: [SVE] Remove the interface for getMaxVScale in favour of the IR attributes

2021-07-26 Thread Dylan Fleming via Phabricator via cfe-commits
DylanFleming-arm updated this revision to Diff 361675.
DylanFleming-arm added a comment.

Added getVScaleRange interface to TargetInfo and removed related AArch64 
specific code from CodeGenFunction.cpp


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106277/new/

https://reviews.llvm.org/D106277

Files:
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/AArch64.h
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/test/CodeGen/arm-sve-vector-bits-vscale-range.c
  llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
  llvm/lib/Target/AArch64/AArch64TargetTransformInfo.h
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
  llvm/test/Analysis/CostModel/AArch64/sve-gather.ll
  llvm/test/Analysis/CostModel/AArch64/sve-scatter.ll
  llvm/test/Transforms/LoopVectorize/AArch64/first-order-recurrence.ll
  llvm/test/Transforms/LoopVectorize/AArch64/scalable-strict-fadd.ll
  llvm/test/Transforms/LoopVectorize/AArch64/scalable-vectorization.ll
  llvm/test/Transforms/LoopVectorize/AArch64/scalable-vf-hint.ll
  llvm/test/Transforms/LoopVectorize/AArch64/sve-cond-inv-loads.ll
  llvm/test/Transforms/LoopVectorize/AArch64/sve-gather-scatter.ll
  llvm/test/Transforms/LoopVectorize/AArch64/sve-inv-store.ll
  llvm/test/Transforms/LoopVectorize/AArch64/sve-large-strides.ll
  llvm/test/Transforms/LoopVectorize/AArch64/sve-widen-phi.ll

Index: llvm/test/Transforms/LoopVectorize/AArch64/sve-widen-phi.ll
===
--- llvm/test/Transforms/LoopVectorize/AArch64/sve-widen-phi.ll
+++ llvm/test/Transforms/LoopVectorize/AArch64/sve-widen-phi.ll
@@ -12,7 +12,7 @@
 ; that we can use gather instructions with the correct offsets, taking
 ; vscale into account.
 
-define void @widen_ptr_phi_unrolled(i32* noalias nocapture %a, i32* noalias nocapture %b, i32* nocapture readonly %c, i64 %n) {
+define void @widen_ptr_phi_unrolled(i32* noalias nocapture %a, i32* noalias nocapture %b, i32* nocapture readonly %c, i64 %n) #0 {
 ; CHECK-LABEL: @widen_ptr_phi_unrolled(
 ; CHECK:   vector.body:
 ; CHECK-NEXT:[[POINTER_PHI:%.*]] = phi i32* [ %c, %vector.ph ], [ %[[PTR_IND:.*]], %vector.body ]
@@ -122,7 +122,7 @@
 ; because it is stored to memory.
 ;
 
-define i32 @pointer_iv_mixed(i32* noalias %a, i32** noalias %b, i64 %n) {
+define i32 @pointer_iv_mixed(i32* noalias %a, i32** noalias %b, i64 %n) #0 {
 ; CHECK-LABEL: @pointer_iv_mixed(
 ; CHECK: vector.body
 ; CHECK:   %[[IDX:.*]] = phi i64 [ 0, %vector.ph ], [ %{{.*}}, %vector.body ]
@@ -170,7 +170,7 @@
   ret i32 %tmp5
 }
 
-
+attributes #0 = { vscale_range(0, 16) }
 !0 = distinct !{!0, !1, !2, !3, !4, !5}
 !1 = !{!"llvm.loop.mustprogress"}
 !2 = !{!"llvm.loop.vectorize.width", i32 4}
Index: llvm/test/Transforms/LoopVectorize/AArch64/sve-large-strides.ll
===
--- llvm/test/Transforms/LoopVectorize/AArch64/sve-large-strides.ll
+++ llvm/test/Transforms/LoopVectorize/AArch64/sve-large-strides.ll
@@ -1,6 +1,6 @@
 ; RUN: opt -mtriple aarch64-linux-gnu -mattr=+sve -loop-vectorize -scalable-vectorization=on -dce -instcombine -S <%s | FileCheck %s
 
-define void @stride7_i32(i32* noalias nocapture %dst, i64 %n) {
+define void @stride7_i32(i32* noalias nocapture %dst, i64 %n) #0 {
 ; CHECK-LABEL: @stride7_i32(
 ; CHECK:  vector.body
 ; CHECK:%[[VEC_IND:.*]] = phi  [ %{{.*}}, %vector.ph ], [ %{{.*}}, %vector.body ]
@@ -27,7 +27,7 @@
   ret void
 }
 
-define void @stride7_f64(double* noalias nocapture %dst, i64 %n) {
+define void @stride7_f64(double* noalias nocapture %dst, i64 %n) #0 {
 ; CHECK-LABEL: @stride7_f64(
 ; CHECK:  vector.body
 ; CHECK:%[[VEC_IND:.*]] = phi  [ %{{.*}}, %vector.ph ], [ %{{.*}}, %vector.body ]
@@ -55,7 +55,7 @@
 }
 
 
-define void @cond_stride7_f64(double* noalias nocapture %dst, i64* noalias nocapture readonly %cond, i64 %n) {
+define void @cond_stride7_f64(double* noalias nocapture %dst, i64* noalias nocapture readonly %cond, i64 %n) #0 {
 ; CHECK-LABEL: @cond_stride7_f64(
 ; CHECK:  vector.body
 ; CHECK:%[[MASK:.*]] = icmp ne 
@@ -90,7 +90,7 @@
   ret void
 }
 
-
+attributes #0 = { vscale_range(0, 16) }
 !0 = distinct !{!0, !1, !2, !3, !4, !5}
 !1 = !{!"llvm.loop.mustprogress"}
 !2 = !{!"llvm.loop.vectorize.width", i32 4}
Index: llvm/test/Transforms/LoopVectorize/AArch64/sve-inv-store.ll
===
--- llvm/test/Transforms/LoopVectorize/AArch64/sve-inv-store.ll
+++ llvm/test/Transforms/LoopVectorize/AArch64/sve-inv-store.ll
@@ -59,7 +59,7 @@
   ret void
 }
 
-attributes #0 = { "target-features"="+neon,+sve" }
+attributes #0 = { "target-features"="+neon,+sve" vscale_range(0, 16) }
 
 !0 = distinct !{!0, !1, !2, !3, !4, !5}
 !1 = !{!"llvm.loop.mustprogress"}
Index: llvm/test/Transforms/LoopVectorize/AArch64/sve-gather-scatter.ll
==

[PATCH] D106799: [OpenMP] Always inline the OpenMP outlined function

2021-07-26 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 created this revision.
jhuber6 added a reviewer: jdoerfert.
Herald added subscribers: guansong, yaxunl.
jhuber6 requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

This patch adds the always inline attribute to the outlined functions generated
by OpenMP regions. Because there is only a single instance of this function and
it always has internal linkage it is safe to inline in every instance it is
created. This could potentially lead to performance degredation due to
inflated register counts in the parallel region.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106799

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp


Index: clang/lib/CodeGen/CGStmtOpenMP.cpp
===
--- clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -517,6 +517,10 @@
 F->setDoesNotThrow();
   F->setDoesNotRecurse();
 
+  // Always inline the outlined function if optimizations are enabled.
+  if (CGM.getCodeGenOpts().OptimizationLevel != 0)
+F->addFnAttr(llvm::Attribute::AlwaysInline);
+
   // Generate the function.
   CGF.StartFunction(CD, Ctx.VoidTy, F, FuncInfo, TargetArgs,
 FO.UIntPtrCastRequired ? FO.Loc : FO.S->getBeginLoc(),
@@ -5303,6 +5307,8 @@
   CGF.CapturedStmtInfo = &CapStmtInfo;
   llvm::Function *Fn = CGF.GenerateOpenMPCapturedStmtFunction(*S, Loc);
   Fn->setDoesNotRecurse();
+  if (CGM.getCodeGenOpts().OptimizationLevel != 0)
+Fn->addFnAttr(llvm::Attribute::AlwaysInline);
   return Fn;
 }
 


Index: clang/lib/CodeGen/CGStmtOpenMP.cpp
===
--- clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -517,6 +517,10 @@
 F->setDoesNotThrow();
   F->setDoesNotRecurse();
 
+  // Always inline the outlined function if optimizations are enabled.
+  if (CGM.getCodeGenOpts().OptimizationLevel != 0)
+F->addFnAttr(llvm::Attribute::AlwaysInline);
+
   // Generate the function.
   CGF.StartFunction(CD, Ctx.VoidTy, F, FuncInfo, TargetArgs,
 FO.UIntPtrCastRequired ? FO.Loc : FO.S->getBeginLoc(),
@@ -5303,6 +5307,8 @@
   CGF.CapturedStmtInfo = &CapStmtInfo;
   llvm::Function *Fn = CGF.GenerateOpenMPCapturedStmtFunction(*S, Loc);
   Fn->setDoesNotRecurse();
+  if (CGM.getCodeGenOpts().OptimizationLevel != 0)
+Fn->addFnAttr(llvm::Attribute::AlwaysInline);
   return Fn;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106732: Support macro deprecation #pragma clang deprecated

2021-07-26 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added a comment.

Will update the patch later today with your feedback.




Comment at: clang/docs/LanguageExtensions.rst:3875
+   #define MIN(x, y) x < y ? x : y
+   #pragma clang deprecated("MIN", "use std::min instead")
+

aaron.ballman wrote:
> Rather than use a string literal, did you consider using an unexpanded 
> identifier token?
The Lexer expands preprocessor macros, so you wouldn't get an identifier token, 
you actually get the tokens inside the macro. I suspect this is why `#pragma 
push_macro` does the same thing and uses a string literal.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106732/new/

https://reviews.llvm.org/D106732

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


[PATCH] D105819: [analyzer] MallocChecker: Add a visitor to leave a note on functions that could have, but did not change ownership on leaked memory

2021-07-26 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

This is amazing and I think we should land this and see how it goes.




Comment at: clang/test/Analysis/self-assign.cpp:1
-// RUN: %clang_analyze_cc1 -std=c++11 
-analyzer-checker=core,cplusplus,unix.Malloc,debug.ExprInspection 
-analyzer-config eagerly-assume=false %s -verify -analyzer-output=text
+// RUN: %clang_analyze_cc1 -std=c++11 %s -verify -analyzer-output=text \
+// RUN:   -analyzer-checker=core \

Changes in this file seem to be formatting-only, maybe they could be committed 
separately?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105819/new/

https://reviews.llvm.org/D105819

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


[PATCH] D106778: [OpenCL] opencl-c.h: add CL 3.0 non-generic address space atomics

2021-07-26 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

Generally LGTM, but I think we should guard the `else` blocks with 
CL_VERSION_2_0 or higher to avoid exposing the functions in earlier standards 
because the spec says:

  The C11 style atomic functions in this sub-section require support for OpenCL 
2.0 or newer. However, this statement does not apply to the "OpenCL C 1.x 
Legacy Atomics" descriptions at the end of this sub-section. 

Adding @azabaznov to check if he can suggest anything for testing. Although it 
seems like this is only related to the new functionality of OpenCL3.0.




Comment at: clang/lib/Headers/opencl-c.h:13678
+uintptr_t __ovld atomic_fetch_sub_explicit(volatile __local atomic_uintptr_t 
*object, ptrdiff_t operand, memory_order order, memory_scope scope);
+#endif
+#endif

can we annotate `#endif` with a comment, please to improve readability? The 
same applies to other places.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106778/new/

https://reviews.llvm.org/D106778

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


[PATCH] D106277: [SVE] Remove the interface for getMaxVScale in favour of the IR attributes

2021-07-26 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen added a comment.

You'll want to rebase your patch on top of latest main, since D105432 
 moved around the call to `getMaxVScale()` in 
AArch64TargetTransformInfo.cpp.




Comment at: clang/lib/Basic/Targets/AArch64.cpp:433
+  }
+  if (hasFeature("sve")) {
+return std::pair(0, 16);

nit: unnecessary curly braces.



Comment at: clang/lib/CodeGen/CodeGenFunction.cpp:499
 
   // Add vscale attribute if appropriate.
+  Optional> VScaleRange =

nit: `vscale_range`



Comment at: llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp:1424
   ElementCount LegalVF = LT.second.getVectorElementCount();
-  Optional MaxNumVScale = getMaxVScale();
+  Optional MaxNumVScale;
+  if (I->getFunction()->hasFnAttribute(Attribute::VScaleRange)) {

This can drop the Optional now.

I also think asserting the attribute must be set is a bit of a strong 
requirement? Maybe we can return an Invalid instead if the attribute is not set.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106277/new/

https://reviews.llvm.org/D106277

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


[clang] e8a64e5 - [clang][pp] adds '#pragma include_instead'

2021-07-26 Thread Christopher Di Bella via cfe-commits

Author: Christopher Di Bella
Date: 2021-07-26T16:07:45Z
New Revision: e8a64e5491260714c79dab65d1aa73245931d314

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

LOG: [clang][pp] adds '#pragma include_instead'

`#pragma clang include_instead()` is a pragma that can be used
by system headers (and only system headers) to indicate to a tool that
the file containing said pragma is an implementation-detail header and
should not be directly included by user code.

The library alternative is very messy code that can be seen in the first
diff of D106124, and we'd rather avoid that with something more
universal.

This patch takes the first step by warning a user when they include a
detail header in their code, and suggests alternative headers that the
user should include instead. Future work will involve adding a fixit to
automate the process, as well as cleaning up modules diagnostics to not
suggest said detail headers. Other tools, such as clangd can also take
advantage of this pragma to add the correct user headers.

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

Added: 
clang/test/Preprocessor/Inputs/include_instead/bad-syntax.h
clang/test/Preprocessor/Inputs/include_instead/file-not-found.h
clang/test/Preprocessor/Inputs/include_instead/non-system-header.h
clang/test/Preprocessor/Inputs/include_instead/private-x.h
clang/test/Preprocessor/Inputs/include_instead/private1.h
clang/test/Preprocessor/Inputs/include_instead/private2.h
clang/test/Preprocessor/Inputs/include_instead/private3.h
clang/test/Preprocessor/Inputs/include_instead/public-after.h
clang/test/Preprocessor/Inputs/include_instead/public-before.h
clang/test/Preprocessor/Inputs/include_instead/public-empty.h
clang/test/Preprocessor/include_instead.cpp
clang/test/Preprocessor/include_instead_file_not_found.cpp

Modified: 
clang/include/clang/Basic/DiagnosticLexKinds.td
clang/include/clang/Lex/HeaderSearch.h
clang/include/clang/Lex/Preprocessor.h
clang/include/clang/Lex/PreprocessorLexer.h
clang/lib/Lex/Lexer.cpp
clang/lib/Lex/PPDirectives.cpp
clang/lib/Lex/PPLexerChange.cpp
clang/lib/Lex/Pragma.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticLexKinds.td 
b/clang/include/clang/Basic/DiagnosticLexKinds.td
index ce6d0d0394b48..690ea693bd366 100644
--- a/clang/include/clang/Basic/DiagnosticLexKinds.td
+++ b/clang/include/clang/Basic/DiagnosticLexKinds.td
@@ -300,6 +300,12 @@ def pp_pragma_once_in_main_file : Warning<"#pragma once in 
main file">,
 def pp_pragma_sysheader_in_main_file : Warning<
   "#pragma system_header ignored in main file">,
   InGroup>;
+
+def err_pragma_include_instead_not_sysheader : Error<
+  "'#pragma clang include_instead' cannot be used outside of system headers">;
+def err_pragma_include_instead_system_reserved : Error<
+  "header '%0' is an implementation detail; #include %select{'%2'|either '%2' 
or '%3'|one of %2}1 instead">;
+
 def pp_poisoning_existing_macro : Warning<"poisoning existing macro">;
 def pp_out_of_date_dependency : Warning<
   "current file is older than dependency %0">;

diff  --git a/clang/include/clang/Lex/HeaderSearch.h 
b/clang/include/clang/Lex/HeaderSearch.h
index 93d6ea72270aa..a35a394f719b0 100644
--- a/clang/include/clang/Lex/HeaderSearch.h
+++ b/clang/include/clang/Lex/HeaderSearch.h
@@ -20,9 +20,12 @@
 #include "clang/Lex/ModuleMap.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/SetVector.h"
+#include "llvm/ADT/SmallSet.h"
+#include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringMap.h"
-#include "llvm/ADT/StringSet.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/StringSet.h"
 #include "llvm/Support/Allocator.h"
 #include 
 #include 
@@ -110,6 +113,14 @@ struct HeaderFileInfo {
   /// of the framework.
   StringRef Framework;
 
+  /// List of aliases that this header is known as.
+  /// Most headers should only have at most one alias, but a handful
+  /// have two.
+  llvm::SetVector,
+  llvm::SmallVector, 2>,
+  llvm::SmallSet, 2>>
+  Aliases;
+
   HeaderFileInfo()
   : isImport(false), isPragmaOnce(false), DirInfo(SrcMgr::C_User),
 External(false), isModuleHeader(false), isCompilingModuleHeader(false),
@@ -453,6 +464,10 @@ class HeaderSearch {
 getFileInfo(File).DirInfo = SrcMgr::C_System;
   }
 
+  void AddFileAlias(const FileEntry *File, StringRef Alias) {
+getFileInfo(File).Aliases.insert(Alias);
+  }
+
   /// Mark the specified file as part of a module.
   void MarkFileModuleHeader(const FileEntry *FE,
 ModuleMap::ModuleHeaderRole Role,

diff  --git a/clang/include/clang/Lex/Preprocessor.h 
b/clang/include/clang/Lex/Preprocessor.h
i

[PATCH] D106394: [clang][pp] adds '#pragma include_instead'

2021-07-26 Thread Christopher Di Bella via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe8a64e549126: [clang][pp] adds '#pragma 
include_instead' (authored by cjdb).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106394/new/

https://reviews.llvm.org/D106394

Files:
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/include/clang/Lex/HeaderSearch.h
  clang/include/clang/Lex/Preprocessor.h
  clang/include/clang/Lex/PreprocessorLexer.h
  clang/lib/Lex/Lexer.cpp
  clang/lib/Lex/PPDirectives.cpp
  clang/lib/Lex/PPLexerChange.cpp
  clang/lib/Lex/Pragma.cpp
  clang/test/Preprocessor/Inputs/include_instead/bad-syntax.h
  clang/test/Preprocessor/Inputs/include_instead/file-not-found.h
  clang/test/Preprocessor/Inputs/include_instead/non-system-header.h
  clang/test/Preprocessor/Inputs/include_instead/private-x.h
  clang/test/Preprocessor/Inputs/include_instead/private1.h
  clang/test/Preprocessor/Inputs/include_instead/private2.h
  clang/test/Preprocessor/Inputs/include_instead/private3.h
  clang/test/Preprocessor/Inputs/include_instead/public-after.h
  clang/test/Preprocessor/Inputs/include_instead/public-before.h
  clang/test/Preprocessor/Inputs/include_instead/public-empty.h
  clang/test/Preprocessor/include_instead.cpp
  clang/test/Preprocessor/include_instead_file_not_found.cpp

Index: clang/test/Preprocessor/include_instead_file_not_found.cpp
===
--- /dev/null
+++ clang/test/Preprocessor/include_instead_file_not_found.cpp
@@ -0,0 +1,2 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -I %S/Inputs %s
+#include 
Index: clang/test/Preprocessor/include_instead.cpp
===
--- /dev/null
+++ clang/test/Preprocessor/include_instead.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -I %S/Inputs %s
+
+#include 
+#include 
+
+#include 
+// expected-error@-1{{header '' is an implementation detail; #include '' instead}}
+
+#include "include_instead/private2.h"
+// expected-error@-1{{header '"include_instead/private2.h"' is an implementation detail; #include either '' or '"include_instead/public-after.h"' instead}}
+
+#include 
+// expected-error@-1{{header '' is an implementation detail; #include one of {'', '', '"include_instead/public-before.h"'} instead}}
+
+#include 
+#include 
Index: clang/test/Preprocessor/Inputs/include_instead/public-empty.h
===
--- /dev/null
+++ clang/test/Preprocessor/Inputs/include_instead/public-empty.h
@@ -0,0 +1 @@
+// This file simply needs to exist.
Index: clang/test/Preprocessor/Inputs/include_instead/public-before.h
===
--- /dev/null
+++ clang/test/Preprocessor/Inputs/include_instead/public-before.h
@@ -0,0 +1,5 @@
+#pragma GCC system_header
+
+#include  // no warning expected
+#include  // no warning expected
+#include  // no warning expected
Index: clang/test/Preprocessor/Inputs/include_instead/public-after.h
===
--- /dev/null
+++ clang/test/Preprocessor/Inputs/include_instead/public-after.h
@@ -0,0 +1,2 @@
+#include 
+#pragma GCC system_header
Index: clang/test/Preprocessor/Inputs/include_instead/private3.h
===
--- /dev/null
+++ clang/test/Preprocessor/Inputs/include_instead/private3.h
@@ -0,0 +1,5 @@
+#pragma GCC system_header
+
+#pragma clang include_instead()
+#pragma clang include_instead()
+#pragma clang include_instead("include_instead/public-before.h")
Index: clang/test/Preprocessor/Inputs/include_instead/private2.h
===
--- /dev/null
+++ clang/test/Preprocessor/Inputs/include_instead/private2.h
@@ -0,0 +1,4 @@
+#pragma GCC system_header
+
+#pragma clang include_instead()
+#pragma clang include_instead("include_instead/public-after.h")
Index: clang/test/Preprocessor/Inputs/include_instead/private1.h
===
--- /dev/null
+++ clang/test/Preprocessor/Inputs/include_instead/private1.h
@@ -0,0 +1,2 @@
+#pragma GCC system_header
+#pragma clang include_instead()
Index: clang/test/Preprocessor/Inputs/include_instead/private-x.h
===
--- /dev/null
+++ clang/test/Preprocessor/Inputs/include_instead/private-x.h
@@ -0,0 +1,4 @@
+#include 
+
+#pragma GCC system_header
+#pragma clang include_instead()
Index: clang/test/Preprocessor/Inputs/include_instead/non-system-header.h
===
--- /dev/null
+++ clang/test/Preprocessor/Inputs/include_instead/non-system-header.h
@@ -0,0 +1,2 @@
+#pragma clang include_instead()
+// expected-error@-1{{'#pragma clang inc

[PATCH] D106732: Support macro deprecation #pragma clang deprecated

2021-07-26 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:3875
+   #define MIN(x, y) x < y ? x : y
+   #pragma clang deprecated("MIN", "use std::min instead")
+

beanz wrote:
> aaron.ballman wrote:
> > Rather than use a string literal, did you consider using an unexpanded 
> > identifier token?
> The Lexer expands preprocessor macros, so you wouldn't get an identifier 
> token, you actually get the tokens inside the macro. I suspect this is why 
> `#pragma push_macro` does the same thing and uses a string literal.
You can lex in either mode. See `LexUnexpandedToken()`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106732/new/

https://reviews.llvm.org/D106732

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


[PATCH] D106715: Thread safety analysis: Drop special block handling

2021-07-26 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

I think this looks reasonable, but @delesley should weigh in.




Comment at: clang/lib/Analysis/ThreadSafety.cpp:2415
 bool LocksetInitialized = false;
 SmallVector SpecialBlocks;
 for (CFGBlock::const_pred_iterator PI = CurrBlock->pred_begin(),

This can be removed now, correct?



Comment at: clang/lib/Analysis/ThreadSafety.cpp:2448
+const Stmt *Terminator = (*PI)->getTerminatorStmt();
+bool IsLoop = Terminator && isa(Terminator);
+intersectAndWarn(

clang-tidy got this one right. :-)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106715/new/

https://reviews.llvm.org/D106715

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


[clang] 240dde9 - [PowerPC] Change altivec indexed load/store builtins argument type

2021-07-26 Thread Qiu Chaofan via cfe-commits

Author: Qiu Chaofan
Date: 2021-07-27T00:26:50+08:00
New Revision: 240dde948252ab9ef0428c46ca578c06127d3799

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

LOG: [PowerPC] Change altivec indexed load/store builtins argument type

This patch changes the index argument of lvxl?/lve[bhw]x and
stvxl?/stve[bhw]x builtins from int to long. Because on 64-bit
subtargets, an extra extsw will always been generated, which is
incorrect.

Reviewed By: nemanjai

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

Added: 


Modified: 
clang/include/clang/Basic/BuiltinsPPC.def
clang/lib/Headers/altivec.h
clang/test/CodeGen/ppc-emmintrin.c
clang/test/CodeGen/ppc-xmmintrin.c

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsPPC.def 
b/clang/include/clang/Basic/BuiltinsPPC.def
index 5d0093434566..a423d1bf4718 100644
--- a/clang/include/clang/Basic/BuiltinsPPC.def
+++ b/clang/include/clang/Basic/BuiltinsPPC.def
@@ -197,11 +197,11 @@ BUILTIN(__builtin_altivec_vexptefp, "V4fV4f", "")
 
 BUILTIN(__builtin_altivec_vrfim, "V4fV4f", "")
 
-BUILTIN(__builtin_altivec_lvx, "V4iivC*", "")
-BUILTIN(__builtin_altivec_lvxl, "V4iivC*", "")
-BUILTIN(__builtin_altivec_lvebx, "V16civC*", "")
-BUILTIN(__builtin_altivec_lvehx, "V8sivC*", "")
-BUILTIN(__builtin_altivec_lvewx, "V4iivC*", "")
+BUILTIN(__builtin_altivec_lvx, "V4iLivC*", "")
+BUILTIN(__builtin_altivec_lvxl, "V4iLivC*", "")
+BUILTIN(__builtin_altivec_lvebx, "V16cLivC*", "")
+BUILTIN(__builtin_altivec_lvehx, "V8sLivC*", "")
+BUILTIN(__builtin_altivec_lvewx, "V4iLivC*", "")
 
 BUILTIN(__builtin_altivec_vlogefp, "V4fV4f", "")
 
@@ -253,11 +253,11 @@ BUILTIN(__builtin_altivec_vpkudum, "V4UiV2ULLiV2ULLi", "")
 
 BUILTIN(__builtin_altivec_vperm_4si, "V4iV4iV4iV16Uc", "")
 
-BUILTIN(__builtin_altivec_stvx, "vV4iiv*", "")
-BUILTIN(__builtin_altivec_stvxl, "vV4iiv*", "")
-BUILTIN(__builtin_altivec_stvebx, "vV16civ*", "")
-BUILTIN(__builtin_altivec_stvehx, "vV8siv*", "")
-BUILTIN(__builtin_altivec_stvewx, "vV4iiv*", "")
+BUILTIN(__builtin_altivec_stvx, "vV4iLiv*", "")
+BUILTIN(__builtin_altivec_stvxl, "vV4iLiv*", "")
+BUILTIN(__builtin_altivec_stvebx, "vV16cLiv*", "")
+BUILTIN(__builtin_altivec_stvehx, "vV8sLiv*", "")
+BUILTIN(__builtin_altivec_stvewx, "vV4iLiv*", "")
 
 BUILTIN(__builtin_altivec_vcmpbfp, "V4iV4fV4f", "")
 
@@ -559,13 +559,13 @@ BUILTIN(__builtin_altivec_vrlqnm, 
"V1ULLLiV1ULLLiV1ULLLi", "")
 
 // VSX built-ins.
 
-BUILTIN(__builtin_vsx_lxvd2x, "V2divC*", "")
-BUILTIN(__builtin_vsx_lxvw4x, "V4iivC*", "")
+BUILTIN(__builtin_vsx_lxvd2x, "V2dLivC*", "")
+BUILTIN(__builtin_vsx_lxvw4x, "V4iLivC*", "")
 BUILTIN(__builtin_vsx_lxvd2x_be, "V2dSLLivC*", "")
 BUILTIN(__builtin_vsx_lxvw4x_be, "V4iSLLivC*", "")
 
-BUILTIN(__builtin_vsx_stxvd2x, "vV2div*", "")
-BUILTIN(__builtin_vsx_stxvw4x, "vV4iiv*", "")
+BUILTIN(__builtin_vsx_stxvd2x, "vV2dLiv*", "")
+BUILTIN(__builtin_vsx_stxvw4x, "vV4iLiv*", "")
 BUILTIN(__builtin_vsx_stxvd2x_be, "vV2dSLLivC*", "")
 BUILTIN(__builtin_vsx_stxvw4x_be, "vV4iSLLivC*", "")
 

diff  --git a/clang/lib/Headers/altivec.h b/clang/lib/Headers/altivec.h
index 862ec290e1c9..edad62158a18 100644
--- a/clang/lib/Headers/altivec.h
+++ b/clang/lib/Headers/altivec.h
@@ -3997,251 +3997,251 @@ vec_vrfim(vector float __a) {
 /* vec_ld */
 
 static __inline__ vector signed char __ATTRS_o_ai
-vec_ld(int __a, const vector signed char *__b) {
+vec_ld(long __a, const vector signed char *__b) {
   return (vector signed char)__builtin_altivec_lvx(__a, __b);
 }
 
 static __inline__ vector signed char __ATTRS_o_ai
-vec_ld(int __a, const signed char *__b) {
+vec_ld(long __a, const signed char *__b) {
   return (vector signed char)__builtin_altivec_lvx(__a, __b);
 }
 
 static __inline__ vector unsigned char __ATTRS_o_ai
-vec_ld(int __a, const vector unsigned char *__b) {
+vec_ld(long __a, const vector unsigned char *__b) {
   return (vector unsigned char)__builtin_altivec_lvx(__a, __b);
 }
 
 static __inline__ vector unsigned char __ATTRS_o_ai
-vec_ld(int __a, const unsigned char *__b) {
+vec_ld(long __a, const unsigned char *__b) {
   return (vector unsigned char)__builtin_altivec_lvx(__a, __b);
 }
 
 static __inline__ vector bool char __ATTRS_o_ai
-vec_ld(int __a, const vector bool char *__b) {
+vec_ld(long __a, const vector bool char *__b) {
   return (vector bool char)__builtin_altivec_lvx(__a, __b);
 }
 
-static __inline__ vector short __ATTRS_o_ai vec_ld(int __a,
+static __inline__ vector short __ATTRS_o_ai vec_ld(long __a,
const vector short *__b) {
   return (vector short)__builtin_altivec_lvx(__a, __b);
 }
 
-static __inline__ vector short __ATTRS_o_ai vec_ld(int __a, const short *__b) {
+static __inline__ vector short __ATTRS_o_ai vec_ld(long __a, const short *__b) 

[PATCH] D106530: [PowerPC] Change altivec indexed load/store builtins argument type

2021-07-26 Thread Qiu Chaofan via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG240dde948252: [PowerPC] Change altivec indexed load/store 
builtins argument type (authored by qiucf).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106530/new/

https://reviews.llvm.org/D106530

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Headers/altivec.h
  clang/test/CodeGen/ppc-emmintrin.c
  clang/test/CodeGen/ppc-xmmintrin.c

Index: clang/test/CodeGen/ppc-xmmintrin.c
===
--- clang/test/CodeGen/ppc-xmmintrin.c
+++ clang/test/CodeGen/ppc-xmmintrin.c
@@ -953,7 +953,7 @@
 // CHECK-LABEL: @test_load
 
 // CHECK: define available_externally <4 x float> @_mm_load_ps
-// CHECK: [[REG469:[0-9a-zA-Z_%.]+]] = call <4 x float> @vec_ld(int, float vector[4] const*)
+// CHECK: [[REG469:[0-9a-zA-Z_%.]+]] = call <4 x float> @vec_ld(long, float vector[4] const*)
 // CHECK-NEXT: ret <4 x float> [[REG469]]
 
 // CHECK: define available_externally <4 x float> @_mm_load_ps1
@@ -993,7 +993,7 @@
 // CHECK-NEXT: ret <4 x float> [[REG490]]
 
 // CHECK: define available_externally <4 x float> @_mm_loadr_ps
-// CHECK: [[REG491:[0-9a-zA-Z_%.]+]] = call <4 x float> @vec_ld(int, float vector[4] const*)
+// CHECK: [[REG491:[0-9a-zA-Z_%.]+]] = call <4 x float> @vec_ld(long, float vector[4] const*)
 // CHECK-NEXT: store <4 x float> [[REG491]], <4 x float>* [[REG492:[0-9a-zA-Z_%.]+]], align 16
 // CHECK-NEXT: [[REG493:[0-9a-zA-Z_%.]+]] = load <4 x float>, <4 x float>* [[REG492]], align 16
 // CHECK-NEXT: [[REG494:[0-9a-zA-Z_%.]+]] = load <4 x float>, <4 x float>* [[REG492]], align 16
@@ -1828,7 +1828,7 @@
 // CHECK-NEXT: [[REG939:[0-9a-zA-Z_%.]+]] = load <4 x float>, <4 x float>* {{[0-9a-zA-Z_%.]+}}, align 16
 // CHECK-NEXT: [[REG940:[0-9a-zA-Z_%.]+]] = load float*, float** {{[0-9a-zA-Z_%.]+}}, align 8
 // CHECK-NEXT: [[REG941:[0-9a-zA-Z_%.]+]] = bitcast float* [[REG940]] to <4 x float>*
-// CHECK-NEXT: call void @vec_st(float vector[4], int, float vector[4]*)(<4 x float> [[REG939]], i32 signext 0, <4 x float>* [[REG941]])
+// CHECK-NEXT: call void @vec_st(float vector[4], long, float vector[4]*)(<4 x float> [[REG939]], i64 0, <4 x float>* [[REG941]])
 // CHECK-NEXT: ret void
 
 // CHECK: define available_externally void @_mm_store_ps1
Index: clang/test/CodeGen/ppc-emmintrin.c
===
--- clang/test/CodeGen/ppc-emmintrin.c
+++ clang/test/CodeGen/ppc-emmintrin.c
@@ -1361,7 +1361,7 @@
 // CHECK: store double* [[REG917]], double** [[REG918:[0-9a-zA-Z_%.]+]], align 8
 // CHECK-NEXT: [[REG919:[0-9a-zA-Z_%.]+]] = load double*, double** [[REG918]], align 8
 // CHECK-NEXT: [[REG920:[0-9a-zA-Z_%.]+]] = bitcast double* [[REG919]] to <16 x i8>*
-// CHECK-NEXT: [[REG921:[0-9a-zA-Z_%.]+]] = call <16 x i8> @vec_ld(int, unsigned char vector[16] const*)(i32 signext 0, <16 x i8>* [[REG920]])
+// CHECK-NEXT: [[REG921:[0-9a-zA-Z_%.]+]] = call <16 x i8> @vec_ld(long, unsigned char vector[16] const*)(i64 0, <16 x i8>* [[REG920]])
 // CHECK-NEXT: [[REG922:[0-9a-zA-Z_%.]+]] = bitcast <16 x i8> [[REG921]] to <2 x double>
 // CHECK-NEXT: ret <2 x double> [[REG922]]
 
@@ -2915,7 +2915,7 @@
 // CHECK-NEXT: [[REG1925:[0-9a-zA-Z_%.]+]] = bitcast <2 x double> [[REG1924]] to <16 x i8>
 // CHECK-NEXT: [[REG1926:[0-9a-zA-Z_%.]+]] = load double*, double** [[REG1922]], align 8
 // CHECK-NEXT: [[REG1927:[0-9a-zA-Z_%.]+]] = bitcast double* [[REG1926]] to <16 x i8>*
-// CHECK-NEXT: call void @vec_st(unsigned char vector[16], int, unsigned char vector[16]*)(<16 x i8> [[REG1925]], i32 signext 0, <16 x i8>* [[REG1927]])
+// CHECK-NEXT: call void @vec_st(unsigned char vector[16], long, unsigned char vector[16]*)(<16 x i8> [[REG1925]], i64 0, <16 x i8>* [[REG1927]])
 // CHECK-NEXT: ret void
 
 // CHECK: define available_externally void @_mm_store_pd1(double* [[REG1928:[0-9a-zA-Z_%.]+]], <2 x double> [[REG1929:[0-9a-zA-Z_%.]+]])
@@ -2942,7 +2942,7 @@
 // CHECK-NEXT: [[REG1946:[0-9a-zA-Z_%.]+]] = bitcast <2 x i64> [[REG1945]] to <16 x i8>
 // CHECK-NEXT: [[REG1947:[0-9a-zA-Z_%.]+]] = load <2 x i64>*, <2 x i64>** [[REG1943]], align 8
 // CHECK-NEXT: [[REG1948:[0-9a-zA-Z_%.]+]] = bitcast <2 x i64>* [[REG1947]] to <16 x i8>*
-// CHECK-NEXT: call void @vec_st(unsigned char vector[16], int, unsigned char vector[16]*)(<16 x i8> [[REG1946]], i32 signext 0, <16 x i8>* [[REG1948]])
+// CHECK-NEXT: call void @vec_st(unsigned char vector[16], long, unsigned char vector[16]*)(<16 x i8> [[REG1946]], i64 0, <16 x i8>* [[REG1948]])
 // CHECK-NEXT: ret void
 
 // CHECK: define available_externally void @_mm_store1_pd(double* [[REG1949:[0-9a-zA-Z_%.]+]], <2 x double> [[REG1950:[0-9a-zA-Z_%.]+]])
Index: clang/lib/Headers/altivec.h
===
--- clang/lib/Headers/altivec.h
+++ clang/lib/Headers/altivec.h
@@ 

[PATCH] D106530: [PowerPC] Change altivec indexed load/store builtins argument type

2021-07-26 Thread Qiu Chaofan via Phabricator via cfe-commits
qiucf added a comment.

In D106530#2903938 , @nemanjai wrote:

> LGTM. Thanks for fixing this.
> I am just curious, was this revealed from a real world test that used an 
> offset that is so large that it doesn't fit into 32 bits?

No :-) It's found in backend codegen (an unnecessary `extsw`).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106530/new/

https://reviews.llvm.org/D106530

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


[PATCH] D106785: [C++4OpenCL] Introduces __remove_address_space utility

2021-07-26 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:1970
+OpenCL v1.0 s2.3.12
+`_.
+

I think we should migrate this description into here for now and make this a 
clang-only feature in C++ for OpenCL v1.0. Mainly because new functionality 
changes can only be added with the version increase. Otherwise, developers 
would have to know which clang supports it and which doesn't. 

But I suggest keeping your draft PR 
https://github.com/KhronosGroup/OpenCL-Docs/pull/647 open so we don't forget to 
add it into the next language version doc.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106785/new/

https://reviews.llvm.org/D106785

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


[PATCH] D106785: [C++4OpenCL] Introduces __remove_address_space utility

2021-07-26 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

I would like @svenvh to take a look from the clang header's design point.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106785/new/

https://reviews.llvm.org/D106785

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


[PATCH] D106804: [test-suite] Add tests for FP classification intrinsics

2021-07-26 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff created this revision.
sepavloff added reviewers: efriedma, kpn, thopre, jonpa, cameron.mcinally, 
RKSimon, craig.topper.
Herald added a subscriber: mgorny.
sepavloff requested review of this revision.

Repository:
  rT test-suite

https://reviews.llvm.org/D106804

Files:
  SingleSource/UnitTests/CMakeLists.txt
  SingleSource/UnitTests/Float/CMakeLists.txt
  SingleSource/UnitTests/Float/classify.cpp
  SingleSource/UnitTests/Float/classify.reference_output

Index: SingleSource/UnitTests/Float/classify.reference_output
===
--- /dev/null
+++ SingleSource/UnitTests/Float/classify.reference_output
@@ -0,0 +1 @@
+exit 0
Index: SingleSource/UnitTests/Float/classify.cpp
===
--- /dev/null
+++ SingleSource/UnitTests/Float/classify.cpp
@@ -0,0 +1,306 @@
+//===--- classify.cpp - Tess for FP classification intrinsics ---*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This is a general test for floating point classification intrinsic.
+//
+//===--===//
+
+#undef NDEBUG
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define DimOf(x) (sizeof(x) / sizeof(x[0]))
+
+#define F32_SIGN 0x8000U
+#define F32_EXP_MASK 0x7F80U
+#define F32_MANTISSA_MASK 0x007FU
+#define F32_QNAN_BIT 0x0040U
+#define F32_PAYLOAD_MASK F32_MANTISSA_MASK
+
+#define F64_SIGN 0x8000ULL
+#define F64_EXP_MASK 0x7FF0ULL
+#define F64_MANTISSA_MASK 0x000FULL
+#define F64_QNAN_BIT 0x0008ULL
+#define F64_PAYLOAD_MASK F64_MANTISSA_MASK
+
+
+uint32_t FloatNaNValues[] = {
+  F32_SIGN | F32_EXP_MASK | F32_QNAN_BIT | F32_PAYLOAD_MASK,
+ F32_EXP_MASK | F32_QNAN_BIT | F32_PAYLOAD_MASK,
+  F32_SIGN | F32_EXP_MASK |F32_PAYLOAD_MASK,
+ F32_EXP_MASK |F32_PAYLOAD_MASK,
+  F32_SIGN | F32_EXP_MASK | F32_QNAN_BIT,
+ F32_EXP_MASK | F32_QNAN_BIT,
+  F32_SIGN | F32_EXP_MASK | F32_QNAN_BIT | 0x0020U,
+ F32_EXP_MASK | F32_QNAN_BIT | 0x0010U,
+  F32_SIGN | F32_EXP_MASK |0x0020U,
+ F32_EXP_MASK |0x0010U,
+  F32_SIGN | F32_EXP_MASK | F32_QNAN_BIT | 0x0001U,
+ F32_EXP_MASK | F32_QNAN_BIT | 0x0002U,
+  F32_SIGN | F32_EXP_MASK |0x0001U,
+ F32_EXP_MASK |0x0002U,
+};
+
+uint32_t FloatInfValues[] = {
+  F32_SIGN | F32_EXP_MASK,   // -Inf
+ F32_EXP_MASK// +Inf
+};
+
+uint32_t FloatZeroValues[] = {
+  F32_SIGN,  // -0.0
+  0  // +0.0
+};
+
+uint32_t FloatDenormValues[] = {
+  F32_SIGN | 0x0001U,// smallest negative denornal number
+ 0x0001U,// smallest positive denornal number
+  F32_SIGN | 0x007FU,// largest negative denormal number
+ 0x007FU,// largest positive normal number
+};
+
+uint32_t FloatNormalValues[] = {
+F32_SIGN | 0x0080U,  // smallest negative normal number
+   0x0080U,  // smallest positive normal number
+F32_SIGN | 0x7F7FU,  // largest negative normal number
+   0x7F7FU,  // largest positive normal number
+F32_SIGN | 0x3F7FU,  // smallest number larger than -1
+F32_SIGN | 0x3F80U,  // -1
+F32_SIGN | 0x3F81U,  // largest number less than -1
+   0x3F7FU,  // largest number less than 1
+   0x3F80U,  // +1
+   0x3F81U,  // smallest number larger than 1
+};
+
+int test_float() {
+  for (unsigned i = 0; i < DimOf(FloatNaNValues); i++) {
+float *FPtr = (float *)&FloatNaNValues[i];
+assert(__builtin_isnan(*FPtr));
+assert(!__builtin_isinf(*FPtr));
+assert(!__builtin_isfinite(*FPtr));
+assert(!__builtin_isnormal(*FPtr));
+assert(__builtin_fpclassify(0, 1, 2, 3, 4, *FPtr) == 0);
+  }
+  for (unsigned i = 0; i < DimOf(FloatInfValues); i++) {
+float *FPtr = (float *)&FloatInfValues[i];
+assert(!__builtin_isnan(*FPtr));
+assert(__builtin_isinf(*FPtr));
+assert(!__builtin_isfinite(*FPtr));
+assert(!__builtin_isnormal(*FPtr));
+assert(__builtin_fpclassify(0, 1, 2, 3, 4, *FPtr) == 1);
+  }
+  for (unsigned i = 0; i < DimOf(FloatZeroValues); i++) {
+float *FPtr = (float *)&FloatZeroValues[i];
+assert(!__builtin_isnan(*FPtr));
+assert(!__builtin_isinf(*FPtr));
+assert(__builtin_isfinite(*FPtr));
+assert(!__builtin_isnormal(*FPtr));
+assert(__builtin_fpclassify(0, 1, 2, 3, 4, *FPtr) == 4);
+  }
+  for (unsigned i = 0; i < DimOf(FloatDenormValues);

[PATCH] D106757: [PowerPC] Implement partial vector ld/st builtins for XL compatibility

2021-07-26 Thread Lei Huang via Phabricator via cfe-commits
lei accepted this revision.
lei added a comment.

thx for the update!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106757/new/

https://reviews.llvm.org/D106757

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


[PATCH] D100582: [WIP][OpenMP][Offloading] New device runtime library - Not for review

2021-07-26 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 abandoned this revision.
tianshilei1992 added a comment.
Herald added a subscriber: ormris.

We're moving to D106803 .


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D100582/new/

https://reviews.llvm.org/D100582

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


[PATCH] D106793: [OpenMP] Add a driver flag to enable the new device runtime library

2021-07-26 Thread Ye Luo via Phabricator via cfe-commits
ye-luo added a comment.

Not clear from the summary what is the new driver option.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106793/new/

https://reviews.llvm.org/D106793

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


[PATCH] D106757: [PowerPC] Implement partial vector ld/st builtins for XL compatibility

2021-07-26 Thread Amy Kwan via Phabricator via cfe-commits
amyk accepted this revision.
amyk added a comment.

Thanks for addressing the comment and adding back the tests! 
LGTM.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106757/new/

https://reviews.llvm.org/D106757

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


[PATCH] D105881: [flang][driver] Switch to `BoolFOption` for boolean options

2021-07-26 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added a comment.

Sorry, I'm not sure I follow.

In D105881#2890134 , @awarzynski 
wrote:

> Apologies, it has taken me a bit longer to get back to this. @jansvoboda11 , 
> now I'm realising the key disadvantage of using `OptInFFlag/OptOutFFlag` - 
> it's impossible to express the `opt-in`/`opt-out` semantics in TableGen.

What do you mean exactly? I think the semantics are expressed pretty well from 
Clang's point of view:

- `OptInFFlag` -> users can opt-in into the behavior by specifying the positive 
flag in `clang -cc1` (e.g. `-fmodules`),
- `OptOutFFlag` -> users can opt-out of the behavior by specifying the negative 
flag in `clang -cc1` (e.g. `-fno-rtti`).

> In fact, only the contents of `clang -cc1 --help` are being tweaked by using 
> `OptInFFlag/OptOutFFlag`.

That's incorrect, `OptInFFlag` and `OptOutFFlag` both set `HelpText` for the 
positive and negative driver flags.

> Basically:
>
> - for `OptInFFlang`, only `-ffoo` is printed with `-clang -cc1 --help` (the 
> help text for `-ffno-foo` becomes irrelevant)
> - for `OptOutFFlang`, only `-fno-foo` is printed with `-clang -cc1 --help` 
> (the help text for `-ffoo` is irrelevant)
>
> IIUC, this is achieved through `flags` (`CC1Option` vs `[]`).

Correct.

> In Flang, we rely on the fact that "no help text? don't include it in 
> `flang-new -fc1 --help`" instead. This behavior is implemented in 
> `clangDriver` and applies to all drivers that use it (so this is nothing 
> specific to Flang).

I see. Is this intentional?

> This way, we can always mark Flang options with the relevant flags (e.g. 
> `FC1Option`). In other words, we can claim them and make it clear that other 
> drivers can ignore them.

I don't understand this. Can you elaborate? Are you relying on the 
absence/presence of a help text to mark flags with `FC1Option`? When does this 
happen? (In `Options.td`? The TableGen backend? The consumer of `Options.inc`?)

> In general, I think that Options.td would become a bit cleaner and easier to 
> reason about if all options specified all their flags. That wouldn't be easy 
> to achieve though!

I think that the way we define flags for the Clang driver and `-cc1` in one go 
is already bit confusing. But it's convenient, so we roll with it. On top of 
that, we have the marshalling infrastructure, that explicitly only applies to 
the `-cc1` side of things. If we introduce `EmptyKPM` to the mix and say 
"Marshalling only applies to `-cc1`, but sometimes not at all", things stop 
making sense in my opinion. People will copy-paste it and be confused things 
don't work.

> I'm just about send an updated patch. It takes into account the points that I 
> raised above ^^^. It also fixes the failing tests reported by @PeteSteinfeld. 
> Does this new approach work for Clang (I quickly tested `clang -cc1 --help` 
> and see no difference)?

I'd need to double-check if we particularly care about showing/hiding flags 
without help text.

> It would be nicer to have the `opt-in`/`opt-out` semantics for Flang in 
> TableGen through something similar to `BoolFOption`. No need for this just 
> now - one step at a time :)

I suggest to find another means of achieving the semantics you want. You always 
just copy the `BoolFOption` implementation and remove the marshalling stuff, if 
that's really the semantics you want.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105881/new/

https://reviews.llvm.org/D105881

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


[PATCH] D106577: [clang] Define __STDC_ISO_10646__

2021-07-26 Thread James Y Knight via Phabricator via cfe-commits
jyknight added a comment.

Perhaps a reasonable path forward here to address the BSD issue can be to add a 
targetinfo method:

  /* Returns true if the expected encoding of wchar_t changes at runtime
 depending on locale for this target.
 Note that clang always encodes wide character literals as utf16/utf32,
 regardless. */
  bool usesDynamicWCharEncoding();

which returns false by default, and true for FreeBSD, NetBSD, OpenBSD, and 
Solaris. Then, the condition for setting this define can be 
`if(TI.getWCharWidth() >= 32 && !TI.usesDynamicWcharEncoding())`.

That doesn't help the fact that wide char literals are effectively broken on 
those OSes, but oh well. Maybe someday they'll decide to switch to a 
consistent/documented wchar encoding, at which point clang can emit that 
(whatever it is). Or maybe someone will teach clang to emit an error or warning 
when using wide char literals on such targets. But I wouldn't hold my breath 
for either of those outcomes, and it seems fine to move forward here simply by 
exempting the known-to-be-problematic OSes.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106577/new/

https://reviews.llvm.org/D106577

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


[PATCH] D104854: Introduce intrinsic llvm.isnan

2021-07-26 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff updated this revision to Diff 361707.
sepavloff added a comment.

Updated patch

- Rebased,
- Applied small enhancement to integer implementation.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104854/new/

https://reviews.llvm.org/D104854

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/X86/strictfp_builtins.c
  clang/test/CodeGen/aarch64-strictfp-builtins.c
  clang/test/CodeGen/strictfp_builtins.c
  llvm/docs/LangRef.rst
  llvm/include/llvm/CodeGen/ISDOpcodes.h
  llvm/include/llvm/CodeGen/TargetLowering.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/lib/Analysis/ConstantFolding.cpp
  llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
  llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
  llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h
  llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
  llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
  llvm/lib/CodeGen/TargetLoweringBase.cpp
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/test/CodeGen/AArch64/aarch64-fpclass.ll
  llvm/test/CodeGen/PowerPC/ppc-fpclass.ll
  llvm/test/CodeGen/X86/x86-fpclass.ll
  llvm/test/Transforms/InstSimplify/ConstProp/fpclassify.ll

Index: llvm/test/Transforms/InstSimplify/ConstProp/fpclassify.ll
===
--- /dev/null
+++ llvm/test/Transforms/InstSimplify/ConstProp/fpclassify.ll
@@ -0,0 +1,28 @@
+; RUN: opt < %s -instsimplify -S | FileCheck %s
+
+define i1 @isnan_01() {
+entry:
+  %0 = tail call i1 @llvm.isnan.f32(float 0x7FF8)
+  ret i1 %0
+}
+; CHECK-LABEL: isnan_01
+; CHECK:   ret i1 true 
+
+define i1 @isnan_02() {
+entry:
+  %0 = tail call i1 @llvm.isnan.f32(float 0x7FF0)
+  ret i1 %0
+}
+; CHECK-LABEL: isnan_02
+; CHECK:   ret i1 false 
+
+define <4 x i1> @isnan_03() {
+entry:
+  %0 = tail call <4 x i1> @llvm.isnan.v4f32(<4 x float>)
+  ret <4 x i1> %0
+}
+; CHECK-LABEL: isnan_03
+; CHECK:   ret <4 x i1> 
+
+declare i1 @llvm.isnan.f32(float)
+declare <4 x i1> @llvm.isnan.v4f32(<4 x float>)
Index: llvm/test/CodeGen/X86/x86-fpclass.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/x86-fpclass.ll
@@ -0,0 +1,641 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=i686 | FileCheck %s -check-prefix=CHECK-32
+; RUN: llc < %s -mtriple=x86_64 | FileCheck %s -check-prefix=CHECK-64
+
+define i1 @isnan_float(float %x) {
+; CHECK-32-LABEL: isnan_float:
+; CHECK-32:   # %bb.0: # %entry
+; CHECK-32-NEXT:flds {{[0-9]+}}(%esp)
+; CHECK-32-NEXT:fucomp %st(0)
+; CHECK-32-NEXT:fnstsw %ax
+; CHECK-32-NEXT:# kill: def $ah killed $ah killed $ax
+; CHECK-32-NEXT:sahf
+; CHECK-32-NEXT:setp %al
+; CHECK-32-NEXT:retl
+;
+; CHECK-64-LABEL: isnan_float:
+; CHECK-64:   # %bb.0: # %entry
+; CHECK-64-NEXT:ucomiss %xmm0, %xmm0
+; CHECK-64-NEXT:setp %al
+; CHECK-64-NEXT:retq
+; NOSSE-32-LABEL: isnan_float:
+entry:
+  %0 = tail call i1 @llvm.isnan.f32(float %x)
+  ret i1 %0
+}
+
+define i1 @isnan_double(double %x) {
+; CHECK-32-LABEL: isnan_double:
+; CHECK-32:   # %bb.0: # %entry
+; CHECK-32-NEXT:fldl {{[0-9]+}}(%esp)
+; CHECK-32-NEXT:fucomp %st(0)
+; CHECK-32-NEXT:fnstsw %ax
+; CHECK-32-NEXT:# kill: def $ah killed $ah killed $ax
+; CHECK-32-NEXT:sahf
+; CHECK-32-NEXT:setp %al
+; CHECK-32-NEXT:retl
+;
+; CHECK-64-LABEL: isnan_double:
+; CHECK-64:   # %bb.0: # %entry
+; CHECK-64-NEXT:ucomisd %xmm0, %xmm0
+; CHECK-64-NEXT:setp %al
+; CHECK-64-NEXT:retq
+entry:
+  %0 = tail call i1 @llvm.isnan.f64(double %x)
+  ret i1 %0
+}
+
+define i1 @isnan_ldouble(x86_fp80 %x) {
+; CHECK-32-LABEL: isnan_ldouble:
+; CHECK-32:   # %bb.0: # %entry
+; CHECK-32-NEXT:fldt {{[0-9]+}}(%esp)
+; CHECK-32-NEXT:fxam
+; CHECK-32-NEXT:fstp %st(0)
+; CHECK-32-NEXT:fnstsw %ax
+; CHECK-32-NEXT:andb $69, %ah
+; CHECK-32-NEXT:cmpb $1, %ah
+; CHECK-32-NEXT:sete %al
+; CHECK-32-NEXT:retl
+;
+; CHECK-64-LABEL: isnan_ldouble:
+; CHECK-64:   # %bb.0: # %entry
+; CHECK-64-NEXT:fldt {{[0-9]+}}(%rsp)
+; CHECK-64-NEXT:fxam
+; CHECK-64-NEXT:fstp %st(0)
+; CHECK-64-NEXT:fnstsw %ax
+; CHECK-64-NEXT:andb $69, %ah
+; CHECK-64-NEXT:cmpb $1, %ah
+; CHECK-64-NEXT:sete %al
+; CHECK-64-NEXT:retq
+entry:
+  %0 = tail call i1 @llvm.isnan.f80(x86_fp80 %x)
+  ret i1 %0
+}
+
+define i1 @isnan_float_strictfp(float %x) strictfp {
+; CHECK-32-LABEL: isnan_float_strictfp:
+; CHECK-32:   # %bb.0: # %entry
+; CHECK-32-NEXT:movl $2147483647, %eax # imm = 0x7FFF
+; CHECK-32-NEXT:andl {{[0-9]+}}(%esp), %eax
+; CHECK-32-NEXT:cmpl $2139095041, %eax # imm = 0x7F81
+; CHECK-32-NEXT:setge %al
+; CHECK-32-NEXT:retl
+;
+; CHECK-64-LABEL: isnan_float

[PATCH] D105951: [clang] P2266 implicit moves STL workaround

2021-07-26 Thread Melanie Blower via Phabricator via cfe-commits
mibintc accepted this revision.
mibintc added a comment.
This revision is now accepted and ready to land.

I tested this patch downstream on Windows with Microsoft (R) C/C++ Optimizing 
Compiler Version 19.28.29334 for x64

I used c++20, x++latest default and c++17 with the stl header files (standalone 
include files--not usage) and didn't find any problems.

c:/Program files (x86)/Microsoft Visual 
Studio/2019/Professional/VC/Tools/MSVC/14.28.29333/


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105951/new/

https://reviews.llvm.org/D105951

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


[PATCH] D106793: [OpenMP] Add a driver flag to enable the new device runtime library

2021-07-26 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

Can we call this something other than new? We don't tend to remove command line 
arguments and this won't make much sense once it's the only runtime.

I'd be inclined to add an argument called 'use_legacy_runtime' or similar, 
which defaults to true


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106793/new/

https://reviews.llvm.org/D106793

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


[PATCH] D104854: Introduce intrinsic llvm.isnan

2021-07-26 Thread Thorsten via Phabricator via cfe-commits
tschuett added inline comments.



Comment at: llvm/docs/LangRef.rst:20983
+
+These functions get properties of floating point values.
+




Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104854/new/

https://reviews.llvm.org/D104854

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


[PATCH] D106793: [OpenMP] Add a driver flag to enable the new device runtime library

2021-07-26 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added inline comments.



Comment at: clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp:229
+ options::OPT_fno_openmp_target_new_runtime, false))
+BitcodeSuffix = "new-amdgcn-" + GPUArch;
+  else

Likewise here, how about amdgcn-legacy-. Taking advantage of the monorepo + no 
guarantees that mix&match clang and devicertl works.

Side note, someone should probably rename the amdgcn devicertl to amdgpu, since 
the gfx10 stuff is the 'rdna' arch instead of the 'gcn' one.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106793/new/

https://reviews.llvm.org/D106793

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


[PATCH] D106809: [clang-offload-bundler] Make Bundle Entry ID backward compatible

2021-07-26 Thread Saiyedul Islam via Phabricator via cfe-commits
saiislam created this revision.
saiislam added reviewers: jdoerfert, yaxunl, grokos.
saiislam requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

Earlier BundleEntryID used to be --.
This used to work because the clang-offload-bundler didn't need
GPUArch explicitly for any bundling/unbundling action. With
unbundleArchive it needs GPUArch to ensure compatibility between
device specific code objects. D93525  enforced 
triples to have
separators for all 4 components irrespective of number of
components, like "amdgcn-amd-amdhsa--". It was required to
to correctly parse a possible 4th environment component or a GPU.
But, this condition is breaking backward compatibility with
archive libraries compiled with compilers older than D93525 
.

This patch allows triples to have any number of components with
and without extra separator for empty environment field. Thus,
both the following bundle entry IDs are same:
openmp-amdgcn-amd-amdhsa--gfx906
openmp-amdgcn-amd-amdhsa-gfx906


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106809

Files:
  clang/docs/ClangOffloadBundler.rst
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/clang-offload-bundler.c
  clang/test/Driver/hip-rdc-device-only.hip
  clang/test/Driver/hip-toolchain-rdc-separate.hip
  clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Index: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -134,21 +134,32 @@
 ///  * Offload Kind - Host, OpenMP, or HIP
 ///  * Triple - Standard LLVM Triple
 ///  * GPUArch (Optional) - Processor name, like gfx906 or sm_30
-/// In presence of Proc, the Triple should contain separator "-" for all
-/// standard four components, even if they are empty.
+
 struct OffloadTargetInfo {
   StringRef OffloadKind;
   llvm::Triple Triple;
   StringRef GPUArch;
 
   OffloadTargetInfo(const StringRef Target) {
-SmallVector Components;
-Target.split(Components, '-', 5);
-Components.resize(6);
-this->OffloadKind = Components[0];
-this->Triple = llvm::Triple(Components[1], Components[2], Components[3],
-Components[4]);
-this->GPUArch = Components[5];
+auto TargetFeatures = Target.split(':');
+auto TripleOrGPU = TargetFeatures.first.rsplit('-');
+
+// Check if the last option before any colon is a triple field or a GPU name
+if (TripleOrGPU.second.startswith("gfx") ||
+TripleOrGPU.second.startswith("sm_")) {
+  auto KindTriple = TripleOrGPU.first.split('-');
+  this->OffloadKind = KindTriple.first;
+  this->Triple = llvm::Triple(KindTriple.second);
+  auto TID = Target.substr(Target.find("gfx"));
+  if (TID.empty())
+TID = Target.substr(Target.find("sm_"));
+  this->GPUArch = TID;
+} else {
+  auto KindTriple = TargetFeatures.first.split('-');
+  this->OffloadKind = KindTriple.first;
+  this->Triple = llvm::Triple(KindTriple.second);
+  this->GPUArch = "";
+}
   }
 
   bool hasHostKind() const { return this->OffloadKind == "host"; }
@@ -1279,6 +1290,16 @@
 "' in heterogenous archive library: " + IFName)
   .str();
   return createStringError(inconvertibleErrorCode(), ErrMsg);
+} else { // Create an empty archive file if no compatible code object is
+ // found and "allow-missing-bundles" is enabled. It ensures that
+ // the linker using output of this step doesn't complain about
+ // the missing input file.
+  std::vector EmptyArchive;
+  EmptyArchive.clear();
+  if (Error WriteErr = writeArchive(FileName, EmptyArchive, true,
+getDefaultArchiveKindForHost(), true,
+false, nullptr))
+return WriteErr;
 }
   }
 
Index: clang/test/Driver/hip-toolchain-rdc-separate.hip
===
--- clang/test/Driver/hip-toolchain-rdc-separate.hip
+++ clang/test/Driver/hip-toolchain-rdc-separate.hip
@@ -44,7 +44,7 @@
 // CHECK-SAME: {{.*}} [[A_SRC]]
 
 // CHECK: [[BUNDLER:".*clang-offload-bundler"]] "-type=o"
-// CHECK-SAME: "-targets=hip-amdgcn-amd-amdhsa--gfx803,hip-amdgcn-amd-amdhsa--gfx900,host-x86_64-unknown-linux-gnu"
+// CHECK-SAME: "-targets=hip-amdgcn-amd-amdhsa-gfx803,hip-amdgcn-amd-amdhsa-gfx900,host-x86_64-unknown-linux-gnu"
 // CHECK-SAME: "-outputs=[[A_O:.*a.o]]" "-inputs=[[A_BC1]],[[A_BC2]],[[A_OBJ_HOST]]"
 
 // CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
@@ -79,7 +79,7 @@
 // CHECK-SAME: {{.*}} [[B_SRC]]
 
 // CHECK: [[BUNDLER:".*clang-offload-bundler"]] "-type=o"
-// CHECK-SAME: "-targets=hip-amdgcn-amd-amdhsa--gfx

[PATCH] D104854: Introduce intrinsic llvm.isnan

2021-07-26 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added a comment.

In D104854#2886328 , @efriedma wrote:

>> The options '-ffast-math' and '-fno-honor-nans' imply that FP operation
>> operands are never NaNs. This assumption however should not be applied
>> to the functions that check FP number properties, including 'isnan'. If
>> such function returns expected result instead of actually making
>> checks, it becomes useless in many cases.
>
> This doesn't work the way you want it to, at least given the way nnan/ninf 
> are currently defined in LangRef.  It's possible to end up in a situation 
> where `isnan(x) == isnan(x)` evaluates to false at runtime.  It doesn't 
> matter how you compute isnan; the problem is that the input is poisoned.
>
> I think the right solution to this sort of issue is to insert a "freeze" in 
> the LLVM IR, or something like that.  Not sure how we'd expect users to write 
> this in C.  Suggestions welcome.

According to the documentation, nnan/ninf may be applied to `fneg`, `fadd`, 
`fsub`, `fmul`, `fdiv`, `frem`, `fcmp`, `phi`, `select` and `call`. We can 
ignore this flag for calls of isnan and similar functions. Of course, if 
conditions of using `-ffast-math` are broken, we have undefined behavior and 
`isnan(x) != isnan(x)` becomes possible, like in this code:

  %c = fadd %a, nan
  %r = call llvm.isnan.f32(%c) 

Similarly, it is legitimate to optimize `isnan` in the code:

  %c = fadd %a, %b
  %r = call llvm.isnan.f32(%c)

In this case the result of `fadd` cannot be NaN, otherwise contract of 
`-ffast-math` is broken. So `isnan` in this case may be optimized to `false`.




Comment at: llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp:6964
+return DAG.getSetCC(DL, ResultVT, Op, DAG.getConstantFP(0.0, DL, 
OperandVT),
+ISD::SETUO);
+

efriedma wrote:
> Maybe we want to consider falling back to the integer path if SETCC isn't 
> legal for the given operand type?  We could do that as a followup, though.
It makes sense, it could be beneficial for targets that have limited set of 
floating point comparisons. However straightforward check like:

if (Flags.hasNoFPExcept() && isOperationLegalOrCustom(ISD::SETCC, 
OperandVT))

results in worse code, mainly for vector types. It should be more complex check.
 



Comment at: llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp:6984
+  return DAG.getSetCC(DL, ResultVT, Sub, DAG.getConstant(0, DL, IntVT),
+  ISD::SETNE);
+}

efriedma wrote:
> Instead of emitting `ExpMaskV - AbsV != 0`, can we just emit `ExpMaskV != 
> AbsV`?
> Instead of emitting ExpMaskV - AbsV != 0, can we just emit ExpMaskV != AbsV?

Implemented.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104854/new/

https://reviews.llvm.org/D104854

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


[PATCH] D104854: Introduce intrinsic llvm.isnan

2021-07-26 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff updated this revision to Diff 361718.
sepavloff added a comment.

Fixed documentation


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104854/new/

https://reviews.llvm.org/D104854

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/X86/strictfp_builtins.c
  clang/test/CodeGen/aarch64-strictfp-builtins.c
  clang/test/CodeGen/strictfp_builtins.c
  llvm/docs/LangRef.rst
  llvm/include/llvm/CodeGen/ISDOpcodes.h
  llvm/include/llvm/CodeGen/TargetLowering.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/lib/Analysis/ConstantFolding.cpp
  llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
  llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
  llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h
  llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
  llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
  llvm/lib/CodeGen/TargetLoweringBase.cpp
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/test/CodeGen/AArch64/aarch64-fpclass.ll
  llvm/test/CodeGen/PowerPC/ppc-fpclass.ll
  llvm/test/CodeGen/X86/x86-fpclass.ll
  llvm/test/Transforms/InstSimplify/ConstProp/fpclassify.ll

Index: llvm/test/Transforms/InstSimplify/ConstProp/fpclassify.ll
===
--- /dev/null
+++ llvm/test/Transforms/InstSimplify/ConstProp/fpclassify.ll
@@ -0,0 +1,28 @@
+; RUN: opt < %s -instsimplify -S | FileCheck %s
+
+define i1 @isnan_01() {
+entry:
+  %0 = tail call i1 @llvm.isnan.f32(float 0x7FF8)
+  ret i1 %0
+}
+; CHECK-LABEL: isnan_01
+; CHECK:   ret i1 true 
+
+define i1 @isnan_02() {
+entry:
+  %0 = tail call i1 @llvm.isnan.f32(float 0x7FF0)
+  ret i1 %0
+}
+; CHECK-LABEL: isnan_02
+; CHECK:   ret i1 false 
+
+define <4 x i1> @isnan_03() {
+entry:
+  %0 = tail call <4 x i1> @llvm.isnan.v4f32(<4 x float>)
+  ret <4 x i1> %0
+}
+; CHECK-LABEL: isnan_03
+; CHECK:   ret <4 x i1> 
+
+declare i1 @llvm.isnan.f32(float)
+declare <4 x i1> @llvm.isnan.v4f32(<4 x float>)
Index: llvm/test/CodeGen/X86/x86-fpclass.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/x86-fpclass.ll
@@ -0,0 +1,641 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=i686 | FileCheck %s -check-prefix=CHECK-32
+; RUN: llc < %s -mtriple=x86_64 | FileCheck %s -check-prefix=CHECK-64
+
+define i1 @isnan_float(float %x) {
+; CHECK-32-LABEL: isnan_float:
+; CHECK-32:   # %bb.0: # %entry
+; CHECK-32-NEXT:flds {{[0-9]+}}(%esp)
+; CHECK-32-NEXT:fucomp %st(0)
+; CHECK-32-NEXT:fnstsw %ax
+; CHECK-32-NEXT:# kill: def $ah killed $ah killed $ax
+; CHECK-32-NEXT:sahf
+; CHECK-32-NEXT:setp %al
+; CHECK-32-NEXT:retl
+;
+; CHECK-64-LABEL: isnan_float:
+; CHECK-64:   # %bb.0: # %entry
+; CHECK-64-NEXT:ucomiss %xmm0, %xmm0
+; CHECK-64-NEXT:setp %al
+; CHECK-64-NEXT:retq
+; NOSSE-32-LABEL: isnan_float:
+entry:
+  %0 = tail call i1 @llvm.isnan.f32(float %x)
+  ret i1 %0
+}
+
+define i1 @isnan_double(double %x) {
+; CHECK-32-LABEL: isnan_double:
+; CHECK-32:   # %bb.0: # %entry
+; CHECK-32-NEXT:fldl {{[0-9]+}}(%esp)
+; CHECK-32-NEXT:fucomp %st(0)
+; CHECK-32-NEXT:fnstsw %ax
+; CHECK-32-NEXT:# kill: def $ah killed $ah killed $ax
+; CHECK-32-NEXT:sahf
+; CHECK-32-NEXT:setp %al
+; CHECK-32-NEXT:retl
+;
+; CHECK-64-LABEL: isnan_double:
+; CHECK-64:   # %bb.0: # %entry
+; CHECK-64-NEXT:ucomisd %xmm0, %xmm0
+; CHECK-64-NEXT:setp %al
+; CHECK-64-NEXT:retq
+entry:
+  %0 = tail call i1 @llvm.isnan.f64(double %x)
+  ret i1 %0
+}
+
+define i1 @isnan_ldouble(x86_fp80 %x) {
+; CHECK-32-LABEL: isnan_ldouble:
+; CHECK-32:   # %bb.0: # %entry
+; CHECK-32-NEXT:fldt {{[0-9]+}}(%esp)
+; CHECK-32-NEXT:fxam
+; CHECK-32-NEXT:fstp %st(0)
+; CHECK-32-NEXT:fnstsw %ax
+; CHECK-32-NEXT:andb $69, %ah
+; CHECK-32-NEXT:cmpb $1, %ah
+; CHECK-32-NEXT:sete %al
+; CHECK-32-NEXT:retl
+;
+; CHECK-64-LABEL: isnan_ldouble:
+; CHECK-64:   # %bb.0: # %entry
+; CHECK-64-NEXT:fldt {{[0-9]+}}(%rsp)
+; CHECK-64-NEXT:fxam
+; CHECK-64-NEXT:fstp %st(0)
+; CHECK-64-NEXT:fnstsw %ax
+; CHECK-64-NEXT:andb $69, %ah
+; CHECK-64-NEXT:cmpb $1, %ah
+; CHECK-64-NEXT:sete %al
+; CHECK-64-NEXT:retq
+entry:
+  %0 = tail call i1 @llvm.isnan.f80(x86_fp80 %x)
+  ret i1 %0
+}
+
+define i1 @isnan_float_strictfp(float %x) strictfp {
+; CHECK-32-LABEL: isnan_float_strictfp:
+; CHECK-32:   # %bb.0: # %entry
+; CHECK-32-NEXT:movl $2147483647, %eax # imm = 0x7FFF
+; CHECK-32-NEXT:andl {{[0-9]+}}(%esp), %eax
+; CHECK-32-NEXT:cmpl $2139095041, %eax # imm = 0x7F81
+; CHECK-32-NEXT:setge %al
+; CHECK-32-NEXT:retl
+;
+; CHECK-64-LABEL: isnan_float_strictfp:
+; CHECK-64:   # %bb.0: # %entry
+; CHECK-64-N

[PATCH] D104854: Introduce intrinsic llvm.isnan

2021-07-26 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added inline comments.



Comment at: llvm/docs/LangRef.rst:20983
+
+These functions get properties of floating point values.
+

tschuett wrote:
> 
Fixed, thank you.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104854/new/

https://reviews.llvm.org/D104854

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


[PATCH] D106401: [CUDA, MemCpyOpt] Add a flag to force-enable memcpyopt and use it for CUDA.

2021-07-26 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

In D106401#2903114 , @nikic wrote:

> Would the variant of the original patch at D106769 
>  be sufficient for your purposes? Or are 
> you also interested in the optimizations that introduce new memset/memcpy?

The specific issue I was looking to fix does need `memcpy`->`memset` 
transformation, so I would still need a way to bypass libcall availability 
checks.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106401/new/

https://reviews.llvm.org/D106401

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


[PATCH] D106005: [Docs] Define matrix initialisation in MatrixTypes documentation

2021-07-26 Thread Saurabh Jha via Phabricator via cfe-commits
SaurabhJha added a comment.

In D106005#2904424 , @fhahn wrote:

> In D106005#2896080 , @SaurabhJha 
> wrote:
>
>> In D106005#2895716 , @fhahn wrote:
>>
>>> Thank you very much for working on this! Are you planning on implementing 
>>> the new specification as well? It would probably be good to land the update 
>>> to the spec in close succession to the implementation, to avoid confusing 
>>> users.
>>
>> Yes, that's my plan. Once this is in, I will start working on the 
>> implementation right away.
>
> Ok cool! I think the latest version looks good (modulo making sure the new 
> lines are limited to 80 chars per line). @rjmccall can you think of any 
> scenarios where defining initializers with one expression and broadcasting 
> them might cause issues?
>
> With respect to ordering the patches, I think it would be good to put up a 
> patch implementing the newly added parts, commit it and then land the patch 
> that adds it to the docs. WDYT?

Yeah, sounds good. I will create a patch for implementing initialisation.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106005/new/

https://reviews.llvm.org/D106005

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


[PATCH] D105821: [analyzer] [WIP] Model destructor for std::unique_ptr

2021-07-26 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

In D105821#2903606 , @RedDocMD wrote:

> The following code **emits** a warning for leaked memory:
> ...
> Why does the following command not display the warnings?

Wait, what's the difference between this command and the command that **did 
emit** the warning for you?

With that specific invocation, apart from the missing 
`cplusplus.NewDeleteLeaks`, and apart from noticing that `std::make_unique` 
isn't actually getting modeled but inlined instead (I have all your patches 
pulled and this patch applied; and the object-under-construction seems to be 
available later, in both C++11 and C++17, so it's kinda weird and needs more 
debugging), I think the reason this doesn't warn is that the pointer is 
technically put on the heap (when stored into `Lame::ptr`) which makes it 
accessible for the entire program and therefore potentially delete-able by 
anybody and we suppress the warning (it's kinda frustrating but we already have 
the opposite problem for locals and we don't really know how to solve either of 
those: D71041#inline-641497 , 
the reverted D71152 , etc.)

So basically it sounds like this is indeed not going to be too big of a 
problem, given that memory managed by `unique_ptr` is always heap memory, so 
everything that's ever put there during analysis is never going to produce any 
leak warnings. Maybe we could indeed get away with conservative modeling of 
constructors (inside `make_unique`) and destructors.

We do need conservative modeling of constructors in `make_unique` though, 
otherwise your pointer never reaches `Lame::ptr` which means an actual leak 
warning.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105821/new/

https://reviews.llvm.org/D105821

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


[PATCH] D106793: [OpenMP] Add a driver flag to enable the new device runtime library

2021-07-26 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D106793#2904661 , @ye-luo wrote:

> Not clear from the summary what is the new driver option.

It's a rewrite of the current device runtime. This option will enable it.

In D106793#2904771 , @JonChesterfield 
wrote:

> Can we call this something other than new? We don't tend to remove command 
> line arguments and this won't make much sense once it's the only runtime.
>
> I'd be inclined to add an argument called 'use_legacy_runtime' or similar, 
> which defaults to true, instead of this one. I.e. invert the logic

I agree somewhat that it might be easier to just call this the legacy, I'm open 
to it. But we had other options like `-enable-new-pm` for awhile before it 
became the default so it's probably not a big deal.




Comment at: clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp:229
+ options::OPT_fno_openmp_target_new_runtime, false))
+BitcodeSuffix = "new-amdgcn-" + GPUArch;
+  else

JonChesterfield wrote:
> Likewise here, how about amdgcn-legacy-. Taking advantage of the monorepo + 
> no guarantees that mix&match clang and devicertl works.
> 
> Side note, someone should probably rename the amdgcn devicertl to amdgpu, 
> since the gfx10 stuff is the 'rdna' arch instead of the 'gcn' one.
I think changing the BC name is something we can do any time, so just calling 
it `libomptarget-new` is fine for now.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106793/new/

https://reviews.llvm.org/D106793

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


[PATCH] D105728: [clang][Codegen] Directly lower `(*((volatile int *)(0))) = 0;` into a `call void @llvm.trap()`

2021-07-26 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a subscriber: efriedma.
lebedev.ri added a comment.

@rsmith @efriedma ping


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105728/new/

https://reviews.llvm.org/D105728

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


[PATCH] D106577: [clang] Define __STDC_ISO_10646__

2021-07-26 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In D106577#2904078 , @aaron.ballman 
wrote:

> In D106577#2902091 , @jyknight 
> wrote:
>
>> In D106577#2901654 , @rsmith wrote:
>>
>>> I think this patch as it stands would cause problems with libc 
>>> implementations that put their `#define` somewhere other than than 
>>> `stdc-predef.h` (eg, older versions of glibc that put it in `features.h` or 
>>> other standard libraries that put it in `yvals.h`) due to the macro 
>>> redefinition with a conflicting expansion. Such implementations are 
>>> non-conforming but certainly exist. Likewise it could break the build for 
>>> the same reason if we start implicitly including `stdc-predef.h` at some 
>>> point. So I think that blindly predefining this macro will prove 
>>> problematic in at least some circumstances.
>>
>> I don't understand what problem you expect to see here. We already suppress 
>> -Wmacro-redefined [which this falls under] for system headers -- doesn't 
>> that suffice?
>
> I'd like to hear more about this as well, FWIW. I think we get all the 
> benefits you describe by defining the macro in the frontend and letting the 
> macro suppression work if there's a conflicting definition from a system 
> header.

I'd expect we will break at least things like libc++ tests that build with 
`-Wsystem-headers` in the case where libc defines the macro. But if the problem 
is limited to old libc and a rare use case, and can easily be worked around 
with a `-Wno` flag, that's probably fine.

One benefit we don't get with this approach is providing the right value for 
the macro (without paying the cost of always including `stdc-predefs.h`). 
AFAICS, the only possible use for the value of the macro is to detect libc 
support, so having Clang pick a specific value seems wrong to me. In some ways 
I'd be more comfortable with this patch if we defined the macro to `1` and 
documented that we think WG14 was wrong to ask for a version number.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106577/new/

https://reviews.llvm.org/D106577

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


[PATCH] D105527: libclang.so: Make SONAME independent from LLVM version

2021-07-26 Thread Tom Stellard via Phabricator via cfe-commits
tstellar updated this revision to Diff 361734.
tstellar added a comment.

Add test case for local symbols and reformat version script.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105527/new/

https://reviews.llvm.org/D105527

Files:
  clang/test/CMakeLists.txt
  clang/test/LibClang/lit.local.cfg
  clang/test/LibClang/symbols.test
  clang/test/lit.site.cfg.py.in
  clang/tools/libclang/CMakeLists.txt
  clang/tools/libclang/libclang.exports
  clang/tools/libclang/libclang.map
  clang/tools/libclang/linker-script-to-export-list.py

Index: clang/tools/libclang/linker-script-to-export-list.py
===
--- /dev/null
+++ clang/tools/libclang/linker-script-to-export-list.py
@@ -0,0 +1,10 @@
+import re
+import os
+
+input_file = open(sys.argv[1])
+output_file = open(sys.argv[2])
+
+for line in input_file:
+m = re.search('clang_[^;]+', line)
+if m:
+output_file.write(m.group(0))
Index: clang/tools/libclang/libclang.map
===
--- /dev/null
+++ clang/tools/libclang/libclang.map
@@ -0,0 +1,415 @@
+/* If you add a symbol to this file, make sure to add it with the correct
+ * version.  For example, if the LLVM main branch is LLVM 14.0.0, add new
+ * symbols with the version LLVM_14.
+ * On platforms where versions scripts are not used, this file will be used to
+ * generate a list of exports for libclang.so
+ */
+
+
+LLVM_13 {
+  clang_BlockCommandComment_getArgText;
+  clang_BlockCommandComment_getCommandName;
+  clang_BlockCommandComment_getNumArgs;
+  clang_BlockCommandComment_getParagraph;
+  clang_CXCursorSet_contains;
+  clang_CXCursorSet_insert;
+  clang_CXIndex_getGlobalOptions;
+  clang_CXIndex_setGlobalOptions;
+  clang_CXIndex_setInvocationEmissionPathOption;
+  clang_CXRewriter_create;
+  clang_CXRewriter_dispose;
+  clang_CXRewriter_insertTextBefore;
+  clang_CXRewriter_overwriteChangedFiles;
+  clang_CXRewriter_removeText;
+  clang_CXRewriter_replaceText;
+  clang_CXRewriter_writeMainFileToStdOut;
+  clang_CXXConstructor_isConvertingConstructor;
+  clang_CXXConstructor_isCopyConstructor;
+  clang_CXXConstructor_isDefaultConstructor;
+  clang_CXXConstructor_isMoveConstructor;
+  clang_CXXField_isMutable;
+  clang_CXXMethod_isConst;
+  clang_CXXMethod_isDefaulted;
+  clang_CXXMethod_isPureVirtual;
+  clang_CXXMethod_isStatic;
+  clang_CXXMethod_isVirtual;
+  clang_CXXRecord_isAbstract;
+  clang_Comment_getChild;
+  clang_Comment_getKind;
+  clang_Comment_getNumChildren;
+  clang_Comment_isWhitespace;
+  clang_CompilationDatabase_dispose;
+  clang_CompilationDatabase_fromDirectory;
+  clang_CompilationDatabase_getAllCompileCommands;
+  clang_CompilationDatabase_getCompileCommands;
+  clang_CompileCommand_getArg;
+  clang_CompileCommand_getDirectory;
+  clang_CompileCommand_getFilename;
+  clang_CompileCommand_getMappedSourceContent;
+  clang_CompileCommand_getMappedSourcePath;
+  clang_CompileCommand_getNumArgs;
+  clang_CompileCommands_dispose;
+  clang_CompileCommands_getCommand;
+  clang_CompileCommands_getSize;
+  clang_Cursor_Evaluate;
+  clang_Cursor_getArgument;
+  clang_Cursor_getBriefCommentText;
+  clang_Cursor_getCXXManglings;
+  clang_Cursor_getCommentRange;
+  clang_Cursor_getMangling;
+  clang_Cursor_getModule;
+  clang_Cursor_getNumArguments;
+  clang_Cursor_getNumTemplateArguments;
+  clang_Cursor_getObjCDeclQualifiers;
+  clang_Cursor_getObjCManglings;
+  clang_Cursor_getObjCPropertyAttributes;
+  clang_Cursor_getObjCPropertyGetterName;
+  clang_Cursor_getObjCPropertySetterName;
+  clang_Cursor_getObjCSelectorIndex;
+  clang_Cursor_getOffsetOfField;
+  clang_Cursor_getParsedComment;
+  clang_Cursor_getRawCommentText;
+  clang_Cursor_getReceiverType;
+  clang_Cursor_getSpellingNameRange;
+  clang_Cursor_getStorageClass;
+  clang_Cursor_getTemplateArgumentKind;
+  clang_Cursor_getTemplateArgumentType;
+  clang_Cursor_getTemplateArgumentUnsignedValue;
+  clang_Cursor_getTemplateArgumentValue;
+  clang_Cursor_getTranslationUnit;
+  clang_Cursor_getVarDeclInitializer;
+  clang_Cursor_hasAttrs;
+  clang_Cursor_hasVarDeclExternalStorage;
+  clang_Cursor_hasVarDeclGlobalStorage;
+  clang_Cursor_isAnonymous;
+  clang_Cursor_isAnonymousRecordDecl;
+  clang_Cursor_isBitField;
+  clang_Cursor_isDynamicCall;
+  clang_Cursor_isExternalSymbol;
+  clang_Cursor_isFunctionInlined;
+  clang_Cursor_isInlineNamespace;
+  clang_Cursor_isMacroBuiltin;
+  clang_Cursor_isMacroFunctionLike;
+  clang_Cursor_isNull;
+  clang_Cursor_isObjCOptional;
+  clang_Cursor_isVariadic;
+  clang_EnumDecl_isScoped;
+  clang_EvalResult_dispose;
+  clang_EvalResult_getAsDouble;
+  clang_EvalResult_getAsInt;
+  clang_EvalResult_getAsLongLong;
+  clang_EvalResult_getAsStr;
+  clang_EvalResult_getAsUnsigned;
+  clang_EvalResult_getKind;
+  clang_EvalResult_isUnsignedInt;
+  clang_File_isEqual;
+  clang_File_tryGetRealPathName;
+  clang_FullComment_getAsHT

[PATCH] D106813: [clang-repl] Build and install clang-repl by default

2021-07-26 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev created this revision.
v.g.vassilev added reviewers: teemperor, rsmith, lhames, hfinkel, sgraenitz.
Herald added a subscriber: mgorny.
v.g.vassilev requested review of this revision.

We have the basic infrastructure in place. We can recover from simple errors 
(recovering from errors in template instantiations is not yet supported). It 
looks like we are in a reasonably functional state for llvm13.


Repository:
  rC Clang

https://reviews.llvm.org/D106813

Files:
  clang/tools/clang-repl/CMakeLists.txt


Index: clang/tools/clang-repl/CMakeLists.txt
===
--- clang/tools/clang-repl/CMakeLists.txt
+++ clang/tools/clang-repl/CMakeLists.txt
@@ -7,7 +7,6 @@
   )
 
 add_clang_executable(clang-repl
-  EXCLUDE_FROM_ALL
   ClangRepl.cpp
   )
 


Index: clang/tools/clang-repl/CMakeLists.txt
===
--- clang/tools/clang-repl/CMakeLists.txt
+++ clang/tools/clang-repl/CMakeLists.txt
@@ -7,7 +7,6 @@
   )
 
 add_clang_executable(clang-repl
-  EXCLUDE_FROM_ALL
   ClangRepl.cpp
   )
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >