[PATCH] D124750: [MLIR] Add a utility to sort the operands of commutative ops

2022-06-15 Thread Srishti Srivastava via Phabricator via cfe-commits
srishti-pm added a comment.

In D124750#3587161 , @mehdi_amini 
wrote:

> Right now I'm not yet understanding all of the algorithm (haven't spent 
> enough time on it), but I'm mostly concerned by the runtime cost of this 
> normalization.

I understand your concern. I'll go through my implementation once and optimize 
things that need it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124750

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


[PATCH] D126676: [clang] Disallow differences in defines used for creating and using PCH

2022-06-15 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In D126676#3587243 , @rnk wrote:

> I don't have a great answer here, but yes, dllexport macro norms sort of run 
> directly counter to the normal ways that people use PCH. It seems like 
> projects will need to have a library module / PCH file for building a DLL and 
> then a PCH / module for consuming the DLL.

This isn’t about sharing a PCH between building and consuming a DLL - that’d be 
highly unusual use of PCHs indeed.

It’s about building a library as both DLL and static library at the same time. 
For that, you’d have a PCH directory containing two versions of the same PCH, 
one built with `-DDLLEXPORT` and one without. When building the object files 
for the two copies of the library (for the static or DLL version), the compiler 
gets called with or without `-DDLLEXPORT`, and is pointed at the directory 
containing the two copies of the PCH.

GCC successfully picks the right one out of the directory, while Clang just 
picks the first one it tries. Clang also does try to pick the right one out of 
a directory with multiple copies (picking the right one, if you have one built 
with `-DFOO=1` and one with `-DFOO=2`), but Clang considers that if you have a 
define entirely missing (PCH built with `-DDLLEXPORT` but the same define 
absent when including the header, or vice versa) that they’re probably 
compatible, and pick the first one out of the directory.

I can somewhat understand the rationale - if not using a PCH directory, but 
only one single file, Clang does allow you to include that while defining 
`-DUNRELATED`. (Clang’s implementation does have a 10 year old todo about 
checking that the differing define indeed was unrelated and not used by the PCH 
in any way.) GCC doesn’t allow that, but requires there to be an exact match 
between all `-D` arguments between when the PCH was built and consumed.

So with GCC’s stricter logic here, I think it would make sense to make Clang 
equally strict, but I wonder if that’d break Clang-only usecases that have 
ended up relying on Clang’s more tolerant behaviour here. (There even are tests 
testing specifically the fuzzy allowing of differences.) Maybe the safest would 
be to only make it strict in the case when picking the right one out of a 
directory with alternatives?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126676

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


[PATCH] D126540: PowerPC] Emit warning for incompatible vector types that are currently diagnosed with -fno-lax-vector-conversions

2022-06-15 Thread Maryam Moghadas via Phabricator via cfe-commits
maryammo added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:7723
+
+  if (SrcTy->isVectorType()) {
+VectorType::VectorKind SrcVecKind =

maryammo wrote:
> lei wrote:
> > do we really need this check since we have an assert above?
> Yes, without this check there is gonna be a compile time failure for cases 
> where SrcTy is not vector but we wanna cast it to vector 
> 'SrcTy->castAs()' 
the assert checks of either of them is a vector but then we wanna check if at 
least one of them is altivec. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126540

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


[PATCH] D126540: PowerPC] Emit warning for incompatible vector types that are currently diagnosed with -fno-lax-vector-conversions

2022-06-15 Thread Maryam Moghadas via Phabricator via cfe-commits
maryammo added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:7723
+
+  if (SrcTy->isVectorType()) {
+VectorType::VectorKind SrcVecKind =

lei wrote:
> do we really need this check since we have an assert above?
Yes, without this check there is gonna be a compile time failure for cases 
where SrcTy is not vector but we wanna cast it to vector 
'SrcTy->castAs()' 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126540

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


[PATCH] D125936: [Sema] Relax an assertion in BuildStmtExpr

2022-06-15 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

In D125936#3587542 , @ahatanak wrote:

> Adding more people to get more eyes on the changes I made to 
> SemaCoroutine.cpp.

The change to SemaCoroutine.cpp might be good. But I feel like it is irreverent 
to the revision. If you want, could you please do the change in another 
revision?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125936

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


[PATCH] D126540: PowerPC] Emit warning for incompatible vector types that are currently diagnosed with -fno-lax-vector-conversions

2022-06-15 Thread Lei Huang via Phabricator via cfe-commits
lei added a comment.

LGTM, just a few nit that can be addressed on commit.




Comment at: clang/lib/Sema/SemaExpr.cpp:7723
+
+  if (SrcTy->isVectorType()) {
+VectorType::VectorKind SrcVecKind =

do we really need this check since we have an assert above?



Comment at: clang/lib/Sema/SemaExpr.cpp:7726
+SrcTy->castAs()->getVectorKind();
+isSrcTyAltivec = (SrcVecKind == VectorType::AltiVecVector);
+  }

I don't think the initialization above is needed.  Can just inline it here.
```
  bool  isSrcTyAltivec = (SrcVecKind == VectorType::AltiVecVector);
```



Comment at: clang/lib/Sema/SemaExpr.cpp:7728
+  }
+  if (DestTy->isVectorType()) {
+VectorType::VectorKind DestVecKind =

same.



Comment at: clang/lib/Sema/SemaExpr.cpp:7731
+DestTy->castAs()->getVectorKind();
+isDestTyAltivec = (DestVecKind == VectorType::AltiVecVector);
+  }

same.



Comment at: clang/lib/Sema/SemaExpr.cpp:7715
 
+bool Sema::areAnyVectorTypesAltivec(QualType SrcTy, QualType DestTy) {
+  assert(DestTy->isVectorType() || SrcTy->isVectorType());

maryammo wrote:
> lei wrote:
> > maryammo wrote:
> > > amyk wrote:
> > > > Can we add some brief documentation for this function, like what is 
> > > > done for other functions in this file?
> > > sure
> > feels like this should be written to just take either 1 param or multiple 
> > params via vararg.. since the 2 arg are not really related in any way.
> I am not sure what you mean, can you please elaborate on that?
actually ignore that comment. I see why you need this now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126540

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


[PATCH] D127876: [clang] Don't emit type test/assume for virtual classes that should never participate in WPD

2022-06-15 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks updated this revision to Diff 437420.
aeubanks added a comment.

update docs to only mention `[[clang::lto_visibility_public]]`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127876

Files:
  clang/docs/LTOVisibility.rst
  clang/lib/CodeGen/CGClass.cpp
  clang/lib/CodeGen/CGVTables.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/test/CodeGenCXX/lto-visibility-inference.cpp

Index: clang/test/CodeGenCXX/lto-visibility-inference.cpp
===
--- clang/test/CodeGenCXX/lto-visibility-inference.cpp
+++ clang/test/CodeGenCXX/lto-visibility-inference.cpp
@@ -79,11 +79,11 @@
   // ITANIUM: type.test{{.*}}!"_ZTS2C4"
   // MS: type.test{{.*}}!"?AUC4@@"
   c4->f();
-  // ITANIUM: type.test{{.*}}!"_ZTS2C5"
-  // MS: type.test{{.*}}!"?AUC5@@"
+  // ITANIUM-NOT: type.test{{.*}}!"_ZTS2C5"
+  // MS-NOT: type.test{{.*}}!"?AUC5@@"
   c5->f();
-  // ITANIUM: type.test{{.*}}!"_ZTS2C6"
-  // MS: type.test{{.*}}!"?AUC6@@"
+  // ITANIUM-NOT: type.test{{.*}}!"_ZTS2C6"
+  // MS-NOT: type.test{{.*}}!"?AUC6@@"
   c6->f();
   // ITANIUM: type.test{{.*}}!"_ZTSSt2C7"
   // MS-STD: type.test{{.*}}!"?AUC7@std@@"
Index: clang/lib/CodeGen/ItaniumCXXABI.cpp
===
--- clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -668,8 +668,8 @@
CGM.HasHiddenLTOVisibility(RD);
   bool ShouldEmitWPDInfo =
   CGM.getCodeGenOpts().WholeProgramVTables &&
-  // Don't insert type tests if we are forcing public std visibility.
-  !CGM.HasLTOVisibilityPublicStd(RD);
+  // Don't insert type tests if we are forcing public visibility.
+  !CGM.AlwaysHasLTOVisibilityPublic(RD);
   llvm::Value *VirtualFn = nullptr;
 
   {
Index: clang/lib/CodeGen/CodeGenModule.h
===
--- clang/lib/CodeGen/CodeGenModule.h
+++ clang/lib/CodeGen/CodeGenModule.h
@@ -1382,10 +1382,10 @@
   /// optimization.
   bool HasHiddenLTOVisibility(const CXXRecordDecl *RD);
 
-  /// Returns whether the given record has public std LTO visibility
-  /// and therefore may not participate in (single-module) CFI and whole-program
-  /// vtable optimization.
-  bool HasLTOVisibilityPublicStd(const CXXRecordDecl *RD);
+  /// Returns whether the given record has public LTO visibility (regardless of
+  /// -lto-whole-program-visibility) and therefore may not participate in
+  /// (single-module) CFI and whole-program vtable optimization.
+  bool AlwaysHasLTOVisibilityPublic(const CXXRecordDecl *RD);
 
   /// Returns the vcall visibility of the given type. This is the scope in which
   /// a virtual function call could be made which ends up being dispatched to a
Index: clang/lib/CodeGen/CGVTables.cpp
===
--- clang/lib/CodeGen/CGVTables.cpp
+++ clang/lib/CodeGen/CGVTables.cpp
@@ -1175,7 +1175,10 @@
   DeferredVTables.clear();
 }
 
-bool CodeGenModule::HasLTOVisibilityPublicStd(const CXXRecordDecl *RD) {
+bool CodeGenModule::AlwaysHasLTOVisibilityPublic(const CXXRecordDecl *RD) {
+  if (RD->hasAttr() || RD->hasAttr())
+return true;
+
   if (!getCodeGenOpts().LTOVisibilityPublicStd)
 return false;
 
@@ -1200,9 +1203,6 @@
   if (!isExternallyVisible(LV.getLinkage()))
 return true;
 
-  if (RD->hasAttr() || RD->hasAttr())
-return false;
-
   if (getTriple().isOSBinFormatCOFF()) {
 if (RD->hasAttr() || RD->hasAttr())
   return false;
@@ -1211,7 +1211,7 @@
   return false;
   }
 
-  return !HasLTOVisibilityPublicStd(RD);
+  return !AlwaysHasLTOVisibilityPublic(RD);
 }
 
 llvm::GlobalObject::VCallVisibility CodeGenModule::GetVCallVisibilityLevel(
Index: clang/lib/CodeGen/CGClass.cpp
===
--- clang/lib/CodeGen/CGClass.cpp
+++ clang/lib/CodeGen/CGClass.cpp
@@ -2695,9 +2695,9 @@
   if (SanOpts.has(SanitizerKind::CFIVCall))
 EmitVTablePtrCheckForCall(RD, VTable, CodeGenFunction::CFITCK_VCall, Loc);
   else if (CGM.getCodeGenOpts().WholeProgramVTables &&
-   // Don't insert type test assumes if we are forcing public std
+   // Don't insert type test assumes if we are forcing public
// visibility.
-   !CGM.HasLTOVisibilityPublicStd(RD)) {
+   !CGM.AlwaysHasLTOVisibilityPublic(RD)) {
 llvm::Metadata *MD =
 CGM.CreateMetadataIdentifierForType(QualType(RD->getTypeForDecl(), 0));
 llvm::Value *TypeId =
Index: clang/docs/LTOVisibility.rst
===
--- clang/docs/LTOVisibility.rst
+++ clang/docs/LTOVisibility.rst
@@ -35,13 +35,14 @@
 (e.g. classes declared in unnamed namespaces) also receive hidden LTO
 visibility.
 
-During the LTO link, all classes with public LTO 

[PATCH] D127182: [Clang][Modules] Merge availability attributes on imported decls

2022-06-15 Thread Michael Spencer 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 rG169417531578: [Clang][Modules] Merge availability attributes 
on imported decls (authored by Bigcheese).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127182

Files:
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/test/Modules/decl-attr-merge.mm


Index: clang/test/Modules/decl-attr-merge.mm
===
--- /dev/null
+++ clang/test/Modules/decl-attr-merge.mm
@@ -0,0 +1,41 @@
+// RUN: rm -rf %t.dir
+// RUN: split-file %s %t.dir
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps \
+// RUN:   -fmodules-cache-path=%t.dir/cache -triple x86_64-apple-macosx10.11.0 
\
+// RUN:   -I%t.dir/headers %t.dir/main.m -emit-llvm -o %t.dir/main.ll
+// RUN: cat %t.dir/main.ll | FileCheck %s
+
+//--- headers/a.h
+
+__attribute__((availability(macos,introduced=10.16)))
+@interface INIntent
+- (instancetype)self;
+@end
+
+//--- headers/b.h
+
+@class INIntent;
+
+//--- headers/module.modulemap
+
+module A {
+  header "a.h"
+}
+
+module B {
+  header "b.h"
+}
+
+//--- main.m
+
+#import 
+#import  // NOTE: Non attributed decl imported after one with attrs.
+
+void F(id);
+
+int main() {
+  if (@available(macOS 11.0, *))
+F([INIntent self]);
+}
+
+// CHECK: @"OBJC_CLASS_$_INIntent" = extern_weak
Index: clang/lib/Serialization/ASTReaderDecl.cpp
===
--- clang/lib/Serialization/ASTReaderDecl.cpp
+++ clang/lib/Serialization/ASTReaderDecl.cpp
@@ -3296,6 +3296,13 @@
 NewAttr->setInherited(true);
 D->addAttr(NewAttr);
   }
+
+  const auto *AA = Previous->getAttr();
+  if (AA && !D->hasAttr()) {
+NewAttr = AA->clone(Context);
+NewAttr->setInherited(true);
+D->addAttr(NewAttr);
+  }
 }
 
 template


Index: clang/test/Modules/decl-attr-merge.mm
===
--- /dev/null
+++ clang/test/Modules/decl-attr-merge.mm
@@ -0,0 +1,41 @@
+// RUN: rm -rf %t.dir
+// RUN: split-file %s %t.dir
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps \
+// RUN:   -fmodules-cache-path=%t.dir/cache -triple x86_64-apple-macosx10.11.0 \
+// RUN:   -I%t.dir/headers %t.dir/main.m -emit-llvm -o %t.dir/main.ll
+// RUN: cat %t.dir/main.ll | FileCheck %s
+
+//--- headers/a.h
+
+__attribute__((availability(macos,introduced=10.16)))
+@interface INIntent
+- (instancetype)self;
+@end
+
+//--- headers/b.h
+
+@class INIntent;
+
+//--- headers/module.modulemap
+
+module A {
+  header "a.h"
+}
+
+module B {
+  header "b.h"
+}
+
+//--- main.m
+
+#import 
+#import  // NOTE: Non attributed decl imported after one with attrs.
+
+void F(id);
+
+int main() {
+  if (@available(macOS 11.0, *))
+F([INIntent self]);
+}
+
+// CHECK: @"OBJC_CLASS_$_INIntent" = extern_weak
Index: clang/lib/Serialization/ASTReaderDecl.cpp
===
--- clang/lib/Serialization/ASTReaderDecl.cpp
+++ clang/lib/Serialization/ASTReaderDecl.cpp
@@ -3296,6 +3296,13 @@
 NewAttr->setInherited(true);
 D->addAttr(NewAttr);
   }
+
+  const auto *AA = Previous->getAttr();
+  if (AA && !D->hasAttr()) {
+NewAttr = AA->clone(Context);
+NewAttr->setInherited(true);
+D->addAttr(NewAttr);
+  }
 }
 
 template
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 1694175 - [Clang][Modules] Merge availability attributes on imported decls

2022-06-15 Thread Michael Spencer via cfe-commits

Author: Michael Spencer
Date: 2022-06-15T17:46:16-07:00
New Revision: 169417531578501e955f12c79ecb8ff05333ae15

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

LOG: [Clang][Modules] Merge availability attributes on imported decls

Currently we do not in general merge attributes when importing decls from 
modules. This patch handles availability, but long term we need to properly 
handle all attributes.

I tried to use Sema::mergeDeclAttributes, but it caused test crashes as I don't 
think it expects to be called in this context. We really shouldn't have 
duplicate code for merging attributes long term, but for now this fixes 
availability. There's already a TODO for this in the declaration of 
ASTDeclReader::mergeInheritableAttributes.

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

rdar://85820301

Added: 
clang/test/Modules/decl-attr-merge.mm

Modified: 
clang/lib/Serialization/ASTReaderDecl.cpp

Removed: 




diff  --git a/clang/lib/Serialization/ASTReaderDecl.cpp 
b/clang/lib/Serialization/ASTReaderDecl.cpp
index 86a9c7733069e..ae298557ee49c 100644
--- a/clang/lib/Serialization/ASTReaderDecl.cpp
+++ b/clang/lib/Serialization/ASTReaderDecl.cpp
@@ -3296,6 +3296,13 @@ void ASTDeclReader::mergeInheritableAttributes(ASTReader 
, Decl *D,
 NewAttr->setInherited(true);
 D->addAttr(NewAttr);
   }
+
+  const auto *AA = Previous->getAttr();
+  if (AA && !D->hasAttr()) {
+NewAttr = AA->clone(Context);
+NewAttr->setInherited(true);
+D->addAttr(NewAttr);
+  }
 }
 
 template

diff  --git a/clang/test/Modules/decl-attr-merge.mm 
b/clang/test/Modules/decl-attr-merge.mm
new file mode 100644
index 0..57f3f93df480e
--- /dev/null
+++ b/clang/test/Modules/decl-attr-merge.mm
@@ -0,0 +1,41 @@
+// RUN: rm -rf %t.dir
+// RUN: split-file %s %t.dir
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps \
+// RUN:   -fmodules-cache-path=%t.dir/cache -triple x86_64-apple-macosx10.11.0 
\
+// RUN:   -I%t.dir/headers %t.dir/main.m -emit-llvm -o %t.dir/main.ll
+// RUN: cat %t.dir/main.ll | FileCheck %s
+
+//--- headers/a.h
+
+__attribute__((availability(macos,introduced=10.16)))
+@interface INIntent
+- (instancetype)self;
+@end
+
+//--- headers/b.h
+
+@class INIntent;
+
+//--- headers/module.modulemap
+
+module A {
+  header "a.h"
+}
+
+module B {
+  header "b.h"
+}
+
+//--- main.m
+
+#import 
+#import  // NOTE: Non attributed decl imported after one with attrs.
+
+void F(id);
+
+int main() {
+  if (@available(macOS 11.0, *))
+F([INIntent self]);
+}
+
+// CHECK: @"OBJC_CLASS_$_INIntent" = extern_weak



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


[PATCH] D127923: [Diagnostics] Accept newline and format diag opts on first line

2022-06-15 Thread Vang Thao via Phabricator via cfe-commits
vangthao created this revision.
Herald added a subscriber: martong.
Herald added a project: All.
vangthao requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Accept newlines when the diagnostic string is being given by an outside source
instead of ignoring newlines. I believe the other processing done in
`FormatDiagnostic()` does not ignore newlines so we should also not ignore it
here.

Also format diagnostic options on the first line when there are multiple lines.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D127923

Files:
  clang/lib/Basic/Diagnostic.cpp
  clang/lib/Frontend/TextDiagnosticPrinter.cpp
  clang/lib/StaticAnalyzer/Core/TextDiagnostics.cpp
  clang/test/Analysis/padding_message.cpp

Index: clang/test/Analysis/padding_message.cpp
===
--- clang/test/Analysis/padding_message.cpp
+++ clang/test/Analysis/padding_message.cpp
@@ -1,11 +1,11 @@
 // RUN: %clang_analyze_cc1 -triple x86_64-unknown-linux -std=c++14 -analyzer-checker=optin.performance -analyzer-config optin.performance.Padding:AllowedPad=2 -verify %s
 
 // expected-warning@+7{{\
-Excessive padding in 'struct IntSandwich' (6 padding bytes, where 2 is optimal). \
-Optimal fields order: \
-i, \
-c1, \
-c2, \
+Excessive padding in 'struct IntSandwich' (6 padding bytes, where 2 is optimal).  [optin.performance.Padding]\n\
+Optimal fields order: \n\
+i, \n\
+c1, \n\
+c2, \n\
 }}
 struct IntSandwich {
   char c1;
@@ -14,11 +14,11 @@
 };
 
 // expected-warning@+7{{\
-Excessive padding in 'struct TurDuckHen' (6 padding bytes, where 2 is optimal). \
-Optimal fields order: \
-i, \
-c1, \
-c2, \
+Excessive padding in 'struct TurDuckHen' (6 padding bytes, where 2 is optimal).  [optin.performance.Padding]\n\
+Optimal fields order: \n\
+i, \n\
+c1, \n\
+c2, \n\
 }}
 struct TurDuckHen {
   char c1;
@@ -29,15 +29,15 @@
 #pragma pack(push)
 #pragma pack(2)
 // expected-warning@+11{{\
-Excessive padding in 'struct SmallIntSandwich' (4 padding bytes, where 0 is optimal). \
-Optimal fields order: \
-i1, \
-i2, \
-i3, \
-c1, \
-c2, \
-c3, \
-c4, \
+Excessive padding in 'struct SmallIntSandwich' (4 padding bytes, where 0 is optimal).  [optin.performance.Padding]\n\
+Optimal fields order: \n\
+i1, \n\
+i2, \n\
+i3, \n\
+c1, \n\
+c2, \n\
+c3, \n\
+c4, \n\
 }}
 struct SmallIntSandwich {
   char c1;
@@ -57,11 +57,11 @@
 };
 
 // expected-warning@+7{{\
-Excessive padding in 'struct HoldsAUnion' (6 padding bytes, where 2 is optimal). \
-Optimal fields order: \
-u, \
-c1, \
-c2, \
+Excessive padding in 'struct HoldsAUnion' (6 padding bytes, where 2 is optimal).  [optin.performance.Padding]\n\
+Optimal fields order: \n\
+u, \n\
+c1, \n\
+c2, \n\
 }}
 struct HoldsAUnion {
   char c1;
@@ -78,11 +78,11 @@
 };
 
 // expected-warning@+7{{\
-Excessive padding in 'struct StructSandwich' (6 padding bytes, where 2 is optimal). \
-Optimal fields order: \
-m, \
-s, \
-s2, \
+Excessive padding in 'struct StructSandwich' (6 padding bytes, where 2 is optimal).  [optin.performance.Padding]\n\
+Optimal fields order: \n\
+m, \n\
+s, \n\
+s2, \n\
 }}
 struct StructSandwich {
   struct SmallCharArray s;
@@ -91,11 +91,11 @@
 };
 
 // expected-warning@+7{{\
-Excessive padding in 'TypedefSandwich' (6 padding bytes, where 2 is optimal). \
-Optimal fields order: \
-i, \
-c1, \
-c2, \
+Excessive padding in 'TypedefSandwich' (6 padding bytes, where 2 is optimal).  [optin.performance.Padding]\n\
+Optimal fields order: \n\
+i, \n\
+c1, \n\
+c2, \n\
 }}
 typedef struct {
   char c1;
@@ -104,11 +104,11 @@
 } TypedefSandwich;
 
 // expected-warning@+7{{\
-Excessive padding in 'struct StructAttrAlign' (10 padding bytes, where 2 is optimal). \
-Optimal fields order: \
-i, \
-c1, \
-c2, \
+Excessive padding in 'struct StructAttrAlign' (10 padding bytes, where 2 is optimal).  [optin.performance.Padding]\n\
+Optimal fields order: \n\
+i, \n\
+c1, \n\
+c2, \n\
 }}
 struct StructAttrAlign {
   char c1;
@@ -117,12 +117,12 @@
 } __attribute__((aligned(8)));
 
 // expected-warning@+8{{\
-Excessive padding in 'struct OverlyAlignedChar' (8185 padding bytes, where 4089 is optimal). \
-Optimal fields order: \
-c, \
-c1, \
-c2, \
-x, \
+Excessive padding in 'struct OverlyAlignedChar' (8185 padding bytes, where 4089 is optimal).  [optin.performance.Padding]\n\
+Optimal fields order: \n\
+c, \n\
+c1, \n\
+c2, \n\
+x, \n\
 }}
 struct OverlyAlignedChar {
   char c1;
@@ -132,11 +132,11 @@
 };
 
 // expected-warning@+7{{\
-Excessive padding in 'struct HoldsOverlyAlignedChar' (8190 padding bytes, where 4094 is optimal). \
-Optimal fields order: \
-o, \
-c1, \
-c2, \
+Excessive padding in 'struct HoldsOverlyAlignedChar' (8190 padding bytes, where 4094 is optimal).  [optin.performance.Padding]\n\
+Optimal fields order: \n\
+o, \n\
+c1, \n\
+c2, \n\
 }}
 struct HoldsOverlyAlignedChar {
   char c1;
@@ -146,11 +146,11 @@
 
 void internalStructFunc() {
   // expected-warning@+7{{\

[PATCH] D125936: [Sema] Relax an assertion in BuildStmtExpr

2022-06-15 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added subscribers: ChuanqiXu, EricWF.
ahatanak added a comment.

Adding more people to get more eyes on the changes I made to SemaCoroutine.cpp.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125936

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


[PATCH] D127812: [AArch64] Function multiversioning support added.

2022-06-15 Thread Pavel Iliin via Phabricator via cfe-commits
ilinpv added inline comments.



Comment at: clang/include/clang/AST/ASTContext.h:3090
 
+  std::vector
+  filterFunctionTargetVersionAttrs(const TargetVersionAttr *TV) const;

erichkeane wrote:
> It is concerning that this differs from the above.  
target_version supports features only, that is similar to ParsedTargetAttr { 
std::vector Features; }.




Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:11483
+def warn_target_clone_no_impact_options
+: Warning<"version list contains no code impact entries">,
+  InGroup;

erichkeane wrote:
> I'm not clear as to what this means?
It gives a warning if target_clones attributes contains features which have no 
impact on code generation ( no supported yet ) and ignored. They has "" 
OPTION in llvm/include/llvm/Support/AArch64TargetParser.def 
See clang/test/Sema/attr-target-clones-aarch64.c tests
```
// expected-warning@+1 {{version list contains no code impact entries}}
void __attribute__((target_clones("sha1+pmull"))) warn2(void);

// expected-warning@+1 {{version list contains no code impact entries}}
int __attribute__((target_clones("rng", "fhm+dpb+sha1", "default"))) 
redecl4(void) { return 1; }
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127812

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


[PATCH] D127876: [clang] Don't emit type test/assume for virtual classes that should never participate in WPD

2022-06-15 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc accepted this revision.
pcc added a comment.
This revision is now accepted and ready to land.

Okay, it seems reasonable enough to have the `[[clang::lto_visibility_public]]` 
attribute override the `--lto-whole-program-visibility` flag.

What I'm not sure about though is whether `__declspec(uuid)` and `std`/`stdext` 
in `/MT`/`/MTd` should also override it.

Fortunately we don't need to solve that now because those are Windows-specific 
attributes/features and we don't support passing  
`--lto-whole-program-visibility` to Windows linkers.

So LGTM if you only mention `[[clang::lto_visibility_public]]` in your change 
to the documentation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127876

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


[PATCH] D126540: PowerPC] Emit warning for incompatible vector types that are currently diagnosed with -fno-lax-vector-conversions

2022-06-15 Thread Amy Kwan via Phabricator via cfe-commits
amyk accepted this revision.
amyk added a comment.
This revision is now accepted and ready to land.

Thanks for the updates. Unless @lei has any other additional comments, I think 
LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126540

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


[PATCH] D127812: [AArch64] Function multiversioning support added.

2022-06-15 Thread Pavel Iliin via Phabricator via cfe-commits
ilinpv added inline comments.



Comment at: clang/docs/ClangCommandLineReference.rst:1086
 
+.. option:: -mno-fmv
+

MaskRay wrote:
> This file is auto-generated. Don't touch it.
It looked out of sync with options td files:

```
+.. option:: -gen-reproducer=, -fno-crash-diagnostics (equivalent to 
-gen-reproducer=off)
+
+Emit reproducer on (option: off, crash (default), error, always)
+

+.. option:: -print-diagnostic-options, --print-diagnostic-options
+
+Print all of Clang's warning options
+

+.. option:: -fdriver-only
+
+Only run the driver.
+

...
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127812

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


[PATCH] D96147: [SEMA] Added warn_decl_shadow support for structured bindings

2022-06-15 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.
Herald added a project: All.

This is very belated, sorry :)

Our shadowing warnings have special behavior for lambdas and local variables: 
the warning for lambdas shadowing uncaptured local variables falls under 
`-Wshadow-uncaptured-local`, which isn't turned on for `-Wshadow` (only for 
`-Wshadow-all`). However, this doesn't extend to structured bindings. Compare 
https://godbolt.org/z/nP6b9f8o4, which doesn't fire for `-Wshadow`, to 
https://godbolt.org/z/9he8Ezsbb, which is the equivalent with structured 
bindings and does fire for `-Wshadow`. This is triggering a whole bunch of new 
`-Wshadow` warnings in our codebase, and I'm wondering if we'd consider also 
separating the lambda + structured binding case into its own warning group, to 
match the behavior for lambdas + local variables.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96147

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


[PATCH] D127911: Delete 'llvm.asan.globals' for global metadata.

2022-06-15 Thread Mitch Phillips via Phabricator via cfe-commits
hctim updated this revision to Diff 437385.
hctim added a comment.

Small test fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127911

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/SanitizerMetadata.cpp
  clang/lib/CodeGen/SanitizerMetadata.h
  clang/test/CodeGen/asan-globals.cpp
  clang/test/CodeGen/hwasan-globals.cpp
  clang/test/CodeGen/memtag-globals.cpp
  clang/test/CodeGen/sanitize-init-order.cpp
  compiler-rt/test/asan/TestCases/global-location.cpp
  llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
  llvm/lib/Passes/PassRegistry.def
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/test/Instrumentation/AddressSanitizer/global_metadata.ll
  llvm/test/Instrumentation/AddressSanitizer/global_metadata_array.ll
  llvm/test/Instrumentation/AddressSanitizer/global_with_comdat.ll
  llvm/test/Instrumentation/AddressSanitizer/instrument_global.ll
  llvm/test/Instrumentation/AddressSanitizer/instrument_initializer_metadata.ll
  llvm/test/Instrumentation/AddressSanitizer/win-string-literal.ll
  llvm/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll
  llvm/tools/opt/NewPMDriver.cpp

