[clang] 08c766a - Bump the trunk major version to 14

2021-07-27 Thread Tom Stellard via cfe-commits

Author: Tom Stellard
Date: 2021-07-27T21:58:25-07:00
New Revision: 08c766a7318ab37bf1d77e0c683cd3b00e700877

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

LOG: Bump the trunk major version to 14

and clear the release notes.

Added: 


Modified: 
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/conf.py
clang/docs/ReleaseNotes.rst
clang/docs/analyzer/conf.py
libcxx/CMakeLists.txt
libcxx/docs/ReleaseNotes.rst
libcxx/docs/conf.py
libcxx/include/__config
libunwind/CMakeLists.txt
libunwind/docs/conf.py
lld/docs/ReleaseNotes.rst
lld/docs/conf.py
llvm/CMakeLists.txt
llvm/docs/ReleaseNotes.rst
llvm/utils/gn/secondary/llvm/version.gni
llvm/utils/lit/lit/__init__.py
llvm/utils/release/build_llvm_package.bat
polly/docs/ReleaseNotes.rst
polly/docs/conf.py
pstl/docs/ReleaseNotes.rst
pstl/include/pstl/internal/pstl_config.h
pstl/test/pstl/version.pass.cpp

Removed: 




diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index b4d325cb553d6..afa685d1fbdd9 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -1,5 +1,5 @@
 
-Extra Clang Tools 13.0.0 (In-Progress) Release Notes
+Extra Clang Tools 14.0.0 (In-Progress) Release Notes
 
 
 .. contents::
@@ -10,7 +10,7 @@ Written by the `LLVM Team `_
 
 .. warning::
 
-   These are in-progress notes for the upcoming Extra Clang Tools 13 release.
+   These are in-progress notes for the upcoming Extra Clang Tools 14 release.
Release notes for previous releases can be found on
`the Download Page `_.
 
@@ -18,7 +18,7 @@ Introduction
 
 
 This document contains the release notes for the Extra Clang Tools, part of the
-Clang release 13.0.0. Here we describe the status of the Extra Clang Tools in
+Clang release 14.0.0. Here we describe the status of the Extra Clang Tools in
 some detail, including major improvements from the previous release and new
 feature work. All LLVM releases may be downloaded from the `LLVM releases web
 site `_.
@@ -32,7 +32,7 @@ main Clang web page, this document applies to the *next* 
release, not
 the current one. To see the release notes for a specific release, please
 see the `releases page `_.
 
-What's New in Extra Clang Tools 13.0.0?
+What's New in Extra Clang Tools 14.0.0?
 ===
 
 Some of the major new features and improvements to Extra Clang Tools are listed
@@ -67,105 +67,20 @@ The improvements are...
 Improvements to clang-tidy
 --
 
-- The `run-clang-tidy.py` helper script is now installed in `bin/` as
-  `run-clang-tidy`. It was previously installed in `share/clang/`.
-
-- Added command line option `--fix-notes` to apply fixes found in notes
-  attached to warnings. These are typically cases where we are less confident
-  the fix will have the desired effect.
-
-- libToolingCore and Clang-Tidy was refactored and now checks can produce
-  highlights (`^` under fragments of the source code) in diagnostics.
-  Existing and new checks in the future can be expected to start implementing
-  this functionality.
-  This change only affects the visual rendering of diagnostics, and does not
-  alter the behavior of generated fixes.
+The improvements are...
 
 New checks
 ^^
 
-- New :doc:`bugprone-implicit-widening-of-multiplication-result
-  ` 
check.
-
-  Diagnoses instances of an implicit widening of multiplication result.
-
-- New :doc:`concurrency-thread-canceltype-asynchronous
-  ` check.
-
-  Finds ``pthread_setcanceltype`` function calls where a thread's cancellation
-  type is set to asynchronous.
-
-- New :doc:`altera-id-dependent-backward-branch
-  ` check.
-
-  Finds ID-dependent variables and fields that are used within loops. This
-  causes branches to occur inside the loops, and thus leads to performance
-  degradation.
-
-- New :doc:`altera-unroll-loops
-  ` check.
-
-  Finds inner loops that have not been unrolled, as well as fully unrolled
-  loops with unknown loops bounds or a large number of iterations.
-
-- New :doc:`bugprone-easily-swappable-parameters
-  ` check.
-
-  Finds function definitions where parameters of convertible types follow each
-  other directly, making call sites prone to calling the function with
-  swapped (or badly ordered) arguments.
-
-- New :doc:`cppcoreguidelines-prefer-member-initializer
-  ` check.
-
-  Finds member initializations in the constructor body which can be placed into

[PATCH] D106674: Runtime for Interop directive

2021-07-27 Thread Sri Hari Krishna Narayanan via Phabricator via cfe-commits
sriharikrishna updated this revision to Diff 362280.
sriharikrishna added a comment.

Runtime for Interop directive


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106674

Files:
  openmp/libomptarget/include/interop.h
  openmp/libomptarget/include/omptarget.h
  openmp/libomptarget/include/omptargetplugin.h
  openmp/libomptarget/plugins/cuda/src/rtl.cpp
  openmp/libomptarget/plugins/exports
  openmp/libomptarget/src/CMakeLists.txt
  openmp/libomptarget/src/exports
  openmp/libomptarget/src/interop.cpp
  openmp/libomptarget/src/private.h
  openmp/libomptarget/src/rtl.cpp
  openmp/libomptarget/src/rtl.h
  openmp/runtime/src/dllexports
  openmp/runtime/src/kmp_ftn_entry.h
  openmp/runtime/src/kmp_ftn_os.h

Index: openmp/runtime/src/kmp_ftn_os.h
===
--- openmp/runtime/src/kmp_ftn_os.h
+++ openmp/runtime/src/kmp_ftn_os.h
@@ -140,6 +140,14 @@
 #define FTN_SET_TEAMS_THREAD_LIMIT omp_set_teams_thread_limit
 #define FTN_GET_TEAMS_THREAD_LIMIT omp_get_teams_thread_limit
 
+#define FTN_GET_NUM_INTEROP_PROPERTIES omp_get_num_interop_properties
+#define FTN_GET_INTEROP_INT omp_get_interop_int
+#define FTN_GET_INTEROP_PTR omp_get_interop_ptr
+#define FTN_GET_INTEROP_STR omp_get_interop_str
+#define FTN_GET_INTEROP_NAME omp_get_interop_name
+#define FTN_GET_INTEROP_TYPE_DESC omp_get_interop_type_desc
+#define FTN_GET_INTEROP_RC_DESC omp_get_interop_rc_desc
+
 #endif /* KMP_FTN_PLAIN */
 
 /*  */
Index: openmp/runtime/src/kmp_ftn_entry.h
===
--- openmp/runtime/src/kmp_ftn_entry.h
+++ openmp/runtime/src/kmp_ftn_entry.h
@@ -1446,6 +1446,134 @@
 #endif
 }
 
+/// TODO: Include the `omp.h` of the current build
+/* OpenMP 5.1 interop */
+typedef intptr_t omp_intptr_t;
+
+/* 0..omp_get_num_interop_properties()-1 are reserved for implementation-defined
+ * properties */
+typedef enum omp_interop_property {
+  omp_ipr_fr_id = -1,
+  omp_ipr_fr_name = -2,
+  omp_ipr_vendor = -3,
+  omp_ipr_vendor_name = -4,
+  omp_ipr_device_num = -5,
+  omp_ipr_platform = -6,
+  omp_ipr_device = -7,
+  omp_ipr_device_context = -8,
+  omp_ipr_targetsync = -9,
+  omp_ipr_first = -9
+} omp_interop_property_t;
+
+#define omp_interop_none 0
+
+typedef enum omp_interop_rc {
+  omp_irc_no_value = 1,
+  omp_irc_success = 0,
+  omp_irc_empty = -1,
+  omp_irc_out_of_range = -2,
+  omp_irc_type_int = -3,
+  omp_irc_type_ptr = -4,
+  omp_irc_type_str = -5,
+  omp_irc_other = -6
+} omp_interop_rc_t;
+
+typedef enum omp_interop_fr {
+  omp_ifr_cuda = 1,
+  omp_ifr_cuda_driver = 2,
+  omp_ifr_opencl = 3,
+  omp_ifr_sycl = 4,
+  omp_ifr_hip = 5,
+  omp_ifr_level_zero = 6,
+  omp_ifr_last = 7
+} omp_interop_fr_t;
+
+typedef void *omp_interop_t;
+
+// libomptarget, if loaded, provides this function
+int FTN_STDCALL FTN_GET_NUM_INTEROP_PROPERTIES(const omp_interop_t interop) {
+#if KMP_MIC || KMP_OS_DARWIN || defined(KMP_STUB)
+  return 0;
+#else
+  int (*fptr)(const omp_interop_t);
+  if ((*(void **)() = KMP_DLSYM_NEXT("omp_get_num_interop_properties"))) {
+return (*fptr)(interop);
+  } else { // liboffload & libomptarget don't exist
+return 0;
+  }
+#endif // KMP_MIC || KMP_OS_DARWIN || KMP_OS_WINDOWS || defined(KMP_STUB)
+}
+
+/// TODO Convert FTN_GET_INTEROP_XXX functions into a macro like interop.cpp
+// libomptarget, if loaded, provides this function
+intptr_t FTN_STDCALL FTN_GET_INTEROP_INT(const omp_interop_t interop,
+ omp_interop_property_t property_id,
+ int *err) {
+  intptr_t (*fptr)(const omp_interop_t, omp_interop_property_t, int *);
+  if ((*(void **)() = KMP_DLSYM_NEXT("omp_get_interop_int"))) {
+return (*fptr)(interop, property_id, err);
+  } else { // liboffload & libomptarget don't exist
+return 0;
+  }
+}
+
+// libomptarget, if loaded, provides this function
+void *FTN_STDCALL FTN_GET_INTEROP_PTR(const omp_interop_t interop,
+  omp_interop_property_t property_id,
+  int *err) {
+  void *(*fptr)(const omp_interop_t, omp_interop_property_t, int *);
+  if ((*(void **)() = KMP_DLSYM_NEXT("omp_get_interop_ptr"))) {
+return (*fptr)(interop, property_id, err);
+  } else { // liboffload & libomptarget don't exist
+return (void *)0;
+  }
+}
+
+// libomptarget, if loaded, provides this function
+const char *FTN_STDCALL FTN_GET_INTEROP_STR(const omp_interop_t interop,
+omp_interop_property_t property_id,
+int *err) {
+  const char *(*fptr)(const omp_interop_t, omp_interop_property_t, int *);
+  if ((*(void **)() = KMP_DLSYM_NEXT("omp_get_interop_str"))) {
+return (*fptr)(interop, property_id, err);
+  } else { 

[PATCH] D106854: Pass `--start-group` and `--end-group` to the linker when using the AVR toolchain

2021-07-27 Thread Matt Jacobson via Phabricator via cfe-commits
mhjacobson updated this revision to Diff 362277.
mhjacobson marked an inline comment as done.
mhjacobson added a comment.

Explicitly added `--start-group` and `--end-group` to the expectation in the 
test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106854

Files:
  clang/lib/Driver/ToolChains/AVR.cpp
  clang/test/Driver/avr-ld.c


Index: clang/test/Driver/avr-ld.c
===
--- clang/test/Driver/avr-ld.c
+++ clang/test/Driver/avr-ld.c
@@ -1,44 +1,44 @@
 // RUN: %clang -### --target=avr -mmcu=at90s2313 --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKA %s
-// LINKA: {{".*ld.*"}} {{.*}} {{"-L.*tiny-stack"}} {{.*}} "-Tdata=0x800060" 
{{.*}} "-lat90s2313" "-mavr2"
+// LINKA: {{".*ld.*"}} {{.*}} {{"-L.*tiny-stack"}} {{.*}} "-Tdata=0x800060" 
"--start-group" {{.*}} "-lat90s2313" "--end-group" "-mavr2"
 
 // RUN: %clang -### --target=avr -mmcu=at90s8515 --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKB %s
-// LINKB: {{".*ld.*"}} {{.*}} "-Tdata=0x800060" {{.*}} "-lat90s8515" "-mavr2"
+// LINKB: {{".*ld.*"}} {{.*}} "-Tdata=0x800060" "--start-group" {{.*}} 
"-lat90s8515" "--end-group" "-mavr2"
 
 // RUN: %clang -### --target=avr -mmcu=attiny13 --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKC %s
-// LINKC: {{".*ld.*"}} {{.*}} {{"-L.*avr25/tiny-stack"}} {{.*}} 
"-Tdata=0x800060" {{.*}} "-lattiny13" "-mavr25"
+// LINKC: {{".*ld.*"}} {{.*}} {{"-L.*avr25/tiny-stack"}} {{.*}} 
"-Tdata=0x800060" "--start-group" {{.*}} "-lattiny13" "--end-group" "-mavr25"
 
 // RUN: %clang -### --target=avr -mmcu=attiny44 --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKD %s
-// LINKD: {{".*ld.*"}} {{.*}} {{"-L.*avr25"}} {{.*}} "-Tdata=0x800060" {{.*}} 
"-lattiny44" "-mavr25"
+// LINKD: {{".*ld.*"}} {{.*}} {{"-L.*avr25"}} {{.*}} "-Tdata=0x800060" 
"--start-group" {{.*}} "-lattiny44" "--end-group" "-mavr25"
 
 // RUN: %clang -### --target=avr -mmcu=atmega103 --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKE %s
-// LINKE: {{".*ld.*"}} {{.*}} {{"-L.*avr31"}} {{.*}} "-Tdata=0x800060" {{.*}} 
"-latmega103" "-mavr31"
+// LINKE: {{".*ld.*"}} {{.*}} {{"-L.*avr31"}} {{.*}} "-Tdata=0x800060" 
"--start-group" {{.*}} "-latmega103" "--end-group" "-mavr31"
 
 // RUN: %clang -### --target=avr -mmcu=atmega8u2 --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKF %s
-// LINKF: {{".*ld.*"}} {{.*}} {{"-L.*avr35"}} {{.*}} "-Tdata=0x800100" {{.*}} 
"-latmega8u2" "-mavr35"
+// LINKF: {{".*ld.*"}} {{.*}} {{"-L.*avr35"}} {{.*}} "-Tdata=0x800100" 
"--start-group" {{.*}} "-latmega8u2" "--end-group" "-mavr35"
 
 // RUN: %clang -### --target=avr -mmcu=atmega48pa --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKG %s
-// LINKG: {{".*ld.*"}} {{.*}} {{"-L.*avr4"}} {{.*}} "-Tdata=0x800100" {{.*}} 
"-latmega48pa" "-mavr4"
+// LINKG: {{".*ld.*"}} {{.*}} {{"-L.*avr4"}} {{.*}} "-Tdata=0x800100" 
"--start-group" {{.*}} "-latmega48pa" "--end-group" "-mavr4"
 
 // RUN: %clang -### --target=avr -mmcu=atmega328 --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKH %s
-// LINKH: {{".*ld.*"}} {{.*}} {{"-L.*avr5"}} {{.*}} "-Tdata=0x800100" {{.*}} 
"-latmega328" "-mavr5"
+// LINKH: {{".*ld.*"}} {{.*}} {{"-L.*avr5"}} {{.*}} "-Tdata=0x800100" 
"--start-group" {{.*}} "-latmega328" "--end-group" "-mavr5"
 
 // RUN: %clang -### --target=avr -mmcu=atmega1281 --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKI %s
-// LINKI: {{".*ld.*"}} {{.*}} {{"-L.*avr51"}} {{.*}} "-Tdata=0x800200" {{.*}} 
"-latmega1281" "-mavr51"
+// LINKI: {{".*ld.*"}} {{.*}} {{"-L.*avr51"}} {{.*}} "-Tdata=0x800200" 
"--start-group" {{.*}} "-latmega1281" "--end-group" "-mavr51"
 
 // RUN: %clang -### --target=avr -mmcu=atmega2560 --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKJ %s
-// LINKJ: {{".*ld.*"}} {{.*}} {{"-L.*avr6"}} {{.*}} "-Tdata=0x800200" {{.*}} 
"-latmega2560" "-mavr6"
+// LINKJ: {{".*ld.*"}} {{.*}} {{"-L.*avr6"}} {{.*}} "-Tdata=0x800200" 
"--start-group" {{.*}} "-latmega2560" "--end-group" "-mavr6"
 
 // RUN: %clang -### --target=avr -mmcu=attiny10 --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKK %s
-// LINKK: {{".*ld.*"}} {{.*}} {{"-L.*avrtiny"}} {{.*}} "-Tdata=0x800040" 
{{.*}} "-lattiny10" "-mavrtiny"
+// LINKK: {{".*ld.*"}} {{.*}} {{"-L.*avrtiny"}} {{.*}} "-Tdata=0x800040" 
"--start-group" {{.*}} "-lattiny10" "--end-group" "-mavrtiny"
 
 // RUN: %clang -### --target=avr -mmcu=atxmega16a4 --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKL %s
-// LINKL: {{".*ld.*"}} {{.*}} {{"-L.*avrxmega2"}} {{.*}} "-Tdata=0x802000" 
{{.*}} "-latxmega16a4" "-mavrxmega2"
+// LINKL: {{".*ld.*"}} {{.*}} {{"-L.*avrxmega2"}} {{.*}} "-Tdata=0x802000" 
"--start-group" {{.*}} 

[PATCH] D106854: Pass `--start-group` and `--end-group` to the linker when using the AVR toolchain

2021-07-27 Thread Matt Jacobson via Phabricator via cfe-commits
mhjacobson marked an inline comment as done.
mhjacobson added inline comments.



Comment at: clang/lib/Driver/ToolChains/AVR.cpp:430
 
+CmdArgs.push_back("--end-group");
+

benshi001 wrote:
> You are appreciated to use 'git show -U99' or 'git diff -U99' for 
> better context display.
Sorry!  Fixed, I think.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106854

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


[PATCH] D106854: Pass `--start-group` and `--end-group` to the linker when using the AVR toolchain

2021-07-27 Thread Matt Jacobson via Phabricator via cfe-commits
mhjacobson updated this revision to Diff 362275.
mhjacobson added a comment.

Updated the diff to add more context.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106854

Files:
  clang/lib/Driver/ToolChains/AVR.cpp
  clang/test/Driver/avr-ld.c


Index: clang/test/Driver/avr-ld.c
===
--- clang/test/Driver/avr-ld.c
+++ clang/test/Driver/avr-ld.c
@@ -1,44 +1,44 @@
 // RUN: %clang -### --target=avr -mmcu=at90s2313 --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKA %s
-// LINKA: {{".*ld.*"}} {{.*}} {{"-L.*tiny-stack"}} {{.*}} "-Tdata=0x800060" 
{{.*}} "-lat90s2313" "-mavr2"
+// LINKA: {{".*ld.*"}} {{.*}} {{"-L.*tiny-stack"}} {{.*}} "-Tdata=0x800060" 
{{.*}} "-lat90s2313" {{.*}} "-mavr2"
 
 // RUN: %clang -### --target=avr -mmcu=at90s8515 --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKB %s
-// LINKB: {{".*ld.*"}} {{.*}} "-Tdata=0x800060" {{.*}} "-lat90s8515" "-mavr2"
+// LINKB: {{".*ld.*"}} {{.*}} "-Tdata=0x800060" {{.*}} "-lat90s8515" {{.*}} 
"-mavr2"
 
 // RUN: %clang -### --target=avr -mmcu=attiny13 --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKC %s
-// LINKC: {{".*ld.*"}} {{.*}} {{"-L.*avr25/tiny-stack"}} {{.*}} 
"-Tdata=0x800060" {{.*}} "-lattiny13" "-mavr25"
+// LINKC: {{".*ld.*"}} {{.*}} {{"-L.*avr25/tiny-stack"}} {{.*}} 
"-Tdata=0x800060" {{.*}} "-lattiny13" {{.*}} "-mavr25"
 
 // RUN: %clang -### --target=avr -mmcu=attiny44 --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKD %s
-// LINKD: {{".*ld.*"}} {{.*}} {{"-L.*avr25"}} {{.*}} "-Tdata=0x800060" {{.*}} 
"-lattiny44" "-mavr25"
+// LINKD: {{".*ld.*"}} {{.*}} {{"-L.*avr25"}} {{.*}} "-Tdata=0x800060" {{.*}} 
"-lattiny44" {{.*}} "-mavr25"
 
 // RUN: %clang -### --target=avr -mmcu=atmega103 --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKE %s
-// LINKE: {{".*ld.*"}} {{.*}} {{"-L.*avr31"}} {{.*}} "-Tdata=0x800060" {{.*}} 
"-latmega103" "-mavr31"
+// LINKE: {{".*ld.*"}} {{.*}} {{"-L.*avr31"}} {{.*}} "-Tdata=0x800060" {{.*}} 
"-latmega103" {{.*}} "-mavr31"
 
 // RUN: %clang -### --target=avr -mmcu=atmega8u2 --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKF %s
-// LINKF: {{".*ld.*"}} {{.*}} {{"-L.*avr35"}} {{.*}} "-Tdata=0x800100" {{.*}} 
"-latmega8u2" "-mavr35"
+// LINKF: {{".*ld.*"}} {{.*}} {{"-L.*avr35"}} {{.*}} "-Tdata=0x800100" {{.*}} 
"-latmega8u2" {{.*}} "-mavr35"
 
 // RUN: %clang -### --target=avr -mmcu=atmega48pa --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKG %s
-// LINKG: {{".*ld.*"}} {{.*}} {{"-L.*avr4"}} {{.*}} "-Tdata=0x800100" {{.*}} 
"-latmega48pa" "-mavr4"
+// LINKG: {{".*ld.*"}} {{.*}} {{"-L.*avr4"}} {{.*}} "-Tdata=0x800100" {{.*}} 
"-latmega48pa" {{.*}} "-mavr4"
 
 // RUN: %clang -### --target=avr -mmcu=atmega328 --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKH %s
-// LINKH: {{".*ld.*"}} {{.*}} {{"-L.*avr5"}} {{.*}} "-Tdata=0x800100" {{.*}} 
"-latmega328" "-mavr5"
+// LINKH: {{".*ld.*"}} {{.*}} {{"-L.*avr5"}} {{.*}} "-Tdata=0x800100" {{.*}} 
"-latmega328" {{.*}} "-mavr5"
 
 // RUN: %clang -### --target=avr -mmcu=atmega1281 --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKI %s
-// LINKI: {{".*ld.*"}} {{.*}} {{"-L.*avr51"}} {{.*}} "-Tdata=0x800200" {{.*}} 
"-latmega1281" "-mavr51"
+// LINKI: {{".*ld.*"}} {{.*}} {{"-L.*avr51"}} {{.*}} "-Tdata=0x800200" {{.*}} 
"-latmega1281" {{.*}} "-mavr51"
 
 // RUN: %clang -### --target=avr -mmcu=atmega2560 --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKJ %s
-// LINKJ: {{".*ld.*"}} {{.*}} {{"-L.*avr6"}} {{.*}} "-Tdata=0x800200" {{.*}} 
"-latmega2560" "-mavr6"
+// LINKJ: {{".*ld.*"}} {{.*}} {{"-L.*avr6"}} {{.*}} "-Tdata=0x800200" {{.*}} 
"-latmega2560" {{.*}} "-mavr6"
 
 // RUN: %clang -### --target=avr -mmcu=attiny10 --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKK %s
-// LINKK: {{".*ld.*"}} {{.*}} {{"-L.*avrtiny"}} {{.*}} "-Tdata=0x800040" 
{{.*}} "-lattiny10" "-mavrtiny"
+// LINKK: {{".*ld.*"}} {{.*}} {{"-L.*avrtiny"}} {{.*}} "-Tdata=0x800040" 
{{.*}} "-lattiny10" {{.*}} "-mavrtiny"
 
 // RUN: %clang -### --target=avr -mmcu=atxmega16a4 --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKL %s
-// LINKL: {{".*ld.*"}} {{.*}} {{"-L.*avrxmega2"}} {{.*}} "-Tdata=0x802000" 
{{.*}} "-latxmega16a4" "-mavrxmega2"
+// LINKL: {{".*ld.*"}} {{.*}} {{"-L.*avrxmega2"}} {{.*}} "-Tdata=0x802000" 
{{.*}} "-latxmega16a4" {{.*}} "-mavrxmega2"
 
 // RUN: %clang -### --target=avr -mmcu=atxmega64b3 --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKM %s
-// LINKM: {{".*ld.*"}} {{.*}} {{"-L.*avrxmega4"}} {{.*}} "-Tdata=0x802000" 
{{.*}} "-latxmega64b3" "-mavrxmega4"
+// LINKM: {{".*ld.*"}} {{.*}} {{"-L.*avrxmega4"}} {{.*}} "-Tdata=0x802000" 
{{.*}} 

[PATCH] D106674: Runtime for Interop directive

2021-07-27 Thread Sri Hari Krishna Narayanan via Phabricator via cfe-commits
sriharikrishna updated this revision to Diff 362269.
sriharikrishna added a comment.

Runtime for Interop directive


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106674

Files:
  openmp/libomptarget/include/interop.h
  openmp/libomptarget/include/omptarget.h
  openmp/libomptarget/include/omptargetplugin.h
  openmp/libomptarget/plugins/cuda/src/rtl.cpp
  openmp/libomptarget/plugins/exports
  openmp/libomptarget/src/CMakeLists.txt
  openmp/libomptarget/src/exports
  openmp/libomptarget/src/interop.cpp
  openmp/libomptarget/src/private.h
  openmp/libomptarget/src/rtl.cpp
  openmp/libomptarget/src/rtl.h
  openmp/runtime/src/dllexports
  openmp/runtime/src/kmp_ftn_entry.h
  openmp/runtime/src/kmp_ftn_os.h

Index: openmp/runtime/src/kmp_ftn_os.h
===
--- openmp/runtime/src/kmp_ftn_os.h
+++ openmp/runtime/src/kmp_ftn_os.h
@@ -140,6 +140,14 @@
 #define FTN_SET_TEAMS_THREAD_LIMIT omp_set_teams_thread_limit
 #define FTN_GET_TEAMS_THREAD_LIMIT omp_get_teams_thread_limit
 
+#define FTN_GET_NUM_INTEROP_PROPERTIES omp_get_num_interop_properties
+#define FTN_GET_INTEROP_INT omp_get_interop_int
+#define FTN_GET_INTEROP_PTR omp_get_interop_ptr
+#define FTN_GET_INTEROP_STR omp_get_interop_str
+#define FTN_GET_INTEROP_NAME omp_get_interop_name
+#define FTN_GET_INTEROP_TYPE_DESC omp_get_interop_type_desc
+#define FTN_GET_INTEROP_RC_DESC omp_get_interop_rc_desc
+
 #endif /* KMP_FTN_PLAIN */
 
 /*  */
Index: openmp/runtime/src/kmp_ftn_entry.h
===
--- openmp/runtime/src/kmp_ftn_entry.h
+++ openmp/runtime/src/kmp_ftn_entry.h
@@ -1446,6 +1446,135 @@
 #endif
 }
 
+/// TODO: Include the `omp.h` of the current build
+/* OpenMP 5.1 interop */
+typedef intptr_t omp_intptr_t;
+
+/* 0..omp_get_num_interop_properties()-1 are reserved for implementation-defined
+ * properties */
+typedef enum omp_interop_property {
+  omp_ipr_fr_id = -1,
+  omp_ipr_fr_name = -2,
+  omp_ipr_vendor = -3,
+  omp_ipr_vendor_name = -4,
+  omp_ipr_device_num = -5,
+  omp_ipr_platform = -6,
+  omp_ipr_device = -7,
+  omp_ipr_device_context = -8,
+  omp_ipr_targetsync = -9,
+  omp_ipr_first = -9
+} omp_interop_property_t;
+
+#define omp_interop_none 0
+
+typedef enum omp_interop_rc {
+  omp_irc_no_value = 1,
+  omp_irc_success = 0,
+  omp_irc_empty = -1,
+  omp_irc_out_of_range = -2,
+  omp_irc_type_int = -3,
+  omp_irc_type_ptr = -4,
+  omp_irc_type_str = -5,
+  omp_irc_other = -6
+} omp_interop_rc_t;
+
+typedef enum omp_interop_fr {
+  omp_ifr_cuda = 1,
+  omp_ifr_cuda_driver = 2,
+  omp_ifr_opencl = 3,
+  omp_ifr_sycl = 4,
+  omp_ifr_hip = 5,
+  omp_ifr_level_zero = 6,
+  omp_ifr_last = 7
+} omp_interop_fr_t;
+
+typedef void *omp_interop_t;
+
+// libomptarget, if loaded, provides this function
+int FTN_STDCALL FTN_GET_NUM_INTEROP_PROPERTIES(const omp_interop_t interop) {
+  assert(0);
+#if KMP_MIC || KMP_OS_DARWIN || defined(KMP_STUB)
+  return 0;
+#else
+  int (*fptr)(const omp_interop_t);
+  if ((*(void **)() = KMP_DLSYM_NEXT("omp_get_num_interop_properties"))) {
+return (*fptr)(interop);
+  } else { // liboffload & libomptarget don't exist
+return 0;
+  }
+#endif // KMP_MIC || KMP_OS_DARWIN || KMP_OS_WINDOWS || defined(KMP_STUB)
+}
+
+/// TODO Convert FTN_GET_INTEROP_XXX functions into a macro like interop.cpp
+// libomptarget, if loaded, provides this function
+intptr_t FTN_STDCALL FTN_GET_INTEROP_INT(const omp_interop_t interop,
+ omp_interop_property_t property_id,
+ int *err) {
+  intptr_t (*fptr)(const omp_interop_t, omp_interop_property_t, int *);
+  if ((*(void **)() = KMP_DLSYM_NEXT("omp_get_interop_int"))) {
+return (*fptr)(interop, property_id, err);
+  } else { // liboffload & libomptarget don't exist
+return 0;
+  }
+}
+
+// libomptarget, if loaded, provides this function
+void *FTN_STDCALL FTN_GET_INTEROP_PTR(const omp_interop_t interop,
+  omp_interop_property_t property_id,
+  int *err) {
+  void *(*fptr)(const omp_interop_t, omp_interop_property_t, int *);
+  if ((*(void **)() = KMP_DLSYM_NEXT("omp_get_interop_ptr"))) {
+return (*fptr)(interop, property_id, err);
+  } else { // liboffload & libomptarget don't exist
+return (void *)0;
+  }
+}
+
+// libomptarget, if loaded, provides this function
+const char *FTN_STDCALL FTN_GET_INTEROP_STR(const omp_interop_t interop,
+omp_interop_property_t property_id,
+int *err) {
+  const char *(*fptr)(const omp_interop_t, omp_interop_property_t, int *);
+  if ((*(void **)() = KMP_DLSYM_NEXT("omp_get_interop_str"))) {
+return (*fptr)(interop, property_id, err);

[PATCH] D106854: Pass `--start-group` and `--end-group` to the linker when using the AVR toolchain

2021-07-27 Thread Ben Shi via Phabricator via cfe-commits
benshi001 added inline comments.



Comment at: clang/lib/Driver/ToolChains/AVR.cpp:430
 
+CmdArgs.push_back("--end-group");
+

You are appreciated to use 'git show -U99' or 'git diff -U99' for 
better context display.



Comment at: clang/test/Driver/avr-ld.c:23
 // RUN: %clang -### --target=avr -mmcu=atmega328 --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKH %s
-// LINKH: {{".*ld.*"}} {{.*}} {{"-L.*avr5"}} {{.*}} "-Tdata=0x800100" {{.*}} 
"-latmega328" "-mavr5"
+// LINKH: {{".*ld.*"}} {{.*}} {{"-L.*avr5"}} {{.*}} "-Tdata=0x800100" {{.*}} 
"-latmega328" {{.*}} "-mavr5"
 

could you add explict options (which you added) to these tests ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106854

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


[PATCH] D106907: [clang] fix concepts crash on substitution failure during normalization

2021-07-27 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 362268.
mizvekov added a comment.

- Restore assert.
- Fix incorrekt use of emplace.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106907

Files:
  clang/lib/Sema/SemaConcept.cpp
  clang/test/CXX/temp/temp.constr/temp.constr.normal/p1.cpp


Index: clang/test/CXX/temp/temp.constr/temp.constr.normal/p1.cpp
===
--- clang/test/CXX/temp/temp.constr/temp.constr.normal/p1.cpp
+++ clang/test/CXX/temp/temp.constr/temp.constr.normal/p1.cpp
@@ -67,3 +67,18 @@
 
   static_assert((foo<1>(), true));
 }
+
+namespace PR47174 {
+// This checks that we don't crash with a failed substitution on the first 
constrained argument when
+// performing normalization.
+template 
+requires true struct S3; // expected-note {{template is declared here}}
+template 
+requires true struct S3; // expected-error {{class template partial 
specialization is not more specialized than the primary template}}
+
+// Same as above, for the second position (but this was already working).
+template 
+requires true struct S4; // expected-note {{template is declared here}}
+template 
+requires true struct S4; // expected-error {{class template partial 
specialization is not more specialized than the primary template}}
+} // namespace PR47174
Index: clang/lib/Sema/SemaConcept.cpp
===
--- clang/lib/Sema/SemaConcept.cpp
+++ clang/lib/Sema/SemaConcept.cpp
@@ -742,22 +742,15 @@
 NormalizedConstraint::fromConstraintExprs(Sema , NamedDecl *D,
   ArrayRef E) {
   assert(E.size() != 0);
-  auto First = fromConstraintExpr(S, D, E[0]);
-  if (E.size() == 1)
-return First;
-  auto Second = fromConstraintExpr(S, D, E[1]);
-  if (!Second)
+  auto Conjunction = fromConstraintExpr(S, D, E[0]);
+  if (!Conjunction)
 return None;
-  llvm::Optional Conjunction;
-  Conjunction.emplace(S.Context, std::move(*First), std::move(*Second),
-  CCK_Conjunction);
-  for (unsigned I = 2; I < E.size(); ++I) {
+  for (unsigned I = 1; I < E.size(); ++I) {
 auto Next = fromConstraintExpr(S, D, E[I]);
 if (!Next)
-  return llvm::Optional{};
-NormalizedConstraint NewConjunction(S.Context, std::move(*Conjunction),
+  return None;
+*Conjunction = NormalizedConstraint(S.Context, std::move(*Conjunction),
 std::move(*Next), CCK_Conjunction);
-*Conjunction = std::move(NewConjunction);
   }
   return Conjunction;
 }


Index: clang/test/CXX/temp/temp.constr/temp.constr.normal/p1.cpp
===
--- clang/test/CXX/temp/temp.constr/temp.constr.normal/p1.cpp
+++ clang/test/CXX/temp/temp.constr/temp.constr.normal/p1.cpp
@@ -67,3 +67,18 @@
 
   static_assert((foo<1>(), true));
 }
+
+namespace PR47174 {
+// This checks that we don't crash with a failed substitution on the first constrained argument when
+// performing normalization.
+template 
+requires true struct S3; // expected-note {{template is declared here}}
+template 
+requires true struct S3; // expected-error {{class template partial specialization is not more specialized than the primary template}}
+
+// Same as above, for the second position (but this was already working).
+template 
+requires true struct S4; // expected-note {{template is declared here}}
+template 
+requires true struct S4; // expected-error {{class template partial specialization is not more specialized than the primary template}}
+} // namespace PR47174
Index: clang/lib/Sema/SemaConcept.cpp
===
--- clang/lib/Sema/SemaConcept.cpp
+++ clang/lib/Sema/SemaConcept.cpp
@@ -742,22 +742,15 @@
 NormalizedConstraint::fromConstraintExprs(Sema , NamedDecl *D,
   ArrayRef E) {
   assert(E.size() != 0);
-  auto First = fromConstraintExpr(S, D, E[0]);
-  if (E.size() == 1)
-return First;
-  auto Second = fromConstraintExpr(S, D, E[1]);
-  if (!Second)
+  auto Conjunction = fromConstraintExpr(S, D, E[0]);
+  if (!Conjunction)
 return None;
-  llvm::Optional Conjunction;
-  Conjunction.emplace(S.Context, std::move(*First), std::move(*Second),
-  CCK_Conjunction);
-  for (unsigned I = 2; I < E.size(); ++I) {
+  for (unsigned I = 1; I < E.size(); ++I) {
 auto Next = fromConstraintExpr(S, D, E[I]);
 if (!Next)
-  return llvm::Optional{};
-NormalizedConstraint NewConjunction(S.Context, std::move(*Conjunction),
+  return None;
+*Conjunction = NormalizedConstraint(S.Context, std::move(*Conjunction),
 std::move(*Next), CCK_Conjunction);
-*Conjunction = std::move(NewConjunction);
   }
   return Conjunction;
 }
___

[PATCH] D106753: ConvertUTF: Created wrapper convertUTF32ToUTF8String

2021-07-27 Thread Marcus Johnson via Phabricator via cfe-commits
MarcusJohnson91 added inline comments.



Comment at: llvm/lib/Support/ConvertUTFWrapper.cpp:176
+  // enough that we can fit a null terminator without reallocating.
+  Out.resize(SrcBytes.size() * UNI_MAX_UTF8_BYTES_PER_CODE_POINT + 1);
+  UTF8 *Dst = reinterpret_cast([0]);

efriedma wrote:
> `SrcBytes.size() * UNI_MAX_UTF8_BYTES_PER_CODE_POINT + 1` seems like way too 
> much memory.
I copied that from the UTF16 code


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

https://reviews.llvm.org/D106753

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


[PATCH] D106674: Runtime for Interop directive

2021-07-27 Thread Sri Hari Krishna Narayanan via Phabricator via cfe-commits
sriharikrishna updated this revision to Diff 362266.
sriharikrishna added a comment.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya.
Herald added projects: clang, LLVM.

Runtime for Interop directive


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106674

Files:
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/OpenMP/interop_irbuilder.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPConstants.h
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  openmp/libomptarget/include/interop.h
  openmp/libomptarget/include/omptarget.h
  openmp/libomptarget/include/omptargetplugin.h
  openmp/libomptarget/plugins/cuda/src/rtl.cpp
  openmp/libomptarget/plugins/exports
  openmp/libomptarget/src/CMakeLists.txt
  openmp/libomptarget/src/exports
  openmp/libomptarget/src/interop.cpp
  openmp/libomptarget/src/private.h
  openmp/libomptarget/src/rtl.cpp
  openmp/libomptarget/src/rtl.h
  openmp/runtime/src/dllexports
  openmp/runtime/src/kmp_ftn_entry.h
  openmp/runtime/src/kmp_ftn_os.h

Index: openmp/runtime/src/kmp_ftn_os.h
===
--- openmp/runtime/src/kmp_ftn_os.h
+++ openmp/runtime/src/kmp_ftn_os.h
@@ -140,6 +140,14 @@
 #define FTN_SET_TEAMS_THREAD_LIMIT omp_set_teams_thread_limit
 #define FTN_GET_TEAMS_THREAD_LIMIT omp_get_teams_thread_limit
 
+#define FTN_GET_NUM_INTEROP_PROPERTIES omp_get_num_interop_properties
+#define FTN_GET_INTEROP_INT omp_get_interop_int
+#define FTN_GET_INTEROP_PTR omp_get_interop_ptr
+#define FTN_GET_INTEROP_STR omp_get_interop_str
+#define FTN_GET_INTEROP_NAME omp_get_interop_name
+#define FTN_GET_INTEROP_TYPE_DESC omp_get_interop_type_desc
+#define FTN_GET_INTEROP_RC_DESC omp_get_interop_rc_desc
+
 #endif /* KMP_FTN_PLAIN */
 
 /*  */
Index: openmp/runtime/src/kmp_ftn_entry.h
===
--- openmp/runtime/src/kmp_ftn_entry.h
+++ openmp/runtime/src/kmp_ftn_entry.h
@@ -1446,6 +1446,135 @@
 #endif
 }
 
+/// TODO: Include the `omp.h` of the current build
+/* OpenMP 5.1 interop */
+typedef intptr_t omp_intptr_t;
+
+/* 0..omp_get_num_interop_properties()-1 are reserved for implementation-defined
+ * properties */
+typedef enum omp_interop_property {
+  omp_ipr_fr_id = -1,
+  omp_ipr_fr_name = -2,
+  omp_ipr_vendor = -3,
+  omp_ipr_vendor_name = -4,
+  omp_ipr_device_num = -5,
+  omp_ipr_platform = -6,
+  omp_ipr_device = -7,
+  omp_ipr_device_context = -8,
+  omp_ipr_targetsync = -9,
+  omp_ipr_first = -9
+} omp_interop_property_t;
+
+#define omp_interop_none 0
+
+typedef enum omp_interop_rc {
+  omp_irc_no_value = 1,
+  omp_irc_success = 0,
+  omp_irc_empty = -1,
+  omp_irc_out_of_range = -2,
+  omp_irc_type_int = -3,
+  omp_irc_type_ptr = -4,
+  omp_irc_type_str = -5,
+  omp_irc_other = -6
+} omp_interop_rc_t;
+
+typedef enum omp_interop_fr {
+  omp_ifr_cuda = 1,
+  omp_ifr_cuda_driver = 2,
+  omp_ifr_opencl = 3,
+  omp_ifr_sycl = 4,
+  omp_ifr_hip = 5,
+  omp_ifr_level_zero = 6,
+  omp_ifr_last = 7
+} omp_interop_fr_t;
+
+typedef void *omp_interop_t;
+
+// libomptarget, if loaded, provides this function
+int FTN_STDCALL FTN_GET_NUM_INTEROP_PROPERTIES(const omp_interop_t interop) {
+  assert(0);
+#if KMP_MIC || KMP_OS_DARWIN || defined(KMP_STUB)
+  return 0;
+#else
+  int (*fptr)(const omp_interop_t);
+  if ((*(void **)() = KMP_DLSYM_NEXT("omp_get_num_interop_properties"))) {
+return (*fptr)(interop);
+  } else { // liboffload & libomptarget don't exist
+return 0;
+  }
+#endif // KMP_MIC || KMP_OS_DARWIN || KMP_OS_WINDOWS || defined(KMP_STUB)
+}
+
+/// TODO Convert FTN_GET_INTEROP_XXX functions into a macro like interop.cpp
+// libomptarget, if loaded, provides this function
+intptr_t FTN_STDCALL FTN_GET_INTEROP_INT(const omp_interop_t interop,
+ omp_interop_property_t property_id,
+ int *err) {
+  intptr_t (*fptr)(const omp_interop_t, omp_interop_property_t, int *);
+  if ((*(void **)() = KMP_DLSYM_NEXT("omp_get_interop_int"))) {
+return (*fptr)(interop, property_id, err);
+  } else { // liboffload & libomptarget don't exist
+return 0;
+  }
+}
+
+// libomptarget, if loaded, provides this function
+void *FTN_STDCALL FTN_GET_INTEROP_PTR(const omp_interop_t interop,
+  omp_interop_property_t property_id,
+  int *err) {
+  void *(*fptr)(const omp_interop_t, omp_interop_property_t, int *);
+  if ((*(void **)() = KMP_DLSYM_NEXT("omp_get_interop_ptr"))) {
+return (*fptr)(interop, property_id, err);
+  } else { // liboffload & libomptarget don't exist
+return (void *)0;
+  }
+}
+
+// 

[PATCH] D106431: [clang-tidy] Fix cppcoreguidelines-init-variables with enum judgement

2021-07-27 Thread Qing Shan Zhang via Phabricator via cfe-commits
steven.zhang added a comment.

In D106431#2907688 , @whisperity 
wrote:

> In D106431#2907002 , @Sockke wrote:
>
>> Any thoughts?  : )
>
> First, let's first fix that we should still warn for the uninitialised `enum` 
> case, without a FixIt. That's the issue at hand, right now, Clang-Tidy 
> generates, as you identified, broken output. We can discuss the later steps 
> after this is fixed. Please implement this logic, and update the patch, so we 
> have a snapshot of how that would look like and the thing working.

+1

> Afterwards, as Aaron suggested:
>
> In D106431#2896441 , @aaron.ballman 
> wrote:
>
>> for enumerations, we could issue up to two fix-its on a note, one for the 
>> first and one for the last enumerator in an enumeration (and if the enum 
>> only contains one enumerator, there's only one fix-it to generate which 
>> suggests it could be on the warning rather than a note, but that seems like 
>> a lot of trouble for an unlikely scenario). However, I don't recall how 
>> clang-tidy interacts with fix-its on notes off the top of my head, so I'm 
>> making an assumption that clang-tidy's automatic fixit applying mode handles 
>> notes the same way as clang and we should double-check that assumption.
>
> This might require nontrivial changes to the check's code, and investigating 
> the potential problem with automated fix-it application when multiple 
> conflicting fix-its are given on a **note** (not a //warning// line).
>
> I think we all would be fine with only doing the first step (reintroduce the 
> warning, without a fixit) in this patch, so it can be merged and hit the the 
> mainline code quickly. The next step can be its own patch. 
>
> 
>
> In addition, I wager that adding a line about this fix to the release notes 
> at `clang-tools-extra/docs/ReleaseNotes.rst` is a good option, I can imagine 
> people having turned this check off due to it being broken on enums.

I think, the intention of the auto fix for such case is to make the program's 
behavior well-defined, not with some uninitialize value that cannot be 
predicted. It is ok as far as we select any enumerator to initialize it from my 
understanding. We should separate it into anther patch of cause.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106431

___
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-27 Thread Dave Airlie via Phabricator via cfe-commits
airlied added a comment.

In D106778#2904509 , @Anastasia wrote:

> 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

Anastasia wrote:
> can we annotate `#endif` with a comment, please to improve readability? The 
> same applies to other places.
Isn't this the same problem we talked about before? how to annotate

#if defined(__opencl_c_generic_address_space)

#else 

#endif 

does it make sense to put //defined(__opencl_c_generic_address_space) on the 
endif?


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] D106778: [OpenCL] opencl-c.h: add CL 3.0 non-generic address space atomics

2021-07-27 Thread Dave Airlie via Phabricator via cfe-commits
airlied added a comment.

In D106778#2904509 , @Anastasia wrote:

> 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.

The whole atomic section is wrapped in
#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)

is that not good enough coverage?

I'll add the endif fixes.


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] D98709: [clang-tidy] New feature --skip-headers, part 1, LocFilter

