[clang] 323a6bf - Add "REQUIRES: arm-registered-target" line to test added in D108603.

2021-08-24 Thread Douglas Yung via cfe-commits

Author: Douglas Yung
Date: 2021-08-24T22:22:16-07:00
New Revision: 323a6bfbb8cf8082e22dc482abeaf6664d84bbdf

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

LOG: Add "REQUIRES: arm-registered-target" line to test added in D108603.

This should fix the test failure on the PS4 build bot.

Added: 


Modified: 
clang/test/CodeGen/linker-diagnostic.ll

Removed: 




diff  --git a/clang/test/CodeGen/linker-diagnostic.ll 
b/clang/test/CodeGen/linker-diagnostic.ll
index 8e4f5a38c8dd..c8406314f8d6 100644
--- a/clang/test/CodeGen/linker-diagnostic.ll
+++ b/clang/test/CodeGen/linker-diagnostic.ll
@@ -1,3 +1,4 @@
+; REQUIRES: arm-registered-target
 ; RUN: mkdir -p %t
 ; RUN: opt -module-summary -o %t/foo.o %s
 ; RUN: opt -module-summary -o %t/bar.o %S/Inputs/linker-diagnostic1.ll



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


[PATCH] D108615: [Coroutines] [libcxx] Move coroutine component out of experimental namespace

2021-08-24 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

In D108615#2962618 , @lxfind wrote:

> I am not familiar with the process of when to move something out of 
> experimental, but I do wonder how this is normally done so that people who 
> uses coroutines can have a smooth migration?
> I assume that this is going to be a breaking change that existing code using 
> coroutine will need to be updated and no longer compatible with old versions.

Thanks for reporting this. Now the clang could still look up in 
std::experimental namespace of  once it fails to look up in std namespace. So 
now it wouldn't be  a break change if the user upgrade the version clang only.


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

https://reviews.llvm.org/D108615

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


[PATCH] D36850: [ThinLTO] Add norecurse function attribute propagation

2021-08-24 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

In D36850#2958594 , @modimo wrote:

> @tejohnson Indirect calls are not captured in FunctionSummaries in CallGraph 
> or in a flag form saying they exist. Also looks like 
> 
>  speculative candidates for ICP do make it on the graph. For this analysis we 
> need to bail out on indirect calls so I think the simplest way is to add a 
> flag indicating the presence of them (In FunFlags?). As for the speculative 
> candidates, it's probably not too big of a deal.

Good point on indirect calls. Rather than add a bit to the summary, can the 
flags just be set conservatively in any function containing an indirect call 
when we build the summaries initially? I think that would get the same effect. 
For speculative devirtualization aka ICP, we will still be left with a fallback 
indirect call, so it would still need to be treated conservatively. The extra 
edges added for ICP promotion candidates shouldn't be a problem or affect this.

Note that with class hierarchy analysis we can do better for virtual calls, 
e.g. when -fwhole-program-vtables is enabled for whole program devirtualization 
and we have the necessary whole program visibility on vtables. We could 
potentially integrate WPD decision here. Even if we can't find a single 
devirtualization target, we can compute the set of all possible targets of 
virtual calls during the thin link and could use that information to basically 
merge the attributes from all possible targets. But probably best to leave that 
as a future refinement as it will take some additional work to get that hooked 
up. We'd still need to be conservative for virtual calls when we don't have the 
necessary type info (when -fwhole-program-vtables not enabled or we don't have 
whole program visibility on the vtable defs), or for non-virtual indirect calls.




Comment at: llvm/lib/Transforms/IPO/FunctionAttrs.cpp:383
+  //   occur in a couple of circumstances:
+  //  a. An internal function gets imported due to its caller getting
+  //  imported, it becomes AvailableExternally

I'm not sure how this case could be happening as we haven't actually done the 
importing that would create these new available externally copies yet - that 
happens in the LTO backends, during the thin link we just add them to import 
lists.



Comment at: llvm/lib/Transforms/IPO/FunctionAttrs.cpp:388
+  // propagating on its caller.
+  //  b. C++11 [temp.explicit]p10 can generate AvailableExternally
+  //  definitions of explicitly instanced template declarations

There is no prevailing copy presumably because the prevailing copy is in a 
native library being linked? I think these cases can be handled conservatively.



Comment at: llvm/lib/Transforms/IPO/FunctionAttrs.cpp:413
+  assert(AS->hasAliasee());
+  FS = dyn_cast(AS->getBaseObject());
+} else {

You can just unconditionally do the getBaseObject call on the GVS without 
casting to AliasSummary. For non-AliasSummary it will just return itself.



Comment at: llvm/lib/Transforms/IPO/FunctionAttrs.cpp:419
+// Virtual calls are unknown so go conservative
+if (!FS || FS->getTypeIdInfo())
+  return CachedAttributes[VI];

I think this checking for virtual calls will only work if 
-fwhole-program-vtables is enabled for whole program devirtualization or CFI. 
Otherwise we don't have the type tests that cause this to get populated. This 
also won't detect non-virtual indirect calls.



Comment at: llvm/lib/Transforms/IPO/FunctionAttrs.cpp:443
+  // we'll keep the last one seen.
+  ODR = FS;
+} else if (!Prevailing && !ODR) {

modimo wrote:
> tejohnson wrote:
> > Won't we still have a copy marked prevailing? Wondering if the weak linkage 
> > cases can all be merged.
> Yeah, there will still be a copy that's prevailing. Reading through the 
> linkage descriptions again and also those in 
> `FunctionImportGlobalProcessing::getLinkage`:
> 
> 1. I think with External/WeakODR/LinkOnceODR once the prevailing is found use 
> that copy
> 
> 2. For Weak/LinkOnce even with a prevailing copy I don't know if the copy 
> ultimately used will be prevailing. I'm wondering if a native definition 
> could be the victor in which case we just can't propagate off these 
> functions. 
> 
> WDYT about (2)? For C++ at least these don't seem to really exist and testing 
> with Clang self-build I'm not seeing this kick in anywhere. I added a flag to 
> specifically disable this case so it's easy to test out the differences.
Since the linker which invokes this should have been passed all objects to 
link, bitcode and native, it can do symbol resolution across all of them. So if 
there is an 

[PATCH] D108618: [CGCall] Add NoInline attr if presented for the target

2021-08-24 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Why do you want to add `noinline` to a function declaration that lacks a 
definition?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108618

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


[PATCH] D107450: [clang-tidy] Fix wrong FIxIt in performance-move-const-arg

2021-08-24 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/performance-move-const-arg.cpp:262-263
+  int a = 10;
+  forwardToShowInt(std::move(a));
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: std::move of the variable 'a' 
of the trivially-copyable type 'int' has no effect
+}

Sockke wrote:
> Quuxplusone wrote:
> > ```
> >   forwardToShowInt(std::move(a));
> >   // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: std::move of the variable 
> > 'a' of the trivially-copyable type 'int' has no effect
> > ```
> > I continue to want-not-to-block this PR, since I think it's improving the 
> > situation. However, FWIW...
> > It's good that this message doesn't contain a fixit, since there's nothing 
> > the programmer can really do to "fix" this call. But then, should this 
> > message be emitted at all? If this were `clang -Wall`, then we definitely 
> > would //not// want to emit a "noisy" warning where there's basically 
> > nothing the programmer can do about it. Does clang-tidy have a similar 
> > philosophy? Or is it okay for clang-tidy to say "This code looks wonky" 
> > even when there's no obvious way to fix it?
> > ```
> >   forwardToShowInt(std::move(a));
> >   // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: std::move of the variable 
> > 'a' of the trivially-copyable type 'int' has no effect
> > ```
> > I continue to want-not-to-block this PR, since I think it's improving the 
> > situation. However, FWIW...
> > It's good that this message doesn't contain a fixit, since there's nothing 
> > the programmer can really do to "fix" this call. But then, should this 
> > message be emitted at all? If this were `clang -Wall`, then we definitely 
> > would //not// want to emit a "noisy" warning where there's basically 
> > nothing the programmer can do about it. Does clang-tidy have a similar 
> > philosophy? Or is it okay for clang-tidy to say "This code looks wonky" 
> > even when there's no obvious way to fix it?
> 
> Yes, I agree with you. I did not remove warning to maintain the original 
> behavior, which will make the current patch clearer. In any case, it is easy 
> for me to make this modification if you want. 
I'll defer on this subject to whomever you get to review the code change in 
`MoveConstArgCheck.cpp`. (@whisperity perhaps?)


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

https://reviews.llvm.org/D107450

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


[PATCH] D107021: [Sema][ObjC] Allow conversions between pointers to ObjC pointers and pointers to structs

2021-08-24 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Alright, LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107021

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


[PATCH] D102449: [WIP][Clang][OpenMP] Add the support for compare clause in atomic directive

2021-08-24 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 planned changes to this revision.
tianshilei1992 marked an inline comment as done.
tianshilei1992 added a comment.

I'm going to move code gen into `OMPIRBuilder`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102449

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


[PATCH] D108680: PR48030: Fix COMDAT-related linking problem with C++ thread_local static data members.

2021-08-24 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcd4d6d718b2e: PR48030: Fix COMDAT-related linking problem 
with C++ thread_local static data… (authored by rsmith).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108680

Files:
  clang/lib/CodeGen/CGDeclCXX.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/test/CodeGenCXX/cxx11-thread-local-instantiated.cpp
  clang/test/CodeGenCXX/cxx11-thread-local.cpp
  clang/test/CodeGenCXX/cxx1z-inline-variables.cpp
  clang/test/OpenMP/threadprivate_codegen.cpp

Index: clang/test/OpenMP/threadprivate_codegen.cpp
===
--- clang/test/OpenMP/threadprivate_codegen.cpp
+++ clang/test/OpenMP/threadprivate_codegen.cpp
@@ -3847,7 +3847,7 @@
 //
 //
 // CHECK-TLS1-LABEL: define {{[^@]+}}@__cxx_global_var_init.3
-// CHECK-TLS1-SAME: () #[[ATTR0]] comdat($_ZN2STI2S4E2stE) {
+// CHECK-TLS1-SAME: () #[[ATTR0]] {
 // CHECK-TLS1-NEXT:  entry:
 // CHECK-TLS1-NEXT:[[TMP0:%.*]] = load i8, i8* bitcast (i64* @_ZGVN2STI2S4E2stE to i8*), align 8
 // CHECK-TLS1-NEXT:[[GUARD_UNINITIALIZED:%.*]] = icmp eq i8 [[TMP0]], 0
@@ -4373,7 +4373,7 @@
 //
 //
 // CHECK-TLS2-LABEL: define {{[^@]+}}@__cxx_global_var_init.3
-// CHECK-TLS2-SAME: () #[[ATTR6]] comdat($_ZN2STI2S4E2stE) {
+// CHECK-TLS2-SAME: () #[[ATTR6]] {
 // CHECK-TLS2-NEXT:  entry:
 // CHECK-TLS2-NEXT:[[TMP0:%.*]] = load i8, i8* bitcast (i64* @_ZGVN2STI2S4E2stE to i8*), align 8
 // CHECK-TLS2-NEXT:[[GUARD_UNINITIALIZED:%.*]] = icmp eq i8 [[TMP0]], 0
@@ -4906,7 +4906,7 @@
 //
 //
 // CHECK-TLS3-LABEL: define {{[^@]+}}@__cxx_global_var_init.3
-// CHECK-TLS3-SAME: () #[[ATTR0]] comdat($_ZN2STI2S4E2stE) !dbg [[DBG289:![0-9]+]] {
+// CHECK-TLS3-SAME: () #[[ATTR0]] !dbg [[DBG289:![0-9]+]] {
 // CHECK-TLS3-NEXT:  entry:
 // CHECK-TLS3-NEXT:[[TMP0:%.*]] = load i8, i8* bitcast (i64* @_ZGVN2STI2S4E2stE to i8*), align 8, !dbg [[DBG290:![0-9]+]]
 // CHECK-TLS3-NEXT:[[GUARD_UNINITIALIZED:%.*]] = icmp eq i8 [[TMP0]], 0, !dbg [[DBG290]]
@@ -5459,7 +5459,7 @@
 //
 //
 // CHECK-TLS4-LABEL: define {{[^@]+}}@__cxx_global_var_init.3
-// CHECK-TLS4-SAME: () #[[ATTR7]] comdat($_ZN2STI2S4E2stE) !dbg [[DBG289:![0-9]+]] {
+// CHECK-TLS4-SAME: () #[[ATTR7]] !dbg [[DBG289:![0-9]+]] {
 // CHECK-TLS4-NEXT:  entry:
 // CHECK-TLS4-NEXT:[[TMP0:%.*]] = load i8, i8* bitcast (i64* @_ZGVN2STI2S4E2stE to i8*), align 8, !dbg [[DBG290:![0-9]+]]
 // CHECK-TLS4-NEXT:[[GUARD_UNINITIALIZED:%.*]] = icmp eq i8 [[TMP0]], 0, !dbg [[DBG290]]
Index: clang/test/CodeGenCXX/cxx1z-inline-variables.cpp
===
--- clang/test/CodeGenCXX/cxx1z-inline-variables.cpp
+++ clang/test/CodeGenCXX/cxx1z-inline-variables.cpp
@@ -90,9 +90,7 @@
 // CHECK-LABEL: define {{.*}}global_var_init
 // CHECK: call i32 @_Z1fv
 
-// CHECK-LABEL: define {{.*}}global_var_init
-// CHECK-NOT: comdat
-// CHECK-SAME: {{$}}
+// CHECK-LABEL: define {{.*}}global_var_init{{.*}} comdat($b)
 // CHECK: load atomic {{.*}} acquire, align
 // CHECK: br
 // CHECK: __cxa_guard_acquire(i64* @_ZGV1b)
Index: clang/test/CodeGenCXX/cxx11-thread-local.cpp
===
--- clang/test/CodeGenCXX/cxx11-thread-local.cpp
+++ clang/test/CodeGenCXX/cxx11-thread-local.cpp
@@ -179,8 +179,7 @@
 
 // LINUX_AIX: define internal void @[[VF_M_INIT]]()
 // DARWIN: define internal cxx_fast_tlscc void @[[VF_M_INIT]]()
-// LINUX-SAME: comdat($_ZN1VIfE1mE)
-// DARWIN-NOT: comdat
+// CHECK-NOT: comdat
 // CHECK: load i8, i8* bitcast (i64* @_ZGVN1VIfE1mE to i8*)
 // CHECK: %[[VF_M_INITIALIZED:.*]] = icmp eq i8 %{{.*}}, 0
 // CHECK: br i1 %[[VF_M_INITIALIZED]],
@@ -192,8 +191,7 @@
 
 // LINUX_AIX: define internal void @[[XF_M_INIT]]()
 // DARWIN: define internal cxx_fast_tlscc void @[[XF_M_INIT]]()
-// LINUX-SAME: comdat($_ZN1XIfE1mE)
-// DARWIN-NOT: comdat
+// CHECK-NOT: comdat
 // CHECK: load i8, i8* bitcast (i64* @_ZGVN1XIfE1mE to i8*)
 // CHECK: %[[XF_M_INITIALIZED:.*]] = icmp eq i8 %{{.*}}, 0
 // CHECK: br i1 %[[XF_M_INITIALIZED]],
@@ -313,8 +311,7 @@
 
 // LINUX_AIX: define internal void @[[V_M_INIT]]()
 // DARWIN: define internal cxx_fast_tlscc void @[[V_M_INIT]]()
-// LINUX-SAME: comdat($_ZN1VIiE1mE)
-// DARWIN-NOT: comdat
+// CHECK-NOT: comdat
 // CHECK: load i8, i8* bitcast (i64* @_ZGVN1VIiE1mE to i8*)
 // CHECK: %[[V_M_INITIALIZED:.*]] = icmp eq i8 %{{.*}}, 0
 // CHECK: br i1 %[[V_M_INITIALIZED]],
@@ -326,8 +323,7 @@
 
 // LINUX_AIX: define internal void @[[X_M_INIT]]()
 // DARWIN: define internal cxx_fast_tlscc void @[[X_M_INIT]]()
-// LINUX-SAME: comdat($_ZN1XIiE1mE)
-// DARWIN-NOT: comdat
+// CHECK-NOT: comdat
 // CHECK: load i8, i8* bitcast (i64* @_ZGVN1XIiE1mE to i8*)
 // CHECK: %[[X_M_INITIALIZED:.*]] = icmp eq i8 %{{.*}}, 0
 // CHECK: br i1 %[[X_M_INITIALIZED]],
Index: 

[clang] cd4d6d7 - PR48030: Fix COMDAT-related linking problem with C++ thread_local static data members.

2021-08-24 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2021-08-24T19:53:44-07:00
New Revision: cd4d6d718b2e51ed830a28d01d765da2a220afd3

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

LOG: PR48030: Fix COMDAT-related linking problem with C++ thread_local static 
data members.

Previously when emitting a C++ guarded initializer, we tried to work out what
the enclosing function would be used for and added it to the COMDAT containing
the variable if we thought that doing so would be correct. But this was done
from a context in which we didn't -- and realistically couldn't -- correctly
infer how the enclosing function would be used.

Instead, add the initialization function to a COMDAT from the code that
creates it, in the case where it makes sense to do so: when we know that
the one and only reference to the initialization function is in
@llvm.global.ctors and that reference is in the same COMDAT.

Reviewed By: rjmccall

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

Added: 
clang/test/CodeGenCXX/cxx11-thread-local-instantiated.cpp

Modified: 
clang/lib/CodeGen/CGDeclCXX.cpp
clang/lib/CodeGen/ItaniumCXXABI.cpp
clang/test/CodeGenCXX/cxx11-thread-local.cpp
clang/test/CodeGenCXX/cxx1z-inline-variables.cpp
clang/test/OpenMP/threadprivate_codegen.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp
index 553fedebfe56b..d22f9dc3b68cd 100644
--- a/clang/lib/CodeGen/CGDeclCXX.cpp
+++ b/clang/lib/CodeGen/CGDeclCXX.cpp
@@ -581,6 +581,16 @@ CodeGenModule::EmitCXXGlobalVarDeclInitFunc(const VarDecl 
*D,
   // llvm.used to prevent linker GC.
   addUsedGlobal(COMDATKey);
 }