Index: llvm/tools/opt/NewPMDriver.cpp
===
--- llvm/tools/opt/NewPMDriver.cpp
+++ llvm/tools/opt/NewPMDriver.cpp
@@ -357,8 +357,6 @@
  ArrayRef) {
 AddressSanitizerOptions Opts;
 if (Name == "asan-pipeline") {
-  MPM.addPass(
-  RequireAnalysisPass());
   MPM.addPass(ModuleAddressSanitizerPass(Opts));
   return true;
 }
Index: llvm/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll
===
--- llvm/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll
+++ llvm/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll
@@ -2,7 +2,7 @@
 ; Make sure asan does not instrument __sancov_gen_
 
 ; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard  -S  | FileCheck %s
-; RUN: opt < %s -passes='module(require,sancov-module,asan-module)' -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard  -S  | FileCheck %s
+; RUN: opt < %s -passes='module(sancov-module,asan-module)' -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard  -S  | FileCheck %s
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
 $Foo = comdat any
Index: llvm/test/Instrumentation/AddressSanitizer/win-string-literal.ll
===
--- llvm/test/Instrumentation/AddressSanitizer/win-string-literal.ll
+++ llvm/test/Instrumentation/AddressSanitizer/win-string-literal.ll
@@ -10,13 +10,12 @@
 ; CHECK-SAME: linkonce_odr dso_local constant { [5 x i8], [27 x i8] }
 ; CHECK-SAME: { [5 x i8] c"asdf\00", [27 x i8] zeroinitializer }, comdat, align 32
 
-; CHECK: @"__asan_global_??_C@_04JIHMPGLA@asdf?$AA@" =
+; CHECK:  @"__asan_global_??_C@_04JIHMPGLA@asdf?$AA@" =
 ; CHECK-SAME: private global { i64, i64, i64, i64, i64, i64, i64, i64 }
 ; CHECK-SAME: { i64 ptrtoint ({ [5 x i8], [27 x i8] }* @"??_C@_04JIHMPGLA@asdf?$AA@" to i64),
-; CHECK-SAME:   i64 5, i64 32, i64 ptrtoint ([17 x i8]* @___asan_gen_.1 to i64),
-; CHECK-SAME:   i64 ptrtoint ([8 x i8]* @___asan_gen_ to i64), i64 0,
-; CHECK-SAME:   i64 ptrtoint ({ [6 x i8]*, i32, i32 }* @___asan_gen_.3 to i64), i64 0 },
-; CHECK-SAME:   section ".ASAN$GL", comdat($"??_C@_04JIHMPGLA@asdf?$AA@"), align 64
+; CHECK-SAME:   i64 5, i64 32, i64 ptrtoint ([7 x i8]* @___asan_gen_.1 to i64), i64 ptrtoint ([8
+; CHECK-SAME:   x i8]* @___asan_gen_ to i64), i64 0, i64 0, i64 0 }, section ".ASAN$GL",
+; CHECK-SAME:   comdat($"??_C@_04JIHMPGLA@asdf?$AA@"), align 64
 
 ; ModuleID = 't.cpp'
 source_filename = "t.cpp"
@@ -35,11 +34,9 @@
 
 attributes #0 = { nounwind sanitize_address uwtable }
 
-!llvm.asan.globals = !{!0}
 !llvm.module.flags = !{!2, !3}
 !llvm.ident = !{!4}
 
-!0 = !{[5 x i8]* @"??_C@_04JIHMPGLA@asdf?$AA@", !1, !"", i1 false, i1 false}
 !1 = !{!"t.cpp", i32 1, i32 31}
 !2 = !{i32 1, !"wchar_size", i32 2}
 !3 = !{i32 7, !"PIC Level", i32 2}
Index: llvm/test/Instrumentation/AddressSanitizer/instrument_initializer_metadata.ll
===
--- llvm/test/Instrumentation/AddressSanitizer/instrument_initializer_metadata.ll
+++ llvm/test/Instrumentation/AddressSanitizer/instrument_initializer_metadata.ll
@@ -2,17 +2,10 @@
 ; RUN: opt < %s -passes='asan-pipeline' -asan-mapping-scale=5 -S | FileCheck %s
 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
 target triple = "x86_64-unknown-linux-gnu"
-@xxx = internal global i32 0, align 4  ; With dynamic initializer.
-@XXX 

[PATCH] D127911: Delete 'llvm.asan.globals' for global metadata.

2022-06-15 Thread Mitch Phillips via Phabricator via cfe-commits
hctim created this revision.
hctim added a reviewer: vitalybuka.
Herald added subscribers: Enna1, ormris, hiraditya.
Herald added a project: All.
hctim requested review of this revision.
Herald added projects: clang, Sanitizers, LLVM.
Herald added subscribers: llvm-commits, Sanitizers, cfe-commits.

Now that we have the sanitizer metadata that is actually on the global
variable, and now that we use debuginfo in order to do symbolization of
globals, we can delete the 'llvm.asan.globals' IR synthesis.

This patch deletes the 'location' part of the __asan_global that's
embedded in the binary as well, because it's unnecessary. This saves
about ~0.275% of the optimised clang binary.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D127911

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/SanitizerMetadata.cpp
  clang/lib/CodeGen/SanitizerMetadata.h
  clang/test/CodeGen/asan-globals.cpp
  clang/test/CodeGen/hwasan-globals.cpp
  clang/test/CodeGen/memtag-globals.cpp
  clang/test/CodeGen/sanitize-init-order.cpp
  compiler-rt/test/asan/TestCases/global-location.cpp
  llvm/include/llvm/Transforms/Instrumentation/AddressSanitizer.h
  llvm/lib/Passes/PassRegistry.def
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/test/Instrumentation/AddressSanitizer/global_metadata.ll
  llvm/test/Instrumentation/AddressSanitizer/global_metadata_array.ll
  llvm/test/Instrumentation/AddressSanitizer/global_with_comdat.ll
  llvm/test/Instrumentation/AddressSanitizer/instrument_global.ll
  llvm/test/Instrumentation/AddressSanitizer/instrument_initializer_metadata.ll
  llvm/test/Instrumentation/AddressSanitizer/win-string-literal.ll
  llvm/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll
  llvm/tools/opt/NewPMDriver.cpp

Index: llvm/tools/opt/NewPMDriver.cpp
===
--- llvm/tools/opt/NewPMDriver.cpp
+++ llvm/tools/opt/NewPMDriver.cpp
@@ -357,8 +357,6 @@
  ArrayRef) {
 AddressSanitizerOptions Opts;
 if (Name == "asan-pipeline") {
-  MPM.addPass(
-  RequireAnalysisPass());
   MPM.addPass(ModuleAddressSanitizerPass(Opts));
   return true;
 }
Index: llvm/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll
===
--- llvm/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll
+++ llvm/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll
@@ -2,7 +2,7 @@
 ; Make sure asan does not instrument __sancov_gen_
 
 ; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard  -S  | FileCheck %s
-; RUN: opt < %s -passes='module(require,sancov-module,asan-module)' -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard  -S  | FileCheck %s
+; RUN: opt < %s -passes='module(sancov-module,asan-module)' -sanitizer-coverage-level=3 -sanitizer-coverage-trace-pc-guard  -S  | FileCheck %s
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
 $Foo = comdat any
Index: llvm/test/Instrumentation/AddressSanitizer/win-string-literal.ll
===
--- llvm/test/Instrumentation/AddressSanitizer/win-string-literal.ll
+++ llvm/test/Instrumentation/AddressSanitizer/win-string-literal.ll
@@ -10,13 +10,12 @@
 ; CHECK-SAME: linkonce_odr dso_local constant { [5 x i8], [27 x i8] }
 ; CHECK-SAME: { [5 x i8] c"asdf\00", [27 x i8] zeroinitializer }, comdat, align 32
 
-; CHECK: @"__asan_global_??_C@_04JIHMPGLA@asdf?$AA@" =
+; CHECK:  @"__asan_global_??_C@_04JIHMPGLA@asdf?$AA@" =
 ; CHECK-SAME: private global { i64, i64, i64, i64, i64, i64, i64, i64 }
 ; CHECK-SAME: { i64 ptrtoint ({ [5 x i8], [27 x i8] }* @"??_C@_04JIHMPGLA@asdf?$AA@" to i64),
-; CHECK-SAME:   i64 5, i64 32, i64 ptrtoint ([17 x i8]* @___asan_gen_.1 to i64),
-; CHECK-SAME:   i64 ptrtoint ([8 x i8]* @___asan_gen_ to i64), i64 0,
-; CHECK-SAME:   i64 ptrtoint ({ [6 x i8]*, i32, i32 }* @___asan_gen_.3 to i64), i64 0 },
-; CHECK-SAME:   section ".ASAN$GL", comdat($"??_C@_04JIHMPGLA@asdf?$AA@"), align 64
+; CHECK-SAME:   i64 5, i64 32, i64 ptrtoint ([7 x i8]* @___asan_gen_.1 to i64), i64 ptrtoint ([8
+; CHECK-SAME:   x i8]* @___asan_gen_ to i64), i64 0, i64 0, i64 0 }, section ".ASAN$GL",
+; CHECK-SAME:   comdat($"??_C@_04JIHMPGLA@asdf?$AA@"), align 64
 
 ; ModuleID = 't.cpp'
 source_filename = "t.cpp"
@@ -35,11 +34,9 @@
 
 attributes #0 = { nounwind sanitize_address uwtable }
 
-!llvm.asan.globals = !{!0}
 !llvm.module.flags = !{!2, !3}
 !llvm.ident = !{!4}
 
-!0 = !{[5 x i8]* @"??_C@_04JIHMPGLA@asdf?$AA@", !1, !"", i1 false, i1 false}
 !1 = !{!"t.cpp", i32 1, i32 31}
 !2 = !{i32 1, !"wchar_size", i32 2}
 !3 = !{i32 7, !"PIC Level", i32 2}
Index: llvm/test/Instrumentation/AddressSanitizer/instrument_initializer_metadata.ll
===
--- 

[PATCH] D127887: [CMake][Fuchsia] Use libunwind as the default unwinder

2022-06-15 Thread Petr Hosek via Phabricator via cfe-commits
phosek updated this revision to Diff 437372.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127887

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


Index: clang/cmake/caches/Fuchsia.cmake
===
--- clang/cmake/caches/Fuchsia.cmake
+++ clang/cmake/caches/Fuchsia.cmake
@@ -26,6 +26,7 @@
 set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
 set(CLANG_DEFAULT_OBJCOPY llvm-objcopy CACHE STRING "")
 set(CLANG_DEFAULT_RTLIB compiler-rt CACHE STRING "")
+set(CLANG_DEFAULT_UNWINDLIB libunwind CACHE STRING "")
 set(CLANG_ENABLE_ARCMT OFF CACHE BOOL "")
 set(CLANG_ENABLE_STATIC_ANALYZER OFF CACHE BOOL "")
 set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -32,6 +32,7 @@
 set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
 set(CLANG_DEFAULT_OBJCOPY llvm-objcopy CACHE STRING "")
 set(CLANG_DEFAULT_RTLIB compiler-rt CACHE STRING "")
+set(CLANG_DEFAULT_UNWINDLIB libunwind CACHE STRING "")
 set(CLANG_ENABLE_ARCMT OFF CACHE BOOL "")
 set(CLANG_ENABLE_STATIC_ANALYZER ON CACHE BOOL "")
 set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
