[PATCH] D47103: Implement strip.invariant.group

2018-05-21 Thread Krzysztof Pszeniczny via Phabricator via cfe-commits
amharc added inline comments.



Comment at: clang/include/clang/AST/DeclCXX.h:778
 
+  bool mayBeDynamicClass() const {
+return !isCompleteDefinition() || isDynamicClass();

xbolva00 wrote:
> maybeDynamicClass?
> 
> https://github.com/llvm-mirror/llvm/search?utf8=%E2%9C%93=maybe=
I think `mayBe` is more appropriate, because it grammatically consists of 'may' 
and 'be'. In this form it appears in multiple places in the codebase, too. A 
few examples:

https://github.com/llvm-mirror/llvm/blob/0b24b74655b976aaba01b2f726659b8c745a16de/include/llvm/IR/GlobalValue.h#L131
https://github.com/llvm-mirror/clang/blob/647be32c6048e24f90f470c557e850597e5526c3/lib/AST/DeclCXX.cpp#L1800
https://github.com/llvm-mirror/llvm/blob/77438c3c98c0901fa9ef56f78bdefccedc16fcc4/lib/Analysis/ValueTracking.cpp#L3659


Repository:
  rL LLVM

https://reviews.llvm.org/D47103



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


[libcxx] r332931 - Missed the tests for the deduction guides for prority_queue

2018-05-21 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Mon May 21 19:19:38 2018
New Revision: 332931

URL: http://llvm.org/viewvc/llvm-project?rev=332931=rev
Log:
Missed the tests for the deduction guides for prority_queue

Added:

libcxx/trunk/test/std/containers/container.adaptors/priority.queue/priqueue.cons/deduct.fail.cpp

libcxx/trunk/test/std/containers/container.adaptors/priority.queue/priqueue.cons/deduct.pass.cpp

Added: 
libcxx/trunk/test/std/containers/container.adaptors/priority.queue/priqueue.cons/deduct.fail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/container.adaptors/priority.queue/priqueue.cons/deduct.fail.cpp?rev=332931=auto
==
--- 
libcxx/trunk/test/std/containers/container.adaptors/priority.queue/priqueue.cons/deduct.fail.cpp
 (added)
+++ 
libcxx/trunk/test/std/containers/container.adaptors/priority.queue/priqueue.cons/deduct.fail.cpp
 Mon May 21 19:19:38 2018
@@ -0,0 +1,58 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+// UNSUPPORTED: libcpp-no-deduction-guides
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+
+int main()
+{  
+//  Test the explicit deduction guides
+{
+//  queue(Compare, Container, const Alloc);
+//  The '45' is not an allocator
+std::priority_queue pri(std::greater(), std::deque({1,2,3}), 
45);  // expected-error {{no viable constructor or deduction guide for 
deduction of template arguments of 'priority_queue'}}
+}
+
+{
+//  queue(const queue&, const Alloc&);
+//  The '45' is not an allocator
+std::priority_queue source;
+std::priority_queue pri(source, 45);  // expected-error {{no viable 
constructor or deduction guide for deduction of template arguments of 
'priority_queue'}}
+}
+
+{
+//  priority_queue(Iter, Iter, Comp)  
+//  int is not an iterator
+std::priority_queue pri(15, 17, std::greater());  // 
expected-error {{no viable constructor or deduction guide for deduction of 
template arguments of 'priority_queue'}}
+}
+
+{
+//  priority_queue(Iter, Iter, Comp, Container)
+//  float is not an iterator
+std::priority_queue pri(23.f, 2.f, std::greater(), 
std::deque());   // expected-error {{no viable constructor or deduction 
guide for deduction of template arguments of 'priority_queue'}}
+}
+
+//  Test the implicit deduction guides
+{
+//  priority_queue (allocator &)
+std::priority_queue pri((std::allocator()));  // expected-error {{no 
viable constructor or deduction guide for deduction of template arguments of 
'priority_queue'}}
+//  Note: The extra parens are necessary, since otherwise clang decides it is 
a function declaration.
+//  Also, we can't use {} instead of parens, because that constructs a
+//  stack>
+}
+
+}

Added: 
libcxx/trunk/test/std/containers/container.adaptors/priority.queue/priqueue.cons/deduct.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/container.adaptors/priority.queue/priqueue.cons/deduct.pass.cpp?rev=332931=auto
==
--- 
libcxx/trunk/test/std/containers/container.adaptors/priority.queue/priqueue.cons/deduct.pass.cpp
 (added)
+++ 
libcxx/trunk/test/std/containers/container.adaptors/priority.queue/priqueue.cons/deduct.pass.cpp
 Mon May 21 19:19:38 2018
@@ -0,0 +1,123 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+// UNSUPPORTED: libcpp-no-deduction-guides
+
+// template
+// priority_queue(Compare, Container)
+// -> priority_queue;
+// 
+// template::value_type>,
+//  class Container = vector::value_type>>
+// priority_queue(InputIterator, InputIterator, Compare = Compare(), Container 
= Container())
+// -> priority_queue::value_type, 
Container, Compare>;
+// 
+// template
+// priority_queue(Compare, Container, Allocator)
+// -> priority_queue;
+
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include  // INT_MAX
+
+#include "test_macros.h"
+#include "test_iterators.h"
+#include "test_allocator.h"
+
+struct A {};
+
+int main()
+{
+  
+//  Test the explicit deduction guides
+{
+std::vector v{0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
+std::priority_queue 

r332929 - [X86] Prevent inclusion of __wmmintrin_aes.h and __wmmintrin_pclmul.h without including wmmintrin.h

2018-05-21 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Mon May 21 19:02:13 2018
New Revision: 332929

URL: http://llvm.org/viewvc/llvm-project?rev=332929=rev
Log:
[X86] Prevent inclusion of __wmmintrin_aes.h and __wmmintrin_pclmul.h without 
including wmmintrin.h

Modified:
cfe/trunk/lib/Headers/__wmmintrin_aes.h
cfe/trunk/lib/Headers/__wmmintrin_pclmul.h

Modified: cfe/trunk/lib/Headers/__wmmintrin_aes.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__wmmintrin_aes.h?rev=332929=332928=332929=diff
==
--- cfe/trunk/lib/Headers/__wmmintrin_aes.h (original)
+++ cfe/trunk/lib/Headers/__wmmintrin_aes.h Mon May 21 19:02:13 2018
@@ -20,11 +20,14 @@
  *
  *===---===
  */
+
+#ifndef __WMMINTRIN_H
+#error "Never use <__wmmintrin_aes.h> directly; include  instead."
+#endif
+
 #ifndef __WMMINTRIN_AES_H
 #define __WMMINTRIN_AES_H
 
-#include 
-
 /* Define the default attributes for the functions in this file. */
 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, 
__target__("aes")))
 

Modified: cfe/trunk/lib/Headers/__wmmintrin_pclmul.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__wmmintrin_pclmul.h?rev=332929=332928=332929=diff
==
--- cfe/trunk/lib/Headers/__wmmintrin_pclmul.h (original)
+++ cfe/trunk/lib/Headers/__wmmintrin_pclmul.h Mon May 21 19:02:13 2018
@@ -20,6 +20,11 @@
  *
  *===---===
  */
+
+#ifndef __WMMINTRIN_H
+#error "Never use <__wmmintrin_pclmul.h> directly; include  
instead."
+#endif
+
 #ifndef __WMMINTRIN_PCLMUL_H
 #define __WMMINTRIN_PCLMUL_H
 


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


[libcxx] r332927 - Deduction guides for the container adaptors - queue, stack, and priority_queue

2018-05-21 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Mon May 21 18:57:53 2018
New Revision: 332927

URL: http://llvm.org/viewvc/llvm-project?rev=332927=rev
Log:
Deduction guides for the container adaptors - queue, stack, and priority_queue

Added:

libcxx/trunk/test/std/containers/container.adaptors/queue/queue.cons/deduct.fail.cpp

libcxx/trunk/test/std/containers/container.adaptors/queue/queue.cons/deduct.pass.cpp

libcxx/trunk/test/std/containers/container.adaptors/stack/stack.cons/deduct.fail.cpp

libcxx/trunk/test/std/containers/container.adaptors/stack/stack.cons/deduct.pass.cpp
Modified:
libcxx/trunk/include/queue
libcxx/trunk/include/stack

Modified: libcxx/trunk/include/queue
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/queue?rev=332927=332926=332927=diff
==
--- libcxx/trunk/include/queue (original)
+++ libcxx/trunk/include/queue Mon May 21 18:57:53 2018
@@ -69,6 +69,12 @@ public:
 void swap(queue& q) noexcept(is_nothrow_swappable_v)
 };
 
+template
+  queue(Container) -> queue; // 
C++17
+  
+template 
+  queue(Container, Allocator) -> queue; // C++17
+
 template 
   bool operator==(const queue& x,const queue& y);
 
@@ -157,6 +163,20 @@ public:
  is_nothrow_swappable_v)
 };
 
+template 
+priority_queue(Compare, Container)
+-> priority_queue; // 
C++17
+  
+template::value_type>,
+ class Container = vector::value_type>>
+priority_queue(InputIterator, InputIterator, Compare = Compare(), Container = 
Container())
+-> priority_queue::value_type, 
Container, Compare>; // C++17
+  
+template
+priority_queue(Compare, Container, Allocator)
+-> priority_queue; // 
C++17
+
 template 
   void swap(priority_queue& x,
 priority_queue& y)
@@ -321,6 +341,22 @@ public:
 operator< (const queue<_T1, _C1>& __x,const queue<_T1, _C1>& __y);
 };
 
+#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
+template::value, 
nullptr_t>::type
+>
+queue(_Container)
+-> queue;
+  
+template::value, 
nullptr_t>::type,
+ class = typename enable_if< __is_allocator<_Alloc>::value, 
nullptr_t>::type
+>
+queue(_Container, _Alloc)
+-> queue;
+#endif
+
 template 
 inline _LIBCPP_INLINE_VISIBILITY
 bool
@@ -515,6 +551,36 @@ public:
__is_nothrow_swappable::value);
 };
 
+#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
+template ::value, 
nullptr_t>::type,
+  class = typename enable_if::value, 
nullptr_t>::type
+>
+priority_queue(_Compare, _Container)
+-> priority_queue;
+  
+template::value_type>,
+ class _Container = vector::value_type>,
+ class = typename enable_if< 
__is_input_iterator<_InputIterator>::value, nullptr_t>::type,
+ class = typename enable_if::value, 
nullptr_t>::type,
+ class = typename enable_if::value, 
nullptr_t>::type
+>
+priority_queue(_InputIterator, _InputIterator, _Compare = _Compare(), 
_Container = _Container())
+-> priority_queue::value_type, 
_Container, _Compare>;
+  
+template::value, 
nullptr_t>::type,
+ class = typename enable_if::value, 
nullptr_t>::type,
+ class = typename enable_if< __is_allocator<_Alloc>::value, 
nullptr_t>::type
+>
+priority_queue(_Compare, _Container, _Alloc)
+-> priority_queue;
+#endif
+
 template 
 inline
 priority_queue<_Tp, _Container, _Compare>::priority_queue(const _Compare& 
__comp,

Modified: libcxx/trunk/include/stack
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/stack?rev=332927=332926=332927=diff
==
--- libcxx/trunk/include/stack (original)
+++ libcxx/trunk/include/stack Mon May 21 18:57:53 2018
@@ -61,6 +61,12 @@ public:
 void swap(stack& c) noexcept(is_nothrow_swappable_v)
 };
 
+template
+  stack(Container) -> stack;  // 
C++17
+  
+template 
+  stack(Container, Allocator) -> stack; // C++17
+
 template 
   bool operator==(const stack& x, const stack& y);
 template 
@@ -229,6 +235,22 @@ public:
 operator< (const stack& __x, const stack& __y);
 };
 
+#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
+template::value, 
nullptr_t>::type
+>
+stack(_Container)
+-> stack;
+  
+template::value, 
nullptr_t>::type,
+ class = typename enable_if< __is_allocator<_Alloc>::value, 
nullptr_t>::type
+ > 
+stack(_Container, _Alloc)
+-> stack;
+#endif
+
 template 
 inline _LIBCPP_INLINE_VISIBILITY
 bool

Added: 
libcxx/trunk/test/std/containers/container.adaptors/queue/queue.cons/deduct.fail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/container.adaptors/queue/queue.cons/deduct.fail.cpp?rev=332927=auto
==
--- 
libcxx/trunk/test/std/containers/container.adaptors/queue/queue.cons/deduct.fail.cpp
 (added)
+++ 

[PATCH] D47174: [X86] Move 128-bit f16c intrinsics to __emmintrin_f16c.h include from emmintrin.h. Move 256-bit f16c intrinsics back to f16cintrin.h

2018-05-21 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: lib/Headers/immintrin.h:72
 
-/* The 256-bit versions of functions in f16cintrin.h.
-   Intel documents these as being in immintrin.h, and

Interesting this to note here, the 256-bit f16c intrinsics were being guarded 
by __AVX2__ when MSC_VER was defined and modules weren't supported. This was 
definitely incorrect.


Repository:
  rC Clang

https://reviews.llvm.org/D47174



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


[PATCH] D47175: [DOXYGEN] Formatting changes for better intrinsics documentation rendering

2018-05-21 Thread Katya Romanova via Phabricator via cfe-commits
kromanova created this revision.
Herald added a subscriber: cfe-commits.

Below are a few doxygen intrisics documentation changes requested by our 
documentation team:

(1) I added some \see cross-references to a few select intrinsics that are 
related (and have the same or very similar semantics). 
https://www.stack.nl/~dimitri/doxygen/manual/commands.html#cmdsee

If someone's version of doxygen doesn't support \see directive, please speak 
up! We will try to come up with a different solution.

bmiintrin.h
__bextr_u32 and _bextr_u32
__bextr_u64 and _bextr_u64

lzcntintrin.h:
__lzcnt32 and _lzcnt_u32
__lzcnt64 and _lzcnt_u64

(2) pmmintrin.h, smmintrin.h, xmmintrin.h have very few minor formatting 
changes. They make rendering of our intrinsics documentation better. I don't 
foresee these changes affect anyone's documentation negatively.


Repository:
  rC Clang

https://reviews.llvm.org/D47175

Files:
  lib/Headers/bmiintrin.h
  lib/Headers/lzcntintrin.h
  lib/Headers/pmmintrin.h
  lib/Headers/smmintrin.h
  lib/Headers/xmmintrin.h

Index: lib/Headers/xmmintrin.h
===
--- lib/Headers/xmmintrin.h
+++ lib/Headers/xmmintrin.h
@@ -2495,10 +2495,14 @@
 ///
 ///For example, the following expression checks if an overflow exception has
 ///occurred:
+///\code
 ///  ( _mm_getcsr() & _MM_EXCEPT_OVERFLOW )
+///\endcode
 ///
 ///The following expression gets the current rounding mode:
+///\code
 ///  _MM_GET_ROUNDING_MODE()
+///\endcode
 ///
 /// \headerfile 
 ///
Index: lib/Headers/smmintrin.h
===
--- lib/Headers/smmintrin.h
+++ lib/Headers/smmintrin.h
@@ -493,7 +493,7 @@
 /// \param __V2
 ///A 128-bit vector of [16 x i8].
 /// \param __M
-///A 128-bit vector operand, with mask bits 127, 119, 111 ... 7 specifying
+///A 128-bit vector operand, with mask bits 127, 119, 111...7 specifying
 ///how the values are to be copied. The position of the mask bit corresponds
 ///to the most significant bit of a copied value. When a mask bit is 0, the
 ///corresponding 8-bit element in operand \a __V1 is copied to the same
@@ -1277,8 +1277,8 @@
 /// This intrinsic corresponds to the  VPMOVSXBD / PMOVSXBD  instruction.
 ///
 /// \param __V
-///A 128-bit vector of [16 x i8]. The lower four 8-bit elements are sign-
-///extended to 32-bit values.
+///A 128-bit vector of [16 x i8]. The lower four 8-bit elements are
+///sign-extended to 32-bit values.
 /// \returns A 128-bit vector of [4 x i32] containing the sign-extended values.
 static __inline__ __m128i __DEFAULT_FN_ATTRS
 _mm_cvtepi8_epi32(__m128i __V)
@@ -1298,8 +1298,8 @@
 /// This intrinsic corresponds to the  VPMOVSXBQ / PMOVSXBQ  instruction.
 ///
 /// \param __V
-///A 128-bit vector of [16 x i8]. The lower two 8-bit elements are sign-
-///extended to 64-bit values.
+///A 128-bit vector of [16 x i8]. The lower two 8-bit elements are
+///sign-extended to 64-bit values.
 /// \returns A 128-bit vector of [2 x i64] containing the sign-extended values.
 static __inline__ __m128i __DEFAULT_FN_ATTRS
 _mm_cvtepi8_epi64(__m128i __V)
@@ -1319,8 +1319,8 @@
 /// This intrinsic corresponds to the  VPMOVSXWD / PMOVSXWD  instruction.
 ///
 /// \param __V
-///A 128-bit vector of [8 x i16]. The lower four 16-bit elements are sign-
-///extended to 32-bit values.
+///A 128-bit vector of [8 x i16]. The lower four 16-bit elements are
+///sign-extended to 32-bit values.
 /// \returns A 128-bit vector of [4 x i32] containing the sign-extended values.
 static __inline__ __m128i __DEFAULT_FN_ATTRS
 _mm_cvtepi16_epi32(__m128i __V)
@@ -1338,8 +1338,8 @@
 /// This intrinsic corresponds to the  VPMOVSXWQ / PMOVSXWQ  instruction.
 ///
 /// \param __V
-///A 128-bit vector of [8 x i16]. The lower two 16-bit elements are sign-
-///extended to 64-bit values.
+///A 128-bit vector of [8 x i16]. The lower two 16-bit elements are
+/// sign-extended to 64-bit values.
 /// \returns A 128-bit vector of [2 x i64] containing the sign-extended values.
 static __inline__ __m128i __DEFAULT_FN_ATTRS
 _mm_cvtepi16_epi64(__m128i __V)
@@ -1357,8 +1357,8 @@
 /// This intrinsic corresponds to the  VPMOVSXDQ / PMOVSXDQ  instruction.
 ///
 /// \param __V
-///A 128-bit vector of [4 x i32]. The lower two 32-bit elements are sign-
-///extended to 64-bit values.
+///A 128-bit vector of [4 x i32]. The lower two 32-bit elements are
+///sign-extended to 64-bit values.
 /// \returns A 128-bit vector of [2 x i64] containing the sign-extended values.
 static __inline__ __m128i __DEFAULT_FN_ATTRS
 _mm_cvtepi32_epi64(__m128i __V)
@@ -1377,8 +1377,8 @@
 /// This intrinsic corresponds to the  VPMOVZXBW / PMOVZXBW  instruction.
 ///
 /// \param __V
-///A 128-bit vector of [16 x i8]. The lower eight 8-bit elements are zero-
-///extended to 16-bit values.
+///A 128-bit 

[PATCH] D47174: [X86] Move 128-bit f16c intrinsics to __emmintrin_f16c.h include from emmintrin.h. Move 256-bit f16c intrinsics back to f16cintrin.h

2018-05-21 Thread Craig Topper via Phabricator via cfe-commits
craig.topper created this revision.
craig.topper added reviewers: RKSimon, spatel, echristo, DavidKreitzer.

Intel documents the 128-bit versions as being in emmintrin.h and the 256-bit 
version as being in immintrin.h.

This patch makes a new __emmtrin_f16c.h to hold the 128-bit versions to be 
included from emmintrin.h. And makes the existing f16cintrin.h contain the 
256-bit versions and include it from immintrin.h with an error if its included 
directly.


Repository:
  rC Clang

https://reviews.llvm.org/D47174

Files:
  lib/Headers/__emmintrin_f16c.h
  lib/Headers/emmintrin.h
  lib/Headers/f16cintrin.h
  lib/Headers/immintrin.h

Index: lib/Headers/immintrin.h
===
--- lib/Headers/immintrin.h
+++ lib/Headers/immintrin.h
@@ -69,54 +69,8 @@
 #if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX2__)
 #include 
 
-/* The 256-bit versions of functions in f16cintrin.h.
-   Intel documents these as being in immintrin.h, and
-   they depend on typedefs from avxintrin.h. */
-
-/// Converts a 256-bit vector of [8 x float] into a 128-bit vector
-///containing 16-bit half-precision float values.
-///
-/// \headerfile 
-///
-/// \code
-/// __m128i _mm256_cvtps_ph(__m256 a, const int imm);
-/// \endcode
-///
-/// This intrinsic corresponds to the  VCVTPS2PH  instruction.
-///
-/// \param a
-///A 256-bit vector containing 32-bit single-precision float values to be
-///converted to 16-bit half-precision float values.
-/// \param imm
-///An immediate value controlling rounding using bits [2:0]: \n
-///000: Nearest \n
-///001: Down \n
-///010: Up \n
-///011: Truncate \n
-///1XX: Use MXCSR.RC for rounding
-/// \returns A 128-bit vector containing the converted 16-bit half-precision
-///float values.
-#define _mm256_cvtps_ph(a, imm) __extension__ ({ \
- (__m128i)__builtin_ia32_vcvtps2ph256((__v8sf)(__m256)(a), (imm)); })
-
-/// Converts a 128-bit vector containing 16-bit half-precision float
-///values into a 256-bit vector of [8 x float].
-///
-/// \headerfile 
-///
-/// This intrinsic corresponds to the  VCVTPH2PS  instruction.
-///
-/// \param __a
-///A 128-bit vector containing 16-bit half-precision float values to be
-///converted to 32-bit single-precision float values.
-/// \returns A vector of [8 x float] containing the converted 32-bit
-///single-precision float values.
-static __inline __m256 __attribute__((__always_inline__, __nodebug__, __target__("f16c")))
-_mm256_cvtph_ps(__m128i __a)
-{
-  return (__m256)__builtin_ia32_vcvtph2ps256((__v8hi)__a);
-}
-#endif /* __AVX2__ */
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__F16C__)
+#include 
 
 #if !defined(_MSC_VER) || __has_feature(modules) || defined(__VPCLMULQDQ__)
 #include 
Index: lib/Headers/emmintrin.h
===
--- lib/Headers/emmintrin.h
+++ lib/Headers/emmintrin.h
@@ -44,7 +44,7 @@
  * appear in the interface though. */
 typedef signed char __v16qs __attribute__((__vector_size__(16)));
 
-#include 
+#include <__emmintrin_f16c.h>
 
 /* Define the default attributes for the functions in this file. */
 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("sse2")))
Index: lib/Headers/f16cintrin.h
===
--- lib/Headers/f16cintrin.h
+++ lib/Headers/f16cintrin.h
@@ -21,8 +21,8 @@
  *===---===
  */
 
-#if !defined __X86INTRIN_H && !defined __EMMINTRIN_H && !defined __IMMINTRIN_H
-#error "Never use  directly; include  instead."
+#if !defined __IMMINTRIN_H
+#error "Never use  directly; include  instead."
 #endif
 
 #ifndef __F16CINTRIN_H
@@ -32,91 +32,52 @@
 #define __DEFAULT_FN_ATTRS \
   __attribute__((__always_inline__, __nodebug__, __target__("f16c")))
 
-/// Converts a 16-bit half-precision float value into a 32-bit float
-///value.
-///
-/// \headerfile 
-///
-/// This intrinsic corresponds to the  VCVTPH2PS  instruction.
-///
-/// \param __a
-///A 16-bit half-precision float value.
-/// \returns The converted 32-bit float value.
-static __inline float __DEFAULT_FN_ATTRS
-_cvtsh_ss(unsigned short __a)
-{
-  __v8hi v = {(short)__a, 0, 0, 0, 0, 0, 0, 0};
-  __v4sf r = __builtin_ia32_vcvtph2ps(v);
-  return r[0];
-}
-
-/// Converts a 32-bit single-precision float value to a 16-bit
-///half-precision float value.
-///
-/// \headerfile 
-///
-/// \code
-/// unsigned short _cvtss_sh(float a, const int imm);
-/// \endcode
-///
-/// This intrinsic corresponds to the  VCVTPS2PH  instruction.
-///
-/// \param a
-///A 32-bit single-precision float value to be converted to a 16-bit
-///half-precision float value.
-/// \param imm
-///An immediate value controlling rounding using bits [2:0]: \n
-///000: Nearest \n
-///001: Down \n
-///010: Up \n
-///011: Truncate \n

[PATCH] D46919: [libclang] Deprecate CXPrintingPolicy_IncludeTagDefinition

2018-05-21 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny added a comment.

In https://reviews.llvm.org/D46919#1107296, @rsmith wrote:

> In https://reviews.llvm.org/D46919#1101268, @jdenny wrote:
>
> > In https://reviews.llvm.org/D46919#1100493, @rsmith wrote:
> >
> > > The deprecated enumerator is also referenced by 
> > > `tools/c-index-test/c-index-test.c`
> >
> >
> > This test prompted me to keep the IncludeTagDefinition member in 
> > PrintingPolicy so that clang_PrintingPolicy_getProperty would return the 
> > previous value set by clang_PrintingPolicy_setProperty.  Otherwise, the 
> > value doesn't have any effect.  Is that self-consistency not worth worrying 
> > about?  If so, I'll remove both.
>
>
> I don't think it's worth worrying about. We don't guarantee that the values 
> round-trip in general (most of them are `unsigned`s being written to a 
> `bool`, so we don't preserve values that are neither 0 nor 1).


I was actually thinking of a different test (see my comments from today), and 
it wants 0 and 1 to be preserved.


https://reviews.llvm.org/D46919



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


[PATCH] D47099: Disable casting of alloca for ActiveFlag

2018-05-21 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 147914.
yaxunl edited the summary of this revision.
yaxunl added a comment.

Revised by John's comments.


https://reviews.llvm.org/D47099

Files:
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGCleanup.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGenCXX/conditional-temporaries.cpp

Index: test/CodeGenCXX/conditional-temporaries.cpp
===
--- test/CodeGenCXX/conditional-temporaries.cpp
+++ test/CodeGenCXX/conditional-temporaries.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin9 -O3 | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=amdgcn-amd-amdhsa -O3 | FileCheck %s
 
 namespace {
 
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -2020,18 +2020,20 @@
   /// to the stack.
   ///
   /// Because the address of a temporary is often exposed to the program in
-  /// various ways, this function will perform the cast by default. The cast
-  /// may be avoided by passing false as \p CastToDefaultAddrSpace; this is
+  /// various ways, this function will perform the cast. The original alloca
+  /// instruction is returned through \p Alloca if it is not nullptr.
+  ///
+  /// The cast is not performaed in CreateTempAllocaWithoutCast. This is
   /// more efficient if the caller knows that the address will not be exposed.
-  /// The original alloca instruction is returned through \p Alloca if it is
-  /// not nullptr.
   llvm::AllocaInst *CreateTempAlloca(llvm::Type *Ty, const Twine  = "tmp",
  llvm::Value *ArraySize = nullptr);
   Address CreateTempAlloca(llvm::Type *Ty, CharUnits align,
const Twine  = "tmp",
llvm::Value *ArraySize = nullptr,
-   Address *Alloca = nullptr,
-   bool CastToDefaultAddrSpace = true);
+   Address *Alloca = nullptr);
+  Address CreateTempAllocaWithoutCast(llvm::Type *Ty, CharUnits align,
+  const Twine  = "tmp",
+  llvm::Value *ArraySize = nullptr);
 
   /// CreateDefaultAlignedTempAlloca - This creates an alloca with the
   /// default ABI alignment of the given LLVM type.
@@ -2066,15 +2068,18 @@
   Address CreateIRTemp(QualType T, const Twine  = "tmp");
 
   /// CreateMemTemp - Create a temporary memory object of the given type, with
-  /// appropriate alignment. Cast it to the default address space if
-  /// \p CastToDefaultAddrSpace is true. Returns the original alloca
-  /// instruction by \p Alloca if it is not nullptr.
+  /// appropriate alignmen and cast it to the default address space. Returns
+  /// the original alloca instruction by \p Alloca if it is not nullptr.
   Address CreateMemTemp(QualType T, const Twine  = "tmp",
-Address *Alloca = nullptr,
-bool CastToDefaultAddrSpace = true);
+Address *Alloca = nullptr);
   Address CreateMemTemp(QualType T, CharUnits Align, const Twine  = "tmp",
-Address *Alloca = nullptr,
-bool CastToDefaultAddrSpace = true);
+Address *Alloca = nullptr);
+
+  /// CreateMemTemp - Create a temporary memory object of the given type, with
+  /// appropriate alignmen without casting it to the default address space.
+  Address CreateMemTempWithoutCast(QualType T, const Twine  = "tmp");
+  Address CreateMemTempWithoutCast(QualType T, CharUnits Align,
+   const Twine  = "tmp");
 
   /// CreateAggTemp - Create a temporary memory object for the given
   /// aggregate type.
Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -61,21 +61,30 @@
 
 /// CreateTempAlloca - This creates a alloca and inserts it into the entry
 /// block.
+Address CodeGenFunction::CreateTempAllocaWithoutCast(llvm::Type *Ty,
+ CharUnits Align,
+ const Twine ,
+ llvm::Value *ArraySize) {
+  auto Alloca = CreateTempAlloca(Ty, Name, ArraySize);
+  Alloca->setAlignment(Align.getQuantity());
+  return Address(Alloca, Align);
+}
+
+/// CreateTempAlloca - This creates a alloca and inserts it into the entry
+/// block. The alloca is casted to default address space if necessary.
 Address CodeGenFunction::CreateTempAlloca(llvm::Type *Ty, CharUnits Align,
   const Twine ,
   llvm::Value *ArraySize,
-  Address *AllocaAddr,
-

[PATCH] D46919: [libclang] Deprecate CXPrintingPolicy_IncludeTagDefinition

2018-05-21 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In https://reviews.llvm.org/D46919#1101268, @jdenny wrote:

> In https://reviews.llvm.org/D46919#1100493, @rsmith wrote:
>
> > The deprecated enumerator is also referenced by 
> > `tools/c-index-test/c-index-test.c`
>
>
> This test prompted me to keep the IncludeTagDefinition member in 
> PrintingPolicy so that clang_PrintingPolicy_getProperty would return the 
> previous value set by clang_PrintingPolicy_setProperty.  Otherwise, the value 
> doesn't have any effect.  Is that self-consistency not worth worrying about?  
> If so, I'll remove both.


I don't think it's worth worrying about. We don't guarantee that the values 
round-trip in general (most of them are `unsigned`s being written to a `bool`, 
so we don't preserve values that are neither 0 nor 1).


https://reviews.llvm.org/D46919



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


[PATCH] D46439: [Sema] Fix incorrect packed aligned structure layout

2018-05-21 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In https://reviews.llvm.org/D46439#1106929, @probinson wrote:

> This wouldn't be another layout/ABI breakage, would it?


Yes, albeit for what I'd expect to be an extremely rare case.


Repository:
  rC Clang

https://reviews.llvm.org/D46439



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


[PATCH] D46979: [Fixed Point Arithmetic] Test for Conversion Between Valid Builtin Types

2018-05-21 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 147902.
leonardchan added a comment.

formatting


Repository:
  rC Clang

https://reviews.llvm.org/D46979

Files:
  include/clang/AST/OperationKinds.def
  lib/AST/Expr.cpp
  lib/AST/ExprConstant.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprAgg.cpp
  lib/CodeGen/CGExprComplex.cpp
  lib/CodeGen/CGExprConstant.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/Edit/RewriteObjCFoundationAPI.cpp
  lib/Sema/SemaExpr.cpp
  lib/StaticAnalyzer/Core/ExprEngineC.cpp
  test/Frontend/fixed_point_all_conversions.c

Index: test/Frontend/fixed_point_all_conversions.c
===
--- /dev/null
+++ test/Frontend/fixed_point_all_conversions.c
@@ -0,0 +1,74 @@
+// RUN: %clang_cc1 -Werror %s
+
+// Test for conversions between fixed point types and all other valid types.
+
+// Conversion from one type to another type
+#define CONVERT(FROM_TYPE, FROM_ID, TO_TYPE, TO_ID) \
+  TO_TYPE FROM_ID##_to_##TO_ID(FROM_TYPE x) { return x; }
+
+// Conversion between 2 types
+#define CONVERT_COMBINATION(TYPE1, ID1, TYPE2, ID2) \
+  CONVERT(TYPE1, ID1, TYPE2, ID2)   \
+  CONVERT(TYPE2, ID2, TYPE1, ID1)
+
+// Conversion between one type and floating point types
+#define CONVERT_BETWEEN_FLOATS(TYPE, ID)  \
+  CONVERT_COMBINATION(TYPE, ID, float, Float) \
+  CONVERT_COMBINATION(TYPE, ID, double, Double)
+
+// Conversion between one type and an integral type with differant signage
+#define CONVERT_BETWEEN_INTEGRALS_WITH_SIGN(TYPE, ID, INT_TYPE, INT_ID) \
+  CONVERT_COMBINATION(TYPE, ID, INT_TYPE, INT_ID)   \
+  CONVERT_COMBINATION(TYPE, ID, signed INT_TYPE, Signed##INT_ID)\
+  CONVERT_COMBINATION(TYPE, ID, unsigned INT_TYPE, Unsigned##INT_ID)
+
+// Conversion between one type and all integral types
+#define CONVERT_BETWEEN_INTEGRALS(TYPE, ID)   \
+  CONVERT_BETWEEN_INTEGRALS_WITH_SIGN(TYPE, ID, char, Char)   \
+  CONVERT_BETWEEN_INTEGRALS_WITH_SIGN(TYPE, ID, short, Short) \
+  CONVERT_BETWEEN_INTEGRALS_WITH_SIGN(TYPE, ID, int, Int) \
+  CONVERT_BETWEEN_INTEGRALS_WITH_SIGN(TYPE, ID, long, Long)   \
+  CONVERT_BETWEEN_INTEGRALS_WITH_SIGN(TYPE, ID, long long, LongLong)
+
+// Conversion between one type and a fixed point type with different saturation
+#define CONVERT_BETWEEN_FIXED_POINT_WITH_SAT(TYPE, ID, FIXED_TYPE, FIXED_ID) \
+  CONVERT_COMBINATION(TYPE, ID, FIXED_TYPE, FIXED_ID)\
+  CONVERT_COMBINATION(TYPE, ID, _Sat FIXED_TYPE, Sat##FIXED_ID)
+
+// Conversion between one type and a fixed point type with different signage
+#define CONVERT_BETWEEN_FIXED_POINT_WITH_SIGN(TYPE, ID, FIXED_TYPE, FIXED_ID) \
+  CONVERT_BETWEEN_FIXED_POINT_WITH_SAT(TYPE, ID, FIXED_TYPE, FIXED_ID)\
+  CONVERT_BETWEEN_FIXED_POINT_WITH_SAT(TYPE, ID, signed FIXED_TYPE,   \
+   Signed##FIXED_ID)  \
+  CONVERT_BETWEEN_FIXED_POINT_WITH_SAT(TYPE, ID, unsigned FIXED_TYPE, \
+   Unsigned##FIXED_ID)
+
+// Convert between one type and all fixed point types.
+// Add "Type" to the end of the ID to avoid multiple definitions of a function
+// if the Type is a fixed point type.
+#define CONVERT_BETWEEN_FIXED_POINT(TYPE, ID)\
+  CONVERT_BETWEEN_FIXED_POINT_WITH_SIGN(TYPE, ID, _Fract, FractType) \
+  CONVERT_BETWEEN_FIXED_POINT_WITH_SIGN(TYPE, ID, _Accum, AccumType)
+
+// Convert between one type and all other types
+#define CONVERT_BETWEEN_ALL_TYPES(TYPE, ID) \
+  CONVERT_BETWEEN_FLOATS(TYPE, ID)  \
+  CONVERT_BETWEEN_INTEGRALS(TYPE, ID)   \
+  CONVERT_BETWEEN_FIXED_POINT(TYPE, ID)
+
+#define CONVERT_FIXED_POINT_TYPE_WITH_SAT(TYPE, ID) \
+  CONVERT_BETWEEN_ALL_TYPES(TYPE, ID)   \
+  CONVERT_BETWEEN_ALL_TYPES(_Sat TYPE, Sat##ID)
+
+#define CONVERT_FIXED_POINT_TYPE(TYPE, ID)   \
+  CONVERT_FIXED_POINT_TYPE_WITH_SAT(TYPE, ID)\
+  CONVERT_FIXED_POINT_TYPE_WITH_SAT(signed TYPE, Signed##ID) \
+  CONVERT_FIXED_POINT_TYPE_WITH_SAT(unsigned TYPE, Unsigned##ID)
+
+CONVERT_FIXED_POINT_TYPE(short _Fract, ShortFract);
+CONVERT_FIXED_POINT_TYPE(_Fract, Fract);
+CONVERT_FIXED_POINT_TYPE(long _Fract, LongFract);
+
+CONVERT_FIXED_POINT_TYPE(short _Accum, ShortAccum);
+CONVERT_FIXED_POINT_TYPE(_Accum, Accum);
+CONVERT_FIXED_POINT_TYPE(long _Accum, LongAccum);
Index: lib/StaticAnalyzer/Core/ExprEngineC.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineC.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineC.cpp
@@ -323,6 +323,8 @@
 switch (CastE->getCastKind()) {
   case CK_FixedPointCast:
 llvm_unreachable("CK_FixedPointCast");  // TODO
+  case CK_FloatingToFixedPoint:
+llvm_unreachable("CK_FloatingToFixedPoint");
   case CK_IntegralToFixedPoint:
 llvm_unreachable(
 "ExprEngine::VisitCast CK_IntegralToFixedPoint");  // TODO
Index: 

[PATCH] D46485: Add python tool to dump and construct header maps

2018-05-21 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno updated this revision to Diff 147901.
bruno added a comment.

Remove more outdated comments


https://reviews.llvm.org/D46485

Files:
  CMakeLists.txt
  test/CMakeLists.txt
  test/Modules/crash-vfs-headermaps.m
  test/Preprocessor/Inputs/headermap-rel/foo.hmap
  test/Preprocessor/Inputs/headermap-rel/foo.hmap.json
  test/Preprocessor/Inputs/headermap-rel2/project-headers.hmap
  test/Preprocessor/Inputs/headermap-rel2/project-headers.hmap.json
  test/Preprocessor/Inputs/nonportable-hmaps/foo.hmap
  test/Preprocessor/Inputs/nonportable-hmaps/foo.hmap.json
  test/Preprocessor/headermap-rel.c
  test/Preprocessor/headermap-rel2.c
  test/Preprocessor/nonportable-include-with-hmap.c
  utils/hmaptool/CMakeLists.txt
  utils/hmaptool/hmaptool

Index: utils/hmaptool/hmaptool
===
--- /dev/null
+++ utils/hmaptool/hmaptool
@@ -0,0 +1,289 @@
+#!/usr/bin/env python
+
+import json
+import optparse
+import os
+import struct
+import sys
+
+###
+
+k_header_magic_LE = 'pamh'
+k_header_magic_BE = 'hmap'
+
+def hmap_hash(str):
+"""hash(str) -> int
+
+Apply the "well-known" headermap hash function.
+"""
+
+return sum((ord(c.lower()) * 13
+for c in str), 0)
+
+class HeaderMap(object):
+@staticmethod
+def frompath(path):
+with open(path, 'rb') as f:
+magic = f.read(4)
+if magic == k_header_magic_LE:
+endian_code = '<'
+elif magic == k_header_magic_BE:
+endian_code = '>'
+else:
+raise SystemExit("error: %s: not a headermap" % (
+path,))
+
+# Read the header information.
+header_fmt = endian_code + 'HH'
+header_size = struct.calcsize(header_fmt)
+data = f.read(header_size)
+if len(data) != header_size:
+raise SystemExit("error: %s: truncated headermap header" % (
+path,))
+
+(version, reserved, strtable_offset, num_entries,
+ num_buckets, max_value_len) = struct.unpack(header_fmt, data)
+
+if version != 1:
+raise SystemExit("error: %s: unknown headermap version: %r" % (
+path, version))
+if reserved != 0:
+raise SystemExit("error: %s: invalid reserved value in header" % (
+path,))
+
+# The number of buckets must be a power of two.
+if num_buckets == 0 or (num_buckets & num_buckets - 1) != 0:
+raise SystemExit("error: %s: invalid number of buckets" % (
+path,))
+
+# Read all of the buckets.
+bucket_fmt = endian_code + 'III'
+bucket_size = struct.calcsize(bucket_fmt)
+buckets_data = f.read(num_buckets * bucket_size)
+if len(buckets_data) != num_buckets * bucket_size:
+raise SystemExit("error: %s: truncated headermap buckets" % (
+path,))
+buckets = [struct.unpack(bucket_fmt,
+ buckets_data[i*bucket_size:(i+1)*bucket_size])
+   for i in range(num_buckets)]
+
+# Read the string table; the format doesn't explicitly communicate the
+# size of the string table (which is dumb), so assume it is the rest of
+# the file.
+f.seek(0, 2)
+strtable_size = f.tell() - strtable_offset
+f.seek(strtable_offset)
+
+strtable = f.read(strtable_size)
+if len(strtable) != strtable_size:
+raise SystemExit("error: %s: unable to read complete string table"%(
+path,))
+if strtable[-1] != '\0':
+raise SystemExit("error: %s: invalid string table in headermap" % (
+path,))
+
+return HeaderMap(num_entries, buckets, strtable)
+
+def __init__(self, num_entries, buckets, strtable):
+self.num_entries = num_entries
+self.buckets = buckets
+self.strtable = strtable
+
+def get_string(self, idx):
+if idx >= len(self.strtable):
+raise SystemExit("error: %s: invalid string index" % (
+path,))
+end_idx = self.strtable.index('\0', idx)
+return self.strtable[idx:end_idx]
+
+@property
+def mappings(self):
+for key_idx,prefix_idx,suffix_idx in self.buckets:
+if key_idx == 0:
+continue
+yield (self.get_string(key_idx),
+   self.get_string(prefix_idx) + self.get_string(suffix_idx))
+
+###
+
+def action_dump(name, args):
+"dump a headermap file"
+
+parser = optparse.OptionParser("%%prog %s [options] " % (
+name,))
+parser.add_option("-v", "--verbose", dest="verbose",
+  help="show more verbose 

[PATCH] D46485: Add python tool to dump and construct header maps

2018-05-21 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

Removing the binary header map files is a clear win, but I'd like someone else 
to approve this.




Comment at: test/Preprocessor/headermap-rel2.c:1-2
 // This uses a headermap with this entry:
 //   someheader.h -> Product/someheader.h
 

This comment also seems unnecessary.


https://reviews.llvm.org/D46485



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


[PATCH] D47155: [analyzer] Reduce simplifySVal complexity threshold further.

2018-05-21 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added a comment.

Also we should make sure that all recursive transformations on expressions 
represented as DAGs should be memoized.


Repository:
  rC Clang

https://reviews.llvm.org/D47155



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


[PATCH] D46241: [CodeGen] Recognize more cases of zero initialization

2018-05-21 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

I've done some more investigation, and I now think this patch is merely working 
around deficiencies elsewhere. See https://reviews.llvm.org/D47166, which aims 
to fix those deficiencies more directly.


Repository:
  rC Clang

https://reviews.llvm.org/D46241



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


[PATCH] D47157: Warning for framework headers using double quote includes

2018-05-21 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

>>> The warning is off by default.
>> 
>> We typically do not add off-by-default warnings because experience has shown 
>> the rarely get enabled in practice. Can you explain a bit more about why 
>> this one is off by default?
> 
> Right. I believe this is going to be used in practice, the reason I'm adding 
> it involves some user demand for such warning. Such quoted include use in 
> frameworks happen often and we would like a smooth transition to happen here 
> (e.g. do not initially affect -Werror users). If it proves worth it, we can 
> migrate to on by default in the future. It wouldn't be a problem if we have 
> it on by default on open source and disable by default downstream, but I 
> rather be consistent.

You could just not include new warning into -Wall and -Wextra. Those who will 
want to check #include statements correctness could enable it explicitly.


Repository:
  rC Clang

https://reviews.llvm.org/D47157



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


[PATCH] D47166: use zeroinitializer for (trailing zero portion of) large array initializers more reliably

2018-05-21 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith created this revision.
rsmith added reviewers: rjmccall, sepavloff.

Clang has two different ways it emits array constants (from `InitListExpr`s and 
from `APValue`s), and both had some ability to emit `zeroinitializer`, but 
neither was able to catch all cases where we could use `zeroinitializer` 
reliably. In particular, emitting from an `APValue` would fail to notice if all 
the explicit array elements happened to be zero. In addition, for large arrays 
where only an initial portion has an explicit initializer, we would emit the 
complete initializer (which could be huge) rather than emitting only the 
non-zero portion. With this change, when the element would have a suffix of 
more than 8 zero elements, we emit the array constant as a packed struct of its 
initial portion followed by a `zeroinitializer` constant for the trailing zero 
portion.

In passing, I found a bug where `SemaInit` would sometimes walk the entire 
array when checking an initializer that only covers the first few elements; 
that's fixed here to unblock testing of the rest.


Repository:
  rC Clang

https://reviews.llvm.org/D47166

Files:
  lib/CodeGen/CGExprConstant.cpp
  lib/Sema/SemaInit.cpp
  test/CodeGen/init.c
  test/CodeGenCXX/cxx11-initializer-aggregate.cpp
  test/SemaCXX/aggregate-initialization.cpp

Index: test/SemaCXX/aggregate-initialization.cpp
===
--- test/SemaCXX/aggregate-initialization.cpp
+++ test/SemaCXX/aggregate-initialization.cpp
@@ -180,3 +180,9 @@
 
 #pragma clang diagnostic pop
 }
+
+namespace HugeArraysUseArrayFiller {
+  // All we're checking here is that initialization completes in a reasonable
+  // amount of time.
+  struct A { int n; int arr[1000 * 1000 * 1000]; } a = {1, {2}};
+}
Index: test/CodeGenCXX/cxx11-initializer-aggregate.cpp
===
--- test/CodeGenCXX/cxx11-initializer-aggregate.cpp
+++ test/CodeGenCXX/cxx11-initializer-aggregate.cpp
@@ -11,6 +11,13 @@
   struct C { A & } c{{1}};
 }
 
+namespace NearlyZeroInit {
+  // CHECK-DAG: @_ZN14NearlyZeroInit1aE = global {{.*}} <{ i32 1, i32 2, i32 3, [120 x i32] zeroinitializer }>
+  int a[123] = {1, 2, 3};
+  // CHECK-DAG: @_ZN14NearlyZeroInit1bE = global {{.*}} { i32 1, <{ i32, [2147483647 x i32] }> <{ i32 2, [2147483647 x i32] zeroinitializer }> }
+  struct B { int n; int arr[1024 * 1024 * 1024 * 2u]; } b = {1, {2}};
+}
+
 // CHECK-LABEL: define {{.*}}@_Z3fn1i(
 int fn1(int x) {
   // CHECK: %[[INITLIST:.*]] = alloca %struct.A
@@ -51,3 +58,30 @@
   // meaningful.
   B b[30] = {};
 }
+
+namespace ZeroInit {
+  enum { Zero, One };
+  constexpr int zero() { return 0; }
+  constexpr int *null() { return nullptr; }
+  struct Filler {
+int x;
+Filler();
+  };
+  struct S1 {
+int x;
+  };
+
+  // These declarations, if implemented elementwise, require huge
+  // amout of memory and compiler time.
+  unsigned char data_1[1024 * 1024 * 1024 * 2u] = { 0 };
+  unsigned char data_2[1024 * 1024 * 1024 * 2u] = { Zero };
+  unsigned char data_3[1024][1024][1024] = {{{0}}};
+  unsigned char data_4[1024 * 1024 * 1024 * 2u] = { zero() };
+  int *data_5[1024 * 1024 * 512] = { nullptr };
+  int *data_6[1024 * 1024 * 512] = { null() };
+  struct S1 data_7[1024 * 1024 * 512] = {{0}};
+
+  // This variable must be initialized elementwise.
+  Filler data_e1[1024] = {};
+  // CHECK: getelementptr inbounds {{.*}} @_ZN8ZeroInit7data_e1E
+}
Index: test/CodeGen/init.c
===
--- test/CodeGen/init.c
+++ test/CodeGen/init.c
@@ -72,6 +72,16 @@
 struct a7 test7 = { .b = 0, .v = "bar" };
 
 
+// CHECK-DAG: @huge_array = global {{.*}} <{ i32 1, i32 0, i32 2, i32 0, i32 3, [5 x i32] zeroinitializer }>
+int huge_array[10] = {1, 0, 2, 0, 3, 0, 0, 0};
+
+// CHECK-DAG: @huge_struct = global {{.*}} { i32 1, <{ i32, [9 x i32] }> <{ i32 2, [9 x i32] zeroinitializer }> }
+struct Huge {
+  int a;
+  int arr[1000 * 1000 * 1000];
+} huge_struct = {1, {2, 0, 0, 0}};
+
+
 // PR279 comment #3
 char test8(int X) {
   char str[10] = "abc"; // tail should be memset.
Index: lib/Sema/SemaInit.cpp
===
--- lib/Sema/SemaInit.cpp
+++ lib/Sema/SemaInit.cpp
@@ -751,6 +751,9 @@
 ElementEntity.getKind() == InitializedEntity::EK_VectorElement)
   ElementEntity.setElementIndex(Init);
 
+if (Init >= NumInits && ILE->hasArrayFiller())
+  return;
+
 Expr *InitExpr = (Init < NumInits ? ILE->getInit(Init) : nullptr);
 if (!InitExpr && Init < NumInits && ILE->hasArrayFiller())
   ILE->setInit(Init, ILE->getArrayFiller());
Index: lib/CodeGen/CGExprConstant.cpp
===
--- lib/CodeGen/CGExprConstant.cpp
+++ lib/CodeGen/CGExprConstant.cpp
@@ -635,6 +635,52 @@
   return ConstantAddress(GV, Align);
 }
 
+static llvm::Constant *

[PATCH] D47157: Warning for framework headers using double quote includes

2018-05-21 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.



> See also PR22165.

Nice, seems related to this indeed. Are you aware of any development along 
those lines in clang-tidy? We would like this to be part of clang and be used 
as part of the normal compiler workflow, it can surely be as well part of any 
clang-tidy related include guidelines in the future.

>> The warning is off by default.
> 
> We typically do not add off-by-default warnings because experience has shown 
> the rarely get enabled in practice. Can you explain a bit more about why this 
> one is off by default?

Right. I believe this is going to be used in practice, the reason I'm adding it 
involves some user demand for such warning. Such quoted include use in 
frameworks happen often and we would like a smooth transition to happen here 
(e.g. do not initially affect -Werror users). If it proves worth it, we can 
migrate to on by default in the future. It wouldn't be a problem if we have it 
on by default on open source and disable by default downstream, but I rather be 
consistent.


Repository:
  rC Clang

https://reviews.llvm.org/D47157



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


[PATCH] D46084: [Fixed Point Arithmetic] Addition of the Fixed Point _Accum type

2018-05-21 Thread Jake Ehrlich via Phabricator via cfe-commits
jakehehrlich added a comment.

LGTM with a couple additions.




Comment at: lib/CodeGen/CodeGenTypes.cpp:448
+case BuiltinType::ULongAccum:
   ResultType = llvm::IntegerType::get(getLLVMContext(),
  
static_cast(Context.getTypeSize(T)));

Add TODO for accum types using a different drawf type.



Comment at: lib/Index/USRGeneration.cpp:731
+
+  if (c == '~') {
+switch (BT->getKind()) {

You can make the 'c' a Twine instead. That will let you inline these in their 
respective locations as `  c = "~UA" ` for instance.


Repository:
  rC Clang

https://reviews.llvm.org/D46084



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


[PATCH] D47135: [analyzer][WIP] A checker for dangling string pointers in C++

2018-05-21 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/DanglingStringPointerChecker.cpp:29
+
+class DanglingStringPointerChecker : public Checker {
+  CallDescription CStrFn;

george.karpenkov wrote:
> "string" is a bit ambiguous, if this checker is specifically for std::string 
> should we change the name to reflect that?
Agree, maybe DanglingStdStringPointerChecker?


Repository:
  rC Clang

https://reviews.llvm.org/D47135



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


[PATCH] D46919: [libclang] Deprecate CXPrintingPolicy_IncludeTagDefinition

2018-05-21 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny added a comment.

In https://reviews.llvm.org/D46919#1101268, @jdenny wrote:

> In https://reviews.llvm.org/D46919#1100493, @rsmith wrote:
>
> > The deprecated enumerator is also referenced by 
> > `tools/c-index-test/c-index-test.c`
>
>
> This test prompted me to keep the IncludeTagDefinition member in 
> PrintingPolicy so that clang_PrintingPolicy_getProperty would return the 
> previous value set by clang_PrintingPolicy_setProperty.  Otherwise, the value 
> doesn't have any effect.  Is that self-consistency not worth worrying about?  
> If so, I'll remove both.


Sorry, I was thinking of a different test.  I've removed the reference you 
mentioned.




Comment at: include/clang/AST/PrettyPrinter.h:97-99
+  /// This flag is deprecated and no longer has any effect.
+  bool IncludeTagDefinition : 1;
+

rsmith wrote:
> There's no need to keep this around. We have no API stability guarantees for 
> our C++ API.
The test LibclangPrintingPolicyTest in unittests/libclang/LibclangTest.cpp 
wants  clang_PrintingPolicy_getProperty to return the previous value set by 
clang_PrintingPolicy_setProperty for every member of CXPrintingPolicyProperty.  
Keeping this field makes that possible.


https://reviews.llvm.org/D46919



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


[PATCH] D47135: [analyzer][WIP] A checker for dangling string pointers in C++

2018-05-21 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/DanglingStringPointerChecker.cpp:29
+
+class DanglingStringPointerChecker : public Checker {
+  CallDescription CStrFn;

"string" is a bit ambiguous, if this checker is specifically for std::string 
should we change the name to reflect that?


Repository:
  rC Clang

https://reviews.llvm.org/D47135



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


[PATCH] D46919: [libclang] Deprecate CXPrintingPolicy_IncludeTagDefinition

2018-05-21 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny updated this revision to Diff 147887.
jdenny marked 2 inline comments as done.
jdenny edited the summary of this revision.
jdenny added a comment.

Made a stab at the suggested changes.


https://reviews.llvm.org/D46919

Files:
  include/clang-c/Index.h
  include/clang/AST/PrettyPrinter.h
  lib/AST/DeclPrinter.cpp
  lib/AST/TypePrinter.cpp
  tools/c-index-test/c-index-test.c

Index: tools/c-index-test/c-index-test.c
===
--- tools/c-index-test/c-index-test.c
+++ tools/c-index-test/c-index-test.c
@@ -99,8 +99,6 @@
CXPrintingPolicy_SuppressSpecifiers},
   {"CINDEXTEST_PRINTINGPOLICY_SUPPRESSTAGKEYWORD",
CXPrintingPolicy_SuppressTagKeyword},
-  {"CINDEXTEST_PRINTINGPOLICY_INCLUDETAGDEFINITION",
-   CXPrintingPolicy_IncludeTagDefinition},
   {"CINDEXTEST_PRINTINGPOLICY_SUPPRESSSCOPE",
CXPrintingPolicy_SuppressScope},
   {"CINDEXTEST_PRINTINGPOLICY_SUPPRESSUNWRITTENSCOPE",
Index: lib/AST/TypePrinter.cpp
===
--- lib/AST/TypePrinter.cpp
+++ lib/AST/TypePrinter.cpp
@@ -454,7 +454,7 @@
 OS << '(';
 
   PrintingPolicy InnerPolicy(Policy);
-  InnerPolicy.IncludeTagDefinition = false;
+  InnerPolicy.State.PrintOwnedTagDecl = false;
   TypePrinter(InnerPolicy).print(QualType(T->getClass(), 0), OS, StringRef());
 
   OS << "::*";
@@ -1054,9 +1054,9 @@
 }
 
 void TypePrinter::printTag(TagDecl *D, raw_ostream ) {
-  if (Policy.IncludeTagDefinition) {
+  if (Policy.State.PrintOwnedTagDecl) {
 PrintingPolicy SubPolicy = Policy;
-SubPolicy.IncludeTagDefinition = false;
+SubPolicy.State.PrintOwnedTagDecl = false;
 D->print(OS, SubPolicy, Indentation);
 spaceBeforePlaceHolder(OS);
 return;
@@ -1209,35 +1209,34 @@
 
 void TypePrinter::printElaboratedBefore(const ElaboratedType *T,
 raw_ostream ) {
-  if (Policy.IncludeTagDefinition && T->getOwnedTagDecl()) {
+  if (Policy.State.PrintOwnedTagDecl && T->getOwnedTagDecl()) {
 TagDecl *OwnedTagDecl = T->getOwnedTagDecl();
 assert(OwnedTagDecl->getTypeForDecl() == T->getNamedType().getTypePtr() &&
"OwnedTagDecl expected to be a declaration for the type");
 PrintingPolicy SubPolicy = Policy;
-SubPolicy.IncludeTagDefinition = false;
+SubPolicy.State.PrintOwnedTagDecl = false;
 OwnedTagDecl->print(OS, SubPolicy, Indentation);
 spaceBeforePlaceHolder(OS);
 return;
   }
 
   // The tag definition will take care of these.
-  if (!Policy.IncludeTagDefinition)
-  {
+  if (!Policy.State.PrintOwnedTagDecl) {
 OS << TypeWithKeyword::getKeywordName(T->getKeyword());
 if (T->getKeyword() != ETK_None)
   OS << " ";
 NestedNameSpecifier *Qualifier = T->getQualifier();
 if (Qualifier)
   Qualifier->print(OS, Policy);
   }
-  
+
   ElaboratedTypePolicyRAII PolicyRAII(Policy);
   printBefore(T->getNamedType(), OS);
 }
 
 void TypePrinter::printElaboratedAfter(const ElaboratedType *T,
 raw_ostream ) {
-  if (Policy.IncludeTagDefinition && T->getOwnedTagDecl())
+  if (Policy.State.PrintOwnedTagDecl && T->getOwnedTagDecl())
 return;
   ElaboratedTypePolicyRAII PolicyRAII(Policy);
   printAfter(T->getNamedType(), OS);
Index: lib/AST/DeclPrinter.cpp
===
--- lib/AST/DeclPrinter.cpp
+++ lib/AST/DeclPrinter.cpp
@@ -178,12 +178,12 @@
   for ( ; Begin != End; ++Begin) {
 if (isFirst) {
   if(TD)
-SubPolicy.IncludeTagDefinition = true;
+SubPolicy.State.PrintOwnedTagDecl = true;
   SubPolicy.SuppressSpecifiers = false;
   isFirst = false;
 } else {
   if (!isFirst) Out << ", ";
-  SubPolicy.IncludeTagDefinition = false;
+  SubPolicy.State.PrintOwnedTagDecl = false;
   SubPolicy.SuppressSpecifiers = true;
 }
 
@@ -849,7 +849,7 @@
   }
   PrintingPolicy SubPolicy(Policy);
   SubPolicy.SuppressSpecifiers = false;
-  SubPolicy.IncludeTagDefinition = false;
+  SubPolicy.State.PrintOwnedTagDecl = false;
   Init->printPretty(Out, nullptr, SubPolicy, Indentation);
   if ((D->getInitStyle() == VarDecl::CallInit) && !isa(Init))
 Out << ")";
Index: include/clang/AST/PrettyPrinter.h
===
--- include/clang/AST/PrettyPrinter.h
+++ include/clang/AST/PrettyPrinter.h
@@ -93,14 +93,7 @@
   /// \endcode
   bool SuppressTagKeyword : 1;
 
-  /// When true, include the body of a tag definition.
-  ///
-  /// This is used to place the definition of a struct
-  /// in the middle of another declaration as with:
-  ///
-  /// \code
-  /// typedef struct { int x, y; } Point;
-  /// \endcode
+  /// This flag is deprecated and no longer has any effect.
   bool IncludeTagDefinition : 1;
 
   /// Suppresses printing of scope specifiers.
@@ -225,6 +218,25 @@
   /// When true, 

[PATCH] D47164: Add missing include for cstdint to Visibility.h

2018-05-21 Thread Raphael Isemann via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL332913: Add missing include for cstdint to Visibility.h 
(authored by teemperor, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D47164?vs=147891=147892#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D47164

Files:
  cfe/trunk/include/clang/Basic/Visibility.h


Index: cfe/trunk/include/clang/Basic/Visibility.h
===
--- cfe/trunk/include/clang/Basic/Visibility.h
+++ cfe/trunk/include/clang/Basic/Visibility.h
@@ -17,6 +17,7 @@
 
 #include "clang/Basic/Linkage.h"
 #include 
+#include 
 
 namespace clang {
 


Index: cfe/trunk/include/clang/Basic/Visibility.h
===
--- cfe/trunk/include/clang/Basic/Visibility.h
+++ cfe/trunk/include/clang/Basic/Visibility.h
@@ -17,6 +17,7 @@
 
 #include "clang/Basic/Linkage.h"
 #include 
+#include 
 
 namespace clang {
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r332913 - Add missing include for cstdint to Visibility.h

2018-05-21 Thread Raphael Isemann via cfe-commits
Author: teemperor
Date: Mon May 21 15:27:22 2018
New Revision: 332913

URL: http://llvm.org/viewvc/llvm-project?rev=332913=rev
Log:
Add missing include for cstdint to Visibility.h

Summary: We use uint8_t in this header, so we need to include cstdint.

Subscribers: cfe-commits

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

Modified:
cfe/trunk/include/clang/Basic/Visibility.h

Modified: cfe/trunk/include/clang/Basic/Visibility.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Visibility.h?rev=332913=332912=332913=diff
==
--- cfe/trunk/include/clang/Basic/Visibility.h (original)
+++ cfe/trunk/include/clang/Basic/Visibility.h Mon May 21 15:27:22 2018
@@ -17,6 +17,7 @@
 
 #include "clang/Basic/Linkage.h"
 #include 
+#include 
 
 namespace clang {
 


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


[PATCH] D47164: Add missing include for cstdint to Visibility.h

2018-05-21 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor created this revision.

We use uint8_t in this header, so we need to include cstdint.


Repository:
  rC Clang

https://reviews.llvm.org/D47164

Files:
  include/clang/Basic/Visibility.h


Index: include/clang/Basic/Visibility.h
===
--- include/clang/Basic/Visibility.h
+++ include/clang/Basic/Visibility.h
@@ -17,6 +17,7 @@
 
 #include "clang/Basic/Linkage.h"
 #include 
+#include 
 
 namespace clang {
 


Index: include/clang/Basic/Visibility.h
===
--- include/clang/Basic/Visibility.h
+++ include/clang/Basic/Visibility.h
@@ -17,6 +17,7 @@
 
 #include "clang/Basic/Linkage.h"
 #include 
+#include 
 
 namespace clang {
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46791: Make -gsplit-dwarf generally available

2018-05-21 Thread Eric Christopher via Phabricator via cfe-commits
echristo added a comment.

In https://reviews.llvm.org/D46791#1107168, @pcc wrote:

> There were a bunch of them but the last one was 
> https://reviews.llvm.org/D47093 which has already landed :)
>
> Probably all that needs to happen on this change is to replace the isLinux() 
> check with isELF().


Be good if it didn't even require the isELF check anymore, but that probably 
requires testing on a few platforms. :)


https://reviews.llvm.org/D46791



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


[PATCH] D46791: Make -gsplit-dwarf generally available

2018-05-21 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc added a comment.

There were a bunch of them but the last one was https://reviews.llvm.org/D47093 
which has already landed :)

Probably all that needs to happen on this change is to replace the isLinux() 
check with isELF().


https://reviews.llvm.org/D46791



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


[PATCH] D46963: [Fixed Point Arithmetic] Test for All Builtin Operations

2018-05-21 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 147888.
leonardchan added a comment.

formatting


Repository:
  rC Clang

https://reviews.llvm.org/D46963

Files:
  lib/AST/ASTContext.cpp
  lib/CodeGen/CGExprScalar.cpp
  test/Frontend/fixed_point_all_builtin_operations.c

Index: test/Frontend/fixed_point_all_builtin_operations.c
===
--- /dev/null
+++ test/Frontend/fixed_point_all_builtin_operations.c
@@ -0,0 +1,68 @@
+// RUN: %clang_cc1 -Werror %s
+
+// Check that we can use all supported binary and unary operations according to
+// clause 4.1.6 in N1169.
+
+#define ALL_OPERATIONS_FOR_TYPE(TYPE, ID) \
+  TYPE unary_add##ID(TYPE a) { return +a; }   \
+  TYPE unary_sub##ID(TYPE a) { return -a; }   \
+  int logical_not##ID(TYPE a) { return !a; }  \
+  TYPE add##ID(TYPE a, TYPE b) { return a + b; }  \
+  TYPE sub##ID(TYPE a, TYPE b) { return a - b; }  \
+  TYPE mul##ID(TYPE a, TYPE b) { return a * b; }  \
+  TYPE div##ID(TYPE a, TYPE b) { return a / b; }  \
+  TYPE shl##ID(TYPE a, int b) { return a << b; }  \
+  TYPE shr##ID(TYPE a, int b) { return a >> b; }  \
+  TYPE augmented_add##ID(TYPE a, TYPE b) {\
+a += b;   \
+return a; \
+  }   \
+  TYPE augmented_sub##ID(TYPE a, TYPE b) {\
+a -= b;   \
+return a; \
+  }   \
+  TYPE augmented_mul##ID(TYPE a, TYPE b) {\
+a *= b;   \
+return a; \
+  }   \
+  TYPE augmented_div##ID(TYPE a, TYPE b) {\
+a /= b;   \
+return a; \
+  }   \
+  TYPE augmented_shl##ID(TYPE a, int b) { \
+a <<= b;  \
+return a; \
+  }   \
+  TYPE augmented_shr##ID(TYPE a, int b) { \
+a >>= b;  \
+return a; \
+  }   \
+  int eq##ID(TYPE a, TYPE b) { return a == b; }   \
+  int ne##ID(TYPE a, TYPE b) { return a != b; }   \
+  int lt##ID(TYPE a, TYPE b) { return a < b; }\
+  int le##ID(TYPE a, TYPE b) { return a <= b; }   \
+  int ge##ID(TYPE a, TYPE b) { return a >= b; }   \
+  int gt##ID(TYPE a, TYPE b) { return a > b; }\
+  TYPE pre_inc##ID(TYPE a) { return ++a; }\
+  TYPE pre_dec##ID(TYPE a) { return --a; }\
+  TYPE post_inc##ID(TYPE a) { return a++; }   \
+  TYPE post_dec##ID(TYPE a) { return a--; }   \
+  TYPE deref_pre_inc##ID(TYPE *a) { return ++(*a); }  \
+  TYPE deref_pre_dec##ID(TYPE *a) { return --(*a); }  \
+  TYPE deref_post_inc##ID(TYPE *a) { return (*a)++; } \
+  TYPE deref_post_dec##ID(TYPE *a) { return (*a)--; }
+
+#define ALL_OPERATIONS(TYPE, ID)   \
+  ALL_OPERATIONS_FOR_TYPE(TYPE, ID)\
+  ALL_OPERATIONS_FOR_TYPE(signed TYPE, Signed##ID) \
+  ALL_OPERATIONS_FOR_TYPE(unsigned TYPE, Unsigned##ID) \
+  ALL_OPERATIONS_FOR_TYPE(_Sat TYPE, Sat##ID)  \
+  ALL_OPERATIONS_FOR_TYPE(_Sat signed TYPE, SatSigned##ID) \
+  ALL_OPERATIONS_FOR_TYPE(_Sat unsigned TYPE, SatUnsigned##ID)
+
+ALL_OPERATIONS(short _Fract, ShortFract);
+ALL_OPERATIONS(_Fract, Fract);
+ALL_OPERATIONS(long _Fract, LongFract);
+ALL_OPERATIONS(short _Accum, ShortAccum);
+ALL_OPERATIONS(_Accum, Accum);
+ALL_OPERATIONS(long _Accum, LongAccum);
Index: lib/CodeGen/CGExprScalar.cpp
===
--- lib/CodeGen/CGExprScalar.cpp
+++ lib/CodeGen/CGExprScalar.cpp
@@ -2214,39 +2214,51 @@
 switch (BT->getKind()) {
   default:
 llvm_unreachable("Not a fixed point type!");
+  case BuiltinType::SatShortAccum:
   case BuiltinType::ShortAccum:
 fbits = BUILTIN_SACCUM_FBIT;
 break;
+  case BuiltinType::SatAccum:
   case BuiltinType::Accum:
 fbits = BUILTIN_ACCUM_FBIT;
 break;
+  case BuiltinType::SatLongAccum:
   case BuiltinType::LongAccum:
 fbits = BUILTIN_LACCUM_FBIT;
 break;
+  case BuiltinType::SatUShortAccum:
   case BuiltinType::UShortAccum:
 fbits = BUILTIN_USACCUM_FBIT;
 break;
+  case BuiltinType::SatUAccum:
   case BuiltinType::UAccum:
 fbits = BUILTIN_UACCUM_FBIT;
 break;
+  case BuiltinType::SatULongAccum:

[PATCH] D47155: [analyzer] Reduce simplifySVal complexity threshold further.

2018-05-21 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added a comment.

@NoQ I'm really wary of magic numbers.

- We should expose it through an analyzer-config flag. We already do so for the 
budget.
- We should probably have both positive and negative tests. What scenarios 
_stop_ working after the threshold is decreased? [point 1 is required to be 
able to test that]
- Finally, do we understand where the slowdown comes from? If it comes from 
attempted rearrangements due to https://reviews.llvm.org/rC329780 I think we 
should roll that back instead.


Repository:
  rC Clang

https://reviews.llvm.org/D47155



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


[PATCH] D46791: Make -gsplit-dwarf generally available

2018-05-21 Thread Jake Ehrlich via Phabricator via cfe-commits
jakehehrlich added a comment.

Yeah I haven't heard back from Lexan nor have I tried reproducing such a build 
myself and if we're that close to not relaying on this sort of hack I'd much 
rather wait on this than risk breaking someone for the sake of a stopgap for 
such a short period of time. @echristo Can you link the review to that?


https://reviews.llvm.org/D46791



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


r332911 - Add missing x86-registered-target.

2018-05-21 Thread Peter Collingbourne via cfe-commits
Author: pcc
Date: Mon May 21 15:14:02 2018
New Revision: 332911

URL: http://llvm.org/viewvc/llvm-project?rev=332911=rev
Log:
Add missing x86-registered-target.

Modified:
cfe/trunk/test/Misc/cc1as-split-dwarf.s

Modified: cfe/trunk/test/Misc/cc1as-split-dwarf.s
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/cc1as-split-dwarf.s?rev=332911=332910=332911=diff
==
--- cfe/trunk/test/Misc/cc1as-split-dwarf.s (original)
+++ cfe/trunk/test/Misc/cc1as-split-dwarf.s Mon May 21 15:14:02 2018
@@ -1,3 +1,4 @@
+// REQUIRES: x86-registered-target
 // RUN: %clang -cc1as -triple x86_64-pc-linux-gnu %s -filetype obj -o %t1 
-split-dwarf-file %t2
 // RUN: llvm-objdump -s %t1 | FileCheck --check-prefix=O %s
 // RUN: llvm-objdump -s %t2 | FileCheck --check-prefix=DWO %s


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


r332909 - [X86] Remove a builtin that should have been removed in r332882.

2018-05-21 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Mon May 21 15:10:02 2018
New Revision: 332909

URL: http://llvm.org/viewvc/llvm-project?rev=332909=rev
Log:
[X86] Remove a builtin that should have been removed in r332882.

Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/test/CodeGen/builtins-x86.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=332909=332908=332909=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Mon May 21 15:10:02 2018
@@ -477,7 +477,6 @@ TARGET_BUILTIN(__builtin_ia32_cmpps, "V4
 TARGET_BUILTIN(__builtin_ia32_cmpps256, "V8fV8fV8fIc", "nc", "avx")
 TARGET_BUILTIN(__builtin_ia32_cmpsd, "V2dV2dV2dIc", "nc", "avx")
 TARGET_BUILTIN(__builtin_ia32_cmpss, "V4fV4fV4fIc", "nc", "avx")
-TARGET_BUILTIN(__builtin_ia32_cvtdq2ps256, "V8fV8i", "nc", "avx")
 TARGET_BUILTIN(__builtin_ia32_cvtpd2ps256, "V4fV4d", "nc", "avx")
 TARGET_BUILTIN(__builtin_ia32_cvtps2dq256, "V8iV8f", "nc", "avx")
 TARGET_BUILTIN(__builtin_ia32_cvttpd2dq256, "V4iV4d", "nc", "avx")

Modified: cfe/trunk/test/CodeGen/builtins-x86.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-x86.c?rev=332909=332908=332909=diff
==
--- cfe/trunk/test/CodeGen/builtins-x86.c (original)
+++ cfe/trunk/test/CodeGen/builtins-x86.c Mon May 21 15:10:02 2018
@@ -433,7 +433,6 @@ void f0() {
   tmp_V8f = __builtin_ia32_dpps256(tmp_V8f, tmp_V8f, 0x7);
   tmp_V4d = __builtin_ia32_cmppd256(tmp_V4d, tmp_V4d, 0);
   tmp_V8f = __builtin_ia32_cmpps256(tmp_V8f, tmp_V8f, 0);
-  tmp_V8f = __builtin_ia32_cvtdq2ps256(tmp_V8i);
   tmp_V4f = __builtin_ia32_cvtpd2ps256(tmp_V4d);
   tmp_V8i = __builtin_ia32_cvtps2dq256(tmp_V8f);
   tmp_V4i = __builtin_ia32_cvttpd2dq256(tmp_V4d);


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


[PATCH] D46960: [Fixed Point Arithmetic] Predefined Precision Macros

2018-05-21 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 147883.
leonardchan added a comment.

formatting


Repository:
  rC Clang

https://reviews.llvm.org/D46960

Files:
  include/clang/Lex/Preprocessor.h
  lib/Lex/PPMacroExpansion.cpp
  test/Frontend/fixed_point_builtin_macros.c

Index: test/Frontend/fixed_point_builtin_macros.c
===
--- /dev/null
+++ test/Frontend/fixed_point_builtin_macros.c
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -S -emit-llvm -o - %s | lli
+
+#define assert(b) if (!(b)) { return 1; }
+
+int main() {
+  // Test using the recommended values for a typical desktop processor (Annex
+  // A.3). These are also the default values when building clang.
+  // Fractional bits of _Accum types
+  assert(__SACCUM_FBIT__  == 7);
+  assert(__ACCUM_FBIT__   == 15);
+  assert(__LACCUM_FBIT__  == 31);
+  assert(__USACCUM_FBIT__ == 8);
+  assert(__UACCUM_FBIT__  == 16);
+  assert(__ULACCUM_FBIT__ == 32);
+
+  // Fractional bits of _Fract types
+  assert(__SFRACT_FBIT__  == 7);
+  assert(__FRACT_FBIT__   == 15);
+  assert(__LFRACT_FBIT__  == 31);
+  assert(__USFRACT_FBIT__ == 8);
+  assert(__UFRACT_FBIT__  == 16);
+  assert(__ULFRACT_FBIT__ == 32);
+
+  // Integral bits of _Accum types
+  assert(__SACCUM_IBIT__  == 8);
+  assert(__ACCUM_IBIT__   == 16);
+  assert(__LACCUM_IBIT__  == 32);
+  assert(__USACCUM_IBIT__ == 8);
+  assert(__UACCUM_IBIT__  == 16);
+  assert(__ULACCUM_IBIT__ == 32);
+}
Index: lib/Lex/PPMacroExpansion.cpp
===
--- lib/Lex/PPMacroExpansion.cpp
+++ lib/Lex/PPMacroExpansion.cpp
@@ -14,6 +14,7 @@
 
 #include "clang/Basic/Attributes.h"
 #include "clang/Basic/FileManager.h"
+#include "clang/Basic/FixedPoint.h"
 #include "clang/Basic/IdentifierTable.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/LangOptions.h"
@@ -355,6 +356,31 @@
   Ident__INCLUDE_LEVEL__ = RegisterBuiltinMacro(*this, "__INCLUDE_LEVEL__");
   Ident__TIMESTAMP__ = RegisterBuiltinMacro(*this, "__TIMESTAMP__");
 
+  // Fixed point macros (ISO/IEC JTC1 SC22 WG14 N1169)
+  // Fractional bits of _Accum types
+  Ident__SACCUM_FBIT__   = RegisterBuiltinMacro(*this, "__SACCUM_FBIT__");
+  Ident__ACCUM_FBIT__= RegisterBuiltinMacro(*this, "__ACCUM_FBIT__");
+  Ident__LACCUM_FBIT__   = RegisterBuiltinMacro(*this, "__LACCUM_FBIT__");
+  Ident__USACCUM_FBIT__  = RegisterBuiltinMacro(*this, "__USACCUM_FBIT__");
+  Ident__UACCUM_FBIT__   = RegisterBuiltinMacro(*this, "__UACCUM_FBIT__");
+  Ident__ULACCUM_FBIT__  = RegisterBuiltinMacro(*this, "__ULACCUM_FBIT__");
+
+  // Fractional bits of _Fract types
+  Ident__SFRACT_FBIT__   = RegisterBuiltinMacro(*this, "__SFRACT_FBIT__");
+  Ident__FRACT_FBIT__= RegisterBuiltinMacro(*this, "__FRACT_FBIT__");
+  Ident__LFRACT_FBIT__   = RegisterBuiltinMacro(*this, "__LFRACT_FBIT__");
+  Ident__USFRACT_FBIT__  = RegisterBuiltinMacro(*this, "__USFRACT_FBIT__");
+  Ident__UFRACT_FBIT__   = RegisterBuiltinMacro(*this, "__UFRACT_FBIT__");
+  Ident__ULFRACT_FBIT__  = RegisterBuiltinMacro(*this, "__ULFRACT_FBIT__");
+
+  // Integral bits of _Accum types
+  Ident__SACCUM_IBIT__   = RegisterBuiltinMacro(*this, "__SACCUM_IBIT__");
+  Ident__ACCUM_IBIT__= RegisterBuiltinMacro(*this, "__ACCUM_IBIT__");
+  Ident__LACCUM_IBIT__   = RegisterBuiltinMacro(*this, "__LACCUM_IBIT__");
+  Ident__USACCUM_IBIT__  = RegisterBuiltinMacro(*this, "__USACCUM_IBIT__");
+  Ident__UACCUM_IBIT__   = RegisterBuiltinMacro(*this, "__UACCUM_IBIT__");
+  Ident__ULACCUM_IBIT__  = RegisterBuiltinMacro(*this, "__ULACCUM_IBIT__");
+
   // Microsoft Extensions.
   if (LangOpts.MicrosoftExt) {
 Ident__identifier = RegisterBuiltinMacro(*this, "__identifier");
@@ -1696,6 +1722,68 @@
 // __LINE__ expands to a simple numeric value.
 OS << (PLoc.isValid()? PLoc.getLine() : 1);
 Tok.setKind(tok::numeric_constant);
+
+  // Fixed point macros
+  // Fractional bits of _Accum types
+  } else if (II == Ident__SACCUM_FBIT__) {
+OS << BUILTIN_SACCUM_FBIT;
+Tok.setKind(tok::numeric_constant);
+  } else if (II == Ident__ACCUM_FBIT__) {
+OS << BUILTIN_ACCUM_FBIT;
+Tok.setKind(tok::numeric_constant);
+  } else if (II == Ident__LACCUM_FBIT__) {
+OS << BUILTIN_LACCUM_FBIT;
+Tok.setKind(tok::numeric_constant);
+  } else if (II == Ident__USACCUM_FBIT__) {
+OS << BUILTIN_USACCUM_FBIT;
+Tok.setKind(tok::numeric_constant);
+  } else if (II == Ident__UACCUM_FBIT__) {
+OS << BUILTIN_UACCUM_FBIT;
+Tok.setKind(tok::numeric_constant);
+  } else if (II == Ident__ULACCUM_FBIT__) {
+OS << BUILTIN_ULACCUM_FBIT;
+Tok.setKind(tok::numeric_constant);
+
+  // Fractional bits of _Fract types
+  } else if (II == Ident__SFRACT_FBIT__) {
+OS << BUILTIN_SFRACT_FBIT;
+Tok.setKind(tok::numeric_constant);
+  } else if (II == Ident__FRACT_FBIT__) {
+OS << BUILTIN_FRACT_FBIT;
+Tok.setKind(tok::numeric_constant);
+  } else if (II == Ident__LFRACT_FBIT__) {
+OS << 

[PATCH] D46927: [Fixed Point Arithmetic] Augmented Assignment for Fixed Point Types

2018-05-21 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 147882.
leonardchan added a comment.

formatting


Repository:
  rC Clang

https://reviews.llvm.org/D46927

Files:
  include/clang/AST/Type.h
  lib/AST/Type.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/Sema/SemaExpr.cpp
  test/Frontend/fixed_point_validation.c

Index: test/Frontend/fixed_point_validation.c
===
--- test/Frontend/fixed_point_validation.c
+++ test/Frontend/fixed_point_validation.c
@@ -1,5 +1,5 @@
-// RUN: %clang -S -emit-llvm %s -o - | FileCheck %s
 // RUN: %clang_cc1 -S -emit-llvm -o - %s | lli
+// RUN: %clang -S -emit-llvm %s -o - | FileCheck %s
 
 // The first test checks the emitted llvm IR.
 // The second test checks the output.
@@ -279,4 +279,35 @@
   float laccum_diff = abs(base - 2.333lk);
   assert(accum_diff < saccum_diff);
   assert(laccum_diff < accum_diff);
+
+  / Auxillary assignments ***/
+
+  s_accum = 7.5hk;
+  s_accum2 = 2.0hk;
+  s_accum += s_accum2;
+  assert(s_accum == 9.5hk);
+  s_accum += 2.5k;
+  assert(s_accum == 12);
+
+  s_accum -= s_accum2;
+  assert(s_accum == 10);
+  s_accum -= 2.5lk;
+  assert(s_accum == 7.5k);
+
+  s_accum2 = 3.0k;
+  s_accum *= s_accum2;
+  assert(s_accum == 22.5k);
+  s_accum *= 0.5r;
+  assert(s_accum == 11.25hk);
+
+  s_accum /= s_accum2;
+  assert(s_accum == 3.75k);
+  s_accum /= 0.5hr;
+  assert(s_accum == 7.5k);
+
+  s_accum <<= 3;
+  assert(s_accum == 60);
+
+  s_accum >>= 3;
+  assert(s_accum == 7.5k);
 }
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -6076,8 +6076,7 @@
   case Type::STK_Floating:
 return CK_FixedPointToFloating;
   case Type::STK_FixedPoint:
-llvm_unreachable(
-"Unimplemented scalar cast from fixed point to fixed point");  // TODO
+return CK_FixedPointCast;
 }
   }
 
Index: lib/CodeGen/CGExprScalar.cpp
===
--- lib/CodeGen/CGExprScalar.cpp
+++ lib/CodeGen/CGExprScalar.cpp
@@ -308,6 +308,17 @@
   Value *EmitScalarConversion(Value *Src, QualType SrcTy, QualType DstTy,
   SourceLocation Loc, bool TreatBooleanAsSigned);
 
+  /// Emit a conversion between fixed point types by moving the radix point.
+  /// This does not take into account resizing of the underlying llvm type
+  /// which should be handled either before or after calling this function.
+  ///
+  /// If the type is being scaled up, this method should be called after
+  /// performing an intcast. If the type is scaled down, this method should be
+  /// called before performing an intcast. This is necessary such that the
+  /// shift operations retain as much of the original data as possible before
+  /// truncation or after extension.
+  Value *EmitFixedPointRadixShift(Value *Src, QualType SrcTy, QualType DstTy);
+
   /// Emit a conversion from the specified complex type to the specified
   /// destination type, where the destination type is an LLVM scalar type.
   Value *EmitComplexToScalarConversion(CodeGenFunction::ComplexPairTy Src,
@@ -961,6 +972,49 @@
 SanitizerHandler::FloatCastOverflow, StaticArgs, OrigSrc);
 }
 
+/// Emit a conversion between fixed point types by moving the radix point.
+/// This does not take into account resizing of the underlying llvm type
+/// which should be handled either before or after calling this function.
+///
+/// If the type is being scaled up, this method should be called after
+/// performing an intcast. If the type is scaled down, this method should be
+/// called before performing an intcast. This is necessary such that the
+/// shift operations retain as much of the original data as possible before
+/// truncation or after extension.
+Value *ScalarExprEmitter::EmitFixedPointRadixShift(Value *Src, QualType SrcTy,
+   QualType DstTy) {
+  assert(DstTy->isFixedPointType());
+  assert(SrcTy->isFixedPointType());
+
+  Value *Res = Src;
+
+  // Casting between fixed point types involves separating the integral and
+  // fractional bits, potentially shifting them, then joining back together.
+  unsigned dest_fbits = getFixedPointFBits(DstTy);
+  unsigned src_fbits = getFixedPointFBits(SrcTy);
+  unsigned dest_ibits = getFixedPointIBits(DstTy);
+  unsigned src_ibits = getFixedPointIBits(SrcTy);
+
+  // If the number of integral bits is decreasing, trim off any extra bits while
+  // retaining the sign.
+  if (dest_ibits < src_ibits) {
+Res = Builder.CreateShl(Res, src_ibits - dest_ibits);
+Res = Builder.CreateAShr(Res, src_ibits - dest_ibits);
+  }
+
+  // Move the radix. For irrational numbers, there will be loss of precision
+  // using this method when the number of fbits increases since we will be right
+  // padding zeros. Precision can still be retained if we temporarily convert to

[PATCH] D46926: [Fixed Point Arithmetic] Conversion between Fixed Point and Floating Point Numbers

2018-05-21 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 147881.
leonardchan added a comment.

formatting


Repository:
  rC Clang

https://reviews.llvm.org/D46926

Files:
  include/clang/AST/OperationKinds.def
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/AST/Expr.cpp
  lib/AST/ExprConstant.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprAgg.cpp
  lib/CodeGen/CGExprComplex.cpp
  lib/CodeGen/CGExprConstant.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/Edit/RewriteObjCFoundationAPI.cpp
  lib/Sema/SemaCast.cpp
  lib/Sema/SemaExpr.cpp
  lib/StaticAnalyzer/Core/ExprEngineC.cpp
  test/Frontend/fixed_point_validation.c

Index: test/Frontend/fixed_point_validation.c
===
--- test/Frontend/fixed_point_validation.c
+++ test/Frontend/fixed_point_validation.c
@@ -30,6 +30,7 @@
 // Run simple validation tests
 
 #define assert(b) if (!(b)) { return 1; }
+#define abs(x) x < 0 ? -x : x
 
 int main(){
   short _Accum s_accum = 0.0hk;
@@ -264,4 +265,18 @@
   assert(5.0hk >> 2 == 1.25hk);
   assert(-5.0hk >> 2 == -1.25k);
   assert(0.0hr >> 2 == 0);
+
+  / Float conversions ***/
+
+  float f = (float)2.5k;
+  assert(f > 2.4999 && f < 2.5001);  // High precision since the fractional
+ // value can be evenly represented.
+  assert((float)2.333hk != 2.333f);
+
+  float base = 2.333f;
+  float saccum_diff = abs(base - 2.333hk);
+  float accum_diff = abs(base - 2.333k);
+  float laccum_diff = abs(base - 2.333lk);
+  assert(accum_diff < saccum_diff);
+  assert(laccum_diff < accum_diff);
 }
Index: lib/StaticAnalyzer/Core/ExprEngineC.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineC.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineC.cpp
@@ -326,6 +326,8 @@
   case CK_IntegralToFixedPoint:
 llvm_unreachable(
 "ExprEngine::VisitCast CK_IntegralToFixedPoint");  // TODO
+  case CK_FixedPointToFloating:
+llvm_unreachable("Unimplemented logic for CK_FixedPointToFloating");
   case CK_LValueToRValue:
 llvm_unreachable("LValueToRValue casts handled earlier.");
   case CK_ToVoid:
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -1029,6 +1029,21 @@
   return result;
 }
 
+/// \brief Handle arithmetic conversion from fixed point to floating.  Helper
+/// function of UsualArithmeticConversions()
+static QualType handleFixedPointToFloatConversion(Sema ,
+  ExprResult ,
+  ExprResult ,
+  QualType FloatTy,
+  QualType FixedPointTy) {
+  assert(FloatTy->isFloatingType());
+  assert(FixedPointTy->isFixedPointType());
+
+  FixedPointExpr = S.ImpCastExprToType(FixedPointExpr.get(), FloatTy,
+   CK_FixedPointToFloating);
+  return FloatTy;
+}
+
 /// \brief Handle arithmethic conversion with floating point types.  Helper
 /// function of UsualArithmeticConversions()
 static QualType handleFloatConversion(Sema , ExprResult ,
@@ -1057,11 +1072,20 @@
 if (LHSType->isHalfType() && !S.getLangOpts().NativeHalfType)
   LHSType = S.Context.FloatTy;
 
+if (RHSType->isFixedPointType()) {
+  return handleFixedPointToFloatConversion(S, LHS, RHS, LHSType, RHSType);
+}
+
 return handleIntToFloatConversion(S, LHS, RHS, LHSType, RHSType,
   /*convertFloat=*/!IsCompAssign,
   /*convertInt=*/ true);
   }
   assert(RHSFloat);
+
+  if (LHSType->isFixedPointType()) {
+return handleFixedPointToFloatConversion(S, RHS, LHS, RHSType, LHSType);
+  }
+
   return handleIntToFloatConversion(S, RHS, LHS, RHSType, LHSType,
 /*convertInt=*/ true,
 /*convertFloat=*/!IsCompAssign);
@@ -1218,6 +1242,7 @@
   CK_IntegralRealToComplex);
   return ComplexType;
 }
+
 /// \brief Handle arithmetic conversion from integer to fixed point.  Helper
 /// function of UsualArithmeticConversions()
 static QualType handleIntToFixedPointConversion(Sema ,
@@ -6041,9 +6066,20 @@
 }
 llvm_unreachable("Should have returned before this");
 
-  case Type::STK_FixedPoint:
-llvm_unreachable(
-"Sema::PrepareScalarCast from STK_FixedPoint to anything");  // TODO
+  case Type::STK_FixedPoint: {
+switch (DestTy->getScalarTypeKind()) {
+  default:
+llvm_unreachable("Unable to convert from fixed point type");
+  case Type::STK_Integral:
+llvm_unreachable(
+"Unimplemented scalar cast from fixed point to int");  // TODO
+  case Type::STK_Floating:
+return CK_FixedPointToFloating;
+  case 

r332906 - Fix another make_unique ambiguity.

2018-05-21 Thread Peter Collingbourne via cfe-commits
Author: pcc
Date: Mon May 21 14:48:17 2018
New Revision: 332906

URL: http://llvm.org/viewvc/llvm-project?rev=332906=rev
Log:
Fix another make_unique ambiguity.

Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=332906=332905=332906=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Mon May 21 14:48:17 2018
@@ -108,7 +108,8 @@ class EmitAssemblyHelper {
 
   std::unique_ptr openOutputFile(StringRef Path) {
 std::error_code EC;
-auto F = make_unique(Path, EC, 
llvm::sys::fs::F_None);
+auto F = llvm::make_unique(Path, EC,
+ llvm::sys::fs::F_None);
 if (EC) {
   Diags.Report(diag::err_fe_unable_to_open_output) << Path << EC.message();
   F.reset();


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


[PATCH] D46925: [Fixed Point Arithmetic] Remaining Binary Operations on Primary Fixed Point Types

2018-05-21 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 147880.
leonardchan added a comment.

formatting


Repository:
  rC Clang

https://reviews.llvm.org/D46925

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/OperationKinds.def
  include/clang/AST/Type.h
  lib/AST/ASTContext.cpp
  lib/AST/Expr.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/Type.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprAgg.cpp
  lib/CodeGen/CGExprComplex.cpp
  lib/CodeGen/CGExprConstant.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/Edit/RewriteObjCFoundationAPI.cpp
  lib/Sema/SemaExpr.cpp
  lib/StaticAnalyzer/Core/ExprEngineC.cpp
  test/Frontend/fixed_point_validation.c

Index: test/Frontend/fixed_point_validation.c
===
--- test/Frontend/fixed_point_validation.c
+++ test/Frontend/fixed_point_validation.c
@@ -74,6 +74,9 @@
   assert(2 == s_accum);
   // CHECK:  {{.*}} = icmp eq i16 256, {{.*}}
 
+  assert(2 == 2.0hk);
+  assert(2 != 2.01hk);
+
   int x = 2;
   assert(s_accum == x);
   // CHECK:  {{.*}} = load i32, i32* %x, align 4
@@ -128,6 +131,46 @@
   // numbers.
   assert(2 == 2.001hk);  // This is valid if SACCUM_FBITS == 7
 
+  // Comparisons between fixed-point types
+  // Signed _Accum to signed _Accum types.
+  assert(2.5hk == 2.5k);
+  assert(2.5k == 2.5lk);
+  assert(-2.5hk == -2.5k);
+  assert(-2.5k == -2.5lk);
+
+  // Unsigned _Accum to unigned _Accum
+  assert(2.5uhk == 2.5uk);
+  assert(2.5uk == 2.5ulk);
+
+  // Signed _Fract to signed _Fract types.
+  assert(0.333hr != 0.333r);  // Loss of precision since different fractional widths
+  assert(0.333r != 0.333lr);
+  assert(-0.333hr != -0.333r);
+  assert(-0.333r != -0.333lr);
+
+  // Unsigned _Fract to unsigned _Fract types.
+  assert(0.333uhr != 0.333ur);
+  assert(0.333ur != 0.333ulr);
+
+  // Signed _Accum to signed _Fract
+  assert(0.333hk == 0.333hr);
+  assert(0.333k == 0.333r);
+  assert(0.333lk == 0.333lr);
+  assert(0.333hk == 0.333r);  // Although _Fract has higher precision, it gets casted up to
+  // short _Accum which (using default precisions)
+  // has fewer fractional bits.
+
+  // Signed _Accum to unsigned _Fract
+  assert(0.333hk == 0.333uhr);
+  assert(0.333k == 0.333ur);
+  assert(0.333lk == 0.333ulr);
+
+  // Signed _Accum to unsigned _Accum
+  assert(2.5hk == 2.5uhk);
+  assert(2.5k == 2.5uk);
+  assert(2.5lk == 2.5ulk);
+
+
   / Unary operations ***/
 
   s_accum = 0.0hk;
@@ -167,4 +210,58 @@
   assert(+s_fract == s_fract);
   assert(+s_fract2 == s_fract2);  // s_fract2 is negative
   assert(-s_fract == s_fract2);
+
+  / Binary operations ***/
+
+  // Addition
+  s_accum = 3.0hk;
+  short _Accum s_accum_sum = s_accum + s_accum2;
+  assert(s_accum_sum == 5);
+  assert(s_fract + s_fract2 == 0);
+
+  // Subtraction
+  short _Accum s_accum_diff = s_accum - s_accum2;
+  assert(s_accum_diff == 1);
+  assert(s_accum2 - s_accum == -1);
+
+  // Multiplication
+  short _Accum s_accum_mul = s_accum * s_accum2;
+  assert(s_accum_mul == 6);
+  assert(2.0hk * 3.0hk == 6);
+  assert(2.0hk * 3 == 6);
+  assert(2.5hk * 3 == 7.5k);
+  assert(-2.5hk * 3 == -7.5lk);
+  assert(3 * -2.5hk == -7.5hk);
+  assert(-2.5hk * 0 == 0);
+
+  // Division
+  const short _Accum s_accum3 = 2.5hk;
+  short _Accum s_accum_div = s_accum3 / s_accum2;
+  assert(s_accum_div == 1.25hk);
+  assert(5.0hk / s_accum3 == 2);
+  assert(-5.0hk / s_accum3 == -2);
+  assert(9.9k / 3.3k == 3);
+  assert(9.9hk / 3.3k != 3);  // We lose precision when converting between types of different
+  // fractional width.
+  assert(6.75hk / 2.25k == 3);  // Unless the fractional part can be evenly represented with
+// sums of powers of 2.
+  assert(0 / 2.0hk == 0);
+
+  // Left shift
+  short _Accum s_accum_shl = s_accum2 << 3;
+  assert(s_accum_shl == 16);
+  assert(1.0hk << 3 == 8);
+  assert(-1.0hk << 3 == -8);
+  assert(1.5k << 1 == 3);  // LShift is equivalent to multiplying by 2
+  assert(-1.25hk << 2 == -5);
+
+  // Right shift
+  const signed short _Accum s_accum4 = 16.0hk;
+  short _Accum s_accum_shr = s_accum4 >> 3;
+  assert(s_accum_shr == 2);
+  assert(s_accum_shr >> 1 == 1);
+  assert(s_accum_shr >> 2 == 0.5hr);  // RShift is equivalent to dividing by 2
+  assert(5.0hk >> 2 == 1.25hk);
+  assert(-5.0hk >> 2 == -1.25k);
+  assert(0.0hr >> 2 == 0);
 }
Index: lib/StaticAnalyzer/Core/ExprEngineC.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngineC.cpp
+++ lib/StaticAnalyzer/Core/ExprEngineC.cpp
@@ -321,6 +321,8 @@
 const LocationContext *LCtx = Pred->getLocationContext();
 
 switch (CastE->getCastKind()) {
+  case CK_FixedPointCast:
+llvm_unreachable("CK_FixedPointCast");  // TODO
   case CK_IntegralToFixedPoint:
 llvm_unreachable(
 "ExprEngine::VisitCast 

[PATCH] D47097: [DebugInfo] Preserve scope in auto generated StoreInst

2018-05-21 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added inline comments.



Comment at: lib/CodeGen/CGDecl.cpp:2074
+  if (DoStore) {
+   auto DL = ApplyDebugLocation::CreateArtificial(*this);
+   EmitStoreOfScalar(ArgVal, lv, /* isInitialization */ true);

Ideally this would precede the calls to CreateMemTemp which set up the allocas.



Comment at: test/CodeGen/debug-info-preserve-scope.c:10
+
+// CHECK: store i32 %b, i32* %b.addr, align 4, !dbg ![[dbgLocForStore:[0-9]+]]
+

Can you check that the alloca gets the same location as well? You can do this 
with:
```
CHECK: alloca {{.*}} !dbg ![[dbgLocForStore:[0-9]+]]
CHECK: store i32 {{.*}} !dbg ![[dbgLocForStore]]
```


Repository:
  rC Clang

https://reviews.llvm.org/D47097



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


[PATCH] D47097: [DebugInfo] Preserve scope in auto generated StoreInst

2018-05-21 Thread Anastasis via Phabricator via cfe-commits
gramanas updated this revision to Diff 147876.
gramanas added a comment.

Update diff


Repository:
  rC Clang

https://reviews.llvm.org/D47097

Files:
  lib/CodeGen/CGDecl.cpp
  test/CodeGen/debug-info-preserve-scope.c


Index: test/CodeGen/debug-info-preserve-scope.c
===
--- /dev/null
+++ test/CodeGen/debug-info-preserve-scope.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -debug-info-kind=limited -emit-llvm -o - %s | FileCheck %s
+
+static int a;
+
+// CHECK-LABEL: define void @f
+void f(int b) {
+  a = b;
+}
+
+// CHECK: store i32 %b, i32* %b.addr, align 4, !dbg ![[dbgLocForStore:[0-9]+]]
+
+// CHECK: ![[dbgLocForStore]] = !DILocation(line: 0
Index: lib/CodeGen/CGDecl.cpp
===
--- lib/CodeGen/CGDecl.cpp
+++ lib/CodeGen/CGDecl.cpp
@@ -2070,8 +2070,10 @@
   }
 
   // Store the initial value into the alloca.
-  if (DoStore)
-EmitStoreOfScalar(ArgVal, lv, /* isInitialization */ true);
+  if (DoStore) {
+   auto DL = ApplyDebugLocation::CreateArtificial(*this);
+   EmitStoreOfScalar(ArgVal, lv, /* isInitialization */ true);
+  }
 
   setAddrOfLocalVar(, DeclPtr);
 


Index: test/CodeGen/debug-info-preserve-scope.c
===
--- /dev/null
+++ test/CodeGen/debug-info-preserve-scope.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -debug-info-kind=limited -emit-llvm -o - %s | FileCheck %s
+
+static int a;
+
+// CHECK-LABEL: define void @f
+void f(int b) {
+  a = b;
+}
+
+// CHECK: store i32 %b, i32* %b.addr, align 4, !dbg ![[dbgLocForStore:[0-9]+]]
+
+// CHECK: ![[dbgLocForStore]] = !DILocation(line: 0
Index: lib/CodeGen/CGDecl.cpp
===
--- lib/CodeGen/CGDecl.cpp
+++ lib/CodeGen/CGDecl.cpp
@@ -2070,8 +2070,10 @@
   }
 
   // Store the initial value into the alloca.
-  if (DoStore)
-EmitStoreOfScalar(ArgVal, lv, /* isInitialization */ true);
+  if (DoStore) {
+   auto DL = ApplyDebugLocation::CreateArtificial(*this);
+   EmitStoreOfScalar(ArgVal, lv, /* isInitialization */ true);
+  }
 
   setAddrOfLocalVar(, DeclPtr);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r332901 - Implement deduction guides for vector

2018-05-21 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Mon May 21 14:30:12 2018
New Revision: 332901

URL: http://llvm.org/viewvc/llvm-project?rev=332901=rev
Log:
Implement deduction guides for vector

Added:

libcxx/trunk/test/std/containers/sequences/vector/vector.cons/deduct.fail.cpp

libcxx/trunk/test/std/containers/sequences/vector/vector.cons/deduct.pass.cpp
Modified:
libcxx/trunk/include/vector

Modified: libcxx/trunk/include/vector
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/vector?rev=332901=332900=332901=diff
==
--- libcxx/trunk/include/vector (original)
+++ libcxx/trunk/include/vector Mon May 21 14:30:12 2018
@@ -244,6 +244,10 @@ public:
 bool __invariants() const;
 };
 
+template ::value_type>>
+   vector(InputIterator, InputIterator, Allocator = Allocator())
+   -> vector::value_type, Allocator>;
+
 template  struct hash>;
 
 template  bool operator==(const vector& 
x, const vector& y);
@@ -316,13 +320,14 @@ template 
 class __vector_base
 : protected __vector_base_common
 {
-protected:
-typedef _Tp  value_type;
+public:
 typedef _Allocator   allocator_type;
 typedef allocator_traits __alloc_traits;
+typedef typename __alloc_traits::size_type   size_type;
+protected:
+typedef _Tp  value_type;
 typedef value_type&  reference;
 typedef const value_type&const_reference;
-typedef typename __alloc_traits::size_type   size_type;
 typedef typename __alloc_traits::difference_type difference_type;
 typedef typename __alloc_traits::pointer pointer;
 typedef typename __alloc_traits::const_pointer   const_pointer;
@@ -492,8 +497,8 @@ public:
 #if _LIBCPP_STD_VER > 11
 explicit vector(size_type __n, const allocator_type& __a);
 #endif
-vector(size_type __n, const_reference __x);
-vector(size_type __n, const_reference __x, const allocator_type& __a);
+vector(size_type __n, const value_type& __x);
+vector(size_type __n, const value_type& __x, const allocator_type& __a);
 template 
 vector(_InputIterator __first,
typename enable_if<__is_input_iterator  <_InputIterator>::value 
&&
@@ -890,6 +895,22 @@ private:
 
 };
 
+#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
+template::value_type>,
+ class = typename enable_if<__is_allocator<_Alloc>::value, void>::type
+ >
+vector(_InputIterator, _InputIterator)
+  -> vector::value_type, _Alloc>;
+
+template::value, void>::type
+ >
+vector(_InputIterator, _InputIterator, _Alloc)
+  -> vector::value_type, _Alloc>;
+#endif
+
 template 
 void
 vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer& __v)
@@ -1099,7 +1120,7 @@ vector<_Tp, _Allocator>::vector(size_typ
 #endif
 
 template 
-vector<_Tp, _Allocator>::vector(size_type __n, const_reference __x)
+vector<_Tp, _Allocator>::vector(size_type __n, const value_type& __x)
 {
 #if _LIBCPP_DEBUG_LEVEL >= 2
 __get_db()->__insert_c(this);
@@ -1112,7 +1133,7 @@ vector<_Tp, _Allocator>::vector(size_typ
 }
 
 template 
-vector<_Tp, _Allocator>::vector(size_type __n, const_reference __x, const 
allocator_type& __a)
+vector<_Tp, _Allocator>::vector(size_type __n, const value_type& __x, const 
allocator_type& __a)
 : __base(__a)
 {
 #if _LIBCPP_DEBUG_LEVEL >= 2

Added: 
libcxx/trunk/test/std/containers/sequences/vector/vector.cons/deduct.fail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/vector/vector.cons/deduct.fail.cpp?rev=332901=auto
==
--- 
libcxx/trunk/test/std/containers/sequences/vector/vector.cons/deduct.fail.cpp 
(added)
+++ 
libcxx/trunk/test/std/containers/sequences/vector/vector.cons/deduct.fail.cpp 
Mon May 21 14:30:12 2018
@@ -0,0 +1,40 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+// UNSUPPORTED: libcpp-no-deduction-guides
+
+
+// template ::value_type>>
+//vector(InputIterator, InputIterator, Allocator = Allocator())
+//-> vector::value_type, 
Allocator>;
+//
+
+
+#include 
+#include 
+#include 
+#include 
+
+
+int main()
+{  
+//  Test the explicit deduction guides
+
+//  Test the implicit deduction guides
+{
+//  vector (allocator &)
+std::vector vec((std::allocator()));  // expected-error {{no viable 
constructor or deduction guide for deduction of 

[PATCH] D47099: Disable casting of alloca for ActiveFlag

2018-05-21 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/CodeGen/CGExpr.cpp:80
   auto Alloca = CreateTempAlloca(Ty, Name, ArraySize);
   Alloca->setAlignment(Align.getQuantity());
   if (AllocaAddr)

Could you change this to call CreateTempAllocaWithoutCast?


https://reviews.llvm.org/D47099



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


[PATCH] D46241: [CodeGen] Recognize more cases of zero initialization

2018-05-21 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: lib/CodeGen/CGExprConstant.cpp:1414-1415
+Expr::EvalResult Result;
+if (Init->EvaluateAsRValue(Result, CE.CGM.getContext()) &&
+!Result.hasUnacceptableSideEffect(Expr::SE_NoSideEffects))
+  return (Result.Val.isInt() && Result.Val.getInt().isNullValue()) ||

sepavloff wrote:
> rsmith wrote:
> > Please call `D.evaluateValue()` here rather than inventing your own 
> > evaluation scheme. That way, we'll cache the evaluated initializer on the 
> > variable for other uses or reuse the value if we've already evaluated it, 
> > and you don't need to worry about the corner cases involved in getting the 
> > evaluation right. (As it happens, you're getting some minor details wrong 
> > because evaluating an initializer is not quite the same as evaluating an 
> > rvalue, but in practice it's not a big deal here.)
> 
> Call of `D.evaluateValue()` may result in substantial memory and time 
> consumption if the variable value is huge, like in:
> ```
> int char data_1[2147483648u] = { 0 };
> ```
> The idea of this patch is to recognize some cases of zero initialization 
> prior to the evaluation of variable initializer. In the example above, value 
> would be evaluated only for part of the initializer, namely `0`, which does 
> not have an associated variable, so call of `D.evaluateValue()` is not 
> possible.
> 
As noted, `EvaluateAsRValue` gets some of the details here wrong. I reverted 
this in r332886 because of a miscompile due to this fact.


Repository:
  rC Clang

https://reviews.llvm.org/D46241



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


[PATCH] D47157: Warning for framework headers using double quote includes

2018-05-21 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

> The warning is off by default.

We typically do not add off-by-default warnings because experience has shown 
the rarely get enabled in practice. Can you explain a bit more about why this 
one is off by default?


Repository:
  rC Clang

https://reviews.llvm.org/D47157



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


[PATCH] D47161: update

2018-05-21 Thread Anastasis via Phabricator via cfe-commits
gramanas created this revision.
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

https://reviews.llvm.org/D47161

Files:
  lib/CodeGen/CGDecl.cpp
  test/CodeGen/debug-info-preserve-scope.c


Index: test/CodeGen/debug-info-preserve-scope.c
===
--- /dev/null
+++ test/CodeGen/debug-info-preserve-scope.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -debug-info-kind=limited -emit-llvm -o - %s | FileCheck %s
+
+static int a;
+
+// CHECK-LABEL: define void @f
+void f(int b) {
+  a = b;
+}
+
+// CHECK: store i32 %b, i32* %b.addr, align 4, !dbg ![[dbgLocForStore:[0-9]+]]
+
+// CHECK: ![[dbgLocForStore]] = !DILocation(line: 0
Index: lib/CodeGen/CGDecl.cpp
===
--- lib/CodeGen/CGDecl.cpp
+++ lib/CodeGen/CGDecl.cpp
@@ -2070,8 +2070,10 @@
   }
 
   // Store the initial value into the alloca.
-  if (DoStore)
-EmitStoreOfScalar(ArgVal, lv, /* isInitialization */ true);
+  if (DoStore) {
+   auto DL = ApplyDebugLocation::CreateArtificial(*this);
+   EmitStoreOfScalar(ArgVal, lv, /* isInitialization */ true);
+  }
 
   setAddrOfLocalVar(, DeclPtr);
 


Index: test/CodeGen/debug-info-preserve-scope.c
===
--- /dev/null
+++ test/CodeGen/debug-info-preserve-scope.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -debug-info-kind=limited -emit-llvm -o - %s | FileCheck %s
+
+static int a;
+
+// CHECK-LABEL: define void @f
+void f(int b) {
+  a = b;
+}
+
+// CHECK: store i32 %b, i32* %b.addr, align 4, !dbg ![[dbgLocForStore:[0-9]+]]
+
+// CHECK: ![[dbgLocForStore]] = !DILocation(line: 0
Index: lib/CodeGen/CGDecl.cpp
===
--- lib/CodeGen/CGDecl.cpp
+++ lib/CodeGen/CGDecl.cpp
@@ -2070,8 +2070,10 @@
   }
 
   // Store the initial value into the alloca.
-  if (DoStore)
-EmitStoreOfScalar(ArgVal, lv, /* isInitialization */ true);
+  if (DoStore) {
+   auto DL = ApplyDebugLocation::CreateArtificial(*this);
+   EmitStoreOfScalar(ArgVal, lv, /* isInitialization */ true);
+  }
 
   setAddrOfLocalVar(, DeclPtr);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D47125: [X86] Remove masking from pternlog llvm intrinsics and use a select instruction instead.

2018-05-21 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL332891: [X86] Remove masking from pternlog llvm intrinsics 
and use a select instruction… (authored by ctopper, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D47125

Files:
  cfe/trunk/lib/CodeGen/CGBuiltin.cpp
  cfe/trunk/test/CodeGen/avx512f-builtins.c
  cfe/trunk/test/CodeGen/avx512vl-builtins.c

Index: cfe/trunk/test/CodeGen/avx512vl-builtins.c
===
--- cfe/trunk/test/CodeGen/avx512vl-builtins.c
+++ cfe/trunk/test/CodeGen/avx512vl-builtins.c
@@ -5608,73 +5608,81 @@
 
 __m128i test_mm_ternarylogic_epi32(__m128i __A, __m128i __B, __m128i __C) {
   // CHECK-LABEL: @test_mm_ternarylogic_epi32
-  // CHECK: @llvm.x86.avx512.mask.pternlog.d.128
+  // CHECK: @llvm.x86.avx512.pternlog.d.128
   return _mm_ternarylogic_epi32(__A, __B, __C, 4); 
 }
 
 __m128i test_mm_mask_ternarylogic_epi32(__m128i __A, __mmask8 __U, __m128i __B, __m128i __C) {
   // CHECK-LABEL: @test_mm_mask_ternarylogic_epi32
-  // CHECK: @llvm.x86.avx512.mask.pternlog.d.128
+  // CHECK: @llvm.x86.avx512.pternlog.d.128
+  // CHECK: select <4 x i1> %{{.*}}, <4 x i32> %{{.*}}, <4 x i32> %{{.*}}
   return _mm_mask_ternarylogic_epi32(__A, __U, __B, __C, 4); 
 }
 
 __m128i test_mm_maskz_ternarylogic_epi32(__mmask8 __U, __m128i __A, __m128i __B, __m128i __C) {
   // CHECK-LABEL: @test_mm_maskz_ternarylogic_epi32
-  // CHECK: @llvm.x86.avx512.maskz.pternlog.d.128
+  // CHECK: @llvm.x86.avx512.pternlog.d.128
+  // CHECK: select <4 x i1> %{{.*}}, <4 x i32> %{{.*}}, <4 x i32> zeroinitializer
   return _mm_maskz_ternarylogic_epi32(__U, __A, __B, __C, 4); 
 }
 
 __m256i test_mm256_ternarylogic_epi32(__m256i __A, __m256i __B, __m256i __C) {
   // CHECK-LABEL: @test_mm256_ternarylogic_epi32
-  // CHECK: @llvm.x86.avx512.mask.pternlog.d.256
+  // CHECK: @llvm.x86.avx512.pternlog.d.256
   return _mm256_ternarylogic_epi32(__A, __B, __C, 4); 
 }
 
 __m256i test_mm256_mask_ternarylogic_epi32(__m256i __A, __mmask8 __U, __m256i __B, __m256i __C) {
   // CHECK-LABEL: @test_mm256_mask_ternarylogic_epi32
-  // CHECK: @llvm.x86.avx512.mask.pternlog.d.256
+  // CHECK: @llvm.x86.avx512.pternlog.d.256
+  // CHECK: select <8 x i1> %{{.*}}, <8 x i32> %{{.*}}, <8 x i32> %{{.*}}
   return _mm256_mask_ternarylogic_epi32(__A, __U, __B, __C, 4); 
 }
 
 __m256i test_mm256_maskz_ternarylogic_epi32(__mmask8 __U, __m256i __A, __m256i __B, __m256i __C) {
   // CHECK-LABEL: @test_mm256_maskz_ternarylogic_epi32
-  // CHECK: @llvm.x86.avx512.maskz.pternlog.d.256
+  // CHECK: @llvm.x86.avx512.pternlog.d.256
+  // CHECK: select <8 x i1> %{{.*}}, <8 x i32> %{{.*}}, <8 x i32> zeroinitializer
   return _mm256_maskz_ternarylogic_epi32(__U, __A, __B, __C, 4); 
 }
 
 __m128i test_mm_ternarylogic_epi64(__m128i __A, __m128i __B, __m128i __C) {
   // CHECK-LABEL: @test_mm_ternarylogic_epi64
-  // CHECK: @llvm.x86.avx512.mask.pternlog.q.128
+  // CHECK: @llvm.x86.avx512.pternlog.q.128
   return _mm_ternarylogic_epi64(__A, __B, __C, 4); 
 }
 
 __m128i test_mm_mask_ternarylogic_epi64(__m128i __A, __mmask8 __U, __m128i __B, __m128i __C) {
   // CHECK-LABEL: @test_mm_mask_ternarylogic_epi64
-  // CHECK: @llvm.x86.avx512.mask.pternlog.q.128
+  // CHECK: @llvm.x86.avx512.pternlog.q.128
+  // CHECK: select <2 x i1> %{{.*}}, <2 x i64> %{{.*}}, <2 x i64> %{{.*}}
   return _mm_mask_ternarylogic_epi64(__A, __U, __B, __C, 4); 
 }
 
 __m128i test_mm_maskz_ternarylogic_epi64(__mmask8 __U, __m128i __A, __m128i __B, __m128i __C) {
   // CHECK-LABEL: @test_mm_maskz_ternarylogic_epi64
-  // CHECK: @llvm.x86.avx512.maskz.pternlog.q.128
+  // CHECK: @llvm.x86.avx512.pternlog.q.128
+  // CHECK: select <2 x i1> %{{.*}}, <2 x i64> %{{.*}}, <2 x i64> zeroinitializer
   return _mm_maskz_ternarylogic_epi64(__U, __A, __B, __C, 4); 
 }
 
 __m256i test_mm256_ternarylogic_epi64(__m256i __A, __m256i __B, __m256i __C) {
   // CHECK-LABEL: @test_mm256_ternarylogic_epi64
-  // CHECK: @llvm.x86.avx512.mask.pternlog.q.256
+  // CHECK: @llvm.x86.avx512.pternlog.q.256
   return _mm256_ternarylogic_epi64(__A, __B, __C, 4); 
 }
 
 __m256i test_mm256_mask_ternarylogic_epi64(__m256i __A, __mmask8 __U, __m256i __B, __m256i __C) {
   // CHECK-LABEL: @test_mm256_mask_ternarylogic_epi64
-  // CHECK: @llvm.x86.avx512.mask.pternlog.q.256
+  // CHECK: @llvm.x86.avx512.pternlog.q.256
+  // CHECK: select <4 x i1> %{{.*}}, <4 x i64> %{{.*}}, <4 x i64> %{{.*}}
   return _mm256_mask_ternarylogic_epi64(__A, __U, __B, __C, 4); 
 }
 
 __m256i test_mm256_maskz_ternarylogic_epi64(__mmask8 __U, __m256i __A, __m256i __B, __m256i __C) {
   // CHECK-LABEL: @test_mm256_maskz_ternarylogic_epi64
-  // CHECK: @llvm.x86.avx512.maskz.pternlog.q.256
+  // CHECK: @llvm.x86.avx512.pternlog.q.256
+  // CHECK: select <4 x i1> %{{.*}}, <4 x i64> %{{.*}}, <4 x i64> zeroinitializer
   return _mm256_maskz_ternarylogic_epi64(__U, __A, __B, __C, 4); 
 }
 __m256 

[PATCH] D47108: Add -fforce-emit-vtables

2018-05-21 Thread Krzysztof Pszeniczny via Phabricator via cfe-commits
amharc added a comment.

I think that `MarkVTableUsed` should be called somewhere in Sema (possibly 
`ActOnFinishCXXMemberDecls`?) if `ForceEmitVTables` is on. This probably 
requires making `ForceEmitVTables` a `LangOption` in addition to it being a 
`CodeGenOption`.

This causes the above example to compile correctly. Moreover, I have checked 
that 7zip and Bullet (the llvm test suite benchmarks which failed previously) 
build and execute correctly with the above change.


Repository:
  rL LLVM

https://reviews.llvm.org/D47108



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


[PATCH] D47157: Warning for framework headers using double quote includes

2018-05-21 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

See also PR22165.


Repository:
  rC Clang

https://reviews.llvm.org/D47157



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


r332891 - [X86] Remove masking from pternlog llvm intrinsics and use a select instruction instead.

2018-05-21 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Mon May 21 13:58:23 2018
New Revision: 332891

URL: http://llvm.org/viewvc/llvm-project?rev=332891=rev
Log:
[X86] Remove masking from pternlog llvm intrinsics and use a select instruction 
instead.

Because the intrinsics in the headers are implemented as macros, we can't just 
use a select builtin and pternlog builtin. This would require one of the macro 
arguments to be used twice. Depending on what was passed to the macro we could 
expand an expression twice leading to weird behavior. We could maybe declare 
our local variable in the macro, but that would need to worry about name 
collisions.

To avoid that just generate IR directly in CGBuiltin.cpp.

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

Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/avx512f-builtins.c
cfe/trunk/test/CodeGen/avx512vl-builtins.c

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=332891=332890=332891=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Mon May 21 13:58:23 2018
@@ -8445,6 +8445,37 @@ static Value *EmitX86Muldq(CodeGenFuncti
   return CGF.Builder.CreateMul(LHS, RHS);
 }
 
+// Emit a masked pternlog intrinsic. This only exists because the header has to
+// use a macro and we aren't able to pass the input argument to a pternlog
+// builtin and a select builtin without evaluating it twice.
+static Value *EmitX86Ternlog(CodeGenFunction , bool ZeroMask,
+ ArrayRef Ops) {
+  llvm::Type *Ty = Ops[0]->getType();
+
+  unsigned VecWidth = Ty->getPrimitiveSizeInBits();
+  unsigned EltWidth = Ty->getScalarSizeInBits();
+  Intrinsic::ID IID;
+  if (VecWidth == 128 && EltWidth == 32)
+IID = Intrinsic::x86_avx512_pternlog_d_128;
+  else if (VecWidth == 256 && EltWidth == 32)
+IID = Intrinsic::x86_avx512_pternlog_d_256;
+  else if (VecWidth == 512 && EltWidth == 32)
+IID = Intrinsic::x86_avx512_pternlog_d_512;
+  else if (VecWidth == 128 && EltWidth == 64)
+IID = Intrinsic::x86_avx512_pternlog_q_128;
+  else if (VecWidth == 256 && EltWidth == 64)
+IID = Intrinsic::x86_avx512_pternlog_q_256;
+  else if (VecWidth == 512 && EltWidth == 64)
+IID = Intrinsic::x86_avx512_pternlog_q_512;
+  else
+llvm_unreachable("Unexpected intrinsic");
+
+  Value *Ternlog = CGF.Builder.CreateCall(CGF.CGM.getIntrinsic(IID),
+  Ops.drop_back());
+  Value *PassThru = ZeroMask ? ConstantAggregateZero::get(Ty) : Ops[0];
+  return EmitX86Select(CGF, Ops[4], Ternlog, PassThru);
+}
+
 static Value *EmitX86SExtMask(CodeGenFunction , Value *Op, 
   llvm::Type *DstTy) {
   unsigned NumberOfElements = DstTy->getVectorNumElements();
@@ -9159,6 +9190,22 @@ Value *CodeGenFunction::EmitX86BuiltinEx
   case X86::BI__builtin_ia32_pmuldq512:
 return EmitX86Muldq(*this, /*IsSigned*/true, Ops);
 
+  case X86::BI__builtin_ia32_pternlogd512_mask:
+  case X86::BI__builtin_ia32_pternlogq512_mask:
+  case X86::BI__builtin_ia32_pternlogd128_mask:
+  case X86::BI__builtin_ia32_pternlogd256_mask:
+  case X86::BI__builtin_ia32_pternlogq128_mask:
+  case X86::BI__builtin_ia32_pternlogq256_mask:
+return EmitX86Ternlog(*this, /*ZeroMask*/false, Ops);
+
+  case X86::BI__builtin_ia32_pternlogd512_maskz:
+  case X86::BI__builtin_ia32_pternlogq512_maskz:
+  case X86::BI__builtin_ia32_pternlogd128_maskz:
+  case X86::BI__builtin_ia32_pternlogd256_maskz:
+  case X86::BI__builtin_ia32_pternlogq128_maskz:
+  case X86::BI__builtin_ia32_pternlogq256_maskz:
+return EmitX86Ternlog(*this, /*ZeroMask*/true, Ops);
+
   // 3DNow!
   case X86::BI__builtin_ia32_pswapdsf:
   case X86::BI__builtin_ia32_pswapdsi: {

Modified: cfe/trunk/test/CodeGen/avx512f-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx512f-builtins.c?rev=332891=332890=332891=diff
==
--- cfe/trunk/test/CodeGen/avx512f-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx512f-builtins.c Mon May 21 13:58:23 2018
@@ -4494,37 +4494,41 @@ __m512i test_mm512_maskz_srlv_epi64(__mm
 
 __m512i test_mm512_ternarylogic_epi32(__m512i __A, __m512i __B, __m512i __C) {
   // CHECK-LABEL: @test_mm512_ternarylogic_epi32
-  // CHECK: @llvm.x86.avx512.mask.pternlog.d.512
+  // CHECK: @llvm.x86.avx512.pternlog.d.512
   return _mm512_ternarylogic_epi32(__A, __B, __C, 4); 
 }
 
 __m512i test_mm512_mask_ternarylogic_epi32(__m512i __A, __mmask16 __U, __m512i 
__B, __m512i __C) {
   // CHECK-LABEL: @test_mm512_mask_ternarylogic_epi32
-  // CHECK: @llvm.x86.avx512.mask.pternlog.d.512
+  // CHECK: @llvm.x86.avx512.pternlog.d.512
+  // CHECK: select <16 x i1> %{{.*}}, <16 x i32> %{{.*}}, <16 x i32> %{{.*}}
   return _mm512_mask_ternarylogic_epi32(__A, __U, __B, __C, 

[PATCH] D47099: Disable casting of alloca for ActiveFlag

2018-05-21 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 147860.
yaxunl added a comment.

Add CreateMemTempWithoutCast and CreateTempAllocaWithoutCast by John's comments.


https://reviews.llvm.org/D47099

Files:
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/CGCleanup.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGenCXX/conditional-temporaries.cpp

Index: test/CodeGenCXX/conditional-temporaries.cpp
===
--- test/CodeGenCXX/conditional-temporaries.cpp
+++ test/CodeGenCXX/conditional-temporaries.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin9 -O3 | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=amdgcn-amd-amdhsa -O3 | FileCheck %s
 
 namespace {
 
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -2020,18 +2020,20 @@
   /// to the stack.
   ///
   /// Because the address of a temporary is often exposed to the program in
-  /// various ways, this function will perform the cast by default. The cast
-  /// may be avoided by passing false as \p CastToDefaultAddrSpace; this is
+  /// various ways, this function will perform the cast. The original alloca
+  /// instruction is returned through \p Alloca if it is not nullptr.
+  ///
+  /// The cast is not performaed in CreateTempAllocaWithoutCast. This is
   /// more efficient if the caller knows that the address will not be exposed.
-  /// The original alloca instruction is returned through \p Alloca if it is
-  /// not nullptr.
   llvm::AllocaInst *CreateTempAlloca(llvm::Type *Ty, const Twine  = "tmp",
  llvm::Value *ArraySize = nullptr);
   Address CreateTempAlloca(llvm::Type *Ty, CharUnits align,
const Twine  = "tmp",
llvm::Value *ArraySize = nullptr,
-   Address *Alloca = nullptr,
-   bool CastToDefaultAddrSpace = true);
+   Address *Alloca = nullptr);
+  Address CreateTempAllocaWithoutCast(llvm::Type *Ty, CharUnits align,
+  const Twine  = "tmp",
+  llvm::Value *ArraySize = nullptr);
 
   /// CreateDefaultAlignedTempAlloca - This creates an alloca with the
   /// default ABI alignment of the given LLVM type.
@@ -2066,15 +2068,18 @@
   Address CreateIRTemp(QualType T, const Twine  = "tmp");
 
   /// CreateMemTemp - Create a temporary memory object of the given type, with
-  /// appropriate alignment. Cast it to the default address space if
-  /// \p CastToDefaultAddrSpace is true. Returns the original alloca
-  /// instruction by \p Alloca if it is not nullptr.
+  /// appropriate alignmen and cast it to the default address space. Returns
+  /// the original alloca instruction by \p Alloca if it is not nullptr.
   Address CreateMemTemp(QualType T, const Twine  = "tmp",
-Address *Alloca = nullptr,
-bool CastToDefaultAddrSpace = true);
+Address *Alloca = nullptr);
   Address CreateMemTemp(QualType T, CharUnits Align, const Twine  = "tmp",
-Address *Alloca = nullptr,
-bool CastToDefaultAddrSpace = true);
+Address *Alloca = nullptr);
+
+  /// CreateMemTemp - Create a temporary memory object of the given type, with
+  /// appropriate alignmen without casting it to the default address space.
+  Address CreateMemTempWithoutCast(QualType T, const Twine  = "tmp");
+  Address CreateMemTempWithoutCast(QualType T, CharUnits Align,
+   const Twine  = "tmp");
 
   /// CreateAggTemp - Create a temporary memory object for the given
   /// aggregate type.
Index: lib/CodeGen/CGExpr.cpp
===
--- lib/CodeGen/CGExpr.cpp
+++ lib/CodeGen/CGExpr.cpp
@@ -61,11 +61,21 @@
 
 /// CreateTempAlloca - This creates a alloca and inserts it into the entry
 /// block.
+Address CodeGenFunction::CreateTempAllocaWithoutCast(llvm::Type *Ty,
+ CharUnits Align,
+ const Twine ,
+ llvm::Value *ArraySize) {
+  auto Alloca = CreateTempAlloca(Ty, Name, ArraySize);
+  Alloca->setAlignment(Align.getQuantity());
+  return Address(Alloca, Align);
+}
+
+/// CreateTempAlloca - This creates a alloca and inserts it into the entry
+/// block. The alloca is casted to default address space if necessary.
 Address CodeGenFunction::CreateTempAlloca(llvm::Type *Ty, CharUnits Align,
   const Twine ,
   llvm::Value *ArraySize,
-  Address *AllocaAddr,

Re: r332847 - [CodeGen] Recognize more cases of zero initialization

2018-05-21 Thread Richard Smith via cfe-commits
Reverted in r332886; I added a testcase for the miscompile below
to test/CodeGenCXX/reference-init.cpp

On 21 May 2018 at 13:28, Richard Smith  wrote:

> On 21 May 2018 at 13:22, Richard Smith  wrote:
>
>> On 21 May 2018 at 09:09, Serge Pavlov via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: sepavloff
>>> Date: Mon May 21 09:09:54 2018
>>> New Revision: 332847
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=332847=rev
>>> Log:
>>> [CodeGen] Recognize more cases of zero initialization
>>>
>>> If a variable has an initializer, codegen tries to build its value. If
>>> the variable is large in size, building its value requires substantial
>>> resources. It causes strange behavior from user viewpoint: compilation
>>> of huge zero initialized arrays like:
>>>
>>> char data_1[2147483648u] = { 0 };
>>>
>>> consumes enormous amount of time and memory.
>>>
>>> With this change codegen tries to determine if variable initializer is
>>> equivalent to zero initializer. In this case variable value is not
>>> constructed.
>>>
>>> This change fixes PR18978.
>>>
>>> Differential Revision: https://reviews.llvm.org/D46241
>>>
>>> Removed:
>>> cfe/trunk/test/SemaCXX/large-array-init.cpp
>>> Modified:
>>> cfe/trunk/include/clang/AST/Expr.h
>>> cfe/trunk/lib/AST/ExprConstant.cpp
>>> cfe/trunk/lib/CodeGen/CGExprConstant.cpp
>>> cfe/trunk/test/CodeGen/const-init.c
>>> cfe/trunk/test/CodeGen/designated-initializers.c
>>> cfe/trunk/test/CodeGen/union-init2.c
>>> cfe/trunk/test/CodeGenCXX/cxx11-initializer-aggregate.cpp
>>> cfe/trunk/test/CodeGenCXX/cxx1z-initializer-aggregate.cpp
>>>
>>> Modified: cfe/trunk/include/clang/AST/Expr.h
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
>>> AST/Expr.h?rev=332847=332846=332847=diff
>>> 
>>> ==
>>> --- cfe/trunk/include/clang/AST/Expr.h (original)
>>> +++ cfe/trunk/include/clang/AST/Expr.h Mon May 21 09:09:54 2018
>>> @@ -537,6 +537,13 @@ public:
>>>bool isConstantInitializer(ASTContext , bool ForRef,
>>>   const Expr **Culprit = nullptr) const;
>>>
>>> +  enum SideEffectsKind {
>>> +SE_NoSideEffects,  ///< Strictly evaluate the expression.
>>> +SE_AllowUndefinedBehavior, ///< Allow UB that we can give a value,
>>> but not
>>> +   ///< arbitrary unmodeled side effects.
>>> +SE_AllowSideEffects///< Allow any unmodeled side effect.
>>> +  };
>>> +
>>>/// EvalStatus is a struct with detailed info about an evaluation in
>>> progress.
>>>struct EvalStatus {
>>>  /// Whether the evaluated expression has side effects.
>>> @@ -565,6 +572,11 @@ public:
>>>  bool hasSideEffects() const {
>>>return HasSideEffects;
>>>  }
>>> +
>>> +bool hasUnacceptableSideEffect(SideEffectsKind SEK) {
>>> +  return (SEK < SE_AllowSideEffects && HasSideEffects) ||
>>> + (SEK < SE_AllowUndefinedBehavior && HasUndefinedBehavior);
>>> +}
>>>};
>>>
>>>/// EvalResult is a struct with detailed info about an evaluated
>>> expression.
>>> @@ -591,13 +603,6 @@ public:
>>>/// side-effects.
>>>bool EvaluateAsBooleanCondition(bool , const ASTContext )
>>> const;
>>>
>>> -  enum SideEffectsKind {
>>> -SE_NoSideEffects,  ///< Strictly evaluate the expression.
>>> -SE_AllowUndefinedBehavior, ///< Allow UB that we can give a value,
>>> but not
>>> -   ///< arbitrary unmodeled side effects.
>>> -SE_AllowSideEffects///< Allow any unmodeled side effect.
>>> -  };
>>> -
>>>/// EvaluateAsInt - Return true if this is a constant which we can
>>> fold and
>>>/// convert to an integer, using any crazy technique that we want to.
>>>bool EvaluateAsInt(llvm::APSInt , const ASTContext ,
>>>
>>> Modified: cfe/trunk/lib/AST/ExprConstant.cpp
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprCo
>>> nstant.cpp?rev=332847=332846=332847=diff
>>> 
>>> ==
>>> --- cfe/trunk/lib/AST/ExprConstant.cpp (original)
>>> +++ cfe/trunk/lib/AST/ExprConstant.cpp Mon May 21 09:09:54 2018
>>> @@ -10312,12 +10312,6 @@ bool Expr::EvaluateAsBooleanCondition(bo
>>>   HandleConversionToBool(Scratch.Val, Result);
>>>  }
>>>
>>> -static bool hasUnacceptableSideEffect(Expr::EvalStatus ,
>>> -  Expr::SideEffectsKind SEK) {
>>> -  return (SEK < Expr::SE_AllowSideEffects && Result.HasSideEffects) ||
>>> - (SEK < Expr::SE_AllowUndefinedBehavior &&
>>> Result.HasUndefinedBehavior);
>>> -}
>>> -
>>>  bool Expr::EvaluateAsInt(APSInt , const ASTContext ,
>>>   SideEffectsKind AllowSideEffects) const {
>>>if (!getType()->isIntegralOrEnumerationType())
>>> @@ -10325,7 +10319,7 @@ bool 

r332886 - Revert r332847; it caused us to miscompile certain forms of reference initialization.

2018-05-21 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon May 21 13:36:58 2018
New Revision: 332886

URL: http://llvm.org/viewvc/llvm-project?rev=332886=rev
Log:
Revert r332847; it caused us to miscompile certain forms of reference 
initialization.

Added:
cfe/trunk/test/SemaCXX/large-array-init.cpp
  - copied unchanged from r332846, 
cfe/trunk/test/SemaCXX/large-array-init.cpp
Modified:
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/CodeGen/CGExprConstant.cpp
cfe/trunk/test/CodeGen/const-init.c
cfe/trunk/test/CodeGen/designated-initializers.c
cfe/trunk/test/CodeGen/union-init2.c
cfe/trunk/test/CodeGenCXX/cxx11-initializer-aggregate.cpp
cfe/trunk/test/CodeGenCXX/cxx1z-initializer-aggregate.cpp
cfe/trunk/test/CodeGenCXX/reference-init.cpp

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=332886=332885=332886=diff
==
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Mon May 21 13:36:58 2018
@@ -537,13 +537,6 @@ public:
   bool isConstantInitializer(ASTContext , bool ForRef,
  const Expr **Culprit = nullptr) const;
 
-  enum SideEffectsKind {
-SE_NoSideEffects,  ///< Strictly evaluate the expression.
-SE_AllowUndefinedBehavior, ///< Allow UB that we can give a value, but not
-   ///< arbitrary unmodeled side effects.
-SE_AllowSideEffects///< Allow any unmodeled side effect.
-  };
-
   /// EvalStatus is a struct with detailed info about an evaluation in 
progress.
   struct EvalStatus {
 /// Whether the evaluated expression has side effects.
@@ -572,11 +565,6 @@ public:
 bool hasSideEffects() const {
   return HasSideEffects;
 }
-
-bool hasUnacceptableSideEffect(SideEffectsKind SEK) {
-  return (SEK < SE_AllowSideEffects && HasSideEffects) ||
- (SEK < SE_AllowUndefinedBehavior && HasUndefinedBehavior);
-}
   };
 
   /// EvalResult is a struct with detailed info about an evaluated expression.
@@ -603,6 +591,13 @@ public:
   /// side-effects.
   bool EvaluateAsBooleanCondition(bool , const ASTContext ) const;
 
+  enum SideEffectsKind {
+SE_NoSideEffects,  ///< Strictly evaluate the expression.
+SE_AllowUndefinedBehavior, ///< Allow UB that we can give a value, but not
+   ///< arbitrary unmodeled side effects.
+SE_AllowSideEffects///< Allow any unmodeled side effect.
+  };
+
   /// EvaluateAsInt - Return true if this is a constant which we can fold and
   /// convert to an integer, using any crazy technique that we want to.
   bool EvaluateAsInt(llvm::APSInt , const ASTContext ,

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=332886=332885=332886=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Mon May 21 13:36:58 2018
@@ -10312,6 +10312,12 @@ bool Expr::EvaluateAsBooleanCondition(bo
  HandleConversionToBool(Scratch.Val, Result);
 }
 
+static bool hasUnacceptableSideEffect(Expr::EvalStatus ,
+  Expr::SideEffectsKind SEK) {
+  return (SEK < Expr::SE_AllowSideEffects && Result.HasSideEffects) ||
+ (SEK < Expr::SE_AllowUndefinedBehavior && 
Result.HasUndefinedBehavior);
+}
+
 bool Expr::EvaluateAsInt(APSInt , const ASTContext ,
  SideEffectsKind AllowSideEffects) const {
   if (!getType()->isIntegralOrEnumerationType())
@@ -10319,7 +10325,7 @@ bool Expr::EvaluateAsInt(APSInt ,
 
   EvalResult ExprResult;
   if (!EvaluateAsRValue(ExprResult, Ctx) || !ExprResult.Val.isInt() ||
-  ExprResult.hasUnacceptableSideEffect(AllowSideEffects))
+  hasUnacceptableSideEffect(ExprResult, AllowSideEffects))
 return false;
 
   Result = ExprResult.Val.getInt();
@@ -10333,7 +10339,7 @@ bool Expr::EvaluateAsFloat(APFloat 
 
   EvalResult ExprResult;
   if (!EvaluateAsRValue(ExprResult, Ctx) || !ExprResult.Val.isFloat() ||
-  ExprResult.hasUnacceptableSideEffect(AllowSideEffects))
+  hasUnacceptableSideEffect(ExprResult, AllowSideEffects))
 return false;
 
   Result = ExprResult.Val.getFloat();
@@ -10411,7 +10417,7 @@ bool Expr::EvaluateAsInitializer(APValue
 bool Expr::isEvaluatable(const ASTContext , SideEffectsKind SEK) const {
   EvalResult Result;
   return EvaluateAsRValue(Result, Ctx) &&
- !Result.hasUnacceptableSideEffect(SEK);
+ !hasUnacceptableSideEffect(Result, SEK);
 }
 
 APSInt Expr::EvaluateKnownConstInt(const ASTContext ,

Modified: cfe/trunk/lib/CodeGen/CGExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprConstant.cpp?rev=332886=332885=332886=diff

[PATCH] D47093: CodeGen, Driver: Start using direct split dwarf emission in clang.

2018-05-21 Thread Peter Collingbourne via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC332885: CodeGen, Driver: Start using direct split dwarf 
emission in clang. (authored by pcc, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D47093?vs=147609=147858#toc

Repository:
  rC Clang

https://reviews.llvm.org/D47093

Files:
  include/clang/Driver/CC1Options.td
  lib/CodeGen/BackendUtil.cpp
  lib/Driver/ToolChains/Clang.cpp
  test/CodeGen/split-debug-filename.c
  test/Driver/split-debug.c
  test/Driver/split-debug.s
  test/Misc/cc1as-split-dwarf.s
  tools/driver/cc1as_main.cpp

Index: test/CodeGen/split-debug-filename.c
===
--- test/CodeGen/split-debug-filename.c
+++ test/CodeGen/split-debug-filename.c
@@ -1,5 +1,8 @@
 // RUN: %clang_cc1 -debug-info-kind=limited -split-dwarf-file foo.dwo -S -emit-llvm -o - %s | FileCheck %s
 // RUN: %clang_cc1 -debug-info-kind=limited -enable-split-dwarf -split-dwarf-file foo.dwo -S -emit-llvm -o - %s | FileCheck --check-prefix=VANILLA %s
+// RUN: %clang_cc1 -debug-info-kind=limited -enable-split-dwarf -split-dwarf-file %t.dwo -emit-obj -o - %s | llvm-objdump -section-headers - | FileCheck --check-prefix=O %s
+// RUN: llvm-objdump -section-headers %t.dwo | FileCheck --check-prefix=DWO %s
+
 int main (void) {
   return 0;
 }
@@ -10,3 +13,6 @@
 // Testing to ensure that the dwo name is not output into the compile unit if
 // it's for vanilla split-dwarf rather than split-dwarf for implicit modules.
 // VANILLA-NOT: splitDebugFilename
+
+// O-NOT: .dwo
+// DWO: .dwo
Index: test/Driver/split-debug.s
===
--- test/Driver/split-debug.s
+++ test/Driver/split-debug.s
@@ -3,8 +3,7 @@
 // RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf -c -### %s 2> %t
 // RUN: FileCheck -check-prefix=CHECK-ACTIONS < %t %s
 //
-// CHECK-ACTIONS: objcopy{{.*}}--extract-dwo{{.*}}"split-debug.dwo"
-// CHECK-ACTIONS: objcopy{{.*}}--strip-dwo{{.*}}"split-debug.o"
+// CHECK-ACTIONS: "-split-dwarf-file" "split-debug.dwo"
 
 
 // RUN: %clang -target x86_64-macosx -gsplit-dwarf -c -### %s 2> %t
Index: test/Driver/split-debug.c
===
--- test/Driver/split-debug.c
+++ test/Driver/split-debug.c
@@ -3,8 +3,7 @@
 // RUN: %clang -target x86_64-unknown-linux-gnu -gsplit-dwarf -c -### %s 2> %t
 // RUN: FileCheck -check-prefix=CHECK-ACTIONS < %t %s
 //
-// CHECK-ACTIONS: objcopy{{.*}}--extract-dwo{{.*}}"split-debug.dwo"
-// CHECK-ACTIONS: objcopy{{.*}}--strip-dwo{{.*}}"split-debug.o"
+// CHECK-ACTIONS: "-split-dwarf-file" "split-debug.dwo"
 
 
 // RUN: %clang -target x86_64-macosx -gsplit-dwarf -c -### %s 2> %t
Index: test/Misc/cc1as-split-dwarf.s
===
--- test/Misc/cc1as-split-dwarf.s
+++ test/Misc/cc1as-split-dwarf.s
@@ -0,0 +1,25 @@
+// RUN: %clang -cc1as -triple x86_64-pc-linux-gnu %s -filetype obj -o %t1 -split-dwarf-file %t2
+// RUN: llvm-objdump -s %t1 | FileCheck --check-prefix=O %s
+// RUN: llvm-objdump -s %t2 | FileCheck --check-prefix=DWO %s
+
+// O-NOT: Contents of section
+// O: Contents of section .strtab:
+// O-NOT: Contents of section
+// O: Contents of section .text:
+// O-NEXT:  c3
+// O-NEXT: Contents of section .symtab:
+// O-NOT: Contents of section
+.globl main
+main:
+.Ltmp1:
+ret
+.Ltmp2:
+
+// DWO-NOT: Contents of section
+// DWO: Contents of section .strtab:
+// DWO-NOT: Contents of section
+// DWO: Contents of section .foo.dwo:
+// DWO-NEXT:  0100
+// DWO-NOT: Contents of section
+.section .foo.dwo
+.long .Ltmp2-.Ltmp1
Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -104,7 +104,17 @@
   ///
   /// \return True on success.
   bool AddEmitPasses(legacy::PassManager , BackendAction Action,
- raw_pwrite_stream );
+ raw_pwrite_stream , raw_pwrite_stream *DwoOS);
+
+  std::unique_ptr openOutputFile(StringRef Path) {
+std::error_code EC;
+auto F = make_unique(Path, EC, llvm::sys::fs::F_None);
+if (EC) {
+  Diags.Report(diag::err_fe_unable_to_open_output) << Path << EC.message();
+  F.reset();
+}
+return F;
+  }
 
 public:
   EmitAssemblyHelper(DiagnosticsEngine &_Diags,
@@ -701,7 +711,8 @@
 
 bool EmitAssemblyHelper::AddEmitPasses(legacy::PassManager ,
BackendAction Action,
-   raw_pwrite_stream ) {
+   raw_pwrite_stream ,
+   raw_pwrite_stream *DwoOS) {
   // Add LibraryInfo.
   llvm::Triple TargetTriple(TheModule->getTargetTriple());
   std::unique_ptr TLII(
@@ -718,7 +729,7 @@
   if (CodeGenOpts.OptimizationLevel > 0)
 CodeGenPasses.add(createObjCARCContractPass());
 

r332885 - CodeGen, Driver: Start using direct split dwarf emission in clang.

2018-05-21 Thread Peter Collingbourne via cfe-commits
Author: pcc
Date: Mon May 21 13:31:59 2018
New Revision: 332885

URL: http://llvm.org/viewvc/llvm-project?rev=332885=rev
Log:
CodeGen, Driver: Start using direct split dwarf emission in clang.

Fixes PR37466.

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

Added:
cfe/trunk/test/Misc/cc1as-split-dwarf.s
Modified:
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/CodeGen/split-debug-filename.c
cfe/trunk/test/Driver/split-debug.c
cfe/trunk/test/Driver/split-debug.s
cfe/trunk/tools/driver/cc1as_main.cpp

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=332885=332884=332885=diff
==
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Mon May 21 13:31:59 2018
@@ -619,6 +619,8 @@ def version : Flag<["-"], "version">,
   HelpText<"Print the compiler version">;
 def main_file_name : Separate<["-"], "main-file-name">,
   HelpText<"Main file name to use for debug info">;
+def split_dwarf_file : Separate<["-"], "split-dwarf-file">,
+  HelpText<"File name to use for split dwarf debug info output">;
 
 }
 
@@ -628,8 +630,6 @@ def fexternc_nounwind : Flag<["-"], "fex
   HelpText<"Assume all functions with C linkage do not unwind">;
 def enable_split_dwarf : Flag<["-"], "enable-split-dwarf">,
   HelpText<"Use split dwarf/Fission">;
-def split_dwarf_file : Separate<["-"], "split-dwarf-file">,
-  HelpText<"File name to use for split dwarf debug info output">;
 def fno_wchar : Flag<["-"], "fno-wchar">,
   HelpText<"Disable C++ builtin type wchar_t">;
 def fconstant_string_class : Separate<["-"], "fconstant-string-class">,

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=332885=332884=332885=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Mon May 21 13:31:59 2018
@@ -104,7 +104,17 @@ class EmitAssemblyHelper {
   ///
   /// \return True on success.
   bool AddEmitPasses(legacy::PassManager , BackendAction Action,
- raw_pwrite_stream );
+ raw_pwrite_stream , raw_pwrite_stream *DwoOS);
+
+  std::unique_ptr openOutputFile(StringRef Path) {
+std::error_code EC;
+auto F = make_unique(Path, EC, 
llvm::sys::fs::F_None);
+if (EC) {
+  Diags.Report(diag::err_fe_unable_to_open_output) << Path << EC.message();
+  F.reset();
+}
+return F;
+  }
 
 public:
   EmitAssemblyHelper(DiagnosticsEngine &_Diags,
@@ -701,7 +711,8 @@ void EmitAssemblyHelper::CreateTargetMac
 
 bool EmitAssemblyHelper::AddEmitPasses(legacy::PassManager ,
BackendAction Action,
-   raw_pwrite_stream ) {
+   raw_pwrite_stream ,
+   raw_pwrite_stream *DwoOS) {
   // Add LibraryInfo.
   llvm::Triple TargetTriple(TheModule->getTargetTriple());
   std::unique_ptr TLII(
@@ -718,7 +729,7 @@ bool EmitAssemblyHelper::AddEmitPasses(l
   if (CodeGenOpts.OptimizationLevel > 0)
 CodeGenPasses.add(createObjCARCContractPass());
 
-  if (TM->addPassesToEmitFile(CodeGenPasses, OS, nullptr, CGFT,
+  if (TM->addPassesToEmitFile(CodeGenPasses, OS, DwoOS, CGFT,
   /*DisableVerify=*/!CodeGenOpts.VerifyModule)) {
 Diags.Report(diag::err_fe_unable_to_interface_with_target);
 return false;
@@ -757,7 +768,7 @@ void EmitAssemblyHelper::EmitAssembly(Ba
   CodeGenPasses.add(
   createTargetTransformInfoWrapperPass(getTargetIRAnalysis()));
 
-  std::unique_ptr ThinLinkOS;
+  std::unique_ptr ThinLinkOS, DwoOS;
 
   switch (Action) {
   case Backend_EmitNothing:
@@ -766,18 +777,12 @@ void EmitAssemblyHelper::EmitAssembly(Ba
   case Backend_EmitBC:
 if (CodeGenOpts.EmitSummaryIndex) {
   if (!CodeGenOpts.ThinLinkBitcodeFile.empty()) {
-std::error_code EC;
-ThinLinkOS.reset(new llvm::raw_fd_ostream(
-CodeGenOpts.ThinLinkBitcodeFile, EC,
-llvm::sys::fs::F_None));
-if (EC) {
-  Diags.Report(diag::err_fe_unable_to_open_output) << 
CodeGenOpts.ThinLinkBitcodeFile
-   << EC.message();
+ThinLinkOS = openOutputFile(CodeGenOpts.ThinLinkBitcodeFile);
+if (!ThinLinkOS)
   return;
-}
   }
-  PerModulePasses.add(
-  createWriteThinLTOBitcodePass(*OS, ThinLinkOS.get()));
+  PerModulePasses.add(createWriteThinLTOBitcodePass(
+  *OS, ThinLinkOS ? >os() : nullptr));
 }
 else
   PerModulePasses.add(
@@ -790,7 

Re: r332847 - [CodeGen] Recognize more cases of zero initialization

2018-05-21 Thread Richard Smith via cfe-commits
On 21 May 2018 at 13:22, Richard Smith  wrote:

> On 21 May 2018 at 09:09, Serge Pavlov via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: sepavloff
>> Date: Mon May 21 09:09:54 2018
>> New Revision: 332847
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=332847=rev
>> Log:
>> [CodeGen] Recognize more cases of zero initialization
>>
>> If a variable has an initializer, codegen tries to build its value. If
>> the variable is large in size, building its value requires substantial
>> resources. It causes strange behavior from user viewpoint: compilation
>> of huge zero initialized arrays like:
>>
>> char data_1[2147483648u] = { 0 };
>>
>> consumes enormous amount of time and memory.
>>
>> With this change codegen tries to determine if variable initializer is
>> equivalent to zero initializer. In this case variable value is not
>> constructed.
>>
>> This change fixes PR18978.
>>
>> Differential Revision: https://reviews.llvm.org/D46241
>>
>> Removed:
>> cfe/trunk/test/SemaCXX/large-array-init.cpp
>> Modified:
>> cfe/trunk/include/clang/AST/Expr.h
>> cfe/trunk/lib/AST/ExprConstant.cpp
>> cfe/trunk/lib/CodeGen/CGExprConstant.cpp
>> cfe/trunk/test/CodeGen/const-init.c
>> cfe/trunk/test/CodeGen/designated-initializers.c
>> cfe/trunk/test/CodeGen/union-init2.c
>> cfe/trunk/test/CodeGenCXX/cxx11-initializer-aggregate.cpp
>> cfe/trunk/test/CodeGenCXX/cxx1z-initializer-aggregate.cpp
>>
>> Modified: cfe/trunk/include/clang/AST/Expr.h
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
>> AST/Expr.h?rev=332847=332846=332847=diff
>> 
>> ==
>> --- cfe/trunk/include/clang/AST/Expr.h (original)
>> +++ cfe/trunk/include/clang/AST/Expr.h Mon May 21 09:09:54 2018
>> @@ -537,6 +537,13 @@ public:
>>bool isConstantInitializer(ASTContext , bool ForRef,
>>   const Expr **Culprit = nullptr) const;
>>
>> +  enum SideEffectsKind {
>> +SE_NoSideEffects,  ///< Strictly evaluate the expression.
>> +SE_AllowUndefinedBehavior, ///< Allow UB that we can give a value,
>> but not
>> +   ///< arbitrary unmodeled side effects.
>> +SE_AllowSideEffects///< Allow any unmodeled side effect.
>> +  };
>> +
>>/// EvalStatus is a struct with detailed info about an evaluation in
>> progress.
>>struct EvalStatus {
>>  /// Whether the evaluated expression has side effects.
>> @@ -565,6 +572,11 @@ public:
>>  bool hasSideEffects() const {
>>return HasSideEffects;
>>  }
>> +
>> +bool hasUnacceptableSideEffect(SideEffectsKind SEK) {
>> +  return (SEK < SE_AllowSideEffects && HasSideEffects) ||
>> + (SEK < SE_AllowUndefinedBehavior && HasUndefinedBehavior);
>> +}
>>};
>>
>>/// EvalResult is a struct with detailed info about an evaluated
>> expression.
>> @@ -591,13 +603,6 @@ public:
>>/// side-effects.
>>bool EvaluateAsBooleanCondition(bool , const ASTContext )
>> const;
>>
>> -  enum SideEffectsKind {
>> -SE_NoSideEffects,  ///< Strictly evaluate the expression.
>> -SE_AllowUndefinedBehavior, ///< Allow UB that we can give a value,
>> but not
>> -   ///< arbitrary unmodeled side effects.
>> -SE_AllowSideEffects///< Allow any unmodeled side effect.
>> -  };
>> -
>>/// EvaluateAsInt - Return true if this is a constant which we can
>> fold and
>>/// convert to an integer, using any crazy technique that we want to.
>>bool EvaluateAsInt(llvm::APSInt , const ASTContext ,
>>
>> Modified: cfe/trunk/lib/AST/ExprConstant.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprCo
>> nstant.cpp?rev=332847=332846=332847=diff
>> 
>> ==
>> --- cfe/trunk/lib/AST/ExprConstant.cpp (original)
>> +++ cfe/trunk/lib/AST/ExprConstant.cpp Mon May 21 09:09:54 2018
>> @@ -10312,12 +10312,6 @@ bool Expr::EvaluateAsBooleanCondition(bo
>>   HandleConversionToBool(Scratch.Val, Result);
>>  }
>>
>> -static bool hasUnacceptableSideEffect(Expr::EvalStatus ,
>> -  Expr::SideEffectsKind SEK) {
>> -  return (SEK < Expr::SE_AllowSideEffects && Result.HasSideEffects) ||
>> - (SEK < Expr::SE_AllowUndefinedBehavior &&
>> Result.HasUndefinedBehavior);
>> -}
>> -
>>  bool Expr::EvaluateAsInt(APSInt , const ASTContext ,
>>   SideEffectsKind AllowSideEffects) const {
>>if (!getType()->isIntegralOrEnumerationType())
>> @@ -10325,7 +10319,7 @@ bool Expr::EvaluateAsInt(APSInt ,
>>
>>EvalResult ExprResult;
>>if (!EvaluateAsRValue(ExprResult, Ctx) || !ExprResult.Val.isInt() ||
>> -  hasUnacceptableSideEffect(ExprResult, AllowSideEffects))
>> +  ExprResult.hasUnacceptableSideEffect(AllowSideEffects))
>>  return false;
>>
>>

[PATCH] D47157: Warning for framework headers using double quote includes

2018-05-21 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.

Depends on https://reviews.llvm.org/D46485


Repository:
  rC Clang

https://reviews.llvm.org/D47157



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


[PATCH] D46863: [X86] Use __builtin_convertvector to implement some of the packed integer to packed float conversion intrinsics.

2018-05-21 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC332882: [X86] Use __builtin_convertvector to implement some 
of the packed integer to… (authored by ctopper, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D46863?vs=146750=147853#toc

Repository:
  rC Clang

https://reviews.llvm.org/D46863

Files:
  include/clang/Basic/BuiltinsX86.def
  lib/Headers/avx512dqintrin.h
  lib/Headers/avx512fintrin.h
  lib/Headers/avx512vldqintrin.h
  lib/Headers/avx512vlintrin.h
  lib/Headers/avxintrin.h
  lib/Headers/emmintrin.h
  test/CodeGen/avx-builtins.c
  test/CodeGen/avx512dq-builtins.c
  test/CodeGen/avx512f-builtins.c
  test/CodeGen/avx512vl-builtins.c
  test/CodeGen/avx512vldq-builtins.c
  test/CodeGen/builtins-x86.c
  test/CodeGen/sse2-builtins.c

Index: include/clang/Basic/BuiltinsX86.def
===
--- include/clang/Basic/BuiltinsX86.def
+++ include/clang/Basic/BuiltinsX86.def
@@ -320,7 +320,6 @@
 TARGET_BUILTIN(__builtin_ia32_psadbw128, "V2LLiV16cV16c", "nc", "sse2")
 TARGET_BUILTIN(__builtin_ia32_sqrtpd, "V2dV2d", "nc", "sse2")
 TARGET_BUILTIN(__builtin_ia32_sqrtsd, "V2dV2d", "nc", "sse2")
-TARGET_BUILTIN(__builtin_ia32_cvtdq2ps, "V4fV4i", "nc", "sse2")
 TARGET_BUILTIN(__builtin_ia32_cvtpd2dq, "V2LLiV2d", "nc", "sse2")
 TARGET_BUILTIN(__builtin_ia32_cvtpd2ps, "V4fV2d", "nc", "sse2")
 TARGET_BUILTIN(__builtin_ia32_cvttpd2dq, "V4iV2d", "nc", "sse2")
@@ -1200,8 +1199,6 @@
 TARGET_BUILTIN(__builtin_ia32_cvttpd2udq256_mask, "V4iV4dV4iUc", "nc", "avx512vl")
 TARGET_BUILTIN(__builtin_ia32_cvttps2udq128_mask, "V4iV4fV4iUc", "nc", "avx512vl")
 TARGET_BUILTIN(__builtin_ia32_cvttps2udq256_mask, "V8iV8fV8iUc", "nc", "avx512vl")
-TARGET_BUILTIN(__builtin_ia32_cvtudq2ps128_mask, "V4fV4iV4fUc", "nc", "avx512vl")
-TARGET_BUILTIN(__builtin_ia32_cvtudq2ps256_mask, "V8fV8iV8fUc", "nc", "avx512vl")
 TARGET_BUILTIN(__builtin_ia32_expanddf128_mask, "V2dV2dV2dUc", "nc", "avx512vl")
 TARGET_BUILTIN(__builtin_ia32_expanddf256_mask, "V4dV4dV4dUc", "nc", "avx512vl")
 TARGET_BUILTIN(__builtin_ia32_expanddi128_mask, "V2LLiV2LLiV2LLiUc", "nc", "avx512vl")
@@ -1363,8 +1360,6 @@
 TARGET_BUILTIN(__builtin_ia32_cvtps2qq256_mask, "V4LLiV4fV4LLiUc", "nc", "avx512vl,avx512dq")
 TARGET_BUILTIN(__builtin_ia32_cvtps2uqq128_mask, "V2LLiV4fV2LLiUc", "nc", "avx512vl,avx512dq")
 TARGET_BUILTIN(__builtin_ia32_cvtps2uqq256_mask, "V4LLiV4fV4LLiUc", "nc", "avx512vl,avx512dq")
-TARGET_BUILTIN(__builtin_ia32_cvtqq2pd128_mask, "V2dV2LLiV2dUc", "nc", "avx512vl,avx512dq")
-TARGET_BUILTIN(__builtin_ia32_cvtqq2pd256_mask, "V4dV4LLiV4dUc", "nc", "avx512vl,avx512dq")
 TARGET_BUILTIN(__builtin_ia32_cvtqq2ps128_mask, "V4fV2LLiV4fUc", "nc", "avx512vl,avx512dq")
 TARGET_BUILTIN(__builtin_ia32_cvtqq2ps256_mask, "V4fV4LLiV4fUc", "nc", "avx512vl,avx512dq")
 TARGET_BUILTIN(__builtin_ia32_cvttpd2qq128_mask, "V2LLiV2dV2LLiUc", "nc", "avx512vl,avx512dq")
@@ -1375,8 +1370,6 @@
 TARGET_BUILTIN(__builtin_ia32_cvttps2qq256_mask, "V4LLiV4fV4LLiUc", "nc", "avx512vl,avx512dq")
 TARGET_BUILTIN(__builtin_ia32_cvttps2uqq128_mask, "V2LLiV4fV2LLiUc", "nc", "avx512vl,avx512dq")
 TARGET_BUILTIN(__builtin_ia32_cvttps2uqq256_mask, "V4LLiV4fV4LLiUc", "nc", "avx512vl,avx512dq")
-TARGET_BUILTIN(__builtin_ia32_cvtuqq2pd128_mask, "V2dV2LLiV2dUc", "nc", "avx512vl,avx512dq")
-TARGET_BUILTIN(__builtin_ia32_cvtuqq2pd256_mask, "V4dV4LLiV4dUc", "nc", "avx512vl,avx512dq")
 TARGET_BUILTIN(__builtin_ia32_cvtuqq2ps128_mask, "V4fV2LLiV4fUc", "nc", "avx512vl,avx512dq")
 TARGET_BUILTIN(__builtin_ia32_cvtuqq2ps256_mask, "V4fV4LLiV4fUc", "nc", "avx512vl,avx512dq")
 TARGET_BUILTIN(__builtin_ia32_rangepd128_mask, "V2dV2dV2dIiV2dUc", "nc", "avx512vl,avx512dq")
Index: test/CodeGen/avx-builtins.c
===
--- test/CodeGen/avx-builtins.c
+++ test/CodeGen/avx-builtins.c
@@ -256,7 +256,7 @@
 
 __m256 test_mm256_cvtepi32_ps(__m256i A) {
   // CHECK-LABEL: test_mm256_cvtepi32_ps
-  // CHECK: call <8 x float> @llvm.x86.avx.cvtdq2.ps.256(<8 x i32> %{{.*}})
+  // CHECK: sitofp <8 x i32> %{{.*}} to <8 x float>
   return _mm256_cvtepi32_ps(A);
 }
 
Index: test/CodeGen/builtins-x86.c
===
--- test/CodeGen/builtins-x86.c
+++ test/CodeGen/builtins-x86.c
@@ -338,7 +338,6 @@
   tmp_V2LLi = __builtin_ia32_psadbw128(tmp_V16c, tmp_V16c);
   tmp_V2d = __builtin_ia32_sqrtpd(tmp_V2d);
   tmp_V2d = __builtin_ia32_sqrtsd(tmp_V2d);
-  tmp_V4f = __builtin_ia32_cvtdq2ps(tmp_V4i);
   tmp_V2LLi = __builtin_ia32_cvtpd2dq(tmp_V2d);
   tmp_V2i = __builtin_ia32_cvtpd2pi(tmp_V2d);
   tmp_V4f = __builtin_ia32_cvtpd2ps(tmp_V2d);
Index: test/CodeGen/avx512vldq-builtins.c
===
--- test/CodeGen/avx512vldq-builtins.c
+++ test/CodeGen/avx512vldq-builtins.c
@@ -421,37 +421,41 @@
 
 __m128d test_mm_cvtepi64_pd(__m128i __A) {
   // CHECK-LABEL: 

r332882 - [X86] Use __builtin_convertvector to implement some of the packed integer to packed float conversion intrinsics.

2018-05-21 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Mon May 21 13:19:17 2018
New Revision: 332882

URL: http://llvm.org/viewvc/llvm-project?rev=332882=rev
Log:
[X86] Use __builtin_convertvector to implement some of the packed integer to 
packed float conversion intrinsics.

I believe this is safe assuming default default FP environment. The conversion 
might be inexact, but it can never overflow the FP type so this shouldn't be 
undefined behavior for the uitofp/sitofp instructions.

We already do something similar for scalar conversions.

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

Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/Headers/avx512dqintrin.h
cfe/trunk/lib/Headers/avx512fintrin.h
cfe/trunk/lib/Headers/avx512vldqintrin.h
cfe/trunk/lib/Headers/avx512vlintrin.h
cfe/trunk/lib/Headers/avxintrin.h
cfe/trunk/lib/Headers/emmintrin.h
cfe/trunk/test/CodeGen/avx-builtins.c
cfe/trunk/test/CodeGen/avx512dq-builtins.c
cfe/trunk/test/CodeGen/avx512f-builtins.c
cfe/trunk/test/CodeGen/avx512vl-builtins.c
cfe/trunk/test/CodeGen/avx512vldq-builtins.c
cfe/trunk/test/CodeGen/builtins-x86.c
cfe/trunk/test/CodeGen/sse2-builtins.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=332882=332881=332882=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Mon May 21 13:19:17 2018
@@ -320,7 +320,6 @@ TARGET_BUILTIN(__builtin_ia32_movnti, "v
 TARGET_BUILTIN(__builtin_ia32_psadbw128, "V2LLiV16cV16c", "nc", "sse2")
 TARGET_BUILTIN(__builtin_ia32_sqrtpd, "V2dV2d", "nc", "sse2")
 TARGET_BUILTIN(__builtin_ia32_sqrtsd, "V2dV2d", "nc", "sse2")
-TARGET_BUILTIN(__builtin_ia32_cvtdq2ps, "V4fV4i", "nc", "sse2")
 TARGET_BUILTIN(__builtin_ia32_cvtpd2dq, "V2LLiV2d", "nc", "sse2")
 TARGET_BUILTIN(__builtin_ia32_cvtpd2ps, "V4fV2d", "nc", "sse2")
 TARGET_BUILTIN(__builtin_ia32_cvttpd2dq, "V4iV2d", "nc", "sse2")
@@ -1200,8 +1199,6 @@ TARGET_BUILTIN(__builtin_ia32_cvttpd2udq
 TARGET_BUILTIN(__builtin_ia32_cvttpd2udq256_mask, "V4iV4dV4iUc", "nc", 
"avx512vl")
 TARGET_BUILTIN(__builtin_ia32_cvttps2udq128_mask, "V4iV4fV4iUc", "nc", 
"avx512vl")
 TARGET_BUILTIN(__builtin_ia32_cvttps2udq256_mask, "V8iV8fV8iUc", "nc", 
"avx512vl")
-TARGET_BUILTIN(__builtin_ia32_cvtudq2ps128_mask, "V4fV4iV4fUc", "nc", 
"avx512vl")
-TARGET_BUILTIN(__builtin_ia32_cvtudq2ps256_mask, "V8fV8iV8fUc", "nc", 
"avx512vl")
 TARGET_BUILTIN(__builtin_ia32_expanddf128_mask, "V2dV2dV2dUc", "nc", 
"avx512vl")
 TARGET_BUILTIN(__builtin_ia32_expanddf256_mask, "V4dV4dV4dUc", "nc", 
"avx512vl")
 TARGET_BUILTIN(__builtin_ia32_expanddi128_mask, "V2LLiV2LLiV2LLiUc", "nc", 
"avx512vl")
@@ -1363,8 +1360,6 @@ TARGET_BUILTIN(__builtin_ia32_cvtps2qq12
 TARGET_BUILTIN(__builtin_ia32_cvtps2qq256_mask, "V4LLiV4fV4LLiUc", "nc", 
"avx512vl,avx512dq")
 TARGET_BUILTIN(__builtin_ia32_cvtps2uqq128_mask, "V2LLiV4fV2LLiUc", "nc", 
"avx512vl,avx512dq")
 TARGET_BUILTIN(__builtin_ia32_cvtps2uqq256_mask, "V4LLiV4fV4LLiUc", "nc", 
"avx512vl,avx512dq")
-TARGET_BUILTIN(__builtin_ia32_cvtqq2pd128_mask, "V2dV2LLiV2dUc", "nc", 
"avx512vl,avx512dq")
-TARGET_BUILTIN(__builtin_ia32_cvtqq2pd256_mask, "V4dV4LLiV4dUc", "nc", 
"avx512vl,avx512dq")
 TARGET_BUILTIN(__builtin_ia32_cvtqq2ps128_mask, "V4fV2LLiV4fUc", "nc", 
"avx512vl,avx512dq")
 TARGET_BUILTIN(__builtin_ia32_cvtqq2ps256_mask, "V4fV4LLiV4fUc", "nc", 
"avx512vl,avx512dq")
 TARGET_BUILTIN(__builtin_ia32_cvttpd2qq128_mask, "V2LLiV2dV2LLiUc", "nc", 
"avx512vl,avx512dq")
@@ -1375,8 +1370,6 @@ TARGET_BUILTIN(__builtin_ia32_cvttps2qq1
 TARGET_BUILTIN(__builtin_ia32_cvttps2qq256_mask, "V4LLiV4fV4LLiUc", "nc", 
"avx512vl,avx512dq")
 TARGET_BUILTIN(__builtin_ia32_cvttps2uqq128_mask, "V2LLiV4fV2LLiUc", "nc", 
"avx512vl,avx512dq")
 TARGET_BUILTIN(__builtin_ia32_cvttps2uqq256_mask, "V4LLiV4fV4LLiUc", "nc", 
"avx512vl,avx512dq")
-TARGET_BUILTIN(__builtin_ia32_cvtuqq2pd128_mask, "V2dV2LLiV2dUc", "nc", 
"avx512vl,avx512dq")
-TARGET_BUILTIN(__builtin_ia32_cvtuqq2pd256_mask, "V4dV4LLiV4dUc", "nc", 
"avx512vl,avx512dq")
 TARGET_BUILTIN(__builtin_ia32_cvtuqq2ps128_mask, "V4fV2LLiV4fUc", "nc", 
"avx512vl,avx512dq")
 TARGET_BUILTIN(__builtin_ia32_cvtuqq2ps256_mask, "V4fV4LLiV4fUc", "nc", 
"avx512vl,avx512dq")
 TARGET_BUILTIN(__builtin_ia32_rangepd128_mask, "V2dV2dV2dIiV2dUc", "nc", 
"avx512vl,avx512dq")

Modified: cfe/trunk/lib/Headers/avx512dqintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512dqintrin.h?rev=332882=332881=332882=diff
==
--- cfe/trunk/lib/Headers/avx512dqintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512dqintrin.h Mon May 21 13:19:17 2018
@@ -361,26 +361,21 @@ _mm512_maskz_cvtps_epu64 (__mmask8 __U,
 
 static __inline__ __m512d __DEFAULT_FN_ATTRS
 

Re: r332847 - [CodeGen] Recognize more cases of zero initialization

2018-05-21 Thread Richard Smith via cfe-commits
On 21 May 2018 at 09:09, Serge Pavlov via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: sepavloff
> Date: Mon May 21 09:09:54 2018
> New Revision: 332847
>
> URL: http://llvm.org/viewvc/llvm-project?rev=332847=rev
> Log:
> [CodeGen] Recognize more cases of zero initialization
>
> If a variable has an initializer, codegen tries to build its value. If
> the variable is large in size, building its value requires substantial
> resources. It causes strange behavior from user viewpoint: compilation
> of huge zero initialized arrays like:
>
> char data_1[2147483648u] = { 0 };
>
> consumes enormous amount of time and memory.
>
> With this change codegen tries to determine if variable initializer is
> equivalent to zero initializer. In this case variable value is not
> constructed.
>
> This change fixes PR18978.
>
> Differential Revision: https://reviews.llvm.org/D46241
>
> Removed:
> cfe/trunk/test/SemaCXX/large-array-init.cpp
> Modified:
> cfe/trunk/include/clang/AST/Expr.h
> cfe/trunk/lib/AST/ExprConstant.cpp
> cfe/trunk/lib/CodeGen/CGExprConstant.cpp
> cfe/trunk/test/CodeGen/const-init.c
> cfe/trunk/test/CodeGen/designated-initializers.c
> cfe/trunk/test/CodeGen/union-init2.c
> cfe/trunk/test/CodeGenCXX/cxx11-initializer-aggregate.cpp
> cfe/trunk/test/CodeGenCXX/cxx1z-initializer-aggregate.cpp
>
> Modified: cfe/trunk/include/clang/AST/Expr.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/AST/Expr.h?rev=332847=332846=332847=diff
> 
> ==
> --- cfe/trunk/include/clang/AST/Expr.h (original)
> +++ cfe/trunk/include/clang/AST/Expr.h Mon May 21 09:09:54 2018
> @@ -537,6 +537,13 @@ public:
>bool isConstantInitializer(ASTContext , bool ForRef,
>   const Expr **Culprit = nullptr) const;
>
> +  enum SideEffectsKind {
> +SE_NoSideEffects,  ///< Strictly evaluate the expression.
> +SE_AllowUndefinedBehavior, ///< Allow UB that we can give a value,
> but not
> +   ///< arbitrary unmodeled side effects.
> +SE_AllowSideEffects///< Allow any unmodeled side effect.
> +  };
> +
>/// EvalStatus is a struct with detailed info about an evaluation in
> progress.
>struct EvalStatus {
>  /// Whether the evaluated expression has side effects.
> @@ -565,6 +572,11 @@ public:
>  bool hasSideEffects() const {
>return HasSideEffects;
>  }
> +
> +bool hasUnacceptableSideEffect(SideEffectsKind SEK) {
> +  return (SEK < SE_AllowSideEffects && HasSideEffects) ||
> + (SEK < SE_AllowUndefinedBehavior && HasUndefinedBehavior);
> +}
>};
>
>/// EvalResult is a struct with detailed info about an evaluated
> expression.
> @@ -591,13 +603,6 @@ public:
>/// side-effects.
>bool EvaluateAsBooleanCondition(bool , const ASTContext )
> const;
>
> -  enum SideEffectsKind {
> -SE_NoSideEffects,  ///< Strictly evaluate the expression.
> -SE_AllowUndefinedBehavior, ///< Allow UB that we can give a value,
> but not
> -   ///< arbitrary unmodeled side effects.
> -SE_AllowSideEffects///< Allow any unmodeled side effect.
> -  };
> -
>/// EvaluateAsInt - Return true if this is a constant which we can fold
> and
>/// convert to an integer, using any crazy technique that we want to.
>bool EvaluateAsInt(llvm::APSInt , const ASTContext ,
>
> Modified: cfe/trunk/lib/AST/ExprConstant.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/
> ExprConstant.cpp?rev=332847=332846=332847=diff
> 
> ==
> --- cfe/trunk/lib/AST/ExprConstant.cpp (original)
> +++ cfe/trunk/lib/AST/ExprConstant.cpp Mon May 21 09:09:54 2018
> @@ -10312,12 +10312,6 @@ bool Expr::EvaluateAsBooleanCondition(bo
>   HandleConversionToBool(Scratch.Val, Result);
>  }
>
> -static bool hasUnacceptableSideEffect(Expr::EvalStatus ,
> -  Expr::SideEffectsKind SEK) {
> -  return (SEK < Expr::SE_AllowSideEffects && Result.HasSideEffects) ||
> - (SEK < Expr::SE_AllowUndefinedBehavior &&
> Result.HasUndefinedBehavior);
> -}
> -
>  bool Expr::EvaluateAsInt(APSInt , const ASTContext ,
>   SideEffectsKind AllowSideEffects) const {
>if (!getType()->isIntegralOrEnumerationType())
> @@ -10325,7 +10319,7 @@ bool Expr::EvaluateAsInt(APSInt ,
>
>EvalResult ExprResult;
>if (!EvaluateAsRValue(ExprResult, Ctx) || !ExprResult.Val.isInt() ||
> -  hasUnacceptableSideEffect(ExprResult, AllowSideEffects))
> +  ExprResult.hasUnacceptableSideEffect(AllowSideEffects))
>  return false;
>
>Result = ExprResult.Val.getInt();
> @@ -10339,7 +10333,7 @@ bool Expr::EvaluateAsFloat(APFloat 
>
>EvalResult ExprResult;
>if (!EvaluateAsRValue(ExprResult, Ctx) || !ExprResult.Val.isFloat() 

[PATCH] D47157: Warning for framework headers using double quote includes

2018-05-21 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno created this revision.
bruno added reviewers: dexonsmith, ributzka, steven_wu.

Introduce -Wquoted-include-in-framework-header, which should fire
a warning whenever a quote include appears in a framework header,
example, for A.h added in the tests:

...
A.framework/Headers/A.h:2:10: warning: double-quoted include "A0.h" in 
framework header, expected system style  include

This should help users prevent frameworks from using local headers
when in fact they should be targetting system level ones.

The warning is off by default.

rdar://problem/37077034


Repository:
  rC Clang

https://reviews.llvm.org/D47157

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticLexKinds.td
  lib/Lex/HeaderSearch.cpp
  test/Modules/Inputs/double-quotes/A.framework/Headers/A.h
  test/Modules/Inputs/double-quotes/A.framework/Headers/A0.h
  test/Modules/Inputs/double-quotes/A.framework/Modules/module.modulemap
  test/Modules/Inputs/double-quotes/B.h
  test/Modules/Inputs/double-quotes/X.framework/Headers/X.h
  test/Modules/Inputs/double-quotes/X.framework/Modules/module.modulemap
  test/Modules/Inputs/double-quotes/a.hmap.json
  test/Modules/Inputs/double-quotes/flat-header-path/Z.h
  test/Modules/Inputs/double-quotes/flat-header-path/Z.modulemap
  test/Modules/Inputs/double-quotes/x.hmap.json
  test/Modules/Inputs/double-quotes/z.yaml
  test/Modules/double-quotes.m

Index: test/Modules/double-quotes.m
===
--- /dev/null
+++ test/Modules/double-quotes.m
@@ -0,0 +1,38 @@
+// REQUIRES: shell
+
+// RUN: rm -rf %t
+// RUN: mkdir %t
+
+// RUN: hmaptool write %S/Inputs/double-quotes/a.hmap.json %t/a.hmap
+// RUN: hmaptool write %S/Inputs/double-quotes/x.hmap.json %t/x.hmap
+
+// RUN: sed -e "s:TEST_DIR:%S/Inputs/double-quotes:g" \
+// RUN:   %S/Inputs/double-quotes/z.yaml > %t/z.yaml
+
+// The output with and without modules should be the same, without modules first.
+// RUN: %clang_cc1 \
+// RUN:   -I %t/x.hmap -iquote %t/a.hmap -ivfsoverlay %t/z.yaml \
+// RUN:   -F%S/Inputs/double-quotes -I%S/Inputs/double-quotes \
+// RUN:   -Wquoted-include-in-framework-header -fsyntax-only %s -verify
+
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache \
+// RUN:   -I %t/x.hmap -iquote %t/a.hmap -ivfsoverlay %t/z.yaml \
+// RUN:   -F%S/Inputs/double-quotes -I%S/Inputs/double-quotes \
+// RUN:   -Wquoted-include-in-framework-header -fsyntax-only %s \
+// RUN:   2>%t/stderr
+
+// The same warnings show up when modules is on but -verify doesn't get it
+// because they only show up under the module A building context.
+// RUN: FileCheck --input-file=%t/stderr %s
+// CHECK: double-quoted include "A0.h" in framework header
+// CHECK: double-quoted include "B.h" in framework header
+// CHECK: double-quoted include "B.h" in framework header
+
+#import "A.h"
+#import 
+
+int bar() { return foo(); }
+
+// expected-warning@Inputs/double-quotes/A.framework/Headers/A.h:2{{double-quoted include "A0.h" in framework header}}
+// expected-warning@Inputs/double-quotes/A.framework/Headers/A.h:3{{double-quoted include "B.h" in framework header}}
+// expected-warning@Inputs/double-quotes/flat-header-path/Z.h:1{{double-quoted include "B.h" in framework header}}
Index: test/Modules/Inputs/double-quotes/z.yaml
===
--- /dev/null
+++ test/Modules/Inputs/double-quotes/z.yaml
@@ -0,0 +1,28 @@
+{
+  'version': 0,
+  'case-sensitive': 'false',
+  'roots': [
+{
+  'type': 'directory',
+  'name': "TEST_DIR/Z.framework/Headers",
+  'contents': [
+{
+  'type': 'file',
+  'name': "Z.h",
+  'external-contents': "TEST_DIR/flat-header-path/Z.h"
+}
+  ]
+},
+{
+  'type': 'directory',
+  'name': "TEST_DIR/Z.framework/Modules",
+  'contents': [
+{
+  'type': 'file',
+  'name': "module.modulemap",
+  'external-contents': "TEST_DIR/flat-header-path/Z.modulemap"
+}
+  ]
+}
+  ]
+}
Index: test/Modules/Inputs/double-quotes/x.hmap.json
===
--- /dev/null
+++ test/Modules/Inputs/double-quotes/x.hmap.json
@@ -0,0 +1,7 @@
+
+{
+  "mappings" :
+{
+ "X.h" : "X/X.h"
+}
+}
Index: test/Modules/Inputs/double-quotes/flat-header-path/Z.modulemap
===
--- /dev/null
+++ test/Modules/Inputs/double-quotes/flat-header-path/Z.modulemap
@@ -0,0 +1,3 @@
+framework module Z {
+	header "Z.h"
+}
Index: test/Modules/Inputs/double-quotes/flat-header-path/Z.h
===
--- /dev/null
+++ test/Modules/Inputs/double-quotes/flat-header-path/Z.h
@@ -0,0 +1 @@
+#import "B.h"
Index: test/Modules/Inputs/double-quotes/a.hmap.json
===
--- /dev/null
+++ 

[PATCH] D47089: CodeGen: Add a dwo output file argument to addPassesToEmitFile and hook it up to dwo output.

2018-05-21 Thread Peter Collingbourne via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC332881: CodeGen: Add a dwo output file argument to 
addPassesToEmitFile and hook it up… (authored by pcc, committed by ).
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D47089?vs=147598=147852#toc

Repository:
  rC Clang

https://reviews.llvm.org/D47089

Files:
  lib/CodeGen/BackendUtil.cpp


Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -718,7 +718,7 @@
   if (CodeGenOpts.OptimizationLevel > 0)
 CodeGenPasses.add(createObjCARCContractPass());
 
-  if (TM->addPassesToEmitFile(CodeGenPasses, OS, CGFT,
+  if (TM->addPassesToEmitFile(CodeGenPasses, OS, nullptr, CGFT,
   /*DisableVerify=*/!CodeGenOpts.VerifyModule)) {
 Diags.Report(diag::err_fe_unable_to_interface_with_target);
 return false;


Index: lib/CodeGen/BackendUtil.cpp
===
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -718,7 +718,7 @@
   if (CodeGenOpts.OptimizationLevel > 0)
 CodeGenPasses.add(createObjCARCContractPass());
 
-  if (TM->addPassesToEmitFile(CodeGenPasses, OS, CGFT,
+  if (TM->addPassesToEmitFile(CodeGenPasses, OS, nullptr, CGFT,
   /*DisableVerify=*/!CodeGenOpts.VerifyModule)) {
 Diags.Report(diag::err_fe_unable_to_interface_with_target);
 return false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r332881 - CodeGen: Add a dwo output file argument to addPassesToEmitFile and hook it up to dwo output.

2018-05-21 Thread Peter Collingbourne via cfe-commits
Author: pcc
Date: Mon May 21 13:16:41 2018
New Revision: 332881

URL: http://llvm.org/viewvc/llvm-project?rev=332881=rev
Log:
CodeGen: Add a dwo output file argument to addPassesToEmitFile and hook it up 
to dwo output.

Part of PR37466.

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

Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=332881=332880=332881=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Mon May 21 13:16:41 2018
@@ -718,7 +718,7 @@ bool EmitAssemblyHelper::AddEmitPasses(l
   if (CodeGenOpts.OptimizationLevel > 0)
 CodeGenPasses.add(createObjCARCContractPass());
 
-  if (TM->addPassesToEmitFile(CodeGenPasses, OS, CGFT,
+  if (TM->addPassesToEmitFile(CodeGenPasses, OS, nullptr, CGFT,
   /*DisableVerify=*/!CodeGenOpts.VerifyModule)) {
 Diags.Report(diag::err_fe_unable_to_interface_with_target);
 return false;


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


r332879 - Revert r332028; see PR37545 for details.

2018-05-21 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon May 21 13:10:54 2018
New Revision: 332879

URL: http://llvm.org/viewvc/llvm-project?rev=332879=rev
Log:
Revert r332028; see PR37545 for details.

Modified:
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/test/CodeGenCXX/rtti-linkage.cpp

Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=332879=332878=332879=diff
==
--- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Mon May 21 13:10:54 2018
@@ -3006,46 +3006,8 @@ void ItaniumRTTIBuilder::BuildVTablePoin
 
 /// Return the linkage that the type info and type info name constants
 /// should have for the given type.
-static std::pair
-getTypeInfoLinkage(CodeGenModule , QualType Ty) {
-  llvm::GlobalValue::LinkageTypes TypeLinkage = [&]() {
-switch (Ty->getLinkage()) {
-case NoLinkage:
-case InternalLinkage:
-case UniqueExternalLinkage:
-  return llvm::GlobalValue::InternalLinkage;
-
-case VisibleNoLinkage:
-case ModuleInternalLinkage:
-case ModuleLinkage:
-case ExternalLinkage:
-  // RTTI is not enabled, which means that this type info struct is going
-  // to be used for exception handling. Give it linkonce_odr linkage.
-  if (!CGM.getLangOpts().RTTI)
-return llvm::GlobalValue::LinkOnceODRLinkage;
-
-  if (const RecordType *Record = dyn_cast(Ty)) {
-const CXXRecordDecl *RD = cast(Record->getDecl());
-if (RD->hasAttr())
-  return llvm::GlobalValue::WeakODRLinkage;
-if (CGM.getTriple().isWindowsItaniumEnvironment())
-  if (RD->hasAttr() &&
-  ShouldUseExternalRTTIDescriptor(CGM, Ty))
-return llvm::GlobalValue::ExternalLinkage;
-// MinGW always uses LinkOnceODRLinkage for type info.
-if (RD->isCompleteDefinition() && RD->isDynamicClass() &&
-!CGM.getContext()
- .getTargetInfo()
- .getTriple()
- .isWindowsGNUEnvironment())
-  return CGM.getVTableLinkage(RD);
-  }
-
-  return llvm::GlobalValue::LinkOnceODRLinkage;
-}
-llvm_unreachable("Invalid linkage!");
-  }();
+static llvm::GlobalVariable::LinkageTypes getTypeInfoLinkage(CodeGenModule 
,
+ QualType Ty) {
   // Itanium C++ ABI 2.9.5p7:
   //   In addition, it and all of the intermediate abi::__pointer_type_info
   //   structs in the chain down to the abi::__class_type_info for the
@@ -3056,8 +3018,44 @@ getTypeInfoLinkage(CodeGenModule , Q
   //   complete class RTTI (because the latter need not exist), possibly by
   //   making it a local static object.
   if (ContainsIncompleteClassType(Ty))
-return {llvm::GlobalValue::InternalLinkage, TypeLinkage};
-  return {TypeLinkage, TypeLinkage};
+return llvm::GlobalValue::InternalLinkage;
+
+  switch (Ty->getLinkage()) {
+  case NoLinkage:
+  case InternalLinkage:
+  case UniqueExternalLinkage:
+return llvm::GlobalValue::InternalLinkage;
+
+  case VisibleNoLinkage:
+  case ModuleInternalLinkage:
+  case ModuleLinkage:
+  case ExternalLinkage:
+// RTTI is not enabled, which means that this type info struct is going
+// to be used for exception handling. Give it linkonce_odr linkage.
+if (!CGM.getLangOpts().RTTI)
+  return llvm::GlobalValue::LinkOnceODRLinkage;
+
+if (const RecordType *Record = dyn_cast(Ty)) {
+  const CXXRecordDecl *RD = cast(Record->getDecl());
+  if (RD->hasAttr())
+return llvm::GlobalValue::WeakODRLinkage;
+  if (CGM.getTriple().isWindowsItaniumEnvironment())
+if (RD->hasAttr() &&
+ShouldUseExternalRTTIDescriptor(CGM, Ty))
+  return llvm::GlobalValue::ExternalLinkage;
+  // MinGW always uses LinkOnceODRLinkage for type info.
+  if (RD->isDynamicClass() &&
+  !CGM.getContext()
+   .getTargetInfo()
+   .getTriple()
+   .isWindowsGNUEnvironment())
+return CGM.getVTableLinkage(RD);
+}
+
+return llvm::GlobalValue::LinkOnceODRLinkage;
+  }
+
+  llvm_unreachable("Invalid linkage!");
 }
 
 llvm::Constant *ItaniumRTTIBuilder::BuildTypeInfo(QualType Ty, bool Force,
@@ -3084,25 +3082,23 @@ llvm::Constant *ItaniumRTTIBuilder::Buil
 return GetAddrOfExternalRTTIDescriptor(Ty);
 
   // Emit the standard library with external linkage.
-  llvm::GlobalVariable::LinkageTypes InfoLinkage, NameLinkage;
+  llvm::GlobalVariable::LinkageTypes Linkage;
   if (IsStdLib)
-InfoLinkage = NameLinkage = llvm::GlobalValue::ExternalLinkage;
-  else {
-auto LinkagePair = getTypeInfoLinkage(CGM, Ty);
-InfoLinkage = LinkagePair.first;
-NameLinkage = LinkagePair.second;
-  }
+Linkage = 

[PATCH] D45616: [X86] Lower _mm[256|512]_cmp[.]_mask intrinsics to native llvm IR

2018-05-21 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a subscriber: andrew.w.kaylor.
efriedma added a comment.

I don't see any reason to exactly match the constant specified by the user, as 
long as the result is semantically equivalent.

Once we have llvm.experimental.constrained.fcmp, this code should be updated to 
emit it; that will preserve the user's intended exception semantics.


Repository:
  rC Clang

https://reviews.llvm.org/D45616



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


[PATCH] D46439: [Sema] Fix incorrect packed aligned structure layout

2018-05-21 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

This wouldn't be another layout/ABI breakage, would it?


Repository:
  rC Clang

https://reviews.llvm.org/D46439



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


[PATCH] D47097: [WIP][DebugInfo] Preserve scope in auto generated StoreInst

2018-05-21 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added inline comments.



Comment at: lib/CodeGen/CGDecl.cpp:2062
 EmitStoreOfScalar(ArgVal, lv, /* isInitialization */ true);
+ApplyDebugLocation::CreateArtificial(*this);
+  }

There are two issues here:
1) ApplyDebugLocation is a RAII helper, which means that it installs the proper 
debug location in its constructor, and restores the old debug location in its 
destructor. Since you are not assigning the result of the static constructor 
(CreateArtificial) to anything, the ApplyDebugLocation instance is immediately 
destroyed, so it's a no-op.
2) This is being applied in the wrong place, because it sets a debug location 
*after* the store is emitted. The right location needs to be applied before the 
store or alloca are emitted.


Repository:
  rC Clang

https://reviews.llvm.org/D47097



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


[PATCH] D47097: [WIP][DebugInfo] Preserve scope in auto generated StoreInst

2018-05-21 Thread Anastasis via Phabricator via cfe-commits
gramanas updated this revision to Diff 147840.
gramanas marked an inline comment as done.
gramanas added a comment.

Update according to the comments


Repository:
  rC Clang

https://reviews.llvm.org/D47097

Files:
  lib/CodeGen/CGDecl.cpp
  test/CodeGen/debug-info-preserve-scope.c


Index: test/CodeGen/debug-info-preserve-scope.c
===
--- /dev/null
+++ test/CodeGen/debug-info-preserve-scope.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -debug-info-kind=limited -emit-llvm -o - %s | FileCheck %s
+
+static int a;
+
+// CHECK-LABEL: define void @f
+void f(int b) {
+  a = b;
+}
+
+// CHECK: store i32 %b, i32* %b.addr, align 4, !dbg ![[dbgLocForStore:[0-9]+]]
+
+// CHECK: ![[dbgLocForStore]] = !DILocation(line: 0
Index: lib/CodeGen/CGDecl.cpp
===
--- lib/CodeGen/CGDecl.cpp
+++ lib/CodeGen/CGDecl.cpp
@@ -2057,8 +2057,10 @@
   }
 
   // Store the initial value into the alloca.
-  if (DoStore)
+  if (DoStore) {
 EmitStoreOfScalar(ArgVal, lv, /* isInitialization */ true);
+ApplyDebugLocation::CreateArtificial(*this);
+  }
 
   setAddrOfLocalVar(, DeclPtr);
 


Index: test/CodeGen/debug-info-preserve-scope.c
===
--- /dev/null
+++ test/CodeGen/debug-info-preserve-scope.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -debug-info-kind=limited -emit-llvm -o - %s | FileCheck %s
+
+static int a;
+
+// CHECK-LABEL: define void @f
+void f(int b) {
+  a = b;
+}
+
+// CHECK: store i32 %b, i32* %b.addr, align 4, !dbg ![[dbgLocForStore:[0-9]+]]
+
+// CHECK: ![[dbgLocForStore]] = !DILocation(line: 0
Index: lib/CodeGen/CGDecl.cpp
===
--- lib/CodeGen/CGDecl.cpp
+++ lib/CodeGen/CGDecl.cpp
@@ -2057,8 +2057,10 @@
   }
 
   // Store the initial value into the alloca.
-  if (DoStore)
+  if (DoStore) {
 EmitStoreOfScalar(ArgVal, lv, /* isInitialization */ true);
+ApplyDebugLocation::CreateArtificial(*this);
+  }
 
   setAddrOfLocalVar(, DeclPtr);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D47097: [WIP][DebugInfo] Preserve scope in auto generated StoreInst

2018-05-21 Thread Anastasis via Phabricator via cfe-commits
gramanas updated this revision to Diff 147838.
gramanas added a comment.

- Apply debug location


Repository:
  rC Clang

https://reviews.llvm.org/D47097

Files:
  lib/CodeGen/CGDecl.cpp
  test/CodeGen/debug-info-preserve-scope.c


Index: test/CodeGen/debug-info-preserve-scope.c
===
--- /dev/null
+++ test/CodeGen/debug-info-preserve-scope.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -O0 -debug-info-kind=limited -emit-llvm -o - %s | FileCheck 
%s
+
+static int a;
+
+// CHECK-LABEL: define void @f
+void f(int b) {
+  a = b;
+}
+
+// CHECK: store i32 %b, i32* %b.addr, align 4, !dbg ![[dbgLocForStore:[0-9]+]]
+
Index: lib/CodeGen/CGDecl.cpp
===
--- lib/CodeGen/CGDecl.cpp
+++ lib/CodeGen/CGDecl.cpp
@@ -2057,8 +2057,10 @@
   }
 
   // Store the initial value into the alloca.
-  if (DoStore)
+  if (DoStore) {
 EmitStoreOfScalar(ArgVal, lv, /* isInitialization */ true);
+ApplyDebugLocation::CreateArtificial(*this);
+  }
 
   setAddrOfLocalVar(, DeclPtr);
 


Index: test/CodeGen/debug-info-preserve-scope.c
===
--- /dev/null
+++ test/CodeGen/debug-info-preserve-scope.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -O0 -debug-info-kind=limited -emit-llvm -o - %s | FileCheck %s
+
+static int a;
+
+// CHECK-LABEL: define void @f
+void f(int b) {
+  a = b;
+}
+
+// CHECK: store i32 %b, i32* %b.addr, align 4, !dbg ![[dbgLocForStore:[0-9]+]]
+
Index: lib/CodeGen/CGDecl.cpp
===
--- lib/CodeGen/CGDecl.cpp
+++ lib/CodeGen/CGDecl.cpp
@@ -2057,8 +2057,10 @@
   }
 
   // Store the initial value into the alloca.
-  if (DoStore)
+  if (DoStore) {
 EmitStoreOfScalar(ArgVal, lv, /* isInitialization */ true);
+ApplyDebugLocation::CreateArtificial(*this);
+  }
 
   setAddrOfLocalVar(, DeclPtr);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D47122: [clang-tidy] SimplifyBoolenExpr doesn't add parens if unary negotiation is of ExprWithCleanups type

2018-05-21 Thread Zinovy Nis via Phabricator via cfe-commits
zinovy.nis updated this revision to Diff 147836.
zinovy.nis edited the summary of this revision.
zinovy.nis added a comment.

- More accurate place to fix.


https://reviews.llvm.org/D47122

Files:
  clang-tidy/readability/SimplifyBooleanExprCheck.cpp
  test/clang-tidy/readability-simplify-bool-expr.cpp


Index: test/clang-tidy/readability-simplify-bool-expr.cpp
===
--- test/clang-tidy/readability-simplify-bool-expr.cpp
+++ test/clang-tidy/readability-simplify-bool-expr.cpp
@@ -938,3 +938,13 @@
 }
 // CHECK-MESSAGES: :[[@LINE-5]]:12: warning: {{.*}} in conditional return
 // CHECK-FIXES: return p->m != 0;{{$}}
+
+bool operator!=(const A&, const A&) { return false; }
+bool expr_with_cleanups(A ) {
+  if (S != (A)S)
+return false;
+
+  return true;
+}
+// CHECK-MESSAGES: :[[@LINE-4]]:12: warning: {{.*}} in conditional return
+// CHECK-FIXES: S == (A)S;{{$}}
Index: clang-tidy/readability/SimplifyBooleanExprCheck.cpp
===
--- clang-tidy/readability/SimplifyBooleanExprCheck.cpp
+++ clang-tidy/readability/SimplifyBooleanExprCheck.cpp
@@ -195,6 +195,9 @@
 std::string replacementExpression(const MatchFinder::MatchResult ,
   bool Negated, const Expr *E) {
   E = E->ignoreParenBaseCasts();
+  if (const auto *EC = dyn_cast(E))
+E = EC->getSubExpr();
+
   const bool NeedsStaticCast = needsStaticCast(E);
   if (Negated) {
 if (const auto *UnOp = dyn_cast(E)) {


Index: test/clang-tidy/readability-simplify-bool-expr.cpp
===
--- test/clang-tidy/readability-simplify-bool-expr.cpp
+++ test/clang-tidy/readability-simplify-bool-expr.cpp
@@ -938,3 +938,13 @@
 }
 // CHECK-MESSAGES: :[[@LINE-5]]:12: warning: {{.*}} in conditional return
 // CHECK-FIXES: return p->m != 0;{{$}}
+
+bool operator!=(const A&, const A&) { return false; }
+bool expr_with_cleanups(A ) {
+  if (S != (A)S)
+return false;
+
+  return true;
+}
+// CHECK-MESSAGES: :[[@LINE-4]]:12: warning: {{.*}} in conditional return
+// CHECK-FIXES: S == (A)S;{{$}}
Index: clang-tidy/readability/SimplifyBooleanExprCheck.cpp
===
--- clang-tidy/readability/SimplifyBooleanExprCheck.cpp
+++ clang-tidy/readability/SimplifyBooleanExprCheck.cpp
@@ -195,6 +195,9 @@
 std::string replacementExpression(const MatchFinder::MatchResult ,
   bool Negated, const Expr *E) {
   E = E->ignoreParenBaseCasts();
+  if (const auto *EC = dyn_cast(E))
+E = EC->getSubExpr();
+
   const bool NeedsStaticCast = needsStaticCast(E);
   if (Negated) {
 if (const auto *UnOp = dyn_cast(E)) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D47155: [analyzer] Reduce simplifySVal complexity threshold further.

2018-05-21 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a reviewer: mikhail.ramalho.
NoQ added a subscriber: mikhail.ramalho.
NoQ added a comment.

@mikhail.ramalho Does it solve your problems with ffmpeg as well? :)


Repository:
  rC Clang

https://reviews.llvm.org/D47155



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


[PATCH] D47155: [analyzer] Reduce simplifySVal complexity threshold further.

2018-05-21 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision.
NoQ added reviewers: dcoughlin, xazax.hun, a.sidorin, george.karpenkov, szepet, 
rnkovacs.
Herald added subscribers: cfe-commits, baloghadamsoftware.

Reported by Mikael Holmén on 
http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20180416/225349.html - 
a combination of https://reviews.llvm.org/rC329780 and 
https://reviews.llvm.org/rC300178 caused a performance regression that seemed 
to be a hang on the attached test case.

Reducing even further from 20 to 10 gives a ~15% further speed boost on the 
test, but i don't think it's worth it because such code is not common and 
therefore accuracy is more important.


Repository:
  rC Clang

https://reviews.llvm.org/D47155

Files:
  lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
  test/Analysis/hangs.c


Index: test/Analysis/hangs.c
===
--- /dev/null
+++ test/Analysis/hangs.c
@@ -0,0 +1,16 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker core -verify %s
+
+// expected-no-diagnostics
+
+// Stuff that used to hang.
+
+int g();
+
+int f(int y) {
+  return y + g();
+}
+
+int produce_a_very_large_symbol(int x) {
+  return f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(
+ f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(x;
+}
Index: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -1274,7 +1274,7 @@
 SVal VisitNonLocSymbolVal(nonloc::SymbolVal V) {
   // Simplification is much more costly than computing complexity.
   // For high complexity, it may be not worth it.
-  if (V.getSymbol()->computeComplexity() > 100)
+  if (V.getSymbol()->computeComplexity() > 20)
 return V;
   return Visit(V.getSymbol());
 }


Index: test/Analysis/hangs.c
===
--- /dev/null
+++ test/Analysis/hangs.c
@@ -0,0 +1,16 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker core -verify %s
+
+// expected-no-diagnostics
+
+// Stuff that used to hang.
+
+int g();
+
+int f(int y) {
+  return y + g();
+}
+
+int produce_a_very_large_symbol(int x) {
+  return f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(
+ f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(x;
+}
Index: lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
===
--- lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
+++ lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
@@ -1274,7 +1274,7 @@
 SVal VisitNonLocSymbolVal(nonloc::SymbolVal V) {
   // Simplification is much more costly than computing complexity.
   // For high complexity, it may be not worth it.
-  if (V.getSymbol()->computeComplexity() > 100)
+  if (V.getSymbol()->computeComplexity() > 20)
 return V;
   return Visit(V.getSymbol());
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D47154: Try to make builtin address space declarations not useless

2018-05-21 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm created this revision.
arsenm added reviewers: Anastasia, yaxunl, rjmccall.
Herald added subscribers: tpr, nhaehnle, wdng.

The way address space declarations for builtins currently work
is nearly useless. The code assumes the address spaces used for
builtins is a confusingly named "target address space" from user
code using __attribute__((address_space(N))) that matches
the builtin declaration. There's no way to use this to declare
a builtin that returns a language specific address space.
The terminology used is highly cofusing since it has nothing
to do with the the address space selected by the target to use
for a language address space.

  

This feature is essentially unused as-is. AMDGPU and NVPTX
are the only in-tree targets attempting to use this. The AMDGPU
builtins certainly do not behave as intended (i.e. all of the
builtins returning pointers can never compile because the numbered
address space never matches the expected named address space).

  

The NVPTX builtins are missing tests for some, and the others
seem to rely on an implicit addrspacecast.

  

Change the used address space for builtins based on a target
hook to allow using a language address space for a builtin.
This allows the same builtin declaration to be used for multiple
languages with similarly purposed address spaces (e.g. the same
AMDGPU builtin can be used in OpenCL and CUDA even though the
constant address spaces are arbitarily different).

  

This breaks the possibility of using arbitrary numbered
address spaces alongside the named address spaces for builtins.
If this is an issue we probably need to introduce another builtin
declaration character to distinguish language address spaces from
so-called "target address spaces".


https://reviews.llvm.org/D47154

Files:
  include/clang/AST/ASTContext.h
  include/clang/Basic/BuiltinsAMDGPU.def
  include/clang/Basic/TargetInfo.h
  lib/AST/ASTContext.cpp
  lib/Basic/Targets/AMDGPU.h
  lib/CodeGen/CGBuiltin.cpp
  lib/Sema/SemaExpr.cpp
  test/CodeGenCUDA/builtins-amdgcn.cu
  test/CodeGenOpenCL/builtins-amdgcn-vi.cl
  test/CodeGenOpenCL/builtins-amdgcn.cl
  test/CodeGenOpenCL/numbered-address-space.cl

Index: test/CodeGenOpenCL/numbered-address-space.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/numbered-address-space.cl
@@ -0,0 +1,47 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -cl-std=CL2.0 -triple amdgcn-unknown-unknown -target-cpu tonga -S -emit-llvm -O0 -o - %s | FileCheck %s
+
+// Make sure using numbered address spaces doesn't trigger crashes when a
+// builtin has an address space parameter.
+
+// CHECK-LABEL: @test_numbered_as_to_generic(
+// CHECK: addrspacecast i32 addrspace(42)* %0 to i32*
+void test_numbered_as_to_generic(__attribute__((address_space(42))) int *arbitary_numbered_ptr) {
+  generic int* generic_ptr = arbitary_numbered_ptr;
+  *generic_ptr = 4;
+}
+
+// CHECK-LABEL: @test_numbered_as_to_builtin(
+// CHECK: addrspacecast i32 addrspace(42)* %0 to float addrspace(3)*
+void test_numbered_as_to_builtin(__attribute__((address_space(42))) int *arbitary_numbered_ptr, float src) {
+  volatile float result = __builtin_amdgcn_ds_fmax(arbitary_numbered_ptr, src, 0, 0, false);
+}
+
+// CHECK-LABEL: @test_generic_as_to_builtin_parameter_explicit_cast(
+// CHECK: addrspacecast i32 addrspace(3)* %0 to i32*
+void test_generic_as_to_builtin_parameter_explicit_cast(__local int *local_ptr, float src) {
+  generic int* generic_ptr = local_ptr;
+  volatile float result = __builtin_amdgcn_ds_fmax((__local float*) generic_ptr, src, 0, 0, false);
+}
+
+// CHECK-LABEL: @test_generic_as_to_builtin_parameter_implicit_cast(
+// CHECK: addrspacecast i32* %2 to float addrspace(3)*
+void test_generic_as_to_builtin_parameter_implicit_cast(__local int *local_ptr, float src) {
+  generic int* generic_ptr = local_ptr;
+
+  volatile float result = __builtin_amdgcn_ds_fmax(generic_ptr, src, 0, 0, false);
+}
+
+#if 0
+// XXX: Should this compile?
+void test_generic_as_to_builtin_parameter_explicit_cast_numeric(__attribute__((address_space(3))) int *local_ptr, float src) {
+  generic int* generic_ptr = local_ptr;
+  volatile float result = __builtin_amdgcn_ds_fmax((__attribute__((address_space(3))) float*) generic_ptr, src, 0, 0, false);
+}
+
+// XXX: Should this compile?
+void test_generic_as_to_builtin_parameterimplicit_cast_numeric(__attribute__((address_space(3))) int *local_ptr, float src) {
+  generic int* generic_ptr = local_ptr;
+  volatile float result = __builtin_amdgcn_ds_fmax(generic_ptr, src, 0, 0, false);
+}
+#endif
Index: test/CodeGenOpenCL/builtins-amdgcn.cl
===
--- test/CodeGenOpenCL/builtins-amdgcn.cl
+++ test/CodeGenOpenCL/builtins-amdgcn.cl
@@ -1,6 +1,6 @@
 // REQUIRES: amdgpu-registered-target
-// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -S -emit-llvm -o - %s | FileCheck %s
-// RUN: %clang_cc1 -triple 

[PATCH] D47142: [x86] invpcid intrinsic

2018-05-21 Thread Gabor Buella via Phabricator via cfe-commits
GBuella added inline comments.



Comment at: lib/Headers/intrin.h:196
+ */
 void __cdecl _invpcid(unsigned int, void *);
+#endif

rnk wrote:
> GBuella wrote:
> > GBuella wrote:
> > > rnk wrote:
> > > > craig.topper wrote:
> > > > > @rnk, what's the right thing to do here?
> > > > What problems does this redeclaration cause?
> > > Now that I think about it, none.
> > Also, I think this could be added as TARGET_HEADER_BUILTIN..."intrin.h", 
> > ALL_MS_LANGUAGES into BuiltinsX86.def
> > And removed from here.
> > Right?
> It could be, but then you'd need to implement it as a builtin instead of 
> having invpcidintrin.h, right?
Meanwhile, I just realized, we add the `!defined(_MSC_VER)` condition around 
the inclusion of all such header files, as I did with `invpcidintrin.h`.
Does clang always define _MSC_VER on Windows? I mean, always in cases where one 
would want to include the MSVC likes`intrin.h`?
In that case, these are completely independent things. Also, I could just add 
both builtins `_invpcid` with the ALL_MS_LANGUAGES thing, and the 
`__builtin_ia32_invpcid` with the usual clang/GCC convention of adding separate 
feature flags (both would be lowered to the same LLVM intrinsic).
BTW, if we stop adding feature flags for such intrinsics, we probably have to 
convince GCC to do the same, as we love that compatibility.


Repository:
  rC Clang

https://reviews.llvm.org/D47142



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


[PATCH] D46863: [X86] Use __builtin_convertvector to implement some of the packed integer to packed float conversion intrinsics.

2018-05-21 Thread David Kreitzer via Phabricator via cfe-commits
DavidKreitzer accepted this revision.
DavidKreitzer added a comment.
This revision is now accepted and ready to land.

I had actually done that as part of my initial review, so LGTM.


Repository:
  rC Clang

https://reviews.llvm.org/D46863



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


[PATCH] D44539: [Sema][Objective-C] Add check to warn when property of objc type has assign attribute

2018-05-21 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D44539#1106802, @rjmccall wrote:

> In https://reviews.llvm.org/D44539#1106443, @aaron.ballman wrote:
>
> > In https://reviews.llvm.org/D44539#1106152, @rjmccall wrote:
> >
> > > This was approved by the Objective-C language group as a default-off 
> > > warning.
> >
> >
> > We usually do not expose new default-off warnings because experience shows 
> > that they rarely ever get enabled by users. If the ObjC group doesn't think 
> > this should be on by default, I wonder if it should be included in Clang at 
> > all.
>
>
> That's a fair question to ask.  In this case, I'm in favor of adding it 
> because we have evidence of there being a substantial set of users who would 
> enable it enthusiastically.


Okay, that works for me. Thank you for verifying.


Repository:
  rC Clang

https://reviews.llvm.org/D44539



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


[PATCH] D46485: Add python tool to dump and construct header maps

2018-05-21 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno updated this revision to Diff 147829.
bruno added a comment.

Update testcases (and fixed a missing one) after Duncan's review.


https://reviews.llvm.org/D46485

Files:
  CMakeLists.txt
  test/CMakeLists.txt
  test/Modules/crash-vfs-headermaps.m
  test/Preprocessor/Inputs/headermap-rel/foo.hmap
  test/Preprocessor/Inputs/headermap-rel/foo.hmap.json
  test/Preprocessor/Inputs/headermap-rel2/project-headers.hmap
  test/Preprocessor/Inputs/headermap-rel2/project-headers.hmap.json
  test/Preprocessor/Inputs/nonportable-hmaps/foo.hmap
  test/Preprocessor/Inputs/nonportable-hmaps/foo.hmap.json
  test/Preprocessor/headermap-rel.c
  test/Preprocessor/headermap-rel2.c
  test/Preprocessor/nonportable-include-with-hmap.c
  utils/hmaptool/CMakeLists.txt
  utils/hmaptool/hmaptool

Index: utils/hmaptool/hmaptool
===
--- /dev/null
+++ utils/hmaptool/hmaptool
@@ -0,0 +1,289 @@
+#!/usr/bin/env python
+
+import json
+import optparse
+import os
+import struct
+import sys
+
+###
+
+k_header_magic_LE = 'pamh'
+k_header_magic_BE = 'hmap'
+
+def hmap_hash(str):
+"""hash(str) -> int
+
+Apply the "well-known" headermap hash function.
+"""
+
+return sum((ord(c.lower()) * 13
+for c in str), 0)
+
+class HeaderMap(object):
+@staticmethod
+def frompath(path):
+with open(path, 'rb') as f:
+magic = f.read(4)
+if magic == k_header_magic_LE:
+endian_code = '<'
+elif magic == k_header_magic_BE:
+endian_code = '>'
+else:
+raise SystemExit("error: %s: not a headermap" % (
+path,))
+
+# Read the header information.
+header_fmt = endian_code + 'HH'
+header_size = struct.calcsize(header_fmt)
+data = f.read(header_size)
+if len(data) != header_size:
+raise SystemExit("error: %s: truncated headermap header" % (
+path,))
+
+(version, reserved, strtable_offset, num_entries,
+ num_buckets, max_value_len) = struct.unpack(header_fmt, data)
+
+if version != 1:
+raise SystemExit("error: %s: unknown headermap version: %r" % (
+path, version))
+if reserved != 0:
+raise SystemExit("error: %s: invalid reserved value in header" % (
+path,))
+
+# The number of buckets must be a power of two.
+if num_buckets == 0 or (num_buckets & num_buckets - 1) != 0:
+raise SystemExit("error: %s: invalid number of buckets" % (
+path,))
+
+# Read all of the buckets.
+bucket_fmt = endian_code + 'III'
+bucket_size = struct.calcsize(bucket_fmt)
+buckets_data = f.read(num_buckets * bucket_size)
+if len(buckets_data) != num_buckets * bucket_size:
+raise SystemExit("error: %s: truncated headermap buckets" % (
+path,))
+buckets = [struct.unpack(bucket_fmt,
+ buckets_data[i*bucket_size:(i+1)*bucket_size])
+   for i in range(num_buckets)]
+
+# Read the string table; the format doesn't explicitly communicate the
+# size of the string table (which is dumb), so assume it is the rest of
+# the file.
+f.seek(0, 2)
+strtable_size = f.tell() - strtable_offset
+f.seek(strtable_offset)
+
+strtable = f.read(strtable_size)
+if len(strtable) != strtable_size:
+raise SystemExit("error: %s: unable to read complete string table"%(
+path,))
+if strtable[-1] != '\0':
+raise SystemExit("error: %s: invalid string table in headermap" % (
+path,))
+
+return HeaderMap(num_entries, buckets, strtable)
+
+def __init__(self, num_entries, buckets, strtable):
+self.num_entries = num_entries
+self.buckets = buckets
+self.strtable = strtable
+
+def get_string(self, idx):
+if idx >= len(self.strtable):
+raise SystemExit("error: %s: invalid string index" % (
+path,))
+end_idx = self.strtable.index('\0', idx)
+return self.strtable[idx:end_idx]
+
+@property
+def mappings(self):
+for key_idx,prefix_idx,suffix_idx in self.buckets:
+if key_idx == 0:
+continue
+yield (self.get_string(key_idx),
+   self.get_string(prefix_idx) + self.get_string(suffix_idx))
+
+###
+
+def action_dump(name, args):
+"dump a headermap file"
+
+parser = optparse.OptionParser("%%prog %s [options] " % (
+name,))
+parser.add_option("-v", "--verbose", dest="verbose",
+   

[PATCH] D47135: [analyzer][WIP] A checker for dangling string pointers in C++

2018-05-21 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

This looks great, i think we should make a single super simple mock test and 
commit this.

@MTC, i really appreciate your help!




Comment at: lib/StaticAnalyzer/Checkers/DanglingStringPointerChecker.cpp:59
+  QualType RegType = TypedR->getValueType();
+  if (RegType.getAsString() != "std::string")
+return;

MTC wrote:
> A little tip, there are other string types besides `std::string`, like 
> `std::wstring`, which can be added in the future. See [[ 
> http://en.cppreference.com/w/cpp/string/basic_string | basic_string ]].
Yup, the current check should work in many cases, but it should be better to 
compare the class name to `basic_string`.

I'm also worried about various sorts of `std::__1::string`s (an inline 
namespace in libc++).



Comment at: lib/StaticAnalyzer/Checkers/DanglingStringPointerChecker.cpp:64
+
+  if (Call.isCalled(CStrFn)) {
+SymbolRef RawPtr = Call.getReturnValue().getAsSymbol();

It has long been planned to extend `isCalled` to C++ methods, i.e. something 
like this:
```
DanglingStringPointerChecker() : CStrFn("std::string::c_str") {}

...

void DanglingStringPointerChecker::checkPostCall(const CallEvent ,
 CheckerContext ) const {
  // Skip the class check.
  if (Call.isCalled(CStrFn)) {
...
  }

  ...
}
```
Still looking for volunteers^^



Comment at: lib/StaticAnalyzer/Checkers/DanglingStringPointerChecker.cpp:71
+
+  if (dyn_cast(ICall)) {
+if (State->contains(TypedR)) {

MTC wrote:
> `CXXDestructorCall::classof(const CallEvent *CA)` can also be used here. 
`isa`.



Comment at: lib/StaticAnalyzer/Checkers/RegionState.h:18
+
+namespace region_state {
+

MTC wrote:
> I'm not sure whether `region_state` follows the naming conventions of LLVM 
> coding standards. Can someone answer this question?
I think it does, cf. `namespace ast_matchers`.

The name should be more specific though, a lot of checkers track "region 
states". Maybe "allocation_state"?


Repository:
  rC Clang

https://reviews.llvm.org/D47135



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


[PATCH] D44539: [Sema][Objective-C] Add check to warn when property of objc type has assign attribute

2018-05-21 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In https://reviews.llvm.org/D44539#1106443, @aaron.ballman wrote:

> In https://reviews.llvm.org/D44539#1106152, @rjmccall wrote:
>
> > This was approved by the Objective-C language group as a default-off 
> > warning.
>
>
> We usually do not expose new default-off warnings because experience shows 
> that they rarely ever get enabled by users. If the ObjC group doesn't think 
> this should be on by default, I wonder if it should be included in Clang at 
> all.


That's a fair question to ask.  In this case, I'm in favor of adding it because 
we have evidence of there being a substantial set of users who would enable it 
enthusiastically.




Comment at: include/clang/Basic/DiagnosticSemaKinds.td:1018
+def warn_objc_property_assign_on_object : Warning<
+  "'assign' attribute must not be of object type, use 'unsafe_unretained' 
instead">,
+  InGroup, DefaultIgnore;

QF5690 wrote:
> rjmccall wrote:
> > "must" is rather strong for a warning.  Maybe something more like "'assign' 
> > attribute on property of object type could be 'unsafe_unretained'"?
> But "could be" is rather weak :) 
> May be "Prefer using explicit 'unsafe_unretained' attribute instead of 
> 'assign' for object types", or "Using explicit 'unsafe_unretained' attribute 
> instead of 'assign' for object types is preferred" (if passive voice is 
> preferred)
Neither of those is quite in the standard diagnostic "voice".  Maybe something 
like "'assign' property of object type may become a dangling reference; 
consider using 'unsafe_unretained'"?

Oh, you should probably not warn about `Class` types.


Repository:
  rC Clang

https://reviews.llvm.org/D44539



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


r332854 - [Clang Tablegen] Add llvm_unreachable() to getModifierName()

2018-05-21 Thread Mark Searles via cfe-commits
Author: msearles
Date: Mon May 21 10:29:08 2018
New Revision: 332854

URL: http://llvm.org/viewvc/llvm-project?rev=332854=rev
Log:
[Clang Tablegen] Add llvm_unreachable() to getModifierName()

Fix internal build failure:

../../../ClangDiagnosticsEmitter.cpp -o ClangDiagnosticsEmitter.o
../../../ClangDiagnosticsEmitter.cpp: In function 'llvm::StringRef
{anonymous}::getModifierName({anonymous}::ModifierType)':
../../../ClangDiagnosticsEmitter.cpp:495:1: error: control reaches end of 
non-void function [-Werror=return-type]
}
^

Build failure triggered by git-svn-id: 
https://llvm.org/svn/llvm-project/cfe/trunk@332799 
91177308-0d34-0410-b5e6-96231b3b80d8

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

Modified:
cfe/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp

Modified: cfe/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp?rev=332854=332853=332854=diff
==
--- cfe/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp (original)
+++ cfe/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp Mon May 21 10:29:08 
2018
@@ -492,6 +492,8 @@ static StringRef getModifierName(Modifie
   case MT_Unknown:
 llvm_unreachable("invalid modifier type");
   }
+  // Unhandled case
+  llvm_unreachable("invalid modifier type");
 }
 
 struct Piece {


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


r332848 - [AMDGPU] fixes for lds f32 builtins

2018-05-21 Thread Daniil Fukalov via cfe-commits
Author: dfukalov
Date: Mon May 21 09:18:07 2018
New Revision: 332848

URL: http://llvm.org/viewvc/llvm-project?rev=332848=rev
Log:
[AMDGPU] fixes for lds f32 builtins

1. added restrictions to memory scope, order and volatile parameters
2. added custom processing for these builtins - currently is not used code,
   needed to switch off GCCBuiltin link to the builtins (ongoing change to llvm
   tree)
3. builtins renamed as requested

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

Modified:
cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-vi.cl
cfe/trunk/test/SemaOpenCL/builtins-amdgcn-error.cl

Modified: cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def?rev=332848=332847=332848=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def Mon May 21 09:18:07 2018
@@ -93,9 +93,9 @@ BUILTIN(__builtin_amdgcn_ds_bpermute, "i
 BUILTIN(__builtin_amdgcn_readfirstlane, "ii", "nc")
 BUILTIN(__builtin_amdgcn_readlane, "iii", "nc")
 BUILTIN(__builtin_amdgcn_fmed3f, "", "nc")
-BUILTIN(__builtin_amdgcn_ds_fadd, "ff*3fiib", "n")
-BUILTIN(__builtin_amdgcn_ds_fmin, "ff*3fiib", "n")
-BUILTIN(__builtin_amdgcn_ds_fmax, "ff*3fiib", "n")
+BUILTIN(__builtin_amdgcn_ds_faddf, "ff*fIiIiIb", "n")
+BUILTIN(__builtin_amdgcn_ds_fminf, "ff*fIiIiIb", "n")
+BUILTIN(__builtin_amdgcn_ds_fmaxf, "ff*fIiIiIb", "n")
 
 
//===--===//
 // VI+ only builtins.

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=332848=332847=332848=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Mon May 21 09:18:07 2018
@@ -10088,6 +10088,49 @@ Value *CodeGenFunction::EmitAMDGPUBuilti
 CI->setConvergent();
 return CI;
   }
+  case AMDGPU::BI__builtin_amdgcn_ds_faddf:
+  case AMDGPU::BI__builtin_amdgcn_ds_fminf:
+  case AMDGPU::BI__builtin_amdgcn_ds_fmaxf: {
+llvm::SmallVector Args;
+for (unsigned I = 0; I != 5; ++I)
+  Args.push_back(EmitScalarExpr(E->getArg(I)));
+const llvm::Type *PtrTy = Args[0]->getType();
+// check pointer parameter
+if (!PtrTy->isPointerTy() ||
+E->getArg(0)
+->getType()
+->getPointeeType()
+.getQualifiers()
+.getAddressSpace() != LangAS::opencl_local ||
+!PtrTy->getPointerElementType()->isFloatTy()) {
+   CGM.Error(E->getArg(0)->getLocStart(),
+"parameter should have type \"local float*\"");
+  return nullptr;
+}
+// check float parameter
+if (!Args[1]->getType()->isFloatTy()) {
+  CGM.Error(E->getArg(1)->getLocStart(),
+"parameter should have type \"float\"");
+  return nullptr;
+}
+
+Intrinsic::ID ID;
+switch (BuiltinID) {
+case AMDGPU::BI__builtin_amdgcn_ds_faddf:
+  ID = Intrinsic::amdgcn_ds_fadd;
+  break;
+case AMDGPU::BI__builtin_amdgcn_ds_fminf:
+  ID = Intrinsic::amdgcn_ds_fmin;
+  break;
+case AMDGPU::BI__builtin_amdgcn_ds_fmaxf:
+  ID = Intrinsic::amdgcn_ds_fmax;
+  break;
+default:
+  llvm_unreachable("Unknown BuiltinID");
+}
+Value *F = CGM.getIntrinsic(ID);
+return Builder.CreateCall(F, Args);
+  }
 
   // amdgcn workitem
   case AMDGPU::BI__builtin_amdgcn_workitem_id_x:

Modified: cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-vi.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-vi.cl?rev=332848=332847=332848=diff
==
--- cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-vi.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-vi.cl Mon May 21 09:18:07 2018
@@ -91,18 +91,18 @@ void test_mov_dpp(global int* out, int s
 
 // CHECK-LABEL: @test_ds_fadd
 // CHECK: call float @llvm.amdgcn.ds.fadd(float addrspace(3)* %out, float 
%src, i32 0, i32 0, i1 false)
-void test_ds_fadd(__attribute__((address_space(3))) float *out, float src) {
-  *out = __builtin_amdgcn_ds_fadd(out, src, 0, 0, false);
+void test_ds_faddf(local float *out, float src) {
+  *out = __builtin_amdgcn_ds_faddf(out, src, 0, 0, false);
 }
 
 // CHECK-LABEL: @test_ds_fmin
 // CHECK: call float @llvm.amdgcn.ds.fmin(float addrspace(3)* %out, float 
%src, i32 0, i32 0, i1 false)
-void test_ds_fmin(__attribute__((address_space(3))) float *out, float src) {
-  *out = __builtin_amdgcn_ds_fmin(out, src, 0, 0, false);
+void test_ds_fminf(local float *out, float src) {
+  *out = __builtin_amdgcn_ds_fminf(out, src, 0, 0, false);

[PATCH] D46863: [X86] Use __builtin_convertvector to implement some of the packed integer to packed float conversion intrinsics.

2018-05-21 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

So I think we've covered the whether this is ok to do questions. If someone can 
double check signed/unsigned and vector element sizes are all correct and 
approve this that would be great.


Repository:
  rC Clang

https://reviews.llvm.org/D46863



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


[PATCH] D47118: [modules] Print input files when -module-file-info file switch is passed.

2018-05-21 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.

Thanks for improving this Vassil. Where does in the output it shows up? I 
wonder if we should have those at the end given the huge amount of headers some 
modules might have.


Repository:
  rC Clang

https://reviews.llvm.org/D47118



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


[PATCH] D46541: [CodeGen] Improve diagnostics related to target attributes

2018-05-21 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

I think you can pass StringRef(F).substr(1). That won't create a temporary 
string. It will just create a StringRef pointing into the middle of an existing 
std::string stored in the parsed attributes.


https://reviews.llvm.org/D46541



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


[PATCH] D47150: [Clang Tablegen] Add llvm_unreachable() to getModifierName()

2018-05-21 Thread Mark Searles via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL332854: [Clang Tablegen] Add llvm_unreachable() to 
getModifierName() (authored by msearles, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D47150?vs=147809=147814#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D47150

Files:
  cfe/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp


Index: cfe/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp
===
--- cfe/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp
+++ cfe/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp
@@ -492,6 +492,8 @@
   case MT_Unknown:
 llvm_unreachable("invalid modifier type");
   }
+  // Unhandled case
+  llvm_unreachable("invalid modifier type");
 }
 
 struct Piece {


Index: cfe/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp
===
--- cfe/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp
+++ cfe/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp
@@ -492,6 +492,8 @@
   case MT_Unknown:
 llvm_unreachable("invalid modifier type");
   }
+  // Unhandled case
+  llvm_unreachable("invalid modifier type");
 }
 
 struct Piece {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D47150: [Clang Tablegen] Add llvm_unreachable() to getModifierName()

2018-05-21 Thread Mark Searles via Phabricator via cfe-commits
msearles updated this revision to Diff 147809.
msearles added a comment.

Add comment per reviewer suggestion.


https://reviews.llvm.org/D47150

Files:
  utils/TableGen/ClangDiagnosticsEmitter.cpp


Index: utils/TableGen/ClangDiagnosticsEmitter.cpp
===
--- utils/TableGen/ClangDiagnosticsEmitter.cpp
+++ utils/TableGen/ClangDiagnosticsEmitter.cpp
@@ -492,6 +492,8 @@
   case MT_Unknown:
 llvm_unreachable("invalid modifier type");
   }
+  // Unhandled case
+  llvm_unreachable("invalid modifier type");
 }
 
 struct Piece {


Index: utils/TableGen/ClangDiagnosticsEmitter.cpp
===
--- utils/TableGen/ClangDiagnosticsEmitter.cpp
+++ utils/TableGen/ClangDiagnosticsEmitter.cpp
@@ -492,6 +492,8 @@
   case MT_Unknown:
 llvm_unreachable("invalid modifier type");
   }
+  // Unhandled case
+  llvm_unreachable("invalid modifier type");
 }
 
 struct Piece {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D47150: [Clang Tablegen] Add llvm_unreachable() to getModifierName()

2018-05-21 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF accepted this revision.
EricWF added a comment.
This revision is now accepted and ready to land.

LGTM.




Comment at: utils/TableGen/ClangDiagnosticsEmitter.cpp:495
   }
+  llvm_unreachable("invalid modifier type");
 }

Perhaps this should say "unhandled case" or similar?


https://reviews.llvm.org/D47150



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


[PATCH] D47142: [x86] invpcid intrinsic

2018-05-21 Thread Gabor Buella via Phabricator via cfe-commits
GBuella added inline comments.



Comment at: lib/Headers/intrin.h:196
+ */
 void __cdecl _invpcid(unsigned int, void *);
+#endif

GBuella wrote:
> rnk wrote:
> > craig.topper wrote:
> > > @rnk, what's the right thing to do here?
> > What problems does this redeclaration cause?
> Now that I think about it, none.
Also, I think this could be added as TARGET_HEADER_BUILTIN..."intrin.h", 
ALL_MS_LANGUAGES into BuiltinsX86.def
And removed from here.
Right?


Repository:
  rC Clang

https://reviews.llvm.org/D47142



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


[PATCH] D47142: [x86] invpcid intrinsic

2018-05-21 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: lib/Headers/intrin.h:196
+ */
 void __cdecl _invpcid(unsigned int, void *);
+#endif

GBuella wrote:
> GBuella wrote:
> > rnk wrote:
> > > craig.topper wrote:
> > > > @rnk, what's the right thing to do here?
> > > What problems does this redeclaration cause?
> > Now that I think about it, none.
> Also, I think this could be added as TARGET_HEADER_BUILTIN..."intrin.h", 
> ALL_MS_LANGUAGES into BuiltinsX86.def
> And removed from here.
> Right?
It could be, but then you'd need to implement it as a builtin instead of having 
invpcidintrin.h, right?


Repository:
  rC Clang

https://reviews.llvm.org/D47142



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


[PATCH] D47142: [x86] invpcid intrinsic

2018-05-21 Thread Gabor Buella via Phabricator via cfe-commits
GBuella added inline comments.



Comment at: lib/Headers/intrin.h:196
+ */
 void __cdecl _invpcid(unsigned int, void *);
+#endif

rnk wrote:
> craig.topper wrote:
> > @rnk, what's the right thing to do here?
> What problems does this redeclaration cause?
Now that I think about it, none.


Repository:
  rC Clang

https://reviews.llvm.org/D47142



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


[PATCH] D47142: [x86] invpcid intrinsic

2018-05-21 Thread Gabor Buella via Phabricator via cfe-commits
GBuella added a comment.

In https://reviews.llvm.org/D47142#1106664, @rnk wrote:

> Why do we need a feature flag for this in the first place? The MSVC model for 
> most "instruction" intrinsics is that the exact instruction is emitted 
> regardless of the feature enabled. The target attribute seems like it would 
> get in the way of that.


I'm fine with getting rid of the feature flag, here, and then probably also for 
other instructions in similar situations (pconfig, wbnoinvd, clwb, etc...).
But as long as we keep those other feature flags, I guess we should just be 
consistent.


Repository:
  rC Clang

https://reviews.llvm.org/D47142



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


[PATCH] D47044: [analyzer] Ensure that we only visit a destructor for a reference if type information is available.

2018-05-21 Thread Matthew Voss via Phabricator via cfe-commits
ormris added a comment.

Hmm... Thanks for these tips. I'll see what I can find.


Repository:
  rC Clang

https://reviews.llvm.org/D47044



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


[PATCH] D47150: [Clang Tablegen] Add llvm_unreachable() to getModifierName()

2018-05-21 Thread Mark Searles via Phabricator via cfe-commits
msearles updated this revision to Diff 147807.
msearles retitled this revision from "[Clang Tablegen] Add default case to 
getModifierName()" to "[Clang Tablegen]  Add llvm_unreachable() to 
getModifierName()".
msearles added a comment.

Ah, yes. Adding llvm_unreachable() is better. Done.


https://reviews.llvm.org/D47150

Files:
  utils/TableGen/ClangDiagnosticsEmitter.cpp


Index: utils/TableGen/ClangDiagnosticsEmitter.cpp
===
--- utils/TableGen/ClangDiagnosticsEmitter.cpp
+++ utils/TableGen/ClangDiagnosticsEmitter.cpp
@@ -492,6 +492,7 @@
   case MT_Unknown:
 llvm_unreachable("invalid modifier type");
   }
+  llvm_unreachable("invalid modifier type");
 }
 
 struct Piece {


Index: utils/TableGen/ClangDiagnosticsEmitter.cpp
===
--- utils/TableGen/ClangDiagnosticsEmitter.cpp
+++ utils/TableGen/ClangDiagnosticsEmitter.cpp
@@ -492,6 +492,7 @@
   case MT_Unknown:
 llvm_unreachable("invalid modifier type");
   }
+  llvm_unreachable("invalid modifier type");
 }
 
 struct Piece {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D47135: [analyzer][WIP] A checker for dangling string pointers in C++

2018-05-21 Thread Reka Kovacs via Phabricator via cfe-commits
rnkovacs added a comment.

Adding a preliminary test file.

F6259981: tests.cpp 


Repository:
  rC Clang

https://reviews.llvm.org/D47135



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


[PATCH] D47125: [X86] Remove masking from pternlog llvm intrinsics and use a select instruction instead.

2018-05-21 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon accepted this revision.
RKSimon added a comment.
This revision is now accepted and ready to land.

LGTM - I'd love to see constexpr arguments someday in C/C++ to avoid all of 
these macro shenanigans...


Repository:
  rC Clang

https://reviews.llvm.org/D47125



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


[PATCH] D47150: [Clang Tablegen] Add default case to getModifierName()

2018-05-21 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

Please instead add an `llvm_unreachable` outside the switch, so that we still 
get warnings on missing switch cases if an enumerator is added.


https://reviews.llvm.org/D47150



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


[PATCH] D47142: [x86] invpcid intrinsic

2018-05-21 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

Why do we need a feature flag for this in the first place? The MSVC model for 
most "instruction" intrinsics is that the exact instruction is emitted 
regardless of the feature enabled. The target attribute seems like it would get 
in the way of that.




Comment at: lib/Headers/intrin.h:196
+ */
 void __cdecl _invpcid(unsigned int, void *);
+#endif

craig.topper wrote:
> @rnk, what's the right thing to do here?
What problems does this redeclaration cause?


Repository:
  rC Clang

https://reviews.llvm.org/D47142



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


[PATCH] D47150: [Clang Tablegen] Add default case to getModifierName()

2018-05-21 Thread Mark Searles via Phabricator via cfe-commits
msearles created this revision.
msearles added reviewers: b-sumner, kzhuravl, EricWF, rjmccall.
Herald added subscribers: ioeric, ilya-biryukov.

  Fix internal build failure:
  
  ../../../ClangDiagnosticsEmitter.cpp -o ClangDiagnosticsEmitter.o
  ../../../ClangDiagnosticsEmitter.cpp: In function 'llvm::StringRef 
  {anonymous}::getModifierName({anonymous}::ModifierType)':
  ../../../ClangDiagnosticsEmitter.cpp:495:1: error: control reaches end of 
non-void function [-Werror=return-type]
  }
  ^
  
  Build failure triggered by git-svn-id: 
https://llvm.org/svn/llvm-project/cfe/trunk@332799 
91177308-0d34-0410-b5e6-96231b3b80d8


https://reviews.llvm.org/D47150

Files:
  utils/TableGen/ClangDiagnosticsEmitter.cpp


Index: utils/TableGen/ClangDiagnosticsEmitter.cpp
===
--- utils/TableGen/ClangDiagnosticsEmitter.cpp
+++ utils/TableGen/ClangDiagnosticsEmitter.cpp
@@ -490,6 +490,7 @@
   case MT_ObjCInstance:
 return "objcinstance";
   case MT_Unknown:
+  default:
 llvm_unreachable("invalid modifier type");
   }
 }


Index: utils/TableGen/ClangDiagnosticsEmitter.cpp
===
--- utils/TableGen/ClangDiagnosticsEmitter.cpp
+++ utils/TableGen/ClangDiagnosticsEmitter.cpp
@@ -490,6 +490,7 @@
   case MT_ObjCInstance:
 return "objcinstance";
   case MT_Unknown:
+  default:
 llvm_unreachable("invalid modifier type");
   }
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D47097: [WIP][DebugInfo] Preserve scope in auto generated StoreInst

2018-05-21 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment.

I think CodeGenFunction::EmitParmDecl is the right place to set up an 
ApplyDebugLocation instance. You can look at CodeGenFunction::EmitAutoVarInit 
for an example of how to use ApplyDebugLocation.




Comment at: test/CodeGen/debug-info-preserve-scope.c:1
+// RUN: %clang_cc1 -O0 -debug-info-kind=limited -emit-llvm -o - %s | FileCheck 
%s
+

The -O0 flag isn't needed here.



Comment at: test/CodeGen/debug-info-preserve-scope.c:11
+// CHECK: store i32 %b, i32* %b.addr, align 4, !dbg ![[dbgLocForStore:[0-9]+]]
+

To check that we set the right location on the store, you might add:
`; CHECK: ![[dbgLocForStore]] = !DILocation(line: 0`


Repository:
  rC Clang

https://reviews.llvm.org/D47097



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


r332852 - [OPENMP-SIMD] Fix PR37536: Fix definition of _OPENMP macro.

2018-05-21 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon May 21 09:40:32 2018
New Revision: 332852

URL: http://llvm.org/viewvc/llvm-project?rev=332852=rev
Log:
[OPENMP-SIMD] Fix PR37536: Fix definition of _OPENMP macro.

if `-fopenmp-simd` is specified alone, `_OPENMP` macro should not be
  defined. If `-fopenmp-simd` is specified along with the `-fopenmp`,
  `_OPENMP` macro should be defined with the value `201511`.

Modified:
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Frontend/InitPreprocessor.cpp
cfe/trunk/test/OpenMP/driver.c
cfe/trunk/test/OpenMP/predefined_macro.c

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=332852=332851=332852=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Mon May 21 09:40:32 2018
@@ -3989,6 +3989,8 @@ void Clang::ConstructJob(Compilation ,
   if (!Args.hasFlag(options::OPT_fopenmp_use_tls,
 options::OPT_fnoopenmp_use_tls, /*Default=*/true))
 CmdArgs.push_back("-fnoopenmp-use-tls");
+  Args.AddLastArg(CmdArgs, options::OPT_fopenmp_simd,
+  options::OPT_fno_openmp_simd);
   Args.AddAllArgs(CmdArgs, options::OPT_fopenmp_version_EQ);
 
   // When in OpenMP offloading mode with NVPTX target, forward

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=332852=332851=332852=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Mon May 21 09:40:32 2018
@@ -2562,9 +2562,10 @@ static void ParseLangArgs(LangOptions 
   // Check if -fopenmp is specified.
   Opts.OpenMP = Args.hasArg(options::OPT_fopenmp) ? 1 : 0;
   // Check if -fopenmp-simd is specified.
-  Opts.OpenMPSimd = !Opts.OpenMP && Args.hasFlag(options::OPT_fopenmp_simd,
- options::OPT_fno_openmp_simd,
- /*Default=*/false);
+  bool IsSimdSpecified =
+  Args.hasFlag(options::OPT_fopenmp_simd, options::OPT_fno_openmp_simd,
+   /*Default=*/false);
+  Opts.OpenMPSimd = !Opts.OpenMP && IsSimdSpecified;
   Opts.OpenMPUseTLS =
   Opts.OpenMP && !Args.hasArg(options::OPT_fnoopenmp_use_tls);
   Opts.OpenMPIsDevice =
@@ -2573,9 +2574,9 @@ static void ParseLangArgs(LangOptions 
   if (Opts.OpenMP || Opts.OpenMPSimd) {
 if (int Version =
 getLastArgIntValue(Args, OPT_fopenmp_version_EQ,
-   Opts.OpenMPSimd ? 45 : Opts.OpenMP, Diags))
+   IsSimdSpecified ? 45 : Opts.OpenMP, Diags))
   Opts.OpenMP = Version;
-else if (Opts.OpenMPSimd)
+else if (IsSimdSpecified)
   Opts.OpenMP = 45;
 // Provide diagnostic when a given target is not expected to be an OpenMP
 // device or host.

Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=332852=332851=332852=diff
==
--- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
+++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Mon May 21 09:40:32 2018
@@ -1027,19 +1027,21 @@ static void InitializePredefinedMacros(c
   //   macro name is defined to have the decimal value mm where
   //    and mm are the year and the month designations of the
   //   version of the OpenMP API that the implementation support.
-  switch (LangOpts.OpenMP) {
-  case 0:
-break;
-  case 40:
-Builder.defineMacro("_OPENMP", "201307");
-break;
-  case 45:
-Builder.defineMacro("_OPENMP", "201511");
-break;
-  default:
-// Default version is OpenMP 3.1, in Simd only mode - 4.5
-Builder.defineMacro("_OPENMP", LangOpts.OpenMPSimd ? "201511" : "201107");
-break;
+  if (!LangOpts.OpenMPSimd) {
+switch (LangOpts.OpenMP) {
+case 0:
+  break;
+case 40:
+  Builder.defineMacro("_OPENMP", "201307");
+  break;
+case 45:
+  Builder.defineMacro("_OPENMP", "201511");
+  break;
+default:
+  // Default version is OpenMP 3.1
+  Builder.defineMacro("_OPENMP", "201107");
+  break;
+}
   }
 
   // CUDA device path compilaton

Modified: cfe/trunk/test/OpenMP/driver.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/driver.c?rev=332852=332851=332852=diff
==
--- cfe/trunk/test/OpenMP/driver.c (original)
+++ cfe/trunk/test/OpenMP/driver.c Mon May 21 09:40:32 2018
@@ -18,19 +18,11 @@
 
 // CHECK-DEFAULT-VERSION: #define _OPENMP 

  1   2   >