+
+// If we used a COMDAT key for the global ctor, the init function can be
+// discarded if the global ctor entry is discarded.
+// FIXME: Do we need to restrict this to ELF and Wasm?
+llvm::Comdat *C = Addr->getComdat();
+if (COMDATKey && C &&
+(getTarget().getTriple().isOSBinFormatELF() ||
+ getTarget().getTriple().isOSBinFormatWasm())) {
+  Fn->setComdat(C);
+}
   } else {
 I = DelayedCXXInitPosition.find(D); // Re-do lookup in case of re-hash.
 if (I == DelayedCXXInitPosition.end()) {

diff  --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp 
b/clang/lib/CodeGen/ItaniumCXXABI.cpp
index d3dc0e6212b8c..8ddc2f1885eb1 100644
--- a/clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -2445,11 +2445,6 @@ void ItaniumCXXABI::EmitGuardedInit(CodeGenFunction ,
 (CGM.getTarget().getTriple().isOSBinFormatELF() ||
  CGM.getTarget().getTriple().isOSBinFormatWasm())) {
   guard->setComdat(C);
-  // An inline variable's guard function is run from the per-TU
-  // initialization function, not via a dedicated global ctor function, so
-  // we can't put it in a comdat.
-  if (!NonTemplateInline)
-CGF.CurFn->setComdat(C);
 } else if (CGM.supportsCOMDAT() && guard->isWeakForLinker()) {
   guard->setComdat(CGM.getModule().getOrInsertComdat(guard->getName()));
 }

diff  --git a/clang/test/CodeGenCXX/cxx11-thread-local-instantiated.cpp 
b/clang/test/CodeGenCXX/cxx11-thread-local-instantiated.cpp
new file mode 100644
index 0..3c78c7f7df902
--- /dev/null
+++ b/clang/test/CodeGenCXX/cxx11-thread-local-instantiated.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -triple x86_64-linux-gnu | 
FileCheck %s
+
+// PR48030
+
+template struct TLS { static thread_local T *mData; };
+inline decltype(nullptr) non_constant_initializer() { return nullptr; }
+template thread_local T *TLS::mData = 
non_constant_initializer();
+struct S {};
+S *current() { return TLS::mData; };
+
+// CHECK-DAG: @_ZN3TLSI1SE5mDataE = linkonce_odr thread_local global {{.*}}, 
comdat,
+// CHECK-DAG: @_ZGVN3TLSI1SE5mDataE = linkonce_odr thread_local global {{.*}}, 
comdat($_ZN3TLSI1SE5mDataE),
+// CHECK-DAG: @_ZTHN3TLSI1SE5mDataE = linkonce_odr alias {{.*}} 
@__cxx_global_var_init
+
+// CHECK-LABEL: define {{.*}} @_Z7currentv()
+// CHECK: call {{.*}} @_ZTWN3TLSI1SE5mDataE()
+
+// CHECK-LABEL: define weak_odr hidden {{.*}} @_ZTWN3TLSI1SE5mDataE() {{.*}} 
comdat {
+// CHECK: call void @_ZTHN3TLSI1SE5mDataE()
+// CHECK: ret {{.*}} @_ZN3TLSI1SE5mDataE
+
+// Unlike for a global, the global initialization function must not be in a
+// COMDAT with the variable, because it is referenced from the _ZTH function
+// which is outside that COMDAT.
+//
+// CHECK-NOT: define {{.*}} @__cxx_global_var_init{{.*}}comdat

diff  --git a/clang/test/CodeGenCXX/cxx11-thread-local.cpp 
b/clang/test/CodeGenCXX/cxx11-thread-local.cpp
index f3146715b9214..e63762ee7bfa0 100644
--- a/clang/test/CodeGenCXX/cxx11-thread-local.cpp
+++ b/clang/test/CodeGenCXX/cxx11-thread-local.cpp
@@ -179,8 

[PATCH] D108680: PR48030: Fix COMDAT-related linking problem with C++ thread_local static data members.

2021-08-24 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108680

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


[PATCH] D108643: Introduce _BitInt, deprecate _ExtInt

2021-08-24 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

I agree with James; I know you've reached out to the Itanium ABI group about 
mangling, but ABI involvement needs to mean also reaching out and getting psABI 
agreement about representation.  I would suggest proposing a generic ABI, 
getting consensus on that generic ABI with other implementors, and then running 
that generic ABI past as many platform ABI groups as you can get in touch with.

I think the most logical generic ABI is:

- Let `MaxFundamentalWidth` be the (target-chosen) bit-width of the largest 
fundamental integer type that can be used to represent a `_BitInt`.  Typically 
this will be the largest integer type supported by the ABI, but some targets 
may want to use a smaller limit.  At the very least, this needs to be locked 
down in the ABI; the ABI for `_BitInt(256)` shouldn't change if the ABI adds 
new support for  an `int256_t` type.
- Let `chunk_t` be the (target-chosen) fundamental integer type that will be 
used to store the components of a `_BitInt` that is wider than 
`MaxFundamentalWidth`.  This should be an integer type that the architecture 
comfortably supports overflow operations on, and it will typically be the full 
width of a GPR.
- Let `ChunkWidth` be defined as `CHAR_BITS * sizeof(chunk_t)`.
- If `N < RepWidth(N)`, then signed/unsigned `_BitInt(N)` has the same 
representation as `_BitInt(RepWidth(N))`, with the value held in the least 
significant bits and sign/zero-extended to the full width.  Values must be in 
the proper range of the original type; that is, it is undefined behavior if 
e.g. a `signed _BitInt(7)` does not hold a value in the range of `-64 ..< 63`.  
Hereafter we will assume that `N == RepWidth(N)`.
- If `N <= MaxFundamentalWidth`, then signed/unsigned `_BitInt(N)` has the same 
representation as the smallest fundamental integer type (least rank, if 
material) of at least `N` bits and the same signedness.  `_Bool` is not 
considered in this selection.
- Otherwise, signed/unsigned `_BitInt(N)` has the same representation as a 
`struct` containing a single field of type `chunk_t[N / sizeof(chunk_t)]`, 
where the element at index `i` stores bits `i*ChunkWidth ..< (i+1)*ChunkWidth` 
of the integer.  That is, the array is always stored in little-endian order, 
which should have better memory-access properties regardless of the endianness 
of the target.  (The individual elements still have natural host endianness, of 
course.)

Some targets that don't pass/return small structs efficiently as a matter of 
course may want to treat smallish (but still non-fundamental) `_BitInt`s 
specially in their calling convention.

I think using a uniform, GPR-sized chunk makes more sense than trying to use a 
smaller chunk that might eliminate some padding.  I could imagine that a 64-bit 
platform that supports 32-bit overflow checking might consider represent 
`_BitInt(96)` with three 32-bit chunks instead of two 64-bit chunks, and that 
would indeed make an array of them pack better, but it would also mean that 
e.g. addition would take three operations instead of two.

You can't have bit-fields of `_BitInt` type, can you?  If people want that, or 
want a truly packed `_BitInt` where `sizeof(_BitInt(56)) == 7`, it's going to 
add a lot of complexity.


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

https://reviews.llvm.org/D108643

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


[PATCH] D108680: PR48030: Fix COMDAT-related linking problem with C++ thread_local static data members.

2021-08-24 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

Note that there's a potential ABI impact here: because we accidentally put the 
`__cxx_global_init` function into a COMDAT with the variable, that meant that 
the `_ZTH` symbol (which is an alias to `__cxx_global_init`) also pointed into 
that same COMDAT. I'm not sure how much that matters given that the old 
behavior was broken.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108680

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


[PATCH] D67429: Improve code generation for thread_local variables:

2021-08-24 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

https://reviews.llvm.org/D108680


Repository:
  rL LLVM

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

https://reviews.llvm.org/D67429

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


[PATCH] D108680: PR48030: Fix COMDAT-related linking problem with C++ thread_local static data members.

2021-08-24 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith created this revision.
rsmith added a reviewer: rjmccall.
rsmith requested review of this revision.
Herald added subscribers: cfe-commits, aheejin.
Herald added a project: clang.

Previously when emitting a C++ guarded initializer, we tried to work out what
the enclosing function would be used for and added it to the COMDAT containing
the variable if we thought that doing so would be correct. But this was done
from a context in which we didn't -- and realistically couldn't -- correctly
infer how the enclosing function would be used.

Instead, add the initialization function to a COMDAT from the code that
creates it, in the case where it makes sense to do so: when we know that
the one and only reference to the initialization function is in
@llvm.global.ctors and that reference is in the same COMDAT.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108680

Files:
  clang/lib/CodeGen/CGDeclCXX.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/test/CodeGenCXX/cxx11-thread-local-instantiated.cpp
  clang/test/CodeGenCXX/cxx11-thread-local.cpp
  clang/test/CodeGenCXX/cxx1z-inline-variables.cpp
  clang/test/OpenMP/threadprivate_codegen.cpp

Index: clang/test/OpenMP/threadprivate_codegen.cpp
===
--- clang/test/OpenMP/threadprivate_codegen.cpp
+++ clang/test/OpenMP/threadprivate_codegen.cpp
@@ -3847,7 +3847,7 @@
 //
 //
 // CHECK-TLS1-LABEL: define {{[^@]+}}@__cxx_global_var_init.3
-// CHECK-TLS1-SAME: () #[[ATTR0]] comdat($_ZN2STI2S4E2stE) {
+// CHECK-TLS1-SAME: () #[[ATTR0]] {
 // CHECK-TLS1-NEXT:  entry:
 // CHECK-TLS1-NEXT:[[TMP0:%.*]] = load i8, i8* bitcast (i64* @_ZGVN2STI2S4E2stE to i8*), align 8
 // CHECK-TLS1-NEXT:[[GUARD_UNINITIALIZED:%.*]] = icmp eq i8 [[TMP0]], 0
@@ -4373,7 +4373,7 @@
 //
 //
 // CHECK-TLS2-LABEL: define {{[^@]+}}@__cxx_global_var_init.3
-// CHECK-TLS2-SAME: () #[[ATTR6]] comdat($_ZN2STI2S4E2stE) {
+// CHECK-TLS2-SAME: () #[[ATTR6]] {
 // CHECK-TLS2-NEXT:  entry:
 // CHECK-TLS2-NEXT:[[TMP0:%.*]] = load i8, i8* bitcast (i64* @_ZGVN2STI2S4E2stE to i8*), align 8
 // CHECK-TLS2-NEXT:[[GUARD_UNINITIALIZED:%.*]] = icmp eq i8 [[TMP0]], 0
@@ -4906,7 +4906,7 @@
 //
 //
 // CHECK-TLS3-LABEL: define {{[^@]+}}@__cxx_global_var_init.3
-// CHECK-TLS3-SAME: () #[[ATTR0]] comdat($_ZN2STI2S4E2stE) !dbg [[DBG289:![0-9]+]] {
+// CHECK-TLS3-SAME: () #[[ATTR0]] !dbg [[DBG289:![0-9]+]] {
 // CHECK-TLS3-NEXT:  entry:
 // CHECK-TLS3-NEXT:[[TMP0:%.*]] = load i8, i8* bitcast (i64* @_ZGVN2STI2S4E2stE to i8*), align 8, !dbg [[DBG290:![0-9]+]]
 // CHECK-TLS3-NEXT:[[GUARD_UNINITIALIZED:%.*]] = icmp eq i8 [[TMP0]], 0, !dbg [[DBG290]]
@@ -5459,7 +5459,7 @@
 //
 //
 // CHECK-TLS4-LABEL: define {{[^@]+}}@__cxx_global_var_init.3
-// CHECK-TLS4-SAME: () #[[ATTR7]] comdat($_ZN2STI2S4E2stE) !dbg [[DBG289:![0-9]+]] {
+// CHECK-TLS4-SAME: () #[[ATTR7]] !dbg [[DBG289:![0-9]+]] {
 // CHECK-TLS4-NEXT:  entry:
 // CHECK-TLS4-NEXT:[[TMP0:%.*]] = load i8, i8* bitcast (i64* @_ZGVN2STI2S4E2stE to i8*), align 8, !dbg [[DBG290:![0-9]+]]
 // CHECK-TLS4-NEXT:[[GUARD_UNINITIALIZED:%.*]] = icmp eq i8 [[TMP0]], 0, !dbg [[DBG290]]
Index: clang/test/CodeGenCXX/cxx1z-inline-variables.cpp
===
--- clang/test/CodeGenCXX/cxx1z-inline-variables.cpp
+++ clang/test/CodeGenCXX/cxx1z-inline-variables.cpp
@@ -90,9 +90,7 @@
 // CHECK-LABEL: define {{.*}}global_var_init
 // CHECK: call i32 @_Z1fv
 
-// CHECK-LABEL: define {{.*}}global_var_init
-// CHECK-NOT: comdat
-// CHECK-SAME: {{$}}
+// CHECK-LABEL: define {{.*}}global_var_init{{.*}} comdat($b)
 // CHECK: load atomic {{.*}} acquire, align
 // CHECK: br
 // CHECK: __cxa_guard_acquire(i64* @_ZGV1b)
Index: clang/test/CodeGenCXX/cxx11-thread-local.cpp
===
--- clang/test/CodeGenCXX/cxx11-thread-local.cpp
+++ clang/test/CodeGenCXX/cxx11-thread-local.cpp
@@ -179,8 +179,7 @@
 
 // LINUX_AIX: define internal void @[[VF_M_INIT]]()
 // DARWIN: define internal cxx_fast_tlscc void @[[VF_M_INIT]]()
-// LINUX-SAME: comdat($_ZN1VIfE1mE)
-// DARWIN-NOT: comdat
+// CHECK-NOT: comdat
 // CHECK: load i8, i8* bitcast (i64* @_ZGVN1VIfE1mE to i8*)
 // CHECK: %[[VF_M_INITIALIZED:.*]] = icmp eq i8 %{{.*}}, 0
 // CHECK: br i1 %[[VF_M_INITIALIZED]],
@@ -192,8 +191,7 @@
 
 // LINUX_AIX: define internal void @[[XF_M_INIT]]()
 // DARWIN: define internal cxx_fast_tlscc void @[[XF_M_INIT]]()
-// LINUX-SAME: comdat($_ZN1XIfE1mE)
-// DARWIN-NOT: comdat
+// CHECK-NOT: comdat
 // CHECK: load i8, i8* bitcast (i64* @_ZGVN1XIfE1mE to i8*)
 // CHECK: %[[XF_M_INITIALIZED:.*]] = icmp eq i8 %{{.*}}, 0
 // CHECK: br i1 %[[XF_M_INITIALIZED]],
@@ -313,8 +311,7 @@
 
 // LINUX_AIX: define internal void @[[V_M_INIT]]()
 // DARWIN: define internal cxx_fast_tlscc void @[[V_M_INIT]]()
-// LINUX-SAME: comdat($_ZN1VIiE1mE)
-// DARWIN-NOT: comdat
+// CHECK-NOT: comdat
 // CHECK: load i8, i8* bitcast (i64* 

[PATCH] D70172: [CUDA][HIP][OpenMP] Emit deferred diagnostics by a post-parsing AST travese

2021-08-24 Thread Igor Sugak via Phabricator via cfe-commits
sugak added subscribers: weiwang, sugak.
sugak added a comment.
Herald added a subscriber: sstefan1.

Hi @yaxunl! I'm working on upgrading a large codebase from LLVM-9 to LLVM-12. I 
noticed on average 10% compilation speed regression that seems to be caused 
this change. We use Clang modules and historically provide `-fopenmp` compiler 
flag by default. The problem seem to be that compiling and importing modules is 
now slower, with the generated modules size increased by 2X. llvm-bcanalyzer 
tool shows that it's dominated by `DECLS_TO_CHECK_FOR_DEFERRED_DIAGS`.  If I 
understand it right, your change is only relevant when target offloading is 
used. I inspected all of `#pragma omp` directives and can confirm that we don't 
use it.

I see that most of this code is gated by OpenMP flag. I wonder if there is a 
finer grain way to enable openmp parallel code generation without target 
offloading? Would it make sense to extend this code to check if 
`-fopenom-targets` is set before recording `DECLS_TO_CHECK_FOR_DEFERRED_DIAGS`?

Note, this was measured @weiwang's https://reviews.llvm.org/D101793.


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

https://reviews.llvm.org/D70172

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


[PATCH] D107850: [asan] Implemented intrinsic for the custom calling convention similar used by HWASan for X86.

2021-08-24 Thread Kirill Stoimenov via Phabricator via cfe-commits
kstoimenov added a comment.

Thanks! I will submit tomorrow morning.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107850

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


[PATCH] D108582: [WebAssembly] Add Wasm SjLj option support for clang

2021-08-24 Thread Heejin Ahn via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa947b40cafa8: [WebAssembly] Add Wasm SjLj option support for 
clang (authored by aheejin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108582

Files:
  clang/lib/Driver/ToolChains/WebAssembly.cpp
  clang/test/Driver/wasm-toolchain.c

Index: clang/test/Driver/wasm-toolchain.c
===
--- clang/test/Driver/wasm-toolchain.c
+++ clang/test/Driver/wasm-toolchain.c
@@ -94,11 +94,11 @@
 // RUN:   | FileCheck -check-prefix=EMSCRIPTEN_EH_ALLOWED_WO_ENABLE %s
 // EMSCRIPTEN_EH_ALLOWED_WO_ENABLE: invalid argument '-mllvm -emscripten-cxx-exceptions-allowed' only allowed with '-mllvm -enable-emscripten-cxx-exceptions'
 
-// '-fwasm-exceptions' sets +exception-handling
+// '-fwasm-exceptions' sets +exception-handling and '-mllvm -wasm-enable-eh'
 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
 // RUN:--sysroot=/foo %s -fwasm-exceptions 2>&1 \
 // RUN:  | FileCheck -check-prefix=WASM_EXCEPTIONS %s
-// WASM_EXCEPTIONS: clang{{.*}}" "-cc1" {{.*}} "-target-feature" "+exception-handling"
+// WASM_EXCEPTIONS: clang{{.*}}" "-cc1" {{.*}} "-target-feature" "+exception-handling" "-mllvm" "-wasm-enable-eh"
 
 // '-fwasm-exceptions' not allowed with '-mno-exception-handling'
 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
@@ -106,13 +106,42 @@
 // RUN:   | FileCheck -check-prefix=WASM_EXCEPTIONS_NO_EH %s
 // WASM_EXCEPTIONS_NO_EH: invalid argument '-fwasm-exceptions' not allowed with '-mno-exception-handling'
 
-// '-fwasm-exceptions' not allowed with
-// '-mllvm -enable-emscripten-cxx-exceptions'
+// '-fwasm-exceptions' not allowed with '-mllvm -enable-emscripten-cxx-exceptions'
 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
-// RUN: --sysroot=/foo %s -fwasm-exceptions -mllvm -enable-emscripten-cxx-exceptions 2>&1 \
+// RUN: --sysroot=/foo %s -fwasm-exceptions \
+// RUN: -mllvm -enable-emscripten-cxx-exceptions 2>&1 \
 // RUN:   | FileCheck -check-prefix=WASM_EXCEPTIONS_EMSCRIPTEN_EH %s
 // WASM_EXCEPTIONS_EMSCRIPTEN_EH: invalid argument '-fwasm-exceptions' not allowed with '-mllvm -enable-emscripten-cxx-exceptions'
 
+// '-mllvm -wasm-enable-sjlj' sets +exception-handling and
+// '-exception-model=wasm'
+// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
+// RUN:--sysroot=/foo %s -mllvm -wasm-enable-sjlj 2>&1 \
+// RUN:  | FileCheck -check-prefix=WASM_SJLJ %s
+// WASM_SJLJ: clang{{.*}}" "-cc1" {{.*}} "-target-feature" "+exception-handling" "-exception-model=wasm"
+
+// '-mllvm -wasm-enable-sjlj' not allowed with '-mno-exception-handling'
+// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
+// RUN: --sysroot=/foo %s -mllvm -wasm-enable-sjlj -mno-exception-handling \
+// RUN: 2>&1 \
+// RUN:   | FileCheck -check-prefix=WASM_SJLJ_NO_EH %s
+// WASM_SJLJ_NO_EH: invalid argument '-mllvm -wasm-enable-sjlj' not allowed with '-mno-exception-handling'
+
+// '-mllvm -wasm-enable-sjlj' not allowed with
+// '-mllvm -enable-emscripten-cxx-exceptions'
+// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
+// RUN: --sysroot=/foo %s -mllvm -wasm-enable-sjlj \
+// RUN: -mllvm -enable-emscripten-cxx-exceptions 2>&1 \
+// RUN:   | FileCheck -check-prefix=WASM_SJLJ_EMSCRIPTEN_EH %s
+// WASM_SJLJ_EMSCRIPTEN_EH: invalid argument '-mllvm -wasm-enable-sjlj' not allowed with '-mllvm -enable-emscripten-cxx-exceptions'
+
+// '-mllvm -wasm-enable-sjlj' not allowed with '-mllvm -enable-emscripten-sjlj'
+// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
+// RUN: --sysroot=/foo %s -mllvm -wasm-enable-sjlj \
+// RUN: -mllvm -enable-emscripten-sjlj 2>&1 \
+// RUN:   | FileCheck -check-prefix=WASM_SJLJ_EMSCRIPTEN_SJLJ %s
+// WASM_SJLJ_EMSCRIPTEN_SJLJ: invalid argument '-mllvm -wasm-enable-sjlj' not allowed with '-mllvm -enable-emscripten-sjlj'
+
 // RUN: %clang %s -### -fsanitize=address -target wasm32-unknown-emscripten 2>&1 | FileCheck -check-prefix=CHECK-ASAN-EMSCRIPTEN %s
 // CHECK-ASAN-EMSCRIPTEN: "-fsanitize=address"
 // CHECK-ASAN-EMSCRIPTEN: "-fsanitize-address-globals-dead-stripping"
Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -293,6 +293,9 @@
 // '-fwasm-exceptions' implies exception-handling feature
 CC1Args.push_back("-target-feature");
 CC1Args.push_back("+exception-handling");
+// Backend needs -wasm-enable-eh to enable Wasm EH
+CC1Args.push_back("-mllvm");
+CC1Args.push_back("-wasm-enable-eh");
   }
 
   for (const Arg *A : 

[clang] a947b40 - [WebAssembly] Add Wasm SjLj option support for clang

2021-08-24 Thread Heejin Ahn via cfe-commits

Author: Heejin Ahn
Date: 2021-08-24T18:12:52-07:00
New Revision: a947b40cafa8a1d7e241699c1400d80c77e9894c

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

LOG: [WebAssembly] Add Wasm SjLj option support for clang

This adds support for Wasm SjLj in clang. Also this sets the new
`-mllvm -wasm-enable-eh` option for Wasm EH.

Note there is a little unfortunate inconsistency there: Wasm EH is
enabled by a clang option `-fwasm-exceptions`, which sets
`-mllvm -wasm-enable-eh` in the backend options. It also sets
`-exception-model=wasm` but this is done in the common code.

Wasm SjLj doesn't have a clang-level option like `-fwasm-exceptions`.
`-fwasm-exceptions` was added because each exception model has its
corresponding `-f***-exceptions`, but I'm not sure if adding a new
option like `-fwasm-sjlj` or something is a good idea.

So the current plan is Emscripten sets `-mllvm -wasm-enable-sjlj` if
Wasm SJLj is enabled in its settings.js, as it does for Emscripten
EH/SjLj (it sets `-mllvm -enable-emscripten-cxx-exceptions` for
Emscripten EH and `-mllvm -enable-emscripten-sjlj` for Emscripten SjLj).
And setting this enables the exception handling feature, and also sets
`-exception-model=wasm`, but this time this is not done in the common
code so we do it ourselves.

Also note that other exception models have 1-to-1 correspondance with
their `-f***-exceptions` flag and their `-exception-model=***` flag, but
because we use `-exception-model=wasm` also for Wasm SjLj while
`-fwasm-exceptions` still means Wasm EH, there is also a little
inconsistency there, but I think it is manageable.

Also this adds various error checking and tests.

Reviewed By: dschuff

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/WebAssembly.cpp
clang/test/Driver/wasm-toolchain.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/WebAssembly.cpp 
b/clang/lib/Driver/ToolChains/WebAssembly.cpp
index 19f3571e6b38..6ce4f4454487 100644
--- a/clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ b/clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -293,6 +293,9 @@ void WebAssembly::addClangTargetOptions(const ArgList 
,
 // '-fwasm-exceptions' implies exception-handling feature
 CC1Args.push_back("-target-feature");
 CC1Args.push_back("+exception-handling");
+// Backend needs -wasm-enable-eh to enable Wasm EH
+CC1Args.push_back("-mllvm");
+CC1Args.push_back("-wasm-enable-eh");
   }
 
   for (const Arg *A : DriverArgs.filtered(options::OPT_mllvm)) {
@@ -300,14 +303,14 @@ void WebAssembly::addClangTargetOptions(const ArgList 
,
 if (Opt.startswith("-emscripten-cxx-exceptions-allowed")) {
   // '-mllvm -emscripten-cxx-exceptions-allowed' should be used with
   // '-mllvm -enable-emscripten-cxx-exceptions'
-  bool EmExceptionArgExists = false;
+  bool EmEHArgExists = false;
   for (const Arg *A : DriverArgs.filtered(options::OPT_mllvm)) {
 if (StringRef(A->getValue(0)) == "-enable-emscripten-cxx-exceptions") {
-  EmExceptionArgExists = true;
+  EmEHArgExists = true;
   break;
 }
   }
-  if (!EmExceptionArgExists)
+  if (!EmEHArgExists)
 getDriver().Diag(diag::err_drv_argument_only_allowed_with)
 << "-mllvm -emscripten-cxx-exceptions-allowed"
 << "-mllvm -enable-emscripten-cxx-exceptions";
@@ -323,6 +326,38 @@ void WebAssembly::addClangTargetOptions(const ArgList 
,
":noinline"));
   }
 }
+
+if (Opt.startswith("-wasm-enable-sjlj")) {
+  // '-mllvm -wasm-enable-sjlj' is not compatible with
+  // '-mno-exception-handling'
+  if (DriverArgs.hasFlag(options::OPT_mno_exception_handing,
+ options::OPT_mexception_handing, false))
+getDriver().Diag(diag::err_drv_argument_not_allowed_with)
+<< "-mllvm -wasm-enable-sjlj"
+<< "-mno-exception-handling";
+  // '-mllvm -wasm-enable-sjlj' is not compatible with
+  // '-mllvm -enable-emscripten-cxx-exceptions'
+  // because we don't allow Emscripten EH + Wasm SjLj
+  for (const Arg *A : DriverArgs.filtered(options::OPT_mllvm)) {
+if (StringRef(A->getValue(0)) == "-enable-emscripten-cxx-exceptions")
+  getDriver().Diag(diag::err_drv_argument_not_allowed_with)
+  << "-mllvm -wasm-enable-sjlj"
+  << "-mllvm -enable-emscripten-cxx-exceptions";
+  }
+  // '-mllvm -wasm-enable-sjlj' is not compatible with
+  // '-mllvm -enable-emscripten-sjlj'
+  for (const Arg *A : DriverArgs.filtered(options::OPT_mllvm)) {
+if (StringRef(A->getValue(0)) == "-enable-emscripten-sjlj")
+  

[PATCH] D108582: [WebAssembly] Add Wasm SjLj option support for clang

2021-08-24 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin updated this revision to Diff 368519.
aheejin added a comment.
This revision is now accepted and ready to land.

Remove multivalue setting


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108582

Files:
  clang/lib/Driver/ToolChains/WebAssembly.cpp
  clang/test/Driver/wasm-toolchain.c

Index: clang/test/Driver/wasm-toolchain.c
===
--- clang/test/Driver/wasm-toolchain.c
+++ clang/test/Driver/wasm-toolchain.c
@@ -94,11 +94,11 @@
 // RUN:   | FileCheck -check-prefix=EMSCRIPTEN_EH_ALLOWED_WO_ENABLE %s
 // EMSCRIPTEN_EH_ALLOWED_WO_ENABLE: invalid argument '-mllvm -emscripten-cxx-exceptions-allowed' only allowed with '-mllvm -enable-emscripten-cxx-exceptions'
 
-// '-fwasm-exceptions' sets +exception-handling
+// '-fwasm-exceptions' sets +exception-handling and '-mllvm -wasm-enable-eh'
 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
 // RUN:--sysroot=/foo %s -fwasm-exceptions 2>&1 \
 // RUN:  | FileCheck -check-prefix=WASM_EXCEPTIONS %s
-// WASM_EXCEPTIONS: clang{{.*}}" "-cc1" {{.*}} "-target-feature" "+exception-handling"
+// WASM_EXCEPTIONS: clang{{.*}}" "-cc1" {{.*}} "-target-feature" "+exception-handling" "-mllvm" "-wasm-enable-eh"
 
 // '-fwasm-exceptions' not allowed with '-mno-exception-handling'
 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
@@ -106,13 +106,42 @@
 // RUN:   | FileCheck -check-prefix=WASM_EXCEPTIONS_NO_EH %s
 // WASM_EXCEPTIONS_NO_EH: invalid argument '-fwasm-exceptions' not allowed with '-mno-exception-handling'
 
-// '-fwasm-exceptions' not allowed with
-// '-mllvm -enable-emscripten-cxx-exceptions'
+// '-fwasm-exceptions' not allowed with '-mllvm -enable-emscripten-cxx-exceptions'
 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
-// RUN: --sysroot=/foo %s -fwasm-exceptions -mllvm -enable-emscripten-cxx-exceptions 2>&1 \
+// RUN: --sysroot=/foo %s -fwasm-exceptions \
+// RUN: -mllvm -enable-emscripten-cxx-exceptions 2>&1 \
 // RUN:   | FileCheck -check-prefix=WASM_EXCEPTIONS_EMSCRIPTEN_EH %s
 // WASM_EXCEPTIONS_EMSCRIPTEN_EH: invalid argument '-fwasm-exceptions' not allowed with '-mllvm -enable-emscripten-cxx-exceptions'
 
+// '-mllvm -wasm-enable-sjlj' sets +exception-handling and
+// '-exception-model=wasm'
+// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
+// RUN:--sysroot=/foo %s -mllvm -wasm-enable-sjlj 2>&1 \
+// RUN:  | FileCheck -check-prefix=WASM_SJLJ %s
+// WASM_SJLJ: clang{{.*}}" "-cc1" {{.*}} "-target-feature" "+exception-handling" "-exception-model=wasm"
+
+// '-mllvm -wasm-enable-sjlj' not allowed with '-mno-exception-handling'
+// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
+// RUN: --sysroot=/foo %s -mllvm -wasm-enable-sjlj -mno-exception-handling \
+// RUN: 2>&1 \
+// RUN:   | FileCheck -check-prefix=WASM_SJLJ_NO_EH %s
+// WASM_SJLJ_NO_EH: invalid argument '-mllvm -wasm-enable-sjlj' not allowed with '-mno-exception-handling'
+
+// '-mllvm -wasm-enable-sjlj' not allowed with
+// '-mllvm -enable-emscripten-cxx-exceptions'
+// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
+// RUN: --sysroot=/foo %s -mllvm -wasm-enable-sjlj \
+// RUN: -mllvm -enable-emscripten-cxx-exceptions 2>&1 \
+// RUN:   | FileCheck -check-prefix=WASM_SJLJ_EMSCRIPTEN_EH %s
+// WASM_SJLJ_EMSCRIPTEN_EH: invalid argument '-mllvm -wasm-enable-sjlj' not allowed with '-mllvm -enable-emscripten-cxx-exceptions'
+
+// '-mllvm -wasm-enable-sjlj' not allowed with '-mllvm -enable-emscripten-sjlj'
+// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
+// RUN: --sysroot=/foo %s -mllvm -wasm-enable-sjlj \
+// RUN: -mllvm -enable-emscripten-sjlj 2>&1 \
+// RUN:   | FileCheck -check-prefix=WASM_SJLJ_EMSCRIPTEN_SJLJ %s
+// WASM_SJLJ_EMSCRIPTEN_SJLJ: invalid argument '-mllvm -wasm-enable-sjlj' not allowed with '-mllvm -enable-emscripten-sjlj'
+
 // RUN: %clang %s -### -fsanitize=address -target wasm32-unknown-emscripten 2>&1 | FileCheck -check-prefix=CHECK-ASAN-EMSCRIPTEN %s
 // CHECK-ASAN-EMSCRIPTEN: "-fsanitize=address"
 // CHECK-ASAN-EMSCRIPTEN: "-fsanitize-address-globals-dead-stripping"
Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -293,6 +293,9 @@
 // '-fwasm-exceptions' implies exception-handling feature
 CC1Args.push_back("-target-feature");
 CC1Args.push_back("+exception-handling");
+// Backend needs -wasm-enable-eh to enable Wasm EH
+CC1Args.push_back("-mllvm");
+CC1Args.push_back("-wasm-enable-eh");
   }
 
   for (const Arg *A : DriverArgs.filtered(options::OPT_mllvm)) {
@@ -300,14 +303,14 @@
 if 

[PATCH] D108571: [clang] allow -fstack-clash-protection on FreeBSD

2021-08-24 Thread Ed Maste via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6609892a2dcd: [clang] allow -fstack-clash-protection on 
FreeBSD (authored by emaste).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108571

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/stack-clash-protection.c


Index: clang/test/Driver/stack-clash-protection.c
===
--- clang/test/Driver/stack-clash-protection.c
+++ clang/test/Driver/stack-clash-protection.c
@@ -5,6 +5,7 @@
 // SCP-i386-NO-NOT: "-fstack-clash-protection"
 
 // RUN: %clang -target x86_64-scei-linux -fstack-clash-protection -### %s 2>&1 
| FileCheck %s -check-prefix=SCP-x86
+// RUN: %clang -target x86_64-unknown-freebsd -fstack-clash-protection -### %s 
2>&1 | FileCheck %s -check-prefix=SCP-x86
 // SCP-x86: "-fstack-clash-protection"
 
 // RUN: %clang -target armv7k-apple-linux -fstack-clash-protection -### %s 
2>&1 | FileCheck %s -check-prefix=SCP-armv7
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3198,7 +3198,7 @@
  ArgStringList ) {
   const llvm::Triple  = TC.getEffectiveTriple();
 
-  if (!EffectiveTriple.isOSLinux())
+  if (!EffectiveTriple.isOSFreeBSD() && !EffectiveTriple.isOSLinux())
 return;
 
   if (!EffectiveTriple.isX86() && !EffectiveTriple.isSystemZ() &&


Index: clang/test/Driver/stack-clash-protection.c
===
--- clang/test/Driver/stack-clash-protection.c
+++ clang/test/Driver/stack-clash-protection.c
@@ -5,6 +5,7 @@
 // SCP-i386-NO-NOT: "-fstack-clash-protection"
 
 // RUN: %clang -target x86_64-scei-linux -fstack-clash-protection -### %s 2>&1 | FileCheck %s -check-prefix=SCP-x86
+// RUN: %clang -target x86_64-unknown-freebsd -fstack-clash-protection -### %s 2>&1 | FileCheck %s -check-prefix=SCP-x86
 // SCP-x86: "-fstack-clash-protection"
 
 // RUN: %clang -target armv7k-apple-linux -fstack-clash-protection -### %s 2>&1 | FileCheck %s -check-prefix=SCP-armv7
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3198,7 +3198,7 @@
  ArgStringList ) {
   const llvm::Triple  = TC.getEffectiveTriple();
 
-  if (!EffectiveTriple.isOSLinux())
+  if (!EffectiveTriple.isOSFreeBSD() && !EffectiveTriple.isOSLinux())
 return;
 
   if (!EffectiveTriple.isX86() && !EffectiveTriple.isSystemZ() &&
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D108643: Introduce _BitInt, deprecate _ExtInt

2021-08-24 Thread James Y Knight via Phabricator via cfe-commits
jyknight added inline comments.



Comment at: clang/include/clang/Basic/TargetInfo.h:581
   /// limitation is put into place for ABI reasons.
-  virtual bool hasExtIntType() const {
+  /// FIXME: _BitInt is a required type in C23, so there's not much utility in
+  /// asking whether the target supported it or not; I think this should be

aaron.ballman wrote:
> erichkeane wrote:
> > erichkeane wrote:
> > > Concur on the fixme.  I would expect after this lands that an llvm-dev 
> > > discussion happen to do this alert, and have us remove this pretty 
> > > quickly (a release or two?)
> > To clarify: This should be removed at the beginning of a release-cycle 
> > (along with an llvm-dev notice) so that we have as much time as possible in 
> > trunk to react/find issues.
> We're basically at the beginning of Clang 14 (13 isn't out the door yet), so 
> I am sort of tempted to alert llvm-dev now and remove it as part of this 
> review. However, if people think that's too harsh, I'm happy to wait as well.
Since we already return true for all in-tree targets, removing this is 
effectively a no-op.

However...

Previously, this was a clang extension, so the ABI didn't really matter, as 
long as it was functional and not broken. But now, it's a standard feature, 
which gives (or, at least SHOULD give) a much stronger expectation as to 
compiler-interoperability and ABI documentation.

So -- where's the ABI specification for how _BitInt is represented in memory 
(size, alignment, ordering/padding location), and how it's passed/returned from 
functions? Presumably that needs to be part of each platform's psABI -- ideally 
before the feature is enabled on each platform, right?

I realize that such idealism may be somewhat impractical, here in the real 
world, since some platforms' psABIs appear to be effectively unmaintained. But 
is it going to be added to all those which //are// being actively maintained?

It would be really quite lovely if this didn't end up like the situation we 
have with _Atomic. (Where the new feature was implemented and deployed by 
compilers, without ever hashing out ABI issues. And, so, _Atomic ABI remains 
undocumented and incompatible between implementations.)



Comment at: clang/lib/AST/ItaniumMangle.cpp:3958
+void CXXNameMangler::mangleType(const BitIntType *T) {
+  // FIXME: this is proposed to the Itanium ABI group but not yet accepted.
+  // 5.1.5.2 Builtin types

There ought to be a ItaniumDemangle.h change corresponding to this, too (As a 
separate review is fine, too.)



Comment at: clang/lib/AST/MicrosoftMangle.cpp:3338
 
-void MicrosoftCXXNameMangler::mangleType(const ExtIntType *T, Qualifiers,
+void MicrosoftCXXNameMangler::mangleType(const BitIntType *T, Qualifiers,
  SourceRange Range) {

It seems unlikely that this will be the official mangling for MS platforms, 
since it has a name __clang in it, right? How do we plan to deal with that 
future ABI issue?


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

https://reviews.llvm.org/D108643

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


[clang] 6609892 - [clang] allow -fstack-clash-protection on FreeBSD

2021-08-24 Thread Ed Maste via cfe-commits

Author: Ed Maste
Date: 2021-08-24T21:02:36-04:00
New Revision: 6609892a2dcdd1a4f6adefe191b55524861f020c

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

LOG: [clang] allow -fstack-clash-protection on FreeBSD

-fstack-clash-protection was added in Clang commit e67cbac81211 but was
enabled only on Linux.  Allow it on FreeBSD as well, as it works fine.

Reviewed By: serge-sans-paille

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/stack-clash-protection.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index e19e1222f702e..b973428549820 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -3198,7 +3198,7 @@ static void RenderSCPOptions(const ToolChain , const 
ArgList ,
  ArgStringList ) {
   const llvm::Triple  = TC.getEffectiveTriple();
 
-  if (!EffectiveTriple.isOSLinux())
+  if (!EffectiveTriple.isOSFreeBSD() && !EffectiveTriple.isOSLinux())
 return;
 
   if (!EffectiveTriple.isX86() && !EffectiveTriple.isSystemZ() &&

diff  --git a/clang/test/Driver/stack-clash-protection.c 
b/clang/test/Driver/stack-clash-protection.c
index 5217ed26a5b19..048668fc951e3 100644
--- a/clang/test/Driver/stack-clash-protection.c
+++ b/clang/test/Driver/stack-clash-protection.c
@@ -5,6 +5,7 @@
 // SCP-i386-NO-NOT: "-fstack-clash-protection"
 
 // RUN: %clang -target x86_64-scei-linux -fstack-clash-protection -### %s 2>&1 
| FileCheck %s -check-prefix=SCP-x86
+// RUN: %clang -target x86_64-unknown-freebsd -fstack-clash-protection -### %s 
2>&1 | FileCheck %s -check-prefix=SCP-x86
 // SCP-x86: "-fstack-clash-protection"
 
 // RUN: %clang -target armv7k-apple-linux -fstack-clash-protection -### %s 
2>&1 | FileCheck %s -check-prefix=SCP-armv7



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


[PATCH] D108582: [WebAssembly] Add Wasm SjLj option support for clang

2021-08-24 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin added a comment.

As we discussed offline, I'll remove `+multivalue` part for now; it doesn't 
have reliable support in the Wasm LLVM backend and Binaryen yet.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108582

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


[PATCH] D107685: [WebAssembly] Tidy up EH/SjLj options

2021-08-24 Thread Heejin Ahn via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG77b921b870aa: [WebAssembly] Tidy up EH/SjLj options 
(authored by aheejin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107685

Files:
  clang/test/CodeGenCXX/wasm-eh.cpp
  lld/test/wasm/tag-section.ll
  llvm/lib/Target/WebAssembly/WebAssembly.h
  llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
  llvm/test/CodeGen/WebAssembly/cfg-stackify-eh.ll
  llvm/test/CodeGen/WebAssembly/eh-lsda.ll
  llvm/test/CodeGen/WebAssembly/exception.ll
  llvm/test/CodeGen/WebAssembly/lower-em-ehsjlj.ll
  llvm/test/CodeGen/WebAssembly/lower-em-exceptions-allowed.ll
  llvm/test/CodeGen/WebAssembly/lower-em-exceptions-resume-only.ll
  llvm/test/CodeGen/WebAssembly/lower-em-exceptions.ll
  llvm/test/CodeGen/WebAssembly/lower-em-sjlj-alias.ll
  llvm/test/CodeGen/WebAssembly/lower-em-sjlj-debuginfo.ll
  llvm/test/CodeGen/WebAssembly/lower-em-sjlj.ll
  llvm/test/CodeGen/WebAssembly/null-streamer.ll
  llvm/test/CodeGen/WebAssembly/wasm-eh-em-sjlj-error.ll
  llvm/test/MC/WebAssembly/tag-section-decoding.ll
  llvm/test/MC/WebAssembly/tag-section.ll

Index: llvm/test/MC/WebAssembly/tag-section.ll
===
--- llvm/test/MC/WebAssembly/tag-section.ll
+++ llvm/test/MC/WebAssembly/tag-section.ll
@@ -1,5 +1,5 @@
-; RUN: llc -filetype=obj -exception-model=wasm -mattr=+exception-handling %s -o - | obj2yaml | FileCheck %s
-; RUN: llc -filetype=obj -exception-model=wasm -mattr=+exception-handling %s -o - | llvm-readobj -S - | FileCheck -check-prefix=SEC %s
+; RUN: llc -filetype=obj -wasm-enable-eh -exception-model=wasm -mattr=+exception-handling %s -o - | obj2yaml | FileCheck %s
+; RUN: llc -filetype=obj -wasm-enable-eh -exception-model=wasm -mattr=+exception-handling %s -o - | llvm-readobj -S - | FileCheck -check-prefix=SEC %s
 
 target triple = "wasm32-unknown-unknown"
 
Index: llvm/test/MC/WebAssembly/tag-section-decoding.ll
===
--- llvm/test/MC/WebAssembly/tag-section-decoding.ll
+++ llvm/test/MC/WebAssembly/tag-section-decoding.ll
@@ -1,4 +1,4 @@
-; RUN: llc -filetype=obj -exception-model=wasm -mattr=+exception-handling %s -o - | obj2yaml | FileCheck %s
+; RUN: llc -filetype=obj -wasm-enable-eh -exception-model=wasm -mattr=+exception-handling %s -o - | obj2yaml | FileCheck %s
 
 ; This is a regression test for a decoding bug that happens when a tag's
 ; sigindex is greater than 63, so we put 63 dummy functions with different
Index: llvm/test/CodeGen/WebAssembly/wasm-eh-em-sjlj-error.ll
===
--- llvm/test/CodeGen/WebAssembly/wasm-eh-em-sjlj-error.ll
+++ llvm/test/CodeGen/WebAssembly/wasm-eh-em-sjlj-error.ll
@@ -1,4 +1,4 @@
-; RUN: not --crash llc < %s -enable-emscripten-sjlj -exception-model=wasm 2>&1 | FileCheck %s
+; RUN: not --crash llc < %s -wasm-enable-eh -enable-emscripten-sjlj -exception-model=wasm 2>&1 | FileCheck %s
 
 target triple = "wasm32-unknown-unknown"
 
Index: llvm/test/CodeGen/WebAssembly/null-streamer.ll
===
--- llvm/test/CodeGen/WebAssembly/null-streamer.ll
+++ llvm/test/CodeGen/WebAssembly/null-streamer.ll
@@ -1,5 +1,5 @@
-; RUN: llc < %s -O0 -filetype=null -exception-model=wasm -mattr=+exception-handling
-; RUN: llc < %s -O0 -filetype=asm -asm-verbose=false -exception-model=wasm -mattr=+exception-handling | FileCheck %s
+; RUN: llc < %s -O0 -filetype=null -wasm-enable-eh -exception-model=wasm -mattr=+exception-handling
+; RUN: llc < %s -O0 -filetype=asm -asm-verbose=false -wasm-enable-eh -exception-model=wasm -mattr=+exception-handling | FileCheck %s
 
 target triple = "wasm32-unknown-unknown"
 
Index: llvm/test/CodeGen/WebAssembly/lower-em-sjlj.ll
===
--- llvm/test/CodeGen/WebAssembly/lower-em-sjlj.ll
+++ llvm/test/CodeGen/WebAssembly/lower-em-sjlj.ll
@@ -1,6 +1,6 @@
-; RUN: opt < %s -wasm-lower-em-ehsjlj -S | FileCheck %s --check-prefixes=CHECK,NO-TLS -DPTR=i32
-; RUN: opt < %s -wasm-lower-em-ehsjlj -S --mattr=+atomics,+bulk-memory | FileCheck %s --check-prefixes=CHECK,TLS -DPTR=i32
-; RUN: opt < %s -wasm-lower-em-ehsjlj --mtriple=wasm64-unknown-unknown -data-layout="e-m:e-p:64:64-i64:64-n32:64-S128" -S | FileCheck %s --check-prefixes=CHECK -DPTR=i64
+; RUN: opt < %s -wasm-lower-em-ehsjlj -enable-emscripten-sjlj -S | FileCheck %s --check-prefixes=CHECK,NO-TLS -DPTR=i32
+; RUN: opt < %s -wasm-lower-em-ehsjlj -enable-emscripten-sjlj -S --mattr=+atomics,+bulk-memory | FileCheck %s --check-prefixes=CHECK,TLS -DPTR=i32
+; RUN: opt < %s 

[PATCH] D107850: [asan] Implemented intrinsic for the custom calling convention similar used by HWASan for X86.

2021-08-24 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka accepted this revision.
vitalybuka added a comment.

And if it's straightforward fix for the revert you can "reuse" approvals and 
land without additional review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107850

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


[PATCH] D107850: [asan] Implemented intrinsic for the custom calling convention similar used by HWASan for X86.

2021-08-24 Thread Kirill Stoimenov via Phabricator via cfe-commits
kstoimenov updated this revision to Diff 368510.
kstoimenov added a comment.

Updated with the fix for Bazel build.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107850

Files:
  llvm/include/llvm/IR/Intrinsics.td
  llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
  llvm/lib/Target/X86/X86AsmPrinter.cpp
  llvm/lib/Target/X86/X86AsmPrinter.h
  llvm/lib/Target/X86/X86InstrCompiler.td
  llvm/lib/Target/X86/X86MCInstLower.cpp
  llvm/lib/Target/X86/X86RegisterInfo.td
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/test/CodeGen/X86/asan-check-memaccess-add.ll
  llvm/test/CodeGen/X86/asan-check-memaccess-or.ll

Index: llvm/test/CodeGen/X86/asan-check-memaccess-or.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/asan-check-memaccess-or.ll
@@ -0,0 +1,253 @@
+; RUN: llc < %s | FileCheck %s
+
+target triple = "x86_64-pc-win"
+
+define void @load1(i8* nocapture readonly %x) {
+; CHECK:  callq   __asan_check_load1_rn[[RN1:.*]]
+; CHECK:  callq   __asan_check_store1_rn[[RN1]]
+; CHECK-NEXT: retq
+  call void @llvm.asan.check.memaccess(i8* %x, i32 0)
+  call void @llvm.asan.check.memaccess(i8* %x, i32 32)
+  ret void
+}
+
+define void @load2(i16* nocapture readonly %x) {
+; CHECK:  callq   __asan_check_load2_rn[[RN2:.*]]
+; CHECK:  callq   __asan_check_store2_rn[[RN2]]
+; CHECK-NEXT: retq
+  %1 = ptrtoint i16* %x to i64
+  %2 = bitcast i16* %x to i8*
+  call void @llvm.asan.check.memaccess(i8* %2, i32 2)
+  call void @llvm.asan.check.memaccess(i8* %2, i32 34)
+  ret void
+}
+
+define void @load4(i32* nocapture readonly %x) {
+; CHECK:  callq   __asan_check_load4_rn[[RN4:.*]]
+; CHECK:  callq   __asan_check_store4_rn[[RN4]]
+; CHECK-NEXT: retq
+  %1 = ptrtoint i32* %x to i64
+  %2 = bitcast i32* %x to i8*
+  call void @llvm.asan.check.memaccess(i8* %2, i32 4)
+  call void @llvm.asan.check.memaccess(i8* %2, i32 36)
+  ret void
+}
+define void @load8(i64* nocapture readonly %x) {
+; CHECK:  callq   __asan_check_load8_rn[[RN8:.*]]
+; CHECK:  callq   __asan_check_store8_rn[[RN8]]
+; CHECK-NEXT: retq
+  %1 = ptrtoint i64* %x to i64
+  %2 = bitcast i64* %x to i8*
+  call void @llvm.asan.check.memaccess(i8* %2, i32 6)
+  call void @llvm.asan.check.memaccess(i8* %2, i32 38)
+  ret void
+}
+
+define void @load16(i128* nocapture readonly %x) {
+; CHECK:  callq   __asan_check_load16_rn[[RN16:.*]]
+; CHECK:  callq   __asan_check_store16_rn[[RN16]]
+; CHECK-NEXT: retq
+  %1 = ptrtoint i128* %x to i64
+  %2 = bitcast i128* %x to i8*
+  call void @llvm.asan.check.memaccess(i8* %2, i32 8)
+  call void @llvm.asan.check.memaccess(i8* %2, i32 40)
+  ret void
+}
+
+; CHECK:  .type   __asan_check_load1_rn[[RN1]],@function
+; CHECK-NEXT: .weak   __asan_check_load1_rn[[RN1]]
+; CHECK-NEXT: .hidden __asan_check_load1_rn[[RN1]]
+; CHECK-NEXT: __asan_check_load1_rn[[RN1]]:
+; CHECK-NEXT: movq[[REG:.*]], %r8
+; CHECK-NEXT: shrq$3, %r8
+; CHECK-NEXT: orq $17592186044416, %r8{{.*}}
+; CHECK-NEXT: movb(%r8), %r8b
+; CHECK-NEXT: testb   %r8b, %r8b
+; CHECK-NEXT: jne [[EXTRA:.*]]
+; CHECK-NEXT: [[RET:.*]]:
+; CHECK-NEXT: retq
+; CHECK-NEXT: [[EXTRA]]:
+; CHECK-NEXT: pushq   %rcx
+; CHECK-NEXT: movq[[REG]], %rcx
+; CHECK-NEXT: andl$7, %ecx
+; CHECK-NEXT: cmpl%r8d, %ecx
+; CHECK-NEXT: popq%rcx
+; CHECK-NEXT: jl  [[RET]]
+; CHECK-NEXT: movq[[REG:.*]], %rdi
+; CHECK-NEXT: jmp __asan_report_load1
+
+; CHECK:  .type   __asan_check_load2_rn[[RN2]],@function
+; CHECK-NEXT: .weak   __asan_check_load2_rn[[RN2]]
+; CHECK-NEXT: .hidden __asan_check_load2_rn[[RN2]]
+; CHECK-NEXT: __asan_check_load2_rn[[RN2]]:
+; CHECK-NEXT: movq[[REG:.*]], %r8
+; CHECK-NEXT: shrq$3, %r8
+; CHECK-NEXT: orq $17592186044416, %r8{{.*}}
+; CHECK-NEXT: movb(%r8), %r8b
+; CHECK-NEXT: testb   %r8b, %r8b
+; CHECK-NEXT: jne [[EXTRA:.*]]
+; CHECK-NEXT: [[RET:.*]]:
+; CHECK-NEXT: retq
+; CHECK-NEXT: [[EXTRA]]:
+; CHECK-NEXT: pushq   %rcx
+; CHECK-NEXT: movq[[REG]], %rcx
+; CHECK-NEXT: andl$7, %ecx
+; CHECK-NEXT: addl$1, %ecx
+; CHECK-NEXT: cmpl%r8d, %ecx
+; CHECK-NEXT: popq%rcx
+; CHECK-NEXT: jl  [[RET]]
+; CHECK-NEXT: movq[[REG:.*]], %rdi
+; CHECK-NEXT: jmp __asan_report_load2
+
+; CHECK:  .type   __asan_check_load4_rn[[RN4]],@function
+; CHECK-NEXT: .weak   __asan_check_load4_rn[[RN4]]
+; CHECK-NEXT: .hidden 

[PATCH] D36850: [ThinLTO] Add norecurse function attribute propagation

2021-08-24 Thread Di Mo via Phabricator via cfe-commits
modimo added a comment.

Checking build timing in release mode Clang self-build looking at purely 
thinlink timing:

| Mode   | Time (s) |
| base   | 2.254|
| base + propagation | 2.556|
| noinline   | 8.870|
| noinline + propagation | 10.215   |
|

So 13% in base and 15% with noinline which seems reasonable for what it's doing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D36850

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


[clang] df7b6b9 - Extend diagnostic for out of date AST input file.

2021-08-24 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2021-08-24T17:03:06-07:00
New Revision: df7b6b91422dbdbdb1de66fd865853e78ea3e5d2

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

LOG: Extend diagnostic for out of date AST input file.

If the size has changed, list the old and new sizes; if the mtime has
changed, list the old and new mtimes (as raw time_t values).

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSerializationKinds.td
clang/lib/Serialization/ASTReader.cpp
clang/test/PCH/include-timestamp.cpp
clang/test/PCH/verify_pch.m

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSerializationKinds.td 
b/clang/include/clang/Basic/DiagnosticSerializationKinds.td
index bf3221be004d..f15a935d2af1 100644
--- a/clang/include/clang/Basic/DiagnosticSerializationKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSerializationKinds.td
@@ -20,7 +20,7 @@ def err_fe_pch_malformed_block : Error<
 def err_fe_ast_file_modified : Error<
 "file '%0' has been modified since the "
 "%select{precompiled header|module file|AST file}1 '%2' was built"
-": %select{size|mtime|content}3 changed">,
+": %select{size|mtime|content}3 changed%select{| (was %5, now %6)}4">,
 DefaultFatal;
 def err_fe_pch_file_overridden : Error<
 "file '%0' from the precompiled header has been overridden">;

diff  --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index b8c4889b10f9..1f9778dc6a0f 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -2380,17 +2380,24 @@ InputFile ASTReader::getInputFile(ModuleFile , 
unsigned ID, bool Complain) {
 }
   }
 
-  enum ModificationType {
-Size,
-ModTime,
-Content,
-None,
+  struct Change {
+enum ModificationKind {
+  Size,
+  ModTime,
+  Content,
+  None,
+} Kind;
+llvm::Optional Old = llvm::None;
+llvm::Optional New = llvm::None;
   };
   auto HasInputFileChanged = [&]() {
 if (StoredSize != File->getSize())
-  return ModificationType::Size;
+  return Change{Change::Size, StoredSize, File->getSize()};
 if (!shouldDisableValidationForFile(F) && StoredTime &&
 StoredTime != File->getModificationTime()) {
+  Change MTimeChange = {Change::ModTime, StoredTime,
+File->getModificationTime()};
+
   // In case the modification time changes but not the content,
   // accept the cached file as legit.
   if (ValidateASTInputFilesContent &&
@@ -2398,28 +2405,30 @@ InputFile ASTReader::getInputFile(ModuleFile , 
unsigned ID, bool Complain) {
 auto MemBuffOrError = FileMgr.getBufferForFile(File);
 if (!MemBuffOrError) {
   if (!Complain)
-return ModificationType::ModTime;
+return MTimeChange;
   std::string ErrorStr = "could not get buffer for file '";
   ErrorStr += File->getName();
   ErrorStr += "'";
   Error(ErrorStr);
-  return ModificationType::ModTime;
+  return MTimeChange;
 }
 
+// FIXME: hash_value is not guaranteed to be stable!
 auto ContentHash = hash_value(MemBuffOrError.get()->getBuffer());
 if (StoredContentHash == static_cast(ContentHash))
-  return ModificationType::None;
-return ModificationType::Content;
+  return Change{Change::None};
+
+return Change{Change::Content};
   }
-  return ModificationType::ModTime;
+  return MTimeChange;
 }
-return ModificationType::None;
+return Change{Change::None};
   };
 
   bool IsOutOfDate = false;
   auto FileChange = HasInputFileChanged();
   // For an overridden file, there is nothing to validate.
-  if (!Overridden && FileChange != ModificationType::None) {
+  if (!Overridden && FileChange.Kind != Change::None) {
 if (Complain && !Diags.isDiagnosticInFlight()) {
   // Build a list of the PCH imports that got us here (in reverse).
   SmallVector ImportStack(1, );
@@ -2430,7 +2439,10 @@ InputFile ASTReader::getInputFile(ModuleFile , 
unsigned ID, bool Complain) {
   StringRef TopLevelPCHName(ImportStack.back()->FileName);
   Diag(diag::err_fe_ast_file_modified)
   << Filename << moduleKindForDiagnostic(ImportStack.back()->Kind)
-  << TopLevelPCHName << FileChange;
+  << TopLevelPCHName << FileChange.Kind
+  << (FileChange.Old && FileChange.New)
+  << llvm::itostr(FileChange.Old.getValueOr(0))
+  << llvm::itostr(FileChange.New.getValueOr(0));
 
   // Print the import stack.
   if (ImportStack.size() > 1) {

diff  --git a/clang/test/PCH/include-timestamp.cpp 
b/clang/test/PCH/include-timestamp.cpp
index 36b887aee85f..0bee9b7f235c 100644
--- 

[PATCH] D108482: [Clang] Fix instantiation of OpaqueValueExprs (Bug #45964)

2021-08-24 Thread Jason Rice via Phabricator via cfe-commits
ricejasonf updated this revision to Diff 368485.
ricejasonf added a comment.

I added a simple lit test. The case is the reduced case mentioned in the bug. I 
spent some time trying to reproduce this outside decomposition. The only other 
way (I know of) to produce an ArrayInitLoopExpr is an implicit copy 
constructor, but the AST for that is generated lazily so it never gets 
transformed. Other entities containing OpaqueValueExpr do not appear to have 
this problem either. Let me know if there are any more deficiencies or 
suggested changes. Thank you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108482

Files:
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/TreeTransform.h
  clang/test/SemaCXX/pr45964-nested-ove.cpp


Index: clang/test/SemaCXX/pr45964-nested-ove.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/pr45964-nested-ove.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -std=c++17 -emit-codegen-only -verify %s
+// Don't crash (Bugzilla - Bug 45964).
+
+// non-dependent ArrayInitLoop should not, upon instantiation,
+// contain an OpaqueValueExpr with a nested OpaqueValueExpr or an
+// uninstantiated source expr. (triggers asserts in CodeGen)
+
+// expected-no-diagnostics
+int a[1];
+template  void b() {
+  auto [c] = a;
+}
+void (*d)(){b<0>};
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -10511,7 +10511,19 @@
 TreeTransform::TransformOpaqueValueExpr(OpaqueValueExpr *E) {
   assert((!E->getSourceExpr() || 
getDerived().AlreadyTransformed(E->getType())) &&
  "opaque value expression requires transformation");
-  return E;
+
+  // Note that SourceExpr can be nullptr
+  ExprResult SourceExpr = TransformExpr(E->getSourceExpr());
+  if (SourceExpr.isInvalid())
+return ExprError();
+  if (SourceExpr.get() == E->getSourceExpr() && !getDerived().AlwaysRebuild()) 
{
+return E;
+  }
+
+  OpaqueValueExpr *New = new (SemaRef.Context)
+  OpaqueValueExpr(E->getExprLoc(), E->getType(), E->getValueKind(),
+  E->getObjectKind(), SourceExpr.get());
+  return New;
 }
 
 template
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -8643,9 +8643,13 @@
 
 case SK_ArrayLoopIndex: {
   Expr *Cur = CurInit.get();
-  Expr *BaseExpr = new (S.Context)
-  OpaqueValueExpr(Cur->getExprLoc(), Cur->getType(),
-  Cur->getValueKind(), Cur->getObjectKind(), Cur);
+  // prevent nested OpaqueValueExprs
+  Expr *BaseExpr = dyn_cast(Cur);
+  if (!BaseExpr) {
+BaseExpr = new (S.Context)
+OpaqueValueExpr(Cur->getExprLoc(), Cur->getType(),
+Cur->getValueKind(), Cur->getObjectKind(), Cur);
+  }
   Expr *IndexExpr =
   new (S.Context) ArrayInitIndexExpr(S.Context.getSizeType());
   CurInit = S.CreateBuiltinArraySubscriptExpr(


Index: clang/test/SemaCXX/pr45964-nested-ove.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/pr45964-nested-ove.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -std=c++17 -emit-codegen-only -verify %s
+// Don't crash (Bugzilla - Bug 45964).
+
+// non-dependent ArrayInitLoop should not, upon instantiation,
+// contain an OpaqueValueExpr with a nested OpaqueValueExpr or an
+// uninstantiated source expr. (triggers asserts in CodeGen)
+
+// expected-no-diagnostics
+int a[1];
+template  void b() {
+  auto [c] = a;
+}
+void (*d)(){b<0>};
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -10511,7 +10511,19 @@
 TreeTransform::TransformOpaqueValueExpr(OpaqueValueExpr *E) {
   assert((!E->getSourceExpr() || getDerived().AlreadyTransformed(E->getType())) &&
  "opaque value expression requires transformation");
-  return E;
+
+  // Note that SourceExpr can be nullptr
+  ExprResult SourceExpr = TransformExpr(E->getSourceExpr());
+  if (SourceExpr.isInvalid())
+return ExprError();
+  if (SourceExpr.get() == E->getSourceExpr() && !getDerived().AlwaysRebuild()) {
+return E;
+  }
+
+  OpaqueValueExpr *New = new (SemaRef.Context)
+  OpaqueValueExpr(E->getExprLoc(), E->getType(), E->getValueKind(),
+  E->getObjectKind(), SourceExpr.get());
+  return New;
 }
 
 template
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -8643,9 +8643,13 @@
 
 case SK_ArrayLoopIndex: {
   Expr *Cur = CurInit.get();
-  Expr *BaseExpr = new (S.Context)
-  

[PATCH] D108647: [clang][deps] Use top-level modules as precompiled dependencies

2021-08-24 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith accepted this revision.
dexonsmith added a comment.
This revision is now accepted and ready to land.

This LGTM.

> The documentation of Module::PresumedModuleMapFile says this field is 
> non-empty only when building from preprocessed source. This means there can 
> still be cases where the dependency scanner generates empty 
> -fmodule-map-file= arguments. That's being addressed in separate patch: 
> D108544 .

I think the documentation might be out of date since 
ab75597ddac52f24e9cbd794cded195262ef670e. I made a comment in D108544 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108647

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


[PATCH] D108544: [clang][deps] Avoid generating arguments for missing module map files

2021-08-24 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

In D108544#2962890 , @jansvoboda11 
wrote:

> I created D108647  to more 
> directly/correctly address the issues I'm seeing at the moment in explicit 
> builds.
>
> I think dealing with the possibility of empty `PresumedModuleMapFile` is 
> still valuable, but I'm not aware how to test this at the moment (create 
> module from non-preprocessed sources).

I'm not sure it is possible, based it being filled in always in ASTReader.cpp. 
I think this changed in ab75597ddac52f24e9cbd794cded195262ef670e but the 
comment wasn't updated. I suggest adding an assert that the module map file is 
not empty.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108544

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


[PATCH] D108661: The maximal representable alignment in LLVM IR is 1GiB, not 512MiB

2021-08-24 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

Could use some MIR tests to make sure that parser doesn't explode


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108661

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


[PATCH] D67429: Improve code generation for thread_local variables:

2021-08-24 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In D67429#2961873 , @rjmccall wrote:

> @rsmith, can you fix or revert?

Sorry for the long delay here. Looking now.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D67429

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


[PATCH] D108603: [clang][codegen] Set CurLinkModule in CodeGenAction::ExecuteAction

2021-08-24 Thread Bob Haarman via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1c829ce1e362: [clang][codegen] Set CurLinkModule in 
CodeGenAction::ExecuteAction (authored by inglorion).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108603

Files:
  clang/include/clang/Basic/DiagnosticFrontendKinds.td
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/test/CodeGen/Inputs/linker-diagnostic1.ll
  clang/test/CodeGen/linker-diagnostic.ll
  clang/test/Misc/serialized-diags-driver.c

Index: clang/test/Misc/serialized-diags-driver.c
===
--- clang/test/Misc/serialized-diags-driver.c
+++ clang/test/Misc/serialized-diags-driver.c
@@ -8,7 +8,8 @@
 // RUN: %clang -Wx-typoed-warning -Wall -fsyntax-only --serialize-diagnostics %t.diag %s
 // RUN: c-index-test -read-diagnostics %t.diag 2>&1 | FileCheck %s
 
-// CHECK: warning: unknown warning option '-Wx-typoed-warning' [-Wunknown-warning-option] []
+// CHECK: warning: unknown warning option '-Wx-typoed-warning'
+// CHECK-SAME: [-Wunknown-warning-option] []
 
 // CHECK: warning: variable 'voodoo' is uninitialized when used here [-Wuninitialized]
 // CHECK: note: initialize the variable 'voodoo' to silence this warning []
Index: clang/test/CodeGen/linker-diagnostic.ll
===
--- /dev/null
+++ clang/test/CodeGen/linker-diagnostic.ll
@@ -0,0 +1,17 @@
+; RUN: mkdir -p %t
+; RUN: opt -module-summary -o %t/foo.o %s
+; RUN: opt -module-summary -o %t/bar.o %S/Inputs/linker-diagnostic1.ll
+; RUN: llvm-lto2 run --thinlto-distributed-indexes -r %t/foo.o,foo,plx -r %t/bar.o,bar,plx \
+; RUN:   -r %t/bar.o,foo, -o %t/foobar.so %t/foo.o %t/bar.o
+; RUN: %clang -c -o %t/lto.bar.o --target=armv4-none-unknown-eabi -O2 \
+; RUN:   -fthinlto-index=%t/bar.o.thinlto.bc %t/bar.o -Wno-override-module 2>&1 | FileCheck %s
+
+; CHECK: linking module '{{.*}}/bar.o': Linking two modules of different target triples: '{{.*}}/foo.o' is 'thumbv6-unknown-linux-gnueabihf' whereas '{{.*}}/bar.o' is 'armv4-none-unknown-eabi'
+
+target triple = "thumbv6-unknown-linux-gnueabihf"
+target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"
+
+define i32 @foo(i32 %x) {
+  %1 = add i32 %x, 1
+  ret i32 %1
+}
Index: clang/test/CodeGen/Inputs/linker-diagnostic1.ll
===
--- /dev/null
+++ clang/test/CodeGen/Inputs/linker-diagnostic1.ll
@@ -0,0 +1,9 @@
+target triple = "armv4-none-unknown-eabi"
+target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"
+
+declare i32 @foo(i32)
+
+define i32 @bar(i32 %x) {
+  %1 = tail call i32 @foo(i32 %x)
+  ret i32 %1
+}
Index: clang/lib/CodeGen/CodeGenAction.cpp
===
--- clang/lib/CodeGen/CodeGenAction.cpp
+++ clang/lib/CodeGen/CodeGenAction.cpp
@@ -160,7 +160,7 @@
 const PreprocessorOptions ,
 const CodeGenOptions ,
 const TargetOptions ,
-const LangOptions ,
+const LangOptions , llvm::Module *Module,
 SmallVector LinkModules, LLVMContext ,
 CoverageSourceInfo *CoverageInfo = nullptr)
 : Diags(Diags), Action(Action), HeaderSearchOpts(HeaderSearchOpts),
@@ -170,7 +170,7 @@
   LLVMIRGenerationRefCount(0),
   Gen(CreateLLVMCodeGen(Diags, "", HeaderSearchOpts, PPOpts,
 CodeGenOpts, C, CoverageInfo)),
-  LinkModules(std::move(LinkModules)) {
+  LinkModules(std::move(LinkModules)), CurLinkModule(Module) {
   TimerIsEnabled = CodeGenOpts.TimePasses;
   llvm::TimePassesIsEnabled = CodeGenOpts.TimePasses;
   llvm::TimePassesPerRun = CodeGenOpts.TimePassesPerRun;
@@ -779,11 +779,7 @@
 ComputeDiagID(Severity, backend_frame_larger_than, DiagID);
 break;
   case DK_Linker:
-assert(CurLinkModule);
-// FIXME: stop eating the warnings and notes.
-if (Severity != DS_Error)
-  return;
-DiagID = diag::err_fe_cannot_link_module;
+ComputeDiagID(Severity, linking_module, DiagID);
 break;
   case llvm::DK_OptimizationRemark:
 // Optimization remarks are always handled completely by this
@@ -845,9 +841,9 @@
 DI.print(DP);
   }
 
-  if (DiagID == diag::err_fe_cannot_link_module) {
-Diags.Report(diag::err_fe_cannot_link_module)
-<< CurLinkModule->getModuleIdentifier() << MsgStorage;
+  if (DI.getKind() == DK_Linker) {
+assert(CurLinkModule && "CurLinkModule must be set for linker diagnostics");
+Diags.Report(DiagID) << CurLinkModule->getModuleIdentifier() << MsgStorage;
 return;
   }
 
@@ -1088,7 +1084,7 @@
   // BackendConsumer.
   BackendConsumer Result(BA, CI.getDiagnostics(), 

[clang] 1c829ce - [clang][codegen] Set CurLinkModule in CodeGenAction::ExecuteAction

2021-08-24 Thread Bob Haarman via cfe-commits

Author: Bob Haarman
Date: 2021-08-24T21:25:49Z
New Revision: 1c829ce1e3627cf9b22da33943dc2e423ded11c4

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

LOG: [clang][codegen] Set CurLinkModule in CodeGenAction::ExecuteAction

CodeGenAction::ExecuteAction creates a BackendConsumer for the
purpose of handling diagnostics. The BackendConsumer's
DiagnosticHandlerImpl method expects CurLinkModule to be set,
but this did not happen on the code path that goes through
ExecuteAction. This change makes it so that the BackendConsumer
constructor used by ExecuteAction requires the Module to be
specified and passes the appropriate module in ExecuteAction.

The change also adds a test that fails without this change
and passes with it. To make the test work, the FIXME in the
handling of DK_Linker diagnostics was addressed so that warnings
and notes are no longer silently discarded. Since this introduces
a new warning diagnostic, a flag to control it (-Wlinker-warnings)
has also been added.

Reviewed By: xur

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

Added: 
clang/test/CodeGen/Inputs/linker-diagnostic1.ll
clang/test/CodeGen/linker-diagnostic.ll

Modified: 
clang/include/clang/Basic/DiagnosticFrontendKinds.td
clang/include/clang/Basic/DiagnosticGroups.td
clang/lib/CodeGen/CodeGenAction.cpp
clang/test/Misc/serialized-diags-driver.c

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticFrontendKinds.td 
b/clang/include/clang/Basic/DiagnosticFrontendKinds.td
index 2bbc93d5682ce..fceafb93eda28 100644
--- a/clang/include/clang/Basic/DiagnosticFrontendKinds.td
+++ b/clang/include/clang/Basic/DiagnosticFrontendKinds.td
@@ -22,8 +22,9 @@ def note_fe_inline_asm_here : Note<"instantiated into 
assembly here">;
 def err_fe_source_mgr : Error<"%0">, CatSourceMgr;
 def warn_fe_source_mgr : Warning<"%0">, CatSourceMgr, 
InGroup;
 def note_fe_source_mgr : Note<"%0">, CatSourceMgr;
-def err_fe_cannot_link_module : Error<"cannot link module '%0': %1">,
-  DefaultFatal;
+def err_fe_linking_module : Error<"cannot link module '%0': %1">, DefaultFatal;
+def warn_fe_linking_module : Warning<"linking module '%0': %1">, 
InGroup;
+def note_fe_linking_module : Note<"linking module '%0': %1">;
 
 def warn_fe_frame_larger_than : Warning<"stack frame size (%0) exceeds limit 
(%1) in %q2">,
 BackendInfo, InGroup;

diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 753a3d5546e2f..95023b8b34375 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -1194,6 +1194,9 @@ def ASM : DiagGroup<"asm", [
 ASMOperandWidths
   ]>;
 
+// Linker warnings.
+def LinkerWarnings : DiagGroup<"linker-warnings">;
+
 // OpenMP warnings.
 def SourceUsesOpenMP : DiagGroup<"source-uses-openmp">;
 def OpenMPClauses : DiagGroup<"openmp-clauses">;

diff  --git a/clang/lib/CodeGen/CodeGenAction.cpp 
b/clang/lib/CodeGen/CodeGenAction.cpp
index b30bd11edbadb..e66e41d1278e3 100644
--- a/clang/lib/CodeGen/CodeGenAction.cpp
+++ b/clang/lib/CodeGen/CodeGenAction.cpp
@@ -160,7 +160,7 @@ namespace clang {
 const PreprocessorOptions ,
 const CodeGenOptions ,
 const TargetOptions ,
-const LangOptions ,
+const LangOptions , llvm::Module *Module,
 SmallVector LinkModules, LLVMContext ,
 CoverageSourceInfo *CoverageInfo = nullptr)
 : Diags(Diags), Action(Action), HeaderSearchOpts(HeaderSearchOpts),
@@ -170,7 +170,7 @@ namespace clang {
   LLVMIRGenerationRefCount(0),
   Gen(CreateLLVMCodeGen(Diags, "", HeaderSearchOpts, PPOpts,
 CodeGenOpts, C, CoverageInfo)),
-  LinkModules(std::move(LinkModules)) {
+  LinkModules(std::move(LinkModules)), CurLinkModule(Module) {
   TimerIsEnabled = CodeGenOpts.TimePasses;
   llvm::TimePassesIsEnabled = CodeGenOpts.TimePasses;
   llvm::TimePassesPerRun = CodeGenOpts.TimePassesPerRun;
@@ -779,11 +779,7 @@ void BackendConsumer::DiagnosticHandlerImpl(const 
DiagnosticInfo ) {
 ComputeDiagID(Severity, backend_frame_larger_than, DiagID);
 break;
   case DK_Linker:
-assert(CurLinkModule);
-// FIXME: stop eating the warnings and notes.
-if (Severity != DS_Error)
-  return;
-DiagID = diag::err_fe_cannot_link_module;
+ComputeDiagID(Severity, linking_module, DiagID);
 break;
   case llvm::DK_OptimizationRemark:
 // Optimization remarks are always handled completely by this
@@ -845,9 +841,9 @@ void BackendConsumer::DiagnosticHandlerImpl(const 
DiagnosticInfo ) {
 DI.print(DP);
   }
 
-  if (DiagID == 

[PATCH] D108661: The maximal representable alignment in LLVM IR is 1GiB, not 512MiB

2021-08-24 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

Wild speculation. This may be a historical artifact of LoadInst and StoreInst 
having their getAlignment() function written like this when this limit was 
created

  unsigned getAlignment() const {
return (1 << (getSubclassDataFromInstruction() >> 1)) >> 1;
  }

Because "1" is signed int the left shift produced a signed int. The final right 
shift would be an arithmetic shift. So if the alignment was 1 << 30, the 
subclass data would be 31, the shift would produce INT_MIN, and the arithmetic 
right shift would produce 0xc000 which would be incorrect.

AllocaInst used 1U instead of 1 so would have been immune.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108661

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


[PATCH] D108003: [Clang] Extend -Wbool-operation to warn about bitwise and of bools with side effects

2021-08-24 Thread Ryan Beltran via Phabricator via cfe-commits
rpbeltran added a comment.

In D108003#2956332 , @xbolva00 wrote:

>>> and it would be more of an optimization than correctness issue as far as I 
>>> understand
>
> Yeah, this is right, indeed.
>
> Maybe @rpbeltran has some idea or motivating cases for OR pattern?

I don't actually have a case off-hand that I've spotted from the real world, 
but this example snippet seems plausible enough:

  if (queue.empty() || queue.pop() == STOP_TOKEN) {
break;
  }

Consider that in this scenario, we only consider queue.pop() if the queue is 
not empty due to short circuiting.

  if (queue.empty() | queue.pop() == STOP_TOKEN) {
break;
  }

While this scenario calls pop() regardless, likely causing a runtime error if 
the queue is empty.

I'll run this warning against ChromeOS and see if I spot any interesting 
results.


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

https://reviews.llvm.org/D108003

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


[PATCH] D108661: The maximal representable alignment in LLVM IR is 1GiB, not 512MiB

2021-08-24 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri created this revision.
lebedev.ri added reviewers: jdoerfert, efriedma, aaron.ballman, nikic, MaskRay.
lebedev.ri added a project: LLVM.
Herald added subscribers: dexonsmith, okura, kuter, pengfei, jfb.
lebedev.ri requested review of this revision.
Herald added a reviewer: sstefan1.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a reviewer: baziotis.
Herald added a project: clang.

In IR bitcode, the alignment is stored log2, biased by one (to represent 
'default' alignment),
in 5 bits (would one/two extra bits cause the sky to fall?).
But that means that the maximal alignment exponent is `(1<<5)-2`, which is 
`30`, not `29`.
And indeed, alignment of `1073741824` rountrips IR 
serialization-deserialization.

While this doesn't seem all that important, this doubles the maximal supported 
alignment
from 512MiB to 1GiB, and there's actually one noticeable use-case for that;
On X86, the huge pages can have sizes of 2MiB and 1GiB (!).

So while this doesn't add support for truly huge alignments,
i think this adds zero-cost support for a not-trivially-dismissable case.

I don't believe we need any upgrade infrastructure,
but perhaps we bump the IR version?


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108661

Files:
  clang/include/clang/Sema/Sema.h
  clang/test/CXX/drs/dr6xx.cpp
  clang/test/CodeGen/builtin-assume-aligned.c
  
clang/test/CodeGen/catch-alignment-assumption-attribute-align_value-on-paramvar.cpp
  
clang/test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-three-params-variable.cpp
  
clang/test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-three-params.cpp
  
clang/test/CodeGen/catch-alignment-assumption-builtin_assume_aligned-two-params.cpp
  clang/test/CodeGen/catch-alignment-assumption-openmp.cpp
  clang/test/Sema/alloc-align-attr.c
  clang/test/Sema/attr-aligned.c
  clang/test/Sema/builtin-assume-aligned.c
  clang/test/SemaCXX/alloc-align-attr.cpp
  llvm/include/llvm/IR/Instruction.h
  llvm/include/llvm/IR/Value.h
  llvm/test/Assembler/align-inst-alloca.ll
  llvm/test/Assembler/align-inst-load.ll
  llvm/test/Assembler/align-inst-store.ll
  llvm/test/Bitcode/inalloca.ll
  llvm/test/Transforms/Attributor/ArgumentPromotion/live_called_from_dead.ll
  llvm/test/Transforms/Attributor/ArgumentPromotion/live_called_from_dead_2.ll
  llvm/test/Transforms/Attributor/IPConstantProp/PR26044.ll
  llvm/test/Transforms/Attributor/IPConstantProp/pthreads.ll
  llvm/test/Transforms/Attributor/callbacks.ll
  llvm/test/Transforms/Attributor/liveness.ll
  llvm/test/Transforms/Attributor/memory_locations.ll
  llvm/test/Transforms/Attributor/noalias.ll
  llvm/test/Transforms/Attributor/nocapture-1.ll
  llvm/test/Transforms/Attributor/noundef.ll
  llvm/test/Transforms/Attributor/undefined_behavior.ll
  llvm/test/Transforms/Attributor/value-simplify.ll
  llvm/test/Transforms/GVN/PRE/2017-06-28-pre-load-dbgloc.ll
  llvm/test/Transforms/InstCombine/atomic.ll
  llvm/test/Transforms/InstCombine/getelementptr.ll
  llvm/test/Transforms/InstCombine/load.ll
  llvm/test/Transforms/InstCombine/mempcpy.ll
  llvm/test/Transforms/InstCombine/pr44245.ll
  llvm/test/Transforms/InstCombine/store.ll
  llvm/test/Transforms/OpenMP/parallel_level_fold.ll
  llvm/test/Verifier/align-md.ll
  llvm/unittests/IR/ValueTest.cpp

Index: llvm/unittests/IR/ValueTest.cpp
===
--- llvm/unittests/IR/ValueTest.cpp
+++ llvm/unittests/IR/ValueTest.cpp
@@ -61,9 +61,9 @@
  GlobalVariable::NotThreadLocal,
  1);
 
-  EXPECT_TRUE(Value::MaximumAlignment == 536870912U);
-  Dummy0->setAlignment(Align(536870912));
-  EXPECT_EQ(Dummy0->getAlignment(), 536870912U);
+  EXPECT_TRUE(Value::MaximumAlignment == 1073741824U);
+  Dummy0->setAlignment(Align(1073741824));
+  EXPECT_EQ(Dummy0->getAlignment(), 1073741824U);
 
   // Make sure the address space isn't dropped when returning this.
   Constant *Dummy1 = M->getOrInsertGlobal("dummy", Int32Ty);
@@ -101,7 +101,7 @@
  Constant::getAllOnesValue(Int32Ty), "var", nullptr,
  GlobalVariable::NotThreadLocal, 1);
 
-  EXPECT_DEATH(Var->setAlignment(Align(1073741824U)),
+  EXPECT_DEATH(Var->setAlignment(Align(2147483648U)),
"Alignment is greater than MaximumAlignment");
 }
 #endif
Index: llvm/test/Verifier/align-md.ll
===
--- llvm/test/Verifier/align-md.ll
+++ llvm/test/Verifier/align-md.ll
@@ -52,8 +52,8 @@
 
 define i8* @f7(i8** %x) {
 entry:
-  %y = load i8*, i8** %x, !align !{i64 1073741824}
+  %y = load i8*, i8** %x, !align !{i64 2147483648}
   ret i8* %y
 }
 ; CHECK: alignment is larger that implementation defined limit
-; CHECK-NEXT: load i8*, i8** %x
\ No newline at end of file
+; CHECK-NEXT: load i8*, i8** %x
Index: llvm/test/Transforms/OpenMP/parallel_level_fold.ll

[PATCH] D108648: [Clang][OpenMP] Use enum to dereference children data array in OMPAtomicDirective

2021-08-24 Thread Shilei Tian via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG148bc251f48e: [Clang][OpenMP] Use enum to dereference 
children data array in… (authored by tianshilei1992).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108648

Files:
  clang/include/clang/AST/StmtOpenMP.h


Index: clang/include/clang/AST/StmtOpenMP.h
===
--- clang/include/clang/AST/StmtOpenMP.h
+++ clang/include/clang/AST/StmtOpenMP.h
@@ -2794,16 +2794,25 @@
   : OMPExecutableDirective(OMPAtomicDirectiveClass, llvm::omp::OMPD_atomic,
SourceLocation(), SourceLocation()) {}
 
+  enum DataPositionTy : size_t {
+POS_X = 0,
+POS_V,
+POS_E,
+POS_UpdateExpr,
+  };
+
   /// Set 'x' part of the associated expression/statement.
-  void setX(Expr *X) { Data->getChildren()[0] = X; }
+  void setX(Expr *X) { Data->getChildren()[DataPositionTy::POS_X] = X; }
   /// Set helper expression of the form
   /// 'OpaqueValueExpr(x) binop OpaqueValueExpr(expr)' or
   /// 'OpaqueValueExpr(expr) binop OpaqueValueExpr(x)'.
-  void setUpdateExpr(Expr *UE) { Data->getChildren()[1] = UE; }
+  void setUpdateExpr(Expr *UE) {
+Data->getChildren()[DataPositionTy::POS_UpdateExpr] = UE;
+  }
   /// Set 'v' part of the associated expression/statement.
-  void setV(Expr *V) { Data->getChildren()[2] = V; }
+  void setV(Expr *V) { Data->getChildren()[DataPositionTy::POS_V] = V; }
   /// Set 'expr' part of the associated expression/statement.
-  void setExpr(Expr *E) { Data->getChildren()[3] = E; }
+  void setExpr(Expr *E) { Data->getChildren()[DataPositionTy::POS_E] = E; }
 
 public:
   /// Creates directive with a list of \a Clauses and 'x', 'v' and 'expr'
@@ -2840,16 +2849,22 @@
  unsigned NumClauses, EmptyShell);
 
   /// Get 'x' part of the associated expression/statement.
-  Expr *getX() { return cast_or_null(Data->getChildren()[0]); }
+  Expr *getX() {
+return cast_or_null(Data->getChildren()[DataPositionTy::POS_X]);
+  }
   const Expr *getX() const {
-return cast_or_null(Data->getChildren()[0]);
+return cast_or_null(Data->getChildren()[DataPositionTy::POS_X]);
   }
   /// Get helper expression of the form
   /// 'OpaqueValueExpr(x) binop OpaqueValueExpr(expr)' or
   /// 'OpaqueValueExpr(expr) binop OpaqueValueExpr(x)'.
-  Expr *getUpdateExpr() { return cast_or_null(Data->getChildren()[1]); }
+  Expr *getUpdateExpr() {
+return cast_or_null(
+Data->getChildren()[DataPositionTy::POS_UpdateExpr]);
+  }
   const Expr *getUpdateExpr() const {
-return cast_or_null(Data->getChildren()[1]);
+return cast_or_null(
+Data->getChildren()[DataPositionTy::POS_UpdateExpr]);
   }
   /// Return true if helper update expression has form
   /// 'OpaqueValueExpr(x) binop OpaqueValueExpr(expr)' and false if it has form
@@ -2859,14 +2874,18 @@
   /// 'x', false if 'v' must be updated to the new value of 'x'.
   bool isPostfixUpdate() const { return IsPostfixUpdate; }
   /// Get 'v' part of the associated expression/statement.
-  Expr *getV() { return cast_or_null(Data->getChildren()[2]); }
+  Expr *getV() {
+return cast_or_null(Data->getChildren()[DataPositionTy::POS_V]);
+  }
   const Expr *getV() const {
-return cast_or_null(Data->getChildren()[2]);
+return cast_or_null(Data->getChildren()[DataPositionTy::POS_V]);
   }
   /// Get 'expr' part of the associated expression/statement.
-  Expr *getExpr() { return cast_or_null(Data->getChildren()[3]); }
+  Expr *getExpr() {
+return cast_or_null(Data->getChildren()[DataPositionTy::POS_E]);
+  }
   const Expr *getExpr() const {
-return cast_or_null(Data->getChildren()[3]);
+return cast_or_null(Data->getChildren()[DataPositionTy::POS_E]);
   }
 
   static bool classof(const Stmt *T) {


Index: clang/include/clang/AST/StmtOpenMP.h
===
--- clang/include/clang/AST/StmtOpenMP.h
+++ clang/include/clang/AST/StmtOpenMP.h
@@ -2794,16 +2794,25 @@
   : OMPExecutableDirective(OMPAtomicDirectiveClass, llvm::omp::OMPD_atomic,
SourceLocation(), SourceLocation()) {}
 
+  enum DataPositionTy : size_t {
+POS_X = 0,
+POS_V,
+POS_E,
+POS_UpdateExpr,
+  };
+
   /// Set 'x' part of the associated expression/statement.
-  void setX(Expr *X) { Data->getChildren()[0] = X; }
+  void setX(Expr *X) { Data->getChildren()[DataPositionTy::POS_X] = X; }
   /// Set helper expression of the form
   /// 'OpaqueValueExpr(x) binop OpaqueValueExpr(expr)' or
   /// 'OpaqueValueExpr(expr) binop OpaqueValueExpr(x)'.
-  void setUpdateExpr(Expr *UE) { Data->getChildren()[1] = UE; }
+  void setUpdateExpr(Expr *UE) {
+Data->getChildren()[DataPositionTy::POS_UpdateExpr] = UE;
+  }
   /// Set 'v' part of the associated expression/statement.
-  

[clang] 148bc25 - [Clang][OpenMP] Use enum to dereference children data array in OMPAtomicDirective

2021-08-24 Thread Shilei Tian via cfe-commits

Author: Shilei Tian
Date: 2021-08-24T16:00:24-04:00
New Revision: 148bc251f48ee68af9b7c7eb725d4ed888629b5c

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

LOG: [Clang][OpenMP] Use enum to dereference children data array in 
OMPAtomicDirective

Reviewed By: ABataev

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

Added: 


Modified: 
clang/include/clang/AST/StmtOpenMP.h

Removed: 




diff  --git a/clang/include/clang/AST/StmtOpenMP.h 
b/clang/include/clang/AST/StmtOpenMP.h
index 9c85df741f48a..cd5fa2b94c317 100644
--- a/clang/include/clang/AST/StmtOpenMP.h
+++ b/clang/include/clang/AST/StmtOpenMP.h
@@ -2794,16 +2794,25 @@ class OMPAtomicDirective : public 
OMPExecutableDirective {
   : OMPExecutableDirective(OMPAtomicDirectiveClass, llvm::omp::OMPD_atomic,
SourceLocation(), SourceLocation()) {}
 
+  enum DataPositionTy : size_t {
+POS_X = 0,
+POS_V,
+POS_E,
+POS_UpdateExpr,
+  };
+
   /// Set 'x' part of the associated expression/statement.
-  void setX(Expr *X) { Data->getChildren()[0] = X; }
+  void setX(Expr *X) { Data->getChildren()[DataPositionTy::POS_X] = X; }
   /// Set helper expression of the form
   /// 'OpaqueValueExpr(x) binop OpaqueValueExpr(expr)' or
   /// 'OpaqueValueExpr(expr) binop OpaqueValueExpr(x)'.
-  void setUpdateExpr(Expr *UE) { Data->getChildren()[1] = UE; }
+  void setUpdateExpr(Expr *UE) {
+Data->getChildren()[DataPositionTy::POS_UpdateExpr] = UE;
+  }
   /// Set 'v' part of the associated expression/statement.
-  void setV(Expr *V) { Data->getChildren()[2] = V; }
+  void setV(Expr *V) { Data->getChildren()[DataPositionTy::POS_V] = V; }
   /// Set 'expr' part of the associated expression/statement.
-  void setExpr(Expr *E) { Data->getChildren()[3] = E; }
+  void setExpr(Expr *E) { Data->getChildren()[DataPositionTy::POS_E] = E; }
 
 public:
   /// Creates directive with a list of \a Clauses and 'x', 'v' and 'expr'
@@ -2840,16 +2849,22 @@ class OMPAtomicDirective : public 
OMPExecutableDirective {
  unsigned NumClauses, EmptyShell);
 
   /// Get 'x' part of the associated expression/statement.
-  Expr *getX() { return cast_or_null(Data->getChildren()[0]); }
+  Expr *getX() {
+return cast_or_null(Data->getChildren()[DataPositionTy::POS_X]);
+  }
   const Expr *getX() const {
-return cast_or_null(Data->getChildren()[0]);
+return cast_or_null(Data->getChildren()[DataPositionTy::POS_X]);
   }
   /// Get helper expression of the form
   /// 'OpaqueValueExpr(x) binop OpaqueValueExpr(expr)' or
   /// 'OpaqueValueExpr(expr) binop OpaqueValueExpr(x)'.
-  Expr *getUpdateExpr() { return cast_or_null(Data->getChildren()[1]); }
+  Expr *getUpdateExpr() {
+return cast_or_null(
+Data->getChildren()[DataPositionTy::POS_UpdateExpr]);
+  }
   const Expr *getUpdateExpr() const {
-return cast_or_null(Data->getChildren()[1]);
+return cast_or_null(
+Data->getChildren()[DataPositionTy::POS_UpdateExpr]);
   }
   /// Return true if helper update expression has form
   /// 'OpaqueValueExpr(x) binop OpaqueValueExpr(expr)' and false if it has form
@@ -2859,14 +2874,18 @@ class OMPAtomicDirective : public 
OMPExecutableDirective {
   /// 'x', false if 'v' must be updated to the new value of 'x'.
   bool isPostfixUpdate() const { return IsPostfixUpdate; }
   /// Get 'v' part of the associated expression/statement.
-  Expr *getV() { return cast_or_null(Data->getChildren()[2]); }
+  Expr *getV() {
+return cast_or_null(Data->getChildren()[DataPositionTy::POS_V]);
+  }
   const Expr *getV() const {
-return cast_or_null(Data->getChildren()[2]);
+return cast_or_null(Data->getChildren()[DataPositionTy::POS_V]);
   }
   /// Get 'expr' part of the associated expression/statement.
-  Expr *getExpr() { return cast_or_null(Data->getChildren()[3]); }
+  Expr *getExpr() {
+return cast_or_null(Data->getChildren()[DataPositionTy::POS_E]);
+  }
   const Expr *getExpr() const {
-return cast_or_null(Data->getChildren()[3]);
+return cast_or_null(Data->getChildren()[DataPositionTy::POS_E]);
   }
 
   static bool classof(const Stmt *T) {



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


[PATCH] D107685: [WebAssembly] Tidy up EH/SjLj options

2021-08-24 Thread Derek Schuff via Phabricator via cfe-commits
dschuff accepted this revision.
dschuff added inline comments.



Comment at: llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp:449
+  // done in WasmEHPrepare pass after these IR passes, but Wasm SjLj requires
+  // Emscripten libraries and processed together in LowerEmscriptenEHSjLJ pass.
+  if (WasmEnableEmEH || WasmEnableEmSjLj || WasmEnableSjLj)

aheejin wrote:
> dschuff wrote:
> > it's not clear what "and processed" is intended to mean here.
> Yeah the sentence is unclear and even grammatically incorrect... Rewrote it.
LGTM now


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107685

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


[PATCH] D42225: libcxx: Provide overloads for basic_filebuf::open() et al that take wchar_t* filenames on Windows.

2021-08-24 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a subscriber: CaseyCarter.
ldionne added a comment.

In D42225#2963190 , @mstorsjo wrote:

> In D42225#2962348 , @ldionne wrote:
>
>> @pcc @mstorsjo Are we aware of anyone using these extensions?
>>
>> I would like to suggest that we either remove this extension if it's not 
>> useful, or make it unconditional (not only on Windows) if we really think 
>> it's that useful (but I'd like that to come with at least a paper proposing 
>> to add them to the standard). Carrying around an extension that's only 
>> enabled on one platform (and not the most widely used platform for libc++ at 
>> that) is kind of awkward.
>
> This extension is fairly essential - without it, you can't interact with 
> files that have names outside of the 8 bit charset on Windows (and exactly 
> what the 8 bit charset is, can vary from system to system). I can't point to 
> a specific user of it, but I'd expect there to be numerous out there.
>
> Making it universally available sounds like a sensible strategy forward - 
> although I don't think I have the bandwidth to take on making it a standards 
> proposal. Maybe someone from Microsoft (who invented this extension) can 
> collaborate on it?

@CaseyCarter Any appetite for that?


Repository:
  rCXX libc++

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

https://reviews.llvm.org/D42225

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


[PATCH] D108377: [asan] Implemented flag to emit intrinsics to optimize ASan callbacks.

2021-08-24 Thread Kirill Stoimenov via Phabricator via cfe-commits
kstoimenov updated this revision to Diff 368432.
kstoimenov added a comment.

Updating after pushing D107850 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108377

Files:
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/test/Instrumentation/AddressSanitizer/asan-optimize-callbacks.ll


Index: llvm/test/Instrumentation/AddressSanitizer/asan-optimize-callbacks.ll
===
--- /dev/null
+++ llvm/test/Instrumentation/AddressSanitizer/asan-optimize-callbacks.ll
@@ -0,0 +1,14 @@
+; RUN: opt < %s -asan -asan-module -enable-new-pm=0 -S | FileCheck %s
+
+target triple = "x86_64-unknown-linux-gnu"
+
+define void @load1(i8* %p1, i16* %p2, i32* %p4, i64* %p8, i128* %p16)
+  sanitize_address {
+  %n1 = load i8, i8* %p1
+  %n2 = load i16, i16* %p2
+  %n4 = load i32, i32* %p4
+  %n8 = load i64, i64* %p8
+  %n16 = load i128, i128* %p16
+;  store i32 0, i32* %p4, align 8
+  ret void
+}
Index: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -356,6 +356,10 @@
 static cl::opt ClOpt("asan-opt", cl::desc("Optimize instrumentation"),
cl::Hidden, cl::init(true));
 
+static cl::opt ClOptimizeCallbacks("asan-optimize-callbacks",
+ cl::desc("Optimize callbacks"),
+ cl::Hidden, cl::init(false));
+
 static cl::opt ClOptSameTemp(
 "asan-opt-same-temp", cl::desc("Instrument the same temp just once"),
 cl::Hidden, cl::init(true));
@@ -657,6 +661,7 @@
 C = &(M.getContext());
 LongSize = M.getDataLayout().getPointerSizeInBits();
 IntptrTy = Type::getIntNTy(*C, LongSize);
+Int8PtrTy = Type::getInt8PtrTy(*C);
 TargetTriple = Triple(M.getTargetTriple());
 
 Mapping = getShadowMapping(TargetTriple, LongSize, this->CompileKernel);
@@ -747,6 +752,7 @@
   bool UseAfterScope;
   AsanDetectStackUseAfterReturnMode UseAfterReturn;
   Type *IntptrTy;
+  Type *Int8PtrTy;
   ShadowMapping Mapping;
   FunctionCallee AsanHandleNoReturnFunc;
   FunctionCallee AsanPtrCmpFunction, AsanPtrSubFunction;
@@ -1768,14 +1774,23 @@
   IRBuilder<> IRB(InsertBefore);
   Value *AddrLong = IRB.CreatePointerCast(Addr, IntptrTy);
   size_t AccessSizeIndex = TypeSizeToSizeIndex(TypeSize);
+  const ASanAccessInfo AccessInfo(IsWrite, CompileKernel, AccessSizeIndex);
 
   if (UseCalls) {
-if (Exp == 0)
-  IRB.CreateCall(AsanMemoryAccessCallback[IsWrite][0][AccessSizeIndex],
- AddrLong);
-else
-  IRB.CreateCall(AsanMemoryAccessCallback[IsWrite][1][AccessSizeIndex],
- {AddrLong, ConstantInt::get(IRB.getInt32Ty(), Exp)});
+if (ClOptimizeCallbacks) {
+  Value *Ptr8 = IRB.CreatePointerCast(Addr, Int8PtrTy);
+  Module *M = IRB.GetInsertBlock()->getParent()->getParent();
+  IRB.CreateCall(
+  Intrinsic::getDeclaration(M, Intrinsic::asan_check_memaccess),
+  {Ptr8, ConstantInt::get(IRB.getInt32Ty(), AccessInfo.Packed)});
+} else {
+  if (Exp == 0)
+IRB.CreateCall(AsanMemoryAccessCallback[IsWrite][0][AccessSizeIndex],
+   AddrLong);
+  else
+IRB.CreateCall(AsanMemoryAccessCallback[IsWrite][1][AccessSizeIndex],
+   {AddrLong, ConstantInt::get(IRB.getInt32Ty(), Exp)});
+}
 return;
   }
 


Index: llvm/test/Instrumentation/AddressSanitizer/asan-optimize-callbacks.ll
===
--- /dev/null
+++ llvm/test/Instrumentation/AddressSanitizer/asan-optimize-callbacks.ll
@@ -0,0 +1,14 @@
+; RUN: opt < %s -asan -asan-module -enable-new-pm=0 -S | FileCheck %s
+
+target triple = "x86_64-unknown-linux-gnu"
+
+define void @load1(i8* %p1, i16* %p2, i32* %p4, i64* %p8, i128* %p16)
+  sanitize_address {
+  %n1 = load i8, i8* %p1
+  %n2 = load i16, i16* %p2
+  %n4 = load i32, i32* %p4
+  %n8 = load i64, i64* %p8
+  %n16 = load i128, i128* %p16
+;  store i32 0, i32* %p4, align 8
+  ret void
+}
Index: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -356,6 +356,10 @@
 static cl::opt ClOpt("asan-opt", cl::desc("Optimize instrumentation"),
cl::Hidden, cl::init(true));
 
+static cl::opt ClOptimizeCallbacks("asan-optimize-callbacks",
+ cl::desc("Optimize callbacks"),
+ cl::Hidden, cl::init(false));
+
 static cl::opt ClOptSameTemp(
 "asan-opt-same-temp", 

[PATCH] D107850: [asan] Implemented intrinsic for the custom calling convention similar used by HWASan for X86.

2021-08-24 Thread Kirill Stoimenov via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9588b685c6b2: [asan] Implemented intrinsic for the custom 
calling convention similar used by… (authored by kstoimenov).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107850

Files:
  llvm/include/llvm/IR/Intrinsics.td
  llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
  llvm/lib/Target/X86/X86AsmPrinter.cpp
  llvm/lib/Target/X86/X86AsmPrinter.h
  llvm/lib/Target/X86/X86InstrCompiler.td
  llvm/lib/Target/X86/X86MCInstLower.cpp
  llvm/lib/Target/X86/X86RegisterInfo.td
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/test/CodeGen/X86/asan-check-memaccess-add.ll
  llvm/test/CodeGen/X86/asan-check-memaccess-or.ll
  llvm/tools/llvm-exegesis/CMakeLists.txt

Index: llvm/tools/llvm-exegesis/CMakeLists.txt
===
--- llvm/tools/llvm-exegesis/CMakeLists.txt
+++ llvm/tools/llvm-exegesis/CMakeLists.txt
@@ -1,4 +1,5 @@
 set(LLVM_LINK_COMPONENTS
+  Instrumentation
   MC
   MCParser
   Support
Index: llvm/test/CodeGen/X86/asan-check-memaccess-or.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/asan-check-memaccess-or.ll
@@ -0,0 +1,253 @@
+; RUN: llc < %s | FileCheck %s
+
+target triple = "x86_64-pc-win"
+
+define void @load1(i8* nocapture readonly %x) {
+; CHECK:  callq   __asan_check_load1_rn[[RN1:.*]]
+; CHECK:  callq   __asan_check_store1_rn[[RN1]]
+; CHECK-NEXT: retq
+  call void @llvm.asan.check.memaccess(i8* %x, i32 0)
+  call void @llvm.asan.check.memaccess(i8* %x, i32 32)
+  ret void
+}
+
+define void @load2(i16* nocapture readonly %x) {
+; CHECK:  callq   __asan_check_load2_rn[[RN2:.*]]
+; CHECK:  callq   __asan_check_store2_rn[[RN2]]
+; CHECK-NEXT: retq
+  %1 = ptrtoint i16* %x to i64
+  %2 = bitcast i16* %x to i8*
+  call void @llvm.asan.check.memaccess(i8* %2, i32 2)
+  call void @llvm.asan.check.memaccess(i8* %2, i32 34)
+  ret void
+}
+
+define void @load4(i32* nocapture readonly %x) {
+; CHECK:  callq   __asan_check_load4_rn[[RN4:.*]]
+; CHECK:  callq   __asan_check_store4_rn[[RN4]]
+; CHECK-NEXT: retq
+  %1 = ptrtoint i32* %x to i64
+  %2 = bitcast i32* %x to i8*
+  call void @llvm.asan.check.memaccess(i8* %2, i32 4)
+  call void @llvm.asan.check.memaccess(i8* %2, i32 36)
+  ret void
+}
+define void @load8(i64* nocapture readonly %x) {
+; CHECK:  callq   __asan_check_load8_rn[[RN8:.*]]
+; CHECK:  callq   __asan_check_store8_rn[[RN8]]
+; CHECK-NEXT: retq
+  %1 = ptrtoint i64* %x to i64
+  %2 = bitcast i64* %x to i8*
+  call void @llvm.asan.check.memaccess(i8* %2, i32 6)
+  call void @llvm.asan.check.memaccess(i8* %2, i32 38)
+  ret void
+}
+
+define void @load16(i128* nocapture readonly %x) {
+; CHECK:  callq   __asan_check_load16_rn[[RN16:.*]]
+; CHECK:  callq   __asan_check_store16_rn[[RN16]]
+; CHECK-NEXT: retq
+  %1 = ptrtoint i128* %x to i64
+  %2 = bitcast i128* %x to i8*
+  call void @llvm.asan.check.memaccess(i8* %2, i32 8)
+  call void @llvm.asan.check.memaccess(i8* %2, i32 40)
+  ret void
+}
+
+; CHECK:  .type   __asan_check_load1_rn[[RN1]],@function
+; CHECK-NEXT: .weak   __asan_check_load1_rn[[RN1]]
+; CHECK-NEXT: .hidden __asan_check_load1_rn[[RN1]]
+; CHECK-NEXT: __asan_check_load1_rn[[RN1]]:
+; CHECK-NEXT: movq[[REG:.*]], %r8
+; CHECK-NEXT: shrq$3, %r8
+; CHECK-NEXT: orq $17592186044416, %r8{{.*}}
+; CHECK-NEXT: movb(%r8), %r8b
+; CHECK-NEXT: testb   %r8b, %r8b
+; CHECK-NEXT: jne [[EXTRA:.*]]
+; CHECK-NEXT: [[RET:.*]]:
+; CHECK-NEXT: retq
+; CHECK-NEXT: [[EXTRA]]:
+; CHECK-NEXT: pushq   %rcx
+; CHECK-NEXT: movq[[REG]], %rcx
+; CHECK-NEXT: andl$7, %ecx
+; CHECK-NEXT: cmpl%r8d, %ecx
+; CHECK-NEXT: popq%rcx
+; CHECK-NEXT: jl  [[RET]]
+; CHECK-NEXT: movq[[REG:.*]], %rdi
+; CHECK-NEXT: jmp __asan_report_load1
+
+; CHECK:  .type   __asan_check_load2_rn[[RN2]],@function
+; CHECK-NEXT: .weak   __asan_check_load2_rn[[RN2]]
+; CHECK-NEXT: .hidden __asan_check_load2_rn[[RN2]]
+; CHECK-NEXT: __asan_check_load2_rn[[RN2]]:
+; CHECK-NEXT: movq[[REG:.*]], %r8
+; CHECK-NEXT: shrq$3, %r8
+; CHECK-NEXT: orq $17592186044416, %r8{{.*}}
+; CHECK-NEXT: movb(%r8), %r8b
+; CHECK-NEXT: testb   %r8b, %r8b
+; CHECK-NEXT: jne [[EXTRA:.*]]
+; CHECK-NEXT: [[RET:.*]]:
+; CHECK-NEXT: retq
+; CHECK-NEXT: [[EXTRA]]:
+; CHECK-NEXT: pushq   %rcx
+; CHECK-NEXT: movq[[REG]], 

[PATCH] D42225: libcxx: Provide overloads for basic_filebuf::open() et al that take wchar_t* filenames on Windows.

2021-08-24 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In D42225#2962348 , @ldionne wrote:

> @pcc @mstorsjo Are we aware of anyone using these extensions?
>
> I would like to suggest that we either remove this extension if it's not 
> useful, or make it unconditional (not only on Windows) if we really think 
> it's that useful (but I'd like that to come with at least a paper proposing 
> to add them to the standard). Carrying around an extension that's only 
> enabled on one platform (and not the most widely used platform for libc++ at 
> that) is kind of awkward.

This extension is fairly essential - without it, you can't interact with files 
that have names outside of the 8 bit charset on Windows (and exactly what the 8 
bit charset is, can vary from system to system). I can't point to a specific 
user of it, but I'd expect there to be numerous out there.

Making it universally available sounds like a sensible strategy forward - 
although I don't think I have the bandwidth to take on making it a standards 
proposal. Maybe someone from Microsoft (who invented this extension) can 
collaborate on it?


Repository:
  rCXX libc++

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

https://reviews.llvm.org/D42225

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


[PATCH] D105151: [OPENMP]Fix PR50733: unexpected final value of list-item in linear clause in loop construct.

2021-08-24 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 368427.
ABataev added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105151

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/for_linear_codegen.cpp
  clang/test/OpenMP/for_simd_codegen.cpp
  clang/test/OpenMP/parallel_for_linear_codegen.cpp
  clang/test/OpenMP/parallel_for_simd_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/simd_codegen.cpp
  clang/test/OpenMP/target_parallel_for_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_codegen.cpp

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


[PATCH] D108377: [asan] Implemented flag to emit intrinsics to optimize ASan callbacks.

2021-08-24 Thread Kirill Stoimenov via Phabricator via cfe-commits
kstoimenov planned changes to this revision.
kstoimenov added a comment.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108377

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


[PATCH] D105297: [OPENMP]Fix PR50347: Mapping of global scope deep object fails.

2021-08-24 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 368426.
ABataev added a comment.
Herald added a subscriber: jfb.

Rebase + update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105297

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/reduction_implicit_map.cpp
  clang/test/OpenMP/target_codegen.cpp
  clang/test/OpenMP/target_data_codegen.cpp
  clang/test/OpenMP/target_data_map_pointer_array_subscript_codegen.cpp
  clang/test/OpenMP/target_data_use_device_addr_codegen.cpp
  clang/test/OpenMP/target_defaultmap_codegen_01.cpp
  clang/test/OpenMP/target_enter_data_codegen.cpp
  clang/test/OpenMP/target_enter_data_depend_codegen.cpp
  clang/test/OpenMP/target_exit_data_codegen.cpp
  clang/test/OpenMP/target_exit_data_depend_codegen.cpp
  clang/test/OpenMP/target_firstprivate_codegen.cpp
  clang/test/OpenMP/target_map_codegen_12.cpp
  clang/test/OpenMP/target_map_codegen_13.cpp
  clang/test/OpenMP/target_map_codegen_14.cpp
  clang/test/OpenMP/target_map_codegen_18.inc
  clang/test/OpenMP/target_map_codegen_20.cpp
  clang/test/OpenMP/target_map_codegen_23.cpp
  clang/test/OpenMP/target_map_codegen_28.cpp
  clang/test/OpenMP/target_map_codegen_29.cpp
  clang/test/OpenMP/target_map_codegen_31.cpp
  clang/test/OpenMP/target_map_codegen_32.cpp
  clang/test/OpenMP/target_map_codegen_34.cpp
  clang/test/OpenMP/target_map_codegen_35.cpp
  clang/test/OpenMP/target_map_member_expr_array_section_codegen.cpp
  clang/test/OpenMP/target_parallel_codegen.cpp
  clang/test/OpenMP/target_parallel_for_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/target_simd_codegen.cpp
  clang/test/OpenMP/target_teams_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_collapse_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_dist_schedule_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_collapse_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_dist_schedule_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_schedule_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_collapse_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_dist_schedule_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_schedule_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_collapse_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_dist_schedule_codegen.cpp
  clang/test/OpenMP/target_update_codegen.cpp
  clang/test/OpenMP/target_update_depend_codegen.cpp
  clang/test/OpenMP/teams_distribute_codegen.cpp
  clang/test/OpenMP/teams_distribute_collapse_codegen.cpp
  clang/test/OpenMP/teams_distribute_dist_schedule_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_collapse_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_dist_schedule_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_schedule_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_simd_collapse_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_simd_dist_schedule_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_simd_schedule_codegen.cpp
  clang/test/OpenMP/teams_distribute_simd_codegen.cpp
  clang/test/OpenMP/teams_distribute_simd_collapse_codegen.cpp
  clang/test/OpenMP/teams_distribute_simd_dist_schedule_codegen.cpp
  clang/test/OpenMP/teams_firstprivate_codegen.cpp

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


[PATCH] D108377: [asan] Implemented flag to emit intrinsics to optimize ASan callbacks.

2021-08-24 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

In D108377#2962445 , @kstoimenov 
wrote:

> Tests are still WIP. This is not ready for review yet. I will ping you when 
> it it.

There is also "Add Acction..."-> "Plan changes", which will remove it from 
reviewers dashboards.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108377

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


[PATCH] D107850: [asan] Implemented intrinsic for the custom calling convention similar used by HWASan for X86.

2021-08-24 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka accepted this revision.
vitalybuka added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107850

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


[PATCH] D108592: [WIP][clang][Fuchsia] Support __attribute__((availability)) on Fuchsia

2021-08-24 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 368423.
leonardchan edited the summary of this revision.
Herald added subscribers: dexonsmith, dang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108592

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/OSTargets.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Frontend/attr-availability-fuchsia.c
  clang/test/Sema/attr-availability-fuchsia.c

Index: clang/test/Sema/attr-availability-fuchsia.c
===
--- /dev/null
+++ clang/test/Sema/attr-availability-fuchsia.c
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 "-triple" "x86_64-unknown-fuchsia" -mfuchsia-version=16 -fsyntax-only -verify %s
+// RUN: %clang_cc1 "-triple" "x86_64-unknown-fuchsia" -fsyntax-only %s |& \
+// RUN:   FileCheck %s
+
+// If the version is not specified, we should not get any errors since there
+// is no checking (the major version number is zero).
+// CHECK-NOT: error:
+
+void f0(int) __attribute__((availability(fuchsia, introduced = 14, deprecated = 19)));
+void f1(int) __attribute__((availability(fuchsia, introduced = 16)));
+void f2(int) __attribute__((availability(fuchsia, introduced = 14, deprecated = 16))); // expected-note {{'f2' has been explicitly marked deprecated here}}
+void f3(int) __attribute__((availability(fuchsia, introduced = 19)));
+void f4(int) __attribute__((availability(fuchsia, introduced = 9, deprecated = 11, obsoleted = 16), availability(ios, introduced = 2.0, deprecated = 3.0))); // expected-note{{explicitly marked unavailable}}
+void f5(int) __attribute__((availability(ios, introduced = 3.2), availability(fuchsia, unavailable)));   // expected-note{{'f5' has been explicitly marked unavailable here}}
+void f6(int) __attribute__((availability(fuchsia, introduced = 16.0)));  // expected-warning {{Fuchsia versions only support 'major', not '.minor[.subminor]}}
+void f7(int) __attribute__((availability(fuchsia, introduced = 16.1))); // expected-warning {{Fuchsia versions only support 'major', not '.minor[.subminor]}}
+
+void test() {
+  f0(0);
+  f1(0);
+  f2(0); // expected-warning{{'f2' is deprecated: first deprecated in Fuchsia 16}}
+  f3(0);
+  f4(0); // expected-error{{f4' is unavailable: obsoleted in Fuchsia 16}}
+  f5(0); // expected-error{{'f5' is unavailable: not available on Fuchsia}}
+}
Index: clang/test/Frontend/attr-availability-fuchsia.c
===
--- /dev/null
+++ clang/test/Frontend/attr-availability-fuchsia.c
@@ -0,0 +1,10 @@
+// Test that `-mfuchsia-version` is propagated to cc1.
+// RUN: %clang -target x86_64-unknown-fuchsia -mfuchsia-version=16 -c %s -### |& FileCheck %s
+//
+// It should also be exposed to non-fuchsia platforms. This is desireable when
+// using common Fuchsia headers for building host libraries that also depend on
+// the Fuchsia version (such as using a compatible host-side FIDL library that
+// talks with a Fuchsia FIDL library of the same version).
+// RUN: %clang -target x86_64-unknown-linux-gnu -mfuchsia-version=16 -c %s -### |& FileCheck %s
+//
+// CHECK: "-mfuchsia-version=16"
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -2488,6 +2488,15 @@
 }
   }
 
+  if (II->isStr("fuchsia")) {
+Optional Min, Sub;
+if ((Min = Introduced.Version.getMinor()) ||
+(Sub = Introduced.Version.getSubminor())) {
+  S.Diag(AL.getLoc(), diag::warn_availability_fuchsia_unavailable_minor);
+  return;
+}
+  }
+
   int PriorityModifier = AL.isPragmaClangAttribute()
  ? Sema::AP_PragmaClangAttribute
  : Sema::AP_Explicit;
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5462,6 +5462,9 @@
   Args.AddLastArg(CmdArgs, options::OPT_fexperimental_relative_cxx_abi_vtables,
   options::OPT_fno_experimental_relative_cxx_abi_vtables);
 
+  if (Arg *A = Args.getLastArg(options::OPT_mfuchsia_version_EQ))
+A->render(Args, CmdArgs);
+
   // Handle -{std, ansi, trigraphs} -- take the last of -{std, ansi}
   // (-ansi is equivalent to -std=c89 or -std=c++98).
   //
Index: clang/lib/Basic/Targets/OSTargets.h
===
--- clang/lib/Basic/Targets/OSTargets.h
+++ clang/lib/Basic/Targets/OSTargets.h
@@ -885,6 

[PATCH] D108643: Introduce _BitInt, deprecate _ExtInt

2021-08-24 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

LGTM, pending some level of Itanium ABI blessing.


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

https://reviews.llvm.org/D108643

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


[PATCH] D42225: libcxx: Provide overloads for basic_filebuf::open() et al that take wchar_t* filenames on Windows.

2021-08-24 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc added subscribers: thomasanderson, thakis.
pcc added a comment.

I believe that Chromium uses it (or at least it did at the time that I added 
this, and Chromium has since switched to using libc++ on Windows).

I don't work on Chromium much anymore but perhaps @thakis or @thomasanderson 
can confirm.


Repository:
  rCXX libc++

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

https://reviews.llvm.org/D42225

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


[PATCH] D108643: Introduce _BitInt, deprecate _ExtInt

2021-08-24 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/docs/ReleaseNotes.rst:145
 
+- The mangling of the ``_ExtInt(N)`` datatype has changed in both the Microsoft
+  ABI and Itanium ABI.

erichkeane wrote:
> Hrm... not a huge fan that this still claims that ``_ExtInt`` is a 
> type(though don't have a better wording), but I'd also probably want to 
> mention that it now matches the new type.  Perhaps something like:
> 
> The ``_ExtInt(N)`` family of types have been replaced with the C2X 
> standardized version of the feature, ``_BitInt(N)``.  Therefore, source that 
> previously used the ``_ExtInt`` types will now be mangled to instead use the 
> ``_BitInt(N)`` spelling in both the Microsoft and Itanium ABIs.
I can go with this.



Comment at: clang/include/clang/Basic/TargetInfo.h:581
   /// limitation is put into place for ABI reasons.
-  virtual bool hasExtIntType() const {
+  /// FIXME: _BitInt is a required type in C23, so there's not much utility in
+  /// asking whether the target supported it or not; I think this should be

erichkeane wrote:
> erichkeane wrote:
> > Concur on the fixme.  I would expect after this lands that an llvm-dev 
> > discussion happen to do this alert, and have us remove this pretty quickly 
> > (a release or two?)
> To clarify: This should be removed at the beginning of a release-cycle (along 
> with an llvm-dev notice) so that we have as much time as possible in trunk to 
> react/find issues.
We're basically at the beginning of Clang 14 (13 isn't out the door yet), so I 
am sort of tempted to alert llvm-dev now and remove it as part of this review. 
However, if people think that's too harsh, I'm happy to wait as well.


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

https://reviews.llvm.org/D108643

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


[PATCH] D108648: [Clang][OpenMP] Use enum to dereference children data array in OMPAtomicDirective

2021-08-24 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108648

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


[PATCH] D108648: [Clang][OpenMP] Use enum to dereference children data array in OMPAtomicDirective

2021-08-24 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 created this revision.
tianshilei1992 added reviewers: ABataev, jdoerfert.
Herald added subscribers: guansong, yaxunl.
tianshilei1992 requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108648

Files:
  clang/include/clang/AST/StmtOpenMP.h


Index: clang/include/clang/AST/StmtOpenMP.h
===
--- clang/include/clang/AST/StmtOpenMP.h
+++ clang/include/clang/AST/StmtOpenMP.h
@@ -2794,16 +2794,25 @@
   : OMPExecutableDirective(OMPAtomicDirectiveClass, llvm::omp::OMPD_atomic,
SourceLocation(), SourceLocation()) {}
 
+  enum DataPositionTy : size_t {
+POS_X = 0,
+POS_V,
+POS_E,
+POS_UpdateExpr,
+  };
+
   /// Set 'x' part of the associated expression/statement.
-  void setX(Expr *X) { Data->getChildren()[0] = X; }
+  void setX(Expr *X) { Data->getChildren()[DataPositionTy::POS_X] = X; }
   /// Set helper expression of the form
   /// 'OpaqueValueExpr(x) binop OpaqueValueExpr(expr)' or
   /// 'OpaqueValueExpr(expr) binop OpaqueValueExpr(x)'.
-  void setUpdateExpr(Expr *UE) { Data->getChildren()[1] = UE; }
+  void setUpdateExpr(Expr *UE) {
+Data->getChildren()[DataPositionTy::POS_UpdateExpr] = UE;
+  }
   /// Set 'v' part of the associated expression/statement.
-  void setV(Expr *V) { Data->getChildren()[2] = V; }
+  void setV(Expr *V) { Data->getChildren()[DataPositionTy::POS_V] = V; }
   /// Set 'expr' part of the associated expression/statement.
-  void setExpr(Expr *E) { Data->getChildren()[3] = E; }
+  void setExpr(Expr *E) { Data->getChildren()[DataPositionTy::POS_E] = E; }
 
 public:
   /// Creates directive with a list of \a Clauses and 'x', 'v' and 'expr'
@@ -2840,16 +2849,22 @@
  unsigned NumClauses, EmptyShell);
 
   /// Get 'x' part of the associated expression/statement.
-  Expr *getX() { return cast_or_null(Data->getChildren()[0]); }
+  Expr *getX() {
+return cast_or_null(Data->getChildren()[DataPositionTy::POS_X]);
+  }
   const Expr *getX() const {
-return cast_or_null(Data->getChildren()[0]);
+return cast_or_null(Data->getChildren()[DataPositionTy::POS_X]);
   }
   /// Get helper expression of the form
   /// 'OpaqueValueExpr(x) binop OpaqueValueExpr(expr)' or
   /// 'OpaqueValueExpr(expr) binop OpaqueValueExpr(x)'.
-  Expr *getUpdateExpr() { return cast_or_null(Data->getChildren()[1]); }
+  Expr *getUpdateExpr() {
+return cast_or_null(
+Data->getChildren()[DataPositionTy::POS_UpdateExpr]);
+  }
   const Expr *getUpdateExpr() const {
-return cast_or_null(Data->getChildren()[1]);
+return cast_or_null(
+Data->getChildren()[DataPositionTy::POS_UpdateExpr]);
   }
   /// Return true if helper update expression has form
   /// 'OpaqueValueExpr(x) binop OpaqueValueExpr(expr)' and false if it has form
@@ -2859,14 +2874,18 @@
   /// 'x', false if 'v' must be updated to the new value of 'x'.
   bool isPostfixUpdate() const { return IsPostfixUpdate; }
   /// Get 'v' part of the associated expression/statement.
-  Expr *getV() { return cast_or_null(Data->getChildren()[2]); }
+  Expr *getV() {
+return cast_or_null(Data->getChildren()[DataPositionTy::POS_V]);
+  }
   const Expr *getV() const {
-return cast_or_null(Data->getChildren()[2]);
+return cast_or_null(Data->getChildren()[DataPositionTy::POS_V]);
   }
   /// Get 'expr' part of the associated expression/statement.
-  Expr *getExpr() { return cast_or_null(Data->getChildren()[3]); }
+  Expr *getExpr() {
+return cast_or_null(Data->getChildren()[DataPositionTy::POS_E]);
+  }
   const Expr *getExpr() const {
-return cast_or_null(Data->getChildren()[3]);
+return cast_or_null(Data->getChildren()[DataPositionTy::POS_E]);
   }
 
   static bool classof(const Stmt *T) {


Index: clang/include/clang/AST/StmtOpenMP.h
===
--- clang/include/clang/AST/StmtOpenMP.h
+++ clang/include/clang/AST/StmtOpenMP.h
@@ -2794,16 +2794,25 @@
   : OMPExecutableDirective(OMPAtomicDirectiveClass, llvm::omp::OMPD_atomic,
SourceLocation(), SourceLocation()) {}
 
+  enum DataPositionTy : size_t {
+POS_X = 0,
+POS_V,
+POS_E,
+POS_UpdateExpr,
+  };
+
   /// Set 'x' part of the associated expression/statement.
-  void setX(Expr *X) { Data->getChildren()[0] = X; }
+  void setX(Expr *X) { Data->getChildren()[DataPositionTy::POS_X] = X; }
   /// Set helper expression of the form
   /// 'OpaqueValueExpr(x) binop OpaqueValueExpr(expr)' or
   /// 'OpaqueValueExpr(expr) binop OpaqueValueExpr(x)'.
-  void setUpdateExpr(Expr *UE) { Data->getChildren()[1] = UE; }
+  void setUpdateExpr(Expr *UE) {
+Data->getChildren()[DataPositionTy::POS_UpdateExpr] = UE;
+  }
   /// Set 'v' part of the associated expression/statement.
-  void 

[PATCH] D108643: Introduce _BitInt, deprecate _ExtInt

2021-08-24 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Please feel free to wordsmith my ABI change comment.  I don't feel strongly 
other than trying to make it clear that `_ExtInt` is no longer a type/types.  A 
question for other reviewers: Do we feel strongly enough to try to keep the old 
mangling around via the `clang-abi-version` flag?  I'm not motivated, as 
`__ExtInt` was generally experimental, but I want to make sure noone feels 
strongly.




Comment at: clang/docs/ReleaseNotes.rst:145
 
+- The mangling of the ``_ExtInt(N)`` datatype has changed in both the Microsoft
+  ABI and Itanium ABI.

Hrm... not a huge fan that this still claims that ``_ExtInt`` is a type(though 
don't have a better wording), but I'd also probably want to mention that it now 
matches the new type.  Perhaps something like:

The ``_ExtInt(N)`` family of types have been replaced with the C2X 
standardized version of the feature, ``_BitInt(N)``.  Therefore, source that 
previously used the ``_ExtInt`` types will now be mangled to instead use the 
``_BitInt(N)`` spelling in both the Microsoft and Itanium ABIs.



Comment at: clang/include/clang/Basic/TargetInfo.h:581
   /// limitation is put into place for ABI reasons.
-  virtual bool hasExtIntType() const {
+  /// FIXME: _BitInt is a required type in C23, so there's not much utility in
+  /// asking whether the target supported it or not; I think this should be

erichkeane wrote:
> Concur on the fixme.  I would expect after this lands that an llvm-dev 
> discussion happen to do this alert, and have us remove this pretty quickly (a 
> release or two?)
To clarify: This should be removed at the beginning of a release-cycle (along 
with an llvm-dev notice) so that we have as much time as possible in trunk to 
react/find issues.


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

https://reviews.llvm.org/D108643

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


[PATCH] D99350: [OPENMP]Fix PR49649: The introduction of $ref globals is not always valid.

2021-08-24 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 368405.
ABataev added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99350

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/declare_target_codegen.cpp
  openmp/libomptarget/test/offloading/ref_to_shared.cpp


Index: openmp/libomptarget/test/offloading/ref_to_shared.cpp
===
--- /dev/null
+++ openmp/libomptarget/test/offloading/ref_to_shared.cpp
@@ -0,0 +1,17 @@
+// RUN: %libomptarget-compilexx-run-and-check-nvptx64-nvidia-cuda
+// REQUIRES: nvptx64-nvidia-cuda
+
+#include 
+#include 
+#pragma omp declare target
+
+static int X;
+#pragma omp allocate(X) allocator(omp_pteam_mem_alloc)
+
+int main() {
+  // CHECK: PASS
+  std::cout << "PASS\n";
+  return 0;
+}
+
+#pragma omp end declare target
Index: clang/test/OpenMP/declare_target_codegen.cpp
===
--- clang/test/OpenMP/declare_target_codegen.cpp
+++ clang/test/OpenMP/declare_target_codegen.cpp
@@ -43,10 +43,10 @@
 // CHECK-DAG: @c = external global i32,
 // CHECK-DAG: @globals ={{ hidden | }}global %struct.S zeroinitializer,
 // CHECK-DAG: [[STAT:@.+stat]] = internal global %struct.S zeroinitializer,
-// CHECK-DAG: [[STAT_REF:@.+]] = internal constant %struct.S* [[STAT]]
+// CHECK-DAG: [[STAT_REF:@.+]] = internal constant i8* bitcast (%struct.S* 
[[STAT]] to i8*)
 // CHECK-DAG: @out_decl_target ={{ hidden | }}global i32 0,
 // CHECK-DAG: @llvm.used = appending global [2 x i8*] [i8* bitcast (void ()* 
@__omp_offloading__{{.+}}_globals_l[[@LINE+84]]_ctor to i8*), i8* bitcast (void 
()* @__omp_offloading__{{.+}}_stat_l[[@LINE+85]]_ctor to i8*)],
-// CHECK-DAG: @llvm.compiler.used = appending global [1 x i8*] [i8* bitcast 
(%struct.S** [[STAT_REF]] to i8*)],
+// CHECK-DAG: @llvm.compiler.used = appending global [1 x i8*] [i8* bitcast 
(i8** [[STAT_REF]] to i8*)],
 
 // CHECK-DAG: define {{.*}}i32 @{{.*}}{{foo|bar|baz2|baz3|FA|f_method}}{{.*}}()
 // CHECK-DAG: define {{.*}}void 
@{{.*}}TemplateClass{{.*}}(%class.TemplateClass* {{[^,]*}} %{{.*}})
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -10827,11 +10827,13 @@
   std::string RefName = getName({VarName, "ref"});
   if (!CGM.GetGlobalValue(RefName)) {
 llvm::Constant *AddrRef =
-getOrCreateInternalVariable(Addr->getType(), RefName);
+getOrCreateInternalVariable(CGM.VoidPtrTy, RefName);
 auto *GVAddrRef = cast(AddrRef);
 GVAddrRef->setConstant(/*Val=*/true);
 GVAddrRef->setLinkage(llvm::GlobalValue::InternalLinkage);
-GVAddrRef->setInitializer(Addr);
+GVAddrRef->setInitializer(
+llvm::ConstantExpr::getPointerBitCastOrAddrSpaceCast(
+Addr, CGM.VoidPtrTy));
 CGM.addCompilerUsedGlobal(GVAddrRef);
   }
 }


Index: openmp/libomptarget/test/offloading/ref_to_shared.cpp
===
--- /dev/null
+++ openmp/libomptarget/test/offloading/ref_to_shared.cpp
@@ -0,0 +1,17 @@
+// RUN: %libomptarget-compilexx-run-and-check-nvptx64-nvidia-cuda
+// REQUIRES: nvptx64-nvidia-cuda
+
+#include 
+#include 
+#pragma omp declare target
+
+static int X;
+#pragma omp allocate(X) allocator(omp_pteam_mem_alloc)
+
+int main() {
+  // CHECK: PASS
+  std::cout << "PASS\n";
+  return 0;
+}
+
+#pragma omp end declare target
Index: clang/test/OpenMP/declare_target_codegen.cpp
===
--- clang/test/OpenMP/declare_target_codegen.cpp
+++ clang/test/OpenMP/declare_target_codegen.cpp
@@ -43,10 +43,10 @@
 // CHECK-DAG: @c = external global i32,
 // CHECK-DAG: @globals ={{ hidden | }}global %struct.S zeroinitializer,
 // CHECK-DAG: [[STAT:@.+stat]] = internal global %struct.S zeroinitializer,
-// CHECK-DAG: [[STAT_REF:@.+]] = internal constant %struct.S* [[STAT]]
+// CHECK-DAG: [[STAT_REF:@.+]] = internal constant i8* bitcast (%struct.S* [[STAT]] to i8*)
 // CHECK-DAG: @out_decl_target ={{ hidden | }}global i32 0,
 // CHECK-DAG: @llvm.used = appending global [2 x i8*] [i8* bitcast (void ()* @__omp_offloading__{{.+}}_globals_l[[@LINE+84]]_ctor to i8*), i8* bitcast (void ()* @__omp_offloading__{{.+}}_stat_l[[@LINE+85]]_ctor to i8*)],
-// CHECK-DAG: @llvm.compiler.used = appending global [1 x i8*] [i8* bitcast (%struct.S** [[STAT_REF]] to i8*)],
+// CHECK-DAG: @llvm.compiler.used = appending global [1 x i8*] [i8* bitcast (i8** [[STAT_REF]] to i8*)],
 
 // CHECK-DAG: define {{.*}}i32 @{{.*}}{{foo|bar|baz2|baz3|FA|f_method}}{{.*}}()
 // CHECK-DAG: define {{.*}}void @{{.*}}TemplateClass{{.*}}(%class.TemplateClass* {{[^,]*}} %{{.*}})
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp

[PATCH] D108643: Introduce _BitInt, deprecate _ExtInt

2021-08-24 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticParseKinds.td:1489
+  InGroup>;
+def warn_prec2x_compat_bit_int : Warning<
+  "'_BitInt' is incompatible with C standards before C2x">,

erichkeane wrote:
> should this be warn_cpre2x here, just to be more consistent with the 'group'?
It turns out that other diagnostics don't put `pre` in the identifier. Going 
with `warn_c17_compat_bit_int` to be consistent with 
`warn_c17_compat_static_assert_no_message` which is in the same group.



Comment at: clang/lib/AST/Type.cpp:2021
+return IT->isSigned();
+  if (const auto *IT = dyn_cast(CanonicalType))
 return IT->isSigned();

erichkeane wrote:
> Note to others: Aaron and I discussed this offline.  I don't think it is 
> NECESSARY (as I don't think we really call these functions on dependent 
> types), but I thought it was a good idea to be here for completeness.
+1 -- I could not find a new test case to write for this, but it seemed like an 
"obvious" oversight because the dependency doesn't matter for determining 
whether the type is signed or not.



Comment at: clang/lib/Parse/ParseDecl.cpp:3873
  DiagID, Policy);
-  break;
-case tok::kw__ExtInt: {
+  break;
+case tok::kw__ExtInt:

erichkeane wrote:
> Is this extra trailing WS?
*gasps* the nerve of some patch authors, right? ;-)


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

https://reviews.llvm.org/D108643

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


[PATCH] D108544: [clang][deps] Avoid generating arguments for missing module map files

2021-08-24 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 planned changes to this revision.
jansvoboda11 added a comment.

I created D108647  to more directly address 
the issues I'm seeing at the moment in explicit builds.

I think dealing with the possibility of empty `PresumedModuleMapFile` is still 
valuable, but I'm not aware how to test this at the moment (create module from 
non-preprocessed sources).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108544

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


[PATCH] D108584: [clangd] Use the active file's language for hover code blocks

2021-08-24 Thread David Goldman via Phabricator via cfe-commits
dgoldman updated this revision to Diff 368395.
dgoldman added a comment.

Simplify setting the definition language


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108584

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -939,6 +939,42 @@
   }
 }
 
+TEST(Hover, DefinitionLanuage) {
+  struct {
+const char *const Code;
+const std::string ClangLanguageFlag;
+const char *const ExpectedDefinitionLanguage;
+  } Cases[] = {{R"cpp(
+  void [[some^Global]]() {}
+  )cpp",
+"", "cpp"},
+   {R"cpp(
+  void [[some^Global]]() {}
+  )cpp",
+"-xobjective-c++", "objective-cpp"},
+   {R"cpp(
+  void [[some^Global]]() {}
+  )cpp",
+"-xobjective-c", "objective-c"}};
+  for (const auto  : Cases) {
+SCOPED_TRACE(Case.Code);
+
+Annotations T(Case.Code);
+TestTU TU = TestTU::withCode(T.code());
+if (!Case.ClangLanguageFlag.empty())
+  TU.ExtraArgs.push_back(Case.ClangLanguageFlag);
+// Types might be different depending on the target triplet, we chose a
+// fixed one to make sure tests passes on different platform.
+TU.ExtraArgs.push_back("--target=x86_64-pc-linux-gnu");
+auto AST = TU.build();
+
+auto H = getHover(AST, T.point(), format::getLLVMStyle(), nullptr);
+ASSERT_TRUE(H);
+
+EXPECT_STREQ(H->DefinitionLanguage, Case.ExpectedDefinitionLanguage);
+  }
+}
+
 TEST(Hover, CallPassType) {
   const llvm::StringRef CodePrefix = R"cpp(
 class Base {};
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -131,6 +131,13 @@
   return Definition;
 }
 
+const char *getMarkdownLanguage(const ASTContext ) {
+  const auto  = Ctx.getLangOpts();
+  if (LangOpts.ObjC && LangOpts.CPlusPlus)
+return "objective-cpp";
+  return LangOpts.ObjC ? "objective-c" : "cpp";
+}
+
 std::string printType(QualType QT, const PrintingPolicy ) {
   // TypePrinter doesn't resolve decltypes, so resolve them here.
   // FIXME: This doesn't handle composite types that contain a decltype in 
them.
@@ -1007,6 +1014,7 @@
   if (auto Formatted =
   tooling::applyAllReplacements(HI->Definition, Replacements))
 HI->Definition = *Formatted;
+  HI->DefinitionLanguage = getMarkdownLanguage(AST.getASTContext());
   HI->SymRange = halfOpenToRange(SM, HighlightRange);
 
   return HI;


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -939,6 +939,42 @@
   }
 }
 
+TEST(Hover, DefinitionLanuage) {
+  struct {
+const char *const Code;
+const std::string ClangLanguageFlag;
+const char *const ExpectedDefinitionLanguage;
+  } Cases[] = {{R"cpp(
+  void [[some^Global]]() {}
+  )cpp",
+"", "cpp"},
+   {R"cpp(
+  void [[some^Global]]() {}
+  )cpp",
+"-xobjective-c++", "objective-cpp"},
+   {R"cpp(
+  void [[some^Global]]() {}
+  )cpp",
+"-xobjective-c", "objective-c"}};
+  for (const auto  : Cases) {
+SCOPED_TRACE(Case.Code);
+
+Annotations T(Case.Code);
+TestTU TU = TestTU::withCode(T.code());
+if (!Case.ClangLanguageFlag.empty())
+  TU.ExtraArgs.push_back(Case.ClangLanguageFlag);
+// Types might be different depending on the target triplet, we chose a
+// fixed one to make sure tests passes on different platform.
+TU.ExtraArgs.push_back("--target=x86_64-pc-linux-gnu");
+auto AST = TU.build();
+
+auto H = getHover(AST, T.point(), format::getLLVMStyle(), nullptr);
+ASSERT_TRUE(H);
+
+EXPECT_STREQ(H->DefinitionLanguage, Case.ExpectedDefinitionLanguage);
+  }
+}
+
 TEST(Hover, CallPassType) {
   const llvm::StringRef CodePrefix = R"cpp(
 class Base {};
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -131,6 +131,13 @@
   return Definition;
 }
 
+const char *getMarkdownLanguage(const ASTContext ) {
+  const auto  = Ctx.getLangOpts();
+  if (LangOpts.ObjC && LangOpts.CPlusPlus)
+return "objective-cpp";
+  return LangOpts.ObjC ? "objective-c" : "cpp";
+}
+
 std::string printType(QualType QT, const PrintingPolicy ) {
   // TypePrinter doesn't resolve decltypes, so resolve them here.
   // FIXME: 

[PATCH] D108647: [clang][deps] Use top-level modules as precompiled dependencies

2021-08-24 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added reviewers: Bigcheese, dexonsmith, arphaman.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The `ASTReader` populates `Module::PresumedModuleMapFile` only for top-level 
modules, not submodules. To avoid generating empty `-fmodule-map-file=` 
arguments, make discovered modules depend on top-level precompiled modules. The 
granularity of submodules is not important here.

The documentation of `Module::PresumedModuleMapFile` says this field is 
non-empty only when building from preprocessed source. This means there can 
still be cases where the dependency scanner generates empty 
`-fmodule-map-file=` arguments. That's being addressed in separate patch: 
D108544 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108647

Files:
  clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
  clang/test/ClangScanDeps/Inputs/modules-pch-common-submodule/cdb_pch.json
  clang/test/ClangScanDeps/Inputs/modules-pch-common-submodule/cdb_tu.json
  clang/test/ClangScanDeps/Inputs/modules-pch-common-submodule/mod_common.h
  clang/test/ClangScanDeps/Inputs/modules-pch-common-submodule/mod_common_sub.h
  clang/test/ClangScanDeps/Inputs/modules-pch-common-submodule/mod_tu.h
  clang/test/ClangScanDeps/Inputs/modules-pch-common-submodule/module.modulemap
  clang/test/ClangScanDeps/Inputs/modules-pch-common-submodule/pch.h
  clang/test/ClangScanDeps/Inputs/modules-pch-common-submodule/tu.c
  clang/test/ClangScanDeps/modules-pch-common-submodule.c

Index: clang/test/ClangScanDeps/modules-pch-common-submodule.c
===
--- /dev/null
+++ clang/test/ClangScanDeps/modules-pch-common-submodule.c
@@ -0,0 +1,134 @@
+// RUN: rm -rf %t && mkdir %t
+// RUN: cp %S/Inputs/modules-pch-common-submodule/* %t
+
+// Scan dependencies of the PCH:
+//
+// RUN: sed "s|DIR|%/t|g" %S/Inputs/modules-pch-common-submodule/cdb_pch.json > %t/cdb.json
+// RUN: echo -%t > %t/result_pch.json
+// RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full \
+// RUN:   -generate-modules-path-args -module-files-dir %t/build >> %t/result_pch.json
+// RUN: cat %t/result_pch.json | sed 's:\?:/:g' | FileCheck %s -check-prefix=CHECK-PCH
+//
+// CHECK-PCH:  -[[PREFIX:.*]]
+// CHECK-PCH-NEXT: {
+// CHECK-PCH-NEXT:   "modules": [
+// CHECK-PCH-NEXT: {
+// CHECK-PCH-NEXT:   "clang-module-deps": [],
+// CHECK-PCH-NEXT:   "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
+// CHECK-PCH-NEXT:   "command-line": [
+// CHECK-PCH-NEXT: "-cc1"
+// CHECK-PCH:  "-emit-module"
+// CHECK-PCH:  "-fmodules"
+// CHECK-PCH:  "-fmodule-name=ModCommon"
+// CHECK-PCH:  "-fno-implicit-modules"
+// CHECK-PCH:],
+// CHECK-PCH-NEXT:   "context-hash": "[[HASH_MOD_COMMON:.*]]",
+// CHECK-PCH-NEXT:   "file-deps": [
+// CHECK-PCH-NEXT: "[[PREFIX]]/mod_common.h",
+// CHECK-PCH-NEXT: "[[PREFIX]]/mod_common_sub.h",
+// CHECK-PCH-NEXT: "[[PREFIX]]/module.modulemap"
+// CHECK-PCH-NEXT:   ],
+// CHECK-PCH-NEXT:   "name": "ModCommon"
+// CHECK-PCH-NEXT: }
+// CHECK-PCH-NEXT:   ],
+// CHECK-PCH-NEXT:   "translation-units": [
+// CHECK-PCH-NEXT: {
+// CHECK-PCH-NEXT:   "clang-context-hash": "[[HASH_PCH:.*]]",
+// CHECK-PCH-NEXT:   "clang-module-deps": [
+// CHECK-PCH-NEXT: {
+// CHECK-PCH-NEXT:   "context-hash": "[[HASH_MOD_COMMON]]",
+// CHECK-PCH-NEXT:   "module-name": "ModCommon"
+// CHECK-PCH-NEXT: }
+// CHECK-PCH-NEXT:   ],
+// CHECK-PCH-NEXT:   "command-line": [
+// CHECK-PCH-NEXT: "-fno-implicit-modules"
+// CHECK-PCH-NEXT: "-fno-implicit-module-maps"
+// CHECK-PCH-NEXT: "-fmodule-file=[[PREFIX]]/build/[[HASH_MOD_COMMON]]/ModCommon-{{.*}}.pcm"
+// CHECK-PCH-NEXT: "-fmodule-map-file=[[PREFIX]]/module.modulemap"
+// CHECK-PCH-NEXT:   ],
+// CHECK-PCH-NEXT:   "file-deps": [
+// CHECK-PCH-NEXT: "[[PREFIX]]/pch.h"
+// CHECK-PCH-NEXT:   ],
+// CHECK-PCH-NEXT:   "input-file": "[[PREFIX]]/pch.h"
+// CHECK-PCH-NEXT: }
+// CHECK-PCH-NEXT:   ]
+// CHECK-PCH-NEXT: }
+
+// Explicitly build the PCH:
+//
+// RUN: tail -n +2 %t/result_pch.json > %t/result_pch_stripped.json
+// RUN: %python %S/../../utils/module-deps-to-rsp.py %t/result_pch_stripped.json \
+// RUN:   --module-name=ModCommon > %t/mod_common.cc1.rsp
+// RUN: %python %S/../../utils/module-deps-to-rsp.py %t/result_pch_stripped.json \
+// RUN:   --tu-index=0 > %t/pch.rsp
+//
+// RUN: %clang @%t/mod_common.cc1.rsp
+// RUN: %clang -x c-header %t/pch.h -fmodules -gmodules -fimplicit-module-maps \
+// RUN:   -fmodules-cache-path=%t/cache -o %t/pch.h.gch @%t/pch.rsp
+
+// Scan dependencies of the TU:
+//
+// RUN: sed "s|DIR|%/t|g" 

[PATCH] D99436: [OPENMP]Fix PR49366: crash on VLAs in task untied regions.

2021-08-24 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 368393.
ABataev added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99436

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/OpenMP/task_messages.cpp
  clang/test/OpenMP/taskloop_loop_messages.cpp

Index: clang/test/OpenMP/taskloop_loop_messages.cpp
===
--- clang/test/OpenMP/taskloop_loop_messages.cpp
+++ clang/test/OpenMP/taskloop_loop_messages.cpp
@@ -691,7 +691,7 @@
 
 void test_loop_eh() {
   const int N = 100;
-  float a[N], b[N], c[N];
+  float a[N], b[N], c[N]; // expected-note {{declared here}}
 #pragma omp parallel
 #pragma omp taskloop
   for (int i = 0; i < 10; i++) {
@@ -729,6 +729,13 @@
   void g() { throw 0; }
 };
   }
+// expected-error@+5 {{variable length arrays are not supported in OpenMP tasking regions with 'untied' clause}}
+// expected-note@+4 {{read of non-constexpr variable 'c' is not allowed in a constant expression}}
+#pragma omp taskloop untied
+  {
+  for (int i = 0; i < 10; ++i)
+int array[(int)c[0]];
+  }
 }
 
 void test_loop_firstprivate_lastprivate() {
Index: clang/test/OpenMP/task_messages.cpp
===
--- clang/test/OpenMP/task_messages.cpp
+++ clang/test/OpenMP/task_messages.cpp
@@ -173,7 +173,7 @@
   int  = a;
   S sa;
   S  = sa;
-  int r;
+  int r; // expected-note {{declared here}}
 #pragma omp task { // expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}}
   foo();
 #pragma omp task( // expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}}
@@ -330,6 +330,12 @@
 // expected-error@+1 {{directive '#pragma omp task' cannot contain more than one 'mergeable' clause}}
 #pragma omp task mergeable mergeable
   ++r;
+// expected-error@+4 {{variable length arrays are not supported in OpenMP tasking regions with 'untied' clause}}
+// expected-note@+3 {{read of non-const variable 'r' is not allowed in a constant expression}}
+#pragma omp task untied
+  {
+int array[r];
+  }
   volatile omp_event_handle_t evt;
   omp_event_handle_t sevt;
   const omp_event_handle_t cevt = evt;
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -2452,6 +2452,9 @@
   } else if (isSFINAEContext()) {
 VLADiag = diag::err_vla_in_sfinae;
 VLAIsError = true;
+  } else if (getLangOpts().OpenMP && isInOpenMPTaskUntiedContext()) {
+VLADiag = diag::err_openmp_vla_in_task_untied;
+VLAIsError = true;
   } else {
 VLADiag = diag::ext_vla;
 VLAIsError = false;
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -174,6 +174,7 @@
 bool HasMutipleLoops = false;
 const Decl *PossiblyLoopCounter = nullptr;
 bool NowaitRegion = false;
+bool UntiedRegion = false;
 bool CancelRegion = false;
 bool LoopStart = false;
 bool BodyComplete = false;
@@ -841,6 +842,15 @@
   return Parent->NowaitRegion;
 return false;
   }
+  /// Marks current region as untied (it has a 'untied' clause).
+  void setUntiedRegion(bool IsUntied = true) {
+getTopOfStack().UntiedRegion = IsUntied;
+  }
+  /// Return true if current region is untied.
+  bool isUntiedRegion() const {
+const SharingMapTy *Top = getTopOfStackOrNull();
+return Top ? Top->UntiedRegion : false;
+  }
   /// Marks parent region as cancel region.
   void setParentCancelRegion(bool Cancel = true) {
 if (SharingMapTy *Parent = getSecondOnStackOrNull())
@@ -2154,6 +2164,11 @@
   return DSAStack->getNestingLevel();
 }
 
+bool Sema::isInOpenMPTaskUntiedContext() const {
+  return isOpenMPTaskingDirective(DSAStack->getCurrentDirective()) &&
+ DSAStack->isUntiedRegion();
+}
+
 bool Sema::isInOpenMPTargetExecutionDirective() const {
   return (isOpenMPTargetExecutionDirective(DSAStack->getCurrentDirective()) &&
   !DSAStack->isClauseParsingMode()) ||
@@ -15071,6 +15086,7 @@
 
 OMPClause *Sema::ActOnOpenMPUntiedClause(SourceLocation StartLoc,
  SourceLocation EndLoc) {
+  DSAStack->setUntiedRegion();
   return new (Context) OMPUntiedClause(StartLoc, EndLoc);
 }
 
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -10549,6 +10549,10 @@
   void finalizeOpenMPDelayedAnalysis(const FunctionDecl *Caller,
  const FunctionDecl *Callee,
  SourceLocation Loc);
+
+  /// Return true if 

[PATCH] D108643: Introduce _BitInt, deprecate _ExtInt

2021-08-24 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/docs/ReleaseNotes.rst:107
 
+- Clang now supports the _BitInt(N) family of bit-precise integer types from
+  C23. This type was previously exposed as _ExtInt(N), which is still supported

This section should probably mention the ABI break.  It shouldn't be a surprise 
for people upgrading.



Comment at: clang/docs/ReleaseNotes.rst:108
+- Clang now supports the _BitInt(N) family of bit-precise integer types from
+  C23. This type was previously exposed as _ExtInt(N), which is still supported
+  but is now deprecated in favor of the standard type. _BitInt(N) and

I would think it would be a better idea to not claim that `_ExtInt` is still 
supported , but perhaps just say that it is now an alias for the 'new type'.  I 
realize it is a little pedantic, but `_ExtInt` is no longer a type in our type 
system. I think this will make the diagnostics more understandable.



Comment at: clang/include/clang/Basic/DiagnosticParseKinds.td:1489
+  InGroup>;
+def warn_prec2x_compat_bit_int : Warning<
+  "'_BitInt' is incompatible with C standards before C2x">,

should this be warn_cpre2x here, just to be more consistent with the 'group'?



Comment at: clang/include/clang/Basic/TargetInfo.h:581
   /// limitation is put into place for ABI reasons.
-  virtual bool hasExtIntType() const {
+  /// FIXME: _BitInt is a required type in C23, so there's not much utility in
+  /// asking whether the target supported it or not; I think this should be

Concur on the fixme.  I would expect after this lands that an llvm-dev 
discussion happen to do this alert, and have us remove this pretty quickly (a 
release or two?)



Comment at: clang/lib/AST/Type.cpp:2021
+return IT->isSigned();
+  if (const auto *IT = dyn_cast(CanonicalType))
 return IT->isSigned();

Note to others: Aaron and I discussed this offline.  I don't think it is 
NECESSARY (as I don't think we really call these functions on dependent types), 
but I thought it was a good idea to be here for completeness.



Comment at: clang/lib/Parse/ParseDecl.cpp:3873
  DiagID, Policy);
-  break;
-case tok::kw__ExtInt: {
+  break;
+case tok::kw__ExtInt:

Is this extra trailing WS?


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

https://reviews.llvm.org/D108643

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


[PATCH] D107021: [Sema][ObjC] Allow conversions between pointers to ObjC pointers and pointers to structs

2021-08-24 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 368391.
ahatanak added a comment.

Rebase and ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107021

Files:
  clang/lib/Sema/SemaExprObjC.cpp
  clang/test/SemaObjC/arc-type-conversion.m


Index: clang/test/SemaObjC/arc-type-conversion.m
===
--- clang/test/SemaObjC/arc-type-conversion.m
+++ clang/test/SemaObjC/arc-type-conversion.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -fobjc-runtime-has-weak -verify 
-fblocks %s
+// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -fobjc-runtime-has-weak -verify 
-fblocks -Wno-incompatible-pointer-types %s
 
 typedef const void * CFTypeRef;
 CFTypeRef CFBridgingRetain(id X);
@@ -96,3 +96,14 @@
   id c = 1 ? a : b; // expected-error {{operands to conditional of types 'id' 
and 'void *' are incompatible in ARC mode}}
   id d = 1 ? b : a; // expected-error {{operands to conditional of types 'void 
*' and 'id' are incompatible in ARC mode}}
 }
+
+void conversion_pointer_to_id(__strong id *x) {
+  struct S {
+int a[2];
+  } s, *p;
+
+  x = (__strong id *)
+  x =  // expected-error {{implicit conversion of a non-Objective-C pointer 
type 'struct S *' to '__strong id *' is disallowed with ARC}}
+  p = (struct S *)x;
+  p = x; // expected-error {{implicit conversion of an indirect pointer to an 
Objective-C pointer to 'struct S *' is disallowed with ARC}}
+}
Index: clang/lib/Sema/SemaExprObjC.cpp
===
--- clang/lib/Sema/SemaExprObjC.cpp
+++ clang/lib/Sema/SemaExprObjC.cpp
@@ -4450,9 +4450,14 @@
   // Allow casts between pointers to lifetime types (e.g., __strong id*)
   // and pointers to void (e.g., cv void *). Casting from void* to lifetime*
   // must be explicit.
-  if (exprACTC == ACTC_indirectRetainable && castACTC == ACTC_voidPtr)
+  // Allow conversions between pointers to lifetime types and coreFoundation
+  // pointers too, but only when the conversions are explicit.
+  if (exprACTC == ACTC_indirectRetainable &&
+  (castACTC == ACTC_voidPtr ||
+   (castACTC == ACTC_coreFoundation && isCast(CCK
 return ACR_okay;
-  if (castACTC == ACTC_indirectRetainable && exprACTC == ACTC_voidPtr &&
+  if (castACTC == ACTC_indirectRetainable &&
+  (exprACTC == ACTC_voidPtr || exprACTC == ACTC_coreFoundation) &&
   isCast(CCK))
 return ACR_okay;
 


Index: clang/test/SemaObjC/arc-type-conversion.m
===
--- clang/test/SemaObjC/arc-type-conversion.m
+++ clang/test/SemaObjC/arc-type-conversion.m
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -fobjc-runtime-has-weak -verify -fblocks %s
+// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -fobjc-runtime-has-weak -verify -fblocks -Wno-incompatible-pointer-types %s
 
 typedef const void * CFTypeRef;
 CFTypeRef CFBridgingRetain(id X);
@@ -96,3 +96,14 @@
   id c = 1 ? a : b; // expected-error {{operands to conditional of types 'id' and 'void *' are incompatible in ARC mode}}
   id d = 1 ? b : a; // expected-error {{operands to conditional of types 'void *' and 'id' are incompatible in ARC mode}}
 }
+
+void conversion_pointer_to_id(__strong id *x) {
+  struct S {
+int a[2];
+  } s, *p;
+
+  x = (__strong id *)
+  x =  // expected-error {{implicit conversion of a non-Objective-C pointer type 'struct S *' to '__strong id *' is disallowed with ARC}}
+  p = (struct S *)x;
+  p = x; // expected-error {{implicit conversion of an indirect pointer to an Objective-C pointer to 'struct S *' is disallowed with ARC}}
+}
Index: clang/lib/Sema/SemaExprObjC.cpp
===
--- clang/lib/Sema/SemaExprObjC.cpp
+++ clang/lib/Sema/SemaExprObjC.cpp
@@ -4450,9 +4450,14 @@
   // Allow casts between pointers to lifetime types (e.g., __strong id*)
   // and pointers to void (e.g., cv void *). Casting from void* to lifetime*
   // must be explicit.
-  if (exprACTC == ACTC_indirectRetainable && castACTC == ACTC_voidPtr)
+  // Allow conversions between pointers to lifetime types and coreFoundation
+  // pointers too, but only when the conversions are explicit.
+  if (exprACTC == ACTC_indirectRetainable &&
+  (castACTC == ACTC_voidPtr ||
+   (castACTC == ACTC_coreFoundation && isCast(CCK
 return ACR_okay;
-  if (castACTC == ACTC_indirectRetainable && exprACTC == ACTC_voidPtr &&
+  if (castACTC == ACTC_indirectRetainable &&
+  (exprACTC == ACTC_voidPtr || exprACTC == ACTC_coreFoundation) &&
   isCast(CCK))
 return ACR_okay;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D108603: [clang][codegen] Set CurLinkModule in CodeGenAction::ExecuteAction

2021-08-24 Thread Rong Xu via Phabricator via cfe-commits
xur accepted this revision.
xur added a comment.
This revision is now accepted and ready to land.

Thanks for fix this!
I like this fix and the patch looks good to me.

-Rong


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108603

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


[PATCH] D108423: [NFC][clang] Move IR-independent parts of target MV support to X86TargetParser.cpp

2021-08-24 Thread Andrei Elovikov via Phabricator via cfe-commits
a.elovikov updated this revision to Diff 368390.
a.elovikov added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108423

Files:
  clang/lib/Basic/Targets/X86.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenModule.cpp
  llvm/include/llvm/Support/X86TargetParser.h
  llvm/lib/Support/X86TargetParser.cpp

Index: llvm/lib/Support/X86TargetParser.cpp
===
--- llvm/lib/Support/X86TargetParser.cpp
+++ llvm/lib/Support/X86TargetParser.cpp
@@ -11,7 +11,9 @@
 //===--===//
 
 #include "llvm/Support/X86TargetParser.h"
+#include "llvm/ADT/StringSwitch.h"
 #include "llvm/ADT/Triple.h"
+#include 
 
 using namespace llvm;
 using namespace llvm::X86;
@@ -662,3 +664,45 @@
 if (ImpliedBits[i] && !FeatureInfos[i].Name.empty())
   Features[FeatureInfos[i].Name] = Enabled;
 }
+
+uint64_t llvm::X86::getCpuSupportsMask(ArrayRef FeatureStrs) {
+  // Processor features and mapping to processor feature value.
+  uint64_t FeaturesMask = 0;
+  for (const StringRef  : FeatureStrs) {
+unsigned Feature = StringSwitch(FeatureStr)
+#define X86_FEATURE_COMPAT(ENUM, STR, PRIORITY)\
+  .Case(STR, llvm::X86::FEATURE_##ENUM)
+#include "llvm/Support/X86TargetParser.def"
+;
+FeaturesMask |= (1ULL << Feature);
+  }
+  return FeaturesMask;
+}
+
+unsigned llvm::X86::getFeaturePriority(ProcessorFeatures Feat) {
+#ifndef NDEBUG
+  // Check that priorities are set properly in the .def file. We expect that
+  // "compat" features are assigned non-duplicate consecutive priorities
+  // starting from zero (0, 1, ..., num_features - 1).
+#define X86_FEATURE_COMPAT(ENUM, STR, PRIORITY) PRIORITY,
+  unsigned Priorities[] = {
+#include "llvm/Support/X86TargetParser.def"
+  std::numeric_limits::max() // Need to consume last comma.
+  };
+  std::array HelperList;
+  std::iota(HelperList.begin(), HelperList.end(), 0);
+  assert(std::is_permutation(HelperList.begin(), HelperList.end(),
+ std::begin(Priorities),
+ std::prev(std::end(Priorities))) &&
+ "Priorities don't form consecutive range!");
+#endif
+
+  switch (Feat) {
+#define X86_FEATURE_COMPAT(ENUM, STR, PRIORITY)\
+  case X86::FEATURE_##ENUM:  \
+return PRIORITY;
+#include "llvm/Support/X86TargetParser.def"
+  default:
+llvm_unreachable("No Feature Priority for non-CPUSupports Features");
+  }
+}
Index: llvm/include/llvm/Support/X86TargetParser.h
===
--- llvm/include/llvm/Support/X86TargetParser.h
+++ llvm/include/llvm/Support/X86TargetParser.h
@@ -13,6 +13,7 @@
 #ifndef LLVM_SUPPORT_X86TARGETPARSER_H
 #define LLVM_SUPPORT_X86TARGETPARSER_H
 
+#include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringMap.h"
 
@@ -154,6 +155,9 @@
 void updateImpliedFeatures(StringRef Feature, bool Enabled,
StringMap );
 
+uint64_t getCpuSupportsMask(ArrayRef FeatureStrs);
+unsigned getFeaturePriority(ProcessorFeatures Feat);
+
 } // namespace X86
 } // namespace llvm
 
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -63,6 +63,7 @@
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/MD5.h"
 #include "llvm/Support/TimeProfiler.h"
+#include "llvm/Support/X86TargetParser.h"
 
 using namespace clang;
 using namespace CodeGen;
@@ -3396,8 +3397,8 @@
   llvm::stable_sort(
   Options, [](const CodeGenFunction::MultiVersionResolverOption ,
   const CodeGenFunction::MultiVersionResolverOption ) {
-return CodeGenFunction::GetX86CpuSupportsMask(LHS.Conditions.Features) >
-   CodeGenFunction::GetX86CpuSupportsMask(RHS.Conditions.Features);
+return llvm::X86::getCpuSupportsMask(LHS.Conditions.Features) >
+   llvm::X86::getCpuSupportsMask(RHS.Conditions.Features);
   });
 
   // If the list contains multiple 'default' versions, such as when it contains
@@ -3405,7 +3406,7 @@
   // always run on at least a 'pentium'). We do this by deleting the 'least
   // advanced' (read, lowest mangling letter).
   while (Options.size() > 1 &&
- CodeGenFunction::GetX86CpuSupportsMask(
+ llvm::X86::getCpuSupportsMask(
  (Options.end() - 2)->Conditions.Features) == 0) {
 StringRef LHSName = (Options.end() - 2)->Function->getName();
 StringRef RHSName = (Options.end() - 1)->Function->getName();
Index: clang/lib/CodeGen/CodeGenFunction.h

[PATCH] D108643: Introduce _BitInt, deprecate _ExtInt

2021-08-24 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman removed subscribers: aheejin, MaskRay, jholewinski, dschuff, 
sdardis, nemanjai, jvesely, nhaehnle, sbc100, jgravelle-google, kbarton, 
fedor.sergeev, kosarev, asb, rbar, johnrusso, simoncook, sabuasal, niosHD, 
martong, jrtc27, zzheng, edward-jones, atanasyan, rogfer01, MartinMosbeck, 
brucehoult, the_o, arphaman, jfb, PkmX, jocewei, Jim, s.egerton, 
sameer.abuasal, apazos, luismarques, kerbowa, dexonsmith, frasercrmck.
aaron.ballman added a comment.

Removing around 40 subscribers. Everyone was automatically added by Herald 
because of the mechanical renaming changes in files and so this review is 
likely spam for many of them. More importantly, having that many people 
subscribed causes mailman to moderate each patch review email. If you've been 
removed as a subscriber and this makes you sad, please re-add yourself with my 
apologies! (And hopefully Herald won't decide to add everyone back as a 
subscriber again automatically!)


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

https://reviews.llvm.org/D108643

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


[PATCH] D102449: [WIP][Clang][OpenMP] Add the support for compare clause in atomic directive

2021-08-24 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 marked an inline comment as done.
tianshilei1992 added inline comments.



Comment at: clang/lib/CodeGen/CGStmtOpenMP.cpp:5775-5802
+static void emitOMPAtomicCompareExpr(CodeGenFunction ,
+ llvm::AtomicOrdering AO, const Expr *X,
+ const Expr *E, const Expr *D,
+ const Expr *CE, bool IsXLHSInRHSPart,
+ SourceLocation Loc) {
+  assert(X->isLValue() && "X of 'omp atomic compare' is not lvalue");
+  assert(isa(CE->IgnoreImpCasts()) &&

ABataev wrote:
> I would think about moving most of the atomic codegen functionality to common 
> runtime/OMPBuilder part to be able to override implementation for different 
> targets. It may help to avoid codegen problems with Nvidia/AMD GPUs. Not 
> directly related to this patch though.
yeah, actually IIRC the `OMPIRBuilder` already supports atomic operations. Not 
sure if it supports the `compare` clause but I'll take a look. If not, I also 
think it's a better place to sit them.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102449

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


[clang] 4c418c1 - Try to fix build with modules enabled after D108422

2021-08-24 Thread Andrei Elovikov via cfe-commits

Author: Andrei Elovikov
Date: 2021-08-24T10:18:15-07:00
New Revision: 4c418c1bfbc544e24b9614efc3926fe2c6218b0c

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

LOG: Try to fix build with modules enabled after D108422

D108422 removed Basic/X86Target.def but didn't delete the entry in
module.modulemap. Do it now. Hopefully it will fix the build.

Added: 


Modified: 
clang/include/clang/module.modulemap

Removed: 




diff  --git a/clang/include/clang/module.modulemap 
b/clang/include/clang/module.modulemap
index 33fcf9dc7576..e99b8d4f5c63 100644
--- a/clang/include/clang/module.modulemap
+++ b/clang/include/clang/module.modulemap
@@ -67,7 +67,6 @@ module Clang_Basic {
   textual header "Basic/Sanitizers.def"
   textual header "Basic/TargetCXXABI.def"
   textual header "Basic/TokenKinds.def"
-  textual header "Basic/X86Target.def"
 
   module * { export * }
 }



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


[PATCH] D102449: [WIP][Clang][OpenMP] Add the support for compare clause in atomic directive

2021-08-24 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/include/clang/AST/StmtOpenMP.h:2797-2824
+  enum DataPositionTy : size_t {
+POS_X = 0,
+POS_V,
+POS_D,
+POS_E,
+POS_UpdateExpr,
+POS_CondExpr,

It is worth it to pre-commit these and related changes in a separate NFC patch



Comment at: clang/include/clang/AST/StmtOpenMP.h:2848-2850
  ArrayRef Clauses, Stmt *AssociatedStmt, Expr *X, Expr *V,
- Expr *E, Expr *UE, bool IsXLHSInRHSPart, bool IsPostfixUpdate);
+ Expr *E, Expr *D, Expr *Ex, Expr *UE, bool IsXLHSInRHSPart,
+ bool IsPostfixUpdate);

Can we pack it into a struct? At least `X`, `V` etc. params?



Comment at: clang/lib/CodeGen/CGStmtOpenMP.cpp:5775-5802
+static void emitOMPAtomicCompareExpr(CodeGenFunction ,
+ llvm::AtomicOrdering AO, const Expr *X,
+ const Expr *E, const Expr *D,
+ const Expr *CE, bool IsXLHSInRHSPart,
+ SourceLocation Loc) {
+  assert(X->isLValue() && "X of 'omp atomic compare' is not lvalue");
+  assert(isa(CE->IgnoreImpCasts()) &&

I would think about moving most of the atomic codegen functionality to common 
runtime/OMPBuilder part to be able to override implementation for different 
targets. It may help to avoid codegen problems with Nvidia/AMD GPUs. Not 
directly related to this patch though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102449

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


[clang] 1b19f90 - Revert "[AST] Pick last tentative definition as the acting definition"

2021-08-24 Thread Benson Chu via cfe-commits

Author: Benson Chu
Date: 2021-08-24T11:41:50-05:00
New Revision: 1b19f90a2390b60852c0ff5e1671c76dd82dac83

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

LOG: Revert "[AST] Pick last tentative definition as the acting definition"

This reverts commit 9a5f3888505630cea88f8372d3068b2d63cfb381.

The written test breaks some builds on Mach-O.

Added: 


Modified: 
clang/lib/AST/Decl.cpp

Removed: 
clang/test/CodeGen/attr-tentative-definition.c



diff  --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 835e28c0bc9fc..aa9fba519642a 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -2216,18 +2216,14 @@ VarDecl *VarDecl::getActingDefinition() {
 return nullptr;
 
   VarDecl *LastTentative = nullptr;
-
-  // Loop through the declaration chain, starting with the most recent.
-  for (VarDecl *Decl = getMostRecentDecl(); Decl;
-   Decl = Decl->getPreviousDecl()) {
-Kind = Decl->isThisDeclarationADefinition();
+  VarDecl *First = getFirstDecl();
+  for (auto I : First->redecls()) {
+Kind = I->isThisDeclarationADefinition();
 if (Kind == Definition)
   return nullptr;
-// Record the first (most recent) TentativeDefinition that is encountered.
-if (Kind == TentativeDefinition && !LastTentative)
-  LastTentative = Decl;
+if (Kind == TentativeDefinition)
+  LastTentative = I;
   }
-
   return LastTentative;
 }
 

diff  --git a/clang/test/CodeGen/attr-tentative-definition.c 
b/clang/test/CodeGen/attr-tentative-definition.c
deleted file mode 100644
index 7405e8079b220..0
--- a/clang/test/CodeGen/attr-tentative-definition.c
+++ /dev/null
@@ -1,7 +0,0 @@
-// RUN: %clang_cc1 -emit-llvm < %s | FileCheck %s
-
-char arr[10];
-char arr[10] __attribute__((section("datadata")));
-char arr[10] __attribute__((aligned(16)));
-
-// CHECK: @arr ={{.*}}section "datadata", align 16



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


Re: [llvm-dev] Phabricator Creator Pulling the Plug

2021-08-24 Thread Renato Golin via cfe-commits
On Tue, 24 Aug 2021 at 17:30, James Y Knight  wrote:

> Yes, the Gerrit hosting which Go uses ("googlesource.com") only permits a
> google-account login as a matter of policy. But that's not a restriction of
> Gerrit itself -- it can perfectly well be configured to use a github login.
>

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


Re: [llvm-dev] Phabricator Creator Pulling the Plug

2021-08-24 Thread James Y Knight via cfe-commits
On Tue, Aug 24, 2021 at 7:33 AM Renato Golin  wrote:

> The main problem with that (Go) solution is that the Gerrit install
> doesn't single-sign-on with Github accounts, it asked me for my Google
> account. We shouldn't ask people to create more accounts if we want
> integration with Github. I guess this is just a configuration issue, right?
>

Yes, the Gerrit hosting which Go uses ("googlesource.com") only permits a
google-account login as a matter of policy. But that's not a restriction of
Gerrit itself -- it can perfectly well be configured to use a github login.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D108422: [NFC][clang] Move remaining part of X86Target.def to llvm/Support/X86TargetParser.def

2021-08-24 Thread Andrei Elovikov via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf387a3617860: [NFC][clang] Move remaining part of 
X86Target.def to… (authored by a.elovikov).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108422

Files:
  clang/include/clang/Basic/X86Target.def
  clang/lib/Basic/Targets/X86.cpp
  llvm/include/llvm/Support/X86TargetParser.def

Index: llvm/include/llvm/Support/X86TargetParser.def
===
--- llvm/include/llvm/Support/X86TargetParser.def
+++ llvm/include/llvm/Support/X86TargetParser.def
@@ -208,3 +208,49 @@
 X86_FEATURE   (LVI_LOAD_HARDENING,  "lvi-load-hardening")
 #undef X86_FEATURE_COMPAT
 #undef X86_FEATURE
+
+#ifndef CPU_SPECIFIC
+#define CPU_SPECIFIC(NAME, MANGLING, FEATURES)
+#endif
+
+#ifndef CPU_SPECIFIC_ALIAS
+#define CPU_SPECIFIC_ALIAS(NEW_NAME, NAME)
+#endif
+
+CPU_SPECIFIC("generic", 'A', "")
+CPU_SPECIFIC("pentium", 'B', "")
+CPU_SPECIFIC("pentium_pro", 'C', "+cmov")
+CPU_SPECIFIC("pentium_mmx", 'D', "+mmx")
+CPU_SPECIFIC("pentium_ii", 'E', "+cmov,+mmx")
+CPU_SPECIFIC("pentium_iii", 'H', "+cmov,+mmx,+sse")
+CPU_SPECIFIC_ALIAS("pentium_iii_no_xmm_regs", "pentium_iii")
+CPU_SPECIFIC("pentium_4", 'J', "+cmov,+mmx,+sse,+sse2")
+CPU_SPECIFIC("pentium_m", 'K', "+cmov,+mmx,+sse,+sse2")
+CPU_SPECIFIC("pentium_4_sse3", 'L', "+cmov,+mmx,+sse,+sse2,+sse3")
+CPU_SPECIFIC("core_2_duo_ssse3", 'M', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3")
+CPU_SPECIFIC("core_2_duo_sse4_1", 'N', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1")
+CPU_SPECIFIC("atom", 'O', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+movbe")
+CPU_SPECIFIC("atom_sse4_2", 'c', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt")
+CPU_SPECIFIC("core_i7_sse4_2", 'P', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt")
+CPU_SPECIFIC("core_aes_pclmulqdq", 'Q', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt")
+CPU_SPECIFIC("atom_sse4_2_movbe", 'd', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt")
+CPU_SPECIFIC("goldmont", 'i', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt")
+CPU_SPECIFIC("sandybridge", 'R', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt,+avx")
+CPU_SPECIFIC_ALIAS("core_2nd_gen_avx", "sandybridge")
+CPU_SPECIFIC("ivybridge", 'S', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt,+f16c,+avx")
+CPU_SPECIFIC_ALIAS("core_3rd_gen_avx", "ivybridge")
+CPU_SPECIFIC("haswell", 'V', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2")
+CPU_SPECIFIC_ALIAS("core_4th_gen_avx", "haswell")
+CPU_SPECIFIC("core_4th_gen_avx_tsx", 'W', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2")
+CPU_SPECIFIC("broadwell", 'X', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+adx")
+CPU_SPECIFIC_ALIAS("core_5th_gen_avx", "broadwell")
+CPU_SPECIFIC("core_5th_gen_avx_tsx", 'Y', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+adx")
+CPU_SPECIFIC("knl", 'Z', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+avx512f,+adx,+avx512er,+avx512pf,+avx512cd")
+CPU_SPECIFIC_ALIAS("mic_avx512", "knl")
+CPU_SPECIFIC("skylake", 'b', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+adx,+mpx")
+CPU_SPECIFIC( "skylake_avx512", 'a', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+avx512dq,+avx512f,+adx,+avx512cd,+avx512bw,+avx512vl,+clwb")
+CPU_SPECIFIC("cannonlake", 'e', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+avx512dq,+avx512f,+adx,+avx512ifma,+avx512cd,+avx512bw,+avx512vl,+avx512vbmi")
+CPU_SPECIFIC("knm", 'j', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+avx512f,+adx,+avx512er,+avx512pf,+avx512cd,+avx5124fmaps,+avx5124vnniw,+avx512vpopcntdq")
+
+#undef CPU_SPECIFIC_ALIAS
+#undef CPU_SPECIFIC
Index: clang/lib/Basic/Targets/X86.cpp
===
--- clang/lib/Basic/Targets/X86.cpp
+++ clang/lib/Basic/Targets/X86.cpp
@@ -1105,21 +1105,21 @@
   return llvm::StringSwitch(Name)
 #define CPU_SPECIFIC(NAME, MANGLING, FEATURES) .Case(NAME, true)
 #define CPU_SPECIFIC_ALIAS(NEW_NAME, NAME) .Case(NEW_NAME, true)
-#include "clang/Basic/X86Target.def"
+#include "llvm/Support/X86TargetParser.def"
   .Default(false);
 }
 
 static StringRef CPUSpecificCPUDispatchNameDealias(StringRef Name) {
   return llvm::StringSwitch(Name)
 #define CPU_SPECIFIC_ALIAS(NEW_NAME, NAME) .Case(NEW_NAME, NAME)
-#include "clang/Basic/X86Target.def"

[clang] f387a36 - [NFC][clang] Move remaining part of X86Target.def to llvm/Support/X86TargetParser.def

2021-08-24 Thread Andrei Elovikov via cfe-commits

Author: Andrei Elovikov
Date: 2021-08-24T09:16:31-07:00
New Revision: f387a361786081f8aadf079aa32e73ed05386242

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

LOG: [NFC][clang] Move remaining part of X86Target.def to 
llvm/Support/X86TargetParser.def

Reviewed By: RKSimon

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

Added: 


Modified: 
clang/lib/Basic/Targets/X86.cpp
llvm/include/llvm/Support/X86TargetParser.def

Removed: 
clang/include/clang/Basic/X86Target.def



diff  --git a/clang/include/clang/Basic/X86Target.def 
b/clang/include/clang/Basic/X86Target.def
deleted file mode 100644
index 3a5d5b2183f2d..0
--- a/clang/include/clang/Basic/X86Target.def
+++ /dev/null
@@ -1,59 +0,0 @@
-//===--- X86Target.def - X86 Feature/Processor Database -*- C++ 
-*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===--===//
-//
-// This file defines the X86-specific Features and Processors, as used by
-// the X86 Targets.
-//
-//===--===//
-
-#ifndef CPU_SPECIFIC
-#define CPU_SPECIFIC(NAME, MANGLING, FEATURES)
-#endif
-
-#ifndef CPU_SPECIFIC_ALIAS
-#define CPU_SPECIFIC_ALIAS(NEW_NAME, NAME)
-#endif
-
-// FIXME: When commented out features are supported in LLVM, enable them here.
-CPU_SPECIFIC("generic", 'A', "")
-CPU_SPECIFIC("pentium", 'B', "")
-CPU_SPECIFIC("pentium_pro", 'C', "+cmov")
-CPU_SPECIFIC("pentium_mmx", 'D', "+mmx")
-CPU_SPECIFIC("pentium_ii", 'E', "+cmov,+mmx")
-CPU_SPECIFIC("pentium_iii", 'H', "+cmov,+mmx,+sse")
-CPU_SPECIFIC_ALIAS("pentium_iii_no_xmm_regs", "pentium_iii")
-CPU_SPECIFIC("pentium_4", 'J', "+cmov,+mmx,+sse,+sse2")
-CPU_SPECIFIC("pentium_m", 'K', "+cmov,+mmx,+sse,+sse2")
-CPU_SPECIFIC("pentium_4_sse3", 'L', "+cmov,+mmx,+sse,+sse2,+sse3")
-CPU_SPECIFIC("core_2_duo_ssse3", 'M', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3")
-CPU_SPECIFIC("core_2_duo_sse4_1", 'N', 
"+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1")
-CPU_SPECIFIC("atom", 'O', "+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+movbe")
-CPU_SPECIFIC("atom_sse4_2", 'c', 
"+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt")
-CPU_SPECIFIC("core_i7_sse4_2", 'P', 
"+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt")
-CPU_SPECIFIC("core_aes_pclmulqdq", 'Q', 
"+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt")
-CPU_SPECIFIC("atom_sse4_2_movbe", 'd', 
"+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt")
-CPU_SPECIFIC("goldmont", 'i', 
"+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt")
-CPU_SPECIFIC("sandybridge", 'R', 
"+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt,+avx")
-CPU_SPECIFIC_ALIAS("core_2nd_gen_avx", "sandybridge")
-CPU_SPECIFIC("ivybridge", 'S', 
"+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+popcnt,+f16c,+avx")
-CPU_SPECIFIC_ALIAS("core_3rd_gen_avx", "ivybridge")
-CPU_SPECIFIC("haswell", 'V', 
"+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2")
-CPU_SPECIFIC_ALIAS("core_4th_gen_avx", "haswell")
-CPU_SPECIFIC("core_4th_gen_avx_tsx", 'W', 
"+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2")
-CPU_SPECIFIC("broadwell", 'X', 
"+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+adx")
-CPU_SPECIFIC_ALIAS("core_5th_gen_avx", "broadwell")
-CPU_SPECIFIC("core_5th_gen_avx_tsx", 'Y', 
"+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+adx")
-CPU_SPECIFIC("knl", 'Z', 
"+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+avx512f,+adx,+avx512er,+avx512pf,+avx512cd")
-CPU_SPECIFIC_ALIAS("mic_avx512", "knl")
-CPU_SPECIFIC("skylake", 'b', 
"+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+adx,+mpx")
-CPU_SPECIFIC( "skylake_avx512", 'a', 
"+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+avx512dq,+avx512f,+adx,+avx512cd,+avx512bw,+avx512vl,+clwb")
-CPU_SPECIFIC("cannonlake", 'e', 
"+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+avx512dq,+avx512f,+adx,+avx512ifma,+avx512cd,+avx512bw,+avx512vl,+avx512vbmi")
-CPU_SPECIFIC("knm", 'j', 
"+cmov,+mmx,+sse,+sse2,+sse3,+ssse3,+sse4.1,+sse4.2,+movbe,+popcnt,+f16c,+avx,+fma,+bmi,+lzcnt,+avx2,+avx512f,+adx,+avx512er,+avx512pf,+avx512cd,+avx5124fmaps,+avx5124vnniw,+avx512vpopcntdq")

[PATCH] D107850: [asan] Implemented intrinsic for the custom calling convention similar used by HWASan for X86.

2021-08-24 Thread Kirill Stoimenov via Phabricator via cfe-commits
kstoimenov added inline comments.



Comment at: llvm/lib/Target/X86/X86MCInstLower.cpp:1426
+  OutStreamer->emitInstruction(MCInstBuilder(X86::AND32ri8)
+   .addReg(X86::ECX)
+   .addReg(X86::ECX)

vitalybuka wrote:
> kstoimenov wrote:
> > vitalybuka wrote:
> > > what is in ECX register here?
> > Should be NoRegister. Done.
> Why NoRegister update is not reflected in tests?
The instruction template for AND32ri8 expects 2 registers for some reason, 
which I am not sure why. If I provide only one register I get a clang crash.  
The emitted instruction is what I want so I didn't dig much deeper into it. 



Comment at: llvm/test/CodeGen/X86/asan-check-memaccess-or.ll:94
+; CHECK-NEXT: movq[[REG]], %rcx
+; CHECK-NEXT: andl$7, %ecx
+; CHECK-NEXT: addl$1, %ecx

vitalybuka wrote:
> What is ECX here?
ECX is the lower 3 bits of the address. Is is the second part of the check 
"((Addr & 7) + AccessSize > k)". 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107850

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


[PATCH] D108615: [Coroutines] [libcxx] Move coroutine component out of experimental namespace

2021-08-24 Thread Xun Li via Phabricator via cfe-commits
lxfind added a comment.

I am not familiar with the process of when to move something out of 
experimental, but I do wonder how this is normally done so that people who uses 
coroutines can have a smooth migration?
I assume that this is going to be a breaking change that existing code using 
coroutine will need to be updated and no longer compatible with old versions.


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

https://reviews.llvm.org/D108615

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


[PATCH] D107850: [asan] Implemented intrinsic for the custom calling convention similar used by HWASan for X86.

2021-08-24 Thread Kirill Stoimenov via Phabricator via cfe-commits
kstoimenov updated this revision to Diff 368367.
kstoimenov marked an inline comment as done.
kstoimenov added a comment.

Fixed a crash.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107850

Files:
  llvm/include/llvm/IR/Intrinsics.td
  llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
  llvm/lib/Target/X86/X86AsmPrinter.cpp
  llvm/lib/Target/X86/X86AsmPrinter.h
  llvm/lib/Target/X86/X86InstrCompiler.td
  llvm/lib/Target/X86/X86MCInstLower.cpp
  llvm/lib/Target/X86/X86RegisterInfo.td
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/test/CodeGen/X86/asan-check-memaccess-add.ll
  llvm/test/CodeGen/X86/asan-check-memaccess-or.ll
  llvm/tools/llvm-exegesis/CMakeLists.txt

Index: llvm/tools/llvm-exegesis/CMakeLists.txt
===
--- llvm/tools/llvm-exegesis/CMakeLists.txt
+++ llvm/tools/llvm-exegesis/CMakeLists.txt
@@ -1,4 +1,5 @@
 set(LLVM_LINK_COMPONENTS
+  Instrumentation
   MC
   MCParser
   Support
Index: llvm/test/CodeGen/X86/asan-check-memaccess-or.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/asan-check-memaccess-or.ll
@@ -0,0 +1,253 @@
+; RUN: llc < %s | FileCheck %s
+
+target triple = "x86_64-pc-win"
+
+define void @load1(i8* nocapture readonly %x) {
+; CHECK:  callq   __asan_check_load1_rn[[RN1:.*]]
+; CHECK:  callq   __asan_check_store1_rn[[RN1]]
+; CHECK-NEXT: retq
+  call void @llvm.asan.check.memaccess(i8* %x, i32 0)
+  call void @llvm.asan.check.memaccess(i8* %x, i32 32)
+  ret void
+}
+
+define void @load2(i16* nocapture readonly %x) {
+; CHECK:  callq   __asan_check_load2_rn[[RN2:.*]]
+; CHECK:  callq   __asan_check_store2_rn[[RN2]]
+; CHECK-NEXT: retq
+  %1 = ptrtoint i16* %x to i64
+  %2 = bitcast i16* %x to i8*
+  call void @llvm.asan.check.memaccess(i8* %2, i32 2)
+  call void @llvm.asan.check.memaccess(i8* %2, i32 34)
+  ret void
+}
+
+define void @load4(i32* nocapture readonly %x) {
+; CHECK:  callq   __asan_check_load4_rn[[RN4:.*]]
+; CHECK:  callq   __asan_check_store4_rn[[RN4]]
+; CHECK-NEXT: retq
+  %1 = ptrtoint i32* %x to i64
+  %2 = bitcast i32* %x to i8*
+  call void @llvm.asan.check.memaccess(i8* %2, i32 4)
+  call void @llvm.asan.check.memaccess(i8* %2, i32 36)
+  ret void
+}
+define void @load8(i64* nocapture readonly %x) {
+; CHECK:  callq   __asan_check_load8_rn[[RN8:.*]]
+; CHECK:  callq   __asan_check_store8_rn[[RN8]]
+; CHECK-NEXT: retq
+  %1 = ptrtoint i64* %x to i64
+  %2 = bitcast i64* %x to i8*
+  call void @llvm.asan.check.memaccess(i8* %2, i32 6)
+  call void @llvm.asan.check.memaccess(i8* %2, i32 38)
+  ret void
+}
+
+define void @load16(i128* nocapture readonly %x) {
+; CHECK:  callq   __asan_check_load16_rn[[RN16:.*]]
+; CHECK:  callq   __asan_check_store16_rn[[RN16]]
+; CHECK-NEXT: retq
+  %1 = ptrtoint i128* %x to i64
+  %2 = bitcast i128* %x to i8*
+  call void @llvm.asan.check.memaccess(i8* %2, i32 8)
+  call void @llvm.asan.check.memaccess(i8* %2, i32 40)
+  ret void
+}
+
+; CHECK:  .type   __asan_check_load1_rn[[RN1]],@function
+; CHECK-NEXT: .weak   __asan_check_load1_rn[[RN1]]
+; CHECK-NEXT: .hidden __asan_check_load1_rn[[RN1]]
+; CHECK-NEXT: __asan_check_load1_rn[[RN1]]:
+; CHECK-NEXT: movq[[REG:.*]], %r8
+; CHECK-NEXT: shrq$3, %r8
+; CHECK-NEXT: orq $17592186044416, %r8{{.*}}
+; CHECK-NEXT: movb(%r8), %r8b
+; CHECK-NEXT: testb   %r8b, %r8b
+; CHECK-NEXT: jne [[EXTRA:.*]]
+; CHECK-NEXT: [[RET:.*]]:
+; CHECK-NEXT: retq
+; CHECK-NEXT: [[EXTRA]]:
+; CHECK-NEXT: pushq   %rcx
+; CHECK-NEXT: movq[[REG]], %rcx
+; CHECK-NEXT: andl$7, %ecx
+; CHECK-NEXT: cmpl%r8d, %ecx
+; CHECK-NEXT: popq%rcx
+; CHECK-NEXT: jl  [[RET]]
+; CHECK-NEXT: movq[[REG:.*]], %rdi
+; CHECK-NEXT: jmp __asan_report_load1
+
+; CHECK:  .type   __asan_check_load2_rn[[RN2]],@function
+; CHECK-NEXT: .weak   __asan_check_load2_rn[[RN2]]
+; CHECK-NEXT: .hidden __asan_check_load2_rn[[RN2]]
+; CHECK-NEXT: __asan_check_load2_rn[[RN2]]:
+; CHECK-NEXT: movq[[REG:.*]], %r8
+; CHECK-NEXT: shrq$3, %r8
+; CHECK-NEXT: orq $17592186044416, %r8{{.*}}
+; CHECK-NEXT: movb(%r8), %r8b
+; CHECK-NEXT: testb   %r8b, %r8b
+; CHECK-NEXT: jne [[EXTRA:.*]]
+; CHECK-NEXT: [[RET:.*]]:
+; CHECK-NEXT: retq
+; CHECK-NEXT: [[EXTRA]]:
+; CHECK-NEXT: pushq   %rcx
+; CHECK-NEXT: movq[[REG]], %rcx
+; CHECK-NEXT: andl$7, %ecx
+; CHECK-NEXT: addl$1, %ecx
+; CHECK-NEXT: cmpl%r8d, %ecx
+; 

[PATCH] D107450: [clang-tidy] Fix wrong FIxIt in performance-move-const-arg

2021-08-24 Thread gehry via Phabricator via cfe-commits
Sockke added a comment.

Which do you prefer? @Quuxplusone




Comment at: 
clang-tools-extra/test/clang-tidy/checkers/performance-move-const-arg.cpp:262-263
+  int a = 10;
+  forwardToShowInt(std::move(a));
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: std::move of the variable 'a' 
of the trivially-copyable type 'int' has no effect
+}

Quuxplusone wrote:
> ```
>   forwardToShowInt(std::move(a));
>   // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: std::move of the variable 'a' 
> of the trivially-copyable type 'int' has no effect
> ```
> I continue to want-not-to-block this PR, since I think it's improving the 
> situation. However, FWIW...
> It's good that this message doesn't contain a fixit, since there's nothing 
> the programmer can really do to "fix" this call. But then, should this 
> message be emitted at all? If this were `clang -Wall`, then we definitely 
> would //not// want to emit a "noisy" warning where there's basically nothing 
> the programmer can do about it. Does clang-tidy have a similar philosophy? Or 
> is it okay for clang-tidy to say "This code looks wonky" even when there's no 
> obvious way to fix it?
> ```
>   forwardToShowInt(std::move(a));
>   // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: std::move of the variable 'a' 
> of the trivially-copyable type 'int' has no effect
> ```
> I continue to want-not-to-block this PR, since I think it's improving the 
> situation. However, FWIW...
> It's good that this message doesn't contain a fixit, since there's nothing 
> the programmer can really do to "fix" this call. But then, should this 
> message be emitted at all? If this were `clang -Wall`, then we definitely 
> would //not// want to emit a "noisy" warning where there's basically nothing 
> the programmer can do about it. Does clang-tidy have a similar philosophy? Or 
> is it okay for clang-tidy to say "This code looks wonky" even when there's no 
> obvious way to fix it?

Yes, I agree with you. I did not remove warning to maintain the original 
behavior, which will make the current patch clearer. In any case, it is easy 
for me to make this modification if you want. 


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

https://reviews.llvm.org/D107450

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


[PATCH] D108370: [clang-tidy] Fix wrong FixIt about union in cppcoreguidelines-pro-type-member-init

2021-08-24 Thread gehry via Phabricator via cfe-commits
Sockke added a comment.

What do you think? @aaron.ballman @bkramer


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108370

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


[PATCH] D107850: [asan] Implemented intrinsic for the custom calling convention similar used by HWASan for X86.

2021-08-24 Thread Kirill Stoimenov via Phabricator via cfe-commits
kstoimenov updated this revision to Diff 368352.
kstoimenov added a comment.

Second attempt to split AddressSanitizer.cpp.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107850

Files:
  llvm/include/llvm/IR/Intrinsics.td
  llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
  llvm/lib/Target/X86/X86AsmPrinter.cpp
  llvm/lib/Target/X86/X86AsmPrinter.h
  llvm/lib/Target/X86/X86InstrCompiler.td
  llvm/lib/Target/X86/X86MCInstLower.cpp
  llvm/lib/Target/X86/X86RegisterInfo.td
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/test/CodeGen/X86/asan-check-memaccess-add.ll
  llvm/test/CodeGen/X86/asan-check-memaccess-or.ll
  llvm/tools/llvm-exegesis/CMakeLists.txt

Index: llvm/tools/llvm-exegesis/CMakeLists.txt
===
--- llvm/tools/llvm-exegesis/CMakeLists.txt
+++ llvm/tools/llvm-exegesis/CMakeLists.txt
@@ -1,4 +1,5 @@
 set(LLVM_LINK_COMPONENTS
+  Instrumentation
   MC
   MCParser
   Support
Index: llvm/test/CodeGen/X86/asan-check-memaccess-or.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/asan-check-memaccess-or.ll
@@ -0,0 +1,253 @@
+; RUN: llc < %s | FileCheck %s
+
+target triple = "x86_64-pc-win"
+
+define void @load1(i8* nocapture readonly %x) {
+; CHECK:  callq   __asan_check_load1_rn[[RN1:.*]]
+; CHECK:  callq   __asan_check_store1_rn[[RN1]]
+; CHECK-NEXT: retq
+  call void @llvm.asan.check.memaccess(i8* %x, i32 0)
+  call void @llvm.asan.check.memaccess(i8* %x, i32 32)
+  ret void
+}
+
+define void @load2(i16* nocapture readonly %x) {
+; CHECK:  callq   __asan_check_load2_rn[[RN2:.*]]
+; CHECK:  callq   __asan_check_store2_rn[[RN2]]
+; CHECK-NEXT: retq
+  %1 = ptrtoint i16* %x to i64
+  %2 = bitcast i16* %x to i8*
+  call void @llvm.asan.check.memaccess(i8* %2, i32 2)
+  call void @llvm.asan.check.memaccess(i8* %2, i32 34)
+  ret void
+}
+
+define void @load4(i32* nocapture readonly %x) {
+; CHECK:  callq   __asan_check_load4_rn[[RN4:.*]]
+; CHECK:  callq   __asan_check_store4_rn[[RN4]]
+; CHECK-NEXT: retq
+  %1 = ptrtoint i32* %x to i64
+  %2 = bitcast i32* %x to i8*
+  call void @llvm.asan.check.memaccess(i8* %2, i32 4)
+  call void @llvm.asan.check.memaccess(i8* %2, i32 36)
+  ret void
+}
+define void @load8(i64* nocapture readonly %x) {
+; CHECK:  callq   __asan_check_load8_rn[[RN8:.*]]
+; CHECK:  callq   __asan_check_store8_rn[[RN8]]
+; CHECK-NEXT: retq
+  %1 = ptrtoint i64* %x to i64
+  %2 = bitcast i64* %x to i8*
+  call void @llvm.asan.check.memaccess(i8* %2, i32 6)
+  call void @llvm.asan.check.memaccess(i8* %2, i32 38)
+  ret void
+}
+
+define void @load16(i128* nocapture readonly %x) {
+; CHECK:  callq   __asan_check_load16_rn[[RN16:.*]]
+; CHECK:  callq   __asan_check_store16_rn[[RN16]]
+; CHECK-NEXT: retq
+  %1 = ptrtoint i128* %x to i64
+  %2 = bitcast i128* %x to i8*
+  call void @llvm.asan.check.memaccess(i8* %2, i32 8)
+  call void @llvm.asan.check.memaccess(i8* %2, i32 40)
+  ret void
+}
+
+; CHECK:  .type   __asan_check_load1_rn[[RN1]],@function
+; CHECK-NEXT: .weak   __asan_check_load1_rn[[RN1]]
+; CHECK-NEXT: .hidden __asan_check_load1_rn[[RN1]]
+; CHECK-NEXT: __asan_check_load1_rn[[RN1]]:
+; CHECK-NEXT: movq[[REG:.*]], %r8
+; CHECK-NEXT: shrq$3, %r8
+; CHECK-NEXT: orq $17592186044416, %r8{{.*}}
+; CHECK-NEXT: movb(%r8), %r8b
+; CHECK-NEXT: testb   %r8b, %r8b
+; CHECK-NEXT: jne [[EXTRA:.*]]
+; CHECK-NEXT: [[RET:.*]]:
+; CHECK-NEXT: retq
+; CHECK-NEXT: [[EXTRA]]:
+; CHECK-NEXT: pushq   %rcx
+; CHECK-NEXT: movq[[REG]], %rcx
+; CHECK-NEXT: andl$7, %ecx
+; CHECK-NEXT: cmpl%r8d, %ecx
+; CHECK-NEXT: popq%rcx
+; CHECK-NEXT: jl  [[RET]]
+; CHECK-NEXT: movq[[REG:.*]], %rdi
+; CHECK-NEXT: jmp __asan_report_load1
+
+; CHECK:  .type   __asan_check_load2_rn[[RN2]],@function
+; CHECK-NEXT: .weak   __asan_check_load2_rn[[RN2]]
+; CHECK-NEXT: .hidden __asan_check_load2_rn[[RN2]]
+; CHECK-NEXT: __asan_check_load2_rn[[RN2]]:
+; CHECK-NEXT: movq[[REG:.*]], %r8
+; CHECK-NEXT: shrq$3, %r8
+; CHECK-NEXT: orq $17592186044416, %r8{{.*}}
+; CHECK-NEXT: movb(%r8), %r8b
+; CHECK-NEXT: testb   %r8b, %r8b
+; CHECK-NEXT: jne [[EXTRA:.*]]
+; CHECK-NEXT: [[RET:.*]]:
+; CHECK-NEXT: retq
+; CHECK-NEXT: [[EXTRA]]:
+; CHECK-NEXT: pushq   %rcx
+; CHECK-NEXT: movq[[REG]], %rcx
+; CHECK-NEXT: andl$7, %ecx
+; CHECK-NEXT: addl$1, %ecx
+; CHECK-NEXT: cmpl%r8d, %ecx
+; CHECK-NEXT:

[PATCH] D108456: [CUDA] Fix static device variables with -fgpu-rdc

2021-08-24 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.

LGTM. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108456

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


[PATCH] D108301: [MSP430][Clang] Update hard-coded MCU data

2021-08-24 Thread Jozef Lawrynowicz via Phabricator via cfe-commits
jozefl updated this revision to Diff 368348.
jozefl added a comment.

Here's an updated patch that fixes some minor nits.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108301

Files:
  clang/include/clang/Basic/MSP430Target.def
  clang/lib/Driver/ToolChains/MSP430.cpp
  clang/test/Driver/msp430-hwmult.c
  clang/test/Driver/msp430-mmcu.c
  clang/test/Driver/msp430-toolchain.c

Index: clang/test/Driver/msp430-toolchain.c
===
--- clang/test/Driver/msp430-toolchain.c
+++ clang/test/Driver/msp430-toolchain.c
@@ -253,6 +253,10 @@
 // RUN:   | FileCheck -check-prefix=HWMult-32BIT %s
 // HWMult-32BIT: "--start-group" "-lmul_32"
 
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430fr5969 --sysroot="" 2>&1 \
+// RUN:   | FileCheck -check-prefix=HWMult-F5 %s
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430fr5969 -mhwmult=auto --sysroot="" 2>&1 \
+// RUN:   | FileCheck -check-prefix=HWMult-F5 %s
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mhwmult=f5series --sysroot="" 2>&1 \
 // RUN:   | FileCheck -check-prefix=HWMult-F5 %s
 // HWMult-F5: "--start-group" "-lmul_f5"
Index: clang/test/Driver/msp430-mmcu.c
===
--- clang/test/Driver/msp430-mmcu.c
+++ clang/test/Driver/msp430-mmcu.c
@@ -1,15 +1,62 @@
+// This file tests that various different values passed to -mmcu= select the
+// correct target features and linker scripts, and create MCU-specific defines.
+
+// Test the lexicographic ordering of MCUs in MSP430Target.def.
+//
+// The MCU "msp430f110" should appear before "msp430f1101" when the data has
+// been sorted lexicographically. Some sorts will put "msp430f110" *after*
+// "msp430f1101", so when this happens, Clang will not be able to find this MCU.
+
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f110 2>&1 \
+// RUN:   | FileCheck %s
+
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f1101 2>&1 \
+// RUN:   | FileCheck %s
+
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f1101a 2>&1 \
+// RUN:   | FileCheck %s
+
+// CHECK-NOT: error: the clang compiler does not support
+
+// Test the symbol definitions, linker scripts and hardware multiply features
+// selected for different MCUs.
+
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430c111 2>&1 \
 // RUN:   | FileCheck -check-prefix=MSP430-C111 %s
 
 // MSP430-C111: clang{{.*}} "-cc1" {{.*}} "-D__MSP430C111__"
+// MSP430-C111-NOT: "-target-feature" "+hwmult16"
+// MSP430-C111-NOT: "-target-feature" "+hwmult32"
+// MSP430-C111-NOT: "-target-feature" "+hwmultf5"
 // MSP430-C111: msp430-elf-ld{{.*}} "-Tmsp430c111.ld"
 
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430i2020 2>&1 \
 // RUN:   | FileCheck -check-prefix=MSP430-I2020 %s
 
 // MSP430-I2020: clang{{.*}} "-cc1" {{.*}} "-D__MSP430i2020__"
+// MSP430-I2020: "-target-feature" "+hwmult16"
 // MSP430-I2020: msp430-elf-ld{{.*}} "-Tmsp430i2020.ld"
 
+// RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430f47126 2>&1 \
+// RUN:   | FileCheck -check-prefix=MSP430-F47126 %s
+
+// MSP430-F47126: clang{{.*}} "-cc1" {{.*}} "-D__MSP430F47126__"
+// MSP430-F47126: "-target-feature" "+hwmult32"
+// MSP430-F47126: msp430-elf-ld{{.*}} "-Tmsp430f47126.ld"
+
+// RAN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=msp430fr5969 2>&1 \
+// RAN:   | FileCheck -check-prefix=MSP430-FR5969 %s
+
+// MSP430-FR5969: clang{{.*}} "-cc1" {{.*}} "-D__MSP430FR5969__"
+// MSP430-FR5969: "-target-feature" "+hwmultf5"
+// MSP430-FR5969: msp430-elf-ld{{.*}} "-Tmsp430fr5969.ld"
+
+// Test for the error message emitted when an invalid MCU is selected.
+//
+// Note that if this test is ever modified because the expected error message is
+// changed, the check prefixes at the top of this file, used to validate the
+// ordering of the hard-coded MCU data, also need to be updated.
+//
 // RUN: %clang %s -### -no-canonical-prefixes -target msp430 -mmcu=not-a-mcu 2>&1 \
 // RUN:   | FileCheck -check-prefix=MSP430-UNSUP %s
 
Index: clang/test/Driver/msp430-hwmult.c
===
--- clang/test/Driver/msp430-hwmult.c
+++ clang/test/Driver/msp430-hwmult.c
@@ -3,17 +3,13 @@
 
 // RUN: %clang -### -target msp430 %s 2>&1 | FileCheck %s
 // RUN: %clang -### -target msp430 %s -mhwmult=auto 2>&1 | FileCheck %s
+// RUN: %clang -### -target msp430 %s -mhwmult=none 2>&1 | FileCheck %s
+// RUN: %clang -### -target msp430 %s -mhwmult=none -mmcu=msp430f147 2>&1 | FileCheck %s
+// RUN: %clang -### -target msp430 %s -mhwmult=none -mmcu=msp430f4783 2>&1 | FileCheck %s
 // CHECK-NOT: "-target-feature" "+hwmult16"
 // CHECK-NOT: "-target-feature" "+hwmult32"
 // CHECK-NOT: "-target-feature" 

[PATCH] D108377: [asan] Implemented flag to emit intrinsics to optimize ASan callbacks.

2021-08-24 Thread Kirill Stoimenov via Phabricator via cfe-commits
kstoimenov added a comment.

Tests are still WIP. This is not ready for review yet. I will ping you when it 
it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108377

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


[PATCH] D108556: [clangd] Don't highlight ObjC `id` and `instancetype`

2021-08-24 Thread David Goldman via Phabricator via cfe-commits
dgoldman added a comment.

In D108556#2962008 , @kadircet wrote:

> thanks, it looks good as a contained fix. but it feels like we probably don't 
> want these to be treated as decls in other places too (e.g. can we really 
> provide any useful goto/hover on those `id` or `instancetype` decls?) maybe 
> we should update ASTVisitors in FindTarget to not report these at all. WDYT?

That's a good point - I guess it could be marginally useful?

Hovering over instancetype you'll see `typedef id instancetype` and can be 
brought via goto definition to objc.h which defines `typedef struct objc_object 
*id;`. Hovering over id you see `typedef id id` (which is quite confusing) and 
go-to definition brings you to objc.h as well. In theory the hover information 
should show you `A pointer to an instance of a class.` (comment from objc.h), 
seems to have worked previously, not sure why it doesn't atm. References 
doesn't appear to work and you'd really never want to use it if it did - 
there'd be way too many.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108556

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


[PATCH] D107850: [asan] Implemented intrinsic for the custom calling convention similar used by HWASan for X86.

2021-08-24 Thread Kirill Stoimenov via Phabricator via cfe-commits
kstoimenov updated this revision to Diff 368347.
kstoimenov added a comment.

Attempt to split AddressSanitizer.cpp.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107850

Files:
  llvm/include/llvm/IR/Intrinsics.td
  llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
  llvm/lib/Target/X86/X86AsmPrinter.cpp
  llvm/lib/Target/X86/X86AsmPrinter.h
  llvm/lib/Target/X86/X86InstrCompiler.td
  llvm/lib/Target/X86/X86MCInstLower.cpp
  llvm/lib/Target/X86/X86RegisterInfo.td
  llvm/test/CodeGen/X86/asan-check-memaccess-add.ll
  llvm/test/CodeGen/X86/asan-check-memaccess-or.ll
  llvm/tools/llvm-exegesis/CMakeLists.txt

Index: llvm/tools/llvm-exegesis/CMakeLists.txt
===
--- llvm/tools/llvm-exegesis/CMakeLists.txt
+++ llvm/tools/llvm-exegesis/CMakeLists.txt
@@ -1,4 +1,5 @@
 set(LLVM_LINK_COMPONENTS
+  Instrumentation
   MC
   MCParser
   Support
Index: llvm/test/CodeGen/X86/asan-check-memaccess-or.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/asan-check-memaccess-or.ll
@@ -0,0 +1,253 @@
+; RUN: llc < %s | FileCheck %s
+
+target triple = "x86_64-pc-win"
+
+define void @load1(i8* nocapture readonly %x) {
+; CHECK:  callq   __asan_check_load1_rn[[RN1:.*]]
+; CHECK:  callq   __asan_check_store1_rn[[RN1]]
+; CHECK-NEXT: retq
+  call void @llvm.asan.check.memaccess(i8* %x, i32 0)
+  call void @llvm.asan.check.memaccess(i8* %x, i32 32)
+  ret void
+}
+
+define void @load2(i16* nocapture readonly %x) {
+; CHECK:  callq   __asan_check_load2_rn[[RN2:.*]]
+; CHECK:  callq   __asan_check_store2_rn[[RN2]]
+; CHECK-NEXT: retq
+  %1 = ptrtoint i16* %x to i64
+  %2 = bitcast i16* %x to i8*
+  call void @llvm.asan.check.memaccess(i8* %2, i32 2)
+  call void @llvm.asan.check.memaccess(i8* %2, i32 34)
+  ret void
+}
+
+define void @load4(i32* nocapture readonly %x) {
+; CHECK:  callq   __asan_check_load4_rn[[RN4:.*]]
+; CHECK:  callq   __asan_check_store4_rn[[RN4]]
+; CHECK-NEXT: retq
+  %1 = ptrtoint i32* %x to i64
+  %2 = bitcast i32* %x to i8*
+  call void @llvm.asan.check.memaccess(i8* %2, i32 4)
+  call void @llvm.asan.check.memaccess(i8* %2, i32 36)
+  ret void
+}
+define void @load8(i64* nocapture readonly %x) {
+; CHECK:  callq   __asan_check_load8_rn[[RN8:.*]]
+; CHECK:  callq   __asan_check_store8_rn[[RN8]]
+; CHECK-NEXT: retq
+  %1 = ptrtoint i64* %x to i64
+  %2 = bitcast i64* %x to i8*
+  call void @llvm.asan.check.memaccess(i8* %2, i32 6)
+  call void @llvm.asan.check.memaccess(i8* %2, i32 38)
+  ret void
+}
+
+define void @load16(i128* nocapture readonly %x) {
+; CHECK:  callq   __asan_check_load16_rn[[RN16:.*]]
+; CHECK:  callq   __asan_check_store16_rn[[RN16]]
+; CHECK-NEXT: retq
+  %1 = ptrtoint i128* %x to i64
+  %2 = bitcast i128* %x to i8*
+  call void @llvm.asan.check.memaccess(i8* %2, i32 8)
+  call void @llvm.asan.check.memaccess(i8* %2, i32 40)
+  ret void
+}
+
+; CHECK:  .type   __asan_check_load1_rn[[RN1]],@function
+; CHECK-NEXT: .weak   __asan_check_load1_rn[[RN1]]
+; CHECK-NEXT: .hidden __asan_check_load1_rn[[RN1]]
+; CHECK-NEXT: __asan_check_load1_rn[[RN1]]:
+; CHECK-NEXT: movq[[REG:.*]], %r8
+; CHECK-NEXT: shrq$3, %r8
+; CHECK-NEXT: orq $17592186044416, %r8{{.*}}
+; CHECK-NEXT: movb(%r8), %r8b
+; CHECK-NEXT: testb   %r8b, %r8b
+; CHECK-NEXT: jne [[EXTRA:.*]]
+; CHECK-NEXT: [[RET:.*]]:
+; CHECK-NEXT: retq
+; CHECK-NEXT: [[EXTRA]]:
+; CHECK-NEXT: pushq   %rcx
+; CHECK-NEXT: movq[[REG]], %rcx
+; CHECK-NEXT: andl$7, %ecx
+; CHECK-NEXT: cmpl%r8d, %ecx
+; CHECK-NEXT: popq%rcx
+; CHECK-NEXT: jl  [[RET]]
+; CHECK-NEXT: movq[[REG:.*]], %rdi
+; CHECK-NEXT: jmp __asan_report_load1
+
+; CHECK:  .type   __asan_check_load2_rn[[RN2]],@function
+; CHECK-NEXT: .weak   __asan_check_load2_rn[[RN2]]
+; CHECK-NEXT: .hidden __asan_check_load2_rn[[RN2]]
+; CHECK-NEXT: __asan_check_load2_rn[[RN2]]:
+; CHECK-NEXT: movq[[REG:.*]], %r8
+; CHECK-NEXT: shrq$3, %r8
+; CHECK-NEXT: orq $17592186044416, %r8{{.*}}
+; CHECK-NEXT: movb(%r8), %r8b
+; CHECK-NEXT: testb   %r8b, %r8b
+; CHECK-NEXT: jne [[EXTRA:.*]]
+; CHECK-NEXT: [[RET:.*]]:
+; CHECK-NEXT: retq
+; CHECK-NEXT: [[EXTRA]]:
+; CHECK-NEXT: pushq   %rcx
+; CHECK-NEXT: movq[[REG]], %rcx
+; CHECK-NEXT: andl$7, %ecx
+; CHECK-NEXT: addl$1, %ecx
+; CHECK-NEXT: cmpl%r8d, %ecx
+; CHECK-NEXT: popq%rcx
+; CHECK-NEXT: jl  [[RET]]
+; 

[PATCH] D108377: [asan] Implemented flag to emit intrinsics to optimize ASan callbacks.

2021-08-24 Thread Kirill Stoimenov via Phabricator via cfe-commits
kstoimenov updated this revision to Diff 368346.
kstoimenov added a comment.

Attempt to split AddressSanitizer.cpp.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108377

Files:
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/test/Instrumentation/AddressSanitizer/asan-optimize-callbacks.ll

Index: llvm/test/Instrumentation/AddressSanitizer/asan-optimize-callbacks.ll
===
--- /dev/null
+++ llvm/test/Instrumentation/AddressSanitizer/asan-optimize-callbacks.ll
@@ -0,0 +1,14 @@
+; RUN: opt < %s -asan -asan-module -enable-new-pm=0 -S | FileCheck %s
+
+target triple = "x86_64-unknown-linux-gnu"
+
+define void @load1(i8* %p1, i16* %p2, i32* %p4, i64* %p8, i128* %p16)
+  sanitize_address {
+  %n1 = load i8, i8* %p1
+  %n2 = load i16, i16* %p2
+  %n4 = load i32, i32* %p4
+  %n8 = load i64, i64* %p8
+  %n16 = load i128, i128* %p16
+;  store i32 0, i32* %p4, align 8
+  ret void
+}
Index: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -178,6 +178,14 @@
 
 static const unsigned kAllocaRzSize = 32;
 
+// ASanAccessInfo implementation constants.
+constexpr size_t kCompileKernelShift = 0;
+constexpr size_t kCompileKernelMask = 0x1;
+constexpr size_t kAccessSizeIndexShift = 1;
+constexpr size_t kAccessSizeIndexMask = 0xf;
+constexpr size_t kIsWriteShift = 5;
+constexpr size_t kIsWriteMask = 0x1;
+
 // Command-line flags.
 
 static cl::opt ClEnableKasan(
@@ -348,6 +356,10 @@
 static cl::opt ClOpt("asan-opt", cl::desc("Optimize instrumentation"),
cl::Hidden, cl::init(true));
 
+static cl::opt ClOptimizeCallbacks("asan-optimize-callbacks",
+ cl::desc("Optimize callbacks"),
+ cl::Hidden, cl::init(false));
+
 static cl::opt ClOptSameTemp(
 "asan-opt-same-temp", cl::desc("Instrument the same temp just once"),
 cl::Hidden, cl::init(true));
@@ -568,6 +580,21 @@
   *MappingScale = Mapping.Scale;
   *OrShadowOffset = Mapping.OrShadowOffset;
 }
+
+ASanAccessInfo::ASanAccessInfo(int32_t Packed)
+: Packed(Packed),
+  AccessSizeIndex((Packed >> kAccessSizeIndexShift) & kAccessSizeIndexMask),
+  IsWrite((Packed >> kIsWriteShift) & kIsWriteMask),
+  CompileKernel((Packed >> kCompileKernelShift) & kCompileKernelMask) {}
+
+ASanAccessInfo::ASanAccessInfo(bool IsWrite, bool CompileKernel,
+   uint8_t AccessSizeIndex)
+: Packed((IsWrite << kIsWriteShift) +
+ (CompileKernel << kCompileKernelShift) +
+ (AccessSizeIndex << kAccessSizeIndexShift)),
+  AccessSizeIndex(AccessSizeIndex), IsWrite(IsWrite),
+  CompileKernel(CompileKernel) {}
+
 } // namespace llvm
 
 static uint64_t getRedzoneSizeForScale(int MappingScale) {
@@ -634,6 +661,7 @@
 C = &(M.getContext());
 LongSize = M.getDataLayout().getPointerSizeInBits();
 IntptrTy = Type::getIntNTy(*C, LongSize);
+Int8PtrTy = Type::getInt8PtrTy(*C);
 TargetTriple = Triple(M.getTargetTriple());
 
 Mapping = getShadowMapping(TargetTriple, LongSize, this->CompileKernel);
@@ -724,6 +752,7 @@
   bool UseAfterScope;
   AsanDetectStackUseAfterReturnMode UseAfterReturn;
   Type *IntptrTy;
+  Type *Int8PtrTy;
   ShadowMapping Mapping;
   FunctionCallee AsanHandleNoReturnFunc;
   FunctionCallee AsanPtrCmpFunction, AsanPtrSubFunction;
@@ -1745,14 +1774,23 @@
   IRBuilder<> IRB(InsertBefore);
   Value *AddrLong = IRB.CreatePointerCast(Addr, IntptrTy);
   size_t AccessSizeIndex = TypeSizeToSizeIndex(TypeSize);
+  const ASanAccessInfo AccessInfo(IsWrite, CompileKernel, AccessSizeIndex);
 
   if (UseCalls) {
-if (Exp == 0)
-  IRB.CreateCall(AsanMemoryAccessCallback[IsWrite][0][AccessSizeIndex],
- AddrLong);
-else
-  IRB.CreateCall(AsanMemoryAccessCallback[IsWrite][1][AccessSizeIndex],
- {AddrLong, ConstantInt::get(IRB.getInt32Ty(), Exp)});
+if (ClOptimizeCallbacks) {
+  Value *Ptr8 = IRB.CreatePointerCast(Addr, Int8PtrTy);
+  Module *M = IRB.GetInsertBlock()->getParent()->getParent();
+  IRB.CreateCall(
+  Intrinsic::getDeclaration(M, Intrinsic::asan_check_memaccess),
+  {Ptr8, ConstantInt::get(IRB.getInt32Ty(), AccessInfo.Packed)});
+} else {
+  if (Exp == 0)
+IRB.CreateCall(AsanMemoryAccessCallback[IsWrite][0][AccessSizeIndex],
+   AddrLong);
+  else
+IRB.CreateCall(AsanMemoryAccessCallback[IsWrite][1][AccessSizeIndex],
+   {AddrLong, ConstantInt::get(IRB.getInt32Ty(), Exp)});
+}
 return;
   }
 
___
cfe-commits mailing list

[PATCH] D108584: [clangd] Use the active file's language for hover code blocks

2021-08-24 Thread David Goldman via Phabricator via cfe-commits
dgoldman added a comment.

In D108584#2962271 , @sammccall wrote:

>> Likely will send a follow up diff to include more context in the Objective-C 
>> decl printing so they highlight properly.
>
> This might make sense if it provides useful context to human readers without 
> too much syntactic weight.
> However if the issue is that particular editors are mis-highlighting snippets 
> of ObjC, that's probably rather bugs to file against those editors (or maybe 
> reasons to drop the language and fall back to regular highlighting)

Right, we're just missing the decl context (since objc decls must be in a top 
level container)

e.g. currently we have:

  // In AppDelegate()
  @property(nonatomic, assign, unsafe_unretained, readwrite) NSInteger version;

instead we could show

  @interface AppDelegate()
  @property(nonatomic, assign, unsafe_unretained, readwrite) NSInteger version;
  @end


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108584

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


[PATCH] D99732: [AST] Pick last tentative definition as the acting definition

2021-08-24 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

This breaks tests on macOS: http://45.33.8.238/macm1/16663/step_7.txt

Please to a look. Just adding a -triple flag is probably sufficient.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99732

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


[PATCH] D42225: libcxx: Provide overloads for basic_filebuf::open() et al that take wchar_t* filenames on Windows.

2021-08-24 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added subscribers: mstorsjo, ldionne.
ldionne added a comment.
Herald added a subscriber: libcxx-commits.

@pcc @mstorsjo Are we aware of anyone using these extensions?

I would like to suggest that we either remove this extension if it's not 
useful, or make it unconditional (not only on Windows) if we really think it's 
that useful (but I'd like that to come with at least a paper proposing to add 
them to the standard). Carrying around an extension that's only enabled on one 
platform (and not the most widely used platform for libc++ at that) is kind of 
awkward.

WDYT?


Repository:
  rCXX libc++

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

https://reviews.llvm.org/D42225

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


[PATCH] D69560: [clang-tidy] Add 'bugprone-easily-swappable-parameters' check

2021-08-24 Thread Whisperity via Phabricator via cfe-commits
whisperity marked 3 inline comments as done.
whisperity added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp:57
+   "Const_Reverse_Iterator",
+   "const_reverse_iterator"
+   "Constreverseiterator",

RKSimon wrote:
> @whisperity There is a missing comma at the end of the 
> "const_reverse_iterator" line causing implicit concatenation with the 
> following "Constreverseiterator" line.
Thanks... I'll get around to hotfixing this ASAP, and hope it can be backported 
to //13.0//...

(I wish there was a checker for this? )


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69560

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


[clang-tools-extra] 8d50a84 - [clang-tidy] Hotfix default parameter value in 'bugprone-easily-swappable-parameters'

2021-08-24 Thread via cfe-commits

Author: Whisperity
Date: 2021-08-24T16:10:19+02:00
New Revision: 8d50a847d410295a9fca466d38a261cca4c2302b

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

LOG: [clang-tidy] Hotfix default parameter value in 
'bugprone-easily-swappable-parameters'

As identified by @RKSimon, there was a missing comma in the default
value for the "ignored parameter type suffixes" array, resulting in
bogus concatenation of two elements.

Added: 


Modified: 
clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
index e4500706b4b2..16ede76af6ab 100644
--- a/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
@@ -56,7 +56,7 @@ static const std::string DefaultIgnoredParameterTypeSuffixes =
"reverse_const_iterator",
"ConstReverseIterator",
"Const_Reverse_Iterator",
-   "const_reverse_iterator"
+   "const_reverse_iterator",
"Constreverseiterator",
"constreverseiterator"});
 



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


[PATCH] D99732: [AST] Pick last tentative definition as the acting definition

2021-08-24 Thread Benson Chu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9a5f38885056: [AST] Pick last tentative definition as the 
acting definition (authored by pestctrl).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99732

Files:
  clang/lib/AST/Decl.cpp
  clang/test/CodeGen/attr-tentative-definition.c


Index: clang/test/CodeGen/attr-tentative-definition.c
===
--- /dev/null
+++ clang/test/CodeGen/attr-tentative-definition.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -emit-llvm < %s | FileCheck %s
+
+char arr[10];
+char arr[10] __attribute__((section("datadata")));
+char arr[10] __attribute__((aligned(16)));
+
+// CHECK: @arr ={{.*}}section "datadata", align 16
Index: clang/lib/AST/Decl.cpp
===
--- clang/lib/AST/Decl.cpp
+++ clang/lib/AST/Decl.cpp
@@ -2216,14 +2216,18 @@
 return nullptr;
 
   VarDecl *LastTentative = nullptr;
-  VarDecl *First = getFirstDecl();
-  for (auto I : First->redecls()) {
-Kind = I->isThisDeclarationADefinition();
+
+  // Loop through the declaration chain, starting with the most recent.
+  for (VarDecl *Decl = getMostRecentDecl(); Decl;
+   Decl = Decl->getPreviousDecl()) {
+Kind = Decl->isThisDeclarationADefinition();
 if (Kind == Definition)
   return nullptr;
-if (Kind == TentativeDefinition)
-  LastTentative = I;
+// Record the first (most recent) TentativeDefinition that is encountered.
+if (Kind == TentativeDefinition && !LastTentative)
+  LastTentative = Decl;
   }
+
   return LastTentative;
 }
 


Index: clang/test/CodeGen/attr-tentative-definition.c
===
--- /dev/null
+++ clang/test/CodeGen/attr-tentative-definition.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -emit-llvm < %s | FileCheck %s
+
+char arr[10];
+char arr[10] __attribute__((section("datadata")));
+char arr[10] __attribute__((aligned(16)));
+
+// CHECK: @arr ={{.*}}section "datadata", align 16
Index: clang/lib/AST/Decl.cpp
===
--- clang/lib/AST/Decl.cpp
+++ clang/lib/AST/Decl.cpp
@@ -2216,14 +2216,18 @@
 return nullptr;
 
   VarDecl *LastTentative = nullptr;
-  VarDecl *First = getFirstDecl();
-  for (auto I : First->redecls()) {
-Kind = I->isThisDeclarationADefinition();
+
+  // Loop through the declaration chain, starting with the most recent.
+  for (VarDecl *Decl = getMostRecentDecl(); Decl;
+   Decl = Decl->getPreviousDecl()) {
+Kind = Decl->isThisDeclarationADefinition();
 if (Kind == Definition)
   return nullptr;
-if (Kind == TentativeDefinition)
-  LastTentative = I;
+// Record the first (most recent) TentativeDefinition that is encountered.
+if (Kind == TentativeDefinition && !LastTentative)
+  LastTentative = Decl;
   }
+
   return LastTentative;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 9a5f388 - [AST] Pick last tentative definition as the acting definition

2021-08-24 Thread Benson Chu via cfe-commits

Author: Benson Chu
Date: 2021-08-24T08:51:50-05:00
New Revision: 9a5f3888505630cea88f8372d3068b2d63cfb381

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

LOG: [AST] Pick last tentative definition as the acting definition

Clang currently picks the second tentative definition when
VarDecl::getActingDefinition is called.

This can lead to attributes being dropped if they are attached to
tentative definitions that appear after the second one. This is
because VarDecl::getActingDefinition loops through VarDecl::redecls
assuming that the last tentative definition is the last element in the
iterator. However, it is the second element that would be the last
tentative definition.

This changeset modifies getActingDefinition to iterate through the
declaration chain in reverse, so that it can immediately return when
it encounters a tentative definition.

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

Added: 
clang/test/CodeGen/attr-tentative-definition.c

Modified: 
clang/lib/AST/Decl.cpp

Removed: 




diff  --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index aa9fba519642..835e28c0bc9f 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -2216,14 +2216,18 @@ VarDecl *VarDecl::getActingDefinition() {
 return nullptr;
 
   VarDecl *LastTentative = nullptr;
-  VarDecl *First = getFirstDecl();
-  for (auto I : First->redecls()) {
-Kind = I->isThisDeclarationADefinition();
+
+  // Loop through the declaration chain, starting with the most recent.
+  for (VarDecl *Decl = getMostRecentDecl(); Decl;
+   Decl = Decl->getPreviousDecl()) {
+Kind = Decl->isThisDeclarationADefinition();
 if (Kind == Definition)
   return nullptr;
-if (Kind == TentativeDefinition)
-  LastTentative = I;
+// Record the first (most recent) TentativeDefinition that is encountered.
+if (Kind == TentativeDefinition && !LastTentative)
+  LastTentative = Decl;
   }
+
   return LastTentative;
 }
 

diff  --git a/clang/test/CodeGen/attr-tentative-definition.c 
b/clang/test/CodeGen/attr-tentative-definition.c
new file mode 100644
index ..7405e8079b22
--- /dev/null
+++ b/clang/test/CodeGen/attr-tentative-definition.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -emit-llvm < %s | FileCheck %s
+
+char arr[10];
+char arr[10] __attribute__((section("datadata")));
+char arr[10] __attribute__((aligned(16)));
+
+// CHECK: @arr ={{.*}}section "datadata", align 16



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


[PATCH] D108625: [Test][Time profiler] Fix test time checking

2021-08-24 Thread Anton Afanasyev via Phabricator via cfe-commits
anton-afanasyev created this revision.
anton-afanasyev added reviewers: broadwaylamb, russell.gallop.
anton-afanasyev requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This test sometimes triggers failures during build testing. For instance, see:
https://lab.llvm.org/buildbot/#/builders/52/builds/10161, details: 
https://lab.llvm.org/buildbot/#/builders/52/builds/10161/steps/5/logs/FAIL__Clang__check-time-trace-sections_cpp
 .
AFAICT the time between driver calling and checking its time tracker output
is not guaranteed to be stable and small:

  > head -2 check-time-trace-sections.cpp
  // RUN: %clangxx -S -ftime-trace -ftime-trace-granularity=0 -o 
%T/check-time-trace-sections %s
  // RUN: cat %T/check-time-trace-sections.json | %python 
%S/check-time-trace-sections.py
  > clang -S -ftime-trace -ftime-trace-granularity=0 -o /tmp/check 
check-time-trace-sections.cpp
  > cat /tmp/check.json | python check-time-trace-sections.py
  > sleep 10
  > cat /tmp/check.json | python check-time-trace-sections.py
  'beginningOfTime' should represent the absolute time when the process has 
started
  >

One can change "10 sec" value to something longer, but I believe
it's enough just to check that `beginningOfTime` exists and is
not later than current time.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108625

Files:
  clang/test/Driver/check-time-trace-sections.py


Index: clang/test/Driver/check-time-trace-sections.py
===
--- clang/test/Driver/check-time-trace-sections.py
+++ clang/test/Driver/check-time-trace-sections.py
@@ -20,10 +20,8 @@
 beginning_of_time = log_contents["beginningOfTime"] / 100
 seconds_since_epoch = time.time()
 
-# Make sure that the 'beginningOfTime' is not earlier than 10 seconds ago
-# and not later than now.
-if beginning_of_time > seconds_since_epoch or \
-seconds_since_epoch - beginning_of_time > 10:
+# Make sure that the 'beginningOfTime' is not later than now.
+if beginning_of_time > seconds_since_epoch:
 sys.exit("'beginningOfTime' should represent the absolute time when the "
  "process has started")
 


Index: clang/test/Driver/check-time-trace-sections.py
===
--- clang/test/Driver/check-time-trace-sections.py
+++ clang/test/Driver/check-time-trace-sections.py
@@ -20,10 +20,8 @@
 beginning_of_time = log_contents["beginningOfTime"] / 100
 seconds_since_epoch = time.time()
 
-# Make sure that the 'beginningOfTime' is not earlier than 10 seconds ago
-# and not later than now.
-if beginning_of_time > seconds_since_epoch or \
-seconds_since_epoch - beginning_of_time > 10:
+# Make sure that the 'beginningOfTime' is not later than now.
+if beginning_of_time > seconds_since_epoch:
 sys.exit("'beginningOfTime' should represent the absolute time when the "
  "process has started")
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D108584: [clangd] Use the active file's language for hover code blocks

2021-08-24 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

> Likely will send a follow up diff to include more context in the Objective-C 
> decl printing so they highlight properly.

This might make sense if it provides useful context to human readers without 
too much syntactic weight.
However if the issue is that particular editors are mis-highlighting snippets 
of ObjC, that's probably rather bugs to file against those editors (or maybe 
reasons to drop the language and fall back to regular highlighting)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108584

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


[PATCH] D108624: [Clang][RISCV] Implement getConstraintRegister for RISC-V

2021-08-24 Thread Luís Marques via Phabricator via cfe-commits
luismarques added inline comments.



Comment at: clang/test/Sema/inline-asm-validate-riscv.c:27-28
+  register long x10 asm("x10");
+  asm volatile("" :: "r"(x10) : "x10"); // expected-error {{conflicts with asm 
clobber list}}
+  asm volatile("" :: "r"(x10) : "a0"); // expected-error {{conflicts with asm 
clobber list}}
+  asm volatile("" : "=r"(x10) :: "x10"); // expected-error {{conflicts with 
asm clobber list}}

I don't really understand the point of erroring-out in these two cases where 
the register is an input and is also clobbered. In fact, I've run into a case 
where that would be useful and accurately reflected the situation. But GCC's 
documentation explicitly prohibits that. I'm not sure if there's a fundamental 
reason for that, or if it's just an implementation quirk.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108624

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


Re: [llvm-dev] Phabricator Creator Pulling the Plug

2021-08-24 Thread Aaron Ballman via cfe-commits
On Tue, Aug 24, 2021 at 8:18 AM Renato Golin  wrote:
>
> On Tue, 24 Aug 2021 at 12:49, Aaron Ballman  wrote:
>>
>> > A minor issue is that the messages Gerrit sends to Github are a bit 
>> > pointless "Message from PersonA: (1 comment)". It would be better if the 
>> > integration either works (like adding comments to a specific line or 
>> > updating the commits) or not pollute.
>>
>> Also, the Gerrit review process uses a different workflow than the
>> Phabricator review process, and we should make sure we're comfortable
>> with that. My uses of Gerrit (which have been purely corporate in
>> nature, so my experience may be with an older version of the tool)
>> have run into some pretty big usability concerns -- like the fact that
>> it only shows you the diff contents of one file at a time, lacks the
>> ability to "stack" related patches, comments are easier to lose track
>> of when updating a review, there's no way to mark comments as "done"
>> or not, etc.
>
>
> Right, my comment was about the integration, not Gerrit vs Phab vs Github.

Ah, apologies!

> Whatever integrates with Github should be more succinct, clearer and re-use 
> Github's ID.

+1, that would be great.

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


[PATCH] D108624: [Clang][RISCV] Implement getConstraintRegister for RISC-V

2021-08-24 Thread Luís Marques via Phabricator via cfe-commits
luismarques updated this revision to Diff 368323.
luismarques added a comment.

Nit: remove nop.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108624

Files:
  clang/lib/Basic/Targets/RISCV.h
  clang/test/Sema/inline-asm-validate-riscv.c


Index: clang/test/Sema/inline-asm-validate-riscv.c
===
--- clang/test/Sema/inline-asm-validate-riscv.c
+++ clang/test/Sema/inline-asm-validate-riscv.c
@@ -21,3 +21,11 @@
   asm volatile ("" :: "K"(BelowMin)); // expected-error{{value '-1' out of 
range for constraint 'K'}}
   asm volatile ("" :: "K"(AboveMax)); // expected-error{{value '32' out of 
range for constraint 'K'}}
 }
+
+void test_clobber_conflict(void) {
+  register long x10 asm("x10");
+  asm volatile("" :: "r"(x10) : "x10"); // expected-error {{conflicts with asm 
clobber list}}
+  asm volatile("" :: "r"(x10) : "a0"); // expected-error {{conflicts with asm 
clobber list}}
+  asm volatile("" : "=r"(x10) :: "x10"); // expected-error {{conflicts with 
asm clobber list}}
+  asm volatile("" : "=r"(x10) :: "a0"); // expected-error {{conflicts with asm 
clobber list}}
+}
Index: clang/lib/Basic/Targets/RISCV.h
===
--- clang/lib/Basic/Targets/RISCV.h
+++ clang/lib/Basic/Targets/RISCV.h
@@ -82,6 +82,11 @@
 
   const char *getClobbers() const override { return ""; }
 
+  StringRef getConstraintRegister(StringRef Constraint,
+  StringRef Expression) const override {
+return Expression;
+  }
+
   ArrayRef getGCCRegNames() const override;
 
   int getEHDataRegisterNumber(unsigned RegNo) const override {


Index: clang/test/Sema/inline-asm-validate-riscv.c
===
--- clang/test/Sema/inline-asm-validate-riscv.c
+++ clang/test/Sema/inline-asm-validate-riscv.c
@@ -21,3 +21,11 @@
   asm volatile ("" :: "K"(BelowMin)); // expected-error{{value '-1' out of range for constraint 'K'}}
   asm volatile ("" :: "K"(AboveMax)); // expected-error{{value '32' out of range for constraint 'K'}}
 }
+
+void test_clobber_conflict(void) {
+  register long x10 asm("x10");
+  asm volatile("" :: "r"(x10) : "x10"); // expected-error {{conflicts with asm clobber list}}
+  asm volatile("" :: "r"(x10) : "a0"); // expected-error {{conflicts with asm clobber list}}
+  asm volatile("" : "=r"(x10) :: "x10"); // expected-error {{conflicts with asm clobber list}}
+  asm volatile("" : "=r"(x10) :: "a0"); // expected-error {{conflicts with asm clobber list}}
+}
Index: clang/lib/Basic/Targets/RISCV.h
===
--- clang/lib/Basic/Targets/RISCV.h
+++ clang/lib/Basic/Targets/RISCV.h
@@ -82,6 +82,11 @@
 
   const char *getClobbers() const override { return ""; }
 
+  StringRef getConstraintRegister(StringRef Constraint,
+  StringRef Expression) const override {
+return Expression;
+  }
+
   ArrayRef getGCCRegNames() const override;
 
   int getEHDataRegisterNumber(unsigned RegNo) const override {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >