[PATCH] D78767: [Sema] Teach -Wcast-align to compute a more accurate alignment when the source expression has array subscript or pointer arithmetic operators

2020-05-14 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:13122
+if (Base->isVirtual()) {
+  BaseAlignment = Ctx.getTypeAlignInChars(Base->getType());
+  Offset = CharUnits::Zero();

rjmccall wrote:
> ahatanak wrote:
> > rjmccall wrote:
> > > Oh, this — and all the other places that do presumed alignment based on a 
> > > pointee type — needs a special case for C++ records with virtual bases, 
> > > because you need to get its presumed alignment as a base sub-object, not 
> > > its presumed alignment as a complete object, which is what 
> > > `getTypeAlignInChars` will return.  The right way to merge that 
> > > information is to get the normal alignment — which may be lower than 
> > > expected if there's a typedef in play — and then `min` that with the base 
> > > sub-object alignment.
> > I think the base sub-object alignment in this case is the 
> > `NonVirtualAlignment` of the class (the `CXXRecordDecl` of `Base` in this 
> > function), but it's not clear to me what the normal alignment is. I don't 
> > think it's what `Ctx.getTypeAlignInChars(Base->getType())` returns, is it? 
> > I see `CodeGenModule::getDynamicOffsetAlignment` seems to be doing what you 
> > are suggesting, but I'm not sure whether that's what we should be doing 
> > here. It looks like it's comparing the alignment of the derived class and 
> > the non-virtual alignment of the base class.
> The base sub-object alignment is the class's non-virtual alignment, right.
> 
> By the normal alignment, I mean the alignment you're starting from for the 
> outer object — if that's less than the base's alignment, the base may be 
> misaligned as well.  For the non-base-conversion case, that's probably not 
> necessary to consider.
> 
Let me know if the comment explaining why we are taking the minimum makes 
sense. I added a test case for this too (``).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78767



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


[PATCH] D78767: [Sema] Teach -Wcast-align to compute a more accurate alignment when the source expression has array subscript or pointer arithmetic operators

2020-05-14 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 264157.
ahatanak marked 2 inline comments as done.
ahatanak added a comment.

Fix alignment computation of virtual bases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78767

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/test/SemaCXX/warn-cast-align.cpp

Index: clang/test/SemaCXX/warn-cast-align.cpp
===
--- clang/test/SemaCXX/warn-cast-align.cpp
+++ clang/test/SemaCXX/warn-cast-align.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -Wcast-align -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -Wno-unused-value -Wcast-align -verify %s
 
 // Simple casts.
 void test0(char *P) {
@@ -43,3 +43,115 @@
   typedef int *IntPtr;
   c = IntPtr(P);
 }
+
+struct __attribute__((aligned(16))) A {
+  char m0[16];
+  char m1[16];
+};
+
+struct B0 {
+  char m0[16];
+};
+
+struct B1 {
+  char m0[16];
+};
+
+struct C {
+  A 
+  B0 
+  A m2;
+};
+
+struct __attribute__((aligned(16))) D0 : B0, B1 {
+};
+
+struct __attribute__((aligned(16))) D1 : virtual B0 {
+};
+
+struct B2 {
+  char m0[8];
+};
+
+struct B3 {
+  char m0[8];
+};
+
+struct B4 {
+  char m0[8];
+};
+
+struct D2 : B2, B3 {
+};
+
+struct __attribute__((aligned(16))) D3 : B4, D2 {
+};
+
+struct __attribute__((aligned(16))) D4 : virtual D2 {
+};
+
+struct D5 : virtual D0 {
+  char m0[16];
+};
+
+struct D6 : virtual D5 {
+};
+
+struct D7 : virtual D3 {
+};
+
+void test2(int n, A *a2) {
+  __attribute__((aligned(16))) char m[sizeof(A) * 2];
+  char(_ref)[sizeof(A) * 2] = m;
+  extern char(_ref_noinit)[sizeof(A) * 2];
+  __attribute__((aligned(16))) char vararray[10][n];
+  A t0;
+  B0 t1;
+  C t2 = {.m0 = t0, .m1 = t1};
+  __attribute__((aligned(16))) char t3[5][5][5];
+  __attribute__((aligned(16))) char t4[4][16];
+  D0 t5;
+  D1 t6;
+  D3 t7;
+  D4 t8;
+  D6 t9;
+  __attribute__((aligned(1))) D7 t10;
+
+  A *a;
+  a = (A *)
+  a = (A *)(m + sizeof(A));
+  a = (A *)(sizeof(A) + m);
+  a = (A *)((sizeof(A) * 2 + m) - sizeof(A));
+  a = (A *)((sizeof(A) * 2 + m) - 1); // expected-warning {{cast from 'char *' to 'A *'}}
+  a = (A *)(m + 1);   // expected-warning {{cast from 'char *' to 'A *'}}
+  a = (A *)(1 + m);   // expected-warning {{cast from 'char *' to 'A *'}}
+  a = (A *)(m + n);   // expected-warning {{cast from 'char *' to 'A *'}}
+  a = (A *)&*[sizeof(A)];
+  a = (A *)(0, 0, [sizeof(A)]);
+  a = (A *)&(0, 0, *[sizeof(A)]);
+  a = (A *)[n]; // expected-warning {{cast from 'char *' to 'A *'}}
+  a = (A *)_ref;
+  a = (A *)_ref_noinit;// expected-warning {{cast from 'char (*)[64]' to 'A *'}}
+  a = (A *)([4][0]);// expected-warning {{cast from 'char *' to 'A *'}}
+  a = (A *)(a2->m0 + sizeof(A)); // expected-warning {{cast from 'char *' to 'A *'}}
+  a = (A *)();
+  a = (A *)(); // expected-warning {{cast from 'B0 *' to 'A *'}}
+  a = (A *)();
+  a = (A *)(t2.m2.m1);
+  a = (A *)([3][3][0]); // expected-warning {{cast from 'char *' to 'A *'}}
+  a = (A *)([2][2][4]);
+  a = (A *)([0][n][0]); // expected-warning {{cast from 'char *' to 'A *'}}
+  a = (A *)[n][0];
+  a = (A *)[n][1]; // expected-warning {{cast from 'char *' to 'A *'}}
+  a = (A *)(t4 + 1);
+  a = (A *)(t4 + n);
+  a = (A *)(static_cast());
+  a = (A *)(&(static_cast(t5)));
+  a = (A *)(static_cast()); // expected-warning {{cast from 'B0 *' to 'A *'}}
+  a = (A *)(static_cast()); // expected-warning {{cast from 'B2 *' to 'A *'}}
+  a = (A *)(static_cast());
+  a = (A *)(static_cast());  // expected-warning {{cast from 'B2 *' to 'A *'}}
+  a = (A *)(static_cast());  // expected-warning {{cast from 'B3 *' to 'A *'}}
+  a = (A *)(static_cast());  // expected-warning {{cast from 'D5 *' to 'A *'}}
+  a = (A *)(static_cast()); // expected-warning {{cast from 'D3 *' to 'A *'}}
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -30,6 +30,7 @@
 #include "clang/AST/NSAPI.h"
 #include "clang/AST/NonTrivialTypeVisitor.h"
 #include "clang/AST/OperationKinds.h"
+#include "clang/AST/RecordLayout.h"
 #include "clang/AST/Stmt.h"
 #include "clang/AST/TemplateBase.h"
 #include "clang/AST/Type.h"
@@ -13105,17 +13106,226 @@
   return HasInvalidParm;
 }
 
-/// A helper function to get the alignment of a Decl referred to by DeclRefExpr
-/// or MemberExpr.
-static CharUnits getDeclAlign(Expr *E, CharUnits TypeAlign,
-  ASTContext ) {
-  if (const auto *DRE = dyn_cast(E))
-return Context.getDeclAlign(DRE->getDecl());
+Optional>
+static getBaseAlignmentAndOffsetFromPtr(const Expr *E, ASTContext );
+
+/// Compute the alignment and offset of the base class object given the
+/// derived-to-base cast expression and the alignment and offset of the derived

[PATCH] D78862: [IR] Convert null-pointer-is-valid into an enum attribute

2020-05-14 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert accepted this revision.
jdoerfert added a comment.
This revision is now accepted and ready to land.
Herald added subscribers: jurahul, kuter.

In D78862#2027254 , @arsenm wrote:

> In D78862#2012560 , @jdoerfert wrote:
>
> > I think this is an improvement over the status quo and it looks fine to me.
> >
> > @arsenm I agree that we should tie this to the data layout (or at least 
> > should try) but I guess there are open questions to answer and code to 
> > write.
> >  I propose to accept this and work on the DL patch after. WDYT?
>
>
> Seems ok, but it's still burning an enum value which I guess isn't super 
> important. With the datalayout property, we might really want the inverse 
> attribute


Given that we lifted the limits on enum attributes I don't think this cost is 
high. Since we do not have a scheduled alternative, I think this should land.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78862



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


[PATCH] D79968: StoreInst should store Align, not MaybeAlign

2020-05-14 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert accepted this revision.
jdoerfert added a comment.
This revision is now accepted and ready to land.

LGTM, two minor things below.




Comment at: clang/lib/CodeGen/CGExpr.cpp:130
+  auto *Store = new llvm::StoreInst(Init, Var.getPointer(), false,
+Var.getAlignment().getAsAlign());
   llvm::BasicBlock *Block = AllocaInsertPt->getParent();

Nit: I guess `/* volatile */ false`



Comment at: llvm/lib/IR/Instructions.cpp:1422
+: StoreInst(val, addr, isVolatile,
+computeLoadAlign(val->getType(), InsertBefore), InsertBefore) 
{}
 

Minor: Do we want toe keep the name? `computeAccessAlign` maybe? Or a shallow 
`computeStoreAlign` wrapper? No strong feelings, just odd.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79968



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


[PATCH] D79676: [Clang][OpenMP][OMPBuilder] Moving OMP allocation and cache creation code to OMPBuilderCBHelpers

2020-05-14 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert accepted this revision.
jdoerfert added a comment.
This revision is now accepted and ready to land.

Interesting that no tests changed but I guess we just start the move to the 
IRBUilder.

I think there are two minor comments from before that need to be addressed and 
the alloca thing, otherwise LGTM.




Comment at: clang/lib/CodeGen/CodeGenFunction.h:1581
+++I;
+
+  return &*I;

fghanim wrote:
> jdoerfert wrote:
> > What is wrong with `BB->getFirstNonPHIOrDbgOrLifetime()`? If it is to avoid 
> > too many test changes, please add a TODO. I think from a functional 
> > perspective there is no need to advance it after the first set of allocas 
> > that may be separated from the phis by non-allocas?
> Nothing wrong with it. The first while loop, I just came across a case that I 
> don't remember at the moment that had an instruction that wasn't an alloca, 
> and I wanted to skip over that.
> the second while, is to get to the first non-alloca instruction. The purpose 
> is to be able to insert new allocas, after already generated allocas.
There is no need to do that. It is fine to insert allocas anywhere in the block.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79676



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


[PATCH] D79675: [OpenMP][OMPBuilder] Adding Privatization Requirements to OMPIRBuilder

2020-05-14 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D79675#2037484 , @fghanim wrote:

> In D79675#2037314 , @jdoerfert wrote:
>
> > I left some comments on the type stuff. The rest looks good.
> >  I think if you rebase the type stuff on D79739 
> >  (which I can merge) we should only need 
> > to expand `initializeTypes` to make this work as expected. WDYT?
>
>
> Currently, I implemented the changes relevant to me from that and made a 
> separate local commit prior to this one to make sure things work.
>  I build llvm locally, and so it take 6 - 8 hours, so when all patches are 
> accepted, I'll do a rebase, etc. in one go to make sure there are no problems.


What takes 6-8h? Are you sure you don't want to merge parts that went through 
review as soon as possible? I mean, at least the type parts would be helpful.




Comment at: llvm/include/llvm/Frontend/OpenMP/OMPKinds.def:234
 __OMP_RTL(__kmpc_critical, false, Void, IdentPtr, Int32, KmpCriticalNamePtrTy)
-__OMP_RTL(__kmpc_critical_with_hint, false, Void, IdentPtr, Int32, 
KmpCriticalNamePtrTy, Int32)
+__OMP_RTL(__kmpc_critical_with_hint, false, Void, IdentPtr, Int32, 
KmpCriticalNamePtrTy, IntPtrTy)
 __OMP_RTL(__kmpc_end_critical, false, Void, IdentPtr, Int32, 
KmpCriticalNamePtrTy)

fghanim wrote:
> jdoerfert wrote:
> > fghanim wrote:
> > > jdoerfert wrote:
> > > > fghanim wrote:
> > > > > jdoerfert wrote:
> > > > > > I think this was correct before:
> > > > > > ```
> > > > > >   KMP_EXPORT void __kmpc_critical_with_hint(ident_t *, kmp_int32 
> > > > > > global_tid, kmp_critical_name *, uint32_t hint);
> > > > > > ```
> > > > > Nop, it's supposed to be whatever `IntPtrTy` is in the frontend (i.e. 
> > > > > 32 for 32bit, 64 for 64bit).
> > > > > 
> > > > > `IntPtrTy` is actually a union with `sizety` in `CodeGenModule`
> > > > I'm confused. I copied the declaration above from the runtime. It 
> > > > doesn't contain an `IntPtrTy` or similar. I agree that `IntPtrTy` is 
> > > > machine dependent and we need your initializers. What I tried to say is 
> > > > that at least one declaration in the runtime has 
> > > > `__kmpc_critical_with_hint` with an int32 as last argument. That said, 
> > > > the runtime is not shy of incompatible declarations for functions.
> > > I cannot speak for what's in the runtime. However, in clang, this 
> > > currently is defined to use `IntPtrTy`. If you go check, I have a todo in 
> > > the current implementation for critical to come back and fix it.
> > That is just an existing bug in Clang. The runtime is consistent with the 
> > type and arguably it is the runtime we must match, not the other way around 
> > ;)
> Apparently, this used to be `uintptr_t` in the runtime and was changed by 
> D51235 . It doesn't say why the change was made.
> 
> Clang uses this in multiple places, which makes me think it may have been 
> intentional. So I suggest we go by the standard. Where can I find what does 
> the OMP standard say about how the signature of the runtime calls should look 
> like? This way I'll fix this one accordingly, and later we may go and make 
> sure that all the rest match up with the standard - where possible.
This is not a standard function. It is a runtime function. I suspect it is a 
int32_t because enums default to `int` which is 32 bit on all interesting 
platforms. Should probably be a `int` but I would need to read up to confirm. 
Long story short, and as I said before, it is a bug in clang. The code here was 
correct.

FWIW, we will soon replace clang's runtime function generation with these 
macros. That will happen in the next days I hope.



Comment at: llvm/lib/Frontend/OpenMP/OMPConstants.cpp:122
+  }
+}
+

fghanim wrote:
> jdoerfert wrote:
> > fghanim wrote:
> > > jdoerfert wrote:
> > > > (I doubt we need the `initVoidPtr` function but if we do, the condition 
> > > > looks wrong)
> > > Forgot to refractor when I changed names.
> > > 
> > > Regarding `void*` , I am not sure how it is defined in fortran. That's 
> > > why I made it possible to initialize it separately.
> > I see. Let's cross that bridge once we get to it.
> Modified it a bit and removed usage from initialization. If fortran people 
> don't end using it, then we can remove it.
Let's not add stuff that might be used.



