r333062 - [X86] In the floating point max reduction intrinsics, negate infinity before feeding it to set1.

2018-05-22 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Tue May 22 22:51:52 2018
New Revision: 333062

URL: http://llvm.org/viewvc/llvm-project?rev=333062=rev
Log:
[X86] In the floating point max reduction intrinsics, negate infinity before 
feeding it to set1.

Previously we negated the whole vector after splatting infinity. But its better 
to negate the infinity before splatting. This generates IR with the negate 
already folded with the infinity constant.

Modified:
cfe/trunk/lib/Headers/avx512fintrin.h
cfe/trunk/test/CodeGen/avx512-reduceMinMaxIntrin.c

Modified: cfe/trunk/lib/Headers/avx512fintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=333062=333061=333062=diff
==
--- cfe/trunk/lib/Headers/avx512fintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512fintrin.h Tue May 22 22:51:52 2018
@@ -9956,7 +9956,7 @@ _mm512_mask_reduce_max_epu64(__mmask8 __
 
 static __inline__ double __DEFAULT_FN_ATTRS
 _mm512_mask_reduce_max_pd(__mmask8 __M, __m512d __V) {
-  _mm512_mask_reduce_maxMin_64bit(__V, -_mm512_set1_pd(__builtin_inf()),
+  _mm512_mask_reduce_maxMin_64bit(__V, _mm512_set1_pd(-__builtin_inf()),
   max_pd, d, f, pd, __M);
 }
 
@@ -10099,7 +10099,7 @@ _mm512_mask_reduce_max_epu32(__mmask16 _
 
 static __inline__ float __DEFAULT_FN_ATTRS
 _mm512_mask_reduce_max_ps(__mmask16 __M, __m512 __V) {
-  _mm512_mask_reduce_maxMin_32bit(__V,-_mm512_set1_ps(__builtin_inff()), 
max_ps, , f,
+  _mm512_mask_reduce_maxMin_32bit(__V,_mm512_set1_ps(-__builtin_inff()), 
max_ps, , f,
   ps, __M);
 }
 

Modified: cfe/trunk/test/CodeGen/avx512-reduceMinMaxIntrin.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx512-reduceMinMaxIntrin.c?rev=333062=333061=333062=diff
==
--- cfe/trunk/test/CodeGen/avx512-reduceMinMaxIntrin.c (original)
+++ cfe/trunk/test/CodeGen/avx512-reduceMinMaxIntrin.c Tue May 22 22:51:52 2018
@@ -564,7 +564,7 @@ unsigned long test_mm512_mask_reduce_max
 // CHECK:   store <8 x double> [[TMP1]], <8 x double>* [[__V_ADDR_I]], align 64
 // CHECK:   [[TMP2:%.*]] = load i8, i8* [[__M_ADDR_I]], align 1
 // CHECK:   [[TMP3:%.*]] = load <8 x double>, <8 x double>* [[__V_ADDR_I]], 
align 64
-// CHECK:   store double 0x7FF0, double* [[__W_ADDR_I_I]], align 8
+// CHECK:   store double 0xFFF0, double* [[__W_ADDR_I_I]], align 8
 // CHECK:   [[TMP4:%.*]] = load double, double* [[__W_ADDR_I_I]], align 8
 // CHECK:   [[VECINIT_I_I:%.*]] = insertelement <8 x double> undef, double 
[[TMP4]], i32 0
 // CHECK:   [[TMP5:%.*]] = load double, double* [[__W_ADDR_I_I]], align 8
@@ -583,9 +583,8 @@ unsigned long test_mm512_mask_reduce_max
 // CHECK:   [[VECINIT7_I_I:%.*]] = insertelement <8 x double> 
[[VECINIT6_I_I]], double [[TMP11]], i32 7
 // CHECK:   store <8 x double> [[VECINIT7_I_I]], <8 x double>* 
[[_COMPOUNDLITERAL_I_I]], align 64
 // CHECK:   [[TMP12:%.*]] = load <8 x double>, <8 x double>* 
[[_COMPOUNDLITERAL_I_I]], align 64
-// CHECK:   [[SUB_I:%.*]] = fsub <8 x double> , [[TMP12]]
 // CHECK:   [[TMP13:%.*]] = bitcast i8 [[TMP2]] to <8 x i1>
-// CHECK:   [[TMP14:%.*]] = select <8 x i1> [[TMP13]], <8 x double> [[TMP3]], 
<8 x double> [[SUB_I]]
+// CHECK:   [[TMP14:%.*]] = select <8 x i1> [[TMP13]], <8 x double> [[TMP3]], 
<8 x double> [[TMP12]]
 // CHECK:   store <8 x double> [[TMP14]], <8 x double>* [[__V_ADDR_I]], align 
64
 // CHECK:   [[TMP15:%.*]] = load <8 x double>, <8 x double>* [[__V_ADDR_I]], 
align 64
 // CHECK:   [[TMP16:%.*]] = load <8 x double>, <8 x double>* [[__V_ADDR_I]], 
align 64
@@ -1859,7 +1858,7 @@ unsigned int test_mm512_mask_reduce_max_
 // CHECK:   store <16 x float> [[TMP1]], <16 x float>* [[__V_ADDR_I]], align 64
 // CHECK:   [[TMP2:%.*]] = load i16, i16* [[__M_ADDR_I]], align 2
 // CHECK:   [[TMP3:%.*]] = load <16 x float>, <16 x float>* [[__V_ADDR_I]], 
align 64
-// CHECK:   store float 0x7FF0, float* [[__W_ADDR_I_I]], align 4
+// CHECK:   store float 0xFFF0, float* [[__W_ADDR_I_I]], align 4
 // CHECK:   [[TMP4:%.*]] = load float, float* [[__W_ADDR_I_I]], align 4
 // CHECK:   [[VECINIT_I_I:%.*]] = insertelement <16 x float> undef, float 
[[TMP4]], i32 0
 // CHECK:   [[TMP5:%.*]] = load float, float* [[__W_ADDR_I_I]], align 4
@@ -1894,9 +1893,8 @@ unsigned int test_mm512_mask_reduce_max_
 // CHECK:   [[VECINIT15_I_I:%.*]] = insertelement <16 x float> 
[[VECINIT14_I_I]], float [[TMP19]], i32 15
 // CHECK:   store <16 x float> [[VECINIT15_I_I]], <16 x float>* 
[[_COMPOUNDLITERAL_I_I]], align 64
 // CHECK:   [[TMP20:%.*]] = load <16 x float>, <16 x float>* 
[[_COMPOUNDLITERAL_I_I]], align 64
-// CHECK:   [[SUB_I:%.*]] = fsub <16 x float> , [[TMP20]]
 // CHECK:   [[TMP21:%.*]] = bitcast i16 [[TMP2]] to <16 x i1>
-// CHECK:   [[TMP22:%.*]] = select <16 x i1> [[TMP21]], <16 x float> [[TMP3]], 
<16 x 

[PATCH] D47247: Fix unaligned memory access when reading INPUT_FILE_OFFSETS data

2018-05-22 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor created this revision.
teemperor added reviewers: rsmith, v.g.vassilev.

The blob data is unaligned, so we also should read it as such. Should fix the 
random failures with the sanitizer builds.


Repository:
  rC Clang

https://reviews.llvm.org/D47247

Files:
  lib/Serialization/ASTReader.cpp


Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -4811,7 +4811,8 @@
 
   unsigned NumInputFiles = Record[0];
   unsigned NumUserFiles = Record[1];
-  const uint64_t *InputFileOffs = (const uint64_t *)Blob.data();
+  const llvm::support::unaligned_uint64_t *InputFileOffs =
+  (const llvm::support::unaligned_uint64_t *)Blob.data();
   for (unsigned I = 0; I != NumInputFiles; ++I) {
 // Go find this input file.
 bool isSystemFile = I >= NumUserFiles;


Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -4811,7 +4811,8 @@
 
   unsigned NumInputFiles = Record[0];
   unsigned NumUserFiles = Record[1];
-  const uint64_t *InputFileOffs = (const uint64_t *)Blob.data();
+  const llvm::support::unaligned_uint64_t *InputFileOffs =
+  (const llvm::support::unaligned_uint64_t *)Blob.data();
   for (unsigned I = 0; I != NumInputFiles; ++I) {
 // Go find this input file.
 bool isSystemFile = I >= NumUserFiles;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D45015: [Preprocessor] Allow libc++ to detect when aligned allocation is unavailable.

2018-05-22 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

In https://reviews.llvm.org/D45015#1105314, @rsmith wrote:

> Hmm, perhaps our strategy for handling aligned allocation on Darwin should be 
> revisited. We shouldn't be defining `__cpp_aligned_allocation` if we believe 
> it doesn't work -- that will break code that uses aligned allocation where 
> available and falls back to something else where it's unavailable.
>
> @ahatanak: how about this:
>
> - Change the driver to not pass `-faligned-alloc-unavailable` if an explicit 
> `-faligned-allocation` or `-fno-aligned-allocation` flag is given; update 
> Clang's note to suggest explicitly passing `-faligned-allocation` rather than 
> `-Wno-aligned-alloc-unavailable` if the user provides their own aligned 
> allocation function.
> - Change `-faligned-alloc-unavailable` so that it does not define 
> `__cpp_aligned_allocation`.
> - Change Sema's handling of the "aligned allocation unavailable" case so 
> that, after warning on selecting an aligned allocation function, it then 
> removes those functions from the candidate set and tries again.
>
>   That is: on old Darwin, we should not define `__cpp_aligned_allocation` 
> (even in C++17), produce the "no aligned allocation support" warning in C++17 
> mode, and then not try to call the aligned allocation function. But if 
> `-faligned-allocation` or `-fno-aligned-allocation` is specified explicitly, 
> then the user knows what they're doing and they get no warning.


I talked with @vsapsai today and we think this looks like a better idea.

A couple of questions:

- Currently clang errors out when aligned operator new is selected but the OS's 
version is too old to support it. What's the reason we want to change this now 
to be a warning rather than an error?

- So clang no longer needs to define macro `__ALIGNED_ALLOCATION_UNAVAILABLE__` 
and libc++ will use `__cpp_aligned_new` (I think you meant `__cpp_aligned_new`, 
not `__cpp_aligned_allocation`?) to determine whether aligned allocation 
functions should be defined or made available in the header?


Repository:
  rC Clang

https://reviews.llvm.org/D45015



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


[PATCH] D47067: Update NRVO logic to support early return

2018-05-22 Thread Taiju Tsuiki via Phabricator via cfe-commits
tzik added inline comments.



Comment at: lib/Sema/SemaDecl.cpp:12760
   // to deduce an implicit return type.
-  if (FD->getReturnType()->isRecordType() &&
-  (!getLangOpts().CPlusPlus || !FD->isDependentContext()))
+  if (!FD->getReturnType()->isScalarType())
 computeNRVO(Body, getCurFunction());

Quuxplusone wrote:
> What is the purpose of this change?
> If it's "no functional change" it should be done separately IMHO; if it is 
> supposed to change codegen, then it needs some codegen tests. (From looking 
> at the code: maybe this affects codegen on functions that return member 
> function pointers by value?)
I think the previous implementation was incorrect.
Though computeNRVO clears ReturnStmt::NRVOCandidate when the corresponding 
variable is not NRVO variable, CGStmt checks both of ReturnStmt::NRVOCandidate 
and VarDecl::NRVOVariable anyway.
So, computeNRVO took no effect in the previous code, and the absence of 
computeNRVO here on function templates did not matter.
Note that there was no chance to call computeNRVO on function template 
elsewhere too.

OTOH in the new implementation, computeNRVO is necessary, and its absence on 
function templates matters.

We can remove computeNRVO here separately as a NFC patch and readd the new impl 
to the same place, but it's probably less readable, IMO.



Comment at: test/CodeGenCXX/nrvo.cpp:139
   }
-  // FIXME: we should NRVO this variable too.
-  X x;
+  // CHECK: tail call {{.*}} @_ZN1XC1ERKS_
   return x;

Quuxplusone wrote:
> You've changed this function from testing one thing with a FIXME, to testing 
> a completely different thing.  Could you add your new code as a new function, 
> and leave the old FIXME alone until it's fixed?
> Alternatively, if your patch actually fixes the FIXME, could you just replace 
> the FIXME comment with a CHECK and leave the rest of this function alone?
My patch fixes the FIXME.
However, on the resulting code of NRVOing,
```
X y;
return y;
```
and
```
X x;
return x;
```
get to the same code and unified. And, the function is simplified as
```
X test3(bool B) {
  X x;
  return x;
}
```
without the if statement.
So, there will be nothing to CHECK left here if I leave the code as-is. I think 
that does not fit to the test scenario.



Comment at: test/CodeGenCXX/nrvo.cpp:254
+  T t;
+  return t;
+}

Quuxplusone wrote:
> Just for my own curiosity: this new test case is surely unaffected by this 
> patch, right?
Hm, this is not so important anymore. This was to check if NRVO is working with 
function templates on the existing code, as computeNRVO was not called on them. 
And also this covered a regression in a draft patch, that didn't work on 
function templates.


Repository:
  rC Clang

https://reviews.llvm.org/D47067



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


[PATCH] D47007: [analyzer] CStringChecker fix for strlcpy when no bytes are copied to the dest buffer

2018-05-22 Thread David CARLIER via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC333060: [analyzer] CStringChecker fix for strlcpy when no 
bytes are copied to the dest… (authored by devnexen, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D47007

Files:
  lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  test/Analysis/bsd-string.c


Index: lib/StaticAnalyzer/Checkers/CStringChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -1652,7 +1652,11 @@
 
 // If the size is known to be zero, we're done.
 if (StateZeroSize && !StateNonZeroSize) {
-  StateZeroSize = StateZeroSize->BindExpr(CE, LCtx, DstVal);
+  if (returnPtr) {
+StateZeroSize = StateZeroSize->BindExpr(CE, LCtx, DstVal);
+  } else {
+StateZeroSize = StateZeroSize->BindExpr(CE, LCtx, *lenValNL);
+  }
   C.addTransition(StateZeroSize);
   return;
 }
Index: test/Analysis/bsd-string.c
===
--- test/Analysis/bsd-string.c
+++ test/Analysis/bsd-string.c
@@ -38,3 +38,8 @@
   size_t len = strlcat(buf, "defg", 4);
   clang_analyzer_eval(len == 7); // expected-warning{{TRUE}}
 }
+
+int f7() {
+  char buf[8];
+  return strlcpy(buf, "1234567", 0); // no-crash
+}


Index: lib/StaticAnalyzer/Checkers/CStringChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -1652,7 +1652,11 @@
 
 // If the size is known to be zero, we're done.
 if (StateZeroSize && !StateNonZeroSize) {
-  StateZeroSize = StateZeroSize->BindExpr(CE, LCtx, DstVal);
+  if (returnPtr) {
+StateZeroSize = StateZeroSize->BindExpr(CE, LCtx, DstVal);
+  } else {
+StateZeroSize = StateZeroSize->BindExpr(CE, LCtx, *lenValNL);
+  }
   C.addTransition(StateZeroSize);
   return;
 }
Index: test/Analysis/bsd-string.c
===
--- test/Analysis/bsd-string.c
+++ test/Analysis/bsd-string.c
@@ -38,3 +38,8 @@
   size_t len = strlcat(buf, "defg", 4);
   clang_analyzer_eval(len == 7); // expected-warning{{TRUE}}
 }
+
+int f7() {
+  char buf[8];
+  return strlcpy(buf, "1234567", 0); // no-crash
+}
___
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-22 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

There are at least three good reasons to make sure this can enabled/disabled by 
a flag:

- We have to anticipate that introducing new keywords will cause some 
compatibility problems.  New language standards that introduce new keywords can 
be disabled using `-std=`.  We shouldn't let this bypass 
that just because it's an out-of-band addition to the base language.
- It seems likely to me that this feature will be target-restricted.
- It seems plausible to me that development of this feature might continue past 
the Clang 7 branch date, and we shouldn't release a compiler with 
significantly-incomplete features on by default.

That said, when it's ready, I think it should probably be on by default on the 
targets that support it.


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] D46084: [Fixed Point Arithmetic] Addition of the Fixed Point _Accum type

2018-05-22 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

This is on by default for any version of C? AFAICK `_Accum` isn't on the C17 
draft that I have, I'd expect to have to specify a command-line flag pertaining 
to TR 18037 to get this. At a minimum I'd be OK having it with the GNU variant 
of C, but not the `__ANSI_C__` one.


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] D47103: Implement strip.invariant.group

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

The changes to Clang generally seem reasonable, but I think you should split 
them into a separate commit from the commit that adds the intrinsic itself.




Comment at: clang/lib/CodeGen/CGExpr.cpp:3858
+}
+  }
+

Please add a comment explaining why this is necessary.  (I'm actually not sure 
why it is, because surely the invariant groups we generate don't contain 
assumptions about memory from fields, right?)



Comment at: clang/lib/CodeGen/CGExprScalar.cpp:1626
+  Src = Builder.CreateStripInvariantGroup(Src);
+}
+

Again, comment.



Comment at: clang/lib/CodeGen/CGExprScalar.cpp:1767
+if (CGF.CGM.getCodeGenOpts().StrictVTablePointers)
+  return Builder.CreateLaunderInvariantGroup(IntToPtr);
+

I think assigning to IntToPtr would be clearer here.  You're changing the value 
returned, not introducing a reason to early-exit.

And a comment, please, on all of these cases.


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


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

2018-05-22 Thread John McCall via Phabricator via cfe-commits
rjmccall added a reviewer: akyrtzi.
rjmccall added a comment.

CC: Argyrios for the USR question.


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] D47108: [CodeGenCXX] Add -fforce-emit-vtables

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

I thought we already had places in Sema that marked inline virtual methods as 
used, instantiated templates, etc. for devirtualization purposes when 
optimization was enabled.  Did we rip that out?

The problem we've had over and over with devirtualization is that we have to 
emit a perfect v-table because LLVM lacks a lot of the key vocabulary for 
talking about incomplete information.  For example, if something weird happens 
and we don't have a definition for an inline virtual method, ideally we'd just 
say "well, you can't devirtualize this slot", then try to fix that as 
incremental progress; but instead we have to get everything just right or else 
disable the whole optimization.  Note that vague-linkage v-tables mean that 
we'd also need to be able to say things like "there is an object with a 
definition that looks like this, but its symbol is not available and you can't 
emit it yourself".


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


[libcxx] r333058 - Mark more bits of P0433 as complete.

2018-05-22 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Tue May 22 20:22:59 2018
New Revision: 333058

URL: http://llvm.org/viewvc/llvm-project?rev=333058=rev
Log:
Mark more bits of P0433 as complete.


Modified:
libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/www/cxx1z_status.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=333058=333057=333058=diff
==
--- libcxx/trunk/www/cxx1z_status.html (original)
+++ libcxx/trunk/www/cxx1z_status.html Tue May 22 20:22:59 2018
@@ -172,7 +172,7 @@
   
 
 The parts of P0607 that are not done are the regex bits.
-So far, only the string part of P0433 has been 
implemented.
+So far, only the string, sequence containers, container adaptors 
and regex portions of P0433 have been implemented.
 
 [ Note: "Nothing to do" means that no library changes were needed to 
implement this change -- end note]
 
@@ -504,7 +504,7 @@
 
   
 
-  Last Updated: 8-Mar-2018
+  Last Updated: 22-May-2018
 
 
 


___
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-22 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added subscribers: echristo, dblaikie, rjmccall.
rsmith added inline comments.



Comment at: include/clang/Basic/DiagnosticCommonKinds.td:172
+def err_fixed_point_only_allowed_in_c : Error<
+  "Fixed point types are only allowed in C">;
 

Diagnostics should not be capitalized. Also, we generally allow conforming C 
extensions to be used in other languages unless there is a really good reason 
not to.



Comment at: lib/AST/ASTContext.cpp:6261
+case BuiltinType::ULongAccum:
+  llvm_unreachable("No ObjC encoding for fixed point types");
+

`llvm_unreachable` should only be used for cases where you believe the 
situation to be impossible. I would add these cases to the `return ' ';` case 
above (for `Float16` / `Float128` / `Half`) for now.



Comment at: lib/AST/ExprConstant.cpp:7323-7325
+case BuiltinType::UShortAccum:
+case BuiltinType::UAccum:
+case BuiltinType::ULongAccum:

Have you checked what value GCC uses for these? Using `integer_type_class` for 
a non-integer value seems very strange to me, but then they probably are 
*passed* as integers, so maybe it's correct?



Comment at: lib/AST/ItaniumMangle.cpp:2552
+  case BuiltinType::ULongAccum:
+llvm_unreachable("Fixed point types are disabled for c++");
   case BuiltinType::Half:

Please check what GCC uses to mangle these, and follow suit; if GCC doesn't 
have a mangling, you can use a vendor mangling (`u6_Accum`) or produce an error 
for now, but please open an issue at 
https://github.com/itanium-cxx-abi/cxx-abi/ to pick a real mangling.



Comment at: lib/CodeGen/CGDebugInfo.cpp:678-681
+  case BuiltinType::UShortAccum:
+  case BuiltinType::UAccum:
+  case BuiltinType::ULongAccum:
 Encoding = llvm::dwarf::DW_ATE_unsigned;

@echristo @dblaikie Is this appropriate?



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

jakehehrlich wrote:
> Add TODO for accum types using a different drawf type.
I think this TODO was added to the wrong file. Should it be in CGDebugInfo?



Comment at: lib/CodeGen/ItaniumCXXABI.cpp:2684
 
   // Types added here must also be added to EmitFundamentalRTTIDescriptors.
   switch (Ty->getKind()) {

Note this comment :)



Comment at: lib/Index/USRGeneration.cpp:691
+case BuiltinType::ULongAccum:
+  llvm_unreachable("No USR name mangling for fixed point types.");
 case BuiltinType::Float16:

leonardchan wrote:
> phosek wrote:
> > We need some solution for fixed point types.
> Added character ~ to indicate fixed point type followed by string detailing 
> the type. I have not added a test to it because logically, I do not think we 
> will ever reach that point. This logic is implemented in the VisitType 
> method, which mostly gets called by visitors to c++ nodes like 
> VisitTemplateParameterList, but we have disabled the use of fixed point types 
> in c++. VisitType does get called in VisitFunctionDecl but the function exits 
> early since we are not reading c++ (line lib/Index/USRGeneration.cpp:238).
@rjmccall Is this an acceptable USR encoding? (Is our USR encoding scheme 
documented anywhere?)



Comment at: lib/Sema/SemaType.cpp:1390-1394
+if (S.getLangOpts().CPlusPlus) {
+  S.Diag(DS.getTypeSpecTypeLoc(), diag::err_fixed_point_only_allowed_in_c);
+  Result = Context.ShortAccumTy;
+  break;
+}

As noted earlier, we should not have such a restriction.



Comment at: lib/Sema/SemaType.cpp:1424
+case DeclSpec::TSW_longlong:
+  // TODO: Replace with diag
+  llvm_unreachable("Unable to specify long long as _Accum width");

No need for a diagnostic as this is already caught elsewhere.


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] D46084: [Fixed Point Arithmetic] Addition of the Fixed Point _Accum type

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

pulled changes from source tree


Repository:
  rC Clang

https://reviews.llvm.org/D46084

Files:
  include/clang-c/Index.h
  include/clang/AST/ASTContext.h
  include/clang/AST/BuiltinTypes.def
  include/clang/Basic/DiagnosticCommonKinds.td
  include/clang/Basic/Specifiers.h
  include/clang/Basic/TokenKinds.def
  include/clang/Sema/DeclSpec.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/ASTContext.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/MicrosoftMangle.cpp
  lib/AST/NSAPI.cpp
  lib/AST/Type.cpp
  lib/AST/TypeLoc.cpp
  lib/Analysis/PrintfFormatString.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CodeGenTypes.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/Index/USRGeneration.cpp
  lib/Parse/ParseDecl.cpp
  lib/Sema/DeclSpec.cpp
  lib/Sema/SemaTemplateVariadic.cpp
  lib/Sema/SemaType.cpp
  lib/Serialization/ASTCommon.cpp
  lib/Serialization/ASTReader.cpp
  test/Frontend/accum.c
  test/Frontend/accum_errors.c
  test/Frontend/accum_errors.cpp
  tools/libclang/CXType.cpp

Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -53,6 +53,12 @@
 BTCASE(Float);
 BTCASE(Double);
 BTCASE(LongDouble);
+BTCASE(ShortAccum);
+BTCASE(Accum);
+BTCASE(LongAccum);
+BTCASE(UShortAccum);
+BTCASE(UAccum);
+BTCASE(ULongAccum);
 BTCASE(Float16);
 BTCASE(Float128);
 BTCASE(NullPtr);
@@ -546,6 +552,12 @@
 TKIND(Float);
 TKIND(Double);
 TKIND(LongDouble);
+TKIND(ShortAccum);
+TKIND(Accum);
+TKIND(LongAccum);
+TKIND(UShortAccum);
+TKIND(UAccum);
+TKIND(ULongAccum);
 TKIND(Float16);
 TKIND(Float128);
 TKIND(NullPtr);
Index: test/Frontend/accum_errors.cpp
===
--- /dev/null
+++ test/Frontend/accum_errors.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -x c++ %s -verify
+
+// Name namgling is not provided for fixed point types in c++
+
+signed short _Accum s_short_accum;  // expected-error{{Fixed point types are only allowed in C}}
+signed _Accum s_accum;  // expected-error{{Fixed point types are only allowed in C}}
+signed long _Accum s_long_accum;  // expected-error{{Fixed point types are only allowed in C}}
+unsigned short _Accum u_short_accum;  // expected-error{{Fixed point types are only allowed in C}}
+unsigned _Accum u_accum;  // expected-error{{Fixed point types are only allowed in C}}
+unsigned long _Accum u_long_accum;  // expected-error{{Fixed point types are only allowed in C}}
+
+short _Accum short_accum;  // expected-error{{Fixed point types are only allowed in C}}
+_Accum accum; // expected-error{{Fixed point types are only allowed in C}}
+long _Accum long_accum;  // expected-error{{Fixed point types are only allowed in C}}
Index: test/Frontend/accum_errors.c
===
--- /dev/null
+++ test/Frontend/accum_errors.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -x c -fsyntax-only -verify -pedantic %s
+
+long long _Accum longlong_accum;  // expected-error{{'long long _Accum' is invalid}}
+unsigned long long _Accum u_longlong_accum;  // expected-error{{'long long _Accum' is invalid}}
Index: test/Frontend/accum.c
===
--- /dev/null
+++ test/Frontend/accum.c
@@ -0,0 +1,26 @@
+// RUN: %clang -cc1 -x c -ast-dump %s | FileCheck %s --strict-whitespace
+
+/*  Various contexts where type _Accum can appear. */
+
+// Primary fixed point types
+signed short _Accum s_short_accum;
+signed _Accum s_accum;
+signed long _Accum s_long_accum;
+unsigned short _Accum u_short_accum;
+unsigned _Accum u_accum;
+unsigned long _Accum u_long_accum;
+
+// Aliased fixed point types
+short _Accum short_accum;
+_Accum accum;
+long _Accum long_accum;
+
+// CHECK:  |-VarDecl {{.*}} s_short_accum 'short _Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} s_accum '_Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} s_long_accum 'long _Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} u_short_accum 'unsigned short _Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} u_accum 'unsigned _Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} u_long_accum 'unsigned long _Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} short_accum 'short _Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} accum '_Accum'
+// CHECK-NEXT: `-VarDecl {{.*}} long_accum 'long _Accum'
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -6818,6 +6818,24 @@
 case PREDEF_TYPE_LONGDOUBLE_ID:
   T = Context.LongDoubleTy;
   break;
