[clang] 410cfc4 - [OpenMP][FIX] Add second include after header was split in d1705c1196

2020-04-01 Thread Johannes Doerfert via cfe-commits

Author: Johannes Doerfert
Date: 2020-04-02T00:20:23-05:00
New Revision: 410cfc478f3540d3f07bba920fa3bf99409f6bda

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

LOG: [OpenMP][FIX] Add second include after header was split in d1705c1196

The math wrapper handling is going to be replaced shortly and
d1705c1196fedfe927716923ac121f1134924a36 was actually a precursor for
that.

Added: 


Modified: 
clang/lib/Headers/openmp_wrappers/__clang_openmp_math_declares.h

Removed: 




diff  --git a/clang/lib/Headers/openmp_wrappers/__clang_openmp_math_declares.h 
b/clang/lib/Headers/openmp_wrappers/__clang_openmp_math_declares.h
index a422c98bf97d..dd97faca6932 100644
--- a/clang/lib/Headers/openmp_wrappers/__clang_openmp_math_declares.h
+++ b/clang/lib/Headers/openmp_wrappers/__clang_openmp_math_declares.h
@@ -26,6 +26,7 @@
 #include <__clang_cuda_libdevice_declares.h>
 /// Provide definitions for these functions.
 #include <__clang_cuda_device_functions.h>
+#include <__clang_cuda_math.h>
 
 #undef __CUDA__
 



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


[PATCH] D77238: [CUDA][NFC] Split math.h functions out of __clang_cuda_device_functions.h

2020-04-01 Thread Johannes Doerfert via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd1705c1196fe: [CUDA][NFC] Split math.h functions out of 
__clang_cuda_device_functions.h (authored by jdoerfert).

Changed prior to commit:
  https://reviews.llvm.org/D77238?vs=254289=254426#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77238

Files:
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/__clang_cuda_device_functions.h
  clang/lib/Headers/__clang_cuda_math.h
  clang/lib/Headers/__clang_cuda_runtime_wrapper.h

Index: clang/lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- clang/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ clang/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -143,11 +143,12 @@
 // to provide our own.
 #include <__clang_cuda_libdevice_declares.h>
 
-// Wrappers for many device-side standard library functions became compiler
-// builtins in CUDA-9 and have been removed from the CUDA headers. Clang now
-// provides its own implementation of the wrappers.
+// Wrappers for many device-side standard library functions, incl. math
+// functions, became compiler builtins in CUDA-9 and have been removed from the
+// CUDA headers. Clang now provides its own implementation of the wrappers.
 #if CUDA_VERSION >= 9000
 #include <__clang_cuda_device_functions.h>
+#include <__clang_cuda_math.h>
 #endif
 
 // __THROW is redefined to be empty by device_functions_decls.h in CUDA. Clang's