Comment at: llvm/lib/Frontend/OpenMP/OMPConstants.cpp:69
 
 void llvm::omp::types::initializeTypes(Module ) {
   if (Void)

fghanim wrote:
> jdoerfert wrote:
> > Maybe we can/should take the IntPtr and SizeTy here so there is only a 
> > single call necessary that initializes all types. I fear "default" values 
> > are problematic.
> > 
> > WDYT?
> you mean pass it as a second argument? Sure, I would love that. I mean it's 
> fine with me either way. I originally wanted to do that. but then thought 
> maybe it is slightly better to 

[PATCH] D79693: [test][ARM][CMSE] Use clang_cc1 in arm_cmse.h tests

2020-05-14 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast updated this revision to Diff 264149.
hubert.reinterpretcast added a comment.

- Use clang_cc1 in arm_cmse.h tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79693

Files:
  clang/test/CodeGen/arm-cmse-nonsecure.c
  clang/test/CodeGen/arm-cmse-secure.c


Index: clang/test/CodeGen/arm-cmse-secure.c
===
--- clang/test/CodeGen/arm-cmse-secure.c
+++ clang/test/CodeGen/arm-cmse-secure.c
@@ -1,5 +1,5 @@
-// RUN: %clang -mlittle-endian -mcmse -target thumbv8m.base-eabi -emit-llvm -S 
-o - %s | FileCheck %s
-// RUN: %clang -mbig-endian-mcmse -target thumbv8m.base-eabi -emit-llvm -S 
-o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple thumbv8m.base-unknown-unknown-eabi   -emit-llvm 
-mrelocation-model static -mcmse -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple thumbebv8m.base-unknown-unknown-eabi -emit-llvm 
-mrelocation-model static -mcmse -o - %s | FileCheck %s
 
 #include 
 
Index: clang/test/CodeGen/arm-cmse-nonsecure.c
===
--- clang/test/CodeGen/arm-cmse-nonsecure.c
+++ clang/test/CodeGen/arm-cmse-nonsecure.c
@@ -1,5 +1,5 @@
-// RUN: %clang  -mlittle-endian -target thumbv8m.base-eabi  -emit-llvm -S -o - 
%s | FileCheck %s
-// RUN: %clang  -mbig-endian-target thumbv8m.base-eabi  -emit-llvm -S -o - 
%s | FileCheck %s
+// RUN: %clang_cc1 -triple thumbv8m.base-unknown-unknown-eabi   -emit-llvm 
-mrelocation-model static -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple thumbebv8m.base-unknown-unknown-eabi -emit-llvm 
-mrelocation-model static -o - %s | FileCheck %s
 
 #include 
 


Index: clang/test/CodeGen/arm-cmse-secure.c
===
--- clang/test/CodeGen/arm-cmse-secure.c
+++ clang/test/CodeGen/arm-cmse-secure.c
@@ -1,5 +1,5 @@
-// RUN: %clang -mlittle-endian -mcmse -target thumbv8m.base-eabi -emit-llvm -S -o - %s | FileCheck %s
-// RUN: %clang -mbig-endian-mcmse -target thumbv8m.base-eabi -emit-llvm -S -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple thumbv8m.base-unknown-unknown-eabi   -emit-llvm -mrelocation-model static -mcmse -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple thumbebv8m.base-unknown-unknown-eabi -emit-llvm -mrelocation-model static -mcmse -o - %s | FileCheck %s
 
 #include 
 
Index: clang/test/CodeGen/arm-cmse-nonsecure.c
===
--- clang/test/CodeGen/arm-cmse-nonsecure.c
+++ clang/test/CodeGen/arm-cmse-nonsecure.c
@@ -1,5 +1,5 @@
-// RUN: %clang  -mlittle-endian -target thumbv8m.base-eabi  -emit-llvm -S -o - %s | FileCheck %s
-// RUN: %clang  -mbig-endian-target thumbv8m.base-eabi  -emit-llvm -S -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple thumbv8m.base-unknown-unknown-eabi   -emit-llvm -mrelocation-model static -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple thumbebv8m.base-unknown-unknown-eabi -emit-llvm -mrelocation-model static -o - %s | FileCheck %s
 
 #include 
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D79967: Fix debug info for NoDebug attr

2020-05-14 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 264148.
yaxunl added a comment.

add a test for nodebug attr.


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

https://reviews.llvm.org/D79967

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGen/nodebug-attr.c
  clang/test/CodeGenCUDA/kernel-dbg-info.cu


Index: clang/test/CodeGenCUDA/kernel-dbg-info.cu
===
--- clang/test/CodeGenCUDA/kernel-dbg-info.cu
+++ clang/test/CodeGenCUDA/kernel-dbg-info.cu
@@ -2,11 +2,28 @@
 
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -O0 \
 // RUN:   -fcuda-include-gpubinary %t -debug-info-kind=limited \
-// RUN:   -o - -x hip | FileCheck %s
+// RUN:   -o - -x hip | FileCheck -check-prefixes=CHECK,O0 %s
 // RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -emit-llvm %s -O0 \
 // RUN:   -fcuda-include-gpubinary %t -debug-info-kind=limited \
 // RUN:   -o - -x hip -fcuda-is-device | FileCheck -check-prefix=DEV %s
 
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -O0 \
+// RUN:   -fcuda-include-gpubinary %t -debug-info-kind=limited \
+// RUN:   -o - -x hip -debugger-tuning=gdb -dwarf-version=4 \
+// RUN:   | FileCheck -check-prefixes=CHECK,O0 %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -emit-llvm %s -O0 \
+// RUN:   -fcuda-include-gpubinary %t -debug-info-kind=limited \
+// RUN:   -o - -x hip -debugger-tuning=gdb -dwarf-version=4 \
+// RUN:   -fcuda-is-device | FileCheck -check-prefix=DEV %s
+
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -O3 \
+// RUN:   -fcuda-include-gpubinary %t -debug-info-kind=limited \
+// RUN:   -o - -x hip -debugger-tuning=gdb -dwarf-version=4 | FileCheck %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -emit-llvm %s -O3 \
+// RUN:   -fcuda-include-gpubinary %t -debug-info-kind=limited \
+// RUN:   -o - -x hip -debugger-tuning=gdb -dwarf-version=4 \
+// RUN:   -fcuda-is-device | FileCheck -check-prefix=DEV %s
+
 #include "Inputs/cuda.h"
 
 extern "C" __global__ void ckernel(int *a) {
@@ -27,7 +44,7 @@
 // CHECK-NOT: ret {{.*}}!dbg
 
 // CHECK-LABEL: define {{.*}}@_Z8hostfuncPi{{.*}}!dbg
-// CHECK: call void @[[CSTUB]]{{.*}}!dbg
+// O0: call void @[[CSTUB]]{{.*}}!dbg
 void hostfunc(int *a) {
   ckernel<<<1, 1>>>(a);
 }
Index: clang/test/CodeGen/nodebug-attr.c
===
--- /dev/null
+++ clang/test/CodeGen/nodebug-attr.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -O3 \
+// RUN:   -debug-info-kind=limited -o - -debugger-tuning=gdb -dwarf-version=4 \
+// RUN:   | FileCheck %s
+
+// CHECK-NOT: define {{.*}}@foo{{.*}}!dbg
+// CHECK-LABEL: define {{.*}}@foo
+// CHECK-NOT: ret {{.*}}!dbg
+__attribute__((nodebug)) void foo(int *a) {
+  *a = 1;
+}
+
+// CHECK-LABEL: define {{.*}}@bar{{.*}}!dbg
+void bar(int *a) {
+  foo(a);
+}
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -3779,7 +3779,7 @@
   StringRef LinkageName;
 
   const Decl *D = GD.getDecl();
-  if (!D)
+  if (!D || D->hasAttr())
 return;
 
   llvm::TimeTraceScope TimeScope("DebugFunction", [&]() {


Index: clang/test/CodeGenCUDA/kernel-dbg-info.cu
===
--- clang/test/CodeGenCUDA/kernel-dbg-info.cu
+++ clang/test/CodeGenCUDA/kernel-dbg-info.cu
@@ -2,11 +2,28 @@
 
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -O0 \
 // RUN:   -fcuda-include-gpubinary %t -debug-info-kind=limited \
-// RUN:   -o - -x hip | FileCheck %s
+// RUN:   -o - -x hip | FileCheck -check-prefixes=CHECK,O0 %s
 // RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -emit-llvm %s -O0 \
 // RUN:   -fcuda-include-gpubinary %t -debug-info-kind=limited \
 // RUN:   -o - -x hip -fcuda-is-device | FileCheck -check-prefix=DEV %s
 
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -O0 \
+// RUN:   -fcuda-include-gpubinary %t -debug-info-kind=limited \
+// RUN:   -o - -x hip -debugger-tuning=gdb -dwarf-version=4 \
+// RUN:   | FileCheck -check-prefixes=CHECK,O0 %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -emit-llvm %s -O0 \
+// RUN:   -fcuda-include-gpubinary %t -debug-info-kind=limited \
+// RUN:   -o - -x hip -debugger-tuning=gdb -dwarf-version=4 \
+// RUN:   -fcuda-is-device | FileCheck -check-prefix=DEV %s
+
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -O3 \
+// RUN:   -fcuda-include-gpubinary %t -debug-info-kind=limited \
+// RUN:   -o - -x hip -debugger-tuning=gdb -dwarf-version=4 | FileCheck %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -emit-llvm %s -O3 \
+// RUN:   -fcuda-include-gpubinary %t -debug-info-kind=limited \
+// RUN:   -o - -x hip -debugger-tuning=gdb -dwarf-version=4 \
+// RUN:   -fcuda-is-device | FileCheck -check-prefix=DEV %s
+
 #include "Inputs/cuda.h"
 
 extern "C" __global__ void ckernel(int *a) {
@@ -27,7 +44,7 @@
 // CHECK-NOT: 

[PATCH] D79693: [test][ARM][CMSE] Use clang_cc1 in arm_cmse.h tests

2020-05-14 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment.

In D79693#2036710 , @chill wrote:

> I can also count (`grep -rn '#include.* standard headers. If they don't create a problem, wouldn't it be better to 
> rewrite this test to use `%clang_cc1` ?


@chill, thanks for the suggestion. I've implemented it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79693



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


[PATCH] D79967: Fix debug info for NoDebug attr

2020-05-14 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D79967#2037675 , @dblaikie wrote:

> I'm not quite following the test case - could you explain how it's testing 
> the situation?
>
> It might be better/easier to have a more intentional test - also, could you 
> check the commit history for this declaration-emitting functionality 
> (CGDebugInfo::EmitFunctionDecl when used for a non-member function) & pull 
> them into this review too?


This patch is a follow up of https://reviews.llvm.org/D79866, where we marked a 
compiler generated stub function with NoDebug attribute to eliminate debug info 
for it. Then we found there is a bug causing debug info not fully eliminated 
for a function with NoDebug attribute when the function is inlined, therefore I 
created this patch.

The bug can be demonstrated by

https://godbolt.org/z/z_tA3Z

There is debug info with function foo, which should not. If you change -O3 to 
-O0, the debug info on function foo disappears, which is the expected behavior.

The following code is supposed to eliminate all debug info for functions with 
NoDebugAttr, however it is not sufficient when the function gets inlined:

https://github.com/llvm/llvm-project/blob/dad2e92eaf531500af5ab9ee3350e3e186944185/clang/lib/CodeGen/CodeGenFunction.cpp#L1272

I can add a lit test for a function with NoDebugAttr.


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

https://reviews.llvm.org/D79967



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


[PATCH] D79967: Fix debug info for NoDebug attr

2020-05-14 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

I'm not quite following the test case - could you explain how it's testing the 
situation?

It might be better/easier to have a more intentional test - also, could you 
check the commit history for this declaration-emitting functionality 
(CGDebugInfo::EmitFunctionDecl when used for a non-member function) & pull them 
into this review too?


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

https://reviews.llvm.org/D79967



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


[PATCH] D79974: [Fuchsia] Do not enable the Z3 solver for a fuchsia toolchain

2020-05-14 Thread Leonard Chan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG592303a53e6b: [Fuchsia] Do not enable the Z3 solver for a 
fuchsia toolchain (authored by leonardchan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79974

Files:
  clang/cmake/caches/Fuchsia-stage2.cmake


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -17,6 +17,7 @@
 set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "")
 set(LLVM_INCLUDE_GO_TESTS OFF CACHE BOOL "")
 set(LLVM_USE_RELATIVE_PATHS_IN_FILES ON CACHE BOOL "")
+set(LLVM_ENABLE_Z3_SOLVER OFF CACHE BOOL "")
 
 set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "")
 if(NOT APPLE)


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -17,6 +17,7 @@
 set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "")
 set(LLVM_INCLUDE_GO_TESTS OFF CACHE BOOL "")
 set(LLVM_USE_RELATIVE_PATHS_IN_FILES ON CACHE BOOL "")
+set(LLVM_ENABLE_Z3_SOLVER OFF CACHE BOOL "")
 
 set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "")
 if(NOT APPLE)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D79895: Fix warning about using uninitialized variable as function const reference parameter

2020-05-14 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu updated this revision to Diff 264129.
zequanwu added a comment.

Use another mapvector `constRefUses` to store uninitialized const reference 
uses so that the new warning can be easily disable by 
`-Wno-initialized-const-reference`


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

https://reviews.llvm.org/D79895

Files:
  clang/include/clang/Analysis/Analyses/UninitializedValues.h
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Analysis/UninitializedValues.cpp
  clang/lib/Sema/AnalysisBasedWarnings.cpp
  clang/test/SemaCXX/uninit-variables.cpp
  clang/test/SemaCXX/uninitialized.cpp

Index: clang/test/SemaCXX/uninitialized.cpp
===
--- clang/test/SemaCXX/uninitialized.cpp
+++ clang/test/SemaCXX/uninitialized.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -Wall -Wuninitialized -Wno-unused-value -Wno-unused-lambda-capture -std=c++1z -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wall -Wuninitialized -Wno-unused-value -Wno-unused-lambda-capture -Wno-uninitialized-const-reference -std=c++1z -verify %s
 
 // definitions for std::move
 namespace std {
Index: clang/test/SemaCXX/uninit-variables.cpp
===
--- clang/test/SemaCXX/uninit-variables.cpp
+++ clang/test/SemaCXX/uninit-variables.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -Wuninitialized -fsyntax-only -fcxx-exceptions %s -verify -std=c++1y
+// RUN: %clang_cc1 -fsyntax-only -Wuninitialized -Wno-uninitialized-const-reference -fsyntax-only -fcxx-exceptions %s -verify -std=c++1y
 
 // Stub out types for 'typeid' to work.
 namespace std { class type_info {}; }
Index: clang/lib/Sema/AnalysisBasedWarnings.cpp
===
--- clang/lib/Sema/AnalysisBasedWarnings.cpp
+++ clang/lib/Sema/AnalysisBasedWarnings.cpp
@@ -974,6 +974,14 @@
 << Use.getUser()->getSourceRange();
 }
 
+/// Diagnose 
+static bool DiagnoseUninitializedConstRefUse(Sema , const VarDecl *VD,
+ const UninitUse ) {
+  S.Diag(Use.getUser()->getBeginLoc(), diag::warn_uninit_const_reference)
+  << VD->getDeclName() << Use.getUser()->getSourceRange();
+  return true;
+}
+
 /// DiagnoseUninitializedUse -- Helper function for diagnosing uses of an
 /// uninitialized variable. This manages the different forms of diagnostic
 /// emitted for particular types of uses. Returns true if the use was diagnosed
@@ -1000,8 +1008,9 @@
 
   ContainsReference CR(S.Context, DRE);
   CR.Visit(Initializer);
+  unsigned DiagID = diag::warn_uninit_self_reference_in_init;
   if (CR.doesContainReference()) {
-S.Diag(DRE->getBeginLoc(), diag::warn_uninit_self_reference_in_init)
+S.Diag(DRE->getBeginLoc(), DiagID)
 << VD->getDeclName() << VD->getLocation() << DRE->getSourceRange();
 return true;
   }
@@ -1506,12 +1515,13 @@
   // order of diagnostics when calling flushDiagnostics().
   typedef llvm::MapVector UsesMap;
   UsesMap uses;
+  UsesMap constRefUses;
 
 public:
   UninitValsDiagReporter(Sema ) : S(S) {}
   ~UninitValsDiagReporter() override { flushDiagnostics(); }
 
-  MappedType (const VarDecl *vd) {
+  MappedType (UsesMap , const VarDecl *vd) {
 MappedType  = uses[vd];
 if (!V.getPointer())
   V.setPointer(new UsesVec());
@@ -1520,11 +1530,16 @@
 
   void handleUseOfUninitVariable(const VarDecl *vd,
  const UninitUse ) override {
-getUses(vd).getPointer()->push_back(use);
+getUses(uses, vd).getPointer()->push_back(use);
   }
 
   void handleSelfInit(const VarDecl *vd) override {
-getUses(vd).setInt(true);
+getUses(uses, vd).setInt(true);
+  }
+
+  void handleConstRefUseOfUninitVariable(const VarDecl *vd,
+ const UninitUse ) override {
+getUses(constRefUses, vd).getPointer()->push_back(use);
   }
 
   void flushDiagnostics() {
@@ -1571,6 +1586,20 @@
 }
 
 uses.clear();
+
+// flush all const reference uses diags
+for (const auto  : constRefUses) {
+  const VarDecl *vd = P.first;
+  const MappedType  = P.second;
+
+  UsesVec *vec = V.getPointer();
+  for (const auto  : *vec) {
+if (DiagnoseUninitializedConstRefUse(S, vd, U))
+  break;
+  }
+}
+
+constRefUses.clear();
   }
 
 private:
@@ -2184,7 +2213,8 @@
 
   if (!Diags.isIgnored(diag::warn_uninit_var, D->getBeginLoc()) ||
   !Diags.isIgnored(diag::warn_sometimes_uninit_var, D->getBeginLoc()) ||
-  !Diags.isIgnored(diag::warn_maybe_uninit_var, D->getBeginLoc())) {
+  !Diags.isIgnored(diag::warn_maybe_uninit_var, D->getBeginLoc()) ||
+  !Diags.isIgnored(diag::warn_uninit_const_reference, D->getBeginLoc())) {
 if (CFG *cfg = AC.getCFG()) {
   UninitValsDiagReporter reporter(S);
   

[clang] 592303a - [Fuchsia] Do not enable the Z3 solver for a fuchsia toolchain

2020-05-14 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2020-05-14T17:03:58-07:00
New Revision: 592303a53e6bc0737c3999e91aab9ea2147f73ab

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

LOG: [Fuchsia] Do not enable the Z3 solver for a fuchsia toolchain

gLinux started shipping incompatible versions of Z3, which can lead to a
missing `z3.h` header when building the Z3 solver locally. This patch
disables the Z3 solver when building a clang toolchain for Fuchsia.

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

Added: 


Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index eb2a03e164dd..4ef404b8aaef 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -17,6 +17,7 @@ set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "")
 set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "")
 set(LLVM_INCLUDE_GO_TESTS OFF CACHE BOOL "")
 set(LLVM_USE_RELATIVE_PATHS_IN_FILES ON CACHE BOOL "")
+set(LLVM_ENABLE_Z3_SOLVER OFF CACHE BOOL "")
 
 set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "")
 if(NOT APPLE)



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


[PATCH] D79903: FastMathFlags.allowContract should be init from FPFeatures.allowFPContractAcrossStatement

2020-05-14 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:2943
+  if (Opts.FastRelaxedMath)
+Opts.setDefaultFPContractMode(LangOptions::FPM_Fast);
   Opts.HexagonQdsp6Compat = Args.hasArg(OPT_mqdsp6_compat);

michele.scandale wrote:
> mibintc wrote:
> > mibintc wrote:
> > > rjmccall wrote:
> > > > mibintc wrote:
> > > > > rjmccall wrote:
> > > > > > mibintc wrote:
> > > > > > > I changed this because the FAST version of this test 
> > > > > > > clang/test/CodeGenOpenCL/relaxed-fpmath.cl wants the 'fast' 
> > > > > > > attribute on the instruction dump.  All the LLVM FMF bits must be 
> > > > > > > set for the fast attribute print.  By default, the value for 
> > > > > > > OpenCL is ffp-contract=on
> > > > > > Is there an overall behavior change for OpenCL across these patches?
> > > > > I think the answer to your question is no.  Here is more details: 
> > > > > OpenCL sets the default behavior to ffp-contract=on.  In 
> > > > > https://reviews.llvm.org/D72841 I added the function 
> > > > > UpdateFastMathFlags, that function set the llvm FMF.allowContract bit 
> > > > > to be ( ffp-contract=on or ffp-contract=fast).  This patch just drops 
> > > > > the check on ffp-contract=on.   I didn't wind back to see how the 
> > > > > llvm fast attribute was being set for this [opencl] test case 
> > > > > originally. 
> > > > Well, to what extent are there (including this patch) overall test 
> > > > changes for the OpenCL tests, and what are tthey?
> > > In the #pragma float_control patch https://reviews.llvm.org/D72841, I 
> > > changed 2 CodeGen/OpenCL tests: relaxed-fp-math.cl in the non-FAST cases 
> > > to show the contract bit.  Also 1 line in single-precision-constant.cl 
> > > for the same reason, to show the contract bit.  This patch undoes those 
> > > test changes. I'll do more investigation to understand why the fast bit 
> > > isn't being set in the FAST case in relaxed-fpmath.cl without the change 
> > > to CompilerInovcaton
> > Prior to the patch for #pragma float_control, the llvm.FastMathFlags was 
> > initialized from LangArgs.FastMath in the CodeGenFunction constructor 
> > approximately line 74, and the FMF values in IRBuilder were never 
> > changed--For the test clang/test/CodeGenOpenCL/relaxed-fpmath.cl with 
> > option -cl-fast-relaxed-math.  (In ParseLangArgs,  Opts.FastMath = 
> > Args.hasArg(OPT_ffast_math) ||  Args.hasArg(OPT_cl_fast_relaxed_math))  
> > If FastMath is on, then all the llvm.FMF flags are set.
> > 
> > The #pragma float_control patch does change the IRBuilder settings in the 
> > course of visiting the Expr nodes, using the information in the Expr nodes, 
> > but the initial setting of FPFeatures from the command line overlooked the 
> > fact that FastMath, and therefore ffp-contract=fast, is enabled. 
> Prior to D72841 compiling something with `-ffast-math -ffp-contract={on,off}` 
> was still producing `fast` as fast-math flags on the instructions for the 
> same reason.
> The clang driver does not consider the contraction mode for passing 
> `-ffast-math` to CC1, which is consistent with the GCC behavior (I checked if 
> the `__FAST_MATH__` is defined if I compile with `-ffast-math 
> -ffp-contract=off`).
> According to this, the code in `CodeGenFunction`:
> ```
> if (LangOpts.FastMath)
>   FMF.setFast();
> ```
> is not correct.
> 
> The OpenCL option `-cl-fast-relaxed-math` should be equivalent to 
> `-ffast-math` for the user. I don't know what the interaction between 
> `-cl-fast-relaxed-math` and `-ffp-contract={on, off,fast}`.
> 
> If we need to keep `-cl-fast-relaxed-math` a CC1 option, I guess the 
> following might work:
> ```
> if (Args.hasArg(OPTS_cl_fast_relaxed_math) && !Arg.hasArg(OPT_ffp_contractEQ))
>   Opts.setDefaultFPContractMode)LangOptions::FPM_Fast);
> ```
Okay, thanks for the investigation, I agree that that all makes sense.  I'm not 
sure what it would mean to enable fast math but disable contraction — that 
combination doesn't seem useful.

I'm fine with going forward with the OpenCL changes as they are, but you might 
want to specifically reach out to the OpenCL people and let them know what's 
going on.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79903



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


[PATCH] D78767: [Sema] Teach -Wcast-align to compute a more accurate alignment when the source expression has array subscript or pointer arithmetic operators

2020-05-14 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Other changes look good to me, thanks.




Comment at: clang/lib/Sema/SemaChecking.cpp:13122
+if (Base->isVirtual()) {
+  BaseAlignment = Ctx.getTypeAlignInChars(Base->getType());
+  Offset = CharUnits::Zero();

ahatanak wrote:
> rjmccall wrote:
> > Oh, this — and all the other places that do presumed alignment based on a 
> > pointee type — needs a special case for C++ records with virtual bases, 
> > because you need to get its presumed alignment as a base sub-object, not 
> > its presumed alignment as a complete object, which is what 
> > `getTypeAlignInChars` will return.  The right way to merge that information 
> > is to get the normal alignment — which may be lower than expected if 
> > there's a typedef in play — and then `min` that with the base sub-object 
> > alignment.
> I think the base sub-object alignment in this case is the 
> `NonVirtualAlignment` of the class (the `CXXRecordDecl` of `Base` in this 
> function), but it's not clear to me what the normal alignment is. I don't 
> think it's what `Ctx.getTypeAlignInChars(Base->getType())` returns, is it? I 
> see `CodeGenModule::getDynamicOffsetAlignment` seems to be doing what you are 
> suggesting, but I'm not sure whether that's what we should be doing here. It 
> looks like it's comparing the alignment of the derived class and the 
> non-virtual alignment of the base class.
The base sub-object alignment is the class's non-virtual alignment, right.

By the normal alignment, I mean the alignment you're starting from for the 
outer object — if that's less than the base's alignment, the base may be 
misaligned as well.  For the non-base-conversion case, that's probably not 
necessary to consider.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78767



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


[PATCH] D79974: [Fuchsia] Do not enable the Z3 solver for a fuchsia toolchain

2020-05-14 Thread Petr Hosek via Phabricator via cfe-commits
phosek accepted this revision.
phosek added a comment.
This revision is now accepted and ready to land.

LGTM, don't forget to include full context with your patches.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79974



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


[PATCH] D79974: [Fuchsia] Do not enable the Z3 solver for a fuchsia toolchain

2020-05-14 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan created this revision.
leonardchan added a reviewer: phosek.
leonardchan added a project: clang.
Herald added subscribers: dexonsmith, mikhail.ramalho, mgorny.
phosek accepted this revision.
phosek added a comment.
This revision is now accepted and ready to land.

LGTM, don't forget to include full context with your patches.


Some workstations may not be using a compatible version of Z3, leading to:

  [118/3622] Building CXX object 
lib/Support/CMakeFiles/LLVMSupport.dir/Z3Solver.cpp.o
  FAILED: lib/Support/CMakeFiles/LLVMSupport.dir/Z3Solver.cpp.o 
  /usr/local/google/home/leonardchan/goma/gomacc 
/usr/local/google/home/leonardchan/llvm-monorepo/llvm-build-3-two-stage-fuchsia-toolchain/./bin/clang++
 --sysroot=/usr/local/google/home/leonardchan/sysroot/linux-amd64  
-DGTEST_HAS_RTTI=0 -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS 
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Ilib/Support 
-I/usr/local/google/home/leonardchan/llvm-monorepo/llvm-project-3/llvm/lib/Support
 -I/usr/local/google/home/leonardchan/misc/libxml2-install/include/libxml2 
-Iinclude 
-I/usr/local/google/home/leonardchan/llvm-monorepo/llvm-project-3/llvm/include 
-I/usr/local/google/home/leonardchan/misc/zlib-install/include -fPIC 
-fvisibility-inlines-hidden -Werror=date-time 
-Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter 
-Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic 
-Wno-long-long -Wimplicit-fallthrough -Wcovered-switch-default 
-Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wno-comment 
-Wstring-conversion -fdiagnostics-color -ffunction-sections -fdata-sections 
-flto 
-ffile-prefix-map=/usr/local/google/home/leonardchan/llvm-monorepo/llvm-build-3-two-stage-fuchsia-toolchain/tools/clang/stage2-bins=../llvm-build-3-two-stage-fuchsia-toolchain/tools/clang/stage2-bins
 
-ffile-prefix-map=/usr/local/google/home/leonardchan/llvm-monorepo/llvm-project-3/=
 -no-canonical-prefixes -O3 -DNDEBUG   -std=c++14  -fno-exceptions 
-fno-unwind-tables -fno-asynchronous-unwind-tables -fno-rtti -MD -MT 
lib/Support/CMakeFiles/LLVMSupport.dir/Z3Solver.cpp.o -MF 
lib/Support/CMakeFiles/LLVMSupport.dir/Z3Solver.cpp.o.d -o 
lib/Support/CMakeFiles/LLVMSupport.dir/Z3Solver.cpp.o -c 
/usr/local/google/home/leonardchan/llvm-monorepo/llvm-project-3/llvm/lib/Support/Z3Solver.cpp
  
/usr/local/google/home/leonardchan/llvm-monorepo/llvm-project-3/llvm/lib/Support/Z3Solver.cpp:18:10:
 fatal error: 'z3.h' file not found
  #include 
   ^~
  1 error generated.

when building locally. Our prod clang builders don't seem to be using this, so 
we don't need this locally either.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79974

Files:
  clang/cmake/caches/Fuchsia-stage2.cmake


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -17,6 +17,7 @@
 set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "")
 set(LLVM_INCLUDE_GO_TESTS OFF CACHE BOOL "")
 set(LLVM_USE_RELATIVE_PATHS_IN_FILES ON CACHE BOOL "")
+set(LLVM_ENABLE_Z3_SOLVER OFF CACHE BOOL "")
 
 set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "")
 if(NOT APPLE)


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -17,6 +17,7 @@
 set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "")
 set(LLVM_INCLUDE_GO_TESTS OFF CACHE BOOL "")
 set(LLVM_USE_RELATIVE_PATHS_IN_FILES ON CACHE BOOL "")
+set(LLVM_ENABLE_Z3_SOLVER OFF CACHE BOOL "")
 
 set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "")
 if(NOT APPLE)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D79972: [OpenMP5.0] map item can be non-contiguous for target update

2020-05-14 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen created this revision.
cchen added a reviewer: ABataev.
Herald added subscribers: cfe-commits, guansong, yaxunl.
Herald added a reviewer: jdoerfert.
Herald added a project: clang.

In order not to modify the `tgt_target_data_update` information but still be
able to pass the extra information for non-contiguous map item (offset,
count, and stride for each dimension), this patch overload `arg` when
the maptype is set as `OMP_MAP_DESCRIPTOR`. The origin `arg` is for
passing the pointer information, however, the overloaded `arg` is an
array of descriptor_dim:

struct descriptor_dim {

  int64_t offset;
  int64_t count;
  int64_t stride

};

and the array size is the same as dimension size. In addition, since we
have count and stride information in descriptor_dim, we can replace/overload the
`arg_size` parameter by using dimension size.

More details can be found here: 
https://github.com/chichunchen/openmp-50-design/blob/master/target_update_noncontiguous.pptx


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79972

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/OpenMP/target_update_ast_print.cpp
  clang/test/OpenMP/target_update_codegen.cpp

Index: clang/test/OpenMP/target_update_codegen.cpp
===
--- clang/test/OpenMP/target_update_codegen.cpp
+++ clang/test/OpenMP/target_update_codegen.cpp
@@ -1059,5 +1059,142 @@
   #pragma omp target update from(([sa][5])f)
 }
 
+#endif
+
+///==///
+// RUN: %clang_cc1 -DCK19 -verify -fopenmp -fopenmp-version=50 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefix CK19 --check-prefix CK19-64
+// RUN: %clang_cc1 -DCK19 -fopenmp -fopenmp-version=50 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s  --check-prefix CK19 --check-prefix CK19-64
+// RUN: %clang_cc1 -DCK19 -verify -fopenmp -fopenmp-version=50 -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s  --check-prefix CK19 --check-prefix CK19-32
+// RUN: %clang_cc1 -DCK19 -fopenmp -fopenmp-version=50 -fopenmp-targets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s  --check-prefix CK19 --check-prefix CK19-32
+
+// RUN: %clang_cc1 -DCK19 -verify -fopenmp-simd -fopenmp-version=50 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY19 %s
+// RUN: %clang_cc1 -DCK19 -fopenmp-simd -fopenmp-version=50 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY19 %s
+// RUN: %clang_cc1 -DCK19 -verify -fopenmp-simd -fopenmp-version=50 -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY19 %s
+// RUN: %clang_cc1 -DCK19 -fopenmp-simd -fopenmp-version=50 -fopenmp-targets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY19 %s
+// SIMD-ONLY19-NOT: {{__kmpc|__tgt}}
+#ifdef CK19
+
+// CK19: [[STRUCT_DESCRIPTOR:%.+]]  = type { i64, i64, i64 }
+
+// CK19: [[MSIZE:@.+]] = {{.+}}constant [1 x i64] [i64 3]
+// CK19: [[MTYPE:@.+]] = {{.+}}constant [1 x i64] [i64 2081]
+
+// CK19-LABEL: _Z3foo
+void foo(int arg) {
+  int arr[3][4][5];
+
+  // CK19: [[DIMS:%.+]] = alloca [3 x [[STRUCT_DESCRIPTOR]]],
+  // CK19: [[ARRAY_IDX:%.+]] = getelementptr inbounds [3 x [4 x [5 x i32]]], [3 x [4 x [5 x i32]]]* [[ARR:%.+]], {{.+}} 0, {{.+}} 0
+  // CK19: [[ARRAY_DECAY:%.+]] = getelementptr inbounds [4 x [5 x i32]], [4 x [5 x i32]]* [[ARRAY_IDX]], {{.+}} 0, {{.+}} 0
+  // CK19: [[ARRAY_IDX_1:%.+]] = getelementptr inbounds [5 x i32], [5 x i32]* [[ARRAY_DECAY]], {{.+}}
+  

[PATCH] D79973: [WebAssembly] Update latest implemented SIMD instructions

2020-05-14 Thread Thomas Lively via Phabricator via cfe-commits
tlively created this revision.
tlively added a reviewer: aheejin.
Herald added subscribers: llvm-commits, cfe-commits, sunfish, hiraditya, 
jgravelle-google, sbc100, dschuff.
Herald added projects: clang, LLVM.

Move instructions that have recently been implemented in V8 from the
`unimplemented-simd128` target feature to the `simd128` target
feature. The updated instructions match the update at
https://github.com/WebAssembly/simd/pull/223.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79973

Files:
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/lib/Headers/wasm_simd128.h
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
  llvm/test/CodeGen/WebAssembly/simd-arith.ll
  llvm/test/CodeGen/WebAssembly/simd-build-vector.ll
  llvm/test/CodeGen/WebAssembly/simd-offset.ll

Index: llvm/test/CodeGen/WebAssembly/simd-offset.ll
===
--- llvm/test/CodeGen/WebAssembly/simd-offset.ll
+++ llvm/test/CodeGen/WebAssembly/simd-offset.ll
@@ -1,5 +1,4 @@
-; RUN: llc < %s -asm-verbose=false -verify-machineinstrs -disable-wasm-fallthrough-return-opt -wasm-keep-registers -wasm-disable-explicit-locals -mattr=+unimplemented-simd128 | FileCheck %s --check-prefixes CHECK,SIMD128
-; RUN: llc < %s -asm-verbose=false -verify-machineinstrs -disable-wasm-fallthrough-return-opt -wasm-keep-registers -wasm-disable-explicit-locals -mattr=+simd128 | FileCheck %s --check-prefixes CHECK,SIMD128-VM
+; RUN: llc < %s -asm-verbose=false -verify-machineinstrs -disable-wasm-fallthrough-return-opt -wasm-keep-registers -wasm-disable-explicit-locals -mattr=+simd128 | FileCheck %s --check-prefixes CHECK,SIMD128
 ; RUN: llc < %s -asm-verbose=false -verify-machineinstrs -disable-wasm-fallthrough-return-opt -wasm-keep-registers -wasm-disable-explicit-locals | FileCheck %s --check-prefixes CHECK,NO-SIMD128
 
 ; Test SIMD loads and stores
@@ -21,7 +20,6 @@
 }
 
 ; CHECK-LABEL: load_splat_v16i8:
-; SIMD128-VM-NOT: v8x16.load_splat
 ; NO-SIMD128-NOT: v128
 ; SIMD128-NEXT: .functype load_splat_v16i8 (i32) -> (v128){{$}}
 ; SIMD128-NEXT: v8x16.load_splat $push[[R:[0-9]+]]=, 0($0){{$}}
@@ -1594,7 +1592,6 @@
 
 ; CHECK-LABEL: load_ext_v2i64:
 ; NO-SIMD128-NOT: v128
-; SIMD128-VM-NOT: load32x2
 ; SIMD128-NEXT: .functype load_ext_v2i64 (i32) -> (v128){{$}}
 ; SIMD128-NEXT: i64x2.load32x2_u $push[[R:[0-9]+]]=, 0($0){{$}}
 ; SIMD128-NEXT: return $pop[[R]]{{$}}
@@ -1661,7 +1658,6 @@
 
 ; CHECK-LABEL: load_ext_v2i64_with_folded_offset:
 ; NO-SIMD128-NOT: v128
-; SIMD128-VM-NOT: load32x2
 ; SIMD128-NEXT: .functype load_ext_v2i64_with_folded_offset (i32) -> (v128){{$}}
 ; SIMD128-NEXT: i64x2.load32x2_u $push[[R:[0-9]+]]=, 16($0){{$}}
 ; SIMD128-NEXT: return $pop[[R]]{{$}}
@@ -1723,7 +1719,6 @@
 
 ; CHECK-LABEL: load_ext_v2i64_with_folded_gep_offset:
 ; NO-SIMD128-NOT: v128
-; SIMD128-VM-NOT: load32x2
 ; SIMD128-NEXT: .functype load_ext_v2i64_with_folded_gep_offset (i32) -> (v128){{$}}
 ; SIMD128-NEXT: i64x2.load32x2_u $push[[R:[0-9]+]]=, 8($0){{$}}
 ; SIMD128-NEXT: return $pop[[R]]{{$}}
@@ -1791,7 +1786,6 @@
 
 ; CHECK-LABEL: load_ext_v2i64_with_unfolded_gep_negative_offset:
 ; NO-SIMD128-NOT: v128
-; SIMD128-VM-NOT: load32x2
 ; SIMD128-NEXT: .functype load_ext_v2i64_with_unfolded_gep_negative_offset (i32) -> (v128){{$}}
 ; SIMD128-NEXT: i32.const $push[[L0:[0-9]+]]=, -8{{$}}
 ; SIMD128-NEXT: i32.add $push[[L1:[0-9]+]]=, $0, $pop[[L0]]{{$}}
@@ -1869,7 +1863,6 @@
 
 ; CHECK-LABEL: load_ext_v2i64_with_unfolded_offset:
 ; NO-SIMD128-NOT: v128
-; SIMD128-VM-NOT: load32x2
 ; SIMD128-NEXT: .functype load_ext_v2i64_with_unfolded_offset (i32) -> (v128){{$}}
 ; SIMD128-NEXT: i32.const $push[[L0:[0-9]+]]=, 16{{$}}
 ; SIMD128-NEXT: i32.add $push[[L1:[0-9]+]]=, $0, $pop[[L0]]{{$}}
@@ -1941,7 +1934,6 @@
 
 ; CHECK-LABEL: load_ext_v2i64_with_unfolded_gep_offset:
 ; NO-SIMD128-NOT: v128
-; SIMD128-VM-NOT: load32x2
 ; SIMD128-NEXT: .functype load_ext_v2i64_with_unfolded_gep_offset (i32) -> (v128){{$}}
 ; SIMD128-NEXT: i32.const $push[[L0:[0-9]+]]=, 8{{$}}
 ; SIMD128-NEXT: i32.add $push[[L1:[0-9]+]]=, $0, $pop[[L0]]{{$}}
@@ -2007,7 +1999,6 @@
 
 ; CHECK-LABEL: load_ext_v2i64_from_numeric_address:
 ; NO-SIMD128-NOT: v128
-; SIMD128-VM-NOT: load32x2
 ; SIMD128-NEXT: .functype load_ext_v2i64_from_numeric_address () -> (v128){{$}}
 ; SIMD128-NEXT: i32.const $push[[L0:[0-9]+]]=, 0{{$}}
 ; SIMD128-NEXT: i64x2.load32x2_u $push[[R:[0-9]+]]=, 32($pop[[L0]]){{$}}
@@ -2071,7 +2062,6 @@
 
 ; CHECK-LABEL: load_ext_v2i64_from_global_address:
 ; NO-SIMD128-NOT: v128
-; SIMD128-VM-NOT: load32x2
 ; SIMD128-NEXT: .functype load_ext_v2i64_from_global_address () -> (v128){{$}}
 ; SIMD128-NEXT: i32.const $push[[L0:[0-9]+]]=, 0{{$}}
 ; SIMD128-NEXT: i64x2.load32x2_u $push[[R:[0-9]+]]=, gv_v2i32($pop[[L0]]){{$}}
Index: llvm/test/CodeGen/WebAssembly/simd-build-vector.ll
===
--- 

[PATCH] D79698: Run Coverage pass before other *San passes under new pass manager

2020-05-14 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

In D79698#2037425 , @aeubanks wrote:

> In D79698#2037305 , @leonardchan 
> wrote:
>
> > Just to followup on this: We believe the root cause of the error we're 
> > running into is that some sancov guards in one comdat are being referenced 
> > by symbols in another comdat, so due to linking order, the other comdat in 
> > question is referencing a sancov guard that was in a discarded comdat 
> > group. I posted full details of this on llvm-dev 
> > . We believe 
> > we're running into this error now because with this patch, inlining occurs 
> > after the sanitizers are run.
> >
> > Based on some discussion in 
> > http://lists.llvm.org/pipermail/llvm-dev/2020-May/141558.html, it seems 
> > appropriate that the solution for this is to just run sanitizers after 
> > inlining, so we would avoid this error that's brought about by inlining 
> > after sanitizer runs. Since this has been breaking us for a few days, and 
> > unless other folks don't mind, I'm thinking it might be appropriate to 
> > temporarily revert this until there's a fix for either
>
>
> Maybe the fix is to use `registerScalarOptimizerLateEPCallback()` instead of 
> `registerPipelineStartEPCallback()`. But I'm not sure how to test that, could 
> you try that and lmk if that fixes the issue?


Thanks. Will try this out later.

>> (1) running sanitizers after inlining or
>>  (2) changing which comdat groups the sancov guards get placed in (such that 
>> guards in one group aren't referenced by functions defined in another group)
>> 
>> I'm not sure how long it would take to implement either solution, so I think 
>> temporarily reverting might be ok here.
> 
> Sure, feel free to revert.

Reverted in e9802aa4221ba3857041c2328639ce2aac0ace67 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79698



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


[PATCH] D79877: [clang][SveEmitter] SVE builtins for `svusdot` and `svsudot` ACLE.

2020-05-14 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli marked 2 inline comments as done.
fpetrogalli added inline comments.



Comment at: clang/include/clang/Basic/arm_sve.td:1249
+def SVSUDOT_S: SInst<"svsudot[_s32]","ddqb", "i",   MergeNone, 
"aarch64_sve_usdot", [ReverseUSDOT]>;
+def SVSUDOT_N_S  : SInst<"svsudot[_n_s32]",  "ddq@", "i",   MergeNone, 
"aarch64_sve_usdot", [ReverseUSDOT]>;
+

efriedma wrote:
> These intrinsics aren't overloaded; maybe consider writing the actual type 
> int8_t/uint8_t, instead of introducing "unsigned scalar of 1/4 width element 
> type"?  If there's some reason the current form is better, that's fine, 
> though.
I am probably missing something, but I can't see a type specifier that is not 
overloaded and that renders to 8-bit elements?

I have opted for adding "unsigned scalar of 1/4 width element type" because it 
keeps things symmetric with the vector equivalent, signed and unsigned.

```
// r: scalar of 1/4 width element type (splat to vector type)
// @: unsigned scalar of 1/4 width element type (splat to vector type)
[..]
// b: 1/4 width unsigned elements, 4x element count
// q: 1/4 width elements, 4x element count
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79877



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


[PATCH] D79675: [OpenMP][OMPBuilder] Adding Privatization Requirements to OMPIRBuilder

2020-05-14 Thread Fady Ghanim via Phabricator via cfe-commits
fghanim marked 3 inline comments as done.
fghanim added a comment.

In D79675#2037314 , @jdoerfert wrote:

> I left some comments on the type stuff. The rest looks good.
>  I think if you rebase the type stuff on D79739 
>  (which I can merge) we should only need to 
> expand `initializeTypes` to make this work as expected. WDYT?


Currently, I implemented the changes relevant to me from that and made a 
separate local commit prior to this one to make sure things work.
I build llvm locally, and so it take 6 - 8 hours, so when all patches are 
accepted, I'll do a rebase, etc. in one go to make sure there are no problems.




Comment at: llvm/include/llvm/Frontend/OpenMP/OMPKinds.def:234
 __OMP_RTL(__kmpc_critical, false, Void, IdentPtr, Int32, KmpCriticalNamePtrTy)
-__OMP_RTL(__kmpc_critical_with_hint, false, Void, IdentPtr, Int32, 
KmpCriticalNamePtrTy, Int32)
+__OMP_RTL(__kmpc_critical_with_hint, false, Void, IdentPtr, Int32, 
KmpCriticalNamePtrTy, IntPtrTy)
 __OMP_RTL(__kmpc_end_critical, false, Void, IdentPtr, Int32, 
KmpCriticalNamePtrTy)

jdoerfert wrote:
> fghanim wrote:
> > jdoerfert wrote:
> > > fghanim wrote:
> > > > jdoerfert wrote:
> > > > > I think this was correct before:
> > > > > ```
> > > > >   KMP_EXPORT void __kmpc_critical_with_hint(ident_t *, kmp_int32 
> > > > > global_tid, kmp_critical_name *, uint32_t hint);
> > > > > ```
> > > > Nop, it's supposed to be whatever `IntPtrTy` is in the frontend (i.e. 
> > > > 32 for 32bit, 64 for 64bit).
> > > > 
> > > > `IntPtrTy` is actually a union with `sizety` in `CodeGenModule`
> > > I'm confused. I copied the declaration above from the runtime. It doesn't 
> > > contain an `IntPtrTy` or similar. I agree that `IntPtrTy` is machine 
> > > dependent and we need your initializers. What I tried to say is that at 
> > > least one declaration in the runtime has `__kmpc_critical_with_hint` with 
> > > an int32 as last argument. That said, the runtime is not shy of 
> > > incompatible declarations for functions.
> > I cannot speak for what's in the runtime. However, in clang, this currently 
> > is defined to use `IntPtrTy`. If you go check, I have a todo in the current 
> > implementation for critical to come back and fix it.
> That is just an existing bug in Clang. The runtime is consistent with the 
> type and arguably it is the runtime we must match, not the other way around ;)
Apparently, this used to be `uintptr_t` in the runtime and was changed by 
D51235 . It doesn't say why the change was made.

Clang uses this in multiple places, which makes me think it may have been 
intentional. So I suggest we go by the standard. Where can I find what does the 
OMP standard say about how the signature of the runtime calls should look like? 
This way I'll fix this one accordingly, and later we may go and make sure that 
all the rest match up with the standard - where possible.



Comment at: llvm/lib/Frontend/OpenMP/OMPConstants.cpp:69
 
 void llvm::omp::types::initializeTypes(Module ) {
   if (Void)

jdoerfert wrote:
> Maybe we can/should take the IntPtr and SizeTy here so there is only a single 
> call necessary that initializes all types. I fear "default" values are 
> problematic.
> 
> WDYT?
you mean pass it as a second argument? Sure, I would love that. I mean it's 
fine with me either way. I originally wanted to do that. but then thought maybe 
it is slightly better to explicitly initialize target specific data types, to 
give initialize type a cleaner look ... maybe?!



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:106
+  initializeVoidPtrTy(VoidPtrTy);
+}
+

jdoerfert wrote:
> I guess we can directly call the initialize functions, right?
> With an assert that SizeTy is set we can make sure users do it ;)
Sure, then again, I am just following in the stylistic footsteps of the 
pioneers who started the OMPBuilder, who created an initialize for initialize ;)

On second thought, I think I will just create something like 
`initializeTargetSpecificTypes()` sort of thing, and be done with it. instead 
of having one for each type.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79675



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


[clang] e9802aa - Revert "Run Coverage pass before other *San passes under new pass manager"

2020-05-14 Thread Leonard Chan via cfe-commits

Author: Leonard Chan
Date: 2020-05-14T15:19:27-07:00
New Revision: e9802aa4221ba3857041c2328639ce2aac0ace67

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

LOG: Revert "Run Coverage pass before other *San passes under new pass manager"

This reverts commit 7d5bb94d78386e4653535c35d3e8258bf4502340.

Reverting since this leads to a linker error we're seeing on Fuchsia.
The underlying issue seems to be that inlining is run after sanitizers
and causes different comdat groups instrumented by Sancov to reference
non-key symbols defined in other comdat groups.

Will re-land this patch after a fix for that is landed.

Added: 


Modified: 
clang/lib/CodeGen/BackendUtil.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 7b876df852b5..33627f3a6733 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -1001,15 +1001,6 @@ static void addSanitizersAtO0(ModulePassManager ,
   const Triple ,
   const LangOptions ,
   const CodeGenOptions ) {
-  if (CodeGenOpts.SanitizeCoverageType ||
-  CodeGenOpts.SanitizeCoverageIndirectCalls ||
-  CodeGenOpts.SanitizeCoverageTraceCmp) {
-auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts);
-MPM.addPass(ModuleSanitizerCoveragePass(
-SancovOpts, CodeGenOpts.SanitizeCoverageWhitelistFiles,
-CodeGenOpts.SanitizeCoverageBlacklistFiles));
-  }
-
   auto ASanPass = [&](SanitizerMask Mask, bool CompileKernel) {
 MPM.addPass(RequireAnalysisPass());
 bool Recover = CodeGenOpts.SanitizeRecover.has(Mask);
@@ -1250,17 +1241,6 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
 EntryExitInstrumenterPass(/*PostInlining=*/false)));
   });
 
-  if (CodeGenOpts.SanitizeCoverageType ||
-  CodeGenOpts.SanitizeCoverageIndirectCalls ||
-  CodeGenOpts.SanitizeCoverageTraceCmp) {
-PB.registerPipelineStartEPCallback([&](ModulePassManager ) {
-  auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts);
-  MPM.addPass(ModuleSanitizerCoveragePass(
-  SancovOpts, CodeGenOpts.SanitizeCoverageWhitelistFiles,
-  CodeGenOpts.SanitizeCoverageBlacklistFiles));
-});
-  }
-
   // Register callbacks to schedule sanitizer passes at the appropriate 
part of
   // the pipeline.
   // FIXME: either handle asan/the remaining sanitizers or error out
@@ -1345,6 +1325,15 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
   }
 }
 
