[clang] 0826a56 - [NFC] make ASTContext:isSame* methods const

2022-07-06 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2022-07-07T13:34:15+08:00
New Revision: 0826a5617885bef2559c8213ec52685786ff0506

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

LOG: [NFC] make ASTContext:isSame* methods const

Added: 


Modified: 
clang/include/clang/AST/ASTContext.h
clang/lib/AST/ASTContext.cpp

Removed: 




diff  --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 7db6af9cb87d..92293622cc3d 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -260,7 +260,7 @@ class ASTContext : public RefCountedBase {
   mutable llvm::FoldingSet
 DeducedTemplateSpecializationTypes;
   mutable llvm::FoldingSet AtomicTypes;
-  llvm::FoldingSet AttributedTypes;
+  mutable llvm::FoldingSet AttributedTypes;
   mutable llvm::FoldingSet PipeTypes;
   mutable llvm::FoldingSet BitIntTypes;
   mutable llvm::FoldingSet DependentBitIntTypes;
@@ -1306,11 +1306,11 @@ class ASTContext : public RefCountedBase {
   /// declaration of a function with an exception specification is permitted
   /// and preserved. Other type sugar (for instance, typedefs) is not.
   QualType getFunctionTypeWithExceptionSpec(
-  QualType Orig, const FunctionProtoType::ExceptionSpecInfo );
+  QualType Orig, const FunctionProtoType::ExceptionSpecInfo ) const;
 
   /// Determine whether two function types are the same, ignoring
   /// exception specifications in cases where they're part of the type.
-  bool hasSameFunctionTypeIgnoringExceptionSpec(QualType T, QualType U);
+  bool hasSameFunctionTypeIgnoringExceptionSpec(QualType T, QualType U) const;
 
   /// Change the exception specification on a function once it is
   /// delay-parsed, instantiated, or computed.
@@ -1597,9 +1597,8 @@ class ASTContext : public RefCountedBase {
 
   QualType getInjectedClassNameType(CXXRecordDecl *Decl, QualType TST) const;
 
-  QualType getAttributedType(attr::Kind attrKind,
- QualType modifiedType,
- QualType equivalentType);
+  QualType getAttributedType(attr::Kind attrKind, QualType modifiedType,
+ QualType equivalentType) const;
 
   QualType getBTFTagAttributedType(const BTFTypeTagAttr *BTFAttr,
QualType Wrapped);
@@ -2654,25 +2653,16 @@ class ASTContext : public RefCountedBase {
   bool hasSameTemplateName(const TemplateName , const TemplateName ) const;
 
   /// Determine whether the two declarations refer to the same entity.
-  ///
-  /// FIXME: isSameEntity is not const due to its implementation calls
-  /// hasSameFunctionTypeIgnoringExceptionSpec which may alter this.
-  bool isSameEntity(const NamedDecl *X, const NamedDecl *Y);
+  bool isSameEntity(const NamedDecl *X, const NamedDecl *Y) const;
 
   /// Determine whether two template parameter lists are similar enough
   /// that they may be used in declarations of the same template.
-  ///
-  /// FIXME: isSameTemplateParameterList is not const since it calls
-  /// isSameTemplateParameter.
   bool isSameTemplateParameterList(const TemplateParameterList *X,
-   const TemplateParameterList *Y);
+   const TemplateParameterList *Y) const;
 
   /// Determine whether two template parameters are similar enough
   /// that they may be used in declarations of the same template.
-  ///
-  /// FIXME: isSameTemplateParameterList is not const since it calls
-  /// isSameEntity.
-  bool isSameTemplateParameter(const NamedDecl *X, const NamedDecl *Y);
+  bool isSameTemplateParameter(const NamedDecl *X, const NamedDecl *Y) const;
 
   /// Retrieve the "canonical" template argument.
   ///

diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index e64135cbf3f4..aced0ab39ace 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -3166,7 +3166,7 @@ void 
ASTContext::adjustDeducedFunctionResultType(FunctionDecl *FD,
 /// declaration of a function with an exception specification is permitted
 /// and preserved. Other type sugar (for instance, typedefs) is not.
 QualType ASTContext::getFunctionTypeWithExceptionSpec(
-QualType Orig, const FunctionProtoType::ExceptionSpecInfo ) {
+QualType Orig, const FunctionProtoType::ExceptionSpecInfo ) const {
   // Might have some parens.
   if (const auto *PT = dyn_cast(Orig))
 return getParenType(
@@ -3194,7 +3194,7 @@ QualType ASTContext::getFunctionTypeWithExceptionSpec(
 }
 
 bool ASTContext::hasSameFunctionTypeIgnoringExceptionSpec(QualType T,
-  QualType U) {
+  QualType U) const {
   return hasSameType(T, U) ||
  

[PATCH] D128921: [Sema] Merge C++20 concept definitions from different modules in same TU

2022-07-06 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added inline comments.



Comment at: clang/lib/Sema/SemaTemplate.cpp:8679
+  Previous.isSingleResult() ? Previous.getAsSingle() : 
nullptr;
+  if (PrevDef && !hasVisibleDefinition(PrevDef) &&
+  Context.isSameEntity(NewDecl, PrevDef)) {

rsmith wrote:
> ChuanqiXu wrote:
> > 
> I don't think that's right: [the C++20 modules 
> rule](http://eel.is/c++draft/basic.def.odr#2) is that at most one definition 
> is permitted per translation unit, and the Clang header modules rule is that 
> a definition is only permissible if no definition is visible (Clang header 
> modules effectively behave as if they're part of the same translation unit 
> for the purposes of this check). For now, checking for a visible definition 
> seems better than checking for a reachable one, until we implement the C++20 
> rule in general.
For clang modules, the reachability should be the visibility: 
https://github.com/llvm/llvm-project/blob/9cb00e7133ea3da6a49ade95e3708240c2aaae39/clang/lib/Sema/SemaLookup.cpp#L1903-L1905.
 So I think it is better to check for a reachable definition here. Otherwise we 
might not be able to handle the following case:
```
import M;
export template 
concept ConflictingConcept = true; // There is another reachable but not 
visible definition for ConflictingConcept.
```



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128921

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


[PATCH] D129174: [C++20][Modules] Invalidate internal-linkage functions in overload sets [P1815R2 part 1]

2022-07-06 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added inline comments.



Comment at: clang/lib/Sema/SemaOverload.cpp:6406
+if (Function->getFormalLinkage() <= Linkage::InternalLinkage &&
+getLangOpts().CPlusPlus20 && MF != getCurrentModule()) {
+  Candidate.Viable = false;

iains wrote:
> iains wrote:
> > ChuanqiXu wrote:
> > > The current implementation may reject following two cases:
> > > ```
> > > module;
> > > static void foo(int); // Ignore header
> > > ...
> > > export module A;
> > > void bar() { foo(5); } // Should it be invalid?
> > > ```
> > > and
> > > ```
> > > export module A;
> > > static void foo(int);
> > > ...
> > > module :private;
> > > void bar() { foo(5); } // Should it be invalid?
> > > ```
> > > 
> > > I mean in the above examples, the function of `foo(int)` is defined in 
> > > the same TU but the call to it might be rejected.
> > > The current implementation may reject following two cases:
> > > ```
> > > module;
> > > static void foo(int); // Ignore header
> > > ...
> > > export module A;
> > > void bar() { foo(5); } // Should it be invalid?
> > > ```
> > > and
> > > ```
> > > export module A;
> > > static void foo(int);
> > > ...
> > > module :private;
> > > void bar() { foo(5); } // Should it be invalid?
> > > ```
> > > 
> > > I mean in the above examples, the function of `foo(int)` is defined in 
> > > the same TU but the call to it might be rejected.
> > 
> > 
> > The current implementation may reject following two cases:
> > ```
> > module;
> > static void foo(int); // Ignore header
> > ...
> 
> Actually, I have a note to check on the global module case, since we have 
> special rules that allow merging of items there,
> 
> 
> > export module A;
> > void bar() { foo(5); } // Should it be invalid?
> > ```
> > and
> > ```
> > export module A;
> > static void foo(int);
> > ...
> > module :private;
> > void bar() { foo(5); } // Should it be invalid?
> > ```
> > 
> > I mean in the above examples, the function of `foo(int)` is defined in the 
> > same TU but the call to it might be rejected.
> 
> otherwise, agreed, these cases should be ok -  I guess we need a second test 
> case with lookups that should succeed.
> 
> Actually, I have a note to check on the global module case, since we have 
> special rules that allow merging of items there,

Yeah, it is surprising that we couldn't handle the global module fragment case.



Comment at: 
clang/test/CXX/basic/basic.lookup/basic.lookup.argdep/p5-ex2.cpp:36-41
+//--- Q.cpp
+export module Q;
+
+//--- Q-impl.cpp
+module Q;
+import N;

iains wrote:
> ChuanqiXu wrote:
> > This looks more consistent with the example.
> This changes the example so that M is directly included in the implementation 
> rather than transitively (the example does specifically use a different 
> module name for the implementation)
> 
> I am not sure what you mean by "more consistent"
>  (the example will fail to reject some of the lookups with this change).
> 
> 
> 
Oh, I didn't notice it uses a different module name. My bad.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129174

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


[PATCH] D129100: [clangd] Support external throttler for preamble builds

2022-07-06 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

This looks flaky https://lab.llvm.org/buildbot/#/builders/5/builds/25929


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129100

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


[PATCH] D125095: [Clang][AIX] Add .ref in frontend for AIX XCOFF to support `-bcdtors:csect` linker option

2022-07-06 Thread Ting Wang via Phabricator via cfe-commits
tingwang updated this revision to Diff 442773.
tingwang added a comment.

Drop TLS related .ref for now


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125095

Files:
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CGDeclCXX.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/test/CodeGen/PowerPC/aix-init-ref-null.cpp
  clang/test/CodeGen/PowerPC/aix-ref-static-var.cpp
  clang/test/CodeGenCXX/aix-static-init-debug-info.cpp
  clang/test/CodeGenCXX/aix-static-init-temp-spec-and-inline-var.cpp
  clang/test/CodeGenCXX/aix-static-init.cpp
  llvm/docs/LangRef.rst

Index: llvm/docs/LangRef.rst
===
--- llvm/docs/LangRef.rst
+++ llvm/docs/LangRef.rst
@@ -7091,6 +7091,10 @@
 @b = internal global i32 2, comdat $a, section "abc", !associated !0
 !0 = !{i32* @a}
 
+On XCOFF target, the ``associated`` metadata indicates connection among static
+variables (static global variable, static class member etc.) and static init/
+term functions. This metadata lowers to ``.ref`` assembler pseudo-operation
+which prevents discarding of the functions in linker GC.
 
 '``prof``' Metadata
 ^^^
Index: clang/test/CodeGenCXX/aix-static-init.cpp
===
--- clang/test/CodeGenCXX/aix-static-init.cpp
+++ clang/test/CodeGenCXX/aix-static-init.cpp
@@ -38,6 +38,10 @@
   }
 } // namespace test4
 
+// CHECK: @_ZN5test12t1E = global %"struct.test1::Test1" zeroinitializer, align {{[0-9]+}}, !associated ![[ASSOC0:[0-9]+]]
+// CHECK: @_ZN5test12t2E = global %"struct.test1::Test1" zeroinitializer, align {{[0-9]+}}, !associated ![[ASSOC0:[0-9]+]]
+// CHECK: @_ZN5test21xE = global i32 0, align {{[0-9]+}}, !associated ![[ASSOC1:[0-9]+]]
+// CHECK: @_ZN5test31tE = global %"struct.test3::Test3" undef, align {{[0-9]+}}, !associated ![[ASSOC0:[0-9]+]]
 // CHECK: @_ZGVZN5test41fEvE11staticLocal = internal global i64 0, align 8
 // CHECK: @llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__sub_I__, i8* null }]
 // CHECK: @llvm.global_dtors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__D_a, i8* null }]
@@ -49,7 +53,7 @@
 // CHECK:   ret void
 // CHECK: }
 
-// CHECK: define internal void @__dtor__ZN5test12t1E() [[ATTR:#[0-9]+]] {
+// CHECK: define internal void @__dtor__ZN5test12t1E() [[ATTR:#[0-9]+]] !associated ![[ASSOC2:[0-9]+]] {
 // CHECK: entry:
 // CHECK:   call void @_ZN5test15Test1D1Ev(%"struct.test1::Test1"* @_ZN5test12t1E)
 // CHECK:   ret void
@@ -80,7 +84,7 @@
 // CHECK:   ret void
 // CHECK: }
 
-// CHECK: define internal void @__dtor__ZN5test12t2E() [[ATTR:#[0-9]+]] {
+// CHECK: define internal void @__dtor__ZN5test12t2E() [[ATTR:#[0-9]+]] !associated ![[ASSOC2:[0-9]+]] {
 // CHECK: entry:
 // CHECK:   call void @_ZN5test15Test1D1Ev(%"struct.test1::Test1"* @_ZN5test12t2E)
 // CHECK:   ret void
@@ -114,7 +118,7 @@
 // CHECK:   ret void
 // CHECK: }
 
-// CHECK: define internal void @__dtor__ZN5test31tE() [[ATTR:#[0-9]+]] {
+// CHECK: define internal void @__dtor__ZN5test31tE() [[ATTR:#[0-9]+]] !associated ![[ASSOC2:[0-9]+]] {
 // CHECK: entry:
 // CHECK:   call void @_ZN5test35Test3D1Ev(%"struct.test3::Test3"* @_ZN5test31tE)
 // CHECK:   ret void
@@ -155,7 +159,7 @@
 // CHECK:   ret void
 // CHECK: }
 
-// CHECK: define internal void @__dtor__ZZN5test41fEvE11staticLocal() [[ATTR:#[0-9]+]] {
+// CHECK: define internal void @__dtor__ZZN5test41fEvE11staticLocal() [[ATTR:#[0-9]+]] !associated ![[ASSOC2:[0-9]+]] {
 // CHECK: entry:
 // CHECK:   call void @_ZN5test45Test4D1Ev(%"struct.test4::Test4"* @_ZZN5test41fEvE11staticLocal)
 // CHECK:   ret void
@@ -192,3 +196,7 @@
 // CHECK:   call void @__finalize__ZN5test12t1E()
 // CHECK:   ret void
 // CHECK: }
+
+// CHECK: ![[ASSOC0]] = !{void ()* @{{_GLOBAL__sub_I__|_GLOBAL__D_a}}, void ()* @{{_GLOBAL__sub_I__|_GLOBAL__D_a}}}
+// CHECK: ![[ASSOC1]] = !{void ()* @_GLOBAL__sub_I__}
+// CHECK: ![[ASSOC2]] = !{void ()* @_GLOBAL__D_a}
Index: clang/test/CodeGenCXX/aix-static-init-temp-spec-and-inline-var.cpp
===
--- clang/test/CodeGenCXX/aix-static-init-temp-spec-and-inline-var.cpp
+++ clang/test/CodeGenCXX/aix-static-init-temp-spec-and-inline-var.cpp
@@ -44,8 +44,13 @@
 A A::instance = bar();
 } // namespace test2
 
+// CHECK: @_ZN5test12t0E = global %"struct.test1::Test1" zeroinitializer, align {{[0-9]+}}, !associated ![[ASSOC0:[0-9]+]]
+// CHECK: @_ZN5test12t2E = linkonce_odr global %"struct.test1::Test1" zeroinitializer, align {{[0-9]+}}, !associated ![[ASSOC1:[0-9]+]]
 // CHECK: @_ZGVN5test12t2E = linkonce_odr global i64 0, align 8
+// CHECK: @_ZN5test12t1IiEE = linkonce_odr global %"struct.test1::Test1" 

[PATCH] D129138: [clang] [docs] Update the changes of C++20 Modules in clang15

2022-07-06 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu marked an inline comment as done.
ChuanqiXu added a comment.

In D129138#3632128 , @iains wrote:

> I would not expect to add all this information to the release notes, or any 
> of the phab links - just single lines to say that paper numbers are 
> implemented
>
> - the details are just to help us track the situation up to 26th July.

Got it. Thanks!




Comment at: clang/docs/ReleaseNotes.rst:472-476
+- Implemented `P1103R3: Merging Modules `_.
+- Implemented `P1779R3: ABI isolation for member functions 
`_.
+- Implemented `P1874R1: Dynamic Initialization Order of Non-Local Variables in 
Modules `_.
+- Partially implemented `P1815R2: Translation-unit-local entities 
`_.
+

h-vetinari wrote:
> This should probably also be reflected in 
> https://clang.llvm.org/cxx_status.html / 
> https://github.com/llvm/llvm-project/blob/main/clang/www/cxx_status.html ...?
Done. Thanks!


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

https://reviews.llvm.org/D129138

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


[PATCH] D129138: [clang] [docs] Update the changes of C++20 Modules in clang15

2022-07-06 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu updated this revision to Diff 442761.
ChuanqiXu added a comment.

Update cxx_status.html


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

https://reviews.llvm.org/D129138

Files:
  clang/docs/ReleaseNotes.rst
  clang/www/cxx_status.html


Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1164,7 +1164,7 @@
 
   Modules
   https://wg21.link/p1103r3;>P1103R3
-  Partial
+  Clang 15
 

 https://wg21.link/p1766r1;>P1766R1 (DR)
@@ -1180,17 +1180,19 @@
   

 https://wg21.link/p1874r1;>P1874R1
-Partial
+Clang 15
   

 https://wg21.link/p1979r0;>P1979R0
-No
+No
   

 https://wg21.link/p1779r3;>P1779R3
+Clang 15
   
   
 https://wg21.link/p1857r3;>P1857R3
+No
   
   
 https://wg21.link/p2115r0;>P2115R0
@@ -1198,7 +1200,7 @@
   
   
 https://wg21.link/p1815r2;>P1815R2
-No
+Partial
   
 
   Coroutines
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -466,6 +466,14 @@
   that can be used for such compatibility. The demangler now demangles
   symbols with named module attachment.
 
+- Enhanced the support for C++20 Modules, including: Partitions,
+  Reachability, Header Unit and ``extern "C++"`` semantics.
+
+- Implemented `P1103R3: Merging Modules `_.
+- Implemented `P1779R3: ABI isolation for member functions 
`_.
+- Implemented `P1874R1: Dynamic Initialization Order of Non-Local Variables in 
Modules `_.
+- Partially implemented `P1815R2: Translation-unit-local entities 
`_.
+
 - As per "Conditionally Trivial Special Member Functions" (P0848), it is
   now possible to overload destructors using concepts. Note that the rest
   of the paper about other special member functions is not yet implemented.


Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1164,7 +1164,7 @@
 
   Modules
   https://wg21.link/p1103r3;>P1103R3
-  Partial
+  Clang 15
 

 https://wg21.link/p1766r1;>P1766R1 (DR)
@@ -1180,17 +1180,19 @@
   

 https://wg21.link/p1874r1;>P1874R1
-Partial
+Clang 15
   

 https://wg21.link/p1979r0;>P1979R0
-No
+No
   

 https://wg21.link/p1779r3;>P1779R3
+Clang 15
   
   
 https://wg21.link/p1857r3;>P1857R3
+No
   
   
 https://wg21.link/p2115r0;>P2115R0
@@ -1198,7 +1200,7 @@
   
   
 https://wg21.link/p1815r2;>P1815R2
-No
+Partial
   
 
   Coroutines
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -466,6 +466,14 @@
   that can be used for such compatibility. The demangler now demangles
   symbols with named module attachment.
 
+- Enhanced the support for C++20 Modules, including: Partitions,
+  Reachability, Header Unit and ``extern "C++"`` semantics.
+
+- Implemented `P1103R3: Merging Modules `_.
+- Implemented `P1779R3: ABI isolation for member functions `_.
+- Implemented `P1874R1: Dynamic Initialization Order of Non-Local Variables in Modules `_.
+- Partially implemented `P1815R2: Translation-unit-local entities `_.
+
 - As per "Conditionally Trivial Special Member Functions" (P0848), it is
   now possible to overload destructors using concepts. Note that the rest
   of the paper about other special member functions is not yet implemented.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D127643: [Static Analyzer] Structured bindings to data members

2022-07-06 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

In D127643#3595731 , @steakhal wrote:

> I missed this commit because it was not tagged by "[analyzer]".
> What is the community preference about tagging CSA commits?

I think [analyzer] is a good tag, no need to change anything. I also just set 
up my subscriptions by directories rather than by tags and I like how it works.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127643

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


[PATCH] D78038: [clangd] WIP: fix several bugs relating to include insertion

2022-07-06 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.
Herald added projects: LLVM, clang-tools-extra, All.
Herald added a subscriber: llvm-commits.

@sammccall should we get this patch landed? The issue of #ifndef-guarded header 
files that include each other recursively is still tripping up some users.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78038

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


[PATCH] D129149: [OMPIRBuilder] Add support for simdlen clause

2022-07-06 Thread Prabhdeep Soni via Phabricator via cfe-commits
psoni2628 updated this revision to Diff 442715.
psoni2628 marked 4 inline comments as done.
psoni2628 added a comment.
Herald added subscribers: bzcheeseman, awarzynski, sdasgup3, wenzhicui, wrengr, 
dcaballe, cota, teijeong, rdzhabarov, tatianashp, msifontes, jurahul, Kayjukh, 
grosul1, Joonsoo, stephenneuendorffer, liufengdb, aartbik, mgester, 
arpith-jacob, nicolasvasilache, antiagainst, shauheen, rriddle, mehdi_amini, 
arichardson.
Herald added a reviewer: ftynse.
Herald added a project: MLIR.

- Remove `applySimdlen` and apply simdlen in `applySimd`
- Remove unnecessary DebugLocation from `applySimd` in both OpenMPIRBuilder and 
Flang MLIR
- Add `llvm.access.group` to `llvm/utils/UpdateTestChecks/common.py`
- Fix test case by adding `--check-globals`


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

https://reviews.llvm.org/D129149

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/test/OpenMP/irbuilder_simd.cpp
  clang/test/OpenMP/irbuilder_simdlen.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
  llvm/utils/UpdateTestChecks/common.py
  mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp

Index: mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
===
--- mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
+++ mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
@@ -942,7 +942,7 @@
   llvm::CanonicalLoopInfo *loopInfo =
   ompBuilder->collapseLoops(ompLoc.DL, loopInfos, {});
 
-  ompBuilder->applySimd(ompLoc.DL, loopInfo);
+  ompBuilder->applySimd(loopInfo, nullptr);
 
   builder.restoreIP(afterIP);
   return success();
Index: llvm/utils/UpdateTestChecks/common.py
===
--- llvm/utils/UpdateTestChecks/common.py
+++ llvm/utils/UpdateTestChecks/common.py
@@ -719,18 +719,19 @@
 # Description of the different "unnamed" values we match in the IR, e.g.,
 # (local) ssa values, (debug) metadata, etc.
 ir_nameless_values = [
-NamelessValue(r'TMP'  , '%' , r'%'   , None, None   , r'[\w$.-]+?' , None , False) ,
-NamelessValue(r'ATTR' , '#' , r'#'   , None, None   , r'[0-9]+', None , False) ,
-NamelessValue(r'ATTR' , '#' , None   , r'attributes #' , r'[0-9]+'  , None , r'{[^}]*}'   , False) ,
-NamelessValue(r'GLOB' , '@' , r'@'   , None, None   , r'[0-9]+', None , False) ,
-NamelessValue(r'GLOB' , '@' , None   , r'@', r'[a-zA-Z0-9_$"\\.-]+' , None , r'.+', True)  ,
-NamelessValue(r'DBG'  , '!' , r'!dbg '   , None, None   , r'![0-9]+'   , None , False) ,
-NamelessValue(r'PROF' , '!' , r'!prof '  , None, None   , r'![0-9]+'   , None , False) ,
-NamelessValue(r'TBAA' , '!' , r'!tbaa '  , None, None   , r'![0-9]+'   , None , False) ,
-NamelessValue(r'RNG'  , '!' , r'!range ' , None, None   , r'![0-9]+'   , None , False) ,
-NamelessValue(r'LOOP' , '!' , r'!llvm.loop ' , None, None   , r'![0-9]+'   , None , False) ,
-NamelessValue(r'META' , '!' , r'metadata '   , None, None   , r'![0-9]+'   , None , False) ,
-NamelessValue(r'META' , '!' , None   , r'' , r'![0-9]+' , None , r'(?:distinct |)!.*' , False) ,
+NamelessValue(r'TMP' , '%' , r'%'   , None, None   , r'[\w$.-]+?' , None , False) ,
+NamelessValue(r'ATTR', '#' , r'#'   , None, None   , r'[0-9]+', None , False) ,
+NamelessValue(r'ATTR', '#' , None   , r'attributes #' , r'[0-9]+'  , None , r'{[^}]*}'   , False) ,
+NamelessValue(r'GLOB', '@' , r'@'   , None, None   , r'[0-9]+', None , False) ,
+NamelessValue(r'GLOB', '@' , None   , r'@', r'[a-zA-Z0-9_$"\\.-]+' , None , r'.+', True)  ,
+NamelessValue(r'DBG' , '!' , r'!dbg '   , None, None   , r'![0-9]+'   , None , False) ,
+NamelessValue(r'PROF', '!' , r'!prof '  , None, None   , r'![0-9]+'   , None , False) ,
+NamelessValue(r'TBAA', '!' , r'!tbaa ' 

[PATCH] D128750: [c++20] Implement P2113R0: Changes to the Partial Ordering of Constrained Functions

2022-07-06 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D128750#3627085 , @royjacobson 
wrote:

> Thanks for working on this! I like the approach, but two comments:

Thanks for the review.

> I would like more tests for the different forms of template argument 
> deduction. Some suggestions for things to test: template template arguments, 
> 'auto' in abbreviated function templates, argument packs, non-type template 
> parameters. We should at least test that we find the more constrained 
> function when the parameters are equal.

Sure, will do.

> I'm also a bit concerned that we're deviating from the standard here w.r.t. 
> to the 'reordering' checks for reversed candidates. I support this - I think 
> your version makes more sense than what the standard says to do here - but if 
> someone could check with the committee (I don't have reflector access myself) 
> that we're not breaking some important use case by doing it this way, I think 
> it's a good idea.

Yeah, I found it kinda hard to implement the `reordering` aspect efficiently. 
My understanding of the `reordering` aspect is for finding an intuitive order 
of template parameters that makes sense for the following constraints tie 
breaker. Hi @hubert.reinterpretcast, could you please shed some light on the 
intended implementation for https://eel.is/c++draft/temp.func.order#6.2.1.2? 
I'm a little hesitant to use an exhaustive approach to find the template 
parameter order for constraints comparison. Does using deducing order sound 
reason to you? Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128750

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


[PATCH] D128745: [Sema] fix trailing parameter pack handling for function template partial ordering

2022-07-06 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added inline comments.



Comment at: clang/lib/Sema/SemaTemplateDeduction.cpp:5184
 
-  // FIXME: This mimics what GCC implements, but doesn't match up with the
-  // proposed resolution for core issue 692. This area needs to be sorted out,

aaron.ballman wrote:
> aaron.ballman wrote:
> > We tend not to use top-level const on locals in the project as a matter of 
> > style.
> Does GCC still implement it this way?
> 
> One concern I have is that this will be an ABI breaking change, and I'm not 
> certain how disruptive it will be. If GCC already made that change, it may be 
> reasonable for us to also break it without having to add ABI tags or 
> something special. But if these changes diverge us from GCC, that may require 
> some extra effort to mitigate.
Unfortunately, GCC is still using the old/non-conforming behavior. 
https://clang.godbolt.org/z/5K4916W71. What is the usual way to mitigate this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128745

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


[PATCH] D128745: [Sema] fix trailing parameter pack handling for function template partial ordering

2022-07-06 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D128745#3632850 , @aaron.ballman 
wrote:

> Thank you for working on this! Can you please add more details to the patch 
> summary about the changes?

Thanks for taking a look.

This was intended to correctly implement 
https://eel.is/c++draft/temp.deduct.partial#11. The test case is from 
https://eel.is/c++draft/temp.func.order#example-4.

  If, after considering the above, function template F is at least as 
specialized as function template G and vice-versa, and if G has a trailing 
function parameter pack for which F does not have a corresponding parameter, 
and if F does not have a trailing function parameter pack, then F is more 
specialized than G.

It looks like this is not too far from implementing DR692. I'll go ahead and 
include the necessary change for fixing the `template parameter packs` case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128745

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


[PATCH] D125693: [DebugInfo] Support types, imports and static locals declared in a lexical block (3/5)

2022-07-06 Thread Ellis Hoag via Phabricator via cfe-commits
ellis added inline comments.



Comment at: llvm/test/Instrumentation/InstrProfiling/debug-info-correlate.ll:23
   call void @llvm.instrprof.increment(i8* getelementptr inbounds ([3 x i8], [3 
x i8]* @__profn_foo, i32 0, i32 0), i64 12345678, i32 2, i32 0)
-  ret void
+  ret void, !dbg !17
 }

krisb wrote:
> ellis wrote:
> > krisb wrote:
> > > ellis wrote:
> > > > I asked the same question in D113741, but why is this test changed?
> > > Normally, we emit function-local entities iff a parent function has 
> > > location information. This is done the same way for local variables, 
> > > labels, parameters, imported entities, and, //now,// for static locals as 
> > > well.
> > > Before this change static locals behaved more like global variables and 
> > > get emitted doesn't matter its parent function. This patch makes them 
> > > handled more like local variables.
> > > 
> > > I believe either the call or the 'ret' (or, likely, both) had had 
> > > DILocation attached originally, but it has been removed to simplify the 
> > > test.
> > I just checked and the `llvm.instrprof.increment` intrinsic does not have 
> > debug info attached. I think you're right that I removed debug info from 
> > the `ret` instruction to simplify the test.
> > 
> > This is a special case where a global and its debug info is synthesized.
> > https://github.com/llvm/llvm-project/blob/23c2bedfd93cfacc62009425c464e659a34e92e6/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp#L976-L1001
> > 
> > So I don't understand why this added debug info is necessary. Does the test 
> > fail otherwise?
> Right, the test would fail w/o the added DILocation, because `__profc_foo` 
> variable (which is function-local 'global' technically) would not be emitted. 
> With this patch we emit function-local entities if and only if the parent 
> function has LexicalScope defined (see createAndAddScopeChildren() and its 
> call from constructSubprogramScopeDIE()), otherwise we skip emitting all 
> function's children (including function-local 'globals').
Got it, thanks for explaining!

I'm ok with this because `llvm.instrprof.increment` should probably be next to 
some instruction with debug info.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125693

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


[PATCH] D129220: [clang] Cleanup ASTContext before output files in crash recovery for modules

2022-07-06 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir updated this revision to Diff 442706.
benlangmuir added a comment.

Updated per out-of-band feedback from @steven_wu :

- Added an assert to `clearOutputFiles` that the `ASTConsumer` is removed. 
Normally this would be done in `FrontendAction::EndSourceFile`.  This should 
help avoid regressions and also means it is covered by existing tests.
- Updated `FailureCleanup` in `FrontendAction::BeginSourceFile` to reset the 
`ASTConsumer`. This is needed due to the assertion, but I don't think it 
changes much in practice since there would also be no output files at this 
stage.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129220

Files:
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/FrontendAction.cpp


Index: clang/lib/Frontend/FrontendAction.cpp
===
--- clang/lib/Frontend/FrontendAction.cpp
+++ clang/lib/Frontend/FrontendAction.cpp
@@ -581,6 +581,7 @@
   auto FailureCleanup = llvm::make_scope_exit([&]() {
 if (HasBegunSourceFile)
   CI.getDiagnosticClient().EndSourceFile();
+CI.setASTConsumer(nullptr);
 CI.clearOutputFiles(/*EraseFiles=*/true);
 CI.getLangOpts().setCompilingModule(LangOptions::CMK_None);
 setCurrentInput(FrontendInputFile());
Index: clang/lib/Frontend/CompilerInstance.cpp
===
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -757,6 +757,8 @@
 // Output Files
 
 void CompilerInstance::clearOutputFiles(bool EraseFiles) {
+  // The ASTConsumer can own streams that write to the output files.
+  assert(!hasASTConsumer() && "ASTConsumer should be reset");
   // Ignore errors that occur when trying to discard the temp file.
   for (OutputFile  : OutputFiles) {
 if (EraseFiles) {
@@ -1235,8 +1237,7 @@
 
   // Execute the action to actually build the module in-place. Use a separate
   // thread so that we get a stack large enough.
-  llvm::CrashRecoveryContext CRC;
-  CRC.RunSafelyOnThread(
+  bool Crashed = !llvm::CrashRecoveryContext().RunSafelyOnThread(
   [&]() {
 GenerateModuleFromModuleMapAction Action;
 Instance.ExecuteAction(Action);
@@ -1249,9 +1250,15 @@
 diag::remark_module_build_done)
 << ModuleName;
 
-  // Delete any remaining temporary files related to Instance, in case the
-  // module generation thread crashed.
-  Instance.clearOutputFiles(/*EraseFiles=*/true);
+  if (Crashed) {
+// Clear the ASTConsumer if it hasn't been already, in case it owns streams
+// that must be closed before clearing output files.
+Instance.setSema(nullptr);
+Instance.setASTConsumer(nullptr);
+
+// Delete any remaining temporary files related to Instance.
+Instance.clearOutputFiles(/*EraseFiles=*/true);
+  }
 
   // If \p AllowPCMWithCompilerErrors is set return 'success' even if errors
   // occurred.


Index: clang/lib/Frontend/FrontendAction.cpp
===
--- clang/lib/Frontend/FrontendAction.cpp
+++ clang/lib/Frontend/FrontendAction.cpp
@@ -581,6 +581,7 @@
   auto FailureCleanup = llvm::make_scope_exit([&]() {
 if (HasBegunSourceFile)
   CI.getDiagnosticClient().EndSourceFile();
+CI.setASTConsumer(nullptr);
 CI.clearOutputFiles(/*EraseFiles=*/true);
 CI.getLangOpts().setCompilingModule(LangOptions::CMK_None);
 setCurrentInput(FrontendInputFile());
Index: clang/lib/Frontend/CompilerInstance.cpp
===
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -757,6 +757,8 @@
 // Output Files
 
 void CompilerInstance::clearOutputFiles(bool EraseFiles) {
+  // The ASTConsumer can own streams that write to the output files.
+  assert(!hasASTConsumer() && "ASTConsumer should be reset");
   // Ignore errors that occur when trying to discard the temp file.
   for (OutputFile  : OutputFiles) {
 if (EraseFiles) {
@@ -1235,8 +1237,7 @@
 
   // Execute the action to actually build the module in-place. Use a separate
   // thread so that we get a stack large enough.
-  llvm::CrashRecoveryContext CRC;
-  CRC.RunSafelyOnThread(
+  bool Crashed = !llvm::CrashRecoveryContext().RunSafelyOnThread(
   [&]() {
 GenerateModuleFromModuleMapAction Action;
 Instance.ExecuteAction(Action);
@@ -1249,9 +1250,15 @@
 diag::remark_module_build_done)
 << ModuleName;
 
-  // Delete any remaining temporary files related to Instance, in case the
-  // module generation thread crashed.
-  Instance.clearOutputFiles(/*EraseFiles=*/true);
+  if (Crashed) {
+// Clear the ASTConsumer if it hasn't been already, in case it owns streams
+// that must be closed before clearing output files.
+

[PATCH] D125693: [DebugInfo] Support types, imports and static locals declared in a lexical block (3/5)

2022-07-06 Thread Kristina Bessonova via Phabricator via cfe-commits
krisb added inline comments.



Comment at: llvm/test/Instrumentation/InstrProfiling/debug-info-correlate.ll:23
   call void @llvm.instrprof.increment(i8* getelementptr inbounds ([3 x i8], [3 
x i8]* @__profn_foo, i32 0, i32 0), i64 12345678, i32 2, i32 0)
-  ret void
+  ret void, !dbg !17
 }

ellis wrote:
> krisb wrote:
> > ellis wrote:
> > > I asked the same question in D113741, but why is this test changed?
> > Normally, we emit function-local entities iff a parent function has 
> > location information. This is done the same way for local variables, 
> > labels, parameters, imported entities, and, //now,// for static locals as 
> > well.
> > Before this change static locals behaved more like global variables and get 
> > emitted doesn't matter its parent function. This patch makes them handled 
> > more like local variables.
> > 
> > I believe either the call or the 'ret' (or, likely, both) had had 
> > DILocation attached originally, but it has been removed to simplify the 
> > test.
> I just checked and the `llvm.instrprof.increment` intrinsic does not have 
> debug info attached. I think you're right that I removed debug info from the 
> `ret` instruction to simplify the test.
> 
> This is a special case where a global and its debug info is synthesized.
> https://github.com/llvm/llvm-project/blob/23c2bedfd93cfacc62009425c464e659a34e92e6/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp#L976-L1001
> 
> So I don't understand why this added debug info is necessary. Does the test 
> fail otherwise?
Right, the test would fail w/o the added DILocation, because `__profc_foo` 
variable (which is function-local 'global' technically) would not be emitted. 
With this patch we emit function-local entities if and only if the parent 
function has LexicalScope defined (see createAndAddScopeChildren() and its call 
from constructSubprogramScopeDIE()), otherwise we skip emitting all function's 
children (including function-local 'globals').


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125693

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


[PATCH] D129008: [Clang][OpenMP] Fix the issue that globalization doesn't work with byval struct function argument

2022-07-06 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

cleanup/destructor test missing.

@ABataev WDYT?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129008

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


[PATCH] D128059: [Clang] Add a warning on invalid UTF-8 in comments.

2022-07-06 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

@aaron.ballman Ok, this didn't turn out great, and given the changes + the fact 
it was completely broken (twice!), I'd love if you could take a look at it 
again. Thanks :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128059

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


[PATCH] D128059: [Clang] Add a warning on invalid UTF-8 in comments.

2022-07-06 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 442702.
cor3ntin added a comment.

Deploying that turned out to reveal a few critical issues

- `getUTF8SequenceSize` never reported a non-zero length for valid

UTF-8 sequences.

- In *some* circumstances (depending on the size of comment),

Unicode codepoints were parsed from one past their start,
because the CurPtr was sometimes, but not always, moved back.

I also added a test file with *valid* utf-8 in comments 
(which would have caught these issues).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128059

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/lib/Lex/Lexer.cpp
  clang/test/Lexer/comment-invalid-utf8.c
  clang/test/Lexer/comment-utf8.c
  clang/test/SemaCXX/static-assert.cpp
  llvm/include/llvm/Support/ConvertUTF.h
  llvm/lib/Support/ConvertUTF.cpp

Index: llvm/lib/Support/ConvertUTF.cpp
===
--- llvm/lib/Support/ConvertUTF.cpp
+++ llvm/lib/Support/ConvertUTF.cpp
@@ -417,6 +417,16 @@
 return isLegalUTF8(source, length);
 }
 
+/*
+ * Exported function to return the size of the first utf-8 code unit sequence,
+ * Or 0 if the sequence is not valid;
+ */
+unsigned getUTF8SequenceSize(const UTF8 *source, const UTF8 *sourceEnd) {
+  int length = trailingBytesForUTF8[*source] + 1;
+  return (length <= sourceEnd - source && isLegalUTF8(source, length)) ? length
+ : 0;
+}
+
 /* - */
 
 static unsigned
Index: llvm/include/llvm/Support/ConvertUTF.h
===
--- llvm/include/llvm/Support/ConvertUTF.h
+++ llvm/include/llvm/Support/ConvertUTF.h
@@ -181,6 +181,8 @@
 
 Boolean isLegalUTF8String(const UTF8 **source, const UTF8 *sourceEnd);
 
+unsigned getUTF8SequenceSize(const UTF8 *source, const UTF8 *sourceEnd);
+
 unsigned getNumBytesForUTF8(UTF8 firstByte);
 
 /*/
Index: clang/test/SemaCXX/static-assert.cpp
===
--- clang/test/SemaCXX/static-assert.cpp
+++ clang/test/SemaCXX/static-assert.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 -pedantic -triple=x86_64-linux-gnu
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 -pedantic -triple=x86_64-linux-gnu -Wno-invalid-utf8
 
 int f(); // expected-note {{declared here}}
 
Index: clang/test/Lexer/comment-utf8.c
===
--- /dev/null
+++ clang/test/Lexer/comment-utf8.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fsyntax-only %s -Winvalid-utf8 -verify
+// expected-no-diagnostics
+
+
+//§ § § 😀 你好 ©
+
+/*§ § § 😀 你好 ©*/
+
+/*
+§ § § 😀 你好 ©©©
+*/
+
+/* § § § 😀 你好 © */
+/*
+a longer comment to exerce the vectorized code path
+
+αααααααααααααααααααααα  // here is some unicode
+
+
+*/
Index: clang/lib/Lex/Lexer.cpp
===
--- clang/lib/Lex/Lexer.cpp
+++ clang/lib/Lex/Lexer.cpp
@@ -2392,13 +2392,37 @@
   //
   // This loop terminates with CurPtr pointing at the newline (or end of buffer)
   // character that ends the line comment.
+
+  // C++23 [lex.phases] p1
+  // Diagnose invalid UTF-8 if the corresponding warning is enabled, emitting a
+  // diagnostic only once per entire ill-formed subsequence to avoid
+  // emiting to many diagnostics (see http://unicode.org/review/pr-121.html).
+  bool UnicodeDecodingAlreadyDiagnosed = false;
+
   char C;
   while (true) {
 C = *CurPtr;
 // Skip over characters in the fast loop.
-while (C != 0 &&// Potentially EOF.
-   C != '\n' && C != '\r')  // Newline or DOS-style newline.
+while (isASCII(C) && C != 0 &&   // Potentially EOF.
+   C != '\n' && C != '\r') { // Newline or DOS-style newline.
   C = *++CurPtr;
+  UnicodeDecodingAlreadyDiagnosed = false;
+}
+
+if (!isASCII(C)) {
+  unsigned Length = llvm::getUTF8SequenceSize(
+  (const llvm::UTF8 *)CurPtr, (const llvm::UTF8 *)BufferEnd);
+  if (Length == 0) {
+if (!UnicodeDecodingAlreadyDiagnosed && !isLexingRawMode())
+  Diag(CurPtr, diag::warn_invalid_utf8_in_comment);
+UnicodeDecodingAlreadyDiagnosed = true;
+++CurPtr;
+  } else {
+UnicodeDecodingAlreadyDiagnosed = false;
+CurPtr += Length;
+  }
+  continue;
+}
 
 const char *NextLine = CurPtr;
 if (C != 0) {
@@ -2665,6 

[PATCH] D128750: [c++20] Implement P2113R0: Changes to the Partial Ordering of Constrained Functions

2022-07-06 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added inline comments.



Comment at: clang/lib/Sema/SemaTemplateDeduction.cpp:5119
-  while (--NumParams > 0) {
-if (Function->getParamDecl(NumParams - 1)->isParameterPack())
-  return false;

royjacobson wrote:
> Curious, why was this removed?
I think this is related to https://wg21.link/cwg818 and 
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3086.html#US45.

I'll include this change in D128745 instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128750

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


[PATCH] D127287: clang: Introduce -fexperimental-max-bitint-width

2022-07-06 Thread Matthias Gehre via Phabricator via cfe-commits
mgehre-amd closed this revision.
mgehre-amd added a comment.

Merged


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127287

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


[PATCH] D129231: [Builtins] Do not claim all libfuncs are readnone with trapping math.

2022-07-06 Thread Florian Hahn via Phabricator via cfe-commits
fhahn created this revision.
fhahn added reviewers: kpn, efriedma, scanon, john.brawn, sepavloff.
Herald added a project: All.
fhahn requested review of this revision.
Herald added a project: clang.

At the moment, Clang only considers errno when deciding if a builtin
is const. This ignores the fact that some library functions may raise
floating point exceptions, which may modify global state, e.g. when
updating FP status registers.

To model the fact that some library functions/builtins may raise
floating point exceptions, this patch adds a new 'g' modifier for
builtins. If a builtin is marked with 'g', it cannot be considered
const, unless FP exceptions are ignored.

So far I've not added CHECK lines for all calls in math-libcalls.c. I'll
do that once we agree on the overall direction.

A consequence seems to be that we fail to select some of the constrained
math builtins now, but I am not entirely sure what's going on there.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129231

Files:
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/Builtins.h
  clang/lib/Sema/SemaDecl.cpp
  clang/test/CodeGen/constrained-math-builtins.c
  clang/test/CodeGen/math-libcalls.c

Index: clang/test/CodeGen/math-libcalls.c
===
--- clang/test/CodeGen/math-libcalls.c
+++ clang/test/CodeGen/math-libcalls.c
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-unknown-unknown -Wno-implicit-function-declaration -w -S -o - -emit-llvm  %s | FileCheck %s --check-prefix=NO__ERRNO
 // RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-unknown-unknown -Wno-implicit-function-declaration -w -S -o - -emit-llvm -fmath-errno %s | FileCheck %s --check-prefix=HAS_ERRNO
+// RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-unknown-unknown -Wno-implicit-function-declaration -w -S -o - -emit-llvm -ffp-exception-behavior=maytrap %s | FileCheck %s --check-prefix=HAS_MAYTRAP
 // RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-unknown-unknown-gnu -Wno-implicit-function-declaration -w -S -o - -emit-llvm -fmath-errno %s | FileCheck %s --check-prefix=HAS_ERRNO_GNU
 // RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-unknown-windows-msvc -Wno-implicit-function-declaration -w -S -o - -emit-llvm -fmath-errno %s | FileCheck %s --check-prefix=HAS_ERRNO_WIN
 
@@ -8,66 +9,87 @@
 void foo(double *d, float f, float *fp, long double *l, int *i, const char *c) {
   f = fmod(f,f); f = fmodf(f,f);f = fmodl(f,f);
 
-// NO__ERRNO: frem double
-// NO__ERRNO: frem float
-// NO__ERRNO: frem x86_fp80
-// HAS_ERRNO: declare double @fmod(double noundef, double noundef) [[NOT_READNONE:#[0-9]+]]
-// HAS_ERRNO: declare float @fmodf(float noundef, float noundef) [[NOT_READNONE]]
-// HAS_ERRNO: declare x86_fp80 @fmodl(x86_fp80 noundef, x86_fp80 noundef) [[NOT_READNONE]]
+  // NO__ERRNO: frem double
+  // NO__ERRNO: frem float
+  // NO__ERRNO: frem x86_fp80
+  // HAS_ERRNO: declare double @fmod(double noundef, double noundef) [[NOT_READNONE:#[0-9]+]]
+  // HAS_ERRNO: declare float @fmodf(float noundef, float noundef) [[NOT_READNONE]]
+  // HAS_ERRNO: declare x86_fp80 @fmodl(x86_fp80 noundef, x86_fp80 noundef) [[NOT_READNONE]]
+  // HAS_MAYTRAP: declare double @fmod(double noundef, double noundef) [[NOT_READNONE:#[0-9]+]]
+  // HAS_MAYTRAP: declare float @fmodf(float noundef, float noundef) [[NOT_READNONE]]
+  // HAS_MAYTRAP: declare x86_fp80 @fmodl(x86_fp80 noundef, x86_fp80 noundef) [[NOT_READNONE]]
 
   atan2(f,f);atan2f(f,f) ;  atan2l(f, f);
 
-// NO__ERRNO: declare double @atan2(double noundef, double noundef) [[READNONE:#[0-9]+]]
-// NO__ERRNO: declare float @atan2f(float noundef, float noundef) [[READNONE]]
-// NO__ERRNO: declare x86_fp80 @atan2l(x86_fp80 noundef, x86_fp80 noundef) [[READNONE]]
-// HAS_ERRNO: declare double @atan2(double noundef, double noundef) [[NOT_READNONE]]
-// HAS_ERRNO: declare float @atan2f(float noundef, float noundef) [[NOT_READNONE]]
-// HAS_ERRNO: declare x86_fp80 @atan2l(x86_fp80 noundef, x86_fp80 noundef) [[NOT_READNONE]]
+  // NO__ERRNO: declare double @atan2(double noundef, double noundef) [[READNONE:#[0-9]+]]
+  // NO__ERRNO: declare float @atan2f(float noundef, float noundef) [[READNONE]]
+  // NO__ERRNO: declare x86_fp80 @atan2l(x86_fp80 noundef, x86_fp80 noundef) [[READNONE]]
+  // HAS_ERRNO: declare double @atan2(double noundef, double noundef) [[NOT_READNONE]]
+  // HAS_ERRNO: declare float @atan2f(float noundef, float noundef) [[NOT_READNONE]]
+  // HAS_ERRNO: declare x86_fp80 @atan2l(x86_fp80 noundef, x86_fp80 noundef) [[NOT_READNONE]]
+  // HAS_MAYTRAP: declare double @atan2(double noundef, double noundef) [[NOT_READNONE]]
+  // HAS_MAYTRAP: declare float @atan2f(float noundef, float noundef) [[NOT_READNONE]]
+  // HAS_MAYTRAP: declare x86_fp80 @atan2l(x86_fp80 noundef, x86_fp80 noundef) [[NOT_READNONE]]
 
   copysign(f,f); copysignf(f,f);copysignl(f,f);
 
-// NO__ERRNO: declare 

[PATCH] D128921: [Sema] Merge C++20 concept definitions from different modules in same TU

2022-07-06 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/lib/Sema/SemaTemplate.cpp:8694-8696
+  Diag(NewDecl->getLocation(), isa(Old)
+   ? diag::err_redefinition
+   : diag::err_redefinition_different_kind)

It'd be nice to have a third diagnostic for the case where there's a known 
declaration that doesn't match. That is:

* If the name is used for something that's not a concept, diagnose with 
err_redefinition_different_kind.
* If the name is used for a visible and matching concept, diagnose with 
err_redefinition.
* If the name is used for a non-matching concept, regardless of whether it's 
visible or even reachable, produce some new mismatch error.
* Otherwise, if the name is used for a matching concept that's not visible, 
merge.



Comment at: clang/lib/Sema/SemaTemplate.cpp:8679
+  Previous.isSingleResult() ? Previous.getAsSingle() : 
nullptr;
+  if (PrevDef && !hasVisibleDefinition(PrevDef) &&
+  Context.isSameEntity(NewDecl, PrevDef)) {

ChuanqiXu wrote:
> 
I don't think that's right: [the C++20 modules 
rule](http://eel.is/c++draft/basic.def.odr#2) is that at most one definition is 
permitted per translation unit, and the Clang header modules rule is that a 
definition is only permissible if no definition is visible (Clang header 
modules effectively behave as if they're part of the same translation unit for 
the purposes of this check). For now, checking for a visible definition seems 
better than checking for a reachable one, until we implement the C++20 rule in 
general.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128921

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


[PATCH] D126864: [clang] Introduce -fstrict-flex-arrays= for stricter handling of flexible arrays

2022-07-06 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 442692.
serge-sans-paille edited the summary of this revision.
serge-sans-paille added a comment.

Remove debug code


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

https://reviews.llvm.org/D126864

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
  clang/lib/AST/ExprConstant.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/StaticAnalyzer/Core/MemRegion.cpp
  clang/test/CodeGen/bounds-checking-fam.c
  clang/test/CodeGen/bounds-checking-fam.cpp
  clang/test/CodeGen/object-size-flex-array.c
  clang/test/CodeGenObjC/ubsan-array-bounds.m
  clang/test/Sema/array-bounds-ptr-arith.c
  clang/test/SemaCXX/array-bounds-strict-flex-arrays.cpp
  clang/test/SemaCXX/array-bounds.cpp

Index: clang/test/SemaCXX/array-bounds.cpp
===
--- clang/test/SemaCXX/array-bounds.cpp
+++ clang/test/SemaCXX/array-bounds.cpp
@@ -208,12 +208,15 @@
 
 namespace metaprogramming {
 #define ONE 1
-  struct foo { char c[ONE]; }; // expected-note {{declared here}}
+struct foo {
+  char c[ONE]; // expected-note {{array 'c' declared here}}
+};
+
   template  struct bar { char c[N]; }; // expected-note {{declared here}}
 
   char test(foo *F, bar<1> *B) {
 return F->c[3] + // expected-warning {{array index 3 is past the end of the array (which contains 1 element)}}
-   B->c[3]; // expected-warning {{array index 3 is past the end of the array (which contains 1 element)}}
+   B->c[3];  // expected-warning {{array index 3 is past the end of the array (which contains 1 element)}}
   }
 }
 
Index: clang/test/SemaCXX/array-bounds-strict-flex-arrays.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/array-bounds-strict-flex-arrays.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -verify -fstrict-flex-arrays=2 %s
+
+// We cannot know for sure the size of a flexible array.
+struct t {
+  int f;
+  int a[];
+};
+void test(t *s2) {
+  s2->a[2] = 0; // no-warning
+}
+
+// Under -fstrict-flex-arrays `a` is not a flexible array.
+struct t1 {
+  int f;
+  int a[1]; // expected-note {{array 'a' declared here}}
+};
+void test1(t1 *s2) {
+  s2->a[2] = 0; // expected-warning {{array index 2 is past the end of the array (which contains 1 element)}}
+}
+
+// Under -fstrict-flex-arrays `a` is a flexible array.
+struct t2 {
+  int f;
+  int a[0];
+};
+void test1(t2 *s2) {
+  s2->a[2] = 0; // no-warning
+}
Index: clang/test/Sema/array-bounds-ptr-arith.c
===
--- clang/test/Sema/array-bounds-ptr-arith.c
+++ clang/test/Sema/array-bounds-ptr-arith.c
@@ -1,4 +1,6 @@
-// RUN: %clang_cc1 -verify -Warray-bounds-pointer-arithmetic %s
+// RUN: %clang_cc1 -verify=expected -Warray-bounds-pointer-arithmetic %s
+// RUN: %clang_cc1 -verify=expected -Warray-bounds-pointer-arithmetic %s -fstrict-flex-arrays=0
+// RUN: %clang_cc1 -verify=expected,strict -Warray-bounds-pointer-arithmetic %s -fstrict-flex-arrays=2
 
 // Test case from PR10615
 struct ext2_super_block{
@@ -14,7 +16,9 @@
 }
 
 // Test case reduced from PR11594
-struct S { int n; };
+struct S {
+  int n;
+};
 void pr11594(struct S *s) {
   int a[10];
   int *p = a - s->n;
@@ -26,26 +30,28 @@
 struct RDar11387038 {};
 typedef struct RDar11387038 RDar11387038Array[1];
 struct RDar11387038_Table {
-  RDar11387038Array z;
+  RDar11387038Array z; // strict-note {{array 'z' declared here}}
 };
-typedef struct RDar11387038_Table * TPtr;
+typedef struct RDar11387038_Table *TPtr;
 typedef TPtr *TabHandle;
-struct RDar11387038_B { TabHandle x; };
+struct RDar11387038_B {
+  TabHandle x;
+};
 typedef struct RDar11387038_B RDar11387038_B;
 
 void radar11387038(void) {
   RDar11387038_B *pRDar11387038_B;
-  struct RDar11387038* y = &(*pRDar11387038_B->x)->z[4];
+  struct RDar11387038 *y = &(*pRDar11387038_B->x)->z[4]; // strict-warning {{array index 4 is past the end of the array (which contains 1 element)}}
 }
 
-void pr51682 (void) {
-  int arr [1];
+void pr51682(void) {
+  int arr[1];
   switch (0) {
-case 0:
-  break;
-case 1:
-  asm goto (""::"r"(arr[42] >> 1)::failed); // no-warning
-  break;
+  case 0:
+break;
+  case 1:
+asm goto("" ::"r"(arr[42] >> 1)::failed);
+break;
   }
 failed:;
 }
Index: clang/test/CodeGenObjC/ubsan-array-bounds.m
===
--- clang/test/CodeGenObjC/ubsan-array-bounds.m
+++ clang/test/CodeGenObjC/ubsan-array-bounds.m
@@ -14,46 +14,3 @@
   return FA1->chars[1];
   // CHECK: }
 }
-
-@interface FlexibleArray2 {
-@public
-  char chars[0];
-}
-@end
-@implementation FlexibleArray2 {
-@public
-  char chars2[0];

[PATCH] D128569: Start support for HLSL `RWBuffer`

2022-07-06 Thread Chris Bieneman via Phabricator via cfe-commits
beanz updated this revision to Diff 442690.
beanz added a comment.

Updating with some minor tweaks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128569

Files:
  clang/include/clang/Sema/HLSLExternalSemaSource.h
  clang/lib/AST/DeclTemplate.cpp
  clang/lib/Sema/HLSLExternalSemaSource.cpp
  clang/test/AST/HLSL/RWBuffer-AST.hlsl
  clang/test/AST/HLSL/ResourceStruct.hlsl
  clang/test/SemaHLSL/BuiltIns/RWBuffers.hlsl

Index: clang/test/SemaHLSL/BuiltIns/RWBuffers.hlsl
===
--- /dev/null
+++ clang/test/SemaHLSL/BuiltIns/RWBuffers.hlsl
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -x hlsl -fsyntax-only -verify %s
+
+Resource ResourceDescriptorHeap[5];
+typedef vector float3;
+
+RWBuffer Buffer;
+
+[numthreads(1,1,1)]
+void main() {
+  (void)Buffer.h; // expected-error {{'h' is a private member of 'hlsl::RWBuffer'}}
+  // expected-note@* {{implicitly declared private here}}
+}
Index: clang/test/AST/HLSL/ResourceStruct.hlsl
===
--- /dev/null
+++ clang/test/AST/HLSL/ResourceStruct.hlsl
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -fsyntax-only -ast-dump %s | FileCheck %s 
+
+// CHECK: NamespaceDecl {{.*}} implicit hlsl
+// CHECK: CXXRecordDecl 0x{{[0-9A-Fa-f]+}} <>  implicit  class Resource definition
+// CHECK-NEXT: DefinitionData
+// CHECK-NEXT: DefaultConstructor exists trivial needs_implicit
+// CHECK-NEXT: CopyConstructor simple trivial has_const_param needs_implicit implicit_has_const_param
+// CHECK-NEXT: MoveConstructor exists simple trivial needs_implicit
+// CHECK-NEXT: CopyAssignment simple trivial has_const_param needs_implicit implicit_has_const_param
+// CHECK-NEXT: MoveAssignment exists simple trivial needs_implicit
+// CHECK-NEXT: Destructor simple irrelevant trivial needs_implicit
+// CHECK-NEXT: FinalAttr 0x{{[0-9A-Fa-f]+}} <> Implicit final
+// CHECK-NEXT: FieldDecl 0x{{[0-9A-Fa-f]+}} <> 
+// implicit h 'void *'
Index: clang/test/AST/HLSL/RWBuffer-AST.hlsl
===
--- /dev/null
+++ clang/test/AST/HLSL/RWBuffer-AST.hlsl
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -fsyntax-only -ast-dump -DEMPTY %s | FileCheck -check-prefix=EMPTY %s 
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -fsyntax-only -ast-dump %s | FileCheck %s 
+
+// EMPTY: ClassTemplateDecl 0x{{[0-9A-Fa-f]+}} <>  implicit RWBuffer
+// EMPTY-NEXT: TemplateTypeParmDecl 0x{{[0-9A-Fa-f]+}} <>  class depth 0 index 0 element_type
+// EMPTY-NEXT: TemplateArgument type 'float'
+// EMPTY-NEXT: BuiltinType 0x{{[0-9A-Fa-f]+}} 'float'
+// EMPTY-NEXT: CXXRecordDecl 0x{{[0-9A-Fa-f]+}} <>  implicit  class RWBuffer
+// EMPTY-NEXT: FinalAttr 0x{{[0-9A-Fa-f]+}} <> Implicit final
+
+// There should be no more occurrances of RWBuffer
+// EMPTY-NOT: RWBuffer
+
+#ifndef EMPTY
+
+RWBuffer Buffer;
+
+#endif
+
+// CHECK: CXXRecordDecl 0x{{[0-9A-Fa-f]+}} <>  implicit  class Resource definition
+// CHECK: FinalAttr 0x{{[0-9A-Fa-f]+}} <> Implicit final
+// CHECK-NEXT: FieldDecl 0x{{[0-9A-Fa-f]+}} <>  implicit h 'void *'
+
+// CHECK: ClassTemplateDecl 0x{{[0-9A-Fa-f]+}} <>  implicit RWBuffer
+// CHECK-NEXT: TemplateTypeParmDecl 0x{{[0-9A-Fa-f]+}} <>  class depth 0 index 0 element_type
+// CHECK-NEXT: TemplateArgument type 'float'
+// CHECK-NEXT: BuiltinType 0x{{[0-9A-Fa-f]+}} 'float'
+// CHECK-NEXT: CXXRecordDecl 0x{{[0-9A-Fa-f]+}} <>  implicit class RWBuffer definition
+
+// CHECK: FinalAttr 0x{{[0-9A-Fa-f]+}} <> Implicit final
+// CHECK-NEXT: FieldDecl 0x{{[0-9A-Fa-f]+}} <>  implicit h 'void *'
+// CHECK: ClassTemplateSpecializationDecl 0x{{[0-9A-Fa-f]+}} <>  class RWBuffer definition
+
+// CHECK: TemplateArgument type 'float'
+// CHECK-NEXT: BuiltinType 0x{{[0-9A-Fa-f]+}} 'float'
+// CHECK-NEXT: FinalAttr 0x{{[0-9A-Fa-f]+}} <> Implicit final
+// CHECK-NEXT: FieldDecl 0x{{[0-9A-Fa-f]+}} <>   implicit h 'void *'
Index: clang/lib/Sema/HLSLExternalSemaSource.cpp
===
--- clang/lib/Sema/HLSLExternalSemaSource.cpp
+++ clang/lib/Sema/HLSLExternalSemaSource.cpp
@@ -15,8 +15,161 @@
 #include "clang/Basic/AttrKinds.h"
 #include "clang/Sema/Sema.h"
 
+#include 
+
 using namespace clang;
 
+namespace {
+
+struct TemplateParameterListBuilder;
+
+struct BuiltinTypeDeclBuilder {
+  CXXRecordDecl *Record = nullptr;
+  ClassTemplateDecl *Template = nullptr;
+  NamespaceDecl *HLSLNamespace = nullptr;
+
+  BuiltinTypeDeclBuilder(CXXRecordDecl *R) : Record(R) {
+Record->startDefinition();
+Template = Record->getDescribedClassTemplate();
+  }
+
+  BuiltinTypeDeclBuilder(Sema , NamespaceDecl *Namespace, StringRef Name)
+  : HLSLNamespace(Namespace) {
+ASTContext  = S.getASTContext();
+IdentifierInfo  = 

[PATCH] D127189: [clang][AIX] Add option to control quadword lock free atomics ABI on AIX

2022-07-06 Thread Kai Luo via Phabricator via cfe-commits
lkail added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127189

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


[PATCH] D123319: Change how we handle auto return types for lambda operator() to be consistent with gcc

2022-07-06 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

@aprantl ^ ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123319

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


[PATCH] D111081: [clang] [MinGW] Fix paths on Gentoo

2022-07-06 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo accepted this revision.
mstorsjo added a comment.
This revision is now accepted and ready to land.

LGTM, thanks, and sorry for losing track of it earlier.

Do you need someone to push the patch for you? In that case, can you provide 
your preferred git author line for the patch?


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

https://reviews.llvm.org/D111081

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


[PATCH] D126864: [clang] Introduce -fstrict-flex-arrays= for stricter handling of flexible arrays

2022-07-06 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 442686.
serge-sans-paille edited the summary of this revision.
serge-sans-paille added a comment.

Take into account @jyknight review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126864

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
  clang/lib/AST/ExprConstant.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/StaticAnalyzer/Core/MemRegion.cpp
  clang/test/CodeGen/bounds-checking-fam.c
  clang/test/CodeGen/bounds-checking-fam.cpp
  clang/test/CodeGen/object-size-flex-array.c
  clang/test/CodeGenObjC/ubsan-array-bounds.m
  clang/test/Sema/array-bounds-ptr-arith.c
  clang/test/SemaCXX/array-bounds-strict-flex-arrays.cpp
  clang/test/SemaCXX/array-bounds.cpp

Index: clang/test/SemaCXX/array-bounds.cpp
===
--- clang/test/SemaCXX/array-bounds.cpp
+++ clang/test/SemaCXX/array-bounds.cpp
@@ -208,12 +208,15 @@
 
 namespace metaprogramming {
 #define ONE 1
-  struct foo { char c[ONE]; }; // expected-note {{declared here}}
+struct foo {
+  char c[ONE]; // expected-note {{array 'c' declared here}}
+};
+
   template  struct bar { char c[N]; }; // expected-note {{declared here}}
 
   char test(foo *F, bar<1> *B) {
 return F->c[3] + // expected-warning {{array index 3 is past the end of the array (which contains 1 element)}}
-   B->c[3]; // expected-warning {{array index 3 is past the end of the array (which contains 1 element)}}
+   B->c[3];  // expected-warning {{array index 3 is past the end of the array (which contains 1 element)}}
   }
 }
 
Index: clang/test/SemaCXX/array-bounds-strict-flex-arrays.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/array-bounds-strict-flex-arrays.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -verify -fstrict-flex-arrays=2 %s
+
+// We cannot know for sure the size of a flexible array.
+struct t {
+  int f;
+  int a[];
+};
+void test(t *s2) {
+  s2->a[2] = 0; // no-warning
+}
+
+// Under -fstrict-flex-arrays `a` is not a flexible array.
+struct t1 {
+  int f;
+  int a[1]; // expected-note {{array 'a' declared here}}
+};
+void test1(t1 *s2) {
+  s2->a[2] = 0; // expected-warning {{array index 2 is past the end of the array (which contains 1 element)}}
+}
+
+// Under -fstrict-flex-arrays `a` is a flexible array.
+struct t2 {
+  int f;
+  int a[0];
+};
+void test1(t2 *s2) {
+  s2->a[2] = 0; // no-warning
+}
Index: clang/test/Sema/array-bounds-ptr-arith.c
===
--- clang/test/Sema/array-bounds-ptr-arith.c
+++ clang/test/Sema/array-bounds-ptr-arith.c
@@ -1,4 +1,6 @@
-// RUN: %clang_cc1 -verify -Warray-bounds-pointer-arithmetic %s
+// RUN: %clang_cc1 -verify=expected -Warray-bounds-pointer-arithmetic %s
+// RUN: %clang_cc1 -verify=expected -Warray-bounds-pointer-arithmetic %s -fstrict-flex-arrays=0
+// RUN: %clang_cc1 -verify=expected,strict -Warray-bounds-pointer-arithmetic %s -fstrict-flex-arrays=2
 
 // Test case from PR10615
 struct ext2_super_block{
@@ -14,7 +16,9 @@
 }
 
 // Test case reduced from PR11594
-struct S { int n; };
+struct S {
+  int n;
+};
 void pr11594(struct S *s) {
   int a[10];
   int *p = a - s->n;
@@ -26,26 +30,28 @@
 struct RDar11387038 {};
 typedef struct RDar11387038 RDar11387038Array[1];
 struct RDar11387038_Table {
-  RDar11387038Array z;
+  RDar11387038Array z; // strict-note {{array 'z' declared here}}
 };
-typedef struct RDar11387038_Table * TPtr;
+typedef struct RDar11387038_Table *TPtr;
 typedef TPtr *TabHandle;
-struct RDar11387038_B { TabHandle x; };
+struct RDar11387038_B {
+  TabHandle x;
+};
 typedef struct RDar11387038_B RDar11387038_B;
 
 void radar11387038(void) {
   RDar11387038_B *pRDar11387038_B;
-  struct RDar11387038* y = &(*pRDar11387038_B->x)->z[4];
+  struct RDar11387038 *y = &(*pRDar11387038_B->x)->z[4]; // strict-warning {{array index 4 is past the end of the array (which contains 1 element)}}
 }
 
-void pr51682 (void) {
-  int arr [1];
+void pr51682(void) {
+  int arr[1];
   switch (0) {
-case 0:
-  break;
-case 1:
-  asm goto (""::"r"(arr[42] >> 1)::failed); // no-warning
-  break;
+  case 0:
+break;
+  case 1:
+asm goto("" ::"r"(arr[42] >> 1)::failed);
+break;
   }
 failed:;
 }
Index: clang/test/CodeGenObjC/ubsan-array-bounds.m
===
--- clang/test/CodeGenObjC/ubsan-array-bounds.m
+++ clang/test/CodeGenObjC/ubsan-array-bounds.m
@@ -14,46 +14,3 @@
   return FA1->chars[1];
   // CHECK: }
 }
-
-@interface FlexibleArray2 {
-@public
-  char chars[0];
-}
-@end

[PATCH] D129223: [Clang] Fix invalid utf-8 detection

2022-07-06 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

In D129223#3633849 , @thakis wrote:

> Reverted in e9fe20dab39edb911afacdb6ed9ec2c7499a59cf 
>  for now.

Thanks, I was going to do that when I noticed you already did, very much 
appreciated.
The patch (well, the one before) appeared to have multiple off-by one errors 
that cancelled each other and were not caught due to insufficient test cases
Once I find a fix, I'll get it reviewed again. Sorry for the inconvenience


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129223

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


[PATCH] D129223: [Clang] Fix invalid utf-8 detection

2022-07-06 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

In D129223#3633754 , @thakis wrote:

> This breaks check-clang: http://45.33.8.238/linux/80462/step_7.txt

(Also on all other bots, e.g. 
https://lab.llvm.org/buildbot/#/builders/171/builds/17060 – did you run tests 
locally before committing?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129223

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


[PATCH] D129016: [PowerPC] implemented @llvm.ppc.kill.canary to corrupt stack guard

2022-07-06 Thread Paul Scoropan via Phabricator via cfe-commits
pscoro added inline comments.



Comment at: llvm/include/llvm/Debuginfod/Debuginfod.h:34
 #include 
+#include 
 #include 

Im really unsure how this change got in here, this is not added by me and on a 
freshly created branch and pull

Any ideas? I'll look into this tomorrow


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129016

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


[PATCH] D129170: [Sema] Add deprecation warnings for some compiler provided __has_* type traits

2022-07-06 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/lib/Sema/SemaExprCXX.cpp:5400-5401
+SourceLocation KWLoc) {
+  if (!S.getLangOpts().CPlusPlus11)
+return;
+

royjacobson wrote:
> aaron.ballman wrote:
> > I think we should always warn on these, not just in C++11.
> I'm not convinced we should. My reasoning is that we need a pretty good 
> reason to start issuing warnings for 20 years old code. The usage of those 
> builtins with deleted functions after C++11 is pretty broken which is a 
> pretty good reason, but for earlier language versions they work 'fine' and if 
> people want to use C++03 I prefer leaving them at peace :)
> 
> People on C++03 are also probably using pretty old versions of libstdc++ 
> and/or boost type_traits, so this could have some impact.
> 
> WDYT?
> 
warnings don't get emitted for code in header files, so at least that part 
isn't a concern.  


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129170

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


[PATCH] D129223: [Clang] Fix invalid utf-8 detection

2022-07-06 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Reverted in e9fe20dab39edb911afacdb6ed9ec2c7499a59cf for now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129223

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


[clang] e9fe20d - Revert "[Clang] Add a warning on invalid UTF-8 in comments."

2022-07-06 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2022-07-06T22:51:52+02:00
New Revision: e9fe20dab39edb911afacdb6ed9ec2c7499a59cf

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

LOG: Revert "[Clang] Add a warning on invalid UTF-8 in comments."

This reverts commit 4174f0ca618b467571b43cff12cbe4c4239670f8.

Also revert follow-up "[Clang] Fix invalid utf-8 detection"
This reverts commit bf45e27a676d87944f1f13d5f0d0f39935fc4010.

The second commit broke tests, see comments on
https://reviews.llvm.org/D129223, and it sounds like the first
commit isn't valid without the second one. So reverting both for now.

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/DiagnosticLexKinds.td
clang/lib/Lex/Lexer.cpp
clang/test/SemaCXX/static-assert.cpp
llvm/include/llvm/Support/ConvertUTF.h
llvm/lib/Support/ConvertUTF.cpp

Removed: 
clang/test/Lexer/comment-invalid-utf8.c



diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index c50e1b89649cf..0f542e08b841c 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -279,8 +279,6 @@ Improvements to Clang's diagnostics
   unevaluated operands of a ``typeid`` expression, as they are now
   modeled correctly in the CFG. This fixes
   `Issue 21668 `_.
-- Added ``-Winvalid-utf8`` which diagnoses invalid UTF-8 code unit sequences in
-  comments.
 
 Non-comprehensive list of changes in this release
 -
@@ -578,7 +576,7 @@ AST Matchers
 
 - Added ``forEachTemplateArgument`` matcher which creates a match every
   time a ``templateArgument`` matches the matcher supplied to it.
-
+  
 - Added ``objcStringLiteral`` matcher which matches ObjectiveC String
   literal expressions.
 

diff  --git a/clang/include/clang/Basic/DiagnosticLexKinds.td 
b/clang/include/clang/Basic/DiagnosticLexKinds.td
index 38ee022e5f04c..ac86076140c58 100644
--- a/clang/include/clang/Basic/DiagnosticLexKinds.td
+++ b/clang/include/clang/Basic/DiagnosticLexKinds.td
@@ -113,8 +113,6 @@ def warn_four_char_character_literal : Warning<
 // Unicode and UCNs
 def err_invalid_utf8 : Error<
   "source file is not valid UTF-8">;
-def warn_invalid_utf8_in_comment : Extension<
-  "invalid UTF-8 in comment">, InGroup>;
 def err_character_not_allowed : Error<
   "unexpected character ">;
 def err_character_not_allowed_identifier : Error<

diff  --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp
index 351e518c7ed37..6820057642bea 100644
--- a/clang/lib/Lex/Lexer.cpp
+++ b/clang/lib/Lex/Lexer.cpp
@@ -2392,37 +2392,13 @@ bool Lexer::SkipLineComment(Token , const char 
*CurPtr,
   //
   // This loop terminates with CurPtr pointing at the newline (or end of 
buffer)
   // character that ends the line comment.
-
-  // C++23 [lex.phases] p1
-  // Diagnose invalid UTF-8 if the corresponding warning is enabled, emitting a
-  // diagnostic only once per entire ill-formed subsequence to avoid
-  // emiting to many diagnostics (see http://unicode.org/review/pr-121.html).
-  bool UnicodeDecodingAlreadyDiagnosed = false;
-
   char C;
   while (true) {
 C = *CurPtr;
 // Skip over characters in the fast loop.
-while (isASCII(C) && C != 0 &&   // Potentially EOF.
-   C != '\n' && C != '\r') { // Newline or DOS-style newline.
+while (C != 0 &&// Potentially EOF.
+   C != '\n' && C != '\r')  // Newline or DOS-style newline.
   C = *++CurPtr;
-  UnicodeDecodingAlreadyDiagnosed = false;
-}
-
-if (!isASCII(C)) {
-  unsigned Length = llvm::getUTF8SequenceSize(
-  (const llvm::UTF8 *)CurPtr, (const llvm::UTF8 *)BufferEnd);
-  if (Length == 0) {
-if (!UnicodeDecodingAlreadyDiagnosed && !isLexingRawMode())
-  Diag(CurPtr, diag::warn_invalid_utf8_in_comment);
-UnicodeDecodingAlreadyDiagnosed = true;
-++CurPtr;
-  } else {
-UnicodeDecodingAlreadyDiagnosed = false;
-CurPtr += Length;
-  }
-  continue;
-}
 
 const char *NextLine = CurPtr;
 if (C != 0) {
@@ -2689,12 +2665,6 @@ bool Lexer::SkipBlockComment(Token , const char 
*CurPtr,
   if (C == '/')
 C = *CurPtr++;
 
-  // C++23 [lex.phases] p1
-  // Diagnose invalid UTF-8 if the corresponding warning is enabled, emitting a
-  // diagnostic only once per entire ill-formed subsequence to avoid
-  // emiting to many diagnostics (see http://unicode.org/review/pr-121.html).
-  bool UnicodeDecodingAlreadyDiagnosed = false;
-
   while (true) {
 // Skip over all non-interesting characters until we find end of buffer or 
a
 // (probably ending) '/' character.
@@ -2703,24 +2673,14 @@ bool Lexer::SkipBlockComment(Token , const char 
*CurPtr,
 // 

[PATCH] D129170: [Sema] Add deprecation warnings for some compiler provided __has_* type traits

2022-07-06 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson marked 9 inline comments as done and 2 inline comments as done.
royjacobson added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticGroups.td:190
 : DiagGroup<"deprecated-dynamic-exception-spec">;
+def DeprecatedHasBuiltins : DiagGroup<"deprecated-has-builtins">;
 def DeprecatedImplementations :DiagGroup<"deprecated-implementations">;

aaron.ballman wrote:
> I wonder if we want to rename this to `deprecated-builtins` so it applies to 
> any builtin we elect to deprecate, not just ones that start with `has`. WDYT?
Sounds good to me, updated it.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:5561
+def warn_deprecated_has_builtins : Warning<
+  "the %0 compiler builtin is deprecated from C++11 onwards. Use %1 instead.">,
+  InGroup;

aaron.ballman wrote:
> erichkeane wrote:
> > cor3ntin wrote:
> > > Should we say something like "and will be removed in the future"?
> > > 
> > > "%0 is deprecated from C++11 onward. Use %1 instead." might be sufficient
> > > 
> > > 
> > Diagnostics arent sentences. Also, we wouldn't say "C++11 onward", we can 
> > just say C++11. I might suggest:
> > 
> > `builtin %0 is deprecated in C++11, use %1 instead`
> > 
> > BUT @aaron.ballman always does great at this level of bikeshedding.
> > 
> I think we might want to rename this to `warn_deprecated_builtin` and make it 
> slightly more general. I think we want to drop the mention of C++11 because 
> the documentation says these are deprecated (not deprecated in a specific 
> version) and the replacement APIs are all available pre C++11 anyway (at 
> least in Clang). How about: `builtin %0 is deprecated; use %1 instead`?
Took Aaron's version at the end.



Comment at: clang/lib/Sema/SemaExprCXX.cpp:5400-5401
+SourceLocation KWLoc) {
+  if (!S.getLangOpts().CPlusPlus11)
+return;
+

aaron.ballman wrote:
> I think we should always warn on these, not just in C++11.
I'm not convinced we should. My reasoning is that we need a pretty good reason 
to start issuing warnings for 20 years old code. The usage of those builtins 
with deleted functions after C++11 is pretty broken which is a pretty good 
reason, but for earlier language versions they work 'fine' and if people want 
to use C++03 I prefer leaving them at peace :)

People on C++03 are also probably using pretty old versions of libstdc++ and/or 
boost type_traits, so this could have some impact.

WDYT?




Comment at: clang/lib/Sema/SemaExprCXX.cpp:5426-5428
+case UTT_HasTrivialDefaultConstructor:
+  Replacement = TT_IsTriviallyConstructible;
+  break;

aaron.ballman wrote:
> This one is not documented as being deprecated (or documented at all). I 
> think it's reasonable to deprecate it, but it should probably be documented 
> in the language extensions page.
It's the `__has_trivial_constructor` builtin that unfortunately has a different 
enum name (it's named after the internal CXXRecordDecl it calls, I think).



Comment at: clang/lib/Sema/SemaExprCXX.cpp:5433
+// FIXME: GCC don't implement __is_trivially_destructible: Warning for this
+//   might be too noisy for now.
+// case UTT_HasTrivialDestructor:

aaron.ballman wrote:
> I'd like to know how plausible that "might" is -- Clang flags it as being 
> deprecated, so it seems very reasonable to diagnose it as such. These 
> diagnostics won't be triggered from system headers by default anyway, so I'm 
> not certain if this will be too noisy in practice.
It's used in libstdc++'s type_traits and in boost's type_traits (but we will 
start warning on boost's type_traits anyway). So it's even if by default people 
are not going to see it I think it's used widely enough to be problematic and 
we shouldn't warn on this for now.

I added the libstdc++ part to the comment as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129170

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


[PATCH] D128652: [PowerPC] Finished kill_canary implementation and debugging

2022-07-06 Thread Paul Scoropan via Phabricator via cfe-commits
pscoro updated this revision to Diff 442682.
pscoro added a comment.

patch fix


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128652

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Basic/Targets/PPC.cpp
  clang/test/CodeGen/PowerPC/builtins-ppc-stackprotect.c
  llvm/include/llvm/Debuginfod/Debuginfod.h
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/test/CodeGen/PowerPC/kill-canary-intrinsic.ll

Index: llvm/test/CodeGen/PowerPC/kill-canary-intrinsic.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/kill-canary-intrinsic.ll
@@ -0,0 +1,77 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-aix \
+; RUN:   --ppc-asm-full-reg-names < %s | FileCheck %s -check-prefix=AIX
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux \
+; RUN:   --ppc-asm-full-reg-names < %s | FileCheck %s -check-prefix=LINUX
+
+declare void @llvm.ppc.kill.canary()
+define dso_local void @test_kill_canary() {
+; AIX-LABEL: test_kill_canary:
+; AIX:   # %bb.0: # %entry
+; AIX-NEXT:blr
+;
+; LINUX-LABEL: test_kill_canary:
+; LINUX:   # %bb.0: # %entry
+; LINUX-NEXT:blr
+entry:
+  call void @llvm.ppc.kill.canary()
+  ret void
+}
+
+attributes #0 = { sspreq }
+; Function Attrs: sspreq
+define dso_local void @test_kill_canary_ssp() #0 {
+; AIX-LABEL: test_kill_canary_ssp:
+; AIX:   # %bb.0: # %entry
+; AIX-NEXT:mflr r0
+; AIX-NEXT:std r0, 16(r1)
+; AIX-NEXT:stdu r1, -128(r1)
+; AIX-NEXT:ld r3, L..C0(r2) # @__ssp_canary_word
+; AIX-NEXT:ld r4, 0(r3)
+; AIX-NEXT:std r4, 120(r1)
+; AIX-NEXT:ld r4, 0(r3)
+; AIX-NEXT:xori r4, r4, 65535
+; AIX-NEXT:xoris r4, r4, 65535
+; AIX-NEXT:std r4, 0(r3)
+; AIX-NEXT:ld r3, 0(r3)
+; AIX-NEXT:ld r4, 120(r1)
+; AIX-NEXT:cmpld r3, r4
+; AIX-NEXT:bne cr0, L..BB1_2
+; AIX-NEXT:  # %bb.1: # %entry
+; AIX-NEXT:addi r1, r1, 128
+; AIX-NEXT:ld r0, 16(r1)
+; AIX-NEXT:mtlr r0
+; AIX-NEXT:blr
+; AIX-NEXT:  L..BB1_2: # %entry
+; AIX-NEXT:bl .__stack_chk_fail[PR]
+; AIX-NEXT:nop
+;
+; LINUX-LABEL: test_kill_canary_ssp:
+; LINUX:   # %bb.0: # %entry
+; LINUX-NEXT:mflr r0
+; LINUX-NEXT:std r0, 16(r1)
+; LINUX-NEXT:stdu r1, -128(r1)
+; LINUX-NEXT:.cfi_def_cfa_offset 128
+; LINUX-NEXT:.cfi_offset lr, 16
+; LINUX-NEXT:ld r3, -28688(r13)
+; LINUX-NEXT:std r3, 120(r1)
+; LINUX-NEXT:ld r3, -28688(r13)
+; LINUX-NEXT:xori r3, r3, 65535
+; LINUX-NEXT:xoris r3, r3, 65535
+; LINUX-NEXT:std r3, 120(r1)
+; LINUX-NEXT:ld r3, 120(r1)
+; LINUX-NEXT:ld r4, -28688(r13)
+; LINUX-NEXT:cmpld r4, r3
+; LINUX-NEXT:bne cr0, .LBB1_2
+; LINUX-NEXT:  # %bb.1: # %entry
+; LINUX-NEXT:addi r1, r1, 128
+; LINUX-NEXT:ld r0, 16(r1)
+; LINUX-NEXT:mtlr r0
+; LINUX-NEXT:blr
+; LINUX-NEXT:  .LBB1_2: # %entry
+; LINUX-NEXT:bl __stack_chk_fail
+; LINUX-NEXT:nop
+entry:
+  call void @llvm.ppc.kill.canary()
+  ret void
+}
Index: llvm/lib/Target/PowerPC/PPCISelLowering.cpp
===
--- llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -10695,6 +10695,72 @@
Op.getOperand(0)),
 0);
   }
+  case Intrinsic::ppc_kill_canary: {
+MachineFunction  = DAG.getMachineFunction();
+const Module *M = MF.getMMI().getModule();
+
+/* If SafeStack or !StackProtector, kill_canary not supported */
+if (MF.getFunction().hasFnAttribute(Attribute::SafeStack) ||
+!MF.getFunction().hasStackProtectorFnAttr()) {
+  DAG.ReplaceAllUsesOfValueWith(
+  SDValue(Op.getNode(), 0),
+  Op->getOperand(0)); // prepare node for deletion
+  break;
+}
+
+EVT VT = DAG.getTargetLoweringInfo().getPointerTy(DAG.getDataLayout());
+
+SDValue Load;
+SDValue Store;
+
+const uint64_t XORWord =
+0x; // XORing with 0b111...111 will never
+// result in the original word
+
+if (useLoadStackGuardNode()) { // linux uses LOAD_STACK_GUARD node instead
+   // of having a canary word global value
+  MachineSDNode *LSG =
+  DAG.getMachineNode(PPC::LOAD_STACK_GUARD, DL, VT, Op->getOperand(0));
+  Load = SDValue(LSG, 0);
+
+  /* frame index used to determine stack guard location if
+   * LOAD_STACK_GUARD is used */
+  MachineFrameInfo  = MF.getFrameInfo();
+  int SPI = MFI.getStackProtectorIndex(); // should return -1
+  PPCFunctionInfo *FuncInfo = MF.getInfo();
+  SDValue FIN = DAG.getFrameIndex(FuncInfo->getVarArgsFrameIndex(), VT);
+
+  // XOR canary word and store back
+  Store = 

[PATCH] D129170: [Sema] Add deprecation warnings for some compiler provided __has_* type traits

2022-07-06 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson updated this revision to Diff 442680.
royjacobson added a comment.

Address CR comments.
Make the switch case slightly more concise.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129170

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/CXX/dcl.decl/dcl.init/p5.cpp
  clang/test/CXX/drs/dr18xx.cpp
  clang/test/CXX/drs/dr21xx.cpp
  clang/test/CXX/special/class.copy/p12-0x.cpp
  clang/test/CXX/special/class.copy/p25-0x.cpp
  clang/test/CXX/special/class.ctor/p5-0x.cpp
  clang/test/Modules/cxx-decls.cpp
  clang/test/SemaCXX/cxx0x-defaulted-functions.cpp
  clang/test/SemaCXX/cxx11-crashes.cpp
  clang/test/SemaCXX/deprecated-builtins.cpp
  clang/test/SemaCXX/sizeless-1.cpp
  clang/test/SemaCXX/trivial-constructor.cpp
  clang/test/SemaCXX/trivial-destructor.cpp
  clang/test/SemaCXX/type-traits.cpp
  clang/test/SemaObjCXX/arc-type-traits.mm
  clang/test/SemaObjCXX/objc-weak-type-traits.mm

Index: clang/test/SemaObjCXX/objc-weak-type-traits.mm
===
--- clang/test/SemaObjCXX/objc-weak-type-traits.mm
+++ clang/test/SemaObjCXX/objc-weak-type-traits.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -fobjc-weak -fobjc-runtime-has-weak -verify -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -fobjc-weak -fobjc-runtime-has-weak -verify -std=c++11 %s -Wno-deprecated-builtins
 // expected-no-diagnostics
 
 // Check the results of the various type-trait query functions on
Index: clang/test/SemaObjCXX/arc-type-traits.mm
===
--- clang/test/SemaObjCXX/arc-type-traits.mm
+++ clang/test/SemaObjCXX/arc-type-traits.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -fobjc-runtime-has-weak -verify -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -fobjc-runtime-has-weak -verify -std=c++11 %s -Wno-deprecated-builtins
 // expected-no-diagnostics
 
 // Check the results of the various type-trait query functions on
Index: clang/test/SemaCXX/type-traits.cpp
===
--- clang/test/SemaCXX/type-traits.cpp
+++ clang/test/SemaCXX/type-traits.cpp
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=gnu++11 -fms-extensions -Wno-microsoft %s
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=gnu++14 -fms-extensions -Wno-microsoft %s
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=gnu++1z -fms-extensions -Wno-microsoft %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=gnu++11 -Wno-deprecated-builtins -fms-extensions -Wno-microsoft %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=gnu++14 -Wno-deprecated-builtins -fms-extensions -Wno-microsoft %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=gnu++1z -Wno-deprecated-builtins -fms-extensions -Wno-microsoft %s
 
 #define T(b) (b) ? 1 : -1
 #define F(b) (b) ? -1 : 1
Index: clang/test/SemaCXX/trivial-destructor.cpp
===
--- clang/test/SemaCXX/trivial-destructor.cpp
+++ clang/test/SemaCXX/trivial-destructor.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 -Wno-deprecated-builtins
 // expected-no-diagnostics
 struct T1 {
 };
Index: clang/test/SemaCXX/trivial-constructor.cpp
===
--- clang/test/SemaCXX/trivial-constructor.cpp
+++ clang/test/SemaCXX/trivial-constructor.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 -Wno-deprecated-builtins
 // expected-no-diagnostics
 struct T1 {
 };
Index: clang/test/SemaCXX/sizeless-1.cpp
===
--- clang/test/SemaCXX/sizeless-1.cpp
+++ clang/test/SemaCXX/sizeless-1.cpp
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify -W -Wall -Wno-unused-but-set-variable -Wrange-loop-analysis -triple arm64-linux-gnu -target-feature +sve -std=c++98 %s
-// RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify -W -Wall -Wno-unused-but-set-variable -Wrange-loop-analysis -triple arm64-linux-gnu -target-feature +sve -std=c++11 %s
-// RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify -W -Wall -Wno-unused-but-set-variable -Wrange-loop-analysis -triple arm64-linux-gnu -target-feature +sve -std=c++17 %s
-// RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -verify -W -Wall -Wno-unused-but-set-variable -Wrange-loop-analysis -triple arm64-linux-gnu -target-feature +sve -std=gnu++17 %s
+// RUN: 

[PATCH] D129226: [clang/mac] Make -mmacos-version-min the canonical spelling over -mmacosx-version-min

2022-07-06 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.
thakis added reviewers: arphaman, dexonsmith.
Herald added a project: All.
thakis requested review of this revision.
Herald added a subscriber: MaskRay.

This was promised 5 years ago in https://reviews.llvm.org/D32796,
let's do it.

Both flags are still accepted. No behavior change except for which
form shows up in --help output and in dumps of internal state
(such as with RC_DEBUG_OPTIONS).


https://reviews.llvm.org/D129226

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/test/Driver/darwin-debug-flags.c


Index: clang/test/Driver/darwin-debug-flags.c
===
--- clang/test/Driver/darwin-debug-flags.c
+++ clang/test/Driver/darwin-debug-flags.c
@@ -9,7 +9,7 @@
 // CHECK-SAME:flags:
 // CHECK-SAME:-I path\\ with\\ spaces
 // CHECK-SAME:-g -Os
-// CHECK-SAME:-mmacosx-version-min=10.5.0
+// CHECK-SAME:-mmacos-version-min=10.5.0
 
 int x;
 
Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1551,7 +1551,7 @@
 options::ID Opt;
 switch (Platform) {
 case DarwinPlatformKind::MacOS:
-  Opt = options::OPT_mmacosx_version_min_EQ;
+  Opt = options::OPT_mmacos_version_min_EQ;
   break;
 case DarwinPlatformKind::IPhoneOS:
   Opt = options::OPT_miphoneos_version_min_EQ;
@@ -1727,7 +1727,7 @@
 Optional
 getDeploymentTargetFromOSVersionArg(DerivedArgList ,
 const Driver ) {
-  Arg *OSXVersion = Args.getLastArg(options::OPT_mmacosx_version_min_EQ);
+  Arg *macOSVersion = Args.getLastArg(options::OPT_mmacos_version_min_EQ);
   Arg *iOSVersion = Args.getLastArg(options::OPT_miphoneos_version_min_EQ,
 
options::OPT_mios_simulator_version_min_EQ);
   Arg *TvOSVersion =
@@ -1736,15 +1736,15 @@
   Arg *WatchOSVersion =
   Args.getLastArg(options::OPT_mwatchos_version_min_EQ,
   options::OPT_mwatchos_simulator_version_min_EQ);
-  if (OSXVersion) {
+  if (macOSVersion) {
 if (iOSVersion || TvOSVersion || WatchOSVersion) {
   TheDriver.Diag(diag::err_drv_argument_not_allowed_with)
-  << OSXVersion->getAsString(Args)
+  << macOSVersion->getAsString(Args)
   << (iOSVersion ? iOSVersion
  : TvOSVersion ? TvOSVersion : WatchOSVersion)
  ->getAsString(Args);
 }
-return DarwinPlatform::createOSVersionArg(Darwin::MacOS, OSXVersion);
+return DarwinPlatform::createOSVersionArg(Darwin::MacOS, macOSVersion);
   } else if (iOSVersion) {
 if (TvOSVersion || WatchOSVersion) {
   TheDriver.Diag(diag::err_drv_argument_not_allowed_with)
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3354,10 +3354,10 @@
 def ffuchsia_api_level_EQ : Joined<["-"], "ffuchsia-api-level=">,
   Group, Flags<[CC1Option]>, HelpText<"Set Fuchsia API level">,
   MarshallingInfoInt>;
-def mmacosx_version_min_EQ : Joined<["-"], "mmacosx-version-min=">,
-  Group, HelpText<"Set Mac OS X deployment target">;
 def mmacos_version_min_EQ : Joined<["-"], "mmacos-version-min=">,
-  Group, Alias;
+  Group, HelpText<"Set macOS deployment target">;
+def : Joined<["-"], "mmacosx-version-min=">,
+  Group, Alias;
 def mms_bitfields : Flag<["-"], "mms-bitfields">, Group, 
Flags<[CC1Option]>,
   HelpText<"Set the default structure layout to be compatible with the 
Microsoft compiler standard">,
   MarshallingInfoFlag>;


Index: clang/test/Driver/darwin-debug-flags.c
===
--- clang/test/Driver/darwin-debug-flags.c
+++ clang/test/Driver/darwin-debug-flags.c
@@ -9,7 +9,7 @@
 // CHECK-SAME:flags:
 // CHECK-SAME:-I path\\ with\\ spaces
 // CHECK-SAME:-g -Os
-// CHECK-SAME:-mmacosx-version-min=10.5.0
+// CHECK-SAME:-mmacos-version-min=10.5.0
 
 int x;
 
Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1551,7 +1551,7 @@
 options::ID Opt;
 switch (Platform) {
 case DarwinPlatformKind::MacOS:
-  Opt = options::OPT_mmacosx_version_min_EQ;
+  Opt = options::OPT_mmacos_version_min_EQ;
   break;
 case DarwinPlatformKind::IPhoneOS:
   Opt = options::OPT_miphoneos_version_min_EQ;
@@ -1727,7 +1727,7 @@
 Optional
 getDeploymentTargetFromOSVersionArg(DerivedArgList ,
 const Driver ) {
-  Arg *OSXVersion = 

[PATCH] D129016: [PowerPC] implemented @llvm.ppc.kill.canary to corrupt stack guard

2022-07-06 Thread Paul Scoropan via Phabricator via cfe-commits
pscoro updated this revision to Diff 442678.
pscoro added a comment.

patch fix


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129016

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Basic/Targets/PPC.cpp
  clang/test/CodeGen/PowerPC/builtins-ppc-stackprotect.c
  llvm/include/llvm/Debuginfod/Debuginfod.h
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/test/CodeGen/PowerPC/kill-canary-intrinsic.ll

Index: llvm/test/CodeGen/PowerPC/kill-canary-intrinsic.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/kill-canary-intrinsic.ll
@@ -0,0 +1,77 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-aix \
+; RUN:   --ppc-asm-full-reg-names < %s | FileCheck %s -check-prefix=AIX
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux \
+; RUN:   --ppc-asm-full-reg-names < %s | FileCheck %s -check-prefix=LINUX
+
+declare void @llvm.ppc.kill.canary()
+define dso_local void @test_kill_canary() {
+; AIX-LABEL: test_kill_canary:
+; AIX:   # %bb.0: # %entry
+; AIX-NEXT:blr
+;
+; LINUX-LABEL: test_kill_canary:
+; LINUX:   # %bb.0: # %entry
+; LINUX-NEXT:blr
+entry:
+  call void @llvm.ppc.kill.canary()
+  ret void
+}
+
+attributes #0 = { sspreq }
+; Function Attrs: sspreq
+define dso_local void @test_kill_canary_ssp() #0 {
+; AIX-LABEL: test_kill_canary_ssp:
+; AIX:   # %bb.0: # %entry
+; AIX-NEXT:mflr r0
+; AIX-NEXT:std r0, 16(r1)
+; AIX-NEXT:stdu r1, -128(r1)
+; AIX-NEXT:ld r3, L..C0(r2) # @__ssp_canary_word
+; AIX-NEXT:ld r4, 0(r3)
+; AIX-NEXT:std r4, 120(r1)
+; AIX-NEXT:ld r4, 0(r3)
+; AIX-NEXT:xori r4, r4, 65535
+; AIX-NEXT:xoris r4, r4, 65535
+; AIX-NEXT:std r4, 0(r3)
+; AIX-NEXT:ld r3, 0(r3)
+; AIX-NEXT:ld r4, 120(r1)
+; AIX-NEXT:cmpld r3, r4
+; AIX-NEXT:bne cr0, L..BB1_2
+; AIX-NEXT:  # %bb.1: # %entry
+; AIX-NEXT:addi r1, r1, 128
+; AIX-NEXT:ld r0, 16(r1)
+; AIX-NEXT:mtlr r0
+; AIX-NEXT:blr
+; AIX-NEXT:  L..BB1_2: # %entry
+; AIX-NEXT:bl .__stack_chk_fail[PR]
+; AIX-NEXT:nop
+;
+; LINUX-LABEL: test_kill_canary_ssp:
+; LINUX:   # %bb.0: # %entry
+; LINUX-NEXT:mflr r0
+; LINUX-NEXT:std r0, 16(r1)
+; LINUX-NEXT:stdu r1, -128(r1)
+; LINUX-NEXT:.cfi_def_cfa_offset 128
+; LINUX-NEXT:.cfi_offset lr, 16
+; LINUX-NEXT:ld r3, -28688(r13)
+; LINUX-NEXT:std r3, 120(r1)
+; LINUX-NEXT:ld r3, -28688(r13)
+; LINUX-NEXT:xori r3, r3, 65535
+; LINUX-NEXT:xoris r3, r3, 65535
+; LINUX-NEXT:std r3, 120(r1)
+; LINUX-NEXT:ld r3, 120(r1)
+; LINUX-NEXT:ld r4, -28688(r13)
+; LINUX-NEXT:cmpld r4, r3
+; LINUX-NEXT:bne cr0, .LBB1_2
+; LINUX-NEXT:  # %bb.1: # %entry
+; LINUX-NEXT:addi r1, r1, 128
+; LINUX-NEXT:ld r0, 16(r1)
+; LINUX-NEXT:mtlr r0
+; LINUX-NEXT:blr
+; LINUX-NEXT:  .LBB1_2: # %entry
+; LINUX-NEXT:bl __stack_chk_fail
+; LINUX-NEXT:nop
+entry:
+  call void @llvm.ppc.kill.canary()
+  ret void
+}
Index: llvm/lib/Target/PowerPC/PPCISelLowering.cpp
===
--- llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -10695,6 +10695,72 @@
Op.getOperand(0)),
 0);
   }
+  case Intrinsic::ppc_kill_canary: {
+MachineFunction  = DAG.getMachineFunction();
+const Module *M = MF.getMMI().getModule();
+
+/* If SafeStack or !StackProtector, kill_canary not supported */
+if (MF.getFunction().hasFnAttribute(Attribute::SafeStack) ||
+!MF.getFunction().hasStackProtectorFnAttr()) {
+  DAG.ReplaceAllUsesOfValueWith(
+  SDValue(Op.getNode(), 0),
+  Op->getOperand(0)); // prepare node for deletion
+  break;
+}
+
+EVT VT = DAG.getTargetLoweringInfo().getPointerTy(DAG.getDataLayout());
+
+SDValue Load;
+SDValue Store;
+
+const uint64_t XORWord =
+0x; // XORing with 0b111...111 will never
+// result in the original word
+
+if (useLoadStackGuardNode()) { // linux uses LOAD_STACK_GUARD node instead
+   // of having a canary word global value
+  MachineSDNode *LSG =
+  DAG.getMachineNode(PPC::LOAD_STACK_GUARD, DL, VT, Op->getOperand(0));
+  Load = SDValue(LSG, 0);
+
+  /* frame index used to determine stack guard location if
+   * LOAD_STACK_GUARD is used */
+  MachineFrameInfo  = MF.getFrameInfo();
+  int SPI = MFI.getStackProtectorIndex(); // should return -1
+  PPCFunctionInfo *FuncInfo = MF.getInfo();
+  SDValue FIN = DAG.getFrameIndex(FuncInfo->getVarArgsFrameIndex(), VT);
+
+  // XOR canary word and store back
+  Store = 

[PATCH] D125916: [PowerPC] Defined and lowered llvm.ppc.kill.canary intrinsic

2022-07-06 Thread Paul Scoropan via Phabricator via cfe-commits
pscoro updated this revision to Diff 442677.
pscoro added a comment.

patch fix


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125916

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Basic/Targets/PPC.cpp
  clang/test/CodeGen/PowerPC/builtins-ppc-stackprotect.c
  llvm/include/llvm/Debuginfod/Debuginfod.h
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/test/CodeGen/PowerPC/kill-canary-intrinsic.ll

Index: llvm/test/CodeGen/PowerPC/kill-canary-intrinsic.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/kill-canary-intrinsic.ll
@@ -0,0 +1,77 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-aix \
+; RUN:   --ppc-asm-full-reg-names < %s | FileCheck %s -check-prefix=AIX
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux \
+; RUN:   --ppc-asm-full-reg-names < %s | FileCheck %s -check-prefix=LINUX
+
+declare void @llvm.ppc.kill.canary()
+define dso_local void @test_kill_canary() {
+; AIX-LABEL: test_kill_canary:
+; AIX:   # %bb.0: # %entry
+; AIX-NEXT:blr
+;
+; LINUX-LABEL: test_kill_canary:
+; LINUX:   # %bb.0: # %entry
+; LINUX-NEXT:blr
+entry:
+  call void @llvm.ppc.kill.canary()
+  ret void
+}
+
+attributes #0 = { sspreq }
+; Function Attrs: sspreq
+define dso_local void @test_kill_canary_ssp() #0 {
+; AIX-LABEL: test_kill_canary_ssp:
+; AIX:   # %bb.0: # %entry
+; AIX-NEXT:mflr r0
+; AIX-NEXT:std r0, 16(r1)
+; AIX-NEXT:stdu r1, -128(r1)
+; AIX-NEXT:ld r3, L..C0(r2) # @__ssp_canary_word
+; AIX-NEXT:ld r4, 0(r3)
+; AIX-NEXT:std r4, 120(r1)
+; AIX-NEXT:ld r4, 0(r3)
+; AIX-NEXT:xori r4, r4, 65535
+; AIX-NEXT:xoris r4, r4, 65535
+; AIX-NEXT:std r4, 0(r3)
+; AIX-NEXT:ld r3, 0(r3)
+; AIX-NEXT:ld r4, 120(r1)
+; AIX-NEXT:cmpld r3, r4
+; AIX-NEXT:bne cr0, L..BB1_2
+; AIX-NEXT:  # %bb.1: # %entry
+; AIX-NEXT:addi r1, r1, 128
+; AIX-NEXT:ld r0, 16(r1)
+; AIX-NEXT:mtlr r0
+; AIX-NEXT:blr
+; AIX-NEXT:  L..BB1_2: # %entry
+; AIX-NEXT:bl .__stack_chk_fail[PR]
+; AIX-NEXT:nop
+;
+; LINUX-LABEL: test_kill_canary_ssp:
+; LINUX:   # %bb.0: # %entry
+; LINUX-NEXT:mflr r0
+; LINUX-NEXT:std r0, 16(r1)
+; LINUX-NEXT:stdu r1, -128(r1)
+; LINUX-NEXT:.cfi_def_cfa_offset 128
+; LINUX-NEXT:.cfi_offset lr, 16
+; LINUX-NEXT:ld r3, -28688(r13)
+; LINUX-NEXT:std r3, 120(r1)
+; LINUX-NEXT:ld r3, -28688(r13)
+; LINUX-NEXT:xori r3, r3, 65535
+; LINUX-NEXT:xoris r3, r3, 65535
+; LINUX-NEXT:std r3, 120(r1)
+; LINUX-NEXT:ld r3, 120(r1)
+; LINUX-NEXT:ld r4, -28688(r13)
+; LINUX-NEXT:cmpld r4, r3
+; LINUX-NEXT:bne cr0, .LBB1_2
+; LINUX-NEXT:  # %bb.1: # %entry
+; LINUX-NEXT:addi r1, r1, 128
+; LINUX-NEXT:ld r0, 16(r1)
+; LINUX-NEXT:mtlr r0
+; LINUX-NEXT:blr
+; LINUX-NEXT:  .LBB1_2: # %entry
+; LINUX-NEXT:bl __stack_chk_fail
+; LINUX-NEXT:nop
+entry:
+  call void @llvm.ppc.kill.canary()
+  ret void
+}
Index: llvm/lib/Target/PowerPC/PPCISelLowering.cpp
===
--- llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -10695,6 +10695,72 @@
Op.getOperand(0)),
 0);
   }
+  case Intrinsic::ppc_kill_canary: {
+MachineFunction  = DAG.getMachineFunction();
+const Module *M = MF.getMMI().getModule();
+
+/* If SafeStack or !StackProtector, kill_canary not supported */
+if (MF.getFunction().hasFnAttribute(Attribute::SafeStack) ||
+!MF.getFunction().hasStackProtectorFnAttr()) {
+  DAG.ReplaceAllUsesOfValueWith(
+  SDValue(Op.getNode(), 0),
+  Op->getOperand(0)); // prepare node for deletion
+  break;
+}
+
+EVT VT = DAG.getTargetLoweringInfo().getPointerTy(DAG.getDataLayout());
+
+SDValue Load;
+SDValue Store;
+
+const uint64_t XORWord =
+0x; // XORing with 0b111...111 will never
+// result in the original word
+
+if (useLoadStackGuardNode()) { // linux uses LOAD_STACK_GUARD node instead
+   // of having a canary word global value
+  MachineSDNode *LSG =
+  DAG.getMachineNode(PPC::LOAD_STACK_GUARD, DL, VT, Op->getOperand(0));
+  Load = SDValue(LSG, 0);
+
+  /* frame index used to determine stack guard location if
+   * LOAD_STACK_GUARD is used */
+  MachineFrameInfo  = MF.getFrameInfo();
+  int SPI = MFI.getStackProtectorIndex(); // should return -1
+  PPCFunctionInfo *FuncInfo = MF.getInfo();
+  SDValue FIN = DAG.getFrameIndex(FuncInfo->getVarArgsFrameIndex(), VT);
+
+  // XOR canary word and store back
+  Store = 

[PATCH] D124690: [clangd] add inlay hints for std::forward-ed parameter packs

2022-07-06 Thread Tobias Ribizel via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa638648fef76: [clangd] add inlay hints for std::forward-ed 
parameter packs (authored by upsj).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124690

Files:
  clang-tools-extra/clangd/AST.cpp
  clang-tools-extra/clangd/AST.h
  clang-tools-extra/clangd/InlayHints.cpp
  clang-tools-extra/clangd/unittests/InlayHintTests.cpp

Index: clang-tools-extra/clangd/unittests/InlayHintTests.cpp
===
--- clang-tools-extra/clangd/unittests/InlayHintTests.cpp
+++ clang-tools-extra/clangd/unittests/InlayHintTests.cpp
@@ -174,6 +174,43 @@
   )cpp");
 }
 
+TEST(ParameterHints, NoNameVariadicDeclaration) {
+  // No hint for anonymous variadic parameter
+  assertParameterHints(R"cpp(
+template 
+void foo(Args&& ...);
+void bar() {
+  foo(42);
+}
+  )cpp");
+}
+
+TEST(ParameterHints, NoNameVariadicForwarded) {
+  // No hint for anonymous variadic parameter
+  // This prototype of std::forward is sufficient for clang to recognize it
+  assertParameterHints(R"cpp(
+namespace std { template  T&& forward(T&); }
+void foo(int);
+template 
+void bar(Args&&... args) { return foo(std::forward(args)...); }
+void baz() {
+  bar(42);
+}
+  )cpp");
+}
+
+TEST(ParameterHints, NoNameVariadicPlain) {
+  // No hint for anonymous variadic parameter
+  assertParameterHints(R"cpp(
+void foo(int);
+template 
+void bar(Args&&... args) { return foo(args...); }
+void baz() {
+  bar(42);
+}
+  )cpp");
+}
+
 TEST(ParameterHints, NameInDefinition) {
   // Parameter name picked up from definition if necessary.
   assertParameterHints(R"cpp(
@@ -186,6 +223,36 @@
ExpectedHint{"param: ", "param"});
 }
 
+TEST(ParameterHints, NamePartiallyInDefinition) {
+  // Parameter name picked up from definition if necessary.
+  assertParameterHints(R"cpp(
+void foo(int, int b);
+void bar() {
+  foo($param1[[42]], $param2[[42]]);
+}
+void foo(int a, int) {};
+  )cpp",
+   ExpectedHint{"a: ", "param1"},
+   ExpectedHint{"b: ", "param2"});
+}
+
+TEST(ParameterHints, NameInDefinitionVariadic) {
+  // Parameter name picked up from definition in a resolved forwarded parameter.
+  assertParameterHints(R"cpp(
+void foo(int, int);
+template 
+void bar(Args... args) {
+  foo(args...);
+}
+void baz() {
+  bar($param1[[42]], $param2[[42]]);
+}
+void foo(int a, int b) {};
+  )cpp",
+   ExpectedHint{"a: ", "param1"},
+   ExpectedHint{"b: ", "param2"});
+}
+
 TEST(ParameterHints, NameMismatch) {
   // Prefer name from declaration.
   assertParameterHints(R"cpp(
@@ -258,6 +325,455 @@
ExpectedHint{"param: ", "param"});
 }
 
+TEST(ParameterHints, VariadicForwardedConstructor) {
+  // Name hint for variadic parameter using std::forward in a constructor call
+  // This prototype of std::forward is sufficient for clang to recognize it
+  assertParameterHints(R"cpp(
+namespace std { template  T&& forward(T&); }
+struct S { S(int a); };
+template 
+T bar(Args&&... args) { return T{std::forward(args)...}; }
+void baz() {
+  int b;
+  bar($param[[b]]);
+}
+  )cpp",
+   ExpectedHint{"a: ", "param"});
+}
+
+TEST(ParameterHints, VariadicPlainConstructor) {
+  // Name hint for variadic parameter in a constructor call
+  assertParameterHints(R"cpp(
+struct S { S(int a); };
+template 
+T bar(Args&&... args) { return T{args...}; }
+void baz() {
+  int b;
+  bar($param[[b]]);
+}
+  )cpp",
+   ExpectedHint{"a: ", "param"});
+}
+
+TEST(ParameterHints, VariadicForwardedNewConstructor) {
+  // Name hint for variadic parameter using std::forward in a new expression
+  // This prototype of std::forward is sufficient for clang to recognize it
+  assertParameterHints(R"cpp(
+namespace std { template  T&& forward(T&); }
+struct S { S(int a); };
+template 
+T* bar(Args&&... args) { return new T{std::forward(args)...}; }
+void baz() {
+  int b;
+  bar($param[[b]]);
+}
+  )cpp",
+   ExpectedHint{"a: ", "param"});
+}
+
+TEST(ParameterHints, VariadicPlainNewConstructor) {
+  // Name hint for variadic parameter in a new expression
+  assertParameterHints(R"cpp(
+struct S { S(int a); };
+template 
+T* bar(Args&&... args) { return new T{args...}; }
+void baz() {
+  int b;
+  bar($param[[b]]);
+}
+  )cpp",
+   ExpectedHint{"a: ", "param"});
+}
+
+TEST(ParameterHints, VariadicForwarded) {
+  // Name for variadic parameter using std::forward
+  // This prototype of std::forward is sufficient for clang to recognize it
+  

[clang-tools-extra] a638648 - [clangd] add inlay hints for std::forward-ed parameter packs

2022-07-06 Thread Tobias Ribizel via cfe-commits

Author: Tobias Ribizel
Date: 2022-07-06T22:23:18+02:00
New Revision: a638648fef76146634c2199ce7b90c4bc6bfed01

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

LOG: [clangd] add inlay hints for std::forward-ed parameter packs

This adds special-case treatment for parameter packs in
make_unique-like functions to forward parameter names to inlay hints.
The parameter packs are being resolved recursively by traversing the
function body of forwarding functions looking for expressions matching
the (std::forwarded) parameters expanded from a pack.
The implementation checks whether parameters are being passed by
(rvalue) reference or value and adds reference inlay hints accordingly.
The traversal has a limited recursion stack depth, and recursive calls
like std::make_tuple are cut off to avoid hinting duplicate parameter
names.

Reviewed By: sammccall

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

Added: 


Modified: 
clang-tools-extra/clangd/AST.cpp
clang-tools-extra/clangd/AST.h
clang-tools-extra/clangd/InlayHints.cpp
clang-tools-extra/clangd/unittests/InlayHintTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/AST.cpp 
b/clang-tools-extra/clangd/AST.cpp
index ca838618badd9..1bf876102f991 100644
--- a/clang-tools-extra/clangd/AST.cpp
+++ b/clang-tools-extra/clangd/AST.cpp
@@ -16,19 +16,23 @@
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/AST/DeclarationName.h"
+#include "clang/AST/ExprCXX.h"
 #include "clang/AST/NestedNameSpecifier.h"
 #include "clang/AST/PrettyPrinter.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/AST/Stmt.h"
 #include "clang/AST/TemplateBase.h"
 #include "clang/AST/TypeLoc.h"
+#include "clang/Basic/Builtins.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/Specifiers.h"
 #include "clang/Index/USRGeneration.h"
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/None.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/raw_ostream.h"
@@ -667,5 +671,300 @@ bool isDeeplyNested(const Decl *D, unsigned MaxDepth) {
   }
   return false;
 }
+
+namespace {
+
+// returns true for `X` in `template  void foo()`
+bool isTemplateTypeParameterPack(NamedDecl *D) {
+  if (const auto *TTPD = dyn_cast(D)) {
+return TTPD->isParameterPack();
+  }
+  return false;
+}
+
+// Returns the template parameter pack type from an instantiated function
+// template, if it exists, nullptr otherwise.
+const TemplateTypeParmType *getFunctionPackType(const FunctionDecl *Callee) {
+  if (const auto *TemplateDecl = Callee->getPrimaryTemplate()) {
+auto TemplateParams = TemplateDecl->getTemplateParameters()->asArray();
+// find the template parameter pack from the back
+const auto It = std::find_if(TemplateParams.rbegin(), 
TemplateParams.rend(),
+ isTemplateTypeParameterPack);
+if (It != TemplateParams.rend()) {
+  const auto *TTPD = dyn_cast(*It);
+  return TTPD->getTypeForDecl()->castAs();
+}
+  }
+  return nullptr;
+}
+
+// Returns the template parameter pack type that this parameter was expanded
+// from (if in the Args... or Args&... or Args&&... form), if this is the case,
+// nullptr otherwise.
+const TemplateTypeParmType *getUnderylingPackType(const ParmVarDecl *Param) {
+  const auto *PlainType = Param->getType().getTypePtr();
+  if (auto *RT = dyn_cast(PlainType))
+PlainType = RT->getPointeeTypeAsWritten().getTypePtr();
+  if (const auto *SubstType = dyn_cast(PlainType)) {
+const auto *ReplacedParameter = SubstType->getReplacedParameter();
+if (ReplacedParameter->isParameterPack()) {
+  return dyn_cast(
+  ReplacedParameter->getCanonicalTypeUnqualified()->getTypePtr());
+}
+  }
+  return nullptr;
+}
+
+// This visitor walks over the body of an instantiated function template.
+// The template accepts a parameter pack and the visitor records whether
+// the pack parameters were forwarded to another call. For example, given:
+//
+// template 
+// auto make_unique(Args... args) {
+//   return unique_ptr(new T(args...));
+// }
+//
+// When called as `make_unique(2, 'x')` this yields a function
+// `make_unique` with two parameters.
+// The visitor records that those two parameters are forwarded to the
+// `constructor std::string(int, char);`.
+//
+// This information is recorded in the `ForwardingInfo` split into fully
+// resolved parameters (passed as argument to a parameter that is not an
+// expanded template type parameter pack) and forwarding parameters (passed to 
a
+// parameter that is an expanded template type 

[PATCH] D129223: [Clang] Fix invalid utf-8 detection

2022-07-06 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

This breaks check-clang: http://45.33.8.238/linux/80462/step_7.txt

Please take a look and revert for now if it takes a while to fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129223

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


[PATCH] D128059: [Clang] Add a warning on invalid UTF-8 in comments.

2022-07-06 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

The bots found a further issue which i committed a fix for directly 
https://reviews.llvm.org/D129223 - I should have caught that sooner


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128059

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


[clang] a60360f - [clang][NFC] Re-generate CommandLineReference.rst

2022-07-06 Thread Louis Dionne via cfe-commits

Author: Louis Dionne
Date: 2022-07-06T16:21:14-04:00
New Revision: a60360f99a6c04f88d223628ed8c6fade195b86b

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

LOG: [clang][NFC] Re-generate CommandLineReference.rst

Added: 


Modified: 
clang/docs/ClangCommandLineReference.rst

Removed: 




diff  --git a/clang/docs/ClangCommandLineReference.rst 
b/clang/docs/ClangCommandLineReference.rst
index 7e53f45c59689..ae110df4148d8 100644
--- a/clang/docs/ClangCommandLineReference.rst
+++ b/clang/docs/ClangCommandLineReference.rst
@@ -1873,6 +1873,10 @@ Enable sanitizer for AMDGPU target
 
 Specify that single precision floating-point divide and sqrt used in the 
program source are correctly rounded (HIP device compilation only)
 
+.. option:: -fhip-kernel-arg-name, -fno-hip-kernel-arg-name
+
+Specify that kernel argument names are preserved (HIP only)
+
 .. option:: -fhip-new-launch-api, -fno-hip-new-launch-api
 
 Use new kernel launching API for HIP
@@ -3439,6 +3443,10 @@ Work around VLLDM erratum CVE-2021-35465 (ARM only)
 
 Work around Cortex-A57 Erratum 1742098 (ARM only)
 
+.. option:: -mframe-chain=
+
+Select the frame chain model used to emit frame records (Arm only).  must 
be 'none', 'aapcs' or 'aapcs+leaf'.
+
 .. option:: -mno-bti-at-return-twice
 
 Do not add a BTI instruction after a setjmp or other return-twice construct 
(Arm/AArch64 only)
@@ -3869,6 +3877,8 @@ X86
 
 .. option:: -mrdpid, -mno-rdpid
 
+.. option:: -mrdpru, -mno-rdpru
+
 .. option:: -mrdrnd, -mno-rdrnd
 
 .. option:: -mrdseed, -mno-rdseed



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


[PATCH] D129223: [Clang] Fix invalid utf-8 detection

2022-07-06 Thread Corentin Jabot via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbf45e27a676d: [Clang] Fix invalid utf-8 detection (authored 
by cor3ntin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129223

Files:
  clang/test/Lexer/comment-invalid-utf8.c
  llvm/lib/Support/ConvertUTF.cpp


Index: llvm/lib/Support/ConvertUTF.cpp
===
--- llvm/lib/Support/ConvertUTF.cpp
+++ llvm/lib/Support/ConvertUTF.cpp
@@ -423,7 +423,7 @@
  */
 unsigned getUTF8SequenceSize(const UTF8 *source, const UTF8 *sourceEnd) {
   int length = trailingBytesForUTF8[*source] + 1;
-  return (length > sourceEnd - source && isLegalUTF8(source, length)) ? length
+  return (length < sourceEnd - source && isLegalUTF8(source, length)) ? length
   : 0;
 }
 
Index: clang/test/Lexer/comment-invalid-utf8.c
===
--- clang/test/Lexer/comment-invalid-utf8.c
+++ clang/test/Lexer/comment-invalid-utf8.c
@@ -25,3 +25,14 @@
 // abcd
 // €abcd
 // expected-warning@-1 {{invalid UTF-8 in comment}}
+
+
+//§ § § 😀 你好 ©
+
+/*§ § § 😀 你好 ©*/
+
+/*
+§ § § 😀 你好 ©
+*/
+
+/* § § § 😀 你好 © */


Index: llvm/lib/Support/ConvertUTF.cpp
===
--- llvm/lib/Support/ConvertUTF.cpp
+++ llvm/lib/Support/ConvertUTF.cpp
@@ -423,7 +423,7 @@
  */
 unsigned getUTF8SequenceSize(const UTF8 *source, const UTF8 *sourceEnd) {
   int length = trailingBytesForUTF8[*source] + 1;
-  return (length > sourceEnd - source && isLegalUTF8(source, length)) ? length
+  return (length < sourceEnd - source && isLegalUTF8(source, length)) ? length
   : 0;
 }
 
Index: clang/test/Lexer/comment-invalid-utf8.c
===
--- clang/test/Lexer/comment-invalid-utf8.c
+++ clang/test/Lexer/comment-invalid-utf8.c
@@ -25,3 +25,14 @@
 // abcd
 // €abcd
 // expected-warning@-1 {{invalid UTF-8 in comment}}
+
+
+//§ § § 😀 你好 ©
+
+/*§ § § 😀 你好 ©*/
+
+/*
+§ § § 😀 你好 ©
+*/
+
+/* § § § 😀 你好 © */
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] bf45e27 - [Clang] Fix invalid utf-8 detection

2022-07-06 Thread Corentin Jabot via cfe-commits

Author: Corentin Jabot
Date: 2022-07-06T22:20:04+02:00
New Revision: bf45e27a676d87944f1f13d5f0d0f39935fc4010

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

LOG: [Clang] Fix invalid utf-8 detection

The length of valid codepoints was incorrectly
calculated which was not caught before because the
absence of tests for the valid codepoints scenario.

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

Added: 


Modified: 
clang/test/Lexer/comment-invalid-utf8.c
llvm/lib/Support/ConvertUTF.cpp

Removed: 




diff  --git a/clang/test/Lexer/comment-invalid-utf8.c 
b/clang/test/Lexer/comment-invalid-utf8.c
index b8bf551dd8564..ed7405a3c079e 100644
--- a/clang/test/Lexer/comment-invalid-utf8.c
+++ b/clang/test/Lexer/comment-invalid-utf8.c
@@ -25,3 +25,14 @@
 // abcd
 // €abcd
 // expected-warning@-1 {{invalid UTF-8 in comment}}
+
+
+//§ § § 😀 你好 ©
+
+/*§ § § 😀 你好 ©*/
+
+/*
+§ § § 😀 你好 ©
+*/
+
+/* § § § 😀 你好 © */

diff  --git a/llvm/lib/Support/ConvertUTF.cpp b/llvm/lib/Support/ConvertUTF.cpp
index c494110cdcee1..25875d4c3184b 100644
--- a/llvm/lib/Support/ConvertUTF.cpp
+++ b/llvm/lib/Support/ConvertUTF.cpp
@@ -423,7 +423,7 @@ Boolean isLegalUTF8Sequence(const UTF8 *source, const UTF8 
*sourceEnd) {
  */
 unsigned getUTF8SequenceSize(const UTF8 *source, const UTF8 *sourceEnd) {
   int length = trailingBytesForUTF8[*source] + 1;
-  return (length > sourceEnd - source && isLegalUTF8(source, length)) ? length
+  return (length < sourceEnd - source && isLegalUTF8(source, length)) ? length
   : 0;
 }
 



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


[PATCH] D129223: [Clang] Fix invalid utf-8 detection

2022-07-06 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
cor3ntin requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

The length of valid codepoints was incorrectly
calculated which was not caught before because the
absence of tests for the valid codepoints scenario.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129223

Files:
  clang/test/Lexer/comment-invalid-utf8.c
  llvm/lib/Support/ConvertUTF.cpp


Index: llvm/lib/Support/ConvertUTF.cpp
===
--- llvm/lib/Support/ConvertUTF.cpp
+++ llvm/lib/Support/ConvertUTF.cpp
@@ -423,7 +423,7 @@
  */
 unsigned getUTF8SequenceSize(const UTF8 *source, const UTF8 *sourceEnd) {
   int length = trailingBytesForUTF8[*source] + 1;
-  return (length > sourceEnd - source && isLegalUTF8(source, length)) ? length
+  return (length < sourceEnd - source && isLegalUTF8(source, length)) ? length
   : 0;
 }
 


Index: llvm/lib/Support/ConvertUTF.cpp
===
--- llvm/lib/Support/ConvertUTF.cpp
+++ llvm/lib/Support/ConvertUTF.cpp
@@ -423,7 +423,7 @@
  */
 unsigned getUTF8SequenceSize(const UTF8 *source, const UTF8 *sourceEnd) {
   int length = trailingBytesForUTF8[*source] + 1;
-  return (length > sourceEnd - source && isLegalUTF8(source, length)) ? length
+  return (length < sourceEnd - source && isLegalUTF8(source, length)) ? length
   : 0;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] fe06b9f - Bringing back the test with the required target related to commit 96515df816ebc3af2a632669a26374745e98b0c5

2022-07-06 Thread Masoud Ataei via cfe-commits

Author: Masoud Ataei
Date: 2022-07-06T13:04:17-07:00
New Revision: fe06b9f02ccddc2843505927fbd38a712d06822d

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

LOG: Bringing back the test with the required target related to commit 
96515df816ebc3af2a632669a26374745e98b0c5

Added: 
clang/test/CodeGen/lower-mass-end-to-end.c

Modified: 


Removed: 




diff  --git a/clang/test/CodeGen/lower-mass-end-to-end.c 
b/clang/test/CodeGen/lower-mass-end-to-end.c
new file mode 100644
index 0..41a65900d4d23
--- /dev/null
+++ b/clang/test/CodeGen/lower-mass-end-to-end.c
@@ -0,0 +1,148 @@
+// REQUIRES: powerpc-registered-target
+// RUN: %clang -mllvm -enable-ppc-gen-scalar-mass -O3 -fapprox-func 
--target=powerpc64le-unknown-linux-gnu -S %s -o -| FileCheck %s 
-check-prefix=CHECK-MASS-AFN
+// RUN: %clang -mllvm -enable-ppc-gen-scalar-mass -Ofast 
--target=powerpc64le-unknown-linux-gnu -S %s -o -| FileCheck %s 
-check-prefix=CHECK-MASS-FAST
+// RUN: %clang -mllvm -enable-ppc-gen-scalar-mass -O3 -fapprox-func 
--target=powerpc-ibm-aix-xcoff -S %s -o -| FileCheck %s 
-check-prefix=CHECK-MASS-AFN
+// RUN: %clang -mllvm -enable-ppc-gen-scalar-mass -Ofast 
--target=powerpc-ibm-aix-xcoff -S %s -o -| FileCheck %s 
-check-prefix=CHECK-MASS-FAST
+
+// RUN: %clang -mllvm -enable-ppc-gen-scalar-mass=false -O3 -fapprox-func 
--target=powerpc64le-unknown-linux-gnu -S %s -o -| FileCheck %s 
-check-prefix=CHECK-NO-MASS-AFN
+// RUN: %clang -mllvm -enable-ppc-gen-scalar-mass=false -Ofast 
--target=powerpc64le-unknown-linux-gnu -S %s -o -| FileCheck %s 
-check-prefix=CHECK-NO-MASS-FAST
+// RUN: %clang -mllvm -enable-ppc-gen-scalar-mass=false -O3 -fapprox-func 
--target=powerpc-ibm-aix-xcoff -S %s -o -| FileCheck %s 
-check-prefix=CHECK-NO-MASS-AFN
+// RUN: %clang -mllvm -enable-ppc-gen-scalar-mass=false -Ofast 
--target=powerpc-ibm-aix-xcoff -S %s -o -| FileCheck %s 
-check-prefix=CHECK-NO-MASS-FAST
+
+// RUN: %clang -mllvm -enable-ppc-gen-scalar-mass -O3 -fno-approx-func 
--target=powerpc64le-unknown-linux-gnu -S %s -o -| FileCheck %s 
-check-prefix=CHECK-NO-MASS-AFN
+// RUN: %clang -mllvm -enable-ppc-gen-scalar-mass -fno-fast-math 
--target=powerpc64le-unknown-linux-gnu -S %s -o -| FileCheck %s 
-check-prefix=CHECK-NO-MASS-FAST
+// RUN: %clang -mllvm -enable-ppc-gen-scalar-mass -O3 -fno-approx-func 
--target=powerpc-ibm-aix-xcoff -S %s -o -| FileCheck %s 
-check-prefix=CHECK-NO-MASS-AFN
+// RUN: %clang -mllvm -enable-ppc-gen-scalar-mass -fno-fast-math 
--target=powerpc-ibm-aix-xcoff -S %s -o -| FileCheck %s 
-check-prefix=CHECK-NO-MASS-FAST
+
+extern double sin(double a);
+extern double cos(double a);
+extern double pow(double a, double b);
+extern double log(double a);
+extern double log10(double a);
+extern double exp(double a);
+extern float sinf(float a);
+extern float cosf(float a);
+extern float powf(float a, float b);
+extern float logf(float a);
+extern float log10f(float a);
+extern float expf(float a);
+
+double sin_f64(double a) {
+// CHECK-LABEL: sin_f64
+// CHECK-MASS-FAST: __xl_sin_finite
+// CHECK-MASS-AFN: __xl_sin
+// CHECK-NO-MASS-FAST-NOT: {{__xl_sin|__xl_sin_finite}}
+// CHECK-NO-MASS-AFN-NOT: {{__xl_sin|__xl_sin_finite}}
+// CHECK: blr
+  return sin(a);
+}
+
+double cos_f64(double a) {
+// CHECK-LABEL: cos_f64
+// CHECK-MASS-FAST: __xl_cos_finite
+// CHECK-MASS-AFN: __xl_cos
+// CHECK-NO-MASS-FAST-NOT: {{__xl_cos|__xl_cos_finite}}
+// CHECK-NO-MASS-AFN-NOT: {{__xl_cos|__xl_cos_finite}}
+// CHECK: blr
+  return cos(a);
+}
+
+double pow_f64(double a, double b) {
+// CHECK-LABEL: pow_f64
+// CHECK-MASS-FAST: __xl_pow_finite
+// CHECK-MASS-AFN: __xl_pow
+// CHECK-NO-MASS-FAST-NOT: {{__xl_pow|__xl_pow_finite}}
+// CHECK-NO-MASS-AFN-NOT: {{__xl_pow|__xl_pow_finite}}
+// CHECK: blr
+  return pow(a, b);
+}
+
+double log_f64(double a) {
+// CHECK-LABEL: log_f64
+// CHECK-MASS-FAST: __xl_log_finite
+// CHECK-MASS-AFN: __xl_log
+// CHECK-NO-MASS-FAST-NOT: {{__xl_log|__xl_log_finite}}
+// CHECK-NO-MASS-AFN-NOT: {{__xl_log|__xl_log_finite}}
+// CHECK: blr
+  return log(a);
+}
+
+double log10_f64(double a) {
+// CHECK-LABEL: log10_f64
+// CHECK-MASS-FAST: __xl_log10_finite
+// CHECK-MASS-AFN: __xl_log10
+// CHECK-NO-MASS-FAST-NOT: {{__xl_log10|__xl_log10_finite}}
+// CHECK-NO-MASS-AFN-NOT: {{__xl_log10|__xl_log10_finite}}
+// CHECK: blr
+  return log10(a);
+}
+
+double exp_f64(double a) {
+// CHECK-LABEL: exp_f64
+// CHECK-MASS-FAST: __xl_exp_finite
+// CHECK-MASS-AFN: __xl_exp
+// CHECK-NO-MASS-FAST-NOT: {{__xl_exp|__xl_exp_finite}}
+// CHECK-NO-MASS-AFN-NOT: {{__xl_exp|__xl_exp_finite}}
+// CHECK: blr
+  return exp(a);
+}
+
+float sin_f32(float a) {
+// CHECK-LABEL: sin_f32
+// CHECK-MASS-FAST: __xl_sinf_finite
+// CHECK-MASS-AFN: __xl_sinf
+// CHECK-NO-MASS-FAST-NOT: 

[PATCH] D128653: [PowerPC] Fix the check for scalar MASS conversion

2022-07-06 Thread Masoud Ataei via Phabricator via cfe-commits
masoud.ataei added a comment.

In D128653#3633704 , @lenary wrote:

> You likely need `// REQUIRES: powerpc-registered-target` in the top of the 
> test, as `-enable-ppc-gen-scalar-mass` is only present if the PowerPC target 
> has been compiled into LLVM.

Thanks, I was looking for that. -- re-committing...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128653

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


[PATCH] D102107: [OpenMP] Codegen aggregate for outlined function captures

2022-07-06 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

Also, make sure to remove all deviceRTL files and probably reset the 
autogenerated tests to upstream (and re-generate) before you merge (or 
reupload).

In D102107#3633678 , @dhruvachak 
wrote:

> I rebased and resolved conflicts just now and got the compiler built. I did 
> not update the tests, hence not updating this review. I see the following 
> outstanding issues:
>
> (1) make check-libomptarget produces a bunch of failures with the following 
> compile-time assertion. So my rebased patch is not interacting correctly with 
> opaque pointers. It is the same assertion for all the failures.
> llvm-project/llvm/include/llvm/IR/Type.h:384: llvm::Type* 
> llvm::Type::getNonOpaquePointerElementType() const: Assertion 
> `NumContainedTys && "Attempting to get element type of opaque pointer"' 
> failed.

See my comment below. I think that's the issue.

> (2) From earlier investigation a couple of months back, this patch uses 
> device alloc and will fail if device allocation is not implemented (e.g. in 
> main branch of amdgpu). Most of these failures are seen at -O0, OpenMPOpt is 
> able to optimize them away at higher opt levels. Are we ok with these 
> failures at -O0?

It used __kmpc_alloc_shared, which should in theory work with O0 (also for 
AMDGPU) but in practice might not, especially if it has to fallback to malloc. 
We are working on malloc support right now. This should not stop us. No 
reasonable code runs with O0 (on AMDGPU) right now.

> (3) There were a few issues found regarding SPDMization, NoCaptureAttrs, 
> alignment that should be applied to this patch. I have those changes on a 
> local branch.

Apply them, I can look over everything again.




Comment at: clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp:1540
+
+llvm::Type *PtrElemTy = AggregateV->getType()->getPointerElementType();
+auto  = CGM.getDataLayout();

This doesn't work anymore with opaque pointers, IIRC. We should remember the 
type and pass to this place.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102107

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


[PATCH] D128653: [PowerPC] Fix the check for scalar MASS conversion

2022-07-06 Thread Sam Elliott via Phabricator via cfe-commits
lenary added a comment.

You likely need `// REQUIRES: powerpc-registered-target` in the top of the 
test, as `-enable-ppc-gen-scalar-mass` is only present if the PowerPC target 
has been compiled into LLVM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128653

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


[PATCH] D128653: [PowerPC] Fix the check for scalar MASS conversion

2022-07-06 Thread Masoud Ataei via Phabricator via cfe-commits
masoud.ataei added a comment.

Just took it down temporarily. -- Looking at it...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128653

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


[clang] d34315e - Removing this test temporarily beacuse of a failure in x86_64

2022-07-06 Thread Masoud Ataei via cfe-commits

Author: Masoud Ataei
Date: 2022-07-06T12:41:13-07:00
New Revision: d34315e71adf2d460770a7d1f8b916c4ff4f9ccd

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

LOG: Removing this test temporarily beacuse of a failure in x86_64

Added: 


Modified: 


Removed: 
clang/test/CodeGen/lower-mass-end-to-end.c



diff  --git a/clang/test/CodeGen/lower-mass-end-to-end.c 
b/clang/test/CodeGen/lower-mass-end-to-end.c
deleted file mode 100644
index 23e50ebc48e9..
--- a/clang/test/CodeGen/lower-mass-end-to-end.c
+++ /dev/null
@@ -1,147 +0,0 @@
-// RUN: %clang -mllvm -enable-ppc-gen-scalar-mass -O3 -fapprox-func 
--target=powerpc64le-unknown-linux-gnu -S %s -o -| FileCheck %s 
-check-prefix=CHECK-MASS-AFN
-// RUN: %clang -mllvm -enable-ppc-gen-scalar-mass -Ofast 
--target=powerpc64le-unknown-linux-gnu -S %s -o -| FileCheck %s 
-check-prefix=CHECK-MASS-FAST
-// RUN: %clang -mllvm -enable-ppc-gen-scalar-mass -O3 -fapprox-func 
--target=powerpc-ibm-aix-xcoff -S %s -o -| FileCheck %s 
-check-prefix=CHECK-MASS-AFN
-// RUN: %clang -mllvm -enable-ppc-gen-scalar-mass -Ofast 
--target=powerpc-ibm-aix-xcoff -S %s -o -| FileCheck %s 
-check-prefix=CHECK-MASS-FAST
-
-// RUN: %clang -mllvm -enable-ppc-gen-scalar-mass=false -O3 -fapprox-func 
--target=powerpc64le-unknown-linux-gnu -S %s -o -| FileCheck %s 
-check-prefix=CHECK-NO-MASS-AFN
-// RUN: %clang -mllvm -enable-ppc-gen-scalar-mass=false -Ofast 
--target=powerpc64le-unknown-linux-gnu -S %s -o -| FileCheck %s 
-check-prefix=CHECK-NO-MASS-FAST
-// RUN: %clang -mllvm -enable-ppc-gen-scalar-mass=false -O3 -fapprox-func 
--target=powerpc-ibm-aix-xcoff -S %s -o -| FileCheck %s 
-check-prefix=CHECK-NO-MASS-AFN
-// RUN: %clang -mllvm -enable-ppc-gen-scalar-mass=false -Ofast 
--target=powerpc-ibm-aix-xcoff -S %s -o -| FileCheck %s 
-check-prefix=CHECK-NO-MASS-FAST
-
-// RUN: %clang -mllvm -enable-ppc-gen-scalar-mass -O3 -fno-approx-func 
--target=powerpc64le-unknown-linux-gnu -S %s -o -| FileCheck %s 
-check-prefix=CHECK-NO-MASS-AFN
-// RUN: %clang -mllvm -enable-ppc-gen-scalar-mass -fno-fast-math 
--target=powerpc64le-unknown-linux-gnu -S %s -o -| FileCheck %s 
-check-prefix=CHECK-NO-MASS-FAST
-// RUN: %clang -mllvm -enable-ppc-gen-scalar-mass -O3 -fno-approx-func 
--target=powerpc-ibm-aix-xcoff -S %s -o -| FileCheck %s 
-check-prefix=CHECK-NO-MASS-AFN
-// RUN: %clang -mllvm -enable-ppc-gen-scalar-mass -fno-fast-math 
--target=powerpc-ibm-aix-xcoff -S %s -o -| FileCheck %s 
-check-prefix=CHECK-NO-MASS-FAST
-
-extern double sin(double a);
-extern double cos(double a);
-extern double pow(double a, double b);
-extern double log(double a);
-extern double log10(double a);
-extern double exp(double a);
-extern float sinf(float a);
-extern float cosf(float a);
-extern float powf(float a, float b);
-extern float logf(float a);
-extern float log10f(float a);
-extern float expf(float a);
-
-double sin_f64(double a) {
-// CHECK-LABEL: sin_f64
-// CHECK-MASS-FAST: __xl_sin_finite
-// CHECK-MASS-AFN: __xl_sin
-// CHECK-NO-MASS-FAST-NOT: {{__xl_sin|__xl_sin_finite}}
-// CHECK-NO-MASS-AFN-NOT: {{__xl_sin|__xl_sin_finite}}
-// CHECK: blr
-  return sin(a);
-}
-
-double cos_f64(double a) {
-// CHECK-LABEL: cos_f64
-// CHECK-MASS-FAST: __xl_cos_finite
-// CHECK-MASS-AFN: __xl_cos
-// CHECK-NO-MASS-FAST-NOT: {{__xl_cos|__xl_cos_finite}}
-// CHECK-NO-MASS-AFN-NOT: {{__xl_cos|__xl_cos_finite}}
-// CHECK: blr
-  return cos(a);
-}
-
-double pow_f64(double a, double b) {
-// CHECK-LABEL: pow_f64
-// CHECK-MASS-FAST: __xl_pow_finite
-// CHECK-MASS-AFN: __xl_pow
-// CHECK-NO-MASS-FAST-NOT: {{__xl_pow|__xl_pow_finite}}
-// CHECK-NO-MASS-AFN-NOT: {{__xl_pow|__xl_pow_finite}}
-// CHECK: blr
-  return pow(a, b);
-}
-
-double log_f64(double a) {
-// CHECK-LABEL: log_f64
-// CHECK-MASS-FAST: __xl_log_finite
-// CHECK-MASS-AFN: __xl_log
-// CHECK-NO-MASS-FAST-NOT: {{__xl_log|__xl_log_finite}}
-// CHECK-NO-MASS-AFN-NOT: {{__xl_log|__xl_log_finite}}
-// CHECK: blr
-  return log(a);
-}
-
-double log10_f64(double a) {
-// CHECK-LABEL: log10_f64
-// CHECK-MASS-FAST: __xl_log10_finite
-// CHECK-MASS-AFN: __xl_log10
-// CHECK-NO-MASS-FAST-NOT: {{__xl_log10|__xl_log10_finite}}
-// CHECK-NO-MASS-AFN-NOT: {{__xl_log10|__xl_log10_finite}}
-// CHECK: blr
-  return log10(a);
-}
-
-double exp_f64(double a) {
-// CHECK-LABEL: exp_f64
-// CHECK-MASS-FAST: __xl_exp_finite
-// CHECK-MASS-AFN: __xl_exp
-// CHECK-NO-MASS-FAST-NOT: {{__xl_exp|__xl_exp_finite}}
-// CHECK-NO-MASS-AFN-NOT: {{__xl_exp|__xl_exp_finite}}
-// CHECK: blr
-  return exp(a);
-}
-
-float sin_f32(float a) {
-// CHECK-LABEL: sin_f32
-// CHECK-MASS-FAST: __xl_sinf_finite
-// CHECK-MASS-AFN: __xl_sinf
-// CHECK-NO-MASS-FAST-NOT: {{__xl_sinf|__xl_sinf_finite}}
-// CHECK-NO-MASS-AFN-NOT: {{__xl_sinf|__xl_sinf_finite}}
-// CHECK: blr
- 

[PATCH] D102107: [OpenMP] Codegen aggregate for outlined function captures

2022-07-06 Thread Dhruva Chakrabarti via Phabricator via cfe-commits
dhruvachak added a comment.

I rebased and resolved conflicts just now and got the compiler built. I did not 
update the tests, hence not updating this review. I see the following 
outstanding issues:

(1) make check-libomptarget produces a bunch of failures with the following 
compile-time assertion. So my rebased patch is not interacting correctly with 
opaque pointers. It is the same assertion for all the failures.
llvm-project/llvm/include/llvm/IR/Type.h:384: llvm::Type* 
llvm::Type::getNonOpaquePointerElementType() const: Assertion `NumContainedTys 
&& "Attempting to get element type of opaque pointer"' failed.

(2) From earlier investigation a couple of months back, this patch uses device 
alloc and will fail if device allocation is not implemented (e.g. in main 
branch of amdgpu). Most of these failures are seen at -O0, OpenMPOpt is able to 
optimize them away at higher opt levels. Are we ok with these failures at -O0?

(3) There were a few issues found regarding SPDMization, NoCaptureAttrs, 
alignment that should be applied to this patch. I have those changes on a local 
branch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102107

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


[PATCH] D128927: [libc++] Always build c++experimental.a

2022-07-06 Thread Louis Dionne via Phabricator via cfe-commits
ldionne updated this revision to Diff 442667.
ldionne added a comment.

Rebase onto main and temporarily disable experimental tests on Windows


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128927

Files:
  clang/cmake/caches/Fuchsia-stage2.cmake
  clang/cmake/caches/Fuchsia.cmake
  compiler-rt/cmake/Modules/AddCompilerRT.cmake
  libcxx/CMakeLists.txt
  libcxx/appveyor.yml
  libcxx/cmake/caches/AIX.cmake
  libcxx/cmake/caches/Apple.cmake
  libcxx/cmake/caches/Generic-no-experimental.cmake
  libcxx/cmake/caches/MinGW.cmake
  libcxx/docs/BuildingLibcxx.rst
  libcxx/docs/ReleaseNotes.rst
  libcxx/docs/UsingLibcxx.rst
  libcxx/src/CMakeLists.txt
  libcxx/test/CMakeLists.txt
  
libcxx/test/libcxx/experimental/memory/memory.resource.global/global_memory_resource_lifetime.pass.cpp
  
libcxx/test/libcxx/experimental/memory/memory.resource.global/new_delete_resource_lifetime.pass.cpp
  
libcxx/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.ctor/default.pass.cpp
  
libcxx/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.eq/equal.pass.cpp
  
libcxx/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.eq/not_equal.pass.cpp
  
libcxx/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/allocate.pass.cpp
  
libcxx/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/construct_pair.pass.cpp
  
libcxx/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/construct_pair_const_lvalue_pair.pass.cpp
  
libcxx/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/construct_pair_rvalue.pass.cpp
  
libcxx/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/construct_pair_values.pass.cpp
  
libcxx/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/construct_piecewise_pair.pass.cpp
  
libcxx/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/construct_piecewise_pair_evil.pass.cpp
  
libcxx/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/construct_types.pass.cpp
  
libcxx/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/deallocate.pass.cpp
  
libcxx/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/destroy.pass.cpp
  
libcxx/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/resource.pass.cpp
  
libcxx/test/std/experimental/memory/memory.polymorphic.allocator.class/memory.polymorphic.allocator.mem/select_on_container_copy_construction.pass.cpp
  
libcxx/test/std/experimental/memory/memory.resource.aliases/header_deque_synop.pass.cpp
  
libcxx/test/std/experimental/memory/memory.resource.aliases/header_forward_list_synop.pass.cpp
  
libcxx/test/std/experimental/memory/memory.resource.aliases/header_list_synop.pass.cpp
  
libcxx/test/std/experimental/memory/memory.resource.aliases/header_map_synop.pass.cpp
  
libcxx/test/std/experimental/memory/memory.resource.aliases/header_regex_synop.pass.cpp
  
libcxx/test/std/experimental/memory/memory.resource.aliases/header_set_synop.pass.cpp
  
libcxx/test/std/experimental/memory/memory.resource.aliases/header_string_synop.pass.cpp
  
libcxx/test/std/experimental/memory/memory.resource.aliases/header_unordered_map_synop.pass.cpp
  
libcxx/test/std/experimental/memory/memory.resource.aliases/header_unordered_set_synop.pass.cpp
  
libcxx/test/std/experimental/memory/memory.resource.aliases/header_vector_synop.pass.cpp
  
libcxx/test/std/experimental/memory/memory.resource.global/default_resource.pass.cpp
  
libcxx/test/std/experimental/memory/memory.resource.global/new_delete_resource.pass.cpp
  
libcxx/test/std/experimental/memory/memory.resource.global/null_memory_resource.pass.cpp
  libcxx/utils/ci/run-buildbot
  libcxx/utils/libcxx/test/params.py

Index: libcxx/utils/libcxx/test/params.py
===
--- libcxx/utils/libcxx/test/params.py
+++ libcxx/utils/libcxx/test/params.py
@@ -62,6 +62,13 @@
 return '-std='+fallbacks[std]
   return None
 
+# TODO: Remove this once all the compilers we support understand `-funstable`
+def getUnstableFlag(cfg):
+  if hasCompileFlag(cfg, '-funstable') and False: # TODO: Enable this once the design of `-funstable` is finished
+return '-funstable'
+  else:
+return '-D_LIBCPP_ENABLE_EXPERIMENTAL -lc++experimental'
+
 DEFAULT_PARAMETERS = [
   Parameter(name='target_triple', type=str,
 help="The target triple to compile the test suite for. This must be "
@@ -156,15 +163,10 @@
 

[PATCH] D129149: [OMPIRBuilder] Add support for simdlen clause

2022-07-06 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D129149#3633627 , @Meinersbur 
wrote:

> Why not have `simdlen` an argument to `applySimd` (which can be null if not 
> used)? In this case it happens to be just adding some metadata, but for 
> others such as `unrollLoopPartial` it does not make sense to have the unroll 
> factor set by a different method. It would also allow better consistency 
> checks if passed as a parameter.

Sure.




Comment at: clang/lib/CodeGen/CGStmtOpenMP.cpp:2596
   // Check for unsupported clauses
-  if (!S.clauses().empty()) {
-// Currently no clause is supported
-return false;
+  for (OMPClause *C : S.clauses()) {
+// Currently only simdlen clause is supported

Meinersbur wrote:
> psoni2628 wrote:
> > shraiysh wrote:
> > > psoni2628 wrote:
> > > > shraiysh wrote:
> > > > > psoni2628 wrote:
> > > > > > psoni2628 wrote:
> > > > > > > arnamoy10 wrote:
> > > > > > > > I am just wondering whether we should have a check to make sure 
> > > > > > > > that we are processing the clauses of only `simd` directive 
> > > > > > > > here. Because the function takes a general 
> > > > > > > > `OMPExecutableDirective` as argument 
> > > > > > > That's a fair point. I guess `isSupportedByOpenMPIRBuilder` could 
> > > > > > > be used for other directive types other than simd, even though 
> > > > > > > it's not right now.
> > > > > > Would it make more sense to only guard the checking of clauses with 
> > > > > > a check for `OMPSimdDirective`, or the whole thing? I believe even 
> > > > > > the code below, which checks for an ordered directive, is also 
> > > > > > specifically for `simd`?
> > > > > > 
> > > > > > 
> > > > > > Example of guarding the whole thing:
> > > > > > 
> > > > > > ```
> > > > > >   if(dyn_cast(S)) {
> > > > > > // Check for unsupported clauses
> > > > > > for (OMPClause *C : S.clauses()) {
> > > > > >   // Currently only simdlen clause is supported
> > > > > >   if (dyn_cast(C))
> > > > > > continue;
> > > > > >   else
> > > > > > return false;
> > > > > > }
> > > > > > 
> > > > > > // Check if we have a statement with the ordered directive.
> > > > > > // Visit the statement hierarchy to find a compound statement
> > > > > > // with a ordered directive in it.
> > > > > > if (const auto *CanonLoop = 
> > > > > > dyn_cast(S.getRawStmt())) {
> > > > > >   if (const Stmt *SyntacticalLoop = CanonLoop->getLoopStmt()) {
> > > > > > for (const Stmt *SubStmt : SyntacticalLoop->children()) {
> > > > > >   if (!SubStmt)
> > > > > > continue;
> > > > > >   if (const CompoundStmt *CS = 
> > > > > > dyn_cast(SubStmt)) {
> > > > > > for (const Stmt *CSSubStmt : CS->children()) {
> > > > > >   if (!CSSubStmt)
> > > > > > continue;
> > > > > >   if (isa(CSSubStmt)) {
> > > > > > return false;
> > > > > >   }
> > > > > > }
> > > > > >   }
> > > > > > }
> > > > > >   }
> > > > > > }
> > > > > >   }
> > > > > > ```
> > > > > Can we instead have separate `isSupportedByOpenMPIRBuilder` for every 
> > > > > directive to avoid bloating the function with checks and if 
> > > > > conditions?
> > > > > ```
> > > > > static bool isSupportedByOpenMPIRBuilder(const OMPSimdDirective ) 
> > > > > {...}
> > > > > void CodeGenFunction::EmitOMPSimdDirective(const OMPSimdDirective ) 
> > > > > {...}
> > > > > 
> > > > > static bool isSupportedByOpenMPIRBuilder(const OMPOrderedDirective 
> > > > > ) {...}
> > > > > void CodeGenFunction::EmitOMPOrderedDirective(const 
> > > > > OMPOrderedDirective ) {...}
> > > > > 
> > > > > static bool isSupportedByOpenMPIRBuilder(const OMPTaskDirective ) 
> > > > > {...}
> > > > > void CodeGenFunction::EmitOMPOrderedDirective(const OMPTaskDirective 
> > > > > ) {...}
> > > > > ```
> > > > It was decided in D114379 to use `OMPExecutableDirective` in order to 
> > > > allow this function to be reused for constructs such as `for simd`. Do 
> > > > you wish to undo this now, and instead specialize the function?
> > > I wasn't aware of the earlier discussion about this. However it seems 
> > > like it was suggested to try either splitting the function or merging it 
> > > with slight preference for merging (I didn't understand how that would 
> > > help constructs like `for simd` because I haven't worked with `for simd` 
> > > much and will take others' word for it).
> > > 
> > > The suggested code change in previous reply - checking of clauses with a 
> > > check for OMPSimdDirective - this seems like it would eventually become a 
> > > huge function because of such checks. 
> > > 
> > > @Meinersbur it would be great if you could please advise on this - if 
> > > keeping the checks for all executable directives in the same function 
> > > will be helpful in the long run - allowing us to reuse 

[PATCH] D128653: [PowerPC] Fix the check for scalar MASS conversion

2022-07-06 Thread Douglas Yung via Phabricator via cfe-commits
dyung added a comment.

Hi @masoud.ataei, the test you added in this commit is failing on the PS4 bot, 
can you take a look?

https://lab.llvm.org/buildbot/#/builders/139/builds/24469

  clang (LLVM option parsing): Unknown command line argument 
'-enable-ppc-gen-scalar-mass'.  Try: 'clang (LLVM option parsing) --help'
  clang (LLVM option parsing): Did you mean '--enable-x86-scalar-amx'?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128653

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


[PATCH] D129222: [pseudo] Implement a guard to determine function declarator.

2022-07-06 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: sammccall.
Herald added a project: All.
hokein requested review of this revision.
Herald added a subscriber: alextsao1999.
Herald added a project: clang-tools-extra.

- emit an enum type to identify each grammar rule (in lhs$$rhs$rhs$ form);
- based on the enum type rule, implement a guard for function declarator, which 
will eliminate some false parses;


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129222

Files:
  clang-tools-extra/pseudo/gen/Main.cpp
  clang-tools-extra/pseudo/include/clang-pseudo/Language.h
  clang-tools-extra/pseudo/include/clang-pseudo/cxx/CXX.h
  clang-tools-extra/pseudo/lib/GLR.cpp
  clang-tools-extra/pseudo/lib/cxx/CXX.cpp
  clang-tools-extra/pseudo/lib/cxx/cxx.bnf
  clang-tools-extra/pseudo/test/cxx/declarator-function.cpp
  clang-tools-extra/pseudo/test/cxx/declarator-var.cpp
  clang-tools-extra/pseudo/unittests/GLRTest.cpp

Index: clang-tools-extra/pseudo/unittests/GLRTest.cpp
===
--- clang-tools-extra/pseudo/unittests/GLRTest.cpp
+++ clang-tools-extra/pseudo/unittests/GLRTest.cpp
@@ -635,7 +635,7 @@
   )bnf");
   TestLang.Guards.try_emplace(
   extensionID("TestOnly"),
-  [&](llvm::ArrayRef RHS, const TokenStream ) {
+  [&](RuleID RID, llvm::ArrayRef RHS, const TokenStream ) {
 assert(RHS.size() == 1 &&
RHS.front()->symbol() == tokenSymbol(clang::tok::identifier));
 return Tokens.tokens()[RHS.front()->startTokenIndex()].text() == "test";
Index: clang-tools-extra/pseudo/test/cxx/declarator-var.cpp
===
--- clang-tools-extra/pseudo/test/cxx/declarator-var.cpp
+++ clang-tools-extra/pseudo/test/cxx/declarator-var.cpp
@@ -1,8 +1,6 @@
 // The standard grammar allows an function-body to use any declarator, including
 // a non-function declarator. This creates an ambiguity where a
 // simple-declaration is misparsed as a function-definition.
-// FIXME: eliminate this false parse.
-// XFAIL: *
 
 // RUN: clang-pseudo -grammar=cxx -source=%s --print-forest | FileCheck %s
 void (*s)(){};
Index: clang-tools-extra/pseudo/test/cxx/declarator-function.cpp
===
--- clang-tools-extra/pseudo/test/cxx/declarator-function.cpp
+++ clang-tools-extra/pseudo/test/cxx/declarator-function.cpp
@@ -1,11 +1,28 @@
 // The standard grammar allows an init-list with any declarator, including
 // a function declarator. This creates an ambiguity where a function-definition
 // is misparsed as a simple-declaration.
-// FIXME: eliminate this false parse.
-// XFAIL: *
 
 // RUN: clang-pseudo -grammar=cxx -source=%s --print-forest | FileCheck %s
 void s(){};
-// CHECK-NOT:  simple-declaration
-// CHECK:  function-definition := decl-specifier-seq declarator
-// function-body CHECK-NOT:  simple-declaration
+// CHECK:  ├─declaration-seq~function-definition := decl-specifier-seq declarator function-body [guard=FunctionDeclarator]
+// CHECK-NEXT: │ ├─decl-specifier-seq~VOID := tok[0]
+// CHECK-NEXT: │ ├─declarator~noptr-declarator := noptr-declarator parameters-and-qualifiers
+// CHECK-NEXT: │ │ ├─noptr-declarator~IDENTIFIER := tok[1]
+// CHECK-NEXT: │ │ └─parameters-and-qualifiers := ( )
+// CHECK-NEXT: │ │   ├─( := tok[2]
+// CHECK-NEXT: │ │   └─) := tok[3]
+// CHECK-NEXT: │ └─function-body~compound-statement := { }
+// CHECK-NEXT: │   ├─{ := tok[4]
+// CHECK-NEXT: │   └─} := tok[5]
+// CHECK-NEXT: └─declaration~; := tok[6]
+
+// Should not parse as a function-definition.
+int s2{};
+// CHECK-NEXT:  declaration~simple-declaration := decl-specifier-seq init-declarator-list ;
+// CHECK-NEXT:  ├─decl-specifier-seq~INT := tok[7]
+// CHECK-NEXT:  ├─init-declarator-list~init-declarator := declarator initializer [guard=NotFunctionDeclarator]
+// CHECK-NEXT:  │ ├─declarator~IDENTIFIER := tok[8]
+// CHECK-NEXT:  │ └─initializer~braced-init-list := { }
+// CHECK-NEXT:  │   ├─{ := tok[9]
+// CHECK-NEXT:  │   └─} := tok[10]
+// CHECK-NEXT:  └─; := tok[11]
Index: clang-tools-extra/pseudo/lib/cxx/cxx.bnf
===
--- clang-tools-extra/pseudo/lib/cxx/cxx.bnf
+++ clang-tools-extra/pseudo/lib/cxx/cxx.bnf
@@ -402,7 +402,7 @@
 placeholder-type-specifier := type-constraint_opt DECLTYPE ( AUTO )
 init-declarator-list := init-declarator
 init-declarator-list := init-declarator-list , init-declarator
-init-declarator := declarator initializer_opt
+init-declarator := declarator initializer_opt [guard=NotFunctionDeclarator]
 init-declarator := declarator requires-clause
 declarator := ptr-declarator
 declarator := noptr-declarator parameters-and-qualifiers trailing-return-type
@@ -472,8 +472,8 @@
 expr-or-braced-init-list := expression
 

[PATCH] D122255: Meta directive runtime support

2022-07-06 Thread Abid via Phabricator via cfe-commits
abidmalikwaterloo updated this revision to Diff 442661.
abidmalikwaterloo marked 14 inline comments as done.
abidmalikwaterloo added a comment.

Updated and clean the code based on the comments from 
the reviewer!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122255

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/StmtOpenMP.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/test/OpenMP/metadirective_ast_print_new_1.cpp
  clang/test/OpenMP/metadirective_ast_print_new_2.cpp
  clang/test/OpenMP/metadirective_ast_print_new_3.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPContext.h
  llvm/lib/Frontend/OpenMP/OMPContext.cpp

Index: llvm/lib/Frontend/OpenMP/OMPContext.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPContext.cpp
+++ llvm/lib/Frontend/OpenMP/OMPContext.cpp
@@ -20,6 +20,7 @@
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/raw_ostream.h"
 
+#include 
 #define DEBUG_TYPE "openmp-ir-builder"
 
 using namespace llvm;
@@ -339,6 +340,45 @@
   return Score;
 }
 
+/// Takes \p VMI and \p Ctx and sort the 
+/// scores using \p VectorOfClauses
+void llvm::omp::getArrayVariantMatchForContext(const SmallVectorImpl ,
+const OMPContext , SmallVector> ){
+	
+//APInt BestScore(64, 0);
+APInt Score (64, 0);
+//The MapOfClauses will contain the index of the cluase and its context socre
+llvm::DenseMap MapOfCluases;
+		
+for (unsigned u = 0, e = VMIs.size(); u < e; ++u) {
+  const VariantMatchInfo  = VMIs[u];
+
+  SmallVector ConstructMatches;
+  // If the variant is not applicable its not the best.
+  if (!isVariantApplicableInContextHelper(VMI, Ctx, ,
+   /* DeviceSetOnly */ false)){
+Score = 0;
+// adding index and its corresdoning score
+MapOfCluases.insert({u, Score});
+  	continue;	
+  }
+   	// Else get the score
+  Score = getVariantMatchScore(VMI, Ctx, ConstructMatches);
+  MapOfCluases.insert({u, Score});	
+}
+			
+for (auto& it : MapOfCluases) 
+  VectorOfClauses.push_back(it);
+  
+// The following Lamda will sort the VectorOfClauses based on the score	
+std::sort(VectorOfClauses.begin(), VectorOfClauses.end(), [] (std::pair,
+	std::pair){	
+	return a.second.ugt(b.second);
+});	
+}
+ 
+
+
 int llvm::omp::getBestVariantMatchForContext(
 const SmallVectorImpl , const OMPContext ) {
 
Index: llvm/include/llvm/Frontend/OpenMP/OMPContext.h
===
--- llvm/include/llvm/Frontend/OpenMP/OMPContext.h
+++ llvm/include/llvm/Frontend/OpenMP/OMPContext.h
@@ -189,6 +189,15 @@
 int getBestVariantMatchForContext(const SmallVectorImpl ,
   const OMPContext );
 
+/// Sort array \p A of clause index  with score
+/// This will be used to produce AST clauses
+/// in a sorted order with the clause with the highiest order
+/// on the top and default clause at the bottom
+void getArrayVariantMatchForContext(
+const SmallVectorImpl , const OMPContext ,
+SmallVector> );
+
+// new--
 } // namespace omp
 
 template <> struct DenseMapInfo {
Index: clang/test/OpenMP/metadirective_ast_print_new_3.cpp
===
--- /dev/null
+++ clang/test/OpenMP/metadirective_ast_print_new_3.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -verify  -fopenmp  -ast-print %s -o - | FileCheck %s
+// expected-no-diagnostics
+
+int main() {
+  int N = 15;
+#pragma omp metadirective when(user = {condition(N > 10)} : parallel for)\
+ default(target teams) 
+  for (int i = 0; i < N; i++)
+;
+
+
+#pragma omp metadirective when(device = {arch("nvptx64")}, user = {condition(N >= 100)} : parallel for)\
+  default(target parallel for)
+  for (int i = 0; i < N; i++)
+;
+  return 0;
+}
+
+
+
+// CHECK: #pragma omp metadirective when(user={condition(N > 10)}: parallel for) default(target teams)
+// CHECK: #pragma omp metadirective when(device={arch(nvptx64)}, user={condition(N >= 100)}: parallel for) default(target parallel for)
Index: clang/test/OpenMP/metadirective_ast_print_new_2.cpp
===
--- /dev/null
+++ clang/test/OpenMP/metadirective_ast_print_new_2.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -verify  -fopenmp  -ast-print %s -o - | FileCheck %s
+// expected-no-diagnostics
+
+void bar(){
+	int i=0;	
+}
+
+void myfoo(void){
+
+	int N = 13;
+	int b,n;
+	int a[100];
+
+	
+	#pragma omp  

[PATCH] D128059: [Clang] Add a warning on invalid UTF-8 in comments.

2022-07-06 Thread Corentin Jabot 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 rG4174f0ca618b: [Clang] Add a warning on invalid UTF-8 in 
comments. (authored by cor3ntin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128059

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/lib/Lex/Lexer.cpp
  clang/test/Lexer/comment-invalid-utf8.c
  clang/test/SemaCXX/static-assert.cpp
  llvm/include/llvm/Support/ConvertUTF.h
  llvm/lib/Support/ConvertUTF.cpp

Index: llvm/lib/Support/ConvertUTF.cpp
===
--- llvm/lib/Support/ConvertUTF.cpp
+++ llvm/lib/Support/ConvertUTF.cpp
@@ -417,6 +417,16 @@
 return isLegalUTF8(source, length);
 }
 
+/*
+ * Exported function to return the size of the first utf-8 code unit sequence,
+ * Or 0 if the sequence is not valid;
+ */
+unsigned getUTF8SequenceSize(const UTF8 *source, const UTF8 *sourceEnd) {
+  int length = trailingBytesForUTF8[*source] + 1;
+  return (length > sourceEnd - source && isLegalUTF8(source, length)) ? length
+  : 0;
+}
+
 /* - */
 
 static unsigned
Index: llvm/include/llvm/Support/ConvertUTF.h
===
--- llvm/include/llvm/Support/ConvertUTF.h
+++ llvm/include/llvm/Support/ConvertUTF.h
@@ -181,6 +181,8 @@
 
 Boolean isLegalUTF8String(const UTF8 **source, const UTF8 *sourceEnd);
 
+unsigned getUTF8SequenceSize(const UTF8 *source, const UTF8 *sourceEnd);
+
 unsigned getNumBytesForUTF8(UTF8 firstByte);
 
 /*/
Index: clang/test/SemaCXX/static-assert.cpp
===
--- clang/test/SemaCXX/static-assert.cpp
+++ clang/test/SemaCXX/static-assert.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 -pedantic -triple=x86_64-linux-gnu
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 -pedantic -triple=x86_64-linux-gnu -Wno-invalid-utf8
 
 int f(); // expected-note {{declared here}}
 
Index: clang/test/Lexer/comment-invalid-utf8.c
===
--- /dev/null
+++ clang/test/Lexer/comment-invalid-utf8.c
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -fsyntax-only %s -Winvalid-utf8 -verify=expected
+// RUN: %clang_cc1 -fsyntax-only %s -verify=nowarn
+// nowarn-no-diagnostics
+
+// This file is purposefully encoded as windows-1252
+// be careful when modifying.
+
+//€
+// expected-warning@-1 {{invalid UTF-8 in comment}}
+
+// € ‚ƒ„…†‡ˆ‰ Š ‹ Œ Ž
+// expected-warning@-1 6{{invalid UTF-8 in comment}}
+
+/*€*/
+// expected-warning@-1 {{invalid UTF-8 in comment}}
+
+/*€ ‚ƒ„…†‡ˆ‰ Š ‹ Œ Ž*/
+// expected-warning@-1 6{{invalid UTF-8 in comment}}
+
+/*
+€
+*/
+// expected-warning@-2 {{invalid UTF-8 in comment}}
+
+// abcd
+// €abcd
+// expected-warning@-1 {{invalid UTF-8 in comment}}
Index: clang/lib/Lex/Lexer.cpp
===
--- clang/lib/Lex/Lexer.cpp
+++ clang/lib/Lex/Lexer.cpp
@@ -2392,13 +2392,37 @@
   //
   // This loop terminates with CurPtr pointing at the newline (or end of buffer)
   // character that ends the line comment.
+
+  // C++23 [lex.phases] p1
+  // Diagnose invalid UTF-8 if the corresponding warning is enabled, emitting a
+  // diagnostic only once per entire ill-formed subsequence to avoid
+  // emiting to many diagnostics (see http://unicode.org/review/pr-121.html).
+  bool UnicodeDecodingAlreadyDiagnosed = false;
+
   char C;
   while (true) {
 C = *CurPtr;
 // Skip over characters in the fast loop.
-while (C != 0 &&// Potentially EOF.
-   C != '\n' && C != '\r')  // Newline or DOS-style newline.
+while (isASCII(C) && C != 0 &&   // Potentially EOF.
+   C != '\n' && C != '\r') { // Newline or DOS-style newline.
   C = *++CurPtr;
+  UnicodeDecodingAlreadyDiagnosed = false;
+}
+
+if (!isASCII(C)) {
+  unsigned Length = llvm::getUTF8SequenceSize(
+  (const llvm::UTF8 *)CurPtr, (const llvm::UTF8 *)BufferEnd);
+  if (Length == 0) {
+if (!UnicodeDecodingAlreadyDiagnosed && !isLexingRawMode())
+  Diag(CurPtr, diag::warn_invalid_utf8_in_comment);
+UnicodeDecodingAlreadyDiagnosed = true;
+++CurPtr;
+  } else {
+UnicodeDecodingAlreadyDiagnosed = false;
+CurPtr += Length;
+  }
+  continue;
+}
 
 const char *NextLine = CurPtr;
 if (C != 0) {
@@ -2665,6 +2689,12 @@
   if (C == '/')
 C = *CurPtr++;
 
+  // C++23 [lex.phases] p1
+  // Diagnose invalid UTF-8 if the corresponding warning is 

[clang] 4174f0c - [Clang] Add a warning on invalid UTF-8 in comments.

2022-07-06 Thread Corentin Jabot via cfe-commits

Author: Corentin Jabot
Date: 2022-07-06T21:18:29+02:00
New Revision: 4174f0ca618b467571b43cff12cbe4c4239670f8

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

LOG: [Clang] Add a warning on invalid UTF-8 in comments.

Introduce an off-by default `-Winvalid-utf8` warning
that detects invalid UTF-8 code units sequences in comments.

Invalid UTF-8 in other places is already diagnosed,
as that cannot appear in identifiers and other grammar constructs.

The warning is off by default as its likely to be somewhat disruptive
otherwise.

This warning allows clang to conform to the yet-to be approved WG21
"P2295R5 Support for UTF-8 as a portable source file encoding"
paper.

Reviewed By: aaron.ballman, #clang-language-wg

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

Added: 
clang/test/Lexer/comment-invalid-utf8.c

Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/DiagnosticLexKinds.td
clang/lib/Lex/Lexer.cpp
clang/test/SemaCXX/static-assert.cpp
llvm/include/llvm/Support/ConvertUTF.h
llvm/lib/Support/ConvertUTF.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 0f542e08b841..c50e1b89649c 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -279,6 +279,8 @@ Improvements to Clang's diagnostics
   unevaluated operands of a ``typeid`` expression, as they are now
   modeled correctly in the CFG. This fixes
   `Issue 21668 `_.
+- Added ``-Winvalid-utf8`` which diagnoses invalid UTF-8 code unit sequences in
+  comments.
 
 Non-comprehensive list of changes in this release
 -
@@ -576,7 +578,7 @@ AST Matchers
 
 - Added ``forEachTemplateArgument`` matcher which creates a match every
   time a ``templateArgument`` matches the matcher supplied to it.
-  
+
 - Added ``objcStringLiteral`` matcher which matches ObjectiveC String
   literal expressions.
 

diff  --git a/clang/include/clang/Basic/DiagnosticLexKinds.td 
b/clang/include/clang/Basic/DiagnosticLexKinds.td
index ac86076140c5..38ee022e5f04 100644
--- a/clang/include/clang/Basic/DiagnosticLexKinds.td
+++ b/clang/include/clang/Basic/DiagnosticLexKinds.td
@@ -113,6 +113,8 @@ def warn_four_char_character_literal : Warning<
 // Unicode and UCNs
 def err_invalid_utf8 : Error<
   "source file is not valid UTF-8">;
+def warn_invalid_utf8_in_comment : Extension<
+  "invalid UTF-8 in comment">, InGroup>;
 def err_character_not_allowed : Error<
   "unexpected character ">;
 def err_character_not_allowed_identifier : Error<

diff  --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp
index 6820057642be..351e518c7ed3 100644
--- a/clang/lib/Lex/Lexer.cpp
+++ b/clang/lib/Lex/Lexer.cpp
@@ -2392,13 +2392,37 @@ bool Lexer::SkipLineComment(Token , const char 
*CurPtr,
   //
   // This loop terminates with CurPtr pointing at the newline (or end of 
buffer)
   // character that ends the line comment.
+
+  // C++23 [lex.phases] p1
+  // Diagnose invalid UTF-8 if the corresponding warning is enabled, emitting a
+  // diagnostic only once per entire ill-formed subsequence to avoid
+  // emiting to many diagnostics (see http://unicode.org/review/pr-121.html).
+  bool UnicodeDecodingAlreadyDiagnosed = false;
+
   char C;
   while (true) {
 C = *CurPtr;
 // Skip over characters in the fast loop.
-while (C != 0 &&// Potentially EOF.
-   C != '\n' && C != '\r')  // Newline or DOS-style newline.
+while (isASCII(C) && C != 0 &&   // Potentially EOF.
+   C != '\n' && C != '\r') { // Newline or DOS-style newline.
   C = *++CurPtr;
+  UnicodeDecodingAlreadyDiagnosed = false;
+}
+
+if (!isASCII(C)) {
+  unsigned Length = llvm::getUTF8SequenceSize(
+  (const llvm::UTF8 *)CurPtr, (const llvm::UTF8 *)BufferEnd);
+  if (Length == 0) {
+if (!UnicodeDecodingAlreadyDiagnosed && !isLexingRawMode())
+  Diag(CurPtr, diag::warn_invalid_utf8_in_comment);
+UnicodeDecodingAlreadyDiagnosed = true;
+++CurPtr;
+  } else {
+UnicodeDecodingAlreadyDiagnosed = false;
+CurPtr += Length;
+  }
+  continue;
+}
 
 const char *NextLine = CurPtr;
 if (C != 0) {
@@ -2665,6 +2689,12 @@ bool Lexer::SkipBlockComment(Token , const char 
*CurPtr,
   if (C == '/')
 C = *CurPtr++;
 
+  // C++23 [lex.phases] p1
+  // Diagnose invalid UTF-8 if the corresponding warning is enabled, emitting a
+  // diagnostic only once per entire ill-formed subsequence to avoid
+  // emiting to many diagnostics (see http://unicode.org/review/pr-121.html).
+  bool UnicodeDecodingAlreadyDiagnosed = false;
+
   while (true) {
 // Skip over all non-interesting 

[PATCH] D129149: [OMPIRBuilder] Add support for simdlen clause

2022-07-06 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added a comment.

Why not have `simdlen` an argument to `applySimd` (which can be null if not 
used)? In this case it happens to be just adding some metadata, but for others 
such as `unrollLoopPartial` it does not make sense to have the unroll factor 
set by a different method. It would also allow better consistency checks if 
passed as a parameter.




Comment at: clang/lib/CodeGen/CGStmtOpenMP.cpp:2596
   // Check for unsupported clauses
-  if (!S.clauses().empty()) {
-// Currently no clause is supported
-return false;
+  for (OMPClause *C : S.clauses()) {
+// Currently only simdlen clause is supported

psoni2628 wrote:
> shraiysh wrote:
> > psoni2628 wrote:
> > > shraiysh wrote:
> > > > psoni2628 wrote:
> > > > > psoni2628 wrote:
> > > > > > arnamoy10 wrote:
> > > > > > > I am just wondering whether we should have a check to make sure 
> > > > > > > that we are processing the clauses of only `simd` directive here. 
> > > > > > > Because the function takes a general `OMPExecutableDirective` as 
> > > > > > > argument 
> > > > > > That's a fair point. I guess `isSupportedByOpenMPIRBuilder` could 
> > > > > > be used for other directive types other than simd, even though it's 
> > > > > > not right now.
> > > > > Would it make more sense to only guard the checking of clauses with a 
> > > > > check for `OMPSimdDirective`, or the whole thing? I believe even the 
> > > > > code below, which checks for an ordered directive, is also 
> > > > > specifically for `simd`?
> > > > > 
> > > > > 
> > > > > Example of guarding the whole thing:
> > > > > 
> > > > > ```
> > > > >   if(dyn_cast(S)) {
> > > > > // Check for unsupported clauses
> > > > > for (OMPClause *C : S.clauses()) {
> > > > >   // Currently only simdlen clause is supported
> > > > >   if (dyn_cast(C))
> > > > > continue;
> > > > >   else
> > > > > return false;
> > > > > }
> > > > > 
> > > > > // Check if we have a statement with the ordered directive.
> > > > > // Visit the statement hierarchy to find a compound statement
> > > > > // with a ordered directive in it.
> > > > > if (const auto *CanonLoop = 
> > > > > dyn_cast(S.getRawStmt())) {
> > > > >   if (const Stmt *SyntacticalLoop = CanonLoop->getLoopStmt()) {
> > > > > for (const Stmt *SubStmt : SyntacticalLoop->children()) {
> > > > >   if (!SubStmt)
> > > > > continue;
> > > > >   if (const CompoundStmt *CS = 
> > > > > dyn_cast(SubStmt)) {
> > > > > for (const Stmt *CSSubStmt : CS->children()) {
> > > > >   if (!CSSubStmt)
> > > > > continue;
> > > > >   if (isa(CSSubStmt)) {
> > > > > return false;
> > > > >   }
> > > > > }
> > > > >   }
> > > > > }
> > > > >   }
> > > > > }
> > > > >   }
> > > > > ```
> > > > Can we instead have separate `isSupportedByOpenMPIRBuilder` for every 
> > > > directive to avoid bloating the function with checks and if conditions?
> > > > ```
> > > > static bool isSupportedByOpenMPIRBuilder(const OMPSimdDirective ) 
> > > > {...}
> > > > void CodeGenFunction::EmitOMPSimdDirective(const OMPSimdDirective ) 
> > > > {...}
> > > > 
> > > > static bool isSupportedByOpenMPIRBuilder(const OMPOrderedDirective ) 
> > > > {...}
> > > > void CodeGenFunction::EmitOMPOrderedDirective(const OMPOrderedDirective 
> > > > ) {...}
> > > > 
> > > > static bool isSupportedByOpenMPIRBuilder(const OMPTaskDirective ) 
> > > > {...}
> > > > void CodeGenFunction::EmitOMPOrderedDirective(const OMPTaskDirective 
> > > > ) {...}
> > > > ```
> > > It was decided in D114379 to use `OMPExecutableDirective` in order to 
> > > allow this function to be reused for constructs such as `for simd`. Do 
> > > you wish to undo this now, and instead specialize the function?
> > I wasn't aware of the earlier discussion about this. However it seems like 
> > it was suggested to try either splitting the function or merging it with 
> > slight preference for merging (I didn't understand how that would help 
> > constructs like `for simd` because I haven't worked with `for simd` much 
> > and will take others' word for it).
> > 
> > The suggested code change in previous reply - checking of clauses with a 
> > check for OMPSimdDirective - this seems like it would eventually become a 
> > huge function because of such checks. 
> > 
> > @Meinersbur it would be great if you could please advise on this - if 
> > keeping the checks for all executable directives in the same function will 
> > be helpful in the long run - allowing us to reuse checks or should we split 
> > it? A third alternative would be to have both functions, one specialized 
> > for SIMD and one for ExecutableConstruct, where the latter might handle 
> > combined constructs like `for simd` etc. Would that arrangement work?
> I agree with you that having a general function for 

[PATCH] D129202: [clang] Add a fixit for warn-self-assign if LHS is a field with the same name as parameter on RHS

2022-07-06 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Thank you for working on this, I think it's a nice new diagnostic. You should 
add a release note to describe it. One question I have is about how chatty this 
is over real world code, especially older code bases. There used to be two 
prevailing ways to silence the "unused variable" warnings you would get when a 
variable is used in an `assert`: `(void)whatever;` and `whatever = whatever;`; 
I'm worried the latter case is still prevalent enough that having this warning 
on by default would be a problem, but I'm also optimistic my worry is unfounded.




Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:6617
+def note_self_assign_insert_this : Note<
+  "did you mean to assign to member %0">;
 

We don't normally have trailing punctuation... except for question marks which 
we will happily use when asking the user a question.



Comment at: clang/lib/Sema/SemaExpr.cpp:14645-14650
+  if (!llvm::isa(RHSDecl))
+return;
+  if (auto *Method =
+  llvm::dyn_cast_or_null(S.getCurFunctionDecl(true))) {
+
+CXXRecordDecl *Parent = Method->getParent();

Removing the `llvm::` from those mostly because we already call `cast<>` 
without the prefix. Oddly, I find myself liking the `llvm::` in `llvm::find_if` 
though, so take or leave the suggestions about it.



Comment at: clang/lib/Sema/SemaExpr.cpp:14656
+
+// Only check the fields declared in Parent, without traversing base 
classes
+auto Field = llvm::find_if(

Why wouldn't we want to look through base classes for a member there? 
Considering a case like:
```
struct Base {
  int X;
};

struct Derived : Base {
  Derived(int X) { X = X; } // Oops
};
```
it seems like we would want to use a real lookup operation instead of the 
fields of the class. Or did you try that and found it was a performance concern?



Comment at: clang/lib/Sema/SemaExpr.cpp:14661-14664
+if (Field != Parent->fields().end())
+  S.Diag(LHSDeclRef->getBeginLoc(), diag::note_self_assign_insert_this)
+  << *Field
+  << FixItHint::CreateInsertion(LHSDeclRef->getBeginLoc(), "this->");

Use of a note like this isn't awful, but I'm not super happy that the note 
always shows up on the same line as the warning. It seems like it would be 
cleaner (in terms of the user experience) to use a `%select` on the warning 
diagnostic to decide whether to add the "did you mean" information, and 
associate the fix directly with the warning. However, there's a slight 
functional difference with that approach which may matter to you: fixits 
attached to a note are not automatically applied when in fixit mode, but they 
are when attached to a warning or error. I don't know a reason why applying the 
fix-it automatically would be a bad thing in this case, so use of a note loses 
a bit of useful functionality.



Comment at: clang/test/SemaCXX/warn-self-assign-builtin.cpp:69-73
+struct Foo {
+  int A;
+  void setA(int A) {
+A = A; // expected-warning{{explicitly assigning}} expected-note {{did you 
mean to assign to member 'A'}}
+  }

An additional test case I'd like to see is:
```
struct S {
  int X;

  S(int X) : X(X) {} // Don't warn about this
};
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129202

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


[PATCH] D129198: [clang] Correct the macOS version that supports aligned allocation

2022-07-06 Thread Louis Dionne 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 rG4722b5d1330a: [clang] Correct the macOS version that 
supports aligned allocation (authored by ldionne).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129198

Files:
  clang/include/clang/Basic/AlignedAllocation.h
  clang/test/Driver/unavailable_aligned_allocation.cpp
  clang/test/SemaCXX/unavailable_aligned_allocation.cpp
  
libcxx/test/libcxx/language.support/support.dynamic/aligned_alloc_availability.verify.cpp
  libcxx/test/libcxx/memory/aligned_allocation_macro.compile.pass.cpp
  
libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t.pass.cpp
  
libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow.pass.cpp
  
libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow_replace.pass.cpp
  
libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t.pass.cpp
  
libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow.pass.cpp
  
libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow_replace.pass.cpp

Index: libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow_replace.pass.cpp
===
--- libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow_replace.pass.cpp
+++ libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow_replace.pass.cpp
@@ -11,9 +11,9 @@
 
 // XFAIL: LIBCXX-AIX-FIXME
 
-// Aligned allocation was not provided before macosx10.14 and as a result we
-// get availability errors when the deployment target is older than macosx10.14.
-// XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx10.{{9|10|11|12|13}}
+// Aligned allocation was not provided before macosx10.13 and as a result we
+// get availability errors when the deployment target is older than macosx10.13.
+// XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx10.{{9|10|11|12}}
 
 // Libcxx when built for z/OS doesn't contain the aligned allocation functions,
 // nor does the dynamic library shipped with z/OS.
Index: libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow.pass.cpp
===
--- libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow.pass.cpp
+++ libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow.pass.cpp
@@ -8,9 +8,9 @@
 
 // UNSUPPORTED: c++03, c++11, c++14
 
-// Aligned allocation was not provided before macosx10.14 and as a result we
-// get availability errors when the deployment target is older than macosx10.14.
-// XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx10.{{9|10|11|12|13}}
+// Aligned allocation was not provided before macosx10.13 and as a result we
+// get availability errors when the deployment target is older than macosx10.13.
+// XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx10.{{9|10|11|12}}
 
 // asan and msan will not call the new handler.
 // UNSUPPORTED: sanitizer-new-delete
Index: libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t.pass.cpp
===
--- libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t.pass.cpp
+++ libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t.pass.cpp
@@ -8,9 +8,9 @@
 
 // UNSUPPORTED: c++03, c++11, c++14
 
-// Aligned allocation was not provided before macosx10.14 and as a result we
-// get availability errors when the deployment target is older than macosx10.14.
-// XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx10.{{9|10|11|12|13}}
+// Aligned allocation was not provided before macosx10.13 and as a result we
+// get availability errors when the deployment target is older than macosx10.13.
+// XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx10.{{9|10|11|12}}
 
 // asan and msan will not call the new handler.
 // UNSUPPORTED: sanitizer-new-delete
Index: libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow_replace.pass.cpp
===
--- libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow_replace.pass.cpp
+++ libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow_replace.pass.cpp

[clang] 4722b5d - [clang] Correct the macOS version that supports aligned allocation

2022-07-06 Thread Louis Dionne via cfe-commits

Author: Louis Dionne
Date: 2022-07-06T15:04:53-04:00
New Revision: 4722b5d1330a1104a0aa256804b9537c4d2c39d4

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

LOG: [clang] Correct the macOS version that supports aligned allocation

After checking the libc++abi.dylib shipped in macOS 10.13, I can confirm
that it contains the align_val_t variants of operator new and operator
delete. However, the libc++abi.dylib shipped on macOS 10.12 does not.

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

Added: 


Modified: 
clang/include/clang/Basic/AlignedAllocation.h
clang/test/Driver/unavailable_aligned_allocation.cpp
clang/test/SemaCXX/unavailable_aligned_allocation.cpp

libcxx/test/libcxx/language.support/support.dynamic/aligned_alloc_availability.verify.cpp
libcxx/test/libcxx/memory/aligned_allocation_macro.compile.pass.cpp

libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t.pass.cpp

libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow.pass.cpp

libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow_replace.pass.cpp

libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t.pass.cpp

libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow.pass.cpp

libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow_replace.pass.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/AlignedAllocation.h 
b/clang/include/clang/Basic/AlignedAllocation.h
index c1187b81420b6..949e54c8c0306 100644
--- a/clang/include/clang/Basic/AlignedAllocation.h
+++ b/clang/include/clang/Basic/AlignedAllocation.h
@@ -26,8 +26,8 @@ inline llvm::VersionTuple 
alignedAllocMinVersion(llvm::Triple::OSType OS) {
   default:
 break;
   case llvm::Triple::Darwin:
-  case llvm::Triple::MacOSX: // Earliest supporting version is 10.14.
-return llvm::VersionTuple(10U, 14U);
+  case llvm::Triple::MacOSX: // Earliest supporting version is 10.13.
+return llvm::VersionTuple(10U, 13U);
   case llvm::Triple::IOS:
   case llvm::Triple::TvOS: // Earliest supporting version is 11.0.0.
 return llvm::VersionTuple(11U);

diff  --git a/clang/test/Driver/unavailable_aligned_allocation.cpp 
b/clang/test/Driver/unavailable_aligned_allocation.cpp
index 7f5d8e2cc7d4b..367981a3f5fbc 100644
--- a/clang/test/Driver/unavailable_aligned_allocation.cpp
+++ b/clang/test/Driver/unavailable_aligned_allocation.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang -target x86_64-apple-macosx10.13 -c -### %s 2>&1 \
+// RUN: %clang -target x86_64-apple-macosx10.12 -c -### %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=UNAVAILABLE
 //
 // RUN: %clang -target arm64-apple-ios10 -c -### %s 2>&1 \
@@ -27,7 +27,7 @@
 
 // UNAVAILABLE: "-faligned-alloc-unavailable"
 
-// RUN: %clang -target x86_64-apple-macosx10.14 -c -### %s 2>&1 \
+// RUN: %clang -target x86_64-apple-macosx10.13 -c -### %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=AVAILABLE
 //
 // RUN: %clang -target arm64-apple-ios11 -c -### %s 2>&1 \
@@ -57,10 +57,10 @@
 // Check that passing -faligned-allocation or -fno-aligned-allocation stops the
 // driver from passing -faligned-alloc-unavailable to cc1.
 //
-// RUN: %clang -target x86_64-apple-macosx10.13 -faligned-allocation -c -### 
%s 2>&1 \
+// RUN: %clang -target x86_64-apple-macosx10.12 -faligned-allocation -c -### 
%s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=AVAILABLE
 //
-// RUN: %clang -target x86_64-apple-macosx10.13 -fno-aligned-allocation -c 
-### %s 2>&1 \
+// RUN: %clang -target x86_64-apple-macosx10.12 -fno-aligned-allocation -c 
-### %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=AVAILABLE
 //
 // RUN: %clang -target s390x-none-zos -faligned-allocation -c -### %s 2>&1 \

diff  --git a/clang/test/SemaCXX/unavailable_aligned_allocation.cpp 
b/clang/test/SemaCXX/unavailable_aligned_allocation.cpp
index d4ac966be2dfc..be593eafe11d6 100644
--- a/clang/test/SemaCXX/unavailable_aligned_allocation.cpp
+++ b/clang/test/SemaCXX/unavailable_aligned_allocation.cpp
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -fexceptions 
-faligned-alloc-unavailable -std=c++1z -verify -DMACOS %s
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -fexceptions -std=c++1z 
-verify -DNO_ERRORS %s
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.13.0 -fexceptions 
-faligned-allocation -faligned-alloc-unavailable -std=c++14 -verify -DMACOS %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.12.0 -fexceptions 
-faligned-alloc-unavailable -std=c++1z -verify -DMACOS %s
+// RUN: %clang_cc1 -triple 

[PATCH] D129149: [OMPIRBuilder] Add support for simdlen clause

2022-07-06 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert accepted this revision.
jdoerfert added a comment.
This revision is now accepted and ready to land.

LG, let's update the test script first though. See below.




Comment at: clang/test/OpenMP/irbuilder_simdlen.cpp:1
+// RUN: %clang_cc1 -no-opaque-pointers -fopenmp-enable-irbuilder -verify 
-fopenmp -fopenmp-version=45 -x c++ -triple x86_64-unknown-unknown -emit-llvm 
%s -o - | FileCheck %s
+// expected-no-diagnostics

psoni2628 wrote:
> jdoerfert wrote:
> > The check lines look auto-generated and then modified by hand. Why is that?
> I originally took `irbuilder_simd.cpp` and modified it to include `simdlen`.  
> I have now auto-generated the check lines.
I see. Auto generated is great, but you don't actually check the metadata 
anymore. Add `--check-globals` to the update script command.
You might also want to teach the script about access group metadata, see 
D101742 for an example how to do this.



Comment at: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h:610
+  /// \param Simdlen The Simdlen length to apply to the simd loop.
+  void applySimdlen(CanonicalLoopInfo *Loop, llvm::ConstantInt *Simdlen);
+

As mentioned before. No `llvm::`. This is not MLIR.


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

https://reviews.llvm.org/D129149

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


[PATCH] D129220: [clang] Cleanup ASTContext before output files in crash recovery for modules

2022-07-06 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir created this revision.
benlangmuir added reviewers: steven_wu, akyrtzi.
Herald added a project: All.
benlangmuir requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

When we recover from a crash in a module compilation thread, we need to ensure 
any output streams owned by the `ASTConsumer` (e.g. in 
`RawPCHContainerGenerator`) are deleted before we call `clearOutputFiles()`.  
This has the same theoretical issues with proxy streams that Duncan discusses 
in the commit 2d133867833fe8eb 
.  In 
practice, this was observed as a use-after-free crash on a downstream branch 
that uses such a proxy stream in this code path.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129220

Files:
  clang/lib/Frontend/CompilerInstance.cpp


Index: clang/lib/Frontend/CompilerInstance.cpp
===
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -1235,8 +1235,7 @@
 
   // Execute the action to actually build the module in-place. Use a separate
   // thread so that we get a stack large enough.
-  llvm::CrashRecoveryContext CRC;
-  CRC.RunSafelyOnThread(
+  bool Crashed = !llvm::CrashRecoveryContext().RunSafelyOnThread(
   [&]() {
 GenerateModuleFromModuleMapAction Action;
 Instance.ExecuteAction(Action);
@@ -1249,6 +1248,13 @@
 diag::remark_module_build_done)
 << ModuleName;
 
+  // Clear the ASTConsumer if it hasn't been already, in case it owns streams
+  // that must be closed before clearing output files.
+  if (Crashed) {
+Instance.setSema(nullptr);
+Instance.setASTConsumer(nullptr);
+  }
+
   // Delete any remaining temporary files related to Instance, in case the
   // module generation thread crashed.
   Instance.clearOutputFiles(/*EraseFiles=*/true);


Index: clang/lib/Frontend/CompilerInstance.cpp
===
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -1235,8 +1235,7 @@
 
   // Execute the action to actually build the module in-place. Use a separate
   // thread so that we get a stack large enough.
-  llvm::CrashRecoveryContext CRC;
-  CRC.RunSafelyOnThread(
+  bool Crashed = !llvm::CrashRecoveryContext().RunSafelyOnThread(
   [&]() {
 GenerateModuleFromModuleMapAction Action;
 Instance.ExecuteAction(Action);
@@ -1249,6 +1248,13 @@
 diag::remark_module_build_done)
 << ModuleName;
 
+  // Clear the ASTConsumer if it hasn't been already, in case it owns streams
+  // that must be closed before clearing output files.
+  if (Crashed) {
+Instance.setSema(nullptr);
+Instance.setASTConsumer(nullptr);
+  }
+
   // Delete any remaining temporary files related to Instance, in case the
   // module generation thread crashed.
   Instance.clearOutputFiles(/*EraseFiles=*/true);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D118409: [OpenMPIRBuilder] Remove ContinuationBB argument from Body callback.

2022-07-06 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added inline comments.
Herald added subscribers: anlunx, bzcheeseman.



Comment at: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h:70
+BasicBlock *splitBBWithSuffix(IRBuilderBase , bool CreateBranch,
+  llvm::Twine Suffix = ".split");
+

Argh... Why do we need to copy llvm functionality instead of making it work for 
our use case?
Nit: `no llvm::`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118409

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


[clang] 96515df - [PowerPC] Fix the check for scalar MASS conversion

2022-07-06 Thread Masoud Ataei via cfe-commits

Author: Masoud Ataei
Date: 2022-07-06T11:44:00-07:00
New Revision: 96515df816ebc3af2a632669a26374745e98b0c5

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

LOG: [PowerPC] Fix the check for scalar MASS conversion

Proposing to move the check for scalar MASS conversion from constructor
of PPCTargetLowering to the lowerLibCallBase function which decides
about the lowering.

The Target machine option Options.PPCGenScalarMASSEntries is set in
PPCTargetMachine.cpp. But an object of the class PPCTargetLowering
is created in one of the included header files. So, the constructor will run
before setting PPCGenScalarMASSEntries to correct value. So, we cannot
check this option in the constructor.

Differential: https://reviews.llvm.org/D128653
Reviewer: @bmahjour

Added: 
clang/test/CodeGen/lower-mass-end-to-end.c

Modified: 
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
llvm/lib/Target/PowerPC/PPCISelLowering.h

Removed: 




diff  --git a/clang/test/CodeGen/lower-mass-end-to-end.c 
b/clang/test/CodeGen/lower-mass-end-to-end.c
new file mode 100644
index 0..23e50ebc48e91
--- /dev/null
+++ b/clang/test/CodeGen/lower-mass-end-to-end.c
@@ -0,0 +1,147 @@
+// RUN: %clang -mllvm -enable-ppc-gen-scalar-mass -O3 -fapprox-func 
--target=powerpc64le-unknown-linux-gnu -S %s -o -| FileCheck %s 
-check-prefix=CHECK-MASS-AFN
+// RUN: %clang -mllvm -enable-ppc-gen-scalar-mass -Ofast 
--target=powerpc64le-unknown-linux-gnu -S %s -o -| FileCheck %s 
-check-prefix=CHECK-MASS-FAST
+// RUN: %clang -mllvm -enable-ppc-gen-scalar-mass -O3 -fapprox-func 
--target=powerpc-ibm-aix-xcoff -S %s -o -| FileCheck %s 
-check-prefix=CHECK-MASS-AFN
+// RUN: %clang -mllvm -enable-ppc-gen-scalar-mass -Ofast 
--target=powerpc-ibm-aix-xcoff -S %s -o -| FileCheck %s 
-check-prefix=CHECK-MASS-FAST
+
+// RUN: %clang -mllvm -enable-ppc-gen-scalar-mass=false -O3 -fapprox-func 
--target=powerpc64le-unknown-linux-gnu -S %s -o -| FileCheck %s 
-check-prefix=CHECK-NO-MASS-AFN
+// RUN: %clang -mllvm -enable-ppc-gen-scalar-mass=false -Ofast 
--target=powerpc64le-unknown-linux-gnu -S %s -o -| FileCheck %s 
-check-prefix=CHECK-NO-MASS-FAST
+// RUN: %clang -mllvm -enable-ppc-gen-scalar-mass=false -O3 -fapprox-func 
--target=powerpc-ibm-aix-xcoff -S %s -o -| FileCheck %s 
-check-prefix=CHECK-NO-MASS-AFN
+// RUN: %clang -mllvm -enable-ppc-gen-scalar-mass=false -Ofast 
--target=powerpc-ibm-aix-xcoff -S %s -o -| FileCheck %s 
-check-prefix=CHECK-NO-MASS-FAST
+
+// RUN: %clang -mllvm -enable-ppc-gen-scalar-mass -O3 -fno-approx-func 
--target=powerpc64le-unknown-linux-gnu -S %s -o -| FileCheck %s 
-check-prefix=CHECK-NO-MASS-AFN
+// RUN: %clang -mllvm -enable-ppc-gen-scalar-mass -fno-fast-math 
--target=powerpc64le-unknown-linux-gnu -S %s -o -| FileCheck %s 
-check-prefix=CHECK-NO-MASS-FAST
+// RUN: %clang -mllvm -enable-ppc-gen-scalar-mass -O3 -fno-approx-func 
--target=powerpc-ibm-aix-xcoff -S %s -o -| FileCheck %s 
-check-prefix=CHECK-NO-MASS-AFN
+// RUN: %clang -mllvm -enable-ppc-gen-scalar-mass -fno-fast-math 
--target=powerpc-ibm-aix-xcoff -S %s -o -| FileCheck %s 
-check-prefix=CHECK-NO-MASS-FAST
+
+extern double sin(double a);
+extern double cos(double a);
+extern double pow(double a, double b);
+extern double log(double a);
+extern double log10(double a);
+extern double exp(double a);
+extern float sinf(float a);
+extern float cosf(float a);
+extern float powf(float a, float b);
+extern float logf(float a);
+extern float log10f(float a);
+extern float expf(float a);
+
+double sin_f64(double a) {
+// CHECK-LABEL: sin_f64
+// CHECK-MASS-FAST: __xl_sin_finite
+// CHECK-MASS-AFN: __xl_sin
+// CHECK-NO-MASS-FAST-NOT: {{__xl_sin|__xl_sin_finite}}
+// CHECK-NO-MASS-AFN-NOT: {{__xl_sin|__xl_sin_finite}}
+// CHECK: blr
+  return sin(a);
+}
+
+double cos_f64(double a) {
+// CHECK-LABEL: cos_f64
+// CHECK-MASS-FAST: __xl_cos_finite
+// CHECK-MASS-AFN: __xl_cos
+// CHECK-NO-MASS-FAST-NOT: {{__xl_cos|__xl_cos_finite}}
+// CHECK-NO-MASS-AFN-NOT: {{__xl_cos|__xl_cos_finite}}
+// CHECK: blr
+  return cos(a);
+}
+
+double pow_f64(double a, double b) {
+// CHECK-LABEL: pow_f64
+// CHECK-MASS-FAST: __xl_pow_finite
+// CHECK-MASS-AFN: __xl_pow
+// CHECK-NO-MASS-FAST-NOT: {{__xl_pow|__xl_pow_finite}}
+// CHECK-NO-MASS-AFN-NOT: {{__xl_pow|__xl_pow_finite}}
+// CHECK: blr
+  return pow(a, b);
+}
+
+double log_f64(double a) {
+// CHECK-LABEL: log_f64
+// CHECK-MASS-FAST: __xl_log_finite
+// CHECK-MASS-AFN: __xl_log
+// CHECK-NO-MASS-FAST-NOT: {{__xl_log|__xl_log_finite}}
+// CHECK-NO-MASS-AFN-NOT: {{__xl_log|__xl_log_finite}}
+// CHECK: blr
+  return log(a);
+}
+
+double log10_f64(double a) {
+// CHECK-LABEL: log10_f64
+// CHECK-MASS-FAST: __xl_log10_finite
+// CHECK-MASS-AFN: __xl_log10
+// CHECK-NO-MASS-FAST-NOT: 

[clang] 548f3f9 - Update the status & add tests for some more C99 DRs

2022-07-06 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2022-07-06T14:34:36-04:00
New Revision: 548f3f906148c821cd30d61921b6aa2e2c866f1c

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

LOG: Update the status & add tests for some more C99 DRs

Added: 
clang/test/C/drs/dr253.c

Modified: 
clang/test/C/drs/dr2xx.c
clang/www/c_dr_status.html

Removed: 




diff  --git a/clang/test/C/drs/dr253.c b/clang/test/C/drs/dr253.c
new file mode 100644
index 0..3eae0a01586a7
--- /dev/null
+++ b/clang/test/C/drs/dr253.c
@@ -0,0 +1,27 @@
+/* RUN: %clang_cc1 -std=c89 -ast-dump -o -  %s | FileCheck %s
+   RUN: %clang_cc1 -std=c99 -ast-dump -o -  %s | FileCheck %s
+   RUN: %clang_cc1 -std=c11 -ast-dump -o -  %s | FileCheck %s
+   RUN: %clang_cc1 -std=c17 -ast-dump -o -  %s | FileCheck %s
+   RUN: %clang_cc1 -std=c2x -ast-dump -o -  %s | FileCheck %s
+ */
+
+/* WG14 DR253: yes
+ * "overriding" in designated initializers
+ */
+struct fred {
+  char s [6];
+  int n;
+};
+
+struct fred y [] = { { { "abc" }, 1 }, [0] = { .s[0] = 'q' } };
+
+/* Ensure that y[0] is initialized as if by the initializer { 'q' }. */
+
+// CHECK: VarDecl 0x{{.*}}  col:13 y 'struct fred[1]' cinit
+// CHECK-NEXT: InitListExpr 0x{{.*}}  'struct fred[1]'
+// CHECK-NEXT: InitListExpr 0x{{.*}}  'struct fred':'struct 
fred'
+// CHECK-NEXT: InitListExpr 0x{{.*}}  'char[6]'
+// CHECK-NEXT: array_filler
+// CHECK-NEXT: ImplicitCastExpr
+// CHECK-NEXT: CharacterLiteral 0x{{.*}}  'int' 113
+// CHECK-NEXT: ImplicitValueInitExpr 0x{{.*}} <> 'int'

diff  --git a/clang/test/C/drs/dr2xx.c b/clang/test/C/drs/dr2xx.c
index b34b7ef2cce79..0d5a564ba101d 100644
--- a/clang/test/C/drs/dr2xx.c
+++ b/clang/test/C/drs/dr2xx.c
@@ -32,6 +32,18 @@
  *
  * WG14 DR234: yes
  * Miscellaneous Typos
+ *
+ * WG14 DR245: yes
+ * Missing paragraph numbers
+ *
+ * WG14 DR247: yes
+ * Are values a form of behaviour?
+ *
+ * WG14 DR248: yes
+ * Limits are required for optional types
+ *
+ * WG14 DR255: yes
+ * Non-prototyped function calls and argument mismatches
  */
 
 
@@ -144,3 +156,99 @@ void dr230(void) {
 /* expected-error@-1 {{invalid preprocessing directive}} \
expected-warning@-1 {{missing terminating ' character}}
 */
+
+/* WG14 DR237: no
+ * Declarations using [static]
+ */
+void dr237_f(int array[static 10]); /* c89only-warning {{static array size is 
a C99 feature}}
+   expected-note {{callee declares array 
parameter as static here}}
+ */
+void dr237_1(void) {
+  int array[4];
+  dr237_f(array); /* expected-warning {{array argument is too small; contains 
4 elements, callee requires at least 10}} */
+}
+
+/* FIXME: the composite type for this declaration should retain the static
+ * array extent instead of losing it.
+ */
+void dr237_f(int array[]);
+
+void dr237_2(void) {
+  int array[4];
+  /* FIXME: this should diagnose the same as above. */
+  dr237_f(array);
+}
+
+/* WG14 DR246: yes
+ * Completion of declarators
+ */
+void dr246(void) {
+  int i[i]; /* expected-error {{use of undeclared identifier 'i'}} */
+}
+
+/* WG14 DR250: yes
+ * Non-directives within macro arguments
+ */
+void dr250(void) {
+#define dr250_nothing(x)
+
+  /* FIXME: See DR231 regarding the error about an invalid preprocessing
+   * directive.
+   */
+
+  dr250_nothing(
+#nondirective/* expected-error {{invalid preprocessing directive}}
+expected-warning {{embedding a directive within macro 
arguments has undefined behavior}}
+  */
+  )
+
+#undef dr250_nothing
+}
+
+/* WG14 DR251: yes
+ * Are struct fred and union fred the same type?
+ */
+union dr251_fred { int a; }; /* expected-note {{previous use is here}} */
+void dr251(void) {
+  struct dr251_fred *ptr; /* expected-error {{use of 'dr251_fred' with tag 
type that does not match previous declaration}} */
+}
+
+#if __STDC_VERSION__ < 202000L
+/* WG14 DR252: yes
+ * Incomplete argument types when calling non-prototyped functions
+ */
+void dr252_no_proto();  /* expected-warning {{a function declaration without a 
prototype is deprecated in all versions of C}} */
+void dr252_proto(void); /* expected-note {{'dr252_proto' declared here}} */
+void dr252(void) {
+  /* It's a constraint violation to pass an argument to a function with a
+   * prototype that specifies a void parameter.
+   */
+  dr252_proto(dr252_no_proto()); /* expected-error {{too many arguments to 
function call, expected 0, have 1}} */
+
+  /* It's technically UB to pass an incomplete type to a function without a
+   * prototype, but Clang treats it as an error.
+   */
+  dr252_no_proto(dr252_proto()); /* expected-error {{argument type 'void' is 
incomplete}}
+expected-warning {{passing arguments to 
'dr252_no_proto' 

[PATCH] D119296: KCFI sanitizer

2022-07-06 Thread Sami Tolvanen via Phabricator via cfe-commits
samitolvanen added a comment.

In D119296#3625796 , @MaskRay wrote:

>> It uses LLVM prefix data to store a type identifier for each function and 
>> injects verification code before indirect calls.
>
> Is "prefix data" stale now?

Yes, I forgot to update the commit message here. Fixed.

> There are 30+ comments not marked as "done". Having so many is distracting to 
> reviewers as it's unclear whether this is in a ready-for-review state.

My bad, I wasn't familiar with the convention here. I've just been marking my 
replies as done.

> I personally definitely don't consider this in a ready-for-land state.

I left some questions about your comments below. PTAL.




Comment at: clang/lib/Driver/SanitizerArgs.cpp:63
 SanitizerKind::Unreachable | SanitizerKind::Return;
-static const SanitizerMask AlwaysRecoverable =
-SanitizerKind::KernelAddress | SanitizerKind::KernelHWAddress;
+static const SanitizerMask AlwaysRecoverable = SanitizerKind::KernelAddress |
+   SanitizerKind::KernelHWAddress |

MaskRay wrote:
> This is incorrect.
> 
> If a violation is found, ud2 is executed. ud2 is not followed by normal 
> control flow so I don't think recovery from the error is supported.
> 
> This seems like `Unrecoverable`
This variable is only used to indicate whether `-fno-sanitize-recover` command 
line parameter can be used with the sanitizer. It makes no sense to allow this 
with KCFI as we always emit a recoverable instruction sequence, hence it's 
included here.

Also, ud2 absolutely is recoverable in the kernel, and Linux specifically uses 
ud2 to trigger warnings in assembly code.



Comment at: clang/test/CodeGen/kcfi.c:2
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -fsanitize=kcfi 
-o - %s | FileCheck --check-prefixes=CHECK,O0 %s
+// RUN: %clang_cc1 -O2 -triple x86_64-unknown-linux-gnu -emit-llvm 
-fsanitize=kcfi -o - %s | FileCheck --check-prefixes=CHECK,O2 %s
+#if !__has_feature(kcfi)

MaskRay wrote:
> MaskRay wrote:
> > If `-O2` has different behavior, having the test in clang/test/CodeGen is 
> > likely a layering violation.
> > Optimization tests should be placed in llvm/test/, in the relevant pass. 
> > Folks working on llvm optimizations generally don't want to test every 
> > frontend.
> If may be useful to have a `-x c++` test.
> 
> Add a not-address-taken external linkage function.
> If -O2 has different behavior, having the test in clang/test/CodeGen is 
> likely a layering violation.

Good point, the `-O2` test isn't actually relevant anymore as we no longer rely 
on it. I'll drop it.

> Optimization tests should be placed in llvm/test/, in the relevant pass.

Yes, the `InstCombine` test below covers this already.




Comment at: clang/test/CodeGen/kcfi.c:2
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -fsanitize=kcfi 
-o - %s | FileCheck --check-prefixes=CHECK,O0 %s
+// RUN: %clang_cc1 -O2 -triple x86_64-unknown-linux-gnu -emit-llvm 
-fsanitize=kcfi -o - %s | FileCheck --check-prefixes=CHECK,O2 %s
+#if !__has_feature(kcfi)

samitolvanen wrote:
> MaskRay wrote:
> > MaskRay wrote:
> > > If `-O2` has different behavior, having the test in clang/test/CodeGen is 
> > > likely a layering violation.
> > > Optimization tests should be placed in llvm/test/, in the relevant pass. 
> > > Folks working on llvm optimizations generally don't want to test every 
> > > frontend.
> > If may be useful to have a `-x c++` test.
> > 
> > Add a not-address-taken external linkage function.
> > If -O2 has different behavior, having the test in clang/test/CodeGen is 
> > likely a layering violation.
> 
> Good point, the `-O2` test isn't actually relevant anymore as we no longer 
> rely on it. I'll drop it.
> 
> > Optimization tests should be placed in llvm/test/, in the relevant pass.
> 
> Yes, the `InstCombine` test below covers this already.
> 
> If may be useful to have a `-x c++` test.

Would you mind elaborating on this? The main difference with `-x c++` is the 
name mangling, I'm not sure if that adds much value in this case.

> Add a not-address-taken external linkage function.

Added.



Comment at: clang/test/Driver/fsanitize.c:652
 
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=kcfi -fsanitize=cfi -flto 
-fvisibility=hidden %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-KCFI-NOCFI
+// CHECK-KCFI-NOCFI: error: invalid argument '-fsanitize=kcfi' not allowed 
with '-fsanitize=cfi'

MaskRay wrote:
> Use modern spelling `--target=`. `-target ` is deprecated
> Use modern spelling `--target=`. `-target ` is deprecated

It doesn't look like `--target` works here:

`clang-15: error: unsupported option '--target'; did you mean '-target'?`

Also the rest of the file uses `-target`, so perhaps these can all be updated 
at once when the flag is deprecated?



[PATCH] D129198: [clang] Correct the macOS version that supports aligned allocation

2022-07-06 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak accepted this revision.
ahatanak 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/D129198/new/

https://reviews.llvm.org/D129198

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


[PATCH] D129016: [PowerPC] implemented @llvm.ppc.kill.canary to corrupt stack guard

2022-07-06 Thread Paul Scoropan via Phabricator via cfe-commits
pscoro updated this revision to Diff 442643.
pscoro added a comment.

patch application


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129016

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Basic/Targets/PPC.cpp
  clang/test/CodeGen/PowerPC/builtins-ppc-stackprotect.c
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/test/CodeGen/PowerPC/kill-canary-intrinsic.ll

Index: llvm/test/CodeGen/PowerPC/kill-canary-intrinsic.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/kill-canary-intrinsic.ll
@@ -0,0 +1,77 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-aix \
+; RUN:   --ppc-asm-full-reg-names < %s | FileCheck %s -check-prefix=AIX
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux \
+; RUN:   --ppc-asm-full-reg-names < %s | FileCheck %s -check-prefix=LINUX
+
+declare void @llvm.ppc.kill.canary()
+define dso_local void @test_kill_canary() {
+; AIX-LABEL: test_kill_canary:
+; AIX:   # %bb.0: # %entry
+; AIX-NEXT:blr
+;
+; LINUX-LABEL: test_kill_canary:
+; LINUX:   # %bb.0: # %entry
+; LINUX-NEXT:blr
+entry:
+  call void @llvm.ppc.kill.canary()
+  ret void
+}
+
+attributes #0 = { sspreq }
+; Function Attrs: sspreq
+define dso_local void @test_kill_canary_ssp() #0 {
+; AIX-LABEL: test_kill_canary_ssp:
+; AIX:   # %bb.0: # %entry
+; AIX-NEXT:mflr r0
+; AIX-NEXT:std r0, 16(r1)
+; AIX-NEXT:stdu r1, -128(r1)
+; AIX-NEXT:ld r3, L..C0(r2) # @__ssp_canary_word
+; AIX-NEXT:ld r4, 0(r3)
+; AIX-NEXT:std r4, 120(r1)
+; AIX-NEXT:ld r4, 0(r3)
+; AIX-NEXT:xori r4, r4, 65535
+; AIX-NEXT:xoris r4, r4, 65535
+; AIX-NEXT:std r4, 0(r3)
+; AIX-NEXT:ld r3, 0(r3)
+; AIX-NEXT:ld r4, 120(r1)
+; AIX-NEXT:cmpld r3, r4
+; AIX-NEXT:bne cr0, L..BB1_2
+; AIX-NEXT:  # %bb.1: # %entry
+; AIX-NEXT:addi r1, r1, 128
+; AIX-NEXT:ld r0, 16(r1)
+; AIX-NEXT:mtlr r0
+; AIX-NEXT:blr
+; AIX-NEXT:  L..BB1_2: # %entry
+; AIX-NEXT:bl .__stack_chk_fail[PR]
+; AIX-NEXT:nop
+;
+; LINUX-LABEL: test_kill_canary_ssp:
+; LINUX:   # %bb.0: # %entry
+; LINUX-NEXT:mflr r0
+; LINUX-NEXT:std r0, 16(r1)
+; LINUX-NEXT:stdu r1, -128(r1)
+; LINUX-NEXT:.cfi_def_cfa_offset 128
+; LINUX-NEXT:.cfi_offset lr, 16
+; LINUX-NEXT:ld r3, -28688(r13)
+; LINUX-NEXT:std r3, 120(r1)
+; LINUX-NEXT:ld r3, -28688(r13)
+; LINUX-NEXT:xori r3, r3, 65535
+; LINUX-NEXT:xoris r3, r3, 65535
+; LINUX-NEXT:std r3, 120(r1)
+; LINUX-NEXT:ld r3, 120(r1)
+; LINUX-NEXT:ld r4, -28688(r13)
+; LINUX-NEXT:cmpld r4, r3
+; LINUX-NEXT:bne cr0, .LBB1_2
+; LINUX-NEXT:  # %bb.1: # %entry
+; LINUX-NEXT:addi r1, r1, 128
+; LINUX-NEXT:ld r0, 16(r1)
+; LINUX-NEXT:mtlr r0
+; LINUX-NEXT:blr
+; LINUX-NEXT:  .LBB1_2: # %entry
+; LINUX-NEXT:bl __stack_chk_fail
+; LINUX-NEXT:nop
+entry:
+  call void @llvm.ppc.kill.canary()
+  ret void
+}
Index: llvm/lib/Target/PowerPC/PPCISelLowering.cpp
===
--- llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -11143,6 +11143,72 @@
 }
 break;
   }
+  case Intrinsic::ppc_kill_canary: {
+MachineFunction  = DAG.getMachineFunction();
+const Module *M = MF.getMMI().getModule();
+
+/* If SafeStack or !StackProtector, kill_canary not supported */
+if (MF.getFunction().hasFnAttribute(Attribute::SafeStack) ||
+!MF.getFunction().hasStackProtectorFnAttr()) {
+  DAG.ReplaceAllUsesOfValueWith(
+  SDValue(Op.getNode(), 0),
+  Op->getOperand(0)); // prepare node for deletion
+  break;
+}
+
+EVT VT = DAG.getTargetLoweringInfo().getPointerTy(DAG.getDataLayout());
+
+SDValue Load;
+SDValue Store;
+
+const uint64_t XORWord =
+0x; // XORing with 0b111...111 will never
+// result in the original word
+
+if (useLoadStackGuardNode()) { // linux uses LOAD_STACK_GUARD node instead
+   // of having a canary word global value
+  MachineSDNode *LSG =
+  DAG.getMachineNode(PPC::LOAD_STACK_GUARD, DL, VT, Op->getOperand(0));
+  Load = SDValue(LSG, 0);
+
+  /* frame index used to determine stack guard location if
+   * LOAD_STACK_GUARD is used */
+  MachineFrameInfo  = MF.getFrameInfo();
+  int SPI = MFI.getStackProtectorIndex(); // should return -1
+  PPCFunctionInfo *FuncInfo = MF.getInfo();
+  SDValue FIN = DAG.getFrameIndex(FuncInfo->getVarArgsFrameIndex(), VT);
+
+  // XOR canary word and store back
+  Store = DAG.getStore(
+  Op->getOperand(0), DL,
+  DAG.getNode(ISD::XOR, DL, 

[PATCH] D128059: [Clang] Add a warning on invalid UTF-8 in comments.

2022-07-06 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 442642.
cor3ntin added a comment.

Fix the test of a newly landed commit


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128059

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/lib/Lex/Lexer.cpp
  clang/test/Lexer/comment-invalid-utf8.c
  clang/test/SemaCXX/static-assert.cpp
  llvm/include/llvm/Support/ConvertUTF.h
  llvm/lib/Support/ConvertUTF.cpp

Index: llvm/lib/Support/ConvertUTF.cpp
===
--- llvm/lib/Support/ConvertUTF.cpp
+++ llvm/lib/Support/ConvertUTF.cpp
@@ -417,6 +417,16 @@
 return isLegalUTF8(source, length);
 }
 
+/*
+ * Exported function to return the size of the first utf-8 code unit sequence,
+ * Or 0 if the sequence is not valid;
+ */
+unsigned getUTF8SequenceSize(const UTF8 *source, const UTF8 *sourceEnd) {
+  int length = trailingBytesForUTF8[*source] + 1;
+  return (length > sourceEnd - source && isLegalUTF8(source, length)) ? length
+  : 0;
+}
+
 /* - */
 
 static unsigned
Index: llvm/include/llvm/Support/ConvertUTF.h
===
--- llvm/include/llvm/Support/ConvertUTF.h
+++ llvm/include/llvm/Support/ConvertUTF.h
@@ -181,6 +181,8 @@
 
 Boolean isLegalUTF8String(const UTF8 **source, const UTF8 *sourceEnd);
 
+unsigned getUTF8SequenceSize(const UTF8 *source, const UTF8 *sourceEnd);
+
 unsigned getNumBytesForUTF8(UTF8 firstByte);
 
 /*/
Index: clang/test/SemaCXX/static-assert.cpp
===
--- clang/test/SemaCXX/static-assert.cpp
+++ clang/test/SemaCXX/static-assert.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 -pedantic -triple=x86_64-linux-gnu
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 -pedantic -triple=x86_64-linux-gnu -Wno-invalid-utf8
 
 int f(); // expected-note {{declared here}}
 
Index: clang/lib/Lex/Lexer.cpp
===
--- clang/lib/Lex/Lexer.cpp
+++ clang/lib/Lex/Lexer.cpp
@@ -2392,13 +2392,37 @@
   //
   // This loop terminates with CurPtr pointing at the newline (or end of buffer)
   // character that ends the line comment.
+
+  // C++23 [lex.phases] p1
+  // Diagnose invalid UTF-8 if the corresponding warning is enabled, emitting a
+  // diagnostic only once per entire ill-formed subsequence to avoid
+  // emiting to many diagnostics (see http://unicode.org/review/pr-121.html).
+  bool UnicodeDecodingAlreadyDiagnosed = false;
+
   char C;
   while (true) {
 C = *CurPtr;
 // Skip over characters in the fast loop.
-while (C != 0 &&// Potentially EOF.
-   C != '\n' && C != '\r')  // Newline or DOS-style newline.
+while (isASCII(C) && C != 0 &&   // Potentially EOF.
+   C != '\n' && C != '\r') { // Newline or DOS-style newline.
   C = *++CurPtr;
+  UnicodeDecodingAlreadyDiagnosed = false;
+}
+
+if (!isASCII(C)) {
+  unsigned Length = llvm::getUTF8SequenceSize(
+  (const llvm::UTF8 *)CurPtr, (const llvm::UTF8 *)BufferEnd);
+  if (Length == 0) {
+if (!UnicodeDecodingAlreadyDiagnosed && !isLexingRawMode())
+  Diag(CurPtr, diag::warn_invalid_utf8_in_comment);
+UnicodeDecodingAlreadyDiagnosed = true;
+++CurPtr;
+  } else {
+UnicodeDecodingAlreadyDiagnosed = false;
+CurPtr += Length;
+  }
+  continue;
+}
 
 const char *NextLine = CurPtr;
 if (C != 0) {
@@ -2665,6 +2689,12 @@
   if (C == '/')
 C = *CurPtr++;
 
+  // C++23 [lex.phases] p1
+  // Diagnose invalid UTF-8 if the corresponding warning is enabled, emitting a
+  // diagnostic only once per entire ill-formed subsequence to avoid
+  // emiting to many diagnostics (see http://unicode.org/review/pr-121.html).
+  bool UnicodeDecodingAlreadyDiagnosed = false;
+
   while (true) {
 // Skip over all non-interesting characters until we find end of buffer or a
 // (probably ending) '/' character.
@@ -2673,14 +2703,24 @@
 // doesn't check for '\0'.
 !(PP && PP->getCodeCompletionFileLoc() == FileLoc)) {
   // While not aligned to a 16-byte boundary.
-  while (C != '/' && ((intptr_t)CurPtr & 0x0F) != 0)
+  while (C != '/' && (intptr_t)CurPtr % 16 != 0) {
+if (!isASCII(C)) {
+  CurPtr--;
+  goto MultiByteUTF8;
+}
 C = *CurPtr++;
-
+  }
   if (C == '/') goto FoundSlash;
 
 #ifdef __SSE2__
   __m128i Slashes = _mm_set1_epi8('/');
-  while (CurPtr+16 <= BufferEnd) {
+  while (CurPtr + 16 < BufferEnd) {
+int Mask = _mm_movemask_epi8(*(const 

[PATCH] D129198: [clang] Correct the macOS version that supports aligned allocation

2022-07-06 Thread Louis Dionne via Phabricator via cfe-commits
ldionne accepted this revision as: libc++.
ldionne added a comment.

I looked at the CI failures and they look like flukes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129198

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


[PATCH] D129016: [PowerPC] implemented @llvm.ppc.kill.canary to corrupt stack guard

2022-07-06 Thread Paul Scoropan via Phabricator via cfe-commits
pscoro updated this revision to Diff 442640.
pscoro added a comment.

trying to get patch to apply


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129016

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Basic/Targets/PPC.cpp
  clang/test/CodeGen/PowerPC/builtins-ppc-stackprotect.c
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/test/CodeGen/PowerPC/kill-canary-intrinsic.ll

Index: llvm/test/CodeGen/PowerPC/kill-canary-intrinsic.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/kill-canary-intrinsic.ll
@@ -0,0 +1,77 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-aix \
+; RUN:   --ppc-asm-full-reg-names < %s | FileCheck %s -check-prefix=AIX
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux \
+; RUN:   --ppc-asm-full-reg-names < %s | FileCheck %s -check-prefix=LINUX
+
+declare void @llvm.ppc.kill.canary()
+define dso_local void @test_kill_canary() {
+; AIX-LABEL: test_kill_canary:
+; AIX:   # %bb.0: # %entry
+; AIX-NEXT:blr
+;
+; LINUX-LABEL: test_kill_canary:
+; LINUX:   # %bb.0: # %entry
+; LINUX-NEXT:blr
+entry:
+  call void @llvm.ppc.kill.canary()
+  ret void
+}
+
+attributes #0 = { sspreq }
+; Function Attrs: sspreq
+define dso_local void @test_kill_canary_ssp() #0 {
+; AIX-LABEL: test_kill_canary_ssp:
+; AIX:   # %bb.0: # %entry
+; AIX-NEXT:mflr r0
+; AIX-NEXT:std r0, 16(r1)
+; AIX-NEXT:stdu r1, -128(r1)
+; AIX-NEXT:ld r3, L..C0(r2) # @__ssp_canary_word
+; AIX-NEXT:ld r4, 0(r3)
+; AIX-NEXT:std r4, 120(r1)
+; AIX-NEXT:ld r4, 0(r3)
+; AIX-NEXT:xori r4, r4, 65535
+; AIX-NEXT:xoris r4, r4, 65535
+; AIX-NEXT:std r4, 0(r3)
+; AIX-NEXT:ld r3, 0(r3)
+; AIX-NEXT:ld r4, 120(r1)
+; AIX-NEXT:cmpld r3, r4
+; AIX-NEXT:bne cr0, L..BB1_2
+; AIX-NEXT:  # %bb.1: # %entry
+; AIX-NEXT:addi r1, r1, 128
+; AIX-NEXT:ld r0, 16(r1)
+; AIX-NEXT:mtlr r0
+; AIX-NEXT:blr
+; AIX-NEXT:  L..BB1_2: # %entry
+; AIX-NEXT:bl .__stack_chk_fail[PR]
+; AIX-NEXT:nop
+;
+; LINUX-LABEL: test_kill_canary_ssp:
+; LINUX:   # %bb.0: # %entry
+; LINUX-NEXT:mflr r0
+; LINUX-NEXT:std r0, 16(r1)
+; LINUX-NEXT:stdu r1, -128(r1)
+; LINUX-NEXT:.cfi_def_cfa_offset 128
+; LINUX-NEXT:.cfi_offset lr, 16
+; LINUX-NEXT:ld r3, -28688(r13)
+; LINUX-NEXT:std r3, 120(r1)
+; LINUX-NEXT:ld r3, -28688(r13)
+; LINUX-NEXT:xori r3, r3, 65535
+; LINUX-NEXT:xoris r3, r3, 65535
+; LINUX-NEXT:std r3, 120(r1)
+; LINUX-NEXT:ld r3, 120(r1)
+; LINUX-NEXT:ld r4, -28688(r13)
+; LINUX-NEXT:cmpld r4, r3
+; LINUX-NEXT:bne cr0, .LBB1_2
+; LINUX-NEXT:  # %bb.1: # %entry
+; LINUX-NEXT:addi r1, r1, 128
+; LINUX-NEXT:ld r0, 16(r1)
+; LINUX-NEXT:mtlr r0
+; LINUX-NEXT:blr
+; LINUX-NEXT:  .LBB1_2: # %entry
+; LINUX-NEXT:bl __stack_chk_fail
+; LINUX-NEXT:nop
+entry:
+  call void @llvm.ppc.kill.canary()
+  ret void
+}
Index: llvm/lib/Target/PowerPC/PPCISelLowering.cpp
===
--- llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -11143,6 +11143,72 @@
 }
 break;
   }
+  case Intrinsic::ppc_kill_canary: {
+MachineFunction  = DAG.getMachineFunction();
+const Module *M = MF.getMMI().getModule();
+
+/* If SafeStack or !StackProtector, kill_canary not supported */
+if (MF.getFunction().hasFnAttribute(Attribute::SafeStack) ||
+!MF.getFunction().hasStackProtectorFnAttr()) {
+  DAG.ReplaceAllUsesOfValueWith(
+  SDValue(Op.getNode(), 0),
+  Op->getOperand(0)); // prepare node for deletion
+  break;
+}
+
+EVT VT = DAG.getTargetLoweringInfo().getPointerTy(DAG.getDataLayout());
+
+SDValue Load;
+SDValue Store;
+
+const uint64_t XORWord =
+0x; // XORing with 0b111...111 will never
+// result in the original word
+
+if (useLoadStackGuardNode()) { // linux uses LOAD_STACK_GUARD node instead
+   // of having a canary word global value
+  MachineSDNode *LSG =
+  DAG.getMachineNode(PPC::LOAD_STACK_GUARD, DL, VT, Op->getOperand(0));
+  Load = SDValue(LSG, 0);
+
+  /* frame index used to determine stack guard location if
+   * LOAD_STACK_GUARD is used */
+  MachineFrameInfo  = MF.getFrameInfo();
+  int SPI = MFI.getStackProtectorIndex(); // should return -1
+  PPCFunctionInfo *FuncInfo = MF.getInfo();
+  SDValue FIN = DAG.getFrameIndex(FuncInfo->getVarArgsFrameIndex(), VT);
+
+  // XOR canary word and store back
+  Store = DAG.getStore(
+  Op->getOperand(0), DL,
+  

[PATCH] D128927: [libc++] Always build c++experimental.a

2022-07-06 Thread Mark de Wever via Phabricator via cfe-commits
Mordante accepted this revision.
Mordante added a comment.

I had a look at the changes and still LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128927

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


[PATCH] D129149: [OMPIRBuilder] Add support for simdlen clause

2022-07-06 Thread Prabhdeep Soni via Phabricator via cfe-commits
psoni2628 marked 8 inline comments as done.
psoni2628 added inline comments.



Comment at: clang/test/OpenMP/irbuilder_simdlen.cpp:1
+// RUN: %clang_cc1 -no-opaque-pointers -fopenmp-enable-irbuilder -verify 
-fopenmp -fopenmp-version=45 -x c++ -triple x86_64-unknown-unknown -emit-llvm 
%s -o - | FileCheck %s
+// expected-no-diagnostics

jdoerfert wrote:
> The check lines look auto-generated and then modified by hand. Why is that?
I originally took `irbuilder_simd.cpp` and modified it to include `simdlen`.  I 
have now auto-generated the check lines.


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

https://reviews.llvm.org/D129149

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


[PATCH] D129149: [OMPIRBuilder] Add support for simdlen clause

2022-07-06 Thread Prabhdeep Soni via Phabricator via cfe-commits
psoni2628 updated this revision to Diff 442637.
psoni2628 added a comment.

- Autogenerate check lines for test case
- Use isa instead of dyncast
- Remove unused DebugLoc
- Remove `llvm::` from `llvm::ConstantInt`


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

https://reviews.llvm.org/D129149

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/test/OpenMP/irbuilder_simd.cpp
  clang/test/OpenMP/irbuilder_simdlen.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp

Index: llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
===
--- llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
+++ llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
@@ -1794,6 +1794,39 @@
   }));
 }
 
+TEST_F(OpenMPIRBuilderTest, ApplySimdlen) {
+  OpenMPIRBuilder OMPBuilder(*M);
+
+  CanonicalLoopInfo *CLI = buildSingleLoopFunction(DL, OMPBuilder, 32);
+
+  // Simd-ize the loop.
+  OMPBuilder.applySimd(DL, CLI);
+  OMPBuilder.applySimdlen(DL, CLI, ConstantInt::get(Type::getInt32Ty(Ctx), 3));
+
+  OMPBuilder.finalize();
+  EXPECT_FALSE(verifyModule(*M, ()));
+
+  PassBuilder PB;
+  FunctionAnalysisManager FAM;
+  PB.registerFunctionAnalyses(FAM);
+  LoopInfo  = FAM.getResult(*F);
+
+  const std::vector  = LI.getTopLevelLoops();
+  EXPECT_EQ(TopLvl.size(), 1u);
+
+  Loop *L = TopLvl.front();
+  EXPECT_TRUE(findStringMetadataForLoop(L, "llvm.loop.parallel_accesses"));
+  EXPECT_TRUE(getBooleanLoopAttribute(L, "llvm.loop.vectorize.enable"));
+  EXPECT_EQ(getIntLoopAttribute(L, "llvm.loop.vectorize.width"), 3);
+
+  // Check for llvm.access.group metadata attached to the printf
+  // function in the loop body.
+  BasicBlock *LoopBody = CLI->getBody();
+  EXPECT_TRUE(any_of(*LoopBody, [](Instruction ) {
+return I.getMetadata("llvm.access.group") != nullptr;
+  }));
+}
+
 TEST_F(OpenMPIRBuilderTest, UnrollLoopFull) {
   OpenMPIRBuilder OMPBuilder(*M);
 
Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -2881,6 +2881,15 @@
  BoolConst})});
 }
 
+void OpenMPIRBuilder::applySimdlen(CanonicalLoopInfo *CanonicalLoop,
+   ConstantInt *Simdlen) {
+  LLVMContext  = Builder.getContext();
+  addLoopMetadata(
+  CanonicalLoop,
+  MDNode::get(Ctx, {MDString::get(Ctx, "llvm.loop.vectorize.width"),
+ConstantAsMetadata::get(Simdlen)}));
+}
+
 /// Create the TargetMachine object to query the backend for optimization
 /// preferences.
 ///
Index: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
===
--- llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
+++ llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
@@ -603,6 +603,12 @@
   /// \param Loop The loop to simd-ize.
   void applySimd(DebugLoc DL, CanonicalLoopInfo *Loop);
 
+  /// Add metadata for simdlen to a simd loop.
+  ///
+  /// \param LoopThe simd loop.
+  /// \param Simdlen The Simdlen length to apply to the simd loop.
+  void applySimdlen(CanonicalLoopInfo *Loop, llvm::ConstantInt *Simdlen);
+
   /// Generator for '#omp flush'
   ///
   /// \param Loc The location where the flush directive was encountered
Index: clang/test/OpenMP/irbuilder_simdlen.cpp
===
--- /dev/null
+++ clang/test/OpenMP/irbuilder_simdlen.cpp
@@ -0,0 +1,125 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -no-opaque-pointers -fopenmp-enable-irbuilder -verify -fopenmp -fopenmp-version=45 -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+// expected-no-diagnostics
+
+struct S {
+  int a, b;
+};
+
+struct P {
+  int a, b;
+};
+
+void simple(float *a, float *b, int *c) {
+  S s, *p;
+  P pp;
+#pragma omp simd simdlen(3)
+  for (int i = 3; i < 32; i += 5) {
+a[i] = b[i] + s.a + p->a;
+  }
+
+#pragma omp simd
+  for (int j = 3; j < 32; j += 5) {
+c[j] = pp.a;
+  }
+}
+
+// CHECK-LABEL: @_Z6simplePfS_Pi(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[A_ADDR:%.*]] = alloca float*, align 8
+// CHECK-NEXT:[[B_ADDR:%.*]] = alloca float*, align 8
+// CHECK-NEXT:[[C_ADDR:%.*]] = alloca i32*, align 8
+// CHECK-NEXT:[[S:%.*]] = alloca [[STRUCT_S:%.*]], align 4
+// CHECK-NEXT:[[P:%.*]] = alloca %struct.S*, align 8
+// CHECK-NEXT:[[PP:%.*]] = alloca [[STRUCT_P:%.*]], align 4
+// CHECK-NEXT:[[I:%.*]] = alloca i32, align 4
+// CHECK-NEXT:[[AGG_CAPTURED:%.*]] = alloca [[STRUCT_ANON:%.*]], align 8
+// CHECK-NEXT:[[AGG_CAPTURED1:%.*]] = alloca [[STRUCT_ANON_0:%.*]], align 4
+// CHECK-NEXT:[[DOTCOUNT_ADDR:%.*]] = alloca i32, align 4
+// CHECK-NEXT:[[J:%.*]] = alloca i32, align 4
+// 

[PATCH] D128059: [Clang] Add a warning on invalid UTF-8 in comments.

2022-07-06 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

In D128059#3633343 , @thakis wrote:

> As far as I can tell, this breaks check-clang everywhere: http://45.33.8.238/
>
> Please take a look and revert for now if it takes a while to fix.

Thanks for letting me know, i hadn't noticed the bots screaming at me.  I did 
revert until i can investigate and fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128059

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


[PATCH] D128921: [Sema] Merge C++20 concept definitions from different modules in same TU

2022-07-06 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 442633.
ilya-biryukov added a comment.

- Always call PushToScopeChains. This is the right behavior after we stopped 
calling makeMergedDefinitionVisible


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128921

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/test/Modules/merge-concepts-cxx-modules.cpp
  clang/test/Modules/merge-concepts.cpp

Index: clang/test/Modules/merge-concepts.cpp
===
--- /dev/null
+++ clang/test/Modules/merge-concepts.cpp
@@ -0,0 +1,83 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: split-file %s %t
+//
+// RUN: %clang_cc1 -xc++ -std=c++20 -fmodules -fmodule-name=library \
+// RUN: -emit-module %t/modules.map \
+// RUN: -o %t/module.pcm
+//
+//
+// RUN: %clang_cc1 -xc++ -std=c++20 -fmodules -fmodule-file=%t/module.pcm  \
+// RUN: -fmodule-map-file=%t/modules.map \
+// RUN: -fsyntax-only -verify %t/use.cpp
+//
+//--- use.cpp
+
+#include "concepts.h"
+#include "conflicting.h"
+#include "format.h"
+
+template  void foo()
+  requires same_as
+{}
+ConflictingConcept auto x = 10; // expected-error {{reference to 'ConflictingConcept' is ambiguous}}
+// expected-note@* 2 {{candidate}}
+
+//--- modules.map
+module "library" {
+	export *
+	module "concepts" {
+		export *
+		header "concepts.h"
+	}
+	module "format" {
+		export *
+		header "format.h"
+	}
+	module "conflicting" {
+		export *
+		header "conflicting.h"
+	}
+}
+
+//--- concepts.h
+#ifndef SAMEAS_CONCEPTS_H_
+#define SAMEAS_CONCEPTS_H_
+
+#include "same_as.h"
+
+template 
+concept ConflictingConcept = true;
+
+#endif // SAMEAS_CONCEPTS_H
+
+//--- same_as.h
+#ifndef SAME_AS_H
+#define SAME_AS_H
+
+template 
+concept same_as = __is_same(T, U);
+
+#endif // SAME_AS_H
+
+//--- format.h
+#ifndef FORMAT_H
+#define FORMAT_H
+
+#include "concepts.h"
+#include "same_as.h"
+
+template  void foo()
+  requires same_as
+{}
+
+#endif // FORMAT_H
+
+//--- conflicting.h
+#ifndef CONFLICTING_H
+#define CONFLICTING_H
+
+template 
+concept ConflictingConcept = true;
+
+#endif // CONFLICTING_H
Index: clang/test/Modules/merge-concepts-cxx-modules.cpp
===
--- /dev/null
+++ clang/test/Modules/merge-concepts-cxx-modules.cpp
@@ -0,0 +1,46 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: split-file %s %t
+//
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/same_as.cppm -o %t/same_as.pcm
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface -fprebuilt-module-path=%t %t/concepts.cppm -o %t/concepts.pcm
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface -fprebuilt-module-path=%t %t/format.cppm -o %t/format.pcm
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/conflicting.cppm -o %t/conflicting.pcm
+// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/Use.cppm -fsyntax-only -verify
+
+//--- same_as.cppm
+export module same_as;
+export template 
+concept same_as = __is_same(T, U);
+
+//--- concepts.cppm
+export module concepts;
+export import same_as;
+
+export template 
+concept ConflictingConcept = true;
+
+//--- format.cppm
+
+export module format;
+export import concepts;
+export import same_as;
+
+export template  void foo()
+  requires same_as
+{}
+
+//--- conflicting.cppm
+export module conflicting;
+export template 
+concept ConflictingConcept = true;
+
+//--- Use.cppm
+import format;
+import conflicting;
+
+template  void foo()
+  requires same_as
+{}
+ConflictingConcept auto x = 10; // expected-error {{reference to 'ConflictingConcept' is ambiguous}}
+// expected-note@* 2 {{candidate}}
Index: clang/lib/Sema/SemaTemplate.cpp
===
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -8656,23 +8656,48 @@
   // Check for conflicting previous declaration.
   DeclarationNameInfo NameInfo(NewDecl->getDeclName(), NameLoc);
   LookupResult Previous(*this, NameInfo, LookupOrdinaryName,
-ForVisibleRedeclaration);
+forRedeclarationInCurContext());
   LookupName(Previous, S);
-
   FilterLookupForScope(Previous, DC, S, /*ConsiderLinkage=*/false,
/*AllowInlineNamespace*/false);
-  if (!Previous.empty()) {
-auto *Old = Previous.getRepresentativeDecl();
-Diag(NameLoc, isa(Old) ? diag::err_redefinition :
- diag::err_redefinition_different_kind) << NewDecl->getDeclName();
-Diag(Old->getLocation(), diag::note_previous_definition);
-  }
+  CheckConceptRedefinition(NewDecl, Previous);
 
   ActOnDocumentableDecl(NewDecl);
   PushOnScopeChains(NewDecl, S);
   return NewDecl;
 }
 
+void Sema::CheckConceptRedefinition(ConceptDecl *NewDecl,
+

[clang] fb06dd3 - Revert "[Clang] Add a warning on invalid UTF-8 in comments."

2022-07-06 Thread Corentin Jabot via cfe-commits

Author: Corentin Jabot
Date: 2022-07-06T19:45:12+02:00
New Revision: fb06dd3e8ca1b89579055a74f2217e7665c3f150

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

LOG: Revert "[Clang] Add a warning on invalid UTF-8 in comments."

Reverting while I investigate build failures

This reverts commit e3dc56805f1029dd5959e4c69196a287961afb8d.

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/DiagnosticLexKinds.td
clang/lib/Lex/Lexer.cpp
llvm/include/llvm/Support/ConvertUTF.h
llvm/lib/Support/ConvertUTF.cpp

Removed: 
clang/test/Lexer/comment-invalid-utf8.c



diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index c50e1b89649cf..0f542e08b841c 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -279,8 +279,6 @@ Improvements to Clang's diagnostics
   unevaluated operands of a ``typeid`` expression, as they are now
   modeled correctly in the CFG. This fixes
   `Issue 21668 `_.
-- Added ``-Winvalid-utf8`` which diagnoses invalid UTF-8 code unit sequences in
-  comments.
 
 Non-comprehensive list of changes in this release
 -
@@ -578,7 +576,7 @@ AST Matchers
 
 - Added ``forEachTemplateArgument`` matcher which creates a match every
   time a ``templateArgument`` matches the matcher supplied to it.
-
+  
 - Added ``objcStringLiteral`` matcher which matches ObjectiveC String
   literal expressions.
 

diff  --git a/clang/include/clang/Basic/DiagnosticLexKinds.td 
b/clang/include/clang/Basic/DiagnosticLexKinds.td
index 38ee022e5f04c..ac86076140c58 100644
--- a/clang/include/clang/Basic/DiagnosticLexKinds.td
+++ b/clang/include/clang/Basic/DiagnosticLexKinds.td
@@ -113,8 +113,6 @@ def warn_four_char_character_literal : Warning<
 // Unicode and UCNs
 def err_invalid_utf8 : Error<
   "source file is not valid UTF-8">;
-def warn_invalid_utf8_in_comment : Extension<
-  "invalid UTF-8 in comment">, InGroup>;
 def err_character_not_allowed : Error<
   "unexpected character ">;
 def err_character_not_allowed_identifier : Error<

diff  --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp
index 351e518c7ed37..6820057642bea 100644
--- a/clang/lib/Lex/Lexer.cpp
+++ b/clang/lib/Lex/Lexer.cpp
@@ -2392,37 +2392,13 @@ bool Lexer::SkipLineComment(Token , const char 
*CurPtr,
   //
   // This loop terminates with CurPtr pointing at the newline (or end of 
buffer)
   // character that ends the line comment.
-
-  // C++23 [lex.phases] p1
-  // Diagnose invalid UTF-8 if the corresponding warning is enabled, emitting a
-  // diagnostic only once per entire ill-formed subsequence to avoid
-  // emiting to many diagnostics (see http://unicode.org/review/pr-121.html).
-  bool UnicodeDecodingAlreadyDiagnosed = false;
-
   char C;
   while (true) {
 C = *CurPtr;
 // Skip over characters in the fast loop.
-while (isASCII(C) && C != 0 &&   // Potentially EOF.
-   C != '\n' && C != '\r') { // Newline or DOS-style newline.
+while (C != 0 &&// Potentially EOF.
+   C != '\n' && C != '\r')  // Newline or DOS-style newline.
   C = *++CurPtr;
-  UnicodeDecodingAlreadyDiagnosed = false;
-}
-
-if (!isASCII(C)) {
-  unsigned Length = llvm::getUTF8SequenceSize(
-  (const llvm::UTF8 *)CurPtr, (const llvm::UTF8 *)BufferEnd);
-  if (Length == 0) {
-if (!UnicodeDecodingAlreadyDiagnosed && !isLexingRawMode())
-  Diag(CurPtr, diag::warn_invalid_utf8_in_comment);
-UnicodeDecodingAlreadyDiagnosed = true;
-++CurPtr;
-  } else {
-UnicodeDecodingAlreadyDiagnosed = false;
-CurPtr += Length;
-  }
-  continue;
-}
 
 const char *NextLine = CurPtr;
 if (C != 0) {
@@ -2689,12 +2665,6 @@ bool Lexer::SkipBlockComment(Token , const char 
*CurPtr,
   if (C == '/')
 C = *CurPtr++;
 
-  // C++23 [lex.phases] p1
-  // Diagnose invalid UTF-8 if the corresponding warning is enabled, emitting a
-  // diagnostic only once per entire ill-formed subsequence to avoid
-  // emiting to many diagnostics (see http://unicode.org/review/pr-121.html).
-  bool UnicodeDecodingAlreadyDiagnosed = false;
-
   while (true) {
 // Skip over all non-interesting characters until we find end of buffer or 
a
 // (probably ending) '/' character.
@@ -2703,24 +2673,14 @@ bool Lexer::SkipBlockComment(Token , const char 
*CurPtr,
 // doesn't check for '\0'.
 !(PP && PP->getCodeCompletionFileLoc() == FileLoc)) {
   // While not aligned to a 16-byte boundary.
-  while (C != '/' && (intptr_t)CurPtr % 16 != 0) {
-if (!isASCII(C)) {
-  CurPtr--;
-  goto MultiByteUTF8;
-}
+  while 

[PATCH] D125693: [DebugInfo] Support types, imports and static locals declared in a lexical block (3/5)

2022-07-06 Thread Ellis Hoag via Phabricator via cfe-commits
ellis added inline comments.



Comment at: llvm/test/Instrumentation/InstrProfiling/debug-info-correlate.ll:23
   call void @llvm.instrprof.increment(i8* getelementptr inbounds ([3 x i8], [3 
x i8]* @__profn_foo, i32 0, i32 0), i64 12345678, i32 2, i32 0)
-  ret void
+  ret void, !dbg !17
 }

krisb wrote:
> ellis wrote:
> > I asked the same question in D113741, but why is this test changed?
> Normally, we emit function-local entities iff a parent function has location 
> information. This is done the same way for local variables, labels, 
> parameters, imported entities, and, //now,// for static locals as well.
> Before this change static locals behaved more like global variables and get 
> emitted doesn't matter its parent function. This patch makes them handled 
> more like local variables.
> 
> I believe either the call or the 'ret' (or, likely, both) had had DILocation 
> attached originally, but it has been removed to simplify the test.
I just checked and the `llvm.instrprof.increment` intrinsic does not have debug 
info attached. I think you're right that I removed debug info from the `ret` 
instruction to simplify the test.

This is a special case where a global and its debug info is synthesized.
https://github.com/llvm/llvm-project/blob/23c2bedfd93cfacc62009425c464e659a34e92e6/llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp#L976-L1001

So I don't understand why this added debug info is necessary. Does the test 
fail otherwise?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125693

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


[PATCH] D123878: [AMDGPU] Add remarks to output some resource usage

2022-07-06 Thread Vang Thao via Phabricator via cfe-commits
vangthao marked 5 inline comments as done.
vangthao added a comment.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123878

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


[PATCH] D129016: [PowerPC] implemented @llvm.ppc.kill.canary to corrupt stack guard

2022-07-06 Thread Paul Scoropan via Phabricator via cfe-commits
pscoro updated this revision to Diff 442630.
pscoro added a comment.

patch appication troubleshooting


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129016

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Basic/Targets/PPC.cpp
  clang/test/CodeGen/PowerPC/builtins-ppc-stackprotect.c
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/test/CodeGen/PowerPC/kill-canary-intrinsic.ll

Index: llvm/test/CodeGen/PowerPC/kill-canary-intrinsic.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/kill-canary-intrinsic.ll
@@ -0,0 +1,77 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-aix \
+; RUN:   --ppc-asm-full-reg-names < %s | FileCheck %s -check-prefix=AIX
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux \
+; RUN:   --ppc-asm-full-reg-names < %s | FileCheck %s -check-prefix=LINUX
+
+declare void @llvm.ppc.kill.canary()
+define dso_local void @test_kill_canary() {
+; AIX-LABEL: test_kill_canary:
+; AIX:   # %bb.0: # %entry
+; AIX-NEXT:blr
+;
+; LINUX-LABEL: test_kill_canary:
+; LINUX:   # %bb.0: # %entry
+; LINUX-NEXT:blr
+entry:
+  call void @llvm.ppc.kill.canary()
+  ret void
+}
+
+attributes #0 = { sspreq }
+; Function Attrs: sspreq
+define dso_local void @test_kill_canary_ssp() #0 {
+; AIX-LABEL: test_kill_canary_ssp:
+; AIX:   # %bb.0: # %entry
+; AIX-NEXT:mflr r0
+; AIX-NEXT:std r0, 16(r1)
+; AIX-NEXT:stdu r1, -128(r1)
+; AIX-NEXT:ld r3, L..C0(r2) # @__ssp_canary_word
+; AIX-NEXT:ld r4, 0(r3)
+; AIX-NEXT:std r4, 120(r1)
+; AIX-NEXT:ld r4, 0(r3)
+; AIX-NEXT:xori r4, r4, 65535
+; AIX-NEXT:xoris r4, r4, 65535
+; AIX-NEXT:std r4, 0(r3)
+; AIX-NEXT:ld r3, 0(r3)
+; AIX-NEXT:ld r4, 120(r1)
+; AIX-NEXT:cmpld r3, r4
+; AIX-NEXT:bne cr0, L..BB1_2
+; AIX-NEXT:  # %bb.1: # %entry
+; AIX-NEXT:addi r1, r1, 128
+; AIX-NEXT:ld r0, 16(r1)
+; AIX-NEXT:mtlr r0
+; AIX-NEXT:blr
+; AIX-NEXT:  L..BB1_2: # %entry
+; AIX-NEXT:bl .__stack_chk_fail[PR]
+; AIX-NEXT:nop
+;
+; LINUX-LABEL: test_kill_canary_ssp:
+; LINUX:   # %bb.0: # %entry
+; LINUX-NEXT:mflr r0
+; LINUX-NEXT:std r0, 16(r1)
+; LINUX-NEXT:stdu r1, -128(r1)
+; LINUX-NEXT:.cfi_def_cfa_offset 128
+; LINUX-NEXT:.cfi_offset lr, 16
+; LINUX-NEXT:ld r3, -28688(r13)
+; LINUX-NEXT:std r3, 120(r1)
+; LINUX-NEXT:ld r3, -28688(r13)
+; LINUX-NEXT:xori r3, r3, 65535
+; LINUX-NEXT:xoris r3, r3, 65535
+; LINUX-NEXT:std r3, 120(r1)
+; LINUX-NEXT:ld r3, 120(r1)
+; LINUX-NEXT:ld r4, -28688(r13)
+; LINUX-NEXT:cmpld r4, r3
+; LINUX-NEXT:bne cr0, .LBB1_2
+; LINUX-NEXT:  # %bb.1: # %entry
+; LINUX-NEXT:addi r1, r1, 128
+; LINUX-NEXT:ld r0, 16(r1)
+; LINUX-NEXT:mtlr r0
+; LINUX-NEXT:blr
+; LINUX-NEXT:  .LBB1_2: # %entry
+; LINUX-NEXT:bl __stack_chk_fail
+; LINUX-NEXT:nop
+entry:
+  call void @llvm.ppc.kill.canary()
+  ret void
+}
Index: llvm/lib/Target/PowerPC/PPCISelLowering.cpp
===
--- llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -11143,6 +11143,72 @@
 }
 break;
   }
+  case Intrinsic::ppc_kill_canary: {
+MachineFunction  = DAG.getMachineFunction();
+const Module *M = MF.getMMI().getModule();
+
+/* If SafeStack or !StackProtector, kill_canary not supported */
+if (MF.getFunction().hasFnAttribute(Attribute::SafeStack) ||
+!MF.getFunction().hasStackProtectorFnAttr()) {
+  DAG.ReplaceAllUsesOfValueWith(
+  SDValue(Op.getNode(), 0),
+  Op->getOperand(0)); // prepare node for deletion
+  break;
+}
+
+EVT VT = DAG.getTargetLoweringInfo().getPointerTy(DAG.getDataLayout());
+
+SDValue Load;
+SDValue Store;
+
+const uint64_t XORWord =
+0x; // XORing with 0b111...111 will never
+// result in the original word
+
+if (useLoadStackGuardNode()) { // linux uses LOAD_STACK_GUARD node instead
+   // of having a canary word global value
+  MachineSDNode *LSG =
+  DAG.getMachineNode(PPC::LOAD_STACK_GUARD, DL, VT, Op->getOperand(0));
+  Load = SDValue(LSG, 0);
+
+  /* frame index used to determine stack guard location if
+   * LOAD_STACK_GUARD is used */
+  MachineFrameInfo  = MF.getFrameInfo();
+  int SPI = MFI.getStackProtectorIndex(); // should return -1
+  PPCFunctionInfo *FuncInfo = MF.getInfo();
+  SDValue FIN = DAG.getFrameIndex(FuncInfo->getVarArgsFrameIndex(), VT);
+
+  // XOR canary word and store back
+  Store = DAG.getStore(
+  Op->getOperand(0), DL,
+  

[PATCH] D129149: [OMPIRBuilder] Add support for simdlen clause

2022-07-06 Thread Prabhdeep Soni via Phabricator via cfe-commits
psoni2628 added inline comments.



Comment at: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h:608
+  ///
+  /// \param DL  Debug location for instructions added by unrolling.
+  /// \param LoopThe simd loop.

jdoerfert wrote:
> psoni2628 wrote:
> > jdoerfert wrote:
> > > No debug location needed. You also copied the comment that makes little 
> > > sene.
> > It isn't used in the original applySimd either. Should I remove it in both 
> > places?
> Yes.
Looks like I'll need to fix `applySimd` on the MLIR side too. I think it makes 
more sense to do that separately in a different patch. For now, I will leave 
`applySimd` with the unused `DebugLocation`. I will fix `applySimdlen`.


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

https://reviews.llvm.org/D129149

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


[PATCH] D129016: [PowerPC] implemented @llvm.ppc.kill.canary to corrupt stack guard

2022-07-06 Thread Paul Scoropan via Phabricator via cfe-commits
pscoro updated this revision to Diff 442627.
pscoro added a comment.

rebased


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129016

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Basic/Targets/PPC.cpp
  clang/test/CodeGen/PowerPC/builtins-ppc-stackprotect.c
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/test/CodeGen/PowerPC/kill-canary-intrinsic.ll

Index: llvm/test/CodeGen/PowerPC/kill-canary-intrinsic.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/kill-canary-intrinsic.ll
@@ -0,0 +1,77 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-aix \
+; RUN:   --ppc-asm-full-reg-names < %s | FileCheck %s -check-prefix=AIX
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux \
+; RUN:   --ppc-asm-full-reg-names < %s | FileCheck %s -check-prefix=LINUX
+
+declare void @llvm.ppc.kill.canary()
+define dso_local void @test_kill_canary() {
+; AIX-LABEL: test_kill_canary:
+; AIX:   # %bb.0: # %entry
+; AIX-NEXT:blr
+;
+; LINUX-LABEL: test_kill_canary:
+; LINUX:   # %bb.0: # %entry
+; LINUX-NEXT:blr
+entry:
+  call void @llvm.ppc.kill.canary()
+  ret void
+}
+
+attributes #0 = { sspreq }
+; Function Attrs: sspreq
+define dso_local void @test_kill_canary_ssp() #0 {
+; AIX-LABEL: test_kill_canary_ssp:
+; AIX:   # %bb.0: # %entry
+; AIX-NEXT:mflr r0
+; AIX-NEXT:std r0, 16(r1)
+; AIX-NEXT:stdu r1, -128(r1)
+; AIX-NEXT:ld r3, L..C0(r2) # @__ssp_canary_word
+; AIX-NEXT:ld r4, 0(r3)
+; AIX-NEXT:std r4, 120(r1)
+; AIX-NEXT:ld r4, 0(r3)
+; AIX-NEXT:xori r4, r4, 65535
+; AIX-NEXT:xoris r4, r4, 65535
+; AIX-NEXT:std r4, 0(r3)
+; AIX-NEXT:ld r3, 0(r3)
+; AIX-NEXT:ld r4, 120(r1)
+; AIX-NEXT:cmpld r3, r4
+; AIX-NEXT:bne cr0, L..BB1_2
+; AIX-NEXT:  # %bb.1: # %entry
+; AIX-NEXT:addi r1, r1, 128
+; AIX-NEXT:ld r0, 16(r1)
+; AIX-NEXT:mtlr r0
+; AIX-NEXT:blr
+; AIX-NEXT:  L..BB1_2: # %entry
+; AIX-NEXT:bl .__stack_chk_fail[PR]
+; AIX-NEXT:nop
+;
+; LINUX-LABEL: test_kill_canary_ssp:
+; LINUX:   # %bb.0: # %entry
+; LINUX-NEXT:mflr r0
+; LINUX-NEXT:std r0, 16(r1)
+; LINUX-NEXT:stdu r1, -128(r1)
+; LINUX-NEXT:.cfi_def_cfa_offset 128
+; LINUX-NEXT:.cfi_offset lr, 16
+; LINUX-NEXT:ld r3, -28688(r13)
+; LINUX-NEXT:std r3, 120(r1)
+; LINUX-NEXT:ld r3, -28688(r13)
+; LINUX-NEXT:xori r3, r3, 65535
+; LINUX-NEXT:xoris r3, r3, 65535
+; LINUX-NEXT:std r3, 120(r1)
+; LINUX-NEXT:ld r3, 120(r1)
+; LINUX-NEXT:ld r4, -28688(r13)
+; LINUX-NEXT:cmpld r4, r3
+; LINUX-NEXT:bne cr0, .LBB1_2
+; LINUX-NEXT:  # %bb.1: # %entry
+; LINUX-NEXT:addi r1, r1, 128
+; LINUX-NEXT:ld r0, 16(r1)
+; LINUX-NEXT:mtlr r0
+; LINUX-NEXT:blr
+; LINUX-NEXT:  .LBB1_2: # %entry
+; LINUX-NEXT:bl __stack_chk_fail
+; LINUX-NEXT:nop
+entry:
+  call void @llvm.ppc.kill.canary()
+  ret void
+}
Index: llvm/lib/Target/PowerPC/PPCISelLowering.cpp
===
--- llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -11143,6 +11143,72 @@
 }
 break;
   }
+  case Intrinsic::ppc_kill_canary: {
+MachineFunction  = DAG.getMachineFunction();
+const Module *M = MF.getMMI().getModule();
+
+/* If SafeStack or !StackProtector, kill_canary not supported */
+if (MF.getFunction().hasFnAttribute(Attribute::SafeStack) ||
+!MF.getFunction().hasStackProtectorFnAttr()) {
+  DAG.ReplaceAllUsesOfValueWith(
+  SDValue(Op.getNode(), 0),
+  Op->getOperand(0)); // prepare node for deletion
+  break;
+}
+
+EVT VT = DAG.getTargetLoweringInfo().getPointerTy(DAG.getDataLayout());
+
+SDValue Load;
+SDValue Store;
+
+const uint64_t XORWord =
+0x; // XORing with 0b111...111 will never
+// result in the original word
+
+if (useLoadStackGuardNode()) { // linux uses LOAD_STACK_GUARD node instead
+   // of having a canary word global value
+  MachineSDNode *LSG =
+  DAG.getMachineNode(PPC::LOAD_STACK_GUARD, DL, VT, Op->getOperand(0));
+  Load = SDValue(LSG, 0);
+
+  /* frame index used to determine stack guard location if
+   * LOAD_STACK_GUARD is used */
+  MachineFrameInfo  = MF.getFrameInfo();
+  int SPI = MFI.getStackProtectorIndex(); // should return -1
+  PPCFunctionInfo *FuncInfo = MF.getInfo();
+  SDValue FIN = DAG.getFrameIndex(FuncInfo->getVarArgsFrameIndex(), VT);
+
+  // XOR canary word and store back
+  Store = DAG.getStore(
+  Op->getOperand(0), DL,
+  DAG.getNode(ISD::XOR, DL, VT, Load, 

[PATCH] D126864: [clang] Introduce -fstrict-flex-arrays= for stricter handling of flexible arrays

2022-07-06 Thread serge via Phabricator via cfe-commits
serge-sans-paille added inline comments.



Comment at: clang/docs/ClangCommandLineReference.rst:2644
+
+Control which arrays are considered as flexible arrays members. 
+can be 1 (array of size 0, 1 and undefined are considered), 2 (array of size 0

jyknight wrote:
> Docs should also mention what the default -fno-strict-flex-arrays means -- 
> that ALL sizes of trailing arrays are considered flexible array members. (I'm 
> amazed that's the rule, and I never knew it. I always thought the special 
> casing for FAMs was restricted to sizes 0 and 1!)
> 
> Also, since apparently different parts of the compiler have been (and will 
> now continue to) use different default behaviors, may want to document that 
> as well. I'm sure I don't know what the rules actually are intended to be 
> here. E.g. that a macro-expansion of the size arg disables the 
> special-behavior for [1] is extremely surprising!
it is worse than that: for some checks, any size is valid for FAM, but not for 
alls. For some checks, macro expansion prohibits FAM, but not for all, etc, 
etc. I don't want to document that behavior, because it is too specific to each 
pass. My plan is

1. land -fstrict-flex-array support
2. launch a thread on the ugly situation we put ourselves in, and extract a 
decision for each case
3. support and document an homogeneous behavior across passes.
4. syndicate code across passes



Comment at: clang/lib/Sema/SemaChecking.cpp:15804
+
+  // FIXME: we should also allow Size = 0 here per the definition of
+  // StrictFlexArraysLevel, but that's backward incompatible with previous 
clang

jyknight wrote:
> Presumably the size-zero/unsized cases are already being taken care of 
> elsewhere in the code? I find it hard to believe we are currently emitting 
> diagnostics for size-0 FAM which we don't emit for size-1 FAM?
correct



Comment at: clang/lib/Sema/SemaChecking.cpp:15969
 // access which precedes the array bounds.
 if (BaseType->isIncompleteType())
   return;

And here



Comment at: clang/lib/Sema/SemaChecking.cpp:15973
 llvm::APInt size = ArrayTy->getSize();
 if (!size.isStrictlyPositive())
   return;

Handled here



Comment at: clang/test/SemaCXX/array-bounds-strict-flex-arrays.cpp:9
+  } s2;
+  s2.a[2] = 0; // no-warning
+}

jyknight wrote:
> Except we actually _do_ know the bounds of the full-object and ought to be 
> able to warn on this code anyhow...
> 
> Better to have the test function accept a pointer, so that's not a conflating 
> issue?
Correct


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126864

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


[PATCH] D128059: [Clang] Add a warning on invalid UTF-8 in comments.

2022-07-06 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

As far as I can tell, this breaks check-clang everywhere: http://45.33.8.238/

Please take a look and revert for now if it takes a while to fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128059

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


[clang] d34ce04 - [CMake][Fuchsia] Install static libuwind

2022-07-06 Thread Petr Hosek via cfe-commits

Author: Petr Hosek
Date: 2022-07-06T17:17:40Z
New Revision: d34ce04f98c387aa86c13cb502e3e2a8a4d8f38b

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

LOG: [CMake][Fuchsia] Install static libuwind

This can now be used with -static-libgcc.

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

Added: 


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

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 4e3ed6086dec5..412dbdf71b68a 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -183,7 +183,6 @@ if(FUCHSIA_SDK)
 set(RUNTIMES_${target}_COMPILER_RT_USE_LLVM_UNWINDER ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBUNWIND_HIDE_SYMBOLS ON CACHE BOOL "")
-set(RUNTIMES_${target}_LIBUNWIND_INSTALL_STATIC_LIBRARY OFF CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_ENABLE_STATIC_UNWINDER ON CACHE BOOL "")



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


[PATCH] D129218: [CMake][Fuchsia] Install static libuwind

2022-07-06 Thread Petr Hosek 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 rGd34ce04f98c3: [CMake][Fuchsia] Install static libuwind 
(authored by phosek).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129218

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


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -183,7 +183,6 @@
 set(RUNTIMES_${target}_COMPILER_RT_USE_LLVM_UNWINDER ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBUNWIND_HIDE_SYMBOLS ON CACHE BOOL "")
-set(RUNTIMES_${target}_LIBUNWIND_INSTALL_STATIC_LIBRARY OFF CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_ENABLE_STATIC_UNWINDER ON CACHE BOOL "")


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -183,7 +183,6 @@
 set(RUNTIMES_${target}_COMPILER_RT_USE_LLVM_UNWINDER ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBUNWIND_HIDE_SYMBOLS ON CACHE BOOL "")
-set(RUNTIMES_${target}_LIBUNWIND_INSTALL_STATIC_LIBRARY OFF CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_ENABLE_STATIC_UNWINDER ON CACHE BOOL "")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D128921: [Sema] Merge C++20 concept definitions from different modules in same TU

2022-07-06 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

PS I will make sure to look at the patches you sent my way this week.
Wanted to do it earlier, but have been having some personal emergencies I 
needed to take care of.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128921

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


[PATCH] D128921: [Sema] Merge C++20 concept definitions from different modules in same TU

2022-07-06 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Many thanks! I didn't know about `split-file`, it's much nicer indeed!

Also incorporating feedback from @rsmith and removing the call to 
`makeMergedDefinitionVisible`. Keeping just `setPrimaryMergedDecl` is enough 
here.
Richard's reply from the email exchange:

  I don't think that makeMergedDefinitionVisible is quite right; that's 
intended to solve a different problem. Specifically, when we have a repeated 
class definition in a single parse:
  
  // in module X
  class A { void f(); };
  
  // in module Y
  class A { void f(); };
  
  Here, we first see and parse the class definition of A in module X. That then 
becomes "the" definition of A, for the purposes of this compilation. Then when 
we see another definition of the class, we choose to skip it because we already 
have a definition, and Clang wants there to only be one definition of each 
class. So we end up behaving as if we parsed this:
  
  // in module X
  class A { void f(); };
  
  // in module Y
  class A;
  
  ... but we still need to track that class A has a complete definition if only 
Y is imported, so that A::f can be used for example. And that's what 
makeMergedDefinitionVisible does: it says that A should be considered as having 
a complete definition when Y is imported, even though the definition actually 
lives in X.
  
  For concepts I think the situation is different: we're not going to skip the 
"body" of the concept and treat
  
  // module X
  template concept bool C = true;
  
  // module Y
  template concept bool C = true;
  
  as if it were
  
  
  // module X
  template concept bool C = true;
  
  // module Y
  template concept bool C; // forward declaration?
  
  ... because there's no such thing as a forward declaration of a concept. 
Instead, I think we should just be calling ASTContext::setPrimaryMergedDecl to 
say that the C in module Y is a redeclaration of the C in module X, so that a 
name lookup that finds both is not ambiguous. It shouldn't matter which one we 
actually pick, because they are the same.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128921

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


[PATCH] D128921: [Sema] Merge C++20 concept definitions from different modules in same TU

2022-07-06 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 442623.
ilya-biryukov marked 2 inline comments as done.
ilya-biryukov added a comment.

- Update code to match how typedefs behave
- remove leftover test from previous version
- Add test for C++20 modules, rewrite original test with split-file
- use isReachable, do not call makeMergedDefinitionVisible


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128921

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/test/Modules/merge-concepts-cxx-modules.cpp
  clang/test/Modules/merge-concepts.cpp

Index: clang/test/Modules/merge-concepts.cpp
===
--- /dev/null
+++ clang/test/Modules/merge-concepts.cpp
@@ -0,0 +1,83 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: split-file %s %t
+//
+// RUN: %clang_cc1 -xc++ -std=c++20 -fmodules -fmodule-name=library \
+// RUN: -emit-module %t/modules.map \
+// RUN: -o %t/module.pcm
+//
+//
+// RUN: %clang_cc1 -xc++ -std=c++20 -fmodules -fmodule-file=%t/module.pcm  \
+// RUN: -fmodule-map-file=%t/modules.map \
+// RUN: -fsyntax-only -verify %t/use.cpp
+//
+//--- use.cpp
+
+#include "concepts.h"
+#include "conflicting.h"
+#include "format.h"
+
+template  void foo()
+  requires same_as
+{}
+ConflictingConcept auto x = 10; // expected-error {{reference to 'ConflictingConcept' is ambiguous}}
+// expected-note@* 2 {{candidate}}
+
+//--- modules.map
+module "library" {
+	export *
+	module "concepts" {
+		export *
+		header "concepts.h"
+	}
+	module "format" {
+		export *
+		header "format.h"
+	}
+	module "conflicting" {
+		export *
+		header "conflicting.h"
+	}
+}
+
+//--- concepts.h
+#ifndef SAMEAS_CONCEPTS_H_
+#define SAMEAS_CONCEPTS_H_
+
+#include "same_as.h"
+
+template 
+concept ConflictingConcept = true;
+
+#endif // SAMEAS_CONCEPTS_H
+
+//--- same_as.h
+#ifndef SAME_AS_H
+#define SAME_AS_H
+
+template 
+concept same_as = __is_same(T, U);
+
+#endif // SAME_AS_H
+
+//--- format.h
+#ifndef FORMAT_H
+#define FORMAT_H
+
+#include "concepts.h"
+#include "same_as.h"
+
+template  void foo()
+  requires same_as
+{}
+
+#endif // FORMAT_H
+
+//--- conflicting.h
+#ifndef CONFLICTING_H
+#define CONFLICTING_H
+
+template 
+concept ConflictingConcept = true;
+
+#endif // CONFLICTING_H
Index: clang/test/Modules/merge-concepts-cxx-modules.cpp
===
--- /dev/null
+++ clang/test/Modules/merge-concepts-cxx-modules.cpp
@@ -0,0 +1,46 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: split-file %s %t
+//
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/same_as.cppm -o %t/same_as.pcm
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface -fprebuilt-module-path=%t %t/concepts.cppm -o %t/concepts.pcm
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface -fprebuilt-module-path=%t %t/format.cppm -o %t/format.pcm
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/conflicting.cppm -o %t/conflicting.pcm
+// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/Use.cppm -fsyntax-only -verify
+
+//--- same_as.cppm
+export module same_as;
+export template 
+concept same_as = __is_same(T, U);
+
+//--- concepts.cppm
+export module concepts;
+export import same_as;
+
+export template 
+concept ConflictingConcept = true;
+
+//--- format.cppm
+
+export module format;
+export import concepts;
+export import same_as;
+
+export template  void foo()
+  requires same_as
+{}
+
+//--- conflicting.cppm
+export module conflicting;
+export template 
+concept ConflictingConcept = true;
+
+//--- Use.cppm
+import format;
+import conflicting;
+
+template  void foo()
+  requires same_as
+{}
+ConflictingConcept auto x = 10; // expected-error {{reference to 'ConflictingConcept' is ambiguous}}
+// expected-note@* 2 {{candidate}}
Index: clang/lib/Sema/SemaTemplate.cpp
===
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -8656,23 +8656,52 @@
   // Check for conflicting previous declaration.
   DeclarationNameInfo NameInfo(NewDecl->getDeclName(), NameLoc);
   LookupResult Previous(*this, NameInfo, LookupOrdinaryName,
-ForVisibleRedeclaration);
+forRedeclarationInCurContext());
   LookupName(Previous, S);
-
   FilterLookupForScope(Previous, DC, S, /*ConsiderLinkage=*/false,
/*AllowInlineNamespace*/false);
-  if (!Previous.empty()) {
-auto *Old = Previous.getRepresentativeDecl();
-Diag(NameLoc, isa(Old) ? diag::err_redefinition :
- diag::err_redefinition_different_kind) << NewDecl->getDeclName();
-Diag(Old->getLocation(), diag::note_previous_definition);
-  }
+  bool AddToScope = true;
+  CheckConceptRedefinition(NewDecl, Previous, AddToScope);
 
   

[PATCH] D129218: [CMake][Fuchsia] Install static libuwind

2022-07-06 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added a reviewer: abrachet.
Herald added a subscriber: mgorny.
Herald added a project: All.
phosek requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This can now be used with -static-libgcc.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129218

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


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -183,7 +183,6 @@
 set(RUNTIMES_${target}_COMPILER_RT_USE_LLVM_UNWINDER ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBUNWIND_HIDE_SYMBOLS ON CACHE BOOL "")
-set(RUNTIMES_${target}_LIBUNWIND_INSTALL_STATIC_LIBRARY OFF CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_ENABLE_STATIC_UNWINDER ON CACHE BOOL "")


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -183,7 +183,6 @@
 set(RUNTIMES_${target}_COMPILER_RT_USE_LLVM_UNWINDER ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBUNWIND_HIDE_SYMBOLS ON CACHE BOOL "")
-set(RUNTIMES_${target}_LIBUNWIND_INSTALL_STATIC_LIBRARY OFF CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_ENABLE_STATIC_UNWINDER ON CACHE BOOL "")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D127042: [Clang][OpenMP] Enable floating-point operation for `atomic compare` series

2022-07-06 Thread Shilei Tian 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 rG83837a61981c: [Clang][OpenMP] Enable floating-point 
operation for `atomic compare` series (authored by tianshilei1992).

Changed prior to commit:
  https://reviews.llvm.org/D127042?vs=442588=442618#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127042

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/atomic_compare_codegen.cpp
  clang/test/OpenMP/atomic_messages.c
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

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


[PATCH] D126864: [clang] Introduce -fstrict-flex-arrays= for stricter handling of flexible arrays

2022-07-06 Thread James Y Knight via Phabricator via cfe-commits
jyknight added inline comments.



Comment at: clang/docs/ClangCommandLineReference.rst:2644
+
+Control which arrays are considered as flexible arrays members. 
+can be 1 (array of size 0, 1 and undefined are considered), 2 (array of size 0

Docs should also mention what the default -fno-strict-flex-arrays means -- that 
ALL sizes of trailing arrays are considered flexible array members. (I'm amazed 
that's the rule, and I never knew it. I always thought the special casing for 
FAMs was restricted to sizes 0 and 1!)

Also, since apparently different parts of the compiler have been (and will now 
continue to) use different default behaviors, may want to document that as 
well. I'm sure I don't know what the rules actually are intended to be here. 
E.g. that a macro-expansion of the size arg disables the special-behavior for 
[1] is extremely surprising!



Comment at: clang/lib/Sema/SemaChecking.cpp:15804
+
+  // FIXME: we should also allow Size = 0 here per the definition of
+  // StrictFlexArraysLevel, but that's backward incompatible with previous 
clang

Presumably the size-zero/unsized cases are already being taken care of 
elsewhere in the code? I find it hard to believe we are currently emitting 
diagnostics for size-0 FAM which we don't emit for size-1 FAM?



Comment at: clang/test/SemaCXX/array-bounds-strict-flex-arrays.cpp:9
+  } s2;
+  s2.a[2] = 0; // no-warning
+}

Except we actually _do_ know the bounds of the full-object and ought to be able 
to warn on this code anyhow...

Better to have the test function accept a pointer, so that's not a conflating 
issue?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126864

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


Re: [PATCH] D129100: [clangd] Support external throttler for preamble builds

2022-07-06 Thread Andres Freund via cfe-commits
Hi,

On 2022-07-06 16:28:14 +, Sam McCall via Phabricator wrote:
> sammccall added a comment.
> 
> In D129100#3633073 , @anarazel 
> wrote:
> 
> > This caused llvm builds to fail for me (using clang-14, debug, debian 
> > unstable, lld as linker):
> 
> Thanks, I have a very similar setup but the build passed locally, I'll never 
> understand linkers...

Might depend on optimization level (if references are discovered to be dead,
there's no undefined reference)?


> I think I've fixed this in e7fa272bc6a6a504c2899bb7cf66029678d97890 
> 

Looks good now, thanks!

Greetings,

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


  1   2   >