Index: clang/lib/Headers/__clang_cuda_math.h
===
--- /dev/null
+++ clang/lib/Headers/__clang_cuda_math.h
@@ -0,0 +1,347 @@
+/*=== __clang_cuda_math.h - Device-side CUDA math support --===
+ *
+ * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+ * See https://llvm.org/LICENSE.txt for license information.
+ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+ *
+ *===---===
+ */
+#ifndef __CLANG_CUDA_MATH_H__
+#define __CLANG_CUDA_MATH_H__
+#ifndef __CUDA__
+#error "This file is for CUDA compilation only."
+#endif
+
+#ifndef _OPENMP
+#if CUDA_VERSION < 9000
+#error This file is intended to be used with CUDA-9+ only.
+#endif
+#endif
+
+// __DEVICE__ is a helper macro with common set of attributes for the wrappers
+// we implement in this file. We need static in order to avoid emitting unused
+// functions and __forceinline__ helps inlining these wrappers at -O1.
+#pragma push_macro("__DEVICE__")
+#ifdef _OPENMP
+#define __DEVICE__ static constexpr __attribute__((always_inline, nothrow))
+#else
+#define __DEVICE__ static __device__ __forceinline__
+#endif
+
+// Specialized version of __DEVICE__ for functions with void return type. Needed
+// because the OpenMP overlay requires constexpr functions here but prior to
+// c++14 void return functions could not be constexpr.
+#pragma push_macro("__DEVICE_VOID__")
+#ifdef _OPENMP
+#if defined(__cplusplus) && __cplusplus >= 201402L
+#define __DEVICE_VOID__ static constexpr __attribute__((always_inline, nothrow))
+#else
+#define __DEVICE_VOID__ static __attribute__((always_inline, nothrow))
+#endif
+#else
+#define __DEVICE_VOID__ __DEVICE__
+#endif
+
+// libdevice provides fast low precision and slow full-recision implementations
+// for some functions. Which one gets selected depends on
+// __CLANG_CUDA_APPROX_TRANSCENDENTALS__ which gets defined by clang if
+// -ffast-math or -fcuda-approx-transcendentals are in effect.
+#pragma push_macro("__FAST_OR_SLOW")
+#if defined(__CLANG_CUDA_APPROX_TRANSCENDENTALS__)
+#define __FAST_OR_SLOW(fast, slow) fast
+#else
+#define __FAST_OR_SLOW(fast, slow) slow
+#endif
+
+__DEVICE__ int abs(int __a) { return __nv_abs(__a); }
+__DEVICE__ double fabs(double __a) { return __nv_fabs(__a); }
+__DEVICE__ double acos(double __a) { return __nv_acos(__a); }
+__DEVICE__ float acosf(float __a) { return __nv_acosf(__a); }
+__DEVICE__ double acosh(double __a) { return __nv_acosh(__a); }
+__DEVICE__ float acoshf(float __a) { return __nv_acoshf(__a); }
+__DEVICE__ double asin(double __a) { return __nv_asin(__a); }
+__DEVICE__ float asinf(float __a) { return __nv_asinf(__a); }
+__DEVICE__ double asinh(double __a) { return __nv_asinh(__a); }
+__DEVICE__ float asinhf(float __a) { return __nv_asinhf(__a); }
+__DEVICE__ double atan(double __a) { return __nv_atan(__a); }
+__DEVICE__ double atan2(double __a, double __b) { return __nv_atan2(__a, __b); }
+__DEVICE__ float atan2f(float __a, float __b) { return __nv_atan2f(__a, __b); }
+__DEVICE__ float atanf(float __a) { return __nv_atanf(__a); }
+__DEVICE__ double atanh(double __a) { return __nv_atanh(__a); }
+__DEVICE__ float atanhf(float __a) { return __nv_atanhf(__a); }
+__DEVICE__ double cbrt(double __a) { return __nv_cbrt(__a); }
+__DEVICE__ float cbrtf(float __a) { return 

[PATCH] D72959: Relative VTables ABI on Fuchsia

2020-04-01 Thread Louis Dionne via Phabricator via cfe-commits
ldionne requested changes to this revision.
ldionne added inline comments.



Comment at: libcxxabi/src/private_typeinfo.cpp:617
 // Get (dynamic_ptr, dynamic_type) from static_ptr
+#ifndef __Fuchsia__
 void **vtable = *static_cast(static_ptr);

Please introduce a macro that generically expresses that relative vtables are 
enabled, and explain what it is. You can then enable that macro only on 
`__Fuchsia__`. I'd like to avoid freely adding platform-specific `#ifdef`s in 
the code when it's easy to avoid.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72959



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


[PATCH] D70411: [analyzer] CERT: STR31-C

2020-04-01 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso updated this revision to Diff 254420.
Charusso marked 4 inline comments as done.
Charusso added a comment.

- Simplify tests.
- Remove dead code, they are far away to being used.
- Add an extra test case.


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

https://reviews.llvm.org/D70411

Files:
  clang/docs/analyzer/checkers.rst
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/lib/StaticAnalyzer/Checkers/AllocationState.h
  clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
  clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/cert/StrChecker.cpp
  clang/test/Analysis/Inputs/system-header-simulator.h
  clang/test/Analysis/cert/str31-c-false-positive-suppression.cpp
  clang/test/Analysis/cert/str31-c-notes.cpp
  clang/test/Analysis/cert/str31-c.cpp

Index: clang/test/Analysis/cert/str31-c.cpp
===
--- /dev/null
+++ clang/test/Analysis/cert/str31-c.cpp
@@ -0,0 +1,185 @@
+// RUN: %clang_analyze_cc1 \
+// RUN:  -analyzer-checker=core,unix,alpha.security.cert.str.31c \
+// RUN:  -verify %s
+
+// See the examples on the page of STR31-C:
+// https://wiki.sei.cmu.edu/confluence/display/c/STR31-C.+Guarantee+that+storage+for+strings+has+sufficient+space+for+character+data+and+the+null+terminator
+
+#include "../Inputs/system-header-simulator.h"
+
+#define EOF -1
+typedef __SIZE_TYPE__ size_t;
+
+void free(void *memblock);
+void *malloc(size_t size);
+
+namespace test_gets_bad {
+#define BUFFER_SIZE 1024
+
+void func(void) {
+  char buf[BUFFER_SIZE];
+  if (gets(buf)) {
+// expected-warning@-1 {{'gets' could write outside of 'buf'}}
+  }
+}
+} // namespace test_gets_bad
+
+namespace test_gets_good {
+enum { BUFFERSIZE = 32 };
+
+void func(void) {
+  char buff[BUFFERSIZE];
+
+  if (fgets(buff, sizeof(buff), stdin)) {
+  }
+}
+} // namespace test_gets_good
+
+namespace test_sprintf_bad {
+void func(const char *name) {
+  char buf[128];
+  sprintf(buf, "%s.txt", name);
+  // expected-warning@-1 {{'sprintf' could write outside of 'buf'}}
+}
+} // namespace test_sprintf_bad
+
+namespace test_sprintf_good {
+void func(const char *name) {
+  char buff[128];
+  snprintf(buff, sizeof(buff), "%s.txt", name);
+}
+} // namespace test_sprintf_good
+
+namespace test_fscanf_bad {
+enum { BUF_LENGTH = 1024 };
+
+void get_data(void) {
+  char buf[BUF_LENGTH];
+  fscanf(stdin, "%s", buf);
+  // expected-warning@-1 {{'fscanf' could write outside of 'buf'}}
+}
+} // namespace test_fscanf_bad
+
+namespace test_fscanf_good {
+enum { BUF_LENGTH = 1024 };
+
+void get_data(void) {
+  char buff[BUF_LENGTH];
+  fscanf(stdin, "%1023s", buff);
+}
+} // namespace test_fscanf_good
+
+namespace test_strcpy_bad {
+int main(int argc, char *argv[]) {
+  const char *const name = (argc && argv[0]) ? argv[0] : "";
+  char prog_name[128];
+  strcpy(prog_name, name);
+  // expected-warning@-1 {{'strcpy' could write outside of 'prog_name'}}
+  return 0;
+}
+
+void func(void) {
+  char buff[256];
+  char *editor = getenv("EDITOR");
+  if (editor != NULL) {
+strcpy(buff, editor);
+// expected-warning@-1 {{'strcpy' could write outside of 'buff'}}
+  }
+}
+} // namespace test_strcpy_bad
+
+namespace test_strcpy_good {
+int main(int argc, char *argv[]) {
+  const char *const name = (argc && argv[0]) ? argv[0] : "";
+  char *prog_name2 = (char *)malloc(strlen(name) + 1);
+  if (prog_name2 != NULL) {
+strcpy(prog_name2, name);
+  }
+
+  free(prog_name2);
+  return 0;
+}
+
+void func(void) {
+  char *buff2;
+  char *editor = getenv("EDITOR");
+  if (editor != NULL) {
+size_t len = strlen(editor) + 1;
+buff2 = (char *)malloc(len);
+if (buff2 != NULL) {
+  strcpy(buff2, editor);
+}
+
+free(buff2);
+  }
+}
+} // namespace test_strcpy_good
+
+//===--===//
+// The following are from the rule's page which we do not handle yet.
+//===--===//
+
+namespace test_loop_index_bad {
+void copy(size_t n, char src[n], char dest[n]) {
+  size_t i;
+
+  for (i = 0; src[i] && (i < n); ++i) {
+dest[i] = src[i];
+  }
+  dest[i] = '\0';
+}
+} // namespace test_loop_index_bad
+
+namespace test_loop_index_good {
+void copy(size_t n, char src[n], char dest[n]) {
+  size_t i;
+
+  for (i = 0; src[i] && (i < n - 1); ++i) {
+dest[i] = src[i];
+  }
+  dest[i] = '\0';
+}
+} // namespace test_loop_index_good
+
+namespace test_getchar_bad {
+enum { BUFFERSIZE = 32 };
+
+void func(void) {
+  char buf[BUFFERSIZE];
+  char *p;
+  int ch;
+  p = buf;
+  while ((ch = getchar()) != '\n' && ch != EOF) {
+*p++ = (char)ch;
+  }
+  *p++ = 0;
+  if (ch == EOF) {
+/* Handle EOF or error */
+  }
+}
+} // namespace test_getchar_bad
+
+namespace test_getchar_good {
+enum { BUFFERSIZE = 32 };
+
+void func(void) {
+  char buf[BUFFERSIZE];
+  int ch;
+  size_t index = 0;
+  size_t 

[PATCH] D70411: [analyzer] CERT: STR31-C

2020-04-01 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso updated this revision to Diff 254423.
Charusso added a comment.

- Remove the last dead comment.


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

https://reviews.llvm.org/D70411

Files:
  clang/docs/analyzer/checkers.rst
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/lib/StaticAnalyzer/Checkers/AllocationState.h
  clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
  clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/cert/StrChecker.cpp
  clang/test/Analysis/Inputs/system-header-simulator.h
  clang/test/Analysis/cert/str31-c-false-positive-suppression.cpp
  clang/test/Analysis/cert/str31-c-notes.cpp
  clang/test/Analysis/cert/str31-c.cpp

Index: clang/test/Analysis/cert/str31-c.cpp
===
--- /dev/null
+++ clang/test/Analysis/cert/str31-c.cpp
@@ -0,0 +1,185 @@
+// RUN: %clang_analyze_cc1 \
+// RUN:  -analyzer-checker=core,unix,alpha.security.cert.str.31c \
+// RUN:  -verify %s
+
+// See the examples on the page of STR31-C:
+// https://wiki.sei.cmu.edu/confluence/display/c/STR31-C.+Guarantee+that+storage+for+strings+has+sufficient+space+for+character+data+and+the+null+terminator
+
+#include "../Inputs/system-header-simulator.h"
+
+#define EOF -1
+typedef __SIZE_TYPE__ size_t;
+
+void free(void *memblock);
+void *malloc(size_t size);
+
+namespace test_gets_bad {
+#define BUFFER_SIZE 1024
+
+void func(void) {
+  char buf[BUFFER_SIZE];
+  if (gets(buf)) {
+// expected-warning@-1 {{'gets' could write outside of 'buf'}}
+  }
+}
+} // namespace test_gets_bad
+
+namespace test_gets_good {
+enum { BUFFERSIZE = 32 };
+
+void func(void) {
+  char buff[BUFFERSIZE];
+
+  if (fgets(buff, sizeof(buff), stdin)) {
+  }
+}
+} // namespace test_gets_good
+
+namespace test_sprintf_bad {
+void func(const char *name) {
+  char buf[128];
+  sprintf(buf, "%s.txt", name);
+  // expected-warning@-1 {{'sprintf' could write outside of 'buf'}}
+}
+} // namespace test_sprintf_bad
+
+namespace test_sprintf_good {
+void func(const char *name) {
+  char buff[128];
+  snprintf(buff, sizeof(buff), "%s.txt", name);
+}
+} // namespace test_sprintf_good
+
+namespace test_fscanf_bad {
+enum { BUF_LENGTH = 1024 };
+
+void get_data(void) {
+  char buf[BUF_LENGTH];
+  fscanf(stdin, "%s", buf);
+  // expected-warning@-1 {{'fscanf' could write outside of 'buf'}}
+}
+} // namespace test_fscanf_bad
+
+namespace test_fscanf_good {
+enum { BUF_LENGTH = 1024 };
+
+void get_data(void) {
+  char buff[BUF_LENGTH];
+  fscanf(stdin, "%1023s", buff);
+}
+} // namespace test_fscanf_good
+
+namespace test_strcpy_bad {
+int main(int argc, char *argv[]) {
+  const char *const name = (argc && argv[0]) ? argv[0] : "";
+  char prog_name[128];
+  strcpy(prog_name, name);
+  // expected-warning@-1 {{'strcpy' could write outside of 'prog_name'}}
+  return 0;
+}
+
+void func(void) {
+  char buff[256];
+  char *editor = getenv("EDITOR");
+  if (editor != NULL) {
+strcpy(buff, editor);
+// expected-warning@-1 {{'strcpy' could write outside of 'buff'}}
+  }
+}
+} // namespace test_strcpy_bad
+
+namespace test_strcpy_good {
+int main(int argc, char *argv[]) {
+  const char *const name = (argc && argv[0]) ? argv[0] : "";
+  char *prog_name2 = (char *)malloc(strlen(name) + 1);
+  if (prog_name2 != NULL) {
+strcpy(prog_name2, name);
+  }
+
+  free(prog_name2);
+  return 0;
+}
+
+void func(void) {
+  char *buff2;
+  char *editor = getenv("EDITOR");
+  if (editor != NULL) {
+size_t len = strlen(editor) + 1;
+buff2 = (char *)malloc(len);
+if (buff2 != NULL) {
+  strcpy(buff2, editor);
+}
+
+free(buff2);
+  }
+}
+} // namespace test_strcpy_good
+
+//===--===//
+// The following are from the rule's page which we do not handle yet.
+//===--===//
+
+namespace test_loop_index_bad {
+void copy(size_t n, char src[n], char dest[n]) {
+  size_t i;
+
+  for (i = 0; src[i] && (i < n); ++i) {
+dest[i] = src[i];
+  }
+  dest[i] = '\0';
+}
+} // namespace test_loop_index_bad
+
+namespace test_loop_index_good {
+void copy(size_t n, char src[n], char dest[n]) {
+  size_t i;
+
+  for (i = 0; src[i] && (i < n - 1); ++i) {
+dest[i] = src[i];
+  }
+  dest[i] = '\0';
+}
+} // namespace test_loop_index_good
+
+namespace test_getchar_bad {
+enum { BUFFERSIZE = 32 };
+
+void func(void) {
+  char buf[BUFFERSIZE];
+  char *p;
+  int ch;
+  p = buf;
+  while ((ch = getchar()) != '\n' && ch != EOF) {
+*p++ = (char)ch;
+  }
+  *p++ = 0;
+  if (ch == EOF) {
+/* Handle EOF or error */
+  }
+}
+} // namespace test_getchar_bad
+
+namespace test_getchar_good {
+enum { BUFFERSIZE = 32 };
+
+void func(void) {
+  char buf[BUFFERSIZE];
+  int ch;
+  size_t index = 0;
+  size_t chars_read = 0;
+
+  while ((ch = getchar()) != '\n' && ch != EOF) {
+if (index < sizeof(buf) - 1) {
+  

[PATCH] D77028: [NFC] Refactor DeferredDiagsEmitter and skip redundant visit

2020-04-01 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/Sema/Sema.cpp:1508
   void checkFunc(SourceLocation Loc, FunctionDecl *FD) {
+auto DiagsCountIt = DiagsCount.find(FD);
 FunctionDecl *Caller = UseStack.empty() ? nullptr : UseStack.back();

It makes me a little uncomfortable to be holding an iterator this long while 
calling a fair amount of other stuff in the meantime.

Your use of DiagsCount is subtle enough that it really needs to be explained in 
some comments.  You're doing stuff conditionally based on both whether the 
entry exists but also whether it's non-zero.


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

https://reviews.llvm.org/D77028



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


[PATCH] D75453: [Driver][ARM] fix undefined behaviour when checking architecture version

2020-04-01 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd requested changes to this revision.
compnerd added a comment.
This revision now requires changes to proceed.
Herald added a subscriber: danielkiss.

Seems reasonable, though this isn't UB, its just use of an uninitialized 
variable.

Please add a test case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75453



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


[PATCH] D77233: [NFC] Refactoring PropertyAttributeKind for ObjCPropertyDecl and ObjCDeclSpec.

2020-04-01 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi marked an inline comment as done.
plotfi added inline comments.



Comment at: clang/include/clang/AST/DeclObjCCommon.h:21
+/// Keep this list in sync with LLVM's Dwarf.h ApplePropertyAttributes.
+enum ObjCPropertyAttributeKind {
+  OBJC_PR_noattr = 0x00,

compnerd wrote:
> It seems that you are touching all the sites that use this, so perhaps this 
> is the time to change this to `enum class` and drop the `OBJC_PR_` prefixes 
> and explicitly inherit from `uint16_t`.  This should be named 
> `ObjCPropertyAttribute` I think.
Ah yeah, that sounds pretty good. Will do. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77233



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


[PATCH] D70411: [analyzer] CERT: STR31-C

2020-04-01 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added a comment.

Thanks for the review, hopefully if I ping @NoQ in every round, it will be 
green-marked soon.




Comment at: clang/lib/StaticAnalyzer/Checkers/cert/StrChecker.cpp:55
+  // they can cause a not null-terminated string. In this case we store the
+  // string is being not null-terminated in the 'NullTerminationMap'.
+  //

balazske wrote:
> The functions `gets`, `strcpy` return a null-terminated string according to 
> standard, probably `sprintf` too, and the `fscanf` `%s` output is 
> null-terminated too even if no length is specified (maybe it writes outside 
> of the specified buffer but null terminated).
From where do you observe such information? I have not seen anything 
`strcpy()`-specific in the standard. My observation clearly says that, if there 
is not enough space for the data you *could* even write to overlapping memory, 
or as people says, you could meet nasal demons. It is called *undefined* 
behavior.



Comment at: clang/test/Analysis/cert/str31-c.cpp:117
+  if (editor != NULL) {
+size_t len = strlen(editor) + 1;
+buff2 = (char *)malloc(len);

balazske wrote:
> Do we get a warning if the `+1` above is missing?
Test added.


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

https://reviews.llvm.org/D70411



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


[PATCH] D77238: [CUDA][NFC] Split math.h functions out of __clang_cuda_device_functions.h

2020-04-01 Thread Michael Liao via Phabricator via cfe-commits
hliao added a comment.

this patch breaks the test clang/test/Headers/nvptx_device_cmath_functions.cpp, 
could you please fix it ASAP?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77238



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


[PATCH] D77244: sancov/inline-bool-flag feature + tests + docs.

2020-04-01 Thread Pratyai Mazumder via Phabricator via cfe-commits
pratyai updated this revision to Diff 254418.
pratyai added a comment.

- Switched to Int1Ty.
- Switched Atomic::NonAtomic (same as just dropping the two lines?)
- C++ files were clang-formatted, but arc lint couldn't find clang-format-diff 
before. Now it seems to have formatted the lit tests.
- Will split the patch later (i.e. remove all non-instrumentation stuff from 
this patch, then move flags & compiler-rt tests into two other patches).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77244

Files:
  clang/docs/SanitizerCoverage.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/SanitizerArgs.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/autocomplete.c
  clang/test/Driver/fsanitize-coverage.c
  
compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_inline_bool_flag.cpp
  llvm/include/llvm/Transforms/Instrumentation.h
  llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
  llvm/test/Instrumentation/SanitizerCoverage/coff-pc-table-inline-bool-flag.ll
  llvm/test/Instrumentation/SanitizerCoverage/inline-bool-flag.ll
  llvm/test/Instrumentation/SanitizerCoverage/pc-table.ll
  llvm/test/Instrumentation/SanitizerCoverage/trace-pc-guard-inline-bool-flag.ll

Index: llvm/test/Instrumentation/SanitizerCoverage/trace-pc-guard-inline-bool-flag.ll
===
--- /dev/null
+++ llvm/test/Instrumentation/SanitizerCoverage/trace-pc-guard-inline-bool-flag.ll
@@ -0,0 +1,14 @@
+; RUN: opt < %s -sancov -sanitizer-coverage-level=1 -sanitizer-coverage-trace-pc-guard -sanitizer-coverage-inline-bool-flag -S | FileCheck %s
+; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=1 -sanitizer-coverage-trace-pc-guard -sanitizer-coverage-inline-bool-flag -S | FileCheck %s
+
+; Module ctors should have stable names across modules, not something like
+; @sancov.module_ctor.3 that may cause duplicate ctors after linked together.
+
+; CHECK: define internal void @sancov.module_ctor_trace_pc_guard() comdat {
+; CHECK: define internal void @sancov.module_ctor_bool_flag() comdat {
+
+target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
+target triple = "x86_64-unknown-linux-gnu"
+define void @foo() {
+  ret void
+}
Index: llvm/test/Instrumentation/SanitizerCoverage/pc-table.ll
===
--- llvm/test/Instrumentation/SanitizerCoverage/pc-table.ll
+++ llvm/test/Instrumentation/SanitizerCoverage/pc-table.ll
@@ -1,8 +1,10 @@
 ; Test -sanitizer-coverage-pc-table=1
 ; RUN: opt < %s -sancov -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard   -sanitizer-coverage-pc-table=1 -S | FileCheck %s
 ; RUN: opt < %s -sancov -sanitizer-coverage-level=3 -sanitizer-coverage-inline-8bit-counters -sanitizer-coverage-pc-table=1 -S | FileCheck %s
+; RUN: opt < %s -sancov -sanitizer-coverage-level=3 -sanitizer-coverage-inline-bool-flag -sanitizer-coverage-pc-table=1 -S | FileCheck %s
 ; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard   -sanitizer-coverage-pc-table=1 -S | FileCheck %s
 ; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=3 -sanitizer-coverage-inline-8bit-counters -sanitizer-coverage-pc-table=1 -S | FileCheck %s
+; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=3 -sanitizer-coverage-inline-bool-flag -sanitizer-coverage-pc-table=1 -S | FileCheck %s
 
 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
 target triple = "x86_64-unknown-linux-gnu"
Index: llvm/test/Instrumentation/SanitizerCoverage/inline-bool-flag.ll
===
--- /dev/null
+++ llvm/test/Instrumentation/SanitizerCoverage/inline-bool-flag.ll
@@ -0,0 +1,13 @@
+; Test -sanitizer-coverage-inline-bool-flag=1
+; RUN: opt < %s -sancov -sanitizer-coverage-level=1 -sanitizer-coverage-inline-bool-flag=1  -S | FileCheck %s
+; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=1 -sanitizer-coverage-inline-bool-flag=1  -S | FileCheck %s
+
+target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
+target triple = "x86_64-unknown-linux-gnu"
+define void @foo() {
+entry:
+; CHECK: section "__sancov_bool_flag", comdat($foo), !associated !0
+; CHECK: store i1 true, i1* getelementptr inbounds ([1 x i1], [1 x i1]* @__sancov_gen_, i64 0, i64 0), !nosanitize !1
+  ret void
+}
+; CHECK: call 

[clang] d1705c1 - [CUDA][NFC] Split math.h functions out of __clang_cuda_device_functions.h

2020-04-01 Thread Johannes Doerfert via cfe-commits

Author: Johannes Doerfert
Date: 2020-04-01T23:46:27-05:00
New Revision: d1705c1196fedfe927716923ac121f1134924a36

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

LOG: [CUDA][NFC] Split math.h functions out of __clang_cuda_device_functions.h

This is not supported to change anything but allow us to reuse the math
functions separately from the device functions, e.g., source them at
different times. This will be used by the OpenMP overlay.

This also adds two `return` keywords that were missing.

Reviewed By: tra

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

Added: 
clang/lib/Headers/__clang_cuda_math.h

Modified: 
clang/lib/Headers/CMakeLists.txt
clang/lib/Headers/__clang_cuda_device_functions.h
clang/lib/Headers/__clang_cuda_runtime_wrapper.h

Removed: 




diff  --git a/clang/lib/Headers/CMakeLists.txt 
b/clang/lib/Headers/CMakeLists.txt
index 8124549bfc48..5ca6f3cca1bc 100644
--- a/clang/lib/Headers/CMakeLists.txt
+++ b/clang/lib/Headers/CMakeLists.txt
@@ -37,6 +37,7 @@ set(files
   bmi2intrin.h
   bmiintrin.h
   __clang_cuda_builtin_vars.h
+  __clang_cuda_math.h
   __clang_cuda_cmath.h
   __clang_cuda_complex_builtins.h
   __clang_cuda_device_functions.h

diff  --git a/clang/lib/Headers/__clang_cuda_device_functions.h 
b/clang/lib/Headers/__clang_cuda_device_functions.h
index 50ad674f9483..d15f6b61d6ef 100644
--- a/clang/lib/Headers/__clang_cuda_device_functions.h
+++ b/clang/lib/Headers/__clang_cuda_device_functions.h
@@ -26,26 +26,6 @@
 #define __DEVICE__ static __device__ __forceinline__
 #endif
 
-// libdevice provides fast low precision and slow full-recision implementations
-// for some functions. Which one gets selected depends on
-// __CLANG_CUDA_APPROX_TRANSCENDENTALS__ which gets defined by clang if
-// -ffast-math or -fcuda-approx-transcendentals are in effect.
-#pragma push_macro("__FAST_OR_SLOW")
-#if defined(__CLANG_CUDA_APPROX_TRANSCENDENTALS__)
-#define __FAST_OR_SLOW(fast, slow) fast
-#else
-#define __FAST_OR_SLOW(fast, slow) slow
-#endif
-
-// For C++ 17 we need to include noexcept attribute to be compatible
-// with the header-defined version. This may be removed once
-// variant is supported.
-#if defined(_OPENMP) && defined(__cplusplus) && __cplusplus >= 201703L
-#define __NOEXCEPT noexcept
-#else
-#define __NOEXCEPT
-#endif
-
 __DEVICE__ int __all(int __a) { return __nvvm_vote_all(__a); }
 __DEVICE__ int __any(int __a) { return __nvvm_vote_any(__a); }
 __DEVICE__ unsigned int __ballot(int __a) { return __nvvm_vote_ballot(__a); }
@@ -359,10 +339,10 @@ __DEVICE__ int __iAtomicAdd(int *__p, int __v) {
   return __nvvm_atom_add_gen_i(__p, __v);
 }
 __DEVICE__ int __iAtomicAdd_block(int *__p, int __v) {
-  __nvvm_atom_cta_add_gen_i(__p, __v);
+  return __nvvm_atom_cta_add_gen_i(__p, __v);
 }
 __DEVICE__ int __iAtomicAdd_system(int *__p, int __v) {
-  __nvvm_atom_sys_add_gen_i(__p, __v);
+  return __nvvm_atom_sys_add_gen_i(__p, __v);
 }
 __DEVICE__ int __iAtomicAnd(int *__p, int __v) {
   return __nvvm_atom_and_gen_i(__p, __v);
@@ -1483,149 +1463,14 @@ __DEVICE__ unsigned int __vsubus4(unsigned int __a, 
unsigned int __b) {
   return r;
 }
 #endif // CUDA_VERSION >= 9020
-__DEVICE__ int abs(int __a) __NOEXCEPT { return __nv_abs(__a); }
-__DEVICE__ double fabs(double __a) __NOEXCEPT { return __nv_fabs(__a); }
-__DEVICE__ double acos(double __a) { return __nv_acos(__a); }
-__DEVICE__ float acosf(float __a) { return __nv_acosf(__a); }
-__DEVICE__ double acosh(double __a) { return __nv_acosh(__a); }
-__DEVICE__ float acoshf(float __a) { return __nv_acoshf(__a); }
-__DEVICE__ double asin(double __a) { return __nv_asin(__a); }
-__DEVICE__ float asinf(float __a) { return __nv_asinf(__a); }
-__DEVICE__ double asinh(double __a) { return __nv_asinh(__a); }
-__DEVICE__ float asinhf(float __a) { return __nv_asinhf(__a); }
-__DEVICE__ double atan(double __a) { return __nv_atan(__a); }
-__DEVICE__ double atan2(double __a, double __b) { return __nv_atan2(__a, __b); 
}
-__DEVICE__ float atan2f(float __a, float __b) { return __nv_atan2f(__a, __b); }
-__DEVICE__ float atanf(float __a) { return __nv_atanf(__a); }
-__DEVICE__ double atanh(double __a) { return __nv_atanh(__a); }
-__DEVICE__ float atanhf(float __a) { return __nv_atanhf(__a); }
-__DEVICE__ double cbrt(double __a) { return __nv_cbrt(__a); }
-__DEVICE__ float cbrtf(float __a) { return __nv_cbrtf(__a); }
-__DEVICE__ double ceil(double __a) { return __nv_ceil(__a); }
-__DEVICE__ float ceilf(float __a) { return __nv_ceilf(__a); }
+
+// For OpenMP we require the user to include  as we need to know what
+// clock_t is on the system.
 #ifndef _OPENMP
-__DEVICE__ int clock() { return __nvvm_read_ptx_sreg_clock(); }
-__DEVICE__ long long clock64() { return __nvvm_read_ptx_sreg_clock64(); }
-#endif

[PATCH] D77233: [NFC] Refactoring PropertyAttributeKind for ObjCPropertyDecl and ObjCDeclSpec.

2020-04-01 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added inline comments.



Comment at: clang/include/clang/AST/DeclObjCCommon.h:21
+/// Keep this list in sync with LLVM's Dwarf.h ApplePropertyAttributes.
+enum ObjCPropertyAttributeKind {
+  OBJC_PR_noattr = 0x00,

It seems that you are touching all the sites that use this, so perhaps this is 
the time to change this to `enum class` and drop the `OBJC_PR_` prefixes and 
explicitly inherit from `uint16_t`.  This should be named 
`ObjCPropertyAttribute` I think.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77233



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


[PATCH] D76812: [X86] Add Indirect Thunk Support to X86 to mitigate Load Value Injection (LVI) [3/3]

2020-04-01 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D76812



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


[PATCH] D73290: [PowerPC] Add clang -msvr4-struct-return for 32-bit ELF

2020-04-01 Thread Brad Smith via Phabricator via cfe-commits
brad added a comment.

Now that 10 is out, any chance of getting some movement on this to resolve this 
ABI issue with 32-bit PowerPC?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73290



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


[PATCH] D77028: [NFC] Refactor DeferredDiagsEmitter and skip redundant visit

2020-04-01 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 254407.
yaxunl added a comment.

rebase


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

https://reviews.llvm.org/D77028

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/Sema.cpp

Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -1436,48 +1436,24 @@
 }
 
 // Print notes showing how we can reach FD starting from an a priori
-// known-callable function.
-static void emitCallStackNotes(Sema , FunctionDecl *FD) {
+// known-callable function. If \DiagsCount is not null pointer, the number
+// of diagnostics emitted for a function is accumulated.
+static void emitCallStackNotes(Sema , FunctionDecl *FD,
+   llvm::DenseMap,
+  unsigned> *DiagsCount = nullptr) {
   auto FnIt = S.DeviceKnownEmittedFns.find(FD);
   while (FnIt != S.DeviceKnownEmittedFns.end()) {
 DiagnosticBuilder Builder(
 S.Diags.Report(FnIt->second.Loc, diag::note_called_by));
 Builder << FnIt->second.FD;
 Builder.setForceEmit();
+if (DiagsCount)
+  (*DiagsCount)[FnIt->second.FD]++;
 
 FnIt = S.DeviceKnownEmittedFns.find(FnIt->second.FD);
   }
 }
 
-// Emit any deferred diagnostics for FD and erase them from the map in which
-// they're stored.
-void Sema::emitDeferredDiags(FunctionDecl *FD, bool ShowCallStack) {
-  auto It = DeviceDeferredDiags.find(FD);
-  if (It == DeviceDeferredDiags.end())
-return;
-  bool HasWarningOrError = false;
-  bool FirstDiag = true;
-  for (PartialDiagnosticAt  : It->second) {
-const SourceLocation  = PDAt.first;
-const PartialDiagnostic  = PDAt.second;
-HasWarningOrError |= getDiagnostics().getDiagnosticLevel(
- PD.getDiagID(), Loc) >= DiagnosticsEngine::Warning;
-{
-  DiagnosticBuilder Builder(Diags.Report(Loc, PD.getDiagID()));
-  Builder.setForceEmit();
-  PD.Emit(Builder);
-}
-
-// Emit the note on the first diagnostic in case too many diagnostics cause
-// the note not emitted.
-if (FirstDiag && HasWarningOrError && ShowCallStack) {
-  emitCallStackNotes(*this, FD);
-  FirstDiag = false;
-}
-  }
-
-}
-
 namespace {
 /// Helper class that emits deferred diagnostic messages if an entity directly
 /// or indirectly using the function that causes the deferred diagnostic
@@ -1488,6 +1464,10 @@
   typedef UsedDeclVisitor Inherited;
   llvm::SmallSet, 4> Visited;
   llvm::SmallVector, 4> UseStack;
+
+  // Deferred diagnostics triggered by a declaration.
+  llvm::DenseMap, unsigned> DiagsCount;
+
   bool ShouldEmit;
   unsigned InOMPDeviceContext;
 
@@ -1525,6 +1505,7 @@
   }
 
   void checkFunc(SourceLocation Loc, FunctionDecl *FD) {
+auto DiagsCountIt = DiagsCount.find(FD);
 FunctionDecl *Caller = UseStack.empty() ? nullptr : UseStack.back();
 auto IsKnownEmitted = S.getEmissionStatus(FD, /*Final=*/true) ==
   Sema::FunctionEmissionStatus::Emitted;
@@ -1536,10 +1517,15 @@
 // Finalize analysis of OpenMP-specific constructs.
 if (Caller && S.LangOpts.OpenMP && UseStack.size() == 1)
   S.finalizeOpenMPDelayedAnalysis(Caller, FD, Loc);
+else if (DiagsCountIt != DiagsCount.end() && DiagsCountIt->second == 0 &&
+ !InOMPDeviceContext)
+  return;
+if (DiagsCountIt == DiagsCount.end())
+  DiagsCount[FD] = 0;
 if (Caller)
   S.DeviceKnownEmittedFns[FD] = {Caller, Loc};
 if (ShouldEmit || InOMPDeviceContext)
-  S.emitDeferredDiags(FD, Caller);
+  emitDeferredDiags(FD, Caller);
 Visited.insert(FD);
 UseStack.push_back(FD);
 if (auto *S = FD->getBody()) {
@@ -1555,6 +1541,35 @@
 else
   checkVar(cast(D));
   }
+
+  // Emit any deferred diagnostics for FD
+  void emitDeferredDiags(FunctionDecl *FD, bool ShowCallStack) {
+auto It = S.DeviceDeferredDiags.find(FD);
+if (It == S.DeviceDeferredDiags.end())
+  return;
+bool HasWarningOrError = false;
+bool FirstDiag = true;
+for (PartialDiagnosticAt  : It->second) {
+  const SourceLocation  = PDAt.first;
+  const PartialDiagnostic  = PDAt.second;
+  HasWarningOrError |=
+  S.getDiagnostics().getDiagnosticLevel(PD.getDiagID(), Loc) >=
+  DiagnosticsEngine::Warning;
+  {
+DiagnosticBuilder Builder(S.Diags.Report(Loc, PD.getDiagID()));
+Builder.setForceEmit();
+PD.Emit(Builder);
+  }
+
+  DiagsCount[FD]++;
+  // Emit the note on the first diagnostic in case too many diagnostics
+  // cause the note not emitted.
+  if (FirstDiag && HasWarningOrError && ShowCallStack) {
+emitCallStackNotes(S, FD, );
+FirstDiag = false;
+  }
+}
+  }
 };
 } // namespace
 
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h

[PATCH] D77244: sancov/inline-bool-flag feature + tests + docs.

2020-04-01 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

LGTM
would it be possible to split into 3 patches

1. Instrumentation
2. clang flags stuff
3. compiler-rt test

Btw. is this clang formated?




Comment at: llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp:482
+Ctor = CreateInitCallsForSections(M, SanCovModuleCtorBoolFlagName,
+  SanCovBoolFlagInitName, Int8PtrTy,
+  SanCovBoolFlagSectionName);

Int1PtrT?



Comment at: llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp:918
+auto Store = IRB.CreateStore(ConstantInt::get(Int8Ty, 1), FlagPtr);
+Store->setAtomic(AtomicOrdering::Monotonic);
+Store->setAlignment(llvm::MaybeAlign(FunctionBoolArray->getAlign()));

Unordered or even NotAtomic is good enough here


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77244



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


[PATCH] D71129: [ARM][CMSE] Implement CMSE attributes

2020-04-01 Thread Todd Snider via Phabricator via cfe-commits
snidertm added inline comments.



Comment at: clang/lib/CodeGen/CGCall.cpp:1882
+  if (FI.isCmseNSCall())
+FuncAttrs.addAttribute("cmse_nonsecure_call");
+

Just curious … Does the LLVM backend have a way to extract a StringRef 
attribute from a CallInst? I know that you can do that with hasFnAttribute(), 
but I don't see anything for CallInst objects


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71129



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


[PATCH] D76937: Fix infinite recursion in deferred diagnostic emitter

2020-04-01 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5767085c8de9: Fix infinite recursion in deferred diag 
emitter (authored by yaxunl).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76937

Files:
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/test/OpenMP/nvptx_target_exceptions_messages.cpp

Index: clang/test/OpenMP/nvptx_target_exceptions_messages.cpp
===
--- clang/test/OpenMP/nvptx_target_exceptions_messages.cpp
+++ clang/test/OpenMP/nvptx_target_exceptions_messages.cpp
@@ -1,5 +1,10 @@
-// RUN: %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc -fexceptions -fcxx-exceptions
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - -fexceptions -fcxx-exceptions -ferror-limit 100
+// RUN: %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown \
+// RUN:   -verify=host -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc \
+// RUN:   %s -o %t-ppc-host.bc -fexceptions -fcxx-exceptions
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown \
+// RUN:   -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s \
+// RUN:   -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - \
+// RUN:   -fexceptions -fcxx-exceptions -ferror-limit 100
 
 #ifndef HEADER
 #define HEADER
@@ -81,4 +86,17 @@
 int foobar1() { throw 1; }
 int foobar2() { throw 1; } // expected-error {{cannot use 'throw' with exceptions disabled}}
 
+
+int foobar3();
+int (*C)() =  // expected-warning {{declaration is not declared in any declare target region}}
+   // host-warning@-1 {{declaration is not declared in any declare target region}}
+#pragma omp declare target
+int (*D)() = C; // expected-note {{used here}}
+// host-note@-1 {{used here}}
+#pragma omp end declare target
+int foobar3() { throw 1; }
+
+// Check no infinite recursion in deferred diagnostic emitter.
+long E = (long)
+
 #endif // HEADER
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -12257,7 +12257,7 @@
 VDecl->setInitStyle(VarDecl::ListInit);
   }
 
-  if (LangOpts.OpenMP && VDecl->hasGlobalStorage())
+  if (LangOpts.OpenMP && VDecl->isFileVarDecl())
 DeclsToCheckForDeferredDiags.push_back(VDecl);
   CheckCompleteVariableDeclaration(VDecl);
 }
Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -1501,43 +1501,60 @@
   }
 
   void visitUsedDecl(SourceLocation Loc, Decl *D) {
-if (auto *FD = dyn_cast(D)) {
-  FunctionDecl *Caller = UseStack.empty() ? nullptr : UseStack.back();
-  auto IsKnownEmitted = S.getEmissionStatus(FD, /*Final=*/true) ==
-Sema::FunctionEmissionStatus::Emitted;
-  if (!Caller)
-ShouldEmit = IsKnownEmitted;
-  if ((!ShouldEmit && !S.getLangOpts().OpenMP && !Caller) ||
-  S.shouldIgnoreInHostDeviceCheck(FD) || Visited.count(D))
-return;
-  // Finalize analysis of OpenMP-specific constructs.
-  if (Caller && S.LangOpts.OpenMP && UseStack.size() == 1)
-S.finalizeOpenMPDelayedAnalysis(Caller, FD, Loc);
-  if (Caller)
-S.DeviceKnownEmittedFns[FD] = {Caller, Loc};
-  if (ShouldEmit || InOMPDeviceContext)
-S.emitDeferredDiags(FD, Caller);
-  Visited.insert(D);
-  UseStack.push_back(FD);
-  if (auto *S = FD->getBody()) {
-this->Visit(S);
-  }
-  UseStack.pop_back();
-  Visited.erase(D);
-} else if (auto *VD = dyn_cast(D)) {
-  if (auto *Init = VD->getInit()) {
-auto DevTy = OMPDeclareTargetDeclAttr::getDeviceType(VD);
-bool IsDev = DevTy && (*DevTy == OMPDeclareTargetDeclAttr::DT_NoHost ||
-   *DevTy == OMPDeclareTargetDeclAttr::DT_Any);
-if (IsDev)
-  ++InOMPDeviceContext;
-this->Visit(Init);
-if (IsDev)
-  --InOMPDeviceContext;
-  }
-} else
+if (isa(D))
+  return;
+if (auto *FD = dyn_cast(D))
+  checkFunc(Loc, FD);
+else
   Inherited::visitUsedDecl(Loc, D);
   }
+
+  void checkVar(VarDecl *VD) {
+assert(VD->isFileVarDecl() &&
+   "Should only check file-scope variables");
+if (auto *Init = VD->getInit()) {
+  auto DevTy = OMPDeclareTargetDeclAttr::getDeviceType(VD);
+  bool IsDev = DevTy && (*DevTy == OMPDeclareTargetDeclAttr::DT_NoHost ||
+ *DevTy == OMPDeclareTargetDeclAttr::DT_Any);
+  if 

[clang] 5767085 - Fix infinite recursion in deferred diag emitter

2020-04-01 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2020-04-01T22:17:43-04:00
New Revision: 5767085c8de97d15d7fb5433f22bb5b858cc4f3a

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

LOG: Fix infinite recursion in deferred diag emitter

Currently deferred diagnostic emitter checks variable decl in DeclRefExpr, which
causes infinite recursion for cases like long a = (long).

Deferred diagnostic emitter does not need check variable decls in DeclRefExpr
since reference of a variable does not cause emission of functions directly or
indirectly. Therefore there is no need to check variable decls in DeclRefExpr.

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

Added: 


Modified: 
clang/lib/Sema/Sema.cpp
clang/lib/Sema/SemaDecl.cpp
clang/test/OpenMP/nvptx_target_exceptions_messages.cpp

Removed: 




diff  --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index 03475240f6f9..44b5115d9d2f 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -1501,43 +1501,60 @@ class DeferredDiagnosticsEmitter
   }
 
   void visitUsedDecl(SourceLocation Loc, Decl *D) {
-if (auto *FD = dyn_cast(D)) {
-  FunctionDecl *Caller = UseStack.empty() ? nullptr : UseStack.back();
-  auto IsKnownEmitted = S.getEmissionStatus(FD, /*Final=*/true) ==
-Sema::FunctionEmissionStatus::Emitted;
-  if (!Caller)
-ShouldEmit = IsKnownEmitted;
-  if ((!ShouldEmit && !S.getLangOpts().OpenMP && !Caller) ||
-  S.shouldIgnoreInHostDeviceCheck(FD) || Visited.count(D))
-return;
-  // Finalize analysis of OpenMP-specific constructs.
-  if (Caller && S.LangOpts.OpenMP && UseStack.size() == 1)
-S.finalizeOpenMPDelayedAnalysis(Caller, FD, Loc);
-  if (Caller)
-S.DeviceKnownEmittedFns[FD] = {Caller, Loc};
-  if (ShouldEmit || InOMPDeviceContext)
-S.emitDeferredDiags(FD, Caller);
-  Visited.insert(D);
-  UseStack.push_back(FD);
-  if (auto *S = FD->getBody()) {
-this->Visit(S);
-  }
-  UseStack.pop_back();
-  Visited.erase(D);
-} else if (auto *VD = dyn_cast(D)) {
-  if (auto *Init = VD->getInit()) {
-auto DevTy = OMPDeclareTargetDeclAttr::getDeviceType(VD);
-bool IsDev = DevTy && (*DevTy == OMPDeclareTargetDeclAttr::DT_NoHost ||
-   *DevTy == OMPDeclareTargetDeclAttr::DT_Any);
-if (IsDev)
-  ++InOMPDeviceContext;
-this->Visit(Init);
-if (IsDev)
-  --InOMPDeviceContext;
-  }
-} else
+if (isa(D))
+  return;
+if (auto *FD = dyn_cast(D))
+  checkFunc(Loc, FD);
+else
   Inherited::visitUsedDecl(Loc, D);
   }
+
+  void checkVar(VarDecl *VD) {
+assert(VD->isFileVarDecl() &&
+   "Should only check file-scope variables");
+if (auto *Init = VD->getInit()) {
+  auto DevTy = OMPDeclareTargetDeclAttr::getDeviceType(VD);
+  bool IsDev = DevTy && (*DevTy == OMPDeclareTargetDeclAttr::DT_NoHost ||
+ *DevTy == OMPDeclareTargetDeclAttr::DT_Any);
+  if (IsDev)
+++InOMPDeviceContext;
+  this->Visit(Init);
+  if (IsDev)
+--InOMPDeviceContext;
+}
+  }
+
+  void checkFunc(SourceLocation Loc, FunctionDecl *FD) {
+FunctionDecl *Caller = UseStack.empty() ? nullptr : UseStack.back();
+auto IsKnownEmitted = S.getEmissionStatus(FD, /*Final=*/true) ==
+  Sema::FunctionEmissionStatus::Emitted;
+if (!Caller)
+  ShouldEmit = IsKnownEmitted;
+if ((!ShouldEmit && !S.getLangOpts().OpenMP && !Caller) ||
+S.shouldIgnoreInHostDeviceCheck(FD) || Visited.count(FD))
+  return;
+// Finalize analysis of OpenMP-specific constructs.
+if (Caller && S.LangOpts.OpenMP && UseStack.size() == 1)
+  S.finalizeOpenMPDelayedAnalysis(Caller, FD, Loc);
+if (Caller)
+  S.DeviceKnownEmittedFns[FD] = {Caller, Loc};
+if (ShouldEmit || InOMPDeviceContext)
+  S.emitDeferredDiags(FD, Caller);
+Visited.insert(FD);
+UseStack.push_back(FD);
+if (auto *S = FD->getBody()) {
+  this->Visit(S);
+}
+UseStack.pop_back();
+Visited.erase(FD);
+  }
+
+  void checkRecordedDecl(Decl *D) {
+if (auto *FD = dyn_cast(D))
+  checkFunc(SourceLocation(), FD);
+else
+  checkVar(cast(D));
+  }
 };
 } // namespace
 
@@ -1552,7 +1569,7 @@ void Sema::emitDeferredDiags() {
 
   DeferredDiagnosticsEmitter DDE(*this);
   for (auto D : DeclsToCheckForDeferredDiags)
-DDE.visitUsedDecl(SourceLocation(), D);
+DDE.checkRecordedDecl(D);
 }
 
 // In CUDA, there are some constructs which may appear in semantically-valid

diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index ea3a0c22c401..494a1cd1a685 100644
--- 

[PATCH] D76184: [OpenMP][NFC] Remove the need to include `OpenMPClause.h`

2020-04-01 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.
Herald added a subscriber: yaxunl.

@rnk What is the plan for this one now? Should I abandon it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76184



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


[PATCH] D75591: [OpenMP] Add firstprivate as a default data-sharing attribute to clang

2020-04-01 Thread Atmn Patel via Phabricator via cfe-commits
atmnpatel updated this revision to Diff 254392.
atmnpatel added a comment.

Rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75591

Files:
  clang-tools-extra/docs/clang-tidy/checks/openmp-use-default-none.rst
  clang-tools-extra/test/clang-tidy/checkers/openmp-use-default-none.cpp
  clang/docs/LibASTMatchersReference.html
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/ASTMatchers/Dynamic/Registry.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/distribute_parallel_for_default_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_default_messages.cpp
  clang/test/OpenMP/driver.c
  clang/test/OpenMP/parallel_default_messages.cpp
  clang/test/OpenMP/parallel_for_default_messages.cpp
  clang/test/OpenMP/parallel_for_simd_default_messages.cpp
  clang/test/OpenMP/parallel_master_codegen.cpp
  clang/test/OpenMP/parallel_master_default_messages.cpp
  clang/test/OpenMP/parallel_sections_default_messages.cpp
  clang/test/OpenMP/target_parallel_default_messages.cpp
  clang/test/OpenMP/target_parallel_for_default_messages.cpp
  clang/test/OpenMP/target_parallel_for_simd_default_messages.cpp
  clang/test/OpenMP/target_teams_default_messages.cpp
  clang/test/OpenMP/target_teams_distribute_default_messages.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_default_messages.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_default_messages.cpp
  clang/test/OpenMP/task_default_messages.cpp
  clang/test/OpenMP/task_messages.cpp
  clang/test/OpenMP/teams_default_messages.cpp
  clang/test/OpenMP/teams_distribute_default_messages.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_default_messages.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_simd_default_messages.cpp
  clang/test/OpenMP/teams_distribute_simd_default_messages.cpp
  clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersTest.h
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def

Index: llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
===
--- llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
+++ llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
@@ -430,6 +430,7 @@
 
 __OMP_DEFAULT_KIND(none)
 __OMP_DEFAULT_KIND(shared)
+__OMP_DEFAULT_KIND(firstprivate)
 __OMP_DEFAULT_KIND(unknown)
 
 #undef __OMP_DEFAULT_KIND
Index: clang/unittests/ASTMatchers/ASTMatchersTest.h
===
--- clang/unittests/ASTMatchers/ASTMatchersTest.h
+++ clang/unittests/ASTMatchers/ASTMatchersTest.h
@@ -314,6 +314,20 @@
   return matchesConditionally(Code, AMatcher, false, "-fopenmp=libomp");
 }
 
+template 
+testing::AssertionResult matchesWithOpenMP51(const std::string ,
+ const T ) {
+  return matchesConditionally(Code, AMatcher, true,
+  {"-fopenmp=libomp", "-fopenmp-version=51"});
+}
+
+template 
+testing::AssertionResult notMatchesWithOpenMP51(const std::string ,
+const T ) {
+  return matchesConditionally(Code, AMatcher, false,
+  {"-fopenmp=libomp", "-fopenmp-version=51"});
+}
+
 template 
 testing::AssertionResult
 matchAndVerifyResultConditionally(const std::string , const T ,
Index: clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -1843,11 +1843,18 @@
   EXPECT_TRUE(matchesWithOpenMP(Source3, Matcher));
 
   const std::string Source4 = R"(
+void x() {
+#pragma omp parallel default(firstprivate)
+;
+})";
+  EXPECT_TRUE(matchesWithOpenMP51(Source4, Matcher));
+
+  const std::string Source5 = R"(
 void x(int x) {
 #pragma omp parallel num_threads(x)
 ;
 })";
-  EXPECT_TRUE(notMatchesWithOpenMP(Source4, Matcher));
+  EXPECT_TRUE(notMatchesWithOpenMP(Source5, Matcher));
 }
 
 TEST(MatchFinderAPI, matchesDynamic) {
Index: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -2805,11 +2805,18 @@
   EXPECT_TRUE(matchesWithOpenMP(Source3, Matcher));
 
   const std::string Source4 = R"(
+void x() {
+#pragma omp parallel default(firstprivate)
+;
+})";
+  EXPECT_TRUE(matchesWithOpenMP51(Source4, Matcher));
+
+  const std::string Source5 = R"(
 void x(int x) {
 #pragma omp parallel num_threads(x)
 ;
 })";
-  EXPECT_TRUE(matchesWithOpenMP(Source4, Matcher));
+  EXPECT_TRUE(matchesWithOpenMP(Source5, Matcher));
 }
 
 

[PATCH] D74935: [LangRef][AliasAnalysis] Clarify `noalias` affects only modified objects

2020-04-01 Thread Johannes Doerfert via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6cd673345cfa: [LangRef][AliasAnalysis] Clarify `noalias` 
affects only modified objects (authored by jdoerfert).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74935

Files:
  llvm/docs/LangRef.rst


Index: llvm/docs/LangRef.rst
===
--- llvm/docs/LangRef.rst
+++ llvm/docs/LangRef.rst
@@ -1107,14 +1107,16 @@
 .. _noalias:
 
 ``noalias``
-This indicates that objects accessed via pointer values
+This indicates that memory locations accessed via pointer values
 :ref:`based ` on the argument or return value are not also
 accessed, during the execution of the function, via pointer values not
-*based* on the argument or return value. The attribute on a return value
-also has additional semantics described below. The caller shares the
-responsibility with the callee for ensuring that these requirements are 
met.
-For further details, please see the discussion of the NoAlias response in
-:ref:`alias analysis `.
+*based* on the argument or return value. This guarantee only holds for
+memory locations that are *modified*, by any means, during the execution of
+the function. The attribute on a return value also has additional semantics
+described below. The caller shares the responsibility with the callee for
+ensuring that these requirements are met.  For further details, please see
+the discussion of the NoAlias response in :ref:`alias analysis `.
 
 Note that this definition of ``noalias`` is intentionally similar
 to the definition of ``restrict`` in C99 for function arguments.


Index: llvm/docs/LangRef.rst
===
--- llvm/docs/LangRef.rst
+++ llvm/docs/LangRef.rst
@@ -1107,14 +1107,16 @@
 .. _noalias:
 
 ``noalias``
-This indicates that objects accessed via pointer values
+This indicates that memory locations accessed via pointer values
 :ref:`based ` on the argument or return value are not also
 accessed, during the execution of the function, via pointer values not
-*based* on the argument or return value. The attribute on a return value
-also has additional semantics described below. The caller shares the
-responsibility with the callee for ensuring that these requirements are met.
-For further details, please see the discussion of the NoAlias response in
-:ref:`alias analysis `.
+*based* on the argument or return value. This guarantee only holds for
+memory locations that are *modified*, by any means, during the execution of
+the function. The attribute on a return value also has additional semantics
+described below. The caller shares the responsibility with the callee for
+ensuring that these requirements are met.  For further details, please see
+the discussion of the NoAlias response in :ref:`alias analysis `.
 
 Note that this definition of ``noalias`` is intentionally similar
 to the definition of ``restrict`` in C99 for function arguments.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75951: Keep a list of already-included pragma-once files for mods.

2020-04-01 Thread Vy Nguyen via Phabricator via cfe-commits
oontvoo updated this revision to Diff 254384.
oontvoo added a comment.

Update docs.

Note: The failure looks spurious ... They seemed to pass locally for me:
One eg:

[hi on] vyng@vyng:~/repo/llvm-project$ ./build/bin/llvm-lit -v 
./clang/test/ClangScanDeps/modules-full.cpp
llvm-lit: 
/usr/local/google/home/vyng/repo/llvm-project/llvm/utils/lit/lit/llvm/config.py:342:
 note: using clang: 
/usr/local/google/home/vyng/repo/llvm-project/build/bin/clang

- Testing: 1 tests, 1 workers --

PASS: Clang :: ClangScanDeps/modules-full.cpp (1 of 1)

Testing Time: 2.75s

  Expected Passes: 1


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75951

Files:
  clang/include/clang/Lex/HeaderSearch.h
  clang/include/clang/Lex/Preprocessor.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/include/clang/Serialization/ASTReader.h
  clang/include/clang/Serialization/ASTWriter.h
  clang/lib/Lex/HeaderSearch.cpp
  clang/lib/Lex/PPDirectives.cpp
  clang/lib/Lex/PPLexerChange.cpp
  clang/lib/Lex/Preprocessor.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/Modules/Inputs/dummy_pragma_once.h
  clang/test/Modules/Inputs/dummy_textual_header.h
  clang/test/Modules/Inputs/header_in_imported_module.h
  clang/test/Modules/Inputs/imported_module.cppm
  clang/test/Modules/Inputs/module.map
  clang/test/Modules/header-in-imported-module.c
  clang/test/Modules/import-pragma-once.c

Index: clang/test/Modules/import-pragma-once.c
===
--- /dev/null
+++ clang/test/Modules/import-pragma-once.c
@@ -0,0 +1,8 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fimplicit-module-maps -I%S/Inputs -verify -x c %s
+// expected-no-diagnostics
+#include "dummy_pragma_once.h"
+#include "dummy_textual_header.h"
+
+void *p = 
+void *q = 
Index: clang/test/Modules/header-in-imported-module.c
===
--- /dev/null
+++ clang/test/Modules/header-in-imported-module.c
@@ -0,0 +1,15 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: %clang -x c++ -fmodules  -fmodules-ts --precompile -o %t/ModuleB39206.pcm %S/Inputs/imported_module.cppm
+// RUN: %clang -x c++ -fmodules   -fmodules-ts -c %t/ModuleB39206.pcm -o %t/ModuleB39206.o
+// RUN: %clang -x c++ -fmodules  -fmodules-ts -I%S/Inputs  -fmodule-file=%t/ModuleB39206.pcm   -c %s
+// expected-no-diagnostics
+
+// Bug 39206
+
+#include "header_in_imported_module.h"
+module ModuleB39206;
+
+#ifndef ALL_GOOD
+#error "missing macro in impl"
+#endif
Index: clang/test/Modules/Inputs/module.map
===
--- clang/test/Modules/Inputs/module.map
+++ clang/test/Modules/Inputs/module.map
@@ -282,6 +282,11 @@
   header "dummy.h"
 }
 
+module dummy_pragma_once {
+  header "dummy_pragma_once.h"
+  textual header "dummy_textual_header.h"
+}
+
 module builtin {
   header "builtin.h"
   explicit module sub {
Index: clang/test/Modules/Inputs/imported_module.cppm
===
--- /dev/null
+++ clang/test/Modules/Inputs/imported_module.cppm
@@ -0,0 +1,6 @@
+export module ModuleB39206;
+#include "header_in_imported_module.h"
+
+#ifndef ALL_GOOD
+#error "Missing macro in module decl"
+#endif
\ No newline at end of file
Index: clang/test/Modules/Inputs/header_in_imported_module.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/header_in_imported_module.h
@@ -0,0 +1,3 @@
+#pragma once
+
+#define ALL_GOOD
Index: clang/test/Modules/Inputs/dummy_textual_header.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/dummy_textual_header.h
@@ -0,0 +1,2 @@
+#pragma once
+int y = 6;
Index: clang/test/Modules/Inputs/dummy_pragma_once.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/dummy_pragma_once.h
@@ -0,0 +1,3 @@
+#include "dummy_textual_header.h"
+
+int x = 5;
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -1621,7 +1621,7 @@
   endian::Writer LE(Out, little);
   unsigned KeyLen = key.Filename.size() + 1 + 8 + 8;
   LE.write(KeyLen);
-  unsigned DataLen = 1 + 2 + 4 + 4;
+  unsigned DataLen = 1 + 2 + 4 + 4 + 4;
   for (auto ModInfo : Data.KnownHeaders)
 if (Writer.getLocalOrImportedSubmoduleID(ModInfo.getModule()))
   DataLen += 4;
@@ -1678,6 +1678,9 @@
   }
   LE.write(Offset);
 
+  // Write this file UID.
+  LE.write(Data.HFI.UID);
+
   auto EmitModule = [&](Module *M, ModuleMap::ModuleHeaderRole Role) {
 if (uint32_t ModID = 

[PATCH] D75561: Remove const qualifier from Modules returned by ExternalASTSource. (NFC)

2020-04-01 Thread Adrian Prantl via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf4754ea0ed7d: Remove const qualifier from Modules returned 
by ExternalASTSource. (NFC) (authored by aprantl).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75561

Files:
  clang/include/clang/Basic/Module.h
  clang/lib/Basic/Module.cpp
  clang/lib/Serialization/ASTReader.cpp


Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -8514,7 +8514,7 @@
 
 llvm::Optional
 ASTReader::getSourceDescriptor(unsigned ID) {
-  if (const Module *M = getSubmodule(ID))
+  if (Module *M = getSubmodule(ID))
 return ASTSourceDescriptor(*M);
 
   // If there is only a single PCH, return it instead.
Index: clang/lib/Basic/Module.cpp
===
--- clang/lib/Basic/Module.cpp
+++ clang/lib/Basic/Module.cpp
@@ -659,7 +659,7 @@
   VisitModule({M, nullptr});
 }
 
-ASTSourceDescriptor::ASTSourceDescriptor(const Module )
+ASTSourceDescriptor::ASTSourceDescriptor(Module )
 : Signature(M.Signature), ClangModule() {
   if (M.Directory)
 Path = M.Directory->getName();
Index: clang/include/clang/Basic/Module.h
===
--- clang/include/clang/Basic/Module.h
+++ clang/include/clang/Basic/Module.h
@@ -662,7 +662,7 @@
   StringRef Path;
   StringRef ASTFile;
   ASTFileSignature Signature;
-  const Module *ClangModule = nullptr;
+  Module *ClangModule = nullptr;
 
 public:
   ASTSourceDescriptor() = default;
@@ -670,13 +670,13 @@
   ASTFileSignature Signature)
   : PCHModuleName(std::move(Name)), Path(std::move(Path)),
 ASTFile(std::move(ASTFile)), Signature(Signature) {}
-  ASTSourceDescriptor(const Module );
+  ASTSourceDescriptor(Module );
 
   std::string getModuleName() const;
   StringRef getPath() const { return Path; }
   StringRef getASTFile() const { return ASTFile; }
   ASTFileSignature getSignature() const { return Signature; }
-  const Module *getModuleOrNull() const { return ClangModule; }
+  Module *getModuleOrNull() const { return ClangModule; }
 };
 
 


Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -8514,7 +8514,7 @@
 
 llvm::Optional
 ASTReader::getSourceDescriptor(unsigned ID) {
-  if (const Module *M = getSubmodule(ID))
+  if (Module *M = getSubmodule(ID))
 return ASTSourceDescriptor(*M);
 
   // If there is only a single PCH, return it instead.
Index: clang/lib/Basic/Module.cpp
===
--- clang/lib/Basic/Module.cpp
+++ clang/lib/Basic/Module.cpp
@@ -659,7 +659,7 @@
   VisitModule({M, nullptr});
 }
 
-ASTSourceDescriptor::ASTSourceDescriptor(const Module )
+ASTSourceDescriptor::ASTSourceDescriptor(Module )
 : Signature(M.Signature), ClangModule() {
   if (M.Directory)
 Path = M.Directory->getName();
Index: clang/include/clang/Basic/Module.h
===
--- clang/include/clang/Basic/Module.h
+++ clang/include/clang/Basic/Module.h
@@ -662,7 +662,7 @@
   StringRef Path;
   StringRef ASTFile;
   ASTFileSignature Signature;
-  const Module *ClangModule = nullptr;
+  Module *ClangModule = nullptr;
 
 public:
   ASTSourceDescriptor() = default;
@@ -670,13 +670,13 @@
   ASTFileSignature Signature)
   : PCHModuleName(std::move(Name)), Path(std::move(Path)),
 ASTFile(std::move(ASTFile)), Signature(Signature) {}
-  ASTSourceDescriptor(const Module );
+  ASTSourceDescriptor(Module );
 
   std::string getModuleName() const;
   StringRef getPath() const { return Path; }
   StringRef getASTFile() const { return ASTFile; }
   ASTFileSignature getSignature() const { return Signature; }
-  const Module *getModuleOrNull() const { return ClangModule; }
+  Module *getModuleOrNull() const { return ClangModule; }
 };
 
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D77282: [AST] Fix formatting whitespace-only comments

2020-04-01 Thread Ryan Gonzalez via Phabricator via cfe-commits
refi64 added a comment.

(I manually ran clang-format-diff afterwards, there were no suggested changes.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77282



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


[PATCH] D77282: [AST] Fix formatting whitespace-only comments

2020-04-01 Thread Ryan Gonzalez via Phabricator via cfe-commits
refi64 created this revision.
Herald added subscribers: cfe-commits, usaxena95, kadircet, ilya-biryukov.
Herald added a project: clang.
refi64 added a reviewer: ilya-biryukov.
refi64 added a comment.

(I manually ran clang-format-diff afterwards, there were no suggested changes.)


If a string consisted only of whitespace, the emptiness check in
getFormattedText would fail, but DropTrailingNewLines would then
call Str.back() on an empty string. In practice, this can easily
crash clangd if an editor asks for a declaration comment that is
whitespace-only.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77282

Files:
  clang/lib/AST/RawCommentList.cpp
  clang/unittests/AST/CommentTextTest.cpp


Index: clang/unittests/AST/CommentTextTest.cpp
===
--- clang/unittests/AST/CommentTextTest.cpp
+++ clang/unittests/AST/CommentTextTest.cpp
@@ -124,4 +124,10 @@
   // clang-format on
 }
 
+TEST_F(CommentTextTest, WorksWithEmptyBlockComments) {
+  auto ExpectedOutput = "";
+  auto Formatted = formatComment(R"(/* */)");
+  EXPECT_EQ(ExpectedOutput, Formatted);
+}
+
 } // namespace clang
Index: clang/lib/AST/RawCommentList.cpp
===
--- clang/lib/AST/RawCommentList.cpp
+++ clang/lib/AST/RawCommentList.cpp
@@ -431,7 +431,7 @@
   };
 
   auto DropTrailingNewLines = [](std::string ) {
-while (Str.back() == '\n')
+while (!Str.empty() && Str.back() == '\n')
   Str.pop_back();
   };
 


Index: clang/unittests/AST/CommentTextTest.cpp
===
--- clang/unittests/AST/CommentTextTest.cpp
+++ clang/unittests/AST/CommentTextTest.cpp
@@ -124,4 +124,10 @@
   // clang-format on
 }
 
+TEST_F(CommentTextTest, WorksWithEmptyBlockComments) {
+  auto ExpectedOutput = "";
+  auto Formatted = formatComment(R"(/* */)");
+  EXPECT_EQ(ExpectedOutput, Formatted);
+}
+
 } // namespace clang
Index: clang/lib/AST/RawCommentList.cpp
===
--- clang/lib/AST/RawCommentList.cpp
+++ clang/lib/AST/RawCommentList.cpp
@@ -431,7 +431,7 @@
   };
 
   auto DropTrailingNewLines = [](std::string ) {
-while (Str.back() == '\n')
+while (!Str.empty() && Str.back() == '\n')
   Str.pop_back();
   };
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75591: [OpenMP] Add firstprivate as a default data-sharing attribute to clang