+if (CodeGenOpts.SanitizeCoverageType ||
+CodeGenOpts.SanitizeCoverageIndirectCalls ||
+CodeGenOpts.SanitizeCoverageTraceCmp) {
+  auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts);
+  MPM.addPass(ModuleSanitizerCoveragePass(
+  SancovOpts, CodeGenOpts.SanitizeCoverageWhitelistFiles,
+  CodeGenOpts.SanitizeCoverageBlacklistFiles));
+}
+
 if (LangOpts.Sanitize.has(SanitizerKind::HWAddress)) {
   bool Recover = CodeGenOpts.SanitizeRecover.has(SanitizerKind::HWAddress);
   MPM.addPass(HWAddressSanitizerPass(



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


[PATCH] D72100: Allow matching "any file" in `VerifyDiagnosticConsumer`.

2020-05-14 Thread Jan Korous via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG05eedf1f5b44: [clang][VerifyDiagnosticConsumer] Support 
filename wildcards (authored by arames, committed by jkorous).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72100

Files:
  clang/include/clang/Frontend/VerifyDiagnosticConsumer.h
  clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
  clang/test/Frontend/verify-any-file.c
  clang/test/Frontend/verify-any-file.h

Index: clang/test/Frontend/verify-any-file.h
===
--- /dev/null
+++ clang/test/Frontend/verify-any-file.h
@@ -0,0 +1 @@
+unexpected var;
Index: clang/test/Frontend/verify-any-file.c
===
--- /dev/null
+++ clang/test/Frontend/verify-any-file.c
@@ -0,0 +1,14 @@
+// RUN: not %clang_cc1 -verify %s 2>&1 | FileCheck %s
+
+#include "verify-any-file.h"
+// expected-error@*:* {{unknown type name 'unexpected'}}
+
+// expected-error@*:* {{missing error}}
+
+// expected-error@*:123 {{invalid line : "*" required}}
+//
+//  CHECK: error: 'error' diagnostics expected but not seen:
+// CHECK-NEXT:   File * Line * (directive at {{.*}}verify-any-file.c:6): missing error
+// CHECK-NEXT: error: 'error' diagnostics seen but not expected:
+// CHECK-NEXT:   File {{.*}}verify-any-file.c Line 8: missing or invalid line number following '@' in expected '*'
+// CHECK-NEXT: 2 errors generated.
Index: clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
===
--- clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
+++ clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
@@ -89,9 +89,10 @@
 class StandardDirective : public Directive {
 public:
   StandardDirective(SourceLocation DirectiveLoc, SourceLocation DiagnosticLoc,
-bool MatchAnyLine, StringRef Text, unsigned Min,
-unsigned Max)
-  : Directive(DirectiveLoc, DiagnosticLoc, MatchAnyLine, Text, Min, Max) {}
+bool MatchAnyFileAndLine, bool MatchAnyLine, StringRef Text,
+unsigned Min, unsigned Max)
+  : Directive(DirectiveLoc, DiagnosticLoc, MatchAnyFileAndLine,
+  MatchAnyLine, Text, Min, Max) {}
 
   bool isValid(std::string ) override {
 // all strings are considered valid; even empty ones
@@ -107,9 +108,10 @@
 class RegexDirective : public Directive {
 public:
   RegexDirective(SourceLocation DirectiveLoc, SourceLocation DiagnosticLoc,
- bool MatchAnyLine, StringRef Text, unsigned Min, unsigned Max,
- StringRef RegexStr)
-  : Directive(DirectiveLoc, DiagnosticLoc, MatchAnyLine, Text, Min, Max),
+ bool MatchAnyFileAndLine, bool MatchAnyLine, StringRef Text,
+ unsigned Min, unsigned Max, StringRef RegexStr)
+  : Directive(DirectiveLoc, DiagnosticLoc, MatchAnyFileAndLine,
+  MatchAnyLine, Text, Min, Max),
 Regex(RegexStr) {}
 
   bool isValid(std::string ) override {
@@ -294,11 +296,13 @@
 // Attach the specified directive to the line of code indicated by
 // \p ExpectedLoc.
 void attachDirective(DiagnosticsEngine , const UnattachedDirective ,
- SourceLocation ExpectedLoc, bool MatchAnyLine = false) {
+ SourceLocation ExpectedLoc,
+ bool MatchAnyFileAndLine = false,
+ bool MatchAnyLine = false) {
   // Construct new directive.
-  std::unique_ptr D =
-  Directive::create(UD.RegexKind, UD.DirectivePos, ExpectedLoc,
-MatchAnyLine, UD.Text, UD.Min, UD.Max);
+  std::unique_ptr D = Directive::create(
+  UD.RegexKind, UD.DirectivePos, ExpectedLoc, MatchAnyFileAndLine,
+  MatchAnyLine, UD.Text, UD.Min, UD.Max);
 
   std::string Error;
   if (!D->isValid(Error)) {
@@ -498,6 +502,7 @@
 // Next optional token: @
 SourceLocation ExpectedLoc;
 StringRef Marker;
+bool MatchAnyFileAndLine = false;
 bool MatchAnyLine = false;
 if (!PH.Next("@")) {
   ExpectedLoc = Pos;
@@ -526,26 +531,39 @@
 StringRef Filename(PH.C, PH.P-PH.C);
 PH.Advance();
 
-// Lookup file via Preprocessor, like a #include.
-const DirectoryLookup *CurDir;
-Optional File =
-PP->LookupFile(Pos, Filename, false, nullptr, nullptr, CurDir,
-   nullptr, nullptr, nullptr, nullptr, nullptr);
-if (!File) {
-  Diags.Report(Pos.getLocWithOffset(PH.C-PH.Begin),
-   diag::err_verify_missing_file) << Filename << KindStr;
-  continue;
-}
-
-const FileEntry *FE = >getFileEntry();
-if (SM.translateFile(FE).isInvalid())
-  SM.createFileID(FE, Pos, SrcMgr::C_User);
-
-if (PH.Next(Line) && Line > 0)
-  ExpectedLoc = 

[PATCH] D79628: [Clang][Driver] Add Bounds and Thread to SupportsCoverage list

2020-05-14 Thread Marco Elver via Phabricator via cfe-commits
melver updated this revision to Diff 264112.
melver added a comment.

Fix formatting.

PTAL.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79628

Files:
  clang/lib/Driver/SanitizerArgs.cpp
  clang/test/CodeGen/sanitize-coverage-bounds.c
  clang/test/CodeGen/sanitize-coverage-thread.c
  clang/test/Driver/fsanitize-coverage.c


Index: clang/test/Driver/fsanitize-coverage.c
===
--- clang/test/Driver/fsanitize-coverage.c
+++ clang/test/Driver/fsanitize-coverage.c
@@ -12,8 +12,10 @@
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=kernel-memory 
-fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=leak 
-fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=undefined 
-fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=bounds 
-fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=bool 
-fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=dataflow 
-fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=thread 
-fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
 // RUN: %clang -target %itanium_abi_triple -fsanitize=float-divide-by-zero 
-fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
 // RUN: %clang -target x86_64-linux-gnu 
-fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
 // CHECK-SANITIZE-COVERAGE-FUNC: fsanitize-coverage-type=1
Index: clang/test/CodeGen/sanitize-coverage-thread.c
===
--- /dev/null
+++ clang/test/CodeGen/sanitize-coverage-thread.c
@@ -0,0 +1,25 @@
+// RUN: %clang %s -emit-llvm -S -fsanitize=thread 
-fsanitize-coverage=trace-pc,trace-cmp -o - | FileCheck %s
+
+int x = 0;
+
+// CHECK-LABEL: define dso_local void @foo(
+void foo(void) {
+  // CHECK: call void @__sanitizer_cov_trace_pc
+
+  // CHECK: call void @__tsan_read4(i8* bitcast (i32* @x to i8*))
+  // CHECK-NEXT: load i32, i32* @x, align 4
+
+  // CHECK: call void @__sanitizer_cov_trace_const_cmp4
+  // CHECK: br
+
+  // CHECK: call void @__sanitizer_cov_trace_pc
+  // CHECK: br
+  if (x)
+// CHECK: call void @__sanitizer_cov_trace_pc
+// CHECK: call void @__tsan_write4(i8* bitcast (i32* @x to i8*))
+// CHECK-NEXT: store i32 42, i32* @x, align 4
+// CHECK: br
+x = 42;
+
+  // CHECK: ret void
+}
Index: clang/test/CodeGen/sanitize-coverage-bounds.c
===
--- /dev/null
+++ clang/test/CodeGen/sanitize-coverage-bounds.c
@@ -0,0 +1,29 @@
+// RUN: %clang %s -emit-llvm -S -fsanitize=bounds 
-fsanitize-coverage=trace-pc,trace-cmp -o - | FileCheck %s
+
+int x[10];
+
+// CHECK-LABEL: define dso_local void @foo(
+void foo(int n) {
+  // CHECK: call void @__sanitizer_cov_trace_pc
+  // CHECK: call void @__sanitizer_cov_trace_const_cmp
+  // CHECK: br
+  // CHECK: call void @__sanitizer_cov_trace_pc
+  // CHECK: br
+  // CHECK: call void @__sanitizer_cov_trace_const_cmp
+  // CHECK: br
+  // CHECK: call void @__sanitizer_cov_trace_pc
+  // CHECK: br
+  if (n)
+// CHECK: call void @__sanitizer_cov_trace_pc
+// CHECK: call void @__ubsan_handle_out_of_bounds
+// CHECK: br
+// CHECK: getelementptr inbounds [10 x i32], [10 x i32]* @x
+// CHECK: call void @__sanitizer_cov_trace_const_cmp8
+// CHECK: br
+// CHECK: call void @__sanitizer_cov_trace_pc
+// CHECK: store i32 42
+// CHECK: br
+x[n] = 42;
+
+  // CHECK: ret void
+}
Index: clang/lib/Driver/SanitizerArgs.cpp
===
--- clang/lib/Driver/SanitizerArgs.cpp
+++ clang/lib/Driver/SanitizerArgs.cpp
@@ -43,11 +43,12 @@
 SanitizerKind::KernelAddress | SanitizerKind::KernelHWAddress |
 SanitizerKind::MemTag | SanitizerKind::Memory |
 SanitizerKind::KernelMemory | SanitizerKind::Leak |
-SanitizerKind::Undefined | SanitizerKind::Integer |
+SanitizerKind::Undefined | SanitizerKind::Integer | SanitizerKind::Bounds |
 SanitizerKind::ImplicitConversion | SanitizerKind::Nullability |
 SanitizerKind::DataFlow | SanitizerKind::Fuzzer |
 SanitizerKind::FuzzerNoLink | 

[clang] 05eedf1 - [clang][VerifyDiagnosticConsumer] Support filename wildcards

2020-05-14 Thread Jan Korous via cfe-commits

Author: Alexandre Rames
Date: 2020-05-14T15:15:49-07:00
New Revision: 05eedf1f5b449ae42f5493576164b0f9a001646c

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

LOG: [clang][VerifyDiagnosticConsumer] Support filename wildcards

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

Added: 
clang/test/Frontend/verify-any-file.c
clang/test/Frontend/verify-any-file.h

Modified: 
clang/include/clang/Frontend/VerifyDiagnosticConsumer.h
clang/lib/Frontend/VerifyDiagnosticConsumer.cpp

Removed: 




diff  --git a/clang/include/clang/Frontend/VerifyDiagnosticConsumer.h 
b/clang/include/clang/Frontend/VerifyDiagnosticConsumer.h
index 7daebe612160..a97cd138d159 100644
--- a/clang/include/clang/Frontend/VerifyDiagnosticConsumer.h
+++ b/clang/include/clang/Frontend/VerifyDiagnosticConsumer.h
@@ -190,11 +190,10 @@ class VerifyDiagnosticConsumer: public DiagnosticConsumer,
   ///
   class Directive {
   public:
-static std::unique_ptr create(bool RegexKind,
- SourceLocation DirectiveLoc,
- SourceLocation DiagnosticLoc,
- bool MatchAnyLine, StringRef Text,
- unsigned Min, unsigned Max);
+static std::unique_ptr
+create(bool RegexKind, SourceLocation DirectiveLoc,
+   SourceLocation DiagnosticLoc, bool MatchAnyFileAndLine,
+   bool MatchAnyLine, StringRef Text, unsigned Min, unsigned Max);
 
   public:
 /// Constant representing n or more matches.
@@ -205,6 +204,7 @@ class VerifyDiagnosticConsumer: public DiagnosticConsumer,
 const std::string Text;
 unsigned Min, Max;
 bool MatchAnyLine;
+bool MatchAnyFileAndLine; // `MatchAnyFileAndLine` implies `MatchAnyLine`.
 
 Directive(const Directive &) = delete;
 Directive =(const Directive &) = delete;
@@ -219,9 +219,11 @@ class VerifyDiagnosticConsumer: public DiagnosticConsumer,
 
   protected:
 Directive(SourceLocation DirectiveLoc, SourceLocation DiagnosticLoc,
-  bool MatchAnyLine, StringRef Text, unsigned Min, unsigned Max)
-: DirectiveLoc(DirectiveLoc), DiagnosticLoc(DiagnosticLoc),
-  Text(Text), Min(Min), Max(Max), MatchAnyLine(MatchAnyLine) {
+  bool MatchAnyFileAndLine, bool MatchAnyLine, StringRef Text,
+  unsigned Min, unsigned Max)
+: DirectiveLoc(DirectiveLoc), DiagnosticLoc(DiagnosticLoc), Text(Text),
+  Min(Min), Max(Max), MatchAnyLine(MatchAnyLine || 
MatchAnyFileAndLine),
+  MatchAnyFileAndLine(MatchAnyFileAndLine) {
   assert(!DirectiveLoc.isInvalid() && "DirectiveLoc is invalid!");
   assert((!DiagnosticLoc.isInvalid() || MatchAnyLine) &&
  "DiagnosticLoc is invalid!");

diff  --git a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp 
b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
index 82c2af87706e..56e05242f7c9 100644
--- a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
+++ b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
@@ -89,9 +89,10 @@ namespace {
 class StandardDirective : public Directive {
 public:
   StandardDirective(SourceLocation DirectiveLoc, SourceLocation DiagnosticLoc,
-bool MatchAnyLine, StringRef Text, unsigned Min,
-unsigned Max)
-  : Directive(DirectiveLoc, DiagnosticLoc, MatchAnyLine, Text, Min, Max) {}
+bool MatchAnyFileAndLine, bool MatchAnyLine, StringRef 
Text,
+unsigned Min, unsigned Max)
+  : Directive(DirectiveLoc, DiagnosticLoc, MatchAnyFileAndLine,
+  MatchAnyLine, Text, Min, Max) {}
 
   bool isValid(std::string ) override {
 // all strings are considered valid; even empty ones
@@ -107,9 +108,10 @@ class StandardDirective : public Directive {
 class RegexDirective : public Directive {
 public:
   RegexDirective(SourceLocation DirectiveLoc, SourceLocation DiagnosticLoc,
- bool MatchAnyLine, StringRef Text, unsigned Min, unsigned Max,
- StringRef RegexStr)
-  : Directive(DirectiveLoc, DiagnosticLoc, MatchAnyLine, Text, Min, Max),
+ bool MatchAnyFileAndLine, bool MatchAnyLine, StringRef Text,
+ unsigned Min, unsigned Max, StringRef RegexStr)
+  : Directive(DirectiveLoc, DiagnosticLoc, MatchAnyFileAndLine,
+  MatchAnyLine, Text, Min, Max),
 Regex(RegexStr) {}
 
   bool isValid(std::string ) override {
@@ -294,11 +296,13 @@ struct UnattachedDirective {
 // Attach the specified directive to the line of code indicated by
 // \p ExpectedLoc.
 void attachDirective(DiagnosticsEngine , const UnattachedDirective ,
- SourceLocation ExpectedLoc, bool 

[PATCH] D79257: [OPENMP50]Codegen for uses_allocators clause.

2020-05-14 Thread Alexey Bataev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0363ae97abb8: [OPENMP50]Codegen for uses_allocators clause. 
(authored by ABataev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79257

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/target_parallel_for_simd_uses_allocators_codegen.cpp
  clang/test/OpenMP/target_parallel_for_uses_allocators_codegen.cpp
  clang/test/OpenMP/target_parallel_uses_allocators_codegen.cpp
  clang/test/OpenMP/target_simd_uses_allocators_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_uses_allocators_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_uses_allocators_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_uses_allocators_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_uses_allocators_codegen.cpp
  clang/test/OpenMP/target_teams_uses_allocators_codegen.cpp
  clang/test/OpenMP/target_uses_allocators_codegen.cpp

Index: clang/test/OpenMP/target_uses_allocators_codegen.cpp
===
--- /dev/null
+++ clang/test/OpenMP/target_uses_allocators_codegen.cpp
@@ -0,0 +1,93 @@
+// Test host codegen.
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=50 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
+
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+enum omp_allocator_handle_t {
+  omp_null_allocator = 0,
+  omp_default_mem_alloc = 1,
+  omp_large_cap_mem_alloc = 2,
+  omp_const_mem_alloc = 3,
+  omp_high_bw_mem_alloc = 4,
+  omp_low_lat_mem_alloc = 5,
+  omp_cgroup_mem_alloc = 6,
+  omp_pteam_mem_alloc = 7,
+  omp_thread_mem_alloc = 8,
+  KMP_ALLOCATOR_MAX_HANDLE = __UINTPTR_MAX__
+};
+
+typedef enum omp_alloctrait_key_t { omp_atk_sync_hint = 1,
+omp_atk_alignment = 2,
+omp_atk_access = 3,
+omp_atk_pool_size = 4,
+omp_atk_fallback = 5,
+omp_atk_fb_data = 6,
+omp_atk_pinned = 7,
+omp_atk_partition = 8
+} omp_alloctrait_key_t;
+typedef enum omp_alloctrait_value_t {
+  omp_atv_false = 0,
+  omp_atv_true = 1,
+  omp_atv_default = 2,
+  omp_atv_contended = 3,
+  omp_atv_uncontended = 4,
+  omp_atv_sequential = 5,
+  omp_atv_private = 6,
+  omp_atv_all = 7,
+  omp_atv_thread = 8,
+  omp_atv_pteam = 9,
+  omp_atv_cgroup = 10,
+  omp_atv_default_mem_fb = 11,
+  omp_atv_null_fb = 12,
+  omp_atv_abort_fb = 13,
+  omp_atv_allocator_fb = 14,
+  omp_atv_environment = 15,
+  omp_atv_nearest = 16,
+  omp_atv_blocked = 17,
+  omp_atv_interleaved = 18
+} omp_alloctrait_value_t;
+
+typedef struct omp_alloctrait_t {
+  omp_alloctrait_key_t key;
+  __UINTPTR_TYPE__ value;
+} omp_alloctrait_t;
+
+// Just map the traits variable as a firstprivate variable.
+// CHECK-DAG: [[SIZES:@.+]] = private unnamed_addr constant [1 x i64] [i64 160]
+// CHECK-DAG: [[MAPTYPES:@.+]] = private unnamed_addr constant [1 x i64] [i64 673]
+
+// CHECK: define {{.*}}[[FOO:@.+]]()
+void foo() {
+  omp_alloctrait_t traits[10];
+  omp_allocator_handle_t my_allocator;
+
+// CHECK: [[RES:%.+]] = call i32 @__tgt_target(i64 -1, i8* @.[[TGT_REGION:.+]].region_id, i32 1, i8** %{{.+}}, i8** %{{.+}}, i64* getelementptr inbounds ([1 x i64], [1 x i64]* [[SIZES]], i32 0, i32 0), i64* getelementptr inbounds ([1 x i64], [1 x i64]* [[MAPTYPES]], i32 0, i32 0))
+// CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
+// CHECK: br i1 [[CMP]], label %[[FAILED:.+]], label %[[DONE:.+]]
+// CHECK: [[FAILED]]:
+// CHECK: call void @[[TGT_REGION]]([10 x %struct.omp_alloctrait_t]* %{{[^,]+}})
+#pragma omp target uses_allocators(omp_null_allocator, omp_thread_mem_alloc, my_allocator(traits))
+  ;
+}
+
+// CHECK: define internal void @[[TGT_REGION]]([10 x %struct.omp_alloctrait_t]* {{.+}})
+// CHECK: [[TRAITS_ADDR_REF:%.+]] = alloca [10 x %struct.omp_alloctrait_t]*,
+// CHECK: [[MY_ALLOCATOR_ADDR:%.+]] = alloca i64,
+// CHECK: [[TRAITS_ADDR:%.+]] = load [10 x %struct.omp_alloctrait_t]*, [10 x %struct.omp_alloctrait_t]** [[TRAITS_ADDR_REF]],
+// CHECK: [[TRAITS_ADDR_VOIDPTR:%.+]] = bitcast [10 x %struct.omp_alloctrait_t]* [[TRAITS_ADDR]] to i8**
+// CHECK: 

[PATCH] D79698: Run Coverage pass before other *San passes under new pass manager

2020-05-14 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

In D79698#2037305 , @leonardchan wrote:

> Just to followup on this: We believe the root cause of the error we're 
> running into is that some sancov guards in one comdat are being referenced by 
> symbols in another comdat, so due to linking order, the other comdat in 
> question is referencing a sancov guard that was in a discarded comdat group. 
> I posted full details of this on llvm-dev 
> . We believe 
> we're running into this error now because with this patch, inlining occurs 
> after the sanitizers are run.
>
> Based on some discussion in 
> http://lists.llvm.org/pipermail/llvm-dev/2020-May/141558.html, it seems 
> appropriate that the solution for this is to just run sanitizers after 
> inlining, so we would avoid this error that's brought about by inlining after 
> sanitizer runs. Since this has been breaking us for a few days, and unless 
> other folks don't mind, I'm thinking it might be appropriate to temporarily 
> revert this until there's a fix for either


Maybe the fix is to use `registerScalarOptimizerLateEPCallback()` instead of 
`registerPipelineStartEPCallback()`. But I'm not sure how to test that, could 
you try that and lmk if that fixes the issue?

> (1) running sanitizers after inlining or
>  (2) changing which comdat groups the sancov guards get placed in (such that 
> guards in one group aren't referenced by functions defined in another group)
> 
> I'm not sure how long it would take to implement either solution, so I think 
> temporarily reverting might be ok here.

Sure, feel free to revert.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79698



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


[PATCH] D78767: [Sema] Teach -Wcast-align to compute a more accurate alignment when the source expression has array subscript or pointer arithmetic operators

2020-05-14 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:13122
+if (Base->isVirtual()) {
+  BaseAlignment = Ctx.getTypeAlignInChars(Base->getType());
+  Offset = CharUnits::Zero();

rjmccall wrote:
> Oh, this — and all the other places that do presumed alignment based on a 
> pointee type — needs a special case for C++ records with virtual bases, 
> because you need to get its presumed alignment as a base sub-object, not its 
> presumed alignment as a complete object, which is what `getTypeAlignInChars` 
> will return.  The right way to merge that information is to get the normal 
> alignment — which may be lower than expected if there's a typedef in play — 
> and then `min` that with the base sub-object alignment.
I think the base sub-object alignment in this case is the `NonVirtualAlignment` 
of the class (the `CXXRecordDecl` of `Base` in this function), but it's not 
clear to me what the normal alignment is. I don't think it's what 
`Ctx.getTypeAlignInChars(Base->getType())` returns, is it? I see 
`CodeGenModule::getDynamicOffsetAlignment` seems to be doing what you are 
suggesting, but I'm not sure whether that's what we should be doing here. It 
looks like it's comparing the alignment of the derived class and the 
non-virtual alignment of the base class.



Comment at: clang/lib/Sema/SemaChecking.cpp:13266
+  if (!RHS->isIntegerConstantExpr(RHSRes, Ctx))
+return Optional>();
+  CharUnits Offset = LHSRes->second;

rjmccall wrote:
> This should be handled the same as array subscripting.  Maybe you can extract 
> a helper for that that's given a pointer expression, an integer expression, 
> and a flag indicating whether it's a subtraction?
The offset computation was wrong when the element type wasn't a char. The bug 
is fixed in the helper function.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78767



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


[PATCH] D79967: Fix debug info for NoDebug attr

2020-05-14 Thread Artem Belevich via Phabricator via cfe-commits
tra added a reviewer: dblaikie.
tra added a subscriber: dblaikie.
tra added a comment.

LGTM.  Added @dblaikie as reviewer for debug info expertise.


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

https://reviews.llvm.org/D79967



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


[PATCH] D79628: [Clang][Driver] Add Bounds and Thread to SupportsCoverage list

2020-05-14 Thread Marco Elver via Phabricator via cfe-commits
melver updated this revision to Diff 264109.
melver added a comment.

Add tests checking that when passing the combination of the sanitizer flags to 
Clang, we generate instrumentation for all enabled sanitizers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79628

Files:
  clang/lib/Driver/SanitizerArgs.cpp
  clang/test/CodeGen/sanitize-coverage-bounds.c
  clang/test/CodeGen/sanitize-coverage-thread.c
  clang/test/Driver/fsanitize-coverage.c


Index: clang/test/Driver/fsanitize-coverage.c
===
--- clang/test/Driver/fsanitize-coverage.c
+++ clang/test/Driver/fsanitize-coverage.c
@@ -12,8 +12,10 @@
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=kernel-memory 
-fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=leak 
-fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=undefined 
-fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=bounds 
-fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=bool 
-fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=dataflow 
-fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=thread 
-fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
 // RUN: %clang -target %itanium_abi_triple -fsanitize=float-divide-by-zero 
-fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
 // RUN: %clang -target x86_64-linux-gnu 
-fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
 // CHECK-SANITIZE-COVERAGE-FUNC: fsanitize-coverage-type=1
Index: clang/test/CodeGen/sanitize-coverage-thread.c
===
--- /dev/null
+++ clang/test/CodeGen/sanitize-coverage-thread.c
@@ -0,0 +1,25 @@
+// RUN: %clang %s -emit-llvm -S -fsanitize=thread 
-fsanitize-coverage=trace-pc,trace-cmp -o - | FileCheck %s
+
+int x = 0;
+
+// CHECK-LABEL: define dso_local void @foo(
+void foo(void) {
+// CHECK: call void @__sanitizer_cov_trace_pc
+
+// CHECK: call void @__tsan_read4(i8* bitcast (i32* @x to i8*))
+// CHECK-NEXT: load i32, i32* @x, align 4
+
+// CHECK: call void @__sanitizer_cov_trace_const_cmp4
+// CHECK: br
+
+// CHECK: call void @__sanitizer_cov_trace_pc
+// CHECK: br
+if (x)
+// CHECK: call void @__sanitizer_cov_trace_pc
+// CHECK: call void @__tsan_write4(i8* bitcast (i32* @x to i8*))
+// CHECK-NEXT: store i32 42, i32* @x, align 4
+// CHECK: br
+x = 42;
+
+// CHECK: ret void
+}
Index: clang/test/CodeGen/sanitize-coverage-bounds.c
===
--- /dev/null
+++ clang/test/CodeGen/sanitize-coverage-bounds.c
@@ -0,0 +1,29 @@
+// RUN: %clang %s -emit-llvm -S -fsanitize=bounds 
-fsanitize-coverage=trace-pc,trace-cmp -o - | FileCheck %s
+
+int x[10];
+
+// CHECK-LABEL: define dso_local void @foo(
+void foo(int n) {
+// CHECK: call void @__sanitizer_cov_trace_pc
+// CHECK: call void @__sanitizer_cov_trace_const_cmp
+// CHECK: br
+// CHECK: call void @__sanitizer_cov_trace_pc
+// CHECK: br
+// CHECK: call void @__sanitizer_cov_trace_const_cmp
+// CHECK: br
+// CHECK: call void @__sanitizer_cov_trace_pc
+// CHECK: br
+if (n)
+// CHECK: call void @__sanitizer_cov_trace_pc
+// CHECK: call void @__ubsan_handle_out_of_bounds
+// CHECK: br
+// CHECK: getelementptr inbounds [10 x i32], [10 x i32]* @x
+// CHECK: call void @__sanitizer_cov_trace_const_cmp8
+// CHECK: br
+// CHECK: call void @__sanitizer_cov_trace_pc
+// CHECK: store i32 42
+// CHECK: br
+x[n] = 42;
+
+// CHECK: ret void
+}
Index: clang/lib/Driver/SanitizerArgs.cpp
===
--- clang/lib/Driver/SanitizerArgs.cpp
+++ clang/lib/Driver/SanitizerArgs.cpp
@@ -43,11 +43,12 @@
 SanitizerKind::KernelAddress | SanitizerKind::KernelHWAddress |
 SanitizerKind::MemTag | SanitizerKind::Memory |
 SanitizerKind::KernelMemory | SanitizerKind::Leak |
-SanitizerKind::Undefined | SanitizerKind::Integer |
+SanitizerKind::Undefined | 

[PATCH] D78767: [Sema] Teach -Wcast-align to compute a more accurate alignment when the source expression has array subscript or pointer arithmetic operators

2020-05-14 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 264106.
ahatanak marked 8 inline comments as done.
ahatanak added a comment.

Address most of the review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78767

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/test/SemaCXX/warn-cast-align.cpp

Index: clang/test/SemaCXX/warn-cast-align.cpp
===
--- clang/test/SemaCXX/warn-cast-align.cpp
+++ clang/test/SemaCXX/warn-cast-align.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -Wcast-align -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -Wno-unused-value -Wcast-align -verify %s
 
 // Simple casts.
 void test0(char *P) {
@@ -43,3 +43,101 @@
   typedef int *IntPtr;
   c = IntPtr(P);
 }
+
+struct __attribute__((aligned(16))) A {
+  char m0[16];
+  char m1[16];
+};
+
+struct B0 {
+  char m0[16];
+};
+
+struct B1 {
+  char m0[16];
+};
+
+struct C {
+  A 
+  B0 
+  A m2;
+};
+
+struct __attribute__((aligned(16))) D0 : B0, B1 {
+};
+
+struct __attribute__((aligned(16))) D1 : virtual B0 {
+};
+
+struct B2 {
+  char m0[8];
+};
+
+struct B3 {
+  char m0[8];
+};
+
+struct B4 {
+  char m0[8];
+};
+
+struct D2 : B2, B3 {
+};
+
+struct __attribute__((aligned(16))) D3 : B4, D2 {
+};
+
+struct __attribute__((aligned(16))) D4 : virtual D2 {
+};
+
+void test2(int n, A *a2) {
+  __attribute__((aligned(16))) char m[sizeof(A) * 2];
+  char(_ref)[sizeof(A) * 2] = m;
+  extern char(_ref_noinit)[sizeof(A) * 2];
+  __attribute__((aligned(16))) char vararray[10][n];
+  A t0;
+  B0 t1;
+  C t2 = {.m0 = t0, .m1 = t1};
+  __attribute__((aligned(16))) char t3[5][5][5];
+  __attribute__((aligned(16))) char t4[4][16];
+  D0 t5;
+  D1 t6;
+  D3 t7;
+  D4 t8;
+
+  A *a;
+  a = (A *)
+  a = (A *)(m + sizeof(A));
+  a = (A *)(sizeof(A) + m);
+  a = (A *)((sizeof(A) * 2 + m) - sizeof(A));
+  a = (A *)((sizeof(A) * 2 + m) - 1); // expected-warning {{cast from 'char *' to 'A *'}}
+  a = (A *)(m + 1);   // expected-warning {{cast from 'char *' to 'A *'}}
+  a = (A *)(1 + m);   // expected-warning {{cast from 'char *' to 'A *'}}
+  a = (A *)(m + n);   // expected-warning {{cast from 'char *' to 'A *'}}
+  a = (A *)&*[sizeof(A)];
+  a = (A *)(0, 0, [sizeof(A)]);
+  a = (A *)&(0, 0, *[sizeof(A)]);
+  a = (A *)[n]; // expected-warning {{cast from 'char *' to 'A *'}}
+  a = (A *)_ref;
+  a = (A *)_ref_noinit;// expected-warning {{cast from 'char (*)[64]' to 'A *'}}
+  a = (A *)([4][0]);// expected-warning {{cast from 'char *' to 'A *'}}
+  a = (A *)(a2->m0 + sizeof(A)); // expected-warning {{cast from 'char *' to 'A *'}}
+  a = (A *)();
+  a = (A *)(); // expected-warning {{cast from 'B0 *' to 'A *'}}
+  a = (A *)();
+  a = (A *)(t2.m2.m1);
+  a = (A *)([3][3][0]); // expected-warning {{cast from 'char *' to 'A *'}}
+  a = (A *)([2][2][4]);
+  a = (A *)([0][n][0]); // expected-warning {{cast from 'char *' to 'A *'}}
+  a = (A *)[n][0];
+  a = (A *)[n][1]; // expected-warning {{cast from 'char *' to 'A *'}}
+  a = (A *)(t4 + 1);
+  a = (A *)(t4 + n);
+  a = (A *)(static_cast());
+  a = (A *)(&(static_cast(t5)));
+  a = (A *)(static_cast()); // expected-warning {{cast from 'B0 *' to 'A *'}}
+  a = (A *)(static_cast()); // expected-warning {{cast from 'B2 *' to 'A *'}}
+  a = (A *)(static_cast());
+  a = (A *)(static_cast()); // expected-warning {{cast from 'B2 *' to 'A *'}}
+  a = (A *)(static_cast()); // expected-warning {{cast from 'B3 *' to 'A *'}}
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -30,6 +30,7 @@
 #include "clang/AST/NSAPI.h"
 #include "clang/AST/NonTrivialTypeVisitor.h"
 #include "clang/AST/OperationKinds.h"
+#include "clang/AST/RecordLayout.h"
 #include "clang/AST/Stmt.h"
 #include "clang/AST/TemplateBase.h"
 #include "clang/AST/Type.h"
@@ -13105,17 +13106,219 @@
   return HasInvalidParm;
 }
 
-/// A helper function to get the alignment of a Decl referred to by DeclRefExpr
-/// or MemberExpr.
-static CharUnits getDeclAlign(Expr *E, CharUnits TypeAlign,
-  ASTContext ) {
-  if (const auto *DRE = dyn_cast(E))
-return Context.getDeclAlign(DRE->getDecl());
+Optional>
+static getBaseAlignmentAndOffsetFromPtr(const Expr *E, ASTContext );
+
+/// Compute the alignment and offset of the base class object given the
+/// derived-to-base cast expression and the alignment and offset of the derived
+/// class object.
+static std::pair
+getDerivedToBaseAlignmentAndOffset(const CastExpr *CE, QualType DerivedType,
+   CharUnits BaseAlignment, CharUnits Offset,
+   ASTContext ) {
+  for (auto PathI = CE->path_begin(), PathE = CE->path_end(); PathI != PathE;
+   

[clang] 0363ae9 - [OPENMP50]Codegen for uses_allocators clause.

2020-05-14 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2020-05-14T18:02:12-04:00
New Revision: 0363ae97abb841114e841a963c95eb6a2202716d

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

LOG: [OPENMP50]Codegen for uses_allocators clause.

Summary:
Predefined allocators should not be mapped at all (they are just enumeric
constants). FOr user-defined allocators need to map the traits only as
firstprivates, the allocator itself is private.
At the beginning of the target region the user-defined allocatores must
be created and then destroyed at the end of the target region:
```
omp_allocator_handle_t my_allocator = __kmpc_init_allocator(,
/*default memhandle*/ 0, , &);
...
call void @__kmpc_destroy_allocator(, my_allocator);
```

Reviewers: jdoerfert, aaron.ballman

Subscribers: jholewinski, yaxunl, guansong, cfe-commits, caomhin

Tags: #clang

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

Added: 
clang/test/OpenMP/target_parallel_for_simd_uses_allocators_codegen.cpp
clang/test/OpenMP/target_parallel_for_uses_allocators_codegen.cpp
clang/test/OpenMP/target_parallel_uses_allocators_codegen.cpp
clang/test/OpenMP/target_simd_uses_allocators_codegen.cpp

clang/test/OpenMP/target_teams_distribute_parallel_for_simd_uses_allocators_codegen.cpp

clang/test/OpenMP/target_teams_distribute_parallel_for_uses_allocators_codegen.cpp
clang/test/OpenMP/target_teams_distribute_simd_uses_allocators_codegen.cpp
clang/test/OpenMP/target_teams_distribute_uses_allocators_codegen.cpp
clang/test/OpenMP/target_teams_uses_allocators_codegen.cpp
clang/test/OpenMP/target_uses_allocators_codegen.cpp

Modified: 
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/CodeGen/CGOpenMPRuntime.h
clang/lib/Sema/SemaOpenMP.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index b7d05ed48e59..250893fef19d 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -720,6 +720,11 @@ enum OpenMPRTLFunction {
   OMPRTL__kmpc_alloc,
   // Call to void __kmpc_free(int gtid, void *ptr, omp_allocator_handle_t al);
   OMPRTL__kmpc_free,
+  // Call to omp_allocator_handle_t __kmpc_init_allocator(int gtid,
+  // omp_memspace_handle_t, int ntraits, omp_alloctrait_t traits[]);
+  OMPRTL__kmpc_init_allocator,
+  // Call to void __kmpc_destroy_allocator(int gtid, omp_allocator_handle_t 
al);
+  OMPRTL__kmpc_destroy_allocator,
 
   //
   // Offloading related calls
@@ -2392,6 +2397,26 @@ llvm::FunctionCallee 
CGOpenMPRuntime::createRuntimeFunction(unsigned Function) {
 RTLFn = CGM.CreateRuntimeFunction(FnTy, /*Name=*/"__kmpc_free");
 break;
   }
+  case OMPRTL__kmpc_init_allocator: {
+// Build omp_allocator_handle_t __kmpc_init_allocator(int gtid,
+// omp_memspace_handle_t, int ntraits, omp_alloctrait_t traits[]);
+// omp_allocator_handle_t type is void*, omp_memspace_handle_t type is
+// void*.
+auto *FnTy = llvm::FunctionType::get(
+CGM.VoidPtrTy, {CGM.IntTy, CGM.VoidPtrTy, CGM.IntTy, CGM.VoidPtrTy},
+/*isVarArg=*/false);
+RTLFn = CGM.CreateRuntimeFunction(FnTy, /*Name=*/"__kmpc_init_allocator");
+break;
+  }
+  case OMPRTL__kmpc_destroy_allocator: {
+// Build void __kmpc_destroy_allocator(int gtid, omp_allocator_handle_t 
al);
+// omp_allocator_handle_t type is void*.
+auto *FnTy = llvm::FunctionType::get(CGM.VoidTy, {CGM.IntTy, 
CGM.VoidPtrTy},
+ /*isVarArg=*/false);
+RTLFn =
+CGM.CreateRuntimeFunction(FnTy, /*Name=*/"__kmpc_destroy_allocator");
+break;
+  }
   case OMPRTL__kmpc_push_target_tripcount: {
 // Build void __kmpc_push_target_tripcount(int64_t device_id, kmp_uint64
 // size);
@@ -7085,16 +7110,104 @@ void CGOpenMPRuntime::emitCancelCall(CodeGenFunction 
, SourceLocation Loc,
   }
 }
 
+namespace {
+/// Cleanup action for uses_allocators support.
+class OMPUsesAllocatorsActionTy final : public PrePostActionTy {
+  ArrayRef> Allocators;
+
+public:
+  OMPUsesAllocatorsActionTy(
+  ArrayRef> Allocators)
+  : Allocators(Allocators) {}
+  void Enter(CodeGenFunction ) override {
+if (!CGF.HaveInsertPoint())
+  return;
+for (const auto  : Allocators) {
+  CGF.CGM.getOpenMPRuntime().emitUsesAllocatorsInit(
+  CGF, AllocatorData.first, AllocatorData.second);
+}
+  }
+  void Exit(CodeGenFunction ) override {
+if (!CGF.HaveInsertPoint())
+  return;
+for (const auto  : Allocators) {
+  CGF.CGM.getOpenMPRuntime().emitUsesAllocatorsFini(CGF,
+AllocatorData.first);
+}
+  }
+};
+} // namespace
+
 void CGOpenMPRuntime::emitTargetOutlinedFunction(
 const OMPExecutableDirective , 

[PATCH] D68997: Allow searching for prebuilt implicit modules.

2020-05-14 Thread Alexandre Rames via Phabricator via cfe-commits
arames updated this revision to Diff 264096.
arames added a comment.

Rebase on top of tree.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68997

Files:
  clang/docs/Modules.rst
  clang/include/clang/Driver/Options.td
  clang/include/clang/Lex/HeaderSearch.h
  clang/include/clang/Lex/HeaderSearchOptions.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Lex/HeaderSearch.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/Modules/Inputs/prebuilt-implicit-module/a.h
  clang/test/Modules/Inputs/prebuilt-implicit-module/module.modulemap
  clang/test/Modules/prebuilt-implicit-modules.m

Index: clang/test/Modules/prebuilt-implicit-modules.m
===
--- /dev/null
+++ clang/test/Modules/prebuilt-implicit-modules.m
@@ -0,0 +1,27 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -x objective-c -fmodules %S/Inputs/prebuilt-implicit-module/module.modulemap -emit-module -fmodule-name=module_a -fmodules-cache-path=%t
+// RUN: find %t -name "module_a*.pcm" | grep module_a
+//
+// Check we use a prebuilt module when available, and do not build an implicit module.
+// RUN: rm -rf %t1
+// RUN: mkdir -p %t1
+// RUN: %clang_cc1 -x objective-c %s -I%S/Inputs/prebuilt-implicit-module -fmodules -fmodule-map-file=%S/Inputs/prebuilt-implicit-module/module.modulemap -fprebuilt-implicit-modules -fprebuilt-module-path=%t -fmodules-cache-path=%t1
+// RUN: find %t1 -name "module_a*.pcm" | not grep module_e
+//
+// Check that we correctly fall back to implicit modules if the prebuilt implicit module is not found.
+// RUN: %clang_cc1 -x objective-c %s -I%S/Inputs/prebuilt-implicit-module -fmodules -fmodule-map-file=%S/Inputs/prebuilt-implicit-module/module.modulemap -fprebuilt-implicit-modules -fprebuilt-module-path=%t -fmodules-cache-path=%t1 -fno-signed-char
+// RUN: find %t1 -name "module_a*.pcm" | grep module_a
+
+// Check that non-implicit prebuilt modules are always preferred to prebuilt implicit modules.
+// RUN: rm -rf %t2
+// RUN: mkdir -p %t2
+// RUN: %clang_cc1 -x objective-c -fmodules %S/Inputs/prebuilt-implicit-module/module.modulemap -emit-module -fmodule-name=module_a -fmodules-cache-path=%t
+// RUN: %clang_cc1 -x objective-c -fmodules %S/Inputs/prebuilt-implicit-module/module.modulemap -emit-module -fmodule-name=module_a -o %t/module_a.pcm -fno-signed-char
+// RUN: not %clang_cc1 -x objective-c %s -I%S/Inputs/prebuilt-implicit-module -fmodules -fmodule-map-file=%S/Inputs/prebuilt-implicit-module/module.modulemap -fprebuilt-implicit-modules -fprebuilt-module-path=%t -fmodules-cache-path=%t2
+// RUN: find %t2 -name "module_a*.pcm" | not grep module_a
+
+// expected-no-diagnostics
+@import module_a;
+int test() {
+  return a;
+}
Index: clang/test/Modules/Inputs/prebuilt-implicit-module/module.modulemap
===
--- /dev/null
+++ clang/test/Modules/Inputs/prebuilt-implicit-module/module.modulemap
@@ -0,0 +1 @@
+module module_a { header "a.h" }
Index: clang/test/Modules/Inputs/prebuilt-implicit-module/a.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/prebuilt-implicit-module/a.h
@@ -0,0 +1 @@
+const int a = 1;
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -1308,6 +1308,7 @@
   Record.push_back(HSOpts.DisableModuleHash);
   Record.push_back(HSOpts.ImplicitModuleMaps);
   Record.push_back(HSOpts.ModuleMapFileHomeIsCwd);
+  Record.push_back(HSOpts.EnablePrebuiltImplicitModules);
   Record.push_back(HSOpts.UseBuiltinIncludes);
   Record.push_back(HSOpts.UseStandardSystemIncludes);
   Record.push_back(HSOpts.UseStandardCXXIncludes);
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -5833,6 +5833,7 @@
   HSOpts.DisableModuleHash = Record[Idx++];
   HSOpts.ImplicitModuleMaps = Record[Idx++];
   HSOpts.ModuleMapFileHomeIsCwd = Record[Idx++];
+  HSOpts.EnablePrebuiltImplicitModules = Record[Idx++];
   HSOpts.UseBuiltinIncludes = Record[Idx++];
   HSOpts.UseStandardSystemIncludes = Record[Idx++];
   HSOpts.UseStandardCXXIncludes = Record[Idx++];
Index: clang/lib/Lex/HeaderSearch.cpp
===
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -164,14 +164,41 @@
   return {};
 }
 
+std::string HeaderSearch::getPrebuiltImplicitModuleFileName(Module *Module) {
+  const FileEntry *ModuleMap =
+  getModuleMap().getModuleMapFileForUniquing(Module);
+  StringRef 

[PATCH] D79967: Fix debug info for NoDebug attr

2020-05-14 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: tra, rjmccall.
Herald added a subscriber: aprantl.

NoDebug attr does not totally eliminate debug info about a function when
inlining is enabled. This is inconsistent with when inlining is disabled.

This patch fixes that.


https://reviews.llvm.org/D79967

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCUDA/kernel-dbg-info.cu


Index: clang/test/CodeGenCUDA/kernel-dbg-info.cu
===
--- clang/test/CodeGenCUDA/kernel-dbg-info.cu
+++ clang/test/CodeGenCUDA/kernel-dbg-info.cu
@@ -2,11 +2,28 @@
 
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -O0 \
 // RUN:   -fcuda-include-gpubinary %t -debug-info-kind=limited \
-// RUN:   -o - -x hip | FileCheck %s
+// RUN:   -o - -x hip | FileCheck -check-prefixes=CHECK,O0 %s
 // RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -emit-llvm %s -O0 \
 // RUN:   -fcuda-include-gpubinary %t -debug-info-kind=limited \
 // RUN:   -o - -x hip -fcuda-is-device | FileCheck -check-prefix=DEV %s
 
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -O0 \
+// RUN:   -fcuda-include-gpubinary %t -debug-info-kind=limited \
+// RUN:   -o - -x hip -debugger-tuning=gdb -dwarf-version=4 \
+// RUN:   | FileCheck -check-prefixes=CHECK,O0 %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -emit-llvm %s -O0 \
+// RUN:   -fcuda-include-gpubinary %t -debug-info-kind=limited \
+// RUN:   -o - -x hip -debugger-tuning=gdb -dwarf-version=4 \
+// RUN:   -fcuda-is-device | FileCheck -check-prefix=DEV %s
+
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -O3 \
+// RUN:   -fcuda-include-gpubinary %t -debug-info-kind=limited \
+// RUN:   -o - -x hip -debugger-tuning=gdb -dwarf-version=4 | FileCheck %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -emit-llvm %s -O3 \
+// RUN:   -fcuda-include-gpubinary %t -debug-info-kind=limited \
+// RUN:   -o - -x hip -debugger-tuning=gdb -dwarf-version=4 \
+// RUN:   -fcuda-is-device | FileCheck -check-prefix=DEV %s
+
 #include "Inputs/cuda.h"
 
 extern "C" __global__ void ckernel(int *a) {
@@ -27,7 +44,7 @@
 // CHECK-NOT: ret {{.*}}!dbg
 
 // CHECK-LABEL: define {{.*}}@_Z8hostfuncPi{{.*}}!dbg
-// CHECK: call void @[[CSTUB]]{{.*}}!dbg
+// O0: call void @[[CSTUB]]{{.*}}!dbg
 void hostfunc(int *a) {
   ckernel<<<1, 1>>>(a);
 }
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -3820,7 +3820,7 @@
   StringRef LinkageName;
 
   const Decl *D = GD.getDecl();
-  if (!D)
+  if (!D || D->hasAttr())
 return;
 
   llvm::TimeTraceScope TimeScope("DebugFunction", [&]() {


Index: clang/test/CodeGenCUDA/kernel-dbg-info.cu
===
--- clang/test/CodeGenCUDA/kernel-dbg-info.cu
+++ clang/test/CodeGenCUDA/kernel-dbg-info.cu
@@ -2,11 +2,28 @@
 
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -O0 \
 // RUN:   -fcuda-include-gpubinary %t -debug-info-kind=limited \
-// RUN:   -o - -x hip | FileCheck %s
+// RUN:   -o - -x hip | FileCheck -check-prefixes=CHECK,O0 %s
 // RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -emit-llvm %s -O0 \
 // RUN:   -fcuda-include-gpubinary %t -debug-info-kind=limited \
 // RUN:   -o - -x hip -fcuda-is-device | FileCheck -check-prefix=DEV %s
 
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -O0 \
+// RUN:   -fcuda-include-gpubinary %t -debug-info-kind=limited \
+// RUN:   -o - -x hip -debugger-tuning=gdb -dwarf-version=4 \
+// RUN:   | FileCheck -check-prefixes=CHECK,O0 %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -emit-llvm %s -O0 \
+// RUN:   -fcuda-include-gpubinary %t -debug-info-kind=limited \
+// RUN:   -o - -x hip -debugger-tuning=gdb -dwarf-version=4 \
+// RUN:   -fcuda-is-device | FileCheck -check-prefix=DEV %s
+
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -O3 \
+// RUN:   -fcuda-include-gpubinary %t -debug-info-kind=limited \
+// RUN:   -o - -x hip -debugger-tuning=gdb -dwarf-version=4 | FileCheck %s
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -emit-llvm %s -O3 \
+// RUN:   -fcuda-include-gpubinary %t -debug-info-kind=limited \
+// RUN:   -o - -x hip -debugger-tuning=gdb -dwarf-version=4 \
+// RUN:   -fcuda-is-device | FileCheck -check-prefix=DEV %s
+
 #include "Inputs/cuda.h"
 
 extern "C" __global__ void ckernel(int *a) {
@@ -27,7 +44,7 @@
 // CHECK-NOT: ret {{.*}}!dbg
 
 // CHECK-LABEL: define {{.*}}@_Z8hostfuncPi{{.*}}!dbg
-// CHECK: call void @[[CSTUB]]{{.*}}!dbg
+// O0: call void @[[CSTUB]]{{.*}}!dbg
 void hostfunc(int *a) {
   ckernel<<<1, 1>>>(a);
 }
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -3820,7 +3820,7 @@
   StringRef LinkageName;
 
   const Decl *D = GD.getDecl();
-  if (!D)
+  if (!D || D->hasAttr())
 

[PATCH] D79966: [OPENMP]Fix PR45911: Data sharing and lambda capture.

2020-05-14 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev created this revision.
ABataev added a reviewer: jdoerfert.
Herald added subscribers: guansong, yaxunl.
Herald added a project: clang.

No need to generate inlined OpenMP region for variables captured in
lambdas or block decls, only for implicitly captured variables in the
OpenMP region.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79966

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/task_firstprivate_codegen.cpp


Index: clang/test/OpenMP/task_firstprivate_codegen.cpp
===
--- clang/test/OpenMP/task_firstprivate_codegen.cpp
+++ clang/test/OpenMP/task_firstprivate_codegen.cpp
@@ -56,6 +56,7 @@
 
 int main() {
   static int sivar;
+  float local = 0;
 #ifdef LAMBDA
   // LAMBDA: [[G:@.+]] = global double
   // LAMBDA: [[SIVAR:@.+]] = internal global i{{[0-9]+}} 0,
@@ -73,9 +74,12 @@
 // LAMBDA: [[SIVAR_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[SIVAR]],
 // LAMBDA: store i{{[0-9]+}} [[SIVAR_VAL]], i{{[0-9]+}}* [[SIVAR_PRIVATE_ADDR]]
 
+// LAMBDA: [[LOCAL_PRIVATE_ADDR:%.+]] = getelementptr inbounds %{{.+}}, 
%{{.+}}* [[PRIVATES]], i{{.+}} 0, i{{.+}} 2
+// LAMBDA: store float %{{.+}}, float* [[LOCAL_PRIVATE_ADDR]]
+
 // LAMBDA: call i32 @__kmpc_omp_task(%{{.+}}* @{{.+}}, i32 %{{.+}}, i8* 
[[RES]])
 // LAMBDA: ret
-#pragma omp task firstprivate(g, sivar)
+#pragma omp task firstprivate(g, sivar, local)
   {
 // LAMBDA: define {{.+}} void [[INNER_LAMBDA:@.+]](%{{.+}}* 
[[ARG_PTR:%.+]])
 // LAMBDA: store %{{.+}}* [[ARG_PTR]], %{{.+}}** [[ARG_PTR_REF:%.+]],
@@ -115,9 +119,13 @@
   // BLOCKS: [[SIVAR_PRIVATE_ADDR:%.+]] = getelementptr inbounds %{{.+}}, 
%{{.+}}* [[PRIVATES]], i{{.+}} 0, i{{.+}} 1
   // BLOCKS: [[SIVAR_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[SIVAR]],
   // BLOCKS: store i{{[0-9]+}} [[SIVAR_VAL]], i{{[0-9]+}}* 
[[SIVAR_PRIVATE_ADDR]],
+
+  // BLOCKS: [[LOCAL_PRIVATE_ADDR:%.+]] = getelementptr inbounds %{{.+}}, 
%{{.+}}* [[PRIVATES]], i{{.+}} 0, i{{.+}} 2
+  // BLOCKS: store float %{{.+}}, float* [[LOCAL_PRIVATE_ADDR]]
+
   // BLOCKS: call i32 @__kmpc_omp_task(%{{.+}}* @{{.+}}, i32 %{{.+}}, i8* 
[[RES]])
   // BLOCKS: ret
-#pragma omp task firstprivate(g, sivar)
+#pragma omp task firstprivate(g, sivar, local)
   {
 // BLOCKS: define {{.+}} void {{@.+}}(i8*
 // BLOCKS-NOT: [[G]]{{[[^:word:]]}}
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -4811,11 +4811,16 @@
   C.getDeclAlign(OriginalVD)),
   SharedRefLValue.getType(), LValueBaseInfo(AlignmentSource::Decl),
   SharedRefLValue.getTBAAInfo());
+} else if (CGF.LambdaCaptureFields.count(
+   Pair.second.Original->getCanonicalDecl()) > 0 ||
+   dyn_cast_or_null(CGF.CurCodeDecl)) {
+  SharedRefLValue = CGF.EmitLValue(Pair.second.OriginalRef);
 } else {
+  // Processing for implicitly captured variables.
   InlinedOpenMPRegionRAII Region(
   CGF, [](CodeGenFunction &, PrePostActionTy &) {}, OMPD_unknown,
   /*HasCancel=*/false);
-  SharedRefLValue =  CGF.EmitLValue(Pair.second.OriginalRef);
+  SharedRefLValue = CGF.EmitLValue(Pair.second.OriginalRef);
 }
 if (Type->isArrayType()) {
   // Initialize firstprivate array.


Index: clang/test/OpenMP/task_firstprivate_codegen.cpp
===
--- clang/test/OpenMP/task_firstprivate_codegen.cpp
+++ clang/test/OpenMP/task_firstprivate_codegen.cpp
@@ -56,6 +56,7 @@
 
 int main() {
   static int sivar;
+  float local = 0;
 #ifdef LAMBDA
   // LAMBDA: [[G:@.+]] = global double
   // LAMBDA: [[SIVAR:@.+]] = internal global i{{[0-9]+}} 0,
@@ -73,9 +74,12 @@
 // LAMBDA: [[SIVAR_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[SIVAR]],
 // LAMBDA: store i{{[0-9]+}} [[SIVAR_VAL]], i{{[0-9]+}}* [[SIVAR_PRIVATE_ADDR]]
 
+// LAMBDA: [[LOCAL_PRIVATE_ADDR:%.+]] = getelementptr inbounds %{{.+}}, %{{.+}}* [[PRIVATES]], i{{.+}} 0, i{{.+}} 2
+// LAMBDA: store float %{{.+}}, float* [[LOCAL_PRIVATE_ADDR]]
+
 // LAMBDA: call i32 @__kmpc_omp_task(%{{.+}}* @{{.+}}, i32 %{{.+}}, i8* [[RES]])
 // LAMBDA: ret
-#pragma omp task firstprivate(g, sivar)
+#pragma omp task firstprivate(g, sivar, local)
   {
 // LAMBDA: define {{.+}} void [[INNER_LAMBDA:@.+]](%{{.+}}* [[ARG_PTR:%.+]])
 // LAMBDA: store %{{.+}}* [[ARG_PTR]], %{{.+}}** [[ARG_PTR_REF:%.+]],
@@ -115,9 +119,13 @@
   // BLOCKS: [[SIVAR_PRIVATE_ADDR:%.+]] = getelementptr inbounds %{{.+}}, %{{.+}}* [[PRIVATES]], i{{.+}} 0, i{{.+}} 1
   // BLOCKS: [[SIVAR_VAL:%.+]] = load i{{[0-9]+}}, i{{[0-9]+}}* [[SIVAR]],
   // BLOCKS: store i{{[0-9]+}} [[SIVAR_VAL]], i{{[0-9]+}}* [[SIVAR_PRIVATE_ADDR]],
+
+  // BLOCKS: [[LOCAL_PRIVATE_ADDR:%.+]] = getelementptr inbounds 

[PATCH] D79834: Speed up preamble building by replacing the slow translateFile call by a new, faster isMainFile check

2020-05-14 Thread Alex Lorenz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG11d612ac99a6: [clang][Preprocessor] Replace the slow 
translateFile call by a new, faster… (authored by arphaman).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79834

Files:
  clang/include/clang/Basic/SourceManager.h
  clang/lib/Basic/SourceManager.cpp
  clang/lib/Lex/PPDirectives.cpp
  clang/unittests/Basic/SourceManagerTest.cpp


Index: clang/unittests/Basic/SourceManagerTest.cpp
===
--- clang/unittests/Basic/SourceManagerTest.cpp
+++ clang/unittests/Basic/SourceManagerTest.cpp
@@ -491,6 +491,30 @@
   EXPECT_TRUE(SourceMgr.isBeforeInTranslationUnit(Macros[10].Loc, 
Macros[11].Loc));
 }
 
+TEST_F(SourceManagerTest, isMainFile) {
+  const char *Source = "int x;";
+
+  std::unique_ptr Buf =
+  llvm::MemoryBuffer::getMemBuffer(Source);
+  const FileEntry *SourceFile =
+  FileMgr.getVirtualFile("mainFile.cpp", Buf->getBufferSize(), 0);
+  SourceMgr.overrideFileContents(SourceFile, std::move(Buf));
+
+  std::unique_ptr Buf2 =
+  llvm::MemoryBuffer::getMemBuffer(Source);
+  const FileEntry *SecondFile =
+  FileMgr.getVirtualFile("file2.cpp", Buf2->getBufferSize(), 0);
+  SourceMgr.overrideFileContents(SecondFile, std::move(Buf2));
+
+  FileID MainFileID = SourceMgr.getOrCreateFileID(SourceFile, SrcMgr::C_User);
+  SourceMgr.setMainFileID(MainFileID);
+
+  EXPECT_TRUE(SourceMgr.isMainFile(FileEntryRef("mainFile.cpp", *SourceFile)));
+  EXPECT_TRUE(
+  SourceMgr.isMainFile(FileEntryRef("anotherName.cpp", *SourceFile)));
+  EXPECT_FALSE(SourceMgr.isMainFile(FileEntryRef("mainFile.cpp", 
*SecondFile)));
+}
+
 #endif
 
 } // anonymous namespace
Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -2054,8 +2054,7 @@
   // some directives (e.g. #endif of a header guard) will never be seen.
   // Since this will lead to confusing errors, avoid the inclusion.
   if (Action == Enter && File && PreambleConditionalStack.isRecording() &&
-  SourceMgr.translateFile(>getFileEntry()) ==
-  SourceMgr.getMainFileID()) {
+  SourceMgr.isMainFile(*File)) {
 Diag(FilenameTok.getLocation(),
  diag::err_pp_including_mainfile_in_preamble);
 return {ImportAction::None};
Index: clang/lib/Basic/SourceManager.cpp
===
--- clang/lib/Basic/SourceManager.cpp
+++ clang/lib/Basic/SourceManager.cpp
@@ -389,6 +389,14 @@
   createExpansionLoc(SourceLocation(), SourceLocation(), SourceLocation(), 1);
 }
 
+bool SourceManager::isMainFile(FileEntryRef SourceFile) {
+  assert(MainFileID.isValid() && "expected initialized SourceManager");
+  auto FE = getFileEntryRefForID(MainFileID);
+  if (!FE)
+return false;
+  return FE->getUID() == SourceFile.getUID();
+}
+
 void SourceManager::initializeForReplay(const SourceManager ) {
   assert(MainFileID.isInvalid() && "expected uninitialized SourceManager");
 
Index: clang/include/clang/Basic/SourceManager.h
===
--- clang/include/clang/Basic/SourceManager.h
+++ clang/include/clang/Basic/SourceManager.h
@@ -813,6 +813,11 @@
 MainFileID = FID;
   }
 
+  /// Returns true when the given FileEntry corresponds to the main file.
+  ///
+  /// The main file should be set prior to calling this function.
+  bool isMainFile(FileEntryRef SourceFile);
+
   /// Set the file ID for the precompiled preamble.
   void setPreambleFileID(FileID Preamble) {
 assert(PreambleFileID.isInvalid() && "PreambleFileID already set!");


Index: clang/unittests/Basic/SourceManagerTest.cpp
===
--- clang/unittests/Basic/SourceManagerTest.cpp
+++ clang/unittests/Basic/SourceManagerTest.cpp
@@ -491,6 +491,30 @@
   EXPECT_TRUE(SourceMgr.isBeforeInTranslationUnit(Macros[10].Loc, Macros[11].Loc));
 }
 
+TEST_F(SourceManagerTest, isMainFile) {
+  const char *Source = "int x;";
+
+  std::unique_ptr Buf =
+  llvm::MemoryBuffer::getMemBuffer(Source);
+  const FileEntry *SourceFile =
+  FileMgr.getVirtualFile("mainFile.cpp", Buf->getBufferSize(), 0);
+  SourceMgr.overrideFileContents(SourceFile, std::move(Buf));
+
+  std::unique_ptr Buf2 =
+  llvm::MemoryBuffer::getMemBuffer(Source);
+  const FileEntry *SecondFile =
+  FileMgr.getVirtualFile("file2.cpp", Buf2->getBufferSize(), 0);
+  SourceMgr.overrideFileContents(SecondFile, std::move(Buf2));
+
+  FileID MainFileID = SourceMgr.getOrCreateFileID(SourceFile, SrcMgr::C_User);
+  SourceMgr.setMainFileID(MainFileID);
+
+  EXPECT_TRUE(SourceMgr.isMainFile(FileEntryRef("mainFile.cpp", *SourceFile)));
+  EXPECT_TRUE(
+  SourceMgr.isMainFile(FileEntryRef("anotherName.cpp", 

[PATCH] D79830: Add support of __builtin_expect_with_probability

2020-05-14 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:2195
+Value *ExpectedValue = EmitScalarExpr(E->getArg(1));
+Value *Confidence = EmitScalarExpr(E->getArg(2));
+// Don't generate llvm.expect.with.probability on -O0 as the backend

LukeZhuang wrote:
> rsmith wrote:
> > If the intrinsic expects a `ConstantFP` value, this isn't enough to 
> > guarantee that you get one (the set of cases that we fold to constants 
> > during expression emission is much smaller than the set of cases we can 
> > constant-evaluate). You should run the constant evaluator first, to produce 
> > an `APFloat`, then emit that value as a constant. (Optionally you can form 
> > a `ConstantExpr` as part of the check in `Sema` and store the value in that 
> > object rather than recomputing it here.)
> Thank you for commenting! I have a question about this. If I check this 
> argument can be fold as constant float in `Sema`, why I need to check it 
> here? Or do you mean I had better create a `ConstantFP` value here after 
> constant emitting? 
`EmitScalarExpr` will emit arbitrary IR that evaluates the argument. If the 
argument isn't a simple floating-point literal, then you won't necessarily get 
an IR-level constant back from that. For example:

```
struct die {
  constexpr int sides() { return 6; }
  int roll();
} d6;
bool rolled_a_one = __builtin_expect_with_probability(d6.roll(), 1, 1.0 / 
d6.sides());
```

Here, we can evaluate `1.0 / d6.sides()`, but `EmitScalarExpr` will emit a 
function call and a division, not a constant.

Instead, you could use `EvaluateAsFloat` here (you can assert it succeeds 
because you already checked that in `Sema`) and then directly form a 
`ConstantFP` from the `APFloat` result.



Comment at: clang/lib/Sema/SemaChecking.cpp:1805
+const Expr *ProbArg = TheCall->getArg(2);
+if (ProbArg->EvaluateAsFloat(Confidence, Context)) {
+  double P = Confidence.convertToDouble();

LukeZhuang wrote:
> LukeZhuang wrote:
> > rsmith wrote:
> > > What rules should be applied here? Do we just want to allow anything that 
> > > we can evaluate (which might change over time), or do we want to use the 
> > > underlying language's notion of floating-point constant expressions, if 
> > > it has them?
> > Thank you for commenting. I just read the llvm::Expr document and found 
> > that it just have `isIntegerConstantExpr` without a float-point version. 
> > Under `EvaluateAsFloat` it says "Return true if this is a constant which we 
> > can fold and convert to a floating point value", thus I use this function. 
> > Is there any better function to achieve this goal?
> Hi, and I didn't find other builtin functions ever handle case like this, is 
> there any example I could refer to?
I think this is the first builtin (and maybe the first part of Clang) that 
wants to enforce that it sees a floating-point constant expression.

The right thing to do is generally to call `EvaluateAsConstantExpr` and check 
that it produces the right kind of value and doesn't generate any notes. See 
the code at the end of `CheckConvertedConstantExpr` for how to do this.

You also need to check that `ProbArg` is not value-dependent before you try to 
evaluate it; it's not meaningful to ask for the value of a value-dependent 
expression.



Comment at: clang/lib/Sema/SemaChecking.cpp:1813-1814
+} else {
+  Diag(ProbArg->getLocStart(), diag::err_probability_not_constant_float)
+  << ProbArg->getSourceRange();
+  return ExprError();

`EvaluateAsConstantExpr` will give you some notes to attach to this diagnostic 
to explain why the expression is non-constant.


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

https://reviews.llvm.org/D79830



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


[PATCH] D76791: [Matrix] Implement matrix index expressions ([][]).

2020-05-14 Thread Florian Hahn via Phabricator via cfe-commits
fhahn updated this revision to Diff 264094.
fhahn added a comment.

Update to support non-constant-integer-expressions as indices.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76791

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/BuiltinTypes.def
  clang/include/clang/AST/Expr.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/NSAPI.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGValue.h
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Serialization/ASTCommon.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/test/CodeGen/matrix-type-operators.c
  clang/test/CodeGenCXX/matrix-type-operators.cpp
  clang/test/Sema/matrix-type-operators.c
  clang/test/SemaCXX/matrix-type-operators.cpp

Index: clang/test/SemaCXX/matrix-type-operators.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/matrix-type-operators.cpp
@@ -0,0 +1,70 @@
+// RUN: %clang_cc1 %s -fenable-matrix -pedantic -std=c++11 -verify -triple=x86_64-apple-darwin9
+
+typedef float sx5x10_t __attribute__((matrix_type(5, 10)));
+
+void insert(sx5x10_t a, float f) {
+  // Non integer indexes.
+  a[3][f] = 0;
+  // expected-error@-1 {{matrix column index is not an integer}}
+  a[f][9] = 0;
+  // expected-error@-1 {{matrix row index is not an integer}}
+  a[f][f] = 0;
+  // expected-error@-1 {{matrix row index is not an integer}}
+  a[0][f] = 0;
+  // expected-error@-1 {{matrix column index is not an integer}}
+
+  // Invalid element type.
+  a[3][4] = 
+  // expected-error@-1 {{assigning to 'float' from incompatible type 'float *'; remove &}}
+
+  // Indexes outside allowed dimensions.
+  a[-1][3] = 10.0;
+  // expected-error@-1 {{matrix row index is outside the allowed range [0, 5)}}
+  a[3][-1] = 10.0;
+  // expected-error@-1 {{matrix column index is outside the allowed range [0, 10)}}
+  a[3][-1u] = 10.0;
+  // expected-error@-1 {{matrix column index is outside the allowed range [0, 10)}}
+  a[-1u][3] = 10.0;
+  // expected-error@-1 {{matrix row index is outside the allowed range [0, 5)}}
+  a[5][2] = 10.0;
+  // expected-error@-1 {{matrix row index is outside the allowed range [0, 5)}}
+  a[4][10] = 10.0;
+  // expected-error@-1 {{matrix column index is outside the allowed range [0, 10)}}
+  a[5][10.0] = f;
+  // expected-error@-1 {{matrix row index is outside the allowed range [0, 5)}}
+}
+
+void extract(sx5x10_t a, float f) {
+  // Non integer indexes.
+  float v1 = a[3][f];
+  // expected-error@-1 {{matrix column index is not an integer}}
+  float v2 = a[f][9];
+  // expected-error@-1 {{matrix row index is not an integer}}
+  float v3 = a[f][f];
+  // expected-error@-1 {{matrix row index is not an integer}}
+
+  // Invalid element type.
+  char *v4 = a[3][4];
+  // expected-error@-1 {{cannot initialize a variable of type 'char *' with an lvalue of type 'float'}}
+
+  // Indexes outside allowed dimensions.
+  float v5 = a[-1][3];
+  // expected-error@-1 {{matrix row index is outside the allowed range [0, 5)}}
+  float v6 = a[3][-1];
+  // expected-error@-1 {{matrix column index is outside the allowed range [0, 10)}}
+  float v8 = a[-1u][3];
+  // expected-error@-1 {{matrix row index is outside the allowed range [0, 5)}}
+  float v9 = a[5][2];
+  // expected-error@-1 {{matrix row index is outside the allowed range [0, 5)}}
+  float v10 = a[4][10];
+  // expected-error@-1 {{matrix column index is outside the allowed range [0, 10)}}
+  float v11 = a[5][10.0];
+  // expected-error@-1 {{matrix row index is outside the allowed range [0, 5)}}
+}
+
+void incomplete_matrix_index_expr(sx5x10_t a, float f) {
+  float x = a[3];
+  // expected-error@-1 {{single subscript expressions are not allowed for matrix values}}
+  a[2] = f;
+  // expected-error@-1 {{single subscript expressions are not allowed for matrix values}}
+}
Index: clang/test/Sema/matrix-type-operators.c
===
--- /dev/null
+++ clang/test/Sema/matrix-type-operators.c
@@ -0,0 +1,69 @@
+// RUN: %clang_cc1 %s -fenable-matrix -pedantic -verify -triple=x86_64-apple-darwin9
+
+typedef float sx5x10_t __attribute__((matrix_type(5, 10)));
+
+void insert(sx5x10_t a, float f) {
+  // Non integer indexes.
+  a[3][f] = 0;
+  // expected-error@-1 {{matrix column index is not an integer}}
+  a[f][9] = 0;
+  // expected-error@-1 {{matrix row index is not an integer}}
+  a[f][f] = 0;
+  // expected-error@-1 {{matrix row index is not an integer}}
+  a[0][f] = 0;
+  // expected-error@-1 {{matrix column index is not an integer}}
+
+  // Invalid element type.
+  a[3][4] = 
+  // expected-error@-1 {{assigning to 'float' from incompatible type 'float *'; remove &}}
+
+  // Indexes 

[PATCH] D72841: Add support for pragma float_control, to control precision and exception behavior at the source level

2020-05-14 Thread Michele Scandale via Phabricator via cfe-commits
michele.scandale added inline comments.



Comment at: clang/lib/CodeGen/CGExprScalar.cpp:227
+  FMF.setAllowContract(FPFeatures.allowFPContractAcrossStatement() ||
+   FPFeatures.allowFPContractWithinStatement());
 }

mibintc wrote:
> mibintc wrote:
> > michele.scandale wrote:
> > > I'm not convinced it correct to set `contract` when 
> > > `allowFPContractWithinStatement` return true. Can someone clarify this?
> > > 
> > > If I compile the following example with `-ffp-contract=on`:
> > > ```
> > > float test1(float a, float b, float c) {
> > >   float x = a * b;
> > >   return x + c;
> > > }
> > > 
> > > float test2(float a, float b, float c) {
> > >   return a * b + c;
> > > }
> > > ```
> > > 
> > > Before this change the generated code was:
> > > ```
> > > define float @test1(float %a, float %b, float %c) {
> > >   %0 = fmul float %a, %b
> > >   %1 = fadd float %0, %c
> > >   ret float %1
> > > }
> > > 
> > > define float @test2(float %a, float %b, float %c) {
> > >   %0 = call float @llvm.fmuladd.f32(float %a, float%b, float %c)
> > >   ret float %0
> > > }
> > > ```
> > > 
> > > And my understanding is that the in-statement contraction is implemented 
> > > by emitting the `llvm.fmuladd` call that a backend might decide to 
> > > implement as `fmul + fadd` or as `fma`.
> > > 
> > > With this change the generated code is:
> > > ```
> > > define float @test1(float %a, float %b, float %c) {
> > >   %0 = fmul contract float %a, %b
> > >   %1 = fadd contract float %0, %c
> > >   ret float %1
> > > }
> > > 
> > > define float @test2(float %a, float %b, float %c) {
> > >   %0 = call contract float @llvm.fmuladd.f32(float %a, float%b, float %c)
> > >   ret float %0
> > > }
> > > ```
> > > and it seems to me that in `test1` (where multiple statements where 
> > > explicitly used) the optimizer is now allowed to perform the contraction, 
> > > violating the original program semantic where only "in-statement" 
> > > contraction was allowed.
> > Thanks @michele.scandale i will work on a patch for this
> @michele.scandale I posted a patch for 'contract' here, 
> https://reviews.llvm.org/D79903 
Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72841



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


[PATCH] D79903: FastMathFlags.allowContract should be init from FPFeatures.allowFPContractAcrossStatement

2020-05-14 Thread Michele Scandale via Phabricator via cfe-commits
michele.scandale added inline comments.



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:2943
+  if (Opts.FastRelaxedMath)
+Opts.setDefaultFPContractMode(LangOptions::FPM_Fast);
   Opts.HexagonQdsp6Compat = Args.hasArg(OPT_mqdsp6_compat);

mibintc wrote:
> mibintc wrote:
> > rjmccall wrote:
> > > mibintc wrote:
> > > > rjmccall wrote:
> > > > > mibintc wrote:
> > > > > > I changed this because the FAST version of this test 
> > > > > > clang/test/CodeGenOpenCL/relaxed-fpmath.cl wants the 'fast' 
> > > > > > attribute on the instruction dump.  All the LLVM FMF bits must be 
> > > > > > set for the fast attribute print.  By default, the value for OpenCL 
> > > > > > is ffp-contract=on
> > > > > Is there an overall behavior change for OpenCL across these patches?
> > > > I think the answer to your question is no.  Here is more details: 
> > > > OpenCL sets the default behavior to ffp-contract=on.  In 
> > > > https://reviews.llvm.org/D72841 I added the function 
> > > > UpdateFastMathFlags, that function set the llvm FMF.allowContract bit 
> > > > to be ( ffp-contract=on or ffp-contract=fast).  This patch just drops 
> > > > the check on ffp-contract=on.   I didn't wind back to see how the llvm 
> > > > fast attribute was being set for this [opencl] test case originally. 
> > > Well, to what extent are there (including this patch) overall test 
> > > changes for the OpenCL tests, and what are tthey?
> > In the #pragma float_control patch https://reviews.llvm.org/D72841, I 
> > changed 2 CodeGen/OpenCL tests: relaxed-fp-math.cl in the non-FAST cases to 
> > show the contract bit.  Also 1 line in single-precision-constant.cl for the 
> > same reason, to show the contract bit.  This patch undoes those test 
> > changes. I'll do more investigation to understand why the fast bit isn't 
> > being set in the FAST case in relaxed-fpmath.cl without the change to 
> > CompilerInovcaton
> Prior to the patch for #pragma float_control, the llvm.FastMathFlags was 
> initialized from LangArgs.FastMath in the CodeGenFunction constructor 
> approximately line 74, and the FMF values in IRBuilder were never 
> changed--For the test clang/test/CodeGenOpenCL/relaxed-fpmath.cl with option 
> -cl-fast-relaxed-math.  (In ParseLangArgs,  Opts.FastMath = 
> Args.hasArg(OPT_ffast_math) ||  Args.hasArg(OPT_cl_fast_relaxed_math))  
> If FastMath is on, then all the llvm.FMF flags are set.
> 
> The #pragma float_control patch does change the IRBuilder settings in the 
> course of visiting the Expr nodes, using the information in the Expr nodes, 
> but the initial setting of FPFeatures from the command line overlooked the 
> fact that FastMath, and therefore ffp-contract=fast, is enabled. 
Prior to D72841 compiling something with `-ffast-math -ffp-contract={on,off}` 
was still producing `fast` as fast-math flags on the instructions for the same 
reason.
The clang driver does not consider the contraction mode for passing 
`-ffast-math` to CC1, which is consistent with the GCC behavior (I checked if 
the `__FAST_MATH__` is defined if I compile with `-ffast-math 
-ffp-contract=off`).
According to this, the code in `CodeGenFunction`:
```
if (LangOpts.FastMath)
  FMF.setFast();
```
is not correct.

The OpenCL option `-cl-fast-relaxed-math` should be equivalent to `-ffast-math` 
for the user. I don't know what the interaction between `-cl-fast-relaxed-math` 
and `-ffp-contract={on, off,fast}`.

If we need to keep `-cl-fast-relaxed-math` a CC1 option, I guess the following 
might work:
```
if (Args.hasArg(OPTS_cl_fast_relaxed_math) && !Arg.hasArg(OPT_ffp_contractEQ))
  Opts.setDefaultFPContractMode)LangOptions::FPM_Fast);
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79903



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


[PATCH] D79698: Run Coverage pass before other *San passes under new pass manager

2020-05-14 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

Just to followup on this: We believe the root cause of the error we're running 
into is that some sancov guards in one comdat are being referenced by symbols 
in another comdat, so due to linking order, the other comdat in question is 
referencing a sancov guard that was in a discarded comdat group. I posted full 
details of this on llvm-dev 
. We believe 
we're running into this error now because with this patch, inlining occurs 
after the sanitizers are run.

Based on some discussion in 
http://lists.llvm.org/pipermail/llvm-dev/2020-May/141558.html, it seems 
appropriate that the solution for this is to just run sanitizers after 
inlining, so we would avoid this error that's brought about by inlining after 
sanitizer runs. Since this has been breaking us for a few days, and unless 
other folks don't mind, I'm thinking it might be appropriate to temporarily 
revert this until there's a fix for either

(1) running sanitizers after inlining or
(2) changing which comdat groups the sancov guards get placed in (such that 
guards in one group aren't referenced by functions defined in another group)

I'm not sure how long it would take to implement either solution, so I think 
temporarily reverting might be ok here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79698



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


[PATCH] D79675: [OpenMP][OMPBuilder] Adding Privatization Requirements to OMPIRBuilder

2020-05-14 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

I left some comments on the type stuff. The rest looks good.
I think if you rebase the type stuff on D79739 
 (which I can merge) we should only need to 
expand `initializeTypes` to make this work as expected. WDYT?




Comment at: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h:336
 
-  /// Generator for '#omp master'
+  /// Generator for '#omp Critical'
   ///

Nit: unrelated (just commit it), use lower case to match OpenMP



Comment at: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h:387
+  CallInst *CreateOMPFree(const LocationDescription , Value *Addr,
+  Value *Allocator, std::string name = "");
+

Style: Use `Name` for the variable name.



Comment at: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h:389
+
+  /// Create a runtime call for kmpc_free
+  ///

Nit: Copy and paste



Comment at: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h:400
+  llvm::ConstantInt *Size,
+  const llvm::Twine  = Twine(" "));
+

Do we really want a space as name here? I would understand `""` but a space 
seems odd to me.



Comment at: llvm/include/llvm/Frontend/OpenMP/OMPKinds.def:234
 __OMP_RTL(__kmpc_critical, false, Void, IdentPtr, Int32, KmpCriticalNamePtrTy)
-__OMP_RTL(__kmpc_critical_with_hint, false, Void, IdentPtr, Int32, 
KmpCriticalNamePtrTy, Int32)
+__OMP_RTL(__kmpc_critical_with_hint, false, Void, IdentPtr, Int32, 
KmpCriticalNamePtrTy, IntPtrTy)
 __OMP_RTL(__kmpc_end_critical, false, Void, IdentPtr, Int32, 
KmpCriticalNamePtrTy)

fghanim wrote:
> jdoerfert wrote:
> > fghanim wrote:
> > > jdoerfert wrote:
> > > > I think this was correct before:
> > > > ```
> > > >   KMP_EXPORT void __kmpc_critical_with_hint(ident_t *, kmp_int32 
> > > > global_tid, kmp_critical_name *, uint32_t hint);
> > > > ```
> > > Nop, it's supposed to be whatever `IntPtrTy` is in the frontend (i.e. 32 
> > > for 32bit, 64 for 64bit).
> > > 
> > > `IntPtrTy` is actually a union with `sizety` in `CodeGenModule`
> > I'm confused. I copied the declaration above from the runtime. It doesn't 
> > contain an `IntPtrTy` or similar. I agree that `IntPtrTy` is machine 
> > dependent and we need your initializers. What I tried to say is that at 
> > least one declaration in the runtime has `__kmpc_critical_with_hint` with 
> > an int32 as last argument. That said, the runtime is not shy of 
> > incompatible declarations for functions.
> I cannot speak for what's in the runtime. However, in clang, this currently 
> is defined to use `IntPtrTy`. If you go check, I have a todo in the current 
> implementation for critical to come back and fix it.
That is just an existing bug in Clang. The runtime is consistent with the type 
and arguably it is the runtime we must match, not the other way around ;)



Comment at: llvm/lib/Frontend/OpenMP/OMPConstants.cpp:69
 
 void llvm::omp::types::initializeTypes(Module ) {
   if (Void)

Maybe we can/should take the IntPtr and SizeTy here so there is only a single 
call necessary that initializes all types. I fear "default" values are 
problematic.

WDYT?



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:106
+  initializeVoidPtrTy(VoidPtrTy);
+}
+

I guess we can directly call the initialize functions, right?
With an assert that SizeTy is set we can make sure users do it ;)



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:942
+  // v
+  //   OMP.Entry.Next
+

Great! thanks!



Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:971
+Builder.SetInsertPoint(br);
+  }
+

Nit: `Br` or just make it a one-liner w/o braces.



Comment at: llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp:817
+  EXPECT_EQ(CopyinEnd,NotMasterBr->getSuccessor(0));
+}
+

Great.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79675



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


[clang] 11d612a - [clang][Preprocessor] Replace the slow translateFile call by a new, faster isMainFile check

2020-05-14 Thread Alex Lorenz via cfe-commits

Author: Alex Lorenz
Date: 2020-05-14T14:13:34-07:00
New Revision: 11d612ac99a621c762c2cc8f7bacbb8ae32d7fe9

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

LOG: [clang][Preprocessor] Replace the slow translateFile call by a new, faster 
isMainFile check

The commit 3c28a2dc6bdc331e5a0d8097a5fa59d06682b9d0 introduced the check that 
checks if we're
trying to re-enter a main file when building a preamble. Unfortunately this 
slowed down the preamble
compilation by 80-90% in some test cases, as translateFile is really slow. This 
change checks
to see if the FileEntry is the main file without calling translateFile, but by 
using the new
isMainFile check instead. This speeds up preamble building by 1.5-2x for 
certain test cases that we have.

rdar://59361291

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

Added: 


Modified: 
clang/include/clang/Basic/SourceManager.h
clang/lib/Basic/SourceManager.cpp
clang/lib/Lex/PPDirectives.cpp
clang/unittests/Basic/SourceManagerTest.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/SourceManager.h 
b/clang/include/clang/Basic/SourceManager.h
index d0910ea31827..693ae4f938e1 100644
--- a/clang/include/clang/Basic/SourceManager.h
+++ b/clang/include/clang/Basic/SourceManager.h
@@ -813,6 +813,11 @@ class SourceManager : public RefCountedBase 
{
 MainFileID = FID;
   }
 
+  /// Returns true when the given FileEntry corresponds to the main file.
+  ///
+  /// The main file should be set prior to calling this function.
+  bool isMainFile(FileEntryRef SourceFile);
+
   /// Set the file ID for the precompiled preamble.
   void setPreambleFileID(FileID Preamble) {
 assert(PreambleFileID.isInvalid() && "PreambleFileID already set!");

diff  --git a/clang/lib/Basic/SourceManager.cpp 
b/clang/lib/Basic/SourceManager.cpp
index e42c3f4ca73f..6e4c8e8052bd 100644
--- a/clang/lib/Basic/SourceManager.cpp
+++ b/clang/lib/Basic/SourceManager.cpp
@@ -389,6 +389,14 @@ void SourceManager::clearIDTables() {
   createExpansionLoc(SourceLocation(), SourceLocation(), SourceLocation(), 1);
 }
 
+bool SourceManager::isMainFile(FileEntryRef SourceFile) {
+  assert(MainFileID.isValid() && "expected initialized SourceManager");
+  auto FE = getFileEntryRefForID(MainFileID);
+  if (!FE)
+return false;
+  return FE->getUID() == SourceFile.getUID();
+}
+
 void SourceManager::initializeForReplay(const SourceManager ) {
   assert(MainFileID.isInvalid() && "expected uninitialized SourceManager");
 

diff  --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index db249126d393..396ba529fc9a 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -2054,8 +2054,7 @@ Preprocessor::ImportAction 
Preprocessor::HandleHeaderIncludeOrImport(
   // some directives (e.g. #endif of a header guard) will never be seen.
   // Since this will lead to confusing errors, avoid the inclusion.
   if (Action == Enter && File && PreambleConditionalStack.isRecording() &&
-  SourceMgr.translateFile(>getFileEntry()) ==
-  SourceMgr.getMainFileID()) {
+  SourceMgr.isMainFile(*File)) {
 Diag(FilenameTok.getLocation(),
  diag::err_pp_including_mainfile_in_preamble);
 return {ImportAction::None};

diff  --git a/clang/unittests/Basic/SourceManagerTest.cpp 
b/clang/unittests/Basic/SourceManagerTest.cpp
index 850a08b74ace..5fd7607f76d7 100644
--- a/clang/unittests/Basic/SourceManagerTest.cpp
+++ b/clang/unittests/Basic/SourceManagerTest.cpp
@@ -491,6 +491,30 @@ TEST_F(SourceManagerTest, 
isBeforeInTranslationUnitWithMacroInInclude) {
   EXPECT_TRUE(SourceMgr.isBeforeInTranslationUnit(Macros[10].Loc, 
Macros[11].Loc));
 }
 
+TEST_F(SourceManagerTest, isMainFile) {
+  const char *Source = "int x;";
+
+  std::unique_ptr Buf =
+  llvm::MemoryBuffer::getMemBuffer(Source);
+  const FileEntry *SourceFile =
+  FileMgr.getVirtualFile("mainFile.cpp", Buf->getBufferSize(), 0);
+  SourceMgr.overrideFileContents(SourceFile, std::move(Buf));
+
+  std::unique_ptr Buf2 =
+  llvm::MemoryBuffer::getMemBuffer(Source);
+  const FileEntry *SecondFile =
+  FileMgr.getVirtualFile("file2.cpp", Buf2->getBufferSize(), 0);
+  SourceMgr.overrideFileContents(SecondFile, std::move(Buf2));
+
+  FileID MainFileID = SourceMgr.getOrCreateFileID(SourceFile, SrcMgr::C_User);
+  SourceMgr.setMainFileID(MainFileID);
+
+  EXPECT_TRUE(SourceMgr.isMainFile(FileEntryRef("mainFile.cpp", *SourceFile)));
+  EXPECT_TRUE(
+  SourceMgr.isMainFile(FileEntryRef("anotherName.cpp", *SourceFile)));
+  EXPECT_FALSE(SourceMgr.isMainFile(FileEntryRef("mainFile.cpp", 
*SecondFile)));
+}
+
 #endif
 
 } // anonymous namespace



___
cfe-commits mailing list

[clang] 428d0b6 - Fix clang test failures from D77454

2020-05-14 Thread Eli Friedman via cfe-commits

Author: Eli Friedman
Date: 2020-05-14T14:10:51-07:00
New Revision: 428d0b6f77986efd944df01bb4ae7888c6262c2f

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

LOG: Fix clang test failures from D77454

Added: 


Modified: 
clang/lib/CodeGen/CGCleanup.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGCleanup.cpp b/clang/lib/CodeGen/CGCleanup.cpp
index 70eaa321a007..ab39d91e9173 100644
--- a/clang/lib/CodeGen/CGCleanup.cpp
+++ b/clang/lib/CodeGen/CGCleanup.cpp
@@ -309,10 +309,9 @@ static void createStoreInstBefore(llvm::Value *value, 
Address addr,
 
 static llvm::LoadInst *createLoadInstBefore(Address addr, const Twine ,
 llvm::Instruction *beforeInst) {
-  auto load = new llvm::LoadInst(addr.getElementType(), addr.getPointer(), 
name,
- beforeInst);
-  load->setAlignment(addr.getAlignment().getAsAlign());
-  return load;
+  return new llvm::LoadInst(addr.getElementType(), addr.getPointer(), name,
+false, addr.getAlignment().getAsAlign(),
+beforeInst);
 }
 
 /// All the branch fixups on the EH stack have propagated out past the



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


[PATCH] D79945: [Sema] Comparison of pointers to complete and incomplete types

2020-05-14 Thread Benson Chu via Phabricator via cfe-commits
pestctrl updated this revision to Diff 264089.
pestctrl added a comment.

Updated test to also expect a warning along with the newly added error.


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

https://reviews.llvm.org/D79945

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Sema/compare.c


Index: clang/test/Sema/compare.c
===
--- clang/test/Sema/compare.c
+++ clang/test/Sema/compare.c
@@ -405,3 +405,12 @@
   if (x == y) x = y; // no warning
   if (y == x) y = x; // no warning
 }
+
+int incomplete[]; // expected-warning {{tentative array definition assumed to 
have one element}}
+int complete[5];
+
+void test13() {
+  if ( < ) { // expected-error {{ordered comparison of 
complete and incomplete pointers}}
+return;
+  }
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -11426,8 +11426,15 @@
 // C99 6.5.9p2 and C99 6.5.8p2
 if (Context.typesAreCompatible(LCanPointeeTy.getUnqualifiedType(),
RCanPointeeTy.getUnqualifiedType())) {
-  // Valid unless a relational comparison of function pointers
-  if (IsRelational && LCanPointeeTy->isFunctionType()) {
+  // Pointers both need to point to complete or incomplete types
+  if (LCanPointeeTy->isIncompleteType() !=
+  RCanPointeeTy->isIncompleteType()) {
+Diag(Loc,
+ diag::err_typecheck_comparison_of_complete_and_incomplete_types)
+<< LHSType << RHSType << LHS.get()->getSourceRange()
+<< RHS.get()->getSourceRange();
+  } else if (IsRelational && LCanPointeeTy->isFunctionType()) {
+// Valid unless a relational comparison of function pointers
 Diag(Loc, diag::ext_typecheck_ordered_comparison_of_function_pointers)
   << LHSType << RHSType << LHS.get()->getSourceRange()
   << RHS.get()->getSourceRange();
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6461,6 +6461,8 @@
   "ordered comparison between pointer and zero (%0 and %1)">;
 def err_typecheck_three_way_comparison_of_pointer_and_zero : Error<
   "three-way comparison between pointer and zero">;
+def err_typecheck_comparison_of_complete_and_incomplete_types : Error<
+  "ordered comparison of complete and incomplete pointers (%0 and %1)">;
 def ext_typecheck_ordered_comparison_of_function_pointers : ExtWarn<
   "ordered comparison of function pointers (%0 and %1)">,
   InGroup>;


Index: clang/test/Sema/compare.c
===
--- clang/test/Sema/compare.c
+++ clang/test/Sema/compare.c
@@ -405,3 +405,12 @@
   if (x == y) x = y; // no warning
   if (y == x) y = x; // no warning
 }
+
+int incomplete[]; // expected-warning {{tentative array definition assumed to have one element}}
+int complete[5];
+
+void test13() {
+  if ( < ) { // expected-error {{ordered comparison of complete and incomplete pointers}}
+return;
+  }
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -11426,8 +11426,15 @@
 // C99 6.5.9p2 and C99 6.5.8p2
 if (Context.typesAreCompatible(LCanPointeeTy.getUnqualifiedType(),
RCanPointeeTy.getUnqualifiedType())) {
-  // Valid unless a relational comparison of function pointers
-  if (IsRelational && LCanPointeeTy->isFunctionType()) {
+  // Pointers both need to point to complete or incomplete types
+  if (LCanPointeeTy->isIncompleteType() !=
+  RCanPointeeTy->isIncompleteType()) {
+Diag(Loc,
+ diag::err_typecheck_comparison_of_complete_and_incomplete_types)
+<< LHSType << RHSType << LHS.get()->getSourceRange()
+<< RHS.get()->getSourceRange();
+  } else if (IsRelational && LCanPointeeTy->isFunctionType()) {
+// Valid unless a relational comparison of function pointers
 Diag(Loc, diag::ext_typecheck_ordered_comparison_of_function_pointers)
   << LHSType << RHSType << LHS.get()->getSourceRange()
   << RHS.get()->getSourceRange();
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6461,6 +6461,8 @@
   "ordered comparison between pointer and zero (%0 and %1)">;
 def err_typecheck_three_way_comparison_of_pointer_and_zero : Error<
   "three-way comparison between pointer and zero">;
+def 

[PATCH] D76420: Prevent IR-gen from emitting consteval declarations

2020-05-14 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/include/clang/AST/Expr.h:1062
+return ConstantExprBits.APValueKind != APValue::None &&
+   ConstantExprBits.APValueKind != APValue::Indeterminate;
   }

Why do we need to treat indeterminate values specially here? Are we using that 
value inappropriately in `ExprConstant`?



Comment at: clang/lib/AST/ExprConstant.cpp:6807-6808
 
+llvm::SaveAndRestore InConstantContext(Info.InConstantContext, true);
 return StmtVisitorTy::Visit(E->getSubExpr());
   }

I don't think this is really right, but perhaps the difference isn't observable 
right now. What I'm thinking of is a case like this:

```
consteval int do_stuff() {
  __builtin_produce_diagnostic("hello world\n");
  return 42;
}
constexpr int f() {
  int n = do_stuff();
  return n;
}
int k = f();
```

Here, I would expect that when we process the immediate invocation of 
`do_stuff()` in `f`, we would immediately evaluate it, including issuing its 
diagnostic. And then for all subsequent calls to `f()`, we would never 
re-evaluate it.

I can see a couple of ways this could work:

 * Whenever we create a `ConstantExpr`, we always evaluate it and fill in the 
`APValue` result; it's never absent except perhaps in a window of time between 
forming that AST node and deciding for sure that we want to keep it (for nested 
immediate invocation handling).
 * Whenever constant evaluation meets a `ConstantExpr` that doesn't have an 
associated result yet, it triggers that result to be computed and cached, as a 
separate evaluation.

I think the first of those two approaches is much better: lazily evaluating the 
`ConstantExpr` will require us to save update records if we're writing an AST 
file, and will mean we don't always have an obvious point where the 
side-effects from builtin consteval functions (eg, reflection-driven actions) 
happen.

So I think the right thing to do is probably to say that a `ConstantExpr` that 
hasn't yet had its `APValue` result filled in is non-constant for now, and to 
ensure that everywhere that creates a `ConstantExpr` always eventually either 
removes it again or fills in the result.



Comment at: clang/lib/AST/ExprConstant.cpp:10772-10777
 bool IntExprEvaluator::VisitConstantExpr(const ConstantExpr *E) {
   llvm::SaveAndRestore InConstantContext(Info.InConstantContext, true);
-  if (E->getResultAPValueKind() != APValue::None)
+  if (E->hasAPValueResult())
 return Success(E->getAPValueResult(), E);
   return ExprEvaluatorBaseTy::VisitConstantExpr(E);
 }

This override looks equivalent to the base class version. (The only difference 
appears to be whether `IsConstantContext` is set during the call to `Success`, 
but I don't think `Success` cares about that flag.) Can you remove this 
override?



Comment at: clang/lib/CodeGen/CGExprConstant.cpp:1364-1365
+llvm::Constant *ConstantEmitter::tryEmitConstantExpr(const ConstantExpr *CE) {
+  if (!CE->isImmediateInvocation())
+return nullptr;
+  const Expr *Inner = CE->getSubExpr()->IgnoreImplicit();

I'm fine with having this check for now, but eventually I think we should do 
this for all `ConstantExpr`s, regardless of whether they're immediate 
invocations.



Comment at: clang/lib/CodeGen/CGExprConstant.cpp:1374
+  emitAbstract(CE->getBeginLoc(), CE->getAPValueResult(), RetType);
+  return Res;
+}

Can we assert that we succeeded here? This emission should never fail.



Comment at: clang/lib/CodeGen/CGExprScalar.cpp:464-470
+  QualType RetType = cast(E->getSubExpr()->IgnoreImplicit())
+ ->getCallReturnType(CGF.getContext());
+  if (RetType->isReferenceType()) {
+return CGF.Builder.CreateLoad(Address(
+Result, CGF.getContext().getTypeAlignInChars(
+cast(RetType)->getPointeeType(;
+  }

OK, so this is presumably handling the case where `ScalarExprEmitter` is used 
to emit an lvalue expression, under the understanding that when it reaches the 
eventual lvalue a load will be implicitly generated.

Looking for a `CallExpr` that returns a reference type is not the best way to 
handle this. It's brittle (it would break if `tryEmitConstantExpr` starts 
emitting more kinds of `ConstantExpr` or if we start supporting more kinds of 
immediate invocations) and we don't need to perform such a subtle check: 
instead, please just check whether `E` is an lvalue, and perform a load if so.



Comment at: clang/lib/CodeGen/CGStmt.cpp:1095
+  if (const auto *EWC = dyn_cast_or_null(RV)) {
+enterFullExpression(EWC);
+RV = EWC->getSubExpr();

Presumably it's OK to skip this for `ConstantExpr` because by definition the 
`ConstantExpr` node isn't tracking any block cleanups. If that's the case, 
should we rename this 

[PATCH] D79961: [PGO] Fix computation of fuction Hash

2020-05-14 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 264084.
serge-sans-paille added a comment.

Update test case


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79961

Files:
  clang/lib/CodeGen/CodeGenPGO.cpp
  clang/test/Profile/c-collision.c


Index: clang/test/Profile/c-collision.c
===
--- /dev/null
+++ clang/test/Profile/c-collision.c
@@ -0,0 +1,22 @@
+// Test that a slight change in the code leads to a different hash.
+// RUN: %clang_cc1 -UEXTRA -triple x86_64-unknown-linux-gnu -main-file-name 
c-collision.c %s -o - -emit-llvm -fprofile-instrument=clang | FileCheck %s 
--check-prefix=CHECK-NOEXTRA
+// RUN: %clang_cc1 -DEXTRA -triple x86_64-unknown-linux-gnu -main-file-name 
c-collision.c %s -o - -emit-llvm -fprofile-instrument=clang | FileCheck %s 
--check-prefix=CHECK-EXTRA
+
+// CHECK-NOEXTRA: @__profd_foo = private global { {{.*}} } { i64 
6699318081062747564, i64 7156072912471487002,
+// CHECK-EXTRA:   @__profd_foo = private global { {{.*}} } { i64 
6699318081062747564, i64 -4383447408116050035,
+
+extern int bar;
+void foo() {
+  if (bar) {
+  }
+  if (bar) {
+  }
+  if (bar) {
+if (bar) {
+#ifdef EXTRA
+  if (bar) {
+  }
+#endif
+}
+  }
+}
Index: clang/lib/CodeGen/CodeGenPGO.cpp
===
--- clang/lib/CodeGen/CodeGenPGO.cpp
+++ clang/lib/CodeGen/CodeGenPGO.cpp
@@ -747,8 +747,11 @@
 return Working;
 
   // Check for remaining work in Working.
-  if (Working)
-MD5.update(Working);
+  if (Working) {
+using namespace llvm::support;
+uint64_t Swapped = endian::byte_swap(Working);
+MD5.update(llvm::makeArrayRef((uint8_t *), sizeof(Swapped)));
+  }
 
   // Finalize the MD5 and return the hash.
   llvm::MD5::MD5Result Result;


Index: clang/test/Profile/c-collision.c
===
--- /dev/null
+++ clang/test/Profile/c-collision.c
@@ -0,0 +1,22 @@
+// Test that a slight change in the code leads to a different hash.
+// RUN: %clang_cc1 -UEXTRA -triple x86_64-unknown-linux-gnu -main-file-name c-collision.c %s -o - -emit-llvm -fprofile-instrument=clang | FileCheck %s --check-prefix=CHECK-NOEXTRA
+// RUN: %clang_cc1 -DEXTRA -triple x86_64-unknown-linux-gnu -main-file-name c-collision.c %s -o - -emit-llvm -fprofile-instrument=clang | FileCheck %s --check-prefix=CHECK-EXTRA
+
+// CHECK-NOEXTRA: @__profd_foo = private global { {{.*}} } { i64 6699318081062747564, i64 7156072912471487002,
+// CHECK-EXTRA:   @__profd_foo = private global { {{.*}} } { i64 6699318081062747564, i64 -4383447408116050035,
+
+extern int bar;
+void foo() {
+  if (bar) {
+  }
+  if (bar) {
+  }
+  if (bar) {
+if (bar) {
+#ifdef EXTRA
+  if (bar) {
+  }
+#endif
+}
+  }
+}
Index: clang/lib/CodeGen/CodeGenPGO.cpp
===
--- clang/lib/CodeGen/CodeGenPGO.cpp
+++ clang/lib/CodeGen/CodeGenPGO.cpp
@@ -747,8 +747,11 @@
 return Working;
 
   // Check for remaining work in Working.
-  if (Working)
-MD5.update(Working);
+  if (Working) {
+using namespace llvm::support;
+uint64_t Swapped = endian::byte_swap(Working);
+MD5.update(llvm::makeArrayRef((uint8_t *), sizeof(Swapped)));
+  }
 
   // Finalize the MD5 and return the hash.
   llvm::MD5::MD5Result Result;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D79895: Fix warning about using uninitialized variable as function const reference parameter

2020-05-14 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu updated this revision to Diff 264076.
zequanwu added a comment.

Add new warning as subgroup of `Uninitialized`.


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

https://reviews.llvm.org/D79895

Files:
  clang/include/clang/Analysis/Analyses/UninitializedValues.h
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Analysis/UninitializedValues.cpp
  clang/lib/Sema/AnalysisBasedWarnings.cpp
  clang/test/SemaCXX/uninit-variables.cpp
  clang/test/SemaCXX/uninitialized.cpp

Index: clang/test/SemaCXX/uninitialized.cpp
===
--- clang/test/SemaCXX/uninitialized.cpp
+++ clang/test/SemaCXX/uninitialized.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -Wall -Wuninitialized -Wno-unused-value -Wno-unused-lambda-capture -std=c++1z -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wall -Wuninitialized -Wno-unused-value -Wno-unused-lambda-capture -Wno-uninitialized-const-reference -std=c++1z -verify %s
 
 // definitions for std::move
 namespace std {
Index: clang/test/SemaCXX/uninit-variables.cpp
===
--- clang/test/SemaCXX/uninit-variables.cpp
+++ clang/test/SemaCXX/uninit-variables.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -Wuninitialized -fsyntax-only -fcxx-exceptions %s -verify -std=c++1y
+// RUN: %clang_cc1 -fsyntax-only -Wuninitialized -Wno-uninitialized-const-reference -fsyntax-only -fcxx-exceptions %s -verify -std=c++1y
 
 // Stub out types for 'typeid' to work.
 namespace std { class type_info {}; }
Index: clang/lib/Sema/AnalysisBasedWarnings.cpp
===
--- clang/lib/Sema/AnalysisBasedWarnings.cpp
+++ clang/lib/Sema/AnalysisBasedWarnings.cpp
@@ -834,6 +834,10 @@
 // Carry on to report sometimes-uninitialized branches, if possible,
 // or a 'may be used uninitialized' diagnostic otherwise.
 break;
+  case UninitUse::ConstRefUse:
+S.Diag(Use.getUser()->getBeginLoc(), diag::warn_uninit_const_reference)
+<< VD->getDeclName() << Use.getUser()->getSourceRange();
+break;
   }
 
   // Diagnose each branch which leads to a sometimes-uninitialized use.
@@ -1000,8 +1004,11 @@
 
   ContainsReference CR(S.Context, DRE);
   CR.Visit(Initializer);
+  unsigned DiagID = Use.getKind() == UninitUse::ConstRefUse
+? diag::warn_uninit_const_reference
+: diag::warn_uninit_self_reference_in_init;
   if (CR.doesContainReference()) {
-S.Diag(DRE->getBeginLoc(), diag::warn_uninit_self_reference_in_init)
+S.Diag(DRE->getBeginLoc(), DiagID)
 << VD->getDeclName() << VD->getLocation() << DRE->getSourceRange();
 return true;
   }
@@ -1541,7 +1548,7 @@
   if (!vec->empty() && hasSelfInit && hasAlwaysUninitializedUse(vec))
 DiagnoseUninitializedUse(S, vd,
  UninitUse(vd->getInit()->IgnoreParenCasts(),
-   /* isAlwaysUninit */ true),
+   /* isAlwaysUninit */ true, false),
  /* alwaysReportSelfInit */ true);
   else {
 // Sort the uses by their SourceLocations.  While not strictly
@@ -1557,7 +1564,7 @@
 
 for (const auto  : *vec) {
   // If we have self-init, downgrade all uses to 'may be uninitialized'.
-  UninitUse Use = hasSelfInit ? UninitUse(U.getUser(), false) : U;
+  UninitUse Use = hasSelfInit ? UninitUse(U.getUser(), false, false) : U;
 
   if (DiagnoseUninitializedUse(S, vd, Use))
 // Skip further diagnostics for this variable. We try to warn only
@@ -2184,7 +2191,8 @@
 
   if (!Diags.isIgnored(diag::warn_uninit_var, D->getBeginLoc()) ||
   !Diags.isIgnored(diag::warn_sometimes_uninit_var, D->getBeginLoc()) ||
-  !Diags.isIgnored(diag::warn_maybe_uninit_var, D->getBeginLoc())) {
+  !Diags.isIgnored(diag::warn_maybe_uninit_var, D->getBeginLoc()) ||
+  !Diags.isIgnored(diag::warn_uninit_const_reference, D->getBeginLoc())) {
 if (CFG *cfg = AC.getCFG()) {
   UninitValsDiagReporter reporter(S);
   UninitVariablesAnalysisStats stats;
Index: clang/lib/Analysis/UninitializedValues.cpp
===
--- clang/lib/Analysis/UninitializedValues.cpp
+++ clang/lib/Analysis/UninitializedValues.cpp
@@ -268,6 +268,7 @@
 Init,
 Use,
 SelfInit,
+ConstRefUse,
 Ignore
   };
 
@@ -413,14 +414,16 @@
 return;
   }
 
-  // If a value is passed by const pointer or by const reference to a function,
+  // If a value is passed by const pointer to a function,
   // we should not assume that it is initialized by the call, and we
   // conservatively do not assume that it is used.
+  // If a value is passed by const reference to 

[PATCH] D79935: [clang-format] [PR44345] Long namespace closing comment is duplicated endlessly

2020-05-14 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir accepted this revision.
krasimir added a comment.
This revision is now accepted and ready to land.

Awesome! Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79935



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


[PATCH] D79639: [SveEmitter] Builtins for SVE matrix multiply `mmla`.

2020-05-14 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli added inline comments.



Comment at: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_mmla.c:17
+  // CHECK: ret  %[[RET]]
+  return SVE_ACLE_FUNC(svmmla, _s32, , )(x, y, z);
+}

sdesmalen wrote:
> nit: please remove the whitespace between the commas (to make it similar to 
> the other tests)
Done. May I ask the reason why this formatting is preferred? The command `git 
clang-format` prefers the one with spaces... 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79639



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


[PATCH] D79639: [SveEmitter] Builtins for SVE matrix multiply `mmla`.

2020-05-14 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli updated this revision to Diff 264074.
fpetrogalli marked 2 inline comments as done.
fpetrogalli added a comment.

Thank you for the review @sdesmalen!

Francesco


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79639

Files:
  clang/include/clang/Basic/arm_sve.td
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_matmul_fp32.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_matmul_fp64.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_mmla.c
  clang/utils/TableGen/SveEmitter.cpp

Index: clang/utils/TableGen/SveEmitter.cpp
===
--- clang/utils/TableGen/SveEmitter.cpp
+++ clang/utils/TableGen/SveEmitter.cpp
@@ -513,6 +513,11 @@
   case 'q':
 ElementBitwidth /= 4;
 break;
+  case 'b':
+Signed = false;
+Float = false;
+ElementBitwidth /= 4;
+break;
   case 'o':
 ElementBitwidth *= 4;
 break;
Index: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_mmla.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_mmla.c
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_SVE_MATMUL_INT8 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_SVE_MATMUL_INT8 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+
+#include 
+
+#ifdef SVE_OVERLOADED_FORMS
+// A simple used,unused... macro, long enough to represent any SVE builtin.
+#define SVE_ACLE_FUNC(A1, A2_UNUSED, A3, A4_UNUSED) A1##A3
+#else
+#define SVE_ACLE_FUNC(A1, A2, A3, A4) A1##A2##A3##A4
+#endif
+
+svint32_t test_svmmla_s32(svint32_t x, svint8_t y, svint8_t z) {
+  // CHECK-LABEL: test_svmmla_s32
+  // CHECK: %[[RET:.*]] = call  @llvm.aarch64.sve.smmla.nxv4i32( %x,  %y,  %z)
+  // CHECK: ret  %[[RET]]
+  return SVE_ACLE_FUNC(svmmla,_s32,,)(x, y, z);
+}
+
+svuint32_t test_svmmla_u32(svuint32_t x, svuint8_t y, svuint8_t z) {
+  // CHECK-LABEL: test_svmmla_u32
+  // CHECK: %[[RET:.*]] = call  @llvm.aarch64.sve.ummla.nxv4i32( %x,  %y,  %z)
+  // CHECK: ret  %[[RET]]
+  return SVE_ACLE_FUNC(svmmla,_u32,,)(x, y, z);
+}
+
+svint32_t test_svusmmla_s32(svint32_t x, svuint8_t y, svint8_t z) {
+  // CHECK-LABEL: test_svusmmla_s32
+  // CHECK: %[[RET:.*]] = call  @llvm.aarch64.sve.usmmla.nxv4i32( %x,  %y,  %z)
+  // CHECK: ret  %[[RET]]
+  return SVE_ACLE_FUNC(svusmmla,_s32,,)(x, y, z);
+}
Index: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_matmul_fp64.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_matmul_fp64.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_SVE_MATMUL_FP64 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_SVE_MATMUL_FP64 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+
+#include 
+
+#ifdef SVE_OVERLOADED_FORMS
+// A simple used,unused... macro, long enough to represent any SVE builtin.
+#define SVE_ACLE_FUNC(A1, A2_UNUSED, A3, A4_UNUSED) A1##A3
+#else
+#define SVE_ACLE_FUNC(A1, A2, A3, A4) A1##A2##A3##A4
+#endif
+
+svfloat64_t test_svmmla_f64(svfloat64_t x, svfloat64_t y, svfloat64_t z) {
+  // CHECK-LABEL: test_svmmla_f64
+  // CHECK: %[[RET:.*]] = call  @llvm.aarch64.sve.fmmla.nxv2f64( %x,  %y,  %z)
+  // CHECK: ret  %[[RET]]
+  return SVE_ACLE_FUNC(svmmla,_f64,,)(x, y, z);
+}
Index: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_matmul_fp32.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_matmul_fp32.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_SVE_MATMUL_FP32 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SVE -D__ARM_FEATURE_SVE_MATMUL_FP32 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
+
+#include 
+
+#ifdef SVE_OVERLOADED_FORMS
+// A simple used,unused... macro, long enough to represent any SVE builtin.
+#define SVE_ACLE_FUNC(A1, A2_UNUSED, A3, A4_UNUSED) A1##A3
+#else
+#define SVE_ACLE_FUNC(A1, A2, A3, A4) A1##A2##A3##A4
+#endif
+
+svfloat32_t test_svmmla_f32(svfloat32_t x, svfloat32_t y, svfloat32_t z) {
+  // CHECK-LABEL: test_svmmla_f32
+  

[PATCH] D79961: [PGO] Fix computation of fuction Hash

2020-05-14 Thread serge via Phabricator via cfe-commits
serge-sans-paille created this revision.
serge-sans-paille added reviewers: dexonsmith, zturner.
serge-sans-paille added a project: clang.
Herald added a subscriber: cfe-commits.

Previous implementation was incorrectly passing an integer, that got converted
to a pointer, to finalize the hash computation. This led to different functions
having the same hash if they only differ by the remaining statements, which is
incorrect.

Added a new test case that trivially tests that a small function change is
reflected in the hash value.

Not that as this patch fixes the hash computation, it invalidates all hashes
computed before that patch applies, which could be an issue for large build
system that pre-compute the profile data and let client download them as part of
the build process.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79961

Files:
  clang/lib/CodeGen/CodeGenPGO.cpp
  clang/test/Profile/c-collision.c


Index: clang/test/Profile/c-collision.c
===
--- /dev/null
+++ clang/test/Profile/c-collision.c
@@ -0,0 +1,26 @@
+// Test that a slight change in the code leads to a different hash.
+// RUN: %clang_cc1 -UEXTRA -triple x86_64-unknown-linux-gnu -main-file-name 
c-collision.c %s -o - -emit-llvm -fprofile-instrument=llvm | FileCheck %s 
--check-prefix=CHECK-NOEXTRA
+// RUN: %clang_cc1 -DEXTRA -triple x86_64-unknown-linux-gnu -main-file-name 
c-collision.c %s -o - -emit-llvm -fprofile-instrument=llvm | FileCheck %s 
--check-prefix=CHECK-EXTRA
+
+// CHECK-NOEXTRA: @__profd_main = private global { {{.*}} } { i64 
-2624081020897602054, i64 88870893692,
+// CHECK-EXTRA:   @__profd_main = private global { {{.*}} } { i64 
-2624081020897602054, i64 101970072141,
+
+int main(int n, char **v) {
+  if (n)
+n += 1;
+  if (n)
+n += 1;
+  if (n)
+n += 1;
+  if (n)
+n += 1;
+  if (n)
+n += 1;
+  if (n)
+n += 1;
+#ifdef EXTRA
+  if (n)
+n += 1;
+#endif
+  return n;
+}
Index: clang/lib/CodeGen/CodeGenPGO.cpp
===
--- clang/lib/CodeGen/CodeGenPGO.cpp
+++ clang/lib/CodeGen/CodeGenPGO.cpp
@@ -747,8 +747,11 @@
 return Working;
 
   // Check for remaining work in Working.
-  if (Working)
-MD5.update(Working);
+  if (Working) {
+using namespace llvm::support;
+uint64_t Swapped = endian::byte_swap(Working);
+MD5.update(llvm::makeArrayRef((uint8_t *), sizeof(Swapped)));
+  }
 
   // Finalize the MD5 and return the hash.
   llvm::MD5::MD5Result Result;


Index: clang/test/Profile/c-collision.c
===
--- /dev/null
+++ clang/test/Profile/c-collision.c
@@ -0,0 +1,26 @@
+// Test that a slight change in the code leads to a different hash.
+// RUN: %clang_cc1 -UEXTRA -triple x86_64-unknown-linux-gnu -main-file-name c-collision.c %s -o - -emit-llvm -fprofile-instrument=llvm | FileCheck %s --check-prefix=CHECK-NOEXTRA
+// RUN: %clang_cc1 -DEXTRA -triple x86_64-unknown-linux-gnu -main-file-name c-collision.c %s -o - -emit-llvm -fprofile-instrument=llvm | FileCheck %s --check-prefix=CHECK-EXTRA
+
+// CHECK-NOEXTRA: @__profd_main = private global { {{.*}} } { i64 -2624081020897602054, i64 88870893692,
+// CHECK-EXTRA:   @__profd_main = private global { {{.*}} } { i64 -2624081020897602054, i64 101970072141,
+
+int main(int n, char **v) {
+  if (n)
+n += 1;
+  if (n)
+n += 1;
+  if (n)
+n += 1;
+  if (n)
+n += 1;
+  if (n)
+n += 1;
+  if (n)
+n += 1;
+#ifdef EXTRA
+  if (n)
+n += 1;
+#endif
+  return n;
+}
Index: clang/lib/CodeGen/CodeGenPGO.cpp
===
--- clang/lib/CodeGen/CodeGenPGO.cpp
+++ clang/lib/CodeGen/CodeGenPGO.cpp
@@ -747,8 +747,11 @@
 return Working;
 
   // Check for remaining work in Working.
-  if (Working)
-MD5.update(Working);
+  if (Working) {
+using namespace llvm::support;
+uint64_t Swapped = endian::byte_swap(Working);
+MD5.update(llvm::makeArrayRef((uint8_t *), sizeof(Swapped)));
+  }
 
   // Finalize the MD5 and return the hash.
   llvm::MD5::MD5Result Result;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D74813: Function block naming - add hash of parameter type to end of block name

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

In D74813#2036966 , @alexbdv wrote:

> @dexonsmith - Are you OK with that ?


SGTM.  I suggest @erik.pilkington lands the demangler patch before landing this 
so there isn't a window where we mangle something that can't be demangled.


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

https://reviews.llvm.org/D74813



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


[PATCH] D79834: Speed up preamble building by replacing the slow translateFile call by a new, faster isMainFile check

2020-05-14 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added inline comments.



Comment at: clang/lib/Basic/SourceManager.cpp:397
+return false;
+  return FE->getUID() == SourceFile.getUID();
+}

arphaman wrote:
> jkorous wrote:
> > I don't really understand all the details here but shouldn't we use this 
> > comparison?
> > ```
> > bool operator==(const FileEntryRef , const FileEntryRef )
> > ```
> The `==` comparison can return false for symlinks due to the different name, 
> but we want to return true for symlinks to the main file as well. 
I suggest adding a comment to the code explaining this when you land it, 
something like:

// Compare UIDs directly so that symlinks compare equal.


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

https://reviews.llvm.org/D79834



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


[PATCH] D79834: Speed up preamble building by replacing the slow translateFile call by a new, faster isMainFile check

2020-05-14 Thread Jan Korous via Phabricator via cfe-commits
jkorous accepted this revision.
jkorous added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks Alex!


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

https://reviews.llvm.org/D79834



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


[PATCH] D72100: Allow matching "any file" in `VerifyDiagnosticConsumer`.

2020-05-14 Thread Jan Korous via Phabricator via cfe-commits
jkorous accepted this revision.
jkorous added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks for the work!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72100



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


[PATCH] D79704: [Analyzer] [NFC] Parameter Regions

2020-05-14 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

In D79704#2036581 , @Szelethus wrote:

> If something tricky like this came up, the `getDecl` function should just 
> return with a nullptr, shouldn't it?


How far are you willing to push it? For instance, are you ok with, say, 
`TypedValueRegion::getValueType()` return a null `QualType` in this single rare 
cornercase? Because that's what we'll also have to do if a `Decl` isn't 
available in `VarRegion`. Unless we add more stuff into `VarRegion`, which is 
basically what we're doing (and it just suddenly turns out that we don't need 
the `Decl` anymore).

> The code changes make me feel like we're doing a lot of chore (and make it 
> super easy to forget checking for parameters explicitly).

I wouldn't mind having a common base class for these regions. `DeclRegion` 
should probably be dropped in this case, in order to avoid dealing with 
multiple inheritance. And it's definitely the one that needs to be dropped 
because it currently does nothing except "inheritance for code reuse": there 
are basically no other common properties between its sub-classes than the 
accidental code reuse in its methods.

> The gain, which is I guess correctness, seems negligible, and I'm not sure 
> this is actually correct, as I mentioned in D79704#inline-730731 
> .

The gain is that we finally have a way to express some regions that we 
previously could not express at all. This gain isn't huge; i agree that 
@baloghadamsoftware could most likely get away without it. Apart from the 
example with no decl at all, i'm pretty excited about eliminating a lot of 
annoying ambiguities with respect to virtual method calls and function 
redeclarations that i've been struggling in D49443 
.

More importantly, this change is correct because that's how programs actually 
behave. You don't need to know everything (and a `Decl` is literally 
everything) about the function you're calling in order to call it. The calling 
convention only requires you to put arguments into certain places in memory and 
these places are entirely determined by the indices and types of the arguments. 
And that's exactly what we're trying to mimic. We technically don't even need 
the `OriginExpr` itself but it's a convenient (and so far seemingly harmless) 
way of capturing all the information that we actually need (which is, well, 
indices and types of arguments).




Comment at: clang/lib/StaticAnalyzer/Core/MemRegion.cpp:191
+const ParmVarDecl *ParamRegion::getDecl() const {
+  const Decl *D = getStackFrame()->getDecl();
+

baloghadamsoftware wrote:
> NoQ wrote:
> > baloghadamsoftware wrote:
> > > NoQ wrote:
> > > > This doesn't work when the callee is unknown.
> > > Please give me an example where the callee is unknown. As I wrote, 
> > > originally I put a `getExpr()` method here as well and `getType()` fell 
> > > back to it if it could not find the `Decl()`. However, it was never 
> > > invoked on the whole test suite. (I put an `assert(false)` into it, and 
> > > did not get a crash.
> > > Please give me an example where the callee is unknown.
> > 
> > >>! In D79704#2034571, @NoQ wrote:
> > >>>! In D79704#2032947, @Szelethus wrote:
> > >> Could you give a specific code example? 
> > > 
> > > ```lang=c++
> > > struct S {
> > >   S() {
> > > this; // What region does 'this' point to...
> > >   }
> > > };
> > > 
> > > void foo(void (*bar)(S)) {
> > >   bar(S()); // ...in this invocation?
> > > }
> > > ```
> OK, but it still does not crash the analyzer, even if I enable creation of 
> stack frames for all the callees, even for those without definition. What 
> else should I do to enforce the crash (null pointer dereference)? Try to use 
> `getParameterLocation()` in a unit test?
Yes. I demonstrated how you can get the region without a decl but you should 
turn this into a test that actually calls one of the problematic functions. 
Like, `clang_analyzer_dump()` it or something.


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

https://reviews.llvm.org/D79704



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


[PATCH] D77572: [clang-tidy] add new check readability-use-anyofallof

2020-05-14 Thread Matthias Gehre via Phabricator via cfe-commits
mgehre added a comment.

Ping :-)
I'm looking for directions on what the next steps are.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77572



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


[PATCH] D79511: [ObjC] Add compatibility mode for type checking of qualified id block parameters.

2020-05-14 Thread Volodymyr Sapsai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6a3469f58d0c: [ObjC] Add compatibility mode for type 
checking of qualified id block… (authored by vsapsai).

Changed prior to commit:
  https://reviews.llvm.org/D79511?vs=263865=264058#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79511

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/CC1Options.td
  clang/lib/AST/ASTContext.cpp
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/darwin-objc-options.m
  clang/test/SemaObjC/block-type-safety.m

Index: clang/test/SemaObjC/block-type-safety.m
===
--- clang/test/SemaObjC/block-type-safety.m
+++ clang/test/SemaObjC/block-type-safety.m
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -fblocks -Wno-objc-root-class %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fblocks -Wno-objc-root-class \
+// RUN:   -fcompatibility-qualified-id-block-type-checking -DCOMPATIBILITY_QUALIFIED_ID_TYPE_CHECKING=1 %s
 // test for block type safety.
 
 @interface Super  @end
@@ -132,6 +134,7 @@
 @interface NSAllArray (FooConformance) 
 @end
 
+#ifndef COMPATIBILITY_QUALIFIED_ID_TYPE_CHECKING
 int test5() {
 // Returned value is used outside of a block, so error on changing
 // a return type to a more general than expected.
@@ -149,6 +152,25 @@
 blockWithParam = genericBlockWithParam;
 return 0;
 }
+#else
+// In Apple SDK APIs using NSItemProviderCompletionHandler require to work with
+// blocks that have parameters more specific than in method signatures. As
+// explained in non-compatibility test above, it is not safe in general. But
+// to keep existing code working we support a compatibility mode that uses
+// previous type checking.
+int test5() {
+NSAllArray *(^block)(id);
+id  (^genericBlock)(id);
+genericBlock = block;
+block = genericBlock; // expected-error {{incompatible block pointer types assigning to 'NSAllArray *(^)(id)' from 'id (^)(id)'}}
+
+void (^blockWithParam)(NSAllArray *);
+void (^genericBlockWithParam)(id);
+genericBlockWithParam = blockWithParam;
+blockWithParam = genericBlockWithParam;
+return 0;
+}
+#endif
 
 // rdar://10798770
 typedef int NSInteger;
Index: clang/test/Driver/darwin-objc-options.m
===
--- clang/test/Driver/darwin-objc-options.m
+++ clang/test/Driver/darwin-objc-options.m
@@ -40,3 +40,9 @@
 
 // Don't crash with an unexpected target triple.
 // RUN: %clang -target i386-apple-ios7 -S -### %s
+
+// Add -fcompatibility-qualified-id-block-type-checking only on Darwin.
+// RUN: %clang -target x86_64-apple-darwin10 -### %s 2>&1 | FileCheck --check-prefix=DARWIN_COMPATIBILITY %s
+// RUN: %clang -target x86_64-linux-gnu -### %s 2>&1 | FileCheck --check-prefix=OTHER_COMPATIBILITY %s
+// DARWIN_COMPATIBILITY: -fcompatibility-qualified-id-block-type-checking
+// OTHER_COMPATIBILITY-NOT: -fcompatibility-qualified-id-block-type-checking
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3381,6 +3381,9 @@
 
   Opts.BranchTargetEnforcement = Args.hasArg(OPT_mbranch_target_enforce);
   Opts.SpeculativeLoadHardening = Args.hasArg(OPT_mspeculative_load_hardening);
+
+  Opts.CompatibilityQualifiedIdBlockParamTypeChecking =
+  Args.hasArg(OPT_fcompatibility_qualified_id_block_param_type_checking);
 }
 
 static bool isStrictlyPreprocessorAction(frontend::ActionKind Action) {
Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -2376,6 +2376,10 @@
 OS << "-target-sdk-version=" << SDKInfo->getVersion();
 CC1Args.push_back(DriverArgs.MakeArgString(OS.str()));
   }
+
+  // Enable compatibility mode for NSItemProviderCompletionHandler in
+  // Foundation/NSItemProvider.h.
+  CC1Args.push_back("-fcompatibility-qualified-id-block-type-checking");
 }
 
 DerivedArgList *
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -8599,10 +8599,18 @@
   RHSOPT->isObjCQualifiedIdType());
   }
 
-  if (LHSOPT->isObjCQualifiedIdType() || RHSOPT->isObjCQualifiedIdType())
-return finish(ObjCQualifiedIdTypesAreCompatible(
-(BlockReturnType ? LHSOPT : RHSOPT),
-(BlockReturnType ? RHSOPT : LHSOPT), false));
+  if (LHSOPT->isObjCQualifiedIdType() || RHSOPT->isObjCQualifiedIdType()) {
+if (getLangOpts().CompatibilityQualifiedIdBlockParamTypeChecking)
+  // Use 

[PATCH] D79830: Add support of __builtin_expect_with_probability

2020-05-14 Thread Zhi Zhuang via Phabricator via cfe-commits
LukeZhuang added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:1805
+const Expr *ProbArg = TheCall->getArg(2);
+if (ProbArg->EvaluateAsFloat(Confidence, Context)) {
+  double P = Confidence.convertToDouble();

LukeZhuang wrote:
> rsmith wrote:
> > What rules should be applied here? Do we just want to allow anything that 
> > we can evaluate (which might change over time), or do we want to use the 
> > underlying language's notion of floating-point constant expressions, if it 
> > has them?
> Thank you for commenting. I just read the llvm::Expr document and found that 
> it just have `isIntegerConstantExpr` without a float-point version. Under 
> `EvaluateAsFloat` it says "Return true if this is a constant which we can 
> fold and convert to a floating point value", thus I use this function. Is 
> there any better function to achieve this goal?
Hi, and I didn't find other builtin functions ever handle case like this, is 
there any example I could refer to?


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

https://reviews.llvm.org/D79830



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


[PATCH] D79511: [ObjC] Add compatibility mode for type checking of qualified id block parameters.

2020-05-14 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

Thanks everyone for reviews.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79511



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


[PATCH] D72100: Allow matching "any file" in `VerifyDiagnosticConsumer`.

2020-05-14 Thread Alexandre Rames via Phabricator via cfe-commits
arames updated this revision to Diff 264048.
arames edited the summary of this revision.
arames added a comment.

Rebase on top of tree.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72100

Files:
  clang/include/clang/Frontend/VerifyDiagnosticConsumer.h
  clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
  clang/test/Frontend/verify-any-file.c
  clang/test/Frontend/verify-any-file.h

Index: clang/test/Frontend/verify-any-file.h
===
--- /dev/null
+++ clang/test/Frontend/verify-any-file.h
@@ -0,0 +1 @@
+unexpected var;
Index: clang/test/Frontend/verify-any-file.c
===
--- /dev/null
+++ clang/test/Frontend/verify-any-file.c
@@ -0,0 +1,14 @@
+// RUN: not %clang_cc1 -verify %s 2>&1 | FileCheck %s
+
+#include "verify-any-file.h"
+// expected-error@*:* {{unknown type name 'unexpected'}}
+
+// expected-error@*:* {{missing error}}
+
+// expected-error@*:123 {{invalid line : "*" required}}
+//
+//  CHECK: error: 'error' diagnostics expected but not seen:
+// CHECK-NEXT:   File * Line * (directive at {{.*}}verify-any-file.c:6): missing error
+// CHECK-NEXT: error: 'error' diagnostics seen but not expected:
+// CHECK-NEXT:   File {{.*}}verify-any-file.c Line 8: missing or invalid line number following '@' in expected '*'
+// CHECK-NEXT: 2 errors generated.
Index: clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
===
--- clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
+++ clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
@@ -89,9 +89,10 @@
 class StandardDirective : public Directive {
 public:
   StandardDirective(SourceLocation DirectiveLoc, SourceLocation DiagnosticLoc,
-bool MatchAnyLine, StringRef Text, unsigned Min,
-unsigned Max)
-  : Directive(DirectiveLoc, DiagnosticLoc, MatchAnyLine, Text, Min, Max) {}
+bool MatchAnyFileAndLine, bool MatchAnyLine, StringRef Text,
+unsigned Min, unsigned Max)
+  : Directive(DirectiveLoc, DiagnosticLoc, MatchAnyFileAndLine,
+  MatchAnyLine, Text, Min, Max) {}
 
   bool isValid(std::string ) override {
 // all strings are considered valid; even empty ones
@@ -107,9 +108,10 @@
 class RegexDirective : public Directive {
 public:
   RegexDirective(SourceLocation DirectiveLoc, SourceLocation DiagnosticLoc,
- bool MatchAnyLine, StringRef Text, unsigned Min, unsigned Max,
- StringRef RegexStr)
-  : Directive(DirectiveLoc, DiagnosticLoc, MatchAnyLine, Text, Min, Max),
+ bool MatchAnyFileAndLine, bool MatchAnyLine, StringRef Text,
+ unsigned Min, unsigned Max, StringRef RegexStr)
+  : Directive(DirectiveLoc, DiagnosticLoc, MatchAnyFileAndLine,
+  MatchAnyLine, Text, Min, Max),
 Regex(RegexStr) {}
 
   bool isValid(std::string ) override {
@@ -294,11 +296,13 @@
 // Attach the specified directive to the line of code indicated by
 // \p ExpectedLoc.
 void attachDirective(DiagnosticsEngine , const UnattachedDirective ,
- SourceLocation ExpectedLoc, bool MatchAnyLine = false) {
+ SourceLocation ExpectedLoc,
+ bool MatchAnyFileAndLine = false,
+ bool MatchAnyLine = false) {
   // Construct new directive.
-  std::unique_ptr D =
-  Directive::create(UD.RegexKind, UD.DirectivePos, ExpectedLoc,
-MatchAnyLine, UD.Text, UD.Min, UD.Max);
+  std::unique_ptr D = Directive::create(
+  UD.RegexKind, UD.DirectivePos, ExpectedLoc, MatchAnyFileAndLine,
+  MatchAnyLine, UD.Text, UD.Min, UD.Max);
 
   std::string Error;
   if (!D->isValid(Error)) {
@@ -498,6 +502,7 @@
 // Next optional token: @
 SourceLocation ExpectedLoc;
 StringRef Marker;
+bool MatchAnyFileAndLine = false;
 bool MatchAnyLine = false;
 if (!PH.Next("@")) {
   ExpectedLoc = Pos;
@@ -526,26 +531,39 @@
 StringRef Filename(PH.C, PH.P-PH.C);
 PH.Advance();
 
-// Lookup file via Preprocessor, like a #include.
-const DirectoryLookup *CurDir;
-Optional File =
-PP->LookupFile(Pos, Filename, false, nullptr, nullptr, CurDir,
-   nullptr, nullptr, nullptr, nullptr, nullptr);
-if (!File) {
-  Diags.Report(Pos.getLocWithOffset(PH.C-PH.Begin),
-   diag::err_verify_missing_file) << Filename << KindStr;
-  continue;
-}
-
-const FileEntry *FE = >getFileEntry();
-if (SM.translateFile(FE).isInvalid())
-  SM.createFileID(FE, Pos, SrcMgr::C_User);
-
-if (PH.Next(Line) && Line > 0)
-  ExpectedLoc = SM.translateFileLineCol(FE, Line, 1);
-else if (PH.Next("*")) {
+if 

[clang] 6a3469f - [ObjC] Add compatibility mode for type checking of qualified id block parameters.

2020-05-14 Thread Volodymyr Sapsai via cfe-commits

Author: Volodymyr Sapsai
Date: 2020-05-14T12:08:19-07:00
New Revision: 6a3469f58d0c230e86043f6975f048968334dfa4

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

LOG: [ObjC] Add compatibility mode for type checking of qualified id block 
parameters.

Commit 73152a2ec20766ac45673a129bf1f5fc97ca9bbe fixed type checking for
blocks with qualified id parameters. But there are existing APIs in
Apple SDKs relying on the old type checking behavior. Specifically,
these are APIs using NSItemProviderCompletionHandler in
Foundation/NSItemProvider.h. To keep existing code working and to allow
developers to use affected APIs introduce a compatibility mode that
enables the previous and the fixed type checking. This mode is enabled
only on Darwin platforms.

Reviewed By: jyknight, ahatanak

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

Added: 


Modified: 
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Driver/CC1Options.td
clang/lib/AST/ASTContext.cpp
clang/lib/Driver/ToolChains/Darwin.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/Driver/darwin-objc-options.m
clang/test/SemaObjC/block-type-safety.m

Removed: 




diff  --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index c582a58e731f..e94305da46ba 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -278,6 +278,9 @@ LANGOPT(ObjCAutoRefCount , 1, 0, "Objective-C automated 
reference counting")
 LANGOPT(ObjCWeakRuntime , 1, 0, "__weak support in the ARC runtime")
 LANGOPT(ObjCWeak, 1, 0, "Objective-C __weak in ARC and MRC files")
 LANGOPT(ObjCSubscriptingLegacyRuntime , 1, 0, "Subscripting support in 
legacy ObjectiveC runtime")
+BENIGN_LANGOPT(CompatibilityQualifiedIdBlockParamTypeChecking, 1, 0,
+   "compatibility mode for type checking block parameters "
+   "involving qualified id types")
 LANGOPT(CFProtectionBranch , 1, 0, "Control-Flow Branch Protection enabled")
 LANGOPT(FakeAddressSpaceMap , 1, 0, "OpenCL fake address space map")
 ENUM_LANGOPT(AddressSpaceMapMangling , AddrSpaceMapMangling, 2, ASMM_Target, 
"OpenCL address space map mangling mode")

diff  --git a/clang/include/clang/Driver/CC1Options.td 
b/clang/include/clang/Driver/CC1Options.td
index 526a51085ce7..9d2bfbf949ef 100644
--- a/clang/include/clang/Driver/CC1Options.td
+++ b/clang/include/clang/Driver/CC1Options.td
@@ -813,6 +813,9 @@ def fsigned_wchar : Flag<["-"], "fsigned-wchar">,
   HelpText<"Use a signed type for wchar_t">;
 def fno_signed_wchar : Flag<["-"], "fno-signed-wchar">,
   HelpText<"Use an unsigned type for wchar_t">;
+def fcompatibility_qualified_id_block_param_type_checking : Flag<["-"], 
"fcompatibility-qualified-id-block-type-checking">,
+  HelpText<"Allow using blocks with parameters of more specific type than "
+   "the type system guarantees when a parameter is qualified id">;
 
 // FIXME: Remove these entirely once functionality/tests have been excised.
 def fobjc_gc_only : Flag<["-"], "fobjc-gc-only">, Group,

diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 8f3858126253..c457a5537168 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -8599,10 +8599,18 @@ bool ASTContext::canAssignObjCInterfacesInBlockPointer(
   RHSOPT->isObjCQualifiedIdType());
   }
 
-  if (LHSOPT->isObjCQualifiedIdType() || RHSOPT->isObjCQualifiedIdType())
-return finish(ObjCQualifiedIdTypesAreCompatible(
-(BlockReturnType ? LHSOPT : RHSOPT),
-(BlockReturnType ? RHSOPT : LHSOPT), false));
+  if (LHSOPT->isObjCQualifiedIdType() || RHSOPT->isObjCQualifiedIdType()) {
+if (getLangOpts().CompatibilityQualifiedIdBlockParamTypeChecking)
+  // Use for block parameters previous type checking for compatibility.
+  return finish(ObjCQualifiedIdTypesAreCompatible(LHSOPT, RHSOPT, false) ||
+// Or corrected type checking as in non-compat mode.
+(!BlockReturnType &&
+ ObjCQualifiedIdTypesAreCompatible(RHSOPT, LHSOPT, 
false)));
+else
+  return finish(ObjCQualifiedIdTypesAreCompatible(
+  (BlockReturnType ? LHSOPT : RHSOPT),
+  (BlockReturnType ? RHSOPT : LHSOPT), false));
+  }
 
   const ObjCInterfaceType* LHS = LHSOPT->getInterfaceType();
   const ObjCInterfaceType* RHS = RHSOPT->getInterfaceType();

diff  --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index f6e93eecb460..3bf7f9cbc139 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -2376,6 +2376,10 @@ void Darwin::addClangTargetOptions(const 

[PATCH] D74813: Function block naming - add hash of parameter type to end of block name

2020-05-14 Thread Alex Borcan via Phabricator via cfe-commits
alexbdv added a comment.

@dexonsmith - Are you OK with that ?


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

https://reviews.llvm.org/D74813



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


[PATCH] D79834: Speed up preamble building by replacing the slow translateFile call by a new, faster isMainFile check

2020-05-14 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman marked an inline comment as done.
arphaman added inline comments.



Comment at: clang/lib/Basic/SourceManager.cpp:397
+return false;
+  return FE->getUID() == SourceFile.getUID();
+}

jkorous wrote:
> I don't really understand all the details here but shouldn't we use this 
> comparison?
> ```
> bool operator==(const FileEntryRef , const FileEntryRef )
> ```
The `==` comparison can return false for symlinks due to the different name, 
but we want to return true for symlinks to the main file as well. 


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

https://reviews.llvm.org/D79834



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


[PATCH] D79834: Speed up preamble building by replacing the slow translateFile call by a new, faster isMainFile check

2020-05-14 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman updated this revision to Diff 264044.
arphaman added a comment.

Added test and a comment.


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

https://reviews.llvm.org/D79834

Files:
  clang/include/clang/Basic/SourceManager.h
  clang/lib/Basic/SourceManager.cpp
  clang/lib/Lex/PPDirectives.cpp
  clang/unittests/Basic/SourceManagerTest.cpp


Index: clang/unittests/Basic/SourceManagerTest.cpp
===
--- clang/unittests/Basic/SourceManagerTest.cpp
+++ clang/unittests/Basic/SourceManagerTest.cpp
@@ -491,6 +491,30 @@
   EXPECT_TRUE(SourceMgr.isBeforeInTranslationUnit(Macros[10].Loc, 
Macros[11].Loc));
 }
 
+TEST_F(SourceManagerTest, isMainFile) {
+  const char *Source = "int x;";
+
+  std::unique_ptr Buf =
+  llvm::MemoryBuffer::getMemBuffer(Source);
+  const FileEntry *SourceFile =
+  FileMgr.getVirtualFile("mainFile.cpp", Buf->getBufferSize(), 0);
+  SourceMgr.overrideFileContents(SourceFile, std::move(Buf));
+
+  std::unique_ptr Buf2 =
+  llvm::MemoryBuffer::getMemBuffer(Source);
+  const FileEntry *SecondFile =
+  FileMgr.getVirtualFile("file2.cpp", Buf2->getBufferSize(), 0);
+  SourceMgr.overrideFileContents(SecondFile, std::move(Buf2));
+
+  FileID MainFileID = SourceMgr.getOrCreateFileID(SourceFile, SrcMgr::C_User);
+  SourceMgr.setMainFileID(MainFileID);
+
+  EXPECT_TRUE(SourceMgr.isMainFile(FileEntryRef("mainFile.cpp", *SourceFile)));
+  EXPECT_TRUE(
+  SourceMgr.isMainFile(FileEntryRef("anotherName.cpp", *SourceFile)));
+  EXPECT_FALSE(SourceMgr.isMainFile(FileEntryRef("mainFile.cpp", 
*SecondFile)));
+}
+
 #endif
 
 } // anonymous namespace
Index: clang/lib/Lex/PPDirectives.cpp
===
--- clang/lib/Lex/PPDirectives.cpp
+++ clang/lib/Lex/PPDirectives.cpp
@@ -2054,8 +2054,7 @@
   // some directives (e.g. #endif of a header guard) will never be seen.
   // Since this will lead to confusing errors, avoid the inclusion.
   if (Action == Enter && File && PreambleConditionalStack.isRecording() &&
-  SourceMgr.translateFile(>getFileEntry()) ==
-  SourceMgr.getMainFileID()) {
+  SourceMgr.isMainFile(*File)) {
 Diag(FilenameTok.getLocation(),
  diag::err_pp_including_mainfile_in_preamble);
 return {ImportAction::None};
Index: clang/lib/Basic/SourceManager.cpp
===
--- clang/lib/Basic/SourceManager.cpp
+++ clang/lib/Basic/SourceManager.cpp
@@ -389,6 +389,14 @@
   createExpansionLoc(SourceLocation(), SourceLocation(), SourceLocation(), 1);
 }
 
+bool SourceManager::isMainFile(FileEntryRef SourceFile) {
+  assert(MainFileID.isValid() && "expected initialized SourceManager");
+  auto FE = getFileEntryRefForID(MainFileID);
+  if (!FE)
+return false;
+  return FE->getUID() == SourceFile.getUID();
+}
+
 void SourceManager::initializeForReplay(const SourceManager ) {
   assert(MainFileID.isInvalid() && "expected uninitialized SourceManager");
 
Index: clang/include/clang/Basic/SourceManager.h
===
--- clang/include/clang/Basic/SourceManager.h
+++ clang/include/clang/Basic/SourceManager.h
@@ -813,6 +813,11 @@
 MainFileID = FID;
   }
 
+  /// Returns true when the given FileEntry corresponds to the main file.
+  ///
+  /// The main file should be set prior to calling this function.
+  bool isMainFile(FileEntryRef SourceFile);
+
   /// Set the file ID for the precompiled preamble.
   void setPreambleFileID(FileID Preamble) {
 assert(PreambleFileID.isInvalid() && "PreambleFileID already set!");


Index: clang/unittests/Basic/SourceManagerTest.cpp
===
--- clang/unittests/Basic/SourceManagerTest.cpp
+++ clang/unittests/Basic/SourceManagerTest.cpp
@@ -491,6 +491,30 @@
   EXPECT_TRUE(SourceMgr.isBeforeInTranslationUnit(Macros[10].Loc, Macros[11].Loc));
 }
 
+TEST_F(SourceManagerTest, isMainFile) {
+  const char *Source = "int x;";
+
+  std::unique_ptr Buf =
+  llvm::MemoryBuffer::getMemBuffer(Source);
+  const FileEntry *SourceFile =
+  FileMgr.getVirtualFile("mainFile.cpp", Buf->getBufferSize(), 0);
+  SourceMgr.overrideFileContents(SourceFile, std::move(Buf));
+
+  std::unique_ptr Buf2 =
+  llvm::MemoryBuffer::getMemBuffer(Source);
+  const FileEntry *SecondFile =
+  FileMgr.getVirtualFile("file2.cpp", Buf2->getBufferSize(), 0);
+  SourceMgr.overrideFileContents(SecondFile, std::move(Buf2));
+
+  FileID MainFileID = SourceMgr.getOrCreateFileID(SourceFile, SrcMgr::C_User);
+  SourceMgr.setMainFileID(MainFileID);
+
+  EXPECT_TRUE(SourceMgr.isMainFile(FileEntryRef("mainFile.cpp", *SourceFile)));
+  EXPECT_TRUE(
+  SourceMgr.isMainFile(FileEntryRef("anotherName.cpp", *SourceFile)));
+  EXPECT_FALSE(SourceMgr.isMainFile(FileEntryRef("mainFile.cpp", *SecondFile)));
+}
+
 #endif
 
 } // anonymous namespace
Index: 

[PATCH] D79903: FastMathFlags.allowContract should be init from FPFeatures.allowFPContractAcrossStatement

2020-05-14 Thread Melanie Blower via Phabricator via cfe-commits
mibintc marked an inline comment as done.
mibintc added a comment.

reply about the incorrect setting of 'fast' during OpenCL compilation with 
option -cl-fast-relaxed-math




Comment at: clang/lib/Frontend/CompilerInvocation.cpp:2943
+  if (Opts.FastRelaxedMath)
+Opts.setDefaultFPContractMode(LangOptions::FPM_Fast);
   Opts.HexagonQdsp6Compat = Args.hasArg(OPT_mqdsp6_compat);

mibintc wrote:
> rjmccall wrote:
> > mibintc wrote:
> > > rjmccall wrote:
> > > > mibintc wrote:
> > > > > I changed this because the FAST version of this test 
> > > > > clang/test/CodeGenOpenCL/relaxed-fpmath.cl wants the 'fast' attribute 
> > > > > on the instruction dump.  All the LLVM FMF bits must be set for the 
> > > > > fast attribute print.  By default, the value for OpenCL is 
> > > > > ffp-contract=on
> > > > Is there an overall behavior change for OpenCL across these patches?
> > > I think the answer to your question is no.  Here is more details: OpenCL 
> > > sets the default behavior to ffp-contract=on.  In 
> > > https://reviews.llvm.org/D72841 I added the function UpdateFastMathFlags, 
> > > that function set the llvm FMF.allowContract bit to be ( ffp-contract=on 
> > > or ffp-contract=fast).  This patch just drops the check on 
> > > ffp-contract=on.   I didn't wind back to see how the llvm fast attribute 
> > > was being set for this [opencl] test case originally. 
> > Well, to what extent are there (including this patch) overall test changes 
> > for the OpenCL tests, and what are tthey?
> In the #pragma float_control patch https://reviews.llvm.org/D72841, I changed 
> 2 CodeGen/OpenCL tests: relaxed-fp-math.cl in the non-FAST cases to show the 
> contract bit.  Also 1 line in single-precision-constant.cl for the same 
> reason, to show the contract bit.  This patch undoes those test changes. I'll 
> do more investigation to understand why the fast bit isn't being set in the 
> FAST case in relaxed-fpmath.cl without the change to CompilerInovcaton
Prior to the patch for #pragma float_control, the llvm.FastMathFlags was 
initialized from LangArgs.FastMath in the CodeGenFunction constructor 
approximately line 74, and the FMF values in IRBuilder were never changed--For 
the test clang/test/CodeGenOpenCL/relaxed-fpmath.cl with option 
-cl-fast-relaxed-math.  (In ParseLangArgs,  Opts.FastMath = 
Args.hasArg(OPT_ffast_math) ||  Args.hasArg(OPT_cl_fast_relaxed_math))  If 
FastMath is on, then all the llvm.FMF flags are set.

The #pragma float_control patch does change the IRBuilder settings in the 
course of visiting the Expr nodes, using the information in the Expr nodes, but 
the initial setting of FPFeatures from the command line overlooked the fact 
that FastMath, and therefore ffp-contract=fast, is enabled. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79903



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


[PATCH] D79743: [clang][asm goto][slh] Warn if asm goto + SLH

2020-05-14 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 added a comment.

I don’t know what consequences is of using asm goto under SLH.

In general, if asm-goto is not allowed, the diagnostic should be emitted during 
the parser.  If asm-goto is not allowed under specified condition, the 
diagnostic should be emitted during sema.  Diagnostic should not be emitted in 
the lower(codegen) in general (exception may be for target related).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79743



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


[PATCH] D79919: [Driver] Pass -plugin-opt=O2 for -Os -Oz and -plugin-opt=O1 for -Og

2020-05-14 Thread Fangrui Song via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5ecb51414637: [Driver] Pass -plugin-opt=O2 for -Os -Oz and 
-plugin-opt=O1 for -Og (authored by MaskRay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79919

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/lto.c


Index: clang/test/Driver/lto.c
===
--- clang/test/Driver/lto.c
+++ clang/test/Driver/lto.c
@@ -48,6 +48,27 @@
 // RUN:   -fuse-ld=gold -flto -fno-lto -### 2>&1 | FileCheck 
--check-prefix=NO-LLVMGOLD %s
 // NO-LLVMGOLD-NOT: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}"
 
+// RUN: %clang -target x86_64-unknown-linux-gnu --sysroot 
%S/Inputs/basic_cross_linux_tree %s \
+// RUN:   -fuse-ld=lld -flto -O -### 2>&1 | FileCheck --check-prefix=O2 %s
+// RUN: %clang -target x86_64-unknown-linux-gnu --sysroot 
%S/Inputs/basic_cross_linux_tree %s \
+// RUN:   -fuse-ld=lld -flto -O1 -### 2>&1 | FileCheck --check-prefix=O1 %s
+// RUN: %clang -target x86_64-unknown-linux-gnu --sysroot 
%S/Inputs/basic_cross_linux_tree %s \
+// RUN:   -fuse-ld=lld -flto -Og -### 2>&1 | FileCheck --check-prefix=O1 %s
+// RUN: %clang -target x86_64-unknown-linux-gnu --sysroot 
%S/Inputs/basic_cross_linux_tree %s \
+// RUN:   -fuse-ld=lld -flto -O2 -### 2>&1 | FileCheck --check-prefix=O2 %s
+// RUN: %clang -target x86_64-unknown-linux-gnu --sysroot 
%S/Inputs/basic_cross_linux_tree %s \
+// RUN:   -fuse-ld=lld -flto -Os -### 2>&1 | FileCheck --check-prefix=O2 %s
+// RUN: %clang -target x86_64-unknown-linux-gnu --sysroot 
%S/Inputs/basic_cross_linux_tree %s \
+// RUN:   -fuse-ld=lld -flto -Oz -### 2>&1 | FileCheck --check-prefix=O2 %s
+// RUN: %clang -target x86_64-unknown-linux-gnu --sysroot 
%S/Inputs/basic_cross_linux_tree %s \
+// RUN:   -fuse-ld=lld -flto -O3 -### 2>&1 | FileCheck --check-prefix=O3 %s
+// RUN: %clang -target x86_64-unknown-linux-gnu --sysroot 
%S/Inputs/basic_cross_linux_tree %s \
+// RUN:   -fuse-ld=lld -flto -Ofast -### 2>&1 | FileCheck --check-prefix=O3 %s
+
+// O1: -plugin-opt=O1
+// O2: -plugin-opt=O2
+// O3: -plugin-opt=O3
+
 // -flto passes along an explicit debugger tuning argument.
 // RUN: %clang -target x86_64-unknown-linux -### %s -flto -glldb 2> %t
 // RUN: FileCheck -check-prefix=CHECK-TUNING-LLDB < %t %s
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -390,13 +390,19 @@
 CmdArgs.push_back(Args.MakeArgString(Twine("-plugin-opt=mcpu=") + CPU));
 
   if (Arg *A = Args.getLastArg(options::OPT_O_Group)) {
+// The optimization level matches
+// CompilerInvocation.cpp:getOptimizationLevel().
 StringRef OOpt;
 if (A->getOption().matches(options::OPT_O4) ||
 A->getOption().matches(options::OPT_Ofast))
   OOpt = "3";
-else if (A->getOption().matches(options::OPT_O))
+else if (A->getOption().matches(options::OPT_O)) {
   OOpt = A->getValue();
-else if (A->getOption().matches(options::OPT_O0))
+  if (OOpt == "g")
+OOpt = "1";
+  else if (OOpt == "s" || OOpt == "z")
+OOpt = "2";
+} else if (A->getOption().matches(options::OPT_O0))
   OOpt = "0";
 if (!OOpt.empty())
   CmdArgs.push_back(Args.MakeArgString(Twine("-plugin-opt=O") + OOpt));


Index: clang/test/Driver/lto.c
===
--- clang/test/Driver/lto.c
+++ clang/test/Driver/lto.c
@@ -48,6 +48,27 @@
 // RUN:   -fuse-ld=gold -flto -fno-lto -### 2>&1 | FileCheck --check-prefix=NO-LLVMGOLD %s
 // NO-LLVMGOLD-NOT: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}"
 
+// RUN: %clang -target x86_64-unknown-linux-gnu --sysroot %S/Inputs/basic_cross_linux_tree %s \
+// RUN:   -fuse-ld=lld -flto -O -### 2>&1 | FileCheck --check-prefix=O2 %s
+// RUN: %clang -target x86_64-unknown-linux-gnu --sysroot %S/Inputs/basic_cross_linux_tree %s \
+// RUN:   -fuse-ld=lld -flto -O1 -### 2>&1 | FileCheck --check-prefix=O1 %s
+// RUN: %clang -target x86_64-unknown-linux-gnu --sysroot %S/Inputs/basic_cross_linux_tree %s \
+// RUN:   -fuse-ld=lld -flto -Og -### 2>&1 | FileCheck --check-prefix=O1 %s
+// RUN: %clang -target x86_64-unknown-linux-gnu --sysroot %S/Inputs/basic_cross_linux_tree %s \
+// RUN:   -fuse-ld=lld -flto -O2 -### 2>&1 | FileCheck --check-prefix=O2 %s
+// RUN: %clang -target x86_64-unknown-linux-gnu --sysroot %S/Inputs/basic_cross_linux_tree %s \
+// RUN:   -fuse-ld=lld -flto -Os -### 2>&1 | FileCheck --check-prefix=O2 %s
+// RUN: %clang -target x86_64-unknown-linux-gnu --sysroot %S/Inputs/basic_cross_linux_tree %s \
+// RUN:   -fuse-ld=lld -flto -Oz -### 2>&1 | FileCheck --check-prefix=O2 %s
+// RUN: %clang -target x86_64-unknown-linux-gnu --sysroot %S/Inputs/basic_cross_linux_tree 

[PATCH] D79916: Map -O to -O1 instead of -O2

2020-05-14 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 264029.
MaskRay edited the summary of this revision.
MaskRay added a comment.
Herald added subscribers: dexonsmith, steven_wu, hiraditya.

Update description


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79916

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/O.c
  clang/test/Driver/clang_f_opts.c
  clang/test/Driver/lto.c


Index: clang/test/Driver/lto.c
===
--- clang/test/Driver/lto.c
+++ clang/test/Driver/lto.c
@@ -49,7 +49,7 @@
 // NO-LLVMGOLD-NOT: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}"
 
 // RUN: %clang -target x86_64-unknown-linux-gnu --sysroot 
%S/Inputs/basic_cross_linux_tree %s \
-// RUN:   -fuse-ld=lld -flto -O -### 2>&1 | FileCheck --check-prefix=O2 %s
+// RUN:   -fuse-ld=lld -flto -O -### 2>&1 | FileCheck --check-prefix=O1 %s
 // RUN: %clang -target x86_64-unknown-linux-gnu --sysroot 
%S/Inputs/basic_cross_linux_tree %s \
 // RUN:   -fuse-ld=lld -flto -O1 -### 2>&1 | FileCheck --check-prefix=O1 %s
 // RUN: %clang -target x86_64-unknown-linux-gnu --sysroot 
%S/Inputs/basic_cross_linux_tree %s \
Index: clang/test/Driver/clang_f_opts.c
===
--- clang/test/Driver/clang_f_opts.c
+++ clang/test/Driver/clang_f_opts.c
@@ -135,7 +135,7 @@
 // RUN: %clang -### -S -fno-tree-vectorize -fvectorize %s 2>&1 | FileCheck 
-check-prefix=CHECK-VECTORIZE %s
 // RUN: %clang -### -S -fno-tree-vectorize %s 2>&1 | FileCheck 
-check-prefix=CHECK-NO-VECTORIZE %s
 // RUN: %clang -### -S -ftree-vectorize -fno-vectorize %s 2>&1 | FileCheck 
-check-prefix=CHECK-NO-VECTORIZE %s
-// RUN: %clang -### -S -O %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s
+// RUN: %clang -### -S -O %s 2>&1 | FileCheck -check-prefix=CHECK-NO-VECTORIZE 
%s
 // RUN: %clang -### -S -O2 %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s
 // RUN: %clang -### -S -Os %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s
 // RUN: %clang -### -S -O3 %s 2>&1 | FileCheck -check-prefix=CHECK-VECTORIZE %s
@@ -157,7 +157,7 @@
 // RUN: %clang -### -S -fno-tree-slp-vectorize -fslp-vectorize %s 2>&1 | 
FileCheck -check-prefix=CHECK-SLP-VECTORIZE %s
 // RUN: %clang -### -S -fno-tree-slp-vectorize %s 2>&1 | FileCheck 
-check-prefix=CHECK-NO-SLP-VECTORIZE %s
 // RUN: %clang -### -S -ftree-slp-vectorize -fno-slp-vectorize %s 2>&1 | 
FileCheck -check-prefix=CHECK-NO-SLP-VECTORIZE %s
-// RUN: %clang -### -S -O %s 2>&1 | FileCheck 
-check-prefix=CHECK-SLP-VECTORIZE %s
+// RUN: %clang -### -S -O %s 2>&1 | FileCheck 
-check-prefix=CHECK-NO-SLP-VECTORIZE %s
 // RUN: %clang -### -S -O2 %s 2>&1 | FileCheck 
-check-prefix=CHECK-SLP-VECTORIZE %s
 // RUN: %clang -### -S -Os %s 2>&1 | FileCheck 
-check-prefix=CHECK-SLP-VECTORIZE %s
 // RUN: %clang -### -S -Oz %s 2>&1 | FileCheck 
-check-prefix=CHECK-SLP-VECTORIZE %s
Index: clang/test/Driver/O.c
===
--- clang/test/Driver/O.c
+++ clang/test/Driver/O.c
@@ -1,7 +1,7 @@
 // Test that we parse and translate the -O option correctly.
 
 // RUN: %clang -O -### %s 2>&1 | FileCheck -check-prefix=CHECK-O %s
-// CHECK-O: -O2
+// CHECK-O: -O1
 
 // RUN: %clang -O0 -### %s 2>&1 | FileCheck -check-prefix=CHECK-O0 %s
 // CHECK-O0: -O0
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -137,7 +137,7 @@
 assert(A->getOption().matches(options::OPT_O));
 
 StringRef S(A->getValue());
-if (S == "s" || S == "z" || S.empty())
+if (S == "s" || S == "z")
   return llvm::CodeGenOpt::Default;
 
 if (S == "g")
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -400,7 +400,7 @@
 def ObjC : Flag<["-"], "ObjC">, Flags<[DriverOption]>,
   HelpText<"Treat source input files as Objective-C inputs">;
 def O : Joined<["-"], "O">, Group, Flags<[CC1Option]>;
-def O_flag : Flag<["-"], "O">, Flags<[CC1Option]>, Alias, AliasArgs<["2"]>;
+def O_flag : Flag<["-"], "O">, Flags<[CC1Option]>, Alias, AliasArgs<["1"]>;
 def Ofast : Joined<["-"], "Ofast">, Group, Flags<[CC1Option]>;
 def P : Flag<["-"], "P">, Flags<[CC1Option]>, Group,
   HelpText<"Disable linemarker output in -E mode">;


Index: clang/test/Driver/lto.c
===
--- clang/test/Driver/lto.c
+++ clang/test/Driver/lto.c
@@ -49,7 +49,7 @@
 // NO-LLVMGOLD-NOT: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}"
 
 // RUN: %clang -target x86_64-unknown-linux-gnu --sysroot %S/Inputs/basic_cross_linux_tree %s \
-// RUN:   -fuse-ld=lld -flto 

[PATCH] D79035: [clang][AIX] Implement ABIInfo and TargetCodeGenInfo for AIX

2020-05-14 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L accepted this revision.
Xiangling_L added a comment.
This revision is now accepted and ready to land.

LGTM with a minor comment:
You may want to add a `TODO` or `FIXME` at `clang/lib/CodeGen/TargetInfo.cpp: 
4496` and `clang/lib/CodeGen/TargetInfo.cpp:4418` like:

  //FIXME:
  Correct the aggregate type alignment when it contains a double/long double as 
its first member.


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

https://reviews.llvm.org/D79035



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


[PATCH] D79919: [Driver] Pass -plugin-opt=O2 for -Os -Oz and -plugin-opt=O1 for -Og

2020-05-14 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 264027.
MaskRay edited the summary of this revision.
MaskRay added a comment.

-O => -O2 (temporarily, pending on the resolution of D79916 
)

Add a test for -Ofast


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79919

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/lto.c


Index: clang/test/Driver/lto.c
===
--- clang/test/Driver/lto.c
+++ clang/test/Driver/lto.c
@@ -48,6 +48,27 @@
 // RUN:   -fuse-ld=gold -flto -fno-lto -### 2>&1 | FileCheck 
--check-prefix=NO-LLVMGOLD %s
 // NO-LLVMGOLD-NOT: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}"
 
+// RUN: %clang -target x86_64-unknown-linux-gnu --sysroot 
%S/Inputs/basic_cross_linux_tree %s \
+// RUN:   -fuse-ld=lld -flto -O -### 2>&1 | FileCheck --check-prefix=O2 %s
+// RUN: %clang -target x86_64-unknown-linux-gnu --sysroot 
%S/Inputs/basic_cross_linux_tree %s \
+// RUN:   -fuse-ld=lld -flto -O1 -### 2>&1 | FileCheck --check-prefix=O1 %s
+// RUN: %clang -target x86_64-unknown-linux-gnu --sysroot 
%S/Inputs/basic_cross_linux_tree %s \
+// RUN:   -fuse-ld=lld -flto -Og -### 2>&1 | FileCheck --check-prefix=O1 %s
+// RUN: %clang -target x86_64-unknown-linux-gnu --sysroot 
%S/Inputs/basic_cross_linux_tree %s \
+// RUN:   -fuse-ld=lld -flto -O2 -### 2>&1 | FileCheck --check-prefix=O2 %s
+// RUN: %clang -target x86_64-unknown-linux-gnu --sysroot 
%S/Inputs/basic_cross_linux_tree %s \
+// RUN:   -fuse-ld=lld -flto -Os -### 2>&1 | FileCheck --check-prefix=O2 %s
+// RUN: %clang -target x86_64-unknown-linux-gnu --sysroot 
%S/Inputs/basic_cross_linux_tree %s \
+// RUN:   -fuse-ld=lld -flto -Oz -### 2>&1 | FileCheck --check-prefix=O2 %s
+// RUN: %clang -target x86_64-unknown-linux-gnu --sysroot 
%S/Inputs/basic_cross_linux_tree %s \
+// RUN:   -fuse-ld=lld -flto -O3 -### 2>&1 | FileCheck --check-prefix=O3 %s
+// RUN: %clang -target x86_64-unknown-linux-gnu --sysroot 
%S/Inputs/basic_cross_linux_tree %s \
+// RUN:   -fuse-ld=lld -flto -Ofast -### 2>&1 | FileCheck --check-prefix=O3 %s
+
+// O1: -plugin-opt=O1
+// O2: -plugin-opt=O2
+// O3: -plugin-opt=O3
+
 // -flto passes along an explicit debugger tuning argument.
 // RUN: %clang -target x86_64-unknown-linux -### %s -flto -glldb 2> %t
 // RUN: FileCheck -check-prefix=CHECK-TUNING-LLDB < %t %s
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -390,13 +390,19 @@
 CmdArgs.push_back(Args.MakeArgString(Twine("-plugin-opt=mcpu=") + CPU));
 
   if (Arg *A = Args.getLastArg(options::OPT_O_Group)) {
+// The optimization level matches
+// CompilerInvocation.cpp:getOptimizationLevel().
 StringRef OOpt;
 if (A->getOption().matches(options::OPT_O4) ||
 A->getOption().matches(options::OPT_Ofast))
   OOpt = "3";
-else if (A->getOption().matches(options::OPT_O))
+else if (A->getOption().matches(options::OPT_O)) {
   OOpt = A->getValue();
-else if (A->getOption().matches(options::OPT_O0))
+  if (OOpt == "g")
+OOpt = "1";
+  else if (OOpt == "s" || OOpt == "z")
+OOpt = "2";
+} else if (A->getOption().matches(options::OPT_O0))
   OOpt = "0";
 if (!OOpt.empty())
   CmdArgs.push_back(Args.MakeArgString(Twine("-plugin-opt=O") + OOpt));


Index: clang/test/Driver/lto.c
===
--- clang/test/Driver/lto.c
+++ clang/test/Driver/lto.c
@@ -48,6 +48,27 @@
 // RUN:   -fuse-ld=gold -flto -fno-lto -### 2>&1 | FileCheck --check-prefix=NO-LLVMGOLD %s
 // NO-LLVMGOLD-NOT: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}"
 
+// RUN: %clang -target x86_64-unknown-linux-gnu --sysroot %S/Inputs/basic_cross_linux_tree %s \
+// RUN:   -fuse-ld=lld -flto -O -### 2>&1 | FileCheck --check-prefix=O2 %s
+// RUN: %clang -target x86_64-unknown-linux-gnu --sysroot %S/Inputs/basic_cross_linux_tree %s \
+// RUN:   -fuse-ld=lld -flto -O1 -### 2>&1 | FileCheck --check-prefix=O1 %s
+// RUN: %clang -target x86_64-unknown-linux-gnu --sysroot %S/Inputs/basic_cross_linux_tree %s \
+// RUN:   -fuse-ld=lld -flto -Og -### 2>&1 | FileCheck --check-prefix=O1 %s
+// RUN: %clang -target x86_64-unknown-linux-gnu --sysroot %S/Inputs/basic_cross_linux_tree %s \
+// RUN:   -fuse-ld=lld -flto -O2 -### 2>&1 | FileCheck --check-prefix=O2 %s
+// RUN: %clang -target x86_64-unknown-linux-gnu --sysroot %S/Inputs/basic_cross_linux_tree %s \
+// RUN:   -fuse-ld=lld -flto -Os -### 2>&1 | FileCheck --check-prefix=O2 %s
+// RUN: %clang -target x86_64-unknown-linux-gnu --sysroot %S/Inputs/basic_cross_linux_tree %s \
+// RUN:   -fuse-ld=lld -flto -Oz -### 2>&1 | FileCheck --check-prefix=O2 %s
+// RUN: %clang -target x86_64-unknown-linux-gnu 

[PATCH] D79919: [Driver] Pass -plugin-opt=O2 for -Os -Oz and -plugin-opt=O1 for -Og

2020-05-14 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay marked an inline comment as done.
MaskRay added a comment.

Thanks for the review. Will remove D79916  as 
a parent and commit this one first.




Comment at: clang/test/Driver/lto.c:52
+// RUN: %clang -target x86_64-unknown-linux-gnu --sysroot 
%S/Inputs/basic_cross_linux_tree %s \
+// RUN:   -fuse-ld=lld -flto -O -### 2>&1 | FileCheck --check-prefix=O1 %s
+// RUN: %clang -target x86_64-unknown-linux-gnu --sysroot 
%S/Inputs/basic_cross_linux_tree %s \

pcc wrote:
> I think this one should be `--check-prefix=O2`.
I added D79916 as a parent:)

Looks like I should just land this patch first and probably update the test in 
D79916.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79919



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


[PATCH] D79257: [OPENMP50]Codegen for uses_allocators clause.

2020-05-14 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert accepted this revision.
jdoerfert added a comment.
This revision is now accepted and ready to land.

LGTM. FWIW, we should directly add new runtime functions we emit into 
OMPKinds.def. That saves us the trouble of searching for the ones we missed 
later.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79257



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


[PATCH] D76420: Prevent IR-gen from emitting consteval declarations

2020-05-14 Thread Tyker via Phabricator via cfe-commits
Tyker updated this revision to Diff 264023.
Tyker added a comment.

rebased


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76420

Files:
  clang/include/clang/AST/Expr.h
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/lib/CodeGen/CGExprComplex.cpp
  clang/lib/CodeGen/CGExprConstant.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/ConstantEmitter.h
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGenCXX/cxx2a-consteval.cpp
  clang/test/SemaCXX/cxx2a-consteval.cpp

Index: clang/test/SemaCXX/cxx2a-consteval.cpp
===
--- clang/test/SemaCXX/cxx2a-consteval.cpp
+++ clang/test/SemaCXX/cxx2a-consteval.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++2a -fsyntax-only -Wno-unused-value %s -verify
+// RUN: %clang_cc1 -std=c++2a -emit-llvm -Wno-unused-value %s -verify > /dev/null
 
 typedef __SIZE_TYPE__ size_t;
 
Index: clang/test/CodeGenCXX/cxx2a-consteval.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/cxx2a-consteval.cpp
@@ -0,0 +1,212 @@
+// NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+// RUN: %clang_cc1 -emit-llvm %s -std=c++2a -o %t.ll
+// RUN: FileCheck -check-prefix=EVAL -input-file=%t.ll %s
+// RUN: FileCheck -check-prefix=EVAL-FN -input-file=%t.ll %s
+// RUN: FileCheck -check-prefix=EVAL-STATIC -input-file=%t.ll %s
+// RUN: %clang_cc1 -emit-llvm %s -Dconsteval="" -std=c++2a -o %t.ll
+// RUNA: FileCheck -check-prefix=EXPR -input-file=%t.ll %s
+
+// there is two version of symbol checks to ensure
+// that the symbol we are looking for are correct
+// EVAL-NOT: @__cxx_global_var_init()
+// EXPR: @__cxx_global_var_init()
+
+// EVAL-NOT: @_Z4ret7v()
+// EXPR: @_Z4ret7v()
+consteval int ret7() {
+  return 7;
+}
+
+int test_ret7() {
+// EVAL-FN-LABEL: @_Z9test_ret7v(
+// EVAL-FN-NEXT:  entry:
+// EVAL-FN-NEXT:[[I:%.*]] = alloca i32, align 4
+// EVAL-FN-NEXT:store i32 7, i32* [[I]], align 4
+// EVAL-FN-NEXT:[[TMP0:%.*]] = load i32, i32* [[I]], align 4
+// EVAL-FN-NEXT:ret i32 [[TMP0]]
+//
+  int i = ret7();
+  return i;
+}
+
+// EVAL-STATIC: @global_i = global i32 7, align 4
+int global_i = ret7();
+
+// EVAL-STATIC: @_ZL7i_const = internal constant i32 5, align 4
+constexpr int i_const = 5;
+
+// EVAL-NOT: @_Z4retIv()
+// EXPR: @_Z4retIv()
+consteval const int& retI() {
+  return i_const;
+}
+
+const int& test_retRefI() {
+// EVAL-FN-LABEL: @_Z12test_retRefIv(
+// EVAL-FN-NEXT:  entry:
+// EVAL-FN-NEXT:ret i32* @_ZL7i_const
+//
+  return retI();
+}
+
+int test_retI() {
+// EVAL-FN-LABEL: @_Z9test_retIv(
+// EVAL-FN-NEXT:  entry:
+// EVAL-FN-NEXT:[[TMP0:%.*]] = load i32, i32* @_ZL7i_const, align 4
+// EVAL-FN-NEXT:ret i32 [[TMP0]]
+//
+  return retI();
+}
+
+// EVAL-NOT: @_Z4retIv()
+// EXPR: @_Z4retIv()
+consteval const int* retIPtr() {
+  return _const;
+}
+
+int test_retIPtr() {
+// EVAL-FN-LABEL: @_Z12test_retIPtrv(
+// EVAL-FN-NEXT:  entry:
+// EVAL-FN-NEXT:[[TMP0:%.*]] = load i32, i32* @_ZL7i_const, align 4
+// EVAL-FN-NEXT:ret i32 [[TMP0]]
+//
+  return *retIPtr();
+}
+
+const int* test_retPIPtr() {
+// EVAL-FN-LABEL: @_Z13test_retPIPtrv(
+// EVAL-FN-NEXT:  entry:
+// EVAL-FN-NEXT:ret i32* @_ZL7i_const
+//
+  return retIPtr();
+}
+
+// EVAL-NOT: @_Z4retIv()
+// EXPR: @_Z4retIv()
+consteval const int&& retIRRef() {
+  return static_cast(i_const);
+}
+
+// EVAL-NOT: @_Z4retIv()
+// EXPR: @_Z4retIv()
+const int&& test_retIRRef() {
+  return static_cast(retIRRef());
+}
+
+int test_retIRRefI() {
+// EVAL-FN-LABEL: @_Z14test_retIRRefIv(
+// EVAL-FN-NEXT:  entry:
+// EVAL-FN-NEXT:[[TMP0:%.*]] = load i32, i32* @_ZL7i_const, align 4
+// EVAL-FN-NEXT:ret i32 [[TMP0]]
+//
+  return retIRRef();
+}
+
+struct Agg {
+  int a;
+  long b;
+};
+
+// EVAL-NOT: @_Z6retAggv()
+// EXPR: @_Z6retAggv()
+consteval Agg retAgg() {
+  return {13, 17};
+}
+
+long test_retAgg() {
+// EVAL-FN-LABEL: @_Z11test_retAggv(
+// EVAL-FN-NEXT:  entry:
+// EVAL-FN-NEXT:[[B:%.*]] = alloca i64, align 8
+// EVAL-FN-NEXT:[[REF_TMP:%.*]] = alloca [[STRUCT_AGG:%.*]], align 8
+// EVAL-FN-NEXT:[[TMP0:%.*]] = getelementptr inbounds [[STRUCT_AGG]], %struct.Agg* [[REF_TMP]], i32 0, i32 0
+// EVAL-FN-NEXT:store i32 13, i32* [[TMP0]], align 8
+// EVAL-FN-NEXT:[[TMP1:%.*]] = getelementptr inbounds [[STRUCT_AGG]], %struct.Agg* [[REF_TMP]], i32 0, i32 1
+// EVAL-FN-NEXT:store i64 17, i64* [[TMP1]], align 8
+// EVAL-FN-NEXT:store i64 17, i64* [[B]], align 8
+// EVAL-FN-NEXT:[[TMP2:%.*]] = load i64, i64* [[B]], align 8
+// EVAL-FN-NEXT:ret i64 [[TMP2]]
+//
+  long b = retAgg().b;
+  return b;
+}
+
+// EVAL-STATIC: @A = 

[PATCH] D79950: [clangd] Avoid wasteful data structures in RefSlab::Builder

2020-05-14 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: kbobyrev.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, mgrang, 
jkorous, MaskRay, ilya-biryukov.
Herald added a project: clang.

This is worth another 10% or so on InedxBenchmark.DexBuild.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79950

Files:
  clang-tools-extra/clangd/index/Ref.cpp
  clang-tools-extra/clangd/index/Ref.h
  clang-tools-extra/clangd/index/SymbolLocation.cpp
  clang-tools-extra/clangd/index/SymbolLocation.h

Index: clang-tools-extra/clangd/index/SymbolLocation.h
===
--- clang-tools-extra/clangd/index/SymbolLocation.h
+++ clang-tools-extra/clangd/index/SymbolLocation.h
@@ -30,22 +30,23 @@
   // Position is encoded into 32 bits to save space.
   // If Line/Column overflow, the value will be their maximum value.
   struct Position {
-Position() : Line(0), Column(0) {}
+Position() : LineColumnPacked(0) {}
 void setLine(uint32_t Line);
-uint32_t line() const { return Line; }
+uint32_t line() const { return LineColumnPacked >> ColumnBits; }
 void setColumn(uint32_t Column);
-uint32_t column() const { return Column; }
+uint32_t column() const { return LineColumnPacked & MaxColumn; }
+uint32_t rep() const { return LineColumnPacked; }
 
 bool hasOverflow() const {
-  return Line >= MaxLine || Column >= MaxColumn;
+  return line() == MaxLine || column() == MaxColumn;
 }
 
-static constexpr uint32_t MaxLine = (1 << 20) - 1;
-static constexpr uint32_t MaxColumn = (1 << 12) - 1;
+static constexpr unsigned ColumnBits = 12;
+static constexpr uint32_t MaxLine = (1 << (32 - ColumnBits)) - 1;
+static constexpr uint32_t MaxColumn = (1 << ColumnBits) - 1;
 
   private:
-uint32_t Line : 20;   // 0-based
-uint32_t Column : 12; // 0-based
+uint32_t LineColumnPacked; // Top 20 bit line, bottom 12 bits column.
   };
 
   /// The symbol range, using half-open range [Start, End).
Index: clang-tools-extra/clangd/index/SymbolLocation.cpp
===
--- clang-tools-extra/clangd/index/SymbolLocation.cpp
+++ clang-tools-extra/clangd/index/SymbolLocation.cpp
@@ -15,18 +15,14 @@
 constexpr uint32_t SymbolLocation::Position::MaxColumn;
 
 void SymbolLocation::Position::setLine(uint32_t L) {
-  if (L > MaxLine) {
-Line = MaxLine;
-return;
-  }
-  Line = L;
+  if (L > MaxLine)
+L = MaxLine;
+  LineColumnPacked = (L << ColumnBits) | column();
 }
 void SymbolLocation::Position::setColumn(uint32_t Col) {
-  if (Col > MaxColumn) {
-Column = MaxColumn;
-return;
-  }
-  Column = Col;
+  if (Col > MaxColumn)
+Col = MaxColumn;
+  LineColumnPacked = (LineColumnPacked & ~MaxColumn) | Col;
 }
 
 llvm::raw_ostream <<(llvm::raw_ostream , const SymbolLocation ) {
Index: clang-tools-extra/clangd/index/Ref.h
===
--- clang-tools-extra/clangd/index/Ref.h
+++ clang-tools-extra/clangd/index/Ref.h
@@ -13,6 +13,7 @@
 #include "SymbolLocation.h"
 #include "clang/Index/IndexSymbol.h"
 #include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/Hashing.h"
 #include "llvm/Support/StringSaver.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
@@ -132,9 +133,17 @@
 RefSlab build() &&;
 
   private:
+// A ref we're storing with its symbol to consume with build().
+// All strings are interned, so DenseMapInfo can use pointer comparisons.
+struct Entry {
+  SymbolID Symbol;
+  Ref R;
+};
+friend struct llvm::DenseMapInfo;
+
 llvm::BumpPtrAllocator Arena;
 llvm::UniqueStringSaver UniqueStrings; // Contents on the arena.
-llvm::DenseMap> Refs;
+llvm::DenseSet Entries;
   };
 
 private:
@@ -151,4 +160,29 @@
 } // namespace clangd
 } // namespace clang
 
+namespace llvm {
+template <> struct DenseMapInfo {
+  using Entry = clang::clangd::RefSlab::Builder::Entry;
+  static inline Entry getEmptyKey() {
+static Entry E{clang::clangd::SymbolID(""), {}};
+return E;
+  }
+  static inline Entry getTombstoneKey() {
+static Entry E{clang::clangd::SymbolID("TOMBSTONE"), {}};
+return E;
+  }
+  static unsigned getHashValue(const Entry ) {
+return llvm::hash_combine(
+Val.Symbol, reinterpret_cast(Val.R.Location.FileURI),
+Val.R.Location.Start.rep(), Val.R.Location.End.rep());
+  }
+  static bool isEqual(const Entry , const Entry ) {
+return std::tie(LHS.Symbol, LHS.R.Location.FileURI, LHS.R.Kind) ==
+   std::tie(RHS.Symbol, RHS.R.Location.FileURI, RHS.R.Kind) &&
+   LHS.R.Location.Start == RHS.R.Location.Start &&
+   LHS.R.Location.End == RHS.R.Location.End;
+  }
+};
+}; // namespace llvm
+
 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_REF_H
Index: clang-tools-extra/clangd/index/Ref.cpp
===
--- 

[clang] 5ecb514 - [Driver] Pass -plugin-opt=O2 for -Os -Oz and -plugin-opt=O1 for -Og

2020-05-14 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2020-05-14T10:37:33-07:00
New Revision: 5ecb51414637402b0f89a96924ac7b015d23bcfa

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

LOG: [Driver] Pass -plugin-opt=O2 for -Os -Oz and -plugin-opt=O1 for -Og

Fixes PR42445 (compiler driver options -Os -Oz translate to
-plugin-opt=Os (Oz) which are not recognized by LLVMgold.so or LLD).

The optimization level mapping matches
CompilerInvocation.cpp:getOptimizationLevel() and SpeedLevel of
PassBuilder::OptimizationLevel::O*.

-plugin-opt=O* affects the way we construct regular LTO/ThinLTO pass
manager pipeline.

Reviewed By: pcc

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/test/Driver/lto.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 5219f28565a4..d6451447a924 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -390,13 +390,19 @@ void tools::addLTOOptions(const ToolChain , 
const ArgList ,
 CmdArgs.push_back(Args.MakeArgString(Twine("-plugin-opt=mcpu=") + CPU));
 
   if (Arg *A = Args.getLastArg(options::OPT_O_Group)) {
+// The optimization level matches
+// CompilerInvocation.cpp:getOptimizationLevel().
 StringRef OOpt;
 if (A->getOption().matches(options::OPT_O4) ||
 A->getOption().matches(options::OPT_Ofast))
   OOpt = "3";
-else if (A->getOption().matches(options::OPT_O))
+else if (A->getOption().matches(options::OPT_O)) {
   OOpt = A->getValue();
-else if (A->getOption().matches(options::OPT_O0))
+  if (OOpt == "g")
+OOpt = "1";
+  else if (OOpt == "s" || OOpt == "z")
+OOpt = "2";
+} else if (A->getOption().matches(options::OPT_O0))
   OOpt = "0";
 if (!OOpt.empty())
   CmdArgs.push_back(Args.MakeArgString(Twine("-plugin-opt=O") + OOpt));

diff  --git a/clang/test/Driver/lto.c b/clang/test/Driver/lto.c
index 34e6076dec2e..2308372af9f5 100644
--- a/clang/test/Driver/lto.c
+++ b/clang/test/Driver/lto.c
@@ -48,6 +48,27 @@
 // RUN:   -fuse-ld=gold -flto -fno-lto -### 2>&1 | FileCheck 
--check-prefix=NO-LLVMGOLD %s
 // NO-LLVMGOLD-NOT: "-plugin" "{{.*}}{{[/\\]}}LLVMgold.{{dll|dylib|so}}"
 
+// RUN: %clang -target x86_64-unknown-linux-gnu --sysroot 
%S/Inputs/basic_cross_linux_tree %s \
+// RUN:   -fuse-ld=lld -flto -O -### 2>&1 | FileCheck --check-prefix=O2 %s
+// RUN: %clang -target x86_64-unknown-linux-gnu --sysroot 
%S/Inputs/basic_cross_linux_tree %s \
+// RUN:   -fuse-ld=lld -flto -O1 -### 2>&1 | FileCheck --check-prefix=O1 %s
+// RUN: %clang -target x86_64-unknown-linux-gnu --sysroot 
%S/Inputs/basic_cross_linux_tree %s \
+// RUN:   -fuse-ld=lld -flto -Og -### 2>&1 | FileCheck --check-prefix=O1 %s
+// RUN: %clang -target x86_64-unknown-linux-gnu --sysroot 
%S/Inputs/basic_cross_linux_tree %s \
+// RUN:   -fuse-ld=lld -flto -O2 -### 2>&1 | FileCheck --check-prefix=O2 %s
+// RUN: %clang -target x86_64-unknown-linux-gnu --sysroot 
%S/Inputs/basic_cross_linux_tree %s \
+// RUN:   -fuse-ld=lld -flto -Os -### 2>&1 | FileCheck --check-prefix=O2 %s
+// RUN: %clang -target x86_64-unknown-linux-gnu --sysroot 
%S/Inputs/basic_cross_linux_tree %s \
+// RUN:   -fuse-ld=lld -flto -Oz -### 2>&1 | FileCheck --check-prefix=O2 %s
+// RUN: %clang -target x86_64-unknown-linux-gnu --sysroot 
%S/Inputs/basic_cross_linux_tree %s \
+// RUN:   -fuse-ld=lld -flto -O3 -### 2>&1 | FileCheck --check-prefix=O3 %s
+// RUN: %clang -target x86_64-unknown-linux-gnu --sysroot 
%S/Inputs/basic_cross_linux_tree %s \
+// RUN:   -fuse-ld=lld -flto -Ofast -### 2>&1 | FileCheck --check-prefix=O3 %s
+
+// O1: -plugin-opt=O1
+// O2: -plugin-opt=O2
+// O3: -plugin-opt=O3
+
 // -flto passes along an explicit debugger tuning argument.
 // RUN: %clang -target x86_64-unknown-linux -### %s -flto -glldb 2> %t
 // RUN: FileCheck -check-prefix=CHECK-TUNING-LLDB < %t %s



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


[PATCH] D79715: [clang-format] Update GoogleStyle for C# code to match Google's internal C# style guide

2020-05-14 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe planned changes to this revision.
jbcoe added a comment.

I will get the Google Style guide uploaded and update this patch with a link.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79715



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


[PATCH] D79919: [Driver] Pass -plugin-opt=O2 for -Os -Oz and -plugin-opt=O1 for -Og

2020-05-14 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc accepted this revision.
pcc added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: clang/test/Driver/lto.c:52
+// RUN: %clang -target x86_64-unknown-linux-gnu --sysroot 
%S/Inputs/basic_cross_linux_tree %s \
+// RUN:   -fuse-ld=lld -flto -O -### 2>&1 | FileCheck --check-prefix=O1 %s
+// RUN: %clang -target x86_64-unknown-linux-gnu --sysroot 
%S/Inputs/basic_cross_linux_tree %s \

I think this one should be `--check-prefix=O2`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79919



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


[PATCH] D79257: [OPENMP50]Codegen for uses_allocators clause.

2020-05-14 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 264020.
ABataev added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79257

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/target_parallel_for_simd_uses_allocators_codegen.cpp
  clang/test/OpenMP/target_parallel_for_uses_allocators_codegen.cpp
  clang/test/OpenMP/target_parallel_uses_allocators_codegen.cpp
  clang/test/OpenMP/target_simd_uses_allocators_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_uses_allocators_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_uses_allocators_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_uses_allocators_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_uses_allocators_codegen.cpp
  clang/test/OpenMP/target_teams_uses_allocators_codegen.cpp
  clang/test/OpenMP/target_uses_allocators_codegen.cpp

Index: clang/test/OpenMP/target_uses_allocators_codegen.cpp
===
--- /dev/null
+++ clang/test/OpenMP/target_uses_allocators_codegen.cpp
@@ -0,0 +1,93 @@
+// Test host codegen.
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=50 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
+
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+enum omp_allocator_handle_t {
+  omp_null_allocator = 0,
+  omp_default_mem_alloc = 1,
+  omp_large_cap_mem_alloc = 2,
+  omp_const_mem_alloc = 3,
+  omp_high_bw_mem_alloc = 4,
+  omp_low_lat_mem_alloc = 5,
+  omp_cgroup_mem_alloc = 6,
+  omp_pteam_mem_alloc = 7,
+  omp_thread_mem_alloc = 8,
+  KMP_ALLOCATOR_MAX_HANDLE = __UINTPTR_MAX__
+};
+
+typedef enum omp_alloctrait_key_t { omp_atk_sync_hint = 1,
+omp_atk_alignment = 2,
+omp_atk_access = 3,
+omp_atk_pool_size = 4,
+omp_atk_fallback = 5,
+omp_atk_fb_data = 6,
+omp_atk_pinned = 7,
+omp_atk_partition = 8
+} omp_alloctrait_key_t;
+typedef enum omp_alloctrait_value_t {
+  omp_atv_false = 0,
+  omp_atv_true = 1,
+  omp_atv_default = 2,
+  omp_atv_contended = 3,
+  omp_atv_uncontended = 4,
+  omp_atv_sequential = 5,
+  omp_atv_private = 6,
+  omp_atv_all = 7,
+  omp_atv_thread = 8,
+  omp_atv_pteam = 9,
+  omp_atv_cgroup = 10,
+  omp_atv_default_mem_fb = 11,
+  omp_atv_null_fb = 12,
+  omp_atv_abort_fb = 13,
+  omp_atv_allocator_fb = 14,
+  omp_atv_environment = 15,
+  omp_atv_nearest = 16,
+  omp_atv_blocked = 17,
+  omp_atv_interleaved = 18
+} omp_alloctrait_value_t;
+
+typedef struct omp_alloctrait_t {
+  omp_alloctrait_key_t key;
+  __UINTPTR_TYPE__ value;
+} omp_alloctrait_t;
+
+// Just map the traits variable as a firstprivate variable.
+// CHECK-DAG: [[SIZES:@.+]] = private unnamed_addr constant [1 x i64] [i64 160]
+// CHECK-DAG: [[MAPTYPES:@.+]] = private unnamed_addr constant [1 x i64] [i64 673]
+
+// CHECK: define {{.*}}[[FOO:@.+]]()
+void foo() {
+  omp_alloctrait_t traits[10];
+  omp_allocator_handle_t my_allocator;
+
+// CHECK: [[RES:%.+]] = call i32 @__tgt_target(i64 -1, i8* @.[[TGT_REGION:.+]].region_id, i32 1, i8** %{{.+}}, i8** %{{.+}}, i64* getelementptr inbounds ([1 x i64], [1 x i64]* [[SIZES]], i32 0, i32 0), i64* getelementptr inbounds ([1 x i64], [1 x i64]* [[MAPTYPES]], i32 0, i32 0))
+// CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
+// CHECK: br i1 [[CMP]], label %[[FAILED:.+]], label %[[DONE:.+]]
+// CHECK: [[FAILED]]:
+// CHECK: call void @[[TGT_REGION]]([10 x %struct.omp_alloctrait_t]* %{{[^,]+}})
+#pragma omp target uses_allocators(omp_null_allocator, omp_thread_mem_alloc, my_allocator(traits))
+  ;
+}
+
+// CHECK: define internal void @[[TGT_REGION]]([10 x %struct.omp_alloctrait_t]* {{.+}})
+// CHECK: [[TRAITS_ADDR_REF:%.+]] = alloca [10 x %struct.omp_alloctrait_t]*,
+// CHECK: [[MY_ALLOCATOR_ADDR:%.+]] = alloca i64,
+// CHECK: [[TRAITS_ADDR:%.+]] = load [10 x %struct.omp_alloctrait_t]*, [10 x %struct.omp_alloctrait_t]** [[TRAITS_ADDR_REF]],
+// CHECK: [[TRAITS_ADDR_VOIDPTR:%.+]] = bitcast [10 x %struct.omp_alloctrait_t]* [[TRAITS_ADDR]] to i8**
+// CHECK: [[TRAITS:%.+]] = load i8*, i8** [[TRAITS_ADDR_VOIDPTR]],
+// CHECK: [[ALLOCATOR:%.+]] = call i8* 

[PATCH] D79693: [test][ARM][CMSE] Use -ffreestanding for arm_cmse.h tests

2020-05-14 Thread Momchil Velikov via Phabricator via cfe-commits
chill added a comment.

I see.

I can also count (`grep -rn '#include.*https://reviews.llvm.org/D79693/new/

https://reviews.llvm.org/D79693



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


[PATCH] D79035: [clang][AIX] Implement ABIInfo and TargetCodeGenInfo for AIX

2020-05-14 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA added a comment.

I'm ok with this now. I will let @Xiangling_L approve if she's ok with it since 
she had the last few comments.


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

https://reviews.llvm.org/D79035



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


[clang-tools-extra] 10b4931 - [test] NFC, add missing declarations and include to test files to avoid 'implicit-function-declaration' diagnostics in the tests

2020-05-14 Thread Alex Lorenz via cfe-commits

Author: Alex Lorenz
Date: 2020-05-14T10:01:50-07:00
New Revision: 10b49315faa6338eaf52bb782e7c53644ad17dab

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

LOG: [test] NFC, add missing declarations and include to test files to avoid 
'implicit-function-declaration' diagnostics in the tests

Added: 


Modified: 
clang-tools-extra/test/clang-tidy/checkers/darwin-avoid-spinlock.m
compiler-rt/test/profile/Inputs/instrprof-gcov-__gcov_flush-multiple.c
compiler-rt/test/profile/Inputs/instrprof-gcov-__gcov_flush-multiple.c.gcov
compiler-rt/test/profile/instrprof-value-prof.c

Removed: 




diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/darwin-avoid-spinlock.m 
b/clang-tools-extra/test/clang-tidy/checkers/darwin-avoid-spinlock.m
index c870e0a0fed0..f395386a02f4 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/darwin-avoid-spinlock.m
+++ b/clang-tools-extra/test/clang-tidy/checkers/darwin-avoid-spinlock.m
@@ -2,6 +2,10 @@
 
 typedef int OSSpinLock;
 
+void OSSpinlockLock(OSSpinLock *l);
+void OSSpinlockTry(OSSpinLock *l);
+void OSSpinlockUnlock(OSSpinLock *l);
+
 @implementation Foo
 - (void)f {
 int i = 1;

diff  --git 
a/compiler-rt/test/profile/Inputs/instrprof-gcov-__gcov_flush-multiple.c 
b/compiler-rt/test/profile/Inputs/instrprof-gcov-__gcov_flush-multiple.c
index dadd8959991a..56e0538b1e83 100644
--- a/compiler-rt/test/profile/Inputs/instrprof-gcov-__gcov_flush-multiple.c
+++ b/compiler-rt/test/profile/Inputs/instrprof-gcov-__gcov_flush-multiple.c
@@ -1,3 +1,5 @@
+extern void __gcov_flush();
+extern int remove(const char *);
 int main(void) {
   __gcov_flush();
 

diff  --git 
a/compiler-rt/test/profile/Inputs/instrprof-gcov-__gcov_flush-multiple.c.gcov 
b/compiler-rt/test/profile/Inputs/instrprof-gcov-__gcov_flush-multiple.c.gcov
index 83755451631d..b0921d22461e 100644
--- 
a/compiler-rt/test/profile/Inputs/instrprof-gcov-__gcov_flush-multiple.c.gcov
+++ 
b/compiler-rt/test/profile/Inputs/instrprof-gcov-__gcov_flush-multiple.c.gcov
@@ -3,19 +3,21 @@
 // CHECK-NEXT:-:0:Data:instrprof-gcov-__gcov_flush-multiple.gcda
 // CHECK-NEXT:-:0:Runs:1
 // CHECK-NEXT:-:0:Programs:1
-// CHECK-NEXT:#:1:int main(void) {
-// CHECK-NEXT:#:2:  __gcov_flush();
-// CHECK-NEXT:-:3:
-// CHECK-NEXT:#:4:  if 
(remove("instrprof-gcov-__gcov_flush-multiple.gcda") != 0) {
-// CHECK-NEXT:#:5:return 1;
-// CHECK-NEXT:-:6:  }
-// CHECK-NEXT:-:7:
-// CHECK-NEXT:#:8:  __gcov_flush();
-// CHECK-NEXT:#:9:  __gcov_flush();
-// CHECK-NEXT:-:   10:
-// CHECK-NEXT:#:   11:  if 
(remove("instrprof-gcov-__gcov_flush-multiple.gcda") != 0) {
-// CHECK-NEXT:#:   12:return 1;
-// CHECK-NEXT:-:   13:  }
-// CHECK-NEXT:-:   14:
-// CHECK-NEXT:1:   15:  return 0;
-// CHECK-NEXT:1:   16:}
+// CHECK-NEXT:-:1:extern void __gcov_flush();
+// CHECK-NEXT:-:2:extern int remove(const char *);
+// CHECK-NEXT:#:3:int main(void) {
+// CHECK-NEXT:#:4:  __gcov_flush();
+// CHECK-NEXT:-:5:
+// CHECK-NEXT:#:6:  if 
(remove("instrprof-gcov-__gcov_flush-multiple.gcda") != 0) {
+// CHECK-NEXT:#:7:return 1;
+// CHECK-NEXT:-:8:  }
+// CHECK-NEXT:-:9:
+// CHECK-NEXT:#:   10:  __gcov_flush();
+// CHECK-NEXT:#:   11:  __gcov_flush();
+// CHECK-NEXT:-:   12:
+// CHECK-NEXT:#:   13:  if 
(remove("instrprof-gcov-__gcov_flush-multiple.gcda") != 0) {
+// CHECK-NEXT:#:   14:return 1;
+// CHECK-NEXT:-:   15:  }
+// CHECK-NEXT:-:   16:
+// CHECK-NEXT:1:   17:  return 0;
+// CHECK-NEXT:1:   18:}

diff  --git a/compiler-rt/test/profile/instrprof-value-prof.c 
b/compiler-rt/test/profile/instrprof-value-prof.c
index 3a5bdbdd552e..53e5fdafc520 100644
--- a/compiler-rt/test/profile/instrprof-value-prof.c
+++ b/compiler-rt/test/profile/instrprof-value-prof.c
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 typedef struct __llvm_profile_data __llvm_profile_data;
 const __llvm_profile_data *__llvm_profile_begin_data(void);
 const __llvm_profile_data *__llvm_profile_end_data(void);



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


[PATCH] D79788: AMDGPU/OpenCL: Accept -nostdlib in place of -nogpulib

2020-05-14 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm closed this revision.
arsenm added a comment.

235fb7dc24b1cf7034dfc76bb853ffb4ac5dec5d 



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

https://reviews.llvm.org/D79788



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


[PATCH] D79677: [clang][OpenMP][OMPIRBuilder] Adding some Privatization clauses to OpenMP `parallel` Directive

2020-05-14 Thread Fady Ghanim via Phabricator via cfe-commits
fghanim marked 2 inline comments as done.
fghanim added a comment.

In D79677#2032942 , @jdoerfert wrote:

> Generally you copied the existing Clang logic, correct?


Well, Yes and no. I tried to keep as much as I can of the original 
implementation, however, some required more extensive changes.

The things added to `emitparalleldirective` are all new
Almost the latter half of the OMPBuilder version of `emitfirstprivateclause`
somethings in the the OMPBuilder version of `emitcopyinclause`
The rest had minor or smaller changes, but generally the same
the lit tests had some changes




Comment at: clang/lib/CodeGen/CGStmtOpenMP.cpp:803
-  OrigVD);
-else
-  (void)CGM.getOpenMPRuntime().registerTargetFirstprivateCopy(*this,

jdoerfert wrote:
> Wasn't this part of D79675?
> 
> (btw I tried to comprehend why this is needed and it is on my list for things 
> we replace eventually).
ignore - I originally wanted to use the original `emitfirstprivate`, before I 
had to make some changes. This is remaining from that code. The same comment / 
todo is in OMPBuilder specific version below.

I also, removed this from D79676


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79677



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


[PATCH] D79754: [OpenMP][AMDGCN] Support OpenMP offloading for AMDGCN architecture - Part 1

2020-05-14 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: llvm/include/llvm/ADT/Triple.h:699
+  /// Tests whether the target is a GPU i.e. NVPTX or AMDGCN
+  bool isGPU() const { return isNVPTX() || isAMDGCN(); }
+

This is skipping out r600, and probably should leave this in clang?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79754



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


[PATCH] D79948: [OPENMP50]Codegen for inscan reductions in worksharing directives.

2020-05-14 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev created this revision.
ABataev added a reviewer: jdoerfert.
Herald added subscribers: arphaman, guansong, yaxunl.
Herald added a project: clang.

Implemented codegen for reduction clauses with inscan modifiers in
worksharing constructs.

Emits the code for the directive with inscan reductions.
The code is the following:

  size num_iters = ;
   buffer[num_iters];
  for (i: 0..) {
;
buffer[i] = red;
  }
  for (int k = 0; k != ceil(log2(num_iters)); ++k)
  for (size cnt = last_iter; cnt >= pow(2, k); --k)
buffer[i] op= buffer[i-pow(2,k)];
  for (0..) {
red = InclusiveScan ? buffer[i] : buffer[i-1];
;
  }


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79948

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/OpenMP/for_scan_codegen.cpp
  clang/test/OpenMP/scan_messages.cpp
  clang/tools/libclang/CIndex.cpp

Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -2376,6 +2376,17 @@
   for (auto *E : C->reduction_ops()) {
 Visitor->AddStmt(E);
   }
+  if (C->getModifier() == clang::OMPC_REDUCTION_inscan) {
+for (auto *E : C->copy_ops()) {
+  Visitor->AddStmt(E);
+}
+for (auto *E : C->copy_array_temps()) {
+  Visitor->AddStmt(E);
+}
+for (auto *E : C->copy_array_elems()) {
+  Visitor->AddStmt(E);
+}
+  }
 }
 void OMPClauseEnqueue::VisitOMPTaskReductionClause(
 const OMPTaskReductionClause *C) {
Index: clang/test/OpenMP/scan_messages.cpp
===
--- clang/test/OpenMP/scan_messages.cpp
+++ clang/test/OpenMP/scan_messages.cpp
@@ -19,32 +19,32 @@
 #pragma omp for simd reduction(inscan, +: argc)
   for (int i = 0; i < 10; ++i)
 if (argc)
-#pragma omp scan inclusive(argc) // expected-error {{'#pragma omp scan' cannot be an immediate substatement}}
+#pragma omp scan inclusive(argc) // expected-error {{'#pragma omp scan' cannot be an immediate substatement}} expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}}
 if (argc) {
 #pragma omp scan inclusive(argc) // expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}}
 }
 #pragma omp simd reduction(inscan, +: argc)
   for (int i = 0; i < 10; ++i)
   while (argc)
-#pragma omp scan inclusive(argc) // expected-error {{'#pragma omp scan' cannot be an immediate substatement}}
+#pragma omp scan inclusive(argc) // expected-error {{'#pragma omp scan' cannot be an immediate substatement}} expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}}
 while (argc) {
 #pragma omp scan inclusive(argc) // expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}}
 }
 #pragma omp simd reduction(inscan, +: argc)
   for (int i = 0; i < 10; ++i)
   do
-#pragma omp scan inclusive(argc) // expected-error {{'#pragma omp scan' cannot be an immediate substatement}}
+#pragma omp scan inclusive(argc) // expected-error {{'#pragma omp scan' cannot be an immediate substatement}} expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}}
 while (argc)
   ;
-#pragma omp simd reduction(inscan, +: argc)
+#pragma omp simd reduction(inscan, +: argc) // expected-error {{the inscan reduction list item must appear as a list item in an 'inclusive' or 'exclusive' clause on an inner 'omp scan' directive}}
   for (int i = 0; i < 10; ++i)
   do {
-#pragma omp scan inclusive(argc)
+#pragma omp scan inclusive(argc) // expected-error {{orphaned 'omp scan' directives are prohibited; perhaps you forget to enclose the directive into a for, simd, for simd, parallel for, or parallel for simd region?}}
   } while (argc);
 #pragma omp simd reduction(inscan, +: argc)
   for (int i = 0; i < 10; ++i)
   switch (argc)
-#pragma omp scan inclusive(argc) // expected-error {{'#pragma omp scan' cannot be an immediate substatement}}
+#pragma omp scan inclusive(argc) // expected-error {{'#pragma omp scan' cannot be an immediate substatement}} expected-error {{orphaned 'omp scan' directives are 

[PATCH] D79693: [test][ARM][CMSE] Use -ffreestanding for arm_cmse.h tests

2020-05-14 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment.

In D79693#2036599 , @chill wrote:

> How do you trigger a problem?


If your build was configured with `DEFAULT_SYSROOT` to a toolchain path that 
has a `/include` directory, then the contents of that directory would be picked 
up. The intent of the person doing the build with regards to `DEFAULT_SYSROOT` 
is to provide a sysroot for their intended targets, which may not match the 
needs of the explicit target provided here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79693



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


[PATCH] D79676: [Clang][OpenMP][OMPBuilder] Moving OMP allocation and cache creation code to OMPBuilderCBHelpers

2020-05-14 Thread Fady Ghanim via Phabricator via cfe-commits
fghanim marked 4 inline comments as done.
fghanim added inline comments.



Comment at: clang/lib/CodeGen/CGStmtOpenMP.cpp:878
+  [this, VDInit, OriginalAddr, VD, ThisFirstprivateIsLastprivate,
+   OrigVD, , IRef, ]() {
 // Emit private VarDecl with copy init.

jdoerfert wrote:
> Is this needed?
All these are changes that I forgot to remove after I created a special version 
for `EmitOMPFirstprivateClause`  in D79677 for the OMPBuilder



Comment at: clang/lib/CodeGen/CodeGenFunction.h:1581
+++I;
+
+  return &*I;

jdoerfert wrote:
> What is wrong with `BB->getFirstNonPHIOrDbgOrLifetime()`? If it is to avoid 
> too many test changes, please add a TODO. I think from a functional 
> perspective there is no need to advance it after the first set of allocas 
> that may be separated from the phis by non-allocas?
Nothing wrong with it. The first while loop, I just came across a case that I 
don't remember at the moment that had an instruction that wasn't an alloca, and 
I wanted to skip over that.
the second while, is to get to the first non-alloca instruction. The purpose is 
to be able to insert new allocas, after already generated allocas.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79676



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


[PATCH] D79676: [Clang][OpenMP][OMPBuilder] Moving OMP allocation and cache creation code to OMPBuilderCBHelpers

2020-05-14 Thread Fady Ghanim via Phabricator via cfe-commits
fghanim updated this revision to Diff 264012.
fghanim marked an inline comment as done.
fghanim added a comment.

updating in response to review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79676

Files:
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h

Index: clang/lib/CodeGen/CodeGenFunction.h
===
--- clang/lib/CodeGen/CodeGenFunction.h
+++ clang/lib/CodeGen/CodeGenFunction.h
@@ -26,6 +26,7 @@
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/ExprObjC.h"
 #include "clang/AST/ExprOpenMP.h"
+#include "clang/AST/StmtOpenMP.h"
 #include "clang/AST/Type.h"
 #include "clang/Basic/ABI.h"
 #include "clang/Basic/CapturedStmt.h"
@@ -77,6 +78,7 @@
 class ObjCAtSynchronizedStmt;
 class ObjCAutoreleasePoolStmt;
 class ReturnsNonNullAttr;
+class OMPExecutableDirective;
 
 namespace analyze_os_log {
 class OSLogBufferLayout;
@@ -256,114 +258,6 @@
 unsigned Index;
   };
 
-  // Helper class for the OpenMP IR Builder. Allows reusability of code used for
-  // region body, and finalization codegen callbacks. This will class will also
-  // contain privatization functions used by the privatization call backs
-  struct OMPBuilderCBHelpers {
-
-using InsertPointTy = llvm::OpenMPIRBuilder::InsertPointTy;
-
-/// Emit the Finalization for an OMP region
-/// \param CGF	The Codegen function this belongs to
-/// \param IP	Insertion point for generating the finalization code.
-static void FinalizeOMPRegion(CodeGenFunction , InsertPointTy IP) {
-  CGBuilderTy::InsertPointGuard IPG(CGF.Builder);
-  assert(IP.getBlock()->end() != IP.getPoint() &&
- "OpenMP IR Builder should cause terminated block!");
-
-  llvm::BasicBlock *IPBB = IP.getBlock();
-  llvm::BasicBlock *DestBB = IPBB->getUniqueSuccessor();
-  assert(DestBB && "Finalization block should have one successor!");
-
-  // erase and replace with cleanup branch.
-  IPBB->getTerminator()->eraseFromParent();
-  CGF.Builder.SetInsertPoint(IPBB);
-  CodeGenFunction::JumpDest Dest = CGF.getJumpDestInCurrentScope(DestBB);
-  CGF.EmitBranchThroughCleanup(Dest);
-}
-
-/// Emit the body of an OMP region
-/// \param CGF	The Codegen function this belongs to
-/// \param RegionBodyStmt	The body statement for the OpenMP region being
-/// 			 generated
-/// \param CodeGenIP	Insertion point for generating the body code.
-/// \param FiniBB	The finalization basic block
-static void EmitOMPRegionBody(CodeGenFunction ,
-  const Stmt *RegionBodyStmt,
-  InsertPointTy CodeGenIP,
-  llvm::BasicBlock ) {
-  llvm::BasicBlock *CodeGenIPBB = CodeGenIP.getBlock();
-  if (llvm::Instruction *CodeGenIPBBTI = CodeGenIPBB->getTerminator())
-CodeGenIPBBTI->eraseFromParent();
-
-  CGF.Builder.SetInsertPoint(CodeGenIPBB);
-
-  CGF.EmitStmt(RegionBodyStmt);
-
-  if (CGF.Builder.saveIP().isSet())
-CGF.Builder.CreateBr();
-}
-
-/// RAII for preserving necessary info during Outlined region body codegen.
-class OutlinedRegionBodyRAII {
-
-  llvm::AssertingVH OldAllocaIP;
-  CodeGenFunction::JumpDest OldReturnBlock;
-  CodeGenFunction 
-
-public:
-  OutlinedRegionBodyRAII(CodeGenFunction , InsertPointTy ,
- llvm::BasicBlock )
-  : CGF(cgf) {
-assert(AllocaIP.isSet() &&
-   "Must specify Insertion point for allocas of outlined function");
-OldAllocaIP = CGF.AllocaInsertPt;
-CGF.AllocaInsertPt = &*AllocaIP.getPoint();
-
-OldReturnBlock = CGF.ReturnBlock;
-CGF.ReturnBlock = CGF.getJumpDestInCurrentScope();
-  }
-
-  ~OutlinedRegionBodyRAII() {
-CGF.AllocaInsertPt = OldAllocaIP;
-CGF.ReturnBlock = OldReturnBlock;
-  }
-};
-
-/// RAII for preserving necessary info during inlined region body codegen.
-class InlinedRegionBodyRAII {
-
-  llvm::AssertingVH OldAllocaIP;
-  CodeGenFunction 
-
-public:
-  InlinedRegionBodyRAII(CodeGenFunction , InsertPointTy ,
-llvm::BasicBlock )
-  : CGF(cgf) {
-// Alloca insertion block should be in the entry block of the containing
-// function so it expects an empty AllocaIP in which case will reuse the
-// old alloca insertion point, or a new AllocaIP in the same block as
-// the old one
-assert((!AllocaIP.isSet() ||
-CGF.AllocaInsertPt->getParent() == AllocaIP.getBlock()) &&
-   "Insertion point should be in the entry block of containing "
-   "function!");
-OldAllocaIP = CGF.AllocaInsertPt;
-if 

[clang] 235fb7d - AMDGPU/OpenCL: Accept -nostdlib in place of -nogpulib

2020-05-14 Thread Matt Arsenault via cfe-commits

Author: Matt Arsenault
Date: 2020-05-14T12:33:31-04:00
New Revision: 235fb7dc24b1cf7034dfc76bb853ffb4ac5dec5d

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

LOG: AMDGPU/OpenCL: Accept -nostdlib in place of -nogpulib

-nogpulib makes sense when there is a host (where -nostdlib would
 apply) and offload target. Accept nostdlib when there is no offload
 target as an alias.

Added: 
clang/test/Driver/rocm-detect.hip

Modified: 
clang/lib/Driver/ToolChains/AMDGPU.cpp
clang/test/Driver/rocm-not-found.cl

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp 
b/clang/lib/Driver/ToolChains/AMDGPU.cpp
index fd81fec5f452..193ccad98f52 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -361,6 +361,12 @@ void ROCMToolChain::addClangTargetOptions(
   AMDGPUToolChain::addClangTargetOptions(DriverArgs, CC1Args,
  DeviceOffloadingKind);
 
+  // For the OpenCL case where there is no offload target, accept -nostdlib to
+  // disable bitcode linking.
+  if (DeviceOffloadingKind == Action::OFK_None &&
+  DriverArgs.hasArg(options::OPT_nostdlib))
+return;
+
   if (DriverArgs.hasArg(options::OPT_nogpulib))
 return;
 

diff  --git a/clang/test/Driver/rocm-detect.hip 
b/clang/test/Driver/rocm-detect.hip
new file mode 100644
index ..82ed7138098a
--- /dev/null
+++ b/clang/test/Driver/rocm-detect.hip
@@ -0,0 +1,27 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: amdgpu-registered-target
+
+// Make sure the appropriate device specific library is available.
+
+// We don't include every target in the test directory, so just pick a valid
+// target not included in the test.
+
+// RUN: %clang -### -v -target x86_64-linux-gnu --cuda-gpu-arch=gfx902 \
+// RUN:   --rocm-path=%S/Inputs/rocm-device-libs %s 2>&1 \
+// RUN:   | FileCheck -check-prefixes=COMMON,GFX902-DEFAULTLIBS %s
+
+// Should not interpret -nostdlib as disabling offload libraries.
+// RUN: %clang -### -v -target x86_64-linux-gnu --cuda-gpu-arch=gfx902 
-nostdlib \
+// RUN:   --rocm-path=%S/Inputs/rocm-device-libs %s 2>&1 \
+// RUN:   | FileCheck -check-prefixes=COMMON,GFX902-DEFAULTLIBS %s
+
+
+// RUN: %clang -### -v -target x86_64-linux-gnu --cuda-gpu-arch=gfx902 
-nogpulib \
+// RUN:   --rocm-path=%S/Inputs/rocm-device-libs %s 2>&1 \
+// RUN:   | FileCheck -check-prefixes=COMMON,GFX902,NODEFAULTLIBS %s
+
+
+// GFX902-DEFAULTLIBS: error: cannot find device library for gfx902. Provide 
path to 
diff erent ROCm installation via --rocm-path, or pass -nogpulib to build 
without linking default libraries.
+
+// NODEFAULTLIBS-NOT: error: cannot find

diff  --git a/clang/test/Driver/rocm-not-found.cl 
b/clang/test/Driver/rocm-not-found.cl
index 49b6c7efcf99..8ecc4b0ef105 100644
--- a/clang/test/Driver/rocm-not-found.cl
+++ b/clang/test/Driver/rocm-not-found.cl
@@ -7,5 +7,7 @@
 // RUN: %clang -### --rocm-path=%s/no-rocm-there -target amdgcn--amdhsa %s 
2>&1 | FileCheck %s --check-prefix ERR
 // ERR: cannot find ROCm installation. Provide its path via --rocm-path, or 
pass -nogpulib.
 
+// Accept nogpulib or nostdlib for OpenCL.
 // RUN: %clang -### -nogpulib --rocm-path=%s/no-rocm-there %s 2>&1 | FileCheck 
%s --check-prefix OK
+// RUN: %clang -### -nostdlib --rocm-path=%s/no-rocm-there %s 2>&1 | FileCheck 
%s --check-prefix OK
 // OK-NOT: cannot find ROCm installation.



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


[PATCH] D79000: [clang-format] C# property formatting can be controlled by config options

2020-05-14 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

I'm ok with your suggestion if you want to land this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79000



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


[PATCH] D34252: Add arbitrary file/path support to clang-format style file selection

2020-05-14 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

I think we can abandon this revision now we support --style=file:


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

https://reviews.llvm.org/D34252



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


[PATCH] D79465: [clang-format] Fix line lengths w/ comments in align

2020-05-14 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/lib/Format/WhitespaceManager.cpp:417
+LineLengthAfter += Changes[j].TokenLength;
+}
 unsigned ChangeMaxColumn = Style.ColumnLimit - LineLengthAfter;

could you help us here with a comment, I don't understand what they mean by 
Change.IsInsideToken?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79465



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


[PATCH] D79715: [clang-format] Update GoogleStyle for C# code to match Google's internal C# style guide

2020-05-14 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay added a comment.
This revision is now accepted and ready to land.

Assuming you either work for google and understand their style or are qualified 
to say this is their style then this LGTM

What I couldn't see from the link was where the google C# style guide was?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79715



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


[PATCH] D70351: [clang][WIP][clang-scan-deps] Add an experimental C API.

2020-05-14 Thread Kousik Kumar via Phabricator via cfe-commits
kousikk added a comment.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70351



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


[PATCH] D79693: [test][ARM][CMSE] Use -ffreestanding for arm_cmse.h tests

2020-05-14 Thread Momchil Velikov via Phabricator via cfe-commits
chill added a comment.

I'm sorry, I don't understand the issue. Certainly it's the compiler (driver) 
responsibility to setup include paths according to the selected target.
How do you trigger a problem?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79693



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


[PATCH] D79704: [Analyzer] [NFC] Parameter Regions

2020-05-14 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

In D79704#2034571 , @NoQ wrote:

> In D79704#2032947 , @Szelethus wrote:
>
> > In D79704#2032271 , @NoQ wrote:
> >
> > > Blanket reply! `ParamRegion` is not a `DeclRegion` because it does not 
> > > necessarily have a corresponding `Decl`. For instance, when calling a 
> > > function through an unknown function pointer, you don't have the 
> > > declaration of a function, let alone its parameters.
> >
> >
> > Well hold on for a second then -- how is this, if it is, different for 
> > member pointers? Aren't they represented with a `VarRegion`?
>
>
> They aren't even `Loc`!
>
> We currently don't have a representation for an unknown pointer-to-member. A 
> known pointer-to-member is represented by a `FieldDecl` (not sure about 
> static members) but it's still a `NonLoc` and as such isn't a region at all. 
> Because, well, you can't dereference a pointer-to-member; you can only apply 
> it to a base pointer like an offset. The mental model is "an offset". 
> Therefore it's `NonLoc`.
>
> Pointers to member functions are a different thing; they're function pointers 
> so they're kinda regions.
>
> >> But for parameters of C++ object type you still need your `ParamRegion` 
> >> because arguments are constructed into it.
> > 
> > Could you give a specific code example?
>
>
>
>   struct S {
> S() {
>   this; // What region does 'this' point to...
> }
>   };
>  
>   void foo(void (*bar)(S)) {
> bar(S()); // ...in this invocation?
>   }
>


I remember this coming up so many times, and I'm an inch away from getting it 
but I'm not there just yet ^-^ Sorry if you have to repeat yourself too many 
times.

The example you have shown sounds like a case we could (should?) abstract away. 
If we model in accordance to the AST as closely as possible, `ParamRegion` 
should totally be a `VarRegion`. If something tricky like this came up, the 
`getDecl` function should just return with a nullptr, shouldn't it? The code 
changes make me feel like we're doing a lot of chore (and make it super easy to 
forget checking for parameters explicitly). The gain, which is I guess 
correctness, seems negligible, and I'm not sure this is actually correct, as I 
mentioned in D79704#inline-730731 
. I don't see why the most 
defining feature of a `DeclRegion` is supposed to be an always existing `Decl`, 
rather than a mirror of the AST.


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

https://reviews.llvm.org/D79704



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


  1   2   >