@@ -119,7 +120,6 @@
 set(RUNTIMES_${target}_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
-set(RUNTIMES_${target}_LIBCXXABI_ENABLE_STATIC_UNWINDER ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_INSTALL_LIBRARY OFF CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
@@ -130,9 +130,6 @@
 set(RUNTIMES_${target}_SANITIZER_CXX_ABI_INTREE ON CACHE BOOL "")
 set(RUNTIMES_${target}_SANITIZER_TEST_CXX "libc++" CACHE STRING "")
 set(RUNTIMES_${target}_SANITIZER_TEST_CXX_INTREE ON CACHE BOOL "")
-set(RUNTIMES_${target}_COMPILER_RT_TEST_COMPILER_CFLAGS 
"--unwindlib=libunwind -static-libgcc" CACHE STRING "")
-set(RUNTIMES_${target}_SANITIZER_COMMON_TEST_TARGET_CFLAGS 
"--unwindlib=libunwind -static-libgcc" CACHE STRING "")
-set(RUNTIMES_${target}_TSAN_TEST_TARGET_CFLAGS "--unwindlib=libunwind 
-static-libgcc" CACHE STRING "")
 set(RUNTIMES_${target}_LLVM_TOOLS_DIR "${CMAKE_BINARY_DIR}/bin" CACHE BOOL 
"")
 set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES 
"compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "")
 
@@ -183,13 +180,10 @@
 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 "")
 set(RUNTIMES_${target}_LIBCXXABI_HERMETIC_STATIC_LIBRARY ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_INSTALL_STATIC_LIBRARY OFF CACHE BOOL "")
-
set(RUNTIMES_${target}_LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY OFF 
CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXX_ENABLE_STATIC_ABI_LIBRARY ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXX_HERMETIC_STATIC_LIBRARY ON CACHE BOOL "")


Index: clang/cmake/caches/Fuchsia.cmake
===
--- clang/cmake/caches/Fuchsia.cmake
+++ clang/cmake/caches/Fuchsia.cmake
@@ -26,6 +26,7 @@
 set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
 set(CLANG_DEFAULT_OBJCOPY llvm-objcopy CACHE STRING "")
 set(CLANG_DEFAULT_RTLIB compiler-rt CACHE STRING "")
+set(CLANG_DEFAULT_UNWINDLIB libunwind CACHE STRING "")
 set(CLANG_ENABLE_ARCMT OFF CACHE BOOL "")
 set(CLANG_ENABLE_STATIC_ANALYZER OFF CACHE BOOL "")
 set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -32,6 +32,7 @@
 set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
 set(CLANG_DEFAULT_OBJCOPY llvm-objcopy CACHE STRING "")
 set(CLANG_DEFAULT_RTLIB compiler-rt CACHE STRING "")
+set(CLANG_DEFAULT_UNWINDLIB libunwind CACHE STRING "")
 set(CLANG_ENABLE_ARCMT OFF CACHE BOOL "")
 set(CLANG_ENABLE_STATIC_ANALYZER ON CACHE BOOL "")
 set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
@@ -119,7 +120,6 @@
 set(RUNTIMES_${target}_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
 

[PATCH] D127860: [msan] Allow KMSAN to use -fsanitize-memory-param-retval

2022-06-15 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis accepted this revision.
eugenis 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/D127860/new/

https://reviews.llvm.org/D127860

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


[PATCH] D126676: [clang] Disallow differences in defines used for creating and using PCH

2022-06-15 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

I don't have a great answer here, but yes, dllexport macro norms sort of run 
directly counter to the normal ways that people use PCH. It seems like projects 
will need to have a library module / PCH file for building a DLL and then a PCH 
/ module for consuming the DLL.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126676

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


[PATCH] D127812: [AArch64] Function multiversioning support added.

2022-06-15 Thread Pavel Iliin via Phabricator via cfe-commits
ilinpv added a comment.

In D127812#3585249 , @erichkeane 
wrote:

> I'm concerned as to the design of this addition, I don't particularly 
> appreciate the reasons for making 'target_clones' different, nor the purpose 
> for adding a new attribute instead of using 'target' for what seems like 
> exactly that?  IF the new spelling is THAT necessary, we perhaps don't need a 
> whole new attribute for it either.

Thank you for fair concern, "target_clones" for AArch64 has different format, 
semantic, e.g. "default" is not required.  Therefore it diverges with X86 in 
these parts. "target" attribute has been already used and supported on AArch64 
in a different sense, like target("arm"), target("dotprod"), 
target("branch-protection=bti"). The intention of creating new "target_version" 
attribute is not to overlap with that. It also has different format, mangling 
and semantic, e.g. treating function without attribute as "default", and option 
to disable attribute droping function multi versions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127812

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


[PATCH] D127163: [clang] Add -fsanitize=memtag-globals (no-op).

2022-06-15 Thread Mitch Phillips via Phabricator via cfe-commits
hctim added a comment.

In D127163#3587115 , @thakis wrote:

> FYI: If you change serialized opts in a def file, you have to bump the pch 
> version, else with builds that don't embed the llvm revision 
> (LLVM_APPEND_VC_REV=OFF) won't notice they have to invalidate pchs.
>
> (In this case, I did this in 
> https://github.com/llvm/llvm-project/commit/307109266f6c7598dfc69b6388fa271662de9388
>  for this change.)

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127163

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


[PATCH] D127544: Add no_sanitize('hwaddress') (and 'memtag', but that's a no-op).

2022-06-15 Thread Mitch Phillips via Phabricator via cfe-commits
hctim added inline comments.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:8849
 break;
-  
   // HLSL attributes:

aaron.ballman wrote:
> Spurious whitespace change?
unfortunately there's no way in my editor to trim trailing whitespace only on 
changed lines :(, so i end up fixing things like this drive-by.

let me know if you feel very strongly about this diff and I can kill it, but I 
personally think the drive-by-fix isn't a huge problem and the alternative of 
whitespace-fix-only commit seems a bit overkill



Comment at: clang/test/CodeGen/hwasan-globals.cpp:1-2
+// RUN: echo "int extra_global;" > %t.extra-source.cpp
+// RUN: echo "global:*ignorelisted_global*" > %t.ignorelist
+// RUN: %clang_cc1 -include %t.extra-source.cpp -fsanitize=hwaddress 
-fsanitize-ignorelist=%t.ignorelist -emit-llvm -o - %s | FileCheck %s 
--check-prefixes=CHECK

aaron.ballman wrote:
> Are these files automatically deleted when the test is done because we're 
> using %t, or do we need to clean those up manually?
AFAIK nothing is ever automatically deleted (e.g. the outputs of the compiler). 
Is automated cleanup here necessary?



Comment at: clang/test/CodeGen/hwasan-globals.cpp:9
+int global;
+int __attribute__((no_sanitize("hwaddress"))) attributed_global;
+int __attribute__((disable_sanitizer_instrumentation)) 
disable_instrumentation_global;

aaron.ballman wrote:
> Should we add a `memtag` test as well given that also changed in this patch?
sure, done



Comment at: compiler-rt/test/hwasan/TestCases/global-with-reduction.c:25
 
-int x = 1;
+#include 
 

aaron.ballman wrote:
> I'm not a compiler-rt expert, but is this valid? I assume this is using the 
> system stdlib.h which is not something we usually want in lit tests.
> 
> I think that's why `atoi` was previously being forward declared; then we 
> don't need to include the whole header file.
I don't see there being any problem with including stdlib.h here, it's done in 
lots of other compiler-rt tests.

I patched this up because the compiler actually complains about 
forward-declaring c library functions (it's just silenced by llvm-lit by 
default).



Comment at: compiler-rt/test/hwasan/TestCases/global-with-reduction.c:50
+  f()[atoi(argv[1])] = 1;
+  return 0;
 }

aaron.ballman wrote:
> This is unnecessary -- falling off `main` already returns 0.
sure, done



Comment at: compiler-rt/test/hwasan/TestCases/global.c:47
   ()[atoi(argv[1])] = 1;
+  return 0;
 }

aaron.ballman wrote:
> This is unnecessary -- falling off `main` already returns 0.
sure, done


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127544

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


[PATCH] D127544: Add no_sanitize('hwaddress') (and 'memtag', but that's a no-op).

2022-06-15 Thread Mitch Phillips via Phabricator via cfe-commits
hctim updated this revision to Diff 437355.
hctim marked 6 inline comments as done.
hctim added a comment.

Update.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127544

Files:
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/hwasan-globals.cpp
  clang/test/CodeGen/memtag-globals.cpp
  compiler-rt/test/hwasan/TestCases/global-with-reduction.c
  compiler-rt/test/hwasan/TestCases/global.c

Index: compiler-rt/test/hwasan/TestCases/global.c
===
--- compiler-rt/test/hwasan/TestCases/global.c
+++ compiler-rt/test/hwasan/TestCases/global.c
@@ -14,9 +14,23 @@
 // RUN: %clang_hwasan -O2 %s -o %t
 // RUN: not %run %t 1 2>&1 | FileCheck --check-prefixes=CHECK,RSYM %s
 
+// RUN: %clang_hwasan -DUSE_NOSANITIZE %s -o %t && %run %t 0
+// RUN: %clang_hwasan -DUSE_NOSANITIZE %s -o %t && %run %t 1
+// RUN: %clang_hwasan -DUSE_NOSANITIZE %s -o %t -fno-pic && %run %t 1
+// RUN: %clang_hwasan -DUSE_NOSANITIZE %s -o %t -O2 && %run %t 1
+// RUN: %clang_hwasan -DUSE_NOSANITIZE %s -o %t -fno-pic -O2 && %run %t 1
+
 // REQUIRES: pointer-tagging
 
+#include 
+
+int a = 1;
+#ifdef USE_NOSANITIZE
+__attribute__((no_sanitize("hwaddress"))) int x = 1;
+#else // USE_NOSANITIZE
 int x = 1;
+#endif // USE_NOSANITIZE
+int b = 1;
 
 int atoi(const char *);
 
Index: compiler-rt/test/hwasan/TestCases/global-with-reduction.c
===
--- compiler-rt/test/hwasan/TestCases/global-with-reduction.c
+++ compiler-rt/test/hwasan/TestCases/global-with-reduction.c
@@ -14,20 +14,37 @@
 // RUN: %clang_hwasan -O2 %s -o %t
 // RUN: not %run %t 1 2>&1 | FileCheck --check-prefixes=CHECK,RSYM %s
 
+// RUN: %clang_hwasan -DUSE_NOSANITIZE %s -o %t && %run %t 0
+// RUN: %clang_hwasan -DUSE_NOSANITIZE %s -o %t && %run %t 1
+// RUN: %clang_hwasan -DUSE_NOSANITIZE %s -o %t -fno-pic && %run %t 1
+// RUN: %clang_hwasan -DUSE_NOSANITIZE %s -o %t -O2 && %run %t 1
+// RUN: %clang_hwasan -DUSE_NOSANITIZE %s -o %t -fno-pic -O2 && %run %t 1
+
 // REQUIRES: pointer-tagging
 
-int x = 1;
+#include 
 
-int atoi(const char *);
+// GlobalOpt may replace the current GV with a new boolean-typed GV. Previously,
+// this resulted in the "nosanitize" getting dropped because while the data/code
+// references to the GV were updated, the old metadata references weren't.
+int* f() {
+#ifdef USE_NOSANITIZE
+__attribute__((no_sanitize("hwaddress"))) static int x = 1;
+#else // USE_NOSANITIZE
+  static int x = 1;
+#endif // USE_NOSANITIZE
+  if (x == 1) x = 0;
+  return 
+}
 
 int main(int argc, char **argv) {
   // CHECK: Cause: global-overflow
-  // RSYM: is located 0 bytes to the right of 4-byte global variable x {{.*}} in {{.*}}global.c.tmp
+  // RSYM: is located 0 bytes to the right of 4-byte global variable f.x {{.*}} in {{.*}}global-with-reduction.c.tmp
   // RNOSYM: is located to the right of a 4-byte global variable in
-  // RNOSYM-NEXT: #0 0x{{.*}} ({{.*}}global.c.tmp+{{.*}})
-  // LSYM: is located 4 bytes to the left of 4-byte global variable x {{.*}} in {{.*}}global.c.tmp
+  // RNOSYM-NEXT: #0 0x{{.*}} ({{.*}}global-with-reduction.c.tmp+{{.*}})
+  // LSYM: is located 4 bytes to the left of 4-byte global variable f.x {{.*}} in {{.*}}global-with-reduction.c.tmp
   // LNOSYM: is located to the left of a 4-byte global variable in
-  // LNOSYM-NEXT: #0 0x{{.*}} ({{.*}}global.c.tmp+{{.*}})
+  // LNOSYM-NEXT: #0 0x{{.*}} ({{.*}}global-with-reduction.c.tmp+{{.*}})
   // CHECK-NOT: can not describe
-  ()[atoi(argv[1])] = 1;
+  f()[atoi(argv[1])] = 1;
 }
Index: clang/test/CodeGen/memtag-globals.cpp
===
--- /dev/null
+++ clang/test/CodeGen/memtag-globals.cpp
@@ -0,0 +1,60 @@
+// RUN: echo "int extra_global;" > %t.extra-source.cpp
+// RUN: echo "global:*ignorelisted_global*" > %t.ignorelist
+// RUN: %clang_cc1 -include %t.extra-source.cpp -fsanitize=memtag-globals -fsanitize-ignorelist=%t.ignorelist -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK
+// The ignorelist file uses regexps, so Windows path backslashes.
+// RUN: echo "src:%s" | sed -e 's/\\//g' > %t.ignorelist-src
+// RUN: %clang_cc1 -include %t.extra-source.cpp -fsanitize=memtag-globals -fsanitize-ignorelist=%t.ignorelist-src -emit-llvm -o - %s | FileCheck %s --check-prefix=IGNORELIST
+
+int global;
+int __attribute__((no_sanitize("memtag"))) attributed_global;
+int __attribute__((disable_sanitizer_instrumentation)) disable_instrumentation_global;
+int ignorelisted_global;
+
+void func() {
+  static int static_var = 0;
+  const char *literal = "Hello, world!";
+}
+
+// CHECK: @{{.*}}extra_global{{.*}} =
+// CHECK-NOT: no_sanitize_memtag
+// CHECK: @{{.*}}global{{.*}} =
+// CHECK-NOT: no_sanitize_memtag
+// CHECK: @{{.*}}attributed_global{{.*}} ={{.*}} global {{.*}}, no_sanitize_memtag
+// CHECK: @{{.*}}disable_instrumentation_global{{.*}} 

[PATCH] D124750: [MLIR] Add a utility to sort the operands of commutative ops

2022-06-15 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

Right now I'm not yet understanding all of the algorithm (haven't spent enough 
time on it), but I'm mostly concerned by the runtime cost of this normalization.




Comment at: mlir/lib/Transforms/Utils/CommutativityUtils.cpp:371
+// assigned a sorted position yet.
+SmallVector bfsOfOperands;
+





Comment at: mlir/lib/Transforms/Utils/CommutativityUtils.cpp:377-379
+  OperandBFS *bfsOfOperand = new OperandBFS();
+  bfsOfOperand->pushAncestor(operand.getDefiningOp());
+  bfsOfOperands.push_back(bfsOfOperand);




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124750

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


[PATCH] D127163: [clang] Add -fsanitize=memtag-globals (no-op).

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

FYI: If you change serialized opts in a def file, you have to bump the pch 
version, else with builds that don't embed the llvm revision 
(LLVM_APPEND_VC_REV=OFF) won't notice they have to invalidate pchs.

(In this case, I did this in 
https://github.com/llvm/llvm-project/commit/307109266f6c7598dfc69b6388fa271662de9388
 for this change.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127163

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


[clang] 3071092 - unbreak Modules/cxx20-export-import.cpp with LLVM_APPEND_VC_REV=OFF after 45d88cd00846

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

Author: Nico Weber
Date: 2022-06-15T17:42:35-04:00
New Revision: 307109266f6c7598dfc69b6388fa271662de9388

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

LOG: unbreak Modules/cxx20-export-import.cpp with LLVM_APPEND_VC_REV=OFF after 
45d88cd00846

See revision b8b7a9dcdcbc for prior art.

Added: 


Modified: 
clang/include/clang/Serialization/ASTBitCodes.h

Removed: 




diff  --git a/clang/include/clang/Serialization/ASTBitCodes.h 
b/clang/include/clang/Serialization/ASTBitCodes.h
index 0ea8b9002a974..2f699ab943fb4 100644
--- a/clang/include/clang/Serialization/ASTBitCodes.h
+++ b/clang/include/clang/Serialization/ASTBitCodes.h
@@ -41,7 +41,7 @@ namespace serialization {
 /// Version 4 of AST files also requires that the version control branch and
 /// revision match exactly, since there is no backward compatibility of
 /// AST files at this time.
-const unsigned VERSION_MAJOR = 20;
+const unsigned VERSION_MAJOR = 21;
 
 /// AST file minor version number supported by this version of
 /// Clang.



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


[PATCH] D127863: [clang] Dont print implicit forrange initializer

2022-06-15 Thread Utkarsh Saxena via Phabricator via cfe-commits
usaxena95 accepted this revision.
usaxena95 added a comment.
This revision is now accepted and ready to land.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127863

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


[PATCH] D127593: [clang] Fix trivially copyable for copy constructor and copy assignment operator

2022-06-15 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson added a comment.

In D127593#3585073 , @erichkeane 
wrote:

> The OMP failures are still there though, which is a touch concerning.

Yeah, I rerun the CI and it still fails. I couldn't reproduce the failures 
locally, though, and the CI logs don't seem to contain any actual problem. I'm 
not sure what to do from here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127593

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


[PATCH] D127888: [clang][WebAssembly] Loosen restriction on `main` symbol mangling

2022-06-15 Thread Sam Clegg 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 rG78747bd39af8: [clang][WebAssembly] Loosen restriction on 
`main` symbol mangling (authored by sbc100).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127888

Files:
  clang/lib/AST/Mangle.cpp
  clang/test/CodeGen/mangle-wasm-main-noproto.c
  clang/test/CodeGen/mangle-wasm-main-void.c
  clang/test/CodeGen/mangle-wasm-main.c


Index: clang/test/CodeGen/mangle-wasm-main.c
===
--- /dev/null
+++ clang/test/CodeGen/mangle-wasm-main.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=wasm32-unknown-unknown | 
FileCheck %s
+
+int main(int argc, char* argv[]) {
+  return 0;
+}
+// CHECK-NOT: __main_void
+// CHECK: define i32 @__main_argc_argv(i32 noundef %argc, ptr noundef %argv) 
#0 { 
Index: clang/test/CodeGen/mangle-wasm-main-void.c
===
--- /dev/null
+++ clang/test/CodeGen/mangle-wasm-main-void.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=wasm32-unknown-unknown | 
FileCheck %s
+
+int main(void) {
+  return 0;
+}
+// CHECK: @__main_void = hidden alias i32 (), ptr @main
+// CHECK: define i32 @main() #0 {
Index: clang/test/CodeGen/mangle-wasm-main-noproto.c
===
--- /dev/null
+++ clang/test/CodeGen/mangle-wasm-main-noproto.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=wasm32-unknown-unknown 
-Wno-deprecated-non-prototype | FileCheck %s
+
+int main(argc, argv)
+  int argc;
+  char* argv[];
+{
+  return 0;
+}
+// CHECK-NOT: __main_void
+// CHECK: define i32 @__main_argc_argv(i32 noundef %argc, ptr noundef %argv) 
#0 { 
Index: clang/lib/AST/Mangle.cpp
===
--- clang/lib/AST/Mangle.cpp
+++ clang/lib/AST/Mangle.cpp
@@ -72,7 +72,7 @@
   // can call it with the correct function signature.
   if (Triple.isWasm())
 if (const FunctionDecl *FD = dyn_cast(ND))
-  if (FD->isMain() && FD->hasPrototype() && FD->param_size() == 2)
+  if (FD->isMain() && FD->getNumParams() == 2)
 return CCM_WasmMainArgcArgv;
 
   if (!Triple.isOSWindows() || !Triple.isX86())


Index: clang/test/CodeGen/mangle-wasm-main.c
===
--- /dev/null
+++ clang/test/CodeGen/mangle-wasm-main.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=wasm32-unknown-unknown | FileCheck %s
+
+int main(int argc, char* argv[]) {
+  return 0;
+}
+// CHECK-NOT: __main_void
+// CHECK: define i32 @__main_argc_argv(i32 noundef %argc, ptr noundef %argv) #0 { 
Index: clang/test/CodeGen/mangle-wasm-main-void.c
===
--- /dev/null
+++ clang/test/CodeGen/mangle-wasm-main-void.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=wasm32-unknown-unknown | FileCheck %s
+
+int main(void) {
+  return 0;
+}
+// CHECK: @__main_void = hidden alias i32 (), ptr @main
+// CHECK: define i32 @main() #0 {
Index: clang/test/CodeGen/mangle-wasm-main-noproto.c
===
--- /dev/null
+++ clang/test/CodeGen/mangle-wasm-main-noproto.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=wasm32-unknown-unknown -Wno-deprecated-non-prototype | FileCheck %s
+
+int main(argc, argv)
+  int argc;
+  char* argv[];
+{
+  return 0;
+}
+// CHECK-NOT: __main_void
+// CHECK: define i32 @__main_argc_argv(i32 noundef %argc, ptr noundef %argv) #0 { 
Index: clang/lib/AST/Mangle.cpp
===
--- clang/lib/AST/Mangle.cpp
+++ clang/lib/AST/Mangle.cpp
@@ -72,7 +72,7 @@
   // can call it with the correct function signature.
   if (Triple.isWasm())
 if (const FunctionDecl *FD = dyn_cast(ND))
-  if (FD->isMain() && FD->hasPrototype() && FD->param_size() == 2)
+  if (FD->isMain() && FD->getNumParams() == 2)
 return CCM_WasmMainArgcArgv;
 
   if (!Triple.isOSWindows() || !Triple.isX86())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 78747bd - [clang][WebAssembly] Loosen restriction on `main` symbol mangling

2022-06-15 Thread Sam Clegg via cfe-commits

Author: Sam Clegg
Date: 2022-06-15T13:56:05-07:00
New Revision: 78747bd39af807eb6b56709b9713c303704c47ad

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

LOG: [clang][WebAssembly] Loosen restriction on `main` symbol mangling

Remove the `hasPrototype()` restriction so that old style K
declarations of main work too.

For example the following has 2 params but no prototype.

```
int main(argc, argv)
int argc;
char *argv[];
{
  return 0;
}
```

Also, use `getNumParams()` over `param_size()` which seems to be a more
direct way to get at the same information.

Also, add missing tests for this mangling.

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

Added: 
clang/test/CodeGen/mangle-wasm-main-noproto.c
clang/test/CodeGen/mangle-wasm-main-void.c
clang/test/CodeGen/mangle-wasm-main.c

Modified: 
clang/lib/AST/Mangle.cpp

Removed: 




diff  --git a/clang/lib/AST/Mangle.cpp b/clang/lib/AST/Mangle.cpp
index c1a345390091b..7ea569c63d9e4 100644
--- a/clang/lib/AST/Mangle.cpp
+++ b/clang/lib/AST/Mangle.cpp
@@ -72,7 +72,7 @@ static CCMangling getCallingConvMangling(const ASTContext 
,
   // can call it with the correct function signature.
   if (Triple.isWasm())
 if (const FunctionDecl *FD = dyn_cast(ND))
-  if (FD->isMain() && FD->hasPrototype() && FD->param_size() == 2)
+  if (FD->isMain() && FD->getNumParams() == 2)
 return CCM_WasmMainArgcArgv;
 
   if (!Triple.isOSWindows() || !Triple.isX86())

diff  --git a/clang/test/CodeGen/mangle-wasm-main-noproto.c 
b/clang/test/CodeGen/mangle-wasm-main-noproto.c
new file mode 100644
index 0..313ce36216e25
--- /dev/null
+++ b/clang/test/CodeGen/mangle-wasm-main-noproto.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=wasm32-unknown-unknown 
-Wno-deprecated-non-prototype | FileCheck %s
+
+int main(argc, argv)
+  int argc;
+  char* argv[];
+{
+  return 0;
+}
+// CHECK-NOT: __main_void
+// CHECK: define i32 @__main_argc_argv(i32 noundef %argc, ptr noundef %argv) 
#0 { 

diff  --git a/clang/test/CodeGen/mangle-wasm-main-void.c 
b/clang/test/CodeGen/mangle-wasm-main-void.c
new file mode 100644
index 0..f541e555ff728
--- /dev/null
+++ b/clang/test/CodeGen/mangle-wasm-main-void.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=wasm32-unknown-unknown | 
FileCheck %s
+
+int main(void) {
+  return 0;
+}
+// CHECK: @__main_void = hidden alias i32 (), ptr @main
+// CHECK: define i32 @main() #0 {

diff  --git a/clang/test/CodeGen/mangle-wasm-main.c 
b/clang/test/CodeGen/mangle-wasm-main.c
new file mode 100644
index 0..3a16d068666fa
--- /dev/null
+++ b/clang/test/CodeGen/mangle-wasm-main.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=wasm32-unknown-unknown | 
FileCheck %s
+
+int main(int argc, char* argv[]) {
+  return 0;
+}
+// CHECK-NOT: __main_void
+// CHECK: define i32 @__main_argc_argv(i32 noundef %argc, ptr noundef %argv) 
#0 { 



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


[PATCH] D127904: [AMDGPU] gfx11 new dot instruction codegen support

2022-06-15 Thread Stanislav Mekhanoshin via Phabricator via cfe-commits
rampitec added inline comments.



Comment at: clang/test/CodeGenOpenCL/builtins-amdgcn-dl-insts-err.cl:1
 // REQUIRES: amdgpu-registered-target
 

Also need positive tests like in builtins-amdgcn-dl-insts.cl.



Comment at: llvm/include/llvm/IR/IntrinsicsAMDGPU.td:1926
 
+// f16 %r = llvm.amdgcn.fdot2.f16.f16(v2f16 %a, v2f16 %b, f16 %c, i1 %clamp)
+//   %r = %a[0] * %b[0] + %a[1] * %b[1] + %c

I do not see clamp in the definition. Make a separate comment for the last 2?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127904

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


[PATCH] D127904: [AMDGPU] gfx11 new dot instruction codegen support

2022-06-15 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.fdot2.f16.f16.ll:2
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -global-isel -march=amdgcn -mcpu=gfx1100 -verify-machineinstrs < %s 
| FileCheck %s --check-prefixes=GFX11
+

Is there actually a reason to split the globalisel and DAG tests? I expect 
tests this simple to be identical


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127904

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


[PATCH] D127904: [AMDGPU] gfx11 new dot instruction codegen support

2022-06-15 Thread Joe Nash via Phabricator via cfe-commits
Joe_Nash created this revision.
Joe_Nash added reviewers: foad, rampitec.
Herald added subscribers: kosarev, jsilvanus, hsmhsm, kerbowa, hiraditya, 
t-tye, tpr, dstuttard, yaxunl, nhaehnle, jvesely, kzhuravl, arsenm.
Herald added a project: All.
Joe_Nash requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, wdng.
Herald added projects: clang, LLVM.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D127904

Files:
  clang/include/clang/Basic/BuiltinsAMDGPU.def
  clang/test/CodeGenOpenCL/builtins-amdgcn-dl-insts-err.cl
  llvm/include/llvm/IR/IntrinsicsAMDGPU.td
  llvm/lib/Target/AMDGPU/AMDGPUGISel.td
  llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp
  llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.h
  llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
  llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.h
  llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp
  llvm/lib/Target/AMDGPU/VOP3Instructions.td
  llvm/lib/Target/AMDGPU/VOP3PInstructions.td
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.fdot2.bf16.bf16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.fdot2.f16.f16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.fdot2.f32.bf16.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.fdot2.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.sudot4.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.sudot8.ll
  llvm/test/CodeGen/AMDGPU/llvm.amdgcn.fdot2.bf16.bf16.ll
  llvm/test/CodeGen/AMDGPU/llvm.amdgcn.fdot2.f16.f16.ll
  llvm/test/CodeGen/AMDGPU/llvm.amdgcn.fdot2.f32.bf16.ll
  llvm/test/CodeGen/AMDGPU/llvm.amdgcn.sudot4.ll
  llvm/test/CodeGen/AMDGPU/llvm.amdgcn.sudot8.ll

Index: llvm/test/CodeGen/AMDGPU/llvm.amdgcn.sudot8.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AMDGPU/llvm.amdgcn.sudot8.ll
@@ -0,0 +1,102 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -march=amdgcn -mcpu=gfx1100 -show-mc-encoding -verify-machineinstrs < %s | FileCheck %s --check-prefixes=GFX11
+
+declare i32 @llvm.amdgcn.sudot8(i1 %asign, i32 %a, i1 %bsign, i32 %b, i32 %c, i1 %clamp)
+
+define i32 @test_llvm_amdgcn_sudot8_uu(i32 %a, i32 %b, i32 %c) {
+; GFX11-LABEL: test_llvm_amdgcn_sudot8_uu:
+; GFX11:   ; %bb.0: ; %entry
+; GFX11-NEXT:s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) ; encoding: [0x00,0x00,0x89,0xbf]
+; GFX11-NEXT:s_waitcnt_vscnt null, 0x0 ; encoding: [0x00,0x00,0x7c,0xbc]
+; GFX11-NEXT:v_dot8_i32_iu4 v0, v0, v1, v2 ; encoding: [0x00,0x40,0x18,0xcc,0x00,0x03,0x0a,0x1c]
+; GFX11-NEXT:s_setpc_b64 s[30:31] ; encoding: [0x1e,0x48,0x80,0xbe]
+entry:
+  %ret = call i32 @llvm.amdgcn.sudot8(i1 0, i32 %a, i1 0, i32 %b, i32 %c, i1 0)
+  ret i32 %ret
+}
+
+define i32 @test_llvm_amdgcn_sudot8_us(i32 %a, i32 %b, i32 %c) {
+; GFX11-LABEL: test_llvm_amdgcn_sudot8_us:
+; GFX11:   ; %bb.0: ; %entry
+; GFX11-NEXT:s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) ; encoding: [0x00,0x00,0x89,0xbf]
+; GFX11-NEXT:s_waitcnt_vscnt null, 0x0 ; encoding: [0x00,0x00,0x7c,0xbc]
+; GFX11-NEXT:v_dot8_i32_iu4 v0, v0, v1, v2 neg_lo:[0,1,0] ; encoding: [0x00,0x40,0x18,0xcc,0x00,0x03,0x0a,0x5c]
+; GFX11-NEXT:s_setpc_b64 s[30:31] ; encoding: [0x1e,0x48,0x80,0xbe]
+entry:
+  %ret = call i32 @llvm.amdgcn.sudot8(i1 0, i32 %a, i1 1, i32 %b, i32 %c, i1 0)
+  ret i32 %ret
+}
+
+define i32 @test_llvm_amdgcn_sudot8_su(i32 %a, i32 %b, i32 %c) {
+; GFX11-LABEL: test_llvm_amdgcn_sudot8_su:
+; GFX11:   ; %bb.0: ; %entry
+; GFX11-NEXT:s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) ; encoding: [0x00,0x00,0x89,0xbf]
+; GFX11-NEXT:s_waitcnt_vscnt null, 0x0 ; encoding: [0x00,0x00,0x7c,0xbc]
+; GFX11-NEXT:v_dot8_i32_iu4 v0, v0, v1, v2 neg_lo:[1,0,0] ; encoding: [0x00,0x40,0x18,0xcc,0x00,0x03,0x0a,0x3c]
+; GFX11-NEXT:s_setpc_b64 s[30:31] ; encoding: [0x1e,0x48,0x80,0xbe]
+entry:
+  %ret = call i32 @llvm.amdgcn.sudot8(i1 1, i32 %a, i1 0, i32 %b, i32 %c, i1 0)
+  ret i32 %ret
+}
+
+define i32 @test_llvm_amdgcn_sudot8_ss(i32 %a, i32 %b, i32 %c) {
+; GFX11-LABEL: test_llvm_amdgcn_sudot8_ss:
+; GFX11:   ; %bb.0: ; %entry
+; GFX11-NEXT:s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) ; encoding: [0x00,0x00,0x89,0xbf]
+; GFX11-NEXT:s_waitcnt_vscnt null, 0x0 ; encoding: [0x00,0x00,0x7c,0xbc]
+; GFX11-NEXT:v_dot8_i32_iu4 v0, v0, v1, v2 neg_lo:[1,1,0] ; encoding: [0x00,0x40,0x18,0xcc,0x00,0x03,0x0a,0x7c]
+; GFX11-NEXT:s_setpc_b64 s[30:31] ; encoding: [0x1e,0x48,0x80,0xbe]
+entry:
+  %ret = call i32 @llvm.amdgcn.sudot8(i1 1, i32 %a, i1 1, i32 %b, i32 %c, i1 0)
+  ret i32 %ret
+}
+
+
+
+define i32 @test_llvm_amdgcn_sudot8_uu_clamp(i32 %a, i32 %b, i32 %c) {
+; GFX11-LABEL: test_llvm_amdgcn_sudot8_uu_clamp:
+; GFX11:   ; %bb.0: ; %entry
+; GFX11-NEXT:s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) ; encoding: [0x00,0x00,0x89,0xbf]
+; GFX11-NEXT:s_waitcnt_vscnt null, 0x0 ; encoding: [0x00,0x00,0x7c,0xbc]
+; GFX11-NEXT:v_dot8_i32_iu4 v0, v0, v1, v2 clamp ; encoding: 

[PATCH] D126495: [clang-tidy] Organize test docs into subdirectories by module (NFC)

2022-06-15 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood added a comment.

Ping.  All review comments should be addressed in the latest diff.


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

https://reviews.llvm.org/D126495

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


[clang] c418d0f - [Driver] Simplify -fno-builtin- handling. NFC

2022-06-15 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2022-06-15T13:35:08-07:00
New Revision: c418d0f1be50545daa68e5abf8771db2e1b00819

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

LOG: [Driver] Simplify -fno-builtin- handling. NFC

Added: 


Modified: 
clang/lib/Driver/ToolChains/Clang.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 0f251614eac22..43373083f8aab 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -3577,20 +3577,13 @@ static void RenderBuiltinOptions(const ToolChain , 
const llvm::Triple ,
 UseBuiltins = false;
 
   // Process the -fno-builtin-* options.
-  for (const auto  : Args) {
-const Option  = Arg->getOption();
-if (!O.matches(options::OPT_fno_builtin_))
-  continue;
-
-Arg->claim();
+  for (const Arg *A : Args.filtered(options::OPT_fno_builtin_)) {
+A->claim();
 
 // If -fno-builtin is specified, then there's no need to pass the option to
 // the frontend.
-if (!UseBuiltins)
-  continue;
-
-StringRef FuncName = Arg->getValue();
-CmdArgs.push_back(Args.MakeArgString("-fno-builtin-" + FuncName));
+if (UseBuiltins)
+  A->render(Args, CmdArgs);
   }
 
   // le32-specific flags:



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


[PATCH] D127883: [clang][deps] Further canonicalize implicit modules options in dep scan

2022-06-15 Thread Ben Langmuir 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 rG509223da6114: [clang][deps] Further canonicalize implicit 
modules options in dep scan (authored by benlangmuir).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127883

Files:
  clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
  clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
  clang/test/ClangScanDeps/Inputs/removed-args/cdb.json.template
  clang/test/ClangScanDeps/removed-args.c

Index: clang/test/ClangScanDeps/removed-args.c
===
--- clang/test/ClangScanDeps/removed-args.c
+++ clang/test/ClangScanDeps/removed-args.c
@@ -2,10 +2,13 @@
 // compatible with the semantics of modules or are likely to differ between
 // identical modules discovered from different translation units. This test
 // checks such arguments are removed from the command-lines: '-include',
-// '-dwarf-debug-flag' and '-main-file-name'.
+// '-dwarf-debug-flag' and '-main-file-name'. Similarly, several arguments
+// such as '-fmodules-cache-path=' are only relevant for implicit modules, and
+// are removed to better-canonicalize the compilation.
 
 // RUN: rm -rf %t && mkdir %t
 // RUN: cp %S/Inputs/removed-args/* %t
+// RUN: touch %t/build-session
 
 // RUN: sed "s|DIR|%/t|g" %S/Inputs/removed-args/cdb.json.template > %t/cdb.json
 // RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full > %t/result.json
@@ -21,6 +24,11 @@
 // CHECK-NOT:  "-dwarf-debug-flags"
 // CHECK-NOT:  "-main-file-name"
 // CHECK-NOT:  "-include"
+// CHECK-NOT:  "-fmodules-cache-path=
+// CHECK-NOT:  "-fmodules-validate-once-per-build-session"
+// CHECK-NOT:  "-fbuild-session-timestamp=
+// CHECK-NOT:  "-fmodules-prune-interval=
+// CHECK-NOT:  "-fmodules-prune-after=
 // CHECK:],
 // CHECK-NEXT:   "context-hash": "[[HASH_MOD_HEADER:.*]]",
 // CHECK-NEXT:   "file-deps": [
@@ -34,7 +42,14 @@
 // CHECK-NEXT:   "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
 // CHECK-NEXT:   "command-line": [
 // CHECK-NEXT: "-cc1"
+// CHECK-NOT:  "-dwarf-debug-flags"
+// CHECK-NOT:  "-main-file-name"
 // CHECK-NOT:  "-include"
+// CHECK-NOT:  "-fmodules-cache-path=
+// CHECK-NOT:  "-fmodules-validate-once-per-build-session"
+// CHECK-NOT:  "-fbuild-session-timestamp=
+// CHECK-NOT:  "-fmodules-prune-interval=
+// CHECK-NOT:  "-fmodules-prune-after=
 // CHECK:],
 // CHECK-NEXT:   "context-hash": "[[HASH_MOD_TU:.*]]",
 // CHECK-NEXT:   "file-deps": [
@@ -57,6 +72,14 @@
 // CHECK-NEXT:   "module-name": "ModTU"
 // CHECK-NEXT: }
 // CHECK-NEXT:   ]
+// CHECK-NEXT:   "command-line": [
+// CHECK-NEXT: "-fsyntax-only",
+// CHECK-NOT:  "-fmodules-cache-path=
+// CHECK-NOT:  "-fmodules-validate-once-per-build-session"
+// CHECK-NOT:  "-fbuild-session-file=
+// CHECK-NOT:  "-fmodules-prune-interval=
+// CHECK-NOT:  "-fmodules-prune-after=
+// CHECK:],
 // CHECK:  }
 // CHECK-NEXT:   ]
 // CHECK-NEXT: }
Index: clang/test/ClangScanDeps/Inputs/removed-args/cdb.json.template
===
--- clang/test/ClangScanDeps/Inputs/removed-args/cdb.json.template
+++ clang/test/ClangScanDeps/Inputs/removed-args/cdb.json.template
@@ -1,7 +1,7 @@
 [
   {
 "directory": "DIR",
-"command": "clang -fsyntax-only DIR/tu.c -fmodules -fimplicit-module-maps -fmodules-cache-path=DIR/cache -include DIR/header.h -grecord-command-line -o DIR/tu.o",
+"command": "clang -fsyntax-only DIR/tu.c -fmodules -fimplicit-module-maps -fmodules-validate-once-per-build-session -fbuild-session-file=DIR/build-session -fmodules-prune-interval=123 -fmodules-prune-after=123 -fmodules-cache-path=DIR/cache -include DIR/header.h -grecord-command-line -o DIR/tu.o",
 "file": "DIR/tu.c"
   }
 ]
Index: clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
===
--- clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -61,9 +61,17 @@
   CI.getLangOpts()->ModuleName = Deps.ID.ModuleName;
   CI.getFrontendOpts().IsSystemModule = Deps.IsSystem;
 
+  // Disable implicit modules and canonicalize options that are only used by
+  // implicit modules.
   CI.getLangOpts()->ImplicitModules = false;
   CI.getHeaderSearchOpts().ImplicitModuleMaps = false;
   CI.getHeaderSearchOpts().ModuleCachePath.clear();
+  CI.getHeaderSearchOpts().ModulesValidateOncePerBuildSession = false;
+  CI.getHeaderSearchOpts().BuildSessionTimestamp 

[clang] 509223d - [clang][deps] Further canonicalize implicit modules options in dep scan

2022-06-15 Thread Ben Langmuir via cfe-commits

Author: Ben Langmuir
Date: 2022-06-15T13:29:47-07:00
New Revision: 509223da61145c3eb982751cba9ab6ddf0f48e9d

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

LOG: [clang][deps] Further canonicalize implicit modules options in dep scan

Disable or canonicalize compiler options that are not relevant in
explicit module builds, similar to what we already did for the modules
cache path. This reduces uninteresting differences between
command-lines, which is particularly useful if there is a tool that can
cache the compilations.

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

Added: 


Modified: 
clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
clang/test/ClangScanDeps/Inputs/removed-args/cdb.json.template
clang/test/ClangScanDeps/removed-args.c

Removed: 




diff  --git a/clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp 
b/clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
index 5041a8eb6e597..26c2b2b2f3948 100644
--- a/clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
+++ b/clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
@@ -32,14 +32,17 @@ FullDependencies::getCommandLineWithoutModulePaths() const {
   for (const PrebuiltModuleDep  : PrebuiltModuleDeps)
 Args.push_back("-fmodule-file=" + PMD.PCMFile);
 
-  // This argument is unused in explicit compiles.
-  llvm::erase_if(Args, [](const std::string ) {
-return Arg.find("-fmodules-cache-path=") == 0;
+  // These arguments are unused in explicit compiles.
+  llvm::erase_if(Args, [](StringRef Arg) {
+if (Arg.consume_front("-fmodules-")) {
+  return Arg.startswith("cache-path=") ||
+ Arg.startswith("prune-interval=") ||
+ Arg.startswith("prune-after=") ||
+ Arg == "validate-once-per-build-session";
+}
+return Arg.startswith("-fbuild-session-file=");
   });
 
-  // TODO: Filter out the remaining implicit modules leftovers
-  // (e.g. "-fmodules-prune-interval=" or "-fmodules-prune-after=").
-
   return Args;
 }
 

diff  --git a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp 
b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
index 6c7fdbc3944a6..8fad65c14e376 100644
--- a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -61,9 +61,17 @@ CompilerInvocation 
ModuleDepCollector::makeInvocationForModuleBuildWithoutPaths(
   CI.getLangOpts()->ModuleName = Deps.ID.ModuleName;
   CI.getFrontendOpts().IsSystemModule = Deps.IsSystem;
 
+  // Disable implicit modules and canonicalize options that are only used by
+  // implicit modules.
   CI.getLangOpts()->ImplicitModules = false;
   CI.getHeaderSearchOpts().ImplicitModuleMaps = false;
   CI.getHeaderSearchOpts().ModuleCachePath.clear();
+  CI.getHeaderSearchOpts().ModulesValidateOncePerBuildSession = false;
+  CI.getHeaderSearchOpts().BuildSessionTimestamp = 0;
+  // The specific values we canonicalize to for pruning don't affect behaviour,
+  /// so use the default values so they will be dropped from the command-line.
+  CI.getHeaderSearchOpts().ModuleCachePruneInterval = 7 * 24 * 60 * 60;
+  CI.getHeaderSearchOpts().ModuleCachePruneAfter = 31 * 24 * 60 * 60;
 
   // Report the prebuilt modules this module uses.
   for (const auto  : Deps.PrebuiltModuleDeps)

diff  --git a/clang/test/ClangScanDeps/Inputs/removed-args/cdb.json.template 
b/clang/test/ClangScanDeps/Inputs/removed-args/cdb.json.template
index 17337c579099d..f92e7884e1786 100644
--- a/clang/test/ClangScanDeps/Inputs/removed-args/cdb.json.template
+++ b/clang/test/ClangScanDeps/Inputs/removed-args/cdb.json.template
@@ -1,7 +1,7 @@
 [
   {
 "directory": "DIR",
-"command": "clang -fsyntax-only DIR/tu.c -fmodules -fimplicit-module-maps 
-fmodules-cache-path=DIR/cache -include DIR/header.h -grecord-command-line -o 
DIR/tu.o",
+"command": "clang -fsyntax-only DIR/tu.c -fmodules -fimplicit-module-maps 
-fmodules-validate-once-per-build-session 
-fbuild-session-file=DIR/build-session -fmodules-prune-interval=123 
-fmodules-prune-after=123 -fmodules-cache-path=DIR/cache -include DIR/header.h 
-grecord-command-line -o DIR/tu.o",
 "file": "DIR/tu.c"
   }
 ]

diff  --git a/clang/test/ClangScanDeps/removed-args.c 
b/clang/test/ClangScanDeps/removed-args.c
index 2867c669134a5..8c07ca8d1f7e9 100644
--- a/clang/test/ClangScanDeps/removed-args.c
+++ b/clang/test/ClangScanDeps/removed-args.c
@@ -2,10 +2,13 @@
 // compatible with the semantics of modules or are likely to 
diff er between
 // identical modules discovered from 
diff erent translation units. This test
 // checks such arguments are removed from the 

[PATCH] D126540: PowerPC] Emit warning for incompatible vector types that are currently diagnosed with -fno-lax-vector-conversions

2022-06-15 Thread Maryam Moghadas via Phabricator via cfe-commits
maryammo updated this revision to Diff 437317.
maryammo added a comment.

Fixing unintentional merge from previous commit


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126540

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/Parser/cxx-altivec.cpp

Index: clang/test/Parser/cxx-altivec.cpp
===
--- clang/test/Parser/cxx-altivec.cpp
+++ clang/test/Parser/cxx-altivec.cpp
@@ -1,10 +1,10 @@
-// RUN: %clang_cc1 -triple=powerpc-apple-darwin8 -target-feature +altivec -fsyntax-only -verify=expected,novsx -std=c++11 %s
-// RUN: %clang_cc1 -triple=powerpc64-unknown-linux-gnu -target-feature +altivec -target-feature +vsx -fsyntax-only -verify=expected,nonaix -std=c++11 %s
-// RUN: %clang_cc1 -triple=powerpc64le-unknown-linux-gnu -target-feature +altivec -fsyntax-only -verify=expected,novsx -std=c++11 %s
-// RUN: %clang_cc1 -triple=powerpc64-unknown-linux-gnu -target-feature +vsx -target-cpu pwr7 -fsyntax-only -verify=expected,nonaix -std=c++11 %s
-// RUN: %clang_cc1 -triple=powerpc64le-unknown-linux-gnu -target-feature -vsx -target-cpu pwr7 -fsyntax-only -verify=expected,novsx -std=c++11 %s
-// RUN: %clang_cc1 -triple=powerpc-ibm-aix -target-feature +altivec -fsyntax-only -verify=expected,aix -std=c++11 %s
-// RUN: %clang_cc1 -triple=powerpc64-ibm-aix -target-feature +altivec -fsyntax-only -verify=expected,aix -std=c++11 %s
+// RUN: %clang_cc1 -triple=powerpc-apple-darwin8 -Wno-deprecate-lax-vec-conv-all -target-feature +altivec -fsyntax-only -verify=expected,novsx -std=c++11 %s
+// RUN: %clang_cc1 -triple=powerpc64-unknown-linux-gnu -Wno-deprecate-lax-vec-conv-all -target-feature +altivec -target-feature +vsx -fsyntax-only -verify=expected,nonaix -std=c++11 %s
+// RUN: %clang_cc1 -triple=powerpc64le-unknown-linux-gnu -Wno-deprecate-lax-vec-conv-all -target-feature +altivec -fsyntax-only -verify=expected,novsx -std=c++11 %s
+// RUN: %clang_cc1 -triple=powerpc64-unknown-linux-gnu -Wno-deprecate-lax-vec-conv-all -target-feature +vsx -target-cpu pwr7 -fsyntax-only -verify=expected,nonaix -std=c++11 %s
+// RUN: %clang_cc1 -triple=powerpc64le-unknown-linux-gnu -Wno-deprecate-lax-vec-conv-all -target-feature -vsx -target-cpu pwr7 -fsyntax-only -verify=expected,novsx -std=c++11 %s
+// RUN: %clang_cc1 -triple=powerpc-ibm-aix -Wno-deprecate-lax-vec-conv-all -target-feature +altivec -fsyntax-only -verify=expected,aix -std=c++11 %s
+// RUN: %clang_cc1 -triple=powerpc64-ibm-aix -Wno-deprecate-lax-vec-conv-all -target-feature +altivec -fsyntax-only -verify=expected,aix -std=c++11 %s
 #include 
 
 __vector char vv_c;
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -1617,8 +1617,9 @@
 ///
 /// \param ICK Will be set to the vector conversion kind, if this is a vector
 /// conversion.
-static bool IsVectorConversion(Sema , QualType FromType,
-   QualType ToType, ImplicitConversionKind ) {
+static bool IsVectorConversion(Sema , QualType FromType, QualType ToType,
+   ImplicitConversionKind , Expr *From,
+   bool InOverloadResolution) {
   // We need at least one of these types to be a vector type to have a vector
   // conversion.
   if (!ToType->isVectorType() && !FromType->isVectorType())
@@ -1660,6 +1661,13 @@
 if (S.Context.areCompatibleVectorTypes(FromType, ToType) ||
 (S.isLaxVectorConversion(FromType, ToType) &&
  !ToType->hasAttr(attr::ArmMveStrictPolymorphism))) {
+  if (S.isLaxVectorConversion(FromType, ToType) &&
+  S.areAnyVectorTypesAltivec(FromType, ToType) &&
+  !S.areVectorTypesSameElmType(FromType, ToType) &&
+  !InOverloadResolution) {
+S.Diag(From->getBeginLoc(), diag::warn_deprecated_lax_vec_conv_all)
+<< FromType << ToType;
+  }
   ICK = ICK_Vector_Conversion;
   return true;
 }
@@ -1908,7 +1916,8 @@
  InOverloadResolution, FromType)) {
 // Pointer to member conversions (4.11).
 SCS.Second = ICK_Pointer_Member;
-  } else if (IsVectorConversion(S, FromType, ToType, SecondICK)) {
+  } else if (IsVectorConversion(S, FromType, ToType, SecondICK, From,
+InOverloadResolution)) {
 SCS.Second = SecondICK;
 FromType = ToType.getUnqualifiedType();
   } else if (!S.getLangOpts().CPlusPlus &&
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -7712,6 +7712,43 @@
   return (SrcLen * SrcEltSize == DestLen * DestEltSize);
 }
 
+// This returns true if at least one 

[PATCH] D126960: [clang][sema] Unary not boolean to int conversion

2022-06-15 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

Thank you for the patch! This is certainly an improvement but I think there are 
still some cases where we compute the wrong range for `~` with this patch 
applied.




Comment at: clang/lib/Sema/SemaChecking.cpp:12328
   return IntRange::forValueOfType(C, GetExprType(E));
 
+case UO_Not:

aaron.ballman wrote:
> erichkeane wrote:
> > Richard mentions UO_PreInc, UO_PreDec, UO_Minus, and UO_Not.  What about 
> > the other 3?
> `UO_Plus` also.
Taking those in turn:
- `UO_PreInc` and `UO_PreDec` can only produce values in the range of the 
lvalue operand; we'll never have a more precise range for an lvalue than the 
range from its type unless it's a bit-field, in which case we *do* want to take 
the bit-field's width into account. So I think the current code is actually 
correct for those two -- looking at the range of the operand gives the right 
result even for bit-fields, whereas looking at the type of the operand would 
give a less precise result in that case.
- `UO_Minus` is [not giving the right answer](https://godbolt.org/z/8veKnrv7v). 
I think we should model `-expr` in exactly the same way we model `0 - expr` -- 
see the code for `BO_Sub` above.
- `UO_Plus` seems OK with the current code: the range of values of `+expr` is 
the same as the range of values of `expr`, even if a promotion happens.

In any case, I don't think we should have a `default` here that returns the 
width of the operand. Instead, I think the `default` should return the range 
for the type of `E`.



Comment at: clang/lib/Sema/SemaChecking.cpp:12334
+
+  LLVM_FALLTHROUGH;
+

I don't think falling through and picking up the expression range of the 
operand is ever correct for `~`. [For example](https://godbolt.org/z/oeE3G6r6d):

```
bool f(char c) {
  return ~c > 0x1;
}
```

... produces a bogus tautological comparison warning. (This is not 
tautological: the `~` operator will map negative `char`s to `int`s in the range 
[2^31 - 2^7, 2^31) and non-negative `char`s to `int`s in the range [-2^31, 
-2^31+2^7), so this is equivalent to `c < 0`.)

Also, using `MaxWidth` here is conservatively correct but isn't precise; for 
example, we should still warn on:

```
bool f(bool b) {
  return ~b > 0x1''LL;
}
```

... because `~b` always fits in an `int`, but I think `MaxWidth` here will be 
64 so we won't warn. (It'd be nice to warn even on `~b > 0` but I don't think 
we can do that without some major changes to how `IntRange` is represented.)

The true result range of `~n` will be something like [-2^N, -2^N + 2^M) u [2^N 
- 2^M, 2^N) if the input is signed. `IntRange` can't represent a range with a 
hole in the middle like that, but it can represent [-2^N, 2^N), which seems 
like the least wrong answer that we can give -- that is notably also the entire 
range of the type of the `~` expression. We get a contiguous range [-2^N, -2^N 
+ 2^M) if the input is known non-negative, but `IntRange` still can't represent 
that, and so that doesn't help us make our result any more precise than using 
the entire range of the type of `E`, unfortunately. So I think `UO_Not` should 
never look at its subexpression -- the best result we can give is 
`IntRange::forValueOfType(C, GetExprType(E))`, and that's what we should use.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126960

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


[PATCH] D127883: [clang][deps] Further canonicalize implicit modules options in dep scan

2022-06-15 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 accepted this revision.
jansvoboda11 added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127883

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


[PATCH] D126061: [clang] Reject non-declaration C++11 attributes on declarations

2022-06-15 Thread Martin Böhme via Phabricator via cfe-commits
mboehme added a comment.

In D126061#3585681 , @nikic wrote:

> FYI this change had a measurable effect on compile-time 
> (http://llvm-compile-time-tracker.com/compare.php?from=7acc88be0312c721bc082ed9934e381d297f4707=8c7b64b5ae2a09027c38db969a04fc9ddd0cd6bb=instructions),
>  about 0.5% regression for `O0` builds. Not sure if that's expected.

Thanks for the heads-up.

Without more extensive investigation, it's hard to say. I wasn't necessarily 
expecting a slowdown, but I can come up with various hypotheses for what might 
be causing it.

I've seen the instructions on the About 
 page on how to reproduce 
results and will give that a go.

The first thing to analyze would be whether the slowdown occurs only on code 
that uses attributes (heavily) or also on code that doesn't use attributes.

There isn't any single substantial change in the code that would cause an 
obvious slowdown. I could speculate on some potential causes, but it seems 
better to measure instead. Is there any particular tooling that you would 
recommend for comparing profiler runs from two different compiler versions (one 
with my patch, one without)?

I'll post an update here when I find out more.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126061

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


[PATCH] D127182: [Clang][Modules] Merge availability attributes on imported decls

2022-06-15 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 accepted this revision.
jansvoboda11 added a comment.

LGTM then.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127182

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


[PATCH] D126540: PowerPC] Emit warning for incompatible vector types that are currently diagnosed with -fno-lax-vector-conversions

2022-06-15 Thread Maryam Moghadas via Phabricator via cfe-commits
maryammo updated this revision to Diff 437313.
maryammo added a comment.
Herald added a subscriber: kbarton.

clang-format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126540

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/altivec.h
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/Parser/cxx-altivec.cpp

Index: clang/test/Parser/cxx-altivec.cpp
===
--- clang/test/Parser/cxx-altivec.cpp
+++ clang/test/Parser/cxx-altivec.cpp
@@ -1,10 +1,10 @@
-// RUN: %clang_cc1 -triple=powerpc-apple-darwin8 -target-feature +altivec -fsyntax-only -verify=expected,novsx -std=c++11 %s
-// RUN: %clang_cc1 -triple=powerpc64-unknown-linux-gnu -target-feature +altivec -target-feature +vsx -fsyntax-only -verify=expected,nonaix -std=c++11 %s
-// RUN: %clang_cc1 -triple=powerpc64le-unknown-linux-gnu -target-feature +altivec -fsyntax-only -verify=expected,novsx -std=c++11 %s
-// RUN: %clang_cc1 -triple=powerpc64-unknown-linux-gnu -target-feature +vsx -target-cpu pwr7 -fsyntax-only -verify=expected,nonaix -std=c++11 %s
-// RUN: %clang_cc1 -triple=powerpc64le-unknown-linux-gnu -target-feature -vsx -target-cpu pwr7 -fsyntax-only -verify=expected,novsx -std=c++11 %s
-// RUN: %clang_cc1 -triple=powerpc-ibm-aix -target-feature +altivec -fsyntax-only -verify=expected,aix -std=c++11 %s
-// RUN: %clang_cc1 -triple=powerpc64-ibm-aix -target-feature +altivec -fsyntax-only -verify=expected,aix -std=c++11 %s
+// RUN: %clang_cc1 -triple=powerpc-apple-darwin8 -Wno-deprecate-lax-vec-conv-all -target-feature +altivec -fsyntax-only -verify=expected,novsx -std=c++11 %s
+// RUN: %clang_cc1 -triple=powerpc64-unknown-linux-gnu -Wno-deprecate-lax-vec-conv-all -target-feature +altivec -target-feature +vsx -fsyntax-only -verify=expected,nonaix -std=c++11 %s
+// RUN: %clang_cc1 -triple=powerpc64le-unknown-linux-gnu -Wno-deprecate-lax-vec-conv-all -target-feature +altivec -fsyntax-only -verify=expected,novsx -std=c++11 %s
+// RUN: %clang_cc1 -triple=powerpc64-unknown-linux-gnu -Wno-deprecate-lax-vec-conv-all -target-feature +vsx -target-cpu pwr7 -fsyntax-only -verify=expected,nonaix -std=c++11 %s
+// RUN: %clang_cc1 -triple=powerpc64le-unknown-linux-gnu -Wno-deprecate-lax-vec-conv-all -target-feature -vsx -target-cpu pwr7 -fsyntax-only -verify=expected,novsx -std=c++11 %s
+// RUN: %clang_cc1 -triple=powerpc-ibm-aix -Wno-deprecate-lax-vec-conv-all -target-feature +altivec -fsyntax-only -verify=expected,aix -std=c++11 %s
+// RUN: %clang_cc1 -triple=powerpc64-ibm-aix -Wno-deprecate-lax-vec-conv-all -target-feature +altivec -fsyntax-only -verify=expected,aix -std=c++11 %s
 #include 
 
 __vector char vv_c;
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -1617,8 +1617,9 @@
 ///
 /// \param ICK Will be set to the vector conversion kind, if this is a vector
 /// conversion.
-static bool IsVectorConversion(Sema , QualType FromType,
-   QualType ToType, ImplicitConversionKind ) {
+static bool IsVectorConversion(Sema , QualType FromType, QualType ToType,
+   ImplicitConversionKind , Expr *From,
+   bool InOverloadResolution) {
   // We need at least one of these types to be a vector type to have a vector
   // conversion.
   if (!ToType->isVectorType() && !FromType->isVectorType())
@@ -1660,6 +1661,13 @@
 if (S.Context.areCompatibleVectorTypes(FromType, ToType) ||
 (S.isLaxVectorConversion(FromType, ToType) &&
  !ToType->hasAttr(attr::ArmMveStrictPolymorphism))) {
+  if (S.isLaxVectorConversion(FromType, ToType) &&
+  S.areAnyVectorTypesAltivec(FromType, ToType) &&
+  !S.areVectorTypesSameElmType(FromType, ToType) &&
+  !InOverloadResolution) {
+S.Diag(From->getBeginLoc(), diag::warn_deprecated_lax_vec_conv_all)
+<< FromType << ToType;
+  }
   ICK = ICK_Vector_Conversion;
   return true;
 }
@@ -1908,7 +1916,8 @@
  InOverloadResolution, FromType)) {
 // Pointer to member conversions (4.11).
 SCS.Second = ICK_Pointer_Member;
-  } else if (IsVectorConversion(S, FromType, ToType, SecondICK)) {
+  } else if (IsVectorConversion(S, FromType, ToType, SecondICK, From,
+InOverloadResolution)) {
 SCS.Second = SecondICK;
 FromType = ToType.getUnqualifiedType();
   } else if (!S.getLangOpts().CPlusPlus &&
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -7712,6 

[PATCH] D126908: [VerifyDiagnosticConsumer] Fix last line being discarded when parsing newline

2022-06-15 Thread Vang Thao via Phabricator via cfe-commits
vangthao added a comment.

Ping..


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126908

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


[PATCH] D126540: PowerPC] Emit warning for incompatible vector types that are currently diagnosed with -fno-lax-vector-conversions

2022-06-15 Thread Maryam Moghadas via Phabricator via cfe-commits
maryammo updated this revision to Diff 437311.
maryammo added a comment.

NFC


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126540

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/Parser/cxx-altivec.cpp

Index: clang/test/Parser/cxx-altivec.cpp
===
--- clang/test/Parser/cxx-altivec.cpp
+++ clang/test/Parser/cxx-altivec.cpp
@@ -1,10 +1,10 @@
-// RUN: %clang_cc1 -triple=powerpc-apple-darwin8 -target-feature +altivec -fsyntax-only -verify=expected,novsx -std=c++11 %s
-// RUN: %clang_cc1 -triple=powerpc64-unknown-linux-gnu -target-feature +altivec -target-feature +vsx -fsyntax-only -verify=expected,nonaix -std=c++11 %s
-// RUN: %clang_cc1 -triple=powerpc64le-unknown-linux-gnu -target-feature +altivec -fsyntax-only -verify=expected,novsx -std=c++11 %s
-// RUN: %clang_cc1 -triple=powerpc64-unknown-linux-gnu -target-feature +vsx -target-cpu pwr7 -fsyntax-only -verify=expected,nonaix -std=c++11 %s
-// RUN: %clang_cc1 -triple=powerpc64le-unknown-linux-gnu -target-feature -vsx -target-cpu pwr7 -fsyntax-only -verify=expected,novsx -std=c++11 %s
-// RUN: %clang_cc1 -triple=powerpc-ibm-aix -target-feature +altivec -fsyntax-only -verify=expected,aix -std=c++11 %s
-// RUN: %clang_cc1 -triple=powerpc64-ibm-aix -target-feature +altivec -fsyntax-only -verify=expected,aix -std=c++11 %s
+// RUN: %clang_cc1 -triple=powerpc-apple-darwin8 -Wno-deprecate-lax-vec-conv-all -target-feature +altivec -fsyntax-only -verify=expected,novsx -std=c++11 %s
+// RUN: %clang_cc1 -triple=powerpc64-unknown-linux-gnu -Wno-deprecate-lax-vec-conv-all -target-feature +altivec -target-feature +vsx -fsyntax-only -verify=expected,nonaix -std=c++11 %s
+// RUN: %clang_cc1 -triple=powerpc64le-unknown-linux-gnu -Wno-deprecate-lax-vec-conv-all -target-feature +altivec -fsyntax-only -verify=expected,novsx -std=c++11 %s
+// RUN: %clang_cc1 -triple=powerpc64-unknown-linux-gnu -Wno-deprecate-lax-vec-conv-all -target-feature +vsx -target-cpu pwr7 -fsyntax-only -verify=expected,nonaix -std=c++11 %s
+// RUN: %clang_cc1 -triple=powerpc64le-unknown-linux-gnu -Wno-deprecate-lax-vec-conv-all -target-feature -vsx -target-cpu pwr7 -fsyntax-only -verify=expected,novsx -std=c++11 %s
+// RUN: %clang_cc1 -triple=powerpc-ibm-aix -Wno-deprecate-lax-vec-conv-all -target-feature +altivec -fsyntax-only -verify=expected,aix -std=c++11 %s
+// RUN: %clang_cc1 -triple=powerpc64-ibm-aix -Wno-deprecate-lax-vec-conv-all -target-feature +altivec -fsyntax-only -verify=expected,aix -std=c++11 %s
 #include 
 
 __vector char vv_c;
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -1617,8 +1617,9 @@
 ///
 /// \param ICK Will be set to the vector conversion kind, if this is a vector
 /// conversion.
-static bool IsVectorConversion(Sema , QualType FromType,
-   QualType ToType, ImplicitConversionKind ) {
+static bool IsVectorConversion(Sema , QualType FromType, QualType ToType,
+   ImplicitConversionKind , Expr *From,
+   bool InOverloadResolution) {
   // We need at least one of these types to be a vector type to have a vector
   // conversion.
   if (!ToType->isVectorType() && !FromType->isVectorType())
@@ -1660,6 +1661,13 @@
 if (S.Context.areCompatibleVectorTypes(FromType, ToType) ||
 (S.isLaxVectorConversion(FromType, ToType) &&
  !ToType->hasAttr(attr::ArmMveStrictPolymorphism))) {
+  if (S.isLaxVectorConversion(FromType, ToType) &&
+	  S.areAnyVectorTypesAltivec(FromType, ToType) &&
+  !S.areVectorTypesSameElmType(FromType, ToType) &&
+	  !InOverloadResolution) {
+S.Diag(From->getBeginLoc(), diag::warn_deprecated_lax_vec_conv_all)
+<< FromType << ToType;
+  }
   ICK = ICK_Vector_Conversion;
   return true;
 }
@@ -1908,7 +1916,8 @@
  InOverloadResolution, FromType)) {
 // Pointer to member conversions (4.11).
 SCS.Second = ICK_Pointer_Member;
-  } else if (IsVectorConversion(S, FromType, ToType, SecondICK)) {
+  } else if (IsVectorConversion(S, FromType, ToType, SecondICK, From,
+InOverloadResolution)) {
 SCS.Second = SecondICK;
 FromType = ToType.getUnqualifiedType();
   } else if (!S.getLangOpts().CPlusPlus &&
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -7712,6 +7712,43 @@
   return (SrcLen * SrcEltSize == DestLen * DestEltSize);
 }
 
+// This returns true if at least one of the types is an altivec vector.
+bool 

[PATCH] D126540: PowerPC] Emit warning for incompatible vector types that are currently diagnosed with -fno-lax-vector-conversions

2022-06-15 Thread Maryam Moghadas via Phabricator via cfe-commits
maryammo updated this revision to Diff 437310.
maryammo added a comment.

NFC


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126540

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/Parser/cxx-altivec.cpp

Index: clang/test/Parser/cxx-altivec.cpp
===
--- clang/test/Parser/cxx-altivec.cpp
+++ clang/test/Parser/cxx-altivec.cpp
@@ -1,10 +1,10 @@
-// RUN: %clang_cc1 -triple=powerpc-apple-darwin8 -target-feature +altivec -fsyntax-only -verify=expected,novsx -std=c++11 %s
-// RUN: %clang_cc1 -triple=powerpc64-unknown-linux-gnu -target-feature +altivec -target-feature +vsx -fsyntax-only -verify=expected,nonaix -std=c++11 %s
-// RUN: %clang_cc1 -triple=powerpc64le-unknown-linux-gnu -target-feature +altivec -fsyntax-only -verify=expected,novsx -std=c++11 %s
-// RUN: %clang_cc1 -triple=powerpc64-unknown-linux-gnu -target-feature +vsx -target-cpu pwr7 -fsyntax-only -verify=expected,nonaix -std=c++11 %s
-// RUN: %clang_cc1 -triple=powerpc64le-unknown-linux-gnu -target-feature -vsx -target-cpu pwr7 -fsyntax-only -verify=expected,novsx -std=c++11 %s
-// RUN: %clang_cc1 -triple=powerpc-ibm-aix -target-feature +altivec -fsyntax-only -verify=expected,aix -std=c++11 %s
-// RUN: %clang_cc1 -triple=powerpc64-ibm-aix -target-feature +altivec -fsyntax-only -verify=expected,aix -std=c++11 %s
+// RUN: %clang_cc1 -triple=powerpc-apple-darwin8 -Wno-deprecate-lax-vec-conv-all -target-feature +altivec -fsyntax-only -verify=expected,novsx -std=c++11 %s
+// RUN: %clang_cc1 -triple=powerpc64-unknown-linux-gnu -Wno-deprecate-lax-vec-conv-all -target-feature +altivec -target-feature +vsx -fsyntax-only -verify=expected,nonaix -std=c++11 %s
+// RUN: %clang_cc1 -triple=powerpc64le-unknown-linux-gnu -Wno-deprecate-lax-vec-conv-all -target-feature +altivec -fsyntax-only -verify=expected,novsx -std=c++11 %s
+// RUN: %clang_cc1 -triple=powerpc64-unknown-linux-gnu -Wno-deprecate-lax-vec-conv-all -target-feature +vsx -target-cpu pwr7 -fsyntax-only -verify=expected,nonaix -std=c++11 %s
+// RUN: %clang_cc1 -triple=powerpc64le-unknown-linux-gnu -Wno-deprecate-lax-vec-conv-all -target-feature -vsx -target-cpu pwr7 -fsyntax-only -verify=expected,novsx -std=c++11 %s
+// RUN: %clang_cc1 -triple=powerpc-ibm-aix -Wno-deprecate-lax-vec-conv-all -target-feature +altivec -fsyntax-only -verify=expected,aix -std=c++11 %s
+// RUN: %clang_cc1 -triple=powerpc64-ibm-aix -Wno-deprecate-lax-vec-conv-all -target-feature +altivec -fsyntax-only -verify=expected,aix -std=c++11 %s
 #include 
 
 __vector char vv_c;
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -1617,8 +1617,9 @@
 ///
 /// \param ICK Will be set to the vector conversion kind, if this is a vector
 /// conversion.
-static bool IsVectorConversion(Sema , QualType FromType,
-   QualType ToType, ImplicitConversionKind ) {
+static bool IsVectorConversion(Sema , QualType FromType, QualType ToType,
+   ImplicitConversionKind , Expr *From,
+   bool InOverloadResolution) {
   // We need at least one of these types to be a vector type to have a vector
   // conversion.
   if (!ToType->isVectorType() && !FromType->isVectorType())
@@ -1660,6 +1661,13 @@
 if (S.Context.areCompatibleVectorTypes(FromType, ToType) ||
 (S.isLaxVectorConversion(FromType, ToType) &&
  !ToType->hasAttr(attr::ArmMveStrictPolymorphism))) {
+  if (S.isLaxVectorConversion(FromType, ToType) &&
+	  S.areAnyVectorTypesAltivec(FromType, ToType) &&
+  !S.areVectorTypesSameElmType(FromType, ToType) &&
+	  !InOverloadResolution) {
+S.Diag(From->getBeginLoc(), diag::warn_deprecated_lax_vec_conv_all)
+<< FromType << ToType;
+  }
   ICK = ICK_Vector_Conversion;
   return true;
 }
@@ -1908,7 +1916,8 @@
  InOverloadResolution, FromType)) {
 // Pointer to member conversions (4.11).
 SCS.Second = ICK_Pointer_Member;
-  } else if (IsVectorConversion(S, FromType, ToType, SecondICK)) {
+  } else if (IsVectorConversion(S, FromType, ToType, SecondICK, From,
+InOverloadResolution)) {
 SCS.Second = SecondICK;
 FromType = ToType.getUnqualifiedType();
   } else if (!S.getLangOpts().CPlusPlus &&
@@ -15285,3 +15294,4 @@
 return false;
   return true;
 }
+
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -7712,6 +7712,43 @@
   return (SrcLen * SrcEltSize == DestLen * DestEltSize);
 }
 
+// This returns true if at 

[PATCH] D127827: [clang-format][NFC] Fix braces in ClangFormat.cpp

2022-06-15 Thread Owen Pan 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 rG2d82c9ccf32c: [clang-format][NFC] Fix braces in 
ClangFormat.cpp (authored by owenpan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127827

Files:
  clang/tools/clang-format/ClangFormat.cpp


Index: clang/tools/clang-format/ClangFormat.cpp
===
--- clang/tools/clang-format/ClangFormat.cpp
+++ clang/tools/clang-format/ClangFormat.cpp
@@ -358,9 +358,10 @@
   if (!Status.FormatComplete)
 outs() << " line='" << Status.Line << "'";
   outs() << ">\n";
-  if (Cursor.getNumOccurrences() != 0)
+  if (Cursor.getNumOccurrences() != 0) {
 outs() << "" << 
FormatChanges.getShiftedCodePosition(CursorPosition)
<< "\n";
+  }
 
   outputReplacementsXML(Replaces);
   outs() << "\n";
@@ -436,11 +437,11 @@
   .Case("left", FormatStyle::QAS_Left)
   .Default(FormatStyle->QualifierAlignment);
 
-  if (FormatStyle->QualifierAlignment == FormatStyle::QAS_Left)
+  if (FormatStyle->QualifierAlignment == FormatStyle::QAS_Left) {
 FormatStyle->QualifierOrder = {"const", "volatile", "type"};
-  else if (FormatStyle->QualifierAlignment == FormatStyle::QAS_Right)
+  } else if (FormatStyle->QualifierAlignment == FormatStyle::QAS_Right) {
 FormatStyle->QualifierOrder = {"type", "const", "volatile"};
-  else if (QualifierAlignmentOrder.contains("type")) {
+  } else if (QualifierAlignmentOrder.contains("type")) {
 FormatStyle->QualifierAlignment = FormatStyle::QAS_Custom;
 SmallVector Qualifiers;
 QualifierAlignmentOrder.split(Qualifiers, " ", /*MaxSplit=*/-1,
@@ -463,9 +464,8 @@
   if (FormatStyle->isJson() && !FormatStyle->DisableFormat) {
 auto Err = Replaces.add(tooling::Replacement(
 tooling::Replacement(AssumedFileName, 0, 0, "x = ")));
-if (Err) {
+if (Err)
   llvm::errs() << "Bad Json variable insertion\n";
-}
   }
 
   auto ChangedCode = tooling::applyAllReplacements(Code->getBuffer(), 
Replaces);
@@ -480,11 +480,10 @@
   reformat(*FormatStyle, *ChangedCode, Ranges, AssumedFileName, );
   Replaces = Replaces.merge(FormatChanges);
   if (OutputXML || DryRun) {
-if (DryRun) {
+if (DryRun)
   return emitReplacementWarnings(Replaces, AssumedFileName, Code);
-} else {
+else
   outputXML(Replaces, FormatChanges, Status, Cursor, CursorPosition);
-}
   } else {
 IntrusiveRefCntPtr InMemoryFileSystem(
 new llvm::vfs::InMemoryFileSystem);
@@ -579,9 +578,8 @@
 return 0;
   }
 
-  if (DumpConfig) {
+  if (DumpConfig)
 return dumpConfig();
-  }
 
   if (!Files.empty()) {
 std::ifstream ExternalFileOfFiles{std::string(Files)};
@@ -608,9 +606,10 @@
 
   unsigned FileNo = 1;
   for (const auto  : FileNames) {
-if (Verbose)
+if (Verbose) {
   errs() << "Formatting [" << FileNo++ << "/" << FileNames.size() << "] "
  << FileName << "\n";
+}
 Error |= clang::format::format(FileName);
   }
   return Error ? 1 : 0;


Index: clang/tools/clang-format/ClangFormat.cpp
===
--- clang/tools/clang-format/ClangFormat.cpp
+++ clang/tools/clang-format/ClangFormat.cpp
@@ -358,9 +358,10 @@
   if (!Status.FormatComplete)
 outs() << " line='" << Status.Line << "'";
   outs() << ">\n";
-  if (Cursor.getNumOccurrences() != 0)
+  if (Cursor.getNumOccurrences() != 0) {
 outs() << "" << FormatChanges.getShiftedCodePosition(CursorPosition)
<< "\n";
+  }
 
   outputReplacementsXML(Replaces);
   outs() << "\n";
@@ -436,11 +437,11 @@
   .Case("left", FormatStyle::QAS_Left)
   .Default(FormatStyle->QualifierAlignment);
 
-  if (FormatStyle->QualifierAlignment == FormatStyle::QAS_Left)
+  if (FormatStyle->QualifierAlignment == FormatStyle::QAS_Left) {
 FormatStyle->QualifierOrder = {"const", "volatile", "type"};
-  else if (FormatStyle->QualifierAlignment == FormatStyle::QAS_Right)
+  } else if (FormatStyle->QualifierAlignment == FormatStyle::QAS_Right) {
 FormatStyle->QualifierOrder = {"type", "const", "volatile"};
-  else if (QualifierAlignmentOrder.contains("type")) {
+  } else if (QualifierAlignmentOrder.contains("type")) {
 FormatStyle->QualifierAlignment = FormatStyle::QAS_Custom;
 SmallVector Qualifiers;
 QualifierAlignmentOrder.split(Qualifiers, " ", /*MaxSplit=*/-1,
@@ -463,9 +464,8 @@
   if (FormatStyle->isJson() && !FormatStyle->DisableFormat) {
 auto Err = Replaces.add(tooling::Replacement(
 tooling::Replacement(AssumedFileName, 0, 0, "x = ")));
-if (Err) {
+if (Err)
   llvm::errs() << "Bad Json variable insertion\n";
-}
   }
 
   auto ChangedCode = tooling::applyAllReplacements(Code->getBuffer(), Replaces);
@@ -480,11 +480,10 @@
   

[clang] 2d82c9c - [clang-format][NFC] Fix braces in ClangFormat.cpp

2022-06-15 Thread via cfe-commits

Author: owenca
Date: 2022-06-15T12:57:48-07:00
New Revision: 2d82c9ccf32c9200b1a48de613869113e8655508

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

LOG: [clang-format][NFC] Fix braces in ClangFormat.cpp

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

Added: 


Modified: 
clang/tools/clang-format/ClangFormat.cpp

Removed: 




diff  --git a/clang/tools/clang-format/ClangFormat.cpp 
b/clang/tools/clang-format/ClangFormat.cpp
index 5f7d65f9a1b0c..b85cb1220d6ba 100644
--- a/clang/tools/clang-format/ClangFormat.cpp
+++ b/clang/tools/clang-format/ClangFormat.cpp
@@ -358,9 +358,10 @@ static void outputXML(const Replacements ,
   if (!Status.FormatComplete)
 outs() << " line='" << Status.Line << "'";
   outs() << ">\n";
-  if (Cursor.getNumOccurrences() != 0)
+  if (Cursor.getNumOccurrences() != 0) {
 outs() << "" << 
FormatChanges.getShiftedCodePosition(CursorPosition)
<< "\n";
+  }
 
   outputReplacementsXML(Replaces);
   outs() << "\n";
@@ -436,11 +437,11 @@ static bool format(StringRef FileName) {
   .Case("left", FormatStyle::QAS_Left)
   .Default(FormatStyle->QualifierAlignment);
 
-  if (FormatStyle->QualifierAlignment == FormatStyle::QAS_Left)
+  if (FormatStyle->QualifierAlignment == FormatStyle::QAS_Left) {
 FormatStyle->QualifierOrder = {"const", "volatile", "type"};
-  else if (FormatStyle->QualifierAlignment == FormatStyle::QAS_Right)
+  } else if (FormatStyle->QualifierAlignment == FormatStyle::QAS_Right) {
 FormatStyle->QualifierOrder = {"type", "const", "volatile"};
-  else if (QualifierAlignmentOrder.contains("type")) {
+  } else if (QualifierAlignmentOrder.contains("type")) {
 FormatStyle->QualifierAlignment = FormatStyle::QAS_Custom;
 SmallVector Qualifiers;
 QualifierAlignmentOrder.split(Qualifiers, " ", /*MaxSplit=*/-1,
@@ -463,9 +464,8 @@ static bool format(StringRef FileName) {
   if (FormatStyle->isJson() && !FormatStyle->DisableFormat) {
 auto Err = Replaces.add(tooling::Replacement(
 tooling::Replacement(AssumedFileName, 0, 0, "x = ")));
-if (Err) {
+if (Err)
   llvm::errs() << "Bad Json variable insertion\n";
-}
   }
 
   auto ChangedCode = tooling::applyAllReplacements(Code->getBuffer(), 
Replaces);
@@ -480,11 +480,10 @@ static bool format(StringRef FileName) {
   reformat(*FormatStyle, *ChangedCode, Ranges, AssumedFileName, );
   Replaces = Replaces.merge(FormatChanges);
   if (OutputXML || DryRun) {
-if (DryRun) {
+if (DryRun)
   return emitReplacementWarnings(Replaces, AssumedFileName, Code);
-} else {
+else
   outputXML(Replaces, FormatChanges, Status, Cursor, CursorPosition);
-}
   } else {
 IntrusiveRefCntPtr InMemoryFileSystem(
 new llvm::vfs::InMemoryFileSystem);
@@ -579,9 +578,8 @@ int main(int argc, const char **argv) {
 return 0;
   }
 
-  if (DumpConfig) {
+  if (DumpConfig)
 return dumpConfig();
-  }
 
   if (!Files.empty()) {
 std::ifstream ExternalFileOfFiles{std::string(Files)};
@@ -608,9 +606,10 @@ int main(int argc, const char **argv) {
 
   unsigned FileNo = 1;
   for (const auto  : FileNames) {
-if (Verbose)
+if (Verbose) {
   errs() << "Formatting [" << FileNo++ << "/" << FileNames.size() << "] "
  << FileName << "\n";
+}
 Error |= clang::format::format(FileName);
   }
   return Error ? 1 : 0;



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


[PATCH] D126907: Deferred Concept Instantiation Implementation Take 2

2022-06-15 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D126907#3585626 , @erichkeane 
wrote:

> See here: https://github.com/llvm/llvm-project/issues/55673
>
> This might be the same issue, the crash at least looks the same.

Note: Looks to not be the same problem :/  Additionally, the fix I thought 
would work here does not, so I'm back at square 1 on that crash again.  I was 
trying to move the 'isEvaluatingAConstraint' out of Sema (since we don't want 
to isntantiate a type constraint until we are checking it!) but that causes us 
to fail a number of OTHER tests for checking an uninstantiated constraint.


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

https://reviews.llvm.org/D126907

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


[PATCH] D127901: [LinkerWrapper] Add PTX output to CUDA fatbinary in LTO-mode

2022-06-15 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 created this revision.
jhuber6 added reviewers: jdoerfert, JonChesterfield, tra, yaxunl.
Herald added subscribers: mattd, gchakrabarti, asavonic, inglorion.
Herald added a project: All.
jhuber6 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

One current downside of the LLVM support for CUDA in RDC-mode is that we
cannot JIT off of the PTX image. This requires the user to provide the
specific architecture when offloading. CUDA's runtime uses a special
method to link the separate PTX files when in RDC-mode, while LLVM
cannot do this with the chosen approach to supporting RDC-mode
compilation. However, if we embed bitcode via LTO we can use the
single-linked PTX image for the whole module and include it in the
fatbinary. This allows us to do the following and have it execute even
without the correct architecture specified.

  clang foo.cu -foffload-lto -fgpu-rdc --offload-new-driver -lcudart

It is also worth noting that in full-LTO mode, RDC-mode will behave
exactly like non-RDC mode after linking.

Depends on D127246 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D127901

Files:
  clang/test/Driver/linker-wrapper.c
  clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp

Index: clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
===
--- clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -557,9 +557,16 @@
   CmdArgs.push_back(TheTriple.isArch64Bit() ? "-64" : "-32");
   CmdArgs.push_back("--create");
   CmdArgs.push_back(TempFile);
-  for (const auto  : InputFiles)
-CmdArgs.push_back(Saver.save("--image=profile=" + std::get<1>(FileAndArch) +
- ",file=" + std::get<0>(FileAndArch)));
+  for (const auto  : InputFiles) {
+if (std::get<0>(FileAndArch).endswith(".s"))
+  CmdArgs.push_back(Saver.save("--image=profile=compute_" +
+   std::get<1>(FileAndArch).split("_").second +
+   ",file=" + std::get<0>(FileAndArch)));
+else
+  CmdArgs.push_back(
+  Saver.save("--image=profile=" + std::get<1>(FileAndArch) +
+ ",file=" + std::get<0>(FileAndArch)));
+  }
 
   if (Error Err = executeCommands(*FatBinaryPath, CmdArgs))
 return std::move(Err);
@@ -820,6 +827,7 @@
 
 Error linkBitcodeFiles(SmallVectorImpl ,
SmallVectorImpl ,
+   SmallVectorImpl ,
const Triple , StringRef Arch) {
   SmallVector BitcodeInputFiles;
   DenseSet UsedInRegularObj;
@@ -998,6 +1006,7 @@
   // Is we are compiling for NVPTX we need to run the assembler first.
   if (TheTriple.isNVPTX()) {
 for (auto  : Files) {
+  AuxOutputFiles.push_back(static_cast(File));
   auto FileOrErr = nvptx::assemble(File, TheTriple, Arch, !WholeProgram);
   if (!FileOrErr)
 return FileOrErr.takeError();
@@ -1187,7 +1196,9 @@
 
 // First link and remove all the input files containing bitcode.
 SmallVector InputFiles;
-if (Error Err = linkBitcodeFiles(Input, InputFiles, Triple, Arch))
+SmallVector OutputFiles;
+if (Error Err =
+linkBitcodeFiles(Input, InputFiles, OutputFiles, Triple, Arch))
   return Err;
 
 // Write any remaining device inputs to an output file for the linker job.
@@ -1205,20 +1216,27 @@
  : InputFiles.front();
 if (!OutputOrErr)
   return OutputOrErr.takeError();
+OutputFiles.push_back(*OutputOrErr);
 
-// Store the offloading image for each linked output file.
+// Store the offloading image for each output file.
 for (OffloadKind Kind : ActiveOffloadKinds) {
-  llvm::ErrorOr> FileOrErr =
-  llvm::MemoryBuffer::getFileOrSTDIN(*OutputOrErr);
-  if (std::error_code EC = FileOrErr.getError())
-return createFileError(*OutputOrErr, EC);
-
-  OffloadingImage TheImage{};
-  TheImage.TheImageKind = IMG_Object;
-  TheImage.TheOffloadKind = Kind;
-  TheImage.StringData = {{"triple", TripleStr}, {"arch", Arch}};
-  TheImage.Image = std::move(*FileOrErr);
-  Images[Kind].emplace_back(std::move(TheImage));
+  for (StringRef Output : OutputFiles) {
+// Ignore any PTX output if we're not creating a fatbinary.
+if (Output.endswith(".s") && Kind != OFK_Cuda)
+  continue;
+
+llvm::ErrorOr> FileOrErr =
+llvm::MemoryBuffer::getFileOrSTDIN(Output);
+if (std::error_code EC = FileOrErr.getError())
+  return createFileError(Output, EC);
+
+OffloadingImage TheImage{};
+TheImage.TheImageKind = Output.endswith(".s") ? IMG_PTX : IMG_Object;
+TheImage.TheOffloadKind = Kind;
+TheImage.StringData = {{"triple", TripleStr}, {"arch", Arch}};
+

[PATCH] D126540: PowerPC] Emit warning for incompatible vector types that are currently diagnosed with -fno-lax-vector-conversions

2022-06-15 Thread Maryam Moghadas via Phabricator via cfe-commits
maryammo updated this revision to Diff 437303.
maryammo marked an inline comment as not done.
maryammo added a comment.

Address the review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126540

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/Parser/cxx-altivec.cpp

Index: clang/test/Parser/cxx-altivec.cpp
===
--- clang/test/Parser/cxx-altivec.cpp
+++ clang/test/Parser/cxx-altivec.cpp
@@ -1,10 +1,10 @@
-// RUN: %clang_cc1 -triple=powerpc-apple-darwin8 -target-feature +altivec -fsyntax-only -verify=expected,novsx -std=c++11 %s
-// RUN: %clang_cc1 -triple=powerpc64-unknown-linux-gnu -target-feature +altivec -target-feature +vsx -fsyntax-only -verify=expected,nonaix -std=c++11 %s
-// RUN: %clang_cc1 -triple=powerpc64le-unknown-linux-gnu -target-feature +altivec -fsyntax-only -verify=expected,novsx -std=c++11 %s
-// RUN: %clang_cc1 -triple=powerpc64-unknown-linux-gnu -target-feature +vsx -target-cpu pwr7 -fsyntax-only -verify=expected,nonaix -std=c++11 %s
-// RUN: %clang_cc1 -triple=powerpc64le-unknown-linux-gnu -target-feature -vsx -target-cpu pwr7 -fsyntax-only -verify=expected,novsx -std=c++11 %s
-// RUN: %clang_cc1 -triple=powerpc-ibm-aix -target-feature +altivec -fsyntax-only -verify=expected,aix -std=c++11 %s
-// RUN: %clang_cc1 -triple=powerpc64-ibm-aix -target-feature +altivec -fsyntax-only -verify=expected,aix -std=c++11 %s
+// RUN: %clang_cc1 -triple=powerpc-apple-darwin8 -Wno-deprecate-lax-vec-conv-all -target-feature +altivec -fsyntax-only -verify=expected,novsx -std=c++11 %s
+// RUN: %clang_cc1 -triple=powerpc64-unknown-linux-gnu -Wno-deprecate-lax-vec-conv-all -target-feature +altivec -target-feature +vsx -fsyntax-only -verify=expected,nonaix -std=c++11 %s
+// RUN: %clang_cc1 -triple=powerpc64le-unknown-linux-gnu -Wno-deprecate-lax-vec-conv-all -target-feature +altivec -fsyntax-only -verify=expected,novsx -std=c++11 %s
+// RUN: %clang_cc1 -triple=powerpc64-unknown-linux-gnu -Wno-deprecate-lax-vec-conv-all -target-feature +vsx -target-cpu pwr7 -fsyntax-only -verify=expected,nonaix -std=c++11 %s
+// RUN: %clang_cc1 -triple=powerpc64le-unknown-linux-gnu -Wno-deprecate-lax-vec-conv-all -target-feature -vsx -target-cpu pwr7 -fsyntax-only -verify=expected,novsx -std=c++11 %s
+// RUN: %clang_cc1 -triple=powerpc-ibm-aix -Wno-deprecate-lax-vec-conv-all -target-feature +altivec -fsyntax-only -verify=expected,aix -std=c++11 %s
+// RUN: %clang_cc1 -triple=powerpc64-ibm-aix -Wno-deprecate-lax-vec-conv-all -target-feature +altivec -fsyntax-only -verify=expected,aix -std=c++11 %s
 #include 
 
 __vector char vv_c;
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -1617,8 +1617,9 @@
 ///
 /// \param ICK Will be set to the vector conversion kind, if this is a vector
 /// conversion.
-static bool IsVectorConversion(Sema , QualType FromType,
-   QualType ToType, ImplicitConversionKind ) {
+static bool IsVectorConversion(Sema , QualType FromType, QualType ToType,
+   ImplicitConversionKind , Expr *From,
+   bool InOverloadResolution) {
   // We need at least one of these types to be a vector type to have a vector
   // conversion.
   if (!ToType->isVectorType() && !FromType->isVectorType())
@@ -1660,6 +1661,13 @@
 if (S.Context.areCompatibleVectorTypes(FromType, ToType) ||
 (S.isLaxVectorConversion(FromType, ToType) &&
  !ToType->hasAttr(attr::ArmMveStrictPolymorphism))) {
+  if (S.isLaxVectorConversion(FromType, ToType) &&
+	  S.areAnyVectorTypesAltivec(FromType, ToType) &&
+  !S.areVectorTypesSameElmType(FromType, ToType) &&
+	  !InOverloadResolution) {
+S.Diag(From->getBeginLoc(), diag::warn_deprecated_lax_vec_conv_all)
+<< FromType << ToType;
+  }
   ICK = ICK_Vector_Conversion;
   return true;
 }
@@ -1908,7 +1916,8 @@
  InOverloadResolution, FromType)) {
 // Pointer to member conversions (4.11).
 SCS.Second = ICK_Pointer_Member;
-  } else if (IsVectorConversion(S, FromType, ToType, SecondICK)) {
+  } else if (IsVectorConversion(S, FromType, ToType, SecondICK, From,
+InOverloadResolution)) {
 SCS.Second = SecondICK;
 FromType = ToType.getUnqualifiedType();
   } else if (!S.getLangOpts().CPlusPlus &&
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -7712,6 +7712,43 @@
   return (SrcLen * SrcEltSize == DestLen * DestEltSize);
 }
 
+// This returns true if 

[PATCH] D127890: [Docs] Update clang & llvm release notes for HLSL

2022-06-15 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added inline comments.



Comment at: clang/docs/ReleaseNotes.rst:72
+- Clang is gaining support for HLSL. Basic features for the HLSL language have
+  started being merged during Clang-15 development, but the implementation is
+  incomplete and highly experimental. For more information about the ongoing

aaron.ballman wrote:
> 
The sentences may be simplified as:

Experimental support for HLSL has been added. 

The doc is about Clang, so many occurrences of Clang are redundant.



Comment at: llvm/docs/ReleaseNotes.rst:116
+
+* An experimental DirectX backend has been introduced to the LLVM tree. It is
+  not packaged with any of the pre-built releases but can be built from source

DirectX has been added as an experimental target.
Specify ``-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=DirectX`` in your CMake 
configuration to enable it. The target is not packaged in pre-built binaries.

"LLVM tree" does not convey more information.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127890

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


[clang] 1082285 - Rolling back tests for WG14 DR145

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

Author: Aaron Ballman
Date: 2022-06-15T15:37:14-04:00
New Revision: 10822857b7d5218a36eb36e36b924f10d981b67c

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

LOG: Rolling back tests for WG14 DR145

Several build bots are failing with surprising behavior, so it's less
clear whether we do or don't implement this DR properly.

https://lab.llvm.org/buildbot/#/builders/91/builds/10454
https://lab.llvm.org/buildbot/#/builders/109/builds/40668
https://lab.llvm.org/buildbot/#/builders/139/builds/23334

Added: 


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

Removed: 




diff  --git a/clang/test/C/drs/dr1xx.c b/clang/test/C/drs/dr1xx.c
index fed5fdd69101..cbcc0524105f 100644
--- a/clang/test/C/drs/dr1xx.c
+++ b/clang/test/C/drs/dr1xx.c
@@ -319,11 +319,15 @@ void dr142(void) {
 # DR144 include  /* expected-error {{invalid preprocessing 
directive}} */
 DR144 # include  /* expected-error {{expected identifier or '('}} */
 
-/* WG14 DR145: yes
+/* WG14 DR145:
  * Constant expressions
  */
 void dr145(void) {
   static int array[10];
   static int *ip = (int *)0;
-  static int i = array[0] + array[1]; /* expected-error {{initializer element 
is not a compile-time constant}} */
+  /* The below is failing because some systems think this is a valid compile-
+   * time constant. Commenting the out while investigating whether we implement
+   * this DR properly or not.
+   * static int i = array[0] + array[1]; broken-expected-error {{initializer 
element is not a compile-time constant}}
+   */
 }

diff  --git a/clang/www/c_dr_status.html b/clang/www/c_dr_status.html
index 0b16bd55b299..c00fd511ef41 100644
--- a/clang/www/c_dr_status.html
+++ b/clang/www/c_dr_status.html
@@ -925,7 +925,7 @@ C defect report implementation status
 https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_145.html;>145
 C89
 Constant expressions
-Yes
+Unknown
   
   
 https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_146.html;>146



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


[PATCH] D127898: [clang][dataflow] Find unsafe locs after fixpoint

2022-06-15 Thread Sam Estep via Phabricator via cfe-commits
samestep created this revision.
Herald added subscribers: martong, tschuett, carlosgalvezp, xazax.hun, mgorny.
Herald added a project: All.
samestep requested review of this revision.
Herald added projects: clang, LLVM, clang-tools-extra.
Herald added subscribers: cfe-commits, llvm-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D127898

Files:
  clang-tools-extra/clang-tidy/bugprone/UncheckedOptionalAccessCheck.cpp
  clang/docs/tools/clang-formatted-files.txt
  clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h
  clang/include/clang/Analysis/FlowSensitive/MatchSwitch.h
  
clang/include/clang/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.h
  clang/include/clang/Analysis/FlowSensitive/NoopLattice.h
  clang/include/clang/Analysis/FlowSensitive/SourceLocations.h
  clang/include/clang/Analysis/FlowSensitive/SourceLocationsLattice.h
  clang/lib/Analysis/FlowSensitive/CMakeLists.txt
  clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
  clang/lib/Analysis/FlowSensitive/SourceLocations.cpp
  clang/lib/Analysis/FlowSensitive/SourceLocationsLattice.cpp
  clang/unittests/Analysis/FlowSensitive/CMakeLists.txt
  clang/unittests/Analysis/FlowSensitive/ChromiumCheckModelTest.cpp
  clang/unittests/Analysis/FlowSensitive/MatchSwitchTest.cpp
  clang/unittests/Analysis/FlowSensitive/MultiVarConstantPropagationTest.cpp
  clang/unittests/Analysis/FlowSensitive/NoopAnalysis.h
  clang/unittests/Analysis/FlowSensitive/SingleVarConstantPropagationTest.cpp
  clang/unittests/Analysis/FlowSensitive/SourceLocationsLatticeTest.cpp
  clang/unittests/Analysis/FlowSensitive/TestingSupport.h
  clang/unittests/Analysis/FlowSensitive/TestingSupportTest.cpp
  clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
  clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
  clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp
  llvm/utils/gn/secondary/clang/lib/Analysis/FlowSensitive/BUILD.gn
  llvm/utils/gn/secondary/clang/unittests/Analysis/FlowSensitive/BUILD.gn

Index: llvm/utils/gn/secondary/clang/unittests/Analysis/FlowSensitive/BUILD.gn
===
--- llvm/utils/gn/secondary/clang/unittests/Analysis/FlowSensitive/BUILD.gn
+++ llvm/utils/gn/secondary/clang/unittests/Analysis/FlowSensitive/BUILD.gn
@@ -25,7 +25,6 @@
 "MultiVarConstantPropagationTest.cpp",
 "SingleVarConstantPropagationTest.cpp",
 "SolverTest.cpp",
-"SourceLocationsLatticeTest.cpp",
 "TestingSupport.cpp",
 "TestingSupportTest.cpp",
 "TransferTest.cpp",
Index: llvm/utils/gn/secondary/clang/lib/Analysis/FlowSensitive/BUILD.gn
===
--- llvm/utils/gn/secondary/clang/lib/Analysis/FlowSensitive/BUILD.gn
+++ llvm/utils/gn/secondary/clang/lib/Analysis/FlowSensitive/BUILD.gn
@@ -9,7 +9,7 @@
 "ControlFlowContext.cpp",
 "DataflowAnalysisContext.cpp",
 "DataflowEnvironment.cpp",
-"SourceLocationsLattice.cpp",
+"SourceLocations.cpp",
 "Transfer.cpp",
 "TypeErasedDataflowAnalysis.cpp",
 "WatchedLiteralsSolver.cpp",
Index: clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp
@@ -11,7 +11,7 @@
 #include "TestingSupport.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
-#include "clang/Analysis/FlowSensitive/SourceLocationsLattice.h"
+#include "clang/Analysis/FlowSensitive/SourceLocations.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/StringExtras.h"
@@ -26,9 +26,6 @@
 using namespace dataflow;
 using namespace test;
 
-using ::testing::Pair;
-using ::testing::UnorderedElementsAre;
-
 // FIXME: Move header definitions in separate file(s).
 static constexpr char CSDtdDefHeader[] = R"(
 #ifndef CSTDDEF_H
@@ -1181,10 +1178,9 @@
 )";
 
 /// Converts `L` to string.
-static std::string ConvertToString(const SourceLocationsLattice ,
+static std::string ConvertToString(const SourceLocations ,
const ASTContext ) {
-  return L.getSourceLocations().empty() ? "safe"
-: "unsafe: " + DebugString(L, Ctx);
+  return L.empty() ? "safe" : "unsafe: " + DebugString(L, Ctx);
 }
 
 /// Replaces all occurrences of `Pattern` in `S` with `Replacement`.
@@ -1253,19 +1249,11 @@
/*IgnoreSmartPointerDereference=*/true});
 },
 [](
-llvm::ArrayRef>>
-CheckToLatticeMap,
-ASTContext ) {
-  // FIXME: Consider using a matcher instead of translating
-  // `CheckToLatticeMap` to `CheckToStringifiedLatticeMap`.
-  std::vector>
- 

[PATCH] D127890: [Docs] Update clang & llvm release notes for HLSL

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

Thanks for adding the release notes! LGTM aside from some minor nits (take em 
or leave em).




Comment at: clang/docs/ReleaseNotes.rst:72
+- Clang is gaining support for HLSL. Basic features for the HLSL language have
+  started being merged during Clang-15 development, but the implementation is
+  incomplete and highly experimental. For more information about the ongoing





Comment at: clang/docs/ReleaseNotes.rst:75
+  work to support HLSL see the `Clang documentation
+  `_, or `GitHub project
+  `_.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127890

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


[clang] 61a649c - Update the status of more C DRs

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

Author: Aaron Ballman
Date: 2022-06-15T15:25:47-04:00
New Revision: 61a649ca3556b24c88f5697660a850b7486ad691

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

LOG: Update the status of more C DRs

This adds information for DRs 126 through 146.

Added: 


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

Removed: 




diff  --git a/clang/test/C/drs/dr1xx.c b/clang/test/C/drs/dr1xx.c
index e7343c0e3573..fed5fdd69101 100644
--- a/clang/test/C/drs/dr1xx.c
+++ b/clang/test/C/drs/dr1xx.c
@@ -31,6 +31,24 @@
  *
  * WG14 DR125: yes
  * Using things declared as 'extern (qualified) void'
+ *
+ * WG14 DR127: dup 013
+ * Composite type of an enumerated type and an integral type
+ *
+ * WG14 DR132: dup 109
+ * Can undefined behavior occur at translation time, or only at run time?
+ *
+ * WG14 DR133: yes
+ * Undefined behavior not previously listed in subclause G2
+ *
+ * WG14 DR138: yes
+ * Is there an allocated storage duration?
+ *
+ * WG14 DR139: yes
+ * Compatibility of complete and incomplete types
+ *
+ * WG14 DR146: yes
+ * Nugatory constraint
  */
 
 
@@ -231,3 +249,81 @@ void dr124(void) {
   /* A cast can cast to void or any qualified version of void. */
   (const volatile void)0;
 }
+
+/* WG14 DR126:  yes
+ * What does 'synonym' mean with respect to typedef names?
+ */
+void dr126(void) {
+  typedef int *IP;
+  const IP object; /* expected-note {{variable 'object' declared const here}} 
*/
+
+  /* The root of the DR is whether 'object' is a pointer to a const int, or a
+   * const pointer to int.
+   */
+  *object = 12; /* ok */
+  ++object; /* expected-error {{cannot assign to variable 'object' with 
const-qualified type 'const IP' (aka 'int *const')}} */
+}
+
+/* WG14 DR128: yes
+ * Editorial issue relating to tag declarations in type specifiers
+ */
+void dr128(void) {
+  {
+struct TAG { int i; };
+  }
+  {
+struct TAG object; /* expected-error {{variable has incomplete type 
'struct TAG'}}
+  expected-note {{forward declaration of 'struct TAG'}}
+*/
+  }
+}
+
+/* WG14 DR129: yes
+ * Tags and name spaces
+ */
+struct dr129_t { int i; };
+void dr129(void) {
+  enum dr129_t { enumerator }; /* expected-note {{previous use is here}} */
+  void *vp;
+
+  (void)(struct dr129_t *)vp; /* expected-error {{use of 'dr129_t' with tag 
type that does not match previous declaration}} */
+}
+
+/* WG14 DR131: yes
+ * const member qualification and assignment
+ */
+void dr131(void) {
+  struct S {
+const int i; /* expected-note {{data member 'i' declared const here}} */
+  } s1, s2;
+  s1 = s2; /* expected-error {{cannot assign to variable 's1' with 
const-qualified data member 'i'}} */
+}
+
+/* WG14 DR142: yes
+ * Reservation of macro names
+ */
+void dr142(void) {
+#include 
+/* FIXME: undefining a macro defined by the standard library is undefined
+ * behavior. We have diagnostics when declaring reserved identifiers, and we
+ * could consider extending that to undefining a macro defined in a system
+ * header. However, whether we diagnose or not, we conform.
+ */
+#undef NULL
+}
+
+/* WG14 DR144: yes
+ * Preprocessing of preprocessing directives
+ */
+#define DR144
+# DR144 include  /* expected-error {{invalid preprocessing 
directive}} */
+DR144 # include  /* expected-error {{expected identifier or '('}} */
+
+/* WG14 DR145: yes
+ * Constant expressions
+ */
+void dr145(void) {
+  static int array[10];
+  static int *ip = (int *)0;
+  static int i = array[0] + array[1]; /* expected-error {{initializer element 
is not a compile-time constant}} */
+}

diff  --git a/clang/www/c_dr_status.html b/clang/www/c_dr_status.html
index 75709d418a83..0b16bd55b299 100644
--- a/clang/www/c_dr_status.html
+++ b/clang/www/c_dr_status.html
@@ -811,25 +811,25 @@ C defect report implementation status
 https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_126.html;>126
 NAD
 What does 'synonym' mean with respect to typedef names?
-Unknown
+Yes
   
   
 https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_127.html;>127
 Dup
 Composite type of an enumerated type and an integral type
-Duplicate of 13
+Duplicate of 13
   
   
 https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_128.html;>128
 NAD
 Editorial issue relating to tag declarations in type specifiers
-Unknown
+Yes
   
   
 https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_129.html;>129
 NAD
 Tags and name spaces
-Unknown
+Yes
   
   
 https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_130.html;>130
@@ -841,19 +841,19 @@ C defect report implementation status
 https://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_131.html;>131
 C89
 const member qualification and assignment
-Unknown

[PATCH] D127873: [clang-format] Fix misplacemnt of `*` in declartion of pointer to struct

2022-06-15 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

Could you please either directly link to the github issue or better use 
llvm.org/pr55810 than just #55810 ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127873

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


[PATCH] D127873: [clang-format] Fix misplacemnt of `*` in declartion of pointer to struct

2022-06-15 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

In D127873#3586475 , @MyDeveloperDay 
wrote:

> what about (may not be useful but compiles)
>
>   struct {
>   int foo;
>   } & = {};
>
> https://godbolt.org/z/rbb8x3hKP

Let's ask why it was set to a binary operator. What kind of code would want the 
binary operator after a closing brace? I can make up such code, but we 
basically have to decide which code is probably more in use, or make the 
detection more sophisticated.




Comment at: clang/unittests/Format/TokenAnnotatorTest.cpp:93
+  EXPECT_EQ(Tokens.size(), 10u) << Tokens;
+  EXPECT_TOKEN(Tokens[6], tok::star, TT_PointerOrReference);
 }

MyDeveloperDay wrote:
> Can you add a verifyFormat test that shows what you want? as well
I think the annotator test is sufficient. Because it's just about annotating 
the token, formatting is secondary (and dependent on style - these tests are 
already in place).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127873

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


[clang-tools-extra] bc1f243 - [clangd] Improve ObjC protocol suggestions from the index

2022-06-15 Thread David Goldman via cfe-commits

Author: David Goldman
Date: 2022-06-15T15:02:37-04:00
New Revision: bc1f24332af3dedccb84a975e57adca495ea016d

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

LOG: [clangd] Improve ObjC protocol suggestions from the index

When querying the index during an ObjC protocol name lookup for code
completion, we should only suggest ObjC protocols.

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

Added: 


Modified: 
clang-tools-extra/clangd/CodeComplete.cpp
clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
clang-tools-extra/clangd/unittests/TestIndex.cpp
clang-tools-extra/clangd/unittests/TestIndex.h

Removed: 




diff  --git a/clang-tools-extra/clangd/CodeComplete.cpp 
b/clang-tools-extra/clangd/CodeComplete.cpp
index 527b6cdc304db..09e516919c807 100644
--- a/clang-tools-extra/clangd/CodeComplete.cpp
+++ b/clang-tools-extra/clangd/CodeComplete.cpp
@@ -1673,6 +1673,14 @@ class CodeCompleteFlow {
 return Output;
   }
 
+  bool includeSymbolFromIndex(const Symbol ) {
+if (CCContextKind == CodeCompletionContext::CCC_ObjCProtocolName) {
+  return Sym.SymInfo.Lang == index::SymbolLanguage::ObjC &&
+  Sym.SymInfo.Kind == index::SymbolKind::Protocol;
+}
+return true;
+  }
+
   SymbolSlab queryIndex() {
 trace::Span Tracer("Query index");
 SPAN_ATTACH(Tracer, "limit", int64_t(Opts.Limit));
@@ -1706,8 +1714,10 @@ class CodeCompleteFlow {
 
 // Run the query against the index.
 SymbolSlab::Builder ResultsBuilder;
-if (Opts.Index->fuzzyFind(
-Req, [&](const Symbol ) { ResultsBuilder.insert(Sym); }))
+if (Opts.Index->fuzzyFind(Req, [&](const Symbol ) {
+  if (includeSymbolFromIndex(Sym))
+ResultsBuilder.insert(Sym);
+}))
   Incomplete = true;
 return std::move(ResultsBuilder).build();
   }

diff  --git a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp 
b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
index 18b02af48095f..88698d3177168 100644
--- a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -3167,6 +3167,20 @@ TEST(CompletionTest, 
ObjectiveCMethodDeclarationFromMiddle) {
   EXPECT_THAT(C, ElementsAre(signature("(id)object")));
 }
 
+TEST(CompletionTest, ObjectiveCProtocolFromIndex) {
+  Symbol FoodClass = objcClass("FoodClass");
+  Symbol SymFood = objcProtocol("Food");
+  Symbol SymFooey = objcProtocol("Fooey");
+  auto Results = completions(R"objc(
+  id
+)objc",
+ {SymFood, FoodClass, SymFooey},
+ /*Opts=*/{}, "Foo.m");
+
+  auto C = Results.Completions;
+  EXPECT_THAT(C, UnorderedElementsAre(named("Food"), named("Fooey")));
+}
+
 TEST(CompletionTest, CursorInSnippets) {
   clangd::CodeCompleteOptions Options;
   Options.EnableSnippets = true;

diff  --git a/clang-tools-extra/clangd/unittests/TestIndex.cpp 
b/clang-tools-extra/clangd/unittests/TestIndex.cpp
index 3378ac856fc6d..6f7bd3aac207b 100644
--- a/clang-tools-extra/clangd/unittests/TestIndex.cpp
+++ b/clang-tools-extra/clangd/unittests/TestIndex.cpp
@@ -81,6 +81,28 @@ Symbol conceptSym(llvm::StringRef Name) {
   return sym(Name, index::SymbolKind::Concept, "@CT@\\0");
 }
 
+Symbol objcSym(llvm::StringRef Name, index::SymbolKind Kind,
+   llvm::StringRef USRPrefix) {
+  Symbol Sym;
+  std::string USR = USRPrefix.str() + Name.str();
+  Sym.Name = Name;
+  Sym.Scope = "";
+  Sym.ID = SymbolID(USR);
+  Sym.SymInfo.Kind = Kind;
+  Sym.SymInfo.Lang = index::SymbolLanguage::ObjC;
+  Sym.Flags |= Symbol::IndexedForCodeCompletion;
+  Sym.Origin = SymbolOrigin::Static;
+  return Sym;
+}
+
+Symbol objcClass(llvm::StringRef Name) {
+  return objcSym(Name, index::SymbolKind::Class, "objc(cs)");
+}
+
+Symbol objcProtocol(llvm::StringRef Name) {
+  return objcSym(Name, index::SymbolKind::Protocol, "objc(pl)");
+}
+
 SymbolSlab generateSymbols(std::vector QualifiedNames) {
   SymbolSlab::Builder Slab;
   for (llvm::StringRef QName : QualifiedNames)

diff  --git a/clang-tools-extra/clangd/unittests/TestIndex.h 
b/clang-tools-extra/clangd/unittests/TestIndex.h
index b55f82eac3292..6a4d2cb5cdd01 100644
--- a/clang-tools-extra/clangd/unittests/TestIndex.h
+++ b/clang-tools-extra/clangd/unittests/TestIndex.h
@@ -34,6 +34,14 @@ Symbol ns(llvm::StringRef Name);
 // Create a C++20 concept symbol.
 Symbol conceptSym(llvm::StringRef Name);
 
+// Create an Objective-C symbol.
+Symbol objcSym(llvm::StringRef Name, index::SymbolKind Kind,
+   llvm::StringRef USRPrefix);
+// Create an @interface or @implementation.
+Symbol objcClass(llvm::StringRef Name);
+// Create an @protocol.
+Symbol objcProtocol(llvm::StringRef Name);
+
 // Create a slab of symbols 

[PATCH] D127125: [clangd] Improve ObjC protocol suggestions from the index

2022-06-15 Thread David Goldman 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 rGbc1f24332af3: [clangd] Improve ObjC protocol suggestions 
from the index (authored by dgoldman).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127125

Files:
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang-tools-extra/clangd/unittests/TestIndex.cpp
  clang-tools-extra/clangd/unittests/TestIndex.h

Index: clang-tools-extra/clangd/unittests/TestIndex.h
===
--- clang-tools-extra/clangd/unittests/TestIndex.h
+++ clang-tools-extra/clangd/unittests/TestIndex.h
@@ -34,6 +34,14 @@
 // Create a C++20 concept symbol.
 Symbol conceptSym(llvm::StringRef Name);
 
+// Create an Objective-C symbol.
+Symbol objcSym(llvm::StringRef Name, index::SymbolKind Kind,
+   llvm::StringRef USRPrefix);
+// Create an @interface or @implementation.
+Symbol objcClass(llvm::StringRef Name);
+// Create an @protocol.
+Symbol objcProtocol(llvm::StringRef Name);
+
 // Create a slab of symbols with the given qualified names as IDs and names.
 SymbolSlab generateSymbols(std::vector QualifiedNames);
 
Index: clang-tools-extra/clangd/unittests/TestIndex.cpp
===
--- clang-tools-extra/clangd/unittests/TestIndex.cpp
+++ clang-tools-extra/clangd/unittests/TestIndex.cpp
@@ -81,6 +81,28 @@
   return sym(Name, index::SymbolKind::Concept, "@CT@\\0");
 }
 
+Symbol objcSym(llvm::StringRef Name, index::SymbolKind Kind,
+   llvm::StringRef USRPrefix) {
+  Symbol Sym;
+  std::string USR = USRPrefix.str() + Name.str();
+  Sym.Name = Name;
+  Sym.Scope = "";
+  Sym.ID = SymbolID(USR);
+  Sym.SymInfo.Kind = Kind;
+  Sym.SymInfo.Lang = index::SymbolLanguage::ObjC;
+  Sym.Flags |= Symbol::IndexedForCodeCompletion;
+  Sym.Origin = SymbolOrigin::Static;
+  return Sym;
+}
+
+Symbol objcClass(llvm::StringRef Name) {
+  return objcSym(Name, index::SymbolKind::Class, "objc(cs)");
+}
+
+Symbol objcProtocol(llvm::StringRef Name) {
+  return objcSym(Name, index::SymbolKind::Protocol, "objc(pl)");
+}
+
 SymbolSlab generateSymbols(std::vector QualifiedNames) {
   SymbolSlab::Builder Slab;
   for (llvm::StringRef QName : QualifiedNames)
Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -3167,6 +3167,20 @@
   EXPECT_THAT(C, ElementsAre(signature("(id)object")));
 }
 
+TEST(CompletionTest, ObjectiveCProtocolFromIndex) {
+  Symbol FoodClass = objcClass("FoodClass");
+  Symbol SymFood = objcProtocol("Food");
+  Symbol SymFooey = objcProtocol("Fooey");
+  auto Results = completions(R"objc(
+  id
+)objc",
+ {SymFood, FoodClass, SymFooey},
+ /*Opts=*/{}, "Foo.m");
+
+  auto C = Results.Completions;
+  EXPECT_THAT(C, UnorderedElementsAre(named("Food"), named("Fooey")));
+}
+
 TEST(CompletionTest, CursorInSnippets) {
   clangd::CodeCompleteOptions Options;
   Options.EnableSnippets = true;
Index: clang-tools-extra/clangd/CodeComplete.cpp
===
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -1673,6 +1673,14 @@
 return Output;
   }
 
+  bool includeSymbolFromIndex(const Symbol ) {
+if (CCContextKind == CodeCompletionContext::CCC_ObjCProtocolName) {
+  return Sym.SymInfo.Lang == index::SymbolLanguage::ObjC &&
+  Sym.SymInfo.Kind == index::SymbolKind::Protocol;
+}
+return true;
+  }
+
   SymbolSlab queryIndex() {
 trace::Span Tracer("Query index");
 SPAN_ATTACH(Tracer, "limit", int64_t(Opts.Limit));
@@ -1706,8 +1714,10 @@
 
 // Run the query against the index.
 SymbolSlab::Builder ResultsBuilder;
-if (Opts.Index->fuzzyFind(
-Req, [&](const Symbol ) { ResultsBuilder.insert(Sym); }))
+if (Opts.Index->fuzzyFind(Req, [&](const Symbol ) {
+  if (includeSymbolFromIndex(Sym))
+ResultsBuilder.insert(Sym);
+}))
   Incomplete = true;
 return std::move(ResultsBuilder).build();
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D125723: [MSVC] Add initial support for MSVC pragma optimize

2022-06-15 Thread Stephen Long via Phabricator via cfe-commits
steplong updated this revision to Diff 437280.
steplong added a comment.

- Fix docs


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125723

Files:
  clang/docs/LanguageExtensions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Sema/SemaAttr.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/test/CodeGen/pragma-msvc-optimize.c
  clang/test/Preprocessor/pragma_microsoft.c

Index: clang/test/Preprocessor/pragma_microsoft.c
===
--- clang/test/Preprocessor/pragma_microsoft.c
+++ clang/test/Preprocessor/pragma_microsoft.c
@@ -228,7 +228,13 @@
 #pragma optimize("g"  // expected-warning{{expected ',' in '#pragma optimize'}}
 #pragma optimize("g", // expected-warning{{missing argument to '#pragma optimize'; expected 'on' or 'off'}}
 #pragma optimize("g",xyz  // expected-warning{{unexpected argument 'xyz' to '#pragma optimize'; expected 'on' or 'off'}}
-#pragma optimize("g",on)  // expected-warning{{#pragma optimize' is not supported}}
+#pragma optimize("g",on)  // expected-warning{{unexpected argument 'g' to '#pragma optimize'; expected ""}}
+#pragma optimize("",on)  // no-warning
+#pragma optimize("", on) asdf // expected-warning{{extra tokens at end of '#pragma optimize'}}
+
+void pragma_optimize_foo() {
+#pragma optimize("", on) // expected-error {{'#pragma optimize' can only appear at file scope}}
+}
 
 #pragma execution_character_set // expected-warning {{expected '('}}
 #pragma execution_character_set(// expected-warning {{expected 'push' or 'pop'}}
Index: clang/test/CodeGen/pragma-msvc-optimize.c
===
--- /dev/null
+++ clang/test/CodeGen/pragma-msvc-optimize.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -O2 -emit-llvm -fms-extensions -o - %s | FileCheck %s
+
+#pragma optimize("", off)
+
+// CHECK: define{{.*}} void @f0(){{.*}} #[[OPTNONE:[0-9]+]]
+void f0() {}
+
+// CHECK: define{{.*}} void @f1(){{.*}} #[[OPTNONE]]
+void f1() {}
+
+#pragma optimize("", on)
+
+// CHECK: define{{.*}} void @f2(){{.*}} #[[NO_OPTNONE:[0-9]+]]
+void f2() {}
+
+// CHECK: define{{.*}} void @f3(){{.*}} #[[NO_OPTNONE]]
+void f3() {}
+
+// CHECK: attributes #[[OPTNONE]] = {{{.*}}optnone{{.*}}}
+// CHECK-NOT: attributes #[[NO_OPTNONE]] = {{{.*}}optnone{{.*}}}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -10192,6 +10192,7 @@
 AddRangeBasedOptnone(NewFD);
 AddImplicitMSFunctionNoBuiltinAttr(NewFD);
 AddSectionMSAllocText(NewFD);
+ModifyFnAttributesMSPragmaOptimize(NewFD);
   }
 
   // If this is the first declaration of an extern C variable, update
Index: clang/lib/Sema/SemaAttr.cpp
===
--- clang/lib/Sema/SemaAttr.cpp
+++ clang/lib/Sema/SemaAttr.cpp
@@ -1096,6 +1096,15 @@
 OptimizeOffPragmaLocation = PragmaLoc;
 }
 
+void Sema::ActOnPragmaMSOptimize(SourceLocation Loc, bool IsOn) {
+  if (!CurContext->getRedeclContext()->isFileContext()) {
+Diag(Loc, diag::err_pragma_expected_file_scope) << "optimize";
+return;
+  }
+
+  MSPragmaOptimizeIsOn = IsOn;
+}
+
 void Sema::ActOnPragmaMSFunction(
 SourceLocation Loc, const llvm::SmallVectorImpl ) {
   if (!CurContext->getRedeclContext()->isFileContext()) {
@@ -1129,6 +1138,13 @@
   }
 }
 
+void Sema::ModifyFnAttributesMSPragmaOptimize(FunctionDecl *FD) {
+  // Don't modify the function attributes if it's "on". "on" resets the
+  // optimizations to the ones listed on the command line
+  if (!MSPragmaOptimizeIsOn)
+AddOptnoneAttributeIfNoConflicts(FD, FD->getBeginLoc());
+}
+
 void Sema::AddOptnoneAttributeIfNoConflicts(FunctionDecl *FD,
 SourceLocation Loc) {
   // Don't add a conflicting attribute. No diagnostic is needed.
Index: clang/lib/Parse/ParsePragma.cpp
===
--- clang/lib/Parse/ParsePragma.cpp
+++ clang/lib/Parse/ParsePragma.cpp
@@ -255,12 +255,6 @@
 Token ) override;
 };
 
-struct PragmaMSOptimizeHandler : public PragmaHandler {
-  PragmaMSOptimizeHandler() : PragmaHandler("optimize") {}
-  void HandlePragma(Preprocessor , PragmaIntroducer Introducer,
-Token ) override;
-};
-
 // "\#pragma fenv_access (on)".
 struct PragmaMSFenvAccessHandler : public PragmaHandler {
   PragmaMSFenvAccessHandler() : PragmaHandler("fenv_access") {}
@@ -449,12 +443,12 @@
 PP.AddPragmaHandler(MSFunction.get());
 MSAllocText = std::make_unique("alloc_text");
 PP.AddPragmaHandler(MSAllocText.get());
+MSOptimize = 

[PATCH] D125723: [MSVC] Add initial support for MSVC pragma optimize

2022-06-15 Thread Stephen Long via Phabricator via cfe-commits
steplong added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:3800
+``g``, ``t``, and ``y``. Clang's current implementation of the pragma behaves 
in
+the same way as the clang pragma. All functions between ``off`` and ``on`` will
+be decorated with the ``optnone`` attribute.

xbolva00 wrote:
> as the clang pragma?
The clang pragma `#pragma clang optimize off`. It's mentioned in this section, 
but hmm maybe I can make it more clear


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125723

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


[PATCH] D127887: [CMake][Fuchsia] Use libunwind as the default unwinder

2022-06-15 Thread Roland McGrath via Phabricator via cfe-commits
mcgrathr accepted this revision.
mcgrathr 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/D127887/new/

https://reviews.llvm.org/D127887

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


[PATCH] D124750: [MLIR] Add a utility to sort the operands of commutative ops

2022-06-15 Thread Srishti Srivastava via Phabricator via cfe-commits
srishti-pm updated this revision to Diff 437276.
srishti-pm added a comment.

Increasing pattern benefit + minor typo correction.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124750

Files:
  mlir/include/mlir/Transforms/CommutativityUtils.h
  mlir/lib/Transforms/Utils/CMakeLists.txt
  mlir/lib/Transforms/Utils/CommutativityUtils.cpp
  mlir/test/Transforms/test-commutativity-utils.mlir
  mlir/test/lib/Dialect/Test/TestOps.td
  mlir/test/lib/Transforms/CMakeLists.txt
  mlir/test/lib/Transforms/TestCommutativityUtils.cpp
  mlir/tools/mlir-opt/mlir-opt.cpp

Index: mlir/tools/mlir-opt/mlir-opt.cpp
===
--- mlir/tools/mlir-opt/mlir-opt.cpp
+++ mlir/tools/mlir-opt/mlir-opt.cpp
@@ -57,6 +57,7 @@
 void registerVectorizerTestPass();
 
 namespace test {
+void registerCommutativityUtils();
 void registerConvertCallOpPass();
 void registerInliner();
 void registerMemRefBoundCheck();
@@ -150,6 +151,7 @@
   registerVectorizerTestPass();
   registerTosaTestQuantUtilAPIPass();
 
+  mlir::test::registerCommutativityUtils();
   mlir::test::registerConvertCallOpPass();
   mlir::test::registerInliner();
   mlir::test::registerMemRefBoundCheck();
Index: mlir/test/lib/Transforms/TestCommutativityUtils.cpp
===
--- /dev/null
+++ mlir/test/lib/Transforms/TestCommutativityUtils.cpp
@@ -0,0 +1,48 @@
+//===- TestCommutativityUtils.cpp - Pass to test the commutativity utility-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This pass tests the functionality of the commutativity utility pattern.
+//
+//===--===//
+
+#include "mlir/Transforms/CommutativityUtils.h"
+
+#include "TestDialect.h"
+#include "mlir/Pass/Pass.h"
+#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
+
+using namespace mlir;
+
+namespace {
+
+struct CommutativityUtils
+: public PassWrapper> {
+  MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(CommutativityUtils)
+
+  StringRef getArgument() const final { return "test-commutativity-utils"; }
+  StringRef getDescription() const final {
+return "Test the functionality of the commutativity utility";
+  }
+
+  void runOnOperation() override {
+auto func = getOperation();
+auto *context = ();
+
+RewritePatternSet patterns(context);
+populateCommutativityUtilsPatterns(patterns);
+
+(void)applyPatternsAndFoldGreedily(func, std::move(patterns));
+  }
+};
+} // namespace
+
+namespace mlir {
+namespace test {
+void registerCommutativityUtils() { PassRegistration(); }
+} // namespace test
+} // namespace mlir
Index: mlir/test/lib/Transforms/CMakeLists.txt
===
--- mlir/test/lib/Transforms/CMakeLists.txt
+++ mlir/test/lib/Transforms/CMakeLists.txt
@@ -1,5 +1,6 @@
 # Exclude tests from libMLIR.so
 add_mlir_library(MLIRTestTransforms
+  TestCommutativityUtils.cpp
   TestConstantFold.cpp
   TestControlFlowSink.cpp
   TestInlining.cpp
Index: mlir/test/lib/Dialect/Test/TestOps.td
===
--- mlir/test/lib/Dialect/Test/TestOps.td
+++ mlir/test/lib/Dialect/Test/TestOps.td
@@ -1172,11 +1172,21 @@
   let hasFolder = 1;
 }
 
+def TestAddIOp : TEST_Op<"addi"> {
+  let arguments = (ins I32:$op1, I32:$op2);
+  let results = (outs I32);
+}
+
 def TestCommutativeOp : TEST_Op<"op_commutative", [Commutative]> {
   let arguments = (ins I32:$op1, I32:$op2, I32:$op3, I32:$op4);
   let results = (outs I32);
 }
 
+def TestLargeCommutativeOp : TEST_Op<"op_large_commutative", [Commutative]> {
+  let arguments = (ins I32:$op1, I32:$op2, I32:$op3, I32:$op4, I32:$op5, I32:$op6, I32:$op7);
+  let results = (outs I32);
+}
+
 def TestCommutative2Op : TEST_Op<"op_commutative2", [Commutative]> {
   let arguments = (ins I32:$op1, I32:$op2);
   let results = (outs I32);
Index: mlir/test/Transforms/test-commutativity-utils.mlir
===
--- /dev/null
+++ mlir/test/Transforms/test-commutativity-utils.mlir
@@ -0,0 +1,116 @@
+// RUN: mlir-opt %s -test-commutativity-utils | FileCheck %s
+
+// CHECK-LABEL: @test_small_pattern_1
+func.func @test_small_pattern_1(%arg0 : i32) -> i32 {
+  // CHECK-NEXT: %[[ARITH_CONST:.*]] = arith.constant
+  %0 = arith.constant 45 : i32
+
+  // CHECK-NEXT: %[[TEST_ADD:.*]] = "test.addi"
+  %1 = "test.addi"(%arg0, %arg0): (i32, i32) -> i32
+
+  // CHECK-NEXT: %[[ARITH_ADD:.*]] = arith.addi
+  %2 = arith.addi %arg0, %arg0 : i32
+
+  // CHECK-NEXT: %[[ARITH_MUL:.*]] = arith.muli
+  %3 = arith.muli 

[PATCH] D127886: [clang-tidy] Allow access to the SourceManager in clang-tidy checks

2022-06-15 Thread Nicolas van Kempen via Phabricator via cfe-commits
nicovank planned changes to this revision.
nicovank added a comment.

Thanks! Looks like `registerPPCallbacks` might be what I am looking for, I was 
not aware of it. I will mark this as planning changes temporarily, then abandon 
if solved.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127886

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


[PATCH] D127886: [clang-tidy] Allow access to the SourceManager in clang-tidy checks

2022-06-15 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added a comment.

Could you provide more context? There seems to be plenty of ways to access the 
SourceManager from a ClangTidy check, for example, see 
`clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127886

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


[PATCH] D127888: [clang][WebAssembly] Loosen restriction on `main` symbol mangling

2022-06-15 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 updated this revision to Diff 437272.
sbc100 edited the summary of this revision.
sbc100 added a comment.
Herald added a subscriber: asb.

add tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127888

Files:
  clang/lib/AST/Mangle.cpp
  clang/test/CodeGen/mangle-wasm-main-noproto.c
  clang/test/CodeGen/mangle-wasm-main-void.c
  clang/test/CodeGen/mangle-wasm-main.c


Index: clang/test/CodeGen/mangle-wasm-main.c
===
--- /dev/null
+++ clang/test/CodeGen/mangle-wasm-main.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=wasm32-unknown-unknown | 
FileCheck %s
+
+int main(int argc, char* argv[]) {
+  return 0;
+}
+// CHECK-NOT: __main_void
+// CHECK: define i32 @__main_argc_argv(i32 noundef %argc, ptr noundef %argv) 
#0 { 
Index: clang/test/CodeGen/mangle-wasm-main-void.c
===
--- /dev/null
+++ clang/test/CodeGen/mangle-wasm-main-void.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=wasm32-unknown-unknown | 
FileCheck %s
+
+int main(void) {
+  return 0;
+}
+// CHECK: @__main_void = hidden alias i32 (), ptr @main
+// CHECK: define i32 @main() #0 {
Index: clang/test/CodeGen/mangle-wasm-main-noproto.c
===
--- /dev/null
+++ clang/test/CodeGen/mangle-wasm-main-noproto.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=wasm32-unknown-unknown 
-Wno-deprecated-non-prototype | FileCheck %s
+
+int main(argc, argv)
+  int argc;
+  char* argv[];
+{
+  return 0;
+}
+// CHECK-NOT: __main_void
+// CHECK: define i32 @__main_argc_argv(i32 noundef %argc, ptr noundef %argv) 
#0 { 
Index: clang/lib/AST/Mangle.cpp
===
--- clang/lib/AST/Mangle.cpp
+++ clang/lib/AST/Mangle.cpp
@@ -72,7 +72,7 @@
   // can call it with the correct function signature.
   if (Triple.isWasm())
 if (const FunctionDecl *FD = dyn_cast(ND))
-  if (FD->isMain() && FD->hasPrototype() && FD->param_size() == 2)
+  if (FD->isMain() && FD->getNumParams() == 2)
 return CCM_WasmMainArgcArgv;
 
   if (!Triple.isOSWindows() || !Triple.isX86())


Index: clang/test/CodeGen/mangle-wasm-main.c
===
--- /dev/null
+++ clang/test/CodeGen/mangle-wasm-main.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=wasm32-unknown-unknown | FileCheck %s
+
+int main(int argc, char* argv[]) {
+  return 0;
+}
+// CHECK-NOT: __main_void
+// CHECK: define i32 @__main_argc_argv(i32 noundef %argc, ptr noundef %argv) #0 { 
Index: clang/test/CodeGen/mangle-wasm-main-void.c
===
--- /dev/null
+++ clang/test/CodeGen/mangle-wasm-main-void.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=wasm32-unknown-unknown | FileCheck %s
+
+int main(void) {
+  return 0;
+}
+// CHECK: @__main_void = hidden alias i32 (), ptr @main
+// CHECK: define i32 @main() #0 {
Index: clang/test/CodeGen/mangle-wasm-main-noproto.c
===
--- /dev/null
+++ clang/test/CodeGen/mangle-wasm-main-noproto.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=wasm32-unknown-unknown -Wno-deprecated-non-prototype | FileCheck %s
+
+int main(argc, argv)
+  int argc;
+  char* argv[];
+{
+  return 0;
+}
+// CHECK-NOT: __main_void
+// CHECK: define i32 @__main_argc_argv(i32 noundef %argc, ptr noundef %argv) #0 { 
Index: clang/lib/AST/Mangle.cpp
===
--- clang/lib/AST/Mangle.cpp
+++ clang/lib/AST/Mangle.cpp
@@ -72,7 +72,7 @@
   // can call it with the correct function signature.
   if (Triple.isWasm())
 if (const FunctionDecl *FD = dyn_cast(ND))
-  if (FD->isMain() && FD->hasPrototype() && FD->param_size() == 2)
+  if (FD->isMain() && FD->getNumParams() == 2)
 return CCM_WasmMainArgcArgv;
 
   if (!Triple.isOSWindows() || !Triple.isX86())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D127890: [Docs] Update clang & llvm release notes for HLSL

2022-06-15 Thread Chris Bieneman via Phabricator via cfe-commits
beanz created this revision.
beanz added reviewers: tstellar, aaron.ballman, MaskRay, hans.
Herald added subscribers: Anastasia, StephenFan.
Herald added a project: All.
beanz requested review of this revision.
Herald added projects: clang, LLVM.

Adding release note entries for LLVM & Clang to introduce the HLSL &
DirectX support that is being added.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D127890

Files:
  clang/docs/ReleaseNotes.rst
  llvm/docs/ReleaseNotes.rst


Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -110,6 +110,17 @@
 
 * ...
 
+Changes to the DirectX Backend
+--
+
+* An experimental DirectX backend has been introduced to the LLVM tree. It is
+  not packaged with any of the pre-built releases but can be built from source
+  by adding ``-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=DirectX`` to your build
+  configuration step.
+* The DirectX backend supports the ``dxil`` architecture which is based on LLVM
+  3.6 IR encoded as bitcode and is the format used for DirectX GPU Shader
+  programs.
+
 Changes to the Hexagon Backend
 --
 
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -68,6 +68,13 @@
 
   Randomizing structure layout is a C-only feature.
 
+- Clang is gaining support for HLSL. Basic features for the HLSL language have
+  started being merged during Clang-15 development, but the implementation is
+  incomplete and highly experimental. For more information about the ongoing
+  work to support HLSL see the `Clang documentation
+  `_, or `GitHub project
+  `_.
+
 Bug Fixes
 -
 - ``CXXNewExpr::getArraySize()`` previously returned a ``llvm::Optional``


Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -110,6 +110,17 @@
 
 * ...
 
+Changes to the DirectX Backend
+--
+
+* An experimental DirectX backend has been introduced to the LLVM tree. It is
+  not packaged with any of the pre-built releases but can be built from source
+  by adding ``-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=DirectX`` to your build
+  configuration step.
+* The DirectX backend supports the ``dxil`` architecture which is based on LLVM
+  3.6 IR encoded as bitcode and is the format used for DirectX GPU Shader
+  programs.
+
 Changes to the Hexagon Backend
 --
 
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -68,6 +68,13 @@
 
   Randomizing structure layout is a C-only feature.
 
+- Clang is gaining support for HLSL. Basic features for the HLSL language have
+  started being merged during Clang-15 development, but the implementation is
+  incomplete and highly experimental. For more information about the ongoing
+  work to support HLSL see the `Clang documentation
+  `_, or `GitHub project
+  `_.
+
 Bug Fixes
 -
 - ``CXXNewExpr::getArraySize()`` previously returned a ``llvm::Optional``
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D127886: [clang-tidy] Allow access to the SourceManager in clang-tidy checks

2022-06-15 Thread Nicolas van Kempen via Phabricator via cfe-commits
nicovank created this revision.
Herald added subscribers: carlosgalvezp, xazax.hun.
Herald added a project: All.
nicovank added reviewers: alexfh, aaron.ballman, njames93.
nicovank published this revision for review.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

I am writing a prototype check that needs source file and line numbers to map 
code to external data. As far as I know, the only way to achieve that is to 
expose the SourceManager which is so far only used to emit diagnostics.

Test Plan:
On a blank new check, 
`MatchedDecl->getBeginLoc().dump(Context->getSourceManager());` does properly 
show the matched declaration's origin filename and line number.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D127886

Files:
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h


Index: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
===
--- clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
+++ clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
@@ -121,6 +121,9 @@
   /// This is called from the \c ClangTidyCheck base class.
   void setSourceManager(SourceManager *SourceMgr);
 
+  /// Gets the \c SourceManager from the used \c DiagnosticsEngine.
+  SourceManager ();
+
   /// Should be called when starting to process new translation unit.
   void setCurrentFile(StringRef File);
 
Index: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
===
--- clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -221,6 +221,10 @@
   DiagEngine->setSourceManager(SourceMgr);
 }
 
+SourceManager ::getSourceManager() {
+  return DiagEngine->getSourceManager();
+}
+
 void ClangTidyContext::setCurrentFile(StringRef File) {
   CurrentFile = std::string(File);
   CurrentOptions = getOptionsForFile(CurrentFile);


Index: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
===
--- clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
+++ clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
@@ -121,6 +121,9 @@
   /// This is called from the \c ClangTidyCheck base class.
   void setSourceManager(SourceManager *SourceMgr);
 
+  /// Gets the \c SourceManager from the used \c DiagnosticsEngine.
+  SourceManager ();
+
   /// Should be called when starting to process new translation unit.
   void setCurrentFile(StringRef File);
 
Index: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
===
--- clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -221,6 +221,10 @@
   DiagEngine->setSourceManager(SourceMgr);
 }
 
+SourceManager ::getSourceManager() {
+  return DiagEngine->getSourceManager();
+}
+
 void ClangTidyContext::setCurrentFile(StringRef File) {
   CurrentFile = std::string(File);
   CurrentOptions = getOptionsForFile(CurrentFile);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D127888: [clang][WebAssembly] Loosen restriction on `main` symbol mangling

2022-06-15 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 created this revision.
Herald added subscribers: pmatos, wingo, ecnelises, sunfish, jgravelle-google, 
dschuff.
Herald added a project: All.
sbc100 requested review of this revision.
Herald added subscribers: cfe-commits, aheejin.
Herald added a project: clang.

Remove the `hasPrototype()` restriction so that old style K
declarations of main work too.

For example the following has 2 params but no prototype.

  int main(argc, argv)
  int argc;
  char *argv[];
  {
return 0;
  }

Also, use `getNumParams()` over `param_size()` which seems to be a more
direct way to get at the same information.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D127888

Files:
  clang/lib/AST/Mangle.cpp


Index: clang/lib/AST/Mangle.cpp
===
--- clang/lib/AST/Mangle.cpp
+++ clang/lib/AST/Mangle.cpp
@@ -72,7 +72,7 @@
   // can call it with the correct function signature.
   if (Triple.isWasm())
 if (const FunctionDecl *FD = dyn_cast(ND))
-  if (FD->isMain() && FD->hasPrototype() && FD->param_size() == 2)
+  if (FD->isMain() && FD->getNumParams() == 2)
 return CCM_WasmMainArgcArgv;
 
   if (!Triple.isOSWindows() || !Triple.isX86())


Index: clang/lib/AST/Mangle.cpp
===
--- clang/lib/AST/Mangle.cpp
+++ clang/lib/AST/Mangle.cpp
@@ -72,7 +72,7 @@
   // can call it with the correct function signature.
   if (Triple.isWasm())
 if (const FunctionDecl *FD = dyn_cast(ND))
-  if (FD->isMain() && FD->hasPrototype() && FD->param_size() == 2)
+  if (FD->isMain() && FD->getNumParams() == 2)
 return CCM_WasmMainArgcArgv;
 
   if (!Triple.isOSWindows() || !Triple.isX86())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D127876: [clang] Don't emit type test/assume for virtual classes that should never participate in WPD

2022-06-15 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

I prefer the way proposed here, which was what I initially intended to do in 
fact. @pcc, I recall from our early internal conversations about my proposal 
that you felt the new mechanism should apply to all classes, so that's why the 
final design did that. I do tend to think that if the source code has 
specifically annotated the classes with public LTO visibility it is better to 
enforce that always. I think revisiting this decision is worthwhile.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127876

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


[PATCH] D127873: [clang-format] Fix misplacemnt of `*` in declartion of pointer to struct

2022-06-15 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay requested changes to this revision.
MyDeveloperDay added a comment.
This revision now requires changes to proceed.

Thank you for the patch, just some observations




Comment at: clang/unittests/Format/TokenAnnotatorTest.cpp:93
+  EXPECT_EQ(Tokens.size(), 10u) << Tokens;
+  EXPECT_TOKEN(Tokens[6], tok::star, TT_PointerOrReference);
 }

Can you add a verifyFormat test that shows what you want? as well


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127873

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


[PATCH] D127873: [clang-format] Fix misplacemnt of `*` in declartion of pointer to struct

2022-06-15 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

what about (may not be useful but compiles)

  struct {
  int foo;
  } & = {};

https://godbolt.org/z/rbb8x3hKP


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127873

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


[PATCH] D125723: [MSVC] Add initial support for MSVC pragma optimize

2022-06-15 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

Thanks




Comment at: clang/docs/LanguageExtensions.rst:3800
+``g``, ``t``, and ``y``. Clang's current implementation of the pragma behaves 
in
+the same way as the clang pragma. All functions between ``off`` and ``on`` will
+be decorated with the ``optnone`` attribute.

as the clang pragma?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125723

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


[PATCH] D127579: [clang][WIP] add option to keep types of ptr args for non-kernel functions in metadata

2022-06-15 Thread Joshua Cranmer via Phabricator via cfe-commits
jcranmer-intel added a comment.

In D127579#3585553 , @bader wrote:

> And in addition to that ISA defines types, which are not natively supported 
> by LLVM IR e.g. image. To represent those types clang in OpenCL language mode 
> emits a pointer to an opaque structure with special name like 
> opencl. (e.g. opencl.image2d_t). All ISA types, which are 
> defined that way look the same with type-less pointers.
> https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/OpenCLImageTypes.def

One of the important facts about these types is that the SPIR-V specification 
doesn't let you actually cast between these types and other types such as 
integers. (Which is an issue because I've just come across a testcase where, in 
opaque pointer mode, an OpenCL event type is being used in a `ptrtoint` to 
store to a variable as an `i64`, which I can't legally translate to SPIR-V.) Of 
course, this probably means that these types need to have their representation 
in LLVM changed entirely, but I haven't yet done the legwork to experiment in 
that mode.

I haven't yet tested whether or not this patch is sufficient to support all of 
the use cases I need for type scavenging for SPIR-V, but one of the things I do 
see is that there's no support for return type information, which may be a bit 
of an issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127579

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


[PATCH] D126479: [Clang] Allow 'Complex float __attribute__((mode(HC)))'

2022-06-15 Thread Tom Honermann via Phabricator via cfe-commits
tahonermann accepted this revision.
tahonermann added a comment.
This revision is now accepted and ready to land.

Looks good to me! Thanks Jolanta!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126479

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


[clang] 55ba083 - [Clang] Let the linker choose shared or static libunwind unless specified

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

Author: Petr Hosek
Date: 2022-06-15T18:22:13Z
New Revision: 55ba0830e4591c9767bbd4530639976f1242a61a

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

LOG: [Clang] Let the linker choose shared or static libunwind unless specified

We shouldn't assume that libunwind.so is available. Rather can defer
the decision to the linker which defaults to libunwind.so, but if .so
isn't available, it'd pick libunwind.a. Users can use -static-libgcc
and -shared-libgcc to override this behavior and explicitly choose
the version they want.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/test/Driver/compiler-rt-unwind.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index accf79f767249..e2437e5787fd7 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1462,17 +1462,12 @@ enum class LibGccType { UnspecifiedLibGcc, 
StaticLibGcc, SharedLibGcc };
 static LibGccType getLibGccType(const ToolChain , const Driver ,
 const ArgList ) {
   if (Args.hasArg(options::OPT_static_libgcc) ||
-  Args.hasArg(options::OPT_static) || Args.hasArg(options::OPT_static_pie))
+  Args.hasArg(options::OPT_static) || Args.hasArg(options::OPT_static_pie) 
||
+  // The Android NDK only provides libunwind.a, not libunwind.so.
+  TC.getTriple().isAndroid())
 return LibGccType::StaticLibGcc;
   if (Args.hasArg(options::OPT_shared_libgcc))
 return LibGccType::SharedLibGcc;
-  // The Android NDK only provides libunwind.a, not libunwind.so.
-  if (TC.getTriple().isAndroid())
-return LibGccType::StaticLibGcc;
-  // For MinGW, don't imply a shared libgcc here, we only want to return
-  // SharedLibGcc if that was explicitly requested.
-  if (D.CCCIsCXX() && !TC.getTriple().isOSCygMing())
-return LibGccType::SharedLibGcc;
   return LibGccType::UnspecifiedLibGcc;
 }
 
@@ -1499,7 +1494,7 @@ static void AddUnwindLibrary(const ToolChain , const 
Driver ,
 return;
 
   LibGccType LGT = getLibGccType(TC, D, Args);
-  bool AsNeeded = LGT == LibGccType::UnspecifiedLibGcc &&
+  bool AsNeeded = LGT == LibGccType::UnspecifiedLibGcc && !D.CCCIsCXX() &&
   !TC.getTriple().isAndroid() &&
   !TC.getTriple().isOSCygMing() && !TC.getTriple().isOSAIX();
   if (AsNeeded)
@@ -1523,15 +1518,15 @@ static void AddUnwindLibrary(const ToolChain , const 
Driver ,
 CmdArgs.push_back("-lunwind");
 } else if (LGT == LibGccType::StaticLibGcc) {
   CmdArgs.push_back("-l:libunwind.a");
-} else if (TC.getTriple().isOSCygMing()) {
-  if (LGT == LibGccType::SharedLibGcc)
+} else if (LGT == LibGccType::SharedLibGcc) {
+  if (TC.getTriple().isOSCygMing())
 CmdArgs.push_back("-l:libunwind.dll.a");
   else
-// Let the linker choose between libunwind.dll.a and libunwind.a
-// depending on what's available, and depending on the -static flag
-CmdArgs.push_back("-lunwind");
+CmdArgs.push_back("-l:libunwind.so");
 } else {
-  CmdArgs.push_back("-l:libunwind.so");
+  // Let the linker choose between libunwind.so and libunwind.a
+  // depending on what's available, and depending on the -static flag
+  CmdArgs.push_back("-lunwind");
 }
 break;
   }
@@ -1543,10 +1538,12 @@ static void AddUnwindLibrary(const ToolChain , const 
Driver ,
 static void AddLibgcc(const ToolChain , const Driver ,
   ArgStringList , const ArgList ) {
   LibGccType LGT = getLibGccType(TC, D, Args);
-  if (LGT != LibGccType::SharedLibGcc)
+  if (LGT == LibGccType::StaticLibGcc ||
+  (LGT == LibGccType::UnspecifiedLibGcc && !D.CCCIsCXX()))
 CmdArgs.push_back("-lgcc");
   AddUnwindLibrary(TC, D, CmdArgs, Args);
-  if (LGT == LibGccType::SharedLibGcc)
+  if (LGT == LibGccType::SharedLibGcc ||
+  (LGT == LibGccType::UnspecifiedLibGcc && D.CCCIsCXX()))
 CmdArgs.push_back("-lgcc");
 }
 

diff  --git a/clang/test/Driver/compiler-rt-unwind.c 
b/clang/test/Driver/compiler-rt-unwind.c
index 2772bc8ce07c1..85c8db973de88 100644
--- a/clang/test/Driver/compiler-rt-unwind.c
+++ b/clang/test/Driver/compiler-rt-unwind.c
@@ -13,7 +13,15 @@
 // RUN: --gcc-toolchain="" -resource-dir=%S/Inputs/resource_dir \
 // RUN:   | FileCheck --check-prefix=RTLIB-GCC-UNWINDLIB-COMPILER-RT %s
 // RTLIB-GCC-UNWINDLIB-COMPILER-RT: "{{.*}}lgcc"
-// RTLIB-GCC-UNWINDLIB-COMPILER-RT: "{{.*}}l:libunwind.so"
+// RTLIB-GCC-UNWINDLIB-COMPILER-RT: "{{.*}}lunwind"
+//
+// RUN: %clang -### %s 2>&1 \
+// RUN: --target=x86_64-unknown-linux -rtlib=libgcc --unwindlib=libunwind \
+// RUN: 

[PATCH] D127528: [Clang] Let the linker choose shared or static libunwind unless specified

2022-06-15 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 rG55ba0830e459: [Clang] Let the linker choose shared or static 
libunwind unless specified (authored by phosek).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127528

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/compiler-rt-unwind.c


Index: clang/test/Driver/compiler-rt-unwind.c
===
--- clang/test/Driver/compiler-rt-unwind.c
+++ clang/test/Driver/compiler-rt-unwind.c
@@ -13,7 +13,15 @@
 // RUN: --gcc-toolchain="" -resource-dir=%S/Inputs/resource_dir \
 // RUN:   | FileCheck --check-prefix=RTLIB-GCC-UNWINDLIB-COMPILER-RT %s
 // RTLIB-GCC-UNWINDLIB-COMPILER-RT: "{{.*}}lgcc"
-// RTLIB-GCC-UNWINDLIB-COMPILER-RT: "{{.*}}l:libunwind.so"
+// RTLIB-GCC-UNWINDLIB-COMPILER-RT: "{{.*}}lunwind"
+//
+// RUN: %clang -### %s 2>&1 \
+// RUN: --target=x86_64-unknown-linux -rtlib=libgcc --unwindlib=libunwind \
+// RUN: -shared-libgcc \
+// RUN: --gcc-toolchain="" -resource-dir=%S/Inputs/resource_dir \
+// RUN:   | FileCheck --check-prefix=RTLIB-GCC-SHARED-UNWINDLIB-COMPILER-RT %s
+// RTLIB-GCC-SHARED-UNWINDLIB-COMPILER-RT: "{{.*}}l:libunwind.so"
+// RTLIB-GCC-SHARED-UNWINDLIB-COMPILER-RT: "{{.*}}lgcc"
 //
 // RUN: %clang -### %s 2>&1 \
 // RUN: --target=x86_64-unknown-linux -rtlib=libgcc --unwindlib=libunwind \
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1462,17 +1462,12 @@
 static LibGccType getLibGccType(const ToolChain , const Driver ,
 const ArgList ) {
   if (Args.hasArg(options::OPT_static_libgcc) ||
-  Args.hasArg(options::OPT_static) || Args.hasArg(options::OPT_static_pie))
+  Args.hasArg(options::OPT_static) || Args.hasArg(options::OPT_static_pie) 
||
+  // The Android NDK only provides libunwind.a, not libunwind.so.
+  TC.getTriple().isAndroid())
 return LibGccType::StaticLibGcc;
   if (Args.hasArg(options::OPT_shared_libgcc))
 return LibGccType::SharedLibGcc;
-  // The Android NDK only provides libunwind.a, not libunwind.so.
-  if (TC.getTriple().isAndroid())
-return LibGccType::StaticLibGcc;
-  // For MinGW, don't imply a shared libgcc here, we only want to return
-  // SharedLibGcc if that was explicitly requested.
-  if (D.CCCIsCXX() && !TC.getTriple().isOSCygMing())
-return LibGccType::SharedLibGcc;
   return LibGccType::UnspecifiedLibGcc;
 }
 
@@ -1499,7 +1494,7 @@
 return;
 
   LibGccType LGT = getLibGccType(TC, D, Args);
-  bool AsNeeded = LGT == LibGccType::UnspecifiedLibGcc &&
+  bool AsNeeded = LGT == LibGccType::UnspecifiedLibGcc && !D.CCCIsCXX() &&
   !TC.getTriple().isAndroid() &&
   !TC.getTriple().isOSCygMing() && !TC.getTriple().isOSAIX();
   if (AsNeeded)
@@ -1523,15 +1518,15 @@
 CmdArgs.push_back("-lunwind");
 } else if (LGT == LibGccType::StaticLibGcc) {
   CmdArgs.push_back("-l:libunwind.a");
-} else if (TC.getTriple().isOSCygMing()) {
-  if (LGT == LibGccType::SharedLibGcc)
+} else if (LGT == LibGccType::SharedLibGcc) {
+  if (TC.getTriple().isOSCygMing())
 CmdArgs.push_back("-l:libunwind.dll.a");
   else
-// Let the linker choose between libunwind.dll.a and libunwind.a
-// depending on what's available, and depending on the -static flag
-CmdArgs.push_back("-lunwind");
+CmdArgs.push_back("-l:libunwind.so");
 } else {
-  CmdArgs.push_back("-l:libunwind.so");
+  // Let the linker choose between libunwind.so and libunwind.a
+  // depending on what's available, and depending on the -static flag
+  CmdArgs.push_back("-lunwind");
 }
 break;
   }
@@ -1543,10 +1538,12 @@
 static void AddLibgcc(const ToolChain , const Driver ,
   ArgStringList , const ArgList ) {
   LibGccType LGT = getLibGccType(TC, D, Args);
-  if (LGT != LibGccType::SharedLibGcc)
+  if (LGT == LibGccType::StaticLibGcc ||
+  (LGT == LibGccType::UnspecifiedLibGcc && !D.CCCIsCXX()))
 CmdArgs.push_back("-lgcc");
   AddUnwindLibrary(TC, D, CmdArgs, Args);
-  if (LGT == LibGccType::SharedLibGcc)
+  if (LGT == LibGccType::SharedLibGcc ||
+  (LGT == LibGccType::UnspecifiedLibGcc && D.CCCIsCXX()))
 CmdArgs.push_back("-lgcc");
 }
 


Index: clang/test/Driver/compiler-rt-unwind.c
===
--- clang/test/Driver/compiler-rt-unwind.c
+++ clang/test/Driver/compiler-rt-unwind.c
@@ -13,7 +13,15 @@
 // RUN: --gcc-toolchain="" -resource-dir=%S/Inputs/resource_dir \
 // RUN:   | FileCheck --check-prefix=RTLIB-GCC-UNWINDLIB-COMPILER-RT %s
 // 

[PATCH] D127887: [CMake][Fuchsia] Use libunwind as the default unwinder

2022-06-15 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added reviewers: abrachet, mcgrathr.
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.

Fuchsia already uses libunwind, but it does so implicitly via libc++. This 
change
makes the unwinder choice explicit.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D127887

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


Index: clang/cmake/caches/Fuchsia.cmake
===
--- clang/cmake/caches/Fuchsia.cmake
+++ clang/cmake/caches/Fuchsia.cmake
@@ -26,6 +26,7 @@
 set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
 set(CLANG_DEFAULT_OBJCOPY llvm-objcopy CACHE STRING "")
 set(CLANG_DEFAULT_RTLIB compiler-rt CACHE STRING "")
+set(CLANG_DEFAULT_UNWINDLIB libunwind CACHE STRING "")
 set(CLANG_ENABLE_ARCMT OFF CACHE BOOL "")
 set(CLANG_ENABLE_STATIC_ANALYZER OFF CACHE BOOL "")
 set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -32,6 +32,7 @@
 set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
 set(CLANG_DEFAULT_OBJCOPY llvm-objcopy CACHE STRING "")
 set(CLANG_DEFAULT_RTLIB compiler-rt CACHE STRING "")
+set(CLANG_DEFAULT_UNWINDLIB libunwind CACHE STRING "")
 set(CLANG_ENABLE_ARCMT OFF CACHE BOOL "")
 set(CLANG_ENABLE_STATIC_ANALYZER ON CACHE BOOL "")
 set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")


Index: clang/cmake/caches/Fuchsia.cmake
===
--- clang/cmake/caches/Fuchsia.cmake
+++ clang/cmake/caches/Fuchsia.cmake
@@ -26,6 +26,7 @@
 set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
 set(CLANG_DEFAULT_OBJCOPY llvm-objcopy CACHE STRING "")
 set(CLANG_DEFAULT_RTLIB compiler-rt CACHE STRING "")
+set(CLANG_DEFAULT_UNWINDLIB libunwind CACHE STRING "")
 set(CLANG_ENABLE_ARCMT OFF CACHE BOOL "")
 set(CLANG_ENABLE_STATIC_ANALYZER OFF CACHE BOOL "")
 set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -32,6 +32,7 @@
 set(CLANG_DEFAULT_LINKER lld CACHE STRING "")
 set(CLANG_DEFAULT_OBJCOPY llvm-objcopy CACHE STRING "")
 set(CLANG_DEFAULT_RTLIB compiler-rt CACHE STRING "")
+set(CLANG_DEFAULT_UNWINDLIB libunwind CACHE STRING "")
 set(CLANG_ENABLE_ARCMT OFF CACHE BOOL "")
 set(CLANG_ENABLE_STATIC_ANALYZER ON CACHE BOOL "")
 set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D125723: [MSVC] Add initial support for MSVC pragma optimize

2022-06-15 Thread Stephen Long via Phabricator via cfe-commits
steplong updated this revision to Diff 437260.
steplong added a comment.

- Add documentation on difference btwn MSVC and Clang's implementation of 
pragma optimize


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125723

Files:
  clang/docs/LanguageExtensions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Sema/SemaAttr.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/test/CodeGen/pragma-msvc-optimize.c
  clang/test/Preprocessor/pragma_microsoft.c

Index: clang/test/Preprocessor/pragma_microsoft.c
===
--- clang/test/Preprocessor/pragma_microsoft.c
+++ clang/test/Preprocessor/pragma_microsoft.c
@@ -228,7 +228,13 @@
 #pragma optimize("g"  // expected-warning{{expected ',' in '#pragma optimize'}}
 #pragma optimize("g", // expected-warning{{missing argument to '#pragma optimize'; expected 'on' or 'off'}}
 #pragma optimize("g",xyz  // expected-warning{{unexpected argument 'xyz' to '#pragma optimize'; expected 'on' or 'off'}}
-#pragma optimize("g",on)  // expected-warning{{#pragma optimize' is not supported}}
+#pragma optimize("g",on)  // expected-warning{{unexpected argument 'g' to '#pragma optimize'; expected ""}}
+#pragma optimize("",on)  // no-warning
+#pragma optimize("", on) asdf // expected-warning{{extra tokens at end of '#pragma optimize'}}
+
+void pragma_optimize_foo() {
+#pragma optimize("", on) // expected-error {{'#pragma optimize' can only appear at file scope}}
+}
 
 #pragma execution_character_set // expected-warning {{expected '('}}
 #pragma execution_character_set(// expected-warning {{expected 'push' or 'pop'}}
Index: clang/test/CodeGen/pragma-msvc-optimize.c
===
--- /dev/null
+++ clang/test/CodeGen/pragma-msvc-optimize.c
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -O2 -emit-llvm -fms-extensions -o - %s | FileCheck %s
+
+#pragma optimize("", off)
+
+// CHECK: define{{.*}} void @f0(){{.*}} #[[OPTNONE:[0-9]+]]
+void f0() {}
+
+// CHECK: define{{.*}} void @f1(){{.*}} #[[OPTNONE]]
+void f1() {}
+
+#pragma optimize("", on)
+
+// CHECK: define{{.*}} void @f2(){{.*}} #[[NO_OPTNONE:[0-9]+]]
+void f2() {}
+
+// CHECK: define{{.*}} void @f3(){{.*}} #[[NO_OPTNONE]]
+void f3() {}
+
+// CHECK: attributes #[[OPTNONE]] = {{{.*}}optnone{{.*}}}
+// CHECK-NOT: attributes #[[NO_OPTNONE]] = {{{.*}}optnone{{.*}}}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -10192,6 +10192,7 @@
 AddRangeBasedOptnone(NewFD);
 AddImplicitMSFunctionNoBuiltinAttr(NewFD);
 AddSectionMSAllocText(NewFD);
+ModifyFnAttributesMSPragmaOptimize(NewFD);
   }
 
   // If this is the first declaration of an extern C variable, update
Index: clang/lib/Sema/SemaAttr.cpp
===
--- clang/lib/Sema/SemaAttr.cpp
+++ clang/lib/Sema/SemaAttr.cpp
@@ -1096,6 +1096,15 @@
 OptimizeOffPragmaLocation = PragmaLoc;
 }
 
+void Sema::ActOnPragmaMSOptimize(SourceLocation Loc, bool IsOn) {
+  if (!CurContext->getRedeclContext()->isFileContext()) {
+Diag(Loc, diag::err_pragma_expected_file_scope) << "optimize";
+return;
+  }
+
+  MSPragmaOptimizeIsOn = IsOn;
+}
+
 void Sema::ActOnPragmaMSFunction(
 SourceLocation Loc, const llvm::SmallVectorImpl ) {
   if (!CurContext->getRedeclContext()->isFileContext()) {
@@ -1129,6 +1138,13 @@
   }
 }
 
+void Sema::ModifyFnAttributesMSPragmaOptimize(FunctionDecl *FD) {
+  // Don't modify the function attributes if it's "on". "on" resets the
+  // optimizations to the ones listed on the command line
+  if (!MSPragmaOptimizeIsOn)
+AddOptnoneAttributeIfNoConflicts(FD, FD->getBeginLoc());
+}
+
 void Sema::AddOptnoneAttributeIfNoConflicts(FunctionDecl *FD,
 SourceLocation Loc) {
   // Don't add a conflicting attribute. No diagnostic is needed.
Index: clang/lib/Parse/ParsePragma.cpp
===
--- clang/lib/Parse/ParsePragma.cpp
+++ clang/lib/Parse/ParsePragma.cpp
@@ -255,12 +255,6 @@
 Token ) override;
 };
 
-struct PragmaMSOptimizeHandler : public PragmaHandler {
-  PragmaMSOptimizeHandler() : PragmaHandler("optimize") {}
-  void HandlePragma(Preprocessor , PragmaIntroducer Introducer,
-Token ) override;
-};
-
 // "\#pragma fenv_access (on)".
 struct PragmaMSFenvAccessHandler : public PragmaHandler {
   PragmaMSFenvAccessHandler() : PragmaHandler("fenv_access") {}
@@ -449,12 +443,12 @@
 PP.AddPragmaHandler(MSFunction.get());
 MSAllocText = std::make_unique("alloc_text");
 

[PATCH] D127876: [clang] Don't emit type test/assume for virtual classes that should never participate in WPD

2022-06-15 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

> We documented the feature in D75655  and 
> there it says "all classes" (and still does).

I've updated the documentation. It was already slightly inaccurate in that we 
weren't emitting type test/assumes for `std`/`stdext` namespace classes when 
`-flto-visibility-public-std`, this now corrects that part and generalizes that 
part of the documentation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127876

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


[PATCH] D127876: [clang] Don't emit type test/assume for virtual classes that should never participate in WPD

2022-06-15 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks updated this revision to Diff 437258.
aeubanks added a comment.

update docs


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127876

Files:
  clang/docs/LTOVisibility.rst
  clang/lib/CodeGen/CGClass.cpp
  clang/lib/CodeGen/CGVTables.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/test/CodeGenCXX/lto-visibility-inference.cpp

Index: clang/test/CodeGenCXX/lto-visibility-inference.cpp
===
--- clang/test/CodeGenCXX/lto-visibility-inference.cpp
+++ clang/test/CodeGenCXX/lto-visibility-inference.cpp
@@ -79,11 +79,11 @@
   // ITANIUM: type.test{{.*}}!"_ZTS2C4"
   // MS: type.test{{.*}}!"?AUC4@@"
   c4->f();
-  // ITANIUM: type.test{{.*}}!"_ZTS2C5"
-  // MS: type.test{{.*}}!"?AUC5@@"
+  // ITANIUM-NOT: type.test{{.*}}!"_ZTS2C5"
+  // MS-NOT: type.test{{.*}}!"?AUC5@@"
   c5->f();
-  // ITANIUM: type.test{{.*}}!"_ZTS2C6"
-  // MS: type.test{{.*}}!"?AUC6@@"
+  // ITANIUM-NOT: type.test{{.*}}!"_ZTS2C6"
+  // MS-NOT: type.test{{.*}}!"?AUC6@@"
   c6->f();
   // ITANIUM: type.test{{.*}}!"_ZTSSt2C7"
   // MS-STD: type.test{{.*}}!"?AUC7@std@@"
Index: clang/lib/CodeGen/ItaniumCXXABI.cpp
===
--- clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -668,8 +668,8 @@
CGM.HasHiddenLTOVisibility(RD);
   bool ShouldEmitWPDInfo =
   CGM.getCodeGenOpts().WholeProgramVTables &&
-  // Don't insert type tests if we are forcing public std visibility.
-  !CGM.HasLTOVisibilityPublicStd(RD);
+  // Don't insert type tests if we are forcing public visibility.
+  !CGM.AlwaysHasLTOVisibilityPublic(RD);
   llvm::Value *VirtualFn = nullptr;
 
   {
Index: clang/lib/CodeGen/CodeGenModule.h
===
--- clang/lib/CodeGen/CodeGenModule.h
+++ clang/lib/CodeGen/CodeGenModule.h
@@ -1382,10 +1382,10 @@
   /// optimization.
   bool HasHiddenLTOVisibility(const CXXRecordDecl *RD);
 
-  /// Returns whether the given record has public std LTO visibility
-  /// and therefore may not participate in (single-module) CFI and whole-program
-  /// vtable optimization.
-  bool HasLTOVisibilityPublicStd(const CXXRecordDecl *RD);
+  /// Returns whether the given record has public LTO visibility (regardless of
+  /// -lto-whole-program-visibility) and therefore may not participate in
+  /// (single-module) CFI and whole-program vtable optimization.
+  bool AlwaysHasLTOVisibilityPublic(const CXXRecordDecl *RD);
 
   /// Returns the vcall visibility of the given type. This is the scope in which
   /// a virtual function call could be made which ends up being dispatched to a
Index: clang/lib/CodeGen/CGVTables.cpp
===
--- clang/lib/CodeGen/CGVTables.cpp
+++ clang/lib/CodeGen/CGVTables.cpp
@@ -1175,7 +1175,10 @@
   DeferredVTables.clear();
 }
 
-bool CodeGenModule::HasLTOVisibilityPublicStd(const CXXRecordDecl *RD) {
+bool CodeGenModule::AlwaysHasLTOVisibilityPublic(const CXXRecordDecl *RD) {
+  if (RD->hasAttr() || RD->hasAttr())
+return true;
+
   if (!getCodeGenOpts().LTOVisibilityPublicStd)
 return false;
 
@@ -1200,9 +1203,6 @@
   if (!isExternallyVisible(LV.getLinkage()))
 return true;
 
-  if (RD->hasAttr() || RD->hasAttr())
-return false;
-
   if (getTriple().isOSBinFormatCOFF()) {
 if (RD->hasAttr() || RD->hasAttr())
   return false;
@@ -1211,7 +1211,7 @@
   return false;
   }
 
-  return !HasLTOVisibilityPublicStd(RD);
+  return !AlwaysHasLTOVisibilityPublic(RD);
 }
 
 llvm::GlobalObject::VCallVisibility CodeGenModule::GetVCallVisibilityLevel(
Index: clang/lib/CodeGen/CGClass.cpp
===
--- clang/lib/CodeGen/CGClass.cpp
+++ clang/lib/CodeGen/CGClass.cpp
@@ -2695,9 +2695,9 @@
   if (SanOpts.has(SanitizerKind::CFIVCall))
 EmitVTablePtrCheckForCall(RD, VTable, CodeGenFunction::CFITCK_VCall, Loc);
   else if (CGM.getCodeGenOpts().WholeProgramVTables &&
-   // Don't insert type test assumes if we are forcing public std
+   // Don't insert type test assumes if we are forcing public
// visibility.
-   !CGM.HasLTOVisibilityPublicStd(RD)) {
+   !CGM.AlwaysHasLTOVisibilityPublic(RD)) {
 llvm::Metadata *MD =
 CGM.CreateMetadataIdentifierForType(QualType(RD->getTypeForDecl(), 0));
 llvm::Value *TypeId =
Index: clang/docs/LTOVisibility.rst
===
--- clang/docs/LTOVisibility.rst
+++ clang/docs/LTOVisibility.rst
@@ -35,15 +35,16 @@
 (e.g. classes declared in unnamed namespaces) also receive hidden LTO
 visibility.
 
-During the LTO link, all classes with public LTO visibility will be refined
-to hidden LTO visibility 

[PATCH] D125936: [Sema] Relax an assertion in BuildStmtExpr

2022-06-15 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

I've removed the call to `ActOnFinishFullStmt` in 
`CoroutineStmtBuilder::makeOnFallthrough` too. `BuildCoreturnStmt` calls 
`ActOnFinishFullExpr`, so I don't think it's necessary to call 
`ActOnFinishFullStmt` after that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125936

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


[PATCH] D126540: PowerPC] Emit warning for incompatible vector types that are currently diagnosed with -fno-lax-vector-conversions

2022-06-15 Thread Maryam Moghadas via Phabricator via cfe-commits
maryammo added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:7715
 
+bool Sema::areAnyVectorTypesAltivec(QualType SrcTy, QualType DestTy) {
+  assert(DestTy->isVectorType() || SrcTy->isVectorType());

lei wrote:
> maryammo wrote:
> > amyk wrote:
> > > Can we add some brief documentation for this function, like what is done 
> > > for other functions in this file?
> > sure
> feels like this should be written to just take either 1 param or multiple 
> params via vararg.. since the 2 arg are not really related in any way.
I am not sure what you mean, can you please elaborate on that?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126540

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


[PATCH] D127883: [clang][deps] Further canonicalize implicit modules options in dep scan

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

Disable or canonicalize compiler options that are not relevant in explicit 
module builds, similar to what we already did for the modules cache path. This 
reduces uninteresting differences between command-lines, which is particularly 
useful if there is a tool that can cache the compilations.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D127883

Files:
  clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
  clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
  clang/test/ClangScanDeps/Inputs/removed-args/cdb.json.template
  clang/test/ClangScanDeps/removed-args.c

Index: clang/test/ClangScanDeps/removed-args.c
===
--- clang/test/ClangScanDeps/removed-args.c
+++ clang/test/ClangScanDeps/removed-args.c
@@ -2,10 +2,13 @@
 // compatible with the semantics of modules or are likely to differ between
 // identical modules discovered from different translation units. This test
 // checks such arguments are removed from the command-lines: '-include',
-// '-dwarf-debug-flag' and '-main-file-name'.
+// '-dwarf-debug-flag' and '-main-file-name'. Similarly, several arguments
+// such as '-fmodules-cache-path=' are only relevant for implicit modules, and
+// are removed to better-canonicalize the compilation.
 
 // RUN: rm -rf %t && mkdir %t
 // RUN: cp %S/Inputs/removed-args/* %t
+// RUN: touch %t/build-session
 
 // RUN: sed "s|DIR|%/t|g" %S/Inputs/removed-args/cdb.json.template > %t/cdb.json
 // RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full > %t/result.json
@@ -21,6 +24,11 @@
 // CHECK-NOT:  "-dwarf-debug-flags"
 // CHECK-NOT:  "-main-file-name"
 // CHECK-NOT:  "-include"
+// CHECK-NOT:  "-fmodules-cache-path=
+// CHECK-NOT:  "-fmodules-validate-once-per-build-session"
+// CHECK-NOT:  "-fbuild-session-timestamp=
+// CHECK-NOT:  "-fmodules-prune-interval=
+// CHECK-NOT:  "-fmodules-prune-after=
 // CHECK:],
 // CHECK-NEXT:   "context-hash": "[[HASH_MOD_HEADER:.*]]",
 // CHECK-NEXT:   "file-deps": [
@@ -34,7 +42,14 @@
 // CHECK-NEXT:   "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
 // CHECK-NEXT:   "command-line": [
 // CHECK-NEXT: "-cc1"
+// CHECK-NOT:  "-dwarf-debug-flags"
+// CHECK-NOT:  "-main-file-name"
 // CHECK-NOT:  "-include"
+// CHECK-NOT:  "-fmodules-cache-path=
+// CHECK-NOT:  "-fmodules-validate-once-per-build-session"
+// CHECK-NOT:  "-fbuild-session-timestamp=
+// CHECK-NOT:  "-fmodules-prune-interval=
+// CHECK-NOT:  "-fmodules-prune-after=
 // CHECK:],
 // CHECK-NEXT:   "context-hash": "[[HASH_MOD_TU:.*]]",
 // CHECK-NEXT:   "file-deps": [
@@ -57,6 +72,14 @@
 // CHECK-NEXT:   "module-name": "ModTU"
 // CHECK-NEXT: }
 // CHECK-NEXT:   ]
+// CHECK-NEXT:   "command-line": [
+// CHECK-NEXT: "-fsyntax-only",
+// CHECK-NOT:  "-fmodules-cache-path=
+// CHECK-NOT:  "-fmodules-validate-once-per-build-session"
+// CHECK-NOT:  "-fbuild-session-file=
+// CHECK-NOT:  "-fmodules-prune-interval=
+// CHECK-NOT:  "-fmodules-prune-after=
+// CHECK:],
 // CHECK:  }
 // CHECK-NEXT:   ]
 // CHECK-NEXT: }
Index: clang/test/ClangScanDeps/Inputs/removed-args/cdb.json.template
===
--- clang/test/ClangScanDeps/Inputs/removed-args/cdb.json.template
+++ clang/test/ClangScanDeps/Inputs/removed-args/cdb.json.template
@@ -1,7 +1,7 @@
 [
   {
 "directory": "DIR",
-"command": "clang -fsyntax-only DIR/tu.c -fmodules -fimplicit-module-maps -fmodules-cache-path=DIR/cache -include DIR/header.h -grecord-command-line -o DIR/tu.o",
+"command": "clang -fsyntax-only DIR/tu.c -fmodules -fimplicit-module-maps -fmodules-validate-once-per-build-session -fbuild-session-file=DIR/build-session -fmodules-prune-interval=123 -fmodules-prune-after=123 -fmodules-cache-path=DIR/cache -include DIR/header.h -grecord-command-line -o DIR/tu.o",
 "file": "DIR/tu.c"
   }
 ]
Index: clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
===
--- clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -61,9 +61,17 @@
   CI.getLangOpts()->ModuleName = Deps.ID.ModuleName;
   CI.getFrontendOpts().IsSystemModule = Deps.IsSystem;
 
+  // Disable implicit modules and canonicalize options that are only used by
+  // implicit modules.
   CI.getLangOpts()->ImplicitModules = false;
   

[PATCH] D125936: [Sema] Relax an assertion in BuildStmtExpr

2022-06-15 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 437248.
ahatanak added a comment.

Stop wrapping a `GCCAsmStmt` with an `ExprWithCleanups`. Instead, just pop the 
cleanups after the asm statement to destruct the temporaries.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125936

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/Parse/ParseStmt.cpp
  clang/lib/Sema/SemaCoroutine.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaStmtAsm.cpp
  clang/test/CodeGenCXX/asm.cpp
  clang/test/SemaTemplate/instantiate-expr-1.cpp

Index: clang/test/SemaTemplate/instantiate-expr-1.cpp
===
--- clang/test/SemaTemplate/instantiate-expr-1.cpp
+++ clang/test/SemaTemplate/instantiate-expr-1.cpp
@@ -190,3 +190,19 @@
 test_asm_tied(1.f); // expected-note {{instantiation of}}
   }
 }
+
+namespace TestAsmCleanup {
+struct S {
+  operator int() const { return 1; }
+  ~S();
+};
+
+template 
+void foo() {
+  __asm__ __volatile__("%[i]"
+   :
+   : [i] "r"(-S()));
+}
+
+void test() { foo(); }
+} // namespace TestAsmCleanup
Index: clang/test/CodeGenCXX/asm.cpp
===
--- clang/test/CodeGenCXX/asm.cpp
+++ clang/test/CodeGenCXX/asm.cpp
@@ -1,4 +1,6 @@
-// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple i386-unknown-unknown -fblocks -emit-llvm %s -o - | FileCheck %s
+
+// CHECK: %[[STRUCT_A:.*]] = type { i8 }
 
 struct A
 {
@@ -12,3 +14,39 @@
 asm("" : : "r"(foo(a)) ); // rdar://8540491
 // CHECK: call void @_ZN1AD1Ev
 }
+
+namespace TestTemplate {
+template 
+void foo0(A ) {
+  asm("" : : "r"(foo(a)) );
+  asm("");
+}
+
+// Check that the temporary is destructed after the first asm statement.
+
+// CHECK: define {{.*}}void @_ZN12TestTemplate4foo0IvEEvR1A(
+// CHECK: %[[AGG_TMP:.*]] = alloca %[[STRUCT_A]],
+// CHECK: %[[CALL:.*]] = call noundef i32 @_Z3foo1A({{.*}}%[[AGG_TMP]])
+// CHECK: call void asm sideeffect "", "r,~{dirflag},~{fpsr},~{flags}"(i32 %[[CALL]])
+// CHECK: call void @_ZN1AD1Ev({{.*}}%[[AGG_TMP]])
+// CHECK: call void asm sideeffect "",
+
+void test0(A ) { foo0(a); }
+
+// Check that the block capture is destructed at the end of the enclosing scope.
+
+// CHECK: define {{.*}}void @_ZN12TestTemplate4foo1IvEEv1A(
+// CHECK: %[[BLOCK:.*]] = alloca <{ ptr, i32, i32, ptr, ptr, %[[STRUCT_A]] }>, align 4
+// CHECK: %[[BLOCK_CAPTURED:.*]] = getelementptr inbounds <{ ptr, i32, i32, ptr, ptr, %[[STRUCT_A]] }>, ptr %[[BLOCK]], i32 0, i32 5
+// CHECK: call void asm sideeffect "", "r,~{dirflag},~{fpsr},~{flags}"(i32 %{{.*}})
+// CHECK: call void asm sideeffect "", "~{dirflag},~{fpsr},~{flags}"()
+// CHECK: call void @_ZN1AD1Ev({{.*}} %[[BLOCK_CAPTURED]])
+
+template 
+void foo1(A a) {
+  asm("" : : "r"(^{ (void)a; return 0; }()));
+  asm("");
+}
+
+void test1(A ) { foo1(a); }
+} // namespace TestTemplate
Index: clang/lib/Sema/SemaStmtAsm.cpp
===
--- clang/lib/Sema/SemaStmtAsm.cpp
+++ clang/lib/Sema/SemaStmtAsm.cpp
@@ -733,6 +733,9 @@
   }
   if (NS->isAsmGoto())
 setFunctionHasBranchIntoScope();
+
+  CleanupVarDeclMarking();
+  DiscardCleanupsInEvaluationContext();
   return NS;
 }
 
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -7283,26 +7283,6 @@
   return E;
 }
 
-Stmt *Sema::MaybeCreateStmtWithCleanups(Stmt *SubStmt) {
-  assert(SubStmt && "sub-statement can't be null!");
-
-  CleanupVarDeclMarking();
-
-  if (!Cleanup.exprNeedsCleanups())
-return SubStmt;
-
-  // FIXME: In order to attach the temporaries, wrap the statement into
-  // a StmtExpr; currently this is only used for asm statements.
-  // This is hacky, either create a new CXXStmtWithTemporaries statement or
-  // a new AsmStmtWithTemporaries.
-  CompoundStmt *CompStmt = CompoundStmt::Create(
-  Context, SubStmt, SourceLocation(), SourceLocation());
-  Expr *E = new (Context)
-  StmtExpr(CompStmt, Context.VoidTy, SourceLocation(), SourceLocation(),
-   /*FIXME TemplateDepth=*/0);
-  return MaybeCreateExprWithCleanups(E);
-}
-
 /// Process the expression contained within a decltype. For such expressions,
 /// certain semantic checks on temporaries are delayed until this point, and
 /// are omitted for the 'topmost' call in the decltype expression. If the
@@ -8803,12 +8783,6 @@
   return MaybeCreateExprWithCleanups(FullExpr);
 }
 
-StmtResult Sema::ActOnFinishFullStmt(Stmt *FullStmt) {
-  if (!FullStmt) return StmtError();
-
-  return MaybeCreateStmtWithCleanups(FullStmt);
-}
-
 Sema::IfExistsResult
 Sema::CheckMicrosoftIfExistsSymbol(Scope *S,
CXXScopeSpec ,

[PATCH] D124750: [MLIR] Add a utility to sort the operands of commutative ops

2022-06-15 Thread Srishti Srivastava via Phabricator via cfe-commits
srishti-pm added a comment.

Addressed most of the comments. A few remaining.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124750

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


[PATCH] D124750: [MLIR] Add a utility to sort the operands of commutative ops

2022-06-15 Thread Srishti Srivastava via Phabricator via cfe-commits
srishti-pm updated this revision to Diff 437249.
srishti-pm marked 20 inline comments as done.
srishti-pm added a comment.

Addressing comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124750

Files:
  mlir/include/mlir/Transforms/CommutativityUtils.h
  mlir/lib/Transforms/Utils/CMakeLists.txt
  mlir/lib/Transforms/Utils/CommutativityUtils.cpp
  mlir/test/Transforms/test-commutativity-utils.mlir
  mlir/test/lib/Dialect/Test/TestOps.td
  mlir/test/lib/Transforms/CMakeLists.txt
  mlir/test/lib/Transforms/TestCommutativityUtils.cpp
  mlir/tools/mlir-opt/mlir-opt.cpp

Index: mlir/tools/mlir-opt/mlir-opt.cpp
===
--- mlir/tools/mlir-opt/mlir-opt.cpp
+++ mlir/tools/mlir-opt/mlir-opt.cpp
@@ -57,6 +57,7 @@
 void registerVectorizerTestPass();
 
 namespace test {
+void registerCommutativityUtils();
 void registerConvertCallOpPass();
 void registerInliner();
 void registerMemRefBoundCheck();
@@ -150,6 +151,7 @@
   registerVectorizerTestPass();
   registerTosaTestQuantUtilAPIPass();
 
+  mlir::test::registerCommutativityUtils();
   mlir::test::registerConvertCallOpPass();
   mlir::test::registerInliner();
   mlir::test::registerMemRefBoundCheck();
Index: mlir/test/lib/Transforms/TestCommutativityUtils.cpp
===
--- /dev/null
+++ mlir/test/lib/Transforms/TestCommutativityUtils.cpp
@@ -0,0 +1,48 @@
+//===- TestCommutativityUtils.cpp - Pass to test the commutativity utility-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This pass tests the functionality of the commutativity utility pattern.
+//
+//===--===//
+
+#include "mlir/Transforms/CommutativityUtils.h"
+
+#include "TestDialect.h"
+#include "mlir/Pass/Pass.h"
+#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
+
+using namespace mlir;
+
+namespace {
+
+struct CommutativityUtils
+: public PassWrapper> {
+  MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(CommutativityUtils)
+
+  StringRef getArgument() const final { return "test-commutativity-utils"; }
+  StringRef getDescription() const final {
+return "Test the functionality of the commutativity utility";
+  }
+
+  void runOnOperation() override {
+auto func = getOperation();
+auto *context = ();
+
+RewritePatternSet patterns(context);
+populateCommutativityUtilsPatterns(patterns);
+
+(void)applyPatternsAndFoldGreedily(func, std::move(patterns));
+  }
+};
+} // namespace
+
+namespace mlir {
+namespace test {
+void registerCommutativityUtils() { PassRegistration(); }
+} // namespace test
+} // namespace mlir
Index: mlir/test/lib/Transforms/CMakeLists.txt
===
--- mlir/test/lib/Transforms/CMakeLists.txt
+++ mlir/test/lib/Transforms/CMakeLists.txt
@@ -1,5 +1,6 @@
 # Exclude tests from libMLIR.so
 add_mlir_library(MLIRTestTransforms
+  TestCommutativityUtils.cpp
   TestConstantFold.cpp
   TestControlFlowSink.cpp
   TestInlining.cpp
Index: mlir/test/lib/Dialect/Test/TestOps.td
===
--- mlir/test/lib/Dialect/Test/TestOps.td
+++ mlir/test/lib/Dialect/Test/TestOps.td
@@ -1172,11 +1172,21 @@
   let hasFolder = 1;
 }
 
+def TestAddIOp : TEST_Op<"addi"> {
+  let arguments = (ins I32:$op1, I32:$op2);
+  let results = (outs I32);
+}
+
 def TestCommutativeOp : TEST_Op<"op_commutative", [Commutative]> {
   let arguments = (ins I32:$op1, I32:$op2, I32:$op3, I32:$op4);
   let results = (outs I32);
 }
 
+def TestLargeCommutativeOp : TEST_Op<"op_large_commutative", [Commutative]> {
+  let arguments = (ins I32:$op1, I32:$op2, I32:$op3, I32:$op4, I32:$op5, I32:$op6, I32:$op7);
+  let results = (outs I32);
+}
+
 def TestCommutative2Op : TEST_Op<"op_commutative2", [Commutative]> {
   let arguments = (ins I32:$op1, I32:$op2);
   let results = (outs I32);
Index: mlir/test/Transforms/test-commutativity-utils.mlir
===
--- /dev/null
+++ mlir/test/Transforms/test-commutativity-utils.mlir
@@ -0,0 +1,116 @@
+// RUN: mlir-opt %s -test-commutativity-utils | FileCheck %s
+
+// CHECK-LABEL: @test_small_pattern_1
+func.func @test_small_pattern_1(%arg0 : i32) -> i32 {
+  // CHECK-NEXT: %[[ARITH_CONST:.*]] = arith.constant
+  %0 = arith.constant 45 : i32
+
+  // CHECK-NEXT: %[[TEST_ADD:.*]] = "test.addi"
+  %1 = "test.addi"(%arg0, %arg0): (i32, i32) -> i32
+
+  // CHECK-NEXT: %[[ARITH_ADD:.*]] = arith.addi
+  %2 = arith.addi %arg0, %arg0 : i32
+
+  // CHECK-NEXT: %[[ARITH_MUL:.*]] = arith.muli
+  %3 

[PATCH] D127798: [AArch64] Define __ARM_FEATURE_RCPC

2022-06-15 Thread Mingming Liu via Phabricator via cfe-commits
mingmingl added a comment.

In D127798#3585025 , @tyb0807 wrote:

> The patch looks correct to me, but looking at 
> https://github.com/ARM-software/acle/blob/main/main/acle.md where all the 
> ACLE macros are defined, I'm not sure that `__ARM_FEATURE_RCPC` is there 
> currently. Maybe you also want to submit a patch there, or at least explain 
> the context of this change please?

thanks for taking a look!

Before this patch, there is a piece of inline assembly like [1] that uses 
`LDAPR` and guarded by `#if defined(__aarch64__)`. Since not all aarch64 
platforms support `LDAPR`, we want to further guard the usage of `LDAPR` by 
MACRO `__ARM_FEATURE_RCPC`. May I know if there are alternatives for this use 
case, if introducing `__ARM_FEATURE_RCPC` sounds ad-hoc?

I'm glad to send a patch to add  `__ARM_FEATURE_RCPC` to 
https://github.com/ARM-software/acle/blob/main/main/acle.md if it's 
conventional to do so. Just let me know your suggestions!

[1]

  add x6, x1, x4
  ldapr x5, [x6]


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127798

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


[PATCH] D126540: PowerPC] Emit warning for incompatible vector types that are currently diagnosed with -fno-lax-vector-conversions

2022-06-15 Thread Maryam Moghadas via Phabricator via cfe-commits
maryammo added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:7715
 
+bool Sema::areAnyVectorTypesAltivec(QualType SrcTy, QualType DestTy) {
+  assert(DestTy->isVectorType() || SrcTy->isVectorType());

amyk wrote:
> Can we add some brief documentation for this function, like what is done for 
> other functions in this file?
sure



Comment at: clang/lib/Sema/SemaExpr.cpp:7716
+bool Sema::areAnyVectorTypesAltivec(QualType SrcTy, QualType DestTy) {
+  assert(DestTy->isVectorType() || SrcTy->isVectorType());
+

amyk wrote:
> Can we add a message to this `assert()`?
I followed what was done for other similar functions like : 
areMatrixTypesOfTheSameDimension



Comment at: clang/lib/Sema/SemaExpr.cpp:7716
+bool Sema::areAnyVectorTypesAltivec(QualType SrcTy, QualType DestTy) {
+  assert(DestTy->isVectorType() || SrcTy->isVectorType());
+

maryammo wrote:
> amyk wrote:
> > Can we add a message to this `assert()`?
> I followed what was done for other similar functions like : 
> areMatrixTypesOfTheSameDimension
same as others



Comment at: clang/lib/Sema/SemaExpr.cpp:7722
+  if (SrcTy->isVectorType())
+  {
+VectorType::VectorKind SrcVecKind = 
SrcTy->castAs()->getVectorKind();

amyk wrote:
> nit: Can we put braces on the same line? (And same goes for 7727)
sure



Comment at: clang/lib/Sema/SemaExpr.cpp:7735
+
+bool Sema::areVectorTypesSameElmType(QualType SrcTy, QualType DestTy) {
+  assert(DestTy->isVectorType() || SrcTy->isVectorType());

amyk wrote:
> Can we add some brief documentation for this function, like what is done for 
> other functions in this file?
sure



Comment at: clang/lib/Sema/SemaExpr.cpp:7736
+bool Sema::areVectorTypesSameElmType(QualType SrcTy, QualType DestTy) {
+  assert(DestTy->isVectorType() || SrcTy->isVectorType());
+

amyk wrote:
> Can we add a message to this assert?
I followed what was done for other similar functions like : 
areMatrixTypesOfTheSameDimension



Comment at: clang/lib/Sema/SemaOverload.cpp:13027
   // end up here.
+  //
   return SemaRef.BuildCallExpr(/*Scope*/ nullptr, NewFn.get(), LParenLoc,

amyk wrote:
> amyk wrote:
> > Unnecessary change?
> Unnecessary change?
yes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126540

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


[PATCH] D126540: PowerPC] Emit warning for incompatible vector types that are currently diagnosed with -fno-lax-vector-conversions

2022-06-15 Thread Lei Huang via Phabricator via cfe-commits
lei added a comment.

Please document all new functions added.




Comment at: clang/lib/Sema/SemaExpr.cpp:7715
 
+bool Sema::areAnyVectorTypesAltivec(QualType SrcTy, QualType DestTy) {
+  assert(DestTy->isVectorType() || SrcTy->isVectorType());

amyk wrote:
> Can we add some brief documentation for this function, like what is done for 
> other functions in this file?
feels like this should be written to just take either 1 param or multiple 
params via vararg.. since the 2 arg are not really related in any way.



Comment at: clang/lib/Sema/SemaExpr.cpp:9567
+  if (areAnyVectorTypesAltivec(RHSType, LHSType) &&
+ !areVectorTypesSameElmType(RHSType, LHSType))
+Diag(RHS.get()->getExprLoc(), 
diag::warn_deprecated_lax_vec_conv_all)

clang-format



Comment at: clang/lib/Sema/SemaExpr.cpp:10519
+  if (areAnyVectorTypesAltivec(RHSType, LHSType) &&
+ !areVectorTypesSameElmType(RHSType, LHSType))
+Diag(Loc, diag::warn_deprecated_lax_vec_conv_all) << RHSType << 
LHSType;

clang-format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126540

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


[PATCH] D111521: [DebugInfo] Mark OpenMP generated functions as artificial

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

In D111521#3584439 , @alok wrote:

> Re-based and updated to include one negative testcase.
> I could not find a test for VarDecl with DynamicInitKind::NoStub. There are 
> constructors for other DynamicInitKind but not for NoStub. Please help me in 
> case you are aware of the condition when it is produced.

I've got no particular knowledge of OpenMP unfortunately - the suggestion was 
based on looking at the conditions in the code & wanting them to all be tested.

If it can't be tested, could the test in the code be replaced with an assertion 
that it never happens?


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

https://reviews.llvm.org/D111521

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


[PATCH] D127641: [clang-cl][MSVC] Enable /Zc:alignedNew for C++17 and /Zc:sizedDealloc by default

2022-06-15 Thread Stephen Long via Phabricator via cfe-commits
steplong updated this revision to Diff 437243.
steplong added a comment.

`https://docs.microsoft.com/en-us/cpp/build/reference/zc-sizeddealloc-enable-global-sized-dealloc-functions?view=msvc-170`
 says it implements this by default starting on MSVC 2015. I don't have an 
older version of MSVC, so maybe someone can confirm for me


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127641

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/cl-zc.cpp


Index: clang/test/Driver/cl-zc.cpp
===
--- clang/test/Driver/cl-zc.cpp
+++ clang/test/Driver/cl-zc.cpp
@@ -1,6 +1,19 @@
 // Note: %s must be preceded by --, otherwise it may be interpreted as a
 // command-line option, e.g. on Mac where %s is commonly under /Users.
 
+// RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck 
-check-prefix=SIZED-DEALLOC-DEFAULT %s
+// RUN: %clang_cl /c -### -fms-compatibility-version=18 -- %s 2>&1 | FileCheck 
-check-prefix=SIZED-DEALLOC-OFF-DEFAULT %s
+// SIZED-DEALLOC-DEFAULT: "-fsized-deallocation"
+// SIZED-DEALLOC-OFF-DEFAULT-NOT: "-fsized-deallocation"
+
+// RUN: %clang_cl /c /std:c++11 -### -- %s 2>&1 | FileCheck 
-check-prefix=ALIGNED-NEW-BEFORE-CPP17-DEFAULT %s
+// RUN: %clang_cl /c /std:c++14 -### -- %s 2>&1 | FileCheck 
-check-prefix=ALIGNED-NEW-BEFORE-CPP17-DEFAULT %s
+// RUN: %clang_cl /c /std:c++17 -### -- %s 2>&1 | FileCheck 
-check-prefix=ALIGNED-NEW-CPP17ONWARDS-DEFAULT %s
+// RUN: %clang_cl /c /std:c++20 -### -- %s 2>&1 | FileCheck 
-check-prefix=ALIGNED-NEW-CPP17ONWARDS-DEFAULT %s
+// RUN: %clang_cl /c /std:c++latest -### -- %s 2>&1 | FileCheck 
-check-prefix=ALIGNED-NEW-CPP17ONWARDS-DEFAULT %s
+// ALIGNED-NEW-BEFORE-CPP17-DEFAULT-NOT: "-faligned-allocation"
+// ALIGNED-NEW-CPP17ONWARDS-DEFAULT: "-faligned-allocation"
+
 // RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck 
-check-prefix=TRIGRAPHS-DEFAULT %s
 // cc1 will disable trigraphs for -fms-compatibility as long as -ftrigraphs
 // isn't explicitly passed.
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6483,6 +6483,7 @@
 }
 CmdArgs.push_back(LanguageStandard.data());
   }
+  bool IsCPP17Onwards = false;
   if (ImplyVCPPCXXVer) {
 StringRef LanguageStandard;
 if (const Arg *StdArg = Args.getLastArg(options::OPT__SLASH_std)) {
@@ -6506,6 +6507,9 @@
 }
 
 CmdArgs.push_back(LanguageStandard.data());
+
+IsCPP17Onwards =
+LanguageStandard != "-std=c++11" && LanguageStandard != "-std=c++14";
   }
 
   Args.addOptInFlag(CmdArgs, options::OPT_fborland_extensions,
@@ -6635,9 +6639,15 @@
 options::OPT_fno_relaxed_template_template_args);
 
   // -fsized-deallocation is off by default, as it is an ABI-breaking change 
for
-  // most platforms.
-  Args.addOptInFlag(CmdArgs, options::OPT_fsized_deallocation,
-options::OPT_fno_sized_deallocation);
+  // most platforms. MSVC turns on /Zc:sizedDealloc by default, starting in
+  // MSVC 2015.
+  if (IsWindowsMSVC && IsMSVC2015Compatible &&
+  !Args.getLastArg(options::OPT_fsized_deallocation,
+   options::OPT_fno_sized_deallocation))
+CmdArgs.push_back("-fsized-deallocation");
+  else
+Args.addOptInFlag(CmdArgs, options::OPT_fsized_deallocation,
+  options::OPT_fno_sized_deallocation);
 
   // -faligned-allocation is on by default in C++17 onwards and otherwise off
   // by default.
@@ -6648,6 +6658,8 @@
   CmdArgs.push_back("-fno-aligned-allocation");
 else
   CmdArgs.push_back("-faligned-allocation");
+  } else if (IsCPP17Onwards) {
+CmdArgs.push_back("-faligned-allocation");
   }
 
   // The default new alignment can be specified using a dedicated option or via


Index: clang/test/Driver/cl-zc.cpp
===
--- clang/test/Driver/cl-zc.cpp
+++ clang/test/Driver/cl-zc.cpp
@@ -1,6 +1,19 @@
 // Note: %s must be preceded by --, otherwise it may be interpreted as a
 // command-line option, e.g. on Mac where %s is commonly under /Users.
 
+// RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck -check-prefix=SIZED-DEALLOC-DEFAULT %s
+// RUN: %clang_cl /c -### -fms-compatibility-version=18 -- %s 2>&1 | FileCheck -check-prefix=SIZED-DEALLOC-OFF-DEFAULT %s
+// SIZED-DEALLOC-DEFAULT: "-fsized-deallocation"
+// SIZED-DEALLOC-OFF-DEFAULT-NOT: "-fsized-deallocation"
+
+// RUN: %clang_cl /c /std:c++11 -### -- %s 2>&1 | FileCheck -check-prefix=ALIGNED-NEW-BEFORE-CPP17-DEFAULT %s
+// RUN: %clang_cl /c /std:c++14 -### -- %s 2>&1 | FileCheck -check-prefix=ALIGNED-NEW-BEFORE-CPP17-DEFAULT %s
+// RUN: %clang_cl /c /std:c++17 -### -- %s 2>&1 | FileCheck -check-prefix=ALIGNED-NEW-CPP17ONWARDS-DEFAULT %s
+// RUN: %clang_cl /c /std:c++20 -### -- %s 

Re: [clang] f13019f - [clang] Use any_of and none_of (NFC)

2022-06-15 Thread Kazu Hirata via cfe-commits
Hi David,

On Mon, Jun 13, 2022 at 2:00 PM David Blaikie  wrote:

> On Sun, Jun 12, 2022 at 10:17 AM Kazu Hirata via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> -  return args_end() != std::find_if(
>> -  args_begin(), args_end(),
>> -  [=](const ParamIdx ) { return Idx.getASTIndex() == IdxAST;
>> });
>> +  return llvm::any_of(args(), [=](const ParamIdx ) {
>> +return Idx.getASTIndex() == IdxAST;
>> +  });
>>
>
> Generally, I think for locally scoped lambdas (lambdas that don't escape
> their scope) we should prefer/default to default reference capture (`[&]`)
> - it simplifies changes in the future. Would that be OK for these sort of
> cleanups?
>

Sure.  I've often wondered about the point of explicitly specifying
captures.

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


[PATCH] D127876: [clang] Don't emit type test/assume for virtual classes that should never participate in WPD

2022-06-15 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc added a comment.

In D127876#3586154 , @aeubanks wrote:

> In D127876#3586134 , @pcc wrote:
>
>> This diverges from the documented behavior of 
>> `-lto-whole-program-visibility`. The flag is meant to give all classes 
>> hidden LTO visibility, but now it only does that to some of them.
>
> perhaps I'm misunderstanding, but even with `-lto-whole-program-visibility` 
> classes explicitly marked with public LTO visibility still shouldn't 
> participate in WPD?

We documented the feature in D75655  and there 
it says "all classes" (and still does).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127876

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


[PATCH] D127876: [clang] Don't emit type test/assume for virtual classes that should never participate in WPD

2022-06-15 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

In D127876#3586134 , @pcc wrote:

> This diverges from the documented behavior of 
> `-lto-whole-program-visibility`. The flag is meant to give all classes hidden 
> LTO visibility, but now it only does that to some of them.

perhaps I'm misunderstanding, but even with `-lto-whole-program-visibility` 
classes explicitly marked with public LTO visibility still shouldn't 
participate in WPD?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127876

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


[PATCH] D127876: [clang] Don't emit type test/assume for virtual classes that should never participate in WPD

2022-06-15 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc requested changes to this revision.
pcc added a comment.
This revision now requires changes to proceed.

This diverges from the documented behavior of `-lto-whole-program-visibility`. 
The flag is meant to give all classes hidden LTO visibility, but now it only 
does that to some of them.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127876

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


[PATCH] D127163: [clang] Add -fsanitize=memtag-globals (no-op).

2022-06-15 Thread Mitch Phillips 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 rG45d88cd00846: [clang] Add -fsanitize=memtag-globals (no-op). 
(authored by hctim).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127163

Files:
  clang/include/clang/Basic/Features.def
  clang/include/clang/Basic/Sanitizers.def
  clang/include/clang/Driver/SanitizerArgs.h
  clang/lib/Driver/SanitizerArgs.cpp
  clang/test/Driver/fsanitize.c


Index: clang/test/Driver/fsanitize.c
===
--- clang/test/Driver/fsanitize.c
+++ clang/test/Driver/fsanitize.c
@@ -193,9 +193,9 @@
 // RUN: %clang -target x86_64-linux-android -fsanitize=memtag -fno-rtti %s 
-### 2>&1 | FileCheck %s --check-prefix=CHECK-SANMT-BAD-ARCH
 // CHECK-SANMT-BAD-ARCH: unsupported option '-fsanitize=memtag' for target
 
-// RUN: %clang -target aarch64-linux -fsanitize=memtag -march=armv8-a+memtag 
%s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANMT-MT
+// RUN: %clang -target aarch64-linux-android31 -fsanitize=memtag 
-march=armv8-a+memtag %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-SANMT-MT
 // CHECK-SANMT-MT: "-target-feature" "+mte"
-// CHECK-SANMT-MT-SAME: "-fsanitize=memtag-stack,memtag-heap"
+// CHECK-SANMT-MT-SAME: "-fsanitize=memtag-stack,memtag-heap,memtag-globals"
 
 // RUN: %clang -target aarch64-linux -fsanitize=memtag %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-SANMT-NOMT-0
 // CHECK-SANMT-NOMT-0: '-fsanitize=memtag-stack' requires hardware support 
(+memtag)
@@ -827,7 +827,7 @@
 // CHECK-INTSAN-MINIMAL: "-fsanitize-minimal-runtime"
 
 // RUN: %clang -target aarch64-linux-android -march=armv8-a+memtag 
-fsanitize=memtag -fsanitize-minimal-runtime %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-MEMTAG-MINIMAL
-// CHECK-MEMTAG-MINIMAL: "-fsanitize=memtag-stack,memtag-heap"
+// CHECK-MEMTAG-MINIMAL: "-fsanitize=memtag-stack,memtag-heap,memtag-globals"
 // CHECK-MEMTAG-MINIMAL: "-fsanitize-minimal-runtime"
 
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=undefined 
-fsanitize=function -fsanitize-minimal-runtime %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-UBSAN-FUNCTION-MINIMAL
Index: clang/lib/Driver/SanitizerArgs.cpp
===
--- clang/lib/Driver/SanitizerArgs.cpp
+++ clang/lib/Driver/SanitizerArgs.cpp
@@ -45,7 +45,8 @@
 SanitizerKind::Address | SanitizerKind::HWAddress |
 SanitizerKind::KernelAddress | SanitizerKind::KernelHWAddress |
 SanitizerKind::MemtagStack | SanitizerKind::MemtagHeap |
-SanitizerKind::Memory | SanitizerKind::KernelMemory | SanitizerKind::Leak |
+SanitizerKind::MemtagGlobals | SanitizerKind::Memory |
+SanitizerKind::KernelMemory | SanitizerKind::Leak |
 SanitizerKind::Undefined | SanitizerKind::Integer | SanitizerKind::Bounds |
 SanitizerKind::ImplicitConversion | SanitizerKind::Nullability |
 SanitizerKind::DataFlow | SanitizerKind::Fuzzer |
@@ -73,7 +74,8 @@
 SanitizerKind::CFIUnrelatedCast;
 static const SanitizerMask CompatibleWithMinimalRuntime =
 TrappingSupported | SanitizerKind::Scudo | SanitizerKind::ShadowCallStack |
-SanitizerKind::MemtagStack | SanitizerKind::MemtagHeap;
+SanitizerKind::MemtagStack | SanitizerKind::MemtagHeap |
+SanitizerKind::MemtagGlobals;
 
 enum CoverageFeature {
   CoverageFunc = 1 << 0,
Index: clang/include/clang/Driver/SanitizerArgs.h
===
--- clang/include/clang/Driver/SanitizerArgs.h
+++ clang/include/clang/Driver/SanitizerArgs.h
@@ -99,13 +99,18 @@
   bool needsStatsRt() const { return Stats; }
   bool needsScudoRt() const { return Sanitizers.has(SanitizerKind::Scudo); }
 
-  bool hasMemTag() const { return hasMemtagHeap() || hasMemtagStack(); }
+  bool hasMemTag() const {
+return hasMemtagHeap() || hasMemtagStack() || hasMemtagGlobals();
+  }
   bool hasMemtagHeap() const {
 return Sanitizers.has(SanitizerKind::MemtagHeap);
   }
   bool hasMemtagStack() const {
 return Sanitizers.has(SanitizerKind::MemtagStack);
   }
+  bool hasMemtagGlobals() const {
+return Sanitizers.has(SanitizerKind::MemtagGlobals);
+  }
   const std::string () const {
 assert(!MemtagMode.empty());
 return MemtagMode;
Index: clang/include/clang/Basic/Sanitizers.def
===
--- clang/include/clang/Basic/Sanitizers.def
+++ clang/include/clang/Basic/Sanitizers.def
@@ -58,7 +58,8 @@
 // A variant of AddressSanitizer using AArch64 MTE extension.
 SANITIZER("memtag-stack", MemtagStack)
 SANITIZER("memtag-heap", MemtagHeap)
-SANITIZER_GROUP("memtag", MemTag, MemtagStack | MemtagHeap)
+SANITIZER("memtag-globals", MemtagGlobals)
+SANITIZER_GROUP("memtag", MemTag, MemtagStack | MemtagHeap | MemtagGlobals)
 
 // MemorySanitizer
 

  1   2   3   >