+case PREDEF_TYPE_SHORT_ACCUM_ID:
+  T = Context.ShortAccumTy;
+  break;
+case PREDEF_TYPE_ACCUM_ID:
+  T = Context.AccumTy;
+  break;
+case PREDEF_TYPE_LONG_ACCUM_ID:
+  T = 

[PATCH] D45898: [SemaCXX] Mark destructor as referenced

2018-05-22 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

In https://reviews.llvm.org/D45898#1104025, @rsmith wrote:

> As it happens, the C++ committee fixed the language wording hole here very 
> recently. The new rule can be found here: http://wg21.link/p0968r0#2227
>  In summary: we should to consider the destructor for all elements of the 
> aggregate to be potentially-invoked.


It doesn't mean that clang should reject the following code, does it?

  // This should compile fine as long as 'Deleted7d d7d' is commented out.
  struct DeletedDtor { ~DeletedDtor() = delete; };
  struct Deleted7d { DeletedDtor a = {}; }; 
  //Deleted7d d7d;

I tried making a helper function out of the code in SK_UserConversion and using 
it in "case SK_ListInitialization". That doesn't seem to work because 
DiagnoseUseOfDecl rejects the code (with error message "error: attempt to use a 
deleted function") above even though the destructor isn't needed (because 'd7d' 
is commented out), so I guess that check should be done in another place.


Repository:
  rC Clang

https://reviews.llvm.org/D45898



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


[libcxx] r333050 - Implement deduction guides for basic_regex

2018-05-22 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Tue May 22 18:57:02 2018
New Revision: 333050

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

Added:
libcxx/trunk/test/std/re/re.regex/re.regex.construct/deduct.fail.cpp
libcxx/trunk/test/std/re/re.regex/re.regex.construct/deduct.pass.cpp
Modified:
libcxx/trunk/include/regex

Modified: libcxx/trunk/include/regex
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/regex?rev=333050=333049=333050=diff
==
--- libcxx/trunk/include/regex (original)
+++ libcxx/trunk/include/regex Tue May 22 18:57:02 2018
@@ -192,6 +192,11 @@ public:
 void swap(basic_regex&);
 };
 
+template
+basic_regex(ForwardIterator, ForwardIterator,
+regex_constants::syntax_option_type = regex_constants::ECMAScript)
+-> basic_regex::value_type>; // 
C++17
+
 typedef basic_regexregex;
 typedef basic_regex wregex;
 
@@ -2922,6 +2927,15 @@ private:
 template  friend class __lookahead;
 };
 
+#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
+template ::value, nullptr_t>::type
+>
+basic_regex(_ForwardIterator, _ForwardIterator,
+regex_constants::syntax_option_type = regex_constants::ECMAScript)
+-> basic_regex::value_type>;
+#endif
+
 template 
 const regex_constants::syntax_option_type basic_regex<_CharT, 
_Traits>::icase;
 template 

Added: libcxx/trunk/test/std/re/re.regex/re.regex.construct/deduct.fail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.regex/re.regex.construct/deduct.fail.cpp?rev=333050=auto
==
--- libcxx/trunk/test/std/re/re.regex/re.regex.construct/deduct.fail.cpp (added)
+++ libcxx/trunk/test/std/re/re.regex/re.regex.construct/deduct.fail.cpp Tue 
May 22 18:57:02 2018
@@ -0,0 +1,45 @@
+//===--===//
+//
+// 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 
+#include 
+
+
+int main()
+{  
+//  Test the explicit deduction guides
+{
+// basic_regex(ForwardIterator, ForwardIterator)
+//   is not an iterator
+std::basic_regex re(23, 34);   // expected-error {{no viable constructor 
or deduction guide for deduction of template arguments of 'basic_regex'}}
+}
+
+{
+// basic_regex(ForwardIterator, ForwardIterator, flag_type)
+//   is not an iterator
+std::basic_regex re(23.0, 34.0, std::regex_constants::basic);   // 
expected-error {{no viable constructor or deduction guide for deduction of 
template arguments of 'basic_regex'}}
+}
+
+//  Test the implicit deduction guides
+
+}

Added: libcxx/trunk/test/std/re/re.regex/re.regex.construct/deduct.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/re/re.regex/re.regex.construct/deduct.pass.cpp?rev=333050=auto
==
--- libcxx/trunk/test/std/re/re.regex/re.regex.construct/deduct.pass.cpp (added)
+++ libcxx/trunk/test/std/re/re.regex/re.regex.construct/deduct.pass.cpp Tue 
May 22 18:57:02 2018
@@ -0,0 +1,137 @@
+//===--===//
+//
+// 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
+// basic_regex(ForwardIterator, ForwardIterator,
+// regex_constants::syntax_option_type = 
regex_constants::ECMAScript)
+// -> basic_regex::value_type>;
+
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+#include "test_iterators.h"
+#include "test_allocator.h"
+
+using namespace std::literals;
+
+struct A {};
+
+int main()
+{
+  
+//  Test the explicit deduction guides
+{
+//  basic_regex(ForwardIterator, ForwardIterator)
+std::string s1("\\(a\\)");
+std::basic_regex re(s1.begin(), s1.end());
+
+static_assert(std::is_same_v, "");
+assert(re.flags() == std::regex_constants::ECMAScript);
+assert(re.mark_count() == 0);
+}
+
+{
+std::wstring s1(L"\\(a\\)");
+

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

2018-05-22 Thread Douglas Yung via Phabricator via cfe-commits
dyung added a comment.

LGTM


Repository:
  rC Clang

https://reviews.llvm.org/D47175



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


r333046 - [AST][ObjC] Print implicit property expression that only has a setter without crashing

2018-05-22 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Tue May 22 17:52:20 2018
New Revision: 333046

URL: http://llvm.org/viewvc/llvm-project?rev=333046=rev
Log:
[AST][ObjC] Print implicit property expression that only has a setter without 
crashing

rdar://40447209

Modified:
cfe/trunk/include/clang/Basic/IdentifierTable.h
cfe/trunk/lib/AST/StmtPrinter.cpp
cfe/trunk/lib/Basic/IdentifierTable.cpp
cfe/trunk/test/Misc/ast-print-objectivec.m

Modified: cfe/trunk/include/clang/Basic/IdentifierTable.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/IdentifierTable.h?rev=333046=333045=333046=diff
==
--- cfe/trunk/include/clang/Basic/IdentifierTable.h (original)
+++ cfe/trunk/include/clang/Basic/IdentifierTable.h Tue May 22 17:52:20 2018
@@ -825,6 +825,9 @@ public:
   static Selector constructSetterSelector(IdentifierTable ,
   SelectorTable ,
   const IdentifierInfo *Name);
+
+  /// Return the property name for the given setter selector.
+  static std::string getPropertyNameFromSetterSelector(Selector Sel);
 };
 
 /// DeclarationNameExtra - Common base of the MultiKeywordSelector,

Modified: cfe/trunk/lib/AST/StmtPrinter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtPrinter.cpp?rev=333046=333045=333046=diff
==
--- cfe/trunk/lib/AST/StmtPrinter.cpp (original)
+++ cfe/trunk/lib/AST/StmtPrinter.cpp Tue May 22 17:52:20 2018
@@ -1406,9 +1406,13 @@ void StmtPrinter::VisitObjCPropertyRefEx
 OS << Node->getClassReceiver()->getName() << ".";
   }
 
-  if (Node->isImplicitProperty())
-Node->getImplicitPropertyGetter()->getSelector().print(OS);
-  else
+  if (Node->isImplicitProperty()) {
+if (const auto *Getter = Node->getImplicitPropertyGetter())
+  Getter->getSelector().print(OS);
+else
+  OS << SelectorTable::getPropertyNameFromSetterSelector(
+  Node->getImplicitPropertySetter()->getSelector());
+  } else
 OS << Node->getExplicitProperty()->getName();
 }
 

Modified: cfe/trunk/lib/Basic/IdentifierTable.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/IdentifierTable.cpp?rev=333046=333045=333046=diff
==
--- cfe/trunk/lib/Basic/IdentifierTable.cpp (original)
+++ cfe/trunk/lib/Basic/IdentifierTable.cpp Tue May 22 17:52:20 2018
@@ -645,6 +645,12 @@ SelectorTable::constructSetterSelector(I
   return SelTable.getUnarySelector(SetterName);
 }
 
+std::string SelectorTable::getPropertyNameFromSetterSelector(Selector Sel) {
+  StringRef Name = Sel.getNameForSlot(0);
+  assert(Name.startswith("set") && "invalid setter name");
+  return (Twine(toLowercase(Name[3])) + Name.drop_front(4)).str();
+}
+
 size_t SelectorTable::getTotalMemory() const {
   SelectorTableImpl  = getSelectorTableImpl(Impl);
   return SelTabImpl.Allocator.getTotalMemory();

Modified: cfe/trunk/test/Misc/ast-print-objectivec.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/ast-print-objectivec.m?rev=333046=333045=333046=diff
==
--- cfe/trunk/test/Misc/ast-print-objectivec.m (original)
+++ cfe/trunk/test/Misc/ast-print-objectivec.m Tue May 22 17:52:20 2018
@@ -50,3 +50,13 @@ struct __attribute__((objc_bridge_relate
 
 // CHECK: @class C1;
 // CHECK: struct __attribute__((objc_bridge_related(C1, , ))) S1;
+
+@interface ImplicitPropertyWithSetterOnly
+
+- (void)setX:(int)x;
+
+@end
+
+void printImplicitPropertyWithSetterOnly(ImplicitPropertyWithSetterOnly *x) {
+  x.x = 313; // CHECK: x.x = 313;
+}


___
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-22 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC333044: Use zeroinitializer for (trailing zero portion of) 
large array initializers (authored by rsmith, committed by ).

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/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,35 @@
   // 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}};
+  char data_8[1000 * 1000 * 1000] = {};
+  int (&_9)[1000 * 1000 * 1000] = {0};
+  unsigned char data_10[1024 * 1024 * 1024 * 2u] = { 1 };
+  unsigned char data_11[1024 * 1024 * 1024 * 2u] = { One };
+  unsigned char data_12[1024][1024][1024] = {{{1}}};
+
+  // This variable must be initialized elementwise.
+  Filler data_e1[1024] = {};
+  // CHECK: getelementptr inbounds {{.*}} @_ZN8ZeroInit7data_e1E
+}
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/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/CodeGen/CGExprConstant.cpp
===
--- lib/CodeGen/CGExprConstant.cpp
+++ lib/CodeGen/CGExprConstant.cpp
@@ -635,6 +635,52 @@
   return ConstantAddress(GV, Align);
 }
 
+static llvm::Constant *
+EmitArrayConstant(llvm::ArrayType *PreferredArrayType,
+  llvm::Type *CommonElementType, unsigned ArrayBound,
+  SmallVectorImpl ,
+  llvm::Constant *Filler) {
+  // Figure out how long the initial prefix of non-zero elements is.
+  unsigned NonzeroLength = ArrayBound;
+  if (Elements.size() < NonzeroLength && Filler->isNullValue())
+NonzeroLength = Elements.size();
+  if (NonzeroLength == Elements.size()) {
+while (NonzeroLength > 0 && Elements[NonzeroLength - 1]->isNullValue())
+  --NonzeroLength;
+  }
+
+  if (NonzeroLength == 0)
+return llvm::ConstantAggregateZero::get(PreferredArrayType);
+
+  // If there's not many trailing zero elements, just emit an array
+  // constant.
+  if (NonzeroLength + 8 >= ArrayBound && CommonElementType) {
+Elements.resize(ArrayBound, Filler);
+return llvm::ConstantArray::get(
+llvm::ArrayType::get(CommonElementType, ArrayBound), Elements);
+  }
+
+  // Add a zeroinitializer array filler if we have trailing zeroes.
+  if (unsigned TrailingZeroes = ArrayBound - NonzeroLength) {
+assert(Elements.size() >= 

r333044 - Use zeroinitializer for (trailing zero portion of) large array initializers

2018-05-22 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue May 22 17:09:29 2018
New Revision: 333044

URL: http://llvm.org/viewvc/llvm-project?rev=333044=rev
Log:
Use zeroinitializer for (trailing zero portion of) large array initializers
more reliably.

Clang has two different ways it emits array constants (from InitListExprs and
from APValues), 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.

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

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

Modified: cfe/trunk/lib/CodeGen/CGExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprConstant.cpp?rev=333044=333043=333044=diff
==
--- cfe/trunk/lib/CodeGen/CGExprConstant.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprConstant.cpp Tue May 22 17:09:29 2018
@@ -635,6 +635,52 @@ static ConstantAddress tryEmitGlobalComp
   return ConstantAddress(GV, Align);
 }
 
+static llvm::Constant *
+EmitArrayConstant(llvm::ArrayType *PreferredArrayType,
+  llvm::Type *CommonElementType, unsigned ArrayBound,
+  SmallVectorImpl ,
+  llvm::Constant *Filler) {
+  // Figure out how long the initial prefix of non-zero elements is.
+  unsigned NonzeroLength = ArrayBound;
+  if (Elements.size() < NonzeroLength && Filler->isNullValue())
+NonzeroLength = Elements.size();
+  if (NonzeroLength == Elements.size()) {
+while (NonzeroLength > 0 && Elements[NonzeroLength - 1]->isNullValue())
+  --NonzeroLength;
+  }
+
+  if (NonzeroLength == 0)
+return llvm::ConstantAggregateZero::get(PreferredArrayType);
+
+  // If there's not many trailing zero elements, just emit an array
+  // constant.
+  if (NonzeroLength + 8 >= ArrayBound && CommonElementType) {
+Elements.resize(ArrayBound, Filler);
+return llvm::ConstantArray::get(
+llvm::ArrayType::get(CommonElementType, ArrayBound), Elements);
+  }
+
+  // Add a zeroinitializer array filler if we have trailing zeroes.
+  if (unsigned TrailingZeroes = ArrayBound - NonzeroLength) {
+assert(Elements.size() >= NonzeroLength &&
+   "missing initializer for non-zero element");
+Elements.resize(NonzeroLength + 1);
+auto *FillerType = PreferredArrayType->getElementType();
+if (TrailingZeroes > 1)
+  FillerType = llvm::ArrayType::get(FillerType, TrailingZeroes);
+Elements.back() = llvm::ConstantAggregateZero::get(FillerType);
+  }
+
+  // We have mixed types. Use a packed struct.
+  llvm::SmallVector Types;
+  Types.reserve(Elements.size());
+  for (llvm::Constant *Elt : Elements)
+Types.push_back(Elt->getType());
+  llvm::StructType *SType =
+  llvm::StructType::get(PreferredArrayType->getContext(), Types, true);
+  return llvm::ConstantStruct::get(SType, Elements);
+}
+
 /// This class only needs to handle two cases:
 /// 1) Literals (this is used by APValue emission to emit literals).
 /// 2) Arrays, structs and unions (outside C++11 mode, we don't currently
@@ -834,7 +880,6 @@ public:
   llvm::Constant *EmitArrayInitialization(InitListExpr *ILE, QualType T) {
 llvm::ArrayType *AType =
 cast(ConvertType(ILE->getType()));
-llvm::Type *ElemTy = AType->getElementType();
 unsigned NumInitElements = ILE->getNumInits();
 unsigned NumElements = AType->getNumElements();
 
@@ -845,55 +890,35 @@ public:
 QualType EltType = CGM.getContext().getAsArrayType(T)->getElementType();
 
 // Initialize remaining array elements.
-llvm::Constant *fillC;
-if (Expr *filler = ILE->getArrayFiller())
+llvm::Constant *fillC = nullptr;
+if (Expr *filler = ILE->getArrayFiller()) {
   fillC = Emitter.tryEmitAbstractForMemory(filler, EltType);
-else
-  fillC = Emitter.emitNullForMemory(EltType);
-if (!fillC)
-  return nullptr;
-
-// Try to use a ConstantAggregateZero if we can.
-if (fillC->isNullValue() && !NumInitableElts)
-  return 

[PATCH] D47233: [CodeGen] Emit MSVC RTTI for Obj-C EH types

2018-05-22 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai updated this revision to Diff 148133.
smeenai added a comment.

Colocate CHECK lines with declarations


Repository:
  rC Clang

https://reviews.llvm.org/D47233

Files:
  lib/CodeGen/CGCXXABI.h
  lib/CodeGen/CGObjCMac.cpp
  lib/CodeGen/MicrosoftCXXABI.cpp
  test/CodeGenObjC/dllstorage.m
  test/CodeGenObjC/exceptions-msvc.m

Index: test/CodeGenObjC/exceptions-msvc.m
===
--- /dev/null
+++ test/CodeGenObjC/exceptions-msvc.m
@@ -0,0 +1,69 @@
+// RUN: %clang_cc1 -triple i686--windows-msvc -fobjc-runtime=ios-6.0 -fdeclspec -fexceptions -fobjc-exceptions -emit-llvm -o - %s | FileCheck -check-prefixes=CHECK,X86 %s
+// RUN: %clang_cc1 -triple i686--windows-msvc -fobjc-runtime=ios-6.0 -fobjc-arc -fdeclspec -fexceptions -fobjc-exceptions -emit-llvm -o - %s | FileCheck -check-prefixes=CHECK,X86 %s
+// RUN: %clang_cc1 -triple x86_64--windows-msvc -fobjc-runtime=ios-6.0 -fdeclspec -fexceptions -fobjc-exceptions -emit-llvm -o - %s | FileCheck -check-prefixes=CHECK,X64 %s
+// RUN: %clang_cc1 -triple x86_64--windows-msvc -fobjc-runtime=ios-6.0 -fobjc-arc -fdeclspec -fexceptions -fobjc-exceptions -emit-llvm -o - %s | FileCheck -check-prefixes=CHECK,X64 %s
+
+#if __has_feature(objc_arc)
+#define WEAK __weak
+#else
+#define WEAK
+#endif
+
+// CHECK-DAG: $OBJC_EHTYPE_id = comdat any
+// X86-DAG: @OBJC_EHTYPE_id = linkonce_odr global {{%[^ ]+}} { i8** @"??_7type_info@@6B@", i8* null, [18 x i8] c".PAUobjc_object@@\00" }, comdat
+// X64-DAG: @OBJC_EHTYPE_id = linkonce_odr global {{%[^ ]+}} { i8** @"??_7type_info@@6B@", i8* null, [19 x i8] c".PEAUobjc_object@@\00" }, comdat
+
+@class I;
+
+// CHECK-DAG: $"OBJC_EHTYPE_$_I" = comdat any
+// X86-DAG: @"OBJC_EHTYPE_$_I" = linkonce_odr global {{%[^ ]+}} { i8** @"??_7type_info@@6B@", i8* null, [8 x i8] c".PAUI@@\00" }, comdat
+// X64-DAG: @"OBJC_EHTYPE_$_I" = linkonce_odr global {{%[^ ]+}} { i8** @"??_7type_info@@6B@", i8* null, [9 x i8] c".PEAUI@@\00" }, comdat
+
+@class J;
+
+// CHECK-DAG: $"OBJC_EHTYPE_$_J" = comdat any
+// X86-DAG: @"OBJC_EHTYPE_$_J" = linkonce_odr global {{%[^ ]+}} { i8** @"??_7type_info@@6B@", i8* null, [8 x i8] c".PAUJ@@\00" }, comdat
+// X64-DAG: @"OBJC_EHTYPE_$_J" = linkonce_odr global {{%[^ ]+}} { i8** @"??_7type_info@@6B@", i8* null, [9 x i8] c".PEAUJ@@\00" }, comdat
+
+// The EHType shouldn't be exported
+__declspec(dllexport)
+__attribute__((objc_root_class))
+@interface K
+@end
+
+@implementation K
+@end
+
+// CHECK-DAG: $"OBJC_EHTYPE_$_K" = comdat any
+// X86-DAG: @"OBJC_EHTYPE_$_K" = linkonce_odr global {{%[^ ]+}} { i8** @"??_7type_info@@6B@", i8* null, [8 x i8] c".PAUK@@\00" }, comdat
+// X64-DAG: @"OBJC_EHTYPE_$_K" = linkonce_odr global {{%[^ ]+}} { i8** @"??_7type_info@@6B@", i8* null, [9 x i8] c".PEAUK@@\00" }, comdat
+
+__attribute__((objc_runtime_name("NotL")))
+@interface L
+@end
+
+// CHECK-DAG: $"OBJC_EHTYPE_$_NotL" = comdat any
+// X86-DAG: @"OBJC_EHTYPE_$_NotL" = linkonce_odr global {{%[^ ]+}} { i8** @"??_7type_info@@6B@", i8* null, [8 x i8] c".PAUL@@\00" }, comdat
+// X64-DAG: @"OBJC_EHTYPE_$_NotL" = linkonce_odr global {{%[^ ]+}} { i8** @"??_7type_info@@6B@", i8* null, [9 x i8] c".PEAUL@@\00" }, comdat
+
+@class M;
+
+// CHECK-DAG: $"OBJC_EHTYPE_$_M" = comdat any
+// X86-DAG: @"OBJC_EHTYPE_$_M" = linkonce_odr global {{%[^ ]+}} { i8** @"??_7type_info@@6B@", i8* null, [8 x i8] c".PAUM@@\00" }, comdat
+// X64-DAG: @"OBJC_EHTYPE_$_M" = linkonce_odr global {{%[^ ]+}} { i8** @"??_7type_info@@6B@", i8* null, [9 x i8] c".PEAUM@@\00" }, comdat
+
+@protocol P;
+
+void f(void);
+
+void g() {
+  @try {
+f();
+  } @catch (I *) {
+  } @catch (J *) {
+  } @catch (K *) {
+  } @catch (L *) {
+  } @catch (M *WEAK) {
+  } @catch (id) {
+  }
+}
Index: test/CodeGenObjC/dllstorage.m
===
--- test/CodeGenObjC/dllstorage.m
+++ test/CodeGenObjC/dllstorage.m
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-windows-msvc -fdeclspec -fobjc-runtime=ios -fobjc-exceptions -S -emit-llvm -o - %s | FileCheck -check-prefix CHECK-IR %s
-// RUN: %clang_cc1 -triple i686-windows-itanium -fms-extensions -fobjc-runtime=macosx -fdeclspec -fobjc-exceptions -S -emit-llvm -o - %s | FileCheck -check-prefix CHECK-IR %s
+// RUN: %clang_cc1 -triple i686-windows-itanium -fms-extensions -fobjc-runtime=macosx -fdeclspec -fobjc-exceptions -S -emit-llvm -o - %s | FileCheck -check-prefix CHECK-IR -check-prefix CHECK-ITANIUM %s
 // RUN: %clang_cc1 -triple i686-windows-itanium -fms-extensions -fobjc-runtime=objfw -fdeclspec -fobjc-exceptions -S -emit-llvm -o - %s | FileCheck -check-prefix CHECK-FW %s
 
 // CHECK-IR-DAG: @_objc_empty_cache = external dllimport global %struct._objc_cache
@@ -100,20 +100,20 @@
 @implementation N : I
 @end
 
-// CHECK-IR-DAG: @"OBJC_EHTYPE_$_N" = dso_local dllexport global %struct._objc_typeinfo
+// CHECK-ITANIUM-DAG: @"OBJC_EHTYPE_$_N" = dso_local dllexport global %struct._objc_typeinfo
 
 __declspec(dllimport)
 

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

2018-05-22 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

CUDA does not expose explicit AS on clang size. All pointers are treated as 
generic and we infer specific address space only in LLVM.
`__nvvm_atom_*_[sg]_*` builtins should probably be removed as they are indeed 
useless without pointers with explicit AS and NVCC itself does not have such 
builtins either.  Instead, we should convert the generic AS builtin to 
address-space specific instruction somewhere in LLVM.

Using `attribute((address_space())` should probably produce an error during 
CUDA compilation.


https://reviews.llvm.org/D47154



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


[PATCH] D47138: [Sparc] Use the leon arch for Leon3's when using an external assembler

2018-05-22 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg added a comment.

This still needs a test case?


https://reviews.llvm.org/D47138



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


[PATCH] D47070: [CUDA] Upgrade linked bitcode to enable inlining

2018-05-22 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

In https://reviews.llvm.org/D47070#1106018, @echristo wrote:

> > As a short-term fix we can disable feature-to-function attribute 
> > propagation for NVPTX until we fix it.
> > 
> > @echristo -- any other suggestions?
>
> This is some of what I was talking about when I was mentioning how function 
> attributes and the targets work. Ideally you'll have a compatible set of 
> features and it won't really cause an issue. The idea is that if you're 
> compiling for a minimum ptx feature of X, then any "compatible" set of ptx 
> should be able to inline into your code. I think you do want the features to 
> propagate in general, just specific use cases may not care one way or another 
> - that said, for those use cases you're probably just compiling everything 
> with the same feature anyhow.


The thing is that with NVPTX you can not have incompatible functions in the 
PTX, period. PTXAS will just throw syntax errors at you. In that regard PTX is 
very different from intel where in the same binary you can have different 
functions with code for different x86 variants.  For PTX, sm_50 and sm_60 mean 
entirely different GPUs with entirely different instruction sets/encoding. PTX 
version would be an approximation of a different language dialect .  You can 
not use anything from PTX 4.0 if your file says it's PTX3.0. It's sort of like 
you can't use c++17 features when you're compiling in c++98 mode. Bottom line 
is that features and target-cpu do not make  much sense for NVPTX. Everything  
we generate in a TU must satisfy minimum PTX version and minimum GPU variant 
and it all will be compiled for and run on only one specific GPU. There's no 
mixing and matching.

The question is -- what's the best way to make things work as they were before 
I broke them?
@Hahnfeld's idea of ignoring features and target-cpu would get us there, but 
that may be a never-ending source of surprises if/when something else decides 
to pay attention to those attributes.
I think the best way to tackle that would be to 
a) figure out how to make builtins available/or not on clang side, and
b) make target-cpu and target-features attributes explicitly unsupported on 
NVPTX as we can not provide the functionality those attributes imply.

> I guess, ultimately, I'm not seeing what the concern here is for how features 
> are working or not working for the target so it's harder to help. What is the 
> problem you're running into, or can you try a different way of explaining it 
> to me? :)

Here's my understanding of what happens: 
We've started adding target-features and target-cpu to everything clang 
generates. 
We also need to link with libdevice (or IR generated by clang which which has 
functions w/o those attributes. Or we need to link with IR produced by clang 
which used different CUDA SDK and thus different PTX version in target-feature.
Due to attribute mismatch we are failing to inline some of the functions and 
that hurts performance.


Repository:
  rC Clang

https://reviews.llvm.org/D47070



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


[PATCH] D47202: [CodeGen] use nsw negation for abs

2018-05-22 Thread Sanjay Patel via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC333038: [CodeGen] use nsw negation for builtin abs (authored 
by spatel, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D47202

Files:
  lib/CodeGen/CGBuiltin.cpp
  test/CodeGen/builtin-abs.c


Index: test/CodeGen/builtin-abs.c
===
--- test/CodeGen/builtin-abs.c
+++ test/CodeGen/builtin-abs.c
@@ -2,25 +2,25 @@
 
 int absi(int x) {
 // CHECK-LABEL: @absi(
-// CHECK:   [[NEG:%.*]] = sub i32 0, [[X:%.*]]
+// CHECK:   [[NEG:%.*]] = sub nsw i32 0, [[X:%.*]]
 // CHECK:   [[CMP:%.*]] = icmp slt i32 [[X]], 0
 // CHECK:   [[SEL:%.*]] = select i1 [[CMP]], i32 [[NEG]], i32 [[X]]
 //
   return __builtin_abs(x);
 }
 
 long absl(long x) {
 // CHECK-LABEL: @absl(
-// CHECK:   [[NEG:%.*]] = sub i64 0, [[X:%.*]]
+// CHECK:   [[NEG:%.*]] = sub nsw i64 0, [[X:%.*]]
 // CHECK:   [[CMP:%.*]] = icmp slt i64 [[X]], 0
 // CHECK:   [[SEL:%.*]] = select i1 [[CMP]], i64 [[NEG]], i64 [[X]]
 //
   return __builtin_labs(x);
 }
 
 long long absll(long long x) {
 // CHECK-LABEL: @absll(
-// CHECK:   [[NEG:%.*]] = sub i64 0, [[X:%.*]]
+// CHECK:   [[NEG:%.*]] = sub nsw i64 0, [[X:%.*]]
 // CHECK:   [[CMP:%.*]] = icmp slt i64 [[X]], 0
 // CHECK:   [[SEL:%.*]] = select i1 [[CMP]], i64 [[NEG]], i64 [[X]]
 //
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -1252,8 +1252,9 @@
   case Builtin::BI__builtin_labs:
   case Builtin::BI__builtin_llabs: {
 // X < 0 ? -X : X
+// The negation has 'nsw' because abs of INT_MIN is undefined.
 Value *ArgValue = EmitScalarExpr(E->getArg(0));
-Value *NegOp = Builder.CreateNeg(ArgValue, "neg");
+Value *NegOp = Builder.CreateNSWNeg(ArgValue, "neg");
 Constant *Zero = llvm::Constant::getNullValue(ArgValue->getType());
 Value *CmpResult = Builder.CreateICmpSLT(ArgValue, Zero, "abscond");
 Value *Result = Builder.CreateSelect(CmpResult, NegOp, ArgValue, "abs");


Index: test/CodeGen/builtin-abs.c
===
--- test/CodeGen/builtin-abs.c
+++ test/CodeGen/builtin-abs.c
@@ -2,25 +2,25 @@
 
 int absi(int x) {
 // CHECK-LABEL: @absi(
-// CHECK:   [[NEG:%.*]] = sub i32 0, [[X:%.*]]
+// CHECK:   [[NEG:%.*]] = sub nsw i32 0, [[X:%.*]]
 // CHECK:   [[CMP:%.*]] = icmp slt i32 [[X]], 0
 // CHECK:   [[SEL:%.*]] = select i1 [[CMP]], i32 [[NEG]], i32 [[X]]
 //
   return __builtin_abs(x);
 }
 
 long absl(long x) {
 // CHECK-LABEL: @absl(
-// CHECK:   [[NEG:%.*]] = sub i64 0, [[X:%.*]]
+// CHECK:   [[NEG:%.*]] = sub nsw i64 0, [[X:%.*]]
 // CHECK:   [[CMP:%.*]] = icmp slt i64 [[X]], 0
 // CHECK:   [[SEL:%.*]] = select i1 [[CMP]], i64 [[NEG]], i64 [[X]]
 //
   return __builtin_labs(x);
 }
 
 long long absll(long long x) {
 // CHECK-LABEL: @absll(
-// CHECK:   [[NEG:%.*]] = sub i64 0, [[X:%.*]]
+// CHECK:   [[NEG:%.*]] = sub nsw i64 0, [[X:%.*]]
 // CHECK:   [[CMP:%.*]] = icmp slt i64 [[X]], 0
 // CHECK:   [[SEL:%.*]] = select i1 [[CMP]], i64 [[NEG]], i64 [[X]]
 //
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -1252,8 +1252,9 @@
   case Builtin::BI__builtin_labs:
   case Builtin::BI__builtin_llabs: {
 // X < 0 ? -X : X
+// The negation has 'nsw' because abs of INT_MIN is undefined.
 Value *ArgValue = EmitScalarExpr(E->getArg(0));
-Value *NegOp = Builder.CreateNeg(ArgValue, "neg");
+Value *NegOp = Builder.CreateNSWNeg(ArgValue, "neg");
 Constant *Zero = llvm::Constant::getNullValue(ArgValue->getType());
 Value *CmpResult = Builder.CreateICmpSLT(ArgValue, Zero, "abscond");
 Value *Result = Builder.CreateSelect(CmpResult, NegOp, ArgValue, "abs");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D47202: [CodeGen] use nsw negation for abs

2018-05-22 Thread Sanjay Patel via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL333038: [CodeGen] use nsw negation for builtin abs (authored 
by spatel, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D47202?vs=148020=148123#toc

Repository:
  rC Clang

https://reviews.llvm.org/D47202

Files:
  cfe/trunk/lib/CodeGen/CGBuiltin.cpp
  cfe/trunk/test/CodeGen/builtin-abs.c


Index: cfe/trunk/test/CodeGen/builtin-abs.c
===
--- cfe/trunk/test/CodeGen/builtin-abs.c
+++ cfe/trunk/test/CodeGen/builtin-abs.c
@@ -2,25 +2,25 @@
 
 int absi(int x) {
 // CHECK-LABEL: @absi(
-// CHECK:   [[NEG:%.*]] = sub i32 0, [[X:%.*]]
+// CHECK:   [[NEG:%.*]] = sub nsw i32 0, [[X:%.*]]
 // CHECK:   [[CMP:%.*]] = icmp slt i32 [[X]], 0
 // CHECK:   [[SEL:%.*]] = select i1 [[CMP]], i32 [[NEG]], i32 [[X]]
 //
   return __builtin_abs(x);
 }
 
 long absl(long x) {
 // CHECK-LABEL: @absl(
-// CHECK:   [[NEG:%.*]] = sub i64 0, [[X:%.*]]
+// CHECK:   [[NEG:%.*]] = sub nsw i64 0, [[X:%.*]]
 // CHECK:   [[CMP:%.*]] = icmp slt i64 [[X]], 0
 // CHECK:   [[SEL:%.*]] = select i1 [[CMP]], i64 [[NEG]], i64 [[X]]
 //
   return __builtin_labs(x);
 }
 
 long long absll(long long x) {
 // CHECK-LABEL: @absll(
-// CHECK:   [[NEG:%.*]] = sub i64 0, [[X:%.*]]
+// CHECK:   [[NEG:%.*]] = sub nsw i64 0, [[X:%.*]]
 // CHECK:   [[CMP:%.*]] = icmp slt i64 [[X]], 0
 // CHECK:   [[SEL:%.*]] = select i1 [[CMP]], i64 [[NEG]], i64 [[X]]
 //
Index: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
===
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp
@@ -1252,8 +1252,9 @@
   case Builtin::BI__builtin_labs:
   case Builtin::BI__builtin_llabs: {
 // X < 0 ? -X : X
+// The negation has 'nsw' because abs of INT_MIN is undefined.
 Value *ArgValue = EmitScalarExpr(E->getArg(0));
-Value *NegOp = Builder.CreateNeg(ArgValue, "neg");
+Value *NegOp = Builder.CreateNSWNeg(ArgValue, "neg");
 Constant *Zero = llvm::Constant::getNullValue(ArgValue->getType());
 Value *CmpResult = Builder.CreateICmpSLT(ArgValue, Zero, "abscond");
 Value *Result = Builder.CreateSelect(CmpResult, NegOp, ArgValue, "abs");


Index: cfe/trunk/test/CodeGen/builtin-abs.c
===
--- cfe/trunk/test/CodeGen/builtin-abs.c
+++ cfe/trunk/test/CodeGen/builtin-abs.c
@@ -2,25 +2,25 @@
 
 int absi(int x) {
 // CHECK-LABEL: @absi(
-// CHECK:   [[NEG:%.*]] = sub i32 0, [[X:%.*]]
+// CHECK:   [[NEG:%.*]] = sub nsw i32 0, [[X:%.*]]
 // CHECK:   [[CMP:%.*]] = icmp slt i32 [[X]], 0
 // CHECK:   [[SEL:%.*]] = select i1 [[CMP]], i32 [[NEG]], i32 [[X]]
 //
   return __builtin_abs(x);
 }
 
 long absl(long x) {
 // CHECK-LABEL: @absl(
-// CHECK:   [[NEG:%.*]] = sub i64 0, [[X:%.*]]
+// CHECK:   [[NEG:%.*]] = sub nsw i64 0, [[X:%.*]]
 // CHECK:   [[CMP:%.*]] = icmp slt i64 [[X]], 0
 // CHECK:   [[SEL:%.*]] = select i1 [[CMP]], i64 [[NEG]], i64 [[X]]
 //
   return __builtin_labs(x);
 }
 
 long long absll(long long x) {
 // CHECK-LABEL: @absll(
-// CHECK:   [[NEG:%.*]] = sub i64 0, [[X:%.*]]
+// CHECK:   [[NEG:%.*]] = sub nsw i64 0, [[X:%.*]]
 // CHECK:   [[CMP:%.*]] = icmp slt i64 [[X]], 0
 // CHECK:   [[SEL:%.*]] = select i1 [[CMP]], i64 [[NEG]], i64 [[X]]
 //
Index: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
===
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp
@@ -1252,8 +1252,9 @@
   case Builtin::BI__builtin_labs:
   case Builtin::BI__builtin_llabs: {
 // X < 0 ? -X : X
+// The negation has 'nsw' because abs of INT_MIN is undefined.
 Value *ArgValue = EmitScalarExpr(E->getArg(0));
-Value *NegOp = Builder.CreateNeg(ArgValue, "neg");
+Value *NegOp = Builder.CreateNSWNeg(ArgValue, "neg");
 Constant *Zero = llvm::Constant::getNullValue(ArgValue->getType());
 Value *CmpResult = Builder.CreateICmpSLT(ArgValue, Zero, "abscond");
 Value *Result = Builder.CreateSelect(CmpResult, NegOp, ArgValue, "abs");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r333038 - [CodeGen] use nsw negation for builtin abs

2018-05-22 Thread Sanjay Patel via cfe-commits
Author: spatel
Date: Tue May 22 16:02:13 2018
New Revision: 333038

URL: http://llvm.org/viewvc/llvm-project?rev=333038=rev
Log:
[CodeGen] use nsw negation for builtin abs

The clang builtins have the same semantics as the stdlib functions.
The stdlib functions are defined in section 7.20.6.1 of the C standard with:
"If the result cannot be represented, the behavior is undefined."

That lets us mark the negation with 'nsw' because "sub i32 0, INT_MIN" would
be UB/poison.

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

Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/builtin-abs.c

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=333038=333037=333038=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Tue May 22 16:02:13 2018
@@ -1252,8 +1252,9 @@ RValue CodeGenFunction::EmitBuiltinExpr(
   case Builtin::BI__builtin_labs:
   case Builtin::BI__builtin_llabs: {
 // X < 0 ? -X : X
+// The negation has 'nsw' because abs of INT_MIN is undefined.
 Value *ArgValue = EmitScalarExpr(E->getArg(0));
-Value *NegOp = Builder.CreateNeg(ArgValue, "neg");
+Value *NegOp = Builder.CreateNSWNeg(ArgValue, "neg");
 Constant *Zero = llvm::Constant::getNullValue(ArgValue->getType());
 Value *CmpResult = Builder.CreateICmpSLT(ArgValue, Zero, "abscond");
 Value *Result = Builder.CreateSelect(CmpResult, NegOp, ArgValue, "abs");

Modified: cfe/trunk/test/CodeGen/builtin-abs.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtin-abs.c?rev=333038=333037=333038=diff
==
--- cfe/trunk/test/CodeGen/builtin-abs.c (original)
+++ cfe/trunk/test/CodeGen/builtin-abs.c Tue May 22 16:02:13 2018
@@ -2,7 +2,7 @@
 
 int absi(int x) {
 // CHECK-LABEL: @absi(
-// CHECK:   [[NEG:%.*]] = sub i32 0, [[X:%.*]]
+// CHECK:   [[NEG:%.*]] = sub nsw i32 0, [[X:%.*]]
 // CHECK:   [[CMP:%.*]] = icmp slt i32 [[X]], 0
 // CHECK:   [[SEL:%.*]] = select i1 [[CMP]], i32 [[NEG]], i32 [[X]]
 //
@@ -11,7 +11,7 @@ int absi(int x) {
 
 long absl(long x) {
 // CHECK-LABEL: @absl(
-// CHECK:   [[NEG:%.*]] = sub i64 0, [[X:%.*]]
+// CHECK:   [[NEG:%.*]] = sub nsw i64 0, [[X:%.*]]
 // CHECK:   [[CMP:%.*]] = icmp slt i64 [[X]], 0
 // CHECK:   [[SEL:%.*]] = select i1 [[CMP]], i64 [[NEG]], i64 [[X]]
 //
@@ -20,7 +20,7 @@ long absl(long x) {
 
 long long absll(long long x) {
 // CHECK-LABEL: @absll(
-// CHECK:   [[NEG:%.*]] = sub i64 0, [[X:%.*]]
+// CHECK:   [[NEG:%.*]] = sub nsw i64 0, [[X:%.*]]
 // CHECK:   [[CMP:%.*]] = icmp slt i64 [[X]], 0
 // CHECK:   [[SEL:%.*]] = select i1 [[CMP]], i64 [[NEG]], i64 [[X]]
 //


___
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-22 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 148121.

Repository:
  rC Clang

https://reviews.llvm.org/D46084

Files:
  include/clang-c/Index.h
  include/clang/AST/ASTContext.h
  include/clang/AST/BuiltinTypes.def
  include/clang/Basic/DiagnosticCommonKinds.td
  include/clang/Basic/Specifiers.h
  include/clang/Basic/TokenKinds.def
  include/clang/Sema/DeclSpec.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/ASTContext.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/MicrosoftMangle.cpp
  lib/AST/NSAPI.cpp
  lib/AST/Type.cpp
  lib/AST/TypeLoc.cpp
  lib/Analysis/PrintfFormatString.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CodeGenTypes.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/Index/USRGeneration.cpp
  lib/Parse/ParseDecl.cpp
  lib/Sema/DeclSpec.cpp
  lib/Sema/SemaTemplateVariadic.cpp
  lib/Sema/SemaType.cpp
  lib/Serialization/ASTCommon.cpp
  lib/Serialization/ASTReader.cpp
  test/Frontend/accum.c
  test/Frontend/accum_errors.c
  test/Frontend/accum_errors.cpp
  tools/libclang/CXType.cpp

Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -53,6 +53,12 @@
 BTCASE(Float);
 BTCASE(Double);
 BTCASE(LongDouble);
+BTCASE(ShortAccum);
+BTCASE(Accum);
+BTCASE(LongAccum);
+BTCASE(UShortAccum);
+BTCASE(UAccum);
+BTCASE(ULongAccum);
 BTCASE(Float16);
 BTCASE(Float128);
 BTCASE(NullPtr);
@@ -542,6 +548,12 @@
 TKIND(Float);
 TKIND(Double);
 TKIND(LongDouble);
+TKIND(ShortAccum);
+TKIND(Accum);
+TKIND(LongAccum);
+TKIND(UShortAccum);
+TKIND(UAccum);
+TKIND(ULongAccum);
 TKIND(Float16);
 TKIND(Float128);
 TKIND(NullPtr);
Index: test/Frontend/accum_errors.cpp
===
--- /dev/null
+++ test/Frontend/accum_errors.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -x c++ %s -verify
+
+// Name namgling is not provided for fixed point types in c++
+
+signed short _Accum s_short_accum;  // expected-error{{Fixed point types are only allowed in C}}
+signed _Accum s_accum;  // expected-error{{Fixed point types are only allowed in C}}
+signed long _Accum s_long_accum;  // expected-error{{Fixed point types are only allowed in C}}
+unsigned short _Accum u_short_accum;  // expected-error{{Fixed point types are only allowed in C}}
+unsigned _Accum u_accum;  // expected-error{{Fixed point types are only allowed in C}}
+unsigned long _Accum u_long_accum;  // expected-error{{Fixed point types are only allowed in C}}
+
+short _Accum short_accum;  // expected-error{{Fixed point types are only allowed in C}}
+_Accum accum; // expected-error{{Fixed point types are only allowed in C}}
+long _Accum long_accum;  // expected-error{{Fixed point types are only allowed in C}}
Index: test/Frontend/accum_errors.c
===
--- /dev/null
+++ test/Frontend/accum_errors.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -x c -fsyntax-only -verify -pedantic %s
+
+long long _Accum longlong_accum;  // expected-error{{'long long _Accum' is invalid}}
+unsigned long long _Accum u_longlong_accum;  // expected-error{{'long long _Accum' is invalid}}
Index: test/Frontend/accum.c
===
--- /dev/null
+++ test/Frontend/accum.c
@@ -0,0 +1,26 @@
+// RUN: %clang -cc1 -x c -ast-dump %s | FileCheck %s --strict-whitespace
+
+/*  Various contexts where type _Accum can appear. */
+
+// Primary fixed point types
+signed short _Accum s_short_accum;
+signed _Accum s_accum;
+signed long _Accum s_long_accum;
+unsigned short _Accum u_short_accum;
+unsigned _Accum u_accum;
+unsigned long _Accum u_long_accum;
+
+// Aliased fixed point types
+short _Accum short_accum;
+_Accum accum;
+long _Accum long_accum;
+
+// CHECK:  |-VarDecl {{.*}} s_short_accum 'short _Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} s_accum '_Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} s_long_accum 'long _Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} u_short_accum 'unsigned short _Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} u_accum 'unsigned _Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} u_long_accum 'unsigned long _Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} short_accum 'short _Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} accum '_Accum'
+// CHECK-NEXT: `-VarDecl {{.*}} long_accum 'long _Accum'
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -6816,6 +6816,24 @@
 case PREDEF_TYPE_LONGDOUBLE_ID:
   T = Context.LongDoubleTy;
   break;
+case PREDEF_TYPE_SHORT_ACCUM_ID:
+  T = Context.ShortAccumTy;
+  break;
+case PREDEF_TYPE_ACCUM_ID:
+  T = Context.AccumTy;
+  break;
+case PREDEF_TYPE_LONG_ACCUM_ID:
+  T = Context.LongAccumTy;
+  break;
+case PREDEF_TYPE_USHORT_ACCUM_ID:

[PATCH] D47233: [CodeGen] Emit MSVC RTTI for Obj-C EH types

2018-05-22 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai created this revision.
smeenai added reviewers: DHowett-MSFT, compnerd, majnemer, rjmccall, rnk.

We're implementing funclet-compatible code generation for Obj-C
exceptions when using the MSVC ABI. The idea is that the Obj-C runtime
will wrap Obj-C exceptions inside C++ exceptions, which allows for
interoperability with C++ exceptions (for Obj-C++) and zero-cost
exceptions. This is the approach taken by e.g. WinObjC, and I believe it
to be the best approach for Obj-C exceptions in the MSVC ABI.

The first step is emitting proper RTTI for Obj-C exception types. Since
we're wrapping Obj-C exceptions in C++ exceptions, the RTTI should be
identical, barring the name of the RTTI variable (OBJC_EHTYPE_$_*).
Since the MSVC ABI does not easily allow for cross-DLL data references
from within other data, we instead emit the RTTI locally wherever
needed, which is also how C++ RTTI works on that ABI.

Follow-up diffs will add code generation support for @try itself, but
I'm splitting it up to get early feedback and make review more
manageable.

Worked on with Saleem Abdulrasool .


Repository:
  rC Clang

https://reviews.llvm.org/D47233

Files:
  lib/CodeGen/CGCXXABI.h
  lib/CodeGen/CGObjCMac.cpp
  lib/CodeGen/MicrosoftCXXABI.cpp
  test/CodeGenObjC/dllstorage.m
  test/CodeGenObjC/exceptions-msvc.m

Index: test/CodeGenObjC/exceptions-msvc.m
===
--- /dev/null
+++ test/CodeGenObjC/exceptions-msvc.m
@@ -0,0 +1,68 @@
+// RUN: %clang_cc1 -triple i686--windows-msvc -fobjc-runtime=ios-6.0 -fdeclspec -fexceptions -fobjc-exceptions -emit-llvm -o - %s | FileCheck -check-prefixes=CHECK,X86 %s
+// RUN: %clang_cc1 -triple i686--windows-msvc -fobjc-runtime=ios-6.0 -fobjc-arc -fdeclspec -fexceptions -fobjc-exceptions -emit-llvm -o - %s | FileCheck -check-prefixes=CHECK,X86 %s
+// RUN: %clang_cc1 -triple x86_64--windows-msvc -fobjc-runtime=ios-6.0 -fdeclspec -fexceptions -fobjc-exceptions -emit-llvm -o - %s | FileCheck -check-prefixes=CHECK,X64 %s
+// RUN: %clang_cc1 -triple x86_64--windows-msvc -fobjc-runtime=ios-6.0 -fobjc-arc -fdeclspec -fexceptions -fobjc-exceptions -emit-llvm -o - %s | FileCheck -check-prefixes=CHECK,X64 %s
+
+// CHECK-DAG: $OBJC_EHTYPE_id = comdat any
+// X86-DAG: @OBJC_EHTYPE_id = linkonce_odr global {{%[^ ]+}} { i8** @"??_7type_info@@6B@", i8* null, [18 x i8] c".PAUobjc_object@@\00" }, comdat
+// X64-DAG: @OBJC_EHTYPE_id = linkonce_odr global {{%[^ ]+}} { i8** @"??_7type_info@@6B@", i8* null, [19 x i8] c".PEAUobjc_object@@\00" }, comdat
+
+// CHECK-DAG: $"OBJC_EHTYPE_$_I" = comdat any
+// X86-DAG: @"OBJC_EHTYPE_$_I" = linkonce_odr global {{%[^ ]+}} { i8** @"??_7type_info@@6B@", i8* null, [8 x i8] c".PAUI@@\00" }, comdat
+// X64-DAG: @"OBJC_EHTYPE_$_I" = linkonce_odr global {{%[^ ]+}} { i8** @"??_7type_info@@6B@", i8* null, [9 x i8] c".PEAUI@@\00" }, comdat
+
+// CHECK-DAG: $"OBJC_EHTYPE_$_J" = comdat any
+// X86-DAG: @"OBJC_EHTYPE_$_J" = linkonce_odr global {{%[^ ]+}} { i8** @"??_7type_info@@6B@", i8* null, [8 x i8] c".PAUJ@@\00" }, comdat
+// X64-DAG: @"OBJC_EHTYPE_$_J" = linkonce_odr global {{%[^ ]+}} { i8** @"??_7type_info@@6B@", i8* null, [9 x i8] c".PEAUJ@@\00" }, comdat
+
+// CHECK-DAG: $"OBJC_EHTYPE_$_K" = comdat any
+// X86-DAG: @"OBJC_EHTYPE_$_K" = linkonce_odr global {{%[^ ]+}} { i8** @"??_7type_info@@6B@", i8* null, [8 x i8] c".PAUK@@\00" }, comdat
+// X64-DAG: @"OBJC_EHTYPE_$_K" = linkonce_odr global {{%[^ ]+}} { i8** @"??_7type_info@@6B@", i8* null, [9 x i8] c".PEAUK@@\00" }, comdat
+
+// CHECK-DAG: $"OBJC_EHTYPE_$_NotL" = comdat any
+// X86-DAG: @"OBJC_EHTYPE_$_NotL" = linkonce_odr global {{%[^ ]+}} { i8** @"??_7type_info@@6B@", i8* null, [8 x i8] c".PAUL@@\00" }, comdat
+// X64-DAG: @"OBJC_EHTYPE_$_NotL" = linkonce_odr global {{%[^ ]+}} { i8** @"??_7type_info@@6B@", i8* null, [9 x i8] c".PEAUL@@\00" }, comdat
+
+// CHECK-DAG: $"OBJC_EHTYPE_$_M" = comdat any
+// X86-DAG: @"OBJC_EHTYPE_$_M" = linkonce_odr global {{%[^ ]+}} { i8** @"??_7type_info@@6B@", i8* null, [8 x i8] c".PAUM@@\00" }, comdat
+// X64-DAG: @"OBJC_EHTYPE_$_M" = linkonce_odr global {{%[^ ]+}} { i8** @"??_7type_info@@6B@", i8* null, [9 x i8] c".PEAUM@@\00" }, comdat
+
+#if __has_feature(objc_arc)
+#define WEAK __weak
+#else
+#define WEAK
+#endif
+
+@class I;
+@class J;
+
+// The EHType shouldn't be exported
+__declspec(dllexport)
+__attribute__((objc_root_class))
+@interface K
+@end
+
+@implementation K
+@end
+
+__attribute__((objc_runtime_name("NotL")))
+@interface L
+@end
+
+@class M;
+
+@protocol P;
+
+void f(void);
+
+void g() {
+  @try {
+f();
+  } @catch (I *) {
+  } @catch (J *) {
+  } @catch (K *) {
+  } @catch (L *) {
+  } @catch (M *WEAK) {
+  } @catch (id) {
+  }
+}
Index: test/CodeGenObjC/dllstorage.m
===
--- test/CodeGenObjC/dllstorage.m
+++ test/CodeGenObjC/dllstorage.m
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-windows-msvc -fdeclspec 

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

2018-05-22 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 148117.
leonardchan marked an inline comment as done.

Repository:
  rC Clang

https://reviews.llvm.org/D46084

Files:
  include/clang-c/Index.h
  include/clang/AST/ASTContext.h
  include/clang/AST/BuiltinTypes.def
  include/clang/Basic/DiagnosticCommonKinds.td
  include/clang/Basic/Specifiers.h
  include/clang/Basic/TokenKinds.def
  include/clang/Sema/DeclSpec.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/ASTContext.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/MicrosoftMangle.cpp
  lib/AST/NSAPI.cpp
  lib/AST/Type.cpp
  lib/AST/TypeLoc.cpp
  lib/Analysis/PrintfFormatString.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CodeGenTypes.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/Index/USRGeneration.cpp
  lib/Parse/ParseDecl.cpp
  lib/Sema/DeclSpec.cpp
  lib/Sema/SemaTemplateVariadic.cpp
  lib/Sema/SemaType.cpp
  lib/Serialization/ASTCommon.cpp
  lib/Serialization/ASTReader.cpp
  test/Frontend/accum.c
  test/Frontend/accum_errors.c
  test/Frontend/accum_errors.cpp
  tools/libclang/CXType.cpp

Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -53,6 +53,12 @@
 BTCASE(Float);
 BTCASE(Double);
 BTCASE(LongDouble);
+BTCASE(ShortAccum);
+BTCASE(Accum);
+BTCASE(LongAccum);
+BTCASE(UShortAccum);
+BTCASE(UAccum);
+BTCASE(ULongAccum);
 BTCASE(Float16);
 BTCASE(Float128);
 BTCASE(NullPtr);
@@ -542,6 +548,12 @@
 TKIND(Float);
 TKIND(Double);
 TKIND(LongDouble);
+TKIND(ShortAccum);
+TKIND(Accum);
+TKIND(LongAccum);
+TKIND(UShortAccum);
+TKIND(UAccum);
+TKIND(ULongAccum);
 TKIND(Float16);
 TKIND(Float128);
 TKIND(NullPtr);
Index: test/Frontend/accum_errors.cpp
===
--- /dev/null
+++ test/Frontend/accum_errors.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -x c++ %s -verify
+
+// Name namgling is not provided for fixed point types in c++
+
+signed short _Accum s_short_accum;  // expected-error{{Fixed point types are only allowed in C}}
+signed _Accum s_accum;  // expected-error{{Fixed point types are only allowed in C}}
+signed long _Accum s_long_accum;  // expected-error{{Fixed point types are only allowed in C}}
+unsigned short _Accum u_short_accum;  // expected-error{{Fixed point types are only allowed in C}}
+unsigned _Accum u_accum;  // expected-error{{Fixed point types are only allowed in C}}
+unsigned long _Accum u_long_accum;  // expected-error{{Fixed point types are only allowed in C}}
+
+short _Accum short_accum;  // expected-error{{Fixed point types are only allowed in C}}
+_Accum accum; // expected-error{{Fixed point types are only allowed in C}}
+long _Accum long_accum;  // expected-error{{Fixed point types are only allowed in C}}
Index: test/Frontend/accum_errors.c
===
--- /dev/null
+++ test/Frontend/accum_errors.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -x c -fsyntax-only -verify -pedantic %s
+
+long long _Accum longlong_accum;  // expected-error{{'long long _Accum' is invalid}}
+unsigned long long _Accum u_longlong_accum;  // expected-error{{'long long _Accum' is invalid}}
Index: test/Frontend/accum.c
===
--- /dev/null
+++ test/Frontend/accum.c
@@ -0,0 +1,26 @@
+// RUN: %clang -cc1 -x c -ast-dump %s | FileCheck %s --strict-whitespace
+
+/*  Various contexts where type _Accum can appear. */
+
+// Primary fixed point types
+signed short _Accum s_short_accum;
+signed _Accum s_accum;
+signed long _Accum s_long_accum;
+unsigned short _Accum u_short_accum;
+unsigned _Accum u_accum;
+unsigned long _Accum u_long_accum;
+
+// Aliased fixed point types
+short _Accum short_accum;
+_Accum accum;
+long _Accum long_accum;
+
+// CHECK:  |-VarDecl {{.*}} s_short_accum 'short _Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} s_accum '_Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} s_long_accum 'long _Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} u_short_accum 'unsigned short _Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} u_accum 'unsigned _Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} u_long_accum 'unsigned long _Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} short_accum 'short _Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} accum '_Accum'
+// CHECK-NEXT: `-VarDecl {{.*}} long_accum 'long _Accum'
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -6816,6 +6816,24 @@
 case PREDEF_TYPE_LONGDOUBLE_ID:
   T = Context.LongDoubleTy;
   break;
+case PREDEF_TYPE_SHORT_ACCUM_ID:
+  T = Context.ShortAccumTy;
+  break;
+case PREDEF_TYPE_ACCUM_ID:
+  T = Context.AccumTy;
+  break;
+case PREDEF_TYPE_LONG_ACCUM_ID:
+  T = Context.LongAccumTy;
+  

[PATCH] D46986: [Fixed Point Arithmetic] Validation Test for Fixed Point Binary Operations and Saturated Addition

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

- formatting
- Running `lli` threw a segfault in the test, though this was probably because 
it was using whatever hist jit was available to optimize the code instead of 
just interpreting it. Forcing it just interpret fixes this.


Repository:
  rC Clang

https://reviews.llvm.org/D46986

Files:
  include/clang/AST/Type.h
  include/clang/Basic/FixedPoint.h.in
  lib/AST/Type.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/Sema/SemaExpr.cpp
  test/Frontend/fixed_point_all_builtin_operations.c
  test/Frontend/fixed_point_builtin_macros.c

Index: test/Frontend/fixed_point_builtin_macros.c
===
--- test/Frontend/fixed_point_builtin_macros.c
+++ test/Frontend/fixed_point_builtin_macros.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -S -emit-llvm -o - %s | lli
+// RUN: %clang_cc1 -S -emit-llvm -o - %s | lli -force-interpreter=true
 
 #define assert(b) if (!(b)) { return 1; }
 
Index: test/Frontend/fixed_point_all_builtin_operations.c
===
--- test/Frontend/fixed_point_all_builtin_operations.c
+++ test/Frontend/fixed_point_all_builtin_operations.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -Werror %s
+// RUN: %clang_cc1 -Werror -S -emit-llvm %s -o - | lli -force-interpreter=true
 
 // Check that we can use all supported binary and unary operations according to
 // clause 4.1.6 in N1169.
@@ -66,3 +66,60 @@
 ALL_OPERATIONS(short _Accum, ShortAccum);
 ALL_OPERATIONS(_Accum, Accum);
 ALL_OPERATIONS(long _Accum, LongAccum);
+
+#define ASSERT(x) \
+  if (!(x)) return 1;
+
+#define BINARY_OPS_FOR_TYPE(TYPE, ID, SUFFIX) \
+  {   \
+TYPE a = 0.5##SUFFIX; \
+TYPE b = 0.25##SUFFIX;\
+ASSERT(add##ID(a, b) == 0.75##SUFFIX);\
+ASSERT(sub##ID(a, b) == 0.25##SUFFIX);\
+ASSERT(mul##ID(a, b) == 0.125##SUFFIX);   \
+ASSERT(div##ID(b, a) == 0.5##SUFFIX); \
+ASSERT(shl##ID(b, 1) == a);   \
+ASSERT(shr##ID(a, 1) == b);   \
+ASSERT(lt##ID(b, a)); \
+ASSERT(le##ID(b, a)); \
+ASSERT(gt##ID(a, b)); \
+ASSERT(ge##ID(a, b)); \
+ASSERT(eq##ID(a, b) == 0);\
+ASSERT(ne##ID(a, b)); \
+ASSERT(augmented_add##ID(a, b) == 0.75##SUFFIX);  \
+ASSERT(augmented_sub##ID(a, b) == 0.25##SUFFIX);  \
+ASSERT(augmented_mul##ID(a, b) == 0.125##SUFFIX); \
+ASSERT(augmented_div##ID(b, a) == 0.5##SUFFIX);   \
+ASSERT(augmented_shl##ID(b, 1) == a); \
+ASSERT(augmented_shr##ID(a, 1) == b); \
+  }
+
+#define BINARY_OPS(TYPE, ID, SUFFIX)\
+  BINARY_OPS_FOR_TYPE(TYPE, ID, SUFFIX);\
+  BINARY_OPS_FOR_TYPE(signed TYPE, Signed##ID, SUFFIX); \
+  BINARY_OPS_FOR_TYPE(unsigned TYPE, Unsigned##ID, u##SUFFIX);  \
+  BINARY_OPS_FOR_TYPE(_Sat TYPE, Sat##ID, SUFFIX);  \
+  BINARY_OPS_FOR_TYPE(_Sat signed TYPE, SatSigned##ID, SUFFIX); \
+  BINARY_OPS_FOR_TYPE(_Sat unsigned TYPE, SatUnsigned##ID, u##SUFFIX);
+
+#define FRACT_SAT_BINARY_OPS(TYPE, ID, SUFFIX) \
+  {\
+TYPE a = 0.7##SUFFIX;  \
+TYPE b = 0.9##SUFFIX;  \
+ASSERT(add##ID(a, b) == 1.0##SUFFIX);  \
+  }
+
+int main() {
+  BINARY_OPS(short _Fract, ShortFract, hr);
+  BINARY_OPS(_Fract, Fract, r);
+  BINARY_OPS(long _Fract, LongFract, lr);
+  BINARY_OPS(short _Accum, ShortAccum, hk);
+  BINARY_OPS(_Accum, Accum, k);
+  BINARY_OPS(long _Accum, LongAccum, lk);
+
+  FRACT_SAT_BINARY_OPS(_Sat short _Fract, SatShortFract, hr);
+  FRACT_SAT_BINARY_OPS(_Sat _Fract, SatFract, r);
+  FRACT_SAT_BINARY_OPS(_Sat long _Fract, SatLongFract, lr);
+
+  return 0;
+}
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -1258,8 +1258,12 @@
   return FixedPointTy;
 }
 
-/// \brief Handle arithmethic conversion with fixed point types.  Helper
-/// function of UsualArithmeticConversions().
+/// \brief Handle arithmethic conversion with fixed point types. The usual
+/// arithmetic conversions do not apply to fixed point type conversions between
+/// integers or other fixed point types due to potential loss of precision.
+/// For this case of fixed point types, the resulting type in a binary operation
+/// does not need to be exactly one of the 2 operand types.
+/// Implemented according to Clause 6.3.1.8 of ISO/IEC JTC1 SC22 WG14 N1169.
 static QualType handleFixedPointConversion(Sema , ExprResult ,

[PATCH] D47182: [X86] Move all Intel defined intrinsic includes into immintrin.h

2018-05-22 Thread Craig Topper via Phabricator via cfe-commits
craig.topper updated this revision to Diff 148115.
craig.topper added a comment.

Leave the message still saying x86intrin.h. Change the error checks to look for 
either x86intrin.h or immintrin.h to have been included. Really only the 
immintrin.h check is necessary since that's the header that does the include, 
but I put both so the error message saying x86intrin.h would be less confusing.


https://reviews.llvm.org/D47182

Files:
  lib/Headers/cldemoteintrin.h
  lib/Headers/clzerointrin.h
  lib/Headers/immintrin.h
  lib/Headers/movdirintrin.h
  lib/Headers/pconfigintrin.h
  lib/Headers/ptwriteintrin.h
  lib/Headers/rdseedintrin.h
  lib/Headers/sgxintrin.h
  lib/Headers/waitpkgintrin.h
  lib/Headers/wbnoinvdintrin.h
  lib/Headers/x86intrin.h

Index: lib/Headers/x86intrin.h
===
--- lib/Headers/x86intrin.h
+++ lib/Headers/x86intrin.h
@@ -32,26 +32,6 @@
 #include 
 #endif
 
-#if !defined(_MSC_VER) || __has_feature(modules) || defined(__BMI__)
-#include 
-#endif
-
-#if !defined(_MSC_VER) || __has_feature(modules) || defined(__BMI2__)
-#include 
-#endif
-
-#if !defined(_MSC_VER) || __has_feature(modules) || defined(__LZCNT__)
-#include 
-#endif
-
-#if !defined(_MSC_VER) || __has_feature(modules) || defined(__POPCNT__)
-#include 
-#endif
-
-#if !defined(_MSC_VER) || __has_feature(modules) || defined(__RDSEED__)
-#include 
-#endif
-
 #if !defined(_MSC_VER) || __has_feature(modules) || defined(__PRFCHW__)
 #include 
 #endif
@@ -76,45 +56,8 @@
 #include 
 #endif
 
-#if !defined(_MSC_VER) || __has_feature(modules) || defined(__F16C__)
-#include 
-#endif
-
 #if !defined(_MSC_VER) || __has_feature(modules) || defined(__MWAITX__)
 #include 
 #endif
 
-#if !defined(_MSC_VER) || __has_feature(modules) || defined(__CLZERO__)
-#include 
-#endif
-
-#if !defined(_MSC_VER) || __has_feature(modules) || defined(__WBNOINVD__)
-#include 
-#endif
-
-#if !defined(_MSC_VER) || __has_feature(modules) || defined(__CLDEMOTE__)
-#include 
-#endif
-
-#if !defined(_MSC_VER) || __has_feature(modules) || defined(__WAITPKG__)
-#include 
-#endif
-
-#if !defined(_MSC_VER) || __has_feature(modules) || \
-  defined(__MOVDIRI__) || defined(__MOVDIR64B__)
-#include 
-#endif
-
-#if !defined(_MSC_VER) || __has_feature(modules) || defined(__PCONFIG__)
-#include 
-#endif
-
-#if !defined(_MSC_VER) || __has_feature(modules) || defined(__SGX__)
-#include 
-#endif
-
-#if !defined(_MSC_VER) || __has_feature(modules) || defined(__PTWRITE__)
-#include 
-#endif
-
 #endif /* __X86INTRIN_H */
Index: lib/Headers/wbnoinvdintrin.h
===
--- lib/Headers/wbnoinvdintrin.h
+++ lib/Headers/wbnoinvdintrin.h
@@ -21,7 +21,7 @@
  *===---===
  */
 
-#ifndef __X86INTRIN_H
+#if !defined __X86INTRIN_H && !defined __IMMINTRIN_H
 #error "Never use  directly; include  instead."
 #endif
 
Index: lib/Headers/waitpkgintrin.h
===
--- lib/Headers/waitpkgintrin.h
+++ lib/Headers/waitpkgintrin.h
@@ -20,7 +20,7 @@
  *
  *===---===
  */
-#ifndef __X86INTRIN_H
+#if !defined __X86INTRIN_H && !defined __IMMINTRIN_H
 #error "Never use  directly; include  instead."
 #endif
 
Index: lib/Headers/sgxintrin.h
===
--- lib/Headers/sgxintrin.h
+++ lib/Headers/sgxintrin.h
@@ -21,7 +21,7 @@
  *===---===
  */
 
-#ifndef __X86INTRIN_H
+#if !defined __X86INTRIN_H && !defined __IMMINTRIN_H
 #error "Never use  directly; include  instead."
 #endif
 
Index: lib/Headers/rdseedintrin.h
===
--- lib/Headers/rdseedintrin.h
+++ lib/Headers/rdseedintrin.h
@@ -21,7 +21,7 @@
  *===---===
  */
 
-#ifndef __X86INTRIN_H
+#if !defined __X86INTRIN_H && !defined __IMMINTRIN_H
 #error "Never use  directly; include  instead."
 #endif
 
Index: lib/Headers/ptwriteintrin.h
===
--- lib/Headers/ptwriteintrin.h
+++ lib/Headers/ptwriteintrin.h
@@ -21,7 +21,7 @@
  *===---===
  */
 
-#ifndef __X86INTRIN_H
+#if !defined __X86INTRIN_H && !defined __IMMINTRIN_H
 #error "Never use  directly; include  instead."
 #endif
 
Index: lib/Headers/pconfigintrin.h
===
--- lib/Headers/pconfigintrin.h
+++ lib/Headers/pconfigintrin.h
@@ -21,7 +21,7 @@
  *===---===
  */
 
-#ifndef __X86INTRIN_H
+#if !defined __X86INTRIN_H && !defined __IMMINTRIN_H
 #error "Never use  directly; include  instead."
 #endif
 

[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-22 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

Implemented @DavidKreitzer's suggestion in r333033


Repository:
  rL LLVM

https://reviews.llvm.org/D47174



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


r333033 - [X86] As mentioned in post-commit feedback in D47174, move the 128 bit f16c intrinsics into f16cintrin.h and remove __emmintrin_f16c.h

2018-05-22 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Tue May 22 15:19:19 2018
New Revision: 333033

URL: http://llvm.org/viewvc/llvm-project?rev=333033=rev
Log:
[X86] As mentioned in post-commit feedback in D47174, move the 128 bit f16c 
intrinsics into f16cintrin.h and remove __emmintrin_f16c.h

These were included in emmintrin.h to match Intel Intrinsics Guide 
documentation. But this is because icc is capable of emulating them on targets 
that don't support F16C using library calls. Clang/LLVM doesn't have this 
emulation support. So it makes more sense to include them in immintrin.h 
instead.

I've left a comment behind to hopefully deter someone from trying to move them 
again in the future.

Removed:
cfe/trunk/lib/Headers/__emmintrin_f16c.h
Modified:
cfe/trunk/lib/Headers/CMakeLists.txt
cfe/trunk/lib/Headers/emmintrin.h
cfe/trunk/lib/Headers/f16cintrin.h
cfe/trunk/lib/Headers/module.modulemap

Modified: cfe/trunk/lib/Headers/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/CMakeLists.txt?rev=333033=333032=333033=diff
==
--- cfe/trunk/lib/Headers/CMakeLists.txt (original)
+++ cfe/trunk/lib/Headers/CMakeLists.txt Tue May 22 15:19:19 2018
@@ -46,7 +46,6 @@ set(files
   clflushoptintrin.h
   clwbintrin.h
   emmintrin.h
-  __emmintrin_f16c.h
   f16cintrin.h
   float.h
   fma4intrin.h

Removed: cfe/trunk/lib/Headers/__emmintrin_f16c.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__emmintrin_f16c.h?rev=333032=auto
==
--- cfe/trunk/lib/Headers/__emmintrin_f16c.h (original)
+++ cfe/trunk/lib/Headers/__emmintrin_f16c.h (removed)
@@ -1,124 +0,0 @@
-/*=== __emmintrin_f16c.h - F16C intrinsics -===
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to 
deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- *===---===
- */
-
-#if !defined __EMMINTRIN_H
-#error "Never use <__emmintrin_f16c.h> directly; include  
instead."
-#endif
-
-#ifndef __EMMINTRIN_F16C_H
-#define __EMMINTRIN_F16C_H
-
-/* Define the default attributes for the functions in this file. */
-#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
-///1XX: Use MXCSR.RC for rounding
-/// \returns The converted 16-bit half-precision float value.
-#define _cvtss_sh(a, imm) __extension__ ({ \
-  (unsigned short)(((__v8hi)__builtin_ia32_vcvtps2ph((__v4sf){a, 0, 0, 0}, \
- (imm)))[0]); })
-
-/// Converts a 128-bit vector containing 32-bit float values into a
-///128-bit vector containing 16-bit half-precision float values.
-///
-/// \headerfile 
-///
-/// \code
-/// __m128i _mm_cvtps_ph(__m128 a, const int imm);
-/// \endcode
-///
-/// This intrinsic 

[PATCH] D47138: [Sparc] Use the leon arch for Leon3's when using an external assembler

2018-05-22 Thread James Y Knight via Phabricator via cfe-commits
jyknight accepted this revision.
jyknight added a comment.
This revision is now accepted and ready to land.

In https://reviews.llvm.org/D47138#1107637, @dcederman wrote:

> I did not find a good way to access the SparcCPUInfo struct from here. No 
> other arch under Toolchains seems to access TargetInfo.


OK.


https://reviews.llvm.org/D47138



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


[PATCH] D47229: Make atomic non-member functions as nonnull

2018-05-22 Thread JF Bastien via Phabricator via cfe-commits
jfb created this revision.
jfb added a reviewer: arphaman.
Herald added subscribers: cfe-commits, aheejin.

As a companion to libc++ patch https://reviews.llvm.org/D47225, mark builtin 
atomic non-member functions which accept pointers as nonnull.

The atomic non-member functions accept pointers to std::atomic / 
std::atomic_flag as well as to the non-atomic value. These are all dereferenced 
unconditionally when lowered, and therefore will fault if null. It's a tiny 
gotcha for new users, especially when they pass in NULL as expected value 
(instead of passing a pointer to a NULL value).

rdar://problem/18473124


Repository:
  rC Clang

https://reviews.llvm.org/D47229

Files:
  lib/Sema/SemaChecking.cpp
  test/Sema/atomic-ops.c

Index: test/Sema/atomic-ops.c
===
--- test/Sema/atomic-ops.c
+++ test/Sema/atomic-ops.c
@@ -531,8 +531,80 @@
 }
 
 void nullPointerWarning(_Atomic(int) *Ap, int *p, int val) {
-  // The 'expected' pointer shouldn't be NULL.
-  (void)__c11_atomic_compare_exchange_strong(Ap, NULL, val, memory_order_relaxed, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
-  (void)atomic_compare_exchange_weak(Ap, ((void*)0), val); // expected-warning {{null passed to a callee that requires a non-null argument}}
-  (void)__atomic_compare_exchange_n(p, NULL, val, 0, memory_order_relaxed, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+  volatile _Atomic(int) vai;
+  _Atomic(int) ai;
+  volatile int vi = 42;
+  int i = 42;
+
+  __c11_atomic_init((volatile _Atomic(int)*)0, 42); // expected-warning {{null passed to a callee that requires a non-null argument}}
+  __c11_atomic_init((_Atomic(int)*)0, 42); // expected-warning {{null passed to a callee that requires a non-null argument}}
+  __c11_atomic_store((volatile _Atomic(int)*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+  __c11_atomic_store((_Atomic(int)*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+  (void)__c11_atomic_load((volatile _Atomic(int)*)0, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+  (void)__c11_atomic_load((_Atomic(int)*)0, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+  (void)__c11_atomic_exchange((volatile _Atomic(int)*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+  (void)__c11_atomic_exchange((_Atomic(int)*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+  (void)__c11_atomic_compare_exchange_weak((volatile _Atomic(int)*)0, , 42, memory_order_relaxed, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+  (void)__c11_atomic_compare_exchange_weak((_Atomic(int)*)0, , 42, memory_order_relaxed, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+  (void)__c11_atomic_compare_exchange_weak(, (int*)0, 42, memory_order_relaxed, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+  (void)__c11_atomic_compare_exchange_weak(, (int*)0, 42, memory_order_relaxed, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+  (void)__c11_atomic_compare_exchange_strong((volatile _Atomic(int)*)0, , 42, memory_order_relaxed, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+  (void)__c11_atomic_compare_exchange_strong((_Atomic(int)*)0, , 42, memory_order_relaxed, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+  (void)__c11_atomic_compare_exchange_strong(, (int*)0, 42, memory_order_relaxed, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+  (void)__c11_atomic_compare_exchange_strong(, (int*)0, 42, memory_order_relaxed, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+  (void)__c11_atomic_fetch_add((volatile _Atomic(int)*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+  (void)__c11_atomic_fetch_add((_Atomic(int)*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+  (void)__c11_atomic_fetch_sub((volatile _Atomic(int)*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a callee that requires a non-null argument}}
+  (void)__c11_atomic_fetch_sub((_Atomic(int)*)0, 42, memory_order_relaxed); // expected-warning {{null passed to a 

[PATCH] D47182: [X86] Move all Intel defined intrinsic includes into immintrin.h

2018-05-22 Thread David Kreitzer via Phabricator via cfe-commits
DavidKreitzer added a comment.

I agree with the changes in x86intrin.h and immintrin.h.  For the others, I 
question whether we ought to recommend inclusion of x86intrin.h or immintrin.h. 
The distinction as I understand it is that immintrin.h is used for 
Intel-specific intrinsics while x86intrin.h covers all intrinsics for x86-based 
architectures.


Repository:
  rC Clang

https://reviews.llvm.org/D47182



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


r333027 - [X86] Remove mask argument from some builtins that are handled completely in CGBuiltin.cpp. Just wrap a select builtin around them in the header file instead.

2018-05-22 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Tue May 22 13:48:24 2018
New Revision: 333027

URL: http://llvm.org/viewvc/llvm-project?rev=333027=rev
Log:
[X86] Remove mask argument from some builtins that are handled completely in 
CGBuiltin.cpp. Just wrap a select builtin around them in the header file 
instead.

Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/Headers/avx512bwintrin.h
cfe/trunk/lib/Headers/avx512cdintrin.h
cfe/trunk/lib/Headers/avx512vlcdintrin.h
cfe/trunk/lib/Sema/SemaChecking.cpp

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=333027=333026=333027=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Tue May 22 13:48:24 2018
@@ -1102,8 +1102,8 @@ TARGET_BUILTIN(__builtin_ia32_vpconflict
 TARGET_BUILTIN(__builtin_ia32_vpconflictsi_256_mask, "V8iV8iV8iUc", "nc", 
"avx512cd,avx512vl")
 TARGET_BUILTIN(__builtin_ia32_vpconflictdi_512_mask, "V8LLiV8LLiV8LLiUc", 
"nc", "avx512cd")
 TARGET_BUILTIN(__builtin_ia32_vpconflictsi_512_mask, "V16iV16iV16iUs", "nc", 
"avx512cd")
-TARGET_BUILTIN(__builtin_ia32_vplzcntd_512_mask, "V16iV16iV16iUs", "nc", 
"avx512cd")
-TARGET_BUILTIN(__builtin_ia32_vplzcntq_512_mask, "V8LLiV8LLiV8LLiUc", "nc", 
"avx512cd")
+TARGET_BUILTIN(__builtin_ia32_vplzcntd_512, "V16iV16i", "nc", "avx512cd")
+TARGET_BUILTIN(__builtin_ia32_vplzcntq_512, "V8LLiV8LLi", "nc", "avx512cd")
 
 TARGET_BUILTIN(__builtin_ia32_vpopcntd_128, "V4iV4i", "nc", 
"avx512vpopcntdq,avx512vl")
 TARGET_BUILTIN(__builtin_ia32_vpopcntq_128, "V2LLiV2LLi", "nc", 
"avx512vpopcntdq,avx512vl")
@@ -1550,10 +1550,10 @@ TARGET_BUILTIN(__builtin_ia32_rcp14pd128
 TARGET_BUILTIN(__builtin_ia32_rcp14pd256_mask, "V4dV4dV4dUc", "nc", "avx512vl")
 TARGET_BUILTIN(__builtin_ia32_rcp14ps128_mask, "V4fV4fV4fUc", "nc", "avx512vl")
 TARGET_BUILTIN(__builtin_ia32_rcp14ps256_mask, "V8fV8fV8fUc", "nc", "avx512vl")
-TARGET_BUILTIN(__builtin_ia32_vplzcntd_128_mask, "V4iV4iV4iUc", "nc", 
"avx512cd,avx512vl")
-TARGET_BUILTIN(__builtin_ia32_vplzcntd_256_mask, "V8iV8iV8iUc", "nc", 
"avx512cd,avx512vl")
-TARGET_BUILTIN(__builtin_ia32_vplzcntq_128_mask, "V2LLiV2LLiV2LLiUc", "nc", 
"avx512cd,avx512vl")
-TARGET_BUILTIN(__builtin_ia32_vplzcntq_256_mask, "V4LLiV4LLiV4LLiUc", "nc", 
"avx512cd,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_vplzcntd_128, "V4iV4i", "nc", 
"avx512cd,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_vplzcntd_256, "V8iV8i", "nc", 
"avx512cd,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_vplzcntq_128, "V2LLiV2LLi", "nc", 
"avx512cd,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_vplzcntq_256, "V4LLiV4LLi", "nc", 
"avx512cd,avx512vl")
 TARGET_BUILTIN(__builtin_ia32_vcvtsd2si32, "iV2dIi", "nc", "avx512f")
 TARGET_BUILTIN(__builtin_ia32_vcvtsd2usi32, "UiV2dIi", "nc", "avx512f")
 TARGET_BUILTIN(__builtin_ia32_vcvtss2si32, "iV4fIi", "nc", "avx512f")
@@ -1778,7 +1778,7 @@ TARGET_BUILTIN(__builtin_ia32_kortestzhi
 TARGET_BUILTIN(__builtin_ia32_kunpckhi, "UsUsUs", "nc", "avx512f")
 TARGET_BUILTIN(__builtin_ia32_kxnorhi, "UsUsUs", "nc", "avx512f")
 TARGET_BUILTIN(__builtin_ia32_kxorhi, "UsUsUs", "nc", "avx512f")
-TARGET_BUILTIN(__builtin_ia32_palignr512_mask, "V64cV64cV64cIiV64cULLi", "nc", 
"avx512bw")
+TARGET_BUILTIN(__builtin_ia32_palignr512, "V64cV64cV64cIi", "nc", "avx512bw")
 TARGET_BUILTIN(__builtin_ia32_dbpsadbw128_mask, "V8sV16cV16cIiV8sUc", "nc", 
"avx512bw,avx512vl")
 TARGET_BUILTIN(__builtin_ia32_dbpsadbw256_mask, "V16sV32cV32cIiV16sUs", "nc", 
"avx512bw,avx512vl")
 TARGET_BUILTIN(__builtin_ia32_dbpsadbw512_mask, "V32sV64cV64cIiV32sUi", "nc", 
"avx512bw")

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=333027=333026=333027=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Tue May 22 13:48:24 2018
@@ -8890,7 +8890,7 @@ Value *CodeGenFunction::EmitX86BuiltinEx
   }
   case X86::BI__builtin_ia32_palignr128:
   case X86::BI__builtin_ia32_palignr256:
-  case X86::BI__builtin_ia32_palignr512_mask: {
+  case X86::BI__builtin_ia32_palignr512: {
 unsigned ShiftVal = cast(Ops[2])->getZExtValue();
 
 unsigned NumElts = Ops[0]->getType()->getVectorNumElements();
@@ -8920,15 +8920,9 @@ Value *CodeGenFunction::EmitX86BuiltinEx
   }
 }
 
-Value *Align = Builder.CreateShuffleVector(Ops[1], Ops[0],
-   makeArrayRef(Indices, NumElts),
-   "palignr");
-
-// If this isn't a masked builtin, just return the align operation.
-if (Ops.size() == 3)
-  return Align;
-
-return EmitX86Select(*this, Ops[4], Align, Ops[3]);
+return 

r333026 - [X86] Another attempt at fixing the intrinsic module map for rr333014.

2018-05-22 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Tue May 22 13:48:20 2018
New Revision: 333026

URL: http://llvm.org/viewvc/llvm-project?rev=333026=rev
Log:
[X86] Another attempt at fixing the intrinsic module map for rr333014.

Modified:
cfe/trunk/lib/Headers/module.modulemap

Modified: cfe/trunk/lib/Headers/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/module.modulemap?rev=333026=333025=333026=diff
==
--- cfe/trunk/lib/Headers/module.modulemap (original)
+++ cfe/trunk/lib/Headers/module.modulemap Tue May 22 13:48:20 2018
@@ -99,7 +99,7 @@ module _Builtin_intrinsics [system] [ext
   header "emmintrin.h"
 }
 
-explicit f16c_128 {
+explicit module f16c_128 {
   header "__emmintrin_f16c.h"
 }
 


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


[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-22 Thread David Kreitzer via Phabricator via cfe-commits
DavidKreitzer added a comment.

A bit of history: In icc, the f16<=>f32 conversion intrinsics are a bit of an 
anomaly in that they can be implemented using either native code or emulation 
code based on the target architecture switch. See https://godbolt.org/g/bQy7xY 
(thanks, Craig, for the example code). The emulation code lives in the Intel 
Math Library.

The reason icc chose to declare the scalar & 128-bit versions of the intrinsics 
in emmintrin.h rather than a header file that more closely corresponds to the 
f16c feature is that emmintrin.h contains the minimum necessary to use the 
emulation code, i.e. the declaration of the __m128i type.

Given that clang doesn't support the lowering of these intrinsics to emulation 
code, I don't see much benefit including them in emmintrin.h. It would make 
more sense to just put everything in f16cintrin.h and include that from 
immintrin.h.

In brief, I like your changes in immintrin.h. I would move the code from 
_emmintrin_f16c.h into f16cintrin.h. And I would remove the include from 
emmintrin.h. I think that would be consistent with gcc as well. We can let the 
emulation behavior of these intrinsics remain an icc-specific anomaly.


Repository:
  rL LLVM

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] D43341: [clang-doc] Implement reducer portion of the frontend framework

2018-05-22 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett added a comment.

ping


https://reviews.llvm.org/D43341



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


[PATCH] D44954: [clangd] Add "member" symbols to the index

2018-05-22 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle added a comment.

In https://reviews.llvm.org/D44954#1104497, @malaperle wrote:

> >>> What scopes will non-scoped enum members have?
> >> 
> >> Hmm. I think all of them, since you can refer them like that in code too. 
> >> Case #1 doesn't work but that was the case before this patch so it can 
> >> probably be addressed separately. I'll add some tests though!
> > 
> > I would vote for making queries `En::A` and `A` match the enumerator, but 
> > **not** `::A`. The reasoning is: yes, you can reference it this way in a 
> > C++ file, but `workspaceSymbol` is not a real C++ resolve and I think it 
> > should match the outline of the code rather than the actual C++ lookup 
> > rules.
> >  E.g. I wouldn't expect it to match symbols from base classes, etc. This 
> > should also simplify implementation too.
>
> I don't have a strong opinion, so I can try this suggestion!


I changed the behavior of non-scoped enums as suggested here: 
https://reviews.llvm.org/D47223


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44954



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


[PATCH] D47225: Add nonnull; use it for atomics

2018-05-22 Thread JF Bastien via Phabricator via cfe-commits
jfb created this revision.
jfb added reviewers: arphaman, EricWF.
Herald added subscribers: cfe-commits, christof, aheejin.

The atomic non-member functions accept pointers to std::atomic / 
std::atomic_flag as well as to the non-atomic value. These are all dereferenced 
unconditionally when lowered, and therefore will fault if null. It's a tiny 
gotcha for new users, especially when they pass in NULL as expected value 
(instead of passing a pointer to a NULL value). We can therefore use the 
nonnull attribute to denote that:

- A warning should be generated if the argument is null
- It is undefined behavior if the argument is null (because a dereference will 
segfault)

This patch adds support for this attribute for clang and GCC, and sticks to the 
subset of the syntax both supports. In particular, work around this GCC oddity:

  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60625

The attributes are documented:

- https://gcc.gnu.org/onlinedocs/gcc-4.0.0/gcc/Function-Attributes.html
- https://clang.llvm.org/docs/AttributeReference.html#nullability-attributes

I'm authoring a companion clang patch for the __c11_* and __atomic_* builtins, 
which currently only warn on a subset of the pointer parameters.

In all cases the check needs to be explicit and not use the empty nonnull list, 
because some of the overloads are for atomic and the values themselves are 
allowed to be null.

rdar://problem/18473124


Repository:
  rCXX libc++

https://reviews.llvm.org/D47225

Files:
  include/__config
  include/atomic
  test/libcxx/atomics/diagnose_nonnull.fail.cpp

Index: test/libcxx/atomics/diagnose_nonnull.fail.cpp
===
--- /dev/null
+++ test/libcxx/atomics/diagnose_nonnull.fail.cpp
@@ -0,0 +1,92 @@
+//===--===//
+//
+// 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.
+//
+//===--===//
+
+// REQUIRES: verify-support
+// UNSUPPORTED: libcpp-has-no-threads
+
+// 
+
+// Test that null pointer parameters are diagnosed.
+
+#include 
+
+int main() {
+  std::atomic ai = ATOMIC_VAR_INIT(0);
+  volatile std::atomic vai = ATOMIC_VAR_INIT(0);
+  int i = 42;
+
+  atomic_is_lock_free((const volatile std::atomic*)0); // expected-error {{null passed to a callee that requires a non-null argument}}
+  atomic_is_lock_free((const std::atomic*)0); // expected-error {{null passed to a callee that requires a non-null argument}}
+  atomic_init((volatile std::atomic*)0, 42); // expected-error {{null passed to a callee that requires a non-null argument}}
+  atomic_init((std::atomic*)0, 42); // expected-error {{null passed to a callee that requires a non-null argument}}
+  atomic_store((volatile std::atomic*)0, 42); // expected-error {{null passed to a callee that requires a non-null argument}}
+  atomic_store((std::atomic*)0, 42); // expected-error {{null passed to a callee that requires a non-null argument}}
+  atomic_store_explicit((volatile std::atomic*)0, 42, std::memory_order_relaxed); // expected-error {{null passed to a callee that requires a non-null argument}}
+  atomic_store_explicit((std::atomic*)0, 42, std::memory_order_relaxed); // expected-error {{null passed to a callee that requires a non-null argument}}
+  (void)atomic_load((const volatile std::atomic*)0); // expected-error {{null passed to a callee that requires a non-null argument}}
+  (void)atomic_load((const std::atomic*)0); // expected-error {{null passed to a callee that requires a non-null argument}}
+  (void)atomic_load_explicit((const volatile std::atomic*)0, std::memory_order_relaxed); // expected-error {{null passed to a callee that requires a non-null argument}}
+  (void)atomic_load_explicit((const std::atomic*)0, std::memory_order_relaxed); // expected-error {{null passed to a callee that requires a non-null argument}}
+  (void)atomic_exchange((volatile std::atomic*)0, 42); // expected-error {{null passed to a callee that requires a non-null argument}}
+  (void)atomic_exchange((std::atomic*)0, 42); // expected-error {{null passed to a callee that requires a non-null argument}}
+  (void)atomic_exchange_explicit((volatile std::atomic*)0, 42, std::memory_order_relaxed); // expected-error {{null passed to a callee that requires a non-null argument}}
+  (void)atomic_exchange_explicit((std::atomic*)0, 42, std::memory_order_relaxed); // expected-error {{null passed to a callee that requires a non-null argument}}
+  (void)atomic_compare_exchange_weak((volatile std::atomic*)0, , 42); // expected-error {{null passed to a callee that requires a non-null argument}}
+  (void)atomic_compare_exchange_weak((std::atomic*)0, , 42); // expected-error {{null passed to a callee that requires a non-null argument}}
+  

[PATCH] D47223: [clangd] Handle enumerators in named, unscoped enums similarly to scoped enums

2018-05-22 Thread Marc-Andre Laperle via Phabricator via cfe-commits
malaperle created this revision.
Herald added subscribers: cfe-commits, jkorous, MaskRay, ioeric, ilya-biryukov, 
klimek.

For enumerators in unscoped enums that have names, even if they are not
scoped, we add the enum name to the scope so that users can find the
enumerators when fully qualifying them, for example: MyEnum::Enumerator.
This makes it more consistent with how the code is visually laid out.

Signed-off-by: Marc-Andre Laperle 


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D47223

Files:
  clangd/index/SymbolCollector.cpp
  unittests/clangd/SymbolCollectorTests.cpp

Index: unittests/clangd/SymbolCollectorTests.cpp
===
--- unittests/clangd/SymbolCollectorTests.cpp
+++ unittests/clangd/SymbolCollectorTests.cpp
@@ -343,9 +343,9 @@
 }
   )";
   runSymbolCollector(Header, /*Main=*/"");
-  EXPECT_THAT(Symbols, UnorderedElementsAre(QName("Red"), QName("Color"),
-QName("Green"), QName("Color2"),
-QName("ns"), QName("ns::Black")));
+  EXPECT_THAT(Symbols, UnorderedElementsAre(
+   QName("Red"), QName("Color"), QName("Color::Green"),
+   QName("Color2"), QName("ns"), QName("ns::Black")));
 }
 
 TEST_F(SymbolCollectorTest, IgnoreNamelessSymbols) {
@@ -726,10 +726,10 @@
bool operator<(const TopLevel &, const TopLevel &);
  })";
   runSymbolCollector(Header, /*Main=*/"");
-  EXPECT_THAT(Symbols,
-  UnorderedElementsAre(QName("nx"), QName("nx::TopLevel"),
-   QName("nx::Kind"), QName("nx::KIND_OK"),
-   QName("nx::operator<")));
+  EXPECT_THAT(Symbols, UnorderedElementsAre(QName("nx"), QName("nx::TopLevel"),
+QName("nx::Kind"),
+QName("nx::Kind::KIND_OK"),
+QName("nx::operator<")));
 }
 
 TEST_F(SymbolCollectorTest, DoubleCheckProtoHeaderComment) {
@@ -743,9 +743,9 @@
   }
   )";
   runSymbolCollector(Header, /*Main=*/"");
-  EXPECT_THAT(Symbols,
-  UnorderedElementsAre(QName("nx"), QName("nx::Top_Level"),
-   QName("nx::Kind"), QName("nx::Kind_Fine")));
+  EXPECT_THAT(Symbols, UnorderedElementsAre(QName("nx"), QName("nx::Top_Level"),
+QName("nx::Kind"),
+QName("nx::Kind::Kind_Fine")));
 }
 
 } // namespace
Index: clangd/index/SymbolCollector.cpp
===
--- clangd/index/SymbolCollector.cpp
+++ clangd/index/SymbolCollector.cpp
@@ -264,6 +264,21 @@
  match(decl(isExpansionInMainFile()), ND, ND.getASTContext()).empty();
 }
 
+std::string getQualifiedName(const NamedDecl ) {
+  std::string QName;
+  llvm::raw_string_ostream OS(QName);
+  PrintingPolicy Policy(ND.getASTContext().getLangOpts());
+  // Note that inline namespaces are treated as transparent scopes. This
+  // reflects the way they're most commonly used for lookup. Ideally we'd
+  // include them, but at query time it's hard to find all the inline
+  // namespaces to query: the preamble doesn't have a dedicated list.
+  Policy.SuppressUnwrittenScope = true;
+  ND.printQualifiedName(OS, Policy);
+  OS.flush();
+  assert(!StringRef(QName).startswith("::"));
+  return QName;
+}
+
 } // namespace
 
 SymbolCollector::SymbolCollector(Options Opts) : Opts(std::move(Opts)) {}
@@ -341,21 +356,29 @@
   auto  = ND.getASTContext();
   auto  = Ctx.getSourceManager();
 
-  std::string QName;
-  llvm::raw_string_ostream OS(QName);
-  PrintingPolicy Policy(ASTCtx->getLangOpts());
-  // Note that inline namespaces are treated as transparent scopes. This
-  // reflects the way they're most commonly used for lookup. Ideally we'd
-  // include them, but at query time it's hard to find all the inline
-  // namespaces to query: the preamble doesn't have a dedicated list.
-  Policy.SuppressUnwrittenScope = true;
-  ND.printQualifiedName(OS, Policy);
-  OS.flush();
-  assert(!StringRef(QName).startswith("::"));
+  std::string QName = getQualifiedName(ND);
 
   Symbol S;
   S.ID = std::move(ID);
   std::tie(S.Scope, S.Name) = splitQualifiedName(QName);
+
+  using namespace clang::ast_matchers;
+  // For enumerators in unscoped enums that have names, even if they are not
+  // scoped, we add the enum name to the scope so that users can find the
+  // enumerators when fully qualifying them, for example: MyEnum::Enumerator.
+  auto InUnscopedEnum =
+  match(decl(hasDeclContext(enumDecl(unless(isScoped())).bind("enum"))), ND,
+*ASTCtx);
+  std::string EnumQName;
+  if (!InUnscopedEnum.empty()) {
+auto Enum = InUnscopedEnum[0].getNodeAs("enum");
+if (Enum->getDeclName()) {
+  

[PATCH] D47067: Update NRVO logic to support early return

2018-05-22 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added inline comments.



Comment at: lib/Sema/SemaDecl.cpp:12760
   // to deduce an implicit return type.
-  if (FD->getReturnType()->isRecordType() &&
-  (!getLangOpts().CPlusPlus || !FD->isDependentContext()))
+  if (!FD->getReturnType()->isScalarType())
 computeNRVO(Body, getCurFunction());

What is the purpose of this change?
If it's "no functional change" it should be done separately IMHO; if it is 
supposed to change codegen, then it needs some codegen tests. (From looking at 
the code: maybe this affects codegen on functions that return member function 
pointers by value?)



Comment at: test/CodeGenCXX/nrvo.cpp:139
   }
-  // FIXME: we should NRVO this variable too.
-  X x;
+  // CHECK: tail call {{.*}} @_ZN1XC1ERKS_
   return x;

You've changed this function from testing one thing with a FIXME, to testing a 
completely different thing.  Could you add your new code as a new function, and 
leave the old FIXME alone until it's fixed?
Alternatively, if your patch actually fixes the FIXME, could you just replace 
the FIXME comment with a CHECK and leave the rest of this function alone?



Comment at: test/CodeGenCXX/nrvo.cpp:254
+  T t;
+  return t;
+}

Just for my own curiosity: this new test case is surely unaffected by this 
patch, right?


Repository:
  rC Clang

https://reviews.llvm.org/D47067



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


r333023 - [X86] Add two missing #endif directives to immintrin.h that should have been in r333014.

2018-05-22 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Tue May 22 13:33:04 2018
New Revision: 333023

URL: http://llvm.org/viewvc/llvm-project?rev=333023=rev
Log:
[X86] Add two missing #endif directives to immintrin.h that should have been in 
r333014.

Modified:
cfe/trunk/lib/Headers/immintrin.h

Modified: cfe/trunk/lib/Headers/immintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/immintrin.h?rev=333023=333022=333023=diff
==
--- cfe/trunk/lib/Headers/immintrin.h (original)
+++ cfe/trunk/lib/Headers/immintrin.h Tue May 22 13:33:04 2018
@@ -68,9 +68,11 @@
 
 #if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX2__)
 #include 
+#endif
 
 #if !defined(_MSC_VER) || __has_feature(modules) || defined(__F16C__)
 #include 
+#endif
 
 #if !defined(_MSC_VER) || __has_feature(modules) || defined(__VPCLMULQDQ__)
 #include 


___
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-22 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

We'll have to track `string_view` ourselves, not relying on `MallocChecker`. So 
we only need an `AF_` for the pointer case.

`DanglingInternalBufferChecker` and `AF_InternalBuffer` sound great to me.


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


r333020 - [X86] Add __emmintrin_f16c.h to module map and CMakeLists.

2018-05-22 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Tue May 22 13:19:05 2018
New Revision: 333020

URL: http://llvm.org/viewvc/llvm-project?rev=333020=rev
Log:
[X86] Add __emmintrin_f16c.h to module map and CMakeLists.

I missed this in r333014

Modified:
cfe/trunk/lib/Headers/CMakeLists.txt
cfe/trunk/lib/Headers/module.modulemap

Modified: cfe/trunk/lib/Headers/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/CMakeLists.txt?rev=333020=333019=333020=diff
==
--- cfe/trunk/lib/Headers/CMakeLists.txt (original)
+++ cfe/trunk/lib/Headers/CMakeLists.txt Tue May 22 13:19:05 2018
@@ -46,6 +46,7 @@ set(files
   clflushoptintrin.h
   clwbintrin.h
   emmintrin.h
+  __emmintrin_f16c.h
   f16cintrin.h
   float.h
   fma4intrin.h

Modified: cfe/trunk/lib/Headers/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/module.modulemap?rev=333020=333019=333020=diff
==
--- cfe/trunk/lib/Headers/module.modulemap (original)
+++ cfe/trunk/lib/Headers/module.modulemap Tue May 22 13:19:05 2018
@@ -95,9 +95,14 @@ module _Builtin_intrinsics [system] [ext
 
 explicit module sse2 {
   export sse
+  export f16c_128
   header "emmintrin.h"
 }
 
+explicit f16c_128 {
+  header "__emmintrin_f16c.h"
+}
+
 explicit module sse3 {
   export sse2
   header "pmmintrin.h"


___
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-22 Thread Reka Kovacs via Phabricator via cfe-commits
rnkovacs added a comment.

Thanks for your comments!

It would be nice if we could reach a consensus on the naming issue before I 
update the patch. I was wondering, as we plan to support stuff like 
`std::vector::data()`, which is not a string, and `std::string_view`, which is 
not strictly a pointer, could we perhaps go with something like 
`DanglingInternalBufferHandle`? The `AllocationFamily` could similarly be 
`AF_InternalBuffer`. What do you think?


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] D41458: [libc++][C++17] Elementary string conversions for integral types

2018-05-22 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added inline comments.



Comment at: include/charconv:89
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+enum class _LIBCPP_ENUM_VIS chars_format

lichray wrote:
> mclow.lists wrote:
> > lichray wrote:
> > > EricWF wrote:
> > > > We need to hide these names when `_LIBCPP_STD_VER < 17`, since we're 
> > > > not allowed to introduce new names into namespace `std` in older 
> > > > dialects.
> > > But this header is backported to C++11, so I intended to not to guard it.
> > > But this header is backported to C++11, so I intended to not to guard it.
> > 
> > In general, we don't provide new features for old language versions.
> > 
> > The only time we've ever done that is for `string_view`, and I'm **still** 
> > not sure I did the right thing there.
> We need to decide on this... From my point of view this header will be widely 
> used by formatting and logging libraries, and it doesn't add much to the 
> community by enforcing C++17 here, especially when the interface we specified 
> are very simple and not using any features beyond C++11.
This question is also relevant to my interests, in re ``.


Repository:
  rCXX libc++

https://reviews.llvm.org/D41458



___
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-22 Thread Zinovy Nis via Phabricator via cfe-commits
zinovy.nis added inline comments.



Comment at: 
clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp:198
   E = E->ignoreParenBaseCasts();
+  if (const auto *EC = dyn_cast(E))
+E = EC->getSubExpr();

zinovy.nis wrote:
> malcolm.parsons wrote:
> > `E->IgnoreImplicit()` can be used to ignore `ExprWithCleanups`
> Thanks. But it seems to be too agressive:
> 
> 
> ```
> return (i & 1) != 0;
> ```
> 
> becomes 
> 
> ```
> return static_cast(i & 1);
> ```
> 
```
  if (!isa(E))
E = E->IgnoreImplicit();

```

works properly but looks a bit verbose. What do you think?


Repository:
  rL LLVM

https://reviews.llvm.org/D47122



___
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-22 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.

LGTM, thanks!


Repository:
  rC Clang

https://reviews.llvm.org/D47166



___
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-22 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: lib/CodeGen/CGExprConstant.cpp:675
+  // We have mixed types. Use a packed struct.
+  std::vector Types;
+  Types.reserve(Elements.size());

rjmccall wrote:
> Why std::vector?
Only because this was extracted from the old version of the code. Switched to a 
`SmallVector`.



Comment at: test/CodeGenCXX/cxx11-initializer-aggregate.cpp:83
+  struct S1 data_7[1024 * 1024 * 512] = {{0}};
+
+  // This variable must be initialized elementwise.

sepavloff wrote:
> Array definitions:
> ```
> char data_8[1000 * 1000 * 1000] = {};
> int (&_9)[1000 * 1000 * 1000] = {0};
> ```
> also compile successfully with this patch and hang compiler without it.
I added these test cases, thanks!


Repository:
  rC Clang

https://reviews.llvm.org/D47166



___
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-22 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith updated this revision to Diff 148079.
rsmith marked 4 inline comments as done.

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,35 @@
   // 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}};
+  char data_8[1000 * 1000 * 1000] = {};
+  int (&_9)[1000 * 1000 * 1000] = {0};
+  unsigned char data_10[1024 * 1024 * 1024 * 2u] = { 1 };
+  unsigned char data_11[1024 * 1024 * 1024 * 2u] = { One };
+  unsigned char data_12[1024][1024][1024] = {{{1}}};
+
+  // 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 *
+EmitArrayConstant(llvm::ArrayType *PreferredArrayType,
+  llvm::Type *CommonElementType, unsigned ArrayBound,
+  SmallVectorImpl ,
+  llvm::Constant *Filler) {
+  // Figure out how long the initial prefix of non-zero elements is.
+  unsigned NonzeroLength = ArrayBound;
+  if (Elements.size() < NonzeroLength && Filler->isNullValue())
+NonzeroLength = Elements.size();
+  if (NonzeroLength == Elements.size()) {
+while (NonzeroLength > 0 && Elements[NonzeroLength - 1]->isNullValue())
+  --NonzeroLength;
+  }
+
+  if (NonzeroLength == 0)
+return llvm::ConstantAggregateZero::get(PreferredArrayType);
+
+  // If there's not many trailing zero elements, just emit an 

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

2018-05-22 Thread Zinovy Nis via Phabricator via cfe-commits
zinovy.nis added inline comments.



Comment at: 
clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp:198
   E = E->ignoreParenBaseCasts();
+  if (const auto *EC = dyn_cast(E))
+E = EC->getSubExpr();

malcolm.parsons wrote:
> `E->IgnoreImplicit()` can be used to ignore `ExprWithCleanups`
Thanks. But it seems to be too agressive:


```
return (i & 1) != 0;
```

becomes 

```
return static_cast(i & 1);
```



Repository:
  rL LLVM

https://reviews.llvm.org/D47122



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


[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-22 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL333014: [X86] Move 128-bit f16c intrinsics to 
__emmintrin_f16c.h include from emmintrin. (authored by ctopper, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D47174?vs=147932=148065#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D47174

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

Index: cfe/trunk/lib/Headers/immintrin.h
===
--- cfe/trunk/lib/Headers/immintrin.h
+++ cfe/trunk/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: cfe/trunk/lib/Headers/emmintrin.h
===
--- cfe/trunk/lib/Headers/emmintrin.h
+++ cfe/trunk/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: cfe/trunk/lib/Headers/f16cintrin.h
===
--- cfe/trunk/lib/Headers/f16cintrin.h
+++ cfe/trunk/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: 

r333014 - [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-22 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Tue May 22 11:54:19 2018
New Revision: 333014

URL: http://llvm.org/viewvc/llvm-project?rev=333014=rev
Log:
[X86] Move 128-bit f16c intrinsics to __emmintrin_f16c.h include from 
emmintrin.h. Move 256-bit f16c intrinsics back to f16cintrin.h

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.

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

Added:
cfe/trunk/lib/Headers/__emmintrin_f16c.h
  - copied, changed from r332998, cfe/trunk/lib/Headers/f16cintrin.h
Modified:
cfe/trunk/lib/Headers/emmintrin.h
cfe/trunk/lib/Headers/f16cintrin.h
cfe/trunk/lib/Headers/immintrin.h

Copied: cfe/trunk/lib/Headers/__emmintrin_f16c.h (from r332998, 
cfe/trunk/lib/Headers/f16cintrin.h)
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__emmintrin_f16c.h?p2=cfe/trunk/lib/Headers/__emmintrin_f16c.h=cfe/trunk/lib/Headers/f16cintrin.h=332998=333014=333014=diff
==
--- cfe/trunk/lib/Headers/f16cintrin.h (original)
+++ cfe/trunk/lib/Headers/__emmintrin_f16c.h Tue May 22 11:54:19 2018
@@ -1,4 +1,4 @@
-/*=== f16cintrin.h - F16C intrinsics ---===
+/*=== __emmintrin_f16c.h - F16C intrinsics -===
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to 
deal
@@ -21,12 +21,12 @@
  *===---===
  */
 
-#if !defined __X86INTRIN_H && !defined __EMMINTRIN_H && !defined __IMMINTRIN_H
-#error "Never use  directly; include  instead."
+#if !defined __EMMINTRIN_H
+#error "Never use <__emmintrin_f16c.h> directly; include  
instead."
 #endif
 
-#ifndef __F16CINTRIN_H
-#define __F16CINTRIN_H
+#ifndef __EMMINTRIN_F16C_H
+#define __EMMINTRIN_F16C_H
 
 /* Define the default attributes for the functions in this file. */
 #define __DEFAULT_FN_ATTRS \
@@ -121,4 +121,4 @@ _mm_cvtph_ps(__m128i __a)
 
 #undef __DEFAULT_FN_ATTRS
 
-#endif /* __F16CINTRIN_H */
+#endif /* __EMMINTRIN_F16C_H */

Modified: cfe/trunk/lib/Headers/emmintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/emmintrin.h?rev=333014=333013=333014=diff
==
--- cfe/trunk/lib/Headers/emmintrin.h (original)
+++ cfe/trunk/lib/Headers/emmintrin.h Tue May 22 11:54:19 2018
@@ -44,7 +44,7 @@ typedef unsigned char __v16qu __attribut
  * 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")))

Modified: cfe/trunk/lib/Headers/f16cintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/f16cintrin.h?rev=333014=333013=333014=diff
==
--- cfe/trunk/lib/Headers/f16cintrin.h (original)
+++ cfe/trunk/lib/Headers/f16cintrin.h Tue May 22 11:54:19 2018
@@ -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,63 +32,24 @@
 #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 

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

2018-05-22 Thread Peter Collingbourne via cfe-commits
Sorry about that, I was keeping an eye on the bots but I must have missed
that one. I've relanded with a fix in r333013.

Peter

On Tue, May 22, 2018 at 4:25 AM, Amara Emerson  wrote:

> On 21 May 2018, at 21:31, Peter Collingbourne via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> 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) <<
> 

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

2018-05-22 Thread Peter Collingbourne via cfe-commits
Author: pcc
Date: Tue May 22 11:52:37 2018
New Revision: 333013

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

As well as two follow-on commits r332906, r332911 with a fix for
test clang/test/CodeGen/split-debug-filename.c.

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=333013=333012=333013=diff
==
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Tue May 22 11:52:37 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=333013=333012=333013=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Tue May 22 11:52:37 2018
@@ -104,7 +104,18 @@ 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 = 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();
+}
+return F;
+  }
 
 public:
   EmitAssemblyHelper(DiagnosticsEngine &_Diags,
@@ -701,7 +712,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 +730,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 +769,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 +778,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()));
+  

[libcxx] r333011 - [libcxx] [test] Mark the test as unsupported by apple-clang-8.1.

2018-05-22 Thread Volodymyr Sapsai via cfe-commits
Author: vsapsai
Date: Tue May 22 11:46:16 2018
New Revision: 333011

URL: http://llvm.org/viewvc/llvm-project?rev=333011=rev
Log:
[libcxx] [test] Mark the test as unsupported by apple-clang-8.1.

Modified:

libcxx/trunk/test/std/strings/basic.string/string.cons/iter_alloc_deduction.fail.cpp

Modified: 
libcxx/trunk/test/std/strings/basic.string/string.cons/iter_alloc_deduction.fail.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/basic.string/string.cons/iter_alloc_deduction.fail.cpp?rev=333011=333010=333011=diff
==
--- 
libcxx/trunk/test/std/strings/basic.string/string.cons/iter_alloc_deduction.fail.cpp
 (original)
+++ 
libcxx/trunk/test/std/strings/basic.string/string.cons/iter_alloc_deduction.fail.cpp
 Tue May 22 11:46:16 2018
@@ -10,7 +10,7 @@
 // 
 // UNSUPPORTED: c++98, c++03, c++11, c++14
 // UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5, clang-3.6, clang-3.7, 
clang-3.8, clang-3.9, clang-4.0
-// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8.0, apple-clang-9
+// UNSUPPORTED: apple-clang-6, apple-clang-7, apple-clang-8, apple-clang-9
 
 // template::value_type>>


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


[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-22 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added a comment.

In https://reviews.llvm.org/D47174#1108329, @craig.topper wrote:

> It is odd, but they really are split in the icc include files. So they got 
> split a while back in clang to match the Intel Intrinsic Guide documentation.


OK - if that means we're matching latest icc/gcc. LGTM.


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] D41376: [libcxx] Implement ABI for Clang/GCC vector extension, constructors, copy_from and copy_to.

2018-05-22 Thread Tim Shen via Phabricator via cfe-commits
timshen updated this revision to Diff 148062.
timshen added a comment.
Herald added a subscriber: bixia.

Chatted with Marshall a bit, we thought that it's bad for toolchain portability 
to support a C++17 library in C++11, especially with modifications w.r.t 
std::plus<>.

Remove the backport of std::integer_sequence to C++11.


https://reviews.llvm.org/D41376

Files:
  libcxx/include/__config
  libcxx/include/experimental/__config
  libcxx/include/experimental/simd
  libcxx/test/std/experimental/simd/simd.abi/vector_extension.pass.cpp
  libcxx/test/std/experimental/simd/simd.access/default.pass.cpp
  libcxx/test/std/experimental/simd/simd.casts/simd_cast.pass.cpp
  libcxx/test/std/experimental/simd/simd.cons/broadcast.pass.cpp
  libcxx/test/std/experimental/simd/simd.cons/default.pass.cpp
  libcxx/test/std/experimental/simd/simd.cons/generator.pass.cpp
  libcxx/test/std/experimental/simd/simd.cons/load.pass.cpp
  libcxx/test/std/experimental/simd/simd.mem/load.pass.cpp
  libcxx/test/std/experimental/simd/simd.mem/store.pass.cpp

Index: libcxx/test/std/experimental/simd/simd.mem/store.pass.cpp
===
--- /dev/null
+++ libcxx/test/std/experimental/simd/simd.mem/store.pass.cpp
@@ -0,0 +1,92 @@
+//===--===//
+//
+// 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
+
+// 
+//
+// // stores [simd.store]
+// template  void copy_to(U* mem, Flags f) const;
+
+#include 
+#include 
+
+#include "test_macros.h"
+
+using namespace std::experimental::parallelism_v2;
+
+void test_store() {
+  fixed_size_simd a([](int i) { return 4 - i; });
+  {
+alignas(32) int32_t buffer[4] = {0};
+a.copy_to(buffer, element_aligned_tag());
+assert(buffer[0] == 4);
+assert(buffer[1] == 3);
+assert(buffer[2] == 2);
+assert(buffer[3] == 1);
+  }
+  {
+alignas(32) int32_t buffer[4] = {0};
+a.copy_to(buffer, vector_aligned_tag());
+assert(buffer[0] == 4);
+assert(buffer[1] == 3);
+assert(buffer[2] == 2);
+assert(buffer[3] == 1);
+  }
+  {
+alignas(32) int32_t buffer[4] = {0};
+a.copy_to(buffer, overaligned_tag<32>());
+assert(buffer[0] == 4);
+assert(buffer[1] == 3);
+assert(buffer[2] == 2);
+assert(buffer[3] == 1);
+  }
+
+#if TEST_STD_VER > 14
+  {
+alignas(32) int32_t buffer[4] = {0};
+a.copy_to(buffer, element_aligned);
+assert(buffer[0] == 4);
+assert(buffer[1] == 3);
+assert(buffer[2] == 2);
+assert(buffer[3] == 1);
+  }
+  {
+alignas(32) int32_t buffer[4] = {0};
+a.copy_to(buffer, vector_aligned);
+assert(buffer[0] == 4);
+assert(buffer[1] == 3);
+assert(buffer[2] == 2);
+assert(buffer[3] == 1);
+  }
+  {
+alignas(32) int32_t buffer[4] = {0};
+a.copy_to(buffer, overaligned<32>);
+assert(buffer[0] == 4);
+assert(buffer[1] == 3);
+assert(buffer[2] == 2);
+assert(buffer[3] == 1);
+  }
+#endif
+}
+
+void test_converting_store() {
+  float buffer[4] = {0.};
+  fixed_size_simd a([](int i) { return 1 << i; });
+  a.copy_to(buffer, element_aligned_tag());
+  assert(buffer[0] == 1.);
+  assert(buffer[1] == 2.);
+  assert(buffer[2] == 4.);
+  assert(buffer[3] == 8.);
+}
+
+int main() {
+  test_store();
+  test_converting_store();
+}
Index: libcxx/test/std/experimental/simd/simd.mem/load.pass.cpp
===
--- /dev/null
+++ libcxx/test/std/experimental/simd/simd.mem/load.pass.cpp
@@ -0,0 +1,118 @@
+//===--===//
+//
+// 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
+
+// 
+//
+// loads [simd.load]
+// template  void copy_from(const U* mem, Flags f);
+
+#include 
+#include 
+
+#include "test_macros.h"
+
+using namespace std::experimental::parallelism_v2;
+
+template 
+auto not_supported_load(Args&&... args) -> decltype(
+std::declval().copy_from(std::forward(args)...),
+void()) = delete;
+
+template 
+void not_supported_load(...) {}
+
+template 
+auto supported_load(Args&&... args) -> decltype(
+std::declval().copy_from(std::forward(args)...),
+void()) {}
+
+template 
+void supported_load(...) = delete;
+
+void compile_load() {
+  supported_load((int*)nullptr, element_aligned_tag());
+  supported_load((int*)nullptr, element_aligned_tag());
+  supported_load((float*)nullptr, 

[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-22 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

It is odd, but they really are split in the icc include files. So they got 
split a while back in clang to match the Intel Intrinsic Guide documentation.


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] 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-22 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added a comment.

Aren't all the instructions from the same CPUID bit? It seems odd to split them 
across multiple files.


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] D47166: use zeroinitializer for (trailing zero portion of) large array initializers more reliably

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

I like this approach a lot.




Comment at: lib/CodeGen/CGExprConstant.cpp:675
+  // We have mixed types. Use a packed struct.
+  std::vector Types;
+  Types.reserve(Elements.size());

Why std::vector?


Repository:
  rC Clang

https://reviews.llvm.org/D47166



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


[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-22 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm


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] D47122: [clang-tidy] SimplifyBoolenExpr doesn't add parens if unary negotiation is of ExprWithCleanups type

2018-05-22 Thread Malcolm Parsons via Phabricator via cfe-commits
malcolm.parsons added inline comments.



Comment at: 
clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp:198
   E = E->ignoreParenBaseCasts();
+  if (const auto *EC = dyn_cast(E))
+E = EC->getSubExpr();

`E->IgnoreImplicit()` can be used to ignore `ExprWithCleanups`


Repository:
  rL LLVM

https://reviews.llvm.org/D47122



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


[PATCH] D47202: [CodeGen] use nsw negation for abs

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

This seems right to me. GCC believes believes that __bultin_abs always returns 
a positive number.


https://reviews.llvm.org/D47202



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


[PATCH] D47196: [Time-report ](2): Recursive timers in Clang

2018-05-22 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang added inline comments.



Comment at: include/clang/Frontend/Utils.h:369
+  llvm::CreateInfoOutputFile();
+  std::sort(FrontendTimes.begin(), FrontendTimes.end(), SortName);
+  using FTPIterator = typename std::vector::iterator;

Please use llvm::sort instead of std::sort. See 
https://llvm.org/docs/CodingStandards.html#beware-of-non-deterministic-sorting-order-of-equal-elements.



Comment at: include/clang/Frontend/Utils.h:389
+  }
+  std::sort(FinalTimes.begin(), FinalTimes.end(), ftimeSort2);
+  double TimeThreshold =

Same here.


https://reviews.llvm.org/D47196



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


[PATCH] D46476: [HIP] Add action builder for HIP

2018-05-22 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 148051.
yaxunl marked 4 inline comments as done.
yaxunl added a comment.

Revised by Artem's comments.


https://reviews.llvm.org/D46476

Files:
  lib/Driver/Driver.cpp
  test/Driver/cuda-phases.cu

Index: test/Driver/cuda-phases.cu
===
--- test/Driver/cuda-phases.cu
+++ test/Driver/cuda-phases.cu
@@ -7,195 +7,242 @@
 // REQUIRES: clang-driver
 // REQUIRES: powerpc-registered-target
 // REQUIRES: nvptx-registered-target
-
+// REQUIRES: amdgpu-registered-target
 //
 // Test single gpu architecture with complete compilation.
 //
 // RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-phases --cuda-gpu-arch=sm_30 %s 2>&1 \
-// RUN: | FileCheck -check-prefix=BIN %s
-// BIN-DAG: [[P0:[0-9]+]]: input, "{{.*}}cuda-phases.cu", cuda, (host-cuda)
-// BIN-DAG: [[P1:[0-9]+]]: preprocessor, {[[P0]]}, cuda-cpp-output, (host-cuda)
-// BIN-DAG: [[P2:[0-9]+]]: compiler, {[[P1]]}, ir, (host-cuda)
-// BIN-DAG: [[P3:[0-9]+]]: input, "{{.*}}cuda-phases.cu", cuda, (device-cuda, sm_30)
-// BIN-DAG: [[P4:[0-9]+]]: preprocessor, {[[P3]]}, cuda-cpp-output, (device-cuda, sm_30)
-// BIN-DAG: [[P5:[0-9]+]]: compiler, {[[P4]]}, ir, (device-cuda, sm_30)
-// BIN-DAG: [[P6:[0-9]+]]: backend, {[[P5]]}, assembler, (device-cuda, sm_30)
-// BIN-DAG: [[P7:[0-9]+]]: assembler, {[[P6]]}, object, (device-cuda, sm_30)
-// BIN-DAG: [[P8:[0-9]+]]: offload, "device-cuda (nvptx64-nvidia-cuda:sm_30)" {[[P7]]}, object
-// BIN-DAG: [[P9:[0-9]+]]: offload, "device-cuda (nvptx64-nvidia-cuda:sm_30)" {[[P6]]}, assembler
-// BIN-DAG: [[P10:[0-9]+]]: linker, {[[P8]], [[P9]]}, cuda-fatbin, (device-cuda)
-// BIN-DAG: [[P11:[0-9]+]]: offload, "host-cuda (powerpc64le-ibm-linux-gnu)" {[[P2]]}, "device-cuda (nvptx64-nvidia-cuda)" {[[P10]]}, ir
-// BIN-DAG: [[P12:[0-9]+]]: backend, {[[P11]]}, assembler, (host-cuda)
-// BIN-DAG: [[P13:[0-9]+]]: assembler, {[[P12]]}, object, (host-cuda)
-// BIN-DAG: [[P14:[0-9]+]]: linker, {[[P13]]}, image, (host-cuda)
+// RUN: | FileCheck -check-prefixes=BIN,BIN_NV %s
+// RUN: %clang -x hip -target powerpc64le-ibm-linux-gnu -ccc-print-phases --cuda-gpu-arch=gfx803 %s 2>&1 \
+// RUN: | FileCheck -check-prefixes=BIN,BIN_AMD %s
+// BIN_NV-DAG: [[P0:[0-9]+]]: input, "{{.*}}cuda-phases.cu", [[T:cuda]], (host-[[T]])
+// BIN_AMD-DAG: [[P0:[0-9]+]]: input, "{{.*}}cuda-phases.cu", [[T:hip]], (host-[[T]])
+// BIN-DAG: [[P1:[0-9]+]]: preprocessor, {[[P0]]}, [[T]]-cpp-output, (host-[[T]])
+// BIN-DAG: [[P2:[0-9]+]]: compiler, {[[P1]]}, ir, (host-[[T]])
+// BIN_NV-DAG: [[P3:[0-9]+]]: input, "{{.*}}cuda-phases.cu", [[T]], (device-[[T]], [[ARCH:sm_30]])
+// BIN_AMD-DAG: [[P3:[0-9]+]]: input, "{{.*}}cuda-phases.cu", [[T]], (device-[[T]], [[ARCH:gfx803]])
+// BIN-DAG: [[P4:[0-9]+]]: preprocessor, {[[P3]]}, [[T]]-cpp-output, (device-[[T]], [[ARCH]])
+// BIN-DAG: [[P5:[0-9]+]]: compiler, {[[P4]]}, ir, (device-[[T]], [[ARCH]])
+// BIN_NV-DAG: [[P6:[0-9]+]]: backend, {[[P5]]}, assembler, (device-[[T]], [[ARCH]])
+// BIN_NV-DAG: [[P7:[0-9]+]]: assembler, {[[P6]]}, object, (device-[[T]], [[ARCH]])
+// BIN_NV-DAG: [[P8:[0-9]+]]: offload, "device-[[T]] ([[TRIPLE:nvptx64-nvidia-cuda]]:[[ARCH]])" {[[P7]]}, object
+// BIN_NV-DAG: [[P9:[0-9]+]]: offload, "device-[[T]] ([[TRIPLE]]:[[ARCH]])" {[[P6]]}, assembler
+// BIN_NV-DAG: [[P10:[0-9]+]]: linker, {[[P8]], [[P9]]}, cuda-fatbin, (device-[[T]])
+// BIN_NV-DAG: [[P11:[0-9]+]]: offload, "host-[[T]] (powerpc64le-ibm-linux-gnu)" {[[P2]]}, "device-[[T]] ([[TRIPLE]])" {[[P10]]}, ir
+// BIN_NV-DAG: [[P12:[0-9]+]]: backend, {[[P11]]}, assembler, (host-[[T]])
+// BIN_AMD-DAG: [[P12:[0-9]+]]: backend, {[[P2]]}, assembler, (host-[[T]])
+// BIN-DAG: [[P13:[0-9]+]]: assembler, {[[P12]]}, object, (host-[[T]])
+// BIN-DAG: [[P14:[0-9]+]]: linker, {[[P13]]}, image, (host-[[T]])
+// BIN_AMD-DAG: [[P15:[0-9]+]]: linker, {[[P5]]}, image, (device-[[T]], [[ARCH]])
+// BIN_AMD-DAG: [[P16:[0-9]+]]: offload, "host-[[T]] (powerpc64le-ibm-linux-gnu)" {[[P14]]},
+// BIN_AMD-DAG-SAME:  "device-[[T]] ([[TRIPLE:amdgcn-amd-amdhsa]]:[[ARCH]])" {[[P15]]}, object
 
 //
 // Test single gpu architecture up to the assemble phase.
 //
 // RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-phases --cuda-gpu-arch=sm_30 %s -S 2>&1 \
-// RUN: | FileCheck -check-prefix=ASM %s
-// ASM-DAG: [[P0:[0-9]+]]: input, "{{.*}}cuda-phases.cu", cuda, (device-cuda, sm_30)
-// ASM-DAG: [[P1:[0-9]+]]: preprocessor, {[[P0]]}, cuda-cpp-output, (device-cuda, sm_30)
-// ASM-DAG: [[P2:[0-9]+]]: compiler, {[[P1]]}, ir, (device-cuda, sm_30)
-// ASM-DAG: [[P3:[0-9]+]]: backend, {[[P2]]}, assembler, (device-cuda, sm_30)
-// ASM-DAG: [[P4:[0-9]+]]: offload, "device-cuda (nvptx64-nvidia-cuda:sm_30)" {[[P3]]}, assembler
-// ASM-DAG: [[P5:[0-9]+]]: input, "{{.*}}cuda-phases.cu", cuda, (host-cuda)
-// ASM-DAG: [[P6:[0-9]+]]: preprocessor, {[[P5]]}, cuda-cpp-output, (host-cuda)
-// ASM-DAG: [[P7:[0-9]+]]: compiler, {[[P6]]}, ir, (host-cuda)
-// ASM-DAG: [[P8:[0-9]+]]: 

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

2018-05-22 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff accepted this revision.
sepavloff added a comment.
This revision is now accepted and ready to land.

Now I understand your idea about moving the logic to `tryEmitPrivateForMemory`. 
Indeed it is more general and consistent solution.
Thank you.




Comment at: lib/CodeGen/CGExprConstant.cpp:643
+  llvm::Constant *Filler) {
+  // Figre out how long the initial prefix of non-zero elements is.
+  unsigned NonzeroLength = ArrayBound;

s/Figre/Figure/ ?



Comment at: lib/CodeGen/CGExprConstant.cpp:903
 SmallVector Elts;
-Elts.reserve(std::max(NumInitableElts, NumElements));
+if (fillC && fillC->isNullValue())
+  Elts.reserve(NumInitableElts + 1);

The check for `fillC != nullptr` here is redundant, it was checked few lines 
above.



Comment at: test/CodeGenCXX/cxx11-initializer-aggregate.cpp:83
+  struct S1 data_7[1024 * 1024 * 512] = {{0}};
+
+  // This variable must be initialized elementwise.

Array definitions:
```
char data_8[1000 * 1000 * 1000] = {};
int (&_9)[1000 * 1000 * 1000] = {0};
```
also compile successfully with this patch and hang compiler without it.


Repository:
  rC Clang

https://reviews.llvm.org/D47166



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


[PATCH] D46476: [HIP] Add action builder for HIP

2018-05-22 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 4 inline comments as done.
yaxunl added inline comments.



Comment at: lib/Driver/Driver.cpp:2221
+CudaDeviceActions.clear();
+for (unsigned I = 0, E = GpuArchList.size(); I != E; ++I) {
+  CudaDeviceActions.push_back(UA);

tra wrote:
> `for(auto Arch: GpuArchList)`
will do



Comment at: lib/Driver/Driver.cpp:2265-2272
+  assert(AssociatedOffloadKind == Action::OFK_Cuda || 
AssociatedOffloadKind == Action::OFK_HIP);
+
   // We don't need to support CUDA.
-  if (!C.hasOffloadToolChain())
+  if (AssociatedOffloadKind == Action::OFK_Cuda && 
!C.hasOffloadToolChain())
+return false;
+
+  // We don't need to support HIP.

tra wrote:
> Please reformat.
will do



Comment at: lib/Driver/Driver.cpp:2330-2332
+  for (CudaArch Arch : GpuArchs) {
 GpuArchList.push_back(Arch);
+  }

tra wrote:
> Single-statement for does not need braces.
will do



Comment at: lib/Driver/Driver.cpp:2485-2493
+  // The host only depends on device action in the linking phase, when all
+  // the device images have to be embedded in the host image.
+  if (CurPhase == phases::Link) {
+DeviceLinkerInputs.resize(CudaDeviceActions.size());
+auto LI = DeviceLinkerInputs.begin();
+for (auto *A : CudaDeviceActions) {
+  LI->push_back(A);

tra wrote:
> I'm not sure I understand what happens here and the comment does not help.
> We appear to add each element of CudaDeviceActions to the action list of each 
> linker input.
> 
> Does the comment mean that *only in linking mode* do we need to add 
> dependency on device actions?
> 
Modified the comment to make it clearer.

We only add dependency on device action at linking phase. HIP embeds device 
image in host image in host linking phase. Since we need to link all device 
actions, we cannot create link action here since we have not went through all 
device actions yet. We just save device actions to  DeviceLinkerInputs and 
create device link action later in appendLinkDependences, where all device 
actions have been went through.


https://reviews.llvm.org/D46476



___
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-22 Thread Zinovy Nis via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL333003: [clang-tidy] SimplifyBoolenExpr doesnt add 
parens if unary negotiation is of… (authored by zinovy.nis, committed by ).
Herald added subscribers: llvm-commits, klimek.

Changed prior to commit:
  https://reviews.llvm.org/D47122?vs=147836=148046#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D47122

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


Index: 
clang-tools-extra/trunk/test/clang-tidy/readability-simplify-bool-expr.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/readability-simplify-bool-expr.cpp
+++ clang-tools-extra/trunk/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-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
+++ clang-tools-extra/trunk/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: clang-tools-extra/trunk/test/clang-tidy/readability-simplify-bool-expr.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/readability-simplify-bool-expr.cpp
+++ clang-tools-extra/trunk/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-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
+++ clang-tools-extra/trunk/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


[clang-tools-extra] r333003 - [clang-tidy] SimplifyBoolenExpr doesn't add parens if unary negotiation is of ExprWithCleanups type

2018-05-22 Thread Zinovy Nis via cfe-commits
Author: zinovy.nis
Date: Tue May 22 10:24:28 2018
New Revision: 333003

URL: http://llvm.org/viewvc/llvm-project?rev=333003=rev
Log:
[clang-tidy] SimplifyBoolenExpr doesn't add parens if unary negotiation is of 
ExprWithCleanups type

bool foo(A ) {
  if (S != (A)S)
return false;
  return true;
}
is fixed into (w/o this patch)

...
return !S != (A)S; // negotiation affects first operand only
}
instead of (with this patch)

...
return S == (A)S; // note == instead of !=
}

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


Modified:
clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/readability-simplify-bool-expr.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp?rev=333003=333002=333003=diff
==
--- clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/readability/SimplifyBooleanExprCheck.cpp 
Tue May 22 10:24:28 2018
@@ -195,6 +195,9 @@ std::string compareExpressionToZero(cons
 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)) {

Modified: 
clang-tools-extra/trunk/test/clang-tidy/readability-simplify-bool-expr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-simplify-bool-expr.cpp?rev=333003=333002=333003=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/readability-simplify-bool-expr.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/readability-simplify-bool-expr.cpp 
Tue May 22 10:24:28 2018
@@ -938,3 +938,13 @@ bool integer_member_implicit_cast(A *p)
 }
 // 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;{{$}}


___
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-22 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: include/clang/Basic/BuiltinsAMDGPU.def:49
+
+// FIXME: Need to disallow constant address space.
 BUILTIN(__builtin_amdgcn_div_scale, "dddbb*", "n")

Do you plan to provide the support for it later? Or if else perhaps we should 
elaborate more what's to be done.



Comment at: include/clang/Basic/TargetInfo.h:1009
 
+  virtual LangAS getOpenCLBuiltinAddressSpace(unsigned AS) const {
+return getLangASFromTargetAS(AS);

Can you add a comment please to explain what the function is for?



Comment at: lib/AST/ASTContext.cpp:9093
   unsigned AddrSpace = strtoul(Str, , 10);
-  if (End != Str && AddrSpace != 0) {
-Type = Context.getAddrSpaceQualType(Type,
-getLangASFromTargetAS(AddrSpace));
+  if (End != Str) {
+// Note AddrSpace == 0 is not the same as an unspecified address space.

Could we check against LangAS::Default instead of removing this completely.



Comment at: lib/CodeGen/CGBuiltin.cpp:3500
+if (auto *PtrTy = dyn_cast(PTy)) {
+  if (PtrTy->getAddressSpace() !=
+  ArgValue->getType()->getPointerAddressSpace()) {

Would this be correct for OpenCL? Should we use  `isAddressSpaceSupersetOf` 
helper instead? Would it also sort the issue with constant AS (at least for 
OpenCL)? 



Comment at: test/CodeGenOpenCL/numbered-address-space.cl:36
+#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) {

`__attribute__((address_space(N)))` is not an OpenCL feature and I think it's 
not specified in C either? But I think generally non matching address spaces 
don't compile in Clang. So it might be useful to disallow this?


https://reviews.llvm.org/D47154



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


[PATCH] D47182: [X86] Move all Intel defined intrinsic includes into immintrin.h

2018-05-22 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

In https://reviews.llvm.org/D47182#1107900, @craig.topper wrote:

> Eventually this was determined to not be very scalable to remember which 
> header file contained what intrinsics and you have to change it with each 
> generation to get the latest.. So immintrin.h was created to just include 
> everything.


Speaking of things that aren't scalable... immintrin.h is like the new 
windows.h. :(

The reorganization looks good to me, though.


Repository:
  rC Clang

https://reviews.llvm.org/D47182



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


[PATCH] D47161: update

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

I take it this was accidental?  If there are weaknesses in our documentation 
for how to use Phabricator, please let us know.  I know it is not always 
straightforward (I had a number of issues when I tried to start using it).


Repository:
  rC Clang

https://reviews.llvm.org/D47161



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


[PATCH] D47195: [clang-format] Fix putting ObjC message arguments in one line for multiline receiver

2018-05-22 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added inline comments.



Comment at: unittests/Format/FormatTestObjC.cpp:815
+
+  // No line break before closing receiver's scope.
+  verifyFormat("[[obj a:42] a:42\n"

jolesiak wrote:
> krasimir wrote:
> > jolesiak wrote:
> > > krasimir wrote:
> > > > What's the receiver's scope in this comment referring to?
> > > > Also, how would the old test cases be formatted?
> > > For a receiver: `[obj a:42]` I meant `]` as a token closing the scope.
> > > I'll rephrase the comment to be more precise.
> > > 
> > > Old tests were introduced in D46879. After this change the formatting 
> > > will be the same as it was before D46879, i.e. the same as for last test 
> > > touched in this change:
> > > ```
> > > [[obj aa:42
> > >b:42]
> > > cc:42
> > >  d:42];
> > > ```
> > > even if
> > > ```
> > > [[obj aa:42
> > >b:42]
> > > cc:42 d:42];
> > > ```
> > > satisfies the column limit.
> > Ah, I think  get it now: the new code should only apply to after object 
> > blocks and not after object receivers? Is this the intention?
> The intention is to put arguments into one line if they fit but only in the 
> same line as last character of a receiver expression, e.g.:
> ```
> [[object block:^{
>   return 42;
> }] aa:42 bb:42];
> ```
> instead of
> ```
> [[object block:^{
>   return 42;
> }] aa:42
>bb:42];
> ```
> but not
> ```
> [[obj a:42]
> a:42 b:42];
> ```
> 
> I think it gets a little bit too complicated for no reason. Let me revert 
> D46879 and rebase this change.
In that case, would this be allowed?
```
//  limit:   V
[[obj a:42
  b:42
  c:42
  d:42] e:42 f:42]
```


Repository:
  rC Clang

https://reviews.llvm.org/D47195



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


[PATCH] D46664: Fix null MSInheritanceAttr deref in CXXRecordDecl::getMSInheritanceModel()

2018-05-22 Thread Andrew Rogers via Phabricator via cfe-commits
adr26 updated this revision to Diff 148044.
adr26 added a comment.

Update to change MSInheritanceAttr to always be attached to the latest 
non-injected class name decl, as suggested by Reid.


https://reviews.llvm.org/D46664

Files:
  include/clang/AST/DeclCXX.h
  lib/AST/MicrosoftMangle.cpp
  lib/AST/Type.cpp
  lib/CodeGen/MicrosoftCXXABI.cpp
  lib/Sema/SemaType.cpp


Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -7544,7 +7544,7 @@
 
 /// Locks in the inheritance model for the given class and all of its bases.
 static void assignInheritanceModel(Sema , CXXRecordDecl *RD) {
-  RD = RD->getMostRecentDecl();
+  RD = RD->getMostRecentNonInjectedDecl();
   if (!RD->hasAttr()) {
 MSInheritanceAttr::Spelling IM;
 
Index: lib/CodeGen/MicrosoftCXXABI.cpp
===
--- lib/CodeGen/MicrosoftCXXABI.cpp
+++ lib/CodeGen/MicrosoftCXXABI.cpp
@@ -2733,7 +2733,7 @@
   assert(MD->isInstance() && "Member function must not be static!");
 
   CharUnits NonVirtualBaseAdjustment = CharUnits::Zero();
-  const CXXRecordDecl *RD = MD->getParent()->getMostRecentDecl();
+  const CXXRecordDecl *RD = MD->getParent()->getMostRecentNonInjectedDecl();
   CodeGenTypes  = CGM.getTypes();
 
   unsigned VBTableIndex = 0;
Index: lib/AST/Type.cpp
===
--- lib/AST/Type.cpp
+++ lib/AST/Type.cpp
@@ -2040,7 +2040,7 @@
   return false;
 // The inheritance attribute might only be present on the most recent
 // CXXRecordDecl, use that one.
-RD = RD->getMostRecentDecl();
+RD = RD->getMostRecentNonInjectedDecl();
 // Nothing interesting to do if the inheritance attribute is already set.
 if (RD->hasAttr())
   return false;
@@ -3936,5 +3936,5 @@
 }
 
 CXXRecordDecl *MemberPointerType::getMostRecentCXXRecordDecl() const {
-  return getClass()->getAsCXXRecordDecl()->getMostRecentDecl();
+  return getClass()->getAsCXXRecordDecl()->getMostRecentNonInjectedDecl();
 }
Index: lib/AST/MicrosoftMangle.cpp
===
--- lib/AST/MicrosoftMangle.cpp
+++ lib/AST/MicrosoftMangle.cpp
@@ -1370,12 +1370,12 @@
 const NamedDecl *ND = TA.getAsDecl();
 if (isa(ND) || isa(ND)) {
   mangleMemberDataPointer(
-  cast(ND->getDeclContext())->getMostRecentDecl(),
+  
cast(ND->getDeclContext())->getMostRecentNonInjectedDecl(),
   cast(ND));
 } else if (const FunctionDecl *FD = dyn_cast(ND)) {
   const CXXMethodDecl *MD = dyn_cast(FD);
   if (MD && MD->isInstance()) {
-mangleMemberFunctionPointer(MD->getParent()->getMostRecentDecl(), MD);
+
mangleMemberFunctionPointer(MD->getParent()->getMostRecentNonInjectedDecl(), 
MD);
   } else {
 Out << "$1?";
 mangleName(FD);
Index: include/clang/AST/DeclCXX.h
===
--- include/clang/AST/DeclCXX.h
+++ include/clang/AST/DeclCXX.h
@@ -751,6 +751,21 @@
 return const_cast(this)->getMostRecentDecl();
   }
 
+  CXXRecordDecl *getMostRecentNonInjectedDecl() {
+CXXRecordDecl *Recent =
+static_cast(this)->getMostRecentDecl();
+while (Recent->isInjectedClassName()) {
+  // FIXME: Does injected class name need to be in the redeclarations 
chain?
+  assert(Recent->getPreviousDecl());
+  Recent = Recent->getPreviousDecl();
+}
+return Recent;
+  }
+
+  const CXXRecordDecl *getMostRecentNonInjectedDecl() const {
+return const_cast(this)->getMostRecentNonInjectedDecl();
+  }
+
   CXXRecordDecl *getDefinition() const {
 // We only need an update if we don't already know which
 // declaration is the definition.


Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -7544,7 +7544,7 @@
 
 /// Locks in the inheritance model for the given class and all of its bases.
 static void assignInheritanceModel(Sema , CXXRecordDecl *RD) {
-  RD = RD->getMostRecentDecl();
+  RD = RD->getMostRecentNonInjectedDecl();
   if (!RD->hasAttr()) {
 MSInheritanceAttr::Spelling IM;
 
Index: lib/CodeGen/MicrosoftCXXABI.cpp
===
--- lib/CodeGen/MicrosoftCXXABI.cpp
+++ lib/CodeGen/MicrosoftCXXABI.cpp
@@ -2733,7 +2733,7 @@
   assert(MD->isInstance() && "Member function must not be static!");
 
   CharUnits NonVirtualBaseAdjustment = CharUnits::Zero();
-  const CXXRecordDecl *RD = MD->getParent()->getMostRecentDecl();
+  const CXXRecordDecl *RD = MD->getParent()->getMostRecentNonInjectedDecl();
   CodeGenTypes  = CGM.getTypes();
 
   unsigned VBTableIndex = 0;
Index: lib/AST/Type.cpp
===
--- lib/AST/Type.cpp
+++ 

[PATCH] D47195: [clang-format] Fix ObjC message arguments handling

2018-05-22 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton added a comment.

Can you update the diff description to reflect that it includes the original 
change?


Repository:
  rC Clang

https://reviews.llvm.org/D47195



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


[PATCH] D47195: [clang-format] Fix ObjC message arguments handling

2018-05-22 Thread Jacek Olesiak via Phabricator via cfe-commits
jolesiak updated this revision to Diff 148038.
jolesiak added a comment.

Rebase.


Repository:
  rC Clang

https://reviews.llvm.org/D47195

Files:
  lib/Format/ContinuationIndenter.cpp
  unittests/Format/FormatTestObjC.cpp


Index: unittests/Format/FormatTestObjC.cpp
===
--- unittests/Format/FormatTestObjC.cpp
+++ unittests/Format/FormatTestObjC.cpp
@@ -796,6 +796,33 @@
   verifyFormat("[((Foo *)foo) bar];");
   verifyFormat("[((Foo *)foo) bar:1 blech:2];");
 
+  // Message receiver taking multiple lines.
+  Style.ColumnLimit = 20;
+  // Non-corner case.
+  verifyFormat("[[object block:^{\n"
+   "  return 42;\n"
+   "}] a:42 b:42];");
+  // Arguments just fit into one line.
+  verifyFormat("[[object block:^{\n"
+   "  return 42;\n"
+   "}] aaa:42 b:42];");
+  // Arguments just over a column limit.
+  verifyFormat("[[object block:^{\n"
+   "  return 42;\n"
+   "}] aaa:42\n"
+   "bb:42];");
+
+  // Arguments do not fit into one line with a receiver.
+  verifyFormat("[[obj a:42] a:42\n"
+   "b:42];\n");
+  verifyFormat("[[obj a:42] a:42\n"
+   "b:42\n"
+   "c:42];\n");
+  verifyFormat("[[obj aa:42\n"
+   "   b:42]\n"
+   "cc:42\n"
+   " d:42];");
+
   Style.ColumnLimit = 70;
   verifyFormat(
   "void f() {\n"
Index: lib/Format/ContinuationIndenter.cpp
===
--- lib/Format/ContinuationIndenter.cpp
+++ lib/Format/ContinuationIndenter.cpp
@@ -1386,6 +1386,29 @@
(Current.is(tok::greater) && Current.is(TT_DictLiteral
 State.Stack.pop_back();
 
+  // Reevaluate whether ObjC message arguments fit into one line.
+  // If a receiver spans multiple lines, e.g.:
+  //   [[object block:^{
+  // return 42;
+  //   }] a:42 b:42];
+  // BreakBeforeParameter is calculated based on an incorrect assumption
+  // (it is checked whether the whole expression fits into one line without
+  // considering a line break inside a message receiver).
+  // We check whether arguements fit after receiver scope closer (into the same
+  // line).
+  if (Current.MatchingParen && Current.MatchingParen->Previous) {
+const FormatToken  = *Current.MatchingParen->Previous;
+if (CurrentScopeOpener.is(TT_ObjCMethodExpr) &&
+CurrentScopeOpener.MatchingParen) {
+  int NecessarySpaceInLine =
+  getLengthToMatchingParen(CurrentScopeOpener, State.Stack) +
+  CurrentScopeOpener.TotalLength - Current.TotalLength - 1;
+  if (State.Column + Current.ColumnWidth + NecessarySpaceInLine <=
+  Style.ColumnLimit)
+State.Stack.back().BreakBeforeParameter = false;
+}
+  }
+
   if (Current.is(tok::r_square)) {
 // If this ends the array subscript expr, reset the corresponding value.
 const FormatToken *NextNonComment = Current.getNextNonComment();


Index: unittests/Format/FormatTestObjC.cpp
===
--- unittests/Format/FormatTestObjC.cpp
+++ unittests/Format/FormatTestObjC.cpp
@@ -796,6 +796,33 @@
   verifyFormat("[((Foo *)foo) bar];");
   verifyFormat("[((Foo *)foo) bar:1 blech:2];");
 
+  // Message receiver taking multiple lines.
+  Style.ColumnLimit = 20;
+  // Non-corner case.
+  verifyFormat("[[object block:^{\n"
+   "  return 42;\n"
+   "}] a:42 b:42];");
+  // Arguments just fit into one line.
+  verifyFormat("[[object block:^{\n"
+   "  return 42;\n"
+   "}] aaa:42 b:42];");
+  // Arguments just over a column limit.
+  verifyFormat("[[object block:^{\n"
+   "  return 42;\n"
+   "}] aaa:42\n"
+   "bb:42];");
+
+  // Arguments do not fit into one line with a receiver.
+  verifyFormat("[[obj a:42] a:42\n"
+   "b:42];\n");
+  verifyFormat("[[obj a:42] a:42\n"
+   "b:42\n"
+   "c:42];\n");
+  verifyFormat("[[obj aa:42\n"
+   "   b:42]\n"
+   "cc:42\n"
+   " d:42];");
+
   Style.ColumnLimit = 70;
   verifyFormat(
   "void f() {\n"
Index: lib/Format/ContinuationIndenter.cpp
===
--- lib/Format/ContinuationIndenter.cpp
+++ lib/Format/ContinuationIndenter.cpp
@@ -1386,6 +1386,29 @@
(Current.is(tok::greater) && Current.is(TT_DictLiteral
 State.Stack.pop_back();
 
+  // Reevaluate whether ObjC message arguments fit into one line.
+  // If a receiver spans multiple lines, e.g.:
+  //   [[object block:^{
+  // return 42;
+  //   }] a:42 b:42];
+  // BreakBeforeParameter is calculated based on an incorrect assumption
+  // (it is checked whether the whole 

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

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



Comment at: test/CodeGen/debug-info-preserve-scope.c:10
+
+// CHECK: alloca i32 {{.*}} !dbg ![[dbgLocForStore:[0-9]+]]
+// CHECK: store i32 {{.*}} !dbg ![[dbgLocForStore:[0-9]+]]

In these two check lines, you're capturing the variable dbgLocForStore twice. 
That means that if the !dbg location on the alloca were different from the 
location on the store, this test would still pass.

To fix that, just capture the dbgLocForStore variable once, the first time you 
see it on the alloca. In the second check line, you can simply refer to the 
captured variable with `[[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-22 Thread Anastasis via Phabricator via cfe-commits
gramanas updated this revision to Diff 148034.
gramanas added a comment.

Move ApplyDebugLocation before CreateMemTemp


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,13 @@
+// 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: alloca i32 {{.*}} !dbg ![[dbgLocForStore:[0-9]+]]
+// CHECK: store i32 {{.*}} !dbg ![[dbgLocForStore:[0-9]+]]
+
+// CHECK: ![[dbgLocForStore]] = !DILocation(line: 0
Index: lib/CodeGen/CGDecl.cpp
===
--- lib/CodeGen/CGDecl.cpp
+++ lib/CodeGen/CGDecl.cpp
@@ -1946,6 +1946,9 @@
 }
   }
 
+  // Set artificial debug location in order to preserve the scope
+  auto DL = ApplyDebugLocation::CreateArtificial(*this);
+
   Address DeclPtr = Address::invalid();
   bool DoStore = false;
   bool IsScalar = hasScalarEvaluationKind(Ty);
@@ -2071,7 +2074,7 @@
 
   // Store the initial value into the alloca.
   if (DoStore)
-EmitStoreOfScalar(ArgVal, lv, /* isInitialization */ true);
+   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,13 @@
+// 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: alloca i32 {{.*}} !dbg ![[dbgLocForStore:[0-9]+]]
+// CHECK: store i32 {{.*}} !dbg ![[dbgLocForStore:[0-9]+]]
+
+// CHECK: ![[dbgLocForStore]] = !DILocation(line: 0
Index: lib/CodeGen/CGDecl.cpp
===
--- lib/CodeGen/CGDecl.cpp
+++ lib/CodeGen/CGDecl.cpp
@@ -1946,6 +1946,9 @@
 }
   }
 
+  // Set artificial debug location in order to preserve the scope
+  auto DL = ApplyDebugLocation::CreateArtificial(*this);
+
   Address DeclPtr = Address::invalid();
   bool DoStore = false;
   bool IsScalar = hasScalarEvaluationKind(Ty);
@@ -2071,7 +2074,7 @@
 
   // Store the initial value into the alloca.
   if (DoStore)
-EmitStoreOfScalar(ArgVal, lv, /* isInitialization */ true);
+   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] D47205: Revert "[clang-format] Fix putting ObjC message arguments in one line for multiline receiver"

2018-05-22 Thread Jacek Olesiak via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC332998: Revert [clang-format] Fix putting ObjC message 
arguments in one line for… (authored by jolesiak, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D47205?vs=148030=148032#toc

Repository:
  rC Clang

https://reviews.llvm.org/D47205

Files:
  lib/Format/ContinuationIndenter.cpp
  unittests/Format/FormatTestObjC.cpp


Index: lib/Format/ContinuationIndenter.cpp
===
--- lib/Format/ContinuationIndenter.cpp
+++ lib/Format/ContinuationIndenter.cpp
@@ -1073,34 +1073,8 @@
   if (Current.isMemberAccess())
 State.Stack.back().StartOfFunctionCall =
 !Current.NextOperator ? 0 : State.Column;
-  if (Current.is(TT_SelectorName) &&
-  !State.Stack.back().ObjCSelectorNameFound) {
+  if (Current.is(TT_SelectorName))
 State.Stack.back().ObjCSelectorNameFound = true;
-
-// Reevaluate whether ObjC message arguments fit into one line.
-// If a receiver spans multiple lines, e.g.:
-//   [[object block:^{
-// return 42;
-//   }] a:42 b:42];
-// BreakBeforeParameter is calculated based on an incorrect assumption
-// (it is checked whether the whole expression fits into one line without
-// considering a line break inside a message receiver).
-if (Current.Previous && Current.Previous->closesScope() &&
-Current.Previous->MatchingParen &&
-Current.Previous->MatchingParen->Previous) {
-  const FormatToken  =
-  *Current.Previous->MatchingParen->Previous;
-  if (CurrentScopeOpener.is(TT_ObjCMethodExpr) &&
-  CurrentScopeOpener.MatchingParen) {
-int NecessarySpaceInLine =
-getLengthToMatchingParen(CurrentScopeOpener, State.Stack) +
-CurrentScopeOpener.TotalLength - Current.TotalLength - 1;
-if (State.Column + Current.ColumnWidth + NecessarySpaceInLine <=
-Style.ColumnLimit)
-  State.Stack.back().BreakBeforeParameter = false;
-  }
-}
-  }
   if (Current.is(TT_CtorInitializerColon) &&
   Style.BreakConstructorInitializers != FormatStyle::BCIS_AfterColon) {
 // Indent 2 from the column, so:
Index: unittests/Format/FormatTestObjC.cpp
===
--- unittests/Format/FormatTestObjC.cpp
+++ unittests/Format/FormatTestObjC.cpp
@@ -796,35 +796,6 @@
   verifyFormat("[((Foo *)foo) bar];");
   verifyFormat("[((Foo *)foo) bar:1 blech:2];");
 
-  // Message receiver taking multiple lines.
-  Style.ColumnLimit = 20;
-  // Non-corner case.
-  verifyFormat("[[object block:^{\n"
-   "  return 42;\n"
-   "}] a:42 b:42];");
-  // Arguments just fit into one line.
-  verifyFormat("[[object block:^{\n"
-   "  return 42;\n"
-   "}] aaa:42 b:42];");
-  // Arguments just over a column limit.
-  verifyFormat("[[object block:^{\n"
-   "  return 42;\n"
-   "}] aaa:42\n"
-   "bb:42];");
-  // Non-corner case.
-  verifyFormat("[[object aaa:42\n"
-   "   b:42]\n"
-   "cc:42 d:42];");
-  // Arguments just fit into one line.
-  verifyFormat("[[object aaa:42\n"
-   "   b:42]\n"
-   "cc:42 d:42];");
-  // Arguments just over a column limit.
-  verifyFormat("[[object aaa:42\n"
-   "   b:42]\n"
-   "cc:42\n"
-   "dd:42];");
-
   Style.ColumnLimit = 70;
   verifyFormat(
   "void f() {\n"


Index: lib/Format/ContinuationIndenter.cpp
===
--- lib/Format/ContinuationIndenter.cpp
+++ lib/Format/ContinuationIndenter.cpp
@@ -1073,34 +1073,8 @@
   if (Current.isMemberAccess())
 State.Stack.back().StartOfFunctionCall =
 !Current.NextOperator ? 0 : State.Column;
-  if (Current.is(TT_SelectorName) &&
-  !State.Stack.back().ObjCSelectorNameFound) {
+  if (Current.is(TT_SelectorName))
 State.Stack.back().ObjCSelectorNameFound = true;
-
-// Reevaluate whether ObjC message arguments fit into one line.
-// If a receiver spans multiple lines, e.g.:
-//   [[object block:^{
-// return 42;
-//   }] a:42 b:42];
-// BreakBeforeParameter is calculated based on an incorrect assumption
-// (it is checked whether the whole expression fits into one line without
-// considering a line break inside a message receiver).
-if (Current.Previous && Current.Previous->closesScope() &&
-Current.Previous->MatchingParen &&
-Current.Previous->MatchingParen->Previous) {
-  const FormatToken  =
-  *Current.Previous->MatchingParen->Previous;
-  if (CurrentScopeOpener.is(TT_ObjCMethodExpr) &&
-  CurrentScopeOpener.MatchingParen) {
-int NecessarySpaceInLine =
-

r332998 - Revert "[clang-format] Fix putting ObjC message arguments in one line for multiline receiver"

2018-05-22 Thread Jacek Olesiak via cfe-commits
Author: jolesiak
Date: Tue May 22 09:44:42 2018
New Revision: 332998

URL: http://llvm.org/viewvc/llvm-project?rev=332998=rev
Log:
Revert "[clang-format] Fix putting ObjC message arguments in one line for 
multiline receiver"

Summary: Reverts D46879

Reviewers: benhamilton

Reviewed By: benhamilton

Subscribers: krasimir, klimek, cfe-commits

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

Modified:
cfe/trunk/lib/Format/ContinuationIndenter.cpp
cfe/trunk/unittests/Format/FormatTestObjC.cpp

Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=332998=332997=332998=diff
==
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Tue May 22 09:44:42 2018
@@ -1073,34 +1073,8 @@ unsigned ContinuationIndenter::moveState
   if (Current.isMemberAccess())
 State.Stack.back().StartOfFunctionCall =
 !Current.NextOperator ? 0 : State.Column;
-  if (Current.is(TT_SelectorName) &&
-  !State.Stack.back().ObjCSelectorNameFound) {
+  if (Current.is(TT_SelectorName))
 State.Stack.back().ObjCSelectorNameFound = true;
-
-// Reevaluate whether ObjC message arguments fit into one line.
-// If a receiver spans multiple lines, e.g.:
-//   [[object block:^{
-// return 42;
-//   }] a:42 b:42];
-// BreakBeforeParameter is calculated based on an incorrect assumption
-// (it is checked whether the whole expression fits into one line without
-// considering a line break inside a message receiver).
-if (Current.Previous && Current.Previous->closesScope() &&
-Current.Previous->MatchingParen &&
-Current.Previous->MatchingParen->Previous) {
-  const FormatToken  =
-  *Current.Previous->MatchingParen->Previous;
-  if (CurrentScopeOpener.is(TT_ObjCMethodExpr) &&
-  CurrentScopeOpener.MatchingParen) {
-int NecessarySpaceInLine =
-getLengthToMatchingParen(CurrentScopeOpener, State.Stack) +
-CurrentScopeOpener.TotalLength - Current.TotalLength - 1;
-if (State.Column + Current.ColumnWidth + NecessarySpaceInLine <=
-Style.ColumnLimit)
-  State.Stack.back().BreakBeforeParameter = false;
-  }
-}
-  }
   if (Current.is(TT_CtorInitializerColon) &&
   Style.BreakConstructorInitializers != FormatStyle::BCIS_AfterColon) {
 // Indent 2 from the column, so:

Modified: cfe/trunk/unittests/Format/FormatTestObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestObjC.cpp?rev=332998=332997=332998=diff
==
--- cfe/trunk/unittests/Format/FormatTestObjC.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestObjC.cpp Tue May 22 09:44:42 2018
@@ -796,35 +796,6 @@ TEST_F(FormatTestObjC, FormatObjCMethodE
   verifyFormat("[((Foo *)foo) bar];");
   verifyFormat("[((Foo *)foo) bar:1 blech:2];");
 
-  // Message receiver taking multiple lines.
-  Style.ColumnLimit = 20;
-  // Non-corner case.
-  verifyFormat("[[object block:^{\n"
-   "  return 42;\n"
-   "}] a:42 b:42];");
-  // Arguments just fit into one line.
-  verifyFormat("[[object block:^{\n"
-   "  return 42;\n"
-   "}] aaa:42 b:42];");
-  // Arguments just over a column limit.
-  verifyFormat("[[object block:^{\n"
-   "  return 42;\n"
-   "}] aaa:42\n"
-   "bb:42];");
-  // Non-corner case.
-  verifyFormat("[[object aaa:42\n"
-   "   b:42]\n"
-   "cc:42 d:42];");
-  // Arguments just fit into one line.
-  verifyFormat("[[object aaa:42\n"
-   "   b:42]\n"
-   "cc:42 d:42];");
-  // Arguments just over a column limit.
-  verifyFormat("[[object aaa:42\n"
-   "   b:42]\n"
-   "cc:42\n"
-   "dd:42];");
-
   Style.ColumnLimit = 70;
   verifyFormat(
   "void f() {\n"


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


[PATCH] D47195: [clang-format] Fix ObjC message arguments handling

2018-05-22 Thread Jacek Olesiak via Phabricator via cfe-commits
jolesiak added inline comments.



Comment at: unittests/Format/FormatTestObjC.cpp:815
+
+  // No line break before closing receiver's scope.
+  verifyFormat("[[obj a:42] a:42\n"

krasimir wrote:
> jolesiak wrote:
> > krasimir wrote:
> > > What's the receiver's scope in this comment referring to?
> > > Also, how would the old test cases be formatted?
> > For a receiver: `[obj a:42]` I meant `]` as a token closing the scope.
> > I'll rephrase the comment to be more precise.
> > 
> > Old tests were introduced in D46879. After this change the formatting will 
> > be the same as it was before D46879, i.e. the same as for last test touched 
> > in this change:
> > ```
> > [[obj aa:42
> >b:42]
> > cc:42
> >  d:42];
> > ```
> > even if
> > ```
> > [[obj aa:42
> >b:42]
> > cc:42 d:42];
> > ```
> > satisfies the column limit.
> Ah, I think  get it now: the new code should only apply to after object 
> blocks and not after object receivers? Is this the intention?
The intention is to put arguments into one line if they fit but only in the 
same line as last character of a receiver expression, e.g.:
```
[[object block:^{
  return 42;
}] aa:42 bb:42];
```
instead of
```
[[object block:^{
  return 42;
}] aa:42
   bb:42];
```
but not
```
[[obj a:42]
a:42 b:42];
```

I think it gets a little bit too complicated for no reason. Let me revert 
D46879 and rebase this change.


Repository:
  rC Clang

https://reviews.llvm.org/D47195



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


[PATCH] D47205: Revert "[clang-format] Fix putting ObjC message arguments in one line for multiline receiver"

2018-05-22 Thread Jacek Olesiak via Phabricator via cfe-commits
jolesiak created this revision.
Herald added subscribers: cfe-commits, klimek.

Repository:
  rC Clang

https://reviews.llvm.org/D47205

Files:
  lib/Format/ContinuationIndenter.cpp
  unittests/Format/FormatTestObjC.cpp


Index: unittests/Format/FormatTestObjC.cpp
===
--- unittests/Format/FormatTestObjC.cpp
+++ unittests/Format/FormatTestObjC.cpp
@@ -796,35 +796,6 @@
   verifyFormat("[((Foo *)foo) bar];");
   verifyFormat("[((Foo *)foo) bar:1 blech:2];");
 
-  // Message receiver taking multiple lines.
-  Style.ColumnLimit = 20;
-  // Non-corner case.
-  verifyFormat("[[object block:^{\n"
-   "  return 42;\n"
-   "}] a:42 b:42];");
-  // Arguments just fit into one line.
-  verifyFormat("[[object block:^{\n"
-   "  return 42;\n"
-   "}] aaa:42 b:42];");
-  // Arguments just over a column limit.
-  verifyFormat("[[object block:^{\n"
-   "  return 42;\n"
-   "}] aaa:42\n"
-   "bb:42];");
-  // Non-corner case.
-  verifyFormat("[[object aaa:42\n"
-   "   b:42]\n"
-   "cc:42 d:42];");
-  // Arguments just fit into one line.
-  verifyFormat("[[object aaa:42\n"
-   "   b:42]\n"
-   "cc:42 d:42];");
-  // Arguments just over a column limit.
-  verifyFormat("[[object aaa:42\n"
-   "   b:42]\n"
-   "cc:42\n"
-   "dd:42];");
-
   Style.ColumnLimit = 70;
   verifyFormat(
   "void f() {\n"
Index: lib/Format/ContinuationIndenter.cpp
===
--- lib/Format/ContinuationIndenter.cpp
+++ lib/Format/ContinuationIndenter.cpp
@@ -1073,34 +1073,8 @@
   if (Current.isMemberAccess())
 State.Stack.back().StartOfFunctionCall =
 !Current.NextOperator ? 0 : State.Column;
-  if (Current.is(TT_SelectorName) &&
-  !State.Stack.back().ObjCSelectorNameFound) {
+  if (Current.is(TT_SelectorName))
 State.Stack.back().ObjCSelectorNameFound = true;
-
-// Reevaluate whether ObjC message arguments fit into one line.
-// If a receiver spans multiple lines, e.g.:
-//   [[object block:^{
-// return 42;
-//   }] a:42 b:42];
-// BreakBeforeParameter is calculated based on an incorrect assumption
-// (it is checked whether the whole expression fits into one line without
-// considering a line break inside a message receiver).
-if (Current.Previous && Current.Previous->closesScope() &&
-Current.Previous->MatchingParen &&
-Current.Previous->MatchingParen->Previous) {
-  const FormatToken  =
-  *Current.Previous->MatchingParen->Previous;
-  if (CurrentScopeOpener.is(TT_ObjCMethodExpr) &&
-  CurrentScopeOpener.MatchingParen) {
-int NecessarySpaceInLine =
-getLengthToMatchingParen(CurrentScopeOpener, State.Stack) +
-CurrentScopeOpener.TotalLength - Current.TotalLength - 1;
-if (State.Column + Current.ColumnWidth + NecessarySpaceInLine <=
-Style.ColumnLimit)
-  State.Stack.back().BreakBeforeParameter = false;
-  }
-}
-  }
   if (Current.is(TT_CtorInitializerColon) &&
   Style.BreakConstructorInitializers != FormatStyle::BCIS_AfterColon) {
 // Indent 2 from the column, so:


Index: unittests/Format/FormatTestObjC.cpp
===
--- unittests/Format/FormatTestObjC.cpp
+++ unittests/Format/FormatTestObjC.cpp
@@ -796,35 +796,6 @@
   verifyFormat("[((Foo *)foo) bar];");
   verifyFormat("[((Foo *)foo) bar:1 blech:2];");
 
-  // Message receiver taking multiple lines.
-  Style.ColumnLimit = 20;
-  // Non-corner case.
-  verifyFormat("[[object block:^{\n"
-   "  return 42;\n"
-   "}] a:42 b:42];");
-  // Arguments just fit into one line.
-  verifyFormat("[[object block:^{\n"
-   "  return 42;\n"
-   "}] aaa:42 b:42];");
-  // Arguments just over a column limit.
-  verifyFormat("[[object block:^{\n"
-   "  return 42;\n"
-   "}] aaa:42\n"
-   "bb:42];");
-  // Non-corner case.
-  verifyFormat("[[object aaa:42\n"
-   "   b:42]\n"
-   "cc:42 d:42];");
-  // Arguments just fit into one line.
-  verifyFormat("[[object aaa:42\n"
-   "   b:42]\n"
-   "cc:42 d:42];");
-  // Arguments just over a column limit.
-  verifyFormat("[[object aaa:42\n"
-   "   b:42]\n"
-   "cc:42\n"
-   "dd:42];");
-
   Style.ColumnLimit = 70;
   verifyFormat(
   "void f() {\n"
Index: lib/Format/ContinuationIndenter.cpp
===
--- lib/Format/ContinuationIndenter.cpp
+++ lib/Format/ContinuationIndenter.cpp
@@ 

[PATCH] D47058: [ASTImporter] Fix ClassTemplateSpecialization in wrong DC

2018-05-22 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin added a comment.

Hi Gabor,
Could you add a test for TSK_Undeclared as well?


Repository:
  rC Clang

https://reviews.llvm.org/D47058



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


[PATCH] D47202: [CodeGen] use nsw negation for abs

2018-05-22 Thread Sanjay Patel via Phabricator via cfe-commits
spatel added a comment.

In https://reviews.llvm.org/D47202#1108016, @lebedev.ri wrote:

> That is what happens for "hand-rolled" `abs`, https://godbolt.org/g/6dbgXD
>  I *think* this makes sense, since **IIRC** LLVM only supports 
> twos-complement platforms.
>  But all these attributes are currently beyond me, so i won't click the 
> accept button :)


Thanks for taking a look! I should also note that we don't translate the 
standard libcall to the builtin in clang (not sure if we should), so this patch 
doesn't currently affect the common case. We'd probably want to do something 
similar in LibCallSimplifier if this is right.


https://reviews.llvm.org/D47202



___
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-22 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan marked 2 inline comments as done.
leonardchan added inline comments.



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

jakehehrlich wrote:
> You can make the 'c' a Twine instead. That will let you inline these in their 
> respective locations as `  c = "~UA" ` for instance.
So Twine also isn't assignable. If I still want to keep the pattern of 
assigning to a temporary variable, I could instead just make `c` a string.


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] D47057: [ASTImporter] Fix missing implict CXXRecordDecl in ClassTemplateSpecializationDecl

2018-05-22 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin accepted this revision.
a.sidorin added a comment.
This revision is now accepted and ready to land.

LGTM with a nit.




Comment at: lib/AST/ASTImporter.cpp:1962
   TagDecl *Definition = D->getDefinition();
-  if (Definition && Definition != D) {
+  if (!D->isImplicit() /*In contrast to a normal CXXRecordDecl, the implicit
+  CXXRecordDecl of ClassTemplateSpecializationDecl is its redeclaration.

Multiline comments are pretty uncommon in LLVM. Could you please replace it 
with `//` before commit? I.e.
```
if (Definition && Definition != D &&
//
//
!D->isImplicit())
```


Repository:
  rC Clang

https://reviews.llvm.org/D47057



___
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-22 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 148025.

Repository:
  rC Clang

https://reviews.llvm.org/D46084

Files:
  include/clang-c/Index.h
  include/clang/AST/ASTContext.h
  include/clang/AST/BuiltinTypes.def
  include/clang/Basic/DiagnosticCommonKinds.td
  include/clang/Basic/Specifiers.h
  include/clang/Basic/TokenKinds.def
  include/clang/Sema/DeclSpec.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/ASTContext.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/MicrosoftMangle.cpp
  lib/AST/NSAPI.cpp
  lib/AST/Type.cpp
  lib/AST/TypeLoc.cpp
  lib/Analysis/PrintfFormatString.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CodeGenTypes.cpp
  lib/CodeGen/ItaniumCXXABI.cpp
  lib/Index/USRGeneration.cpp
  lib/Parse/ParseDecl.cpp
  lib/Sema/DeclSpec.cpp
  lib/Sema/SemaTemplateVariadic.cpp
  lib/Sema/SemaType.cpp
  lib/Serialization/ASTCommon.cpp
  lib/Serialization/ASTReader.cpp
  test/Frontend/accum.c
  test/Frontend/accum_errors.c
  test/Frontend/accum_errors.cpp
  tools/libclang/CXType.cpp

Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -53,6 +53,12 @@
 BTCASE(Float);
 BTCASE(Double);
 BTCASE(LongDouble);
+BTCASE(ShortAccum);
+BTCASE(Accum);
+BTCASE(LongAccum);
+BTCASE(UShortAccum);
+BTCASE(UAccum);
+BTCASE(ULongAccum);
 BTCASE(Float16);
 BTCASE(Float128);
 BTCASE(NullPtr);
@@ -542,6 +548,12 @@
 TKIND(Float);
 TKIND(Double);
 TKIND(LongDouble);
+TKIND(ShortAccum);
+TKIND(Accum);
+TKIND(LongAccum);
+TKIND(UShortAccum);
+TKIND(UAccum);
+TKIND(ULongAccum);
 TKIND(Float16);
 TKIND(Float128);
 TKIND(NullPtr);
Index: test/Frontend/accum_errors.cpp
===
--- /dev/null
+++ test/Frontend/accum_errors.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -x c++ %s -verify
+
+// Name namgling is not provided for fixed point types in c++
+
+signed short _Accum s_short_accum;  // expected-error{{Fixed point types are only allowed in C}}
+signed _Accum s_accum;  // expected-error{{Fixed point types are only allowed in C}}
+signed long _Accum s_long_accum;  // expected-error{{Fixed point types are only allowed in C}}
+unsigned short _Accum u_short_accum;  // expected-error{{Fixed point types are only allowed in C}}
+unsigned _Accum u_accum;  // expected-error{{Fixed point types are only allowed in C}}
+unsigned long _Accum u_long_accum;  // expected-error{{Fixed point types are only allowed in C}}
+
+short _Accum short_accum;  // expected-error{{Fixed point types are only allowed in C}}
+_Accum accum; // expected-error{{Fixed point types are only allowed in C}}
+long _Accum long_accum;  // expected-error{{Fixed point types are only allowed in C}}
Index: test/Frontend/accum_errors.c
===
--- /dev/null
+++ test/Frontend/accum_errors.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -x c -fsyntax-only -verify -pedantic %s
+
+long long _Accum longlong_accum;  // expected-error{{'long long _Accum' is invalid}}
+unsigned long long _Accum u_longlong_accum;  // expected-error{{'long long _Accum' is invalid}}
Index: test/Frontend/accum.c
===
--- /dev/null
+++ test/Frontend/accum.c
@@ -0,0 +1,26 @@
+// RUN: %clang -cc1 -x c -ast-dump %s | FileCheck %s --strict-whitespace
+
+/*  Various contexts where type _Accum can appear. */
+
+// Primary fixed point types
+signed short _Accum s_short_accum;
+signed _Accum s_accum;
+signed long _Accum s_long_accum;
+unsigned short _Accum u_short_accum;
+unsigned _Accum u_accum;
+unsigned long _Accum u_long_accum;
+
+// Aliased fixed point types
+short _Accum short_accum;
+_Accum accum;
+long _Accum long_accum;
+
+// CHECK:  |-VarDecl {{.*}} s_short_accum 'short _Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} s_accum '_Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} s_long_accum 'long _Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} u_short_accum 'unsigned short _Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} u_accum 'unsigned _Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} u_long_accum 'unsigned long _Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} short_accum 'short _Accum'
+// CHECK-NEXT: |-VarDecl {{.*}} accum '_Accum'
+// CHECK-NEXT: `-VarDecl {{.*}} long_accum 'long _Accum'
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -6816,6 +6816,24 @@
 case PREDEF_TYPE_LONGDOUBLE_ID:
   T = Context.LongDoubleTy;
   break;
+case PREDEF_TYPE_SHORT_ACCUM_ID:
+  T = Context.ShortAccumTy;
+  break;
+case PREDEF_TYPE_ACCUM_ID:
+  T = Context.AccumTy;
+  break;
+case PREDEF_TYPE_LONG_ACCUM_ID:
+  T = Context.LongAccumTy;
+  break;
+case PREDEF_TYPE_USHORT_ACCUM_ID:

[PATCH] D47202: [CodeGen] use nsw negation for abs

2018-05-22 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

That is what happens for "hand-rolled" `abs`, https://godbolt.org/g/6dbgXD
I *think* this makes sense, since **IIRC** LLVM only supports twos-complement 
platforms.
But all these attributes are currently beyond me, so i won't click the accept 
button :)


https://reviews.llvm.org/D47202



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


[PATCH] D46950: [ASTImporter] Fix duplicate class template definitions problem

2018-05-22 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin accepted this revision.
a.sidorin added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!


Repository:
  rC Clang

https://reviews.llvm.org/D46950



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


[libcxx] r332996 - Change the names of two private methods: allocate -> __vallocate and deallocate -> __vdeallocate. NFC. This change triggered by https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61806, w

2018-05-22 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Tue May 22 09:20:28 2018
New Revision: 332996

URL: http://llvm.org/viewvc/llvm-project?rev=332996=rev
Log:
Change the names of two private methods: allocate -> __vallocate and deallocate 
-> __vdeallocate. NFC. This change triggered by 
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61806, which shows up when we 
implement deduction guides for the container adaptors.The names have a 'v' in 
them because WIN32 has a macro named __deallocate. (sigh).


Modified:
libcxx/trunk/include/vector

Modified: libcxx/trunk/include/vector
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/vector?rev=332996=332995=332996=diff
==
--- libcxx/trunk/include/vector (original)
+++ libcxx/trunk/include/vector Tue May 22 09:20:28 2018
@@ -781,8 +781,8 @@ public:
 private:
 _LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators();
 _LIBCPP_INLINE_VISIBILITY void __invalidate_iterators_past(pointer 
__new_last);
-void allocate(size_type __n);
-void deallocate() _NOEXCEPT;
+void __vallocate(size_type __n);
+void __vdeallocate() _NOEXCEPT;
 _LIBCPP_INLINE_VISIBILITY size_type __recommend(size_type __new_size) 
const;
 void __construct_at_end(size_type __n);
 _LIBCPP_INLINE_VISIBILITY
@@ -951,7 +951,7 @@ vector<_Tp, _Allocator>::__swap_out_circ
 //  Postcondition:  size() == 0
 template 
 void
-vector<_Tp, _Allocator>::allocate(size_type __n)
+vector<_Tp, _Allocator>::__vallocate(size_type __n)
 {
 if (__n > max_size())
 this->__throw_length_error();
@@ -962,7 +962,7 @@ vector<_Tp, _Allocator>::allocate(size_t
 
 template 
 void
-vector<_Tp, _Allocator>::deallocate() _NOEXCEPT
+vector<_Tp, _Allocator>::__vdeallocate() _NOEXCEPT
 {
 if (this->__begin_ != nullptr)
 {
@@ -1098,7 +1098,7 @@ vector<_Tp, _Allocator>::vector(size_typ
 #endif
 if (__n > 0)
 {
-allocate(__n);
+__vallocate(__n);
 __construct_at_end(__n);
 }
 }
@@ -1113,7 +1113,7 @@ vector<_Tp, _Allocator>::vector(size_typ
 #endif
 if (__n > 0)
 {
-allocate(__n);
+__vallocate(__n);
 __construct_at_end(__n);
 }
 }
@@ -1127,7 +1127,7 @@ vector<_Tp, _Allocator>::vector(size_typ
 #endif
 if (__n > 0)
 {
-allocate(__n);
+__vallocate(__n);
 __construct_at_end(__n, __x);
 }
 }
@@ -1141,7 +1141,7 @@ vector<_Tp, _Allocator>::vector(size_typ
 #endif
 if (__n > 0)
 {
-allocate(__n);
+__vallocate(__n);
 __construct_at_end(__n, __x);
 }
 }
@@ -1195,7 +1195,7 @@ vector<_Tp, _Allocator>::vector(_Forward
 size_type __n = static_cast(_VSTD::distance(__first, __last));
 if (__n > 0)
 {
-allocate(__n);
+__vallocate(__n);
 __construct_at_end(__first, __last, __n);
 }
 }
@@ -1215,7 +1215,7 @@ vector<_Tp, _Allocator>::vector(_Forward
 size_type __n = static_cast(_VSTD::distance(__first, __last));
 if (__n > 0)
 {
-allocate(__n);
+__vallocate(__n);
 __construct_at_end(__first, __last, __n);
 }
 }
@@ -1230,7 +1230,7 @@ vector<_Tp, _Allocator>::vector(const ve
 size_type __n = __x.size();
 if (__n > 0)
 {
-allocate(__n);
+__vallocate(__n);
 __construct_at_end(__x.__begin_, __x.__end_, __n);
 }
 }
@@ -1245,7 +1245,7 @@ vector<_Tp, _Allocator>::vector(const ve
 size_type __n = __x.size();
 if (__n > 0)
 {
-allocate(__n);
+__vallocate(__n);
 __construct_at_end(__x.__begin_, __x.__end_, __n);
 }
 }
@@ -1306,7 +1306,7 @@ vector<_Tp, _Allocator>::vector(initiali
 #endif
 if (__il.size() > 0)
 {
-allocate(__il.size());
+__vallocate(__il.size());
 __construct_at_end(__il.begin(), __il.end(), __il.size());
 }
 }
@@ -1321,7 +1321,7 @@ vector<_Tp, _Allocator>::vector(initiali
 #endif
 if (__il.size() > 0)
 {
-allocate(__il.size());
+__vallocate(__il.size());
 __construct_at_end(__il.begin(), __il.end(), __il.size());
 }
 }
@@ -1356,7 +1356,7 @@ void
 vector<_Tp, _Allocator>::__move_assign(vector& __c, true_type)
 _NOEXCEPT_(is_nothrow_move_assignable::value)
 {
-deallocate();
+__vdeallocate();
 __base::__move_assign_alloc(__c); // this can throw
 this->__begin_ = __c.__begin_;
 this->__end_ = __c.__end_;
@@ -1431,8 +1431,8 @@ vector<_Tp, _Allocator>::assign(_Forward
 }
 else
 {
-deallocate();
-allocate(__recommend(__new_size));
+__vdeallocate();
+__vallocate(__recommend(__new_size));
 __construct_at_end(__first, __last, __new_size);
 }
 __invalidate_all_iterators();
@@ -1453,8 +1453,8 @@ vector<_Tp, _Allocator>::assign(size_typ
 }
 else
 {
-deallocate();
-allocate(__recommend(static_cast(__n)));
+__vdeallocate();
+

[PATCH] D47099: Call CreateTempAllocaWithoutCast for ActiveFlag

2018-05-22 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

I revert it since it caused regression on arm and some other arch's.

  Script:
  --
  
/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/stage1/bin/clang
 -cc1 -internal-isystem 
/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/stage1/lib/clang/7.0.0/include
 -nostdsysteminc -emit-llvm 
/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/tools/clang/test/CodeGenCXX/conditional-temporaries.cpp
 -o - -triple=x86_64-apple-darwin9 -O3 | 
/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/stage1/bin/FileCheck
 
/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/tools/clang/test/CodeGenCXX/conditional-temporaries.cpp
  
/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/stage1/bin/clang
 -cc1 -internal-isystem 
/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/stage1/lib/clang/7.0.0/include
 -nostdsysteminc -emit-llvm 
/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/tools/clang/test/CodeGenCXX/conditional-temporaries.cpp
 -o - -triple=amdgcn-amd-amdhsa -O3 | 
/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/stage1/bin/FileCheck
 
/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/tools/clang/test/CodeGenCXX/conditional-temporaries.cpp
  --
  Exit Code: 1
  
  Command Output (stderr):
  --
  
/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/tools/clang/test/CodeGenCXX/conditional-temporaries.cpp:42:12:
 error: expected string not found in input
   // CHECK: ret i32 5
 ^
  :11:33: note: scanning from here
  define i32 @_Z12getCtorCallsv() local_unnamed_addr #0 {
  ^
  :14:2: note: possible intended match here
   ret i32 %0
   ^
  
/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/tools/clang/test/CodeGenCXX/conditional-temporaries.cpp:48:12:
 error: expected string not found in input
   // CHECK: ret i32 5
 ^
  :18:33: note: scanning from here
  define i32 @_Z12getDtorCallsv() local_unnamed_addr #0 {
  ^
  :21:2: note: possible intended match here
   ret i32 %0
   ^
  
/home/ssglocal/clang-cmake-x86_64-avx2-linux/clang-cmake-x86_64-avx2-linux/llvm/tools/clang/test/CodeGenCXX/conditional-temporaries.cpp:54:12:
 error: expected string not found in input
   // CHECK: ret i1 true
 ^
  :25:34: note: scanning from here
  define zeroext i1 @_Z7successv() local_unnamed_addr #0 {
   ^
  :30:2: note: possible intended match here
   ret i1 %cmp
   ^
  
  --

Strange thing is that this only happens on some arch's. It passes on my 
x86_64/ubuntu built with clang.


Repository:
  rC Clang

https://reviews.llvm.org/D47099



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


r332991 - Revert r332982 Call CreateTempMemWithoutCast for ActiveFlag

2018-05-22 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Tue May 22 09:13:07 2018
New Revision: 332991

URL: http://llvm.org/viewvc/llvm-project?rev=332991=rev
Log:
Revert r332982 Call CreateTempMemWithoutCast for ActiveFlag

Due to regression on arm.

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

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=332991=332990=332991=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Tue May 22 09:13:07 2018
@@ -3888,8 +3888,9 @@ RValue CodeGenFunction::EmitCall(const C
   assert(NumIRArgs == 1);
   if (!I->isAggregate()) {
 // Make a temporary alloca to pass the argument.
-Address Addr = CreateMemTempWithoutCast(
-I->Ty, ArgInfo.getIndirectAlign(), "indirect-arg-temp");
+Address Addr = CreateMemTemp(I->Ty, ArgInfo.getIndirectAlign(),
+ "indirect-arg-temp", /*Alloca=*/nullptr,
+ /*Cast=*/false);
 IRCallArgs[FirstIRArg] = Addr.getPointer();
 
 I->copyInto(*this, Addr);
@@ -3934,8 +3935,9 @@ RValue CodeGenFunction::EmitCall(const C
 }
 if (NeedCopy) {
   // Create an aligned temporary, and copy to it.
-  Address AI = CreateMemTempWithoutCast(
-  I->Ty, ArgInfo.getIndirectAlign(), "byval-temp");
+  Address AI = CreateMemTemp(I->Ty, ArgInfo.getIndirectAlign(),
+ "byval-temp", /*Alloca=*/nullptr,
+ /*Cast=*/false);
   IRCallArgs[FirstIRArg] = AI.getPointer();
   I->copyInto(*this, AI);
 } else {

Modified: cfe/trunk/lib/CodeGen/CGCleanup.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCleanup.cpp?rev=332991=332990=332991=diff
==
--- cfe/trunk/lib/CodeGen/CGCleanup.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCleanup.cpp Tue May 22 09:13:07 2018
@@ -283,8 +283,8 @@ void EHScopeStack::popNullFixups() {
 
 void CodeGenFunction::initFullExprCleanup() {
   // Create a variable to decide whether the cleanup needs to be run.
-  Address active = CreateTempAllocaWithoutCast(
-  Builder.getInt1Ty(), CharUnits::One(), "cleanup.cond");
+  Address active = CreateTempAlloca(Builder.getInt1Ty(), CharUnits::One(),
+"cleanup.cond");
 
   // Initialize it to false at a site that's guaranteed to be run
   // before each evaluation.

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=332991=332990=332991=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Tue May 22 09:13:07 2018
@@ -61,30 +61,21 @@ llvm::Value *CodeGenFunction::EmitCastTo
 
 /// 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) {
-  auto Alloca = CreateTempAllocaWithoutCast(Ty, Align, Name, ArraySize);
+  Address *AllocaAddr,
+  bool CastToDefaultAddrSpace) {
+  auto Alloca = CreateTempAlloca(Ty, Name, ArraySize);
+  Alloca->setAlignment(Align.getQuantity());
   if (AllocaAddr)
-*AllocaAddr = Alloca;
-  llvm::Value *V = Alloca.getPointer();
+*AllocaAddr = Address(Alloca, Align);
+  llvm::Value *V = Alloca;
   // Alloca always returns a pointer in alloca address space, which may
   // be different from the type defined by the language. For example,
   // in C++ the auto variables are in the default address space. Therefore
   // cast alloca to the default address space when necessary.
-  if (getASTAllocaAddressSpace() != LangAS::Default) {
+  if 

[PATCH] D47200: [Sema] Add tests for weak functions

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

LGTM!


Repository:
  rC Clang

https://reviews.llvm.org/D47200



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


[PATCH] D47065: [clangd] Enable parsing of non-doxygen comments in global-symbol-builder

2018-05-22 Thread Eric Liu via Phabricator via cfe-commits
ioeric accepted this revision.
ioeric added a comment.
This revision is now accepted and ready to land.

lgtm


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D47065



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


[PATCH] D47161: update

2018-05-22 Thread Anastasis via Phabricator via cfe-commits
gramanas abandoned this revision.
gramanas added a comment.

Duplicate of https://reviews.llvm.org/D47097


Repository:
  rC Clang

https://reviews.llvm.org/D47161



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


[PATCH] D47195: [clang-format] Fix ObjC message arguments handling

2018-05-22 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added inline comments.



Comment at: unittests/Format/FormatTestObjC.cpp:815
+
+  // No line break before closing receiver's scope.
+  verifyFormat("[[obj a:42] a:42\n"

jolesiak wrote:
> krasimir wrote:
> > What's the receiver's scope in this comment referring to?
> > Also, how would the old test cases be formatted?
> For a receiver: `[obj a:42]` I meant `]` as a token closing the scope.
> I'll rephrase the comment to be more precise.
> 
> Old tests were introduced in D46879. After this change the formatting will be 
> the same as it was before D46879, i.e. the same as for last test touched in 
> this change:
> ```
> [[obj aa:42
>b:42]
> cc:42
>  d:42];
> ```
> even if
> ```
> [[obj aa:42
>b:42]
> cc:42 d:42];
> ```
> satisfies the column limit.
Ah, I think  get it now: the new code should only apply to after object blocks 
and not after object receivers? Is this the intention?


Repository:
  rC Clang

https://reviews.llvm.org/D47195



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


  1   2   >