2021-07-27 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
chh updated this revision to Diff 362262.
chh added a comment.

apply clang-format


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

https://reviews.llvm.org/D98709

Files:
  clang-tools-extra/clang-tidy/ClangTidy.cpp
  clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
  clang-tools-extra/clang-tidy/ClangTidyCheck.h
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/clang-tidy/ClangTidyModule.cpp
  clang-tools-extra/clang-tidy/ClangTidyModule.h
  clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
  clang-tools-extra/clang-tidy/ClangTidyOptions.h
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/ForwardDeclarationNamespaceCheck.cpp
  clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
  clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/bugprone-forward-declaration-namespace/a.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/bugprone-forward-declaration-namespace/b.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/skip-headers/a.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/skip-headers/b.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/skip-headers/c1.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/skip-headers/my_header1.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/skip-headers/my_header2.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/unused-using-decls.h
  clang-tools-extra/test/clang-tidy/checkers/abseil-no-internal-dependencies.cpp
  
clang-tools-extra/test/clang-tidy/checkers/abseil-upgrade-duration-conversions.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-forward-declaration-namespace-header.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-forward-declaration-namespace.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-reserved-identifier.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-include.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-interfaces-global-init.cpp
  clang-tools-extra/test/clang-tidy/checkers/google-namespaces.cpp
  clang-tools-extra/test/clang-tidy/checkers/google-objc-function-naming.m
  clang-tools-extra/test/clang-tidy/checkers/llvm-include-order.cpp
  
clang-tools-extra/test/clang-tidy/checkers/llvm-prefer-register-over-unsigned.cpp
  
clang-tools-extra/test/clang-tidy/checkers/llvmlibc-implementation-in-namespace.cpp
  
clang-tools-extra/test/clang-tidy/checkers/llvmlibc-restrict-system-libc-headers.cpp
  clang-tools-extra/test/clang-tidy/checkers/misc-no-recursion.cpp
  clang-tools-extra/test/clang-tidy/checkers/misc-unused-using-decls.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-cxx03.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-cxx11.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize-pass-by-value-header.cpp
  
clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-allow.cpp
  
clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-disallow.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-simplify-bool-expr-chained-conditional-assignment.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-simplify-bool-expr-chained-conditional-return.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-simplify-bool-expr-members.cpp
  clang-tools-extra/test/clang-tidy/checkers/readability-simplify-bool-expr.cpp
  clang-tools-extra/test/clang-tidy/checkers/skip-headers-2.cpp
  clang-tools-extra/test/clang-tidy/checkers/skip-headers-3.cpp
  clang-tools-extra/test/clang-tidy/checkers/skip-headers.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/file-filter-symlinks.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/file-filter.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/line-filter.cpp
  clang/include/clang/ASTMatchers/ASTMatchFinder.h
  clang/lib/ASTMatchers/ASTMatchFinder.cpp

Index: clang/lib/ASTMatchers/ASTMatchFinder.cpp
===
--- clang/lib/ASTMatchers/ASTMatchFinder.cpp
+++ clang/lib/ASTMatchers/ASTMatchFinder.cpp
@@ -1202,6 +1202,8 @@
   if (!DeclNode) {
 return true;
   }
+  if (Options.Filter && Options.Filter->skipLocation(DeclNode->getLocation()))
+return true;
 
   bool ScopedTraversal =
   TraversingASTNodeNotSpelledInSource || DeclNode->isImplicit();
@@ -1232,6 +1234,13 @@
   if (!StmtNode) {
 return true;
   }
+  // When a function call is in the main file or wanted header files,
+  // the call site maybe in the Decl that is not to be skipped.
+  // But the statements of the called function or parameter default expressions
+  // should be skipped. So here we need to call skipLocation here.
+  if (Options.Filter && Options.Filter->skipLocation(StmtNode->getBeginLoc()))
+return true;
+
   bool 

[PATCH] D106033: [OpenMP] Folding threadLimit and numThreads when single value in kernels

2021-07-27 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 rG5ab6aedda9d9: [OpenMP] Folding threadLimit and numThreads 
when single value in kernels (authored by Jose M Monsalve Diaz 
jmonsalved...@anl.gov, committed by tianshilei1992).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106033

Files:
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  llvm/lib/Transforms/IPO/OpenMPOpt.cpp
  llvm/test/Transforms/OpenMP/get_hardware_num_threads_in_block_fold.ll
  openmp/libomptarget/deviceRTLs/target_interface.h

Index: openmp/libomptarget/deviceRTLs/target_interface.h
===
--- openmp/libomptarget/deviceRTLs/target_interface.h
+++ openmp/libomptarget/deviceRTLs/target_interface.h
@@ -18,8 +18,8 @@
 // Calls to the NVPTX layer (assuming 1D layout)
 EXTERN int __kmpc_get_hardware_thread_id_in_block();
 EXTERN int GetBlockIdInKernel();
-EXTERN int __kmpc_get_hardware_num_blocks();
-EXTERN int __kmpc_get_hardware_num_threads_in_block();
+EXTERN NOINLINE int __kmpc_get_hardware_num_blocks();
+EXTERN NOINLINE int __kmpc_get_hardware_num_threads_in_block();
 EXTERN unsigned GetWarpId();
 EXTERN unsigned GetWarpSize();
 EXTERN unsigned GetLaneId();