2020-04-01 Thread Atmn Patel via Phabricator via cfe-commits
atmnpatel updated this revision to Diff 254379.
atmnpatel added a comment.
Herald added a subscriber: yaxunl.

Fixes to tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75591

Files:
  clang-tools-extra/docs/clang-tidy/checks/openmp-use-default-none.rst
  clang-tools-extra/test/clang-tidy/checkers/openmp-use-default-none.cpp
  clang/docs/LibASTMatchersReference.html
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/ASTMatchers/Dynamic/Registry.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/distribute_parallel_for_default_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_default_messages.cpp
  clang/test/OpenMP/driver.c
  clang/test/OpenMP/parallel_default_messages.cpp
  clang/test/OpenMP/parallel_for_default_messages.cpp
  clang/test/OpenMP/parallel_for_simd_default_messages.cpp
  clang/test/OpenMP/parallel_master_codegen.cpp
  clang/test/OpenMP/parallel_master_default_messages.cpp
  clang/test/OpenMP/parallel_sections_default_messages.cpp
  clang/test/OpenMP/target_parallel_default_messages.cpp
  clang/test/OpenMP/target_parallel_for_default_messages.cpp
  clang/test/OpenMP/target_parallel_for_simd_default_messages.cpp
  clang/test/OpenMP/target_teams_default_messages.cpp
  clang/test/OpenMP/target_teams_distribute_default_messages.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_default_messages.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_default_messages.cpp
  clang/test/OpenMP/task_default_messages.cpp
  clang/test/OpenMP/task_messages.cpp
  clang/test/OpenMP/teams_default_messages.cpp
  clang/test/OpenMP/teams_distribute_default_messages.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_default_messages.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_simd_default_messages.cpp
  clang/test/OpenMP/teams_distribute_simd_default_messages.cpp
  clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersTest.h
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def

Index: llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
===
--- llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
+++ llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
@@ -430,6 +430,7 @@
 
 __OMP_DEFAULT_KIND(none)
 __OMP_DEFAULT_KIND(shared)
+__OMP_DEFAULT_KIND(firstprivate)
 __OMP_DEFAULT_KIND(unknown)
 
 #undef __OMP_DEFAULT_KIND
Index: clang/unittests/ASTMatchers/ASTMatchersTest.h
===
--- clang/unittests/ASTMatchers/ASTMatchersTest.h
+++ clang/unittests/ASTMatchers/ASTMatchersTest.h
@@ -314,6 +314,20 @@
   return matchesConditionally(Code, AMatcher, false, "-fopenmp=libomp");
 }
 
+template 
+testing::AssertionResult matchesWithOpenMP51(const std::string ,
+ const T ) {
+  return matchesConditionally(Code, AMatcher, true,
+  {"-fopenmp=libomp", "-fopenmp-version=51"});
+}
+
+template 
+testing::AssertionResult notMatchesWithOpenMP51(const std::string ,
+const T ) {
+  return matchesConditionally(Code, AMatcher, false,
+  {"-fopenmp=libomp", "-fopenmp-version=51"});
+}
+
 template 
 testing::AssertionResult
 matchAndVerifyResultConditionally(const std::string , const T ,
Index: clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -1843,11 +1843,18 @@
   EXPECT_TRUE(matchesWithOpenMP(Source3, Matcher));
 
   const std::string Source4 = R"(
+void x() {
+#pragma omp parallel default(firstprivate)
+;
+})";
+  EXPECT_TRUE(matchesWithOpenMP51(Source4, Matcher));
+
+  const std::string Source5 = R"(
 void x(int x) {
 #pragma omp parallel num_threads(x)
 ;
 })";
-  EXPECT_TRUE(notMatchesWithOpenMP(Source4, Matcher));
+  EXPECT_TRUE(notMatchesWithOpenMP(Source5, Matcher));
 }
 
 TEST(MatchFinderAPI, matchesDynamic) {
Index: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -2805,11 +2805,18 @@
   EXPECT_TRUE(matchesWithOpenMP(Source3, Matcher));
 
   const std::string Source4 = R"(
+void x() {
+#pragma omp parallel default(firstprivate)
+;
+})";
+  EXPECT_TRUE(matchesWithOpenMP51(Source4, Matcher));
+
+  const std::string Source5 = R"(
 void x(int x) {
 #pragma omp parallel num_threads(x)
 ;
 })";
-  EXPECT_TRUE(matchesWithOpenMP(Source4, Matcher));
+  

[PATCH] D72893: [NewPassManager] Add assertions when getting statefull cached analysis.

2020-04-01 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea updated this revision to Diff 254378.
asbirlea added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Update clang test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72893

Files:
  clang/test/CodeGen/thinlto-distributed-newpm.ll
  llvm/include/llvm/Analysis/AliasAnalysis.h
  llvm/include/llvm/Analysis/CGSCCPassManager.h
  llvm/include/llvm/IR/PassManager.h
  llvm/include/llvm/Transforms/Utils/CallGraphUpdater.h
  llvm/lib/Analysis/CGSCCPassManager.cpp
  llvm/lib/Transforms/Coroutines/CoroSplit.cpp
  llvm/lib/Transforms/IPO/Inliner.cpp
  llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp
  llvm/lib/Transforms/Scalar/ConstantHoisting.cpp
  llvm/lib/Transforms/Scalar/LoopLoadElimination.cpp
  llvm/lib/Transforms/Scalar/LoopUnrollPass.cpp
  llvm/lib/Transforms/Utils/CallGraphUpdater.cpp
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
  llvm/unittests/Analysis/CGSCCPassManagerTest.cpp
  llvm/unittests/IR/PassManagerTest.cpp
  llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp

Index: llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
===
--- llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
+++ llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp
@@ -779,9 +779,11 @@
   .WillByDefault(Invoke([&](Loop , LoopAnalysisManager ,
 LoopStandardAnalysisResults ) {
 auto  = AM.getResult(L, AR);
-auto  = FAMP.getManager();
 Function  = *L.getHeader()->getParent();
-if (FAM.getCachedResult(F))
+// This call will assert when trying to get the actual analysis if the
+// FunctionAnalysis can be invalidated. Only check its existence.
+// Alternatively, use FAM above, for the purposes of this unittest.
+if (FAMP.cachedResultExists(F))
   FAMP.registerOuterAnalysisInvalidation();
 return MLAHandle.getResult();
Index: llvm/unittests/IR/PassManagerTest.cpp
===
--- llvm/unittests/IR/PassManagerTest.cpp
+++ llvm/unittests/IR/PassManagerTest.cpp
@@ -107,20 +107,23 @@
 
 struct TestFunctionPass : PassInfoMixin {
   TestFunctionPass(int , int ,
-   int ,
+   int , ModuleAnalysisManager ,
bool OnlyUseCachedResults = false)
   : RunCount(RunCount), AnalyzedInstrCount(AnalyzedInstrCount),
-AnalyzedFunctionCount(AnalyzedFunctionCount),
+AnalyzedFunctionCount(AnalyzedFunctionCount), MAM(MAM),
 OnlyUseCachedResults(OnlyUseCachedResults) {}
 
   PreservedAnalyses run(Function , FunctionAnalysisManager ) {
 ++RunCount;
 
-const ModuleAnalysisManager  =
-AM.getResult(F).getManager();
+// Getting a cached result that isn't stateless through the proxy will
+// trigger an assert:
+// auto  = AM.getResult(F);
+// Use MAM, for the purposes of this unittest.
 if (TestModuleAnalysis::Result *TMA =
-MAM.getCachedResult(*F.getParent()))
+MAM.getCachedResult(*F.getParent())) {
   AnalyzedFunctionCount += TMA->FunctionCount;
+}
 
 if (OnlyUseCachedResults) {
   // Hack to force the use of the cached interface.
@@ -139,6 +142,7 @@
   int 
   int 
   int 
+  ModuleAnalysisManager 
   bool OnlyUseCachedResults;
 };
 
@@ -436,8 +440,9 @@
 {
   // Pointless scope to test move assignment.
   FunctionPassManager NestedFPM(/*DebugLogging*/ true);
-  NestedFPM.addPass(TestFunctionPass(
-  FunctionPassRunCount1, AnalyzedInstrCount1, AnalyzedFunctionCount1));
+  NestedFPM.addPass(TestFunctionPass(FunctionPassRunCount1,
+ AnalyzedInstrCount1,
+ AnalyzedFunctionCount1, MAM));
   FPM = std::move(NestedFPM);
 }
 NestedMPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
@@ -455,7 +460,7 @@
   {
 FunctionPassManager FPM(/*DebugLogging*/ true);
 FPM.addPass(TestFunctionPass(FunctionPassRunCount2, AnalyzedInstrCount2,
- AnalyzedFunctionCount2));
+ AnalyzedFunctionCount2, MAM));
 MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
   }
 
@@ -468,7 +473,7 @@
   {
 FunctionPassManager FPM(/*DebugLogging*/ true);
 FPM.addPass(TestFunctionPass(FunctionPassRunCount3, AnalyzedInstrCount3,
- AnalyzedFunctionCount3));
+ AnalyzedFunctionCount3, MAM));
 FPM.addPass(TestInvalidationFunctionPass("f"));
 MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
   }
@@ -482,7 +487,7 @@
   {
 

[PATCH] D76818: [clang-tidy] Add check llvmlibc-implementation-in-namespace.

2020-04-01 Thread Paula Toth via Phabricator via cfe-commits
PaulkaToast updated this revision to Diff 254376.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76818

Files:
  clang-tools-extra/clang-tidy/llvmlibc/CMakeLists.txt
  clang-tools-extra/clang-tidy/llvmlibc/ImplementationInNamespaceCheck.cpp
  clang-tools-extra/clang-tidy/llvmlibc/ImplementationInNamespaceCheck.h
  clang-tools-extra/clang-tidy/llvmlibc/LLVMLibcTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/docs/clang-tidy/checks/llvmlibc-implementation-in-namespace.rst
  
clang-tools-extra/test/clang-tidy/checkers/llvmlibc-implementation-in-namespace.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/llvmlibc-implementation-in-namespace.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/llvmlibc-implementation-in-namespace.cpp
@@ -0,0 +1,40 @@
+// RUN: %check_clang_tidy %s llvmlibc-implementation-in-namespace %t
+
+#define MACRO_A "defining macros outside namespace is valid"
+
+class ClassB;
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: Please wrap implentation in '__llvm_libc' namespace.
+struct StructC {};
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: Please wrap implentation in '__llvm_libc' namespace.
+char *VarD = MACRO_A;
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: Please wrap implentation in '__llvm_libc' namespace.
+typedef int typeE;
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: Please wrap implentation in '__llvm_libc' namespace.
+void funcF() {}
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: Please wrap implentation in '__llvm_libc' namespace.
+
+namespace namespaceG {
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: '__llvm_libc' needs to be the outermost namespace.
+namespace __llvm_libc{
+namespace namespaceH {
+class ClassB;
+} // namespace namespaceH
+struct StructC {};
+} // namespace __llvm_libc
+char *VarD = MACRO_A;
+typedef int typeE;
+void funcF() {}
+} // namespace namespaceG
+
+// Wrapped in correct namespace.
+namespace __llvm_libc {
+// Namespaces within __llvim_libc namespace allowed.
+namespace namespaceI {
+class ClassB;
+} // namespace namespaceI
+struct StructC {};
+char *VarD = MACRO_A;
+typedef int typeE;
+void funcF() {}
+extern "C" void extern_funcJ() {}
+} // namespace __llvm_libc
Index: clang-tools-extra/docs/clang-tidy/checks/llvmlibc-implementation-in-namespace.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/llvmlibc-implementation-in-namespace.rst
@@ -0,0 +1,35 @@
+.. title:: clang-tidy - llvmlibc-implementation-in-namespace
+
+llvmlibc-implementation-in-namespace
+
+
+Checks all llvm-libc implementation is within the correct namespace.
+
+.. code-block:: c++
+
+// Correct: implementation inside the correct namespace.
+namespace __llvm_libc {
+void LLVM_LIBC_ENTRYPOINT(strcpy)(char *dest, const char *src) {}
+// Namespaces within __llvm_libc namespace are allowed.
+namespace inner{
+int localVar = 0;
+}
+// Functions with C linkage are allowed.
+extern "C" void str_fuzz(){}
+}
+
+// Incorrect: implementation not in a namespace.
+void LLVM_LIBC_ENTRYPOINT(strcpy)(char *dest, const char *src) {}
+
+// Incorrect: outer most namespace is not correct.
+namespace something_else {
+void LLVM_LIBC_ENTRYPOINT(strcpy)(char *dest, const char *src) {}
+}
+
+Options
+---
+
+.. option:: RequiredNamespace
+
+The namespace that llvm-libc implementations must be wrapped in. The default
+is `__llvm_libc`.
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -188,6 +188,7 @@
`llvm-prefer-isa-or-dyn-cast-in-conditionals `_, "Yes"
`llvm-prefer-register-over-unsigned `_, "Yes"
`llvm-twine-local `_, "Yes"
+   `llvmlibc-implementation-in-namespace `_,
`llvmlibc-restrict-system-libc-headers `_, "Yes"
`misc-definitions-in-headers `_, "Yes"
`misc-misplaced-const `_,
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -113,6 +113,11 @@
   Flags use of the `C` standard library functions ``memset``, ``memcpy`` and
   ``memcmp`` and similar derivatives on non-trivial types.
 
+- New :doc:`llvmlibc-implementation-in-namespace
+  ` check.
+
+  Checks all llvm-libc implementation is within the correct namespace.
+
 - New :doc:`llvmlibc-restrict-system-libc-headers
   ` check.
 
Index: clang-tools-extra/clang-tidy/llvmlibc/LLVMLibcTidyModule.cpp

[clang] f4754ea - Remove const qualifier from Modules returned by ExternalASTSource. (NFC)

2020-04-01 Thread Adrian Prantl via cfe-commits

Author: Adrian Prantl
Date: 2020-04-01T17:46:02-07:00
New Revision: f4754ea0ed7ddc35042bacbc47d661bfe660f132

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

LOG: Remove const qualifier from Modules returned by ExternalASTSource. (NFC)

This API is used by LLDB to attach owning module information to
Declarations deserialized from DWARF.

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

Added: 


Modified: 
clang/include/clang/Basic/Module.h
clang/lib/Basic/Module.cpp
clang/lib/Serialization/ASTReader.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/Module.h 
b/clang/include/clang/Basic/Module.h
index 9c2bc155cd4f..c47eb4587a57 100644
--- a/clang/include/clang/Basic/Module.h
+++ b/clang/include/clang/Basic/Module.h
@@ -662,7 +662,7 @@ class ASTSourceDescriptor {
   StringRef Path;
   StringRef ASTFile;
   ASTFileSignature Signature;
-  const Module *ClangModule = nullptr;
+  Module *ClangModule = nullptr;
 
 public:
   ASTSourceDescriptor() = default;
@@ -670,13 +670,13 @@ class ASTSourceDescriptor {
   ASTFileSignature Signature)
   : PCHModuleName(std::move(Name)), Path(std::move(Path)),
 ASTFile(std::move(ASTFile)), Signature(Signature) {}
-  ASTSourceDescriptor(const Module );
+  ASTSourceDescriptor(Module );
 
   std::string getModuleName() const;
   StringRef getPath() const { return Path; }
   StringRef getASTFile() const { return ASTFile; }
   ASTFileSignature getSignature() const { return Signature; }
-  const Module *getModuleOrNull() const { return ClangModule; }
+  Module *getModuleOrNull() const { return ClangModule; }
 };
 
 

diff  --git a/clang/lib/Basic/Module.cpp b/clang/lib/Basic/Module.cpp
index dd8f11101107..5fd7d304f8f4 100644
--- a/clang/lib/Basic/Module.cpp
+++ b/clang/lib/Basic/Module.cpp
@@ -659,7 +659,7 @@ void VisibleModuleSet::setVisible(Module *M, SourceLocation 
Loc,
   VisitModule({M, nullptr});
 }
 
-ASTSourceDescriptor::ASTSourceDescriptor(const Module )
+ASTSourceDescriptor::ASTSourceDescriptor(Module )
 : Signature(M.Signature), ClangModule() {
   if (M.Directory)
 Path = M.Directory->getName();

diff  --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index 7437f649a090..bea9bdd22bab 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -8514,7 +8514,7 @@ unsigned ASTReader::getModuleFileID(ModuleFile *F) {
 
 llvm::Optional
 ASTReader::getSourceDescriptor(unsigned ID) {
-  if (const Module *M = getSubmodule(ID))
+  if (Module *M = getSubmodule(ID))
 return ASTSourceDescriptor(*M);
 
   // If there is only a single PCH, return it instead.



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


[PATCH] D75788: [OpenMP] Provide math functions in OpenMP device code via OpenMP variants

2020-04-01 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 254375.
jdoerfert added a comment.
Herald added a subscriber: yaxunl.

Rewrite. Wrap math.h, time.h, and cmath. Preload only device functions.

Passes all 185 math c++11 tests from [0] which do not deal with long double.
[0] https://github.com/TApplencourt/OmpVal


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75788

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/__clang_cuda_cmath.h
  clang/lib/Headers/__clang_cuda_device_functions.h
  clang/lib/Headers/__clang_cuda_math.h
  clang/lib/Headers/__clang_cuda_math_forward_declares.h
  clang/lib/Headers/openmp_wrappers/__clang_openmp_device_functions.h
  clang/lib/Headers/openmp_wrappers/__clang_openmp_math.h
  clang/lib/Headers/openmp_wrappers/__clang_openmp_math_declares.h
  clang/lib/Headers/openmp_wrappers/cmath
  clang/lib/Headers/openmp_wrappers/math.h
  clang/lib/Headers/openmp_wrappers/time.h
  clang/test/Headers/Inputs/include/climits
  clang/test/Headers/Inputs/include/cmath
  clang/test/Headers/Inputs/include/cstdlib
  clang/test/Headers/Inputs/include/math.h
  clang/test/Headers/Inputs/include/stdlib.h
  clang/test/Headers/nvptx_device_cmath_functions.c
  clang/test/Headers/nvptx_device_cmath_functions.cpp
  clang/test/Headers/nvptx_device_cmath_functions_cxx17.cpp
  clang/test/Headers/nvptx_device_math_complex.c
  clang/test/Headers/nvptx_device_math_functions.c
  clang/test/Headers/nvptx_device_math_functions.cpp
  clang/test/Headers/nvptx_device_math_functions_cxx17.cpp
  clang/test/Headers/nvptx_device_math_macro.cpp
  clang/test/Headers/nvptx_device_math_modf.cpp
  clang/test/Headers/nvptx_device_math_sin.c
  clang/test/Headers/nvptx_device_math_sin.cpp
  clang/test/Headers/nvptx_device_math_sin_cos.cpp
  clang/test/Headers/nvptx_device_math_sincos.cpp
  llvm/utils/gn/secondary/clang/lib/Headers/BUILD.gn

Index: llvm/utils/gn/secondary/clang/lib/Headers/BUILD.gn
===
--- llvm/utils/gn/secondary/clang/lib/Headers/BUILD.gn
+++ llvm/utils/gn/secondary/clang/lib/Headers/BUILD.gn
@@ -194,7 +194,7 @@
 "openmp_wrappers/math.h",
 "openmp_wrappers/cmath",
 "openmp_wrappers/__clang_openmp_math.h",
-"openmp_wrappers/__clang_openmp_math_declares.h",
+"openmp_wrappers/__clang_openmp_device_functions.h",
   ]
   outputs = [ "$clang_resource_dir/include/{{source_target_relative}}" ]
 }
Index: clang/test/Headers/nvptx_device_math_sincos.cpp
===
--- /dev/null
+++ clang/test/Headers/nvptx_device_math_sincos.cpp
@@ -0,0 +1,58 @@
+// REQUIRES: nvptx-registered-target
+// RUN: %clang_cc1 -internal-isystem %S/Inputs/include -fopenmp -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -internal-isystem %S/Inputs/include -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s
+
+#include 
+
+// 4 calls to sincos(f), all translated to __nv_sincos calls:
+
+// CHECK-NOT: _Z.sincos
+// CHECK: call void @__nv_sincos(double
+// CHECK-NOT: _Z.sincos
+// CHECK: call void @__nv_sincosf(float
+// CHECK-NOT: _Z.sincos
+// CHECK: call void @__nv_sincos(double
+// CHECK-NOT: _Z.sincos
+// CHECK: call void @__nv_sincosf(float
+// CHECK-NOT: _Z.sincos
+
+// single precision wrapper
+inline void sincos(float x, float* __restrict__ sin, float* __restrict__ cos)
+{
+  sincosf(x, sin, cos);
+}
+
+template
+void test_sincos(T x)
+{
+  T res_sin, res_cos;
+
+  #pragma omp target map(from: res_sin, res_cos)
+  {
+sincos(x, _sin, _cos);
+  }
+
+}
+
+int main(int argc, char **argv)
+{
+
+#if !defined(C_ONLY)
+  test_sincos(0.0);
+  test_sincos(0.0);
+#endif
+
+  #pragma omp target
+  {
+double s, c;
+sincos(0, , );
+  }
+
+  #pragma omp target
+  {
+float s, c;
+sincosf(0.f, , );
+  }
+
+  return 0;
+}
Index: clang/test/Headers/nvptx_device_math_sin_cos.cpp
===
--- /dev/null
+++ clang/test/Headers/nvptx_device_math_sin_cos.cpp
@@ -0,0 +1,63 @@
+// REQUIRES: nvptx-registered-target
+// RUN: %clang_cc1 -internal-isystem %S/Inputs/include -fopenmp -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
+// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -internal-isystem %S/Inputs/include -fopenmp -triple nvptx64-nvidia-cuda -aux-triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device 

[PATCH] D71129: [ARM][CMSE] Implement CMSE attributes

2020-04-01 Thread Todd Snider via Phabricator via cfe-commits
snidertm added a comment.

Have you already committed support for CMSE attributes to the LLVM backend? Or 
is that on the way?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71129



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


[PATCH] D71129: [ARM][CMSE] Implement CMSE attributes

2020-04-01 Thread Todd Snider via Phabricator via cfe-commits
snidertm added inline comments.



Comment at: clang/include/clang/AST/Type.h:3622
 bool getNoCfCheck() const { return Bits & NoCfCheckMask; }
 bool getHasRegParm() const { return (Bits >> RegParmOffset) != 0; }
 

chill wrote:
> snidertm wrote:
> > chill wrote:
> > > ... here.
> > > 
> > >bool getHasRegParm() const { return ((Bits & RegParmMask) >> 
> > > RegParmOffset) != 0;
> > I don't see how this helps. If RegParmOffset is 8 and the CmseNSCall bit is 
> > set in Bits, then your proposed getHasRegParm() will return true. Given the 
> > above assignment to Bits, we don't know if the CmseNSCall bit was set by 
> > cmseNSCall or by regParm.
> > 
> > MIght I be missing something?
> No, it will not return true, because the mask will clear all bits, except 
> bits [8-10,13-31].
> Bits [13-31] are unused/zero, and in the patch I'm preparing, the RegParmMask 
> will be simply 0x700,
> so they will be cleared anyway.
> CmseNSCall is bit 12, so it will be cleared. Also RegParm + 1 is at most 7, 
> so, it cannot overflow into
> NoCfCheck of CmseNSCall.
Got it, ok.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71129



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


[PATCH] D73307: Unique Names for Functions with Internal Linkage

2020-04-01 Thread Sriraman Tallam via Phabricator via cfe-commits
tmsriram updated this revision to Diff 254347.
tmsriram added a comment.

Rebase and add tests for anonymous namespace symbol and function static global.


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

https://reviews.llvm.org/D73307

Files:
  clang/docs/UsersManual.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/unique-internal-linkage-names.cpp
  clang/test/Driver/funique-internal-linkage-names.c

Index: clang/test/Driver/funique-internal-linkage-names.c
===
--- /dev/null
+++ clang/test/Driver/funique-internal-linkage-names.c
@@ -0,0 +1,4 @@
+// RUN: %clang -### -funique-internal-linkage-names %s -c 2>&1 | FileCheck -check-prefix=CHECK-OPT %s
+// RUN: %clang -### -funique-internal-linkage-names -fno-unique-internal-linkage-names %s -c 2>&1 | FileCheck -check-prefix=CHECK-NOOPT %s
+// CHECK-OPT: "-funique-internal-linkage-names"
+// CHECK-NOOPT-NOT: "-funique-internal-linkage-names"
Index: clang/test/CodeGen/unique-internal-linkage-names.cpp
===
--- /dev/null
+++ clang/test/CodeGen/unique-internal-linkage-names.cpp
@@ -0,0 +1,68 @@
+// This test checks if internal linkage symbols get unique names with
+// -funique-internal-linkage-names option.
+// RUN: %clang_cc1 -triple x86_64 -x c++ -S -emit-llvm -o - < %s | FileCheck %s --check-prefix=PLAIN
+// RUN: %clang_cc1 -triple x86_64 -x c++ -S -emit-llvm -funique-internal-linkage-names -o - < %s | FileCheck %s --check-prefix=UNIQUE
+
+static int glob;
+static int foo() {
+  return 0;
+}
+
+int (*bar())() {
+  return foo;
+}
+
+int getGlob() {
+  return glob;
+}
+
+// Function local static variable and anonymous namespace namespace variable.
+namespace {
+int anon_m;
+int getM() {
+  return anon_m;
+}
+} // namespace
+
+int retAnonM() {
+  static int fGlob;
+  return getM() + fGlob;
+}
+
+// Multiversioning symbols
+__attribute__((target("default"))) static int mver() {
+  return 0;
+}
+
+__attribute__((target("sse4.2"))) static int mver() {
+  return 1;
+}
+
+int mver_call() {
+  return mver();
+}
+
+// PLAIN: @_ZL4glob = internal global
+// PLAIN: @_ZL3foov()
+// PLAIN: @_ZN12_GLOBAL__N_14getMEv
+// PLAIN: @_ZZ8retAnonMvE5fGlob
+// PLAIN: @_ZN12_GLOBAL__N_16anon_mE
+// PLAIN: @_ZL4mverv.resolver()
+// PLAIN: @_ZL4mverv()
+// PLAIN: @_ZL4mverv.sse4.2()
+// UNIQUE-NOT: @_ZL4glob = internal global
+// UNIQUE-NOT: @_ZL3foov()
+// UNIQUE-NOT: @_ZN12_GLOBAL__N_14getMEv
+// UNIQUE-NOT: @_ZZ8retAnonMvE5fGlob
+// UNIQUE-NOT: @_ZN12_GLOBAL__N_16anon_mE
+// UNIQUE-NOT: @_ZL4mverv.resolver()
+// UNIQUE-NOT: @_ZL4mverv()
+// UNIQUE-NOT: @_ZL4mverv.sse4.2()
+// UNIQUE: @_ZL4glob.{{[0-9a-f]+}} = internal global
+// UNIQUE: @_ZL3foov.{{[0-9a-f]+}}()
+// UNIQUE: @_ZN12_GLOBAL__N_14getMEv.{{[0-9a-f]+}}
+// UNIQUE: @_ZZ8retAnonMvE5fGlob.{{[0-9a-f]+}}
+// UNIQUE: @_ZN12_GLOBAL__N_16anon_mE.{{[0-9a-f]+}}
+// UNIQUE: @_ZL4mverv.{{[0-9a-f]+}}.resolver()
+// UNIQUE: @_ZL4mverv.{{[0-9a-f]+}}()
+// UNIQUE: @_ZL4mverv.{{[0-9a-f]+}}.sse4.2()
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -958,6 +958,8 @@
   Opts.DataSections = Args.hasArg(OPT_fdata_sections);
   Opts.StackSizeSection = Args.hasArg(OPT_fstack_size_section);
   Opts.UniqueSectionNames = !Args.hasArg(OPT_fno_unique_section_names);
+  Opts.UniqueInternalLinkageNames =
+  Args.hasArg(OPT_funique_internal_linkage_names);
 
   Opts.MergeFunctions = Args.hasArg(OPT_fmerge_functions);
 
Index: clang/docs/UsersManual.rst
===
--- clang/docs/UsersManual.rst
+++ clang/docs/UsersManual.rst
@@ -1677,6 +1677,24 @@
on ELF targets when using the integrated assembler. This flag currently
only has an effect on ELF targets.
 
+**-f[no]-unique-internal-linkage-names**
+
+   Controls whether Clang emits a unique (best-effort) symbol name for internal
+   linkage symbols. The unique name is obtained by appending the hash of the
+   full module name to the original symbol. This option is particularly useful
+   in attributing profile information to the correct function when multiple
+   functions with the same private linkage name exist in the binary.
+
+   It should be noted that this option cannot guarantee uniqueness and the
+   following is an example where it is not unique when two modules contain
+   symbols with the same private linkage name:
+
+   .. code-block:: console
+
+ $ cd $P/foo && clang -c -funique-internal-linkage-names name_conflict.c
+ $ cd $P/bar && clang -c -funique-internal-linkage-names name_conflict.c
+ $ cd 

[PATCH] D77257: Clean up usages of asserting vector getters in Type

2020-04-01 Thread Christopher Tetreault via Phabricator via cfe-commits
ctetreau created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Remove usages of asserting vector getters in Type in preparation for the
VectorType refactor. The existence of these functions complicates the
refactor while adding little value.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77257

Files:
  clang/lib/CodeGen/CGAtomic.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/PatternInit.cpp
  clang/lib/CodeGen/TargetInfo.cpp

Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -3054,7 +3054,7 @@
 // Don't pass vXi128 vectors in their native type, the backend can't
 // legalize them.
 if (passInt128VectorsInMem() &&
-IRType->getVectorElementType()->isIntegerTy(128)) {
+cast(IRType)->getElementType()->isIntegerTy(128)) {
   // Use a vXi64 vector.
   uint64_t Size = getContext().getTypeSize(Ty);
   return llvm::VectorType::get(llvm::Type::getInt64Ty(getVMContext()),
Index: clang/lib/CodeGen/PatternInit.cpp
===
--- clang/lib/CodeGen/PatternInit.cpp
+++ clang/lib/CodeGen/PatternInit.cpp
@@ -34,9 +34,11 @@
   constexpr bool NegativeNaN = true;
   constexpr uint64_t NaNPayload = 0xull;
   if (Ty->isIntOrIntVectorTy()) {
-unsigned BitWidth = cast(
-Ty->isVectorTy() ? Ty->getVectorElementType() : Ty)
-->getBitWidth();
+unsigned BitWidth =
+cast(
+Ty->isVectorTy() ? cast(Ty)->getElementType()
+ : Ty)
+->getBitWidth();
 if (BitWidth <= 64)
   return llvm::ConstantInt::get(Ty, IntValue);
 return llvm::ConstantInt::get(
@@ -44,7 +46,7 @@
   }
   if (Ty->isPtrOrPtrVectorTy()) {
 auto *PtrTy = cast(
-Ty->isVectorTy() ? Ty->getVectorElementType() : Ty);
+Ty->isVectorTy() ? cast(Ty)->getElementType() : Ty);
 unsigned PtrWidth = CGM.getContext().getTargetInfo().getPointerWidth(
 PtrTy->getAddressSpace());
 if (PtrWidth > 64)
@@ -55,7 +57,7 @@
   }
   if (Ty->isFPOrFPVectorTy()) {
 unsigned BitWidth = llvm::APFloat::semanticsSizeInBits(
-(Ty->isVectorTy() ? Ty->getVectorElementType() : Ty)
+(Ty->isVectorTy() ? cast(Ty)->getElementType() : Ty)
 ->getFltSemantics());
 llvm::APInt Payload(64, NaNPayload);
 if (BitWidth >= 64)
Index: clang/lib/CodeGen/CGExprScalar.cpp
===
--- clang/lib/CodeGen/CGExprScalar.cpp
+++ clang/lib/CodeGen/CGExprScalar.cpp
@@ -1306,7 +1306,7 @@
"Splatted expr doesn't match with vector element type?");
 
 // Splat the element across to all elements
-unsigned NumElements = DstTy->getVectorNumElements();
+unsigned NumElements = cast(DstTy)->getNumElements();
 return Builder.CreateVectorSplat(NumElements, Src, "splat");
   }
 
@@ -1324,8 +1324,8 @@
 // short or half vector.
 
 // Source and destination are both expected to be vectors.
-llvm::Type *SrcElementTy = SrcTy->getVectorElementType();
-llvm::Type *DstElementTy = DstTy->getVectorElementType();
+llvm::Type *SrcElementTy = cast(SrcTy)->getElementType();
+llvm::Type *DstElementTy = cast(DstTy)->getElementType();
 (void)DstElementTy;
 
 assert(((SrcElementTy->isIntegerTy() &&
@@ -1691,8 +1691,8 @@
   assert(DstTy->isVectorTy() &&
  "ConvertVector destination IR type must be a vector");
 
-  llvm::Type *SrcEltTy = SrcTy->getVectorElementType(),
- *DstEltTy = DstTy->getVectorElementType();
+  llvm::Type *SrcEltTy = cast(SrcTy)->getElementType(),
+ *DstEltTy = cast(DstTy)->getElementType();
 
   if (DstEltType->isBooleanType()) {
 assert((SrcEltTy->isFloatingPointTy() ||
@@ -2219,7 +2219,7 @@
 llvm::Type *DstTy = ConvertType(DestTy);
 Value *Elt = Visit(const_cast(E));
 // Splat the element across to all elements
-unsigned NumElements = DstTy->getVectorNumElements();
+unsigned NumElements = cast(DstTy)->getNumElements();
 return Builder.CreateVectorSplat(NumElements, Elt, "splat");
   }
 
@@ -4545,7 +4545,8 @@
   // get a vec3.
   if (NumElementsSrc != 3 && NumElementsDst == 3) {
 if (!CGF.CGM.getCodeGenOpts().PreserveVec3Type) {
-  auto Vec4Ty = llvm::VectorType::get(DstTy->getVectorElementType(), 4);
+  auto Vec4Ty = llvm::VectorType::get(
+  cast(DstTy)->getElementType(), 4);
   Src = createCastsForTypeOfSameSize(Builder, CGF.CGM.getDataLayout(), Src,
  Vec4Ty);
 }
Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ 

[PATCH] D71129: [ARM][CMSE] Implement CMSE attributes

2020-04-01 Thread Momchil Velikov via Phabricator via cfe-commits
chill marked 2 inline comments as done.
chill added inline comments.



Comment at: clang/include/clang/AST/Type.h:3622
 bool getNoCfCheck() const { return Bits & NoCfCheckMask; }
 bool getHasRegParm() const { return (Bits >> RegParmOffset) != 0; }
 

snidertm wrote:
> chill wrote:
> > ... here.
> > 
> >bool getHasRegParm() const { return ((Bits & RegParmMask) >> 
> > RegParmOffset) != 0;
> I don't see how this helps. If RegParmOffset is 8 and the CmseNSCall bit is 
> set in Bits, then your proposed getHasRegParm() will return true. Given the 
> above assignment to Bits, we don't know if the CmseNSCall bit was set by 
> cmseNSCall or by regParm.
> 
> MIght I be missing something?
No, it will not return true, because the mask will clear all bits, except bits 
[8-10,13-31].
Bits [13-31] are unused/zero, and in the patch I'm preparing, the RegParmMask 
will be simply 0x700,
so they will be cleared anyway.
CmseNSCall is bit 12, so it will be cleared. Also RegParm + 1 is at most 7, so, 
it cannot overflow into
NoCfCheck of CmseNSCall.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71129



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


[PATCH] D77254: Clean up usages of asserting vector getters in Type

2020-04-01 Thread Christopher Tetreault via Phabricator via cfe-commits
ctetreau created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Remove usages of asserting vector getters in Type in preparation for the
VectorType refactor. The existence of these functions complicates the
refactor while adding little value.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77254

Files:
  clang/lib/CodeGen/CGAtomic.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/PatternInit.cpp
  clang/lib/CodeGen/TargetInfo.cpp

Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -3054,7 +3054,7 @@
 // Don't pass vXi128 vectors in their native type, the backend can't
 // legalize them.
 if (passInt128VectorsInMem() &&
-IRType->getVectorElementType()->isIntegerTy(128)) {
+cast(IRType)->getElementType()->isIntegerTy(128)) {
   // Use a vXi64 vector.
   uint64_t Size = getContext().getTypeSize(Ty);
   return llvm::VectorType::get(llvm::Type::getInt64Ty(getVMContext()),
Index: clang/lib/CodeGen/PatternInit.cpp
===
--- clang/lib/CodeGen/PatternInit.cpp
+++ clang/lib/CodeGen/PatternInit.cpp
@@ -34,9 +34,11 @@
   constexpr bool NegativeNaN = true;
   constexpr uint64_t NaNPayload = 0xull;
   if (Ty->isIntOrIntVectorTy()) {
-unsigned BitWidth = cast(
-Ty->isVectorTy() ? Ty->getVectorElementType() : Ty)
-->getBitWidth();
+unsigned BitWidth =
+cast(
+Ty->isVectorTy() ? cast(Ty)->getElementType()
+ : Ty)
+->getBitWidth();
 if (BitWidth <= 64)
   return llvm::ConstantInt::get(Ty, IntValue);
 return llvm::ConstantInt::get(
@@ -44,7 +46,7 @@
   }
   if (Ty->isPtrOrPtrVectorTy()) {
 auto *PtrTy = cast(
-Ty->isVectorTy() ? Ty->getVectorElementType() : Ty);
+Ty->isVectorTy() ? cast(Ty)->getElementType() : Ty);
 unsigned PtrWidth = CGM.getContext().getTargetInfo().getPointerWidth(
 PtrTy->getAddressSpace());
 if (PtrWidth > 64)
@@ -55,7 +57,7 @@
   }
   if (Ty->isFPOrFPVectorTy()) {
 unsigned BitWidth = llvm::APFloat::semanticsSizeInBits(
-(Ty->isVectorTy() ? Ty->getVectorElementType() : Ty)
+(Ty->isVectorTy() ? cast(Ty)->getElementType() : Ty)
 ->getFltSemantics());
 llvm::APInt Payload(64, NaNPayload);
 if (BitWidth >= 64)
Index: clang/lib/CodeGen/CGExprScalar.cpp
===
--- clang/lib/CodeGen/CGExprScalar.cpp
+++ clang/lib/CodeGen/CGExprScalar.cpp
@@ -1306,7 +1306,7 @@
"Splatted expr doesn't match with vector element type?");
 
 // Splat the element across to all elements
-unsigned NumElements = DstTy->getVectorNumElements();
+unsigned NumElements = cast(DstTy)->getNumElements();
 return Builder.CreateVectorSplat(NumElements, Src, "splat");
   }
 
@@ -1324,8 +1324,8 @@
 // short or half vector.
 
 // Source and destination are both expected to be vectors.
-llvm::Type *SrcElementTy = SrcTy->getVectorElementType();
-llvm::Type *DstElementTy = DstTy->getVectorElementType();
+llvm::Type *SrcElementTy = cast(SrcTy)->getElementType();
+llvm::Type *DstElementTy = cast(DstTy)->getElementType();
 (void)DstElementTy;
 
 assert(((SrcElementTy->isIntegerTy() &&
@@ -1691,8 +1691,8 @@
   assert(DstTy->isVectorTy() &&
  "ConvertVector destination IR type must be a vector");
 
-  llvm::Type *SrcEltTy = SrcTy->getVectorElementType(),
- *DstEltTy = DstTy->getVectorElementType();
+  llvm::Type *SrcEltTy = cast(SrcTy)->getElementType(),
+ *DstEltTy = cast(DstTy)->getElementType();
 
   if (DstEltType->isBooleanType()) {
 assert((SrcEltTy->isFloatingPointTy() ||
@@ -2219,7 +2219,7 @@
 llvm::Type *DstTy = ConvertType(DestTy);
 Value *Elt = Visit(const_cast(E));
 // Splat the element across to all elements
-unsigned NumElements = DstTy->getVectorNumElements();
+unsigned NumElements = cast(DstTy)->getNumElements();
 return Builder.CreateVectorSplat(NumElements, Elt, "splat");
   }
 
@@ -4545,7 +4545,8 @@
   // get a vec3.
   if (NumElementsSrc != 3 && NumElementsDst == 3) {
 if (!CGF.CGM.getCodeGenOpts().PreserveVec3Type) {
-  auto Vec4Ty = llvm::VectorType::get(DstTy->getVectorElementType(), 4);
+  auto Vec4Ty = llvm::VectorType::get(
+  cast(DstTy)->getElementType(), 4);
   Src = createCastsForTypeOfSameSize(Builder, CGF.CGM.getDataLayout(), Src,
  Vec4Ty);
 }
Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ 

[PATCH] D74299: [clang-tidy] extend tests of run-clang-tidy

2020-04-01 Thread Alexander Lanin via Phabricator via cfe-commits
AlexanderLanin added a comment.

*ping*


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

https://reviews.llvm.org/D74299



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


[PATCH] D77234: clang/AMDGPU: Stop setting old denormal subtarget features

2020-04-01 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks!


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

https://reviews.llvm.org/D77234



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


[PATCH] D77240: [CUDA] Add missing cmath overloads

2020-04-01 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

We do have a problem. With your patch I see a lot of errors about function 
redefinitions conflicting with the ones in CUDA's `math_functions.hpp`:

E.g:

  In file included from :1:
  In file included from 
/usr/local/google/home/tra/work/llvm/build/release+assert+zapcc/lib/clang/11.0.0/include/__clang_cuda_runtime_wrapper.h:398:
  
/usr/local/google/home/tra/work/llvm/build/release+assert+zapcc/lib/clang/11.0.0/include/__clang_cuda_cmath.h:60:18:
 error: redefinition of 'acosh'
  __DEVICE__ float acosh(float __x) { return ::acoshf(__x); }
   ^
  
/usr/local/google/home/tra/local/cuda-10.0/include/crt/math_functions.hpp:624:31:
 note: previous definition is here
  __MATH_FUNCTIONS_DECL__ float acosh(float a)

Full list of conflicting functions in CUDA 9.0, 10.0, 10.1, 10.2

  redefinition of 'acosh'
  redefinition of 'asinh'
  redefinition of 'atanh'
  redefinition of 'cbrt'
  redefinition of 'erf'
  redefinition of 'erfc'
  redefinition of 'exp2'
  redefinition of 'expm1'
  redefinition of 'fdim'
  redefinition of 'hypot'
  redefinition of 'ilogb'
  redefinition of 'lgamma'
  redefinition of 'llrint'
  redefinition of 'llround'
  redefinition of 'log1p'
  redefinition of 'log2'
  redefinition of 'logb'
  redefinition of 'lrint'
  redefinition of 'lround'


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77240



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


[PATCH] D73307: Unique Names for Functions with Internal Linkage

2020-04-01 Thread David Li via Phabricator via cfe-commits
davidxl added inline comments.



Comment at: clang/test/CodeGen/unique-internal-linkage-names.cpp:29
+int mver_call() {
+  return mver();
+}

[a side note]: interesting, since when Clang had this target attribute based 
multi-versioning and function overloading ? Sriraman added this support in GCC 
8 years ago. Did not realize it is in Clang too :)


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

https://reviews.llvm.org/D73307



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


[PATCH] D77236: [SVE] Cleanup prior to introdution of FixedVectorType

2020-04-01 Thread Christopher Tetreault via Phabricator via cfe-commits
ctetreau updated this revision to Diff 254327.
ctetreau added a comment.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Split commit up into multiple smaller commits:

1 commit per llvm library, 1 for clang, and 1 for mlir. Plus one final commit 
to remove the functions from Type


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77236

Files:
  llvm/include/llvm/IR/DerivedTypes.h
  llvm/include/llvm/IR/Type.h
  llvm/lib/IR/Type.cpp


Index: llvm/lib/IR/Type.cpp
===
--- llvm/lib/IR/Type.cpp
+++ llvm/lib/IR/Type.cpp
@@ -149,6 +149,12 @@
   return -1;
 }
 
+Type *Type::getScalarType() const {
+  if (isVectorTy())
+return cast(this)->getElementType();
+  return const_cast(this);
+}
+
 bool Type::isSizedDerivedType(SmallPtrSetImpl *Visited) const {
   if (auto *ATy = dyn_cast(this))
 return ATy->getElementType()->isSized(Visited);
Index: llvm/include/llvm/IR/Type.h
===
--- llvm/include/llvm/IR/Type.h
+++ llvm/include/llvm/IR/Type.h
@@ -304,11 +304,7 @@
 
   /// If this is a vector type, return the element type, otherwise return
   /// 'this'.
-  Type *getScalarType() const {
-if (isVectorTy())
-  return getVectorElementType();
-return const_cast(this);
-  }
+  Type *getScalarType() const;
 
   
//======//
   // Type Iteration support.
@@ -343,8 +339,8 @@
 
   
//======//
   // Helper methods corresponding to subclass methods.  This forces a cast to
-  // the specified subclass and calls its accessor.  "getVectorNumElements" 
(for
-  // example) is shorthand for cast(Ty)->getNumElements().  This is
+  // the specified subclass and calls its accessor.  "getArrayNumElements" (for
+  // example) is shorthand for cast(Ty)->getNumElements().  This is
   // only intended to cover the core methods that are frequently used, helper
   // methods should not be added here.
 
@@ -370,14 +366,6 @@
 return ContainedTys[0];
   }
 
-  inline bool getVectorIsScalable() const;
-  inline unsigned getVectorNumElements() const;
-  inline ElementCount getVectorElementCount() const;
-  Type *getVectorElementType() const {
-assert(getTypeID() == VectorTyID);
-return ContainedTys[0];
-  }
-
   Type *getPointerElementType() const {
 assert(getTypeID() == PointerTyID);
 return ContainedTys[0];
Index: llvm/include/llvm/IR/DerivedTypes.h
===
--- llvm/include/llvm/IR/DerivedTypes.h
+++ llvm/include/llvm/IR/DerivedTypes.h
@@ -546,18 +546,6 @@
   }
 };
 
-unsigned Type::getVectorNumElements() const {
-  return cast(this)->getNumElements();
-}
-
-bool Type::getVectorIsScalable() const {
-  return cast(this)->isScalable();
-}
-
-ElementCount Type::getVectorElementCount() const {
-  return cast(this)->getElementCount();
-}
-
 /// Class to represent pointers.
 class PointerType : public Type {
   explicit PointerType(Type *ElType, unsigned AddrSpace);
@@ -610,8 +598,8 @@
   isIntOrIntVectorTy() &&
   "Original type expected to be a vector of integers or a scalar 
integer.");
   Type *NewType = getIntNTy(getContext(), NewBitWidth);
-  if (isVectorTy())
-NewType = VectorType::get(NewType, getVectorElementCount());
+  if (auto *VTy = dyn_cast(this))
+NewType = VectorType::get(NewType, VTy->getElementCount());
   return NewType;
 }
 


Index: llvm/lib/IR/Type.cpp
===
--- llvm/lib/IR/Type.cpp
+++ llvm/lib/IR/Type.cpp
@@ -149,6 +149,12 @@
   return -1;
 }
 
+Type *Type::getScalarType() const {
+  if (isVectorTy())
+return cast(this)->getElementType();
+  return const_cast(this);
+}
+
 bool Type::isSizedDerivedType(SmallPtrSetImpl *Visited) const {
   if (auto *ATy = dyn_cast(this))
 return ATy->getElementType()->isSized(Visited);
Index: llvm/include/llvm/IR/Type.h
===
--- llvm/include/llvm/IR/Type.h
+++ llvm/include/llvm/IR/Type.h
@@ -304,11 +304,7 @@
 
   /// If this is a vector type, return the element type, otherwise return
   /// 'this'.
-  Type *getScalarType() const {
-if (isVectorTy())
-  return getVectorElementType();
-return const_cast(this);
-  }
+  Type *getScalarType() const;
 
   //======//
   // Type Iteration support.
@@ -343,8 +339,8 @@
 
   //======//
   // Helper methods corresponding to subclass methods.  This forces a cast to
-  // the specified subclass and calls its accessor.  "getVectorNumElements" (for
-  // example) is shorthand for cast(Ty)->getNumElements().  This 

[PATCH] D71129: [ARM][CMSE] Implement CMSE attributes

2020-04-01 Thread Todd Snider via Phabricator via cfe-commits
snidertm added inline comments.



Comment at: clang/include/clang/AST/Type.h:3604
+ (noCallerSavedRegs ? NoCallerSavedRegsMask : 0) |
+ (hasRegParm ? ((regParm + 1) << RegParmOffset) : 0) |
+ (NoCfCheck ? NoCfCheckMask : 0) |

Wouldn't this overwrite the CmseNSCallMask bit if hasRegParm is true and 
((regParm + 1) & 1) is non-zero?



Comment at: clang/include/clang/AST/Type.h:3622
 bool getNoCfCheck() const { return Bits & NoCfCheckMask; }
 bool getHasRegParm() const { return (Bits >> RegParmOffset) != 0; }
 

chill wrote:
> ... here.
> 
>bool getHasRegParm() const { return ((Bits & RegParmMask) >> 
> RegParmOffset) != 0;
I don't see how this helps. If RegParmOffset is 8 and the CmseNSCall bit is set 
in Bits, then your proposed getHasRegParm() will return true. Given the above 
assignment to Bits, we don't know if the CmseNSCall bit was set by cmseNSCall 
or by regParm.

MIght I be missing something?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71129



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


[PATCH] D77246: Instead of scream, why not roll?

2020-04-01 Thread Diab Neiroukh via Phabricator via cfe-commits
lazerl0rd created this revision.
lazerl0rd added reviewers: nathanchance, clang.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Everyone naturally converts hex to text when they see a long
value, so provide clearer information on their bad coding habits
with a nice link.

If you're still a bit lazy, why not use 
https://www.browserling.com/tools/hex-to-text?


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77246

Files:
  clang/lib/CodeGen/PatternInit.cpp


Index: clang/lib/CodeGen/PatternInit.cpp
===
--- clang/lib/CodeGen/PatternInit.cpp
+++ clang/lib/CodeGen/PatternInit.cpp
@@ -24,7 +24,7 @@
   const uint64_t IntValue =
   CGM.getContext().getTargetInfo().getMaxPointerWidth() < 64
   ? 0xull
-  : 0xull;
+  : 0x68747470733a2f2f74696e7975726c2e636f6d2f32666370726536;
   // Floating-point values are initialized as NaNs because they propagate. 
Using
   // a repeated byte pattern means that it will be easier to initialize
   // all-floating-point aggregates and arrays with memset. Further, aggregates


Index: clang/lib/CodeGen/PatternInit.cpp
===
--- clang/lib/CodeGen/PatternInit.cpp
+++ clang/lib/CodeGen/PatternInit.cpp
@@ -24,7 +24,7 @@
   const uint64_t IntValue =
   CGM.getContext().getTargetInfo().getMaxPointerWidth() < 64
   ? 0xull
-  : 0xull;
+  : 0x68747470733a2f2f74696e7975726c2e636f6d2f32666370726536;
   // Floating-point values are initialized as NaNs because they propagate. Using
   // a repeated byte pattern means that it will be easier to initialize
   // all-floating-point aggregates and arrays with memset. Further, aggregates
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76389: [NewPM] Run the Speculative Execution Pass only if the target has divergent branches

2020-04-01 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: clang/test/CodeGen/thinlto-distributed-newpm.ll:110
 ; CHECK-O: Running analysis: OuterAnalysisManagerProxy
-; CHECK-O: Running pass: SpeculativeExecutionPass on main
+; CHECK-O: Running pass: SpeculativeExecutionIfHasBranchDivergencePass on main
 ; CHECK-O: Running pass: JumpThreadingPass on main

The pass name shouldn't change here?



Comment at: llvm/lib/Passes/PassBuilder.cpp:435
   if (Level.getSpeedupLevel() > 1) {
-FPM.addPass(SpeculativeExecutionPass());
+FPM.addPass(SpeculativeExecutionIfHasBranchDivergencePass());
 

I don't expect this to be a separate pass, just added based on a divergent 
target


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76389



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


[PATCH] D75951: Keep a list of already-included pragma-once files for mods.

2020-04-01 Thread Vy Nguyen via Phabricator via cfe-commits
oontvoo updated this revision to Diff 254321.
oontvoo added a comment.

clean up ... Ready to review. PTAL! =)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75951

Files:
  clang/include/clang/Lex/HeaderSearch.h
  clang/include/clang/Lex/Preprocessor.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/include/clang/Serialization/ASTReader.h
  clang/include/clang/Serialization/ASTWriter.h
  clang/lib/Lex/HeaderSearch.cpp
  clang/lib/Lex/PPDirectives.cpp
  clang/lib/Lex/PPLexerChange.cpp
  clang/lib/Lex/Preprocessor.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/Modules/Inputs/dummy_pragma_once.h
  clang/test/Modules/Inputs/dummy_textual_header.h
  clang/test/Modules/Inputs/header_in_imported_module.h
  clang/test/Modules/Inputs/imported_module.cppm
  clang/test/Modules/Inputs/module.map
  clang/test/Modules/header-in-imported-module.c
  clang/test/Modules/import-pragma-once.c

Index: clang/test/Modules/import-pragma-once.c
===
--- /dev/null
+++ clang/test/Modules/import-pragma-once.c
@@ -0,0 +1,8 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fimplicit-module-maps -I%S/Inputs -verify -x c %s
+// expected-no-diagnostics
+#include "dummy_pragma_once.h"
+#include "dummy_textual_header.h"
+
+void *p = 
+void *q = 
Index: clang/test/Modules/header-in-imported-module.c
===
--- /dev/null
+++ clang/test/Modules/header-in-imported-module.c
@@ -0,0 +1,14 @@
+// RUN: rm -rf %t
+// RUN: %clang -fmodules -x c++ -fmodules-ts --precompile -o %t/ModuleB39206.pcm %S/Inputs/imported_module.cppm
+// RUN: %clang -fmodules -x c++ -fmodules-ts -c %t/ModuleB39206.pcm -o %t/ModuleB39206.o
+// RUN: %clang -fmodules -x c++ -fmodules-ts -fmodule-file=%t/ModuleB39206.pcm -verify  -c %s
+// expected-no-diagnostics
+
+// Bug 39206
+
+#include "header_in_imported_module.h"
+module ModuleB39206;
+
+#ifndef ALL_GOOD
+#error "missing macro in impl"
+#endif
Index: clang/test/Modules/Inputs/module.map
===
--- clang/test/Modules/Inputs/module.map
+++ clang/test/Modules/Inputs/module.map
@@ -282,6 +282,11 @@
   header "dummy.h"
 }
 
+module dummy_pragma_once {
+  header "dummy_pragma_once.h"
+  textual header "dummy_textual_header.h"
+}
+
 module builtin {
   header "builtin.h"
   explicit module sub {
Index: clang/test/Modules/Inputs/imported_module.cppm
===
--- /dev/null
+++ clang/test/Modules/Inputs/imported_module.cppm
@@ -0,0 +1,5 @@
+export module ModuleB39206;
+#include "header.h"
+
+#ifndef ALL_GOOD
+#error "Missing macro in module decl"
\ No newline at end of file
Index: clang/test/Modules/Inputs/header_in_imported_module.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/header_in_imported_module.h
@@ -0,0 +1,3 @@
+#pragma once
+
+#define ALL_GOOD
Index: clang/test/Modules/Inputs/dummy_textual_header.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/dummy_textual_header.h
@@ -0,0 +1,2 @@
+#pragma once
+int y = 6;
Index: clang/test/Modules/Inputs/dummy_pragma_once.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/dummy_pragma_once.h
@@ -0,0 +1,3 @@
+#include "dummy_textual_header.h"
+
+int x = 5;
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -1621,7 +1621,7 @@
   endian::Writer LE(Out, little);
   unsigned KeyLen = key.Filename.size() + 1 + 8 + 8;
   LE.write(KeyLen);
-  unsigned DataLen = 1 + 2 + 4 + 4;
+  unsigned DataLen = 1 + 2 + 4 + 4 + 4;
   for (auto ModInfo : Data.KnownHeaders)
 if (Writer.getLocalOrImportedSubmoduleID(ModInfo.getModule()))
   DataLen += 4;
@@ -1678,6 +1678,9 @@
   }
   LE.write(Offset);
 
+  // Write this file UID.
+  LE.write(Data.HFI.UID);
+
   auto EmitModule = [&](Module *M, ModuleMap::ModuleHeaderRole Role) {
 if (uint32_t ModID = Writer.getLocalOrImportedSubmoduleID(M)) {
   uint32_t Value = (ModID << 2) | (unsigned)Role;
@@ -1705,7 +1708,7 @@
 /// Write the header search block for the list of files that
 ///
 /// \param HS The header search structure to save.
-void ASTWriter::WriteHeaderSearch(const HeaderSearch ) {
+void ASTWriter::WriteHeaderSearch(HeaderSearch ) {
   HeaderFileInfoTrait GeneratorTrait(*this);
   llvm::OnDiskChainedHashTableGenerator Generator;
   SmallVector SavedStrings;
@@ -1783,8 +1786,7 @@
 // changed since it was loaded. Also skip it if 

[PATCH] D77236: [SVE] Cleanup prior to introdution of FixedVectorType

2020-04-01 Thread Christopher Tetreault via Phabricator via cfe-commits
ctetreau added a comment.

> 1. This is orthogonal to splitting VectorType, as far as I can tell.  
> `Ty->getVectorNumElements()` works equally well whether the implementation 
> asserts it's a VectorType that isn't scalable, or asserts it's a 
> FixedVectorType.

While it's not strictly neccesary, the refactor will be more straightforward 
with this change. Before, we would have:

  unsigned n = t->getVectorNumElements();

After the VectorTypes refactor, if t is not a FixedLengthVector, then this code 
will still compile but fail at runtime. However with:

  unsigned n = cast(t)->getNumElements();

... it will be a compile time failure.

Realistically, it would need to be at least renamed to 
getFixedVectorNumElements anyways to avoid confusion.

> 2. This needs to be split up; it's way too long to read, and it's mixing 
> functional and non-functional changes.

I can split it up into a few chunks that make the corrections a bit at a time, 
then a final change to get rid of the functions

> 3. It might make sense to add helpers to remove the use of cast<> in more 
> places. For example, the inputs of a shufflevector are guaranteed to be 
> vectors.

It seems to me that we use base Type for basically everything when we could use 
concrete subclasses. As you can see in my patch, I fixed a few, but ideally 
functions would just return a VectorType if they have a VectorType. The issue 
is pervasive, and is enabled by the existence of these functions. This is a 
deep rabbit hole that I don't really want to go down in this patch.

> 4. Some of the changes are leading to really crazy indentation because the 
> `cast<>` is more characters.

While I agree, there's not much we can do about that. Really, the problem is 
that we have these crazy complicated if statements that check 15 things at once.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77236



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


[PATCH] D71129: [ARM][CMSE] Implement CMSE attributes

2020-04-01 Thread Momchil Velikov via Phabricator via cfe-commits
chill marked 3 inline comments as done.
chill added inline comments.



Comment at: clang/include/clang/AST/Type.h:3588
+  NoCallerSavedRegsMask | NoCfCheckMask | CmseNSCallMask),
   RegParmOffset = 8
 }; // Assumed to be the last field

snidertm wrote:
> Shouldn't RegParmOffset be updated to 9, I believe it is used to shift the 
> regParm value so that it encoded in the bits above CmseNSCallMask
Hmm, I think 8 is OK, but we should mask it ...



Comment at: clang/include/clang/AST/Type.h:3622
 bool getNoCfCheck() const { return Bits & NoCfCheckMask; }
 bool getHasRegParm() const { return (Bits >> RegParmOffset) != 0; }
 

... here.

   bool getHasRegParm() const { return ((Bits & RegParmMask) >> RegParmOffset) 
!= 0;


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71129



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


[PATCH] D77240: [CUDA] Add missing cmath overloads

2020-04-01 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D77240#1955755 , @tra wrote:

> In D77240#1955724 , @jdoerfert wrote:
>
> > At least that one is defined in what is "now" `__clang_cuda_math.h`:
>
>
> Cool. We may be OK, but we still need to verify it. Math headers are rather 
> fragile and we need to make sure it all still works two different standard 
> libraries and all CUDA versions. 
>  Unfortunately my CUDA build bot has decided to die the day we've started 
> working from home, so it has to be done manually.
>  Let me try patching in your changes and try them with the CUDA versions I 
> have. Stay tuned.


Thank you very much! I (now) know what pain math headers are... These are 
almost the last infrastructure changes I need, there is a problem with the 
include path order on some system but for that I first need to write a patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77240



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


[PATCH] D77240: [CUDA] Add missing cmath overloads

2020-04-01 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

In D77240#1955724 , @jdoerfert wrote:

> At least that one is defined in what is "now" `__clang_cuda_math.h`:


Cool. We may be OK, but we still need to verify it. Math headers are rather 
fragile and we need to make sure it all still works two different standard 
libraries and all CUDA versions. 
Unfortunately my CUDA build bot has decided to die the day we've started 
working from home, so it has to be done manually.
Let me try patching in your changes and try them with the CUDA versions I have. 
Stay tuned.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77240



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


[PATCH] D73462: [dwarf-5] Support DebugInfo for Defaulted parameters for C++ templates

2020-04-01 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

This wasn't well committed, unfortunately.

It seems it was committed in two parts:

IR support and clang functionality: 
https://github.com/llvm/llvm-project/commit/7a42babeb83e3927e89e72a0e7e45be9d41b6c23
 (a recommit of 
https://github.com/llvm/llvm-project/commit/c2b437d53d40b6dc5603c97f527398f477d9c5f1
 )
LLVM functionality (lib/CodeGen/AsmPrinter) and a clang test: 
https://github.com/llvm/llvm-project/commit/1cb0e01e42ca5e9de44d9b7cb03d23552a9a9ae1

It's still missing the LLVM test & this was not the right division for 
committing them. In the future, perhaps it's best to go through separate 
reviews to validate the individual commits after the general review is done.

The Clang functionality and clang test should've been committed together, but 
separately from everything else (after the IR support was in)
The LLVM functionality should've been committed separately but with testing, 
which is not present at all.

The test file llvm/test/DebugInfo/X86/debug-info-template-parameter.ll that was 
in the review seems to have never been committed & this might've been more 
obvious if things were separated as intended/per protocol - please commit it at 
your earliest convenience.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73462



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


[PATCH] D77244: sancov/inline-bool-flag feature + tests + docs.

2020-04-01 Thread Pratyai Mazumder via Phabricator via cfe-commits
pratyai updated this revision to Diff 254316.
pratyai added a comment.

Still had a couple of lines of diff left :(


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77244

Files:
  clang/docs/SanitizerCoverage.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/SanitizerArgs.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/autocomplete.c
  clang/test/Driver/fsanitize-coverage.c
  
compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_inline_bool_flag.cpp
  llvm/include/llvm/Transforms/Instrumentation.h
  llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
  llvm/test/Instrumentation/SanitizerCoverage/coff-pc-table-inline-bool-flag.ll
  llvm/test/Instrumentation/SanitizerCoverage/inline-bool-flag.ll
  llvm/test/Instrumentation/SanitizerCoverage/pc-table.ll
  llvm/test/Instrumentation/SanitizerCoverage/trace-pc-guard-inline-bool-flag.ll

Index: llvm/test/Instrumentation/SanitizerCoverage/trace-pc-guard-inline-bool-flag.ll
===
--- /dev/null
+++ llvm/test/Instrumentation/SanitizerCoverage/trace-pc-guard-inline-bool-flag.ll
@@ -0,0 +1,14 @@
+; RUN: opt < %s -sancov -sanitizer-coverage-level=1 -sanitizer-coverage-trace-pc-guard -sanitizer-coverage-inline-bool-flag -S | FileCheck %s
+; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=1 -sanitizer-coverage-trace-pc-guard -sanitizer-coverage-inline-bool-flag -S | FileCheck %s
+
+; Module ctors should have stable names across modules, not something like
+; @sancov.module_ctor.3 that may cause duplicate ctors after linked together.
+
+; CHECK: define internal void @sancov.module_ctor_trace_pc_guard() comdat {
+; CHECK: define internal void @sancov.module_ctor_bool_flag() comdat {
+
+target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
+target triple = "x86_64-unknown-linux-gnu"
+define void @foo() {
+  ret void
+}
Index: llvm/test/Instrumentation/SanitizerCoverage/pc-table.ll
===
--- llvm/test/Instrumentation/SanitizerCoverage/pc-table.ll
+++ llvm/test/Instrumentation/SanitizerCoverage/pc-table.ll
@@ -1,8 +1,10 @@
 ; Test -sanitizer-coverage-pc-table=1
 ; RUN: opt < %s -sancov -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard   -sanitizer-coverage-pc-table=1 -S | FileCheck %s
 ; RUN: opt < %s -sancov -sanitizer-coverage-level=3 -sanitizer-coverage-inline-8bit-counters -sanitizer-coverage-pc-table=1 -S | FileCheck %s
+; RUN: opt < %s -sancov -sanitizer-coverage-level=3 -sanitizer-coverage-inline-bool-flag -sanitizer-coverage-pc-table=1 -S | FileCheck %s
 ; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard   -sanitizer-coverage-pc-table=1 -S | FileCheck %s
 ; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=3 -sanitizer-coverage-inline-8bit-counters -sanitizer-coverage-pc-table=1 -S | FileCheck %s
+; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=3 -sanitizer-coverage-inline-bool-flag -sanitizer-coverage-pc-table=1 -S | FileCheck %s
 
 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
 target triple = "x86_64-unknown-linux-gnu"
Index: llvm/test/Instrumentation/SanitizerCoverage/inline-bool-flag.ll
===
--- /dev/null
+++ llvm/test/Instrumentation/SanitizerCoverage/inline-bool-flag.ll
@@ -0,0 +1,13 @@
+; Test -sanitizer-coverage-inline-bool-flag=1
+; RUN: opt < %s -sancov -sanitizer-coverage-level=1 -sanitizer-coverage-inline-bool-flag=1  -S | FileCheck %s
+; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=1 -sanitizer-coverage-inline-bool-flag=1  -S | FileCheck %s
+
+target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
+target triple = "x86_64-unknown-linux-gnu"
+define void @foo() {
+entry:
+; CHECK: section "__sancov_bool_flag", comdat($foo), align 1
+; CHECK: store atomic i8 1, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @__sancov_gen_, i64 0, i64 0) monotonic, align 1, !nosanitize !1
+  ret void
+}
+; CHECK: call void @__sanitizer_cov_bool_flag_init(i8* bitcast (i8** @__start___sancov_bool_flag to i8*), i8* bitcast (i8** @__stop___sancov_bool_flag to i8*))
Index: llvm/test/Instrumentation/SanitizerCoverage/coff-pc-table-inline-bool-flag.ll
===
--- /dev/null
+++ 

[PATCH] D59321: AMDGPU: Teach toolchain to link rocm device libs

2020-04-01 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: clang/include/clang/Driver/Options.td:611
 def fno_cuda_short_ptr : Flag<["-"], "fno-cuda-short-ptr">;
+def rocm_path_EQ : Joined<["--"], "rocm-path=">, Group,
+  HelpText<"ROCm installation path">;

HIP toolchain will also use it to add include path for HIP header files, 
therefore this is more like --cuda-path=. i_Group is more proper.


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

https://reviews.llvm.org/D59321



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


[PATCH] D77236: [SVE] Cleanup prior to introdution of FixedVectorType

2020-04-01 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

My thoughts, in no particular order:

1. This is orthogonal to splitting VectorType, as far as I can tell.  
`Ty->getVectorNumElements()` works equally well whether the implementation 
asserts it's a VectorType that isn't scalable, or asserts it's a 
FixedVectorType.
2. This needs to be split up; it's way too long to read, and it's mixing 
functional and non-functional changes.
3. It might make sense to add helpers to remove the use of cast<> in more 
places. For example, the inputs of a shufflevector are guaranteed to be vectors.
4. Some of the changes are leading to really crazy indentation because the 
`cast<>` is more characters.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77236



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


[PATCH] D71129: [ARM][CMSE] Implement CMSE attributes

2020-04-01 Thread Todd Snider via Phabricator via cfe-commits
snidertm added inline comments.



Comment at: clang/include/clang/AST/Type.h:3588
+  NoCallerSavedRegsMask | NoCfCheckMask | CmseNSCallMask),
   RegParmOffset = 8
 }; // Assumed to be the last field

Shouldn't RegParmOffset be updated to 9, I believe it is used to shift the 
regParm value so that it encoded in the bits above CmseNSCallMask


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71129



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


[PATCH] D77244: sancov/inline-bool-flag feature + tests + docs.

2020-04-01 Thread Pratyai Mazumder via Phabricator via cfe-commits
pratyai updated this revision to Diff 254312.
pratyai added a comment.

Removed some unintentional diffs.

Removed some unintentional diffs from clang/lib/Frontend/CompilerInvocation.cpp.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77244

Files:
  clang/docs/SanitizerCoverage.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/SanitizerArgs.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/autocomplete.c
  clang/test/Driver/fsanitize-coverage.c
  
compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_inline_bool_flag.cpp
  llvm/include/llvm/Transforms/Instrumentation.h
  llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
  llvm/test/Instrumentation/SanitizerCoverage/coff-pc-table-inline-bool-flag.ll
  llvm/test/Instrumentation/SanitizerCoverage/inline-bool-flag.ll
  llvm/test/Instrumentation/SanitizerCoverage/pc-table.ll
  llvm/test/Instrumentation/SanitizerCoverage/trace-pc-guard-inline-bool-flag.ll

Index: llvm/test/Instrumentation/SanitizerCoverage/trace-pc-guard-inline-bool-flag.ll
===
--- /dev/null
+++ llvm/test/Instrumentation/SanitizerCoverage/trace-pc-guard-inline-bool-flag.ll
@@ -0,0 +1,14 @@
+; RUN: opt < %s -sancov -sanitizer-coverage-level=1 -sanitizer-coverage-trace-pc-guard -sanitizer-coverage-inline-bool-flag -S | FileCheck %s
+; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=1 -sanitizer-coverage-trace-pc-guard -sanitizer-coverage-inline-bool-flag -S | FileCheck %s
+
+; Module ctors should have stable names across modules, not something like
+; @sancov.module_ctor.3 that may cause duplicate ctors after linked together.
+
+; CHECK: define internal void @sancov.module_ctor_trace_pc_guard() comdat {
+; CHECK: define internal void @sancov.module_ctor_bool_flag() comdat {
+
+target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
+target triple = "x86_64-unknown-linux-gnu"
+define void @foo() {
+  ret void
+}
Index: llvm/test/Instrumentation/SanitizerCoverage/pc-table.ll
===
--- llvm/test/Instrumentation/SanitizerCoverage/pc-table.ll
+++ llvm/test/Instrumentation/SanitizerCoverage/pc-table.ll
@@ -1,8 +1,10 @@
 ; Test -sanitizer-coverage-pc-table=1
 ; RUN: opt < %s -sancov -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard   -sanitizer-coverage-pc-table=1 -S | FileCheck %s
 ; RUN: opt < %s -sancov -sanitizer-coverage-level=3 -sanitizer-coverage-inline-8bit-counters -sanitizer-coverage-pc-table=1 -S | FileCheck %s
+; RUN: opt < %s -sancov -sanitizer-coverage-level=3 -sanitizer-coverage-inline-bool-flag -sanitizer-coverage-pc-table=1 -S | FileCheck %s
 ; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard   -sanitizer-coverage-pc-table=1 -S | FileCheck %s
 ; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=3 -sanitizer-coverage-inline-8bit-counters -sanitizer-coverage-pc-table=1 -S | FileCheck %s
+; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=3 -sanitizer-coverage-inline-bool-flag -sanitizer-coverage-pc-table=1 -S | FileCheck %s
 
 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
 target triple = "x86_64-unknown-linux-gnu"
Index: llvm/test/Instrumentation/SanitizerCoverage/inline-bool-flag.ll
===
--- /dev/null
+++ llvm/test/Instrumentation/SanitizerCoverage/inline-bool-flag.ll
@@ -0,0 +1,13 @@
+; Test -sanitizer-coverage-inline-bool-flag=1
+; RUN: opt < %s -sancov -sanitizer-coverage-level=1 -sanitizer-coverage-inline-bool-flag=1  -S | FileCheck %s
+; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=1 -sanitizer-coverage-inline-bool-flag=1  -S | FileCheck %s
+
+target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
+target triple = "x86_64-unknown-linux-gnu"
+define void @foo() {
+entry:
+; CHECK: section "__sancov_bool_flag", comdat($foo), align 1
+; CHECK: store atomic i8 1, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @__sancov_gen_, i64 0, i64 0) monotonic, align 1, !nosanitize !1
+  ret void
+}
+; CHECK: call void @__sanitizer_cov_bool_flag_init(i8* bitcast (i8** @__start___sancov_bool_flag to i8*), i8* bitcast (i8** @__stop___sancov_bool_flag to i8*))
Index: llvm/test/Instrumentation/SanitizerCoverage/coff-pc-table-inline-bool-flag.ll

[PATCH] D77239: [CUDA][NFCI] Use unqualified lookup for math functions

2020-04-01 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert abandoned this revision.
jdoerfert added a comment.

In D77239#1955720 , @tra wrote:

> > The other macro uses a unqualified lookup already and the qualified one
> >  will cause problems in the OpenMP overlay.
>
> There's a bit of inconsitency here.  While 
> `__CUDA_CLANG_FN_INTEGER_OVERLOAD_2` indeed uses unqualified lookup, pretty 
> much all other functions use qualified global scope lookups, which, I believe 
> is correct, as we want to use the functions defined by CUDA headers there.
>
> @jlebar -- WDYT?


It turns out I can disable this entire code region for OpenMP (or have to for 
c++17 I tihnk), so I'll abandon this revision and you make it consistent in the 
way that fits your need :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77239



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


[PATCH] D77240: [CUDA] Add missing cmath overloads

2020-04-01 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D77240#1955678 , @tra wrote:

> We'll need to make sure that all of these new functions are vailable in all 
> supported CUDA versions.
>  E.g. `acoshf` does not seem to be present in CUDA-9.


At least that one is defined in what is "now" `__clang_cuda_math.h`:

`__DEVICE__ float acoshf(float __a) { return __nv_acoshf(__a); } `


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77240



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


[PATCH] D77239: [CUDA][NFCI] Use unqualified lookup for math functions

2020-04-01 Thread Artem Belevich via Phabricator via cfe-commits
tra added a subscriber: jlebar.
tra added a comment.

> The other macro uses a unqualified lookup already and the qualified one
>  will cause problems in the OpenMP overlay.

There's a bit of inconsitency here.  While `__CUDA_CLANG_FN_INTEGER_OVERLOAD_2` 
indeed uses unqualified lookup, pretty much all other functions use qualified 
global scope lookups, which, I believe is correct, as we want to use the 
functions defined by CUDA headers there.

@jlebar -- WDYT?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77239



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


[PATCH] D77238: [CUDA][NFC] Split math.h functions out of __clang_cuda_device_functions.h

2020-04-01 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert marked an inline comment as done.
jdoerfert added inline comments.



Comment at: clang/lib/Headers/__clang_cuda_math.h:81
+#endif
+__DEVICE__ long long clock64() { return __nvvm_read_ptx_sreg_clock64(); }
+__DEVICE__ double copysign(double __a, double __b) {

I accidentally moved the clock functions and added the openmp ifdef we'll need 
later. I'll move the clock functions back before I commit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77238



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


[PATCH] D77244: sancov/inline-bool-flag feature + tests + docs.

2020-04-01 Thread Pratyai Mazumder via Phabricator via cfe-commits
pratyai created this revision.
pratyai added reviewers: kcc, vitalybuka.
Herald added subscribers: Sanitizers, cfe-commits, jfb, hiraditya.
Herald added projects: clang, Sanitizers.
pratyai updated this revision to Diff 254312.
pratyai added a comment.

Removed some unintentional diffs.

Removed some unintentional diffs from clang/lib/Frontend/CompilerInvocation.cpp.


New SanitizerCoverage feature `inline-bool-flag` which inserts an atomic store 
of `1` to a boolean (which is an 8bit integer in practice) flag on every 
instrumented edge.

Implementation-wise it's very similar to `inline-8bit-counters` features. So, 
much of wiring and test just follows the same pattern.

Tested with `cmake --build . -- check-llvm`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77244

Files:
  clang/docs/SanitizerCoverage.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/SanitizerArgs.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/autocomplete.c
  clang/test/Driver/fsanitize-coverage.c
  
compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_inline_bool_flag.cpp
  llvm/include/llvm/Transforms/Instrumentation.h
  llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
  llvm/test/Instrumentation/SanitizerCoverage/coff-pc-table-inline-bool-flag.ll
  llvm/test/Instrumentation/SanitizerCoverage/inline-bool-flag.ll
  llvm/test/Instrumentation/SanitizerCoverage/pc-table.ll
  llvm/test/Instrumentation/SanitizerCoverage/trace-pc-guard-inline-bool-flag.ll

Index: llvm/test/Instrumentation/SanitizerCoverage/trace-pc-guard-inline-bool-flag.ll
===
--- /dev/null
+++ llvm/test/Instrumentation/SanitizerCoverage/trace-pc-guard-inline-bool-flag.ll
@@ -0,0 +1,14 @@
+; RUN: opt < %s -sancov -sanitizer-coverage-level=1 -sanitizer-coverage-trace-pc-guard -sanitizer-coverage-inline-bool-flag -S | FileCheck %s
+; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=1 -sanitizer-coverage-trace-pc-guard -sanitizer-coverage-inline-bool-flag -S | FileCheck %s
+
+; Module ctors should have stable names across modules, not something like
+; @sancov.module_ctor.3 that may cause duplicate ctors after linked together.
+
+; CHECK: define internal void @sancov.module_ctor_trace_pc_guard() comdat {
+; CHECK: define internal void @sancov.module_ctor_bool_flag() comdat {
+
+target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
+target triple = "x86_64-unknown-linux-gnu"
+define void @foo() {
+  ret void
+}
Index: llvm/test/Instrumentation/SanitizerCoverage/pc-table.ll
===
--- llvm/test/Instrumentation/SanitizerCoverage/pc-table.ll
+++ llvm/test/Instrumentation/SanitizerCoverage/pc-table.ll
@@ -1,8 +1,10 @@
 ; Test -sanitizer-coverage-pc-table=1
 ; RUN: opt < %s -sancov -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard   -sanitizer-coverage-pc-table=1 -S | FileCheck %s
 ; RUN: opt < %s -sancov -sanitizer-coverage-level=3 -sanitizer-coverage-inline-8bit-counters -sanitizer-coverage-pc-table=1 -S | FileCheck %s
+; RUN: opt < %s -sancov -sanitizer-coverage-level=3 -sanitizer-coverage-inline-bool-flag -sanitizer-coverage-pc-table=1 -S | FileCheck %s
 ; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard   -sanitizer-coverage-pc-table=1 -S | FileCheck %s
 ; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=3 -sanitizer-coverage-inline-8bit-counters -sanitizer-coverage-pc-table=1 -S | FileCheck %s
+; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=3 -sanitizer-coverage-inline-bool-flag -sanitizer-coverage-pc-table=1 -S | FileCheck %s
 
 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
 target triple = "x86_64-unknown-linux-gnu"
Index: llvm/test/Instrumentation/SanitizerCoverage/inline-bool-flag.ll
===
--- /dev/null
+++ llvm/test/Instrumentation/SanitizerCoverage/inline-bool-flag.ll
@@ -0,0 +1,13 @@
+; Test -sanitizer-coverage-inline-bool-flag=1
+; RUN: opt < %s -sancov -sanitizer-coverage-level=1 -sanitizer-coverage-inline-bool-flag=1  -S | FileCheck %s
+; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=1 -sanitizer-coverage-inline-bool-flag=1  -S | FileCheck %s
+
+target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
+target triple = "x86_64-unknown-linux-gnu"
+define void @foo() {
+entry:
+; 

[PATCH] D77240: [CUDA] Add missing cmath overloads

2020-04-01 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

We'll need to make sure that all of these new functions are vailable in all 
supported CUDA versions.
E.g. `acoshf` does not seem to be present in CUDA-9.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77240



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


[PATCH] D59321: AMDGPU: Teach toolchain to link rocm device libs

2020-04-01 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm marked 2 inline comments as done.
arsenm added a comment.

In D59321#1955405 , @hliao wrote:

> Do we have a better way to avoid adding those empty bitcode files?


No, we need the files to exist for tests. This is what existing bitcode link 
tests do




Comment at: clang/lib/Driver/ToolChains/AMDGPU.h:44-46
+  //RocmVersion Version = RocmVersion::UNKNOWN;
+  SmallString<0> InstallPath;
+  //SmallString<0> BinPath;

hliao wrote:
> sounds to me that both `Version` and `BinPath` should be added. They will be 
> used eventually.
It's easy to add when needded



Comment at: clang/lib/Driver/ToolChains/HIP.h:76
 
-class LLVM_LIBRARY_VISIBILITY HIPToolChain final : public AMDGPUToolChain {
+class LLVM_LIBRARY_VISIBILITY HIPToolChain final : public ROCMToolChain {
 public:

hliao wrote:
> Do you miss the change in HIP.cpp? That constructor needs revising as the 
> base class is changed.
Yes, I fixed this locally already


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

https://reviews.llvm.org/D59321



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


[PATCH] D70094: [clang-tidy] new altera ID dependent backward branch check

2020-04-01 Thread Frank Derry Wanye via Phabricator via cfe-commits
ffrankies updated this revision to Diff 254305.
ffrankies marked 5 inline comments as done.
ffrankies added a comment.

- Updated underlying repo to https://github.com/llvm/llvm-project
- Removed braces from one-line if-statements


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

https://reviews.llvm.org/D70094

Files:
  clang-tools-extra/clang-tidy/CMakeLists.txt
  clang-tools-extra/clang-tidy/ClangTidyForceLinker.h
  clang-tools-extra/clang-tidy/altera/AlteraTidyModule.cpp
  clang-tools-extra/clang-tidy/altera/CMakeLists.txt
  clang-tools-extra/clang-tidy/altera/IdDependentBackwardBranchCheck.cpp
  clang-tools-extra/clang-tidy/altera/IdDependentBackwardBranchCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/altera-id-dependent-backward-branch.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/index.rst
  
clang-tools-extra/test/clang-tidy/checkers/altera-id-dependent-backward-branch.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/altera-id-dependent-backward-branch.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/altera-id-dependent-backward-branch.cpp
@@ -0,0 +1,83 @@
+// RUN: %check_clang_tidy %s altera-id-dependent-backward-branch %t -- -header-filter=.* "--" -cl-std=CL1.2 -c --include opencl-c.h
+
+typedef struct ExampleStruct {
+  int IDDepField;
+} ExampleStruct;
+
+void error() {
+  //  Assignments 
+  int ThreadID = get_local_id(0); 
+// CHECK-NOTES: :[[@LINE-1]]:3: warning: assignment of ID-dependent variable ThreadID [altera-id-dependent-backward-branch]
+
+  ExampleStruct Example;
+  Example.IDDepField = get_local_id(0);
+// CHECK-NOTES: :[[@LINE-1]]:3: warning: assignment of ID-dependent field IDDepField [altera-id-dependent-backward-branch]
+
+  //  Inferred Assignments 
+  int ThreadID2 = ThreadID * get_local_size(0);
+// CHECK-NOTES: :[[@LINE-1]]:3: warning: inferred assignment of ID-dependent value from ID-dependent variable ThreadID [altera-id-dependent-backward-branch]
+  
+  int ThreadID3 = Example.IDDepField;  // OK: not used in any loops
+
+  ExampleStruct UnusedStruct = {
+ThreadID * 2  // OK: not used in any loops
+  };
+
+  //  Conditional Expressions 
+  int accumulator = 0;
+  for (int i = 0; i < get_local_id(0); i++) {
+// CHECK-NOTES: :[[@LINE-1]]:19: warning: backward branch (for loop) is ID-dependent due to ID function call and may cause performance degradation [altera-id-dependent-backward-branch]
+accumulator++;
+  }
+
+  int j = 0;
+  while (j < get_local_id(0)) {
+// CHECK-NOTES: :[[@LINE-1]]:10: warning: backward branch (while loop) is ID-dependent due to ID function call and may cause performance degradation [altera-id-dependent-backward-branch]
+accumulator++;
+  }
+
+  do {
+accumulator++;
+  } while (j < get_local_id(0));
+  // CHECK-NOTES: :[[@LINE-1]]:12: warning: backward branch (do loop) is ID-dependent due to ID function call and may cause performance degradation [altera-id-dependent-backward-branch]
+  
+  for (int i = 0; i < ThreadID2; i++) {
+// CHECK-NOTES: :[[@LINE-1]]:19: warning: backward branch (for loop) is ID-dependent due to variable reference to 'ThreadID2' and may cause performance degradation [altera-id-dependent-backward-branch]
+accumulator++;
+  }
+
+  while (j < ThreadID) {
+// CHECK-NOTES: :[[@LINE-1]]:10: warning: backward branch (while loop) is ID-dependent due to variable reference to 'ThreadID' and may cause performance degradation [altera-id-dependent-backward-branch]
+accumulator++;
+  }
+
+  do {
+accumulator++;
+  } while (j < ThreadID);
+  // CHECK-NOTES: :[[@LINE-1]]:12: warning: backward branch (do loop) is ID-dependent due to variable reference to 'ThreadID' and may cause performance degradation [altera-id-dependent-backward-branch]
+  
+  for (int i = 0; i < Example.IDDepField; i++) {
+// CHECK-NOTES: :[[@LINE-1]]:19: warning: backward branch (for loop) is ID-dependent due to member reference to 'IDDepField' and may cause performance degradation [altera-id-dependent-backward-branch]
+accumulator++;
+  }
+
+  while (j < Example.IDDepField) {
+// CHECK-NOTES: :[[@LINE-1]]:10: warning: backward branch (while loop) is ID-dependent due to member reference to 'IDDepField' and may cause performance degradation [altera-id-dependent-backward-branch]
+accumulator++;
+  }
+
+  do {
+accumulator++;
+  } while (j < Example.IDDepField);
+  // CHECK-NOTES: :[[@LINE-1]]:12: warning: backward branch (do loop) is ID-dependent due to member reference to 'IDDepField' and may cause performance degradation [altera-id-dependent-backward-branch]
+}
+
+void success() {
+  int accumulator = 0;
+
+  for (int i = 0; i < 1000; i++) {
+if (i < get_local_id(0)) {
+  accumulator++;
+}
+  }
+}
Index: clang-tools-extra/docs/clang-tidy/index.rst

[PATCH] D77131: [clang] Move branch-protection from CodeGenOptions to LangOptions

2020-04-01 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.

LGTM


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

https://reviews.llvm.org/D77131



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


[PATCH] D72241: [clang-tidy] new altera single work item barrier check

2020-04-01 Thread Frank Derry Wanye via Phabricator via cfe-commits
ffrankies updated this revision to Diff 254304.
ffrankies added a comment.

- Updated underlying repo to https://github.com/llvm/llvm-project
- Removed braces from one-line if-statements


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

https://reviews.llvm.org/D72241

Files:
  clang-tools-extra/clang-tidy/CMakeLists.txt
  clang-tools-extra/clang-tidy/ClangTidyForceLinker.h
  clang-tools-extra/clang-tidy/altera/AlteraTidyModule.cpp
  clang-tools-extra/clang-tidy/altera/CMakeLists.txt
  clang-tools-extra/clang-tidy/altera/SingleWorkItemBarrierCheck.cpp
  clang-tools-extra/clang-tidy/altera/SingleWorkItemBarrierCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/altera-single-work-item-barrier.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/index.rst
  clang-tools-extra/test/clang-tidy/checkers/altera-single-work-item-barrier.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/altera-single-work-item-barrier.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/altera-single-work-item-barrier.cpp
@@ -0,0 +1,294 @@
+// RUN: %check_clang_tidy -check-suffix=OLD %s altera-single-work-item-barrier %t -- -header-filter=.* "--" -cl-std=CL1.2 -c --include opencl-c.h -DOLD
+// RUN: %check_clang_tidy -check-suffix=NEW %s altera-single-work-item-barrier %t -- -header-filter=.* "--" -cl-std=CL2.0 -c --include opencl-c.h -DNEW
+// RUN: %check_clang_tidy -check-suffix=AOCOLD %s altera-single-work-item-barrier %t -- -config='{CheckOptions: [{key: altera-single-work-item-barrier.AOCVersion, value: 1701}]}' -header-filter=.* "--" -cl-std=CL1.2 -c --include opencl-c.h -DAOCOLD
+// RUN: %check_clang_tidy -check-suffix=AOCNEW %s altera-single-work-item-barrier %t -- -config='{CheckOptions: [{key: altera-single-work-item-barrier.AOCVersion, value: 1701}]}' -header-filter=.* "--" -cl-std=CL2.0 -c --include opencl-c.h -DAOCNEW
+
+#ifdef OLD
+void __kernel error_barrier_no_id(__global int * foo, int size) {
+  for (int j = 0; j < 256; j++) {
+	for (int i = 256; i < size; i+= 256) {
+  foo[j] += foo[j+i];
+}
+  }
+  barrier(CLK_GLOBAL_MEM_FENCE);
+  // CHECK-MESSAGES-OLD: :[[@LINE-7]]:15: warning: Kernel function 'error_barrier_no_id' does not call get_global_id or get_local_id and will be treated as single-work-item.{{[[:space:]]}}Barrier call at {{(\/)?([^\/\0]+(\/)?)+}}:[[@LINE-1]]:3 may error out [altera-single-work-item-barrier]
+  for (int i = 1; i < 256; i++) {
+	foo[0] += foo[i];
+  }
+}
+
+void __kernel success_barrier_global_id(__global int * foo, int size) {
+  barrier(CLK_GLOBAL_MEM_FENCE);
+  int tid = get_global_id(0);
+}
+
+void __kernel success_barrier_local_id(__global int * foo, int size) {
+  barrier(CLK_GLOBAL_MEM_FENCE);
+  int tid = get_local_id(0);
+}
+
+void __kernel success_barrier_both_ids(__global int * foo, int size) {
+  barrier(CLK_GLOBAL_MEM_FENCE);
+  int gid = get_global_id(0);
+  int lid = get_local_id(0);
+}
+
+void success_nokernel_barrier_no_id(__global int * foo, int size) {
+  for (int j = 0; j < 256; j++) {
+	for (int i = 256; i < size; i+= 256) {
+  foo[j] += foo[j+i];
+}
+  }
+  barrier(CLK_GLOBAL_MEM_FENCE);
+  for (int i = 1; i < 256; i++) {
+	foo[0] += foo[i];
+  }
+}
+
+void success_nokernel_barrier_global_id(__global int * foo, int size) {
+  barrier(CLK_GLOBAL_MEM_FENCE);
+  int tid = get_global_id(0);
+}
+
+void success_nokernel_barrier_local_id(__global int * foo, int size) {
+  barrier(CLK_GLOBAL_MEM_FENCE);
+  int tid = get_local_id(0);
+}
+
+void success_nokernel_barrier_both_ids(__global int * foo, int size) {
+  barrier(CLK_GLOBAL_MEM_FENCE);
+  int gid = get_global_id(0);
+  int lid = get_local_id(0);
+}
+#endif
+
+#ifdef NEW
+void __kernel error_barrier_no_id(__global int * foo, int size) {
+  for (int j = 0; j < 256; j++) {
+	for (int i = 256; i < size; i+= 256) {
+  foo[j] += foo[j+i];
+}
+  }
+  work_group_barrier(CLK_GLOBAL_MEM_FENCE);
+  // CHECK-MESSAGES-NEW: :[[@LINE-7]]:15: warning: Kernel function 'error_barrier_no_id' does not call get_global_id or get_local_id and will be treated as single-work-item.{{[[:space:]]}}Barrier call at {{(\/)?([^\/\0]+(\/)?)+}}:[[@LINE-1]]:3 may error out [altera-single-work-item-barrier]
+  for (int i = 1; i < 256; i++) {
+	foo[0] += foo[i];
+  }
+}
+
+void __kernel success_barrier_global_id(__global int * foo, int size) {
+  work_group_barrier(CLK_GLOBAL_MEM_FENCE);
+  int tid = get_global_id(0);
+}
+
+void __kernel success_barrier_local_id(__global int * foo, int size) {
+  work_group_barrier(CLK_GLOBAL_MEM_FENCE);
+  int tid = get_local_id(0);
+}
+
+void __kernel success_barrier_both_ids(__global int * foo, int size) {
+  work_group_barrier(CLK_GLOBAL_MEM_FENCE);
+  int gid = get_global_id(0);
+  int lid = get_local_id(0);
+}
+
+void success_nokernel_barrier_no_id(__global int * foo, int size) {
+  for (int j = 0; j < 256; j++) 

[PATCH] D72218: [clang-tidy] new altera kernel name restriction check

2020-04-01 Thread Frank Derry Wanye via Phabricator via cfe-commits
ffrankies updated this revision to Diff 254301.
ffrankies added a comment.

- Updated underlying repo to https://github.com/llvm/llvm-project
- Removed braces from one-line if-statements


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

https://reviews.llvm.org/D72218

Files:
  clang-tools-extra/clang-tidy/CMakeLists.txt
  clang-tools-extra/clang-tidy/ClangTidyForceLinker.h
  clang-tools-extra/clang-tidy/altera/AlteraTidyModule.cpp
  clang-tools-extra/clang-tidy/altera/CMakeLists.txt
  clang-tools-extra/clang-tidy/altera/KernelNameRestrictionCheck.cpp
  clang-tools-extra/clang-tidy/altera/KernelNameRestrictionCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/altera-kernel-name-restriction.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/index.rst
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/altera-kernel-name-restriction/KERNEL.cl
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/altera-kernel-name-restriction/VHDL.cl
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/altera-kernel-name-restriction/Verilog.cl
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/altera-kernel-name-restriction/kernel.cl
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/altera-kernel-name-restriction/kernel.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/altera-kernel-name-restriction/other_Verilog.cl
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/altera-kernel-name-restriction/otherdir/vhdl.cl
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/altera-kernel-name-restriction/otherthing.cl
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/altera-kernel-name-restriction/some/dir/kernel.cl
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/altera-kernel-name-restriction/some_kernel.cl
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/altera-kernel-name-restriction/somedir/verilog.cl
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/altera-kernel-name-restriction/thing.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/altera-kernel-name-restriction/vERILOG.cl
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/altera-kernel-name-restriction/verilog.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/altera-kernel-name-restriction/vhdl.CL
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/altera-kernel-name-restriction/vhdl.h
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/altera-kernel-name-restriction/vhdl_number_two.cl
  clang-tools-extra/test/clang-tidy/checkers/altera-kernel-name-restriction.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/altera-kernel-name-restriction.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/altera-kernel-name-restriction.cpp
@@ -0,0 +1,42 @@
+// RUN: %check_clang_tidy %s altera-kernel-name-restriction %t -- -- -I%S/Inputs/altera-kernel-name-restriction
+
+// These are the banned kernel filenames, and should trigger warnings
+#include "kernel.cl"
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: The imported kernel source file is named 'kernel.cl','Verilog.cl', or 'VHDL.cl', which could cause compilation errors. [altera-kernel-name-restriction]
+#include "Verilog.cl"
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: The imported kernel source file is named 'kernel.cl','Verilog.cl', or 'VHDL.cl', which could cause compilation errors. [altera-kernel-name-restriction]
+#include "VHDL.cl"
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: The imported kernel source file is named 'kernel.cl','Verilog.cl', or 'VHDL.cl', which could cause compilation errors. [altera-kernel-name-restriction]
+
+// The warning should be triggered regardless of capitalization
+#include "KERNEL.cl"
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: The imported kernel source file is named 'kernel.cl','Verilog.cl', or 'VHDL.cl', which could cause compilation errors. [altera-kernel-name-restriction]
+#include "vERILOG.cl"
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: The imported kernel source file is named 'kernel.cl','Verilog.cl', or 'VHDL.cl', which could cause compilation errors. [altera-kernel-name-restriction]
+#include "vhdl.CL"
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: The imported kernel source file is named 'kernel.cl','Verilog.cl', or 'VHDL.cl', which could cause compilation errors. [altera-kernel-name-restriction]
+
+// The warning should be triggered if the names are within a directory
+#include "some/dir/kernel.cl"
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: The imported kernel source file is named 'kernel.cl','Verilog.cl', or 'VHDL.cl', which could cause compilation errors. [altera-kernel-name-restriction]
+#include "somedir/verilog.cl"
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: The imported kernel source file is named 'kernel.cl','Verilog.cl', or 'VHDL.cl', which could cause compilation errors. [altera-kernel-name-restriction]
+#include "otherdir/vhdl.cl"
+// CHECK-MESSAGES: 

[PATCH] D72235: [clang-tidy] new altera unroll loops check

2020-04-01 Thread Frank Derry Wanye via Phabricator via cfe-commits
ffrankies updated this revision to Diff 254299.
ffrankies added a comment.

Addressed comments by @Eugene.Zelenko

- Removed braces from one-lien if statements
- Release notes on the altera unroll loops check now match the first line of 
documentation.


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

https://reviews.llvm.org/D72235

Files:
  clang-tools-extra/clang-tidy/CMakeLists.txt
  clang-tools-extra/clang-tidy/ClangTidyForceLinker.h
  clang-tools-extra/clang-tidy/altera/AlteraTidyModule.cpp
  clang-tools-extra/clang-tidy/altera/CMakeLists.txt
  clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
  clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/altera-unroll-loops.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/index.rst
  clang-tools-extra/test/clang-tidy/checkers/altera-unroll-loops.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/altera-unroll-loops.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/altera-unroll-loops.cpp
@@ -0,0 +1,359 @@
+// RUN: %check_clang_tidy %s altera-unroll-loops %t -- -config="{CheckOptions: [{key: "altera-unroll-loops.MaxLoopIterations", value: 50}]}" -header-filter=.* "--" --include opencl-c.h -cl-std=CL1.2 -c
+
+// Inner loops should be unrolled
+__kernel void nested_simple_loops(__global int *A) {
+for (int i = 0; i < 1000; ++i) {
+for (int j = 0; j < 2000; ++j) { 
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: The performance of the kernel could be improved by unrolling this loop with a #pragma unroll directive [altera-unroll-loops]
+A[0] += i + j;
+}
+}
+
+for (int i = 0; i < 1000; ++i) {
+int j = 0;
+while (j < 2000) {
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: The performance of the kernel could be improved by unrolling this loop with a #pragma unroll directive [altera-unroll-loops]
+A[1] += i + j;
+j++;
+}
+}
+
+for (int i = 0; i < 1000; ++i) {
+int j = 0; 
+do {
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: The performance of the kernel could be improved by unrolling this loop with a #pragma unroll directive [altera-unroll-loops]
+A[2] += i + j;
+j++;
+} while (j < 2000);
+}
+
+int i = 0;
+while (i < 1000) {
+for (int j = 0; j < 2000; ++j) {
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: The performance of the kernel could be improved by unrolling this loop with a #pragma unroll directive [altera-unroll-loops]
+A[3] += i + j;
+}
+i++;
+}
+
+i = 0;
+while (i < 1000) {
+int j = 0;
+while (j < 2000) {
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: The performance of the kernel could be improved by unrolling this loop with a #pragma unroll directive [altera-unroll-loops]
+A[4] += i + j;
+j++;
+}
+i++;
+}
+
+i = 0;
+while (i < 1000) {
+int j = 0;
+do {
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: The performance of the kernel could be improved by unrolling this loop with a #pragma unroll directive [altera-unroll-loops]
+A[5] += i + j;
+j++;
+} while (j < 2000);
+i++;
+}
+
+i = 0;
+do {
+for (int j = 0; j < 2000; ++j) {
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: The performance of the kernel could be improved by unrolling this loop with a #pragma unroll directive [altera-unroll-loops]
+A[6] += i + j;
+}
+i++;
+} while (i < 1000);
+
+i = 0;
+do {
+int j = 0;
+while (j < 2000) {
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: The performance of the kernel could be improved by unrolling this loop with a #pragma unroll directive [altera-unroll-loops]
+A[7] += i + j;
+j++;
+}
+i++;
+} while (i < 1000);
+
+i = 0;
+do {
+int j = 0;
+do {
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: The performance of the kernel could be improved by unrolling this loop with a #pragma unroll directive [altera-unroll-loops]
+A[8] += i + j;
+j++;
+} while (j < 2000);
+i++;
+} while (i < 1000);
+
+for (int i = 0; i < 100; ++i) {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: The performance of the kernel could be improved by unrolling this loop with a #pragma unroll directive [altera-unroll-loops]
+printf("Hello");
+}
+
+i = 0;
+while (i < 100) {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: The performance of the kernel could be improved by unrolling this loop with a #pragma unroll directive [altera-unroll-loops]
+i++;
+}
+
+i = 0;
+do {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: The performance of the 

[PATCH] D77233: [NFC] Refactoring PropertyAttributeKind for ObjCPropertyDecl and ObjCDeclSpec.

2020-04-01 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi updated this revision to Diff 254297.
plotfi added a comment.

Applying clang-format suggestions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77233

Files:
  clang/include/clang/AST/DeclObjC.h
  clang/include/clang/AST/DeclObjCCommon.h
  clang/include/clang/Sema/DeclSpec.h
  clang/lib/ARCMigrate/TransGCAttrs.cpp
  clang/lib/ARCMigrate/TransProperties.cpp
  clang/lib/ARCMigrate/TransZeroOutPropsInDealloc.cpp
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/DeclObjC.cpp
  clang/lib/AST/DeclPrinter.cpp
  clang/lib/AST/JSONNodeDumper.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/Analysis/BodyFarm.cpp
  clang/lib/CodeGen/CGObjC.cpp
  clang/lib/CodeGen/CGObjCGNU.cpp
  clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
  clang/lib/Frontend/Rewrite/RewriteObjC.cpp
  clang/lib/Parse/ParseObjc.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/lib/Sema/SemaExprObjC.cpp
  clang/lib/Sema/SemaObjCProperty.cpp
  clang/lib/Sema/SemaPseudoObject.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/tools/libclang/CIndex.cpp

Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -22,6 +22,7 @@
 #include "CursorVisitor.h"
 #include "clang-c/FatalErrorHandler.h"
 #include "clang/AST/Attr.h"
+#include "clang/AST/DeclObjCCommon.h"
 #include "clang/AST/Mangle.h"
 #include "clang/AST/OpenMPClause.h"
 #include "clang/AST/StmtVisitor.h"
@@ -8141,11 +8142,10 @@
 
   unsigned Result = CXObjCPropertyAttr_noattr;
   const ObjCPropertyDecl *PD = dyn_cast(getCursorDecl(C));
-  ObjCPropertyDecl::PropertyAttributeKind Attr =
-  PD->getPropertyAttributesAsWritten();
+  ObjCPropertyAttributeKind Attr = PD->getPropertyAttributesAsWritten();
 
 #define SET_CXOBJCPROP_ATTR(A) \
-  if (Attr & ObjCPropertyDecl::OBJC_PR_##A)\
+  if (Attr & ObjCPropertyAttributeKind::OBJC_PR_##A)   \
   Result |= CXObjCPropertyAttr_##A
   SET_CXOBJCPROP_ATTR(readonly);
   SET_CXOBJCPROP_ATTR(getter);
Index: clang/lib/Serialization/ASTReaderDecl.cpp
===
--- clang/lib/Serialization/ASTReaderDecl.cpp
+++ clang/lib/Serialization/ASTReaderDecl.cpp
@@ -1279,10 +1279,9 @@
   QualType T = Record.readType();
   TypeSourceInfo *TSI = readTypeSourceInfo();
   D->setType(T, TSI);
-  D->setPropertyAttributes(
-  (ObjCPropertyDecl::PropertyAttributeKind)Record.readInt());
+  D->setPropertyAttributes((ObjCPropertyAttributeKind)Record.readInt());
   D->setPropertyAttributesAsWritten(
-  (ObjCPropertyDecl::PropertyAttributeKind)Record.readInt());
+  (ObjCPropertyAttributeKind)Record.readInt());
   D->setPropertyImplementation(
   (ObjCPropertyDecl::PropertyControl)Record.readInt());
   DeclarationName GetterName = Record.readDeclarationName();
Index: clang/lib/Sema/SemaPseudoObject.cpp
===
--- clang/lib/Sema/SemaPseudoObject.cpp
+++ clang/lib/Sema/SemaPseudoObject.cpp
@@ -585,7 +585,7 @@
   QualType T;
   if (RefExpr->isExplicitProperty()) {
 const ObjCPropertyDecl *Prop = RefExpr->getExplicitProperty();
-if (Prop->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_weak)
+if (Prop->getPropertyAttributes() & ObjCPropertyAttributeKind::OBJC_PR_weak)
   return true;
 
 T = Prop->getType();
Index: clang/lib/Sema/SemaObjCProperty.cpp
===
--- clang/lib/Sema/SemaObjCProperty.cpp
+++ clang/lib/Sema/SemaObjCProperty.cpp
@@ -35,24 +35,23 @@
 ///
 /// Returns OCL_None if the attributes as stated do not imply an ownership.
 /// Never returns OCL_Autoreleasing.
-static Qualifiers::ObjCLifetime getImpliedARCOwnership(
-   ObjCPropertyDecl::PropertyAttributeKind attrs,
-QualType type) {
+static Qualifiers::ObjCLifetime
+getImpliedARCOwnership(ObjCPropertyAttributeKind attrs, QualType type) {
   // retain, strong, copy, weak, and unsafe_unretained are only legal
   // on properties of retainable pointer type.
-  if (attrs & (ObjCPropertyDecl::OBJC_PR_retain |
-   ObjCPropertyDecl::OBJC_PR_strong |
-   ObjCPropertyDecl::OBJC_PR_copy)) {
+  if (attrs & (ObjCPropertyAttributeKind::OBJC_PR_retain |
+   ObjCPropertyAttributeKind::OBJC_PR_strong |
+   ObjCPropertyAttributeKind::OBJC_PR_copy)) {
 return Qualifiers::OCL_Strong;
-  } else if (attrs & ObjCPropertyDecl::OBJC_PR_weak) {
+  } else if (attrs & ObjCPropertyAttributeKind::OBJC_PR_weak) {
 return Qualifiers::OCL_Weak;
-  } else if (attrs & ObjCPropertyDecl::OBJC_PR_unsafe_unretained) {
+  } else if (attrs & 

[PATCH] D77240: [CUDA] Add missing cmath overloads

2020-04-01 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert created this revision.
jdoerfert added a reviewer: tra.
Herald added subscribers: bollu, yaxunl.
Herald added a project: clang.

Some function overloads for floats were missing, found by running a test
suite [0] with the OpenMP overlay.

[0] https://github.com/TApplencourt/OmpVal

Depends on D77239 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77240

Files:
  clang/lib/Headers/__clang_cuda_cmath.h


Index: clang/lib/Headers/__clang_cuda_cmath.h
===
--- clang/lib/Headers/__clang_cuda_cmath.h
+++ clang/lib/Headers/__clang_cuda_cmath.h
@@ -57,15 +57,24 @@
 __DEVICE__ const double abs(const double __x) { return ::fabs((double)__x); }
 #endif
 __DEVICE__ float acos(float __x) { return ::acosf(__x); }
+__DEVICE__ float acosh(float __x) { return ::acoshf(__x); }
 __DEVICE__ float asin(float __x) { return ::asinf(__x); }
+__DEVICE__ float asinh(float __x) { return ::asinhf(__x); }
 __DEVICE__ float atan(float __x) { return ::atanf(__x); }
+__DEVICE__ float atanh(float __x) { return ::atanhf(__x); }
 __DEVICE__ float atan2(float __x, float __y) { return ::atan2f(__x, __y); }
+__DEVICE__ float cbrt(float __x) { return ::cbrtf(__x); }
 __DEVICE__ float ceil(float __x) { return ::ceilf(__x); }
 __DEVICE__ float cos(float __x) { return ::cosf(__x); }
 __DEVICE__ float cosh(float __x) { return ::coshf(__x); }
+__DEVICE__ float erf(float __x) { return ::erff(__x); }
+__DEVICE__ float erfc(float __x) { return ::erfcf(__x); }
 __DEVICE__ float exp(float __x) { return ::expf(__x); }
+__DEVICE__ float exp2(float __x) { return ::exp2f(__x); }
+__DEVICE__ float expm1(float __x) { return ::expm1f(__x); }
 __DEVICE__ float fabs(float __x) __NOEXCEPT { return ::fabsf(__x); }
 __DEVICE__ float floor(float __x) { return ::floorf(__x); }
+__DEVICE__ float fdim(float __x, float __y) { return ::fdimf(__x, __y); }
 __DEVICE__ float fmod(float __x, float __y) { return ::fmodf(__x, __y); }
 // TODO: remove when variant is supported
 #ifndef _OPENMP
@@ -82,6 +91,8 @@
   return ::frexpf(__arg, __exp);
 }
 
+__DEVICE__ float hypot(float __x, float __y) { return ::hypotf(__x, __y); }
+__DEVICE__ int ilogb(float __x) { return ::ilogbf(__x); }
 // For inscrutable reasons, the CUDA headers define these functions for us on
 // Windows.
 #ifndef _MSC_VER
@@ -137,9 +148,18 @@
 __DEVICE__ float ldexp(float __arg, int __exp) {
   return ::ldexpf(__arg, __exp);
 }
+__DEVICE__ float lgamma(float __x) { return ::lgammaf(__x); }
+__DEVICE__ long long int llrint(float __x) { return ::llrintf(__x); }
+__DEVICE__ long long int llround(float __x) { return ::llroundf(__x); }
 __DEVICE__ float log(float __x) { return ::logf(__x); }
 __DEVICE__ float log10(float __x) { return ::log10f(__x); }
+__DEVICE__ float log1p(float __x) { return ::log1pf(__x); }
+__DEVICE__ float log2(float __x) { return ::log2f(__x); }
+__DEVICE__ float logb(float __x) { return ::logbf(__x); }
+__DEVICE__ long int lrint(float __x) { return ::lrintf(__x); }
+__DEVICE__ long int lround(float __x) { return ::lroundf(__x); }
 __DEVICE__ float modf(float __x, float *__iptr) { return ::modff(__x, __iptr); 
}
+__DEVICE__ float nextafter(float __x, float __y) { return ::nextafterf(__x, 
__y); }
 __DEVICE__ float pow(float __base, float __exp) {
   return ::powf(__base, __exp);
 }
@@ -149,6 +169,9 @@
 __DEVICE__ double pow(double __base, int __iexp) {
   return ::powi(__base, __iexp);
 }
+__DEVICE__ float remainder(float __x, float __y) { return ::remainderf(__x, 
__y); }
+__DEVICE__ float scalbln(float __x, long int __y) { return ::scalblnf(__x, 
__y); }
+__DEVICE__ float scalbn(float __x, int __y) { return ::scalbnf(__x, __y); }
 __DEVICE__ bool signbit(float __x) { return ::__signbitf(__x); }
 __DEVICE__ bool signbit(double __x) { return ::__signbitd(__x); }
 __DEVICE__ float sin(float __x) { return ::sinf(__x); }
@@ -156,6 +179,7 @@
 __DEVICE__ float sqrt(float __x) { return ::sqrtf(__x); }
 __DEVICE__ float tan(float __x) { return ::tanf(__x); }
 __DEVICE__ float tanh(float __x) { return ::tanhf(__x); }
+__DEVICE__ float tgamma(float __x) { return ::tgammaf(__x); }
 
 // Notably missing above is nexttoward.  We omit it because
 // libdevice doesn't provide an implementation, and we don't want to be in the


Index: clang/lib/Headers/__clang_cuda_cmath.h
===
--- clang/lib/Headers/__clang_cuda_cmath.h
+++ clang/lib/Headers/__clang_cuda_cmath.h
@@ -57,15 +57,24 @@
 __DEVICE__ const double abs(const double __x) { return ::fabs((double)__x); }
 #endif
 __DEVICE__ float acos(float __x) { return ::acosf(__x); }
+__DEVICE__ float acosh(float __x) { return ::acoshf(__x); }
 __DEVICE__ float asin(float __x) { return ::asinf(__x); }
+__DEVICE__ float asinh(float __x) { return ::asinhf(__x); }
 __DEVICE__ float atan(float __x) { return ::atanf(__x); }
+__DEVICE__ float atanh(float __x) { return ::atanhf(__x); }

[PATCH] D77238: [CUDA][NFC] Split math.h functions out of __clang_cuda_device_functions.h

2020-04-01 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert created this revision.
jdoerfert added a reviewer: tra.
Herald added subscribers: bollu, yaxunl, mgorny.
Herald added a project: clang.
jdoerfert added a child revision: D77239: [CUDA][NFCI] Use unqualified lookup 
for math functions.

This is not supported to change anything but allow us to reuse the math
functions separately from the device functions, e.g., source them at
different times. This will be used by the OpenMP overlay.

This also adds two `return` keywords that were missing.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77238

Files:
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/__clang_cuda_device_functions.h
  clang/lib/Headers/__clang_cuda_math.h
  clang/lib/Headers/__clang_cuda_runtime_wrapper.h

Index: clang/lib/Headers/__clang_cuda_runtime_wrapper.h
===
--- clang/lib/Headers/__clang_cuda_runtime_wrapper.h
+++ clang/lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -141,11 +141,12 @@
 // to provide our own.
 #include <__clang_cuda_libdevice_declares.h>
 
-// Wrappers for many device-side standard library functions became compiler
-// builtins in CUDA-9 and have been removed from the CUDA headers. Clang now
-// provides its own implementation of the wrappers.
+// Wrappers for many device-side standard library functions, incl. math
+// functions, became compiler builtins in CUDA-9 and have been removed from the
+// CUDA headers. Clang now provides its own implementation of the wrappers.
 #if CUDA_VERSION >= 9000
 #include <__clang_cuda_device_functions.h>
+#include <__clang_cuda_math.h>
 #endif
 
 // __THROW is redefined to be empty by device_functions_decls.h in CUDA. Clang's
Index: clang/lib/Headers/__clang_cuda_math.h
===
--- /dev/null
+++ clang/lib/Headers/__clang_cuda_math.h
@@ -0,0 +1,363 @@
+/*=== __clang_cuda_math.h - Device-side CUDA math support --===
+ *
+ * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+ * See https://llvm.org/LICENSE.txt for license information.
+ * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+ *
+ *===---===
+ */
+#ifndef __CLANG_CUDA_MATH_H__
+#define __CLANG_CUDA_MATH_H__
+#ifndef __CUDA__
+#error "This file is for CUDA compilation only."
+#endif
+
+#ifndef _OPENMP
+#if CUDA_VERSION < 9000
+#error This file is intended to be used with CUDA-9+ only.
+#endif
+#endif
+
+// __DEVICE__ is a helper macro with common set of attributes for the wrappers
+// we implement in this file. We need static in order to avoid emitting unused
+// functions and __forceinline__ helps inlining these wrappers at -O1.
+#pragma push_macro("__DEVICE__")
+#ifdef _OPENMP
+#define __DEVICE__ static constexpr __attribute__((always_inline, nothrow))
+#else
+#define __DEVICE__ static __device__ __forceinline__
+#endif
+
+// Specialized version of __DEVICE__ for functions with void return type. Needed
+// because the OpenMP overlay requires constexpr functions here but prior to
+// c++14 void return functions could not be constexpr.
+#pragma push_macro("__DEVICE_VOID__")
+#ifdef _OPENMP
+#if defined(__cplusplus) && __cplusplus >= 201402L
+#define __DEVICE_VOID__ static constexpr __attribute__((always_inline, nothrow))
+#else
+#define __DEVICE_VOID__ static __attribute__((always_inline, nothrow))
+#endif
+#else
+#define __DEVICE_VOID__ __DEVICE__
+#endif
+
+// libdevice provides fast low precision and slow full-recision implementations
+// for some functions. Which one gets selected depends on
+// __CLANG_CUDA_APPROX_TRANSCENDENTALS__ which gets defined by clang if
+// -ffast-math or -fcuda-approx-transcendentals are in effect.
+#pragma push_macro("__FAST_OR_SLOW")
+#if defined(__CLANG_CUDA_APPROX_TRANSCENDENTALS__)
+#define __FAST_OR_SLOW(fast, slow) fast
+#else
+#define __FAST_OR_SLOW(fast, slow) slow
+#endif
+
+__DEVICE__ int abs(int __a) { return __nv_abs(__a); }
+__DEVICE__ double fabs(double __a) { return __nv_fabs(__a); }
+__DEVICE__ double acos(double __a) { return __nv_acos(__a); }
+__DEVICE__ float acosf(float __a) { return __nv_acosf(__a); }
+__DEVICE__ double acosh(double __a) { return __nv_acosh(__a); }
+__DEVICE__ float acoshf(float __a) { return __nv_acoshf(__a); }
+__DEVICE__ double asin(double __a) { return __nv_asin(__a); }
+__DEVICE__ float asinf(float __a) { return __nv_asinf(__a); }
+__DEVICE__ double asinh(double __a) { return __nv_asinh(__a); }
+__DEVICE__ float asinhf(float __a) { return __nv_asinhf(__a); }
+__DEVICE__ double atan(double __a) { return __nv_atan(__a); }
+__DEVICE__ double atan2(double __a, double __b) { return __nv_atan2(__a, __b); }
+__DEVICE__ float atan2f(float __a, float __b) { return __nv_atan2f(__a, __b); }
+__DEVICE__ float atanf(float __a) { return __nv_atanf(__a); }
+__DEVICE__ double atanh(double __a) { return __nv_atanh(__a); }
+__DEVICE__ float 

[PATCH] D77239: [CUDA][NFCI] Use unqualified lookup for math functions

2020-04-01 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert created this revision.
jdoerfert added a reviewer: tra.
Herald added subscribers: bollu, yaxunl.
Herald added a project: clang.
jdoerfert added a child revision: D77240: [CUDA] Add missing cmath overloads.

The other macro uses a unqualified lookup already and the qualified one
will cause problems in the OpenMP overlay.

Depends on D77238 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77239

Files:
  clang/lib/Headers/__clang_cuda_cmath.h


Index: clang/lib/Headers/__clang_cuda_cmath.h
===
--- clang/lib/Headers/__clang_cuda_cmath.h
+++ clang/lib/Headers/__clang_cuda_cmath.h
@@ -191,7 +191,7 @@
   typename __clang_cuda_enable_if::is_integer,
\
   __retty>::type   
\
   __fn(__T __x) {  
\
-return ::__fn((double)__x);
\
+return __fn((double)__x);  
\
   }
 
 // Defines an overload of __fn that accepts one two arithmetic arguments, calls


Index: clang/lib/Headers/__clang_cuda_cmath.h
===
--- clang/lib/Headers/__clang_cuda_cmath.h
+++ clang/lib/Headers/__clang_cuda_cmath.h
@@ -191,7 +191,7 @@
   typename __clang_cuda_enable_if::is_integer,\
   __retty>::type   \
   __fn(__T __x) {  \
-return ::__fn((double)__x);\
+return __fn((double)__x);  \
   }
 
 // Defines an overload of __fn that accepts one two arithmetic arguments, calls
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [clang] db92719 - DebugInfo: Defaulted non-type template parameters of bool type

2020-04-01 Thread David Blaikie via cfe-commits
On Wed, Apr 1, 2020 at 1:21 PM David Blaikie via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

>
> Author: David Blaikie
> Date: 2020-04-01T13:21:13-07:00
> New Revision: db92719c1d17f5052e7cd1309b0e1e92240f47be
>
> URL:
> https://github.com/llvm/llvm-project/commit/db92719c1d17f5052e7cd1309b0e1e92240f47be
> DIFF:
> https://github.com/llvm/llvm-project/commit/db92719c1d17f5052e7cd1309b0e1e92240f47be.diff
>
> LOG: DebugInfo: Defaulted non-type template parameters of bool type
>
> Caused an assertion due to mismatched bit widths - this seems like the
> right API to use for a possibly width-varying equality test. Though
> certainly open to some post-commit review feedback if there's a more
> suitable way to do this comparison/test.
>
> Added:
>
>
> Modified:
> clang/lib/CodeGen/CGDebugInfo.cpp
> clang/test/CodeGenCXX/debug-info-template-parameter.cpp
>
> Removed:
>
>
>
>
> 
> diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp
> b/clang/lib/CodeGen/CGDebugInfo.cpp
> index 49c57e9860a6..6d3c2ad66cdc 100644
> --- a/clang/lib/CodeGen/CGDebugInfo.cpp
> +++ b/clang/lib/CodeGen/CGDebugInfo.cpp
> @@ -1817,9 +1817,10 @@ CGDebugInfo::CollectTemplateParams(const
> TemplateParameterList *TPList,
>  if (auto *templateType =
>
>  dyn_cast_or_null(TPList->getParam(i)))
>if (templateType->hasDefaultArgument())
> -defaultParameter =
> +defaultParameter = llvm::APSInt::isSameValue(
>  templateType->getDefaultArgument()->EvaluateKnownConstInt(
> -CGM.getContext()) == TA.getAsIntegral();
> +CGM.getContext()),
> +TA.getAsIntegral());
>

Hey Richard - is this the best way to do this? Are there other ways to test
if a default argument is the same as the actual template parameter we
could/should be doing here?


>
>TemplateParams.push_back(DBuilder.createTemplateValueParameter(
>TheCU, Name, TTy, defaultParameter,
>
> diff  --git a/clang/test/CodeGenCXX/debug-info-template-parameter.cpp
> b/clang/test/CodeGenCXX/debug-info-template-parameter.cpp
> index 95e7a187fe10..c38c535d8b06 100644
> --- a/clang/test/CodeGenCXX/debug-info-template-parameter.cpp
> +++ b/clang/test/CodeGenCXX/debug-info-template-parameter.cpp
> @@ -8,22 +8,24 @@
>
>  // CHECK: DILocalVariable(name: "f1", {{.*}}, type:
> ![[TEMPLATE_TYPE:[0-9]+]]
>  // CHECK: [[TEMPLATE_TYPE]] = {{.*}}!DICompositeType({{.*}},
> templateParams: ![[F1_TYPE:[0-9]+]]
> -// CHECK: [[F1_TYPE]] = !{![[FIRST:[0-9]+]], ![[SECOND:[0-9]+]]}
> +// CHECK: [[F1_TYPE]] = !{![[FIRST:[0-9]+]], ![[SECOND:[0-9]+]],
> ![[THIRD:[0-9]+]]}
>  // CHECK: [[FIRST]] = !DITemplateTypeParameter(name: "T", type:
> !{{[0-9]*}})
>  // CHECK: [[SECOND]] = !DITemplateValueParameter(name: "i", type:
> !{{[0-9]*}}, value: i32 6)
> +// CHECK: [[THIRD]] = !DITemplateValueParameter(name: "b", type:
> !{{[0-9]*}}, value: i8 0)
>
>  // CHECK: DILocalVariable(name: "f2", {{.*}}, type:
> ![[TEMPLATE_TYPE:[0-9]+]]
>  // CHECK: [[TEMPLATE_TYPE]] = {{.*}}!DICompositeType({{.*}},
> templateParams: ![[F2_TYPE:[0-9]+]]
> -// CHECK: [[F2_TYPE]] = !{![[FIRST:[0-9]+]], ![[SECOND:[0-9]+]]}
> +// CHECK: [[F2_TYPE]] = !{![[FIRST:[0-9]+]], ![[SECOND:[0-9]+]],
> ![[THIRD:[0-9]+]]}
>  // CHECK: [[FIRST]] = !DITemplateTypeParameter(name: "T", type:
> !{{[0-9]*}}, defaulted: true)
>  // CHECK: [[SECOND]] = !DITemplateValueParameter(name: "i", type:
> !{{[0-9]*}}, defaulted: true, value: i32 3)
> +// CHECK: [[THIRD]] = !DITemplateValueParameter(name: "b", type:
> !{{[0-9]*}}, defaulted: true, value: i8 1)
>
> -template 
> +template 
>  class foo {
>  };
>
>  int main() {
> -  foo f1;
> +  foo f1;
>foo<> f2;
>return 0;
>  }
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 6e916b5 - Updating the documentation for the noescape attribute.

2020-04-01 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2020-04-01T16:21:37-04:00
New Revision: 6e916b5860950fee2661ded847abe551f5259ec4

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

LOG: Updating the documentation for the noescape attribute.

A question came up from a glibc maintainer as to whether it was permissible to
free a pointer marked [[clang::noescape]], and after investigation, I
determined that this is allowed. This updates the documentation in case others
have the same question.

Added: 


Modified: 
clang/include/clang/Basic/AttrDocs.td

Removed: 




diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 2c89dc6f4952..bdc47b43c34b 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -140,7 +140,8 @@ def NoEscapeDocs : Documentation {
 the compiler that the pointer cannot escape: that is, no reference to the 
object
 the pointer points to that is derived from the parameter value will survive
 after the function returns. Users are responsible for making sure parameters
-annotated with ``noescape`` do not actuallly escape.
+annotated with ``noescape`` do not actuallly escape. Calling ``free()`` on such
+a parameter does not constitute an escape.
 
 For example:
 



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


[clang] db92719 - DebugInfo: Defaulted non-type template parameters of bool type

2020-04-01 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2020-04-01T13:21:13-07:00
New Revision: db92719c1d17f5052e7cd1309b0e1e92240f47be

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

LOG: DebugInfo: Defaulted non-type template parameters of bool type

Caused an assertion due to mismatched bit widths - this seems like the
right API to use for a possibly width-varying equality test. Though
certainly open to some post-commit review feedback if there's a more
suitable way to do this comparison/test.

Added: 


Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp
clang/test/CodeGenCXX/debug-info-template-parameter.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 49c57e9860a6..6d3c2ad66cdc 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1817,9 +1817,10 @@ CGDebugInfo::CollectTemplateParams(const 
TemplateParameterList *TPList,
 if (auto *templateType =
 dyn_cast_or_null(TPList->getParam(i)))
   if (templateType->hasDefaultArgument())
-defaultParameter =
+defaultParameter = llvm::APSInt::isSameValue(
 templateType->getDefaultArgument()->EvaluateKnownConstInt(
-CGM.getContext()) == TA.getAsIntegral();
+CGM.getContext()),
+TA.getAsIntegral());
 
   TemplateParams.push_back(DBuilder.createTemplateValueParameter(
   TheCU, Name, TTy, defaultParameter,

diff  --git a/clang/test/CodeGenCXX/debug-info-template-parameter.cpp 
b/clang/test/CodeGenCXX/debug-info-template-parameter.cpp
index 95e7a187fe10..c38c535d8b06 100644
--- a/clang/test/CodeGenCXX/debug-info-template-parameter.cpp
+++ b/clang/test/CodeGenCXX/debug-info-template-parameter.cpp
@@ -8,22 +8,24 @@
 
 // CHECK: DILocalVariable(name: "f1", {{.*}}, type: ![[TEMPLATE_TYPE:[0-9]+]]
 // CHECK: [[TEMPLATE_TYPE]] = {{.*}}!DICompositeType({{.*}}, templateParams: 
![[F1_TYPE:[0-9]+]]
-// CHECK: [[F1_TYPE]] = !{![[FIRST:[0-9]+]], ![[SECOND:[0-9]+]]}
+// CHECK: [[F1_TYPE]] = !{![[FIRST:[0-9]+]], ![[SECOND:[0-9]+]], 
![[THIRD:[0-9]+]]}
 // CHECK: [[FIRST]] = !DITemplateTypeParameter(name: "T", type: !{{[0-9]*}})
 // CHECK: [[SECOND]] = !DITemplateValueParameter(name: "i", type: !{{[0-9]*}}, 
value: i32 6)
+// CHECK: [[THIRD]] = !DITemplateValueParameter(name: "b", type: !{{[0-9]*}}, 
value: i8 0)
 
 // CHECK: DILocalVariable(name: "f2", {{.*}}, type: ![[TEMPLATE_TYPE:[0-9]+]]
 // CHECK: [[TEMPLATE_TYPE]] = {{.*}}!DICompositeType({{.*}}, templateParams: 
![[F2_TYPE:[0-9]+]]
-// CHECK: [[F2_TYPE]] = !{![[FIRST:[0-9]+]], ![[SECOND:[0-9]+]]}
+// CHECK: [[F2_TYPE]] = !{![[FIRST:[0-9]+]], ![[SECOND:[0-9]+]], 
![[THIRD:[0-9]+]]}
 // CHECK: [[FIRST]] = !DITemplateTypeParameter(name: "T", type: !{{[0-9]*}}, 
defaulted: true)
 // CHECK: [[SECOND]] = !DITemplateValueParameter(name: "i", type: !{{[0-9]*}}, 
defaulted: true, value: i32 3)
+// CHECK: [[THIRD]] = !DITemplateValueParameter(name: "b", type: !{{[0-9]*}}, 
defaulted: true, value: i8 1)
 
-template 
+template 
 class foo {
 };
 
 int main() {
-  foo f1;
+  foo f1;
   foo<> f2;
   return 0;
 }



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


[PATCH] D66564: [clang-tidy] new altera struct pack align check

2020-04-01 Thread Frank Derry Wanye via Phabricator via cfe-commits
ffrankies updated this revision to Diff 254277.
ffrankies added a comment.

Addressed comments by @aaron.ballman

You're right, we don't want this to trigger on template instantiations and 
structs declared in system headers.

- Check no longer triggers on template instantiations
- Check no longer triggers on structs declared in system headers

To add to @Eugene.Zelenko's comment: there are 5 patches for the `altera` 
module including this one (D72235 , D72218 
, D72241 , 
and D70094 ). We also have 2 checks that have 
been put on the backlog due to time/funding constraints, but could be 
resurrected if that changes.


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

https://reviews.llvm.org/D66564

Files:
  clang-tools-extra/clang-tidy/CMakeLists.txt
  clang-tools-extra/clang-tidy/ClangTidyForceLinker.h
  clang-tools-extra/clang-tidy/altera/AlteraTidyModule.cpp
  clang-tools-extra/clang-tidy/altera/CMakeLists.txt
  clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp
  clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/altera-struct-pack-align.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/index.rst
  clang-tools-extra/test/clang-tidy/checkers/altera-struct-pack-align.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/altera-struct-pack-align.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/altera-struct-pack-align.cpp
@@ -0,0 +1,96 @@
+// RUN: %check_clang_tidy %s altera-struct-pack-align %t -- -header-filter=.*
+
+// Struct needs both alignment and packing
+struct error {
+  char a;
+  double b;
+  char c;
+};
+// CHECK-MESSAGES: :[[@LINE-5]]:8: warning: accessing fields in struct 'error' is inefficient due to padding; only needs 10 bytes but is using 24 bytes [altera-struct-pack-align]
+// CHECK-MESSAGES: :[[@LINE-6]]:8: note: use "__attribute__((packed))" to reduce the amount of padding applied to struct 'error'
+// CHECK-MESSAGES: :[[@LINE-7]]:8: warning: accessing fields in struct 'error' is inefficient due to poor alignment; currently aligned to 8 bytes, but recommended alignment is 16 bytes [altera-struct-pack-align]
+// CHECK-MESSAGES: :[[@LINE-8]]:8: note: use "__attribute__((aligned(16)))" to align struct 'error' to 16 bytes
+// CHECK-FIXES: __attribute__((packed))
+// CHECK-FIXES: __attribute__((aligned(16)));
+
+// Struct is explicitly packed, but needs alignment
+struct error_packed {
+  char a;
+  double b;
+  char c;
+} __attribute__((packed));
+// CHECK-MESSAGES: :[[@LINE-5]]:8: warning: accessing fields in struct 'error_packed' is inefficient due to poor alignment; currently aligned to 1 bytes, but recommended alignment is 16 bytes [altera-struct-pack-align]
+// CHECK-MESSAGES: :[[@LINE-6]]:8: note: use "__attribute__((aligned(16)))" to align struct 'error_packed' to 16 bytes
+// CHECK-FIXES: __attribute__((aligned(16)))
+
+// Struct is properly packed, but needs alignment
+struct align_only {
+  char a;
+  char b;
+  char c;
+  char d;
+  int e;
+  double f;
+};
+// CHECK-MESSAGES: :[[@LINE-8]]:8: warning: accessing fields in struct 'align_only' is inefficient due to poor alignment; currently aligned to 8 bytes, but recommended alignment is 16 bytes [altera-struct-pack-align]
+// CHECK-MESSAGES: :[[@LINE-9]]:8: note: use "__attribute__((aligned(16)))" to align struct 'align_only' to 16 bytes
+// CHECK-FIXES: __attribute__((aligned(16)));
+
+// Struct is perfectly packed but wrongly aligned
+struct bad_align {
+  char a;
+  double b;
+  char c;
+} __attribute__((packed)) __attribute__((aligned(8)));
+// CHECK-MESSAGES: :[[@LINE-5]]:8: warning: accessing fields in struct 'bad_align' is inefficient due to poor alignment; currently aligned to 8 bytes, but recommended alignment is 16 bytes [altera-struct-pack-align]
+// CHECK-MESSAGES: :[[@LINE-6]]:8: note: use "__attribute__((aligned(16)))" to align struct 'bad_align' to 16 bytes
+// CHECK-FIXES: __attribute__((aligned(16)));
+
+struct bad_align2 {
+  char a;
+  double b;
+  char c;
+} __attribute__((packed)) __attribute__((aligned(32)));
+// CHECK-MESSAGES: :[[@LINE-5]]:8: warning: accessing fields in struct 'bad_align2' is inefficient due to poor alignment; currently aligned to 32 bytes, but recommended alignment is 16 bytes [altera-struct-pack-align]
+// CHECK-MESSAGES: :[[@LINE-6]]:8: note: use "__attribute__((aligned(16)))" to align struct 'bad_align2' to 16 bytes
+// CHECK-FIXES: __attribute__((aligned(16)));
+
+struct bad_align3 {
+  char a;
+  double b;
+  char c;
+} __attribute__((packed)) __attribute__((aligned(4)));
+// CHECK-MESSAGES: :[[@LINE-5]]:8: warning: accessing fields in struct 'bad_align3' is inefficient due to poor alignment; currently 

[PATCH] D76812: [X86] Add Indirect Thunk Support to X86 to mitigate Load Value Injection (LVI) [3/3]

2020-04-01 Thread Scott Constable via Phabricator via cfe-commits
sconstab updated this revision to Diff 254276.
sconstab added a comment.

@craig.topper I think that removing spurious MBBs is not really necessary 
because the emitted machine code doesn't contain the spurious MBBs, from what I 
have observed. I added the check anyways, if only because others may look at 
this discrepancy and have the same question.


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

https://reviews.llvm.org/D76812

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Arch/X86.cpp
  llvm/lib/Target/X86/X86.td
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/lib/Target/X86/X86IndirectThunks.cpp
  llvm/lib/Target/X86/X86Subtarget.h
  llvm/test/CodeGen/X86/lvi-hardening-indirectbr.ll

Index: llvm/test/CodeGen/X86/lvi-hardening-indirectbr.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/lvi-hardening-indirectbr.ll
@@ -0,0 +1,281 @@
+; RUN: llc -verify-machineinstrs -mtriple=x86_64-unknown -mattr=+lvi-cfi < %s | FileCheck %s --check-prefix=X64
+; RUN: llc -verify-machineinstrs -mtriple=x86_64-unknown -mattr=+lvi-cfi -O0 < %s | FileCheck %s --check-prefix=X64FAST
+;
+; Note that a lot of this code was lifted from retpoline.ll.
+
+declare void @bar(i32)
+
+; Test a simple indirect call and tail call.
+define void @icall_reg(void (i32)* %fp, i32 %x) {
+entry:
+  tail call void @bar(i32 %x)
+  tail call void %fp(i32 %x)
+  tail call void @bar(i32 %x)
+  tail call void %fp(i32 %x)
+  ret void
+}
+
+; X64-LABEL: icall_reg:
+; X64-DAG:   movq %rdi, %[[fp:[^ ]*]]
+; X64-DAG:   movl %esi, %[[x:[^ ]*]]
+; X64:   movl %esi, %edi
+; X64:   callq bar
+; X64-DAG:   movl %[[x]], %edi
+; X64-DAG:   movq %[[fp]], %r11
+; X64:   callq __llvm_lvi_thunk_r11
+; X64:   movl %[[x]], %edi
+; X64:   callq bar
+; X64-DAG:   movl %[[x]], %edi
+; X64-DAG:   movq %[[fp]], %r11
+; X64:   jmp __llvm_lvi_thunk_r11 # TAILCALL
+
+; X64FAST-LABEL: icall_reg:
+; X64FAST:   callq bar
+; X64FAST:   callq __llvm_lvi_thunk_r11
+; X64FAST:   callq bar
+; X64FAST:   jmp __llvm_lvi_thunk_r11 # TAILCALL
+
+
+@global_fp = external global void (i32)*
+
+; Test an indirect call through a global variable.
+define void @icall_global_fp(i32 %x, void (i32)** %fpp) #0 {
+  %fp1 = load void (i32)*, void (i32)** @global_fp
+  call void %fp1(i32 %x)
+  %fp2 = load void (i32)*, void (i32)** @global_fp
+  tail call void %fp2(i32 %x)
+  ret void
+}
+
+; X64-LABEL: icall_global_fp:
+; X64-DAG:   movl %edi, %[[x:[^ ]*]]
+; X64-DAG:   movq global_fp(%rip), %r11
+; X64:   callq __llvm_lvi_thunk_r11
+; X64-DAG:   movl %[[x]], %edi
+; X64-DAG:   movq global_fp(%rip), %r11
+; X64:   jmp __llvm_lvi_thunk_r11 # TAILCALL
+
+; X64FAST-LABEL: icall_global_fp:
+; X64FAST:   movq global_fp(%rip), %r11
+; X64FAST:   callq __llvm_lvi_thunk_r11
+; X64FAST:   movq global_fp(%rip), %r11
+; X64FAST:   jmp __llvm_lvi_thunk_r11 # TAILCALL
+
+
+%struct.Foo = type { void (%struct.Foo*)** }
+
+; Test an indirect call through a vtable.
+define void @vcall(%struct.Foo* %obj) #0 {
+  %vptr_field = getelementptr %struct.Foo, %struct.Foo* %obj, i32 0, i32 0
+  %vptr = load void (%struct.Foo*)**, void (%struct.Foo*)*** %vptr_field
+  %vslot = getelementptr void(%struct.Foo*)*, void(%struct.Foo*)** %vptr, i32 1
+  %fp = load void(%struct.Foo*)*, void(%struct.Foo*)** %vslot
+  tail call void %fp(%struct.Foo* %obj)
+  tail call void %fp(%struct.Foo* %obj)
+  ret void
+}
+
+; X64-LABEL: vcall:
+; X64:   movq %rdi, %[[obj:[^ ]*]]
+; X64:   movq (%rdi), %[[vptr:[^ ]*]]
+; X64:   movq 8(%[[vptr]]), %[[fp:[^ ]*]]
+; X64:   movq %[[fp]], %r11
+; X64:   callq __llvm_lvi_thunk_r11
+; X64-DAG:   movq %[[obj]], %rdi
+; X64-DAG:   movq %[[fp]], %r11
+; X64:   jmp __llvm_lvi_thunk_r11 # TAILCALL
+
+; X64FAST-LABEL: vcall:
+; X64FAST:   callq __llvm_lvi_thunk_r11
+; X64FAST:   jmp __llvm_lvi_thunk_r11 # TAILCALL
+
+
+declare void @direct_callee()
+
+define void @direct_tail() #0 {
+  tail call void @direct_callee()
+  ret void
+}
+
+; X64-LABEL: direct_tail:
+; X64:   jmp direct_callee # TAILCALL
+; X64FAST-LABEL: direct_tail:
+; X64FAST:   jmp direct_callee # TAILCALL
+
+
+declare void @nonlazybind_callee() #1
+
+define void @nonlazybind_caller() #0 {
+  call void @nonlazybind_callee()
+  tail call void @nonlazybind_callee()
+  ret void
+}
+
+; X64-LABEL: nonlazybind_caller:
+; X64:   movq nonlazybind_callee@GOTPCREL(%rip), %[[REG:.*]]
+; X64:   movq %[[REG]], %r11
+; X64:   callq __llvm_lvi_thunk_r11
+; X64:   movq %[[REG]], %r11
+; X64:   jmp __llvm_lvi_thunk_r11 # TAILCALL
+; X64FAST-LABEL: nonlazybind_caller:
+; X64FAST:   movq nonlazybind_callee@GOTPCREL(%rip), %r11
+; X64FAST:   callq __llvm_lvi_thunk_r11
+; X64FAST:   movq nonlazybind_callee@GOTPCREL(%rip), %r11
+; X64FAST:   jmp __llvm_lvi_thunk_r11 # TAILCALL
+
+
+; Check that a switch gets lowered using a jump table

[PATCH] D77168: Add a flag to debug automatic variable initialization

2020-04-01 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D77168#1955500 , @jfb wrote:

> In D77168#1955450 , @jcai19 wrote:
>
> > In D77168#1955312 , @jfb wrote:
> >
> > > Do you not think `pragma` is a more general approach? That's what's used 
> > > in a bunch of other cases, and I'd like to see it attempted here.
> >
> >
> > Yes I absolutely agree pragma is a great way to bisect and will work in 
> > many scenarios, and the result is clear once the bisection is done. But 
> > like @srhines said, doing this one function at a time is preferable but not 
> > always possible (or maybe we can wrap consecutive functions within the same 
> > pragma push/pop pair? I tried to verify but ran into error: attribute 
> > 'uninitialized' is not supported by '#pragma clang attribute), and 
> > automating it is more difficult. From this perspective, I think the 
> > proposed patch is complementary to pragma and not meant to replace it.
>
>
> Right, support needs to be added, and I was wondering if you'd want to do 
> this because it seems like a tool that would help you out.


My understanding is that we can invent a compiler option to add `#pragma clang 
attribute push` for declarations satisfying some criteria (e.g. first N)? No 
source is modified. This option can potentially be useful for other attributes 
which are orthogonal to their functionality (concrete examples: sanitizer/XRay 
attributes). If we go that route, I agree that this proposed 
-ftrivial-auto-var-init-stop-after= does not seem that useful.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77168



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


[PATCH] D77168: Add a flag to debug automatic variable initialization

2020-04-01 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

In D77168#1955450 , @jcai19 wrote:

> In D77168#1955312 , @jfb wrote:
>
> > Do you not think `pragma` is a more general approach? That's what's used in 
> > a bunch of other cases, and I'd like to see it attempted here.
>
>
> Yes I absolutely agree pragma is a great way to bisect and will work in many 
> scenarios, and the result is clear once the bisection is done. But like 
> @srhines said, doing this one function at a time is preferable but not always 
> possible (or maybe we can wrap consecutive functions within the same pragma 
> push/pop pair? I tried to verify but ran into error: attribute 
> 'uninitialized' is not supported by '#pragma clang attribute), and automating 
> it is more difficult. From this perspective, I think the proposed patch is 
> complementary to pragma and not meant to replace it.


Right, support needs to be added, and I was wondering if you'd want to do this 
because it seems like a tool that would help you out.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77168



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


[PATCH] D77168: Add a flag to debug automatic variable initialization

2020-04-01 Thread Jian Cai via Phabricator via cfe-commits
jcai19 added a comment.

In D77168#1955312 , @jfb wrote:

> Do you not think `pragma` is a more general approach? That's what's used in a 
> bunch of other cases, and I'd like to see it attempted here.


Yes I absolutely agree pragma is a great way to bisect and will work in many 
scenarios, and the result is clear once the bisection is done. But like 
@srhines said, doing this one function at a time is preferable but not always 
possible (or maybe we can wrap consecutive functions within the same pragma 
push/pop pair? I tried to verify but ran into error: attribute 'uninitialized' 
is not supported by '#pragma clang attribute), and automating it is more 
difficult. From this perspective, I think the proposed patch is complementary 
to pragma and not meant to replace it.

> If not, I agree with John that just counting up isn't a good bisection 
> experience. I'd rather see a begin / end bound.

Thank you for the feedback! I will start looking into it.

> You're also missing the auto-init in `initializeAlloca`.

Thanks I will address this in next patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77168



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


Re: [clang] 6f428e0 - [AST] Fix crashes on decltype(recovery-expr).

2020-04-01 Thread Haojian Wu via cfe-commits
Hello Douglas,

Thanks for the report. I don't think it is intentional, it is certainly a
regression (I'm surprised the patch would lead to such behavior), I will
take a look tomorrow.

On Wed, Apr 1, 2020 at 8:28 PM Yung, Douglas via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Hi Haojian,
>
> I noticed that after your change, the compiler is now giving an error when
> trying to create a vector of >= 1024 elements when previously it worked,
> and gcc has no problem with the same code. Is that intentional? I have put
> the details in PR45387, can you take a look?
>
> Douglas Yung
>
> -Original Message-
> From: cfe-commits  On Behalf Of
> Haojian Wu via cfe-commits
> Sent: Monday, March 30, 2020 5:57
> To: cfe-commits@lists.llvm.org
> Subject: [clang] 6f428e0 - [AST] Fix crashes on decltype(recovery-expr).
>
>
> Author: Haojian Wu
> Date: 2020-03-30T14:56:33+02:00
> New Revision: 6f428e09fbe8ce7e3510ae024031a5fc19653483
>
> URL:
> https://github.com/llvm/llvm-project/commit/6f428e09fbe8ce7e3510ae024031a5fc19653483
> DIFF:
> https://github.com/llvm/llvm-project/commit/6f428e09fbe8ce7e3510ae024031a5fc19653483.diff
>
> LOG: [AST] Fix crashes on decltype(recovery-expr).
>
> Summary: We mark these decls as invalid.
>
> Reviewers: sammccall
>
> Subscribers: cfe-commits
>
> Tags: #clang
>
> Differential Revision: https://reviews.llvm.org/D77037
>
> Added:
>
>
> Modified:
> clang/include/clang/AST/DependenceFlags.h
> clang/include/clang/AST/Type.h
> clang/lib/Parse/ParseExprCXX.cpp
> clang/lib/Sema/SemaType.cpp
> clang/test/AST/ast-dump-expr-errors.cpp
> clang/test/Sema/invalid-member.cpp
> clang/unittests/Sema/CodeCompleteTest.cpp
>
> Removed:
>
>
>
>
> 
> diff  --git a/clang/include/clang/AST/DependenceFlags.h
> b/clang/include/clang/AST/DependenceFlags.h
> index 75c9aa1656b8..0b24bae6df9b 100644
> --- a/clang/include/clang/AST/DependenceFlags.h
> +++ b/clang/include/clang/AST/DependenceFlags.h
> @@ -50,14 +50,16 @@ struct TypeDependenceScope {
>  /// Whether this type is a variably-modified type (C99 6.7.5).
>  VariablyModified = 8,
>
> -// FIXME: add Error bit.
> +/// Whether this type references an error, e.g.
> decltype(err-expression)
> +/// yields an error type.
> +Error = 16,
>
>  None = 0,
> -All = 15,
> +All = 31,
>
>  DependentInstantiation = Dependent | Instantiation,
>
> -LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/VariablyModified)
> +LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/Error)
>};
>  };
>  using TypeDependence = TypeDependenceScope::TypeDependence;
> @@ -147,6 +149,7 @@ class Dependence {
>  return translate(V, UnexpandedPack, TypeDependence::UnexpandedPack) |
> translate(V, Instantiation, TypeDependence::Instantiation) |
> translate(V, Dependent, TypeDependence::Dependent) |
> +   translate(V, Error, TypeDependence::Error) |
> translate(V, VariablyModified,
> TypeDependence::VariablyModified);
>}
>
>
> diff  --git a/clang/include/clang/AST/Type.h
> b/clang/include/clang/AST/Type.h index 248fbcfba98e..5d2c035ea0fe 100644
> --- a/clang/include/clang/AST/Type.h
> +++ b/clang/include/clang/AST/Type.h
> @@ -2139,6 +2139,11 @@ class alignas(8) Type : public
> ExtQualsTypeCommonBase {
>  return static_cast(TypeBits.Dependence);
>}
>
> +  /// Whether this type is an error type.
> +  bool containsErrors() const {
> +return getDependence() & TypeDependence::Error;  }
> +
>/// Whether this type is a dependent type, meaning that its definition
>/// somehow depends on a template parameter (C++ [temp.dep.type]).
>bool isDependentType() const {
>
> diff  --git a/clang/lib/Parse/ParseExprCXX.cpp
> b/clang/lib/Parse/ParseExprCXX.cpp
> index 761fad9456be..4389c8777c6d 100644
> --- a/clang/lib/Parse/ParseExprCXX.cpp
> +++ b/clang/lib/Parse/ParseExprCXX.cpp
> @@ -3105,10 +3105,14 @@ Parser::ParseCXXNewExpression(bool UseGlobal,
> SourceLocation Start) {
>auto RunSignatureHelp = [&]() {
>  ParsedType TypeRep =
>  Actions.ActOnTypeName(getCurScope(), DeclaratorInfo).get();
> -assert(TypeRep && "invalid types should be handled before");
> -QualType PreferredType = Actions.ProduceConstructorSignatureHelp(
> -getCurScope(), TypeRep.get()->getCanonicalTypeInternal(),
> -DeclaratorInfo.getEndLoc(), ConstructorArgs,
> ConstructorLParen);
> +QualType PreferredType;
> +// ActOnTypeName might adjust DeclaratorInfo and return a null
> type even
> +// the passing DeclaratorInfo is valid, e.g. running
> SignatureHelp on
> +// `new decltype(invalid) (^)`.
> +if (TypeRep)
> +  PreferredType = Actions.ProduceConstructorSignatureHelp(
> +  getCurScope(), TypeRep.get()->getCanonicalTypeInternal(),
> +  DeclaratorInfo.getEndLoc(), ConstructorArgs,

[clang] c028472 - Revert "[OPENMP50]Add initial support for OpenMP 5.0 iterator."

2020-04-01 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2020-04-01T14:54:45-04:00
New Revision: c028472fa1f0e20cc87cfa47d87fe0dd65fea830

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

LOG: Revert "[OPENMP50]Add initial support for OpenMP 5.0 iterator."

This reverts commit f08df464ae89972a777c0a7e299a2c153a9829d8 to fix the
bug with serialization support for iterator expression.

Added: 


Modified: 
clang/include/clang-c/Index.h
clang/include/clang/AST/ASTContext.h
clang/include/clang/AST/BuiltinTypes.def
clang/include/clang/AST/ComputeDependence.h
clang/include/clang/AST/ExprOpenMP.h
clang/include/clang/AST/OpenMPClause.h
clang/include/clang/AST/RecursiveASTVisitor.h
clang/include/clang/AST/TextNodeDumper.h
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/StmtNodes.td
clang/include/clang/Parse/Parser.h
clang/include/clang/Sema/Sema.h
clang/include/clang/Serialization/ASTBitCodes.h
clang/lib/AST/ASTContext.cpp
clang/lib/AST/ComputeDependence.cpp
clang/lib/AST/Expr.cpp
clang/lib/AST/ExprClassification.cpp
clang/lib/AST/ExprConstant.cpp
clang/lib/AST/ItaniumMangle.cpp
clang/lib/AST/NSAPI.cpp
clang/lib/AST/OpenMPClause.cpp
clang/lib/AST/StmtPrinter.cpp
clang/lib/AST/StmtProfile.cpp
clang/lib/AST/TextNodeDumper.cpp
clang/lib/AST/Type.cpp
clang/lib/AST/TypeLoc.cpp
clang/lib/Parse/ParseOpenMP.cpp
clang/lib/Sema/SemaExceptionSpec.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Sema/TreeTransform.h
clang/lib/Serialization/ASTCommon.cpp
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTReaderStmt.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/lib/Serialization/ASTWriterStmt.cpp
clang/lib/StaticAnalyzer/Checkers/IdenticalExprChecker.cpp
clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
clang/test/OpenMP/depobj_messages.cpp
clang/test/OpenMP/task_ast_print.cpp
clang/test/OpenMP/task_depend_messages.cpp
clang/tools/libclang/CIndex.cpp
clang/tools/libclang/CXCursor.cpp

Removed: 




diff  --git a/clang/include/clang-c/Index.h b/clang/include/clang-c/Index.h
index 0acd50021ed8..641f058dafaa 100644
--- a/clang/include/clang-c/Index.h
+++ b/clang/include/clang-c/Index.h
@@ -2180,12 +2180,7 @@ enum CXCursorKind {
*/
   CXCursor_OMPArrayShapingExpr = 150,
 
-  /**
-   * OpenMP 5.0 [2.1.6 Iterators]
-   */
-  CXCursor_OMPIteratorExpr = 151,
-
-  CXCursor_LastExpr = CXCursor_OMPIteratorExpr,
+  CXCursor_LastExpr = CXCursor_OMPArrayShapingExpr,
 
   /* Statements */
   CXCursor_FirstStmt = 200,

diff  --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 6813ab58874e..ebb5ca593843 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -970,7 +970,7 @@ class ASTContext : public RefCountedBase {
 #include "clang/Basic/OpenCLImageTypes.def"
   CanQualType OCLSamplerTy, OCLEventTy, OCLClkEventTy;
   CanQualType OCLQueueTy, OCLReserveIDTy;
-  CanQualType OMPArraySectionTy, OMPArrayShapingTy, OMPIteratorTy;
+  CanQualType OMPArraySectionTy, OMPArrayShapingTy;
 #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
   CanQualType Id##Ty;
 #include "clang/Basic/OpenCLExtensionTypes.def"

diff  --git a/clang/include/clang/AST/BuiltinTypes.def 
b/clang/include/clang/AST/BuiltinTypes.def
index f8eb4ec19c8f..f42503773945 100644
--- a/clang/include/clang/AST/BuiltinTypes.def
+++ b/clang/include/clang/AST/BuiltinTypes.def
@@ -316,11 +316,8 @@ PLACEHOLDER_TYPE(OMPArraySection, OMPArraySectionTy)
 // A placeholder type for OpenMP array shaping operation.
 PLACEHOLDER_TYPE(OMPArrayShaping, OMPArrayShapingTy)
 
-// A placeholder type for OpenMP iterators.
-PLACEHOLDER_TYPE(OMPIterator, OMPIteratorTy)
-
 #ifdef LAST_BUILTIN_TYPE
-LAST_BUILTIN_TYPE(OMPIterator)
+LAST_BUILTIN_TYPE(OMPArrayShaping)
 #undef LAST_BUILTIN_TYPE
 #endif
 

diff  --git a/clang/include/clang/AST/ComputeDependence.h 
b/clang/include/clang/AST/ComputeDependence.h
index ab742c9b70dd..63947eaff73b 100644
--- a/clang/include/clang/AST/ComputeDependence.h
+++ b/clang/include/clang/AST/ComputeDependence.h
@@ -88,7 +88,6 @@ class PseudoObjectExpr;
 class AtomicExpr;
 class OMPArraySectionExpr;
 class OMPArrayShapingExpr;
-class OMPIteratorExpr;
 class ObjCArrayLiteral;
 class ObjCDictionaryLiteral;
 class ObjCBoxedExpr;
@@ -175,7 +174,6 @@ ExprDependence computeDependence(AtomicExpr *E);
 
 ExprDependence computeDependence(OMPArraySectionExpr *E);
 ExprDependence computeDependence(OMPArrayShapingExpr *E);
-ExprDependence computeDependence(OMPIteratorExpr *E);
 
 ExprDependence computeDependence(ObjCArrayLiteral *E);
 

[PATCH] D76937: Fix infinite recursion in deferred diagnostic emitter

2020-04-01 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Thanks, LGTM.


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

https://reviews.llvm.org/D76937



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


[PATCH] D59321: AMDGPU: Teach toolchain to link rocm device libs

2020-04-01 Thread Michael Liao via Phabricator via cfe-commits
hliao added a comment.

Do we have a better way to avoid adding those empty bitcode files?




Comment at: clang/lib/Driver/ToolChains/AMDGPU.h:29
+  struct ConditionalLibrary {
+SmallString<0> On;
+SmallString<0> Off;

may need to add `llvm` namespace prefix just like all other LLVM stuffs used in 
clang in case the same name is introduced later by accident.



Comment at: clang/lib/Driver/ToolChains/AMDGPU.h:44-46
+  //RocmVersion Version = RocmVersion::UNKNOWN;
+  SmallString<0> InstallPath;
+  //SmallString<0> BinPath;

sounds to me that both `Version` and `BinPath` should be added. They will be 
used eventually.



Comment at: clang/lib/Driver/ToolChains/HIP.h:76
 
-class LLVM_LIBRARY_VISIBILITY HIPToolChain final : public AMDGPUToolChain {
+class LLVM_LIBRARY_VISIBILITY HIPToolChain final : public ROCMToolChain {
 public:

Do you miss the change in HIP.cpp? That constructor needs revising as the base 
class is changed.


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

https://reviews.llvm.org/D59321



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


[PATCH] D76937: Fix infinite recursion in deferred diagnostic emitter

2020-04-01 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 254262.
yaxunl added a comment.

fix assert message


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

https://reviews.llvm.org/D76937

Files:
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/test/OpenMP/nvptx_target_exceptions_messages.cpp

Index: clang/test/OpenMP/nvptx_target_exceptions_messages.cpp
===
--- clang/test/OpenMP/nvptx_target_exceptions_messages.cpp
+++ clang/test/OpenMP/nvptx_target_exceptions_messages.cpp
@@ -1,5 +1,10 @@
-// RUN: %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc -fexceptions -fcxx-exceptions
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - -fexceptions -fcxx-exceptions -ferror-limit 100
+// RUN: %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown \
+// RUN:   -verify=host -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc \
+// RUN:   %s -o %t-ppc-host.bc -fexceptions -fcxx-exceptions
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown \
+// RUN:   -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s \
+// RUN:   -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - \
+// RUN:   -fexceptions -fcxx-exceptions -ferror-limit 100
 
 #ifndef HEADER
 #define HEADER
@@ -81,4 +86,17 @@
 int foobar1() { throw 1; }
 int foobar2() { throw 1; } // expected-error {{cannot use 'throw' with exceptions disabled}}
 
+
+int foobar3();
+int (*C)() =  // expected-warning {{declaration is not declared in any declare target region}}
+   // host-warning@-1 {{declaration is not declared in any declare target region}}
+#pragma omp declare target
+int (*D)() = C; // expected-note {{used here}}
+// host-note@-1 {{used here}}
+#pragma omp end declare target
+int foobar3() { throw 1; }
+
+// Check no infinite recursion in deferred diagnostic emitter.
+long E = (long)
+
 #endif // HEADER
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -12257,7 +12257,7 @@
 VDecl->setInitStyle(VarDecl::ListInit);
   }
 
-  if (LangOpts.OpenMP && VDecl->hasGlobalStorage())
+  if (LangOpts.OpenMP && VDecl->isFileVarDecl())
 DeclsToCheckForDeferredDiags.push_back(VDecl);
   CheckCompleteVariableDeclaration(VDecl);
 }
Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -1501,43 +1501,60 @@
   }
 
   void visitUsedDecl(SourceLocation Loc, Decl *D) {
-if (auto *FD = dyn_cast(D)) {
-  FunctionDecl *Caller = UseStack.empty() ? nullptr : UseStack.back();
-  auto IsKnownEmitted = S.getEmissionStatus(FD, /*Final=*/true) ==
-Sema::FunctionEmissionStatus::Emitted;
-  if (!Caller)
-ShouldEmit = IsKnownEmitted;
-  if ((!ShouldEmit && !S.getLangOpts().OpenMP && !Caller) ||
-  S.shouldIgnoreInHostDeviceCheck(FD) || Visited.count(D))
-return;
-  // Finalize analysis of OpenMP-specific constructs.
-  if (Caller && S.LangOpts.OpenMP && UseStack.size() == 1)
-S.finalizeOpenMPDelayedAnalysis(Caller, FD, Loc);
-  if (Caller)
-S.DeviceKnownEmittedFns[FD] = {Caller, Loc};
-  if (ShouldEmit || InOMPDeviceContext)
-S.emitDeferredDiags(FD, Caller);
-  Visited.insert(D);
-  UseStack.push_back(FD);
-  if (auto *S = FD->getBody()) {
-this->Visit(S);
-  }
-  UseStack.pop_back();
-  Visited.erase(D);
-} else if (auto *VD = dyn_cast(D)) {
-  if (auto *Init = VD->getInit()) {
-auto DevTy = OMPDeclareTargetDeclAttr::getDeviceType(VD);
-bool IsDev = DevTy && (*DevTy == OMPDeclareTargetDeclAttr::DT_NoHost ||
-   *DevTy == OMPDeclareTargetDeclAttr::DT_Any);
-if (IsDev)
-  ++InOMPDeviceContext;
-this->Visit(Init);
-if (IsDev)
-  --InOMPDeviceContext;
-  }
-} else
+if (isa(D))
+  return;
+if (auto *FD = dyn_cast(D))
+  checkFunc(Loc, FD);
+else
   Inherited::visitUsedDecl(Loc, D);
   }
+
+  void checkVar(VarDecl *VD) {
+assert(VD->isFileVarDecl() &&
+   "Should only check file-scope variables");
+if (auto *Init = VD->getInit()) {
+  auto DevTy = OMPDeclareTargetDeclAttr::getDeviceType(VD);
+  bool IsDev = DevTy && (*DevTy == OMPDeclareTargetDeclAttr::DT_NoHost ||
+ *DevTy == OMPDeclareTargetDeclAttr::DT_Any);
+  if (IsDev)
+++InOMPDeviceContext;
+  this->Visit(Init);
+  if (IsDev)
+--InOMPDeviceContext;
+}
+  }
+
+  void checkFunc(SourceLocation 

[PATCH] D77168: Add a flag to debug automatic variable initialization

2020-04-01 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/CodeGen/CGDecl.cpp:1814
+if (StopAfter) {
+  static unsigned Counter = 0;
+  if (Counter >= StopAfter)

jcai19 wrote:
> rjmccall wrote:
> > srhines wrote:
> > > MaskRay wrote:
> > > > I am a bit worried about the static variable. This makes CodeGen not 
> > > > reusable.
> > > The counter could exist in ASTContext instead.
> > IRGenModule would be the more appropriate place.
> I can't seem to find IRGenModule. Do you mean CodeGenModule by any chance? 
> Thanks.
Yes, sorry.  The Clang and Swift frontends use slightly different names for the 
same concept.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77168



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


[PATCH] D76937: Fix infinite recursion in deferred diagnostic emitter

2020-04-01 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 254261.
yaxunl added a comment.

Revised by John's comments. Also only check file scope variables.


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

https://reviews.llvm.org/D76937

Files:
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/test/OpenMP/nvptx_target_exceptions_messages.cpp

Index: clang/test/OpenMP/nvptx_target_exceptions_messages.cpp
===
--- clang/test/OpenMP/nvptx_target_exceptions_messages.cpp
+++ clang/test/OpenMP/nvptx_target_exceptions_messages.cpp
@@ -1,5 +1,10 @@
-// RUN: %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc -fexceptions -fcxx-exceptions
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - -fexceptions -fcxx-exceptions -ferror-limit 100
+// RUN: %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown \
+// RUN:   -verify=host -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc \
+// RUN:   %s -o %t-ppc-host.bc -fexceptions -fcxx-exceptions
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown \
+// RUN:   -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s \
+// RUN:   -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - \
+// RUN:   -fexceptions -fcxx-exceptions -ferror-limit 100
 
 #ifndef HEADER
 #define HEADER
@@ -81,4 +86,17 @@
 int foobar1() { throw 1; }
 int foobar2() { throw 1; } // expected-error {{cannot use 'throw' with exceptions disabled}}
 
+
+int foobar3();
+int (*C)() =  // expected-warning {{declaration is not declared in any declare target region}}
+   // host-warning@-1 {{declaration is not declared in any declare target region}}
+#pragma omp declare target
+int (*D)() = C; // expected-note {{used here}}
+// host-note@-1 {{used here}}
+#pragma omp end declare target
+int foobar3() { throw 1; }
+
+// Check no infinite recursion in deferred diagnostic emitter.
+long E = (long)
+
 #endif // HEADER
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -12257,7 +12257,7 @@
 VDecl->setInitStyle(VarDecl::ListInit);
   }
 
-  if (LangOpts.OpenMP && VDecl->hasGlobalStorage())
+  if (LangOpts.OpenMP && VDecl->isFileVarDecl())
 DeclsToCheckForDeferredDiags.push_back(VDecl);
   CheckCompleteVariableDeclaration(VDecl);
 }
Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -1501,43 +1501,60 @@
   }
 
   void visitUsedDecl(SourceLocation Loc, Decl *D) {
-if (auto *FD = dyn_cast(D)) {
-  FunctionDecl *Caller = UseStack.empty() ? nullptr : UseStack.back();
-  auto IsKnownEmitted = S.getEmissionStatus(FD, /*Final=*/true) ==
-Sema::FunctionEmissionStatus::Emitted;
-  if (!Caller)
-ShouldEmit = IsKnownEmitted;
-  if ((!ShouldEmit && !S.getLangOpts().OpenMP && !Caller) ||
-  S.shouldIgnoreInHostDeviceCheck(FD) || Visited.count(D))
-return;
-  // Finalize analysis of OpenMP-specific constructs.
-  if (Caller && S.LangOpts.OpenMP && UseStack.size() == 1)
-S.finalizeOpenMPDelayedAnalysis(Caller, FD, Loc);
-  if (Caller)
-S.DeviceKnownEmittedFns[FD] = {Caller, Loc};
-  if (ShouldEmit || InOMPDeviceContext)
-S.emitDeferredDiags(FD, Caller);
-  Visited.insert(D);
-  UseStack.push_back(FD);
-  if (auto *S = FD->getBody()) {
-this->Visit(S);
-  }
-  UseStack.pop_back();
-  Visited.erase(D);
-} else if (auto *VD = dyn_cast(D)) {
-  if (auto *Init = VD->getInit()) {
-auto DevTy = OMPDeclareTargetDeclAttr::getDeviceType(VD);
-bool IsDev = DevTy && (*DevTy == OMPDeclareTargetDeclAttr::DT_NoHost ||
-   *DevTy == OMPDeclareTargetDeclAttr::DT_Any);
-if (IsDev)
-  ++InOMPDeviceContext;
-this->Visit(Init);
-if (IsDev)
-  --InOMPDeviceContext;
-  }
-} else
+if (isa(D))
+  return;
+if (auto *FD = dyn_cast(D))
+  checkFunc(Loc, FD);
+else
   Inherited::visitUsedDecl(Loc, D);
   }
+
+  void checkVar(VarDecl *VD) {
+assert(VD->isFileVarDecl() &&
+   "Should only check variables with global storage");
+if (auto *Init = VD->getInit()) {
+  auto DevTy = OMPDeclareTargetDeclAttr::getDeviceType(VD);
+  bool IsDev = DevTy && (*DevTy == OMPDeclareTargetDeclAttr::DT_NoHost ||
+ *DevTy == OMPDeclareTargetDeclAttr::DT_Any);
+  if (IsDev)
+++InOMPDeviceContext;
+  this->Visit(Init);
+  if (IsDev)
+

[PATCH] D76384: Move FPFeatures from BinaryOperator bitfields to Trailing storage

2020-04-01 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/include/clang/Basic/LangOptions.h:394
+ return true;
+  }
+

rjmccall wrote:
> erichkeane wrote:
> > rjmccall wrote:
> > > rjmccall wrote:
> > > > erichkeane wrote:
> > > > > rjmccall wrote:
> > > > > > The problem with having both functions that take `ASTContext`s and 
> > > > > > functions that don't is that it's easy to mix them, so they either 
> > > > > > need to have the same behavior (in which case it's pointless to 
> > > > > > have an overload that takes the `ASTContext`) or you're making 
> > > > > > something really error-prone.
> > > > > > 
> > > > > > I would feel a lot more confident that you were designing and using 
> > > > > > these APIs correctly if you actually took advantage of the ability 
> > > > > > to not store trailing FPOptions in some case, like when they match 
> > > > > > the global settings in the ASTContext.  That way you'll actually be 
> > > > > > verifying that everything behaves correctly if nodes don't store 
> > > > > > FPOptions.  If you do that, I think you'll see my point about not 
> > > > > > having all these easily-confusable functions that do or do not take 
> > > > > > `ASTContext`s..
> > > > > I think I disagree with @rjmccall that these requiresTrailingStorage 
> > > > > should be here at all.  I think we should store in the AST ANY 
> > > > > programmer opinion, even if they match the global setting.  It seems 
> > > > > to me that this would be more tolerant of any global-setting rewrites 
> > > > > that modules/et-al introduce, as well as make the AST Print 
> > > > > consistent.  Always storing FPOptions when the user has explicitly 
> > > > > overriding it also better captures the programmer's intent.
> > > > I covered this elsewhere in the review.  If you want to have that 
> > > > tolerance — and I think you should — then expressions should store (and 
> > > > Sema should track) the active pragma state, which can be most easily 
> > > > expressed as a pair of an FPOptions and a mask to apply to the global 
> > > > FPOptions.  When you enter a pragma, you clear the relevant bits from 
> > > > the global FPOptions mask.
> > > > 
> > > > But the whole point of putting this stuff in trailing storage is so 
> > > > that you can make FPOptions as big as you need without actually 
> > > > inflating the AST size for a million nodes that don't care in the 
> > > > slightest about FPOptions.
> > > > But the whole point of putting this stuff in trailing storage is so 
> > > > that you can make FPOptions as big as you need without actually 
> > > > inflating the AST size for a million nodes that don't care in the 
> > > > slightest about FPOptions.
> > > 
> > > I meant to say: for a million nodes that don't care in the slightest 
> > > about FPOptions, as well as for a million more nodes that aren't using 
> > > pragma overrides.
> > Right, I get the intent, and I completely agree with that.  My point was 
> > EVERY Expr that is affected by a #pragma should store it.  Though, after 
> > looking at your Macro concern above, I'm less compelled.
> > 
> > I guess was suggesting that the logic for "requiresTrailingStorage" should 
> > just be "modified by a pragma" instead of "FPOptions != The global setting".
> Well, "modified by a pragma" still wouldn't make the AST agnostic to global 
> settings, since the pragmas don't override everything in FPOptions at once.  
> But I agree that would achieve the most important goal, which is to stop 
> inflating the AST when pragmas *aren't* in effect, which is approximately 
> 100% of the time.  In order to do that, though, we'll need to start tracking 
> pragmas, which we should do but which can wait for a follow-up patch.  In the 
> meantime, I don't think you're ever going to get the interfaces right for 
> queries like `BinaryOperator::getFPOptions` unless you actually stop relying 
> on the fact that you're unconditionally storing `FPOptions`.  You need to 
> passing around ASTContexts for that.  That's why I'm suggesting using an 
> exact match with the global settings as a simple thing you can easily check 
> without modifying what data you collect in `FPOptions`.
That sounds like a good plan to me.  Thanks for entertaining my 
conversation/questions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76384



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


[PATCH] D77074: [FPEnv][AArch64] Platform-specific builtin constrained FP enablement

2020-04-01 Thread Diogo N. Sampaio via Phabricator via cfe-commits
dnsampaio added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:8486-8492
+  return Builder.CreateConstrainedFPCall(
+  F,
+  {EmitScalarExpr(E->getArg(1)), EmitScalarExpr(E->getArg(2)), 
Ops[0]});
+} else {
+  Function *F = CGM.getIntrinsic(Intrinsic::fma, HalfTy);
+  // NEON intrinsic puts accumulator first, unlike the LLVM fma.
+  return Builder.CreateCall(F, {EmitScalarExpr(E->getArg(1)),

It seems that `Builder.CreateCall` and `Builder.CreateConstrainedFPCall` 
usually have the same arguments, except for the function F being or not part of 
"experimental_constrained_".
Would it make sense to teach the `Builder` to select between creating a 
constrained or not call, depending if the function passed is constrained?

I was thinking in something like this:
```
Function *F = CGM.getIntrinsic( Builder.getIsFPConstrained()?

Intrinsic::experimental_constrained_fma :
Intrinsic::fma, HalfTy);
return Builder.CreateCallConstrainedFPIfRequired(F, 
```



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77074



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


[PATCH] D77229: [Analyzer][WIP] Avoid handling of LazyCompundVals in IteratorModeling

2020-04-01 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

The assert points out that the object under construction is already tracked and 
you're trying to add it twice. You don't want to add it tho, you just want to 
find the region.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77229



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


[PATCH] D76384: Move FPFeatures from BinaryOperator bitfields to Trailing storage

2020-04-01 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/include/clang/Basic/LangOptions.h:394
+ return true;
+  }
+

erichkeane wrote:
> rjmccall wrote:
> > rjmccall wrote:
> > > erichkeane wrote:
> > > > rjmccall wrote:
> > > > > The problem with having both functions that take `ASTContext`s and 
> > > > > functions that don't is that it's easy to mix them, so they either 
> > > > > need to have the same behavior (in which case it's pointless to have 
> > > > > an overload that takes the `ASTContext`) or you're making something 
> > > > > really error-prone.
> > > > > 
> > > > > I would feel a lot more confident that you were designing and using 
> > > > > these APIs correctly if you actually took advantage of the ability to 
> > > > > not store trailing FPOptions in some case, like when they match the 
> > > > > global settings in the ASTContext.  That way you'll actually be 
> > > > > verifying that everything behaves correctly if nodes don't store 
> > > > > FPOptions.  If you do that, I think you'll see my point about not 
> > > > > having all these easily-confusable functions that do or do not take 
> > > > > `ASTContext`s..
> > > > I think I disagree with @rjmccall that these requiresTrailingStorage 
> > > > should be here at all.  I think we should store in the AST ANY 
> > > > programmer opinion, even if they match the global setting.  It seems to 
> > > > me that this would be more tolerant of any global-setting rewrites that 
> > > > modules/et-al introduce, as well as make the AST Print consistent.  
> > > > Always storing FPOptions when the user has explicitly overriding it 
> > > > also better captures the programmer's intent.
> > > I covered this elsewhere in the review.  If you want to have that 
> > > tolerance — and I think you should — then expressions should store (and 
> > > Sema should track) the active pragma state, which can be most easily 
> > > expressed as a pair of an FPOptions and a mask to apply to the global 
> > > FPOptions.  When you enter a pragma, you clear the relevant bits from the 
> > > global FPOptions mask.
> > > 
> > > But the whole point of putting this stuff in trailing storage is so that 
> > > you can make FPOptions as big as you need without actually inflating the 
> > > AST size for a million nodes that don't care in the slightest about 
> > > FPOptions.
> > > But the whole point of putting this stuff in trailing storage is so that 
> > > you can make FPOptions as big as you need without actually inflating the 
> > > AST size for a million nodes that don't care in the slightest about 
> > > FPOptions.
> > 
> > I meant to say: for a million nodes that don't care in the slightest about 
> > FPOptions, as well as for a million more nodes that aren't using pragma 
> > overrides.
> Right, I get the intent, and I completely agree with that.  My point was 
> EVERY Expr that is affected by a #pragma should store it.  Though, after 
> looking at your Macro concern above, I'm less compelled.
> 
> I guess was suggesting that the logic for "requiresTrailingStorage" should 
> just be "modified by a pragma" instead of "FPOptions != The global setting".
Well, "modified by a pragma" still wouldn't make the AST agnostic to global 
settings, since the pragmas don't override everything in FPOptions at once.  
But I agree that would achieve the most important goal, which is to stop 
inflating the AST when pragmas *aren't* in effect, which is approximately 100% 
of the time.  In order to do that, though, we'll need to start tracking 
pragmas, which we should do but which can wait for a follow-up patch.  In the 
meantime, I don't think you're ever going to get the interfaces right for 
queries like `BinaryOperator::getFPOptions` unless you actually stop relying on 
the fact that you're unconditionally storing `FPOptions`.  You need to passing 
around ASTContexts for that.  That's why I'm suggesting using an exact match 
with the global settings as a simple thing you can easily check without 
modifying what data you collect in `FPOptions`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76384



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


[PATCH] D77234: clang/AMDGPU: Stop setting old denormal subtarget features

2020-04-01 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm created this revision.
arsenm added a reviewer: yaxunl.
Herald added subscribers: kerbowa, t-tye, tpr, dstuttard, nhaehnle, wdng, 
jvesely, kzhuravl.

https://reviews.llvm.org/D77234

Files:
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/lib/Basic/Targets/AMDGPU.h
  clang/test/CodeGenCUDA/flush-denormals.cu
  clang/test/CodeGenOpenCL/amdgpu-features.cl

Index: clang/test/CodeGenOpenCL/amdgpu-features.cl
===
--- clang/test/CodeGenOpenCL/amdgpu-features.cl
+++ clang/test/CodeGenOpenCL/amdgpu-features.cl
@@ -14,15 +14,15 @@
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx600 -S -emit-llvm -o - %s | FileCheck --check-prefix=GFX600 %s
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx601 -S -emit-llvm -o - %s | FileCheck --check-prefix=GFX601 %s
 
-// GFX904: "target-features"="+16-bit-insts,+ci-insts,+dpp,+flat-address-space,+fp32-denormals,+fp64-fp16-denormals,+gfx8-insts,+gfx9-insts,+s-memrealtime"
-// GFX906: "target-features"="+16-bit-insts,+ci-insts,+dl-insts,+dot1-insts,+dot2-insts,+dpp,+flat-address-space,+fp32-denormals,+fp64-fp16-denormals,+gfx8-insts,+gfx9-insts,+s-memrealtime"
-// GFX908: "target-features"="+16-bit-insts,+ci-insts,+dl-insts,+dot1-insts,+dot2-insts,+dot3-insts,+dot4-insts,+dot5-insts,+dot6-insts,+dpp,+flat-address-space,+fp32-denormals,+fp64-fp16-denormals,+gfx8-insts,+gfx9-insts,+mai-insts,+s-memrealtime"
-// GFX1010: "target-features"="+16-bit-insts,+ci-insts,+dl-insts,+dpp,+flat-address-space,+fp32-denormals,+fp64-fp16-denormals,+gfx10-insts,+gfx8-insts,+gfx9-insts,+s-memrealtime"
-// GFX1011: "target-features"="+16-bit-insts,+ci-insts,+dl-insts,+dot1-insts,+dot2-insts,+dot5-insts,+dot6-insts,+dpp,+flat-address-space,+fp32-denormals,+fp64-fp16-denormals,+gfx10-insts,+gfx8-insts,+gfx9-insts,+s-memrealtime"
-// GFX1012: "target-features"="+16-bit-insts,+ci-insts,+dl-insts,+dot1-insts,+dot2-insts,+dot5-insts,+dot6-insts,+dpp,+flat-address-space,+fp32-denormals,+fp64-fp16-denormals,+gfx10-insts,+gfx8-insts,+gfx9-insts,+s-memrealtime"
-// GFX801: "target-features"="+16-bit-insts,+ci-insts,+dpp,+flat-address-space,+fp32-denormals,+fp64-fp16-denormals,+gfx8-insts,+s-memrealtime"
-// GFX700: "target-features"="+ci-insts,+flat-address-space,+fp64-fp16-denormals,-fp32-denormals"
-// GFX600: "target-features"="+fp64-fp16-denormals,-fp32-denormals"
-// GFX601: "target-features"="+fp64-fp16-denormals,-fp32-denormals"
+// GFX904: "target-features"="+16-bit-insts,+ci-insts,+dpp,+flat-address-space,+gfx8-insts,+gfx9-insts,+s-memrealtime"
+// GFX906: "target-features"="+16-bit-insts,+ci-insts,+dl-insts,+dot1-insts,+dot2-insts,+dpp,+flat-address-space,+gfx8-insts,+gfx9-insts,+s-memrealtime"
+// GFX908: "target-features"="+16-bit-insts,+ci-insts,+dl-insts,+dot1-insts,+dot2-insts,+dot3-insts,+dot4-insts,+dot5-insts,+dot6-insts,+dpp,+flat-address-space,+gfx8-insts,+gfx9-insts,+mai-insts,+s-memrealtime"
+// GFX1010: "target-features"="+16-bit-insts,+ci-insts,+dl-insts,+dpp,+flat-address-space,+gfx10-insts,+gfx8-insts,+gfx9-insts,+s-memrealtime"
+// GFX1011: "target-features"="+16-bit-insts,+ci-insts,+dl-insts,+dot1-insts,+dot2-insts,+dot5-insts,+dot6-insts,+dpp,+flat-address-space,+gfx10-insts,+gfx8-insts,+gfx9-insts,+s-memrealtime"
+// GFX1012: "target-features"="+16-bit-insts,+ci-insts,+dl-insts,+dot1-insts,+dot2-insts,+dot5-insts,+dot6-insts,+dpp,+flat-address-space,+gfx10-insts,+gfx8-insts,+gfx9-insts,+s-memrealtime"
+// GFX801: "target-features"="+16-bit-insts,+ci-insts,+dpp,+flat-address-space,+gfx8-insts,+s-memrealtime"
+// GFX700: "target-features"="+ci-insts,+flat-address-space"
+// GFX600-NOT: "target-features"
+// GFX601-NOT: "target-features"
 
 kernel void test() {}
Index: clang/test/CodeGenCUDA/flush-denormals.cu
===
--- clang/test/CodeGenCUDA/flush-denormals.cu
+++ clang/test/CodeGenCUDA/flush-denormals.cu
@@ -1,26 +1,26 @@
 // RUN: %clang_cc1 -fcuda-is-device \
 // RUN:   -triple nvptx-nvidia-cuda -emit-llvm -o - %s | \
-// RUN:   FileCheck -check-prefix=NOFTZ %s
+// RUN:   FileCheck -check-prefixes=NOFTZ,PTXNOFTZ %s
 
 // RUN: %clang_cc1 -fcuda-is-device -fdenormal-fp-math-f32=ieee \
 // RUN:   -triple nvptx-nvidia-cuda -emit-llvm -o - %s | \
-// RUN:   FileCheck -check-prefix=NOFTZ %s
+// RUN:   FileCheck -check-prefixes=NOFTZ,PTXNOFTZ %s
 
 // RUN: %clang_cc1 -fcuda-is-device -fdenormal-fp-math-f32=preserve-sign \
 // RUN:   -triple nvptx-nvidia-cuda -emit-llvm -o - %s | \
-// RUN:   FileCheck -check-prefix=FTZ %s
+// RUN:   FileCheck -check-prefixes=FTZ,PTXFTZ %s
 
 // RUN: %clang_cc1 -fcuda-is-device -x hip \
 // RUN:   -triple amdgcn-amd-amdhsa -target-cpu gfx900 -emit-llvm -o - %s | \
-// RUN:   FileCheck -check-prefix=AMDNOFTZ %s
+// RUN:   FileCheck -check-prefix=NOFTZ %s
 
 // RUN: %clang_cc1 -fcuda-is-device -x hip \
 // RUN:   -triple amdgcn-amd-amdhsa -target-cpu gfx900 -fdenormal-fp-math-f32=ieee -emit-llvm -o - %s | \
-// RUN:   FileCheck 

[PATCH] D77233: [NFC] Refactoring PropertyAttributeKind for ObjCPropertyDecl and ObjCDeclSpec.

2020-04-01 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi updated this revision to Diff 254259.
plotfi added a comment.
Herald added a subscriber: jfb.

 Clipboard gave me junk the first submit. Sorry


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77233

Files:
  clang/include/clang/AST/DeclObjC.h
  clang/include/clang/AST/DeclObjCCommon.h
  clang/include/clang/Sema/DeclSpec.h
  clang/lib/ARCMigrate/TransGCAttrs.cpp
  clang/lib/ARCMigrate/TransProperties.cpp
  clang/lib/ARCMigrate/TransZeroOutPropsInDealloc.cpp
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/DeclObjC.cpp
  clang/lib/AST/DeclPrinter.cpp
  clang/lib/AST/JSONNodeDumper.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/Analysis/BodyFarm.cpp
  clang/lib/CodeGen/CGObjC.cpp
  clang/lib/CodeGen/CGObjCGNU.cpp
  clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
  clang/lib/Frontend/Rewrite/RewriteObjC.cpp
  clang/lib/Parse/ParseObjc.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/lib/Sema/SemaExprObjC.cpp
  clang/lib/Sema/SemaObjCProperty.cpp
  clang/lib/Sema/SemaPseudoObject.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/tools/libclang/CIndex.cpp

Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -8141,11 +8141,10 @@
 
   unsigned Result = CXObjCPropertyAttr_noattr;
   const ObjCPropertyDecl *PD = dyn_cast(getCursorDecl(C));
-  ObjCPropertyDecl::PropertyAttributeKind Attr =
-  PD->getPropertyAttributesAsWritten();
+  ObjCPropertyAttributeKind Attr = PD->getPropertyAttributesAsWritten();
 
 #define SET_CXOBJCPROP_ATTR(A) \
-  if (Attr & ObjCPropertyDecl::OBJC_PR_##A)\
+  if (Attr & ObjCPropertyAttributeKind::OBJC_PR_##A)   \
   Result |= CXObjCPropertyAttr_##A
   SET_CXOBJCPROP_ATTR(readonly);
   SET_CXOBJCPROP_ATTR(getter);
Index: clang/lib/Serialization/ASTReaderDecl.cpp
===
--- clang/lib/Serialization/ASTReaderDecl.cpp
+++ clang/lib/Serialization/ASTReaderDecl.cpp
@@ -1280,9 +1280,9 @@
   TypeSourceInfo *TSI = readTypeSourceInfo();
   D->setType(T, TSI);
   D->setPropertyAttributes(
-  (ObjCPropertyDecl::PropertyAttributeKind)Record.readInt());
+  (ObjCPropertyAttributeKind)Record.readInt());
   D->setPropertyAttributesAsWritten(
-  (ObjCPropertyDecl::PropertyAttributeKind)Record.readInt());
+  (ObjCPropertyAttributeKind)Record.readInt());
   D->setPropertyImplementation(
   (ObjCPropertyDecl::PropertyControl)Record.readInt());
   DeclarationName GetterName = Record.readDeclarationName();
Index: clang/lib/Sema/SemaPseudoObject.cpp
===
--- clang/lib/Sema/SemaPseudoObject.cpp
+++ clang/lib/Sema/SemaPseudoObject.cpp
@@ -585,7 +585,7 @@
   QualType T;
   if (RefExpr->isExplicitProperty()) {
 const ObjCPropertyDecl *Prop = RefExpr->getExplicitProperty();
-if (Prop->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_weak)
+if (Prop->getPropertyAttributes() & ObjCPropertyAttributeKind::OBJC_PR_weak)
   return true;
 
 T = Prop->getType();
Index: clang/lib/Sema/SemaObjCProperty.cpp
===
--- clang/lib/Sema/SemaObjCProperty.cpp
+++ clang/lib/Sema/SemaObjCProperty.cpp
@@ -35,24 +35,23 @@
 ///
 /// Returns OCL_None if the attributes as stated do not imply an ownership.
 /// Never returns OCL_Autoreleasing.
-static Qualifiers::ObjCLifetime getImpliedARCOwnership(
-   ObjCPropertyDecl::PropertyAttributeKind attrs,
-QualType type) {
+static Qualifiers::ObjCLifetime
+getImpliedARCOwnership(ObjCPropertyAttributeKind attrs, QualType type) {
   // retain, strong, copy, weak, and unsafe_unretained are only legal
   // on properties of retainable pointer type.
-  if (attrs & (ObjCPropertyDecl::OBJC_PR_retain |
-   ObjCPropertyDecl::OBJC_PR_strong |
-   ObjCPropertyDecl::OBJC_PR_copy)) {
+  if (attrs & (ObjCPropertyAttributeKind::OBJC_PR_retain |
+   ObjCPropertyAttributeKind::OBJC_PR_strong |
+   ObjCPropertyAttributeKind::OBJC_PR_copy)) {
 return Qualifiers::OCL_Strong;
-  } else if (attrs & ObjCPropertyDecl::OBJC_PR_weak) {
+  } else if (attrs & ObjCPropertyAttributeKind::OBJC_PR_weak) {
 return Qualifiers::OCL_Weak;
-  } else if (attrs & ObjCPropertyDecl::OBJC_PR_unsafe_unretained) {
+  } else if (attrs & ObjCPropertyAttributeKind::OBJC_PR_unsafe_unretained) {
 return Qualifiers::OCL_ExplicitNone;
   }
 
   // assign can appear on other types, so we have to check the
   // property type.
-  if (attrs & ObjCPropertyDecl::OBJC_PR_assign &&
+  if (attrs & 

[PATCH] D77168: Add a flag to debug automatic variable initialization

2020-04-01 Thread Stephen Hines via Phabricator via cfe-commits
srhines added a comment.

In D77168#1955312 , @jfb wrote:

> Do you not think `pragma` is a more general approach? That's what's used in a 
> bunch of other cases, and I'd like to see it attempted here.
>  If not, I agree with John that just counting up isn't a good bisection 
> experience. I'd rather see a begin / end bound.


I agree that begin/end is actually better.

My experience has been that you really don't want to be modifying source files 
if you can avoid it, as that is harder to automate in a script. And you do want 
to script this kind of debugging because it isn't a compiler crash, it's often 
a runtime issue that might take longer to reproduce/etc., so I think that it is 
preferable to remove the human (error prone) element of adding/tweaking 
pragmas. I did say that the pragmas are useful in other ways, but I don't think 
that it is effective for everything.

> You're also missing the auto-init in `initializeAlloca`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77168



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


[PATCH] D76812: [X86] Add Indirect Thunk Support to X86 to mitigate Load Value Injection (LVI) [3/3]

2020-04-01 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: llvm/lib/Target/X86/X86IndirectThunks.cpp:97
+  void populateThunk(MachineFunction ) {
+// This code mitigates LVI by replacing each indirect call/jump with a 
direct
+// call/jump to a thunk that looks like:

Why don't you need the code from retpoline that erases extra BBs?


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

https://reviews.llvm.org/D76812



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


[PATCH] D76932: [AIX] emit .extern and .weak directive linkage

2020-04-01 Thread Jason Liu via Phabricator via cfe-commits
jasonliu added a comment.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76932



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


[PATCH] D77233: [NFC] Refactoring PropertyAttributeKind for ObjCPropertyDecl and ObjCDeclSpec.

2020-04-01 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi created this revision.
plotfi added reviewers: compnerd, manmanren.
Herald added subscribers: cfe-commits, arphaman.
Herald added a project: clang.
plotfi edited the summary of this revision.
plotfi updated this revision to Diff 254259.
plotfi added a comment.
Herald added a subscriber: jfb.
plotfi added a reviewer: jfb.
Herald added a subscriber: dexonsmith.

 Clipboard gave me junk the first submit. Sorry


I noticed PropertyAttributeKind / ObjCPropertyAttributeKind enums in 
ObjCPropertyDecl and ObjCDeclSpec are exactly identical. This is a 
non-functional change to make these two enums less redundant.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77233

Files:
  clang/include/clang/AST/DeclObjC.h
  clang/include/clang/AST/DeclObjCCommon.h
  clang/include/clang/Sema/DeclSpec.h
  clang/lib/ARCMigrate/TransGCAttrs.cpp
  clang/lib/ARCMigrate/TransProperties.cpp
  clang/lib/ARCMigrate/TransZeroOutPropsInDealloc.cpp
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/DeclObjC.cpp
  clang/lib/AST/DeclPrinter.cpp
  clang/lib/AST/JSONNodeDumper.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/Analysis/BodyFarm.cpp
  clang/lib/CodeGen/CGObjC.cpp
  clang/lib/CodeGen/CGObjCGNU.cpp
  clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
  clang/lib/Frontend/Rewrite/RewriteObjC.cpp
  clang/lib/Parse/ParseObjc.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/lib/Sema/SemaExprObjC.cpp
  clang/lib/Sema/SemaObjCProperty.cpp
  clang/lib/Sema/SemaPseudoObject.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/tools/libclang/CIndex.cpp

Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -8141,11 +8141,10 @@
 
   unsigned Result = CXObjCPropertyAttr_noattr;
   const ObjCPropertyDecl *PD = dyn_cast(getCursorDecl(C));
-  ObjCPropertyDecl::PropertyAttributeKind Attr =
-  PD->getPropertyAttributesAsWritten();
+  ObjCPropertyAttributeKind Attr = PD->getPropertyAttributesAsWritten();
 
 #define SET_CXOBJCPROP_ATTR(A) \
-  if (Attr & ObjCPropertyDecl::OBJC_PR_##A)\
+  if (Attr & ObjCPropertyAttributeKind::OBJC_PR_##A)   \
   Result |= CXObjCPropertyAttr_##A
   SET_CXOBJCPROP_ATTR(readonly);
   SET_CXOBJCPROP_ATTR(getter);
Index: clang/lib/Serialization/ASTReaderDecl.cpp
===
--- clang/lib/Serialization/ASTReaderDecl.cpp
+++ clang/lib/Serialization/ASTReaderDecl.cpp
@@ -1280,9 +1280,9 @@
   TypeSourceInfo *TSI = readTypeSourceInfo();
   D->setType(T, TSI);
   D->setPropertyAttributes(
-  (ObjCPropertyDecl::PropertyAttributeKind)Record.readInt());
+  (ObjCPropertyAttributeKind)Record.readInt());
   D->setPropertyAttributesAsWritten(
-  (ObjCPropertyDecl::PropertyAttributeKind)Record.readInt());
+  (ObjCPropertyAttributeKind)Record.readInt());
   D->setPropertyImplementation(
   (ObjCPropertyDecl::PropertyControl)Record.readInt());
   DeclarationName GetterName = Record.readDeclarationName();
Index: clang/lib/Sema/SemaPseudoObject.cpp
===
--- clang/lib/Sema/SemaPseudoObject.cpp
+++ clang/lib/Sema/SemaPseudoObject.cpp
@@ -585,7 +585,7 @@
   QualType T;
   if (RefExpr->isExplicitProperty()) {
 const ObjCPropertyDecl *Prop = RefExpr->getExplicitProperty();
-if (Prop->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_weak)
+if (Prop->getPropertyAttributes() & ObjCPropertyAttributeKind::OBJC_PR_weak)
   return true;
 
 T = Prop->getType();
Index: clang/lib/Sema/SemaObjCProperty.cpp
===
--- clang/lib/Sema/SemaObjCProperty.cpp
+++ clang/lib/Sema/SemaObjCProperty.cpp
@@ -35,24 +35,23 @@
 ///
 /// Returns OCL_None if the attributes as stated do not imply an ownership.
 /// Never returns OCL_Autoreleasing.
-static Qualifiers::ObjCLifetime getImpliedARCOwnership(
-   ObjCPropertyDecl::PropertyAttributeKind attrs,
-QualType type) {
+static Qualifiers::ObjCLifetime
+getImpliedARCOwnership(ObjCPropertyAttributeKind attrs, QualType type) {
   // retain, strong, copy, weak, and unsafe_unretained are only legal
   // on properties of retainable pointer type.
-  if (attrs & (ObjCPropertyDecl::OBJC_PR_retain |
-   ObjCPropertyDecl::OBJC_PR_strong |
-   ObjCPropertyDecl::OBJC_PR_copy)) {
+  if (attrs & (ObjCPropertyAttributeKind::OBJC_PR_retain |
+   ObjCPropertyAttributeKind::OBJC_PR_strong |
+   ObjCPropertyAttributeKind::OBJC_PR_copy)) {
 return Qualifiers::OCL_Strong;
-  } else if (attrs & ObjCPropertyDecl::OBJC_PR_weak) {
+  } else if (attrs & ObjCPropertyAttributeKind::OBJC_PR_weak) {
 

RE: [clang] 6f428e0 - [AST] Fix crashes on decltype(recovery-expr).

2020-04-01 Thread Yung, Douglas via cfe-commits
Hi Haojian,

I noticed that after your change, the compiler is now giving an error when 
trying to create a vector of >= 1024 elements when previously it worked, and 
gcc has no problem with the same code. Is that intentional? I have put the 
details in PR45387, can you take a look?

Douglas Yung

-Original Message-
From: cfe-commits  On Behalf Of Haojian Wu 
via cfe-commits
Sent: Monday, March 30, 2020 5:57
To: cfe-commits@lists.llvm.org
Subject: [clang] 6f428e0 - [AST] Fix crashes on decltype(recovery-expr).


Author: Haojian Wu
Date: 2020-03-30T14:56:33+02:00
New Revision: 6f428e09fbe8ce7e3510ae024031a5fc19653483

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

LOG: [AST] Fix crashes on decltype(recovery-expr).

Summary: We mark these decls as invalid.

Reviewers: sammccall

Subscribers: cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/AST/DependenceFlags.h
clang/include/clang/AST/Type.h
clang/lib/Parse/ParseExprCXX.cpp
clang/lib/Sema/SemaType.cpp
clang/test/AST/ast-dump-expr-errors.cpp
clang/test/Sema/invalid-member.cpp
clang/unittests/Sema/CodeCompleteTest.cpp

Removed: 




diff  --git a/clang/include/clang/AST/DependenceFlags.h 
b/clang/include/clang/AST/DependenceFlags.h
index 75c9aa1656b8..0b24bae6df9b 100644
--- a/clang/include/clang/AST/DependenceFlags.h
+++ b/clang/include/clang/AST/DependenceFlags.h
@@ -50,14 +50,16 @@ struct TypeDependenceScope {
 /// Whether this type is a variably-modified type (C99 6.7.5).
 VariablyModified = 8,
 
-// FIXME: add Error bit.
+/// Whether this type references an error, e.g. decltype(err-expression)
+/// yields an error type.
+Error = 16,
 
 None = 0,
-All = 15,
+All = 31,
 
 DependentInstantiation = Dependent | Instantiation,
 
-LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/VariablyModified)
+LLVM_MARK_AS_BITMASK_ENUM(/*LargestValue=*/Error)
   };
 };
 using TypeDependence = TypeDependenceScope::TypeDependence;
@@ -147,6 +149,7 @@ class Dependence {
 return translate(V, UnexpandedPack, TypeDependence::UnexpandedPack) |
translate(V, Instantiation, TypeDependence::Instantiation) |
translate(V, Dependent, TypeDependence::Dependent) |
+   translate(V, Error, TypeDependence::Error) |
translate(V, VariablyModified, TypeDependence::VariablyModified);
   }
 

diff  --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h 
index 248fbcfba98e..5d2c035ea0fe 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -2139,6 +2139,11 @@ class alignas(8) Type : public ExtQualsTypeCommonBase {
 return static_cast(TypeBits.Dependence);
   }
 
+  /// Whether this type is an error type.
+  bool containsErrors() const {
+return getDependence() & TypeDependence::Error;  }
+
   /// Whether this type is a dependent type, meaning that its definition
   /// somehow depends on a template parameter (C++ [temp.dep.type]).
   bool isDependentType() const {

diff  --git a/clang/lib/Parse/ParseExprCXX.cpp 
b/clang/lib/Parse/ParseExprCXX.cpp
index 761fad9456be..4389c8777c6d 100644
--- a/clang/lib/Parse/ParseExprCXX.cpp
+++ b/clang/lib/Parse/ParseExprCXX.cpp
@@ -3105,10 +3105,14 @@ Parser::ParseCXXNewExpression(bool UseGlobal, 
SourceLocation Start) {
   auto RunSignatureHelp = [&]() {
 ParsedType TypeRep =
 Actions.ActOnTypeName(getCurScope(), DeclaratorInfo).get();
-assert(TypeRep && "invalid types should be handled before");
-QualType PreferredType = Actions.ProduceConstructorSignatureHelp(
-getCurScope(), TypeRep.get()->getCanonicalTypeInternal(),
-DeclaratorInfo.getEndLoc(), ConstructorArgs, ConstructorLParen);
+QualType PreferredType;
+// ActOnTypeName might adjust DeclaratorInfo and return a null type 
even
+// the passing DeclaratorInfo is valid, e.g. running SignatureHelp on
+// `new decltype(invalid) (^)`.
+if (TypeRep)
+  PreferredType = Actions.ProduceConstructorSignatureHelp(
+  getCurScope(), TypeRep.get()->getCanonicalTypeInternal(),
+  DeclaratorInfo.getEndLoc(), ConstructorArgs, 
+ ConstructorLParen);
 CalledSignatureHelp = true;
 return PreferredType;
   };

diff  --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index 
55ce028fb8c2..e128ebf31270 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -1678,6 +1678,12 @@ static QualType 
ConvertDeclSpecToType(TypeProcessingState ) {
 break;
   }
 
+  // FIXME: we want resulting declarations to be marked invalid, but 
+ claiming  // the type is invalid is 

[PATCH] D77205: [X86] Add TSXLDTRK instructions.

2020-04-01 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper 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/D77205/new/

https://reviews.llvm.org/D77205



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


  1   2   3   >