Index: llvm/test/Transforms/OpenMP/get_hardware_num_threads_in_block_fold.ll
===
--- /dev/null
+++ llvm/test/Transforms/OpenMP/get_hardware_num_threads_in_block_fold.ll
@@ -0,0 +1,128 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-globals
+; RUN: opt -S -passes=openmp-opt < %s | FileCheck %s
+target triple = "nvptx64"
+
+%struct.ident_t = type { i32, i32, i32, i32, i8* }
+
+@kernel0_exec_mode = weak constant i8 1
+
+@G = external global i32
+;.
+; CHECK: @[[G:[a-zA-Z0-9_$"\\.-]+]] = external global i32
+;.
+define weak void @kernel0() #0 {
+; CHECK-LABEL: define {{[^@]+}}@kernel0()
+; CHECK: #[[ATTR0:[0-9]+]] {
+; CHECK-NEXT:[[I:%.*]] = call i32 @__kmpc_target_init(%struct.ident_t* null, i1 true, i1 false, i1 false)
+; CHECK-NEXT:call void @helper0()
+; CHECK-NEXT:call void @helper1()
+; CHECK-NEXT:call void @helper2()
+; CHECK-NEXT:call void @__kmpc_target_deinit(%struct.ident_t* null, i1 true, i1 false)
+; CHECK-NEXT:ret void
+;
+  %i = call i32 @__kmpc_target_init(%struct.ident_t* null, i1 true, i1 false, i1 false)
+  call void @helper0()
+  call void @helper1()
+  call void @helper2()
+  call void @__kmpc_target_deinit(%struct.ident_t* null, i1 true, i1 false)
+  ret void
+}
+
+@kernel1_exec_mode = weak constant i8 1
+
+define weak void @kernel1() #0 {
+; CHECK-LABEL: define {{[^@]+}}@kernel1()
+; CHECK: #[[ATTR0]] {
+; CHECK-NEXT:[[I:%.*]] = call i32 @__kmpc_target_init(%struct.ident_t* null, i1 true, i1 false, i1 false)
+; CHECK-NEXT:call void @helper1()
+; CHECK-NEXT:call void @__kmpc_target_deinit(%struct.ident_t* null, i1 false, i1 false)
+; CHECK-NEXT:ret void
+;
+  %i = call i32 @__kmpc_target_init(%struct.ident_t* null, i1 true, i1 false, i1 false)
+  call void @helper1()
+  call void @__kmpc_target_deinit(%struct.ident_t* null, i1 false, i1 false)
+  ret void
+}
+
+@kernel2_exec_mode = weak constant i8 1
+
+define weak void @kernel2() #0 {
+; CHECK-LABEL: define {{[^@]+}}@kernel2()
+; CHECK: #[[ATTR0]] {
+; CHECK-NEXT:[[I:%.*]] = call i32 @__kmpc_target_init(%struct.ident_t* null, i1 false, i1 false, i1 false)
+; CHECK-NEXT:call void @helper0()
+; CHECK-NEXT:call void @helper1()
+; CHECK-NEXT:call void @helper2()
+; CHECK-NEXT:call void @__kmpc_target_deinit(%struct.ident_t* null, i1 false, i1 false)
+; CHECK-NEXT:ret void
+;
+  %i = call i32 @__kmpc_target_init(%struct.ident_t* null, i1 false, i1 false, i1 false)
+  call void @helper0()
+  call void @helper1()
+  call void @helper2()
+  call void @__kmpc_target_deinit(%struct.ident_t* null, i1 false, i1 false)
+  ret void
+}
+
+define internal void @helper0() {
+; CHECK-LABEL: define {{[^@]+}}@helper0() {{#[0-9]+}} {
+; CHECK-NEXT:store i32 666, i32* @G, align 4
+; CHECK-NEXT:ret void
+;
+  %threadLimit = call i32 @__kmpc_get_hardware_num_threads_in_block()
+  store i32 %threadLimit, i32* @G
+  ret void
+}
+
+define internal void @helper1() {
+; CHECK-LABEL: define {{[^@]+}}@helper1() {{#[0-9]+}} {
+; CHECK-NEXT:br label [[F:%.*]]
+; CHECK:   t:
+; CHECK-NEXT:unreachable
+; CHECK:   f:
+; CHECK-NEXT:ret void
+;
+  %threadLimit = call i32 @__kmpc_get_hardware_num_threads_in_block()
+  %c = icmp eq i32 %threadLimit, 666
+  br i1 %c, label %f, label %t
+t:
+  call void @helper0()
+  ret void
+f:
+  ret void
+}
+
+define internal void @helper2() {
+; CHECK-LABEL: define {{[^@]+}}@helper2() {{#[0-9]+}} {
+; CHECK-NEXT:store i32 666, i32* @G
+; CHECK-NEXT:

[PATCH] D100713: [clang] NFC: refactor multiple implementations of getDecltypeForParenthesizedExpr

2021-07-27 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov marked 2 inline comments as done.
mizvekov added inline comments.



Comment at: clang/lib/Sema/SemaExprCXX.cpp:5845
+  if (!To->isRValue()) {
+QualType T = Self.Context.getDecltypeForParenthesizedExpr(To);
 InitializedEntity Entity = InitializedEntity::InitializeTemporary(T);

rsmith wrote:
> mizvekov wrote:
> > aaronpuchert wrote:
> > > mizvekov wrote:
> > > > aaronpuchert wrote:
> > > > > The quote doesn't reference parenthesized expressions, isn't this 
> > > > > just coincidentally the same thing?
> > > > It's fundamentally the same thing. The 
> > > > `getDecltypeForParenthesizedExpr` name is what I tried to keep, I don't 
> > > > have better ideas there.
> > > What this is doing is pointwise equal to 
> > > `getDecltypeForParenthesizedExpr`, but there is no parenthesized 
> > > expression, and no `decltype`. There is a quote from the standard that 
> > > defines this separately (by now this seems to be 
> > > [[http://eel.is/c++draft/expr.cond#4|expr.cond#4]]), and there are some 
> > > differences especially in the prvalue case. So I'm not sure this helps.
> > Here for XValue and and LValue, the rules are exactly the same as 
> > https://eel.is/c++draft/dcl.type.decltype#1.
> > And the original code here even already special cases it...
> > 
> > I am sure there is some way we can agree that we should not repeat the code 
> > just because the standard did not bother to give a name to this part of the 
> > rules... And again I think it is no coincidence that it makes sense to 
> > perform the same changes in all these cases.
> Maybe we can find a more general name for this functionality that doesn't 
> mention `decltype`. Perhaps something like `getReferenceQualifiedType`?
Yes that is a good name, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100713

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


[PATCH] D100713: [clang] NFC: refactor multiple implementations of getDecltypeForParenthesizedExpr

2021-07-27 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 362257.
mizvekov added a comment.

- rename to getReferenceQualifiedType.
- Move the null expression special case out of the function, back to the 
original user.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100713

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ExprObjC.cpp
  clang/lib/Sema/SemaConcept.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaType.cpp
  clang/lib/StaticAnalyzer/Core/CallEvent.cpp

Index: clang/lib/StaticAnalyzer/Core/CallEvent.cpp
===
--- clang/lib/StaticAnalyzer/Core/CallEvent.cpp
+++ clang/lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -73,26 +73,7 @@
   const Expr *E = getOriginExpr();
   if (!E)
 return Ctx.VoidTy;
-  assert(E);
-
-  QualType ResultTy = E->getType();
-
-  // A function that returns a reference to 'int' will have a result type
-  // of simply 'int'. Check the origin expr's value kind to recover the
-  // proper type.
-  switch (E->getValueKind()) {
-  case VK_LValue:
-ResultTy = Ctx.getLValueReferenceType(ResultTy);
-break;
-  case VK_XValue:
-ResultTy = Ctx.getRValueReferenceType(ResultTy);
-break;
-  case VK_PRValue:
-// No adjustment is necessary.
-break;
-  }
-
-  return ResultTy;
+  return Ctx.getReferenceQualifiedType(E);
 }
 
 static bool isCallback(QualType T) {
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -8891,29 +8891,6 @@
   return Context.getTypeOfExprType(E);
 }
 
-/// getDecltypeForParenthesizedExpr - Given an expr, will return the type for
-/// that expression, as in [dcl.type.simple]p4 but without taking id-expressions
-/// and class member access into account.
-QualType Sema::getDecltypeForParenthesizedExpr(Expr *E) {
-  // C++11 [dcl.type.simple]p4:
-  //   [...]
-  QualType T = E->getType();
-  switch (E->getValueKind()) {
-  // - otherwise, if e is an xvalue, decltype(e) is T&&, where T is the
-  //   type of e;
-  case VK_XValue:
-return Context.getRValueReferenceType(T);
-  // - otherwise, if e is an lvalue, decltype(e) is T&, where T is the
-  //   type of e;
-  case VK_LValue:
-return Context.getLValueReferenceType(T);
-  //  - otherwise, decltype(e) is the type of e.
-  case VK_PRValue:
-return T;
-  }
-  llvm_unreachable("Unknown value kind");
-}
-
 /// getDecltypeForExpr - Given an expr, will return the decltype for
 /// that expression, according to the rules in C++11
 /// [dcl.type.simple]p4 and C++11 [expr.lambda.prim]p18.
@@ -8983,7 +8960,7 @@
 }
   }
 
-  return S.getDecltypeForParenthesizedExpr(E);
+  return S.Context.getReferenceQualifiedType(E);
 }
 
 QualType Sema::BuildDecltypeType(Expr *E, SourceLocation Loc,
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -5891,10 +5891,8 @@
   //   -- If E2 is an xvalue: E1 can be converted to match E2 if E1 can be
   //  implicitly converted to the type "rvalue reference to R2", subject to
   //  the constraint that the reference must bind directly.
-  if (To->isLValue() || To->isXValue()) {
-QualType T = To->isLValue() ? Self.Context.getLValueReferenceType(ToType)
-: Self.Context.getRValueReferenceType(ToType);
-
+  if (To->isGLValue()) {
+QualType T = Self.Context.getReferenceQualifiedType(To);
 InitializedEntity Entity = InitializedEntity::InitializeTemporary(T);
 
 InitializationSequence InitSeq(Self, Entity, Kind, From);
@@ -8743,7 +8741,7 @@
 TemplateParameterList *TPL =
 ReturnTypeRequirement.getTypeConstraintTemplateParameterList();
 QualType MatchedType =
-getDecltypeForParenthesizedExpr(E).getCanonicalType();
+Context.getReferenceQualifiedType(E).getCanonicalType();
 llvm::SmallVector Args;
 Args.push_back(TemplateArgument(MatchedType));
 TemplateArgumentList TAL(TemplateArgumentList::OnStack, Args);
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -19371,14 +19371,7 @@
 if (ParamTypes.empty() && Proto->isVariadic()) { // the special case
   ArgTypes.reserve(E->getNumArgs());
   for (unsigned i = 0, e = E->getNumArgs(); i != e; ++i) {
-Expr *Arg = E->getArg(i);
-QualType ArgType = Arg->getType();
-if (E->isLValue()) {
-  ArgType = S.Context.getLValueReferenceType(ArgType);
-} else if (E->isXValue()) {
-  ArgType = S.Context.getRValueReferenceType(ArgType);
-}
-

[PATCH] D100733: [clang] NFC: change uses of `Expr->getValueKind` into `is?Value`

2021-07-27 Thread Matheus Izvekov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4819b751bd87: [clang] NFC: change uses of 
`Expr-getValueKind` into `is?Value` (authored by mizvekov).

Changed prior to commit:
  https://reviews.llvm.org/D100733?vs=351123=362254#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100733

Files:
  clang/include/clang/AST/ExprCXX.h
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprClassification.cpp
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaCoroutine.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaInit.cpp

Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -5832,7 +5832,7 @@
  Entity.getType()) &&
 canPerformArrayCopy(Entity)) {
   // If source is a prvalue, use it directly.
-  if (Initializer->getValueKind() == VK_PRValue) {
+  if (Initializer->isPRValue()) {
 AddArrayInitStep(DestType, /*IsGNUExtension*/false);
 return;
   }
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -6897,7 +6897,7 @@
   assert(!isa(E) && "Double-bound temporary?");
 
   // If the result is a glvalue, we shouldn't bind it.
-  if (!E->isPRValue())
+  if (E->isGLValue())
 return E;
 
   // In ARC, calls that return a retainable type can return retained,
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -5546,7 +5546,7 @@
 BaseExpr = LHSExp;// vectors: V[123]
 IndexExpr = RHSExp;
 // We apply C++ DR1213 to vector subscripting too.
-if (getLangOpts().CPlusPlus11 && LHSExp->getValueKind() == VK_PRValue) {
+if (getLangOpts().CPlusPlus11 && LHSExp->isPRValue()) {
   ExprResult Materialized = TemporaryMaterializationConversion(LHSExp);
   if (Materialized.isInvalid())
 return ExprError();
@@ -10159,7 +10159,7 @@
 RHSType, DiagID))
 return RHSType;
 } else {
-  if (LHS.get()->getValueKind() == VK_LValue ||
+  if (LHS.get()->isLValue() ||
   !tryGCCVectorConvertAndSplat(*this, , ))
 return RHSType;
 }
@@ -14939,7 +14939,7 @@
 // complex l-values to ordinary l-values and all other values to r-values.
 if (Input.isInvalid()) return ExprError();
 if (Opc == UO_Real || Input.get()->getType()->isAnyComplexType()) {
-  if (Input.get()->getValueKind() != VK_PRValue &&
+  if (Input.get()->isGLValue() &&
   Input.get()->getObjectKind() == OK_Ordinary)
 VK = Input.get()->getValueKind();
 } else if (!getLangOpts().CPlusPlus) {
@@ -19176,7 +19176,7 @@
   Expr *SubExpr = SubResult.get();
   E->setSubExpr(SubExpr);
   E->setType(S.Context.getPointerType(SubExpr->getType()));
-  assert(E->getValueKind() == VK_PRValue);
+  assert(E->isPRValue());
   assert(E->getObjectKind() == OK_Ordinary);
   return E;
 }
@@ -19186,7 +19186,7 @@
 
   E->setType(VD->getType());
 
-  assert(E->getValueKind() == VK_PRValue);
+  assert(E->isPRValue());
   if (S.getLangOpts().CPlusPlus &&
   !(isa(VD) &&
 cast(VD)->isInstance()))
@@ -19277,7 +19277,7 @@
 return ExprError();
   }
 
-  assert(E->getValueKind() == VK_PRValue);
+  assert(E->isPRValue());
   assert(E->getObjectKind() == OK_Ordinary);
   E->setType(DestType);
 
@@ -19437,7 +19437,7 @@
 ExprResult RebuildUnknownAnyExpr::VisitImplicitCastExpr(ImplicitCastExpr *E) {
   // The only case we should ever see here is a function-to-pointer decay.
   if (E->getCastKind() == CK_FunctionToPointerDecay) {
-assert(E->getValueKind() == VK_PRValue);
+assert(E->isPRValue());
 assert(E->getObjectKind() == OK_Ordinary);
 
 E->setType(DestType);
@@ -19451,7 +19451,7 @@
 E->setSubExpr(Result.get());
 return E;
   } else if (E->getCastKind() == CK_LValueToRValue) {
-assert(E->getValueKind() == VK_PRValue);
+assert(E->isPRValue());
 assert(E->getObjectKind() == OK_Ordinary);
 
 assert(isa(E->getType()));
Index: clang/lib/Sema/SemaCoroutine.cpp
===
--- clang/lib/Sema/SemaCoroutine.cpp
+++ clang/lib/Sema/SemaCoroutine.cpp
@@ -877,7 +877,7 @@
 
   // If the expression is a temporary, materialize it as an lvalue so that we
   // can use it multiple times.
-  if (E->getValueKind() == VK_PRValue)
+  if (E->isPRValue())
 E = CreateMaterializeTemporaryExpr(E->getType(), E, true);
 
   // The location of the 

[clang] 4819b75 - [clang] NFC: change uses of `Expr->getValueKind` into `is?Value`

2021-07-27 Thread Matheus Izvekov via cfe-commits

Author: Matheus Izvekov
Date: 2021-07-28T03:09:31+02:00
New Revision: 4819b751bd875f458eb0060f7c586aa9ac41965c

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

LOG: [clang] NFC: change uses of `Expr->getValueKind` into `is?Value`

Signed-off-by: Matheus Izvekov 

Reviewed By: rsmith

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

Added: 


Modified: 
clang/include/clang/AST/ExprCXX.h
clang/lib/AST/Expr.cpp
clang/lib/AST/ExprClassification.cpp
clang/lib/CodeGen/CGDecl.cpp
clang/lib/CodeGen/CGExprScalar.cpp
clang/lib/Sema/Sema.cpp
clang/lib/Sema/SemaCoroutine.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaExprCXX.cpp
clang/lib/Sema/SemaInit.cpp

Removed: 




diff  --git a/clang/include/clang/AST/ExprCXX.h 
b/clang/include/clang/AST/ExprCXX.h
index 2626f9b925962..161287adce4ca 100644
--- a/clang/include/clang/AST/ExprCXX.h
+++ b/clang/include/clang/AST/ExprCXX.h
@@ -4528,9 +4528,7 @@ class MaterializeTemporaryExpr : public Expr {
 
   /// Determine whether this materialized temporary is bound to an
   /// lvalue reference; otherwise, it's bound to an rvalue reference.
-  bool isBoundToLvalueReference() const {
-return getValueKind() == VK_LValue;
-  }
+  bool isBoundToLvalueReference() const { return isLValue(); }
 
   /// Determine whether this temporary object is usable in constant
   /// expressions, as specified in C++20 [expr.const]p4.

diff  --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index ebf87618e1277..e8b4aaa2b81e6 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -2406,7 +2406,7 @@ bool Expr::isReadIfDiscardedInCPlusPlus11() const {
   // In C++11, discarded-value expressions of a certain form are special,
   // according to [expr]p10:
   //   The lvalue-to-rvalue conversion (4.1) is applied only if the
-  //   expression is an lvalue of volatile-qualified type and it has
+  //   expression is a glvalue of volatile-qualified type and it has
   //   one of the following forms:
   if (!isGLValue() || !getType().isVolatileQualified())
 return false;
@@ -3874,8 +3874,7 @@ Expr::isNullPointerConstant(ASTContext ,
 const ObjCPropertyRefExpr *Expr::getObjCProperty() const {
   const Expr *E = this;
   while (true) {
-assert((E->getValueKind() == VK_LValue &&
-E->getObjectKind() == OK_ObjCProperty) &&
+assert((E->isLValue() && E->getObjectKind() == OK_ObjCProperty) &&
"expression is not a property reference");
 E = E->IgnoreParenCasts();
 if (const BinaryOperator *BO = dyn_cast(E)) {
@@ -3914,7 +3913,7 @@ FieldDecl *Expr::getSourceBitField() {
 
   while (ImplicitCastExpr *ICE = dyn_cast(E)) {
 if (ICE->getCastKind() == CK_LValueToRValue ||
-(ICE->getValueKind() != VK_PRValue && ICE->getCastKind() == CK_NoOp))
+(ICE->isGLValue() && ICE->getCastKind() == CK_NoOp))
   E = ICE->getSubExpr()->IgnoreParens();
 else
   break;
@@ -3961,7 +3960,7 @@ bool Expr::refersToVectorElement() const {
   const Expr *E = this->IgnoreParens();
 
   while (const ImplicitCastExpr *ICE = dyn_cast(E)) {
-if (ICE->getValueKind() != VK_PRValue && ICE->getCastKind() == CK_NoOp)
+if (ICE->isGLValue() && ICE->getCastKind() == CK_NoOp)
   E = ICE->getSubExpr()->IgnoreParens();
 else
   break;

diff  --git a/clang/lib/AST/ExprClassification.cpp 
b/clang/lib/AST/ExprClassification.cpp
index 07fb44ceef2a4..6998e28fd2ea8 100644
--- a/clang/lib/AST/ExprClassification.cpp
+++ b/clang/lib/AST/ExprClassification.cpp
@@ -53,8 +53,12 @@ Cl Expr::ClassifyImpl(ASTContext , SourceLocation *Loc) 
const {
 
   // Enable this assertion for testing.
   switch (kind) {
-  case Cl::CL_LValue: assert(getValueKind() == VK_LValue); break;
-  case Cl::CL_XValue: assert(getValueKind() == VK_XValue); break;
+  case Cl::CL_LValue:
+assert(isLValue());
+break;
+  case Cl::CL_XValue:
+assert(isXValue());
+break;
   case Cl::CL_Function:
   case Cl::CL_Void:
   case Cl::CL_AddressableVoid:
@@ -65,7 +69,7 @@ Cl Expr::ClassifyImpl(ASTContext , SourceLocation *Loc) 
const {
   case Cl::CL_ArrayTemporary:
   case Cl::CL_ObjCMessageRValue:
   case Cl::CL_PRValue:
-assert(getValueKind() == VK_PRValue);
+assert(isPRValue());
 break;
   }
 

diff  --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp
index de9f3f6f899c6..5b3d39f20b416 100644
--- a/clang/lib/CodeGen/CGDecl.cpp
+++ b/clang/lib/CodeGen/CGDecl.cpp
@@ -714,10 +714,10 @@ static bool tryEmitARCCopyWeakInit(CodeGenFunction ,
   }
 
   // If it was an l-value, use objc_copyWeak.
-  if (srcExpr->getValueKind() == VK_LValue) {
+  if (srcExpr->isLValue()) {
 CGF.EmitARCCopyWeak(destLV.getAddress(CGF), srcAddr);
   } else {
-

[PATCH] D106033: [OpenMP] Folding threadLimit and numThreads when single value in kernels

2021-07-27 Thread Jose Manuel Monsalve Diaz via Phabricator via cfe-commits
josemonsalve2 updated this revision to Diff 362248.
josemonsalve2 added a comment.

Rebasing to main this time for real


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106033

Files:
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  llvm/lib/Transforms/IPO/OpenMPOpt.cpp
  llvm/test/Transforms/OpenMP/get_hardware_num_threads_in_block_fold.ll
  openmp/libomptarget/deviceRTLs/target_interface.h

Index: openmp/libomptarget/deviceRTLs/target_interface.h
===
--- openmp/libomptarget/deviceRTLs/target_interface.h
+++ openmp/libomptarget/deviceRTLs/target_interface.h
@@ -18,8 +18,8 @@
 // Calls to the NVPTX layer (assuming 1D layout)
 EXTERN int __kmpc_get_hardware_thread_id_in_block();
 EXTERN int GetBlockIdInKernel();
-EXTERN int __kmpc_get_hardware_num_blocks();
-EXTERN int __kmpc_get_hardware_num_threads_in_block();
+EXTERN NOINLINE int __kmpc_get_hardware_num_blocks();
+EXTERN NOINLINE int __kmpc_get_hardware_num_threads_in_block();
 EXTERN unsigned GetWarpId();
 EXTERN unsigned GetWarpSize();
 EXTERN unsigned GetLaneId();
Index: llvm/test/Transforms/OpenMP/get_hardware_num_threads_in_block_fold.ll
===
--- /dev/null
+++ llvm/test/Transforms/OpenMP/get_hardware_num_threads_in_block_fold.ll
@@ -0,0 +1,128 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-globals
+; RUN: opt -S -passes=openmp-opt < %s | FileCheck %s
+target triple = "nvptx64"
+
+%struct.ident_t = type { i32, i32, i32, i32, i8* }
+
+@kernel0_exec_mode = weak constant i8 1
+
+@G = external global i32
+;.
+; CHECK: @[[G:[a-zA-Z0-9_$"\\.-]+]] = external global i32
+;.
+define weak void @kernel0() #0 {
+; CHECK-LABEL: define {{[^@]+}}@kernel0()
+; CHECK: #[[ATTR0:[0-9]+]] {
+; CHECK-NEXT:[[I:%.*]] = call i32 @__kmpc_target_init(%struct.ident_t* null, i1 true, i1 false, i1 false)
+; CHECK-NEXT:call void @helper0()
+; CHECK-NEXT:call void @helper1()
+; CHECK-NEXT:call void @helper2()
+; CHECK-NEXT:call void @__kmpc_target_deinit(%struct.ident_t* null, i1 true, i1 false)
+; CHECK-NEXT:ret void
+;
+  %i = call i32 @__kmpc_target_init(%struct.ident_t* null, i1 true, i1 false, i1 false)
+  call void @helper0()
+  call void @helper1()
+  call void @helper2()
+  call void @__kmpc_target_deinit(%struct.ident_t* null, i1 true, i1 false)
+  ret void
+}
+
+@kernel1_exec_mode = weak constant i8 1
+
+define weak void @kernel1() #0 {
+; CHECK-LABEL: define {{[^@]+}}@kernel1()
+; CHECK: #[[ATTR0]] {
+; CHECK-NEXT:[[I:%.*]] = call i32 @__kmpc_target_init(%struct.ident_t* null, i1 true, i1 false, i1 false)
+; CHECK-NEXT:call void @helper1()
+; CHECK-NEXT:call void @__kmpc_target_deinit(%struct.ident_t* null, i1 false, i1 false)
+; CHECK-NEXT:ret void
+;
+  %i = call i32 @__kmpc_target_init(%struct.ident_t* null, i1 true, i1 false, i1 false)
+  call void @helper1()
+  call void @__kmpc_target_deinit(%struct.ident_t* null, i1 false, i1 false)
+  ret void
+}
+
+@kernel2_exec_mode = weak constant i8 1
+
+define weak void @kernel2() #0 {
+; CHECK-LABEL: define {{[^@]+}}@kernel2()
+; CHECK: #[[ATTR0]] {
+; CHECK-NEXT:[[I:%.*]] = call i32 @__kmpc_target_init(%struct.ident_t* null, i1 false, i1 false, i1 false)
+; CHECK-NEXT:call void @helper0()
+; CHECK-NEXT:call void @helper1()
+; CHECK-NEXT:call void @helper2()
+; CHECK-NEXT:call void @__kmpc_target_deinit(%struct.ident_t* null, i1 false, i1 false)
+; CHECK-NEXT:ret void
+;
+  %i = call i32 @__kmpc_target_init(%struct.ident_t* null, i1 false, i1 false, i1 false)
+  call void @helper0()
+  call void @helper1()
+  call void @helper2()
+  call void @__kmpc_target_deinit(%struct.ident_t* null, i1 false, i1 false)
+  ret void
+}
+
+define internal void @helper0() {
+; CHECK-LABEL: define {{[^@]+}}@helper0() {{#[0-9]+}} {
+; CHECK-NEXT:store i32 666, i32* @G, align 4
+; CHECK-NEXT:ret void
+;
+  %threadLimit = call i32 @__kmpc_get_hardware_num_threads_in_block()
+  store i32 %threadLimit, i32* @G
+  ret void
+}
+
+define internal void @helper1() {
+; CHECK-LABEL: define {{[^@]+}}@helper1() {{#[0-9]+}} {
+; CHECK-NEXT:br label [[F:%.*]]
+; CHECK:   t:
+; CHECK-NEXT:unreachable
+; CHECK:   f:
+; CHECK-NEXT:ret void
+;
+  %threadLimit = call i32 @__kmpc_get_hardware_num_threads_in_block()
+  %c = icmp eq i32 %threadLimit, 666
+  br i1 %c, label %f, label %t
+t:
+  call void @helper0()
+  ret void
+f:
+  ret void
+}
+
+define internal void @helper2() {
+; CHECK-LABEL: define {{[^@]+}}@helper2() {{#[0-9]+}} {
+; CHECK-NEXT:store i32 666, i32* @G
+; CHECK-NEXT:ret void
+;
+  %threadLimit = call i32 @__kmpc_get_hardware_num_threads_in_block()
+  store i32 %threadLimit, i32* @G
+  ret void
+}
+
+declare i32 @__kmpc_get_hardware_num_threads_in_block()
+declare 

[PATCH] D106907: [clang] fix concepts crash on substitution failure during normalization

2021-07-27 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added inline comments.



Comment at: clang/lib/Sema/SemaConcept.cpp:751
+  return None;
+Conjunction.emplace(S.Context, std::move(*Conjunction), std::move(*Next),
+CCK_Conjunction);

mizvekov wrote:
> rsmith wrote:
> > Doesn't this have a use-after-destruction bug? I'd expect `emplace` to 
> > first destroy its contained value and then construct a new one; in this 
> > case the second constructor argument looks like it'll be a reference to a 
> > destroyed object. I assume that's why the old code did the two-step 
> > construct and assign dance.
> The constructor used here takes both constraints by value:
> ```
>   NormalizedConstraint(ASTContext , NormalizedConstraint LHS,
>NormalizedConstraint RHS, CompoundConstraintKind Kind)
>   : Constraint{CompoundConstraint{
> new (C) std::pair{
> std::move(LHS), std::move(RHS)}, Kind}} { };
> ```
But I will also check if emplace is doing the right thing here or not.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106907

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


[PATCH] D106907: [clang] fix concepts crash on substitution failure during normalization

2021-07-27 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added inline comments.



Comment at: clang/lib/Sema/SemaConcept.cpp:744
   ArrayRef E) {
-  assert(E.size() != 0);
-  auto First = fromConstraintExpr(S, D, E[0]);

rsmith wrote:
> Might be useful to keep this assert; it will make it clearer to future 
> readers that this function isn't intended to handle this case.
Yeah you are right, the assert makes it obvious this is intended.



Comment at: clang/lib/Sema/SemaConcept.cpp:751
+  return None;
+Conjunction.emplace(S.Context, std::move(*Conjunction), std::move(*Next),
+CCK_Conjunction);

rsmith wrote:
> Doesn't this have a use-after-destruction bug? I'd expect `emplace` to first 
> destroy its contained value and then construct a new one; in this case the 
> second constructor argument looks like it'll be a reference to a destroyed 
> object. I assume that's why the old code did the two-step construct and 
> assign dance.
The constructor used here takes both constraints by value:
```
  NormalizedConstraint(ASTContext , NormalizedConstraint LHS,
   NormalizedConstraint RHS, CompoundConstraintKind Kind)
  : Constraint{CompoundConstraint{
new (C) std::pair{
std::move(LHS), std::move(RHS)}, Kind}} { };
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106907

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


[PATCH] D98710: [clang-tidy] New feature --skip-headers, part 1, setTraversalScope

2021-07-27 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
chh updated this revision to Diff 362239.
chh edited the summary of this revision.
chh added a comment.

Add new test cases into misc-unused-using-decls.cpp.


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

https://reviews.llvm.org/D98710

Files:
  clang-tools-extra/clang-tidy/ClangTidy.cpp
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
  clang-tools-extra/clang-tidy/ClangTidyOptions.h
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/bugprone-forward-declaration-namespace/a.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/bugprone-forward-declaration-namespace/b.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/skip-headers/a.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/skip-headers/b.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/skip-headers/c1.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/skip-headers/my_header1.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/skip-headers/my_header2.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/unused-using-decls.h
  clang-tools-extra/test/clang-tidy/checkers/abseil-no-internal-dependencies.cpp
  
clang-tools-extra/test/clang-tidy/checkers/abseil-upgrade-duration-conversions.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-forward-declaration-namespace-header.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-forward-declaration-namespace.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-reserved-identifier.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-include.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-interfaces-global-init.cpp
  clang-tools-extra/test/clang-tidy/checkers/google-namespaces.cpp
  clang-tools-extra/test/clang-tidy/checkers/google-objc-function-naming.m
  clang-tools-extra/test/clang-tidy/checkers/llvm-include-order.cpp
  
clang-tools-extra/test/clang-tidy/checkers/llvm-prefer-register-over-unsigned.cpp
  
clang-tools-extra/test/clang-tidy/checkers/llvmlibc-implementation-in-namespace.cpp
  
clang-tools-extra/test/clang-tidy/checkers/llvmlibc-restrict-system-libc-headers.cpp
  clang-tools-extra/test/clang-tidy/checkers/misc-no-recursion.cpp
  clang-tools-extra/test/clang-tidy/checkers/misc-unused-using-decls.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-cxx03.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-cxx11.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize-pass-by-value-header.cpp
  
clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-allow.cpp
  
clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-disallow.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-simplify-bool-expr-chained-conditional-assignment.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-simplify-bool-expr-chained-conditional-return.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-simplify-bool-expr-members.cpp
  clang-tools-extra/test/clang-tidy/checkers/readability-simplify-bool-expr.cpp
  clang-tools-extra/test/clang-tidy/checkers/skip-headers-2.cpp
  clang-tools-extra/test/clang-tidy/checkers/skip-headers-3.cpp
  clang-tools-extra/test/clang-tidy/checkers/skip-headers.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/file-filter-symlinks.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/file-filter.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/line-filter.cpp
  clang/include/clang/Frontend/MultiplexConsumer.h

Index: clang/include/clang/Frontend/MultiplexConsumer.h
===
--- clang/include/clang/Frontend/MultiplexConsumer.h
+++ clang/include/clang/Frontend/MultiplexConsumer.h
@@ -77,8 +77,9 @@
   void InitializeSema(Sema ) override;
   void ForgetSema() override;
 
-private:
+protected:
   std::vector> Consumers; // Owns these.
+private:
   std::unique_ptr MutationListener;
   std::unique_ptr DeserializationListener;
 };
Index: clang-tools-extra/test/clang-tidy/infrastructure/line-filter.cpp
===
--- clang-tools-extra/test/clang-tidy/infrastructure/line-filter.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/line-filter.cpp
@@ -1,4 +1,4 @@
-// RUN: clang-tidy -checks='-*,google-explicit-constructor' -line-filter='[{"name":"line-filter.cpp","lines":[[18,18],[22,22]]},{"name":"header1.h","lines":[[1,2]]},{"name":"header2.h"},{"name":"header3.h"}]' -header-filter='header[12]\.h$' %s -- -I %S/Inputs/line-filter 2>&1 | FileCheck %s
+// RUN: clang-tidy --skip-headers=0 -checks='-*,google-explicit-constructor' -line-filter='[{"name":"line-filter.cpp","lines":[[18,18],[22,22]]},{"name":"header1.h","lines":[[1,2]]},{"name":"header2.h"},{"name":"header3.h"}]' -header-filter='header[12]\.h$' %s -- -I 

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

2021-07-27 Thread Tom Stellard via Phabricator via cfe-commits
tstellar added a comment.

In D105527#2908944 , @Bigcheese wrote:

> Also, this python script just doesn't work. It's missing a sys import, a "w" 
> flag, and a new line after each write. It also dumps the output into the 
> source directory. Was this actually tested?

I fixed all these issues in the main branch yesterday.




Comment at: clang/test/LibClang/symbols.test:2
+# Check that there are no unversioned clang symbols in libclang.so
+RUN: llvm-nm -Dj --defined-only %libclang | grep -v -e '@@LLVM_[0-9]\+$' | not 
grep '^clang'
+

thakis wrote:
> thakis wrote:
> > I think it's possible to configure the build to only build a static 
> > libclang. This should probably only be done if libclang is built 
> > dynamically?
> Aha, libclang.so doesn't exist then and then the config.pipefail=False makes 
> things pass then. Subtle.
> Aha, libclang.so doesn't exist then and then the config.pipefail=False makes 
> things pass then. Subtle.

This was not my intention, but I'm glad it works.  



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105527

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


[PATCH] D60912: MS ABI: handle inline static data member and inline variable as template static data member

2021-07-27 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: lib/CodeGen/CGDeclCXX.cpp:494
 // too.
 AddGlobalCtor(Fn, 65535, COMDATKey);
   } else {

Confirmed with `lld-link -subsystem:console -opt:ref -debug:symtab a.o b.o c.o 
-entry:main -out:win.exe` that `__declspec(selectany)` can be linker GCed.

Sent D106925 to fix it.


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

https://reviews.llvm.org/D60912

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


[PATCH] D104601: [Preprocessor] Implement -fminimize-whitespace.

2021-07-27 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added a comment.

Proposed fix here: D106924 

The reproducer had another whitespace difference before and after D104601 
: "  typedef __builtin_va_list 
__gnuc_va_list;" instead of " typedef __builtin_va_list __gnuc_va_list;" (two 
spaces before "typedef" instead of one). I assume this is not the issue, 
especially since the source file (`include\vadefs.h`) acutally has two spaces 
before "typedef".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104601

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


[PATCH] D106925: COFF/ELF: Place llvm.global_ctors elements in llvm.used if comdat is used

2021-07-27 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision.
MaskRay added reviewers: rnk, rsmith.
MaskRay requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

On ELF, an SHT_INIT_ARRAY outside a section group is a GC root. The current
codegen abuses SHT_INIT_ARRAY in a section group to mean a GC root.

On PE/COFF, the dynamic initialization for `__declspec(selectany)` in a comdat
can be garbage collected by `-opt:ref`.

Call `addUsedGlobal` for the two cases to fix the abuse/bug.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106925

Files:
  clang/lib/CodeGen/CGDeclCXX.cpp
  clang/test/CodeGenCXX/microsoft-abi-template-static-init.cpp
  clang/test/CodeGenCXX/static-member-variable-explicit-specialization.cpp


Index: clang/test/CodeGenCXX/static-member-variable-explicit-specialization.cpp
===
--- clang/test/CodeGenCXX/static-member-variable-explicit-specialization.cpp
+++ clang/test/CodeGenCXX/static-member-variable-explicit-specialization.cpp
@@ -1,5 +1,20 @@
 // RUN: %clang_cc1 %s -std=c++1y -triple=x86_64-pc-linux -emit-llvm -o - | 
FileCheck --check-prefix=ELF --check-prefix=ALL %s
 // RUN: %clang_cc1 %s -std=c++1y -triple=x86_64-apple-darwin -emit-llvm -o - | 
FileCheck --check-prefix=MACHO --check-prefix=ALL %s
+// RUN: %clang_cc1 %s -std=c++1y -triple=x86_64-pc-linux -emit-llvm -fdeclspec 
-DSELECTANY -o - | FileCheck --check-prefix=ELF-SELECTANY %s
+
+#ifdef SELECTANY
+struct S {
+  S();
+  ~S();
+};
+
+int f();
+
+// ELF-SELECTANY: @llvm.global_ctors = appending global [1 x { i32, void ()*, 
i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @__cxx_global_var_init, 
i8* bitcast (i32* @selectany to i8*) }]
+// ELF-SELECTANY: @llvm.used = appending global [1 x i8*] [i8* bitcast (i32* 
@selectany to i8*)]
+int __declspec(selectany) selectany = f();
+
+#else
 
 // ALL: ; ModuleID
 
@@ -38,6 +53,9 @@
 
 // ALL:  { i32, void ()*, i8* } { i32 65535, void ()* 
@_GLOBAL__sub_I_static_member_variable_explicit_specialization.cpp, i8* null }]
 
+/// llvm.used ensures SHT_INIT_ARRAY in a section group cannot be GCed.
+// ELF: @llvm.used = appending global [6 x i8*] [i8* bitcast (i32* 
@_ZN1AIsE1aE to i8*), i8* bitcast (i16* @_Z1xIsE to i8*), i8* bitcast (i32* 
@_ZN2ns1aIiE1iE to i8*), i8* bitcast (i32* @_ZN2ns1b1iIiEE to i8*), i8* bitcast 
(i32* @_ZN1AIvE1aE to i8*), i8* @_Z1xIcE]
+
 template int A::a;  // Unordered
 int b = foo();
 int c = foo();
@@ -76,6 +94,8 @@
 }
 int *use_internal_a = ::a;
 
+#endif
+
 // ALL: define internal void @[[unordered1]](
 // ALL: call i32 @foo()
 // ALL: store {{.*}} @_ZN1AIsE1aE
Index: clang/test/CodeGenCXX/microsoft-abi-template-static-init.cpp
===
--- clang/test/CodeGenCXX/microsoft-abi-template-static-init.cpp
+++ clang/test/CodeGenCXX/microsoft-abi-template-static-init.cpp
@@ -88,5 +88,4 @@
 inline int zoo = foo();
 inline static int boo = foo();
 
-
-// CHECK: @llvm.used = appending global [7 x i8*] [i8* bitcast (i32* 
@"?x1@selectany_init@@3HA" to i8*), i8* bitcast (i32* 
@"?x@?$A@H@explicit_template_instantiation@@2HA" to i8*), i8* bitcast (i32* 
@"?ioo@?$X_@H@@2HA" to i8*), i8* getelementptr inbounds (%struct.A, %struct.A* 
@"?aoo@S1@@2UA@@A", i32 0, i32 0), i8* bitcast (i32* @"?zoo@@3HA" to i8*), i8* 
getelementptr inbounds (%struct.S, %struct.S* 
@"?s@?$ExportedTemplate@H@@2US@@A", i32 0, i32 0), i8* bitcast (i32* 
@"?x@?$A@H@implicit_template_instantiation@@2HA" to i8*)], section 
"llvm.metadata"
+// CHECK: @llvm.used = appending global [8 x i8*] [i8* bitcast (i32* 
@"?x@selectany_init@@3HA" to i8*), i8* bitcast (i32* @"?x1@selectany_init@@3HA" 
to i8*), i8* bitcast (i32* @"?x@?$A@H@explicit_template_instantiation@@2HA" to 
i8*), i8* bitcast (i32* @"?ioo@?$X_@H@@2HA" to i8*), i8* getelementptr inbounds 
(%struct.A, %struct.A* @"?aoo@S1@@2UA@@A", i32 0, i32 0), i8* bitcast (i32* 
@"?zoo@@3HA" to i8*), i8* getelementptr inbounds (%struct.S, %struct.S* 
@"?s@?$ExportedTemplate@H@@2US@@A", i32 0, i32 0), i8* bitcast (i32* 
@"?x@?$A@H@implicit_template_instantiation@@2HA" to i8*)], section 
"llvm.metadata"
Index: clang/lib/CodeGen/CGDeclCXX.cpp
===
--- clang/lib/CodeGen/CGDeclCXX.cpp
+++ clang/lib/CodeGen/CGDeclCXX.cpp
@@ -555,7 +555,8 @@
   PrioritizedCXXGlobalInits.size());
 PrioritizedCXXGlobalInits.push_back(std::make_pair(Key, Fn));
   } else if (isTemplateInstantiation(D->getTemplateSpecializationKind()) ||
- getContext().GetGVALinkageForVariable(D) == GVA_DiscardableODR) {
+ getContext().GetGVALinkageForVariable(D) == GVA_DiscardableODR ||
+ D->hasAttr()) {
 // C++ [basic.start.init]p2:
 //   Definitions of explicitly specialized class template static data
 //   members have ordered initialization. Other class template static data
@@ 

[PATCH] D106924: [Preprocessor] -E -P: Ensure newline after 8 skipped lines.

2021-07-27 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur created this revision.
Meinersbur added reviewers: aaron.ballman, mstorsjo, dblaikie.
Meinersbur added a project: clang.
Meinersbur requested review of this revision.

The implementation of -fminimize-whitespace (D104601 
) revised the logic when to emit newlines. 
There was no case to handle when more than 8 lines were skippped in `-P` 
(DisableLineMarkers) mode and instead fell through the case intended for 
`-fminimize-whitespace`, i.e. emit nothing. This patch will emit one newline in 
this case.

The newline logic is slightly reorganized. The `-fminimize-whitespace` case is 
handled explicitly and the emit at least one newline is the new fallback case. 
Without `DisableLineMarkers`, there is the choice between emitting a line 
marker or up to 8 empty lines. 
The up to 8 newlines likely are fewer characters that a line directive, but in 
`-P` mode this had the paradoxic effect that it would print up to 7 empty 
lines, but none at all if more than 8 lines had to be skipped. With 
`DisableLineMarkers`, we now don't consider printing empty lines (just start a 
new line) which matches gcc's behaviour.

The `line-directive-output-mincol.c` test is replaced with a more comprehensive 
test `skip-empty-lines.c` that also tests the more than 8 skipped lines 
behaviour with a various flag combinations.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106924

Files:
  clang/lib/Frontend/PrintPreprocessedOutput.cpp
  clang/test/Preprocessor/line-directive-output-mincol.c
  clang/test/Preprocessor/minimize-whitespace.c
  clang/test/Preprocessor/skip-empty-lines.c

Index: clang/test/Preprocessor/skip-empty-lines.c
===
--- /dev/null
+++ clang/test/Preprocessor/skip-empty-lines.c
@@ -0,0 +1,44 @@
+int  a ;
+int  b ;
+// A single empty line
+int  c ;
+/*
+
+more than 8 empty lines
+
+
+
+
+
+*/
+int  d ;
+
+// RUN: %clang_cc1 -E %s 2>&1 | FileCheck %s --strict-whitespace --check-prefix=LINEMARKES
+// RUN: %clang_cc1 -E -P %s 2>&1 | FileCheck %s --strict-whitespace --check-prefix=COLSONLY
+// RUN: %clang_cc1 -E -fminimize-whitespace %s 2>&1 | FileCheck %s --strict-whitespace --check-prefix=MINWS
+// RUN: %clang_cc1 -E -P -fminimize-whitespace %s 2>&1 | FileCheck %s --strict-whitespace --check-prefix=MINCOL
+
+// Check behavior after variying number of lines without emitted tokens.
+
+// LINEMARKES:   # 1 "{{.*}}skip-empty-lines.c" 2
+// LINEMARKERS-NEXT: int a ;
+// LINEMARKERS-NEXT: int b ;
+// LINEMARKERS-EMPTY:
+// LINEMARKERS-NEXT: int c ;
+// LINEMARKERS-NEXT: # 14 "/c/Users/meinersbur/src/llvm-project/clang/test/Preprocessor/skip-empty-lines.c"
+// LINEMARKERS-NEXT: int d ;
+
+// COLSONLY:  int a ;
+// COLSONLY-NEXT: int b ;
+// COLSONLY-NEXT: int c ;
+// COLSONLY-NEXT: int d ;
+
+// MINWS:  # 1 "{{.*}}skip-empty-lines.c" 2
+// MINWS-NEXT: int a;
+// MINWS-NEXT: int b;
+// MINWS-EMPTY:
+// MINWS-NEXT: int c;
+// MINWS-NEXT: # 14 "{{.*}}skip-empty-lines.c"
+// MINWS-NEXT: int d;
+
+// MINCOL: int a;int b;int c;int d;
Index: clang/test/Preprocessor/minimize-whitespace.c
===
--- clang/test/Preprocessor/minimize-whitespace.c
+++ clang/test/Preprocessor/minimize-whitespace.c
@@ -2,6 +2,12 @@
 // RUN: %clang_cc1 -fminimize-whitespace -E -C %s 2>&1 | FileCheck %s --strict-whitespace --check-prefix=MINCCOL
 // RUN: %clang_cc1 -fminimize-whitespace -E -P %s 2>&1 | FileCheck %s --strict-whitespace --check-prefix=MINWS
 // RUN: %clang_cc1 -fminimize-whitespace -E -C -P %s 2>&1 | FileCheck %s --strict-whitespace --check-prefix=MINCWS
+// The follow empty lines ensure that a #line directive is emitted instead of newline padding after the RUN lines
+
+
+
+
+
 
 #define NOT_OMP  omp  something
 #define HASH #
@@ -16,11 +22,11 @@
 f  ;
 
 
-// MINCOL:  {{^}}# 9 "{{.*}}minimize-whitespace.c"{{$}}
+// MINCOL:  {{^}}# 15 "{{.*}}minimize-whitespace.c"{{$}}
 // MINCOL:  {{^}}int a;{{$}}
 // MINCOL-NEXT: {{^}}int b;{{$}}
 // MINCOL-NEXT: {{^}}#pragma omp barrier{{$}}
-// MINCOL-NEXT: # 11 "{{.*}}minimize-whitespace.c"
+// MINCOL-NEXT: # 17 "{{.*}}minimize-whitespace.c"
 // MINCOL-NEXT: {{^}}x{{$}}
 // MINCOL-NEXT: {{^}}#pragma omp nothing{{$}}
 // MINCOL-NEXT: {{^ }}#pragma omp something{{$}}
@@ -28,11 +34,11 @@
 // MINCOL-NEXT: {{^}}int f;{{$}}
 
 // FIXME: Comments after pragmas disappear, even without -fminimize-whitespace
-// MINCCOL:  {{^}}# 9 "{{.*}}minimize-whitespace.c"{{$}}
+// MINCCOL:  {{^}}# 15 "{{.*}}minimize-whitespace.c"{{$}}
 // MINCCOL:  {{^}}int a;/*  span-comment  */{{$}}
 // MINCCOL-NEXT: {{^}}int b;//  line-comment{{$}}
 // MINCCOL-NEXT: {{^}}#pragma omp barrier{{$}}
-// MINCCOL-NEXT: # 11 "{{.*}}minimize-whitespace.c"
+// MINCCOL-NEXT: # 17 "{{.*}}minimize-whitespace.c"
 // MINCCOL-NEXT: {{^}}x//  more line-comments{{$}}
 // MINCCOL-NEXT: {{^}}#pragma omp nothing{{$}}
 // MINCCOL-NEXT: {{^ 

[PATCH] D100713: [clang] NFC: refactor multiple implementations of getDecltypeForParenthesizedExpr

2021-07-27 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/lib/AST/ASTContext.cpp:5461
+QualType ASTContext::getDecltypeForParenthesizedExpr(const Expr *e) const {
+  if (!e)
+return VoidTy;

This check doesn't seem like it belongs here.



Comment at: clang/lib/Sema/SemaExprCXX.cpp:5845
+  if (!To->isRValue()) {
+QualType T = Self.Context.getDecltypeForParenthesizedExpr(To);
 InitializedEntity Entity = InitializedEntity::InitializeTemporary(T);

mizvekov wrote:
> aaronpuchert wrote:
> > mizvekov wrote:
> > > aaronpuchert wrote:
> > > > The quote doesn't reference parenthesized expressions, isn't this just 
> > > > coincidentally the same thing?
> > > It's fundamentally the same thing. The `getDecltypeForParenthesizedExpr` 
> > > name is what I tried to keep, I don't have better ideas there.
> > What this is doing is pointwise equal to `getDecltypeForParenthesizedExpr`, 
> > but there is no parenthesized expression, and no `decltype`. There is a 
> > quote from the standard that defines this separately (by now this seems to 
> > be [[http://eel.is/c++draft/expr.cond#4|expr.cond#4]]), and there are some 
> > differences especially in the prvalue case. So I'm not sure this helps.
> Here for XValue and and LValue, the rules are exactly the same as 
> https://eel.is/c++draft/dcl.type.decltype#1.
> And the original code here even already special cases it...
> 
> I am sure there is some way we can agree that we should not repeat the code 
> just because the standard did not bother to give a name to this part of the 
> rules... And again I think it is no coincidence that it makes sense to 
> perform the same changes in all these cases.
Maybe we can find a more general name for this functionality that doesn't 
mention `decltype`. Perhaps something like `getReferenceQualifiedType`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100713

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


[PATCH] D106033: [OpenMP] Folding threadLimit and numThreads when single value in kernels

2021-07-27 Thread Jose Manuel Monsalve Diaz via Phabricator via cfe-commits
josemonsalve2 updated this revision to Diff 362234.
josemonsalve2 added a comment.

Resync again


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106033

Files:
  clang/test/OpenMP/declare_target_codegen_globalization.cpp
  clang/test/OpenMP/nvptx_multi_target_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_target_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_num_threads_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/target_map_codegen_03.cpp
  clang/test/OpenMP/target_parallel_codegen.cpp
  clang/test/OpenMP/target_parallel_for_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/target_parallel_if_codegen.cpp
  clang/test/OpenMP/target_parallel_num_threads_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_collapse_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_dist_schedule_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_private_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_reduction_codegen.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  llvm/lib/Transforms/IPO/OpenMPOpt.cpp
  llvm/test/Transforms/OpenMP/get_hardware_num_threads_in_block_fold.ll
  openmp/libomptarget/deviceRTLs/target_interface.h

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


[PATCH] D106907: [clang] fix concepts crash on substitution failure during normalization

2021-07-27 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/lib/Sema/SemaConcept.cpp:744
   ArrayRef E) {
-  assert(E.size() != 0);
-  auto First = fromConstraintExpr(S, D, E[0]);

Might be useful to keep this assert; it will make it clearer to future readers 
that this function isn't intended to handle this case.



Comment at: clang/lib/Sema/SemaConcept.cpp:751
+  return None;
+Conjunction.emplace(S.Context, std::move(*Conjunction), std::move(*Next),
+CCK_Conjunction);

Doesn't this have a use-after-destruction bug? I'd expect `emplace` to first 
destroy its contained value and then construct a new one; in this case the 
second constructor argument looks like it'll be a reference to a destroyed 
object. I assume that's why the old code did the two-step construct and assign 
dance.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106907

___
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-27 Thread Michael Spencer via Phabricator via cfe-commits
Bigcheese added a comment.

Here's a version that actually works (python 3, not sure if it's valid in 2), 
although I would much prefer we not write to the source directory during a 
build.

  import re
  import os
  import sys
  
  input_file = open(sys.argv[1])
  with open(sys.argv[2], "w") as output_file:
  for line in input_file:
  m = re.search('clang_[^;]+', line)
  if m:
  output_file.write(m.group(0) + '\n')


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105527

___
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-27 Thread Michael Spencer via Phabricator via cfe-commits
Bigcheese added a comment.

Also, this python script just doesn't work. It's missing a sys import, a "w" 
flag, and a new line after each write. It also dumps the output into the source 
directory. Was this actually tested?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105527

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


[PATCH] D106033: [OpenMP] Folding threadLimit and numThreads when single value in kernels

2021-07-27 Thread Jose Manuel Monsalve Diaz via Phabricator via cfe-commits
josemonsalve2 updated this revision to Diff 362226.
josemonsalve2 added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Sync to main


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106033

Files:
  clang/test/OpenMP/declare_target_codegen_globalization.cpp
  clang/test/OpenMP/nvptx_multi_target_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_target_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_num_threads_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/target_map_codegen_03.cpp
  clang/test/OpenMP/target_parallel_codegen.cpp
  clang/test/OpenMP/target_parallel_for_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/target_parallel_if_codegen.cpp
  clang/test/OpenMP/target_parallel_num_threads_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_collapse_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_dist_schedule_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_private_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_reduction_codegen.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  llvm/lib/Transforms/IPO/OpenMPOpt.cpp
  llvm/test/Transforms/OpenMP/get_hardware_num_threads_in_block_fold.ll
  openmp/libomptarget/deviceRTLs/target_interface.h

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


[PATCH] D99840: [clang-format] Correctly attach enum braces with ShortEnums disabled

2021-07-27 Thread Luna Kirkby via Phabricator via cfe-commits
lunasorcery updated this revision to Diff 362220.
lunasorcery added a comment.

Sorry it took me so long to get back to this - fell off my radar somewhat.
I've updated the release notes, I think it's ready to commit now?
I lack commit rights (first time contributor!) so for attribution it'd be "Luna 
Kirkby "


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

https://reviews.llvm.org/D99840

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTest.cpp
  clang/unittests/Format/FormatTestCSharp.cpp


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -402,8 +402,7 @@
 }
 
 TEST_F(FormatTestCSharp, CSharpKeyWordEscaping) {
-  verifyFormat("public enum var\n"
-   "{\n"
+  verifyFormat("public enum var {\n"
"none,\n"
"@string,\n"
"bool,\n"
Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -2451,6 +2451,14 @@
   Style.AllowShortEnumsOnASingleLine = true;
   verifyFormat("enum { A, B, C } ShortEnum1, ShortEnum2;", Style);
   Style.AllowShortEnumsOnASingleLine = false;
+  verifyFormat("enum {\n"
+   "  A,\n"
+   "  B,\n"
+   "  C\n"
+   "} ShortEnum1, ShortEnum2;",
+   Style);
+  Style.BreakBeforeBraces = FormatStyle::BS_Custom;
+  Style.BraceWrapping.AfterEnum = true;
   verifyFormat("enum\n"
"{\n"
"  A,\n"
@@ -22123,8 +22131,7 @@
Style);
   // Enumerations are not records and should be unaffected.
   Style.AllowShortEnumsOnASingleLine = false;
-  verifyFormat("enum class E\n"
-   "{\n"
+  verifyFormat("enum class E {\n"
"  A,\n"
"  B\n"
"};\n",
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -2515,6 +2515,8 @@
   if (FormatTok->Tok.is(tok::kw_enum))
 nextToken();
 
+  const FormatToken  = *FormatTok;
+
   // In TypeScript, "enum" can also be used as property name, e.g. in interface
   // declarations. An "enum" keyword followed by a colon would be a syntax
   // error and thus assume it is just an identifier.
@@ -2561,7 +2563,8 @@
 return true;
   }
 
-  if (!Style.AllowShortEnumsOnASingleLine)
+  if (!Style.AllowShortEnumsOnASingleLine &&
+  ShouldBreakBeforeBrace(Style, InitialToken))
 addUnwrappedLine();
   // Parse enum body.
   nextToken();
Index: clang/include/clang/Format/Format.h
===
--- clang/include/clang/Format/Format.h
+++ clang/include/clang/Format/Format.h
@@ -544,8 +544,7 @@
   ///   enum { A, B } myEnum;
   ///
   ///   false:
-  ///   enum
-  ///   {
+  ///   enum {
   /// A,
   /// B
   ///   } myEnum;
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -284,6 +284,9 @@
 
 - Support for formatting JSON file (\*.json) has been added to clang-format.
 
+- Option ``AllowShortEnumsOnASingleLine: false`` has been improved, it now
+  correctly places the opening brace according to ``BraceWrapping.AfterEnum``.
+
 libclang
 
 


Index: clang/unittests/Format/FormatTestCSharp.cpp
===
--- clang/unittests/Format/FormatTestCSharp.cpp
+++ clang/unittests/Format/FormatTestCSharp.cpp
@@ -402,8 +402,7 @@
 }
 
 TEST_F(FormatTestCSharp, CSharpKeyWordEscaping) {
-  verifyFormat("public enum var\n"
-   "{\n"
+  verifyFormat("public enum var {\n"
"none,\n"
"@string,\n"
"bool,\n"
Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -2451,6 +2451,14 @@
   Style.AllowShortEnumsOnASingleLine = true;
   verifyFormat("enum { A, B, C } ShortEnum1, ShortEnum2;", Style);
   Style.AllowShortEnumsOnASingleLine = false;
+  verifyFormat("enum {\n"
+   "  A,\n"
+   "  B,\n"
+   "  C\n"
+   "} ShortEnum1, ShortEnum2;",
+   Style);
+  Style.BreakBeforeBraces = FormatStyle::BS_Custom;
+  Style.BraceWrapping.AfterEnum = true;
   verifyFormat("enum\n"
"{\n"
"  A,\n"
@@ -22123,8 +22131,7 @@
Style);
   // Enumerations are not 

[PATCH] D98709: [clang-tidy] New feature --skip-headers, part 1, LocFilter

2021-07-27 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
chh updated this revision to Diff 362216.
chh edited the summary of this revision.
chh added a comment.

- Use clang-format layout in ClangTidy.cpp and ClangTidyModule.h.
- Fix misc-unused-using-decls false-positive warning from --skip-headers.
  - UnusedUsingDeclsCheck is now registered as an AllFileCheck.
  - Add new test cases into misc-unused-using-decls.cpp.


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

https://reviews.llvm.org/D98709

Files:
  clang-tools-extra/clang-tidy/ClangTidy.cpp
  clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
  clang-tools-extra/clang-tidy/ClangTidyCheck.h
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/clang-tidy/ClangTidyModule.cpp
  clang-tools-extra/clang-tidy/ClangTidyModule.h
  clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
  clang-tools-extra/clang-tidy/ClangTidyOptions.h
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/ForwardDeclarationNamespaceCheck.cpp
  clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
  clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/bugprone-forward-declaration-namespace/a.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/bugprone-forward-declaration-namespace/b.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/skip-headers/a.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/skip-headers/b.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/skip-headers/c1.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/skip-headers/my_header1.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/skip-headers/my_header2.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/unused-using-decls.h
  clang-tools-extra/test/clang-tidy/checkers/abseil-no-internal-dependencies.cpp
  
clang-tools-extra/test/clang-tidy/checkers/abseil-upgrade-duration-conversions.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-forward-declaration-namespace-header.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-forward-declaration-namespace.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-reserved-identifier.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-include.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-interfaces-global-init.cpp
  clang-tools-extra/test/clang-tidy/checkers/google-namespaces.cpp
  clang-tools-extra/test/clang-tidy/checkers/google-objc-function-naming.m
  clang-tools-extra/test/clang-tidy/checkers/llvm-include-order.cpp
  
clang-tools-extra/test/clang-tidy/checkers/llvm-prefer-register-over-unsigned.cpp
  
clang-tools-extra/test/clang-tidy/checkers/llvmlibc-implementation-in-namespace.cpp
  
clang-tools-extra/test/clang-tidy/checkers/llvmlibc-restrict-system-libc-headers.cpp
  clang-tools-extra/test/clang-tidy/checkers/misc-no-recursion.cpp
  clang-tools-extra/test/clang-tidy/checkers/misc-unused-using-decls.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-cxx03.cpp
  
clang-tools-extra/test/clang-tidy/checkers/modernize-deprecated-headers-cxx11.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize-pass-by-value-header.cpp
  
clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-allow.cpp
  
clang-tools-extra/test/clang-tidy/checkers/portability-restrict-system-includes-disallow.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-simplify-bool-expr-chained-conditional-assignment.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-simplify-bool-expr-chained-conditional-return.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-simplify-bool-expr-members.cpp
  clang-tools-extra/test/clang-tidy/checkers/readability-simplify-bool-expr.cpp
  clang-tools-extra/test/clang-tidy/checkers/skip-headers-2.cpp
  clang-tools-extra/test/clang-tidy/checkers/skip-headers-3.cpp
  clang-tools-extra/test/clang-tidy/checkers/skip-headers.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/file-filter-symlinks.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/file-filter.cpp
  clang-tools-extra/test/clang-tidy/infrastructure/line-filter.cpp
  clang/include/clang/ASTMatchers/ASTMatchFinder.h
  clang/lib/ASTMatchers/ASTMatchFinder.cpp

Index: clang/lib/ASTMatchers/ASTMatchFinder.cpp
===
--- clang/lib/ASTMatchers/ASTMatchFinder.cpp
+++ clang/lib/ASTMatchers/ASTMatchFinder.cpp
@@ -1202,6 +1202,8 @@
   if (!DeclNode) {
 return true;
   }
+  if (Options.Filter && Options.Filter->skipLocation(DeclNode->getLocation()))
+return true;
 
   bool ScopedTraversal =
   TraversingASTNodeNotSpelledInSource || DeclNode->isImplicit();
@@ -1232,6 +1234,13 @@
   if (!StmtNode) {
 return true;
   }
+  // When a function call is in the main file or wanted header files,
+  // the call site maybe in the Decl 

[PATCH] D106753: ConvertUTF: Created wrapper convertUTF32ToUTF8String

2021-07-27 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: llvm/lib/Support/ConvertUTFWrapper.cpp:176
+  // enough that we can fit a null terminator without reallocating.
+  Out.resize(SrcBytes.size() * UNI_MAX_UTF8_BYTES_PER_CODE_POINT + 1);
+  UTF8 *Dst = reinterpret_cast([0]);

`SrcBytes.size() * UNI_MAX_UTF8_BYTES_PER_CODE_POINT + 1` seems like way too 
much memory.


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

https://reviews.llvm.org/D106753

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


[PATCH] D105516: [clang][PassManager] Add -falways-mem2reg to run mem2reg at -O0

2021-07-27 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added a comment.

In D105516#2892512 , @rjmccall wrote:

> I agree with Eli: we should decide what the goals are here and then use those 
> goals to decide if we can identify a desirable permanent feature and, if so, 
> what the appropriate name for that feature is.
>
> It sounds like your goal is to get readable assembly that still corresponds 
> fairly literally to your original code, in the sense that the readability of 
> -O0 assembly is often undermined by the sheer amount of code and all the 
> extra, unnecessary work it seems to do.  However, I've found that a lot of 
> the extra -O0 code is not actually from loads and stores to local variables, 
> it's from the -O0 instruction selection and register allocation, which often 
> combine to do very silly things.  Have you looked into whether you get more 
> readable code by just running normal -O0 IR through the non-O0 codegen 
> pipeline?  Because the problem with doing just mem2reg is that that's already 
> a fairly major non-literal change to the code, and at some point it's tricky 
> to say what exactly should be part of this new pipeline; whereas still 
> emitting exactly what the abstract machine says to do, just with less 
> nonsense from fast-isel, is a lot easier to define.

Well, I'm dealing with RISC-V which doesn't have FastISel. And no, running -O0 
IR through a different pipeline is never going to work well without mem2reg 
(and you can't mem2reg -O0 IR without -disable-O0-optnone), so you need at 
least this to work well. Whether or not there's a useful load of additional 
stuff you could do, maybe, but I do think this patch in and of itself makes a 
huge difference, and the limited scope of it is beneficial.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105516

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


[PATCH] D105516: [clang][PassManager] Add -falways-mem2reg to run mem2reg at -O0

2021-07-27 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson added a comment.

I like this since the flag significantly improves readability for 
`update_cc_test_checks.py`-generated Clang test without having to use the 
`-disable-O0-optnone | opt` trick. Not sure what the best flag name is, but as 
long as it's a CC1 flag it shouldn't really matter.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105516

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


[PATCH] D105516: [clang][PassManager] Add -falways-mem2reg to run mem2reg at -O0

2021-07-27 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

Seems fine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105516

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


[PATCH] D106891: [AMDGPU] [Remarks] Emit optimization remarks when an FP atomic instruction is converted into a CAS loop or unsafe hardware instruction for GFX90A

2021-07-27 Thread Anshil Gandhi via Phabricator via cfe-commits
gandhi21299 updated this revision to Diff 362208.
gandhi21299 added a comment.

Instruction selector is unable to select unsafe hw atomic instruction for add. 
Adding relevant diagnostic in the test case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106891

Files:
  clang/test/CodeGenCUDA/fp-atomics-optremarks.cu
  llvm/lib/Target/AMDGPU/SIISelLowering.cpp
  llvm/lib/Target/AMDGPU/SIISelLowering.h

Index: llvm/lib/Target/AMDGPU/SIISelLowering.h
===
--- llvm/lib/Target/AMDGPU/SIISelLowering.h
+++ llvm/lib/Target/AMDGPU/SIISelLowering.h
@@ -30,6 +30,7 @@
 class SITargetLowering final : public AMDGPUTargetLowering {
 private:
   const GCNSubtarget *Subtarget;
+  OptimizationRemarkEmitter *ORE;
 
 public:
   MVT getRegisterTypeForCallingConv(LLVMContext ,
Index: llvm/lib/Target/AMDGPU/SIISelLowering.cpp
===
--- llvm/lib/Target/AMDGPU/SIISelLowering.cpp
+++ llvm/lib/Target/AMDGPU/SIISelLowering.cpp
@@ -19,6 +19,7 @@
 #include "SIRegisterInfo.h"
 #include "llvm/ADT/Statistic.h"
 #include "llvm/Analysis/LegacyDivergenceAnalysis.h"
+#include "llvm/Analysis/OptimizationRemarkEmitter.h"
 #include "llvm/BinaryFormat/ELF.h"
 #include "llvm/CodeGen/Analysis.h"
 #include "llvm/CodeGen/FunctionLoweringInfo.h"
@@ -12117,6 +12118,27 @@
   return DenormMode == DenormalMode::getIEEE();
 }
 
+static TargetLowering::AtomicExpansionKind
+atomicExpandReturn(OptimizationRemarkEmitter *ORE, AtomicRMWInst *RMW,
+   TargetLowering::AtomicExpansionKind Kind, bool UnsafeFlag) {
+  ORE = new OptimizationRemarkEmitter(RMW->getFunction());
+  if (Kind == TargetLowering::AtomicExpansionKind::CmpXChg) {
+ORE->emit([&]() {
+  OptimizationRemark Remark(DEBUG_TYPE, "Passed", RMW->getFunction());
+  Remark << "An FP atomic instruction was expanded into a CAS loop.";
+  return Remark;
+});
+  } else if (Kind == TargetLowering::AtomicExpansionKind::None && UnsafeFlag) {
+ORE->emit([&]() {
+  OptimizationRemark Remark(DEBUG_TYPE, "Passed", RMW->getFunction());
+  Remark << "An unsafe hardware instruction was generated.";
+  return Remark;
+});
+  }
+  delete ORE;
+  return Kind;
+}
+
 TargetLowering::AtomicExpansionKind
 SITargetLowering::shouldExpandAtomicRMWInIR(AtomicRMWInst *RMW) const {
   switch (RMW->getOperation()) {
@@ -12132,35 +12154,42 @@
   return AtomicExpansionKind::CmpXChg;
 
 unsigned AS = RMW->getPointerAddressSpace();
-
+bool UnsafeFPAtomicFlag = RMW->getFunction()
+  ->getFnAttribute("amdgpu-unsafe-fp-atomics")
+  .getValueAsBool();
 if ((AS == AMDGPUAS::GLOBAL_ADDRESS || AS == AMDGPUAS::FLAT_ADDRESS) &&
  Subtarget->hasAtomicFaddInsts()) {
   // The amdgpu-unsafe-fp-atomics attribute enables generation of unsafe
   // floating point atomic instructions. May generate more efficient code,
   // but may not respect rounding and denormal modes, and may give incorrect
   // results for certain memory destinations.
-  if (RMW->getFunction()
-  ->getFnAttribute("amdgpu-unsafe-fp-atomics")
-  .getValueAsString() != "true")
-return AtomicExpansionKind::CmpXChg;
+  if (!UnsafeFPAtomicFlag)
+return atomicExpandReturn(ORE, RMW, AtomicExpansionKind::CmpXChg,
+  UnsafeFPAtomicFlag);
+  atomicExpandReturn(ORE, RMW, AtomicExpansionKind::None, UnsafeFPAtomicFlag);
 
   if (Subtarget->hasGFX90AInsts()) {
 if (Ty->isFloatTy() && AS == AMDGPUAS::FLAT_ADDRESS)
-  return AtomicExpansionKind::CmpXChg;
+  return atomicExpandReturn(ORE, RMW, AtomicExpansionKind::CmpXChg,
+UnsafeFPAtomicFlag);
 
 auto SSID = RMW->getSyncScopeID();
 if (SSID == SyncScope::System ||
 SSID == RMW->getContext().getOrInsertSyncScopeID("one-as"))
-  return AtomicExpansionKind::CmpXChg;
+  return atomicExpandReturn(ORE, RMW, AtomicExpansionKind::CmpXChg,
+UnsafeFPAtomicFlag);
 
-return AtomicExpansionKind::None;
+return atomicExpandReturn(ORE, RMW, AtomicExpansionKind::None,
+  UnsafeFPAtomicFlag);
   }
 
   if (AS == AMDGPUAS::FLAT_ADDRESS)
-return AtomicExpansionKind::CmpXChg;
+return atomicExpandReturn(ORE, RMW, AtomicExpansionKind::CmpXChg,
+  UnsafeFPAtomicFlag);
 
-  return RMW->use_empty() ? AtomicExpansionKind::None
-  : AtomicExpansionKind::CmpXChg;
+  auto Kind = RMW->use_empty() ? AtomicExpansionKind::None
+   : AtomicExpansionKind::CmpXChg;
+  return atomicExpandReturn(ORE, RMW, Kind, 

[PATCH] D106891: [AMDGPU] [Remarks] Emit optimization remarks when an FP atomic instruction is converted into a CAS loop or unsafe hardware instruction for GFX90A

2021-07-27 Thread Anshil Gandhi via Phabricator via cfe-commits
gandhi21299 updated this revision to Diff 362157.
gandhi21299 added a comment.

- corrected test by replacing the hardware instruction check by `v_add_f32_e64`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106891

Files:
  clang/test/CodeGenCUDA/fp-atomics-optremarks.cu
  llvm/lib/Target/AMDGPU/SIISelLowering.cpp
  llvm/lib/Target/AMDGPU/SIISelLowering.h

Index: llvm/lib/Target/AMDGPU/SIISelLowering.h
===
--- llvm/lib/Target/AMDGPU/SIISelLowering.h
+++ llvm/lib/Target/AMDGPU/SIISelLowering.h
@@ -30,6 +30,7 @@
 class SITargetLowering final : public AMDGPUTargetLowering {
 private:
   const GCNSubtarget *Subtarget;
+  OptimizationRemarkEmitter *ORE;
 
 public:
   MVT getRegisterTypeForCallingConv(LLVMContext ,
Index: llvm/lib/Target/AMDGPU/SIISelLowering.cpp
===
--- llvm/lib/Target/AMDGPU/SIISelLowering.cpp
+++ llvm/lib/Target/AMDGPU/SIISelLowering.cpp
@@ -19,6 +19,7 @@
 #include "SIRegisterInfo.h"
 #include "llvm/ADT/Statistic.h"
 #include "llvm/Analysis/LegacyDivergenceAnalysis.h"
+#include "llvm/Analysis/OptimizationRemarkEmitter.h"
 #include "llvm/BinaryFormat/ELF.h"
 #include "llvm/CodeGen/Analysis.h"
 #include "llvm/CodeGen/FunctionLoweringInfo.h"
@@ -12117,6 +12118,27 @@
   return DenormMode == DenormalMode::getIEEE();
 }
 
+static TargetLowering::AtomicExpansionKind
+atomicExpandReturn(OptimizationRemarkEmitter *ORE, AtomicRMWInst *RMW,
+   TargetLowering::AtomicExpansionKind Kind, bool UnsafeFlag) {
+  ORE = new OptimizationRemarkEmitter(RMW->getFunction());
+  if (Kind == TargetLowering::AtomicExpansionKind::CmpXChg) {
+ORE->emit([&]() {
+  OptimizationRemark Remark(DEBUG_TYPE, "Passed", RMW->getFunction());
+  Remark << "An FP atomic instruction was expanded into a CAS loop.";
+  return Remark;
+});
+  } else if (Kind == TargetLowering::AtomicExpansionKind::None && UnsafeFlag) {
+ORE->emit([&]() {
+  OptimizationRemark Remark(DEBUG_TYPE, "Passed", RMW->getFunction());
+  Remark << "An unsafe hardware instruction was generated.";
+  return Remark;
+});
+  }
+  delete ORE;
+  return Kind;
+}
+
 TargetLowering::AtomicExpansionKind
 SITargetLowering::shouldExpandAtomicRMWInIR(AtomicRMWInst *RMW) const {
   switch (RMW->getOperation()) {
@@ -12132,35 +12154,42 @@
   return AtomicExpansionKind::CmpXChg;
 
 unsigned AS = RMW->getPointerAddressSpace();
-
+bool UnsafeFPAtomicFlag = RMW->getFunction()
+  ->getFnAttribute("amdgpu-unsafe-fp-atomics")
+  .getValueAsBool();
 if ((AS == AMDGPUAS::GLOBAL_ADDRESS || AS == AMDGPUAS::FLAT_ADDRESS) &&
  Subtarget->hasAtomicFaddInsts()) {
   // The amdgpu-unsafe-fp-atomics attribute enables generation of unsafe
   // floating point atomic instructions. May generate more efficient code,
   // but may not respect rounding and denormal modes, and may give incorrect
   // results for certain memory destinations.
-  if (RMW->getFunction()
-  ->getFnAttribute("amdgpu-unsafe-fp-atomics")
-  .getValueAsString() != "true")
-return AtomicExpansionKind::CmpXChg;
+  if (!UnsafeFPAtomicFlag)
+return atomicExpandReturn(ORE, RMW, AtomicExpansionKind::CmpXChg,
+  false);
+  atomicExpandReturn(ORE, RMW, AtomicExpansionKind::None, true);
 
   if (Subtarget->hasGFX90AInsts()) {
 if (Ty->isFloatTy() && AS == AMDGPUAS::FLAT_ADDRESS)
-  return AtomicExpansionKind::CmpXChg;
+  return atomicExpandReturn(ORE, RMW, AtomicExpansionKind::CmpXChg,
+UnsafeFPAtomicFlag);
 
 auto SSID = RMW->getSyncScopeID();
 if (SSID == SyncScope::System ||
 SSID == RMW->getContext().getOrInsertSyncScopeID("one-as"))
-  return AtomicExpansionKind::CmpXChg;
+  return atomicExpandReturn(ORE, RMW, AtomicExpansionKind::CmpXChg,
+UnsafeFPAtomicFlag);
 
-return AtomicExpansionKind::None;
+return atomicExpandReturn(ORE, RMW, AtomicExpansionKind::None,
+  UnsafeFPAtomicFlag);
   }
 
   if (AS == AMDGPUAS::FLAT_ADDRESS)
-return AtomicExpansionKind::CmpXChg;
+return atomicExpandReturn(ORE, RMW, AtomicExpansionKind::CmpXChg,
+  UnsafeFPAtomicFlag);
 
-  return RMW->use_empty() ? AtomicExpansionKind::None
-  : AtomicExpansionKind::CmpXChg;
+  auto Kind = RMW->use_empty() ? AtomicExpansionKind::None
+   : AtomicExpansionKind::CmpXChg;
+  return atomicExpandReturn(ORE, RMW, Kind, UnsafeFPAtomicFlag);
 }
 
 // DS FP atomics do repect the denormal mode, 

[PATCH] D106909: [clang] Add clang builtins support for gfx90a

2021-07-27 Thread Anshil Gandhi via Phabricator via cfe-commits
gandhi21299 created this revision.
gandhi21299 added reviewers: arsenm, yaxunl, rampitec.
Herald added subscribers: kerbowa, jfb, tpr, nhaehnle, jvesely.
gandhi21299 requested review of this revision.
Herald added subscribers: cfe-commits, wdng.
Herald added a project: clang.

Implement target builtins for gfx90a including fadd64, fadd32, add2h, max and 
min on various global, flat and ds address spaces for which intrinsics are 
already implemented.

@rampitec Compiler recommended me to add `global-noret` target feature after 
setting it in BuiltinsAMDGPU.def. I am not sure what that means outside of the 
BuiltinsAMDGPU.def so I have changed it back to `gfx90a-insts`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106909

Files:
  clang/include/clang/Basic/BuiltinsAMDGPU.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGenOpenCL/builtins-fp-atomics.cl

Index: clang/test/CodeGenOpenCL/builtins-fp-atomics.cl
===
--- /dev/null
+++ clang/test/CodeGenOpenCL/builtins-fp-atomics.cl
@@ -0,0 +1,98 @@
+// RUN: %clang_cc1 -cl-std=CL2.0 -triple amdgcn-amd-amdhsa -target-cpu gfx90a \
+// RUN:   %s -S -emit-llvm -o - | FileCheck %s -check-prefix=CHECK
+
+// RUN: %clang_cc1 -cl-std=CL2.0 -triple amdgcn-amd-amdhsa -target-cpu gfx90a \
+// RUN:   -S -o - %s | FileCheck -check-prefix=GFX90A %s
+
+
+typedef enum memory_order {
+  memory_order_relaxed = __ATOMIC_RELAXED,
+  memory_order_acquire = __ATOMIC_ACQUIRE,
+  memory_order_release = __ATOMIC_RELEASE,
+  memory_order_acq_rel = __ATOMIC_ACQ_REL,
+  memory_order_seq_cst = __ATOMIC_SEQ_CST
+} memory_order;
+
+typedef half __attribute__((ext_vector_type(2))) half2;
+
+// CHECK-LABEL: test_global_add
+// CHECK: tail call double @llvm.amdgcn.global.atomic.fadd.f64.p1f64.f64(double addrspace(1)* %{{.*}}, double %{{.*}})
+// GFX90A:  test_global_add
+// GFX90A:  global_atomic_add_f64 v2, v[0:1], s[0:1]
+// GFX90A:  s_endpgm
+kernel void test_global_add(__global double *addr, double x) {
+  __builtin_amdgcn_atomic_fadd64(addr, x, memory_order_relaxed);
+}
+
+// CHECK-LABEL: test_global_addf
+// CHECK: tail call float @llvm.amdgcn.global.atomic.fadd.f32.p1f32.f32(float addrspace(1)* %{{.*}}, float %{{.*}})
+// GFX90A-LABEL: test_global_addf
+// GFX90A: global_atomic_add_f32 v0, v1, s[0:1]
+// GFX90A: s_endpgm
+kernel void test_global_addf(__global float *addr, float x) {
+  __builtin_amdgcn_atomic_fadd32(addr, x, memory_order_relaxed);
+}
+
+// CHECK-LABEL: test_global_add2h
+// CHECK: tail call <2 x half> @llvm.amdgcn.global.atomic.fadd.v2f16.p1v2f16.v2f16(<2 x half> addrspace(1)* %{{.*}}, <2 x half> %{{.*}})
+// GFX90A-LABEL: test_global_add2h
+// GFX90A: global_atomic_pk_add_f16 v0, v1, s[0:1]
+// GFX90A: s_endpgm
+kernel void test_global_add2h(__global half2 *addr, half2 x){
+  __builtin_amdgcn_atomic_add2h(addr, x, memory_order_relaxed);
+}
+
+// CHECK-LABEL: test_global_min
+// CHECK: tail call double @llvm.amdgcn.global.atomic.fmin.f64.p1f64.f64(double addrspace(1)* %{{.*}}, double %{{.*}})
+// GFX90A:  test_global_min
+// GFX90A:  global_atomic_min_f64 v2, v[0:1], s[0:1]
+// GFX90A:  s_endpgm
+kernel void test_global_min(__global double *addr, double x){
+  __builtin_amdgcn_atomic_min(addr, x, memory_order_relaxed);
+}
+
+// CHECK-LABEL: test_global_max
+// CHECK: tail call double @llvm.amdgcn.global.atomic.fmax.f64.p1f64.f64(double addrspace(1)* %{{.*}}, double %{{.*}})
+// GFX90A:  test_global_max
+// GFX90A:  global_atomic_max_f64 v2, v[0:1], s[0:1]
+// GFX90A:  s_endpgm
+kernel void test_global_max(__global double *addr, double x){
+  __builtin_amdgcn_atomic_max(addr, x, memory_order_relaxed);
+}
+
+// CHECK-LABEL: test_flat_add_local
+// CHECK: tail call double @llvm.amdgcn.flat.atomic.fadd.f64.p3f64.f64(double addrspace(3)* %{{.*}}, double %{{.*}})
+// GFX90A:  test_flat_add_local
+// GFX90A:  ds_add_f64 v2, v[0:1]
+// GFX90A:  s_endpgm
+kernel void test_flat_add_local(__local double *addr, double x){
+  __builtin_amdgcn_flat_atomic_fadd64(addr, x, memory_order_relaxed);
+}
+
+
+// CHECK-LABEL: test_flat_min_constant
+// CHECK: tail call double @llvm.amdgcn.flat.atomic.fmin.f64.p4f64.f64(double addrspace(4)* %{{.*}}, double %{{.*}})
+// GFX90A:  test_flat_min_constant
+// GFX90A:  global_atomic_min_f64 v2, v[0:1], s[0:1]
+// GFX90A:  s_endpgm
+kernel void test_flat_min_constant(__constant double *addr, double x){
+  __builtin_amdgcn_flat_atomic_min(addr, x, memory_order_relaxed);
+}
+
+// CHECK-LABEL: test_ds_add_local
+// CHECK: tail call double @llvm.amdgcn.ds.fadd.f64(double addrspace(3)* %{{.*}}, double %{{.*}},
+// GFX90A:  test_ds_add_local
+// GFX90A:  ds_add_f64 v2, v[0:1]
+// GFX90A:  s_endpgm
+kernel void test_ds_add_local(__local double *addr, double x){
+  __builtin_amdgcn_ds_atomic_fadd64(addr, x, memory_order_relaxed);
+}
+
+// CHECK-LABEL: test_ds_addf_local
+// CHECK: tail call float @llvm.amdgcn.ds.fadd.f32(float addrspace(3)* %{{.*}}, float %{{.*}},
+// 

[PATCH] D105516: [clang][PassManager] Add -falways-mem2reg to run mem2reg at -O0

2021-07-27 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 updated this revision to Diff 362214.
jrtc27 added a comment.

Now only a CC1 option


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105516

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/falways-mem2reg.c
  llvm/include/llvm/Passes/PassBuilder.h
  llvm/include/llvm/Transforms/IPO/PassManagerBuilder.h
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Transforms/IPO/PassManagerBuilder.cpp

Index: llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
===
--- llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
+++ llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
@@ -187,6 +187,7 @@
 LibraryInfo = nullptr;
 Inliner = nullptr;
 DisableUnrollLoops = false;
+AlwaysMem2Reg = false;
 SLPVectorize = false;
 LoopVectorize = true;
 LoopsInterleaved = true;
@@ -658,8 +659,11 @@
   MPM.add(createForceFunctionAttrsLegacyPass());
 
   // If all optimizations are disabled, just run the always-inline pass and,
-  // if enabled, the function merging pass.
+  // if enabled, the mem2reg and function merging passes.
   if (OptLevel == 0) {
+if (AlwaysMem2Reg)
+  MPM.add(createPromoteMemoryToRegisterPass());
+
 addPGOInstrPasses(MPM);
 if (Inliner) {
   MPM.add(Inliner);
Index: llvm/lib/Passes/PassBuilder.cpp
===
--- llvm/lib/Passes/PassBuilder.cpp
+++ llvm/lib/Passes/PassBuilder.cpp
@@ -283,6 +283,7 @@
   SLPVectorization = false;
   LoopUnrolling = true;
   ForgetAllSCEVInLoopUnroll = ForgetSCEVInLoopUnroll;
+  AlwaysMem2Reg = false;
   Coroutines = false;
   LicmMssaOptCap = SetLicmMssaOptCap;
   LicmMssaNoAccForPromotionCap = SetLicmMssaNoAccForPromotionCap;
@@ -1931,6 +1932,9 @@
   MPM.addPass(AlwaysInlinerPass(
   /*InsertLifetimeIntrinsics=*/PTO.Coroutines));
 
+  if (PTO.AlwaysMem2Reg)
+MPM.addPass(createModuleToFunctionPassAdaptor(PromotePass()));
+
   if (PTO.MergeFunctions)
 MPM.addPass(MergeFunctionsPass());
 
Index: llvm/include/llvm/Transforms/IPO/PassManagerBuilder.h
===
--- llvm/include/llvm/Transforms/IPO/PassManagerBuilder.h
+++ llvm/include/llvm/Transforms/IPO/PassManagerBuilder.h
@@ -156,6 +156,7 @@
 
   bool DisableTailCalls;
   bool DisableUnrollLoops;
+  bool AlwaysMem2Reg;
   bool CallGraphProfile;
   bool SLPVectorize;
   bool LoopVectorize;
Index: llvm/include/llvm/Passes/PassBuilder.h
===
--- llvm/include/llvm/Passes/PassBuilder.h
+++ llvm/include/llvm/Passes/PassBuilder.h
@@ -107,6 +107,10 @@
   /// is that of the flag: `-forget-scev-loop-unroll`.
   bool ForgetAllSCEVInLoopUnroll;
 
+  /// Tuning option to always run mem2reg regardless of the optimisation level.
+  /// Its default value is false.
+  bool AlwaysMem2Reg;
+
   /// Tuning option to enable/disable coroutine intrinsic lowering. Its default
   /// value is false. Frontends such as Clang may enable this conditionally. For
   /// example, Clang enables this option if the flags `-std=c++2a` or above, or
Index: clang/test/CodeGen/falways-mem2reg.c
===
--- /dev/null
+++ clang/test/CodeGen/falways-mem2reg.c
@@ -0,0 +1,33 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple riscv64 -emit-llvm -o - -flegacy-pass-manager -O0 %s \
+// RUN:   | FileCheck --check-prefix=O0-NO-MEM2REG %s
+// RUN: %clang_cc1 -triple riscv64 -emit-llvm -o - -fno-legacy-pass-manager -O0 %s \
+// RUN:   | FileCheck --check-prefix=O0-NO-MEM2REG %s
+// RUN: %clang_cc1 -triple riscv64 -emit-llvm -o - -flegacy-pass-manager -O0 -fno-always-mem2reg %s \
+// RUN:   | FileCheck --check-prefix=O0-NO-MEM2REG %s
+// RUN: %clang_cc1 -triple riscv64 -emit-llvm -o - -fno-legacy-pass-manager -O0 -fno-always-mem2reg %s \
+// RUN:   | FileCheck --check-prefix=O0-NO-MEM2REG %s
+// RUN: %clang_cc1 -triple riscv64 -emit-llvm -o - -flegacy-pass-manager -O0 -falways-mem2reg %s \
+// RUN:   | FileCheck --check-prefix=O0-MEM2REG %s
+// RUN: %clang_cc1 -triple riscv64 -emit-llvm -o - -fno-legacy-pass-manager -O0 -falways-mem2reg %s \
+// RUN:   | FileCheck --check-prefix=O0-MEM2REG %s
+
+// O0-NO-MEM2REG-LABEL: @add(
+// O0-NO-MEM2REG-NEXT:  entry:
+// O0-NO-MEM2REG-NEXT:[[A_ADDR:%.*]] = alloca i32, align 4
+// O0-NO-MEM2REG-NEXT:[[B_ADDR:%.*]] = alloca i32, align 4
+// O0-NO-MEM2REG-NEXT:store i32 [[A:%.*]], i32* [[A_ADDR]], align 4
+// O0-NO-MEM2REG-NEXT:store i32 [[B:%.*]], i32* [[B_ADDR]], align 4
+// O0-NO-MEM2REG-NEXT:[[TMP0:%.*]] = load i32, i32* [[A_ADDR]], align 4
+// O0-NO-MEM2REG-NEXT:[[TMP1:%.*]] = load i32, i32* 

[PATCH] D106614: [Clang] add btf_tag attribute

2021-07-27 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song added inline comments.



Comment at: clang/include/clang/Basic/AttrDocs.td:2019
+targets. This attribute may be attached to a struct/union, struct/union field,
+function or variables declaration. If -g is specified, the ARGUMENT info will
+be preserved in IR and be emitted to dwarf. For BPF target, the ARGUMENT info

anakryiko wrote:
> can it be also applied to function's argument?
The attribute does apply to function argument. I missed it in the 
documentation. Will add it.



Comment at: clang/test/Sema/attr-btf_tag.c:13
+
+int __tag foo(struct t1 __tag *arg) {
+  return arg->a;

anakryiko wrote:
> in this case, second __tag, does it apply to function argument, or pointer, 
> or pointer's pointee (struct t1)?
apply to function argument. In dwarf, it applies to DW_TAG_member.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106614

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


[PATCH] D106920: [AIX] Update fetch_and_add type

2021-07-27 Thread Jinsong Ji 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 rGedbdf8e5b5aa: [AIX] Update fetch_and_add type (authored by 
jsji).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106920

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/test/CodeGen/builtins-ppc-xlcompat-fetch-error.c
  clang/test/CodeGen/builtins-ppc-xlcompat-fetch.c


Index: clang/test/CodeGen/builtins-ppc-xlcompat-fetch.c
===
--- clang/test/CodeGen/builtins-ppc-xlcompat-fetch.c
+++ clang/test/CodeGen/builtins-ppc-xlcompat-fetch.c
@@ -16,7 +16,7 @@
 // CHECK-NEXT:[[TMP2:%.*]] = atomicrmw add i32* [[A_ADDR]], i32 [[TMP1]] 
monotonic, align 4
 // CHECK-NEXT:ret void
 //
-void test_builtin_ppc_fetch_and_add(unsigned int a, unsigned int b) {
+void test_builtin_ppc_fetch_and_add(int a, int b) {
   __fetch_and_add(, b);
 }
 
@@ -31,7 +31,7 @@
 // CHECK-NEXT:[[TMP2:%.*]] = atomicrmw add i64* [[A_ADDR]], i64 [[TMP1]] 
monotonic, align 8
 // CHECK-NEXT:ret void
 //
-void test_builtin_ppc_fetch_and_addlp(unsigned long a, unsigned long b) {
+void test_builtin_ppc_fetch_and_addlp(long a, long b) {
   __fetch_and_addlp(, b);
 }
 // CHECK-LABEL: @test_builtin_ppc_fetch_and_and(
Index: clang/test/CodeGen/builtins-ppc-xlcompat-fetch-error.c
===
--- clang/test/CodeGen/builtins-ppc-xlcompat-fetch-error.c
+++ clang/test/CodeGen/builtins-ppc-xlcompat-fetch-error.c
@@ -1,17 +1,18 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
 // REQUIRES: powerpc-registered-target
 // RUN: %clang_cc1 -triple powerpc64-unknown-aix -target-cpu pwr8 \
 // RUN:  -verify %s
 
 void test_builtin_ppc_fetch_and_add2() {
-  volatile int a = 0;
+  volatile unsigned int a = 0;
   unsigned int b = 0;
 
-  __fetch_and_add(, b); // expected-warning {{passing 'volatile int *' to 
parameter of type 'volatile unsigned int *' converts between pointers to 
integer types with different sign}}
+  __fetch_and_add(, b); // expected-warning {{passing 'volatile unsigned int 
*' to parameter of type 'volatile int *' converts between pointers to integer 
types with different sign}}
 }
 
 void test_builtin_ppc_fetch_and_addlp() {
-  volatile long a = 0;
+  volatile unsigned long a = 0;
   unsigned long b = 0;
 
-  __fetch_and_addlp(, b); // expected-warning {{passing 'volatile long *' to 
parameter of type 'volatile unsigned long *' converts between pointers to 
integer types with different sign}}
+  __fetch_and_addlp(, b); // expected-warning {{passing 'volatile unsigned 
long *' to parameter of type 'volatile long *' converts between pointers to 
integer types with different sign}}
 }
Index: clang/include/clang/Basic/BuiltinsPPC.def
===
--- clang/include/clang/Basic/BuiltinsPPC.def
+++ clang/include/clang/Basic/BuiltinsPPC.def
@@ -64,8 +64,8 @@
 BUILTIN(__builtin_ppc_fsqrts, "ff", "")
 BUILTIN(__builtin_ppc_compare_and_swap, "iiD*i*i", "")
 BUILTIN(__builtin_ppc_compare_and_swaplp, "iLiD*Li*Li", "")
-BUILTIN(__builtin_ppc_fetch_and_add, "UiUiD*Ui", "")
-BUILTIN(__builtin_ppc_fetch_and_addlp, "ULiULiD*ULi", "")
+BUILTIN(__builtin_ppc_fetch_and_add, "iiD*i", "")
+BUILTIN(__builtin_ppc_fetch_and_addlp, "LiLiD*Li", "")
 BUILTIN(__builtin_ppc_fetch_and_and, "UiUiD*Ui", "")
 BUILTIN(__builtin_ppc_fetch_and_andlp, "ULiULiD*ULi", "")
 BUILTIN(__builtin_ppc_fetch_and_or, "UiUiD*Ui", "")


Index: clang/test/CodeGen/builtins-ppc-xlcompat-fetch.c
===
--- clang/test/CodeGen/builtins-ppc-xlcompat-fetch.c
+++ clang/test/CodeGen/builtins-ppc-xlcompat-fetch.c
@@ -16,7 +16,7 @@
 // CHECK-NEXT:[[TMP2:%.*]] = atomicrmw add i32* [[A_ADDR]], i32 [[TMP1]] monotonic, align 4
 // CHECK-NEXT:ret void
 //
-void test_builtin_ppc_fetch_and_add(unsigned int a, unsigned int b) {
+void test_builtin_ppc_fetch_and_add(int a, int b) {
   __fetch_and_add(, b);
 }
 
@@ -31,7 +31,7 @@
 // CHECK-NEXT:[[TMP2:%.*]] = atomicrmw add i64* [[A_ADDR]], i64 [[TMP1]] monotonic, align 8
 // CHECK-NEXT:ret void
 //
-void test_builtin_ppc_fetch_and_addlp(unsigned long a, unsigned long b) {
+void test_builtin_ppc_fetch_and_addlp(long a, long b) {
   __fetch_and_addlp(, b);
 }
 // CHECK-LABEL: @test_builtin_ppc_fetch_and_and(
Index: clang/test/CodeGen/builtins-ppc-xlcompat-fetch-error.c
===
--- clang/test/CodeGen/builtins-ppc-xlcompat-fetch-error.c
+++ clang/test/CodeGen/builtins-ppc-xlcompat-fetch-error.c
@@ -1,17 +1,18 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
 // REQUIRES: powerpc-registered-target
 // RUN: %clang_cc1 -triple powerpc64-unknown-aix 

[clang] edbdf8e - [AIX] Update fetch_and_add type

2021-07-27 Thread Jinsong Ji via cfe-commits

Author: Jinsong Ji
Date: 2021-07-27T22:13:29Z
New Revision: edbdf8e5b5aad9f1d7f12dd4025d6811a6fff0b2

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

LOG: [AIX] Update fetch_and_add type

It turns out that the AIX kernel is defining int instead of unsigned int for 
fetch_and_add.

Legacy XL also defines this to be signed.

https://www.ibm.com/docs/en/aix/7.2?topic=f-fetch-add-kernel-services

So update the type for compat.

Reviewed By: hubert.reinterpretcast

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

Added: 


Modified: 
clang/include/clang/Basic/BuiltinsPPC.def
clang/test/CodeGen/builtins-ppc-xlcompat-fetch-error.c
clang/test/CodeGen/builtins-ppc-xlcompat-fetch.c

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsPPC.def 
b/clang/include/clang/Basic/BuiltinsPPC.def
index 3873231cdfe4..dfe97af300f4 100644
--- a/clang/include/clang/Basic/BuiltinsPPC.def
+++ b/clang/include/clang/Basic/BuiltinsPPC.def
@@ -64,8 +64,8 @@ BUILTIN(__builtin_ppc_fsqrt, "dd", "")
 BUILTIN(__builtin_ppc_fsqrts, "ff", "")
 BUILTIN(__builtin_ppc_compare_and_swap, "iiD*i*i", "")
 BUILTIN(__builtin_ppc_compare_and_swaplp, "iLiD*Li*Li", "")
-BUILTIN(__builtin_ppc_fetch_and_add, "UiUiD*Ui", "")
-BUILTIN(__builtin_ppc_fetch_and_addlp, "ULiULiD*ULi", "")
+BUILTIN(__builtin_ppc_fetch_and_add, "iiD*i", "")
+BUILTIN(__builtin_ppc_fetch_and_addlp, "LiLiD*Li", "")
 BUILTIN(__builtin_ppc_fetch_and_and, "UiUiD*Ui", "")
 BUILTIN(__builtin_ppc_fetch_and_andlp, "ULiULiD*ULi", "")
 BUILTIN(__builtin_ppc_fetch_and_or, "UiUiD*Ui", "")

diff  --git a/clang/test/CodeGen/builtins-ppc-xlcompat-fetch-error.c 
b/clang/test/CodeGen/builtins-ppc-xlcompat-fetch-error.c
index a5124e3c10e9..3e9042df7a2c 100644
--- a/clang/test/CodeGen/builtins-ppc-xlcompat-fetch-error.c
+++ b/clang/test/CodeGen/builtins-ppc-xlcompat-fetch-error.c
@@ -1,17 +1,18 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
 // REQUIRES: powerpc-registered-target
 // RUN: %clang_cc1 -triple powerpc64-unknown-aix -target-cpu pwr8 \
 // RUN:  -verify %s
 
 void test_builtin_ppc_fetch_and_add2() {
-  volatile int a = 0;
+  volatile unsigned int a = 0;
   unsigned int b = 0;
 
-  __fetch_and_add(, b); // expected-warning {{passing 'volatile int *' to 
parameter of type 'volatile unsigned int *' converts between pointers to 
integer types with 
diff erent sign}}
+  __fetch_and_add(, b); // expected-warning {{passing 'volatile unsigned int 
*' to parameter of type 'volatile int *' converts between pointers to integer 
types with 
diff erent sign}}
 }
 
 void test_builtin_ppc_fetch_and_addlp() {
-  volatile long a = 0;
+  volatile unsigned long a = 0;
   unsigned long b = 0;
 
-  __fetch_and_addlp(, b); // expected-warning {{passing 'volatile long *' to 
parameter of type 'volatile unsigned long *' converts between pointers to 
integer types with 
diff erent sign}}
+  __fetch_and_addlp(, b); // expected-warning {{passing 'volatile unsigned 
long *' to parameter of type 'volatile long *' converts between pointers to 
integer types with 
diff erent sign}}
 }

diff  --git a/clang/test/CodeGen/builtins-ppc-xlcompat-fetch.c 
b/clang/test/CodeGen/builtins-ppc-xlcompat-fetch.c
index 7d0b674b39c2..8b2b3630300d 100644
--- a/clang/test/CodeGen/builtins-ppc-xlcompat-fetch.c
+++ b/clang/test/CodeGen/builtins-ppc-xlcompat-fetch.c
@@ -16,7 +16,7 @@
 // CHECK-NEXT:[[TMP2:%.*]] = atomicrmw add i32* [[A_ADDR]], i32 [[TMP1]] 
monotonic, align 4
 // CHECK-NEXT:ret void
 //
-void test_builtin_ppc_fetch_and_add(unsigned int a, unsigned int b) {
+void test_builtin_ppc_fetch_and_add(int a, int b) {
   __fetch_and_add(, b);
 }
 
@@ -31,7 +31,7 @@ void test_builtin_ppc_fetch_and_add(unsigned int a, unsigned 
int b) {
 // CHECK-NEXT:[[TMP2:%.*]] = atomicrmw add i64* [[A_ADDR]], i64 [[TMP1]] 
monotonic, align 8
 // CHECK-NEXT:ret void
 //
-void test_builtin_ppc_fetch_and_addlp(unsigned long a, unsigned long b) {
+void test_builtin_ppc_fetch_and_addlp(long a, long b) {
   __fetch_and_addlp(, b);
 }
 // CHECK-LABEL: @test_builtin_ppc_fetch_and_and(



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


[PATCH] D106753: ConvertUTF: Created wrapper convertUTF32ToUTF8String

2021-07-27 Thread Marcus Johnson via Phabricator via cfe-commits
MarcusJohnson91 updated this revision to Diff 362198.
MarcusJohnson91 added a comment.

Dropped the UTF32 BOM stuff


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

https://reviews.llvm.org/D106753

Files:
  llvm/include/llvm/Support/ConvertUTF.h
  llvm/lib/Support/ConvertUTFWrapper.cpp
  llvm/unittests/Support/ConvertUTFTest.cpp

Index: llvm/unittests/Support/ConvertUTFTest.cpp
===
--- llvm/unittests/Support/ConvertUTFTest.cpp
+++ llvm/unittests/Support/ConvertUTFTest.cpp
@@ -36,6 +36,28 @@
   EXPECT_EQ(Expected, Result);
 }
 
+TEST(ConvertUTFTest, ConvertUTF32LittleEndianToUTF8String) {
+  // Src is the look of disapproval.
+  alignas(UTF32) static const char Src[] = "\xff\xfe\xa0\x0c_\x00\xa0\x0c";
+  ArrayRef Ref(Src, sizeof(Src) - 1);
+  std::string Result;
+  bool Success = convertUTF32ToUTF8String(Ref, Result);
+  EXPECT_TRUE(Success);
+  std::string Expected("\xe0\xb2\xa0_\xe0\xb2\xa0");
+  EXPECT_EQ(Expected, Result);
+}
+
+TEST(ConvertUTFTest, ConvertUTF32BigEndianToUTF8String) {
+  // Src is the look of disapproval.
+  alignas(UTF32) static const char Src[] = "\xfe\xff\x0c\xa0\x00_\x0c\xa0";
+  ArrayRef Ref(Src, sizeof(Src) - 1);
+  std::string Result;
+  bool Success = convertUTF32ToUTF8String(Ref, Result);
+  EXPECT_TRUE(Success);
+  std::string Expected("\xe0\xb2\xa0_\xe0\xb2\xa0");
+  EXPECT_EQ(Expected, Result);
+}
+
 TEST(ConvertUTFTest, ConvertUTF8ToUTF16String) {
   // Src is the look of disapproval.
   static const char Src[] = "\xe0\xb2\xa0_\xe0\xb2\xa0";
@@ -78,6 +100,17 @@
   EXPECT_FALSE(HasBOM);
 }
 
+TEST(ConvertUTFTest, UTF32WrappersForConvertUTF32ToUTF8String) {
+  // Src is the look of disapproval.
+  alignas(UTF32) static const char Src[] = "\xff\xfe\xa0\x0c_\x00\xa0\x0c";
+  ArrayRef SrcRef = makeArrayRef((const UTF32 *)Src, 4);
+  std::string Result;
+  bool Success = convertUTF32ToUTF8String(SrcRef, Result);
+  EXPECT_TRUE(Success);
+  std::string Expected("\xe0\xb2\xa0_\xe0\xb2\xa0");
+  EXPECT_EQ(Expected, Result);
+}
+
 TEST(ConvertUTFTest, UTF16WrappersForConvertUTF16ToUTF8String) {
   // Src is the look of disapproval.
   alignas(UTF16) static const char Src[] = "\xff\xfe\xa0\x0c_\x00\xa0\x0c";
Index: llvm/lib/Support/ConvertUTFWrapper.cpp
===
--- llvm/lib/Support/ConvertUTFWrapper.cpp
+++ llvm/lib/Support/ConvertUTFWrapper.cpp
@@ -141,6 +141,64 @@
   Src.size() * sizeof(UTF16)), Out);
 }
 
+bool convertUTF32ToUTF8String(ArrayRef SrcBytes, std::string ) {
+  assert(Out.empty());
+
+  // Error out on an uneven byte count.
+  if (SrcBytes.size() % 4)
+return false;
+
+  // Avoid OOB by returning early on empty input.
+  if (SrcBytes.empty())
+return true;
+
+  const UTF32 *Src = reinterpret_cast(SrcBytes.begin());
+  const UTF32 *SrcEnd = reinterpret_cast(SrcBytes.end());
+
+  assert((uintptr_t)Src % sizeof(UTF32) == 0);
+
+  // Byteswap if necessary.
+  std::vector ByteSwapped;
+  if (Src[0] == UNI_UTF32_BYTE_ORDER_MARK_SWAPPED) {
+ByteSwapped.insert(ByteSwapped.end(), Src, SrcEnd);
+for (unsigned I = 0, E = ByteSwapped.size(); I != E; ++I)
+  ByteSwapped[I] = llvm::ByteSwap_32(ByteSwapped[I]);
+Src = [0];
+SrcEnd = [ByteSwapped.size() - 1] + 1;
+  }
+
+  // Skip the BOM for conversion.
+  if (Src[0] == UNI_UTF32_BYTE_ORDER_MARK_NATIVE)
+Src++;
+
+  // Just allocate enough space up front.  We'll shrink it later.  Allocate
+  // enough that we can fit a null terminator without reallocating.
+  Out.resize(SrcBytes.size() * UNI_MAX_UTF8_BYTES_PER_CODE_POINT + 1);
+  UTF8 *Dst = reinterpret_cast([0]);
+  UTF8 *DstEnd = Dst + Out.size();
+
+  ConversionResult CR =
+  ConvertUTF32toUTF8(, SrcEnd, , DstEnd, strictConversion);
+  assert(CR != targetExhausted);
+
+  if (CR != conversionOK) {
+Out.clear();
+return false;
+  }
+
+  Out.resize(reinterpret_cast(Dst) - [0]);
+  Out.push_back(0);
+  Out.pop_back();
+  return true;
+}
+
+bool convertUTF32ToUTF8String(ArrayRef Src, std::string ) {
+  return convertUTF32ToUTF8String(
+  llvm::ArrayRef(reinterpret_cast(Src.data()),
+   Src.size() * sizeof(UTF32)),
+  Out);
+}
+
 bool convertUTF8ToUTF16String(StringRef SrcUTF8,
   SmallVectorImpl ) {
   assert(DstUTF16.empty());
Index: llvm/include/llvm/Support/ConvertUTF.h
===
--- llvm/include/llvm/Support/ConvertUTF.h
+++ llvm/include/llvm/Support/ConvertUTF.h
@@ -278,6 +278,24 @@
 */
 bool convertUTF16ToUTF8String(ArrayRef Src, std::string );
 
+/**
+ * Converts a stream of raw bytes assumed to be UTF32 into a UTF8 std::string.
+ *
+ * \param [in] SrcBytes A buffer of what is assumed to be UTF-32 encoded text.
+ * \param [out] Out Converted UTF-8 is stored here on success.
+ * \returns true on success
+ */
+bool convertUTF32ToUTF8String(ArrayRef SrcBytes, std::string );
+

[PATCH] D106920: [AIX] Update fetch_and_add type

2021-07-27 Thread Jinsong Ji via Phabricator via cfe-commits
jsji updated this revision to Diff 362197.
jsji edited the summary of this revision.
jsji added a comment.

Update tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106920

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/test/CodeGen/builtins-ppc-xlcompat-fetch-error.c
  clang/test/CodeGen/builtins-ppc-xlcompat-fetch.c


Index: clang/test/CodeGen/builtins-ppc-xlcompat-fetch.c
===
--- clang/test/CodeGen/builtins-ppc-xlcompat-fetch.c
+++ clang/test/CodeGen/builtins-ppc-xlcompat-fetch.c
@@ -16,7 +16,7 @@
 // CHECK-NEXT:[[TMP2:%.*]] = atomicrmw add i32* [[A_ADDR]], i32 [[TMP1]] 
monotonic, align 4
 // CHECK-NEXT:ret void
 //
-void test_builtin_ppc_fetch_and_add(unsigned int a, unsigned int b) {
+void test_builtin_ppc_fetch_and_add(int a, int b) {
   __fetch_and_add(, b);
 }
 
@@ -31,7 +31,7 @@
 // CHECK-NEXT:[[TMP2:%.*]] = atomicrmw add i64* [[A_ADDR]], i64 [[TMP1]] 
monotonic, align 8
 // CHECK-NEXT:ret void
 //
-void test_builtin_ppc_fetch_and_addlp(unsigned long a, unsigned long b) {
+void test_builtin_ppc_fetch_and_addlp(long a, long b) {
   __fetch_and_addlp(, b);
 }
 // CHECK-LABEL: @test_builtin_ppc_fetch_and_and(
Index: clang/test/CodeGen/builtins-ppc-xlcompat-fetch-error.c
===
--- clang/test/CodeGen/builtins-ppc-xlcompat-fetch-error.c
+++ clang/test/CodeGen/builtins-ppc-xlcompat-fetch-error.c
@@ -1,17 +1,18 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
 // REQUIRES: powerpc-registered-target
 // RUN: %clang_cc1 -triple powerpc64-unknown-aix -target-cpu pwr8 \
 // RUN:  -verify %s
 
 void test_builtin_ppc_fetch_and_add2() {
-  volatile int a = 0;
+  volatile unsigned int a = 0;
   unsigned int b = 0;
 
-  __fetch_and_add(, b); // expected-warning {{passing 'volatile int *' to 
parameter of type 'volatile unsigned int *' converts between pointers to 
integer types with different sign}}
+  __fetch_and_add(, b); // expected-warning {{passing 'volatile unsigned int 
*' to parameter of type 'volatile int *' converts between pointers to integer 
types with different sign}}
 }
 
 void test_builtin_ppc_fetch_and_addlp() {
-  volatile long a = 0;
+  volatile unsigned long a = 0;
   unsigned long b = 0;
 
-  __fetch_and_addlp(, b); // expected-warning {{passing 'volatile long *' to 
parameter of type 'volatile unsigned long *' converts between pointers to 
integer types with different sign}}
+  __fetch_and_addlp(, b); // expected-warning {{passing 'volatile unsigned 
long *' to parameter of type 'volatile long *' converts between pointers to 
integer types with different sign}}
 }
Index: clang/include/clang/Basic/BuiltinsPPC.def
===
--- clang/include/clang/Basic/BuiltinsPPC.def
+++ clang/include/clang/Basic/BuiltinsPPC.def
@@ -64,8 +64,8 @@
 BUILTIN(__builtin_ppc_fsqrts, "ff", "")
 BUILTIN(__builtin_ppc_compare_and_swap, "iiD*i*i", "")
 BUILTIN(__builtin_ppc_compare_and_swaplp, "iLiD*Li*Li", "")
-BUILTIN(__builtin_ppc_fetch_and_add, "UiUiD*Ui", "")
-BUILTIN(__builtin_ppc_fetch_and_addlp, "ULiULiD*ULi", "")
+BUILTIN(__builtin_ppc_fetch_and_add, "iiD*i", "")
+BUILTIN(__builtin_ppc_fetch_and_addlp, "LiLiD*Li", "")
 BUILTIN(__builtin_ppc_fetch_and_and, "UiUiD*Ui", "")
 BUILTIN(__builtin_ppc_fetch_and_andlp, "ULiULiD*ULi", "")
 BUILTIN(__builtin_ppc_fetch_and_or, "UiUiD*Ui", "")


Index: clang/test/CodeGen/builtins-ppc-xlcompat-fetch.c
===
--- clang/test/CodeGen/builtins-ppc-xlcompat-fetch.c
+++ clang/test/CodeGen/builtins-ppc-xlcompat-fetch.c
@@ -16,7 +16,7 @@
 // CHECK-NEXT:[[TMP2:%.*]] = atomicrmw add i32* [[A_ADDR]], i32 [[TMP1]] monotonic, align 4
 // CHECK-NEXT:ret void
 //
-void test_builtin_ppc_fetch_and_add(unsigned int a, unsigned int b) {
+void test_builtin_ppc_fetch_and_add(int a, int b) {
   __fetch_and_add(, b);
 }
 
@@ -31,7 +31,7 @@
 // CHECK-NEXT:[[TMP2:%.*]] = atomicrmw add i64* [[A_ADDR]], i64 [[TMP1]] monotonic, align 8
 // CHECK-NEXT:ret void
 //
-void test_builtin_ppc_fetch_and_addlp(unsigned long a, unsigned long b) {
+void test_builtin_ppc_fetch_and_addlp(long a, long b) {
   __fetch_and_addlp(, b);
 }
 // CHECK-LABEL: @test_builtin_ppc_fetch_and_and(
Index: clang/test/CodeGen/builtins-ppc-xlcompat-fetch-error.c
===
--- clang/test/CodeGen/builtins-ppc-xlcompat-fetch-error.c
+++ clang/test/CodeGen/builtins-ppc-xlcompat-fetch-error.c
@@ -1,17 +1,18 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
 // REQUIRES: powerpc-registered-target
 // RUN: %clang_cc1 -triple powerpc64-unknown-aix -target-cpu pwr8 \
 // RUN:  -verify %s
 
 void test_builtin_ppc_fetch_and_add2() {
-  volatile 

[PATCH] D106920: [AIX] Update fetch_and_add type

2021-07-27 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast accepted this revision.
hubert.reinterpretcast added a comment.
This revision is now accepted and ready to land.

Thanks. LGTM with minor nits.




Comment at: clang/test/CodeGen/builtins-ppc-xlcompat-fetch.c:19
 //
-void test_builtin_ppc_fetch_and_add(unsigned int a, unsigned int b) {
+void test_builtin_ppc_fetch_and_add(int a, unsigned int b) {
   __fetch_and_add(, b);





Comment at: clang/test/CodeGen/builtins-ppc-xlcompat-fetch.c:34
 //
-void test_builtin_ppc_fetch_and_addlp(unsigned long a, unsigned long b) {
+void test_builtin_ppc_fetch_and_addlp(long a, unsigned long b) {
   __fetch_and_addlp(, b);




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106920

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


[PATCH] D106701: [clang] Add -falign-loops=N where N is a power of 2

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

In D106701#2908679 , @craig.topper 
wrote:

> Does this work with LTO?

`-falign-loops=` doesn't affect ld.lld code generation options.

`-Wl,-mllvm,--align-loops=128` can be used for now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106701

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


[PATCH] D106614: [Clang] add btf_tag attribute

2021-07-27 Thread Andrii Nakryiko via Phabricator via cfe-commits
anakryiko added inline comments.



Comment at: clang/include/clang/Basic/AttrDocs.td:2019
+targets. This attribute may be attached to a struct/union, struct/union field,
+function or variables declaration. If -g is specified, the ARGUMENT info will
+be preserved in IR and be emitted to dwarf. For BPF target, the ARGUMENT info

can it be also applied to function's argument?



Comment at: clang/test/Sema/attr-btf_tag.c:13
+
+int __tag foo(struct t1 __tag *arg) {
+  return arg->a;

in this case, second __tag, does it apply to function argument, or pointer, or 
pointer's pointee (struct t1)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106614

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


[PATCH] D106920: [AIX] Update fetch_and_add type

2021-07-27 Thread Jinsong Ji via Phabricator via cfe-commits
jsji created this revision.
Herald added subscribers: steven.zhang, kbarton, nemanjai.
jsji requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

It turns out that AIX kernerl are definiing int instead of unsing int
for fectch_and_add.

Legacy XL also define this to be signed.

https://www.ibm.com/docs/en/aix/7.2?topic=f-fetch-add-kernel-services

So update the type for compat.

Reviewere: hubert.reinterpretcast, Whitney, #PowerPC 



Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106920

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/test/CodeGen/builtins-ppc-xlcompat-fetch-error.c
  clang/test/CodeGen/builtins-ppc-xlcompat-fetch.c


Index: clang/test/CodeGen/builtins-ppc-xlcompat-fetch.c
===
--- clang/test/CodeGen/builtins-ppc-xlcompat-fetch.c
+++ clang/test/CodeGen/builtins-ppc-xlcompat-fetch.c
@@ -16,7 +16,7 @@
 // CHECK-NEXT:[[TMP2:%.*]] = atomicrmw add i32* [[A_ADDR]], i32 [[TMP1]] 
monotonic, align 4
 // CHECK-NEXT:ret void
 //
-void test_builtin_ppc_fetch_and_add(unsigned int a, unsigned int b) {
+void test_builtin_ppc_fetch_and_add(int a, unsigned int b) {
   __fetch_and_add(, b);
 }
 
@@ -31,7 +31,7 @@
 // CHECK-NEXT:[[TMP2:%.*]] = atomicrmw add i64* [[A_ADDR]], i64 [[TMP1]] 
monotonic, align 8
 // CHECK-NEXT:ret void
 //
-void test_builtin_ppc_fetch_and_addlp(unsigned long a, unsigned long b) {
+void test_builtin_ppc_fetch_and_addlp(long a, unsigned long b) {
   __fetch_and_addlp(, b);
 }
 // CHECK-LABEL: @test_builtin_ppc_fetch_and_and(
Index: clang/test/CodeGen/builtins-ppc-xlcompat-fetch-error.c
===
--- clang/test/CodeGen/builtins-ppc-xlcompat-fetch-error.c
+++ clang/test/CodeGen/builtins-ppc-xlcompat-fetch-error.c
@@ -1,17 +1,18 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
 // REQUIRES: powerpc-registered-target
 // RUN: %clang_cc1 -triple powerpc64-unknown-aix -target-cpu pwr8 \
 // RUN:  -verify %s
 
 void test_builtin_ppc_fetch_and_add2() {
-  volatile int a = 0;
+  volatile unsigned int a = 0;
   unsigned int b = 0;
 
-  __fetch_and_add(, b); // expected-warning {{passing 'volatile int *' to 
parameter of type 'volatile unsigned int *' converts between pointers to 
integer types with different sign}}
+  __fetch_and_add(, b); // expected-warning {{passing 'volatile unsigned int 
*' to parameter of type 'volatile int *' converts between pointers to integer 
types with different sign}}
 }
 
 void test_builtin_ppc_fetch_and_addlp() {
-  volatile long a = 0;
+  volatile unsigned long a = 0;
   unsigned long b = 0;
 
-  __fetch_and_addlp(, b); // expected-warning {{passing 'volatile long *' to 
parameter of type 'volatile unsigned long *' converts between pointers to 
integer types with different sign}}
+  __fetch_and_addlp(, b); // expected-warning {{passing 'volatile unsigned 
long *' to parameter of type 'volatile long *' converts between pointers to 
integer types with different sign}}
 }
Index: clang/include/clang/Basic/BuiltinsPPC.def
===
--- clang/include/clang/Basic/BuiltinsPPC.def
+++ clang/include/clang/Basic/BuiltinsPPC.def
@@ -64,8 +64,8 @@
 BUILTIN(__builtin_ppc_fsqrts, "ff", "")
 BUILTIN(__builtin_ppc_compare_and_swap, "iiD*i*i", "")
 BUILTIN(__builtin_ppc_compare_and_swaplp, "iLiD*Li*Li", "")
-BUILTIN(__builtin_ppc_fetch_and_add, "UiUiD*Ui", "")
-BUILTIN(__builtin_ppc_fetch_and_addlp, "ULiULiD*ULi", "")
+BUILTIN(__builtin_ppc_fetch_and_add, "iiD*i", "")
+BUILTIN(__builtin_ppc_fetch_and_addlp, "LiLiD*Li", "")
 BUILTIN(__builtin_ppc_fetch_and_and, "UiUiD*Ui", "")
 BUILTIN(__builtin_ppc_fetch_and_andlp, "ULiULiD*ULi", "")
 BUILTIN(__builtin_ppc_fetch_and_or, "UiUiD*Ui", "")


Index: clang/test/CodeGen/builtins-ppc-xlcompat-fetch.c
===
--- clang/test/CodeGen/builtins-ppc-xlcompat-fetch.c
+++ clang/test/CodeGen/builtins-ppc-xlcompat-fetch.c
@@ -16,7 +16,7 @@
 // CHECK-NEXT:[[TMP2:%.*]] = atomicrmw add i32* [[A_ADDR]], i32 [[TMP1]] monotonic, align 4
 // CHECK-NEXT:ret void
 //
-void test_builtin_ppc_fetch_and_add(unsigned int a, unsigned int b) {
+void test_builtin_ppc_fetch_and_add(int a, unsigned int b) {
   __fetch_and_add(, b);
 }
 
@@ -31,7 +31,7 @@
 // CHECK-NEXT:[[TMP2:%.*]] = atomicrmw add i64* [[A_ADDR]], i64 [[TMP1]] monotonic, align 8
 // CHECK-NEXT:ret void
 //
-void test_builtin_ppc_fetch_and_addlp(unsigned long a, unsigned long b) {
+void test_builtin_ppc_fetch_and_addlp(long a, unsigned long b) {
   __fetch_and_addlp(, b);
 }
 // CHECK-LABEL: @test_builtin_ppc_fetch_and_and(
Index: clang/test/CodeGen/builtins-ppc-xlcompat-fetch-error.c
===
--- 

[PATCH] D106701: [clang] Add -falign-loops=N where N is a power of 2

2021-07-27 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

Does this work with LTO?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106701

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


[PATCH] D106854: Pass `--start-group` and `--end-group` to the linker when using the AVR toolchain

2021-07-27 Thread Matt Jacobson via Phabricator via cfe-commits
mhjacobson updated this revision to Diff 362185.
mhjacobson added a comment.

Modified regression test `Driver/avr-ld.c` to account for the new arguments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106854

Files:
  clang/lib/Driver/ToolChains/AVR.cpp
  clang/test/Driver/avr-ld.c


Index: clang/test/Driver/avr-ld.c
===
--- clang/test/Driver/avr-ld.c
+++ clang/test/Driver/avr-ld.c
@@ -1,44 +1,44 @@
 // RUN: %clang -### --target=avr -mmcu=at90s2313 --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKA %s
-// LINKA: {{".*ld.*"}} {{.*}} {{"-L.*tiny-stack"}} {{.*}} "-Tdata=0x800060" 
{{.*}} "-lat90s2313" "-mavr2"
+// LINKA: {{".*ld.*"}} {{.*}} {{"-L.*tiny-stack"}} {{.*}} "-Tdata=0x800060" 
{{.*}} "-lat90s2313" {{.*}} "-mavr2"
 
 // RUN: %clang -### --target=avr -mmcu=at90s8515 --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKB %s
-// LINKB: {{".*ld.*"}} {{.*}} "-Tdata=0x800060" {{.*}} "-lat90s8515" "-mavr2"
+// LINKB: {{".*ld.*"}} {{.*}} "-Tdata=0x800060" {{.*}} "-lat90s8515" {{.*}} 
"-mavr2"
 
 // RUN: %clang -### --target=avr -mmcu=attiny13 --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKC %s
-// LINKC: {{".*ld.*"}} {{.*}} {{"-L.*avr25/tiny-stack"}} {{.*}} 
"-Tdata=0x800060" {{.*}} "-lattiny13" "-mavr25"
+// LINKC: {{".*ld.*"}} {{.*}} {{"-L.*avr25/tiny-stack"}} {{.*}} 
"-Tdata=0x800060" {{.*}} "-lattiny13" {{.*}} "-mavr25"
 
 // RUN: %clang -### --target=avr -mmcu=attiny44 --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKD %s
-// LINKD: {{".*ld.*"}} {{.*}} {{"-L.*avr25"}} {{.*}} "-Tdata=0x800060" {{.*}} 
"-lattiny44" "-mavr25"
+// LINKD: {{".*ld.*"}} {{.*}} {{"-L.*avr25"}} {{.*}} "-Tdata=0x800060" {{.*}} 
"-lattiny44" {{.*}} "-mavr25"
 
 // RUN: %clang -### --target=avr -mmcu=atmega103 --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKE %s
-// LINKE: {{".*ld.*"}} {{.*}} {{"-L.*avr31"}} {{.*}} "-Tdata=0x800060" {{.*}} 
"-latmega103" "-mavr31"
+// LINKE: {{".*ld.*"}} {{.*}} {{"-L.*avr31"}} {{.*}} "-Tdata=0x800060" {{.*}} 
"-latmega103" {{.*}} "-mavr31"
 
 // RUN: %clang -### --target=avr -mmcu=atmega8u2 --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKF %s
-// LINKF: {{".*ld.*"}} {{.*}} {{"-L.*avr35"}} {{.*}} "-Tdata=0x800100" {{.*}} 
"-latmega8u2" "-mavr35"
+// LINKF: {{".*ld.*"}} {{.*}} {{"-L.*avr35"}} {{.*}} "-Tdata=0x800100" {{.*}} 
"-latmega8u2" {{.*}} "-mavr35"
 
 // RUN: %clang -### --target=avr -mmcu=atmega48pa --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKG %s
-// LINKG: {{".*ld.*"}} {{.*}} {{"-L.*avr4"}} {{.*}} "-Tdata=0x800100" {{.*}} 
"-latmega48pa" "-mavr4"
+// LINKG: {{".*ld.*"}} {{.*}} {{"-L.*avr4"}} {{.*}} "-Tdata=0x800100" {{.*}} 
"-latmega48pa" {{.*}} "-mavr4"
 
 // RUN: %clang -### --target=avr -mmcu=atmega328 --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKH %s
-// LINKH: {{".*ld.*"}} {{.*}} {{"-L.*avr5"}} {{.*}} "-Tdata=0x800100" {{.*}} 
"-latmega328" "-mavr5"
+// LINKH: {{".*ld.*"}} {{.*}} {{"-L.*avr5"}} {{.*}} "-Tdata=0x800100" {{.*}} 
"-latmega328" {{.*}} "-mavr5"
 
 // RUN: %clang -### --target=avr -mmcu=atmega1281 --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKI %s
-// LINKI: {{".*ld.*"}} {{.*}} {{"-L.*avr51"}} {{.*}} "-Tdata=0x800200" {{.*}} 
"-latmega1281" "-mavr51"
+// LINKI: {{".*ld.*"}} {{.*}} {{"-L.*avr51"}} {{.*}} "-Tdata=0x800200" {{.*}} 
"-latmega1281" {{.*}} "-mavr51"
 
 // RUN: %clang -### --target=avr -mmcu=atmega2560 --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKJ %s
-// LINKJ: {{".*ld.*"}} {{.*}} {{"-L.*avr6"}} {{.*}} "-Tdata=0x800200" {{.*}} 
"-latmega2560" "-mavr6"
+// LINKJ: {{".*ld.*"}} {{.*}} {{"-L.*avr6"}} {{.*}} "-Tdata=0x800200" {{.*}} 
"-latmega2560" {{.*}} "-mavr6"
 
 // RUN: %clang -### --target=avr -mmcu=attiny10 --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKK %s
-// LINKK: {{".*ld.*"}} {{.*}} {{"-L.*avrtiny"}} {{.*}} "-Tdata=0x800040" 
{{.*}} "-lattiny10" "-mavrtiny"
+// LINKK: {{".*ld.*"}} {{.*}} {{"-L.*avrtiny"}} {{.*}} "-Tdata=0x800040" 
{{.*}} "-lattiny10" {{.*}} "-mavrtiny"
 
 // RUN: %clang -### --target=avr -mmcu=atxmega16a4 --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKL %s
-// LINKL: {{".*ld.*"}} {{.*}} {{"-L.*avrxmega2"}} {{.*}} "-Tdata=0x802000" 
{{.*}} "-latxmega16a4" "-mavrxmega2"
+// LINKL: {{".*ld.*"}} {{.*}} {{"-L.*avrxmega2"}} {{.*}} "-Tdata=0x802000" 
{{.*}} "-latxmega16a4" {{.*}} "-mavrxmega2"
 
 // RUN: %clang -### --target=avr -mmcu=atxmega64b3 --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKM %s
-// LINKM: {{".*ld.*"}} {{.*}} {{"-L.*avrxmega4"}} {{.*}} "-Tdata=0x802000" 
{{.*}} "-latxmega64b3" "-mavrxmega4"
+// LINKM: {{".*ld.*"}} {{.*}} 

[PATCH] D106298: [OpenMP] Creating the `omp_target_num_teams` and `omp_target_thread_limit` attributes to outlined functions

2021-07-27 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 rG0276db14167b: [OpenMP] Creating the `omp_target_num_teams` 
and `omp_target_thread_limit`… (authored by Jose M Monsalve Diaz 
jmonsalved...@anl.gov, committed by tianshilei1992).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106298

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/test/OpenMP/declare_target_codegen_globalization.cpp
  clang/test/OpenMP/nvptx_lambda_capturing.cpp
  clang/test/OpenMP/nvptx_multi_target_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_target_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_num_threads_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/target_map_codegen_03.cpp
  clang/test/OpenMP/target_num_teams_num_threads_attributes.cpp
  clang/test/OpenMP/target_parallel_codegen.cpp
  clang/test/OpenMP/target_parallel_debug_codegen.cpp
  clang/test/OpenMP/target_parallel_for_codegen.cpp
  clang/test/OpenMP/target_parallel_for_debug_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/target_parallel_if_codegen.cpp
  clang/test/OpenMP/target_parallel_num_threads_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_collapse_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_dist_schedule_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_private_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_reduction_codegen.cpp
  clang/test/OpenMP/target_teams_num_teams_codegen.cpp
  clang/test/OpenMP/target_teams_thread_limit_codegen.cpp
  clang/test/OpenMP/teams_codegen.cpp

___
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-27 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA added inline comments.



Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:262-269
+  if (T.isOSAIX()) {
+// Pass -b prefix for AIX linker.
+A.claim();
+A.render(Args, CmdArgs);
+continue;
+  } else {
+TC.getDriver().Diag(diag::err_drv_unsupported_opt)

Can this be reversed so the error check is first for `(!T.isOSAIX())` instead? 
Then you don't need the `else`. 



Comment at: clang/test/Driver/Xlinker-args.c:15-16
+
+// RUN: %clang -target powerpc-unknown-aix -### \
+// RUN:   -b one %s 2> %t
+// RUN: FileCheck -check-prefix=AIX < %t %s

Does this mean that we need space between `-b` and the linker option when using 
clang normally? Or this an artifact of the way we need to write tests? 


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] D106903: [dfsan][NFC] Describe how origin trace tracking works

2021-07-27 Thread 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 rGc49df15c2788: [dfsan][NFC] Describe how origin trace 
tracking works (authored by Jianzhou Zhao jianzho...@google.com).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106903

Files:
  clang/docs/DataFlowSanitizerDesign.rst


Index: clang/docs/DataFlowSanitizerDesign.rst
===
--- clang/docs/DataFlowSanitizerDesign.rst
+++ clang/docs/DataFlowSanitizerDesign.rst
@@ -135,6 +135,35 @@
 track of what labels they have used so far, picking one that is yet
 unused, etc).
 
+Origin tracking trace representation
+
+
+An origin tracking trace is a list of chains. Each chain has a stack trace
+where the DFSan runtime records a label propapation, and a pointer to its
+previous chain. The very first chain does not point to any chain.
+
+Every four 4-bytes aligned application bytes share a 4-byte origin trace ID. A
+4-byte origin trace ID contains a 4-bit depth and a 28-bit hash ID of a chain.
+
+A chain ID is calculated as a hash from a chain structure. A chain structure
+contains a stack ID and the previous chain ID. The chain head has a zero
+previous chain ID. A stack ID is a hash from a stack trace. The 4-bit depth
+limits the maximal length of a path. The environment variable 
``origin_history_size``
+can set the depth limit. Non-positive values mean unlimited. Its default value
+is 16. When reaching the limit, origin tracking ignores following propagation
+chains.
+
+The first chain of a trace starts by `dfsan_set_label` with non-zero labels. A
+new chain is appended at the end of a trace at stores or memory transfers when
+``-dfsan-track-origins`` is 1. Memory transfers include LLVM memory transfer
+instructions, glibc memcpy and memmove. When ``-dfsan-track-origins`` is 2, a
+new chain is also appended at loads.
+
+Other instructions do not create new chains, but simply propagate origin trace
+IDs. If an instruction has more than one operands with non-zero labels, the 
origin
+treace ID of the last operand with non-zero label is propagated to the result 
of
+the instruction.
+
 Memory layout and label management
 --
 


Index: clang/docs/DataFlowSanitizerDesign.rst
===
--- clang/docs/DataFlowSanitizerDesign.rst
+++ clang/docs/DataFlowSanitizerDesign.rst
@@ -135,6 +135,35 @@
 track of what labels they have used so far, picking one that is yet
 unused, etc).
 
+Origin tracking trace representation
+
+
+An origin tracking trace is a list of chains. Each chain has a stack trace
+where the DFSan runtime records a label propapation, and a pointer to its
+previous chain. The very first chain does not point to any chain.
+
+Every four 4-bytes aligned application bytes share a 4-byte origin trace ID. A
+4-byte origin trace ID contains a 4-bit depth and a 28-bit hash ID of a chain.
+
+A chain ID is calculated as a hash from a chain structure. A chain structure
+contains a stack ID and the previous chain ID. The chain head has a zero
+previous chain ID. A stack ID is a hash from a stack trace. The 4-bit depth
+limits the maximal length of a path. The environment variable ``origin_history_size``
+can set the depth limit. Non-positive values mean unlimited. Its default value
+is 16. When reaching the limit, origin tracking ignores following propagation
+chains.
+
+The first chain of a trace starts by `dfsan_set_label` with non-zero labels. A
+new chain is appended at the end of a trace at stores or memory transfers when
+``-dfsan-track-origins`` is 1. Memory transfers include LLVM memory transfer
+instructions, glibc memcpy and memmove. When ``-dfsan-track-origins`` is 2, a
+new chain is also appended at loads.
+
+Other instructions do not create new chains, but simply propagate origin trace
+IDs. If an instruction has more than one operands with non-zero labels, the origin
+treace ID of the last operand with non-zero label is propagated to the result of
+the instruction.
+
 Memory layout and label management
 --
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] c49df15 - [dfsan][NFC] Describe how origin trace tracking works

2021-07-27 Thread Jianzhou Zhao via cfe-commits

Author: Jianzhou Zhao
Date: 2021-07-27T21:10:39Z
New Revision: c49df15c278857adecd12db6bb1cdc96885f7079

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

LOG: [dfsan][NFC] Describe how origin trace tracking works

Reviewed By: gbalats

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

Added: 


Modified: 
clang/docs/DataFlowSanitizerDesign.rst

Removed: 




diff  --git a/clang/docs/DataFlowSanitizerDesign.rst 
b/clang/docs/DataFlowSanitizerDesign.rst
index ea40fe332010..bed4d2f38cba 100644
--- a/clang/docs/DataFlowSanitizerDesign.rst
+++ b/clang/docs/DataFlowSanitizerDesign.rst
@@ -135,6 +135,35 @@ Users are responsible for managing the 8 integer labels 
(i.e., keeping
 track of what labels they have used so far, picking one that is yet
 unused, etc).
 
+Origin tracking trace representation
+
+
+An origin tracking trace is a list of chains. Each chain has a stack trace
+where the DFSan runtime records a label propapation, and a pointer to its
+previous chain. The very first chain does not point to any chain.
+
+Every four 4-bytes aligned application bytes share a 4-byte origin trace ID. A
+4-byte origin trace ID contains a 4-bit depth and a 28-bit hash ID of a chain.
+
+A chain ID is calculated as a hash from a chain structure. A chain structure
+contains a stack ID and the previous chain ID. The chain head has a zero
+previous chain ID. A stack ID is a hash from a stack trace. The 4-bit depth
+limits the maximal length of a path. The environment variable 
``origin_history_size``
+can set the depth limit. Non-positive values mean unlimited. Its default value
+is 16. When reaching the limit, origin tracking ignores following propagation
+chains.
+
+The first chain of a trace starts by `dfsan_set_label` with non-zero labels. A
+new chain is appended at the end of a trace at stores or memory transfers when
+``-dfsan-track-origins`` is 1. Memory transfers include LLVM memory transfer
+instructions, glibc memcpy and memmove. When ``-dfsan-track-origins`` is 2, a
+new chain is also appended at loads.
+
+Other instructions do not create new chains, but simply propagate origin trace
+IDs. If an instruction has more than one operands with non-zero labels, the 
origin
+treace ID of the last operand with non-zero label is propagated to the result 
of
+the instruction.
+
 Memory layout and label management
 --
 



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


[PATCH] D106907: [clang] fix concepts crash on substitution failure during normalization

2021-07-27 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov created this revision.
mizvekov edited the summary of this revision.
mizvekov added a reviewer: rsmith.
mizvekov added a subscriber: Quuxplusone.
mizvekov published this revision for review.
mizvekov added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This partially fixes https://bugs.llvm.org/show_bug.cgi?id=47174

It fixes the crash, but there is however a remaining issue, the bogus template 
lookup (`no template named 'Y'`) diagnostic from @Quuxplusone's reduced test 
case is still there.

So far as I have seen though, it is only a diagnostic issue.
I can't find an alternate test case with valid code (non ambiguous overload 
resolution or otherwise) that triggers that kind of error.


When substitution failed on the first constrained template argument (but
only the first), we would assert / crash. Checking for failure was only
being performed from the second constraint on.

This changes it so the checking is performed in that case,
and the code is also now simplified a little bit to hopefully
avoid this confusion.

Signed-off-by: Matheus Izvekov 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106907

Files:
  clang/lib/Sema/SemaConcept.cpp
  clang/test/CXX/temp/temp.constr/temp.constr.normal/p1.cpp


Index: clang/test/CXX/temp/temp.constr/temp.constr.normal/p1.cpp
===
--- clang/test/CXX/temp/temp.constr/temp.constr.normal/p1.cpp
+++ clang/test/CXX/temp/temp.constr/temp.constr.normal/p1.cpp
@@ -67,3 +67,14 @@
 
   static_assert((foo<1>(), true));
 }
+
+namespace PR47174 {
+  // This checks that we don't crash with a failed substitution on the first 
constrained argument when
+  // performing normalization.
+  template requires true struct S3;   // expected-note 
{{template is declared here}}
+  template requires true struct S3; // expected-error 
{{class template partial specialization is not more specialized than the 
primary template}}
+
+  // Same as above, for the second position (but this was already working).
+  template requires true struct S4;   // expected-note 
{{template is declared here}}
+  template requires true struct S4; // expected-error 
{{class template partial specialization is not more specialized than the 
primary template}}
+} // namespace PR47174
Index: clang/lib/Sema/SemaConcept.cpp
===
--- clang/lib/Sema/SemaConcept.cpp
+++ clang/lib/Sema/SemaConcept.cpp
@@ -741,23 +741,15 @@
 Optional
 NormalizedConstraint::fromConstraintExprs(Sema , NamedDecl *D,
   ArrayRef E) {
-  assert(E.size() != 0);
-  auto First = fromConstraintExpr(S, D, E[0]);
-  if (E.size() == 1)
-return First;
-  auto Second = fromConstraintExpr(S, D, E[1]);
-  if (!Second)
+  auto Conjunction = fromConstraintExpr(S, D, E[0]);
+  if (!Conjunction)
 return None;
-  llvm::Optional Conjunction;
-  Conjunction.emplace(S.Context, std::move(*First), std::move(*Second),
-  CCK_Conjunction);
-  for (unsigned I = 2; I < E.size(); ++I) {
+  for (unsigned I = 1; I < E.size(); ++I) {
 auto Next = fromConstraintExpr(S, D, E[I]);
 if (!Next)
-  return llvm::Optional{};
-NormalizedConstraint NewConjunction(S.Context, std::move(*Conjunction),
-std::move(*Next), CCK_Conjunction);
-*Conjunction = std::move(NewConjunction);
+  return None;
+Conjunction.emplace(S.Context, std::move(*Conjunction), std::move(*Next),
+CCK_Conjunction);
   }
   return Conjunction;
 }


Index: clang/test/CXX/temp/temp.constr/temp.constr.normal/p1.cpp
===
--- clang/test/CXX/temp/temp.constr/temp.constr.normal/p1.cpp
+++ clang/test/CXX/temp/temp.constr/temp.constr.normal/p1.cpp
@@ -67,3 +67,14 @@
 
   static_assert((foo<1>(), true));
 }
+
+namespace PR47174 {
+  // This checks that we don't crash with a failed substitution on the first constrained argument when
+  // performing normalization.
+  template requires true struct S3;   // expected-note {{template is declared here}}
+  template requires true struct S3; // expected-error {{class template partial specialization is not more specialized than the primary template}}
+
+  // Same as above, for the second position (but this was already working).
+  template requires true struct S4;   // expected-note {{template is declared here}}
+  template requires true struct S4; // expected-error {{class template partial specialization is not more specialized than the primary template}}
+} // namespace PR47174
Index: clang/lib/Sema/SemaConcept.cpp
===
--- clang/lib/Sema/SemaConcept.cpp
+++ clang/lib/Sema/SemaConcept.cpp
@@ -741,23 +741,15 @@
 Optional
 NormalizedConstraint::fromConstraintExprs(Sema , NamedDecl *D,
   

[PATCH] D105972: Fix __attribute__((annotate("")) with non-zero globals AS

2021-07-27 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson added a comment.

ping?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105972

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


[PATCH] D104601: [Preprocessor] Implement -fminimize-whitespace.

2021-07-27 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added a comment.

Looking into it...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104601

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


[PATCH] D106903: [dfsan][NFC] Describe how origin trace tracking works

2021-07-27 Thread stephan.yichao.zhao via Phabricator via cfe-commits
stephan.yichao.zhao updated this revision to Diff 362161.
stephan.yichao.zhao added a comment.

typos


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106903

Files:
  clang/docs/DataFlowSanitizerDesign.rst


Index: clang/docs/DataFlowSanitizerDesign.rst
===
--- clang/docs/DataFlowSanitizerDesign.rst
+++ clang/docs/DataFlowSanitizerDesign.rst
@@ -135,6 +135,35 @@
 track of what labels they have used so far, picking one that is yet
 unused, etc).
 
+Origin tracking trace representation
+
+
+An origin tracking trace is a list of chains. Each chain has a stack trace
+where the DFSan runtime records a label propapation, and a pointer to its
+previous chain. The very first chain does not point to any chain.
+
+Every four 4-bytes aligned application bytes share a 4-byte origin trace ID. A
+4-byte origin trace ID contains a 4-bit depth and a 28-bit hash ID of a chain.
+
+A chain ID is calculated as a hash from a chain structure. A chain structure
+contains a stack ID and the previous chain ID. The chain head has a zero
+previous chain ID. A stack ID is a hash from a stack trace. The 4-bit depth
+limits the maximal length of a path. The environment variable 
``origin_history_size``
+can set the depth limit. Non-positive values mean unlimited. Its default value
+is 16. When reaching the limit, origin tracking ignores following propagation
+chains.
+
+The first chain of a trace starts by `dfsan_set_label` with non-zero labels. A
+new chain is appended at the end of a trace at stores or memory transfers when
+``-dfsan-track-origins`` is 1. Memory transfers include LLVM memory transfer
+instructions, glibc memcpy and memmove. When ``-dfsan-track-origins`` is 2, a
+new chain is also appended at loads.
+
+Other instructions do not create new chains, but simply propagate origin trace
+IDs. If an instruction has more than one operands with non-zero labels, the 
origin
+treace ID of the last operand with non-zero label is propagated to the result 
of
+the instruction.
+
 Memory layout and label management
 --
 


Index: clang/docs/DataFlowSanitizerDesign.rst
===
--- clang/docs/DataFlowSanitizerDesign.rst
+++ clang/docs/DataFlowSanitizerDesign.rst
@@ -135,6 +135,35 @@
 track of what labels they have used so far, picking one that is yet
 unused, etc).
 
+Origin tracking trace representation
+
+
+An origin tracking trace is a list of chains. Each chain has a stack trace
+where the DFSan runtime records a label propapation, and a pointer to its
+previous chain. The very first chain does not point to any chain.
+
+Every four 4-bytes aligned application bytes share a 4-byte origin trace ID. A
+4-byte origin trace ID contains a 4-bit depth and a 28-bit hash ID of a chain.
+
+A chain ID is calculated as a hash from a chain structure. A chain structure
+contains a stack ID and the previous chain ID. The chain head has a zero
+previous chain ID. A stack ID is a hash from a stack trace. The 4-bit depth
+limits the maximal length of a path. The environment variable ``origin_history_size``
+can set the depth limit. Non-positive values mean unlimited. Its default value
+is 16. When reaching the limit, origin tracking ignores following propagation
+chains.
+
+The first chain of a trace starts by `dfsan_set_label` with non-zero labels. A
+new chain is appended at the end of a trace at stores or memory transfers when
+``-dfsan-track-origins`` is 1. Memory transfers include LLVM memory transfer
+instructions, glibc memcpy and memmove. When ``-dfsan-track-origins`` is 2, a
+new chain is also appended at loads.
+
+Other instructions do not create new chains, but simply propagate origin trace
+IDs. If an instruction has more than one operands with non-zero labels, the origin
+treace ID of the last operand with non-zero label is propagated to the result of
+the instruction.
+
 Memory layout and label management
 --
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106914: [libclang] Check LLVM_HAVE_LINK_VERSION_SCRIPT

2021-07-27 Thread Tom Stellard via Phabricator via cfe-commits
tstellar added a comment.

LGTM. Thanks for fixing this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106914

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


[PATCH] D106914: [libclang] Check LLVM_HAVE_LINK_VERSION_SCRIPT

2021-07-27 Thread Jinsong Ji 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 rGe07f9342be71: [libclang] Check LLVM_HAVE_LINK_VERSION_SCRIPT 
(authored by jsji).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106914

Files:
  clang/tools/libclang/CMakeLists.txt


Index: clang/tools/libclang/CMakeLists.txt
===
--- clang/tools/libclang/CMakeLists.txt
+++ clang/tools/libclang/CMakeLists.txt
@@ -76,7 +76,7 @@
 
 if (UNIX AND NOT APPLE)
   set(LLVM_EXPORTED_SYMBOL_FILE)
-  set(USE_VERSION_SCRIPT TRUE)
+  set(USE_VERSION_SCRIPT ${LLVM_HAVE_LINK_VERSION_SCRIPT})
 endif()
 
 if (LLVM_EXPORTED_SYMBOL_FILE)


Index: clang/tools/libclang/CMakeLists.txt
===
--- clang/tools/libclang/CMakeLists.txt
+++ clang/tools/libclang/CMakeLists.txt
@@ -76,7 +76,7 @@
 
 if (UNIX AND NOT APPLE)
   set(LLVM_EXPORTED_SYMBOL_FILE)
-  set(USE_VERSION_SCRIPT TRUE)
+  set(USE_VERSION_SCRIPT ${LLVM_HAVE_LINK_VERSION_SCRIPT})
 endif()
 
 if (LLVM_EXPORTED_SYMBOL_FILE)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106903: [dfsan][NFC] Describe how origin trace tracking works

2021-07-27 Thread stephan.yichao.zhao via Phabricator via cfe-commits
stephan.yichao.zhao updated this revision to Diff 362159.
stephan.yichao.zhao added a comment.

tweak


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106903

Files:
  clang/docs/DataFlowSanitizerDesign.rst


Index: clang/docs/DataFlowSanitizerDesign.rst
===
--- clang/docs/DataFlowSanitizerDesign.rst
+++ clang/docs/DataFlowSanitizerDesign.rst
@@ -135,6 +135,35 @@
 track of what labels they have used so far, picking one that is yet
 unused, etc).
 
+Origin tracking trace representation
+
+
+An origin tracking trace is a list of chains. Each chain has a stack trace
+where the DFSan runtime records a label propapation, and a pointer to its
+previous chain. The very first chain does not point to any chain.
+
+Every four 4-bytes aligned application bytes share a 4-byte origin trace ID. A
+4-byte origin trace ID contains a 4-bit depth and a 28-bit hash ID of a chain.
+
+A chain ID is calculated as a hash from a chain structure. A chain structure
+contains a stack ID and the previous chain ID. The chain head has a zero
+previous chain ID. A stack ID is a hash from a stack trace. The 4-bit depth
+limits the maximal length of a path. The environment variable 
``origin_history_size``
+can set the depth limit. Non-positive values mean unlimited. Its default value
+is 16. When reaching the limit, origin tracking ignores following propagation
+chains.
+
+The first chain of a trace starts by `dfsan_set_label` with non-zero labels. A
+new chain is appended at the end of a trace at stores or memory transfers when
+``-dfsan-track-origins`` is 1. Memory transfers include LLVM memory transfer
+instructions and wrapped glibc memcpy and memmove. When 
``-dfsan-track-origins``
+is 2, a new chain is also appended at loads.
+
+Other instructions do not create new chains, but simply propagate origin trace
+IDs. If an instruction has more than one operands with non-zero labels, the 
origin
+treace ID of the last operand with non-zero label is propagated to the result 
of
+this instruction.
+
 Memory layout and label management
 --
 


Index: clang/docs/DataFlowSanitizerDesign.rst
===
--- clang/docs/DataFlowSanitizerDesign.rst
+++ clang/docs/DataFlowSanitizerDesign.rst
@@ -135,6 +135,35 @@
 track of what labels they have used so far, picking one that is yet
 unused, etc).
 
+Origin tracking trace representation
+
+
+An origin tracking trace is a list of chains. Each chain has a stack trace
+where the DFSan runtime records a label propapation, and a pointer to its
+previous chain. The very first chain does not point to any chain.
+
+Every four 4-bytes aligned application bytes share a 4-byte origin trace ID. A
+4-byte origin trace ID contains a 4-bit depth and a 28-bit hash ID of a chain.
+
+A chain ID is calculated as a hash from a chain structure. A chain structure
+contains a stack ID and the previous chain ID. The chain head has a zero
+previous chain ID. A stack ID is a hash from a stack trace. The 4-bit depth
+limits the maximal length of a path. The environment variable ``origin_history_size``
+can set the depth limit. Non-positive values mean unlimited. Its default value
+is 16. When reaching the limit, origin tracking ignores following propagation
+chains.
+
+The first chain of a trace starts by `dfsan_set_label` with non-zero labels. A
+new chain is appended at the end of a trace at stores or memory transfers when
+``-dfsan-track-origins`` is 1. Memory transfers include LLVM memory transfer
+instructions and wrapped glibc memcpy and memmove. When ``-dfsan-track-origins``
+is 2, a new chain is also appended at loads.
+
+Other instructions do not create new chains, but simply propagate origin trace
+IDs. If an instruction has more than one operands with non-zero labels, the origin
+treace ID of the last operand with non-zero label is propagated to the result of
+this instruction.
+
 Memory layout and label management
 --
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] e07f934 - [libclang] Check LLVM_HAVE_LINK_VERSION_SCRIPT

2021-07-27 Thread Jinsong Ji via cfe-commits

Author: Jinsong Ji
Date: 2021-07-27T20:18:50Z
New Revision: e07f9342be7132f433963880d95e471ae2246d64

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

LOG: [libclang] Check LLVM_HAVE_LINK_VERSION_SCRIPT

There are some platform that might not have version script support,
don't try to use version script on those.

Reviewed By: MaskRay, hubert.reinterpretcast

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

Added: 


Modified: 
clang/tools/libclang/CMakeLists.txt

Removed: 




diff  --git a/clang/tools/libclang/CMakeLists.txt 
b/clang/tools/libclang/CMakeLists.txt
index 65863d7508a8c..8cc0fc622174a 100644
--- a/clang/tools/libclang/CMakeLists.txt
+++ b/clang/tools/libclang/CMakeLists.txt
@@ -76,7 +76,7 @@ endif()
 
 if (UNIX AND NOT APPLE)
   set(LLVM_EXPORTED_SYMBOL_FILE)
-  set(USE_VERSION_SCRIPT TRUE)
+  set(USE_VERSION_SCRIPT ${LLVM_HAVE_LINK_VERSION_SCRIPT})
 endif()
 
 if (LLVM_EXPORTED_SYMBOL_FILE)



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


[PATCH] D106903: [dfsan][NFC] Describe how origin trace tracking works

2021-07-27 Thread stephan.yichao.zhao via Phabricator via cfe-commits
stephan.yichao.zhao updated this revision to Diff 362158.
stephan.yichao.zhao added a comment.

explained what a trace and a chain are.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106903

Files:
  clang/docs/DataFlowSanitizerDesign.rst


Index: clang/docs/DataFlowSanitizerDesign.rst
===
--- clang/docs/DataFlowSanitizerDesign.rst
+++ clang/docs/DataFlowSanitizerDesign.rst
@@ -135,6 +135,35 @@
 track of what labels they have used so far, picking one that is yet
 unused, etc).
 
+Origin tracking trace representation
+
+
+An origin tracking trace is a list of chains. Each chain has a stack trace
+where the DFSan runtime records a label propapation, and a pointer to its
+previous chain. The very first chain does not point to any chain.
+
+Every four 4-bytes aligned application bytes share a 4-byte origin trace ID. A
+4-byte origin trace ID contains a 4-bit depth and a 28-bit hash ID of a chain.
+
+A chain ID is calculated as a hash from a chain structure. A chain structure
+contains a stack ID and the previous chain ID. The chain head has a zero
+previous chain ID. A stack ID is a hash from a stack trace. The 4-bit depth
+limits the maximal length of a path. The environment variable 
``origin_history_size``
+can set the depth limit. Non-positive values mean unlimited. Its default value
+is 16. When reaching the limit, origin tracking ignores following propagation
+chains.
+
+The first chain of a trace starts by `dfsan_set_label` with non-zero labels. A
+new chain is appended at the end of a trace at stores or memory-transfer when
+``-dfsan-track-origins`` is 1. Memory transfers include LLVM memory transfer
+instructions and wrapped glibc memcpy and memmove. When 
``-dfsan-track-origins``
+is 2, a new chain is also appended at loads.
+
+Other instructions do not create new chains, but simply propagate origin trace
+IDs. If an instruction has more than one operands with non-zero labels, the 
origin
+treace ID of the last operand with non-zero label is propagated to the result 
of
+this instruction.
+
 Memory layout and label management
 --
 


Index: clang/docs/DataFlowSanitizerDesign.rst
===
--- clang/docs/DataFlowSanitizerDesign.rst
+++ clang/docs/DataFlowSanitizerDesign.rst
@@ -135,6 +135,35 @@
 track of what labels they have used so far, picking one that is yet
 unused, etc).
 
+Origin tracking trace representation
+
+
+An origin tracking trace is a list of chains. Each chain has a stack trace
+where the DFSan runtime records a label propapation, and a pointer to its
+previous chain. The very first chain does not point to any chain.
+
+Every four 4-bytes aligned application bytes share a 4-byte origin trace ID. A
+4-byte origin trace ID contains a 4-bit depth and a 28-bit hash ID of a chain.
+
+A chain ID is calculated as a hash from a chain structure. A chain structure
+contains a stack ID and the previous chain ID. The chain head has a zero
+previous chain ID. A stack ID is a hash from a stack trace. The 4-bit depth
+limits the maximal length of a path. The environment variable ``origin_history_size``
+can set the depth limit. Non-positive values mean unlimited. Its default value
+is 16. When reaching the limit, origin tracking ignores following propagation
+chains.
+
+The first chain of a trace starts by `dfsan_set_label` with non-zero labels. A
+new chain is appended at the end of a trace at stores or memory-transfer when
+``-dfsan-track-origins`` is 1. Memory transfers include LLVM memory transfer
+instructions and wrapped glibc memcpy and memmove. When ``-dfsan-track-origins``
+is 2, a new chain is also appended at loads.
+
+Other instructions do not create new chains, but simply propagate origin trace
+IDs. If an instruction has more than one operands with non-zero labels, the origin
+treace ID of the last operand with non-zero label is propagated to the result of
+this instruction.
+
 Memory layout and label management
 --
 
___
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-27 Thread Jinsong Ji via Phabricator via cfe-commits
jsji added inline comments.



Comment at: clang/tools/libclang/CMakeLists.txt:79
+  set(LLVM_EXPORTED_SYMBOL_FILE)
+  set(USE_VERSION_SCRIPT TRUE)
+endif()

jsji wrote:
> I think we should check LLVM_HAVE_LINK_VERSION_SCRIPT here, there are 
> platforms that does NOT support VERSION_SCRIPT.
https://reviews.llvm.org/D106914 posted to fix it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105527

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


[PATCH] D106914: [libclang] Check LLVM_HAVE_LINK_VERSION_SCRIPT

2021-07-27 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast accepted this revision.
hubert.reinterpretcast added a comment.
This revision is now accepted and ready to land.

LGTM; thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106914

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


[PATCH] D106914: [libclang] Check LLVM_HAVE_LINK_VERSION_SCRIPT

2021-07-27 Thread Jinsong Ji via Phabricator via cfe-commits
jsji created this revision.
jsji added reviewers: PowerPC, tstellar, MaskRay, hubert.reinterpretcast.
Herald added a subscriber: mgorny.
jsji requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

There are some platform that might not have version script support,
don't try to use version script on those.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106914

Files:
  clang/tools/libclang/CMakeLists.txt


Index: clang/tools/libclang/CMakeLists.txt
===
--- clang/tools/libclang/CMakeLists.txt
+++ clang/tools/libclang/CMakeLists.txt
@@ -76,7 +76,7 @@
 
 if (UNIX AND NOT APPLE)
   set(LLVM_EXPORTED_SYMBOL_FILE)
-  set(USE_VERSION_SCRIPT TRUE)
+  set(USE_VERSION_SCRIPT ${LLVM_HAVE_LINK_VERSION_SCRIPT})
 endif()
 
 if (LLVM_EXPORTED_SYMBOL_FILE)


Index: clang/tools/libclang/CMakeLists.txt
===
--- clang/tools/libclang/CMakeLists.txt
+++ clang/tools/libclang/CMakeLists.txt
@@ -76,7 +76,7 @@
 
 if (UNIX AND NOT APPLE)
   set(LLVM_EXPORTED_SYMBOL_FILE)
-  set(USE_VERSION_SCRIPT TRUE)
+  set(USE_VERSION_SCRIPT ${LLVM_HAVE_LINK_VERSION_SCRIPT})
 endif()
 
 if (LLVM_EXPORTED_SYMBOL_FILE)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106858: [hwasan] Fix stack safety test for old PM.

2021-07-27 Thread Florian Mayer 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 rG835ef6f93d57: [hwasan] Fix stack safety test for old PM. 
(authored by fmayer).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106858

Files:
  clang/test/CodeGen/hwasan-stack-safety-analysis.c


Index: clang/test/CodeGen/hwasan-stack-safety-analysis.c
===
--- clang/test/CodeGen/hwasan-stack-safety-analysis.c
+++ clang/test/CodeGen/hwasan-stack-safety-analysis.c
@@ -1,5 +1,8 @@
-// RUN: %clang -fsanitize=hwaddress -target aarch64-linux-gnu -S -emit-llvm 
-mllvm -hwasan-use-stack-safety=true -mllvm -hwasan-generate-tags-with-calls 
-O2 %s -o - | FileCheck %s --check-prefix=SAFETY
-// RUN: %clang -fsanitize=hwaddress -target aarch64-linux-gnu -S -emit-llvm 
-mllvm -hwasan-use-stack-safety=false -mllvm -hwasan-generate-tags-with-calls 
-O2 %s -o - | FileCheck %s --check-prefix=NOSAFETY
+// RUN: %clang -fno-legacy-pass-manager -fsanitize=hwaddress -target 
aarch64-linux-gnu -S -emit-llvm -mllvm -hwasan-use-stack-safety=true -mllvm 
-hwasan-generate-tags-with-calls -O2 %s -o - | FileCheck %s 
--check-prefix=SAFETY
+// RUN: %clang -fno-legacy-pass-manager -fsanitize=hwaddress -target 
aarch64-linux-gnu -S -emit-llvm -mllvm -hwasan-use-stack-safety=false -mllvm 
-hwasan-generate-tags-with-calls -O2 %s -o - | FileCheck %s 
--check-prefix=NOSAFETY
+
+// RUN: %clang -flegacy-pass-manager -fsanitize=hwaddress -target 
aarch64-linux-gnu -S -emit-llvm -mllvm -hwasan-use-stack-safety=true -mllvm 
-hwasan-generate-tags-with-calls -O2 %s -o - | FileCheck %s 
--check-prefix=SAFETY
+// RUN: %clang -flegacy-pass-manager -fsanitize=hwaddress -target 
aarch64-linux-gnu -S -emit-llvm -mllvm -hwasan-use-stack-safety=false -mllvm 
-hwasan-generate-tags-with-calls -O2 %s -o - | FileCheck %s 
--check-prefix=NOSAFETY
 
 // Default when optimizing, but not with O0.
 // RUN: %clang -fsanitize=hwaddress -target aarch64-linux-gnu -S -emit-llvm 
-mllvm -hwasan-generate-tags-with-calls -O2 %s -o - | FileCheck %s 
--check-prefix=SAFETY
@@ -10,6 +13,6 @@
   volatile char *x = buf;
   *x = 0;
   return buf[0];
-  // NOSAFETY: __hwasan_generate_tag
-  // SAFETY-NOT: __hwasan_generate_tag
+  // NOSAFETY: call i8 @__hwasan_generate_tag
+  // SAFETY-NOT: call i8 @__hwasan_generate_tag
 }


Index: clang/test/CodeGen/hwasan-stack-safety-analysis.c
===
--- clang/test/CodeGen/hwasan-stack-safety-analysis.c
+++ clang/test/CodeGen/hwasan-stack-safety-analysis.c
@@ -1,5 +1,8 @@
-// RUN: %clang -fsanitize=hwaddress -target aarch64-linux-gnu -S -emit-llvm -mllvm -hwasan-use-stack-safety=true -mllvm -hwasan-generate-tags-with-calls -O2 %s -o - | FileCheck %s --check-prefix=SAFETY
-// RUN: %clang -fsanitize=hwaddress -target aarch64-linux-gnu -S -emit-llvm -mllvm -hwasan-use-stack-safety=false -mllvm -hwasan-generate-tags-with-calls -O2 %s -o - | FileCheck %s --check-prefix=NOSAFETY
+// RUN: %clang -fno-legacy-pass-manager -fsanitize=hwaddress -target aarch64-linux-gnu -S -emit-llvm -mllvm -hwasan-use-stack-safety=true -mllvm -hwasan-generate-tags-with-calls -O2 %s -o - | FileCheck %s --check-prefix=SAFETY
+// RUN: %clang -fno-legacy-pass-manager -fsanitize=hwaddress -target aarch64-linux-gnu -S -emit-llvm -mllvm -hwasan-use-stack-safety=false -mllvm -hwasan-generate-tags-with-calls -O2 %s -o - | FileCheck %s --check-prefix=NOSAFETY
+
+// RUN: %clang -flegacy-pass-manager -fsanitize=hwaddress -target aarch64-linux-gnu -S -emit-llvm -mllvm -hwasan-use-stack-safety=true -mllvm -hwasan-generate-tags-with-calls -O2 %s -o - | FileCheck %s --check-prefix=SAFETY
+// RUN: %clang -flegacy-pass-manager -fsanitize=hwaddress -target aarch64-linux-gnu -S -emit-llvm -mllvm -hwasan-use-stack-safety=false -mllvm -hwasan-generate-tags-with-calls -O2 %s -o - | FileCheck %s --check-prefix=NOSAFETY
 
 // Default when optimizing, but not with O0.
 // RUN: %clang -fsanitize=hwaddress -target aarch64-linux-gnu -S -emit-llvm -mllvm -hwasan-generate-tags-with-calls -O2 %s -o - | FileCheck %s --check-prefix=SAFETY
@@ -10,6 +13,6 @@
   volatile char *x = buf;
   *x = 0;
   return buf[0];
-  // NOSAFETY: __hwasan_generate_tag
-  // SAFETY-NOT: __hwasan_generate_tag
+  // NOSAFETY: call i8 @__hwasan_generate_tag
+  // SAFETY-NOT: call i8 @__hwasan_generate_tag
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 835ef6f - [hwasan] Fix stack safety test for old PM.

2021-07-27 Thread Florian Mayer via cfe-commits

Author: Florian Mayer
Date: 2021-07-27T20:50:46+01:00
New Revision: 835ef6f93d5789d3d7d905462e7574a38b30577d

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

LOG: [hwasan] Fix stack safety test for old PM.

With the old PM, the stub for __hwasan_generate_tag is still generated
in the IR, but never called.

Reviewed By: vitalybuka

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

Added: 


Modified: 
clang/test/CodeGen/hwasan-stack-safety-analysis.c

Removed: 




diff  --git a/clang/test/CodeGen/hwasan-stack-safety-analysis.c 
b/clang/test/CodeGen/hwasan-stack-safety-analysis.c
index 5c4f34027bac..ba50274de282 100644
--- a/clang/test/CodeGen/hwasan-stack-safety-analysis.c
+++ b/clang/test/CodeGen/hwasan-stack-safety-analysis.c
@@ -1,5 +1,8 @@
-// RUN: %clang -fsanitize=hwaddress -target aarch64-linux-gnu -S -emit-llvm 
-mllvm -hwasan-use-stack-safety=true -mllvm -hwasan-generate-tags-with-calls 
-O2 %s -o - | FileCheck %s --check-prefix=SAFETY
-// RUN: %clang -fsanitize=hwaddress -target aarch64-linux-gnu -S -emit-llvm 
-mllvm -hwasan-use-stack-safety=false -mllvm -hwasan-generate-tags-with-calls 
-O2 %s -o - | FileCheck %s --check-prefix=NOSAFETY
+// RUN: %clang -fno-legacy-pass-manager -fsanitize=hwaddress -target 
aarch64-linux-gnu -S -emit-llvm -mllvm -hwasan-use-stack-safety=true -mllvm 
-hwasan-generate-tags-with-calls -O2 %s -o - | FileCheck %s 
--check-prefix=SAFETY
+// RUN: %clang -fno-legacy-pass-manager -fsanitize=hwaddress -target 
aarch64-linux-gnu -S -emit-llvm -mllvm -hwasan-use-stack-safety=false -mllvm 
-hwasan-generate-tags-with-calls -O2 %s -o - | FileCheck %s 
--check-prefix=NOSAFETY
+
+// RUN: %clang -flegacy-pass-manager -fsanitize=hwaddress -target 
aarch64-linux-gnu -S -emit-llvm -mllvm -hwasan-use-stack-safety=true -mllvm 
-hwasan-generate-tags-with-calls -O2 %s -o - | FileCheck %s 
--check-prefix=SAFETY
+// RUN: %clang -flegacy-pass-manager -fsanitize=hwaddress -target 
aarch64-linux-gnu -S -emit-llvm -mllvm -hwasan-use-stack-safety=false -mllvm 
-hwasan-generate-tags-with-calls -O2 %s -o - | FileCheck %s 
--check-prefix=NOSAFETY
 
 // Default when optimizing, but not with O0.
 // RUN: %clang -fsanitize=hwaddress -target aarch64-linux-gnu -S -emit-llvm 
-mllvm -hwasan-generate-tags-with-calls -O2 %s -o - | FileCheck %s 
--check-prefix=SAFETY
@@ -10,6 +13,6 @@ int main(int argc, char **argv) {
   volatile char *x = buf;
   *x = 0;
   return buf[0];
-  // NOSAFETY: __hwasan_generate_tag
-  // SAFETY-NOT: __hwasan_generate_tag
+  // NOSAFETY: call i8 @__hwasan_generate_tag
+  // SAFETY-NOT: call i8 @__hwasan_generate_tag
 }



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


[PATCH] D106890: [z/OS] Make MinGlobalAlign consistent with SystemZ

2021-07-27 Thread Fanbo Meng via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa2d4b064644b: [z/OS] Make MinGlobalAlign consistent with 
SystemZ (authored by fanbo-meng).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106890

Files:
  clang/lib/Basic/Targets/OSTargets.h


Index: clang/lib/Basic/Targets/OSTargets.h
===
--- clang/lib/Basic/Targets/OSTargets.h
+++ clang/lib/Basic/Targets/OSTargets.h
@@ -796,7 +796,6 @@
 this->UseZeroLengthBitfieldAlignment = true;
 this->UseLeadingZeroLengthBitfield = false;
 this->ZeroLengthBitfieldBoundary = 32;
-this->MinGlobalAlign = 0;
 this->DefaultAlignForAttributeAligned = 128;
   }
 };


Index: clang/lib/Basic/Targets/OSTargets.h
===
--- clang/lib/Basic/Targets/OSTargets.h
+++ clang/lib/Basic/Targets/OSTargets.h
@@ -796,7 +796,6 @@
 this->UseZeroLengthBitfieldAlignment = true;
 this->UseLeadingZeroLengthBitfield = false;
 this->ZeroLengthBitfieldBoundary = 32;
-this->MinGlobalAlign = 0;
 this->DefaultAlignForAttributeAligned = 128;
   }
 };
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] a2d4b06 - [z/OS] Make MinGlobalAlign consistent with SystemZ

2021-07-27 Thread Fanbo Meng via cfe-commits

Author: Fanbo Meng
Date: 2021-07-27T15:39:14-04:00
New Revision: a2d4b064644bdf146d0649c6a70e595567f1213f

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

LOG: [z/OS] Make MinGlobalAlign consistent with SystemZ

Remove overriding MinGlobalAlign to 0 for z/OS target to be consistent with 
SystemZ.

Reviewed By: abhina.sreeskantharajan

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

Added: 


Modified: 
clang/lib/Basic/Targets/OSTargets.h

Removed: 




diff  --git a/clang/lib/Basic/Targets/OSTargets.h 
b/clang/lib/Basic/Targets/OSTargets.h
index 31f8b4bea30d9..e24fb5cf082df 100644
--- a/clang/lib/Basic/Targets/OSTargets.h
+++ b/clang/lib/Basic/Targets/OSTargets.h
@@ -796,7 +796,6 @@ class LLVM_LIBRARY_VISIBILITY ZOSTargetInfo : public 
OSTargetInfo {
 this->UseZeroLengthBitfieldAlignment = true;
 this->UseLeadingZeroLengthBitfield = false;
 this->ZeroLengthBitfieldBoundary = 32;
-this->MinGlobalAlign = 0;
 this->DefaultAlignForAttributeAligned = 128;
   }
 };



___
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-27 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

In D106790#2906762 , @hans wrote:

> In D106790#2905110 , @rnk wrote:
>
>> Does this match GCC? They also provide this Intel intrinsic.
>
> No, they define it without volatile (and also without const): 
> https://github.com/gcc-mirror/gcc/blob/releases/gcc-11.1.0/gcc/config/i386/prfchwintrin.h#L32
>
> But maybe their header doesn't get included together with Microsoft's header?

Sure, they won't be included together, but will GCC users get warnings from 
passing non-volatile pointers to `_mm_prefetchw`? If we change these qualifiers 
to match MSVC, will GCC/Clang users be able to observe any change in behavior?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106790

___
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-27 Thread Jinsong Ji via Phabricator via cfe-commits
jsji added inline comments.



Comment at: clang/tools/libclang/CMakeLists.txt:79
+  set(LLVM_EXPORTED_SYMBOL_FILE)
+  set(USE_VERSION_SCRIPT TRUE)
+endif()

I think we should check LLVM_HAVE_LINK_VERSION_SCRIPT here, there are platforms 
that does NOT support VERSION_SCRIPT.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105527

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


[PATCH] D106903: [dfsan][NFC] Describe how origin trace tracking works

2021-07-27 Thread George Balatsouras via Phabricator via cfe-commits
gbalats added inline comments.



Comment at: clang/docs/DataFlowSanitizerDesign.rst:142
+Every four 4-bytes aligned application bytes share a 4-byte origin value. A
+4-byte origin contains a 4-bit depth and a 28-bit hash ID of a chain.
+

What is a chain? It's not yet explained at this point.



Comment at: clang/docs/DataFlowSanitizerDesign.rst:152
+
+A chain starts by `dfsan_set_label` with non-zero labels. A new chain is added
+at stores or memory-transfer when ``-dfsan-track-origins`` is 1. Memory 
transfers

Do you mean that the chain is extended?



Comment at: clang/docs/DataFlowSanitizerDesign.rst:155
+include LLVM memory transfer instructions and wrapped glibc memcpy and memmove.
+When ``-dfsan-track-origins`` is 2, a new chain is also added at loads.
+

same here



Comment at: clang/docs/DataFlowSanitizerDesign.rst:157
+
+Other instructions do not create new chains, but simply propagate origin 
values.
+If an instruction has more than one operands with non-zero labels, the origin

I'm not sure I understand the definition of a chain. What are the links? When 
you say, "create a new chain" you mean adding a new link to an existing chain? 
I think you might be using this expression to reflect the implementation (e.g., 
chain has a pointer to its tail) but it doesn't help when explaining.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106903

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


[PATCH] D106903: [dfsan][NFC] Describe how origin trace tracking works

2021-07-27 Thread stephan.yichao.zhao via Phabricator via cfe-commits
stephan.yichao.zhao created this revision.
stephan.yichao.zhao added a reviewer: gbalats.
stephan.yichao.zhao requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106903

Files:
  clang/docs/DataFlowSanitizerDesign.rst


Index: clang/docs/DataFlowSanitizerDesign.rst
===
--- clang/docs/DataFlowSanitizerDesign.rst
+++ clang/docs/DataFlowSanitizerDesign.rst
@@ -135,6 +135,30 @@
 track of what labels they have used so far, picking one that is yet
 unused, etc).
 
+Origin tracking trace representation
+
+
+Every four 4-bytes aligned application bytes share a 4-byte origin value. A
+4-byte origin contains a 4-bit depth and a 28-bit hash ID of a chain.
+
+A chain ID is calculated as a hash from a chain structure. A chain structure
+contains a stack ID and the previous chain ID. The chain head has a zero
+previous chain ID. A stack ID is a hash from a stack trace. The 4-bit depth
+limits the maximal length of a path. The environment variable 
``origin_history_size``
+can set the depth limit. Non-positive values mean unlimited. Its default value
+is 16. When reaching the limit, origin tracking ignores following propagation
+chains.
+
+A chain starts by `dfsan_set_label` with non-zero labels. A new chain is added
+at stores or memory-transfer when ``-dfsan-track-origins`` is 1. Memory 
transfers
+include LLVM memory transfer instructions and wrapped glibc memcpy and memmove.
+When ``-dfsan-track-origins`` is 2, a new chain is also added at loads.
+
+Other instructions do not create new chains, but simply propagate origin 
values.
+If an instruction has more than one operands with non-zero labels, the origin
+value of the last operand with non-zero label is propagated to the result of
+this instruction.
+
 Memory layout and label management
 --
 


Index: clang/docs/DataFlowSanitizerDesign.rst
===
--- clang/docs/DataFlowSanitizerDesign.rst
+++ clang/docs/DataFlowSanitizerDesign.rst
@@ -135,6 +135,30 @@
 track of what labels they have used so far, picking one that is yet
 unused, etc).
 
+Origin tracking trace representation
+
+
+Every four 4-bytes aligned application bytes share a 4-byte origin value. A
+4-byte origin contains a 4-bit depth and a 28-bit hash ID of a chain.
+
+A chain ID is calculated as a hash from a chain structure. A chain structure
+contains a stack ID and the previous chain ID. The chain head has a zero
+previous chain ID. A stack ID is a hash from a stack trace. The 4-bit depth
+limits the maximal length of a path. The environment variable ``origin_history_size``
+can set the depth limit. Non-positive values mean unlimited. Its default value
+is 16. When reaching the limit, origin tracking ignores following propagation
+chains.
+
+A chain starts by `dfsan_set_label` with non-zero labels. A new chain is added
+at stores or memory-transfer when ``-dfsan-track-origins`` is 1. Memory transfers
+include LLVM memory transfer instructions and wrapped glibc memcpy and memmove.
+When ``-dfsan-track-origins`` is 2, a new chain is also added at loads.
+
+Other instructions do not create new chains, but simply propagate origin values.
+If an instruction has more than one operands with non-zero labels, the origin
+value of the last operand with non-zero label is propagated to the result of
+this instruction.
+
 Memory layout and label management
 --
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106895: [dfsan][NFC] Update API interfaces

2021-07-27 Thread 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 rG00411ebeeb71: [dfsan][NFC] Update API interfaces (authored 
by Jianzhou Zhao jianzho...@google.com).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106895

Files:
  clang/docs/DataFlowSanitizerDesign.rst


Index: clang/docs/DataFlowSanitizerDesign.rst
===
--- clang/docs/DataFlowSanitizerDesign.rst
+++ clang/docs/DataFlowSanitizerDesign.rst
@@ -48,12 +48,79 @@
   /// value.
   dfsan_label dfsan_get_label(long data);
 
+  /// Retrieves the label associated with the data at the given address.
+  dfsan_label dfsan_read_label(const void *addr, size_t size);
+
   /// Returns whether the given label label contains the label elem.
   int dfsan_has_label(dfsan_label label, dfsan_label elem);
 
   /// Computes the union of \c l1 and \c l2, resulting in a union label.
   dfsan_label dfsan_union(dfsan_label l1, dfsan_label l2);
 
+  /// Flushes the DFSan shadow, i.e. forgets about all labels currently 
associated
+  /// with the application memory.  Use this call to start over the taint 
tracking
+  /// within the same process.
+  ///
+  /// Note: If another thread is working with tainted data during the flush, 
that
+  /// taint could still be written to shadow after the flush.
+  void dfsan_flush(void);
+
+The following functions are provided to check origin tracking status and 
results.
+
+.. code-block:: c
+
+  /// Retrieves the immediate origin associated with the given data. The 
returned
+  /// origin may point to another origin.
+  ///
+  /// The type of 'data' is arbitrary. The function accepts a value of any 
type,
+  /// which can be truncated or extended (implicitly or explicitly) as 
necessary.
+  /// The truncation/extension operations will preserve the label of the 
original
+  /// value.
+  dfsan_origin dfsan_get_origin(long data);
+
+  /// Retrieves the very first origin associated with the data at the given
+  /// address.
+  dfsan_origin dfsan_get_init_origin(const void *addr);
+
+  /// Prints the origin trace of the label at the address `addr` to stderr. It 
also
+  /// prints description at the beginning of the trace. If origin tracking is 
not
+  /// on, or the address is not labeled, it prints nothing.
+  void dfsan_print_origin_trace(const void *addr, const char *description);
+
+  /// Prints the origin trace of the label at the address `addr` to a 
pre-allocated
+  /// output buffer. If origin tracking is not on, or the address is`
+  /// not labeled, it prints nothing.
+  ///
+  /// `addr` is the tainted memory address whose origin we are printing.
+  /// `description` is a description printed at the beginning of the trace.
+  /// `out_buf` is the output buffer to write the results to. `out_buf_size` is
+  /// the size of `out_buf`. The function returns the number of symbols that
+  /// should have been written to `out_buf` (not including trailing null byte 
'\0').
+  /// Thus, the string is truncated iff return value is not less than 
`out_buf_size`.
+  size_t dfsan_sprint_origin_trace(const void *addr, const char *description,
+   char *out_buf, size_t out_buf_size);
+
+  /// Returns the value of `-dfsan-track-origins`.
+  int dfsan_get_track_origins(void);
+
+The following functions are provided to register hooks called by custom 
wrappers.
+
+.. code-block:: c
+
+  /// Sets a callback to be invoked on calls to `write`.  The callback is 
invoked
+  /// before the write is done. The write is not guaranteed to succeed when the
+  /// callback executes. Pass in NULL to remove any callback.
+  typedef void (*dfsan_write_callback_t)(int fd, const void *buf, size_t 
count);
+  void dfsan_set_write_callback(dfsan_write_callback_t labeled_write_callback);
+
+  /// Callbacks to be invoked on calls to `memcmp` or `strncmp`.
+  void dfsan_weak_hook_memcmp(void *caller_pc, const void *s1, const void *s2,
+  size_t n, dfsan_label s1_label,
+  dfsan_label s2_label, dfsan_label n_label);
+  void dfsan_weak_hook_strncmp(void *caller_pc, const char *s1, const char *s2,
+  size_t n, dfsan_label s1_label,
+  dfsan_label s2_label, dfsan_label n_label);
+
 Taint label representation
 --
 


Index: clang/docs/DataFlowSanitizerDesign.rst
===
--- clang/docs/DataFlowSanitizerDesign.rst
+++ clang/docs/DataFlowSanitizerDesign.rst
@@ -48,12 +48,79 @@
   /// value.
   dfsan_label dfsan_get_label(long data);
 
+  /// Retrieves the label associated with the data at the given address.
+  dfsan_label dfsan_read_label(const void *addr, size_t size);
+
   /// Returns whether the given label label 

[clang] 00411eb - [dfsan][NFC] Update API interfaces

2021-07-27 Thread Jianzhou Zhao via cfe-commits

Author: Jianzhou Zhao
Date: 2021-07-27T18:53:36Z
New Revision: 00411ebeeb718da63d1ec0e0ffc8e5012e474fe9

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

LOG: [dfsan][NFC] Update API interfaces

Reviewed By: gbalats

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

Added: 


Modified: 
clang/docs/DataFlowSanitizerDesign.rst

Removed: 




diff  --git a/clang/docs/DataFlowSanitizerDesign.rst 
b/clang/docs/DataFlowSanitizerDesign.rst
index 7615a2acc58b..ea40fe332010 100644
--- a/clang/docs/DataFlowSanitizerDesign.rst
+++ b/clang/docs/DataFlowSanitizerDesign.rst
@@ -48,12 +48,79 @@ file ``sanitizer/dfsan_interface.h``.
   /// value.
   dfsan_label dfsan_get_label(long data);
 
+  /// Retrieves the label associated with the data at the given address.
+  dfsan_label dfsan_read_label(const void *addr, size_t size);
+
   /// Returns whether the given label label contains the label elem.
   int dfsan_has_label(dfsan_label label, dfsan_label elem);
 
   /// Computes the union of \c l1 and \c l2, resulting in a union label.
   dfsan_label dfsan_union(dfsan_label l1, dfsan_label l2);
 
+  /// Flushes the DFSan shadow, i.e. forgets about all labels currently 
associated
+  /// with the application memory.  Use this call to start over the taint 
tracking
+  /// within the same process.
+  ///
+  /// Note: If another thread is working with tainted data during the flush, 
that
+  /// taint could still be written to shadow after the flush.
+  void dfsan_flush(void);
+
+The following functions are provided to check origin tracking status and 
results.
+
+.. code-block:: c
+
+  /// Retrieves the immediate origin associated with the given data. The 
returned
+  /// origin may point to another origin.
+  ///
+  /// The type of 'data' is arbitrary. The function accepts a value of any 
type,
+  /// which can be truncated or extended (implicitly or explicitly) as 
necessary.
+  /// The truncation/extension operations will preserve the label of the 
original
+  /// value.
+  dfsan_origin dfsan_get_origin(long data);
+
+  /// Retrieves the very first origin associated with the data at the given
+  /// address.
+  dfsan_origin dfsan_get_init_origin(const void *addr);
+
+  /// Prints the origin trace of the label at the address `addr` to stderr. It 
also
+  /// prints description at the beginning of the trace. If origin tracking is 
not
+  /// on, or the address is not labeled, it prints nothing.
+  void dfsan_print_origin_trace(const void *addr, const char *description);
+
+  /// Prints the origin trace of the label at the address `addr` to a 
pre-allocated
+  /// output buffer. If origin tracking is not on, or the address is`
+  /// not labeled, it prints nothing.
+  ///
+  /// `addr` is the tainted memory address whose origin we are printing.
+  /// `description` is a description printed at the beginning of the trace.
+  /// `out_buf` is the output buffer to write the results to. `out_buf_size` is
+  /// the size of `out_buf`. The function returns the number of symbols that
+  /// should have been written to `out_buf` (not including trailing null byte 
'\0').
+  /// Thus, the string is truncated iff return value is not less than 
`out_buf_size`.
+  size_t dfsan_sprint_origin_trace(const void *addr, const char *description,
+   char *out_buf, size_t out_buf_size);
+
+  /// Returns the value of `-dfsan-track-origins`.
+  int dfsan_get_track_origins(void);
+
+The following functions are provided to register hooks called by custom 
wrappers.
+
+.. code-block:: c
+
+  /// Sets a callback to be invoked on calls to `write`.  The callback is 
invoked
+  /// before the write is done. The write is not guaranteed to succeed when the
+  /// callback executes. Pass in NULL to remove any callback.
+  typedef void (*dfsan_write_callback_t)(int fd, const void *buf, size_t 
count);
+  void dfsan_set_write_callback(dfsan_write_callback_t labeled_write_callback);
+
+  /// Callbacks to be invoked on calls to `memcmp` or `strncmp`.
+  void dfsan_weak_hook_memcmp(void *caller_pc, const void *s1, const void *s2,
+  size_t n, dfsan_label s1_label,
+  dfsan_label s2_label, dfsan_label n_label);
+  void dfsan_weak_hook_strncmp(void *caller_pc, const char *s1, const char *s2,
+  size_t n, dfsan_label s1_label,
+  dfsan_label s2_label, dfsan_label n_label);
+
 Taint label representation
 --
 



___
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-27 Thread Chris Bieneman via Phabricator via cfe-commits
beanz updated this revision to Diff 362123.
beanz added a comment.

One last fix for a test failure my change caused.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106732

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/include/clang/Basic/IdentifierTable.h
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/Lex/PPDirectives.cpp
  clang/lib/Lex/PPExpressions.cpp
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/lib/Lex/Pragma.cpp
  clang/test/Lexer/deprecate-macro.c

Index: clang/test/Lexer/deprecate-macro.c
===
--- /dev/null
+++ clang/test/Lexer/deprecate-macro.c
@@ -0,0 +1,60 @@
+// RUN: %clang_cc1 -Wdeprecated %s -fsyntax-only -verify
+
+// expected-error@+1{{expected (}}
+#pragma clang deprecated
+
+// expected-error@+1{{expected identifier}}
+#pragma clang deprecated(4
+
+// expected-error@+1{{no macro named foo}}
+#pragma clang deprecated(foo)
+
+#define bar 1
+#pragma clang deprecated(bar, "bar is deprecated use 1")
+
+// expected-warning@+1{{macro 'bar' has been marked as deprecated: bar is deprecated use 1}}
+#if bar
+#endif
+
+#define foo 1
+#pragma clang deprecated(foo)
+
+// expected-error@+1{{expected )}}
+#pragma clang deprecated(foo
+
+// expected-warning@+1{{macro 'foo' has been marked as deprecated}}
+#if foo
+#endif
+
+// expected-warning@+1{{macro 'foo' has been marked as deprecated}}
+#if defined(foo)
+#endif
+
+// expected-warning@+1{{macro 'foo' has been marked as deprecated}}
+#ifdef foo
+#endif
+
+// expected-warning@+1{{macro 'foo' has been marked as deprecated}}
+#ifndef foo
+#endif
+
+int main(int argc, char** argv) {
+  // expected-error@+1{{no macro named main}}
+#pragma clang deprecated(main)
+
+  // expected-warning@+1{{macro 'foo' has been marked as deprecated}}
+  return foo;
+}
+
+#define frobble 1
+#pragma clang deprecated(frobble)
+
+// not-expected-warning@+1{{macro 'frobble' has been marked as deprecated}}
+#undef frobble // Expect no diagnostics here
+
+// not-expected-warning@+1{{macro 'frobble' has been marked as deprecated}}
+#define frobble 1 // How about here given that this was undefined?
+
+// not-expected-warning@+1{{macro 'frobble' has been marked as deprecated}}
+#if defined(frobble)
+#endif
Index: clang/lib/Lex/Pragma.cpp
===
--- clang/lib/Lex/Pragma.cpp
+++ clang/lib/Lex/Pragma.cpp
@@ -1911,6 +1911,57 @@
   }
 };
 
+/// "\#pragma clang deprecated(...)"
+///
+/// The syntax is
+/// \code
+///   #pragma clang deprecate(MACRO_NAME [, Message])
+/// \endcode
+struct PragmaDeprecatedHandler : public PragmaHandler {
+  PragmaDeprecatedHandler() : PragmaHandler("deprecated") {}
+
+  void HandlePragma(Preprocessor , PragmaIntroducer Introducer,
+Token ) override {
+std::string Macro, MessageString;
+
+PP.Lex(Tok);
+if (Tok.isNot(tok::l_paren)) {
+  PP.Diag(Tok, diag::err_expected) << "(";
+  return;
+}
+
+PP.LexUnexpandedToken(Tok);
+if (!Tok.is(tok::identifier)) {
+  PP.Diag(Tok, diag::err_expected) << tok::identifier;
+  return;
+}
+IdentifierInfo *II = Tok.getIdentifierInfo();
+
+if (!II->hasMacroDefinition()) {
+  PP.Diag(Tok, diag::err_pp_visibility_non_macro) << II->getName();
+  return;
+}
+
+PP.Lex(Tok);
+if (Tok.is(tok::comma)) {
+  PP.Lex(Tok);
+  if (!PP.FinishLexStringLiteral(Tok, MessageString,
+ "#pragma clang deprecated",
+ /*AllowMacroExpansion=*/true))
+return;
+}
+
+if (Tok.isNot(tok::r_paren)) {
+  PP.Diag(Tok, diag::err_expected) << ")";
+  return;
+}
+
+II->setIsDeprecatedMacro(true);
+if (!MessageString.empty())
+  PP.addMacroDeprecationMsg(II, std::move(MessageString));
+  }
+};
+
 } // namespace
 
 /// RegisterBuiltinPragmas - Install the standard preprocessor pragmas:
@@ -1939,6 +1990,7 @@
   AddPragmaHandler("clang", new PragmaDiagnosticHandler("clang"));
   AddPragmaHandler("clang", new PragmaARCCFCodeAuditedHandler());
   AddPragmaHandler("clang", new PragmaAssumeNonNullHandler());
+  AddPragmaHandler("clang", new PragmaDeprecatedHandler());
 
   // #pragma clang module ...
   auto *ModuleHandler = new PragmaNamespace("module");
Index: clang/lib/Lex/PPMacroExpansion.cpp
===
--- clang/lib/Lex/PPMacroExpansion.cpp
+++ clang/lib/Lex/PPMacroExpansion.cpp
@@ -471,6 +471,16 @@
 /// expanded as a macro, handle it and return the next token as 'Identifier'.
 bool Preprocessor::HandleMacroExpandedIdentifier(Token ,
  const MacroDefinition ) {
+  if (Identifier.getIdentifierInfo()->isDeprecatedMacro()) {
+auto DepMsg 

[PATCH] D106898: Revert "Revert "[clang][pp] adds '#pragma include_instead'""

2021-07-27 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb updated this revision to Diff 362116.
cjdb retitled this revision from "Revert "Revert "[clang][pp] adds '#pragma 
include_instead'""

Includes regression test for problem noted by @hans." to "Revert "Revert 
"[clang][pp] adds '#pragma include_instead'""".
cjdb edited the summary of this revision.
cjdb added a comment.

updates commit message


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106898

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/PCH/ms-pch-macro-include_instead-regression.c
  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

[PATCH] D106898: Revert "Revert "[clang][pp] adds '#pragma include_instead'"" Includes regression test for problem noted by @hans.

2021-07-27 Thread Hans Wennborg via Phabricator via cfe-commits
hans added inline comments.



Comment at: clang/test/PCH/ms-pch-macro-include_instead-regression.c:24
+
+#include BAZ
+

This is really the interesting part. Maybe the other checks and macros could be 
removed, if that's enough to trigger the crash?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106898

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


[PATCH] D99381: [compiler-rt][hwasan] Remove __sanitizer allocation functions from hwasan interface

2021-07-27 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

@eugenis Why do we have them in here and in sanitizer/hwasan_interface.h ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99381

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


[PATCH] D106900: [PowerPC][AIX] Packed zero-width bitfields do not affect alignment.

2021-07-27 Thread Sean Fertile via Phabricator via cfe-commits
sfertile created this revision.
sfertile added reviewers: stevewan, Jake-Egan.
Herald added subscribers: shchenz, nemanjai.
sfertile requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Zero-width bitfields on AIX pad out to the natral alignment boundary but do not 
change the containing records alignment when they are packed.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106900

Files:
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/test/Layout/aix-packed-bitfields.c


Index: clang/test/Layout/aix-packed-bitfields.c
===
--- clang/test/Layout/aix-packed-bitfields.c
+++ clang/test/Layout/aix-packed-bitfields.c
@@ -75,3 +75,33 @@
 // CHECK-NEXT: 3:6-35 |   int a2
 // CHECK-NEXT:  7:4-7 |   int a3
 // CHECK-NEXT:  sizeof=8, {{(dsize=8, )?}}align=2, preferredalign=2
+//
+struct __attribute__((packed)) PackedAttr {
+  char f1;
+  int : 0;
+  short : 3;
+  char f4 : 2;
+};
+
+int e = sizeof(struct PackedAttr);
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct PackedAttr
+// CHECK-NEXT:  0 |   char f1
+// CHECK-NEXT:4:- |   int
+// CHECK-NEXT:  4:0-2 |   short
+// CHECK-NEXT:  4:3-4 |   char f4
+// CHECK-NEXT:  sizeof=5, {{(dsize=5, )?}}align=1, preferredalign=1
+
+#pragma pack(2)
+struct __attribute__((packed)) PackedAttrAndPragma {
+  char f1;
+  int : 0;
+};
+#pragma pack(pop)
+
+int f = sizeof(struct PackedAttrAndPragma);
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct PackedAttrAndPragma
+// CHECK-NEXT:  0 |   char f1
+// CHECK-NEXT:4:- |   int
+// CHECK-NEXT:  sizeof=4, {{(dsize=4, )?}}align=1, preferredalign=1
Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1775,11 +1775,17 @@
   !D->getIdentifier())
 FieldAlign = UnpackedFieldAlign = 1;
 
-  // On AIX, zero-width bitfields pad out to the alignment boundary, but then
-  // do not affect overall record alignment if there is a pragma pack or
-  // pragma align(packed).
-  if (isAIXLayout(Context) && !MaxFieldAlignment.isZero() && !FieldSize)
-FieldAlign = std::min(FieldAlign, MaxFieldAlignmentInBits);
+  // On AIX, zero-width bitfields pad out to the natural alignment boundary,
+  // but dont increase the alignment greater than the MaxFieldAlignment, or 1
+  // if packed.
+  if (isAIXLayout(Context) && !FieldSize) {
+if (FieldPacked) {
+  FieldAlign = UnpackedFieldAlign = 1;
+} else if(!MaxFieldAlignment.isZero()) {
+  UnpackedFieldAlign = std::min(UnpackedFieldAlign, 
MaxFieldAlignmentInBits);
+  FieldAlign = std::min(FieldAlign, MaxFieldAlignmentInBits);
+}
+  }
 
   // Diagnose differences in layout due to padding or packing.
   if (!UseExternalLayout)


Index: clang/test/Layout/aix-packed-bitfields.c
===
--- clang/test/Layout/aix-packed-bitfields.c
+++ clang/test/Layout/aix-packed-bitfields.c
@@ -75,3 +75,33 @@
 // CHECK-NEXT: 3:6-35 |   int a2
 // CHECK-NEXT:  7:4-7 |   int a3
 // CHECK-NEXT:  sizeof=8, {{(dsize=8, )?}}align=2, preferredalign=2
+//
+struct __attribute__((packed)) PackedAttr {
+  char f1;
+  int : 0;
+  short : 3;
+  char f4 : 2;
+};
+
+int e = sizeof(struct PackedAttr);
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct PackedAttr
+// CHECK-NEXT:  0 |   char f1
+// CHECK-NEXT:4:- |   int
+// CHECK-NEXT:  4:0-2 |   short
+// CHECK-NEXT:  4:3-4 |   char f4
+// CHECK-NEXT:  sizeof=5, {{(dsize=5, )?}}align=1, preferredalign=1
+
+#pragma pack(2)
+struct __attribute__((packed)) PackedAttrAndPragma {
+  char f1;
+  int : 0;
+};
+#pragma pack(pop)
+
+int f = sizeof(struct PackedAttrAndPragma);
+// CHECK:  *** Dumping AST Record Layout
+// CHECK-NEXT:  0 | struct PackedAttrAndPragma
+// CHECK-NEXT:  0 |   char f1
+// CHECK-NEXT:4:- |   int
+// CHECK-NEXT:  sizeof=4, {{(dsize=4, )?}}align=1, preferredalign=1
Index: clang/lib/AST/RecordLayoutBuilder.cpp
===
--- clang/lib/AST/RecordLayoutBuilder.cpp
+++ clang/lib/AST/RecordLayoutBuilder.cpp
@@ -1775,11 +1775,17 @@
   !D->getIdentifier())
 FieldAlign = UnpackedFieldAlign = 1;
 
-  // On AIX, zero-width bitfields pad out to the alignment boundary, but then
-  // do not affect overall record alignment if there is a pragma pack or
-  // pragma align(packed).
-  if (isAIXLayout(Context) && !MaxFieldAlignment.isZero() && !FieldSize)
-FieldAlign = std::min(FieldAlign, MaxFieldAlignmentInBits);
+  // On AIX, zero-width bitfields pad out to the natural alignment boundary,
+  // but dont increase the alignment greater than the MaxFieldAlignment, or 1
+  // if packed.
+  if 

[libunwind] 21c24ae - [runtimes] Always build libc++, libc++abi and libunwind with -fPIC

2021-07-27 Thread Louis Dionne via cfe-commits

Author: Louis Dionne
Date: 2021-07-27T14:19:05-04:00
New Revision: 21c24ae9029a1fcd1c76b61b1c48b81b5c66c606

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

LOG: [runtimes] Always build libc++, libc++abi and libunwind with -fPIC

Building the libraries with -fPIC ensures that we can link an executable
against the static libraries with -fPIE. Furthermore, there is apparently
basically no downside to building the libraries with position independent
code, since modern toolchains are sufficiently clever.

This commit enforces that we always build the runtime libraries with -fPIC.
This is another take on D104327, which instead makes the decision of whether
to build with -fPIC or not to the build script that drives the runtimes'
build.

Fixes http://llvm.org/PR43604.

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

Added: 


Modified: 
libcxx/src/CMakeLists.txt
libcxxabi/src/CMakeLists.txt
libunwind/src/CMakeLists.txt

Removed: 




diff  --git a/libcxx/src/CMakeLists.txt b/libcxx/src/CMakeLists.txt
index 87b71f7ba334b..f8c4d3e7df80b 100644
--- a/libcxx/src/CMakeLists.txt
+++ b/libcxx/src/CMakeLists.txt
@@ -198,6 +198,7 @@ if (LIBCXX_ENABLE_SHARED)
   VERSION   "${LIBCXX_ABI_VERSION}.0"
   SOVERSION "${LIBCXX_ABI_VERSION}"
   DEFINE_SYMBOL ""
+  POSITION_INDEPENDENT_CODE ON
   )
   cxx_add_common_build_flags(cxx_shared)
   cxx_set_common_defines(cxx_shared)
@@ -272,6 +273,7 @@ if (LIBCXX_ENABLE_STATIC)
   COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}"
   LINK_FLAGS"${LIBCXX_LINK_FLAGS}"
   OUTPUT_NAME   "c++"
+  POSITION_INDEPENDENT_CODE ON
   )
   cxx_add_common_build_flags(cxx_static)
   cxx_set_common_defines(cxx_static)

diff  --git a/libcxxabi/src/CMakeLists.txt b/libcxxabi/src/CMakeLists.txt
index 889d751b2ef7d..f07d4334916ae 100644
--- a/libcxxabi/src/CMakeLists.txt
+++ b/libcxxabi/src/CMakeLists.txt
@@ -191,6 +191,7 @@ if (LIBCXXABI_ENABLE_SHARED)
   SOVERSION "1"
   VERSION "${LIBCXXABI_LIBRARY_VERSION}"
   DEFINE_SYMBOL ""
+  POSITION_INDEPENDENT_CODE ON
   )
 
   list(APPEND LIBCXXABI_BUILD_TARGETS "cxxabi_shared")
@@ -243,6 +244,7 @@ if (LIBCXXABI_ENABLE_STATIC)
   COMPILE_FLAGS "${LIBCXXABI_COMPILE_FLAGS}"
   LINK_FLAGS "${LIBCXXABI_LINK_FLAGS}"
   OUTPUT_NAME "c++abi"
+  POSITION_INDEPENDENT_CODE ON
 )
 
   if(LIBCXXABI_HERMETIC_STATIC_LIBRARY)

diff  --git a/libunwind/src/CMakeLists.txt b/libunwind/src/CMakeLists.txt
index 05d3e59c81fb8..093804fe4a2f9 100644
--- a/libunwind/src/CMakeLists.txt
+++ b/libunwind/src/CMakeLists.txt
@@ -141,6 +141,7 @@ if (LIBUNWIND_ENABLE_SHARED)
   OUTPUT_NAME "unwind"
   VERSION "1.0"
   SOVERSION "1"
+  POSITION_INDEPENDENT_CODE ON
   )
   list(APPEND LIBUNWIND_BUILD_TARGETS "unwind_shared")
   if (LIBUNWIND_INSTALL_SHARED_LIBRARY)
@@ -166,6 +167,7 @@ if (LIBUNWIND_ENABLE_STATIC)
   LINK_FLAGS "${LIBUNWIND_LINK_FLAGS}"
   LINKER_LANGUAGE C
   OUTPUT_NAME "unwind"
+  POSITION_INDEPENDENT_CODE ON
   )
 
   if(LIBUNWIND_HIDE_SYMBOLS)



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


[PATCH] D106737: DRAFT - [clang] [hexagon] Add resource include dir

2021-07-27 Thread Sid Manning via Phabricator via cfe-commits
sidneym added inline comments.



Comment at: clang/lib/Driver/ToolChains/Hexagon.cpp:604
+  const bool HasSysRoot = !D.SysRoot.empty();
+  if (HasSysRoot) {
 SmallString<128> P(D.SysRoot);

bcain wrote:
> MaskRay wrote:
> > To match Linux.cpp, this code block should be unconditional.
> I *think* this is an intentional difference from `Linux.cpp` in order to suit 
> `hexagon-unknown-elf`. @sidneym do you think we need this conditional 
> behavior?
The isMusl check is to distinguish between our internal c-library and musl 
c-library.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106737

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


[PATCH] D106898: Revert "Revert "[clang][pp] adds '#pragma include_instead'"" Includes regression test for problem noted by @hans.

2021-07-27 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb created this revision.
cjdb added reviewers: aaron.ballman, rsmith, dblaikie.
cjdb requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This reverts commit 973de7185606a21fd5e9d5e8c014fbf898c0e72f 
.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106898

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/PCH/ms-pch-macro-include_instead-regression.c
  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
+++ 

[PATCH] D102107: [OpenMP] Codegen aggregate for outlined function captures

2021-07-27 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp:1601
+  CGM.getModule(), OMPRTL___kmpc_free_shared),
+  V);
+}

This needs to include the size of the accompanying push after D106496.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102107

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


[PATCH] D106891: [AMDGPU] [Remarks] Emit optimization remarks when an FP atomic instruction is converted into a CAS loop or unsafe hardware instruction for GFX90A

2021-07-27 Thread Anshil Gandhi via Phabricator via cfe-commits
gandhi21299 updated this revision to Diff 362093.
gandhi21299 added a comment.

- replaced `check-prefixes` to `check-prefix` in the test
- Function ffp1 emits a `flat_atomic_cmpswap` instead of `global_atomic_add`, I 
am not sure if that is considered an unsafe hardware instruction. @arsenm ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106891

Files:
  clang/test/CodeGenCUDA/fp-atomics-optremarks.cu
  llvm/lib/Target/AMDGPU/SIISelLowering.cpp
  llvm/lib/Target/AMDGPU/SIISelLowering.h

Index: llvm/lib/Target/AMDGPU/SIISelLowering.h
===
--- llvm/lib/Target/AMDGPU/SIISelLowering.h
+++ llvm/lib/Target/AMDGPU/SIISelLowering.h
@@ -30,6 +30,7 @@
 class SITargetLowering final : public AMDGPUTargetLowering {
 private:
   const GCNSubtarget *Subtarget;
+  OptimizationRemarkEmitter *ORE;
 
 public:
   MVT getRegisterTypeForCallingConv(LLVMContext ,
Index: llvm/lib/Target/AMDGPU/SIISelLowering.cpp
===
--- llvm/lib/Target/AMDGPU/SIISelLowering.cpp
+++ llvm/lib/Target/AMDGPU/SIISelLowering.cpp
@@ -19,6 +19,7 @@
 #include "SIRegisterInfo.h"
 #include "llvm/ADT/Statistic.h"
 #include "llvm/Analysis/LegacyDivergenceAnalysis.h"
+#include "llvm/Analysis/OptimizationRemarkEmitter.h"
 #include "llvm/BinaryFormat/ELF.h"
 #include "llvm/CodeGen/Analysis.h"
 #include "llvm/CodeGen/FunctionLoweringInfo.h"
@@ -12117,6 +12118,27 @@
   return DenormMode == DenormalMode::getIEEE();
 }
 
+static TargetLowering::AtomicExpansionKind
+atomicExpandReturn(OptimizationRemarkEmitter *ORE, AtomicRMWInst *RMW,
+   TargetLowering::AtomicExpansionKind Kind, bool UnsafeFlag) {
+  ORE = new OptimizationRemarkEmitter(RMW->getFunction());
+  if (Kind == TargetLowering::AtomicExpansionKind::CmpXChg) {
+ORE->emit([&]() {
+  OptimizationRemark Remark(DEBUG_TYPE, "Passed", RMW->getFunction());
+  Remark << "An FP atomic instruction was expanded into a CAS loop.";
+  return Remark;
+});
+  } else if (Kind == TargetLowering::AtomicExpansionKind::None && UnsafeFlag) {
+ORE->emit([&]() {
+  OptimizationRemark Remark(DEBUG_TYPE, "Passed", RMW->getFunction());
+  Remark << "An unsafe hardware instruction was generated.";
+  return Remark;
+});
+  }
+  delete ORE;
+  return Kind;
+}
+
 TargetLowering::AtomicExpansionKind
 SITargetLowering::shouldExpandAtomicRMWInIR(AtomicRMWInst *RMW) const {
   switch (RMW->getOperation()) {
@@ -12132,35 +12154,42 @@
   return AtomicExpansionKind::CmpXChg;
 
 unsigned AS = RMW->getPointerAddressSpace();
-
+bool UnsafeFPAtomicFlag = RMW->getFunction()
+  ->getFnAttribute("amdgpu-unsafe-fp-atomics")
+  .getValueAsBool();
 if ((AS == AMDGPUAS::GLOBAL_ADDRESS || AS == AMDGPUAS::FLAT_ADDRESS) &&
  Subtarget->hasAtomicFaddInsts()) {
   // The amdgpu-unsafe-fp-atomics attribute enables generation of unsafe
   // floating point atomic instructions. May generate more efficient code,
   // but may not respect rounding and denormal modes, and may give incorrect
   // results for certain memory destinations.
-  if (RMW->getFunction()
-  ->getFnAttribute("amdgpu-unsafe-fp-atomics")
-  .getValueAsString() != "true")
-return AtomicExpansionKind::CmpXChg;
+  if (!UnsafeFPAtomicFlag)
+return atomicExpandReturn(ORE, RMW, AtomicExpansionKind::CmpXChg,
+  false);
+  atomicExpandReturn(ORE, RMW, AtomicExpansionKind::None, true);
 
   if (Subtarget->hasGFX90AInsts()) {
 if (Ty->isFloatTy() && AS == AMDGPUAS::FLAT_ADDRESS)
-  return AtomicExpansionKind::CmpXChg;
+  return atomicExpandReturn(ORE, RMW, AtomicExpansionKind::CmpXChg,
+UnsafeFPAtomicFlag);
 
 auto SSID = RMW->getSyncScopeID();
 if (SSID == SyncScope::System ||
 SSID == RMW->getContext().getOrInsertSyncScopeID("one-as"))
-  return AtomicExpansionKind::CmpXChg;
+  return atomicExpandReturn(ORE, RMW, AtomicExpansionKind::CmpXChg,
+UnsafeFPAtomicFlag);
 
-return AtomicExpansionKind::None;
+return atomicExpandReturn(ORE, RMW, AtomicExpansionKind::None,
+  UnsafeFPAtomicFlag);
   }
 
   if (AS == AMDGPUAS::FLAT_ADDRESS)
-return AtomicExpansionKind::CmpXChg;
+return atomicExpandReturn(ORE, RMW, AtomicExpansionKind::CmpXChg,
+  UnsafeFPAtomicFlag);
 
-  return RMW->use_empty() ? AtomicExpansionKind::None
-  : AtomicExpansionKind::CmpXChg;
+  auto Kind = RMW->use_empty() ? AtomicExpansionKind::None
+   : 

[PATCH] D99381: [compiler-rt][hwasan] Remove __sanitizer allocation functions from hwasan interface

2021-07-27 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

In D99381#2858599 , @mcgrathr wrote:

> Frankly I don't think it makes sense to have __sanitizer_mallinfo and those 
> other allocator functions declared in hwasan_interface_internal.h at all.
> Those are neither APIs that the compiler emits nor ones that anyone else 
> should use.  They are just implementation details of the allocator 
> interceptors.
> I think a better cleanup is to move those declarations out of that file.  I 
> don't see why they need to be in any header file rather than just in 
> hwasan_allocation_functions.cpp.

I see. So something like this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99381

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


[PATCH] D99381: [compiler-rt][hwasan] Remove __sanitizer allocation functions from hwasan interface

2021-07-27 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 362103.
leonardchan retitled this revision from "[compiler-rt][hwasan] Add 
Fuchsia-specific sanitizer platform limits" to "[compiler-rt][hwasan] Remove 
__sanitizer allocation functions from hwasan interface".
leonardchan edited the summary of this revision.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99381

Files:
  compiler-rt/lib/hwasan/hwasan_allocation_functions.cpp
  compiler-rt/lib/hwasan/hwasan_interface_internal.h

Index: compiler-rt/lib/hwasan/hwasan_interface_internal.h
===
--- compiler-rt/lib/hwasan/hwasan_interface_internal.h
+++ compiler-rt/lib/hwasan/hwasan_interface_internal.h
@@ -168,54 +168,6 @@
 SANITIZER_INTERFACE_ATTRIBUTE
 void __hwasan_print_memory_usage();
 
-SANITIZER_INTERFACE_ATTRIBUTE
-int __sanitizer_posix_memalign(void **memptr, uptr alignment, uptr size);
-
-SANITIZER_INTERFACE_ATTRIBUTE
-void * __sanitizer_memalign(uptr alignment, uptr size);
-
-SANITIZER_INTERFACE_ATTRIBUTE
-void * __sanitizer_aligned_alloc(uptr alignment, uptr size);
-
-SANITIZER_INTERFACE_ATTRIBUTE
-void * __sanitizer___libc_memalign(uptr alignment, uptr size);
-
-SANITIZER_INTERFACE_ATTRIBUTE
-void * __sanitizer_valloc(uptr size);
-
-SANITIZER_INTERFACE_ATTRIBUTE
-void * __sanitizer_pvalloc(uptr size);
-
-SANITIZER_INTERFACE_ATTRIBUTE
-void __sanitizer_free(void *ptr);
-
-SANITIZER_INTERFACE_ATTRIBUTE
-void __sanitizer_cfree(void *ptr);
-
-SANITIZER_INTERFACE_ATTRIBUTE
-uptr __sanitizer_malloc_usable_size(const void *ptr);
-
-SANITIZER_INTERFACE_ATTRIBUTE
-__hwasan::__sanitizer_struct_mallinfo __sanitizer_mallinfo();
-
-SANITIZER_INTERFACE_ATTRIBUTE
-int __sanitizer_mallopt(int cmd, int value);
-
-SANITIZER_INTERFACE_ATTRIBUTE
-void __sanitizer_malloc_stats(void);
-
-SANITIZER_INTERFACE_ATTRIBUTE
-void * __sanitizer_calloc(uptr nmemb, uptr size);
-
-SANITIZER_INTERFACE_ATTRIBUTE
-void * __sanitizer_realloc(void *ptr, uptr size);
-
-SANITIZER_INTERFACE_ATTRIBUTE
-void * __sanitizer_reallocarray(void *ptr, uptr nmemb, uptr size);
-
-SANITIZER_INTERFACE_ATTRIBUTE
-void * __sanitizer_malloc(uptr size);
-
 SANITIZER_INTERFACE_ATTRIBUTE
 void *__hwasan_memcpy(void *dst, const void *src, uptr size);
 SANITIZER_INTERFACE_ATTRIBUTE
Index: compiler-rt/lib/hwasan/hwasan_allocation_functions.cpp
===
--- compiler-rt/lib/hwasan/hwasan_allocation_functions.cpp
+++ compiler-rt/lib/hwasan/hwasan_allocation_functions.cpp
@@ -17,6 +17,58 @@
 #include "sanitizer_common/sanitizer_allocator_interface.h"
 #include "sanitizer_common/sanitizer_tls_get_addr.h"
 
+#if !SANITIZER_FUCHSIA
+extern "C" {
+
+SANITIZER_INTERFACE_ATTRIBUTE
+int __sanitizer_posix_memalign(void **memptr, uptr alignment, uptr size);
+
+SANITIZER_INTERFACE_ATTRIBUTE
+void * __sanitizer_memalign(uptr alignment, uptr size);
+
+SANITIZER_INTERFACE_ATTRIBUTE
+void * __sanitizer_aligned_alloc(uptr alignment, uptr size);
+
+SANITIZER_INTERFACE_ATTRIBUTE
+void * __sanitizer___libc_memalign(uptr alignment, uptr size);
+
+SANITIZER_INTERFACE_ATTRIBUTE
+void * __sanitizer_valloc(uptr size);
+
+SANITIZER_INTERFACE_ATTRIBUTE
+void * __sanitizer_pvalloc(uptr size);
+
+SANITIZER_INTERFACE_ATTRIBUTE
+void __sanitizer_free(void *ptr);
+
+SANITIZER_INTERFACE_ATTRIBUTE
+void __sanitizer_cfree(void *ptr);
+
+SANITIZER_INTERFACE_ATTRIBUTE
+uptr __sanitizer_malloc_usable_size(const void *ptr);
+
+SANITIZER_INTERFACE_ATTRIBUTE
+__hwasan::__sanitizer_struct_mallinfo __sanitizer_mallinfo();
+
+SANITIZER_INTERFACE_ATTRIBUTE
+int __sanitizer_mallopt(int cmd, int value);
+
+SANITIZER_INTERFACE_ATTRIBUTE
+void __sanitizer_malloc_stats(void);
+
+SANITIZER_INTERFACE_ATTRIBUTE
+void * __sanitizer_calloc(uptr nmemb, uptr size);
+
+SANITIZER_INTERFACE_ATTRIBUTE
+void * __sanitizer_realloc(void *ptr, uptr size);
+
+SANITIZER_INTERFACE_ATTRIBUTE
+void * __sanitizer_reallocarray(void *ptr, uptr nmemb, uptr size);
+
+SANITIZER_INTERFACE_ATTRIBUTE
+void * __sanitizer_malloc(uptr size);
+}  // extern "C"
+
 using namespace __hwasan;
 
 static uptr allocated_for_dlsym;
@@ -170,3 +222,4 @@
 INTERCEPTOR_ALIAS(void, malloc_stats, void);
 #  endif
 #endif  // #if HWASAN_WITH_INTERCEPTORS
+#endif
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74436: Change clang option -ffp-model=precise to select ffp-contract=on

2021-07-27 Thread Melanie Blower via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG48ad446a0fb2: [clang][fpenv][patch] Change clang option 
-ffp-model=precise to select ffp… (authored by mibintc).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74436

Files:
  clang/docs/UsersManual.rst
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGen/ffp-contract-option.c
  clang/test/CodeGen/ppc-emmintrin.c
  clang/test/CodeGen/ppc-xmmintrin.c
  clang/test/Driver/fp-model.c

Index: clang/test/Driver/fp-model.c
===
--- clang/test/Driver/fp-model.c
+++ clang/test/Driver/fp-model.c
@@ -1,88 +1,90 @@
 // Test that incompatible combinations of -ffp-model= options
 // and other floating point options get a warning diagnostic.
-//
-// REQUIRES: clang-driver
 
-// RUN: %clang -### -ffp-model=fast -ffp-contract=off -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=fast -ffp-contract=off -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARN %s
 // WARN: warning: overriding '-ffp-model=fast' option with '-ffp-contract=off' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=fast -ffp-contract=on -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=fast -ffp-contract=on -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARN1 %s
 // WARN1: warning: overriding '-ffp-model=fast' option with '-ffp-contract=on' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -fassociative-math -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict -fassociative-math -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARN2 %s
 // WARN2: warning: overriding '-ffp-model=strict' option with '-fassociative-math' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -ffast-math -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict -ffast-math -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARN3 %s
 // WARN3: warning: overriding '-ffp-model=strict' option with '-ffast-math' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -ffinite-math-only -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict -ffinite-math-only -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARN4 %s
 // WARN4: warning: overriding '-ffp-model=strict' option with '-ffinite-math-only' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -ffp-contract=fast -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict -ffp-contract=fast -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARN5 %s
 // WARN5: warning: overriding '-ffp-model=strict' option with '-ffp-contract=fast' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -ffp-contract=on -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict -ffp-contract=fast -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN6 %s
+// WARN6: warning: overriding '-ffp-model=strict' option with '-ffp-contract=fast' [-Woverriding-t-option]
+
+// RUN: %clang -target x86_64 -### -ffp-model=strict -ffp-contract=on -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARN7 %s
 // WARN7: warning: overriding '-ffp-model=strict' option with '-ffp-contract=on' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -fno-honor-infinities -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict -fno-honor-infinities -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARN8 %s
 // WARN8: warning: overriding '-ffp-model=strict' option with '-fno-honor-infinities' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -fno-honor-nans -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict -fno-honor-nans -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARN9 %s
 // WARN9: warning: overriding '-ffp-model=strict' option with '-fno-honor-nans' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -fno-rounding-math -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict -fno-rounding-math -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARNa %s
 // WARNa: warning: overriding '-ffp-model=strict' option with '-fno-rounding-math' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -fno-signed-zeros -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict -fno-signed-zeros -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARNb %s
 // WARNb: warning: overriding '-ffp-model=strict' option with '-fno-signed-zeros' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -fno-trapping-math -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### -ffp-model=strict -fno-trapping-math -c %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=WARNc %s
 // WARNc: warning: overriding '-ffp-model=strict' option with '-fno-trapping-math' [-Woverriding-t-option]
 
-// RUN: %clang -### -ffp-model=strict -freciprocal-math -c %s 2>&1 \
+// RUN: %clang -target x86_64 -### 

[clang] 48ad446 - [clang][fpenv][patch] Change clang option -ffp-model=precise to select ffp-contract=on

2021-07-27 Thread Melanie Blower via cfe-commits

Author: Melanie Blower
Date: 2021-07-27T13:55:31-04:00
New Revision: 48ad446a0fb2c9b98cb7047e4daf8a84c29cef8f

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

LOG: [clang][fpenv][patch] Change clang option -ffp-model=precise to select 
ffp-contract=on

Change the ffp-model=precise to enables -ffp-contract=on (previously
-ffp-model=precise enabled -ffp-contract=fast). This is a follow-up
to Andy Kaylor's comments in the llvm-dev discussion "Floating Point
semantic modes". From the same email thread, I put Andy's distillation
of floating point options and floating point modes into UsersManual.rst
Also fixes bugs.llvm.org/show_bug.cgi?id=50222

I had to revert this a few times because of failures on the x86-64
buildbot but I think we finally have that fixed by LNT/79f2b03c51.

Reviewed By: rjmccall, andrew.kaylor

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

Added: 


Modified: 
clang/docs/UsersManual.rst
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/CodeGen/ffp-contract-option.c
clang/test/CodeGen/ppc-emmintrin.c
clang/test/CodeGen/ppc-xmmintrin.c
clang/test/Driver/fp-model.c

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 20be01a5f40ac..aecd28e5e12a6 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -1260,8 +1260,50 @@ installed.
 Controlling Floating Point Behavior
 ---
 
-Clang provides a number of ways to control floating point behavior. The options
-are listed below.
+Clang provides a number of ways to control floating point behavior, including
+with command line options and source pragmas. This section
+describes the various floating point semantic modes and the corresponding 
options.
+
+.. csv-table:: Floating Point Semantic Modes
+  :header: "Mode", "Values"
+  :widths: 15, 30, 30
+
+  "except_behavior", "{ignore, strict, may_trap}", "ffp-exception-behavior"
+  "fenv_access", "{off, on}", "(none)"
+  "rounding_mode", "{dynamic, tonearest, downward, upward, towardzero}", 
"frounding-math"
+  "contract", "{on, off, fast}", "ffp-contract"
+  "denormal_fp_math", "{IEEE, PreserveSign, PositiveZero}", "fdenormal-fp-math"
+  "denormal_fp32_math", "{IEEE, PreserveSign, PositiveZero}", 
"fdenormal-fp-math-fp32"
+  "support_math_errno", "{on, off}", "fmath-errno"
+  "no_honor_nans", "{on, off}", "fhonor-nans"
+  "no_honor_infinities", "{on, off}", "fhonor-infinities"
+  "no_signed_zeros", "{on, off}", "fsigned-zeros"
+  "allow_reciprocal", "{on, off}", "freciprocal-math"
+  "allow_approximate_fns", "{on, off}", "(none)"
+  "allow_reassociation", "{on, off}", "fassociative-math"
+
+
+This table describes the option settings that correspond to the three
+floating point semantic models: precise (the default), strict, and fast.
+
+
+.. csv-table:: Floating Point Models
+  :header: "Mode", "Precise", "Strict", "Fast"
+  :widths: 25, 15, 15, 15
+
+  "except_behavior", "ignore", "strict", "ignore"
+  "fenv_access", "off", "on", "off"
+  "rounding_mode", "tonearest", "dynamic", "tonearest"
+  "contract", "on", "off", "fast"
+  "denormal_fp_math", "IEEE", "IEEE", "PreserveSign"
+  "denormal_fp32_math", "IEEE","IEEE", "PreserveSign"
+  "support_math_errno", "on", "on", "off"
+  "no_honor_nans", "off", "off", "on"
+  "no_honor_infinities", "off", "off", "on"
+  "no_signed_zeros", "off", "off", "on"
+  "allow_reciprocal", "off", "off", "on"
+  "allow_approximate_fns", "off", "off", "on"
+  "allow_reassociation", "off", "off", "on"
 
 .. option:: -ffast-math
 
@@ -1456,7 +1498,7 @@ Note that floating-point operations performed as part of 
constant initialization
and ``fast``.
Details:
 
-   * ``precise`` Disables optimizations that are not value-safe on 
floating-point data, although FP contraction (FMA) is enabled 
(``-ffp-contract=fast``).  This is the default behavior.
+   * ``precise`` Disables optimizations that are not value-safe on 
floating-point data, although FP contraction (FMA) is enabled 
(``-ffp-contract=on``).  This is the default behavior.
* ``strict`` Enables ``-frounding-math`` and 
``-ffp-exception-behavior=strict``, and disables contractions (FMA).  All of 
the ``-ffast-math`` enablements are disabled. Enables ``STDC FENV_ACCESS``: by 
default ``FENV_ACCESS`` is disabled. This option setting behaves as though 
``#pragma STDC FENV_ACESS ON`` appeared at the top of the source file.
* ``fast`` Behaves identically to specifying both ``-ffast-math`` and 
``ffp-contract=fast``
 

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index ebdc63e249b61..a4b53a640ab5c 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2638,7 +2638,7 @@ static 

[PATCH] D106895: [dfsan][NFC] Update API interfaces

2021-07-27 Thread stephan.yichao.zhao via Phabricator via cfe-commits
stephan.yichao.zhao created this revision.
stephan.yichao.zhao added a reviewer: gbalats.
stephan.yichao.zhao requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106895

Files:
  clang/docs/DataFlowSanitizerDesign.rst


Index: clang/docs/DataFlowSanitizerDesign.rst
===
--- clang/docs/DataFlowSanitizerDesign.rst
+++ clang/docs/DataFlowSanitizerDesign.rst
@@ -48,12 +48,79 @@
   /// value.
   dfsan_label dfsan_get_label(long data);
 
+  /// Retrieves the label associated with the data at the given address.
+  dfsan_label dfsan_read_label(const void *addr, size_t size);
+
   /// Returns whether the given label label contains the label elem.
   int dfsan_has_label(dfsan_label label, dfsan_label elem);
 
   /// Computes the union of \c l1 and \c l2, resulting in a union label.
   dfsan_label dfsan_union(dfsan_label l1, dfsan_label l2);
 
+  /// Flushes the DFSan shadow, i.e. forgets about all labels currently 
associated
+  /// with the application memory.  Use this call to start over the taint 
tracking
+  /// within the same process.
+  ///
+  /// Note: If another thread is working with tainted data during the flush, 
that
+  /// taint could still be written to shadow after the flush.
+  void dfsan_flush(void);
+
+The following functions are provided to check origin tracking status and 
results.
+
+.. code-block:: c
+
+  /// Retrieves the immediate origin associated with the given data. The 
returned
+  /// origin may point to another origin.
+  ///
+  /// The type of 'data' is arbitrary. The function accepts a value of any 
type,
+  /// which can be truncated or extended (implicitly or explicitly) as 
necessary.
+  /// The truncation/extension operations will preserve the label of the 
original
+  /// value.
+  dfsan_origin dfsan_get_origin(long data);
+
+  /// Retrieves the very first origin associated with the data at the given
+  /// address.
+  dfsan_origin dfsan_get_init_origin(const void *addr);
+
+  /// Prints the origin trace of the label at the address `addr` to stderr. It 
also
+  /// prints description at the beginning of the trace. If origin tracking is 
not
+  /// on, or the address is not labeled, it prints nothing.
+  void dfsan_print_origin_trace(const void *addr, const char *description);
+
+  /// Prints the origin trace of the label at the address `addr` to a 
pre-allocated
+  /// output buffer. If origin tracking is not on, or the address is`
+  /// not labeled, it prints nothing.
+  ///
+  /// `addr` is the tainted memory address whose origin we are printing.
+  /// `description` is a description printed at the beginning of the trace.
+  /// `out_buf` is the output buffer to write the results to. `out_buf_size` is
+  /// the size of `out_buf`. The function returns the number of symbols that
+  /// should have been written to `out_buf` (not including trailing null byte 
'\0').
+  /// Thus, the string is truncated iff return value is not less than 
`out_buf_size`.
+  size_t dfsan_sprint_origin_trace(const void *addr, const char *description,
+   char *out_buf, size_t out_buf_size);
+
+  /// Returns the value of `-dfsan-track-origins`.
+  int dfsan_get_track_origins(void);
+
+The following functions are provided to register hooks called by custom 
wrappers.
+
+.. code-block:: c
+
+  /// Sets a callback to be invoked on calls to `write`.  The callback is 
invoked
+  /// before the write is done. The write is not guaranteed to succeed when the
+  /// callback executes. Pass in NULL to remove any callback.
+  typedef void (*dfsan_write_callback_t)(int fd, const void *buf, size_t 
count);
+  void dfsan_set_write_callback(dfsan_write_callback_t labeled_write_callback);
+
+  /// Callbacks to be invoked on calls to `memcmp` or `strncmp`.
+  void dfsan_weak_hook_memcmp(void *caller_pc, const void *s1, const void *s2,
+  size_t n, dfsan_label s1_label,
+  dfsan_label s2_label, dfsan_label n_label);
+  void dfsan_weak_hook_strncmp(void *caller_pc, const char *s1, const char *s2,
+  size_t n, dfsan_label s1_label,
+  dfsan_label s2_label, dfsan_label n_label);
+
 Taint label representation
 --
 


Index: clang/docs/DataFlowSanitizerDesign.rst
===
--- clang/docs/DataFlowSanitizerDesign.rst
+++ clang/docs/DataFlowSanitizerDesign.rst
@@ -48,12 +48,79 @@
   /// value.
   dfsan_label dfsan_get_label(long data);
 
+  /// Retrieves the label associated with the data at the given address.
+  dfsan_label dfsan_read_label(const void *addr, size_t size);
+
   /// Returns whether the given label label contains the label elem.
   int dfsan_has_label(dfsan_label label, dfsan_label elem);
 
   /// Computes 

[PATCH] D106891: [AMDGPU] [Remarks] Emit optimization remarks when an FP atomic instruction is converted into a CAS loop or unsafe hardware instruction for GFX90A

2021-07-27 Thread Anshil Gandhi via Phabricator via cfe-commits
gandhi21299 created this revision.
gandhi21299 added reviewers: arsenm, yaxunl, rampitec.
gandhi21299 created this object with edit policy "Members of Project: AMDGPU".
Herald added subscribers: foad, kerbowa, jfb, hiraditya, t-tye, tpr, dstuttard, 
nhaehnle, jvesely, kzhuravl.
gandhi21299 requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, wdng.
Herald added projects: clang, LLVM.

Implements ORE in SIISelLowering.cpp, reports CAS loop or unsafe hardware 
instruction if the flag `unsafe-fp-atomics` is enabled for the subtarget GFX90A.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106891

Files:
  clang/test/CodeGenCUDA/fp-atomics-optremarks.cu
  llvm/lib/Target/AMDGPU/SIISelLowering.cpp
  llvm/lib/Target/AMDGPU/SIISelLowering.h

Index: llvm/lib/Target/AMDGPU/SIISelLowering.h
===
--- llvm/lib/Target/AMDGPU/SIISelLowering.h
+++ llvm/lib/Target/AMDGPU/SIISelLowering.h
@@ -30,6 +30,7 @@
 class SITargetLowering final : public AMDGPUTargetLowering {
 private:
   const GCNSubtarget *Subtarget;
+  OptimizationRemarkEmitter *ORE;
 
 public:
   MVT getRegisterTypeForCallingConv(LLVMContext ,
Index: llvm/lib/Target/AMDGPU/SIISelLowering.cpp
===
--- llvm/lib/Target/AMDGPU/SIISelLowering.cpp
+++ llvm/lib/Target/AMDGPU/SIISelLowering.cpp
@@ -19,6 +19,7 @@
 #include "SIRegisterInfo.h"
 #include "llvm/ADT/Statistic.h"
 #include "llvm/Analysis/LegacyDivergenceAnalysis.h"
+#include "llvm/Analysis/OptimizationRemarkEmitter.h"
 #include "llvm/BinaryFormat/ELF.h"
 #include "llvm/CodeGen/Analysis.h"
 #include "llvm/CodeGen/FunctionLoweringInfo.h"
@@ -12117,6 +12118,27 @@
   return DenormMode == DenormalMode::getIEEE();
 }
 
+static TargetLowering::AtomicExpansionKind
+atomicExpandReturn(OptimizationRemarkEmitter *ORE, AtomicRMWInst *RMW,
+   TargetLowering::AtomicExpansionKind Kind, bool UnsafeFlag) {
+  ORE = new OptimizationRemarkEmitter(RMW->getFunction());
+  if (Kind == TargetLowering::AtomicExpansionKind::CmpXChg) {
+ORE->emit([&]() {
+  OptimizationRemark Remark(DEBUG_TYPE, "Passed", RMW->getFunction());
+  Remark << "An FP atomic instruction was expanded into a CAS loop.";
+  return Remark;
+});
+  } else if (Kind == TargetLowering::AtomicExpansionKind::None && UnsafeFlag) {
+ORE->emit([&]() {
+  OptimizationRemark Remark(DEBUG_TYPE, "Passed", RMW->getFunction());
+  Remark << "An unsafe hardware instruction was generated.";
+  return Remark;
+});
+  }
+  delete ORE;
+  return Kind;
+}
+
 TargetLowering::AtomicExpansionKind
 SITargetLowering::shouldExpandAtomicRMWInIR(AtomicRMWInst *RMW) const {
   switch (RMW->getOperation()) {
@@ -12132,35 +12154,42 @@
   return AtomicExpansionKind::CmpXChg;
 
 unsigned AS = RMW->getPointerAddressSpace();
-
+bool UnsafeFPAtomicFlag = RMW->getFunction()
+  ->getFnAttribute("amdgpu-unsafe-fp-atomics")
+  .getValueAsBool();
 if ((AS == AMDGPUAS::GLOBAL_ADDRESS || AS == AMDGPUAS::FLAT_ADDRESS) &&
  Subtarget->hasAtomicFaddInsts()) {
   // The amdgpu-unsafe-fp-atomics attribute enables generation of unsafe
   // floating point atomic instructions. May generate more efficient code,
   // but may not respect rounding and denormal modes, and may give incorrect
   // results for certain memory destinations.
-  if (RMW->getFunction()
-  ->getFnAttribute("amdgpu-unsafe-fp-atomics")
-  .getValueAsString() != "true")
-return AtomicExpansionKind::CmpXChg;
+  if (!UnsafeFPAtomicFlag)
+return atomicExpandReturn(ORE, RMW, AtomicExpansionKind::CmpXChg,
+  false);
+  atomicExpandReturn(ORE, RMW, AtomicExpansionKind::None, true);
 
   if (Subtarget->hasGFX90AInsts()) {
 if (Ty->isFloatTy() && AS == AMDGPUAS::FLAT_ADDRESS)
-  return AtomicExpansionKind::CmpXChg;
+  return atomicExpandReturn(ORE, RMW, AtomicExpansionKind::CmpXChg,
+UnsafeFPAtomicFlag);
 
 auto SSID = RMW->getSyncScopeID();
 if (SSID == SyncScope::System ||
 SSID == RMW->getContext().getOrInsertSyncScopeID("one-as"))
-  return AtomicExpansionKind::CmpXChg;
+  return atomicExpandReturn(ORE, RMW, AtomicExpansionKind::CmpXChg,
+UnsafeFPAtomicFlag);
 
-return AtomicExpansionKind::None;
+return atomicExpandReturn(ORE, RMW, AtomicExpansionKind::None,
+  UnsafeFPAtomicFlag);
   }
 
   if (AS == AMDGPUAS::FLAT_ADDRESS)
-return AtomicExpansionKind::CmpXChg;
+return atomicExpandReturn(ORE, RMW, AtomicExpansionKind::CmpXChg,
+  UnsafeFPAtomicFlag);
 
-  return RMW->use_empty() ? 

[PATCH] D106890: [z/OS] Make MinGlobalAlign consistent with SystemZ

2021-07-27 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan accepted this revision.
abhina.sreeskantharajan added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106890

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


[PATCH] D106890: [z/OS] Make MinGlobalAlign consistent with SystemZ

2021-07-27 Thread Fanbo Meng via Phabricator via cfe-commits
fanbo-meng created this revision.
fanbo-meng requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Remove overriding MinGlobalAlign to 0 for z/OS target to be consistent with 
SystemZ.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106890

Files:
  clang/lib/Basic/Targets/OSTargets.h


Index: clang/lib/Basic/Targets/OSTargets.h
===
--- clang/lib/Basic/Targets/OSTargets.h
+++ clang/lib/Basic/Targets/OSTargets.h
@@ -796,7 +796,6 @@
 this->UseZeroLengthBitfieldAlignment = true;
 this->UseLeadingZeroLengthBitfield = false;
 this->ZeroLengthBitfieldBoundary = 32;
-this->MinGlobalAlign = 0;
 this->DefaultAlignForAttributeAligned = 128;
   }
 };


Index: clang/lib/Basic/Targets/OSTargets.h
===
--- clang/lib/Basic/Targets/OSTargets.h
+++ clang/lib/Basic/Targets/OSTargets.h
@@ -796,7 +796,6 @@
 this->UseZeroLengthBitfieldAlignment = true;
 this->UseLeadingZeroLengthBitfield = false;
 this->ZeroLengthBitfieldBoundary = 32;
-this->MinGlobalAlign = 0;
 this->DefaultAlignForAttributeAligned = 128;
   }
 };
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D106298: [OpenMP] Creating the `omp_target_num_teams` and `omp_target_thread_limit` attributes to outlined functions

2021-07-27 Thread Jose Manuel Monsalve Diaz via Phabricator via cfe-commits
josemonsalve2 updated this revision to Diff 362074.
josemonsalve2 added a comment.

Fixing tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D106298

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/test/OpenMP/declare_target_codegen_globalization.cpp
  clang/test/OpenMP/nvptx_lambda_capturing.cpp
  clang/test/OpenMP/nvptx_multi_target_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_target_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_num_threads_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/target_map_codegen_03.cpp
  clang/test/OpenMP/target_num_teams_num_threads_attributes.cpp
  clang/test/OpenMP/target_parallel_codegen.cpp
  clang/test/OpenMP/target_parallel_debug_codegen.cpp
  clang/test/OpenMP/target_parallel_for_codegen.cpp
  clang/test/OpenMP/target_parallel_for_debug_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/target_parallel_if_codegen.cpp
  clang/test/OpenMP/target_parallel_num_threads_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_collapse_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_dist_schedule_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_private_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_reduction_codegen.cpp
  clang/test/OpenMP/target_teams_num_teams_codegen.cpp
  clang/test/OpenMP/target_teams_thread_limit_codegen.cpp
  clang/test/OpenMP/teams_codegen.cpp

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


  1   2   3   >