[PATCH] D129832: [sanitizer] Add "mainsrc" prefix to sanitizer special case list

2022-07-14 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 444892.
MaskRay added a comment.

update doc


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129832

Files:
  clang/docs/SanitizerSpecialCaseList.rst
  clang/include/clang/Basic/NoSanitizeList.h
  clang/lib/Basic/NoSanitizeList.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/sanitize-ignorelist-mainsrc.c
  llvm/include/llvm/Support/SpecialCaseList.h

Index: llvm/include/llvm/Support/SpecialCaseList.h
===
--- llvm/include/llvm/Support/SpecialCaseList.h
+++ llvm/include/llvm/Support/SpecialCaseList.h
@@ -19,9 +19,9 @@
 //   prefix:wildcard_expression[=category]
 // If category is not specified, it is assumed to be empty string.
 // Definitions of "prefix" and "category" are sanitizer-specific. For example,
-// sanitizer exclusion support prefixes "src", "fun" and "global".
-// Wildcard expressions define, respectively, source files, functions or
-// globals which shouldn't be instrumented.
+// sanitizer exclusion support prefixes "src", "mainsrc", "fun" and "global".
+// Wildcard expressions define, respectively, source files, main source files,
+// functions or globals which shouldn't be instrumented.
 // Examples of categories:
 //   "functional": used in DFSan to list functions with pure functional
 // semantics.
@@ -37,6 +37,7 @@
 // type:*Namespace::ClassName*=init
 // src:file_with_tricky_code.cc
 // src:ignore-global-initializers-issues.cc=init
+// mainsrc:file_with_tricky_code.cc
 //
 // [dataflow]
 // # Functions with pure functional semantics:
Index: clang/test/CodeGen/sanitize-ignorelist-mainsrc.c
===
--- /dev/null
+++ clang/test/CodeGen/sanitize-ignorelist-mainsrc.c
@@ -0,0 +1,41 @@
+/// Test mainsrc in a sanitizer special case list.
+// RUN: rm -rf %t && split-file %s %t && cd %t
+// RUN: %clang_cc1 -emit-llvm -triple x86_64 -fsanitize=address,alignment a.c -o - | FileCheck %s --check-prefixes=CHECK,DEFAULT
+// RUN: %clang_cc1 -emit-llvm -triple x86_64 -fsanitize=address,alignment -fsanitize-ignorelist=a.list a.c -o - | FileCheck %s --check-prefixes=CHECK,IGNORE
+// RUN: %clang_cc1 -emit-llvm -triple x86_64 -fsanitize=address,alignment -fsanitize-ignorelist=b.list a.c -o - | FileCheck %s --check-prefixes=CHECK,IGNORE
+
+//--- a.list
+mainsrc:*a.c
+
+//--- b.list
+[address]
+mainsrc:*a.c
+
+[alignment]
+mainsrc:*.c
+
+//--- a.h
+int global_h;
+
+static inline int load(int *x) {
+  return *x;
+}
+
+//--- a.c
+#include "a.h"
+
+int global_c;
+
+int foo(void *x) {
+  return load(x);
+}
+
+// DEFAULT: @___asan_gen_{{.*}} = {{.*}} c"global_h\00"
+// DEFAULT: @___asan_gen_{{.*}} = {{.*}} c"global_c\00"
+// IGNORE-NOT:  @___asan_gen_
+
+// CHECK-LABEL: define {{.*}}@load(
+// DEFAULT:   call void @__ubsan_handle_type_mismatch_v1_abort(
+// DEFAULT:   call void @__asan_report_load4(
+// IGNORE-NOT:call void @__ubsan_handle_type_mismatch_v1_abort(
+// IGNORE-NOT:call void @__asan_report_load4(
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -2780,16 +2780,18 @@
   // NoSanitize by function name.
   if (NoSanitizeL.containsFunction(Kind, Fn->getName()))
 return true;
-  // NoSanitize by location.
+  // NoSanitize by location. Check "mainsrc" category.
+  auto &SM = Context.getSourceManager();
+  const FileEntry &MainFile = *SM.getFileEntryForID(SM.getMainFileID());
+  if (NoSanitizeL.containsMainFile(Kind, MainFile.getName()))
+return true;
+
+  // Check "src" category.
   if (Loc.isValid())
 return NoSanitizeL.containsLocation(Kind, Loc);
   // If location is unknown, this may be a compiler-generated function. Assume
   // it's located in the main file.
-  auto &SM = Context.getSourceManager();
-  if (const auto *MainFile = SM.getFileEntryForID(SM.getMainFileID())) {
-return NoSanitizeL.containsFile(Kind, MainFile->getName());
-  }
-  return false;
+  return NoSanitizeL.containsFile(Kind, MainFile.getName());
 }
 
 bool CodeGenModule::isInNoSanitizeList(SanitizerMask Kind,
@@ -2799,8 +2801,13 @@
   const auto &NoSanitizeL = getContext().getNoSanitizeList();
   if (NoSanitizeL.containsGlobal(Kind, GV->getName(), Category))
 return true;
+  auto &SM = Context.getSourceManager();
+  if (NoSanitizeL.containsMainFile(
+  Kind, SM.getFileEntryForID(SM.getMainFileID())->getName(), Category))
+return true;
   if (NoSanitizeL.containsLocation(Kind, Loc, Category))
 return true;
+
   // Check global type.
   if (!Ty.isNull()) {
 // Drill down the array types: if global variable of a fixed type is
Index: clang/lib/Basic/NoSanitizeList.cpp
===
--- clang/lib/Basic/NoSanit

[PATCH] D129832: [sanitizer] Add "mainsrc" prefix to sanitizer special case list

2022-07-14 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay marked 2 inline comments as done.
MaskRay added inline comments.



Comment at: clang/docs/SanitizerSpecialCaseList.rst:108
+caution. It may still be useful, e.g. when patterns are picked in a way to
+ensure the prevailing one is ignored.
+

Added: ``(There is an action at a distance risk.)``



Comment at: clang/docs/SanitizerSpecialCaseList.rst:110-112
+``mainsrc`` can be useful enabling a ubsan check for a large code base when
+finding the direct stack frame triggering the failure for every failure is
+difficult.

vitalybuka wrote:
> if this is transitionalt solution, would it be better just to use 
> -fno-sanitize= on *.cpp file?
This provides a more convenient way than using `-fno-sanitize=` for a different 
set of files.

E.g. if a group wants to ignore a check for all ``[a-m]*` files, then can use 
`mainsrc:[a-m]*` instead of patching the build system.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129832

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


[PATCH] D129835: [clang] adds a discardable attribute

2022-07-14 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb updated this revision to Diff 444890.
cjdb added a comment.

undoes editor autotrimming of spaces


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129835

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/Expr.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/AST/Expr.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/SemaCXX/discardable.cpp

Index: clang/test/SemaCXX/discardable.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/discardable.cpp
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -fsyntax-only -Wunknown-attributes -verify -std=c++17 %s
+
+[[clang::discardable]] int without_nodiscard();
+
+[[nodiscard, clang::discardable]] int no_warn_fundamental();
+
+struct naked {};
+[[nodiscard, clang::discardable]] naked no_warn_class_type();
+[[nodiscard, clang::discardable]] naked* no_warn_pointer();
+[[nodiscard, clang::discardable]] naked& no_warn_reference();
+
+struct [[nodiscard]] nodiscard_type {};
+[[clang::discardable]] nodiscard_type no_warn_function_override();
+
+struct [[clang::discardable]] discardable_type {};
+discardable_type no_warn_discardable_type();
+[[nodiscard]] discardable_type warns_function_override();
+
+struct [[nodiscard, clang::discardable]] discardable_type2 {};
+discardable_type2 no_warn_discardable_type2();
+
+struct discardable_members {
+  [[nodiscard, clang::discardable]] discardable_members(int);
+  [[nodiscard, clang::discardable]] int f() const;
+};
+
+void test_expression_statements() {
+  without_nodiscard();
+
+  no_warn_fundamental();
+
+  no_warn_class_type();
+  no_warn_pointer();
+  no_warn_reference();
+
+  no_warn_function_override();
+
+  no_warn_discardable_type();
+  warns_function_override(); // expected-warning{{ignoring return value}}
+
+  no_warn_discardable_type2();
+
+  discardable_members(0);
+  discardable_members(0).f();
+}
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -60,6 +60,7 @@
 // CHECK-NEXT: DiagnoseAsBuiltin (SubjectMatchRule_function)
 // CHECK-NEXT: DisableSanitizerInstrumentation (SubjectMatchRule_function, SubjectMatchRule_objc_method, SubjectMatchRule_variable_is_global)
 // CHECK-NEXT: DisableTailCalls (SubjectMatchRule_function, SubjectMatchRule_objc_method)
+// CHECK-NEXT: DisableWarnUnusedResult (SubjectMatchRule_objc_method, SubjectMatchRule_enum, SubjectMatchRule_record, SubjectMatchRule_hasType_functionType, SubjectMatchRule_type_alias)
 // CHECK-NEXT: EnableIf (SubjectMatchRule_function)
 // CHECK-NEXT: EnforceTCB (SubjectMatchRule_function, SubjectMatchRule_objc_method)
 // CHECK-NEXT: EnforceTCBLeaf (SubjectMatchRule_function, SubjectMatchRule_objc_method)
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -282,8 +282,12 @@
 if (E->getType()->isVoidType())
   return;
 
-if (DiagnoseNoDiscard(*this, cast_or_null(
- CE->getUnusedResultAttr(Context)),
+if (CE->getDisableUnusedResultAttr(Context))
+  return;
+
+if (DiagnoseNoDiscard(*this,
+  cast_or_null(
+  CE->getUnusedResultAttr(Context)),
   Loc, R1, R2, /*isCtor=*/false))
   return;
 
@@ -305,6 +309,11 @@
 }
   } else if (const auto *CE = dyn_cast(E)) {
 if (const CXXConstructorDecl *Ctor = CE->getConstructor()) {
+  const auto *D = Ctor->getAttr();
+  D = D ? D : Ctor->getParent()->getAttr();
+  if (D)
+return;
+
   const auto *A = Ctor->getAttr();
   A = A ? A : Ctor->getParent()->getAttr();
   if (DiagnoseNoDiscard(*this, A, Loc, R1, R2, /*isCtor=*/true))
@@ -312,6 +321,8 @@
 }
   } else if (const auto *ILE = dyn_cast(E)) {
 if (const TagDecl *TD = ILE->getType()->getAsTagDecl()) {
+  if (TD->getAttr())
+return;
 
   if (DiagnoseNoDiscard(*this, TD->getAttr(), Loc, R1,
 R2, /*isCtor=*/false))
@@ -328,6 +339,8 @@
 }
 const ObjCMethodDecl *MD = ME->getMethodDecl();
 if (MD) {
+  if (MD->getAttr())
+return;
   if (DiagnoseNoDiscard(*this, MD->getAttr(), Loc, R1,
 R2, /*isCtor=*/false))
 return;
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -3167,6 +3167,39 @@
   D->addAttr(::new (S.Context) WarnUnusedResultAttr(S.Context, 

[PATCH] D129832: [sanitizer] Add "mainsrc" prefix to sanitizer special case list

2022-07-14 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added inline comments.



Comment at: clang/docs/SanitizerSpecialCaseList.rst:110-112
+``mainsrc`` can be useful enabling a ubsan check for a large code base when
+finding the direct stack frame triggering the failure for every failure is
+difficult.

if this is transitionalt solution, would it be better just to use 
-fno-sanitize= on *.cpp file?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129832

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


[PATCH] D129832: [sanitizer] Add "mainsrc" prefix to sanitizer special case list

2022-07-14 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:2786
+  const FileEntry &MainFile = *SM.getFileEntryForID(SM.getMainFileID());
+  if (NoSanitizeL.containsMainFile(Kind, MainFile.getName()))
+return true;

vitalybuka wrote:
> we search exactly the same  MainFile.getName() in containsMainFile and 
> containsFile ?
I see, it's some fallback branch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129832

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


[PATCH] D129835: [clang] adds a discardable attribute

2022-07-14 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb created this revision.
cjdb added a reviewer: aaron.ballman.
Herald added a subscriber: jdoerfert.
Herald added a project: All.
cjdb requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Although the default behaviour for C and C++ is to not diagnose ignored function
calls, we can make this the default by using `#pragma clang attribute
push([[nodiscard]],  apply_to = function)`. When we have a function that can
have its value discarded, we can use `[[clang::discardable]]` to indicate that
the ``[[nodiscard]]`` attribute should be ignored.

`[[clang::discardable]]` can be placed anywhere `[[nodiscard]]` is allowed,
but the presence of either is prioritised when it's applied to a callable.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129835

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/Expr.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/AST/Expr.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/SemaCXX/discardable.cpp

Index: clang/test/SemaCXX/discardable.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/discardable.cpp
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -fsyntax-only -Wunknown-attributes -verify -std=c++17 %s
+
+[[clang::discardable]] int without_nodiscard();
+
+[[nodiscard, clang::discardable]] int no_warn_fundamental();
+
+struct naked {};
+[[nodiscard, clang::discardable]] naked no_warn_class_type();
+[[nodiscard, clang::discardable]] naked* no_warn_pointer();
+[[nodiscard, clang::discardable]] naked& no_warn_reference();
+
+struct [[nodiscard]] nodiscard_type {};
+[[clang::discardable]] nodiscard_type no_warn_function_override();
+
+struct [[clang::discardable]] discardable_type {};
+discardable_type no_warn_discardable_type();
+[[nodiscard]] discardable_type warns_function_override();
+
+struct [[nodiscard, clang::discardable]] discardable_type2 {};
+discardable_type2 no_warn_discardable_type2();
+
+struct discardable_members {
+  [[nodiscard, clang::discardable]] discardable_members(int);
+  [[nodiscard, clang::discardable]] int f() const;
+};
+
+void test_expression_statements() {
+  without_nodiscard();
+
+  no_warn_fundamental();
+
+  no_warn_class_type();
+  no_warn_pointer();
+  no_warn_reference();
+
+  no_warn_function_override();
+
+  no_warn_discardable_type();
+  warns_function_override(); // expected-warning{{ignoring return value}}
+
+  no_warn_discardable_type2();
+
+  discardable_members(0);
+  discardable_members(0).f();
+}
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -60,6 +60,7 @@
 // CHECK-NEXT: DiagnoseAsBuiltin (SubjectMatchRule_function)
 // CHECK-NEXT: DisableSanitizerInstrumentation (SubjectMatchRule_function, SubjectMatchRule_objc_method, SubjectMatchRule_variable_is_global)
 // CHECK-NEXT: DisableTailCalls (SubjectMatchRule_function, SubjectMatchRule_objc_method)
+// CHECK-NEXT: DisableWarnUnusedResult (SubjectMatchRule_objc_method, SubjectMatchRule_enum, SubjectMatchRule_record, SubjectMatchRule_hasType_functionType, SubjectMatchRule_type_alias)
 // CHECK-NEXT: EnableIf (SubjectMatchRule_function)
 // CHECK-NEXT: EnforceTCB (SubjectMatchRule_function, SubjectMatchRule_objc_method)
 // CHECK-NEXT: EnforceTCBLeaf (SubjectMatchRule_function, SubjectMatchRule_objc_method)
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -282,8 +282,12 @@
 if (E->getType()->isVoidType())
   return;
 
-if (DiagnoseNoDiscard(*this, cast_or_null(
- CE->getUnusedResultAttr(Context)),
+if (CE->getDisableUnusedResultAttr(Context))
+  return;
+
+if (DiagnoseNoDiscard(*this,
+  cast_or_null(
+  CE->getUnusedResultAttr(Context)),
   Loc, R1, R2, /*isCtor=*/false))
   return;
 
@@ -305,6 +309,11 @@
 }
   } else if (const auto *CE = dyn_cast(E)) {
 if (const CXXConstructorDecl *Ctor = CE->getConstructor()) {
+  const auto *D = Ctor->getAttr();
+  D = D ? D : Ctor->getParent()->getAttr();
+  if (D)
+return;
+
   const auto *A = Ctor->getAttr();
   A = A ? A : Ctor->getParent()->getAttr();
   if (DiagnoseNoDiscard(*this, A, Loc, R1, R2, /*isCtor=*/true))
@@ -312,6 +321,8 @@
 }
   } else if (const auto *ILE = dyn_cast(E)) {
 if (const TagDecl *TD = ILE->getType()->getAsTagDecl()) {
+  if (TD->getAttr())
+return;
 
   if (DiagnoseNoDiscard(*this, TD->getAttr(), Loc, R1,

[PATCH] D129832: [sanitizer] Add "mainsrc" prefix to sanitizer special case list

2022-07-14 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:2786
+  const FileEntry &MainFile = *SM.getFileEntryForID(SM.getMainFileID());
+  if (NoSanitizeL.containsMainFile(Kind, MainFile.getName()))
+return true;

we search exactly the same  MainFile.getName() in containsMainFile and 
containsFile ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129832

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


[PATCH] D129832: [sanitizer] Add "mainsrc" prefix to sanitizer special case list

2022-07-14 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D129832#3654076 , @vitalybuka 
wrote:

>> mainsrc may still be useful, e.g. if a wildcard is used to ensure the 
>> prevailing one is ignored.
>
> Not sure I understand, how can we make that? Usually it's hard to control 
> what is included, especially indirectly.

Elaborated in the updated `clang/docs/SanitizerSpecialCaseList.rst`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129832

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


[PATCH] D129832: [sanitizer] Add "mainsrc" prefix to sanitizer special case list

2022-07-14 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 444882.
MaskRay added a comment.

Warn mainsrc for C++ vague linkage functions


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129832

Files:
  clang/docs/SanitizerSpecialCaseList.rst
  clang/include/clang/Basic/NoSanitizeList.h
  clang/lib/Basic/NoSanitizeList.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/sanitize-ignorelist-mainsrc.c
  llvm/include/llvm/Support/SpecialCaseList.h

Index: llvm/include/llvm/Support/SpecialCaseList.h
===
--- llvm/include/llvm/Support/SpecialCaseList.h
+++ llvm/include/llvm/Support/SpecialCaseList.h
@@ -19,9 +19,9 @@
 //   prefix:wildcard_expression[=category]
 // If category is not specified, it is assumed to be empty string.
 // Definitions of "prefix" and "category" are sanitizer-specific. For example,
-// sanitizer exclusion support prefixes "src", "fun" and "global".
-// Wildcard expressions define, respectively, source files, functions or
-// globals which shouldn't be instrumented.
+// sanitizer exclusion support prefixes "src", "mainsrc", "fun" and "global".
+// Wildcard expressions define, respectively, source files, main source files,
+// functions or globals which shouldn't be instrumented.
 // Examples of categories:
 //   "functional": used in DFSan to list functions with pure functional
 // semantics.
@@ -37,6 +37,7 @@
 // type:*Namespace::ClassName*=init
 // src:file_with_tricky_code.cc
 // src:ignore-global-initializers-issues.cc=init
+// mainsrc:file_with_tricky_code.cc
 //
 // [dataflow]
 // # Functions with pure functional semantics:
Index: clang/test/CodeGen/sanitize-ignorelist-mainsrc.c
===
--- /dev/null
+++ clang/test/CodeGen/sanitize-ignorelist-mainsrc.c
@@ -0,0 +1,41 @@
+/// Test mainsrc in a sanitizer special case list.
+// RUN: rm -rf %t && split-file %s %t && cd %t
+// RUN: %clang_cc1 -emit-llvm -triple x86_64 -fsanitize=address,alignment a.c -o - | FileCheck %s --check-prefixes=CHECK,DEFAULT
+// RUN: %clang_cc1 -emit-llvm -triple x86_64 -fsanitize=address,alignment -fsanitize-ignorelist=a.list a.c -o - | FileCheck %s --check-prefixes=CHECK,IGNORE
+// RUN: %clang_cc1 -emit-llvm -triple x86_64 -fsanitize=address,alignment -fsanitize-ignorelist=b.list a.c -o - | FileCheck %s --check-prefixes=CHECK,IGNORE
+
+//--- a.list
+mainsrc:*a.c
+
+//--- b.list
+[address]
+mainsrc:*a.c
+
+[alignment]
+mainsrc:*.c
+
+//--- a.h
+int global_h;
+
+static inline int load(int *x) {
+  return *x;
+}
+
+//--- a.c
+#include "a.h"
+
+int global_c;
+
+int foo(void *x) {
+  return load(x);
+}
+
+// DEFAULT: @___asan_gen_{{.*}} = {{.*}} c"global_h\00"
+// DEFAULT: @___asan_gen_{{.*}} = {{.*}} c"global_c\00"
+// IGNORE-NOT:  @___asan_gen_
+
+// CHECK-LABEL: define {{.*}}@load(
+// DEFAULT:   call void @__ubsan_handle_type_mismatch_v1_abort(
+// DEFAULT:   call void @__asan_report_load4(
+// IGNORE-NOT:call void @__ubsan_handle_type_mismatch_v1_abort(
+// IGNORE-NOT:call void @__asan_report_load4(
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -2780,16 +2780,18 @@
   // NoSanitize by function name.
   if (NoSanitizeL.containsFunction(Kind, Fn->getName()))
 return true;
-  // NoSanitize by location.
+  // NoSanitize by location. Check "mainsrc" category.
+  auto &SM = Context.getSourceManager();
+  const FileEntry &MainFile = *SM.getFileEntryForID(SM.getMainFileID());
+  if (NoSanitizeL.containsMainFile(Kind, MainFile.getName()))
+return true;
+
+  // Check "src" category.
   if (Loc.isValid())
 return NoSanitizeL.containsLocation(Kind, Loc);
   // If location is unknown, this may be a compiler-generated function. Assume
   // it's located in the main file.
-  auto &SM = Context.getSourceManager();
-  if (const auto *MainFile = SM.getFileEntryForID(SM.getMainFileID())) {
-return NoSanitizeL.containsFile(Kind, MainFile->getName());
-  }
-  return false;
+  return NoSanitizeL.containsFile(Kind, MainFile.getName());
 }
 
 bool CodeGenModule::isInNoSanitizeList(SanitizerMask Kind,
@@ -2799,8 +2801,13 @@
   const auto &NoSanitizeL = getContext().getNoSanitizeList();
   if (NoSanitizeL.containsGlobal(Kind, GV->getName(), Category))
 return true;
+  auto &SM = Context.getSourceManager();
+  if (NoSanitizeL.containsMainFile(
+  Kind, SM.getFileEntryForID(SM.getMainFileID())->getName(), Category))
+return true;
   if (NoSanitizeL.containsLocation(Kind, Loc, Category))
 return true;
+
   // Check global type.
   if (!Ty.isNull()) {
 // Drill down the array types: if global variable of a fixed type is
Index: clang/lib/Basic/NoSanitizeList.cpp
=

[PATCH] D129832: [sanitizer] Add "mainsrc" prefix to sanitizer special case list

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

> mainsrc may still be useful, e.g. if a wildcard is used to ensure the 
> prevailing one is ignored.

Not sure I understand, how can we make that? Usually it's hard to control what 
is included, especially indirectly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129832

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


[PATCH] D129832: [sanitizer] Add "mainsrc" prefix to sanitizer special case list

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

In D129832#3654066 , @MaskRay wrote:

> In D129832#3654040 , @vitalybuka 
> wrote:
>
>> problem with included files that  we don't know which non-inlined version of 
>> the function will endup in the binary
>> so using this option, user may unintentionally disable instrumentation on 
>> all included headers, even when included from a different place
>
> This argument applies to vague linkage functions which are deduplicated.
> There are many internal linkage function use cases which can benefit this, 
> e.g. `static inline`.
> But thanks for the comment. Let me improve the summary.

I understand how it benefit static inclines, it still unintentionally regress 
instrumentation for other code.
we need at least a warning in documentation

Also if this is not widespread problem, I would prefer we don't do that.
Having mainsrc: in ignore list will complicate debugging false negatives.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129832

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


[PATCH] D129832: [sanitizer] Add "mainsrc" prefix to sanitizer special case list

2022-07-14 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D129832#3654040 , @vitalybuka 
wrote:

> problem with included files that  we don't know which non-inlined version of 
> the function will endup in the binary
> so using this option, user may unintentionally disable instrumentation on all 
> included headers, even when included from a different place

This argument applies to vague linkage functions which are deduplicated.
There are many internal linkage function use cases which can benefit this, e.g. 
`static inline`.
But thanks for the comment. Let me improve the summary.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129832

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


[PATCH] D125291: Introduce @llvm.threadlocal.address intrinsic to access TLS variable

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

In D125291#3651640 , @nhaehnle wrote:

> I can't judge the Clang changes.

Now the clang part is moved to D129833 .

> On the LLVM side, can you also add the implementation and a test for the 
> GlobalISel path? Plus, I have some minor inline comments.

I don't understand it a lot since I lack experience in the backend. I've 
implemented it in SelectionDAG. And it looks redundant to implement it again in 
GlobalISel. May you explain it?




Comment at: llvm/docs/LangRef.rst:24541
+
+  declare ptr @llvm.threadlocal.address(ptr) nounwind readnone willreturn
+

ychen wrote:
> Like @jyknight already did, any idea what it would take to change the 
> parameter type from pointer to token? Looking at the test changes, it looks 
> like OpenMP is impacted a lot. I suggest splitting this patch into Clang and 
> LLVM parts to gain insights from the frontend experts.
The change for OpenMP is relatively large since they used 
utils/update_cc_test_checks.py to update their tests automatically.

I've split the clang part into https://reviews.llvm.org/D129833


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

https://reviews.llvm.org/D125291

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


[PATCH] D125291: Introduce @llvm.threadlocal.address intrinsic to access TLS variable

2022-07-14 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu updated this revision to Diff 444880.
ChuanqiXu marked 3 inline comments as done.
ChuanqiXu added a comment.

Address comments and remove verifier due to the automatic merging for constant 
expression I mentioned above.


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

https://reviews.llvm.org/D125291

Files:
  llvm/docs/LangRef.rst
  llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
  llvm/include/llvm/IR/IRBuilder.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/IR/IRBuilder.cpp
  llvm/test/CodeGen/X86/threadlocal_address.ll

Index: llvm/test/CodeGen/X86/threadlocal_address.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/threadlocal_address.ll
@@ -0,0 +1,41 @@
+; RUN: llc -mtriple=x86_64-unknown-linux-gnu -stop-after=finalize-isel %s -o - | FileCheck %s
+
+@i = thread_local global i32 0, align 4
+
+define noundef i32 @foo() {
+; CHECK: %0:gr64 = MOV64rm $rip, 1, $noreg, target-flags(x86-gottpoff) @i, $noreg :: (load (s64) from got)
+; CHECK: %1:gr32 = MOV32rm %0, 1, $noreg, 0, $fs :: (load (s32) from %ir.0)
+; CHECK: %2:gr32 = nsw INC32r %1, implicit-def dead $eflags
+; CHECK: MOV32mr %0, 1, $noreg, 0, $fs, %2 :: (store (s32) into %ir.0)
+; CHECK: $eax = COPY %2
+; CHECK: RET 0, $eax
+entry:
+  %0 = call ptr @llvm.threadlocal.address(ptr @i)
+  %1 = load i32, ptr %0, align 4
+  %inc = add nsw i32 %1, 1
+  store i32 %inc, ptr %0, align 4
+  %2 = call ptr @llvm.threadlocal.address(ptr @i)
+  %3 = load i32, ptr %2, align 4
+  ret i32 %3
+}
+
+@j =  thread_local addrspace(1) global  i32 addrspace(0)* @i, align 4
+define noundef i32 @bar() {
+; CHECK: %0:gr64 = MOV64rm $rip, 1, $noreg, target-flags(x86-gottpoff) @j, $noreg :: (load (s64) from got)
+; CHECK: %1:gr32 = MOV32rm %0, 1, $noreg, 0, $fs :: (load (s32) from %ir.0, addrspace 1)
+; CHECK: %2:gr32 = nsw INC32r %1, implicit-def dead $eflags
+; CHECK: MOV32mr %0, 1, $noreg, 0, $fs, %2 :: (store (s32) into %ir.0, addrspace 1)
+; CHECK: $eax = COPY %2
+; CHECK: RET 0, $eax
+entry:
+  %0 = call ptr addrspace(1) @llvm.threadlocal.address.p1(ptr addrspace(1) @j)
+  %1 = load i32, ptr addrspace(1) %0, align 4
+  %inc = add nsw i32 %1, 1
+  store i32 %inc, ptr addrspace(1) %0, align 4
+  %2 = call ptr addrspace(1) @llvm.threadlocal.address.p1(ptr addrspace(1) @j)
+  %3 = load i32, ptr addrspace(1) %2, align 4
+  ret i32 %3
+}
+
+declare ptr @llvm.threadlocal.address(ptr) nounwind readnone willreturn
+declare ptr addrspace(1) @llvm.threadlocal.address.p1(ptr addrspace(1)) nounwind readnone willreturn
Index: llvm/lib/IR/IRBuilder.cpp
===
--- llvm/lib/IR/IRBuilder.cpp
+++ llvm/lib/IR/IRBuilder.cpp
@@ -528,6 +528,13 @@
   return createCallHelper(TheFn, Ops, this);
 }
 
+CallInst *IRBuilderBase::CreateThreadLocalAddress(Value *Ptr) {
+  assert(isa(Ptr) && cast(Ptr)->isThreadLocal() &&
+ "threadlocal_address only applies to thread local variables.");
+  return  CreateIntrinsic(llvm::Intrinsic::threadlocal_address, {Ptr->getType()},
+ {Ptr});
+}
+
 CallInst *
 IRBuilderBase::CreateAssumption(Value *Cond,
 ArrayRef OpBundles) {
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
===
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -7167,6 +7167,10 @@
  DAG.getZExtOrTrunc(Const, sdl, PtrVT)));
 return;
   }
+  case Intrinsic::threadlocal_address: {
+setValue(&I, getValue(I.getOperand(0)));
+return;
+  }
   case Intrinsic::get_active_lane_mask: {
 EVT CCVT = TLI.getValueType(DAG.getDataLayout(), I.getType());
 SDValue Index = getValue(I.getOperand(0));
Index: llvm/include/llvm/IR/Intrinsics.td
===
--- llvm/include/llvm/IR/Intrinsics.td
+++ llvm/include/llvm/IR/Intrinsics.td
@@ -1402,6 +1402,10 @@
 def int_ptrmask: DefaultAttrsIntrinsic<[llvm_anyptr_ty], [LLVMMatchType<0>, llvm_anyint_ty],
[IntrNoMem, IntrSpeculatable, IntrWillReturn]>;
 
+// Intrinsic to wrap a thread local variable.
+def int_threadlocal_address : DefaultAttrsIntrinsic<[llvm_anyptr_ty], [LLVMMatchType<0>],
+   [IntrNoMem, IntrSpeculatable, IntrWillReturn]>;
+
 def int_experimental_stepvector : DefaultAttrsIntrinsic<[llvm_anyvector_ty],
 [], [IntrNoMem]>;
 
Index: llvm/include/llvm/IR/IRBuilder.h
===
--- llvm/include/llvm/IR/IRBuilder.h
+++ llvm/include/llvm/IR/IRBuilder.h
@@ -749,6 +749,9 @@
   /// If the pointer isn't i8* it will be converted.
   CallInst *CreateInvariantStart(Value *Ptr, ConstantInt *Size = nu

[PATCH] D129832: [sanitizer] Add "mainsrc" prefix to sanitizer special case list

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

problem with included files that  we don't know which non-inlined version of 
the function will endup in the binary
so using this option, user may unintentionally disable instrumentation on all 
included headers, even when included from a different place


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129832

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


[PATCH] D129654: [Clang][Driver] Fix include paths for `--sysroot /` on OpenBSD/FreeBSD

2022-07-14 Thread Brad Smith via Phabricator via cfe-commits
brad added a comment.

Also -stdlib=libc++ is the default on OpenBSD and FreeBSD so you can probably 
leave that out and I think you can remove --gcc-toolchain="".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129654

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


[PATCH] D129654: [Clang][Driver] Fix include paths for `--sysroot /` on OpenBSD/FreeBSD

2022-07-14 Thread Brad Smith via Phabricator via cfe-commits
brad added a comment.

In D129654#3650590 , @3405691582 
wrote:

> As mentioned, this replicates https://reviews.llvm.org/D126289 for OpenBSD 
> which fixes #28283. That particular issue caused a build problem in Swift's 
> use of VFS in which I verified this patch solves. I was trying to clarify the 
> scope and mechanism in which I tested this change, sorry for the confusion.

Ah, that clarifies things. Thank you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129654

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


[PATCH] D129832: [sanitizer] Add "mainsrc" prefix to sanitizer special case list

2022-07-14 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision.
MaskRay added reviewers: Sanitizers, hctim, kstoimenov, vitalybuka.
Herald added a subscriber: StephenFan.
Herald added a project: All.
MaskRay requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

When an issue exists in the main file (caller) instead of an included file
(callee), using a `src` pattern applying to the included file may be
inappropriate if it's the caller's responsibility. Add "mainsrc" prefix to check
the main filename.

For the example below, the issue may reside in a.c (foo should not be called
with a misaligned pointer or foo should switch to an unaligned load), but with
`src` we can only apply to the innocent callee a.h. With this patch we can use
the more appropriate `mainsrc:a.c`.

  //--- a.h
  static inline int load(int *x) { return *x; }
  
  //--- a.c
  #include "a.h"
  int foo(void *x) { return load(x); }


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129832

Files:
  clang/docs/SanitizerSpecialCaseList.rst
  clang/include/clang/Basic/NoSanitizeList.h
  clang/lib/Basic/NoSanitizeList.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/sanitize-ignorelist-mainsrc.c
  llvm/include/llvm/Support/SpecialCaseList.h

Index: llvm/include/llvm/Support/SpecialCaseList.h
===
--- llvm/include/llvm/Support/SpecialCaseList.h
+++ llvm/include/llvm/Support/SpecialCaseList.h
@@ -19,9 +19,9 @@
 //   prefix:wildcard_expression[=category]
 // If category is not specified, it is assumed to be empty string.
 // Definitions of "prefix" and "category" are sanitizer-specific. For example,
-// sanitizer exclusion support prefixes "src", "fun" and "global".
-// Wildcard expressions define, respectively, source files, functions or
-// globals which shouldn't be instrumented.
+// sanitizer exclusion support prefixes "src", "mainsrc", "fun" and "global".
+// Wildcard expressions define, respectively, source files, main source files,
+// functions or globals which shouldn't be instrumented.
 // Examples of categories:
 //   "functional": used in DFSan to list functions with pure functional
 // semantics.
@@ -37,6 +37,7 @@
 // type:*Namespace::ClassName*=init
 // src:file_with_tricky_code.cc
 // src:ignore-global-initializers-issues.cc=init
+// mainsrc:file_with_tricky_code.cc
 //
 // [dataflow]
 // # Functions with pure functional semantics:
Index: clang/test/CodeGen/sanitize-ignorelist-mainsrc.c
===
--- /dev/null
+++ clang/test/CodeGen/sanitize-ignorelist-mainsrc.c
@@ -0,0 +1,41 @@
+/// Test mainsrc in a sanitizer special case list.
+// RUN: rm -rf %t && split-file %s %t && cd %t
+// RUN: %clang_cc1 -emit-llvm -triple x86_64 -fsanitize=address,alignment a.c -o - | FileCheck %s --check-prefixes=CHECK,DEFAULT
+// RUN: %clang_cc1 -emit-llvm -triple x86_64 -fsanitize=address,alignment -fsanitize-ignorelist=a.list a.c -o - | FileCheck %s --check-prefixes=CHECK,IGNORE
+// RUN: %clang_cc1 -emit-llvm -triple x86_64 -fsanitize=address,alignment -fsanitize-ignorelist=b.list a.c -o - | FileCheck %s --check-prefixes=CHECK,IGNORE
+
+//--- a.list
+mainsrc:*a.c
+
+//--- b.list
+[address]
+mainsrc:*a.c
+
+[alignment]
+mainsrc:*.c
+
+//--- a.h
+int global_h;
+
+static inline int load(int *x) {
+  return *x;
+}
+
+//--- a.c
+#include "a.h"
+
+int global_c;
+
+int foo(void *x) {
+  return load(x);
+}
+
+// DEFAULT: @___asan_gen_{{.*}} = {{.*}} c"global_h\00"
+// DEFAULT: @___asan_gen_{{.*}} = {{.*}} c"global_c\00"
+// IGNORE-NOT:  @___asan_gen_
+
+// CHECK-LABEL: define {{.*}}@load(
+// DEFAULT:   call void @__ubsan_handle_type_mismatch_v1_abort(
+// DEFAULT:   call void @__asan_report_load4(
+// IGNORE-NOT:call void @__ubsan_handle_type_mismatch_v1_abort(
+// IGNORE-NOT:call void @__asan_report_load4(
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -2780,16 +2780,18 @@
   // NoSanitize by function name.
   if (NoSanitizeL.containsFunction(Kind, Fn->getName()))
 return true;
-  // NoSanitize by location.
+  // NoSanitize by location. Check "mainsrc" category.
+  auto &SM = Context.getSourceManager();
+  const FileEntry &MainFile = *SM.getFileEntryForID(SM.getMainFileID());
+  if (NoSanitizeL.containsMainFile(Kind, MainFile.getName()))
+return true;
+
+  // Check "src" category.
   if (Loc.isValid())
 return NoSanitizeL.containsLocation(Kind, Loc);
   // If location is unknown, this may be a compiler-generated function. Assume
   // it's located in the main file.
-  auto &SM = Context.getSourceManager();
-  if (const auto *MainFile = SM.getFileEntryForID(SM.getMainFileID())) {
-return NoSanitizeL.containsFile(Kind, MainFile->getName());
-  }
-  return false;
+  return NoSa

[PATCH] D112374: [clang] Implement ElaboratedType sugaring for types written bare

2022-07-14 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere added a subscriber: teemperor.
JDevlieghere added a comment.

In D112374#3653702 , @mizvekov wrote:

> @JDevlieghere I spent a lot of time trying to get this test running on my 
> machine to no avail. I think lldb build and test setup is quite convoluted, 
> fragile and antiquated. It uses many deprecated CMake features, It fails to 
> properly link to system libraries it needs like librt. And I just kept 
> patching these problems up and more kept coming. At some point I just gave up.

I'm sorry to hear you're having trouble building LLDB. The LLDB website has 
quite an elaborate guide with instructions in how to build LLDB: 
https://lldb.llvm.org/resources/build.html, including specific instructions on 
Windows. Windows is not my main platform, but I've successfully built LLDB 
there in the past following those instructions. I'm not sure what you feel is 
"convoluted, fragile and antiquated" about our build and test setup, as it's 
fairly similar to the rest of LLVM. I'd be happy to hear your suggestions on 
how we could improve things.

> And even this test itself requires the whole libcxx it seems, which is 
> another difficult thing to get building outside of CI.
>
> I think pre-commit CI is essential here.
>
> So I would be happy to help sort this lldb bug, but you have to help me help 
> you.

I'm happy to help out. I personally don't know if we should go with (1) or (2), 
both sound reasonable in their own way. I'd like @teemperor, who's the author 
of the feature and the affected tests, to weigh in.

> I think reverting it with no prior notification was unreasonable, and landing 
> this back as it was, no changes, is reasonable.
>
> Do you agree? Please let me know soon otherwise.

I don't. I think reverting your change was well within the guidelines outlined 
by LLVM's patch reversion policy: 
https://llvm.org/docs/DeveloperPolicy.html#patch-reversion-policy

Additionally, I think you could've given me a little bit more time to catch up 
on the discussion here. The code review policy and practices 
(https://llvm.org/docs/CodeReview.html#code-reviews-speed-and-reciprocity) 
recommend pinging every few days to once per week depending on how urgent the 
patch is.

By relanding, you broke the bots again 
(https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/45354/#showFailuresLink)
 and I'm forced to revert this change a second time. Please refrain from 
landing this again until we've settled on a way forward.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112374

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


[PATCH] D112374: [clang] Implement ElaboratedType sugaring for types written bare

2022-07-14 Thread NAKAMURA Takumi via Phabricator via cfe-commits
chapuni added inline comments.



Comment at: clang/lib/Sema/TypeLocBuilder.cpp:159
 
-  assert(Capacity - Index == TypeLoc::getFullDataSizeForType(T) &&
+  unsigned FDSz = TypeLoc::getFullDataSizeForType(T);
+  assert(Capacity - Index == FDSz &&

It causes a warning with -Asserts. May be rolled back.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112374

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


[PATCH] D129824: [RISCV] Set triple based on -march flag which can be deduced in more generic way

2022-07-14 Thread Zixuan Wu via Phabricator via cfe-commits
zixuan-wu added a comment.

In D129824#3653895 , @jrtc27 wrote:

> Does GCC allow this or not? Because this strikes me as a bad idea at first 
> sight…

GCC can deduce from -mcpu but not -mabi.

> riscv64-unknown-linux-gnu-gcc a.c -mabi=ilp32
> cc1: error: ABI requires '-march=rv32'

But I think it can be negotiated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129824

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


[PATCH] D129748: [Modules] Disable preferred_name attribute in C++20 Modules

2022-07-14 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

In D129748#3651771 , @erichkeane 
wrote:

> I guess I don't have a good idea why this attribute would cause ODR issues?  
> It would seem that if it appeared in 2 different TUs that we could just 
> 'pick' whichever we wanted, right?

If the compiler finds it appeared in 2 different TUs with different definition 
(although the judgement is wrong), the compiler would emit an error. So it 
would block the uses of C++20 Modules with `preferred_name`.

> The description in the bug report of the problem isn't clear to me what the 
> actual issue is.

Sorry. My bad. Let me try to clarify it. When we write the attribute 
`preferred_name(foo)` in ASTWriter, the compiler would try to write the type 
for the argument `foo`. Then when the compiler write the type for `foo`, the 
compiler find the type for `foo` is a TypeDef type. So the compiler would write 
the corresponding type `foo_templ`. The key point here is that the AST 
for `foo_templ` is complete now. Since the AST for `foo_templ` is 
constructed in Sema.

But problem comes when we read it. When we read the attribute 
`preferred_name(foo)`, we would read the type for the argument `foo` and then 
we would try to read the type `foo_templ` later. However, the key problem 
here is that when we read `foo_templ`, its AST is not constructed yet! So 
we get a different type with the writer writes. So here is the ODR violation.

The problem is fundamental and I've spent 2 weeks on it. But I don't find any 
fixes for it. Then I found that, once I disabled `preferred_name`, we could go 
much further. So I am wondering if it would be an option to skip 
`preferred_name` if C++ modules is enabled. The idea may not be good in 
general. But I feel it might be an option in this specific case given it is 
hard to solve and `preferred_name` is primarily for printers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129748

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


[PATCH] D129824: [RISCV] Set triple based on -march flag which can be deduced in more generic way

2022-07-14 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added a comment.

Does GCC allow this or not? Because this strikes me as a bad idea at first 
sight…


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129824

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


[PATCH] D54214: [RISCV] Set triple based on -march flag

2022-07-14 Thread Zixuan Wu via Phabricator via cfe-commits
zixuan-wu added a comment.
Herald added subscribers: sunshaoce, pcwang-thead, eopXD, VincentWu, luke957, 
StephenFan, vkmr, frasercrmck, evandro, luismarques, MaskRay, arichardson.
Herald added a project: All.

In D54214#1737255 , @simoncook wrote:

> Rebase.
>
> @lenary Following the discussion regarding D69383 
> , I think it's best for now to keep the 
> logic just keeping `-march` directly, rather than using `getRISCVArch`. I 
> think in the case of `-target risc32-. -mabi=lp64` I think it would 
> confuse users if the tools suddenly changed to doing an rv64 compile. If we 
> disable that, all that function would provide me is the same StringRef I'm 
> already evaluating. I think adding any extra flag to indicate whether a 
> rv32<->rv64 switch is acceptable would just make the code unnecessarily more 
> messy. I think in the future if `getRISCVArch` evaluates more flags, then it 
> might make sense to reconsider this.

I think the case of `-target risc32-. -mabi=lp64` is acceptable since the 
-target is less usable than -march/-mabi/-mcpu and is almost invisible to users.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D54214

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


[PATCH] D129824: [RISCV] Set triple based on -march flag which can be deduced in more generic way

2022-07-14 Thread Zixuan Wu via Phabricator via cfe-commits
zixuan-wu created this revision.
zixuan-wu added reviewers: simoncook, lenary, asb.
Herald added subscribers: sunshaoce, VincentWu, luke957, StephenFan, vkmr, 
frasercrmck, evandro, luismarques, apazos, sameer.abuasal, s.egerton, Jim, 
benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, 
edward-jones, zzheng, jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, 
johnrusso, rbar, arichardson.
Herald added a project: All.
zixuan-wu requested review of this revision.
Herald added subscribers: cfe-commits, pcwang-thead, eopXD, MaskRay.
Herald added a project: clang.

Now RISC-V the value provided to -march can determine whether to compile for 
32- or 64-bit RISC-V irrespective of the target provided to the Clang driver. 
Further, -march can be deduced in more generic way without providing -march but 
-mcpu or -mabi.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129824

Files:
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/riscv-abi.c
  clang/test/Driver/riscv-arch.c


Index: clang/test/Driver/riscv-arch.c
===
--- clang/test/Driver/riscv-arch.c
+++ clang/test/Driver/riscv-arch.c
@@ -392,12 +392,29 @@
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-TARGET %s
 // RUN: %clang --target=riscv64-unknown-elf -march=rv32i -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-TARGET %s
+// RUN: %clang --target=riscv32-unknown-elf -mcpu=sifive-e20 -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-TARGET %s
+// RUN: %clang --target=riscv64-unknown-elf -mcpu=sifive-e20 -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-TARGET %s
+// RUN: %clang --target=riscv32-unknown-elf -mabi=ilp32 -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-TARGET %s
+// RUN: %clang --target=riscv64-unknown-elf -mabi=ilp32 -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-TARGET %s
 // RV32-TARGET: "-triple" "riscv32-unknown-unknown-elf"
 
+
 // RUN: %clang --target=riscv32-unknown-elf -march=rv64i -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV64-TARGET %s
 // RUN: %clang --target=riscv64-unknown-elf -march=rv64i -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV64-TARGET %s
+// RUN: %clang --target=riscv32-unknown-elf -mcpu=sifive-s21 -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV64-TARGET %s
+// RUN: %clang --target=riscv64-unknown-elf -mcpu=sifive-s21 -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV64-TARGET %s
+// RUN: %clang --target=riscv32-unknown-elf -mabi=lp64 -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV64-TARGET %s
+// RUN: %clang --target=riscv64-unknown-elf -mabi=lp64 -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV64-TARGET %s
 // RV64-TARGET: "-triple" "riscv64-unknown-unknown-elf"
 
 // RUN: %clang --target=riscv32-unknown-elf -march=rv32ifzfh01p0 -### %s \
Index: clang/test/Driver/riscv-abi.c
===
--- clang/test/Driver/riscv-abi.c
+++ clang/test/Driver/riscv-abi.c
@@ -40,11 +40,6 @@
 
 // CHECK-ILP32D: "-target-abi" "ilp32d"
 
-// RUN: not %clang --target=riscv32-unknown-elf %s -o %t.o -mabi=lp64 2>&1 \
-// RUN:   | FileCheck -check-prefix=CHECK-RV32-LP64 %s
-
-// CHECK-RV32-LP64: error: unknown target ABI 'lp64'
-
 // RUN: %clang --target=riscv64-unknown-elf %s -### 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-LP64 %s
 // RUN: %clang --target=riscv64-unknown-elf %s -### -mabi=lp64 2>&1 \
@@ -77,8 +72,3 @@
 // RUN:   | FileCheck -check-prefix=CHECK-LP64D  %s
 
 // CHECK-LP64D: "-target-abi" "lp64d"
-
-// RUN: not %clang --target=riscv64-unknown-elf %s -o %t.o -mabi=ilp32 2>&1 \
-// RUN:   | FileCheck -check-prefix=CHECK-RV64-ILP32 %s
-
-// CHECK-RV64-ILP32: error: unknown target ABI 'ilp32'
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -7,6 +7,8 @@
 
//===--===//
 
 #include "clang/Driver/Driver.h"
+#include "ToolChains/Arch/RISCV.h"
+#include "ToolChains/AIX.h"
 #include "ToolChains/AIX.h"
 #include "ToolChains/AMDGPU.h"
 #include "ToolChains/AMDGPUOpenMP.h"
@@ -650,13 +652,16 @@
   }
 
   // If target is RISC-V adjust the target triple according to
-  // provided architecture name
-  A = Args.getLastArg(options::OPT_march_EQ);
-  if (A && Target.isRISCV()) {
-StringRef ArchName = A->getValue();
-if (ArchName.startswith_insensitive("rv32"))
+  // provided architecture relative info such as -march/-mcpu/-mabi.
+  if (Target.isRISCV()) {
+StringRef ArchName = tools::riscv::getRISCVArch(Args, Target);
+llvm::Triple::ArchType RVArch = Target.getArch();
+
+if (RVArch == llvm::Triple::riscv64 &&
+ArchName.startswith_insensitive("rv32"))
 

[PATCH] D112374: [clang] Implement ElaboratedType sugaring for types written bare

2022-07-14 Thread Matheus Izvekov via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7c51f02effdb: [clang] Implement ElaboratedType sugaring for 
types written bare (authored by mizvekov).

Changed prior to commit:
  https://reviews.llvm.org/D112374?vs=444113&id=444856#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112374

Files:
  clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp
  clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp
  clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/SmartPtrArrayMismatchCheck.cpp
  clang-tools-extra/clang-tidy/google/AvoidCStyleCastsCheck.cpp
  clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp
  clang-tools-extra/clang-tidy/misc/MisplacedConstCheck.cpp
  clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
  clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/unittests/ASTTests.cpp
  clang-tools-extra/clangd/unittests/DumpASTTests.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone/copy-constructor-init.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone/shared-ptr-array-mismatch.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone/suspicious-memory-comparison-32bits.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone/suspicious-memory-comparison.cpp
  clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
  clang-tools-extra/unittests/clang-change-namespace/ChangeNamespaceTests.cpp
  clang/bindings/python/tests/cindex/test_type.py
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Type.h
  clang/include/clang/AST/TypeLoc.h
  clang/lib/ARCMigrate/ObjCMT.cpp
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTDiagnostic.cpp
  clang/lib/AST/DeclCXX.cpp
  clang/lib/AST/ExprCXX.cpp
  clang/lib/AST/FormatString.cpp
  clang/lib/AST/PrintfFormatString.cpp
  clang/lib/AST/QualTypeNames.cpp
  clang/lib/AST/ScanfFormatString.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/Analysis/RetainSummaryManager.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaExprObjC.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaType.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Sema/TypeLocBuilder.cpp
  clang/lib/Sema/TypeLocBuilder.h
  clang/lib/StaticAnalyzer/Checkers/NonnullGlobalConstantsChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/NumberObjectConversionChecker.cpp
  clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp
  clang/test/AST/ast-dump-APValue-anon-union.cpp
  clang/test/AST/ast-dump-APValue-struct.cpp
  clang/test/AST/ast-dump-APValue-union.cpp
  clang/test/AST/ast-dump-decl.cpp
  clang/test/AST/ast-dump-expr-json.cpp
  clang/test/AST/ast-dump-expr.cpp
  clang/test/AST/ast-dump-funcs.cpp
  clang/test/AST/ast-dump-openmp-begin-declare-variant_template_3.cpp
  clang/test/AST/ast-dump-overloaded-operators.cpp
  clang/test/AST/ast-dump-records-json.cpp
  clang/test/AST/ast-dump-recovery.cpp
  clang/test/AST/ast-dump-stmt-json.cpp
  clang/test/AST/ast-dump-stmt.cpp
  clang/test/AST/ast-dump-template-decls-json.cpp
  clang/test/AST/ast-dump-temporaries-json.cpp
  clang/test/AST/ast-dump-using-template.cpp
  clang/test/AST/ast-dump-using.cpp
  clang/test/AST/coroutine-locals-cleanup-exp-namespace.cpp
  clang/test/AST/coroutine-locals-cleanup.cpp
  clang/test/AST/float16.cpp
  clang/test/AST/sourceranges.cpp
  clang/test/Analysis/Inputs/expected-plists/NewDelete-path-notes.cpp.plist
  clang/test/Analysis/Inputs/expected-plists/cxx-for-range.cpp.plist
  clang/test/Analysis/Inputs/expected-plists/method-call-path-notes.cpp.plist
  clang/test/Analysis/analyzer-display-progress.cpp
  clang/test/Analysis/auto-obj-dtors-cfg-output.cpp
  clang/test/Analysis/blocks.mm
  clang/test/Analysis/bug_hash_test.cpp
  clang/test/Analysis/cast-value-notes.cpp
  clang/test/Analysis/cast-value-state-dump.cpp
  clang/test/Analysis/cfg-rich-constructors.cpp
  clang/test/Analysis/cfg-rich-constructors.mm
  clang/test/Analysis/cfg.cpp
  clang/test/Analysis/copy-elision.cpp
  clang/test/Analysis/cxx-uninitialized-object-inheritance.cpp
  clang/test/Analysis/dump

[PATCH] D129771: [clang-format] distinguish multiplication after brace-init from pointer

2022-07-14 Thread Jack Huang via Phabricator via cfe-commits
jackhong12 accepted this revision.
jackhong12 added a comment.

I think we can also add new test cases in 
`clang/unittests/Format/TokenAnnotatorTest.cpp`.

  Tokens = annotate("int i = int{42} * 34;");
  ...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129771

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


[PATCH] D125291: Introduce @llvm.threadlocal.address intrinsic to access TLS variable

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



Comment at: llvm/docs/LangRef.rst:24541
+
+  declare ptr @llvm.threadlocal.address(ptr) nounwind readnone willreturn
+

Like @jyknight already did, any idea what it would take to change the parameter 
type from pointer to token? Looking at the test changes, it looks like OpenMP 
is impacted a lot. I suggest splitting this patch into Clang and LLVM parts to 
gain insights from the frontend experts.



Comment at: llvm/lib/IR/IRBuilder.cpp:533
+  if (!isa(Ptr) || !cast(Ptr)->isThreadLocal()) {
+llvm::outs() << "Non Global Value wanted.\n";
+Ptr->dump();

Here and below `llvm::outs()` are for debugging and should be removed?


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

https://reviews.llvm.org/D125291

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


[PATCH] D112374: [clang] Implement ElaboratedType sugaring for types written bare

2022-07-14 Thread Mike Hommey via Phabricator via cfe-commits
glandium added a comment.

In D112374#3651218 , @mizvekov wrote:

> Can you confirm that this `NoPrincipalGetURI` matcher would, in clang version 
> without this patch here, fail to match if you had rewritten the `GetUri` 
> method to use a qualified name?

I can confirm it's the case, and your fix works. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112374

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


[PATCH] D112374: [clang] Implement ElaboratedType sugaring for types written bare

2022-07-14 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added a comment.

@JDevlieghere I spent a lot of time trying to get this test running on my 
machine to no avail. I think lldb build and test setup is quite convoluted, 
fragile and antiquated. It uses many deprecated CMake features, It fails to 
properly link to system libraries it needs like librt. And I just kept patching 
these problems up and more kept coming. At some point I just gave up.

And even this test itself requires the whole libcxx it seems, which is another 
difficult thing to get building outside of CI.

I think pre-commit CI is essential here.

So I would be happy to help sort this lldb bug, but you have to help me help 
you.

I think reverting it with no prior notification was unreasonable, and landing 
this back as it was, no changes, is reasonable.

Do you agree? Please let me know soon otherwise.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112374

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


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

2022-07-14 Thread Vang Thao via Phabricator via cfe-commits
vangthao updated this revision to Diff 444844.
vangthao added a comment.

Change `auto &&Argument` to `auto Argument`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123878

Files:
  clang/test/Frontend/amdgcn-machine-analysis-remarks.cl
  llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
  llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.h
  llvm/lib/Target/AMDGPU/SIProgramInfo.h
  llvm/test/CodeGen/AMDGPU/resource-optimization-remarks.ll

Index: llvm/test/CodeGen/AMDGPU/resource-optimization-remarks.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AMDGPU/resource-optimization-remarks.ll
@@ -0,0 +1,158 @@
+; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx908 -pass-remarks-output=%t -pass-remarks-analysis=kernel-resource-usage -filetype=obj -o /dev/null %s 2>&1 | FileCheck -check-prefix=STDERR %s
+; RUN: FileCheck -check-prefix=REMARK %s < %t
+
+; STDERR: remark: foo.cl:27:0: Function Name: test_kernel
+; STDERR-NEXT: remark: foo.cl:27:0: SGPRs: 24
+; STDERR-NEXT: remark: foo.cl:27:0: VGPRs: 9
+; STDERR-NEXT: remark: foo.cl:27:0: AGPRs: 43
+; STDERR-NEXT: remark: foo.cl:27:0: ScratchSize [bytes/lane]: 0
+; STDERR-NEXT: remark: foo.cl:27:0: Occupancy [waves/SIMD]: 5
+; STDERR-NEXT: remark: foo.cl:27:0: SGPRs Spill: 0
+; STDERR-NEXT: remark: foo.cl:27:0: VGPRs Spill: 0
+; STDERR-NEXT: remark: foo.cl:27:0: LDS Size [bytes/block]: 512
+
+; REMARK-LABEL: --- !Analysis
+; REMARK: Pass:kernel-resource-usage
+; REMARK-NEXT: Name:FunctionName
+; REMARK-NEXT: DebugLoc:{ File: foo.cl, Line: 27, Column: 0 }
+; REMARK-NEXT: Function:test_kernel
+; REMARK-NEXT: Args:
+; REMARK-NEXT:   - String:  'Function Name: '
+; REMARK-NEXT:   - FunctionName:  test_kernel
+; REMARK-NEXT: ...
+; REMARK-NEXT: --- !Analysis
+; REMARK-NEXT: Pass:kernel-resource-usage
+; REMARK-NEXT: Name:NumSGPR
+; REMARK-NEXT: DebugLoc:{ File: foo.cl, Line: 27, Column: 0 }
+; REMARK-NEXT: Function:test_kernel
+; REMARK-NEXT: Args:
+; REMARK-NEXT:   - String:  'SGPRs: '
+; REMARK-NEXT:   - NumSGPR: '24'
+; REMARK-NEXT: ...
+; REMARK-NEXT: --- !Analysis
+; REMARK-NEXT: Pass:kernel-resource-usage
+; REMARK-NEXT: Name:NumVGPR
+; REMARK-NEXT: DebugLoc:{ File: foo.cl, Line: 27, Column: 0 }
+; REMARK-NEXT: Function:test_kernel
+; REMARK-NEXT: Args:
+; REMARK-NEXT:   - String:  'VGPRs: '
+; REMARK-NEXT:   - NumVGPR: '9'
+; REMARK-NEXT: ...
+; REMARK-NEXT: --- !Analysis
+; REMARK-NEXT: Pass:kernel-resource-usage
+; REMARK-NEXT: Name:NumAGPR
+; REMARK-NEXT: DebugLoc:{ File: foo.cl, Line: 27, Column: 0 }
+; REMARK-NEXT: Function:test_kernel
+; REMARK-NEXT: Args:
+; REMARK-NEXT:   - String:  'AGPRs: '
+; REMARK-NEXT:   - NumAGPR: '43'
+; REMARK-NEXT: ...
+; REMARK-NEXT: --- !Analysis
+; REMARK-NEXT: Pass:kernel-resource-usage
+; REMARK-NEXT: Name:ScratchSize
+; REMARK-NEXT: DebugLoc:{ File: foo.cl, Line: 27, Column: 0 }
+; REMARK-NEXT: Function:test_kernel
+; REMARK-NEXT: Args:
+; REMARK-NEXT:   - String:  'ScratchSize [bytes/lane]: '
+; REMARK-NEXT:   - ScratchSize: '0'
+; REMARK-NEXT: ...
+; REMARK-NEXT: --- !Analysis
+; REMARK-NEXT: Pass:kernel-resource-usage
+; REMARK-NEXT: Name:Occupancy
+; REMARK-NEXT: DebugLoc:{ File: foo.cl, Line: 27, Column: 0 }
+; REMARK-NEXT: Function:test_kernel
+; REMARK-NEXT: Args:
+; REMARK-NEXT:   - String:  'Occupancy [waves/SIMD]: '
+; REMARK-NEXT:   - Occupancy:   '5'
+; REMARK-NEXT: ...
+; REMARK-NEXT: --- !Analysis
+; REMARK-NEXT: Pass:kernel-resource-usage
+; REMARK-NEXT: Name:SGPRSpill
+; REMARK-NEXT: DebugLoc:{ File: foo.cl, Line: 27, Column: 0 }
+; REMARK-NEXT: Function:test_kernel
+; REMARK-NEXT: Args:
+; REMARK-NEXT:   - String:  'SGPRs Spill: '
+; REMARK-NEXT:   - SGPRSpill:   '0'
+; REMARK-NEXT: ...
+; REMARK-NEXT: --- !Analysis
+; REMARK-NEXT: Pass:kernel-resource-usage
+; REMARK-NEXT: Name:VGPRSpill
+; REMARK-NEXT: DebugLoc:{ File: foo.cl, Line: 27, Column: 0 }
+; REMARK-NEXT: Function:test_kernel
+; REMARK-NEXT: Args:
+; REMARK-NEXT:   - String:  'VGPRs Spill: '
+; REMARK-NEXT:   - VGPRSpill:   '0'
+; REMARK-NEXT: ...
+; REMARK-NEXT: --- !Analysis
+; REMARK-NEXT: Pass:kernel-resource-usage
+; REMARK-NEXT: Name:BytesLDS
+; REMARK-NEXT: DebugLoc:{ File: foo.cl, Line: 27, Column: 0 }
+; REMARK-NEXT: Function:test_kernel
+; REMARK-NEXT: Args:
+; REMARK-NEXT:   - String:  'LDS Size [bytes/block]: '
+; REMARK-NEXT:   - BytesLDS:'512'
+; REMARK-NEXT: ...
+
+@l

[PATCH] D129160: libclang.so: Make SONAME the same as LLVM version

2022-07-14 Thread Tom Stellard via Phabricator via cfe-commits
tstellar updated this revision to Diff 444843.
tstellar added a comment.

Add release note.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129160

Files:
  clang/docs/ReleaseNotes.rst
  clang/tools/libclang/CMakeLists.txt
  clang/tools/libclang/libclang.exports
  clang/tools/libclang/libclang.map
  clang/tools/libclang/linker-script-to-export-list.py

Index: clang/tools/libclang/linker-script-to-export-list.py
===
--- clang/tools/libclang/linker-script-to-export-list.py
+++ /dev/null
@@ -1,11 +0,0 @@
-import re
-import os
-import sys
-
-input_file = open(sys.argv[1])
-output_file = open(sys.argv[2], 'w')
-
-for line in input_file:
-m = re.search('^\s+(clang_[^;]+)', line)
-if m:
-output_file.write(m.group(1) + "\n")
Index: clang/tools/libclang/libclang.map
===
--- clang/tools/libclang/libclang.map
+++ /dev/null
@@ -1,413 +0,0 @@
-# If you add a symbol to this file, make sure to add it with the correct
-# version.  For example, if the LLVM main branch is LLVM 14.0.0, add new
-# symbols with the version LLVM_14.
-# On platforms where versions scripts are not used, this file will be used to
-# generate a list of exports for libclang.so
-
-LLVM_13 {
-  global:
-clang_BlockCommandComment_getArgText;
-clang_BlockCommandComment_getCommandName;
-clang_BlockCommandComment_getNumArgs;
-clang_BlockCommandComment_getParagraph;
-clang_CXCursorSet_contains;
-clang_CXCursorSet_insert;
-clang_CXIndex_getGlobalOptions;
-clang_CXIndex_setGlobalOptions;
-clang_CXIndex_setInvocationEmissionPathOption;
-clang_CXRewriter_create;
-clang_CXRewriter_dispose;
-clang_CXRewriter_insertTextBefore;
-clang_CXRewriter_overwriteChangedFiles;
-clang_CXRewriter_removeText;
-clang_CXRewriter_replaceText;
-clang_CXRewriter_writeMainFileToStdOut;
-clang_CXXConstructor_isConvertingConstructor;
-clang_CXXConstructor_isCopyConstructor;
-clang_CXXConstructor_isDefaultConstructor;
-clang_CXXConstructor_isMoveConstructor;
-clang_CXXField_isMutable;
-clang_CXXMethod_isConst;
-clang_CXXMethod_isDefaulted;
-clang_CXXMethod_isPureVirtual;
-clang_CXXMethod_isStatic;
-clang_CXXMethod_isVirtual;
-clang_CXXRecord_isAbstract;
-clang_Comment_getChild;
-clang_Comment_getKind;
-clang_Comment_getNumChildren;
-clang_Comment_isWhitespace;
-clang_CompilationDatabase_dispose;
-clang_CompilationDatabase_fromDirectory;
-clang_CompilationDatabase_getAllCompileCommands;
-clang_CompilationDatabase_getCompileCommands;
-clang_CompileCommand_getArg;
-clang_CompileCommand_getDirectory;
-clang_CompileCommand_getFilename;
-clang_CompileCommand_getMappedSourceContent;
-clang_CompileCommand_getMappedSourcePath;
-clang_CompileCommand_getNumArgs;
-clang_CompileCommand_getNumMappedSources;
-clang_CompileCommands_dispose;
-clang_CompileCommands_getCommand;
-clang_CompileCommands_getSize;
-clang_Cursor_Evaluate;
-clang_Cursor_getArgument;
-clang_Cursor_getBriefCommentText;
-clang_Cursor_getCXXManglings;
-clang_Cursor_getCommentRange;
-clang_Cursor_getMangling;
-clang_Cursor_getModule;
-clang_Cursor_getNumArguments;
-clang_Cursor_getNumTemplateArguments;
-clang_Cursor_getObjCDeclQualifiers;
-clang_Cursor_getObjCManglings;
-clang_Cursor_getObjCPropertyAttributes;
-clang_Cursor_getObjCPropertyGetterName;
-clang_Cursor_getObjCPropertySetterName;
-clang_Cursor_getObjCSelectorIndex;
-clang_Cursor_getOffsetOfField;
-clang_Cursor_getParsedComment;
-clang_Cursor_getRawCommentText;
-clang_Cursor_getReceiverType;
-clang_Cursor_getSpellingNameRange;
-clang_Cursor_getStorageClass;
-clang_Cursor_getTemplateArgumentKind;
-clang_Cursor_getTemplateArgumentType;
-clang_Cursor_getTemplateArgumentUnsignedValue;
-clang_Cursor_getTemplateArgumentValue;
-clang_Cursor_getTranslationUnit;
-clang_Cursor_getVarDeclInitializer;
-clang_Cursor_hasAttrs;
-clang_Cursor_hasVarDeclExternalStorage;
-clang_Cursor_hasVarDeclGlobalStorage;
-clang_Cursor_isAnonymous;
-clang_Cursor_isAnonymousRecordDecl;
-clang_Cursor_isBitField;
-clang_Cursor_isDynamicCall;
-clang_Cursor_isExternalSymbol;
-clang_Cursor_isFunctionInlined;
-clang_Cursor_isInlineNamespace;
-clang_Cursor_isMacroBuiltin;
-clang_Cursor_isMacroFunctionLike;
-clang_Cursor_isNull;
-clang_Cursor_isObjCOptional;
-clang_Cursor_isVariadic;
-clang_EnumDecl_isScoped;
-clang_EvalResult_dispose;
-clang_EvalResult_getAsDouble;
-clang_EvalResult_getAsInt;
-clang_EvalResult_getAsLongLong;
-clang_EvalResult_getAsStr;
-clang_EvalResult_getAsUnsigned;
-clang_EvalResult_getKind;

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

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

In D125693#3648942 , @krisb wrote:

> In D125693#3644029 , @dblaikie 
> wrote:
>
>> In D125693#3641742 , @krisb wrote:
>>
>>> @dblaikie, could you please take a look at this and/or D113741 
>>> ? Do you see any ways to proceed?
>>
>> My concern with this direction is that anything that adds lists to the IR 
>> metadata makes it difficult for that data to be dropped when it becomes 
>> unused (the type graph, apart from the "retained types" on the CU, is 
>> structured so that if a variable, say, gets optimized away, or a function 
>> gets optimized away and its parameters along with it, the types get dropped 
>> too - similarly with function descriptions, they aren't in a list (they used 
>> to be) and are instead referenced from the `llvm::Function` ensuring that if 
>> the function is optimized away entirely, the debug info for that goes away 
>> too). Admittedly function-local things are handled somewhat differently, for 
>> instance there is a list on the `DISubprogram` of the local variables to 
>> ensure they are retained through optimizations so name lookup does the right 
>> things at function-scope. So /maybe/ it's OK to move in that direction here, 
>> but it might look more like that, add these other function-local things to 
>> the `DISubprogram`-scoped list (rename the list to generalize over more than 
>> just variables), rather than adding per-scope lists?
>
> Initially, I made the dedicated per-scope list of local static 
> vars/imports/types to make possible to remove unused entities if their parent 
> scope gets optimized out. This doesn't fully resolve your concern about local 
> types that might be emitted even if they are not used, but this makes the 
> things a bit better. Moreover, such local entities as well as 
> variables/labels are not going to be emitted to a final DWARF if their scope 
> was optimized away. Currently, to emit any local entity we need its scope to 
> have LexicalScope defined. If there are no DILocations in such a scope (so 
> that it may be considered as optimized out), it will not have LexicalScope 
> defined for it, thus no variables/labels/other local things will be emitted 
> for it. So, if we are not going to change this design in a near future, it 
> might be worse to consider switching local variables/labels to per-scope list 
> as well.
>
> What about merging variables/labels/other entities to a single list, I fully 
> support this idea (it would require some additional checks in the backend, 
> but would look more consistent).

Ah, fair point about implicitly dropping some debug info if it's in a dead 
scope. & yeah, maybe moving the existing optimized local variables list into a 
per-scope list might be a nice improvement regardless.

@aprantl @probinson you folks have any thoughts on this? I'm starting to lean 
towards this being: 1) move the current "optimized variables" subprogram list 
into the lexical scope 2) add other local things into that list 3) profit. 
Though adding a list/fiel dto every lexical scope feels a bit heavy - not sure 
if there's a good metric/benchmark to measure the impact of that on memory 
usage, bitcode size, etc. It's probably not that big in the grand scheme of 
things, though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125693

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


[PATCH] D128462: [HLSL] add -I option for dxc mode.

2022-07-14 Thread Xiang Li via Phabricator via cfe-commits
python3kgae updated this revision to Diff 444834.
python3kgae added a comment.

Remove DXCJoinedOrSeparateConflict.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128462

Files:
  clang/include/clang/Driver/Options.h
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/dxc_I.hlsl

Index: clang/test/Driver/dxc_I.hlsl
===
--- /dev/null
+++ clang/test/Driver/dxc_I.hlsl
@@ -0,0 +1,4 @@
+// RUN: %clang_dxc -I test  -### %s 2>&1 | FileCheck %s
+
+// Make sure -I send to cc1.
+// CHECK:"-I" "test"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3481,6 +3481,7 @@
   types::ID InputType) {
   const unsigned ForwardedArguments[] = {options::OPT_dxil_validator_version,
  options::OPT_D,
+ options::OPT_I,
  options::OPT_S,
  options::OPT_emit_llvm,
  options::OPT_disable_llvm_passes,
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -6225,6 +6225,7 @@
   if (IsClCompatMode) {
 // Include CL and Core options.
 IncludedFlagsBitmask |= options::CLOption;
+IncludedFlagsBitmask |= options::CLDXCOption;
 IncludedFlagsBitmask |= options::CoreOption;
   } else {
 ExcludedFlagsBitmask |= options::CLOption;
@@ -6232,10 +6233,14 @@
   if (IsDXCMode()) {
 // Include DXC and Core options.
 IncludedFlagsBitmask |= options::DXCOption;
+IncludedFlagsBitmask |= options::CLDXCOption;
 IncludedFlagsBitmask |= options::CoreOption;
   } else {
 ExcludedFlagsBitmask |= options::DXCOption;
   }
+  if (!IsClCompatMode && !IsDXCMode())
+ExcludedFlagsBitmask |= options::CLDXCOption;
+
   return std::make_pair(IncludedFlagsBitmask, ExcludedFlagsBitmask);
 }
 
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -53,6 +53,10 @@
 // are made available when the driver is running in DXC compatibility mode.
 def DXCOption : OptionFlag;
 
+// CLDXCOption - This is a cl.exe/dxc.exe compatibility option. Options with this flag
+// are made available when the driver is running in CL/DXC compatibility mode.
+def CLDXCOption : OptionFlag;
+
 // NoDriverOption - This option should not be accepted by the driver.
 def NoDriverOption : OptionFlag;
 
@@ -6306,7 +6310,7 @@
 // clang-cl Options
 //===--===//
 
-def cl_Group : OptionGroup<"">, Flags<[CLOption]>,
+def cl_Group : OptionGroup<"">, Flags<[CLDXCOption]>,
   HelpText<"CL.EXE COMPATIBILITY OPTIONS">;
 
 def cl_compile_Group : OptionGroup<"">,
@@ -6336,6 +6340,9 @@
 class CLJoinedOrSeparate : Option<["/", "-"], name,
   KIND_JOINED_OR_SEPARATE>, Group, Flags<[CLOption, NoXarchOption]>;
 
+class CLDXCJoinedOrSeparate : Option<["/", "-"], name,
+  KIND_JOINED_OR_SEPARATE>, Group, Flags<[CLDXCOption, NoXarchOption]>;
+
 class CLCompileJoinedOrSeparate : Option<["/", "-"], name,
   KIND_JOINED_OR_SEPARATE>, Group,
   Flags<[CLOption, NoXarchOption]>;
@@ -6413,7 +6420,7 @@
 def _SLASH_HELP : CLFlag<"HELP">, Alias;
 def _SLASH_hotpatch : CLFlag<"hotpatch">, Alias,
   HelpText<"Create hotpatchable image">;
-def _SLASH_I : CLJoinedOrSeparate<"I">,
+def _SLASH_I : CLDXCJoinedOrSeparate<"I">,
   HelpText<"Add directory to include search path">, MetaVarName<"">,
   Alias;
 def _SLASH_J : CLFlag<"J">, HelpText<"Make char type unsigned">,
Index: clang/include/clang/Driver/Options.h
===
--- clang/include/clang/Driver/Options.h
+++ clang/include/clang/Driver/Options.h
@@ -36,7 +36,8 @@
   FC1Option = (1 << 15),
   FlangOnlyOption = (1 << 16),
   DXCOption = (1 << 17),
-  Ignored = (1 << 18),
+  CLDXCOption = (1 << 18),
+  Ignored = (1 << 19),
 };
 
 enum ID {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D128462: [HLSL] add -I option for dxc mode.

2022-07-14 Thread Xiang Li via Phabricator via cfe-commits
python3kgae updated this revision to Diff 444830.
python3kgae marked an inline comment as done.
python3kgae added a comment.

Merge change from Chris.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128462

Files:
  clang/include/clang/Driver/Options.h
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/dxc_I.hlsl

Index: clang/test/Driver/dxc_I.hlsl
===
--- /dev/null
+++ clang/test/Driver/dxc_I.hlsl
@@ -0,0 +1,4 @@
+// RUN: %clang_dxc -I test  -### %s 2>&1 | FileCheck %s
+
+// Make sure -I send to cc1.
+// CHECK:"-I" "test"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3481,6 +3481,7 @@
   types::ID InputType) {
   const unsigned ForwardedArguments[] = {options::OPT_dxil_validator_version,
  options::OPT_D,
+ options::OPT_I,
  options::OPT_S,
  options::OPT_emit_llvm,
  options::OPT_disable_llvm_passes,
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -6225,6 +6225,7 @@
   if (IsClCompatMode) {
 // Include CL and Core options.
 IncludedFlagsBitmask |= options::CLOption;
+IncludedFlagsBitmask |= options::CLDXCOption;
 IncludedFlagsBitmask |= options::CoreOption;
   } else {
 ExcludedFlagsBitmask |= options::CLOption;
@@ -6232,10 +6233,14 @@
   if (IsDXCMode()) {
 // Include DXC and Core options.
 IncludedFlagsBitmask |= options::DXCOption;
+IncludedFlagsBitmask |= options::CLDXCOption;
 IncludedFlagsBitmask |= options::CoreOption;
   } else {
 ExcludedFlagsBitmask |= options::DXCOption;
   }
+  if (!IsClCompatMode && !IsDXCMode())
+ExcludedFlagsBitmask |= options::CLDXCOption;
+
   return std::make_pair(IncludedFlagsBitmask, ExcludedFlagsBitmask);
 }
 
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -53,6 +53,10 @@
 // are made available when the driver is running in DXC compatibility mode.
 def DXCOption : OptionFlag;
 
+// CLDXCOption - This is a cl.exe/dxc.exe compatibility option. Options with this flag
+// are made available when the driver is running in CL/DXC compatibility mode.
+def CLDXCOption : OptionFlag;
+
 // NoDriverOption - This option should not be accepted by the driver.
 def NoDriverOption : OptionFlag;
 
@@ -6306,7 +6310,7 @@
 // clang-cl Options
 //===--===//
 
-def cl_Group : OptionGroup<"">, Flags<[CLOption]>,
+def cl_Group : OptionGroup<"">, Flags<[CLDXCOption]>,
   HelpText<"CL.EXE COMPATIBILITY OPTIONS">;
 
 def cl_compile_Group : OptionGroup<"">,
@@ -6336,6 +6340,9 @@
 class CLJoinedOrSeparate : Option<["/", "-"], name,
   KIND_JOINED_OR_SEPARATE>, Group, Flags<[CLOption, NoXarchOption]>;
 
+class CLDXCJoinedOrSeparate : Option<["/", "-"], name,
+  KIND_JOINED_OR_SEPARATE>, Group, Flags<[CLDXCOption, NoXarchOption]>;
+
 class CLCompileJoinedOrSeparate : Option<["/", "-"], name,
   KIND_JOINED_OR_SEPARATE>, Group,
   Flags<[CLOption, NoXarchOption]>;
@@ -6413,7 +6420,7 @@
 def _SLASH_HELP : CLFlag<"HELP">, Alias;
 def _SLASH_hotpatch : CLFlag<"hotpatch">, Alias,
   HelpText<"Create hotpatchable image">;
-def _SLASH_I : CLJoinedOrSeparate<"I">,
+def _SLASH_I : CLDXCJoinedOrSeparate<"I">,
   HelpText<"Add directory to include search path">, MetaVarName<"">,
   Alias;
 def _SLASH_J : CLFlag<"J">, HelpText<"Make char type unsigned">,
@@ -6820,6 +6827,8 @@
   Group, Flags<[DXCOption, NoXarchOption]>;
 class DXCJoinedOrSeparate : Option<["/", "-"], name,
   KIND_JOINED_OR_SEPARATE>, Group, Flags<[DXCOption, NoXarchOption]>;
+class DXCJoinedOrSeparateConflict : Option<["--", "/", "-"], name,
+  KIND_JOINED_OR_SEPARATE>, Group, Flags<[DXCOption, NoXarchOption]>;
 
 def dxc_help : Option<["/", "-", "--"], "help", KIND_JOINED>,
   Group, Flags<[DXCOption, NoXarchOption]>, Alias,
Index: clang/include/clang/Driver/Options.h
===
--- clang/include/clang/Driver/Options.h
+++ clang/include/clang/Driver/Options.h
@@ -36,7 +36,8 @@
   FC1Option = (1 << 15),
   FlangOnlyOption = (1 << 16),
   DXCOption = (1 << 17),
-  Ignored = (1 << 18),
+  CLDXCOption = (1 << 18),
+  Ignored = (1 << 19),
 };
 
 enum ID {
___
cfe-com

[PATCH] D129591: Modify CXXMethodDecl::isMoveAssignmentOperator() to look through type sugar

2022-07-14 Thread Shafik Yaghmour via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG80dec2ecfffe: [Clang] Modify 
CXXMethodDecl::isMoveAssignmentOperator() to look through type… (authored by 
shafik).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129591

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/AST/DeclCXX.cpp
  clang/test/SemaCXX/cxx0x-defaulted-functions.cpp


Index: clang/test/SemaCXX/cxx0x-defaulted-functions.cpp
===
--- clang/test/SemaCXX/cxx0x-defaulted-functions.cpp
+++ clang/test/SemaCXX/cxx0x-defaulted-functions.cpp
@@ -259,3 +259,28 @@
 
   static_assert(noexcept(A::B()), "");
 }
+
+namespace GH56456 {
+template 
+using RC=T const&;
+template 
+using RV=T&;
+template 
+using RM=T&&;
+
+struct A {
+  A(RC) = default;
+  A(RM) = default;
+
+  auto operator=(RC) -> RV = default;
+  auto operator=(RM) -> RV = default;
+};
+
+struct B {
+  B (RC) = delete;
+  B (RM) = delete;
+
+  auto operator = (RC) -> RV = delete;
+  auto operator = (RM) -> RV = delete;
+};
+}
Index: clang/lib/AST/DeclCXX.cpp
===
--- clang/lib/AST/DeclCXX.cpp
+++ clang/lib/AST/DeclCXX.cpp
@@ -2410,7 +2410,7 @@
 return false;
 
   QualType ParamType = getParamDecl(0)->getType();
-  if (!isa(ParamType))
+  if (!ParamType->isRValueReferenceType())
 return false;
   ParamType = ParamType->getPointeeType();
 
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -186,6 +186,8 @@
 - Clang now checks ODR violations when merging concepts from different modules.
   Note that this may possibly break existing code, and is done so 
intentionally.
   Fixes `Issue 56310 `_.
+- Clang will now look through type sugar when checking a member function is a
+  move assignment operator. Fixes `Issue 56456 
`_.
 
 Improvements to Clang's diagnostics
 ^^^


Index: clang/test/SemaCXX/cxx0x-defaulted-functions.cpp
===
--- clang/test/SemaCXX/cxx0x-defaulted-functions.cpp
+++ clang/test/SemaCXX/cxx0x-defaulted-functions.cpp
@@ -259,3 +259,28 @@
 
   static_assert(noexcept(A::B()), "");
 }
+
+namespace GH56456 {
+template 
+using RC=T const&;
+template 
+using RV=T&;
+template 
+using RM=T&&;
+
+struct A {
+  A(RC) = default;
+  A(RM) = default;
+
+  auto operator=(RC) -> RV = default;
+  auto operator=(RM) -> RV = default;
+};
+
+struct B {
+  B (RC) = delete;
+  B (RM) = delete;
+
+  auto operator = (RC) -> RV = delete;
+  auto operator = (RM) -> RV = delete;
+};
+}
Index: clang/lib/AST/DeclCXX.cpp
===
--- clang/lib/AST/DeclCXX.cpp
+++ clang/lib/AST/DeclCXX.cpp
@@ -2410,7 +2410,7 @@
 return false;
 
   QualType ParamType = getParamDecl(0)->getType();
-  if (!isa(ParamType))
+  if (!ParamType->isRValueReferenceType())
 return false;
   ParamType = ParamType->getPointeeType();
 
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -186,6 +186,8 @@
 - Clang now checks ODR violations when merging concepts from different modules.
   Note that this may possibly break existing code, and is done so intentionally.
   Fixes `Issue 56310 `_.
+- Clang will now look through type sugar when checking a member function is a
+  move assignment operator. Fixes `Issue 56456 `_.
 
 Improvements to Clang's diagnostics
 ^^^
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 80dec2e - [Clang] Modify CXXMethodDecl::isMoveAssignmentOperator() to look through type sugar

2022-07-14 Thread Shafik Yaghmour via cfe-commits

Author: Shafik Yaghmour
Date: 2022-07-14T16:09:52-07:00
New Revision: 80dec2ecfffe30f86ecfeec8f553b16bb992c48b

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

LOG: [Clang] Modify CXXMethodDecl::isMoveAssignmentOperator() to look through 
type sugar
AcceptedPublic

Currently CXXMethodDecl::isMoveAssignmentOperator() does not look though type
sugar and so if the parameter is a type alias it will not be able to detect
that the method is a move assignment operator. This PR fixes that and adds a set
of tests that covers that we correctly detect special member functions when
defaulting or deleting them.

This fixes: https://github.com/llvm/llvm-project/issues/56456

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/AST/DeclCXX.cpp
clang/test/SemaCXX/cxx0x-defaulted-functions.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index a02bc0a2f691..17c1dac2e82a 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -186,6 +186,8 @@ Bug Fixes
 - Clang now checks ODR violations when merging concepts from 
diff erent modules.
   Note that this may possibly break existing code, and is done so 
intentionally.
   Fixes `Issue 56310 `_.
+- Clang will now look through type sugar when checking a member function is a
+  move assignment operator. Fixes `Issue 56456 
`_.
 
 Improvements to Clang's diagnostics
 ^^^

diff  --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp
index 6fc9a86bc3cf..c307cbe02ecf 100644
--- a/clang/lib/AST/DeclCXX.cpp
+++ b/clang/lib/AST/DeclCXX.cpp
@@ -2410,7 +2410,7 @@ bool CXXMethodDecl::isMoveAssignmentOperator() const {
 return false;
 
   QualType ParamType = getParamDecl(0)->getType();
-  if (!isa(ParamType))
+  if (!ParamType->isRValueReferenceType())
 return false;
   ParamType = ParamType->getPointeeType();
 

diff  --git a/clang/test/SemaCXX/cxx0x-defaulted-functions.cpp 
b/clang/test/SemaCXX/cxx0x-defaulted-functions.cpp
index 25a40ef49401..73916fd3027e 100644
--- a/clang/test/SemaCXX/cxx0x-defaulted-functions.cpp
+++ b/clang/test/SemaCXX/cxx0x-defaulted-functions.cpp
@@ -259,3 +259,28 @@ namespace P1286R2 {
 
   static_assert(noexcept(A::B()), "");
 }
+
+namespace GH56456 {
+template 
+using RC=T const&;
+template 
+using RV=T&;
+template 
+using RM=T&&;
+
+struct A {
+  A(RC) = default;
+  A(RM) = default;
+
+  auto operator=(RC) -> RV = default;
+  auto operator=(RM) -> RV = default;
+};
+
+struct B {
+  B (RC) = delete;
+  B (RM) = delete;
+
+  auto operator = (RC) -> RV = delete;
+  auto operator = (RM) -> RV = delete;
+};
+}



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


[PATCH] D129802: [DRAFT] Implementing new atomic orderings in LLVM and generate barriers for legacy __sync builtins. Support corresponding memory model in outline atomics as well.

2022-07-14 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

`atomicrmw add [...] sync_seq_cst` is supposed to be equivalent to `fence 
seq_cst; atomicrmw add seq_cst; fence seq_cst`, I think.

The extra fences aren't necessary for most uses of `__sync_*`, but the 
difference is theoretically visible for exotic synchronization primitives.  At 
least the gcc developers thought the difference might be visible.  They 
therefore decided to add the extra barriers to `__sync_*` on AArch64 (and maybe 
other targets?).

As far as I know, the issue is entirely theoretical; nobody has demonstrated 
any issue on actual hardware, even with a synthetic testcase.

If we do decide we need to do something here, I'd prefer to model this using 
explicit fences in the IR, as opposed to a new atomic ordering.  Adding extra 
atomic orderings just makes everything harder to reason about.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129802

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


[PATCH] D128462: [HLSL] add -I option for dxc mode.

2022-07-14 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added a comment.

This change works and avoids the duplicated group. The duplicated group results 
in the help spew duplicating the group heading, which is undesirable.

  diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
  index 6dd4ec82d376..2dcdbae4385d 100644
  --- a/clang/include/clang/Driver/Options.td
  +++ b/clang/include/clang/Driver/Options.td
  @@ -6310,10 +6310,7 @@ def defsym : Separate<["-"], "defsym">,
   // clang-cl Options
   
//===--===//
   
  -def cl_Group : OptionGroup<"">, Flags<[CLOption]>,
  -  HelpText<"CL.EXE COMPATIBILITY OPTIONS">;
  -
  -def cl_dxc_Group : OptionGroup<"">, Flags<[CLDXCOption]>,
  +def cl_Group : OptionGroup<"">, Flags<[CLDXCOption]>,
 HelpText<"CL.EXE COMPATIBILITY OPTIONS">;
   
   def cl_compile_Group : OptionGroup<"">,
  @@ -6344,7 +6341,7 @@ class CLJoinedOrSeparate : Option<["/", 
"-"], name,
 KIND_JOINED_OR_SEPARATE>, Group, Flags<[CLOption, 
NoXarchOption]>;
   
   class CLDXCJoinedOrSeparate : Option<["/", "-"], name,
  -  KIND_JOINED_OR_SEPARATE>, Group, Flags<[CLDXCOption, 
NoXarchOption]>;
  +  KIND_JOINED_OR_SEPARATE>, Group, Flags<[CLDXCOption, 
NoXarchOption]>;
   
   class CLCompileJoinedOrSeparate : Option<["/", "-"], name,
 KIND_JOINED_OR_SEPARATE>, Group,
  diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
  index bc26f0d279a2..ee72f0fcb54c 100644
  --- a/clang/lib/Driver/Driver.cpp
  +++ b/clang/lib/Driver/Driver.cpp
  @@ -6238,6 +6238,10 @@ Driver::getIncludeExcludeOptionFlagMasks(bool 
IsClCompatMode) const {
 } else {
   ExcludedFlagsBitmask |= options::DXCOption;
 }
  +
  +  if (!IsClCompatMode && !IsDXCMode())
  +ExcludedFlagsBitmask |= options::CLDXCOption;
  +
 return std::make_pair(IncludedFlagsBitmask, ExcludedFlagsBitmask);
   }
   


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128462

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


[PATCH] D128619: [Clang] Implement P0848 (Conditionally Trivial Special Member Functions)

2022-07-14 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson created this revision.
Herald added a project: All.
royjacobson updated this revision to Diff 444173.
royjacobson added a comment.
royjacobson updated this revision to Diff 19.
royjacobson retitled this revision from "[WIP][Clang] Implement P0848 
(Conditionally Trivial Special Member Functions)" to "[Clang] Implement P0848 
(Conditionally Trivial Special Member Functions)".
royjacobson edited the summary of this revision.
royjacobson added reviewers: clang-language-wg, erichkeane, cor3ntin, BRevzin, 
CaseyCarter, aaron.ballman.
royjacobson published this revision for review.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The implementation is more or less complete, but I still need to add an AST 
test for canPassInRegisters.


royjacobson added a comment.

Implementation ready for CR.




Comment at: clang/www/cxx_status.html:930
 https://wg21.link/p0848r3";>P0848R3
-No
+Clang 15
   

Should be `class="unreleased"`, I believe



Comment at: clang/www/cxx_status.html:930
 https://wg21.link/p0848r3";>P0848R3
-No
+Clang 15
   

h-vetinari wrote:
> Should be `class="unreleased"`, I believe
Thanks, nice catch!


This patch implements P0848 in Clang.

During the instantiation of a C++ class, in `Sema::ActOnFields`, we evaluate 
constraints for all the SMFs and compare the constraints to compute the 
eligibility. We defer the computation of the type's [copy-]trivial bits from 
addedMember to the eligibility computation, like we did for destructors in 
D126194 . `canPassInRegisters` is modified as 
well to better respect the ineligibility of functions.

Note: Because of the non-implementation of DR1734 and DR1496, I treat deleted 
member functions as 'eligible' for the purpose of [copy-]triviallity. This is 
unfortunate, but I couldn't think of a way to make this make sense otherwise.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128619

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/AST/DeclCXX.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/AST/conditionally-trivial-smfs.cpp
  clang/test/Lexer/cxx-features.cpp
  clang/test/SemaCXX/constrained-special-member-functions.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -927,7 +927,7 @@
   

 https://wg21.link/p0848r3";>P0848R3
-No
+Clang 15
   
   
 https://wg21.link/p1616r1";>P1616R1
Index: clang/test/SemaCXX/constrained-special-member-functions.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/constrained-special-member-functions.cpp
@@ -0,0 +1,130 @@
+// RUN: %clang_cc1 -verify -std=c++20 %s
+// expected-no-diagnostics
+
+template 
+concept C0 = (N == 0);
+template 
+concept C1 = (N == 1);
+template 
+concept C2 = (N == 2);
+
+// Checks are indexed by:
+// Definition:
+//  1. Explicitly defaulted definition
+//  2. Deleted definition
+//  3. User provided definition
+// We have a less constrained user provided method that should not disable
+// the (copyable) triviality of the type.
+
+// Note that because Clang does not implement DRs 1496 and 1734, we say some
+// classes are trivial when the SMFs are deleted.
+
+template 
+struct DefaultConstructorChecker {
+DefaultConstructorChecker() requires C0 = default;
+DefaultConstructorChecker() requires C1 = delete;
+DefaultConstructorChecker() requires C2;
+DefaultConstructorChecker();
+};
+static_assert(__is_trivially_copyable(DefaultConstructorChecker<0>));
+static_assert(__is_trivially_copyable(DefaultConstructorChecker<1>));
+static_assert(__is_trivially_copyable(DefaultConstructorChecker<2>));
+static_assert(__is_trivially_copyable(DefaultConstructorChecker<3>));
+static_assert(__is_trivial(DefaultConstructorChecker<0>));
+// FIXME: DR1496
+static_assert(__is_trivial(DefaultConstructorChecker<1>));
+static_assert(!__is_trivial(DefaultConstructorChecker<2>));
+static_assert(!__is_trivial(DefaultConstructorChecker<3>));
+
+template 
+struct CopyConstructorChecker {
+CopyConstructorChecker(const CopyConstructorChecker&) requires C0 = default;
+CopyConstructorChecker(const CopyConstructorChecker&) requires C1 = delete;
+CopyConstructorChecker(const CopyConstructorChecker&) requires C2;
+CopyConstructorChecker(const CopyConstructorChecker&);
+};
+
+static_assert(__is_trivially_copyable(CopyConstructorChecker<0>));
+// FIXME: DR1734
+static_assert(__is_trivially_copyable(CopyConstructorChecker<1>));
+static_assert(!__is_trivially_copyable(CopyConstructorChecker<2>));
+static_assert(!__is_trivially_

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

2022-07-14 Thread Scott Linder via Phabricator via cfe-commits
scott.linder added inline comments.



Comment at: llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp:1207
+  auto EmitResourceUsageRemark = [&](StringRef RemarkName,
+ StringRef RemarkLabel, auto &&Argument) {
+// Add an indent for every line besides the line with the kernel name. This

arsenm wrote:
> Why &&?
Looking at the `ore::NV` constructors I would vote that this just be by value, 
i.e. `auto Argument`. Everything that can be an `Argument` is a small "prefer 
passing by value" type.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123878

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


[PATCH] D129706: [NFCI][clang-tidy] Reimplement GlobList without relying on Regex.

2022-07-14 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 444820.
njames93 added a comment.

More code cleanup.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129706

Files:
  clang-tools-extra/clang-tidy/GlobList.cpp
  clang-tools-extra/clang-tidy/GlobList.h
  clang-tools-extra/unittests/clang-tidy/GlobListTest.cpp

Index: clang-tools-extra/unittests/clang-tidy/GlobListTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/GlobListTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/GlobListTest.cpp
@@ -16,6 +16,13 @@
   EXPECT_FALSE(Filter.contains("aaa"));
 }
 
+TYPED_TEST(GlobListTest, NotEmpty) {
+  TypeParam Filter("*,-");
+
+  EXPECT_FALSE(Filter.contains(""));
+  EXPECT_TRUE(Filter.contains("aaa"));
+}
+
 TYPED_TEST(GlobListTest, Nothing) {
   TypeParam Filter("-*");
 
@@ -57,6 +64,51 @@
   EXPECT_FALSE(Filter.contains(""));
 }
 
+TYPED_TEST(GlobListTest, PreAndPostFixPattern) {
+  TypeParam Filter("a*b");
+
+  EXPECT_TRUE(Filter.contains("ab"));
+  EXPECT_TRUE(Filter.contains("aMiddleb"));
+  EXPECT_FALSE(Filter.contains("aba"));
+  EXPECT_FALSE(Filter.contains("bab"));
+}
+
+TYPED_TEST(GlobListTest, DoubleWildcard) {
+  {
+TypeParam Filter("a**b");
+
+EXPECT_TRUE(Filter.isEquivalentTo("a*b"));
+EXPECT_TRUE(Filter.isEquivalentTo("a***b"));
+
+EXPECT_TRUE(Filter.contains("ab"));
+EXPECT_TRUE(Filter.contains("aMiddleb"));
+EXPECT_FALSE(Filter.contains("aba"));
+EXPECT_FALSE(Filter.contains("bab"));
+  }
+  {
+TypeParam Filter("a**");
+
+EXPECT_TRUE(Filter.isEquivalentTo("a*"));
+EXPECT_TRUE(Filter.isEquivalentTo("a***"));
+
+EXPECT_TRUE(Filter.contains("ab"));
+EXPECT_TRUE(Filter.contains("aMiddleb"));
+EXPECT_TRUE(Filter.contains("aba"));
+EXPECT_FALSE(Filter.contains("bab"));
+  }
+  {
+TypeParam Filter("**b");
+
+EXPECT_TRUE(Filter.isEquivalentTo("*b"));
+EXPECT_TRUE(Filter.isEquivalentTo("***b"));
+
+EXPECT_TRUE(Filter.contains("ab"));
+EXPECT_TRUE(Filter.contains("aMiddleb"));
+EXPECT_FALSE(Filter.contains("aba"));
+EXPECT_TRUE(Filter.contains("bab"));
+  }
+}
+
 TYPED_TEST(GlobListTest, PatternPriority) {
   // The last glob that matches the string decides whether that string is
   // included or excluded.
@@ -107,6 +159,9 @@
 TYPED_TEST(GlobListTest, NewlineCharactersAsSeparators) {
   TypeParam Filter("a*  \n b,\n-c*,dd");
 
+  // FIXME: Define this behaviour, There are 2 seperator characters next to each
+  // other (,\n), Technically that should be represented as containing an empty
+  // item.
   EXPECT_FALSE(Filter.contains(""));
   EXPECT_TRUE(Filter.contains("aaa"));
   EXPECT_TRUE(Filter.contains("b"));
@@ -117,5 +172,45 @@
   EXPECT_FALSE(Filter.contains("ddd"));
 }
 
+TYPED_TEST(GlobListTest, IgnoreNegativeMatches) {
+  TypeParam Filter("a,-a,b*,-b*,-*", false);
+
+  EXPECT_FALSE(Filter.contains(""));
+  EXPECT_TRUE(Filter.contains("a"));
+  EXPECT_TRUE(Filter.contains("b"));
+  EXPECT_TRUE(Filter.contains("bar"));
+}
+
+void checkCanonicalize(StringRef Glob, StringRef Expected) {
+  GlobList Orig(Glob);
+  std::string Canonicalized;
+  llvm::raw_string_ostream Str(Canonicalized);
+  Orig.print(Str);
+  Str.flush();
+  EXPECT_EQ(Canonicalized, Expected)
+  << "While canonicalizing glob: \"" << Glob << "\"";
+  EXPECT_TRUE(Orig.isEquivalentTo(Expected))
+  << "While canonicalizing glob: \"" << Glob << "\"";
+  ;
+  GlobList Canonical(Canonicalized);
+  EXPECT_TRUE(Orig.isEquivalentTo(Canonical))
+  << "While canonicalizing glob: \"" << Glob << "\"";
+  ;
+  EXPECT_TRUE(Canonical.isEquivalentTo(Glob))
+  << "While canonicalizing glob: \"" << Glob << "\"";
+  ;
+}
+
+TEST(GlobListTest, Printing) {
+  // A positive wildcard is always printed with any previous items removed
+  // checkCanonicalize(" *", "*");
+  // checkCanonicalize(" * ,   -AAA ", "*,-AAA");
+  checkCanonicalize("Unused , *, -A*", "*,-A*");
+  // A negative wildcard is removed if there is nothing else after it.
+  checkCanonicalize("-* ", "-*");
+  checkCanonicalize("-*, AAA  ", "AAA");
+  checkCanonicalize("Unused\n-*\nRest\n*Others", "Rest,*Others");
+}
+
 } // namespace tidy
 } // namespace clang
Index: clang-tools-extra/clang-tidy/GlobList.h
===
--- clang-tools-extra/clang-tidy/GlobList.h
+++ clang-tools-extra/clang-tidy/GlobList.h
@@ -10,10 +10,10 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_GLOBLIST_H
 
 #include "clang/Basic/LLVM.h"
-#include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
-#include "llvm/Support/Regex.h"
+#include 
+#include 
 
 namespace clang {
 namespace tidy {
@@ -25,7 +25,9 @@
 /// them in the order of appearance in the list.
 class GlobList {
 public:
-  virtual ~GlobList() = default;
+  virtual ~GlobList();
+
+  GlobList(const GlobList &) = delete;
 

[PATCH] D129742: [clang-format] Fix invalid-code-generation by RemoveBracesLLVM

2022-07-14 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 rG6ab7307177c3: [clang-format] Fix invalid-code-generation by 
RemoveBracesLLVM (authored by owenpan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129742

Files:
  clang/lib/Format/Format.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -25741,6 +25741,17 @@
"}",
Style);
 
+  verifyFormat("if (a) {\n"
+   "  if (b)\n"
+   "c = 1; // comment\n"
+   "}",
+   "if (a) {\n"
+   "  if (b) {\n"
+   "c = 1; // comment\n"
+   "  }\n"
+   "}",
+   Style);
+
   verifyFormat("if (a) {\n"
"Label:\n"
"}",
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -1895,26 +1895,31 @@
   void removeBraces(SmallVectorImpl &Lines,
 tooling::Replacements &Result) {
 const auto &SourceMgr = Env.getSourceManager();
+bool EndsWithComment = false;
 for (AnnotatedLine *Line : Lines) {
   removeBraces(Line->Children, Result);
-  if (!Line->Affected)
-continue;
-  for (FormatToken *Token = Line->First; Token && !Token->Finalized;
-   Token = Token->Next) {
-if (!Token->Optional)
-  continue;
-assert(Token->isOneOf(tok::l_brace, tok::r_brace));
-assert(Token->Next || Token == Line->Last);
-const auto Start =
-Token == Line->Last ||
-(Token->Next->isOneOf(tok::kw_else, tok::comment) &&
- Token->Next->NewlinesBefore > 0)
-? Token->WhitespaceRange.getBegin()
-: Token->Tok.getLocation();
-const auto Range =
-CharSourceRange::getCharRange(Start, Token->Tok.getEndLoc());
-cantFail(Result.add(tooling::Replacement(SourceMgr, Range, "")));
+  if (Line->Affected) {
+for (FormatToken *Token = Line->First; Token && !Token->Finalized;
+ Token = Token->Next) {
+  if (!Token->Optional)
+continue;
+  assert(Token->isOneOf(tok::l_brace, tok::r_brace));
+  assert(Token->Previous || Token == Line->First);
+  const FormatToken *Next = Token->Next;
+  assert(Next || Token == Line->Last);
+  const auto Start =
+  (!Token->Previous && EndsWithComment) ||
+  (Next && !(Next->isOneOf(tok::kw_else, tok::comment) &&
+ Next->NewlinesBefore > 0))
+  ? Token->Tok.getLocation()
+  : Token->WhitespaceRange.getBegin();
+  const auto Range =
+  CharSourceRange::getCharRange(Start, Token->Tok.getEndLoc());
+  cantFail(Result.add(tooling::Replacement(SourceMgr, Range, "")));
+}
   }
+  assert(Line->Last);
+  EndsWithComment = Line->Last->is(tok::comment);
 }
   }
 };


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -25741,6 +25741,17 @@
"}",
Style);
 
+  verifyFormat("if (a) {\n"
+   "  if (b)\n"
+   "c = 1; // comment\n"
+   "}",
+   "if (a) {\n"
+   "  if (b) {\n"
+   "c = 1; // comment\n"
+   "  }\n"
+   "}",
+   Style);
+
   verifyFormat("if (a) {\n"
"Label:\n"
"}",
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -1895,26 +1895,31 @@
   void removeBraces(SmallVectorImpl &Lines,
 tooling::Replacements &Result) {
 const auto &SourceMgr = Env.getSourceManager();
+bool EndsWithComment = false;
 for (AnnotatedLine *Line : Lines) {
   removeBraces(Line->Children, Result);
-  if (!Line->Affected)
-continue;
-  for (FormatToken *Token = Line->First; Token && !Token->Finalized;
-   Token = Token->Next) {
-if (!Token->Optional)
-  continue;
-assert(Token->isOneOf(tok::l_brace, tok::r_brace));
-assert(Token->Next || Token == Line->Last);
-const auto Start =
-Token == Line->Last ||
-(Token->Next->isOneOf(tok::kw_else, tok::comment) &&
-  

[PATCH] D129802: [DRAFT] Implementing new atomic orderings in LLVM and generate barriers for legacy __sync builtins. Support corresponding memory model in outline atomics as well.

2022-07-14 Thread James Y Knight via Phabricator via cfe-commits
jyknight added a comment.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65697 is the relevant discussion 
thread that added these to GCC. I personally never found it very convincing, 
even back in 2015 when they first made the change.

And, now, 7 years later, I'd be even more reluctant to add this to LLVM's core 
atomic memory model. By now, the `__sync_*` routines have been obsolete for 
over a decade. And they never really had a proper memory model description in 
the first place -- I don't see how they even make sense to use //at all// on a 
non-TSO (which is to say: non-X86) memory architecture, since they don't 
include proper atomic load/store operations.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129802

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


[clang] 6ab7307 - [clang-format] Fix invalid-code-generation by RemoveBracesLLVM

2022-07-14 Thread via cfe-commits

Author: owenca
Date: 2022-07-14T15:19:57-07:00
New Revision: 6ab7307177c336d7ca5910fc434c012f35245fd1

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

LOG: [clang-format] Fix invalid-code-generation by RemoveBracesLLVM

When removing an r_brace that is the first token of an annotated line, if the
line above ends with a line comment, clang-format generates invalid code by
merging the tokens after the r_brace into the line comment.

Fixes #56488.

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

Added: 


Modified: 
clang/lib/Format/Format.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index d13907faca43f..2659fa2af1a7f 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -1895,26 +1895,31 @@ class BracesRemover : public TokenAnalyzer {
   void removeBraces(SmallVectorImpl &Lines,
 tooling::Replacements &Result) {
 const auto &SourceMgr = Env.getSourceManager();
+bool EndsWithComment = false;
 for (AnnotatedLine *Line : Lines) {
   removeBraces(Line->Children, Result);
-  if (!Line->Affected)
-continue;
-  for (FormatToken *Token = Line->First; Token && !Token->Finalized;
-   Token = Token->Next) {
-if (!Token->Optional)
-  continue;
-assert(Token->isOneOf(tok::l_brace, tok::r_brace));
-assert(Token->Next || Token == Line->Last);
-const auto Start =
-Token == Line->Last ||
-(Token->Next->isOneOf(tok::kw_else, tok::comment) &&
- Token->Next->NewlinesBefore > 0)
-? Token->WhitespaceRange.getBegin()
-: Token->Tok.getLocation();
-const auto Range =
-CharSourceRange::getCharRange(Start, Token->Tok.getEndLoc());
-cantFail(Result.add(tooling::Replacement(SourceMgr, Range, "")));
+  if (Line->Affected) {
+for (FormatToken *Token = Line->First; Token && !Token->Finalized;
+ Token = Token->Next) {
+  if (!Token->Optional)
+continue;
+  assert(Token->isOneOf(tok::l_brace, tok::r_brace));
+  assert(Token->Previous || Token == Line->First);
+  const FormatToken *Next = Token->Next;
+  assert(Next || Token == Line->Last);
+  const auto Start =
+  (!Token->Previous && EndsWithComment) ||
+  (Next && !(Next->isOneOf(tok::kw_else, tok::comment) &&
+ Next->NewlinesBefore > 0))
+  ? Token->Tok.getLocation()
+  : Token->WhitespaceRange.getBegin();
+  const auto Range =
+  CharSourceRange::getCharRange(Start, Token->Tok.getEndLoc());
+  cantFail(Result.add(tooling::Replacement(SourceMgr, Range, "")));
+}
   }
+  assert(Line->Last);
+  EndsWithComment = Line->Last->is(tok::comment);
 }
   }
 };

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index e506d0dbf3a5e..ba07584d661ae 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -25741,6 +25741,17 @@ TEST_F(FormatTest, RemoveBraces) {
"}",
Style);
 
+  verifyFormat("if (a) {\n"
+   "  if (b)\n"
+   "c = 1; // comment\n"
+   "}",
+   "if (a) {\n"
+   "  if (b) {\n"
+   "c = 1; // comment\n"
+   "  }\n"
+   "}",
+   Style);
+
   verifyFormat("if (a) {\n"
"Label:\n"
"}",



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


[PATCH] D128462: [HLSL] add -I option for dxc mode.

2022-07-14 Thread Xiang Li via Phabricator via cfe-commits
python3kgae marked an inline comment as done.
python3kgae added inline comments.



Comment at: clang/include/clang/Driver/Options.td:6318
+  HelpText<"CL.EXE COMPATIBILITY OPTIONS">;
+
 def cl_compile_Group : OptionGroup<"">,

beanz wrote:
> Do we need this group or can it just be `cl_Group`?
Yes. Without the group, it fails.
Also the text is keeping as cl_Group to avoid change help for cl mode.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128462

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


[PATCH] D128462: [HLSL] add -I option for dxc mode.

2022-07-14 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added inline comments.



Comment at: clang/include/clang/Driver/Options.td:6318
+  HelpText<"CL.EXE COMPATIBILITY OPTIONS">;
+
 def cl_compile_Group : OptionGroup<"">,

Do we need this group or can it just be `cl_Group`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128462

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


[PATCH] D128462: [HLSL] add -I option for dxc mode.

2022-07-14 Thread Xiang Li via Phabricator via cfe-commits
python3kgae updated this revision to Diff 444803.
python3kgae marked an inline comment as done.
python3kgae added a comment.

Add CLDXCOption flag and share option with CL mode.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128462

Files:
  clang/include/clang/Driver/Options.h
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/dxc_I.hlsl

Index: clang/test/Driver/dxc_I.hlsl
===
--- /dev/null
+++ clang/test/Driver/dxc_I.hlsl
@@ -0,0 +1,4 @@
+// RUN: %clang_dxc -I test  -### %s 2>&1 | FileCheck %s
+
+// Make sure -I send to cc1.
+// CHECK:"-I" "test"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3481,6 +3481,7 @@
   types::ID InputType) {
   const unsigned ForwardedArguments[] = {options::OPT_dxil_validator_version,
  options::OPT_D,
+ options::OPT_I,
  options::OPT_S,
  options::OPT_emit_llvm,
  options::OPT_disable_llvm_passes,
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -6225,6 +6225,7 @@
   if (IsClCompatMode) {
 // Include CL and Core options.
 IncludedFlagsBitmask |= options::CLOption;
+IncludedFlagsBitmask |= options::CLDXCOption;
 IncludedFlagsBitmask |= options::CoreOption;
   } else {
 ExcludedFlagsBitmask |= options::CLOption;
@@ -6232,6 +6233,7 @@
   if (IsDXCMode()) {
 // Include DXC and Core options.
 IncludedFlagsBitmask |= options::DXCOption;
+IncludedFlagsBitmask |= options::CLDXCOption;
 IncludedFlagsBitmask |= options::CoreOption;
   } else {
 ExcludedFlagsBitmask |= options::DXCOption;
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -53,6 +53,10 @@
 // are made available when the driver is running in DXC compatibility mode.
 def DXCOption : OptionFlag;
 
+// CLDXCOption - This is a cl.exe/dxc.exe compatibility option. Options with this flag
+// are made available when the driver is running in CL/DXC compatibility mode.
+def CLDXCOption : OptionFlag;
+
 // NoDriverOption - This option should not be accepted by the driver.
 def NoDriverOption : OptionFlag;
 
@@ -6309,6 +6313,9 @@
 def cl_Group : OptionGroup<"">, Flags<[CLOption]>,
   HelpText<"CL.EXE COMPATIBILITY OPTIONS">;
 
+def cl_dxc_Group : OptionGroup<"">, Flags<[CLDXCOption]>,
+  HelpText<"CL.EXE COMPATIBILITY OPTIONS">;
+
 def cl_compile_Group : OptionGroup<"">,
   Group;
 
@@ -6336,6 +6343,9 @@
 class CLJoinedOrSeparate : Option<["/", "-"], name,
   KIND_JOINED_OR_SEPARATE>, Group, Flags<[CLOption, NoXarchOption]>;
 
+class CLDXCJoinedOrSeparate : Option<["/", "-"], name,
+  KIND_JOINED_OR_SEPARATE>, Group, Flags<[CLDXCOption, NoXarchOption]>;
+
 class CLCompileJoinedOrSeparate : Option<["/", "-"], name,
   KIND_JOINED_OR_SEPARATE>, Group,
   Flags<[CLOption, NoXarchOption]>;
@@ -6413,7 +6423,7 @@
 def _SLASH_HELP : CLFlag<"HELP">, Alias;
 def _SLASH_hotpatch : CLFlag<"hotpatch">, Alias,
   HelpText<"Create hotpatchable image">;
-def _SLASH_I : CLJoinedOrSeparate<"I">,
+def _SLASH_I : CLDXCJoinedOrSeparate<"I">,
   HelpText<"Add directory to include search path">, MetaVarName<"">,
   Alias;
 def _SLASH_J : CLFlag<"J">, HelpText<"Make char type unsigned">,
@@ -6820,6 +6830,8 @@
   Group, Flags<[DXCOption, NoXarchOption]>;
 class DXCJoinedOrSeparate : Option<["/", "-"], name,
   KIND_JOINED_OR_SEPARATE>, Group, Flags<[DXCOption, NoXarchOption]>;
+class DXCJoinedOrSeparateConflict : Option<["--", "/", "-"], name,
+  KIND_JOINED_OR_SEPARATE>, Group, Flags<[DXCOption, NoXarchOption]>;
 
 def dxc_help : Option<["/", "-", "--"], "help", KIND_JOINED>,
   Group, Flags<[DXCOption, NoXarchOption]>, Alias,
Index: clang/include/clang/Driver/Options.h
===
--- clang/include/clang/Driver/Options.h
+++ clang/include/clang/Driver/Options.h
@@ -36,7 +36,8 @@
   FC1Option = (1 << 15),
   FlangOnlyOption = (1 << 16),
   DXCOption = (1 << 17),
-  Ignored = (1 << 18),
+  CLDXCOption = (1 << 18),
+  Ignored = (1 << 19),
 };
 
 enum ID {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D127973: [analyzer] Eval construction of non POD type arrays.

2022-07-14 Thread Domján Dániel 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 rGb032e3ff6121: [analyzer] Evaluate construction of non-POD 
type arrays (authored by isuckatcs).
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127973

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
  clang/test/Analysis/ctor-array.cpp
  clang/test/Analysis/ctor.mm
  clang/test/Analysis/cxxctr-array-evalcall-analysis-order.cpp
  clang/test/Analysis/dtor.cpp
  clang/test/Analysis/exploded-graph-rewriter/checker_messages.dot
  clang/test/Analysis/exploded-graph-rewriter/checker_messages_diff.dot
  clang/test/Analysis/exploded-graph-rewriter/constraints.dot
  clang/test/Analysis/exploded-graph-rewriter/constraints_diff.dot
  clang/test/Analysis/exploded-graph-rewriter/environment.dot
  clang/test/Analysis/exploded-graph-rewriter/environment_diff.dot
  clang/test/Analysis/exploded-graph-rewriter/store.dot
  clang/test/Analysis/exploded-graph-rewriter/store_diff.dot
  clang/test/Analysis/exploded-graph-rewriter/topology.dot
  clang/test/Analysis/expr-inspection.c
  clang/test/Analysis/handle_constructors_with_new_array.cpp
  clang/test/Analysis/new-ctor-conservative.cpp
  clang/test/Analysis/new.cpp
  clang/test/Analysis/operator-calls.cpp
  clang/utils/analyzer/exploded-graph-rewriter.py

Index: clang/utils/analyzer/exploded-graph-rewriter.py
===
--- clang/utils/analyzer/exploded-graph-rewriter.py
+++ clang/utils/analyzer/exploded-graph-rewriter.py
@@ -144,7 +144,8 @@
 
 
 # A deserialized Environment. This class can also hold other entities that
-# are similar to Environment, such as Objects Under Construction.
+# are similar to Environment, such as Objects Under Construction or 
+# Indices Of Elements Under Construction.
 class GenericEnvironment:
 def __init__(self, json_e):
 self.frames = [EnvironmentFrame(f) for f in json_e]
@@ -269,6 +270,7 @@
 'constraints': None,
 'dynamic_types': None,
 'constructing_objects': None,
+'index_of_element': None,
 'checker_messages': None
 }
 
@@ -296,6 +298,10 @@
 GenericEnvironment(json_ps['constructing_objects']) \
 if json_ps['constructing_objects'] is not None else None
 
+self.index_of_element = \
+GenericEnvironment(json_ps['index_of_element']) \
+if json_ps['index_of_element'] is not None else None
+
 self.checker_messages = CheckerMessages(json_ps['checker_messages']) \
 if json_ps['checker_messages'] is not None else None
 
@@ -796,6 +802,9 @@
 self.visit_environment_in_state('constructing_objects',
 'Objects Under Construction',
 s, prev_s)
+self.visit_environment_in_state('index_of_element',
+'Indices Of Elements Under Construction',
+s, prev_s)
 self.visit_checker_messages_in_state(s, prev_s)
 
 def visit_node(self, node):
Index: clang/test/Analysis/operator-calls.cpp
===
--- clang/test/Analysis/operator-calls.cpp
+++ clang/test/Analysis/operator-calls.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,alpha.core,debug.ExprInspection -verify %s
+// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,alpha.core,debug.ExprInspection -analyzer-output=text -verify %s
 void clang_analyzer_eval(bool);
 
 struct X0 { };
@@ -29,6 +29,7 @@
 
 void testMemberOperator(IntComparable B) {
   clang_analyzer_eval(B == 0); // expected-warning{{TRUE}}
+  // expected-note@-1{{TRUE}}
 }
 
 
@@ -46,7 +47,9 @@
 
   void test(const Convertible &obj) {
 clang_analyzer_eval((int)obj == 42); // expected-warning{{TRUE}}
+// expected-note@-1{{TRUE}}
 clang_analyzer_eval(obj); // expected-warning{{TRUE}}
+// expected-note@-1{{TRUE}}
   }
 }
 
@@ -82,7 +85,15 @@
 // Force a cache-out when we try to conjure a temporary region for the operator call.
 // ...then, don't crash.
 clang_analyzer_eval(+(coin ? getSmallOpaque() : getSmallOpaque())); // expected-warning{{UNKNOWN}}
+// expected-note@-1{{Assuming 'coin' is 0}}
+// expected-note@-2{{'?' condition is false}}
+// expected-note@-3{{UNKNOWN}}
+// expected-note@-4{{Assuming 'coin' is 0}}
+// expected-note@-5{{'?' condition is false}}
 clang_analyzer_eval(+(coin ? getLargeOpaque() : getLargeOpaque())); // expected-

[clang] b032e3f - [analyzer] Evaluate construction of non-POD type arrays

2022-07-14 Thread via cfe-commits

Author: isuckatcs
Date: 2022-07-14T23:30:21+02:00
New Revision: b032e3ff6121a969b2e90ad7bf493c2d5d7ac3a2

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

LOG: [analyzer] Evaluate construction of non-POD type arrays

Introducing the support for evaluating the constructor
of every element in an array. The idea is to record the
index of the current array member being constructed and
create a loop during the analysis. We looping over the
same CXXConstructExpr as many times as many elements
the array has.

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

Added: 
clang/test/Analysis/ctor-array.cpp
clang/test/Analysis/cxxctr-array-evalcall-analysis-order.cpp

Modified: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
clang/test/Analysis/ctor.mm
clang/test/Analysis/dtor.cpp
clang/test/Analysis/exploded-graph-rewriter/checker_messages.dot
clang/test/Analysis/exploded-graph-rewriter/checker_messages_diff.dot
clang/test/Analysis/exploded-graph-rewriter/constraints.dot
clang/test/Analysis/exploded-graph-rewriter/constraints_diff.dot
clang/test/Analysis/exploded-graph-rewriter/environment.dot
clang/test/Analysis/exploded-graph-rewriter/environment_diff.dot
clang/test/Analysis/exploded-graph-rewriter/store.dot
clang/test/Analysis/exploded-graph-rewriter/store_diff.dot
clang/test/Analysis/exploded-graph-rewriter/topology.dot
clang/test/Analysis/expr-inspection.c
clang/test/Analysis/handle_constructors_with_new_array.cpp
clang/test/Analysis/new-ctor-conservative.cpp
clang/test/Analysis/new.cpp
clang/test/Analysis/operator-calls.cpp
clang/utils/analyzer/exploded-graph-rewriter.py

Removed: 




diff  --git 
a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
index 415fa05586edf..116a5970c341f 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
@@ -617,6 +617,11 @@ class ExprEngine {
 return svalBuilder.evalBinOp(ST, Op, LHS, RHS, T);
   }
 
+  /// Retreives which element is being constructed in a non POD type array.
+  static Optional
+  getIndexOfElementToConstruct(ProgramStateRef State, const CXXConstructExpr 
*E,
+   const LocationContext *LCtx);
+
   /// By looking at a certain item that may be potentially part of an object's
   /// ConstructionContext, retrieve such object's location. A particular
   /// statement can be transparently passed as \p Item in most cases.
@@ -708,10 +713,19 @@ class ExprEngine {
   /// fully implemented it sometimes indicates that it failed via its
   /// out-parameter CallOpts; in such cases a fake temporary region is
   /// returned, which is better than nothing but does not represent
-  /// the actual behavior of the program.
-  SVal computeObjectUnderConstruction(
-  const Expr *E, ProgramStateRef State, const LocationContext *LCtx,
-  const ConstructionContext *CC, EvalCallOptions &CallOpts);
+  /// the actual behavior of the program. The Idx parameter is used if we
+  /// construct an array of objects. In that case it points to the index
+  /// of the continous memory region.
+  /// E.g.:
+  /// For `int arr[4]` this index can be 0,1,2,3.
+  /// For `int arr2[3][3]` this index can be 0,1,...,7,8.
+  /// A multi-dimensional array is also a continous memory location in a
+  /// row major order, so for arr[0][0] Idx is 0 and for arr[2][2] Idx is 8.
+  SVal computeObjectUnderConstruction(const Expr *E, ProgramStateRef State,
+  const LocationContext *LCtx,
+  const ConstructionContext *CC,
+  EvalCallOptions &CallOpts,
+  unsigned Idx = 0);
 
   /// Update the program state with all the path-sensitive information
   /// that's necessary to perform construction of an object with a given
@@ -724,12 +738,16 @@ class ExprEngine {
 
   /// A convenient wrapper around computeObjectUnderConstruction
   /// and updateObjectsUnderConstruction.
-  std::pair handleConstructionContext(
-  const Expr *E, ProgramStateRef State, const LocationContext *LCtx,
-  const ConstructionContext *CC, EvalCallOptions &CallOpts) {
-SVal V = computeObjectUnderConstruction(E, State, LCtx, CC, CallOpts);
-return std::make_pair(
-updateObjectsUnderConstruction(V, E, State, LCtx, CC, CallOpts), V);
+  std::pair
+  handleConstructionContext(cons

[PATCH] D128465: [llvm] add zstd to `llvm::compression` namespace

2022-07-14 Thread Jason Molenda via Phabricator via cfe-commits
jasonmolenda added a comment.

In D128465#3653216 , @ckissane wrote:

> In D128465#3653051 , @jasonmolenda 
> wrote:
>
>> In D128465#3652525 , @ckissane 
>> wrote:
>>
>>> In D128465#3651025 , @aemerson 
>>> wrote:
>>>
 I just reverted this in 6e6be5f9504d 
  
 because it seems to have broken macOS builds:

   llvm/lib/Support/Compression.cpp:24:10: fatal error: 'zstd.h' file not 
 found
   #include 
^~~~
>>>
>>> @aemerson Could you provide the output of your cmake command?
>>> (I can't easily reproduce because I don't have a mac on hand)
>>
>> FWIW I hit this last night on my mac desktop - it looked like I had zstd 
>> installed by homebrew (as a dependency on something I installed), and cmake 
>> was able to find it in /opt/homebrew (somehow) but when Compression.cpp was 
>> built, nothing had added -I/opt/homebrew/include so the header wasn't found. 
>>  I hacked the FindZSTD.cmake to not find it, to finish what I was working on 
>> before bedtime.  This might not be related to what @aemerson saw though.
>
> @jasonmolenda Thank you for the info, I believe it is similar, could you try: 
> https://reviews.llvm.org/D129786 for me?

I applied the patch from https://reviews.llvm.org/D129786 on a clean checkout, 
` cmake ../llvm -G Ninja -DCMAKE_BUILD_TYPE=Debug -DLLVM_ENABLE_ASSERTIONS=1 
-DLLVM_ENABLE_PROJECTS='llvm;lldb;clang' 
'-DLLVM_ENABLE_RUNTIMES=libcxx;libcxxabi' -DLLDB_ENABLE_PYTHON=1` (my normal 
cmake line) and got

  -- Found ZSTD: /opt/homebrew/lib/libzstd.dylib  
  -- Looking for ZSTD_compress
  -- Looking for ZSTD_compress - found
  
  [...]
  
  FAILED: lib/Support/CMakeFiles/LLVMSupport.dir/Compression.cpp.o 
  
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
 -DGTEST_HAS_RTTI=0 -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS 
-D__STDC_LIMIT_MACROS -I/Users/jason/k/llvm/llvm-project/build/lib/Support 
-I/Users/jason/k/llvm/llvm-project/llvm/lib/Support 
-I/Users/jason/k/llvm/llvm-project/build/include 
-I/Users/jason/k/llvm/llvm-project/llvm/include -fPIC 
-fvisibility-inlines-hidden -Werror=date-time 
-Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter 
-Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic 
-Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion 
-Wmisleading-indentation -fdiagnostics-color  -g -arch arm64 -isysroot 
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk
 -std=c++14  -fno-exceptions -fno-rtti -MD -MT 
lib/Support/CMakeFiles/LLVMSupport.dir/Compression.cpp.o -MF 
lib/Support/CMakeFiles/LLVMSupport.dir/Compression.cpp.o.d -o 
lib/Support/CMakeFiles/LLVMSupport.dir/Compression.cpp.o -c 
/Users/jason/k/llvm/llvm-project/llvm/lib/Support/Compression.cpp
  /Users/jason/k/llvm/llvm-project/llvm/lib/Support/Compression.cpp:24:10: 
fatal error: 'zstd.h' file not found
  #include 
   ^~~~
  1 error generated.
  
  % file /opt/homebrew/lib/libzstd.dylib 
  /opt/homebrew/lib/libzstd.dylib: Mach-O 64-bit dynamically linked shared 
library arm64
  % head -2 /opt/homebrew/include/zstd.h 
  /*
   * Copyright (c) Yann Collet, Facebook, Inc.
  %
  
  % grep -i zstd CMakeCache.txt 
  //Use zstd for compression/decompression if available. Can be ON,
  LLVM_ENABLE_ZSTD:STRING=ON
  ZSTD_INCLUDE_DIR:PATH=/opt/homebrew/include
  ZSTD_LIBRARY:FILEPATH=/opt/homebrew/lib/libzstd.dylib
  //Details about finding ZSTD
  
FIND_PACKAGE_MESSAGE_DETAILS_ZSTD:INTERNAL=[/opt/homebrew/lib/libzstd.dylib][/opt/homebrew/include][v()]
  //Have symbol ZSTD_compress
  HAVE_ZSTD:INTERNAL=1
  //ADVANCED property for variable: ZSTD_INCLUDE_DIR
  ZSTD_INCLUDE_DIR-ADVANCED:INTERNAL=1
  //ADVANCED property for variable: ZSTD_LIBRARY
  ZSTD_LIBRARY-ADVANCED:INTERNAL=1


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128465

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


[PATCH] D129048: Rewording the "static_assert" to static assertion

2022-07-14 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

Most of the libc++ CI testing happens on BuildKite, and we only trigger the 
libc++ buildkite pipeline if files in `libcxx/` (and a few others) have 
changed. This wasn't the case here. If you want to re-land without breaking 
libc++, you'd have to go through libc++'s `.verify.cpp` tests and change the 
regex that we look for.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129048

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


[PATCH] D128465: [llvm] add zstd to `llvm::compression` namespace

2022-07-14 Thread Cole Kissane via Phabricator via cfe-commits
ckissane added a comment.

In D128465#3653051 , @jasonmolenda 
wrote:

> In D128465#3652525 , @ckissane 
> wrote:
>
>> In D128465#3651025 , @aemerson 
>> wrote:
>>
>>> I just reverted this in 6e6be5f9504d 
>>>  
>>> because it seems to have broken macOS builds:
>>>
>>>   llvm/lib/Support/Compression.cpp:24:10: fatal error: 'zstd.h' file not 
>>> found
>>>   #include 
>>>^~~~
>>
>> @aemerson Could you provide the output of your cmake command?
>> (I can't easily reproduce because I don't have a mac on hand)
>
> FWIW I hit this last night on my mac desktop - it looked like I had zstd 
> installed by homebrew (as a dependency on something I installed), and cmake 
> was able to find it in /opt/homebrew (somehow) but when Compression.cpp was 
> built, nothing had added -I/opt/homebrew/include so the header wasn't found.  
> I hacked the FindZSTD.cmake to not find it, to finish what I was working on 
> before bedtime.  This might not be related to what @aemerson saw though.

@jasonmolenda Thank you for the info, I believe it is similar, could you try: 
https://reviews.llvm.org/D129786 for me?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128465

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


[PATCH] D129802: [DRAFT] Implementing new atomic orderings in LLVM and generate barriers for legacy __sync builtins. Support corresponding memory model in outline atomics as well.

2022-07-14 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added a comment.

I can't obviously see a description of what the additional barriers implied by 
the sync variants is (which should be in an update to LangRef at the very 
least, if not also in the summary itself). Inferring it from the AArch64 
assembly is also difficult, and the RISC-V lowering being identical to the 
non-sync forms confuses me further. I don't particularly want to trawl through 
the web of mailing list posts to try and find out which emails have the right 
information and which aren't relevant, either.




Comment at: llvm/include/llvm-c/Core.h:360
+  operations. */
+  LLVMAtomicOrderingSyncAcquire = 8, /**< Acquire with additional barrier. */
+  LLVMAtomicOrderingSyncRelease = 9, /**< Release with additional barrier. */

These comments are not particularly insightful



Comment at: llvm/include/llvm/IR/Instructions.h:660
+  /// Release requests from the AtomicOrdering. A SequentiallyConsistent and
+  /// StrongSequetiallyConsistent operations would remain
+  /// SequentiallyConsistent.

You mean SyncSequentiallyConsistent?



Comment at: llvm/include/llvm/IR/Instructions.h:670
 case AtomicOrdering::Monotonic:
   return AtomicOrdering::Monotonic;
 case AtomicOrdering::AcquireRelease:

Are these correct? Without a clear description of what SyncFoo add over and 
above Foo it's hard to know.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129802

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


[PATCH] D127363: [Lex] Fix for char32_t literal truncation on 16 bit architectures

2022-07-14 Thread Tom Honermann via Phabricator via cfe-commits
tahonermann added a comment.

>> Additionally, the type of a character constant in C is int.
>
> This means that char32_t c4 = U'\U00064321'; is invalid in C

No. A character constant that does not have an encoding prefix has type `int` 
in C. Character constants that have an encoding prefix have the type indicated 
by the encoding prefix. `U'\U00064321'` has type `char32_t` in C (a typedef of 
`uint_least32_t` which is a typedef of some integer type).

When posting an updated patch, please make sure to add the `-U9` option to 
`diff` to ensure that surrounding code context is available for code reviewers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127363

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


[PATCH] D129714: [Driver] Don't passs --dynamic-linker in -r mode

2022-07-14 Thread Brad Smith via Phabricator via cfe-commits
brad updated this revision to Diff 444791.
brad added a comment.

Disable -pie when using -r.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129714

Files:
  clang/lib/Driver/ToolChains/Ananas.cpp
  clang/lib/Driver/ToolChains/DragonFly.cpp
  clang/lib/Driver/ToolChains/FreeBSD.cpp
  clang/lib/Driver/ToolChains/Fuchsia.cpp
  clang/lib/Driver/ToolChains/NetBSD.cpp
  clang/lib/Driver/ToolChains/OpenBSD.cpp
  clang/test/Driver/ananas.c
  clang/test/Driver/dragonfly.c
  clang/test/Driver/freebsd.c
  clang/test/Driver/fuchsia.c
  clang/test/Driver/netbsd.c
  clang/test/Driver/openbsd.c

Index: clang/test/Driver/openbsd.c
===
--- clang/test/Driver/openbsd.c
+++ clang/test/Driver/openbsd.c
@@ -37,6 +37,7 @@
 // RUN: %clang --target=mips64el-unknown-openbsd -### %s 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-MIPS64EL-LD %s
 // CHECK-LD-R: "-r"
+// CHECK-LD-R-NOT: "-dynamic-linker"
 // CHECK-LD-R-NOT: "-l
 // CHECK-LD-R-NOT: crt{{[^./]+}}.o
 // CHECK-LD-S: "-cc1" "-triple" "i686-pc-openbsd"
Index: clang/test/Driver/netbsd.c
===
--- clang/test/Driver/netbsd.c
+++ clang/test/Driver/netbsd.c
@@ -468,10 +468,12 @@
 // RUN:   | FileCheck -check-prefix=POWERPC-SECUREPLT %s
 // POWERPC-SECUREPLT: "-target-feature" "+secure-plt"
 
-// -r suppresses default -l and crt*.o like -nostdlib.
+// -r suppresses -dynamic-linker, default -l and crt*.o like -nostdlib.
 // RUN: %clang --target=x86_64-unknown-netbsd -r \
 // RUN: --sysroot=%S/Inputs/basic_netbsd_tree -### %s 2>&1 \
 // RUN: | FileCheck -check-prefix=RELOCATABLE %s
 // RELOCATABLE: "-r"
+// RELOCATABLE-NOT: "-pie"
+// RELOCATABLE-NOT: "-dynamic-linker"
 // RELOCATABLE-NOT: "-l
 // RELOCATABLE-NOT: crt{{[^./]+}}.o
Index: clang/test/Driver/fuchsia.c
===
--- clang/test/Driver/fuchsia.c
+++ clang/test/Driver/fuchsia.c
@@ -74,6 +74,7 @@
 // RUN: | FileCheck %s -check-prefix=CHECK-RELOCATABLE
 // CHECK-RELOCATABLE-NOT: "-pie"
 // CHECK-RELOCATABLE-NOT: "--build-id"
+// CHECK-RELOCATABLE-NOT "-dynamic-linker"
 // CHECK-RELOCATABLE: "-r"
 // CHECK-RELOCATABLE-NOT: "-l
 // CHECK-RELOCATABLE-NOT: crt{{[^./]+}}.o
Index: clang/test/Driver/freebsd.c
===
--- clang/test/Driver/freebsd.c
+++ clang/test/Driver/freebsd.c
@@ -206,9 +206,10 @@
 // RUN: FileCheck -check-prefix=PPC64-MUNWIND %s
 // PPC64-MUNWIND: "-funwind-tables=2"
 
-/// -r suppresses default -l and crt*.o like -nostdlib.
+/// -r suppresses -dynamic-linker, default -l and crt*.o like -nostdlib.
 // RUN: %clang -### %s --target=aarch64-pc-freebsd11 -r \
 // RUN:   --sysroot=%S/Inputs/basic_freebsd64_tree 2>&1 | FileCheck %s --check-prefix=RELOCATABLE
 // RELOCATABLE: "-r"
+// RELOCATABLE-NOT: "-dynamic-linker"
 // RELOCATABLE-NOT: "-l
 // RELOCATABLE-NOT: crt{{[^./]+}}.o
Index: clang/test/Driver/dragonfly.c
===
--- clang/test/Driver/dragonfly.c
+++ clang/test/Driver/dragonfly.c
@@ -4,9 +4,10 @@
 // CHECK: "-cc1" "-triple" "x86_64-pc-dragonfly"
 // CHECK: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker" "/usr/libexec/ld-elf.so.{{.*}}" "--hash-style=gnu" "--enable-new-dtags" "-o" "a.out" "{{.*}}crt1.o" "{{.*}}crti.o" "{{.*}}crtbegin.o" "{{.*}}.o" "-L{{.*}}gcc{{.*}}" "-rpath" "{{.*}}gcc{{.*}}" "-lc" "-lgcc" "{{.*}}crtend.o" "{{.*}}crtn.o"
 
-// -r suppresses default -l and crt*.o like -nostdlib.
+// -r suppresses -dynamic-linker, default -l and crt*.o like -nostdlib.
 // RUN: %clang -### %s --target=x86_64-pc-dragonfly -r \
 // RUN:   2>&1 | FileCheck %s --check-prefix=RELOCATABLE
 // RELOCATABLE: "-r"
+// RELOCATABLE-NOT: "-dynamic-linker"
 // RELOCATABLE-NOT: "-l
 // RELOCATABLE-NOT: {{.*}}crt{{[^./]+}}.o
Index: clang/test/Driver/ananas.c
===
--- clang/test/Driver/ananas.c
+++ clang/test/Driver/ananas.c
@@ -16,9 +16,11 @@
 // CHECK-SHARED: crtendS.o
 // CHECK-SHARED: crtn.o
 
-// -r suppresses default -l and crt*.o like -nostdlib.
+// -r suppresses -dynamic-linker, default -l and crt*.o like -nostdlib.
 // RUN: %clang %s -### -o %t.o --target=x86_64-unknown-ananas -r 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-RELOCATABLE
 // CHECK-RELOCATABLE: "-r"
+// CHECK-RELOCATABLE-NOT: "-pie"
+// CHECK-RELOCATABLE-NOT: "-dynamic-linker"
 // CHECK-RELOCATABLE-NOT: "-l
 // CHECK-RELOCATABLE-NOT: /crt{{[^.]+}}.o
Index: clang/lib/Driver/ToolChains/OpenBSD.cpp
===
--- clang/lib/Driver/ToolChains/OpenBSD.cpp
+++ clang/lib/Driver/ToolChains/OpenBSD.cpp
@@ -147,7 +147,7 @@
 CmdArgs.push_back("-Bdynamic");
 if (Args.hasArg(options::OPT_shared)) {
   CmdArgs.push_back("-s

[PATCH] D129772: [clang] Document -femit-compact-unwind option in the User’s Manual

2022-07-14 Thread Jez Ng 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 rG7dbfc4fc065d: [clang] Document -femit-compact-unwind option 
in the User’s Manual (authored by int3).

Changed prior to commit:
  https://reviews.llvm.org/D129772?vs=444740&id=444790#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129772

Files:
  clang/docs/UsersManual.rst


Index: clang/docs/UsersManual.rst
===
--- clang/docs/UsersManual.rst
+++ clang/docs/UsersManual.rst
@@ -843,6 +843,23 @@
 option tells Clang to put double-quotes around the entire filename, which
 is the convention used by NMake and Jom.
 
+.. option:: -femit-dwarf-unwind=
+
+  When to emit DWARF unwind (EH frame) info. This is a Mach-O-specific option.
+
+  Valid values are:
+
+  * ``no-compact-unwind`` - Only emit DWARF unwind when compact unwind 
encodings
+aren't available. This is the default for arm64.
+  * ``always`` - Always emit DWARF unwind regardless.
+  * ``default`` - Use the platform-specific default (``always`` for all
+non-arm64-platforms).
+
+``no-compact-unwind`` is a performance optimization -- Clang will emit smaller
+object files that are more quickly processed by the linker. This may cause
+binary compatibility issues on older x86_64 targets, however, so use it with
+caution.
+
 .. _configuration-files:
 
 Configuration files


Index: clang/docs/UsersManual.rst
===
--- clang/docs/UsersManual.rst
+++ clang/docs/UsersManual.rst
@@ -843,6 +843,23 @@
 option tells Clang to put double-quotes around the entire filename, which
 is the convention used by NMake and Jom.
 
+.. option:: -femit-dwarf-unwind=
+
+  When to emit DWARF unwind (EH frame) info. This is a Mach-O-specific option.
+
+  Valid values are:
+
+  * ``no-compact-unwind`` - Only emit DWARF unwind when compact unwind encodings
+aren't available. This is the default for arm64.
+  * ``always`` - Always emit DWARF unwind regardless.
+  * ``default`` - Use the platform-specific default (``always`` for all
+non-arm64-platforms).
+
+``no-compact-unwind`` is a performance optimization -- Clang will emit smaller
+object files that are more quickly processed by the linker. This may cause
+binary compatibility issues on older x86_64 targets, however, so use it with
+caution.
+
 .. _configuration-files:
 
 Configuration files
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 7dbfc4f - [clang] Document -femit-compact-unwind option in the User’s Manual

2022-07-14 Thread Jez Ng via cfe-commits

Author: Jez Ng
Date: 2022-07-14T16:50:36-04:00
New Revision: 7dbfc4fc065d7f1bd85988351399c7fd2db1ec53

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

LOG: [clang] Document -femit-compact-unwind option in the User’s Manual

Reviewed By: #lld-macho, thakis

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

Added: 


Modified: 
clang/docs/UsersManual.rst

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index c2767d65adbf..1d11b00a1a78 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -843,6 +843,23 @@ a special character, which is the convention used by GNU 
Make. The -MV
 option tells Clang to put double-quotes around the entire filename, which
 is the convention used by NMake and Jom.
 
+.. option:: -femit-dwarf-unwind=
+
+  When to emit DWARF unwind (EH frame) info. This is a Mach-O-specific option.
+
+  Valid values are:
+
+  * ``no-compact-unwind`` - Only emit DWARF unwind when compact unwind 
encodings
+aren't available. This is the default for arm64.
+  * ``always`` - Always emit DWARF unwind regardless.
+  * ``default`` - Use the platform-specific default (``always`` for all
+non-arm64-platforms).
+
+``no-compact-unwind`` is a performance optimization -- Clang will emit smaller
+object files that are more quickly processed by the linker. This may cause
+binary compatibility issues on older x86_64 targets, however, so use it with
+caution.
+
 .. _configuration-files:
 
 Configuration files



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


[PATCH] D129443: [clang-format] Add option for aligning requires clause body

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

Looks very promising.




Comment at: clang/include/clang/Format/Format.h:396
+  /// \version 15
+  RequiresExpressionIndentationKind RequiresExpressionIndentation;
+

Please resort.



Comment at: clang/include/clang/Format/Format.h:3885
AlignOperands == R.AlignOperands &&
+   RequiresExpressionIndentation == R.RequiresExpressionIndentation &&
AlignTrailingComments == R.AlignTrailingComments &&

Please resort.



Comment at: clang/unittests/Format/FormatTest.cpp:24805-24810
+  verifyFormat("template  void f() {\n"
+   "  if constexpr (requires(T t) {\n"
+   "  { t.bar() } -> std::same_as;\n"
+   "}) {\n"
+   "  }\n"
+   "}",

This is a bad example, since we can't see any difference.

What happens if it's not the first expression in the if.



Comment at: clang/unittests/Format/FormatTest.cpp:20036
   Style.Language = FormatStyle::LK_Cpp;
+  CHECK_PARSE_BOOL(AlignRequiresClauseBody);
   CHECK_PARSE_BOOL(AlignTrailingComments);

Please add the parsing test for the enum.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129443

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


[PATCH] D128690: [ODRHash diagnostics] Preparation to minimize subsequent diffs. NFC.

2022-07-14 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai updated this revision to Diff 444787.
vsapsai added a comment.

Rebase and unhoist `ComputeTemplateParameterListODRHash`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128690

Files:
  clang/lib/Serialization/ASTReader.cpp

Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -9445,6 +9445,31 @@
   PendingMergedDefinitionsToDeduplicate.clear();
 }
 
+static unsigned computeODRHash(QualType Ty) {
+  ODRHash Hasher;
+  Hasher.AddQualType(Ty);
+  return Hasher.CalculateHash();
+}
+
+static unsigned computeODRHash(const Stmt *S) {
+  ODRHash Hasher;
+  Hasher.AddStmt(S);
+  return Hasher.CalculateHash();
+}
+
+static unsigned computeODRHash(const Decl *D) {
+  assert(D);
+  ODRHash Hasher;
+  Hasher.AddSubDecl(D);
+  return Hasher.CalculateHash();
+}
+
+static unsigned computeODRHash(const TemplateArgument &TA) {
+  ODRHash Hasher;
+  Hasher.AddTemplateArgument(TA);
+  return Hasher.CalculateHash();
+}
+
 void ASTReader::diagnoseOdrViolations() {
   if (PendingOdrMergeFailures.empty() && PendingOdrMergeChecks.empty() &&
   PendingFunctionOdrMergeFailures.empty() &&
@@ -9584,42 +9609,6 @@
   // we're producing our diagnostics.
   Deserializing RecursionGuard(this);
 
-  // Common code for hashing helpers.
-  ODRHash Hash;
-  auto ComputeQualTypeODRHash = [&Hash](QualType Ty) {
-Hash.clear();
-Hash.AddQualType(Ty);
-return Hash.CalculateHash();
-  };
-
-  auto ComputeODRHash = [&Hash](const Stmt *S) {
-assert(S);
-Hash.clear();
-Hash.AddStmt(S);
-return Hash.CalculateHash();
-  };
-
-  auto ComputeSubDeclODRHash = [&Hash](const Decl *D) {
-assert(D);
-Hash.clear();
-Hash.AddSubDecl(D);
-return Hash.CalculateHash();
-  };
-
-  auto ComputeTemplateArgumentODRHash = [&Hash](const TemplateArgument &TA) {
-Hash.clear();
-Hash.AddTemplateArgument(TA);
-return Hash.CalculateHash();
-  };
-
-  auto ComputeTemplateParameterListODRHash =
-  [&Hash](const TemplateParameterList *TPL) {
-assert(TPL);
-Hash.clear();
-Hash.AddTemplateParameterList(TPL);
-return Hash.CalculateHash();
-  };
-
   // Used with err_module_odr_violation_mismatch_decl and
   // note_module_odr_violation_mismatch_decl
   // This list should be the same Decl's as in ODRHash::isDeclToBeProcessed
@@ -9639,49 +9628,13 @@
 Other
   };
 
-  // Used with err_module_odr_violation_record and
-  // note_module_odr_violation_record
-  enum ODRCXXRecordDifference {
-StaticAssertCondition,
-StaticAssertMessage,
-StaticAssertOnlyMessage,
-MethodName,
-MethodDeleted,
-MethodDefaulted,
-MethodVirtual,
-MethodStatic,
-MethodVolatile,
-MethodConst,
-MethodInline,
-MethodNumberParameters,
-MethodParameterType,
-MethodParameterName,
-MethodParameterSingleDefaultArgument,
-MethodParameterDifferentDefaultArgument,
-MethodNoTemplateArguments,
-MethodDifferentNumberTemplateArguments,
-MethodDifferentTemplateArgument,
-MethodSingleBody,
-MethodDifferentBody,
-FriendTypeFunction,
-FriendType,
-FriendFunction,
-FunctionTemplateDifferentNumberParameters,
-FunctionTemplateParameterDifferentKind,
-FunctionTemplateParameterName,
-FunctionTemplateParameterSingleDefaultArgument,
-FunctionTemplateParameterDifferentDefaultArgument,
-FunctionTemplateParameterDifferentType,
-FunctionTemplatePackParameter,
-  };
-
   // These lambdas have the common portions of the ODR diagnostics.  This
   // has the same return as Diag(), so addition parameters can be passed
   // in with operator<<
-  auto ODRDiagField = [this, &ComputeQualTypeODRHash, &ComputeODRHash](
-  NamedDecl *FirstRecord, StringRef FirstModule,
-  StringRef SecondModule, FieldDecl *FirstField,
-  FieldDecl *SecondField) {
+  auto ODRDiagField = [this](NamedDecl *FirstRecord, StringRef FirstModule,
+ StringRef SecondModule,
+ const FieldDecl *FirstField,
+ const FieldDecl *SecondField) {
 enum ODRFieldDifference {
   FieldName,
   FieldTypeName,
@@ -9719,8 +9672,7 @@
 
 QualType FirstType = FirstField->getType();
 QualType SecondType = SecondField->getType();
-if (ComputeQualTypeODRHash(FirstType) !=
-ComputeQualTypeODRHash(SecondType)) {
+if (computeODRHash(FirstType) != computeODRHash(SecondType)) {
   DiagError(FieldTypeName) << FirstII << FirstType;
   DiagNote(FieldTypeName) << SecondII << SecondType;
   return true;
@@ -9735,10 +9687,8 @@
 }
 
 if (IsFirstBitField && IsSecondBitField) {
-  unsigned FirstBitWidthHash =
-  ComputeODRHash(First

[PATCH] D129706: [NFCI][clang-tidy] Reimplement GlobList without relying on Regex.

2022-07-14 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 444786.
njames93 added a comment.

Added functionality for Checking equivalence to a StringRef without having to 
build the Glob.

These features are ground work for upcoming patches.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129706

Files:
  clang-tools-extra/clang-tidy/GlobList.cpp
  clang-tools-extra/clang-tidy/GlobList.h
  clang-tools-extra/unittests/clang-tidy/GlobListTest.cpp

Index: clang-tools-extra/unittests/clang-tidy/GlobListTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/GlobListTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/GlobListTest.cpp
@@ -16,6 +16,13 @@
   EXPECT_FALSE(Filter.contains("aaa"));
 }
 
+TYPED_TEST(GlobListTest, NotEmpty) {
+  TypeParam Filter("*,-");
+
+  EXPECT_FALSE(Filter.contains(""));
+  EXPECT_TRUE(Filter.contains("aaa"));
+}
+
 TYPED_TEST(GlobListTest, Nothing) {
   TypeParam Filter("-*");
 
@@ -57,6 +64,51 @@
   EXPECT_FALSE(Filter.contains(""));
 }
 
+TYPED_TEST(GlobListTest, PreAndPostFixPattern) {
+  TypeParam Filter("a*b");
+
+  EXPECT_TRUE(Filter.contains("ab"));
+  EXPECT_TRUE(Filter.contains("aMiddleb"));
+  EXPECT_FALSE(Filter.contains("aba"));
+  EXPECT_FALSE(Filter.contains("bab"));
+}
+
+TYPED_TEST(GlobListTest, DoubleWildcard) {
+  {
+TypeParam Filter("a**b");
+
+EXPECT_TRUE(Filter.isEquivalentTo("a*b"));
+EXPECT_TRUE(Filter.isEquivalentTo("a***b"));
+
+EXPECT_TRUE(Filter.contains("ab"));
+EXPECT_TRUE(Filter.contains("aMiddleb"));
+EXPECT_FALSE(Filter.contains("aba"));
+EXPECT_FALSE(Filter.contains("bab"));
+  }
+  {
+TypeParam Filter("a**");
+
+EXPECT_TRUE(Filter.isEquivalentTo("a*"));
+EXPECT_TRUE(Filter.isEquivalentTo("a***"));
+
+EXPECT_TRUE(Filter.contains("ab"));
+EXPECT_TRUE(Filter.contains("aMiddleb"));
+EXPECT_TRUE(Filter.contains("aba"));
+EXPECT_FALSE(Filter.contains("bab"));
+  }
+  {
+TypeParam Filter("**b");
+
+EXPECT_TRUE(Filter.isEquivalentTo("*b"));
+EXPECT_TRUE(Filter.isEquivalentTo("***b"));
+
+EXPECT_TRUE(Filter.contains("ab"));
+EXPECT_TRUE(Filter.contains("aMiddleb"));
+EXPECT_FALSE(Filter.contains("aba"));
+EXPECT_TRUE(Filter.contains("bab"));
+  }
+}
+
 TYPED_TEST(GlobListTest, PatternPriority) {
   // The last glob that matches the string decides whether that string is
   // included or excluded.
@@ -107,6 +159,9 @@
 TYPED_TEST(GlobListTest, NewlineCharactersAsSeparators) {
   TypeParam Filter("a*  \n b,\n-c*,dd");
 
+  // FIXME: Define this behaviour, There are 2 seperator characters next to each
+  // other (,\n), Technically that should be represented as containing an empty
+  // item.
   EXPECT_FALSE(Filter.contains(""));
   EXPECT_TRUE(Filter.contains("aaa"));
   EXPECT_TRUE(Filter.contains("b"));
@@ -117,5 +172,45 @@
   EXPECT_FALSE(Filter.contains("ddd"));
 }
 
+TYPED_TEST(GlobListTest, IgnoreNegativeMatches) {
+  TypeParam Filter("a,-a,b*,-b*,-*", false);
+
+  EXPECT_FALSE(Filter.contains(""));
+  EXPECT_TRUE(Filter.contains("a"));
+  EXPECT_TRUE(Filter.contains("b"));
+  EXPECT_TRUE(Filter.contains("bar"));
+}
+
+void checkCanonicalize(StringRef Glob, StringRef Expected) {
+  GlobList Orig(Glob);
+  std::string Canonicalized;
+  llvm::raw_string_ostream Str(Canonicalized);
+  Orig.print(Str);
+  Str.flush();
+  EXPECT_EQ(Canonicalized, Expected)
+  << "While canonicalizing glob: \"" << Glob << "\"";
+  EXPECT_TRUE(Orig.isEquivalentTo(Expected))
+  << "While canonicalizing glob: \"" << Glob << "\"";
+  ;
+  GlobList Canonical(Canonicalized);
+  EXPECT_TRUE(Orig.isEquivalentTo(Canonical))
+  << "While canonicalizing glob: \"" << Glob << "\"";
+  ;
+  EXPECT_TRUE(Canonical.isEquivalentTo(Glob))
+  << "While canonicalizing glob: \"" << Glob << "\"";
+  ;
+}
+
+TEST(GlobListTest, Printing) {
+  // A positive wildcard is always printed with any previous items removed
+  // checkCanonicalize(" *", "*");
+  // checkCanonicalize(" * ,   -AAA ", "*,-AAA");
+  checkCanonicalize("Unused , *, -A*", "*,-A*");
+  // A negative wildcard is removed if there is nothing else after it.
+  checkCanonicalize("-* ", "-*");
+  checkCanonicalize("-*, AAA  ", "AAA");
+  checkCanonicalize("Unused\n-*\nRest\n*Others", "Rest,*Others");
+}
+
 } // namespace tidy
 } // namespace clang
Index: clang-tools-extra/clang-tidy/GlobList.h
===
--- clang-tools-extra/clang-tidy/GlobList.h
+++ clang-tools-extra/clang-tidy/GlobList.h
@@ -10,10 +10,10 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_GLOBLIST_H
 
 #include "clang/Basic/LLVM.h"
-#include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
-#include "llvm/Support/Regex.h"
+#include 
+#include 
 
 namespace clang {
 namespace tidy {
@@ -25,7 +25,9 @@
 /// them in the order of appearance in the list.

[PATCH] D128955: [WPD] Use new llvm.public.type.test intrinsic for potentially publicly visible classes

2022-07-14 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

I did verify that `-fvisibility=hidden` still devirtualizes, and same with 
`-Wl,--lto-whole-program-visibility`, but not if both are missing




Comment at: llvm/lib/LTO/LTOBackend.cpp:595
 
+  updatePublicTypeTestCalls(Mod, Conf.HasWholeProgramVisibility);
+

I'm not sure where the best place to put these is


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128955

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


[PATCH] D129799: [clang-tidy] Add CLANG_MAKE_CONFUSABLE_TABLE cmake cache variable to avoid building when cross compiling

2022-07-14 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

As the name of the tool becomes somewhat public and stable at this point, feel 
free to suggest shorter/neater names in D129798 
 too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129799

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


[PATCH] D129799: [clang-tidy] Add CLANG_MAKE_CONFUSABLE_TABLE cmake cache variable to avoid building when cross compiling

2022-07-14 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.
mstorsjo added reviewers: serge-sans-paille, sammccall, whisperity, 
aaron.ballman.
Herald added subscribers: carlosgalvezp, rnkovacs, xazax.hun, mgorny.
Herald added a project: All.
mstorsjo requested review of this revision.
Herald added a project: clang-tools-extra.

This is similar to the LLVM_TABLEGEN, CLANG_TABLEGEN and
CLANG_PSEUDO_GEN variables.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129799

Files:
  clang-tools-extra/clang-tidy/misc/CMakeLists.txt


Index: clang-tools-extra/clang-tidy/misc/CMakeLists.txt
===
--- clang-tools-extra/clang-tidy/misc/CMakeLists.txt
+++ clang-tools-extra/clang-tidy/misc/CMakeLists.txt
@@ -3,7 +3,13 @@
   Support
   )
 
-if(LLVM_USE_HOST_TOOLS)
+set(CLANG_MAKE_CONFUSABLE_TABLE "clang-make-confusable-table" CACHE
+  STRING "Host clang-make-confusable-table executable. Saves building if 
cross-compiling.")
+
+if(NOT CLANG_MAKE_CONFUSABLE_TABLE STREQUAL "clang-make-confusable-table")
+  set(make_confusable_table ${CLANG_MAKE_CONFUSABLE_TABLE})
+  set(make_confusable_table_target ${CLANG_MAKE_CONFUSABLE_TABLE})
+elseif(LLVM_USE_HOST_TOOLS)
   build_native_tool(clang-make-confusable-table make_confusable_table)
   set(make_confusable_table_target "${make_confusable_table}")
 else()


Index: clang-tools-extra/clang-tidy/misc/CMakeLists.txt
===
--- clang-tools-extra/clang-tidy/misc/CMakeLists.txt
+++ clang-tools-extra/clang-tidy/misc/CMakeLists.txt
@@ -3,7 +3,13 @@
   Support
   )
 
-if(LLVM_USE_HOST_TOOLS)
+set(CLANG_MAKE_CONFUSABLE_TABLE "clang-make-confusable-table" CACHE
+  STRING "Host clang-make-confusable-table executable. Saves building if cross-compiling.")
+
+if(NOT CLANG_MAKE_CONFUSABLE_TABLE STREQUAL "clang-make-confusable-table")
+  set(make_confusable_table ${CLANG_MAKE_CONFUSABLE_TABLE})
+  set(make_confusable_table_target ${CLANG_MAKE_CONFUSABLE_TABLE})
+elseif(LLVM_USE_HOST_TOOLS)
   build_native_tool(clang-make-confusable-table make_confusable_table)
   set(make_confusable_table_target "${make_confusable_table}")
 else()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129798: [clang-tidy] Add a "clang-" namespace prefix to the make-confusable-target executable

2022-07-14 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.
mstorsjo added reviewers: serge-sans-paille, sammccall, whisperity, 
aaron.ballman.
Herald added subscribers: carlosgalvezp, rnkovacs, xazax.hun, mgorny.
Herald added a project: All.
mstorsjo requested review of this revision.
Herald added projects: LLVM, clang-tools-extra.
Herald added a subscriber: llvm-commits.

In cross builds, the caller might want to provide this tool
externally (to avoid needing to rebuild it in the cross build).
In such a case, having the tool properly namespaced makes its role
clearer.

This matches how the clang-pseudo-gen tool was renamed in
a43fef05d4fae32f02365c7b8fef2aa631d23628 
 / D126725 
.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129798

Files:
  clang-tools-extra/clang-tidy/misc/CMakeLists.txt
  clang-tools-extra/clang-tidy/misc/ConfusableTable/CMakeLists.txt
  
llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/misc/ConfusableTable/BUILD.gn


Index: 
llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/misc/ConfusableTable/BUILD.gn
===
--- 
llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/misc/ConfusableTable/BUILD.gn
+++ 
llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/misc/ConfusableTable/BUILD.gn
@@ -1,4 +1,4 @@
-executable("make-confusable-table") {
+executable("clang-make-confusable-table") {
   deps = [ "//llvm/lib/Support" ]
   sources = [ "BuildConfusableTable.cpp" ]
 }
Index: clang-tools-extra/clang-tidy/misc/ConfusableTable/CMakeLists.txt
===
--- clang-tools-extra/clang-tidy/misc/ConfusableTable/CMakeLists.txt
+++ clang-tools-extra/clang-tidy/misc/ConfusableTable/CMakeLists.txt
@@ -1,6 +1,6 @@
 set(LLVM_LINK_COMPONENTS Support)
 list(REMOVE_ITEM LLVM_COMMON_DEPENDS clang-tablegen-targets)
 
-add_llvm_executable(make-confusable-table
+add_llvm_executable(clang-make-confusable-table
   BuildConfusableTable.cpp
   )
Index: clang-tools-extra/clang-tidy/misc/CMakeLists.txt
===
--- clang-tools-extra/clang-tidy/misc/CMakeLists.txt
+++ clang-tools-extra/clang-tidy/misc/CMakeLists.txt
@@ -4,11 +4,11 @@
   )
 
 if(LLVM_USE_HOST_TOOLS)
-  build_native_tool(make-confusable-table make_confusable_table)
+  build_native_tool(clang-make-confusable-table make_confusable_table)
   set(make_confusable_table_target "${make_confusable_table}")
 else()
-  set(make_confusable_table $)
-  set(make_confusable_table_target make-confusable-table)
+  set(make_confusable_table $)
+  set(make_confusable_table_target clang-make-confusable-table)
 endif()
 
 add_subdirectory(ConfusableTable)


Index: llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/misc/ConfusableTable/BUILD.gn
===
--- llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/misc/ConfusableTable/BUILD.gn
+++ llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/misc/ConfusableTable/BUILD.gn
@@ -1,4 +1,4 @@
-executable("make-confusable-table") {
+executable("clang-make-confusable-table") {
   deps = [ "//llvm/lib/Support" ]
   sources = [ "BuildConfusableTable.cpp" ]
 }
Index: clang-tools-extra/clang-tidy/misc/ConfusableTable/CMakeLists.txt
===
--- clang-tools-extra/clang-tidy/misc/ConfusableTable/CMakeLists.txt
+++ clang-tools-extra/clang-tidy/misc/ConfusableTable/CMakeLists.txt
@@ -1,6 +1,6 @@
 set(LLVM_LINK_COMPONENTS Support)
 list(REMOVE_ITEM LLVM_COMMON_DEPENDS clang-tablegen-targets)
 
-add_llvm_executable(make-confusable-table
+add_llvm_executable(clang-make-confusable-table
   BuildConfusableTable.cpp
   )
Index: clang-tools-extra/clang-tidy/misc/CMakeLists.txt
===
--- clang-tools-extra/clang-tidy/misc/CMakeLists.txt
+++ clang-tools-extra/clang-tidy/misc/CMakeLists.txt
@@ -4,11 +4,11 @@
   )
 
 if(LLVM_USE_HOST_TOOLS)
-  build_native_tool(make-confusable-table make_confusable_table)
+  build_native_tool(clang-make-confusable-table make_confusable_table)
   set(make_confusable_table_target "${make_confusable_table}")
 else()
-  set(make_confusable_table $)
-  set(make_confusable_table_target make-confusable-table)
+  set(make_confusable_table $)
+  set(make_confusable_table_target clang-make-confusable-table)
 endif()
 
 add_subdirectory(ConfusableTable)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129797: [clang-tidy] Reduce the dependencies for the "make-confusable-table" tool

2022-07-14 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.
mstorsjo added reviewers: serge-sans-paille, sammccall, whisperity, 
aaron.ballman.
Herald added subscribers: carlosgalvezp, rnkovacs, xazax.hun, mgorny.
Herald added a project: All.
mstorsjo requested review of this revision.
Herald added a project: clang-tools-extra.

When cross compiling llvm, a separate recursive native cmake build
is generated, for building the tools that generate code (unless they're
provided externally by the caller).

This reduces the number of build steps for that native build from
1000+ steps to 162.

This matches how the clang-pseudo-gen tool is set up in
clang-tools-extra/pseudo/gen/CMakeLists.txt.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129797

Files:
  clang-tools-extra/clang-tidy/misc/ConfusableTable/CMakeLists.txt


Index: clang-tools-extra/clang-tidy/misc/ConfusableTable/CMakeLists.txt
===
--- clang-tools-extra/clang-tidy/misc/ConfusableTable/CMakeLists.txt
+++ clang-tools-extra/clang-tidy/misc/ConfusableTable/CMakeLists.txt
@@ -1,3 +1,6 @@
+set(LLVM_LINK_COMPONENTS Support)
+list(REMOVE_ITEM LLVM_COMMON_DEPENDS clang-tablegen-targets)
+
 add_llvm_executable(make-confusable-table
   BuildConfusableTable.cpp
   )


Index: clang-tools-extra/clang-tidy/misc/ConfusableTable/CMakeLists.txt
===
--- clang-tools-extra/clang-tidy/misc/ConfusableTable/CMakeLists.txt
+++ clang-tools-extra/clang-tidy/misc/ConfusableTable/CMakeLists.txt
@@ -1,3 +1,6 @@
+set(LLVM_LINK_COMPONENTS Support)
+list(REMOVE_ITEM LLVM_COMMON_DEPENDS clang-tablegen-targets)
+
 add_llvm_executable(make-confusable-table
   BuildConfusableTable.cpp
   )
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D128465: [llvm] add zstd to `llvm::compression` namespace

2022-07-14 Thread Jason Molenda via Phabricator via cfe-commits
jasonmolenda added a comment.

In D128465#3652525 , @ckissane wrote:

> In D128465#3651025 , @aemerson 
> wrote:
>
>> I just reverted this in 6e6be5f9504d 
>>  
>> because it seems to have broken macOS builds:
>>
>>   llvm/lib/Support/Compression.cpp:24:10: fatal error: 'zstd.h' file not 
>> found
>>   #include 
>>^~~~
>
> @aemerson Could you provide the output of your cmake command?
> (I can't easily reproduce because I don't have a mac on hand)

FWIW I hit this last night on my mac desktop - it looked like I had zstd 
installed by homebrew (as a dependency on something I installed), and cmake was 
able to find it in /opt/homebrew (somehow) but when Compression.cpp was built, 
nothing had added -I/opt/homebrew/include so the header wasn't found.  I hacked 
the FindZSTD.cmake to not find it, to finish what I was working on before 
bedtime.  This might not be related to what @aemerson saw though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128465

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


[clang] a629ec2 - [test] Fix D129789 for 32bit platforms

2022-07-14 Thread Vitaly Buka via cfe-commits

Author: Vitaly Buka
Date: 2022-07-14T12:44:15-07:00
New Revision: a629ec2f47a64b1a5b33dbcedf1efc6989f97641

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

LOG: [test] Fix D129789 for 32bit platforms

Added: 


Modified: 
clang/test/CodeGen/lifetime2.c

Removed: 




diff  --git a/clang/test/CodeGen/lifetime2.c b/clang/test/CodeGen/lifetime2.c
index 0def7b6de8c2..6486517dec44 100644
--- a/clang/test/CodeGen/lifetime2.c
+++ b/clang/test/CodeGen/lifetime2.c
@@ -89,7 +89,7 @@ extern void foo2(int p);
 // O2-LABEL: @jump_backward_over_declaration(
 int jump_backward_over_declaration(int a) {
   int *p = 0;
-// O2: call void @llvm.lifetime.start.p0i8(i64 8,
+// O2: call void @llvm.lifetime.start.p0i8(
 label1:
   if (p) {
 foo2(*p);
@@ -102,5 +102,5 @@ int jump_backward_over_declaration(int a) {
 goto label1;
   }
   return -1;
-// O2: call void @llvm.lifetime.end.p0i8(i64 8,
+// O2: call void @llvm.lifetime.end.p0i8(
 }



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


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

2022-07-14 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp:1207
+  auto EmitResourceUsageRemark = [&](StringRef RemarkName,
+ StringRef RemarkLabel, auto &&Argument) {
+// Add an indent for every line besides the line with the kernel name. This

Why &&?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123878

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


[PATCH] D129648: Use pseudo parser for folding ranges

2022-07-14 Thread Utkarsh Saxena via Phabricator via cfe-commits
usaxena95 updated this revision to Diff 444765.
usaxena95 added a comment.

Removed changes from previous revision.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129648

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/SemanticSelection.cpp
  clang-tools-extra/clangd/SemanticSelection.h
  clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp
  clang-tools-extra/pseudo/include/clang-pseudo/Token.h
  clang-tools-extra/pseudo/lib/Lex.cpp

Index: clang-tools-extra/pseudo/lib/Lex.cpp
===
--- clang-tools-extra/pseudo/lib/Lex.cpp
+++ clang-tools-extra/pseudo/lib/Lex.cpp
@@ -26,6 +26,8 @@
 
   TokenStream Result;
   clang::Token CT;
+  // Index into the token stream of original source code.
+  unsigned TokenIdx = 0;
   unsigned LastOffset = 0;
   unsigned Line = 0;
   unsigned Indent = 0;
@@ -66,9 +68,12 @@
 if (CT.needsCleaning() || CT.hasUCN())
   Tok.setFlag(LexFlags::NeedsCleaning);
 
+Tok.OrigTokIdx = TokenIdx++;
 Result.push(Tok);
 LastOffset = Offset;
   }
+  // This stream represents the original source code.
+  Result.setOriginal();
   Result.finalize();
   return Result;
 }
Index: clang-tools-extra/pseudo/include/clang-pseudo/Token.h
===
--- clang-tools-extra/pseudo/include/clang-pseudo/Token.h
+++ clang-tools-extra/pseudo/include/clang-pseudo/Token.h
@@ -33,6 +33,7 @@
 #include "clang/Basic/TokenKinds.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/Support/raw_ostream.h"
+#include 
 #include 
 #include 
 #include 
@@ -67,6 +68,8 @@
   uint8_t Indent = 0;
   /// Flags have some meaning defined by the function that produced this stream.
   uint8_t Flags = 0;
+  /// Index into the original token stream (of the original source file).
+  Index OrigTokIdx = 0;
   // Helpers to get/set Flags based on `enum class`.
   template  bool flag(T Mask) const {
 return Flags & uint8_t{static_cast>(Mask)};
@@ -96,7 +99,7 @@
   /// If this token is a paired bracket, the offset of the pair in the stream.
   int32_t Pair = 0;
 };
-static_assert(sizeof(Token) <= sizeof(char *) + 20, "Careful with layout!");
+static_assert(sizeof(Token) <= sizeof(char *) + 24, "Careful with layout!");
 llvm::raw_ostream &operator<<(llvm::raw_ostream &, const Token &);
 
 /// A half-open range of tokens within a stream.
@@ -170,6 +173,18 @@
 return Storage[1];
   }
 
+  /// An original token stream corresponds to the original source file (Eg.
+  /// produced by lex()). It is not derived from another token stream.
+  bool isOriginal() const { return IsOriginal; }
+  void setOriginal() { IsOriginal = true; }
+
+  /// Extracts the token in original stream corresponding to Token T.
+  const Token &origToken(const Token &T) const {
+assert(isOriginal() && "stream is derived");
+assert(T.OrigTokIdx < tokens().size() && "invalid index");
+return tokens()[T.OrigTokIdx];
+  }
+
   /// Print the tokens in this stream to the output stream.
   ///
   /// The presence of newlines/spaces is preserved, but not the quantity.
@@ -180,6 +195,7 @@
 
   MutableArrayRef Tokens;
   std::vector Storage; // eof + Tokens + eof
+  bool IsOriginal = false;
 };
 llvm::raw_ostream &operator<<(llvm::raw_ostream &, const TokenStream &);
 
Index: clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp
@@ -240,7 +240,7 @@
 ]]}
   )cpp",
   R"cpp(
-class Foo {
+class Foo {[[
 public:
   Foo() {[[
 int X = 1;
@@ -253,14 +253,25 @@
 
   // Braces are located at the same line: no folding range here.
   void getFooBar() { }
-};
+]]};
+  )cpp",
+  R"cpp(
+// Range boundaries on escaped newlines.
+class Foo \
+\
+{[[  \
+public:
+  Foo() {[[\
+int X = 1;
+  ]]}   \
+]]};
   )cpp",
   };
   for (const char *Test : Tests) {
 auto T = Annotations(Test);
-auto AST = TestTU::withCode(T.code()).build();
-EXPECT_THAT(gatherFoldingRanges(llvm::cantFail(getFoldingRanges(AST))),
-UnorderedElementsAreArray(T.ranges()))
+EXPECT_THAT(
+gatherFoldingRanges(llvm::cantFail(getFoldingRanges(T.code().str(,
+UnorderedElementsAreArray(T.ranges()))
 << Test;
   }
 }
Index: clang-tools-extra/clangd/SemanticSelection.h
===
--- clang-tools-extra/clangd/SemanticSelection.h
+++ clang-tools-extra/clangd/SemanticSelection.h
@@ -15,6 +15,7 @@
 #include "ParsedAST.h"
 #include "Protocol.h"
 #include "llvm/Support/Error.h"

[PATCH] D109701: [clang] Emit SARIF Diagnostics: Create `clang::SarifDocumentWriter` interface

2022-07-14 Thread Vaibhav Yenamandra via Phabricator via cfe-commits
vaibhav.y updated this revision to Diff 444764.
vaibhav.y added a comment.

Gate death tests on `NDEBUG` and available of `GTEST_HAS_DEATH_TEST`

This should fix recent pre-merge failures


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109701

Files:
  clang/include/clang/Basic/Sarif.h
  clang/lib/Basic/CMakeLists.txt
  clang/lib/Basic/Sarif.cpp
  clang/unittests/Basic/CMakeLists.txt
  clang/unittests/Basic/SarifTest.cpp

Index: clang/unittests/Basic/SarifTest.cpp
===
--- /dev/null
+++ clang/unittests/Basic/SarifTest.cpp
@@ -0,0 +1,325 @@
+//===- unittests/Basic/SarifTest.cpp - Test writing SARIF documents ---===//
+//
+// 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
+//
+//===--===//
+
+#include "clang/Basic/Sarif.h"
+#include "clang/Basic/DiagnosticIDs.h"
+#include "clang/Basic/DiagnosticOptions.h"
+#include "clang/Basic/FileManager.h"
+#include "clang/Basic/FileSystemOptions.h"
+#include "clang/Basic/LangOptions.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/SourceManager.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/FormatVariadic.h"
+#include "llvm/Support/JSON.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/VirtualFileSystem.h"
+#include "llvm/Support/raw_ostream.h"
+#include "gmock/gmock-matchers.h"
+#include "gtest/gtest-death-test.h"
+#include "gtest/gtest-matchers.h"
+#include "gtest/gtest.h"
+
+#include 
+
+using namespace clang;
+
+namespace {
+
+using LineCol = std::pair;
+
+static std::string serializeSarifDocument(llvm::json::Object &&Doc) {
+  std::string Output;
+  llvm::json::Value value(std::move(Doc));
+  llvm::raw_string_ostream OS{Output};
+  OS << llvm::formatv("{0}", value);
+  OS.flush();
+  return Output;
+}
+
+class SarifDocumentWriterTest : public ::testing::Test {
+protected:
+  SarifDocumentWriterTest()
+  : InMemoryFileSystem(new llvm::vfs::InMemoryFileSystem),
+FileMgr(FileSystemOptions(), InMemoryFileSystem),
+DiagID(new DiagnosticIDs()), DiagOpts(new DiagnosticOptions()),
+Diags(DiagID, DiagOpts.get(), new IgnoringDiagConsumer()),
+SourceMgr(Diags, FileMgr) {}
+
+  IntrusiveRefCntPtr InMemoryFileSystem;
+  FileManager FileMgr;
+  IntrusiveRefCntPtr DiagID;
+  IntrusiveRefCntPtr DiagOpts;
+  DiagnosticsEngine Diags;
+  SourceManager SourceMgr;
+  LangOptions LangOpts;
+
+  FileID registerSource(llvm::StringRef Name, const char *SourceText,
+bool IsMainFile = false) {
+std::unique_ptr SourceBuf =
+llvm::MemoryBuffer::getMemBuffer(SourceText);
+const FileEntry *SourceFile =
+FileMgr.getVirtualFile(Name, SourceBuf->getBufferSize(), 0);
+SourceMgr.overrideFileContents(SourceFile, std::move(SourceBuf));
+FileID FID = SourceMgr.getOrCreateFileID(SourceFile, SrcMgr::C_User);
+if (IsMainFile)
+  SourceMgr.setMainFileID(FID);
+return FID;
+  }
+
+  CharSourceRange getFakeCharSourceRange(FileID FID, LineCol Begin,
+ LineCol End) {
+auto BeginLoc = SourceMgr.translateLineCol(FID, Begin.first, Begin.second);
+auto EndLoc = SourceMgr.translateLineCol(FID, End.first, End.second);
+return CharSourceRange{SourceRange{BeginLoc, EndLoc}, /* ITR = */ false};
+  }
+};
+
+TEST_F(SarifDocumentWriterTest, CanCreateEmptyDocument) {
+  // GIVEN:
+  SarifDocumentWriter Writer{SourceMgr};
+
+  // WHEN:
+  const llvm::json::Object &EmptyDoc = Writer.createDocument();
+  std::vector Keys(EmptyDoc.size());
+  std::transform(EmptyDoc.begin(), EmptyDoc.end(), Keys.begin(),
+ [](auto item) { return item.getFirst(); });
+
+  // THEN:
+  ASSERT_THAT(Keys, testing::UnorderedElementsAre("$schema", "version"));
+}
+
+// Test that a newly inserted run will associate correct tool names
+TEST_F(SarifDocumentWriterTest, CanCreateDocumentWithOneRun) {
+  // GIVEN:
+  SarifDocumentWriter Writer{SourceMgr};
+  const char *ShortName = "sariftest";
+  const char *LongName = "sarif writer test";
+
+  // WHEN:
+  Writer.createRun(ShortName, LongName);
+  Writer.endRun();
+  const llvm::json::Object &Doc = Writer.createDocument();
+  const llvm::json::Array *Runs = Doc.getArray("runs");
+
+  // THEN:
+  // A run was created
+  ASSERT_THAT(Runs, testing::NotNull());
+
+  // It is the only run
+  ASSERT_EQ(Runs->size(), 1UL);
+
+  // The tool associated with the run was the tool
+  const llvm::json::Object *driver =
+  Runs->begin()->getAsObject()->getObject("tool")->getObject("driver");
+  ASSERT_THAT(driver, testing::NotNull());
+
+  ASSERT_TRUE(driver->getString("name").hasValue());
+  ASSERT_TRUE(driver->getString("fullName").

[PATCH] D129377: [lldb/Fuzzer] Add fuzzer for expression evaluator

2022-07-14 Thread Chelsea Cassanova via Phabricator via cfe-commits
cassanova updated this revision to Diff 444761.
cassanova edited the summary of this revision.
cassanova added a comment.

Removed the cxx_proto.proto file since we include the headers that it generates 
from the clang side.


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

https://reviews.llvm.org/D129377

Files:
  clang/cmake/modules/ProtobufMutator.cmake
  clang/tools/clang-fuzzer/handle-cxx/CMakeLists.txt
  clang/tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt
  lldb/tools/lldb-fuzzer/CMakeLists.txt
  lldb/tools/lldb-fuzzer/lldb-expression-fuzzer/CMakeLists.txt
  lldb/tools/lldb-fuzzer/lldb-expression-fuzzer/lldb-expression-fuzzer.cpp

Index: lldb/tools/lldb-fuzzer/lldb-expression-fuzzer/lldb-expression-fuzzer.cpp
===
--- /dev/null
+++ lldb/tools/lldb-fuzzer/lldb-expression-fuzzer/lldb-expression-fuzzer.cpp
@@ -0,0 +1,73 @@
+//===-- lldb-expression-fuzzer.cpp ---===//
+//
+// 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
+//
+//===-===//
+//
+// \file
+// This file is a fuzzer for LLDB's expression evaluator. It uses protobufs
+// and the libprotobuf-mutator to create valid C-like inputs for the
+// expression evaluator.
+//
+//===-===//
+
+#include 
+
+#include "cxx_proto.pb.h"
+#include "handle_cxx.h"
+#include "lldb/API/SBBreakpoint.h"
+#include "lldb/API/SBDebugger.h"
+#include "lldb/API/SBError.h"
+#include "lldb/API/SBLaunchInfo.h"
+#include "lldb/API/SBProcess.h"
+#include "lldb/API/SBTarget.h"
+#include "proto_to_cxx.h"
+#include "src/libfuzzer/libfuzzer_macro.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Error.h"
+
+using namespace lldb;
+using namespace llvm;
+using namespace clang_fuzzer;
+
+char **originalargv;
+
+extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) {
+  SBDebugger::Initialize();
+
+  // The path for a simple compiled program is needed to create a
+  // target for the debugger and that path is passed in through argv
+  originalargv = *argv;
+  return 0;
+}
+
+DEFINE_BINARY_PROTO_FUZZER(const clang_fuzzer::Function &input) {
+  auto S = clang_fuzzer::FunctionToString(input);
+
+  // Get the second argument from argv and strip the '--' from it.
+  // This will be used as the path for the object file to create a target from
+  std::string rawpath = originalargv[2];
+  StringRef objpath = rawpath.erase(0, 2);
+
+  // Create a debugger and a target
+  SBDebugger debugger = SBDebugger::Create(false);
+  SBTarget target = debugger.CreateTarget(objpath.str().c_str());
+
+  // Create a breakpoint on the only line in the program
+  SBBreakpoint bp = target.BreakpointCreateByLocation(objpath.str().c_str(), 1);
+
+  // Create launch info and error for launching the process
+  SBLaunchInfo li = target.GetLaunchInfo();
+  SBError error;
+
+  // Launch the process and evaluate the fuzzer's input data
+  // as an expression
+  SBProcess process = target.Launch(li, error);
+  target.EvaluateExpression(S.c_str());
+
+  debugger.DeleteTarget(target);
+  SBDebugger::Destroy(debugger);
+  SBModule::GarbageCollectAllocatedModules();
+}
Index: lldb/tools/lldb-fuzzer/lldb-expression-fuzzer/CMakeLists.txt
===
--- /dev/null
+++ lldb/tools/lldb-fuzzer/lldb-expression-fuzzer/CMakeLists.txt
@@ -0,0 +1,57 @@
+if(CLANG_ENABLE_PROTO_FUZZER)
+  set(LLVM_LINK_COMPONENTS
+Support
+)
+
+  add_llvm_fuzzer(lldb-expression-fuzzer
+EXCLUDE_FROM_ALL
+lldb-expression-fuzzer.cpp
+)
+
+  if(TARGET lldb-expression-fuzzer)
+target_include_directories(lldb-expression-fuzzer PRIVATE ..)
+find_package(Protobuf REQUIRED)
+add_definitions(-DGOOGLE_PROTOBUF_NO_RTTI)
+include_directories(${PROTOBUF_INCLUDE_DIRS})
+include_directories(${CMAKE_CURRENT_BINARY_DIR}/../../../../clang/tools/clang-fuzzer PRIVATE ..)
+
+set(CLANG_CMAKE_MODULE_PATH
+  ${CMAKE_CURRENT_SOURCE_DIR}/../../../../clang/cmake/modules)
+
+set(CMAKE_MODULE_PATH
+  ${CMAKE_MODULE_PATH}
+  ${CLANG_CMAKE_MODULE_PATH})
+
+
+set (PBM_PREFIX lldb_protobuf_mutator)
+include(ProtobufMutator)
+include_directories(${ProtobufMutator_INCLUDE_DIRS})
+
+target_link_libraries(lldb-expression-fuzzer
+  PRIVATE
+  ${ProtobufMutator_LIBRARIES}
+  ${LLVM_LIB_FUZZING_ENGINE}
+  clangHandleCXX
+  clangCXXProto
+  clangProtoToCXX
+  liblldb
+  )
+
+add_custom_command(TARGET lldb-expression-fuzzer PRE_BUILD
+  COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/fuzzer-artifacts/expression-artifacts
+  # Create and compile a simple C program using the command line. This 

[PATCH] D129377: [lldb/Fuzzer] Add fuzzer for expression evaluator

2022-07-14 Thread Chelsea Cassanova via Phabricator via cfe-commits
cassanova marked an inline comment as done.
cassanova added inline comments.



Comment at: lldb/tools/lldb-fuzzer/lldb-expression-fuzzer/cxx_proto.proto:1
+//===-- cxx_proto.proto - Protobuf description of C++ 
-===//
+//

JDevlieghere wrote:
> Do we still need a copy of this for LLDB?
This file is used to generate the cxx_proto.pb.h which is included in the 
source file. Since we just use the clang-fuzzer directory as an include 
directory then we shouldn't need this file anymore 


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

https://reviews.llvm.org/D129377

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


[PATCH] D129594: [InstrProf] Add options to profile function groups

2022-07-14 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129594

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


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

2022-07-14 Thread Vang Thao via Phabricator via cfe-commits
vangthao updated this revision to Diff 444759.
vangthao added a comment.

Change "Kernel Name" to "Function Name" and rebased patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123878

Files:
  clang/test/Frontend/amdgcn-machine-analysis-remarks.cl
  llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
  llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.h
  llvm/lib/Target/AMDGPU/SIProgramInfo.h
  llvm/test/CodeGen/AMDGPU/resource-optimization-remarks.ll

Index: llvm/test/CodeGen/AMDGPU/resource-optimization-remarks.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AMDGPU/resource-optimization-remarks.ll
@@ -0,0 +1,158 @@
+; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx908 -pass-remarks-output=%t -pass-remarks-analysis=kernel-resource-usage -filetype=obj -o /dev/null %s 2>&1 | FileCheck -check-prefix=STDERR %s
+; RUN: FileCheck -check-prefix=REMARK %s < %t
+
+; STDERR: remark: foo.cl:27:0: Function Name: test_kernel
+; STDERR-NEXT: remark: foo.cl:27:0: SGPRs: 24
+; STDERR-NEXT: remark: foo.cl:27:0: VGPRs: 9
+; STDERR-NEXT: remark: foo.cl:27:0: AGPRs: 43
+; STDERR-NEXT: remark: foo.cl:27:0: ScratchSize [bytes/lane]: 0
+; STDERR-NEXT: remark: foo.cl:27:0: Occupancy [waves/SIMD]: 5
+; STDERR-NEXT: remark: foo.cl:27:0: SGPRs Spill: 0
+; STDERR-NEXT: remark: foo.cl:27:0: VGPRs Spill: 0
+; STDERR-NEXT: remark: foo.cl:27:0: LDS Size [bytes/block]: 512
+
+; REMARK-LABEL: --- !Analysis
+; REMARK: Pass:kernel-resource-usage
+; REMARK-NEXT: Name:FunctionName
+; REMARK-NEXT: DebugLoc:{ File: foo.cl, Line: 27, Column: 0 }
+; REMARK-NEXT: Function:test_kernel
+; REMARK-NEXT: Args:
+; REMARK-NEXT:   - String:  'Function Name: '
+; REMARK-NEXT:   - FunctionName:  test_kernel
+; REMARK-NEXT: ...
+; REMARK-NEXT: --- !Analysis
+; REMARK-NEXT: Pass:kernel-resource-usage
+; REMARK-NEXT: Name:NumSGPR
+; REMARK-NEXT: DebugLoc:{ File: foo.cl, Line: 27, Column: 0 }
+; REMARK-NEXT: Function:test_kernel
+; REMARK-NEXT: Args:
+; REMARK-NEXT:   - String:  'SGPRs: '
+; REMARK-NEXT:   - NumSGPR: '24'
+; REMARK-NEXT: ...
+; REMARK-NEXT: --- !Analysis
+; REMARK-NEXT: Pass:kernel-resource-usage
+; REMARK-NEXT: Name:NumVGPR
+; REMARK-NEXT: DebugLoc:{ File: foo.cl, Line: 27, Column: 0 }
+; REMARK-NEXT: Function:test_kernel
+; REMARK-NEXT: Args:
+; REMARK-NEXT:   - String:  'VGPRs: '
+; REMARK-NEXT:   - NumVGPR: '9'
+; REMARK-NEXT: ...
+; REMARK-NEXT: --- !Analysis
+; REMARK-NEXT: Pass:kernel-resource-usage
+; REMARK-NEXT: Name:NumAGPR
+; REMARK-NEXT: DebugLoc:{ File: foo.cl, Line: 27, Column: 0 }
+; REMARK-NEXT: Function:test_kernel
+; REMARK-NEXT: Args:
+; REMARK-NEXT:   - String:  'AGPRs: '
+; REMARK-NEXT:   - NumAGPR: '43'
+; REMARK-NEXT: ...
+; REMARK-NEXT: --- !Analysis
+; REMARK-NEXT: Pass:kernel-resource-usage
+; REMARK-NEXT: Name:ScratchSize
+; REMARK-NEXT: DebugLoc:{ File: foo.cl, Line: 27, Column: 0 }
+; REMARK-NEXT: Function:test_kernel
+; REMARK-NEXT: Args:
+; REMARK-NEXT:   - String:  'ScratchSize [bytes/lane]: '
+; REMARK-NEXT:   - ScratchSize: '0'
+; REMARK-NEXT: ...
+; REMARK-NEXT: --- !Analysis
+; REMARK-NEXT: Pass:kernel-resource-usage
+; REMARK-NEXT: Name:Occupancy
+; REMARK-NEXT: DebugLoc:{ File: foo.cl, Line: 27, Column: 0 }
+; REMARK-NEXT: Function:test_kernel
+; REMARK-NEXT: Args:
+; REMARK-NEXT:   - String:  'Occupancy [waves/SIMD]: '
+; REMARK-NEXT:   - Occupancy:   '5'
+; REMARK-NEXT: ...
+; REMARK-NEXT: --- !Analysis
+; REMARK-NEXT: Pass:kernel-resource-usage
+; REMARK-NEXT: Name:SGPRSpill
+; REMARK-NEXT: DebugLoc:{ File: foo.cl, Line: 27, Column: 0 }
+; REMARK-NEXT: Function:test_kernel
+; REMARK-NEXT: Args:
+; REMARK-NEXT:   - String:  'SGPRs Spill: '
+; REMARK-NEXT:   - SGPRSpill:   '0'
+; REMARK-NEXT: ...
+; REMARK-NEXT: --- !Analysis
+; REMARK-NEXT: Pass:kernel-resource-usage
+; REMARK-NEXT: Name:VGPRSpill
+; REMARK-NEXT: DebugLoc:{ File: foo.cl, Line: 27, Column: 0 }
+; REMARK-NEXT: Function:test_kernel
+; REMARK-NEXT: Args:
+; REMARK-NEXT:   - String:  'VGPRs Spill: '
+; REMARK-NEXT:   - VGPRSpill:   '0'
+; REMARK-NEXT: ...
+; REMARK-NEXT: --- !Analysis
+; REMARK-NEXT: Pass:kernel-resource-usage
+; REMARK-NEXT: Name:BytesLDS
+; REMARK-NEXT: DebugLoc:{ File: foo.cl, Line: 27, Column: 0 }
+; REMARK-NEXT: Function:test_kernel
+; REMARK-NEXT: Args:
+; REMARK-NEXT:   - String:  'LDS Size [bytes/block]: '
+; REMARK-NEXT:   - BytesLDS:'512'
+; REMARK-N

[PATCH] D121141: [Clang] Add `-funstable` flag to enable unstable and experimental features: follow-up fixes

2022-07-14 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added inline comments.
This revision is now accepted and ready to land.
Herald added a subscriber: StephenFan.



Comment at: clang/include/clang/Driver/Options.td:1186
 
-defm unstable : BoolFOption<"unstable",
-  LangOpts<"Unstable">, DefaultFalse,
-  PosFlag,
+defm experimental_library : BoolFOption<"experimental-library",
+  LangOpts<"ExperimentalLibrary">, DefaultFalse,

This can be simplified with `OptInCC1FFlag` (both driver/CC1 for the pos form, 
but driver-only for the neg form).
You'll need to set CoreOption to make the option available to clang-cl.



Comment at: clang/lib/Driver/ToolChain.cpp:1016
 CmdArgs.push_back("-lc++");
+if (Args.hasArg(options::OPT_fexperimental_library))
+  CmdArgs.push_back("-lc++experimental");

There may be an archive ordering problem. 



Comment at: clang/lib/Driver/ToolChains/AIX.cpp:279
 CmdArgs.push_back("-lc++abi");
+if (Args.hasArg(options::OPT_fexperimental_library))
+  CmdArgs.push_back("-lc++experimental");

There may be an archive ordering problem. -lc++experimental should probably be 
before -lc++abi



Comment at: clang/lib/Driver/ToolChains/BareMetal.cpp:280
 CmdArgs.push_back("-lc++abi");
+if (Args.hasArg(options::OPT_fexperimental_library))
+  CmdArgs.push_back("-lc++experimental");

There may be an archive ordering problem. -lc++experimental should probably be 
before -lc++abi



Comment at: clang/lib/Driver/ToolChains/CloudABI.cpp:122
   CmdArgs.push_back("-lunwind");
+  if (Args.hasArg(options::OPT_fexperimental_library))
+CmdArgs.push_back("-lc++experimental");

There may be an archive ordering problem. -lc++experimental should probably be 
before -lc++abi




Comment at: clang/lib/Driver/ToolChains/MipsLinux.cpp:117
   CmdArgs.push_back("-lunwind");
+  if (Args.hasArg(options::OPT_fexperimental_library))
+CmdArgs.push_back("-lc++experimental");

There may be an archive ordering problem. -lc++experimental should probably be 
before -lc++abi



Comment at: clang/lib/Driver/ToolChains/OpenBSD.cpp:335
   CmdArgs.push_back(Profiling ? "-lc++abi_p" : "-lc++abi");
   CmdArgs.push_back(Profiling ? "-lpthread_p" : "-lpthread");
+  if (Args.hasArg(options::OPT_fexperimental_library))

There may be an archive ordering problem. -lc++experimental should probably be 
before -lc++abi



Comment at: clang/lib/Driver/ToolChains/VEToolchain.cpp:151
+
+  if (Args.hasArg(options::OPT_fexperimental_library))
+CmdArgs.push_back("-lc++experimental");

There may be an archive ordering problem. -lc++experimental should probably be 
before -lc++abi



Comment at: clang/lib/Driver/ToolChains/WebAssembly.cpp:448
 CmdArgs.push_back("-lc++abi");
+if (Args.hasArg(options::OPT_fexperimental_library))
+  CmdArgs.push_back("-lc++experimental");

There may be an archive ordering problem. -lc++experimental should probably be 
before -lc++abi



Comment at: clang/test/Driver/experimental-library-flag.cpp:5
+
+// -fexperimental-library must be passed to CC1
+// CHECK: -fexperimental-library

End full sentences with a period.



Comment at: clang/test/Driver/experimental-library-flag.cpp:6
+// -fexperimental-library must be passed to CC1
+// CHECK: -fexperimental-library
+

Suggest testing `-lc++` as well


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121141

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


[PATCH] D129772: [clang] Document -femit-compact-unwind option in the User’s Manual

2022-07-14 Thread Nico Weber via Phabricator via cfe-commits
thakis accepted this revision.
thakis added a comment.
This revision is now accepted and ready to land.

Thanks!




Comment at: clang/docs/UsersManual.rst:853
+  * ``no-compact-unwind`` - Only emit DWARF unwind when compact unwind 
encodings
+aren't available. This is the default for AArch64.
+  * ``always`` - Always emit DWARF unwind regardless.

nit: I think most things in apple-land call it arm64, not aarch64


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129772

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


[PATCH] D129648: Use pseudo parser for folding ranges

2022-07-14 Thread Utkarsh Saxena via Phabricator via cfe-commits
usaxena95 updated this revision to Diff 444755.
usaxena95 added a comment.

Addressed offline comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129648

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/SemanticSelection.cpp
  clang-tools-extra/clangd/SemanticSelection.h
  clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp
  clang-tools-extra/pseudo/include/clang-pseudo/Token.h
  clang-tools-extra/pseudo/lib/Lex.cpp

Index: clang-tools-extra/pseudo/lib/Lex.cpp
===
--- clang-tools-extra/pseudo/lib/Lex.cpp
+++ clang-tools-extra/pseudo/lib/Lex.cpp
@@ -26,7 +26,10 @@
 
   TokenStream Result;
   clang::Token CT;
+  // Index into the token stream of original source code.
+  unsigned TokenIdx = 0;
   unsigned LastOffset = 0;
+  unsigned LineStartOffset = 0;
   unsigned Line = 0;
   unsigned Indent = 0;
   for (Lexer.LexFromRawLexer(CT); CT.getKind() != clang::tok::eof;
@@ -40,16 +43,17 @@
 Tok.Kind = CT.getKind();
 
 // Update current line number and indentation from raw source code.
-unsigned NewLineStart = 0;
+bool SawNewLine = 0;
 for (unsigned I = LastOffset; I < Offset; ++I) {
   if (Code[I] == '\n') {
-NewLineStart = I + 1;
+LineStartOffset = I + 1;
+SawNewLine = true;
 ++Line;
   }
 }
-if (NewLineStart || !LastOffset) {
+if (SawNewLine || !LastOffset) {
   Indent = 0;
-  for (char C : StringRef(Code).slice(NewLineStart, Offset)) {
+  for (char C : StringRef(Code).slice(LineStartOffset, Offset)) {
 if (C == ' ')
   ++Indent;
 else if (C == '\t')
@@ -66,9 +70,12 @@
 if (CT.needsCleaning() || CT.hasUCN())
   Tok.setFlag(LexFlags::NeedsCleaning);
 
+Tok.OrigTokIdx = TokenIdx;
 Result.push(Tok);
 LastOffset = Offset;
+TokenIdx++;
   }
+  Result.setOriginal();
   Result.finalize();
   return Result;
 }
Index: clang-tools-extra/pseudo/include/clang-pseudo/Token.h
===
--- clang-tools-extra/pseudo/include/clang-pseudo/Token.h
+++ clang-tools-extra/pseudo/include/clang-pseudo/Token.h
@@ -33,6 +33,7 @@
 #include "clang/Basic/TokenKinds.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/Support/raw_ostream.h"
+#include 
 #include 
 #include 
 #include 
@@ -67,6 +68,8 @@
   uint8_t Indent = 0;
   /// Flags have some meaning defined by the function that produced this stream.
   uint8_t Flags = 0;
+  /// Index into the original token stream (of the original source file).
+  Index OrigTokIdx = 0;
   // Helpers to get/set Flags based on `enum class`.
   template  bool flag(T Mask) const {
 return Flags & uint8_t{static_cast>(Mask)};
@@ -96,7 +99,7 @@
   /// If this token is a paired bracket, the offset of the pair in the stream.
   int32_t Pair = 0;
 };
-static_assert(sizeof(Token) <= sizeof(char *) + 20, "Careful with layout!");
+static_assert(sizeof(Token) <= sizeof(char *) + 24, "Careful with layout!");
 llvm::raw_ostream &operator<<(llvm::raw_ostream &, const Token &);
 
 /// A half-open range of tokens within a stream.
@@ -170,6 +173,18 @@
 return Storage[1];
   }
 
+  /// An original token stream corresponds to the original source file (Eg.
+  /// produced by lex()). It is not derived from another token stream.
+  bool isOriginal() const { return IsOriginal; }
+  void setOriginal() { IsOriginal = true; }
+
+  /// Extracts the token in original stream corresponding to Token T.
+  const Token &origToken(const Token &T) const {
+assert(isOriginal() && "stream is derived");
+assert(T.OrigTokIdx < tokens().size() && "invalid index");
+return tokens()[T.OrigTokIdx];
+  }
+
   /// Print the tokens in this stream to the output stream.
   ///
   /// The presence of newlines/spaces is preserved, but not the quantity.
@@ -180,6 +195,7 @@
 
   MutableArrayRef Tokens;
   std::vector Storage; // eof + Tokens + eof
+  bool IsOriginal = false;
 };
 llvm::raw_ostream &operator<<(llvm::raw_ostream &, const TokenStream &);
 
Index: clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticSelectionTests.cpp
@@ -240,7 +240,7 @@
 ]]}
   )cpp",
   R"cpp(
-class Foo {
+class Foo {[[
 public:
   Foo() {[[
 int X = 1;
@@ -253,14 +253,25 @@
 
   // Braces are located at the same line: no folding range here.
   void getFooBar() { }
-};
+]]};
+  )cpp",
+  R"cpp(
+// Range boundaries on escaped newlines.
+class Foo \
+\
+{[[  \
+public:
+  Foo() {[[\
+int X = 1;
+  ]]}   \
+]]};
   )cp

[PATCH] D129714: [Driver] Don't passs --dynamic-linker in -r mode

2022-07-14 Thread Petr Hosek via Phabricator via cfe-commits
phosek accepted this revision.
phosek added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129714

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


[PATCH] D121141: [Clang] Add `-funstable` flag to enable unstable and experimental features: follow-up fixes

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

Address review comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121141

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Basic/Features.def
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/BareMetal.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CloudABI.cpp
  clang/lib/Driver/ToolChains/CrossWindows.cpp
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/lib/Driver/ToolChains/FreeBSD.cpp
  clang/lib/Driver/ToolChains/Fuchsia.cpp
  clang/lib/Driver/ToolChains/Hexagon.cpp
  clang/lib/Driver/ToolChains/MipsLinux.cpp
  clang/lib/Driver/ToolChains/NaCl.cpp
  clang/lib/Driver/ToolChains/OpenBSD.cpp
  clang/lib/Driver/ToolChains/VEToolchain.cpp
  clang/lib/Driver/ToolChains/WebAssembly.cpp
  clang/test/Driver/experimental-library-flag.cpp
  clang/test/Driver/unstable-flag.cpp
  clang/test/Lexer/has_feature_cxx_unstable.cpp
  clang/test/Lexer/has_feature_experimental_library.cpp

Index: clang/test/Lexer/has_feature_experimental_library.cpp
===
--- /dev/null
+++ clang/test/Lexer/has_feature_experimental_library.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -E -fexperimental-library %s -o - | FileCheck --check-prefix=CHECK-EXPERIMENTAL %s
+// RUN: %clang_cc1 -E %s -o - | FileCheck --check-prefix=CHECK-NO-EXPERIMENTAL %s
+
+#if __has_feature(experimental_library)
+int has_experimental_library();
+#else
+int has_no_experimental_library();
+#endif
+// CHECK-EXPERIMENTAL: int has_experimental_library();
+// CHECK-NO-EXPERIMENTAL: int has_no_experimental_library();
Index: clang/test/Lexer/has_feature_cxx_unstable.cpp
===
--- clang/test/Lexer/has_feature_cxx_unstable.cpp
+++ /dev/null
@@ -1,10 +0,0 @@
-// RUN: %clang_cc1 -funstable -E %s -o - | FileCheck --check-prefix=CHECK-UNSTABLE %s
-// RUN: %clang_cc1 -E %s -o - | FileCheck --check-prefix=CHECK-NO-UNSTABLE %s
-
-#if __has_feature(cxx_unstable)
-int has_cxx_unstable();
-#else
-int has_no_cxx_unstable();
-#endif
-// CHECK-UNSTABLE: int has_cxx_unstable();
-// CHECK-NO-UNSTABLE: int has_no_cxx_unstable();
Index: clang/test/Driver/unstable-flag.cpp
===
--- clang/test/Driver/unstable-flag.cpp
+++ /dev/null
@@ -1,5 +0,0 @@
-// RUN: %clang -funstable -### %s 2>&1 | FileCheck %s
-
-// CHECK: -funstable
-// CHECK: -fcoroutines-ts
-// CHECK: -fmodules-ts
Index: clang/test/Driver/experimental-library-flag.cpp
===
--- /dev/null
+++ clang/test/Driver/experimental-library-flag.cpp
@@ -0,0 +1,11 @@
+// RUN: %clangxx -fexperimental-library -stdlib=libc++ -### %s 2>&1 | FileCheck --check-prefixes=CHECK,CHECK-LIBCXX %s
+// RUN: %clangxx -fexperimental-library -stdlib=libstdc++ -### %s 2>&1 | FileCheck --check-prefixes=CHECK,CHECK-LIBSTDCXX %s
+// RUN: %clangxx -fexperimental-library -stdlib=libc++ -nostdlib++ -### %s 2>&1 | FileCheck --check-prefixes=CHECK,CHECK-NOSTDLIB %s
+
+// -fexperimental-library must be passed to CC1
+// CHECK: -fexperimental-library
+
+// Depending on the stdlib in use, we should (or not) pass -lc++experimental
+// CHECK-LIBCXX: -lc++experimental
+// CHECK-LIBSTDCXX-NOT: -lc++experimental
+// CHECK-NOSTDLIB-NOT: -lc++experimental
Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -445,6 +445,8 @@
   case ToolChain::CST_Libcxx:
 CmdArgs.push_back("-lc++");
 CmdArgs.push_back("-lc++abi");
+if (Args.hasArg(options::OPT_fexperimental_library))
+  CmdArgs.push_back("-lc++experimental");
 break;
   case ToolChain::CST_Libstdcxx:
 CmdArgs.push_back("-lstdc++");
Index: clang/lib/Driver/ToolChains/VEToolchain.cpp
===
--- clang/lib/Driver/ToolChains/VEToolchain.cpp
+++ clang/lib/Driver/ToolChains/VEToolchain.cpp
@@ -147,6 +147,9 @@
   CmdArgs.push_back("-lpthread");
   // libunwind requires -ldl under glibc environment
   CmdArgs.push_back("-ldl");
+
+  if (Args.hasArg(options::OPT_fexperimental_library))
+CmdArgs.push_back("-lc++experimental");
 }
 
 llvm::ExceptionHandling
Index: clang/lib/Driver/ToolChains/OpenBSD.cpp
===
--- clang/lib/Driver/ToolChains/OpenBSD.cpp
+++ clang/lib/Driver/ToolChains/OpenBSD.cpp
@@ -333,6 +333,8 @@
   CmdArgs.push_back(Profiling ? "-lc++_p" : "-lc++");
   CmdArgs.push_back(Profiling ? "-lc++abi_p" : "-lc++abi");
   CmdArgs.push_bac

[PATCH] D121141: [Clang] Add `-funstable` flag to enable unstable and experimental features: follow-up fixes

2022-07-14 Thread Louis Dionne via Phabricator via cfe-commits
ldionne marked an inline comment as done.
ldionne added a comment.

In D121141#3652616 , @MaskRay wrote:

> LGTM.
>
> It may be related, @urnathan wants to add `-std=c++{current,future}` to GCC 
> and may have opinions on the option name.

Interesting! @urnathan , is there any documentation/discussion on what 
`-std=c++{current,future}` would do? I think it's unrelated to this specific 
proposal, since `-fexperimental-library` is valid regardless of the Standard 
mode, however I still think it would make sense to align what Clang and GCC do. 
One idea we had floated around was `-std=c++latest` meaning the latest 
officially ratified Standard, and `-std=c++next` being the one currently 
cooking. For example, right now that would give us `-std=c++latest == 
-std=c++20` and `-std=c++next == -std=c++2b`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121141

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


[PATCH] D129678: [analyzer][NFC] Tidy up handler-functions in SymbolicRangeInferrer

2022-07-14 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 444752.
ASDenysPetrov added a comment.

Fixed a typo that caused `constraint_manager_negate.c` and `unary-sym-expr.c` 
tests crashes.


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

https://reviews.llvm.org/D129678

Files:
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp

Index: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
+++ clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
@@ -1213,13 +1213,21 @@
   }
 
   RangeSet VisitSymExpr(SymbolRef Sym) {
-// If we got to this function, the actual type of the symbolic
+if (Optional RS = getRangeForNegatedSym(Sym))
+  return *RS;
+// If we've reached this line, the actual type of the symbolic
 // expression is not supported for advanced inference.
 // In this case, we simply backoff to the default "let's simply
 // infer the range from the expression's type".
 return infer(Sym->getType());
   }
 
+  RangeSet VisitUnarySymExpr(const UnarySymExpr *USE) {
+if (Optional RS = getRangeForNegatedUnarySym(USE))
+  return *RS;
+return infer(USE->getType());
+  }
+
   RangeSet VisitSymIntExpr(const SymIntExpr *Sym) {
 return VisitBinaryOperator(Sym);
   }
@@ -1228,14 +1236,25 @@
 return VisitBinaryOperator(Sym);
   }
 
-  RangeSet VisitSymSymExpr(const SymSymExpr *Sym) {
+  RangeSet VisitSymSymExpr(const SymSymExpr *SSE) {
 return intersect(
 RangeFactory,
+// If Sym is a difference of symbols A - B, then maybe we have range
+// set stored for B - A.
+//
+// If we have range set stored for both A - B and B - A then
+// calculate the effective range set by intersecting the range set
+// for A - B and the negated range set of B - A.
+getRangeForNegatedSymSym(SSE),
+// If Sym is a comparison expression (except <=>),
+// find any other comparisons with the same operands.
+// See function description.
+getRangeForComparisonSymbol(SSE),
 // If Sym is (dis)equality, we might have some information
 // on that in our equality classes data structure.
-getRangeForEqualities(Sym),
+getRangeForEqualities(SSE),
 // And we should always check what we can get from the operands.
-VisitBinaryOperator(Sym));
+VisitBinaryOperator(SSE));
   }
 
 private:
@@ -1264,25 +1283,13 @@
   }
 
   RangeSet infer(SymbolRef Sym) {
-return intersect(
-RangeFactory,
-// Of course, we should take the constraint directly associated with
-// this symbol into consideration.
-getConstraint(State, Sym),
-// If Sym is a difference of symbols A - B, then maybe we have range
-// set stored for B - A.
-//
-// If we have range set stored for both A - B and B - A then
-// calculate the effective range set by intersecting the range set
-// for A - B and the negated range set of B - A.
-getRangeForNegatedSub(Sym),
-// If Sym is a comparison expression (except <=>),
-// find any other comparisons with the same operands.
-// See function description.
-getRangeForComparisonSymbol(Sym),
-// Apart from the Sym itself, we can infer quite a lot if we look
-// into subexpressions of Sym.
-Visit(Sym));
+return intersect(RangeFactory,
+ // Of course, we should take the constraint directly
+ // associated with this symbol into consideration.
+ getConstraint(State, Sym),
+ // Apart from the Sym itself, we can infer quite a lot if
+ // we look into subexpressions of Sym.
+ Visit(Sym));
   }
 
   RangeSet infer(EquivalenceClass Class) {
@@ -1443,38 +1450,53 @@
 return RangeFactory.deletePoint(Domain, IntType.getZeroValue());
   }
 
-  Optional getRangeForNegatedSub(SymbolRef Sym) {
+  template 
+  Optional getRangeForNegatedExpr(ProduceNegatedSymFunc F,
+QualType T) {
 // Do not negate if the type cannot be meaningfully negated.
-if (!Sym->getType()->isUnsignedIntegerOrEnumerationType() &&
-!Sym->getType()->isSignedIntegerOrEnumerationType())
+if (!T->isUnsignedIntegerOrEnumerationType() &&
+!T->isSignedIntegerOrEnumerationType())
   return llvm::None;
 
-const RangeSet *NegatedRange = nullptr;
-SymbolManager &SymMgr = State->getSymbolManager();
-if (const auto *USE = dyn_cast(Sym)) {
-  if (USE->getOpcode() == UO_Minus) {
-// Just get the operand when we negate a symbol that is already negated.
-// -(-a) == a
-NegatedRange = getConstraint(State, USE->getOperand());
-  }
-} else if (const SymSymExpr *SSE = dyn_cast(Sym)) 

[PATCH] D129594: [InstrProf] Add options to profile function groups

2022-07-14 Thread Ellis Hoag via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGaf58684f2720: [InstrProf] Add options to profile function 
groups (authored by ellis).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129594

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/docs/UsersManual.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGen/profile-function-groups.c
  compiler-rt/test/profile/instrprof-groups.c

Index: compiler-rt/test/profile/instrprof-groups.c
===
--- /dev/null
+++ compiler-rt/test/profile/instrprof-groups.c
@@ -0,0 +1,28 @@
+// RUN: %clang_pgogen -fprofile-function-groups=3 -fprofile-selected-function-group=0 %s -o %t.0.out
+// RUN: %clang_pgogen -fprofile-function-groups=3 -fprofile-selected-function-group=1 %s -o %t.1.out
+// RUN: %clang_pgogen -fprofile-function-groups=3 -fprofile-selected-function-group=2 %s -o %t.2.out
+// RUN: env LLVM_PROFILE_FILE=%t.0.profraw %run %t.0.out
+// RUN: env LLVM_PROFILE_FILE=%t.1.profraw %run %t.1.out
+// RUN: env LLVM_PROFILE_FILE=%t.2.profraw %run %t.2.out
+// RUN: llvm-profdata merge -o %t.profdata %t.*.profraw
+// RUN: llvm-profdata show %t.profdata --all-functions | FileCheck %s
+
+int foo(int i) { return 4 * i + 1; }
+int bar(int i) { return 4 * i + 2; }
+int goo(int i) { return 4 * i + 3; }
+
+int main(int argc, char *argv[]) {
+  foo(5);
+  bar(6);
+  goo(7);
+  return 0;
+}
+
+// Even though we ran this code three times, we expect all counts to be one if
+// functions were partitioned into groups correctly.
+
+// CHECK: Counters: 1
+// CHECK: Counters: 1
+// CHECK: Counters: 1
+// CHECK: Counters: 1
+// CHECK: Total functions: 4
Index: clang/test/CodeGen/profile-function-groups.c
===
--- /dev/null
+++ clang/test/CodeGen/profile-function-groups.c
@@ -0,0 +1,24 @@
+// RUN: %clang -fprofile-generate -fprofile-function-groups=3 -fprofile-selected-function-group=0 -emit-llvm -S %s -o - | FileCheck %s --check-prefixes=CHECK,SELECT0
+// RUN: %clang -fprofile-generate -fprofile-function-groups=3 -fprofile-selected-function-group=1 -emit-llvm -S %s -o - | FileCheck %s --check-prefixes=CHECK,SELECT1
+// RUN: %clang -fprofile-generate -fprofile-function-groups=3 -fprofile-selected-function-group=2 -emit-llvm -S %s -o - | FileCheck %s --check-prefixes=CHECK,SELECT2
+
+// Group 0
+// SELECT0-NOT: noprofile
+// SELECT1: noprofile
+// SELECT2: noprofile
+// CHECK: define {{.*}} @hoo()
+void hoo() {}
+
+// Group 1
+// SELECT0: noprofile
+// SELECT1-NOT: noprofile
+// SELECT2: noprofile
+// CHECK: define {{.*}} @goo()
+void goo() {}
+
+// Group 2
+// SELECT0: noprofile
+// SELECT1: noprofile
+// SELECT2-NOT: noprofile
+// CHECK: define {{.*}} @boo()
+void boo() {}
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -956,6 +956,27 @@
 CmdArgs.push_back("-fprofile-update=atomic");
   }
 
+  int FunctionGroups = 1;
+  int SelectedFunctionGroup = 0;
+  if (const auto *A = Args.getLastArg(options::OPT_fprofile_function_groups)) {
+StringRef Val = A->getValue();
+if (Val.getAsInteger(0, FunctionGroups) || FunctionGroups < 1)
+  D.Diag(diag::err_drv_invalid_int_value) << A->getAsString(Args) << Val;
+  }
+  if (const auto *A =
+  Args.getLastArg(options::OPT_fprofile_selected_function_group)) {
+StringRef Val = A->getValue();
+if (Val.getAsInteger(0, SelectedFunctionGroup) ||
+SelectedFunctionGroup < 0 || SelectedFunctionGroup >= FunctionGroups)
+  D.Diag(diag::err_drv_invalid_int_value) << A->getAsString(Args) << Val;
+  }
+  if (FunctionGroups != 1)
+CmdArgs.push_back(Args.MakeArgString("-fprofile-function-groups=" +
+ Twine(FunctionGroups)));
+  if (SelectedFunctionGroup != 0)
+CmdArgs.push_back(Args.MakeArgString("-fprofile-selected-function-group=" +
+ Twine(SelectedFunctionGroup)));
+
   // Leave -fprofile-dir= an unused argument unless .gcda emission is
   // enabled. To be polite, with '-fprofile-arcs -fno-profile-arcs' consider
   // the flag used. There is no -fno-profile-dir, so the user has no
Index: clang/lib/CodeGen/CodeGenModule.h
===
--- clang/lib/CodeGen/CodeGenModule.h
+++ clang/lib/CodeGen/CodeGenModule.h
@@ -1340,9 +1340,15 @@
   bool imbueXRayAttrs(llvm::Function *Fn, SourceLocation Loc,
   StringRef Category = StringRef()) const;
 
-  /// Returns t

[clang] af58684 - [InstrProf] Add options to profile function groups

2022-07-14 Thread Ellis Hoag via cfe-commits

Author: Ellis Hoag
Date: 2022-07-14T11:41:30-07:00
New Revision: af58684f272046f293a9f469f03d23bd2b138349

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

LOG: [InstrProf] Add options to profile function groups

Add two options, `-fprofile-function-groups=N` and 
`-fprofile-selected-function-group=i` used to partition functions into `N` 
groups and only instrument the functions in group `i`. Similar options were 
added to xray in https://reviews.llvm.org/D87953 and the goal is the same; to 
reduce instrumented size overhead by spreading the overhead across multiple 
builds. Raw profiles from different groups can be added like normal using the 
`llvm-profdata merge` command.

Reviewed By: ianlevesque

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

Added: 
clang/test/CodeGen/profile-function-groups.c
compiler-rt/test/profile/instrprof-groups.c

Modified: 
clang/docs/ClangCommandLineReference.rst
clang/docs/UsersManual.rst
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Driver/Options.td
clang/lib/CodeGen/CodeGenFunction.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/CodeGen/CodeGenModule.h
clang/lib/Driver/ToolChains/Clang.cpp

Removed: 




diff  --git a/clang/docs/ClangCommandLineReference.rst 
b/clang/docs/ClangCommandLineReference.rst
index 776b84da96572..216872b60cdc8 100644
--- a/clang/docs/ClangCommandLineReference.rst
+++ b/clang/docs/ClangCommandLineReference.rst
@@ -2329,6 +2329,10 @@ Use instrumentation data for profile-guided optimization
 
 Filename defining the list of functions/files to instrument
 
+.. option:: -fprofile-function-groups=, 
-fprofile-selected-function-group=
+
+Partition functions into  groups and select only functions in group  to 
be instrumented
+
 .. option:: -fprofile-remapping-file=
 
 Use the remappings described in  to match the profile data against names 
in the program

diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index e12dc72407b13..c2767d65adbf0 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -2513,6 +2513,32 @@ When the file contains only excludes, all files and 
functions except for the
 excluded ones will be instrumented. Otherwise, only the files and functions
 specified will be instrumented.
 
+Instrument function groups
+^^
+
+Sometimes it is desirable to minimize the size overhead of instrumented
+binaries. One way to do this is to partition functions into groups and only
+instrument functions in a specified group. This can be done using the
+`-fprofile-function-groups` and `-fprofile-selected-function-group` options.
+
+.. option:: -fprofile-function-groups=, 
-fprofile-selected-function-group=
+
+  The following uses 3 groups
+
+  .. code-block:: console
+
+$ clang++ -Oz -fprofile-generate=group_0/ -fprofile-function-groups=3 
-fprofile-selected-function-group=0 code.cc -o code.0
+$ clang++ -Oz -fprofile-generate=group_1/ -fprofile-function-groups=3 
-fprofile-selected-function-group=1 code.cc -o code.1
+$ clang++ -Oz -fprofile-generate=group_2/ -fprofile-function-groups=3 
-fprofile-selected-function-group=2 code.cc -o code.2
+
+  After collecting raw profiles from the three binaries, they can be merged 
into
+  a single profile like normal.
+
+  .. code-block:: console
+
+$ llvm-profdata merge -output=code.profdata group_*/*.profraw
+
+
 Profile remapping
 ^
 

diff  --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index b1d394edd04ab..ef7957979dccd 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -213,6 +213,10 @@ CODEGENOPT(AtomicProfileUpdate , 1, 0) ///< Set 
-fprofile-update=atomic
 ENUM_CODEGENOPT(ProfileInstr, ProfileInstrKind, 2, ProfileNone)
 /// Choose profile kind for PGO use compilation.
 ENUM_CODEGENOPT(ProfileUse, ProfileInstrKind, 2, ProfileNone)
+/// Partition functions into N groups and select only functions in group i to 
be
+/// instrumented. Selected group numbers can be 0 to N-1 inclusive.
+VALUE_CODEGENOPT(ProfileTotalFunctionGroups, 32, 1)
+VALUE_CODEGENOPT(ProfileSelectedFunctionGroup, 32, 0)
 CODEGENOPT(CoverageMapping , 1, 0) ///< Generate coverage mapping regions to
///< enable code coverage analysis.
 CODEGENOPT(DumpCoverageMapping , 1, 0) ///< Dump the generated coverage mapping

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 532d7780c529b..404effb4e1de4 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1333,6 +1333,15 @@ def fprofile_list_EQ : Joined<["-"], "fprofile-list=">,
   

[PATCH] D128465: [llvm] add zstd to `llvm::compression` namespace

2022-07-14 Thread Cole Kissane via Phabricator via cfe-commits
ckissane added a comment.

@aemerson can you let me know if https://reviews.llvm.org/D129786 works on 
MacOS?
I am continuing work on that revision because this one has a lot of outdated 
unrelated history.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128465

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


[PATCH] D109701: [clang] Emit SARIF Diagnostics: Create `clang::SarifDocumentWriter` interface

2022-07-14 Thread Vaibhav Yenamandra via Phabricator via cfe-commits
vaibhav.y added a comment.

@aaron.ballman

The culprit turned out to be the difference in release flags on the build 
server vs my environment. I had unfortunately run the configuration command 
once in `Debug` mode, and hadn't re-configured. Not a bright moment :)

The `ASSERT_DEATH` tests that I had written weren't gated by `NDEBUG, 
GTEST_HAS_DEATH_TEST` (other unit tests use some combination two). This was 
causing them to pass on my machine but fail pre-merge (which is 
`RelWithDebInfo`)

I will gate the tests similar to what  
https://github.com/llvm/llvm-project/blob/main/clang/unittests/Serialization/InMemoryModuleCacheTest.cpp#L48-L52
  does, but force a skip instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109701

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


[PATCH] D129709: [clang][CodeGen] add fn_ret_thunk_extern to synthetic fns

2022-07-14 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/test/CodeGen/attr-function-return.c:9
 // RUN:  --check-prefixes=CHECK,CHECK-EXTERN
+// RUN: %clang_cc1 -std=gnu2x -triple x86_64-linux-gnu %s -emit-llvm -o - \
+// RUN:  -mfunction-return=thunk-extern -fprofile-arcs \

nickdesaulniers wrote:
> MaskRay wrote:
> > nickdesaulniers wrote:
> > > MaskRay wrote:
> > > > I feel that having 3 RUN lines is excessive. Since we already have a 
> > > > test that asan/tsan/gcov respect getModuleFlag, it is not necessary for 
> > > > a new one to duplicate all the combinations.
> > > All three have caused problems for us; I'd prefer to retain each.
> > Having asan/tsan may invite others to add more sanitizer tests to this 
> > not-so-related file. I can step back and think that gcov/asan are 
> > sufficient.
> If such sanitizers produce synthetic functions, we should add them to this 
> file.
No. The sanitizers should pick a dedicated test file and be added there, if the 
use case is important enough.

Today we have -mfunction-return=thunk-extern, tomorrow we can have -mfoobar. We 
should not add `{-mfunction-return=thunk-extern,-mfoobar} * 
{-fsanitize=address,-fsanitize=thread,...}` for every combination.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129709

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


[PATCH] D129709: [clang][CodeGen] add fn_ret_thunk_extern to synthetic fns

2022-07-14 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: clang/test/CodeGen/attr-function-return.c:9
 // RUN:  --check-prefixes=CHECK,CHECK-EXTERN
+// RUN: %clang_cc1 -std=gnu2x -triple x86_64-linux-gnu %s -emit-llvm -o - \
+// RUN:  -mfunction-return=thunk-extern -fprofile-arcs \

MaskRay wrote:
> nickdesaulniers wrote:
> > MaskRay wrote:
> > > I feel that having 3 RUN lines is excessive. Since we already have a test 
> > > that asan/tsan/gcov respect getModuleFlag, it is not necessary for a new 
> > > one to duplicate all the combinations.
> > All three have caused problems for us; I'd prefer to retain each.
> Having asan/tsan may invite others to add more sanitizer tests to this 
> not-so-related file. I can step back and think that gcov/asan are sufficient.
If such sanitizers produce synthetic functions, we should add them to this file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129709

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


[PATCH] D129709: [clang][CodeGen] add fn_ret_thunk_extern to synthetic fns

2022-07-14 Thread Nick Desaulniers 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 rG140bfdca60ae: [clang][CodeGen] add fn_ret_thunk_extern to 
synthetic fns (authored by nickdesaulniers).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129709

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/attr-function-return.c
  llvm/docs/LangRef.rst
  llvm/lib/IR/Function.cpp


Index: llvm/lib/IR/Function.cpp
===
--- llvm/lib/IR/Function.cpp
+++ llvm/lib/IR/Function.cpp
@@ -354,6 +354,8 @@
 B.addAttribute("frame-pointer", "all");
 break;
   }
+  if (M->getModuleFlag("function_return_thunk_extern"))
+B.addAttribute(Attribute::FnRetThunkExtern);
   F->addFnAttrs(B);
   return F;
 }
Index: llvm/docs/LangRef.rst
===
--- llvm/docs/LangRef.rst
+++ llvm/docs/LangRef.rst
@@ -7364,6 +7364,8 @@
 - "frame-pointer": **Max**. The value can be 0, 1, or 2. A synthesized function
   will get the "frame-pointer" function attribute, with value being "none",
   "non-leaf", or "all", respectively.
+- "function_return_thunk_extern": The synthesized function will get the
+  ``fn_return_thunk_extern`` function attribute.
 - "uwtable": **Max**. The value can be 0, 1, or 2. If the value is 1, a 
synthesized
   function will get the ``uwtable(sync)`` function attribute, if the value is 
2,
   a synthesized function will get the ``uwtable(async)`` function attribute.
Index: clang/test/CodeGen/attr-function-return.c
===
--- clang/test/CodeGen/attr-function-return.c
+++ clang/test/CodeGen/attr-function-return.c
@@ -7,6 +7,15 @@
 // RUN: %clang_cc1 -std=gnu2x -triple x86_64-linux-gnu %s -emit-llvm -o - \
 // RUN:   -Werror=ignored-attributes -mfunction-return=thunk-extern \
 // RUN:   | FileCheck %s --check-prefixes=CHECK,CHECK-EXTERN
+// RUN: %clang_cc1 -std=gnu2x -triple x86_64-linux-gnu %s -emit-llvm -o - \
+// RUN:  -mfunction-return=thunk-extern -fprofile-arcs \
+// RUN:   | FileCheck %s --check-prefix=CHECK-GCOV
+// RUN: %clang_cc1 -std=gnu2x -triple x86_64-linux-gnu %s -emit-llvm -o - \
+// RUN:  -mfunction-return=thunk-extern -fsanitize=address \
+// RUN:   | FileCheck %s --check-prefix=CHECK-ASAN
+// RUN: %clang_cc1 -std=gnu2x -triple x86_64-linux-gnu %s -emit-llvm -o - \
+// RUN:  -mfunction-return=thunk-extern -fsanitize=thread \
+// RUN:   | FileCheck %s --check-prefix=CHECK-TSAN
 
 #if !__has_attribute(function_return)
 #error "missing attribute support for function_return"
@@ -92,6 +101,16 @@
 // CHECK-EXTERN: @no_attrs() [[EXTERN]]
 void no_attrs(void) {}
 
+// Test synthetic functions.
+// CHECK-GCOV: @__llvm_gcov_writeout() unnamed_addr [[EXTERNGCOV:#[0-9]+]]
+// CHECK-GCOV: @__llvm_gcov_reset() unnamed_addr [[EXTERNGCOV]]
+// CHECK-GCOV: @__llvm_gcov_init() unnamed_addr [[EXTERNGCOV]]
+// CHECK-ASAN: @asan.module_ctor() [[EXTERNASAN:#[0-9]+]]
+// CHECK-TSAN: @tsan.module_ctor() [[EXTERNTSAN:#[0-9]+]]
+
 // CHECK-NOM-NOT:  [[NOATTR]] = {{.*}}fn_ret_thunk_extern
 // CHECK-KEEP-NOT: [[NOATTR]] = {{.*}}fn_ret_thunk_extern
 // CHECK: [[EXTERN]] = {{.*}}fn_ret_thunk_extern
+// CHECK-GCOV: [[EXTERNGCOV]] = {{.*}}fn_ret_thunk_extern
+// CHECK-ASAN: [[EXTERNASAN]] = {{.*}}fn_ret_thunk_extern
+// CHECK-TSAN: [[EXTERNTSAN]] = {{.*}}fn_ret_thunk_extern
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -756,6 +756,9 @@
   if (CodeGenOpts.IBTSeal)
 getModule().addModuleFlag(llvm::Module::Override, "ibt-seal", 1);
 
+  if (CodeGenOpts.FunctionReturnThunks)
+getModule().addModuleFlag(llvm::Module::Override, 
"function_return_thunk_extern", 1);
+
   // Add module metadata for return address signing (ignoring
   // non-leaf/all) and stack tagging. These are actually turned on by function
   // attributes, but we use module metadata to emit build attributes. This is


Index: llvm/lib/IR/Function.cpp
===
--- llvm/lib/IR/Function.cpp
+++ llvm/lib/IR/Function.cpp
@@ -354,6 +354,8 @@
 B.addAttribute("frame-pointer", "all");
 break;
   }
+  if (M->getModuleFlag("function_return_thunk_extern"))
+B.addAttribute(Attribute::FnRetThunkExtern);
   F->addFnAttrs(B);
   return F;
 }
Index: llvm/docs/LangRef.rst
===
--- llvm/docs/LangRef.rst
+++ llvm/docs/LangRef.rst
@@ -7364,6 +7364,8 @@
 - "frame-pointer": **Max**. The value can be 0, 1, or 2. A synthesized function
   will get the "frame-pointer" function attribute, with value being "none",
   "non-leaf", or "all", respectively.
+- "function_return_thunk_exte

[clang] 140bfdc - [clang][CodeGen] add fn_ret_thunk_extern to synthetic fns

2022-07-14 Thread Nick Desaulniers via cfe-commits

Author: Nick Desaulniers
Date: 2022-07-14T11:25:24-07:00
New Revision: 140bfdca60ae8b1b2ad115846379e3c9ca914bfb

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

LOG: [clang][CodeGen] add fn_ret_thunk_extern to synthetic fns

Follow up fix to
commit 2240d72f15f3 ("[X86] initial -mfunction-return=thunk-extern
support")
https://reviews.llvm.org/D129572

@nathanchance reported that -mfunction-return=thunk-extern was failing
to annotate the asan and tsan contructors.
https://lore.kernel.org/llvm/Ys7pLq+tQk5xEa%2FB@dev-arch.thelio-3990X/

I then noticed the same occurring for gcov synthetic functions.

Similar to
commit 2786e67 ("[IR][sanitizer] Add module flag "frame-pointer" and set
it for cc1 -mframe-pointer={non-leaf,all}")
define a new module level MetaData, "fn_ret_thunk_extern", then when set
adds the fn_ret_thunk_extern IR Fn Attr to synthetically created
Functions.

Fixes https://github.com/llvm/llvm-project/issues/56514

Reviewed By: MaskRay

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

Added: 


Modified: 
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/CodeGen/attr-function-return.c
llvm/docs/LangRef.rst
llvm/lib/IR/Function.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index c372bab1eccbc..bdee31b504aec 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -756,6 +756,9 @@ void CodeGenModule::Release() {
   if (CodeGenOpts.IBTSeal)
 getModule().addModuleFlag(llvm::Module::Override, "ibt-seal", 1);
 
+  if (CodeGenOpts.FunctionReturnThunks)
+getModule().addModuleFlag(llvm::Module::Override, 
"function_return_thunk_extern", 1);
+
   // Add module metadata for return address signing (ignoring
   // non-leaf/all) and stack tagging. These are actually turned on by function
   // attributes, but we use module metadata to emit build attributes. This is

diff  --git a/clang/test/CodeGen/attr-function-return.c 
b/clang/test/CodeGen/attr-function-return.c
index 2ec3fb146432c..2187e014aabab 100644
--- a/clang/test/CodeGen/attr-function-return.c
+++ b/clang/test/CodeGen/attr-function-return.c
@@ -7,6 +7,15 @@
 // RUN: %clang_cc1 -std=gnu2x -triple x86_64-linux-gnu %s -emit-llvm -o - \
 // RUN:   -Werror=ignored-attributes -mfunction-return=thunk-extern \
 // RUN:   | FileCheck %s --check-prefixes=CHECK,CHECK-EXTERN
+// RUN: %clang_cc1 -std=gnu2x -triple x86_64-linux-gnu %s -emit-llvm -o - \
+// RUN:  -mfunction-return=thunk-extern -fprofile-arcs \
+// RUN:   | FileCheck %s --check-prefix=CHECK-GCOV
+// RUN: %clang_cc1 -std=gnu2x -triple x86_64-linux-gnu %s -emit-llvm -o - \
+// RUN:  -mfunction-return=thunk-extern -fsanitize=address \
+// RUN:   | FileCheck %s --check-prefix=CHECK-ASAN
+// RUN: %clang_cc1 -std=gnu2x -triple x86_64-linux-gnu %s -emit-llvm -o - \
+// RUN:  -mfunction-return=thunk-extern -fsanitize=thread \
+// RUN:   | FileCheck %s --check-prefix=CHECK-TSAN
 
 #if !__has_attribute(function_return)
 #error "missing attribute support for function_return"
@@ -92,6 +101,16 @@ __attribute__((function_return("thunk-extern"))) void 
change_def4(void) {}
 // CHECK-EXTERN: @no_attrs() [[EXTERN]]
 void no_attrs(void) {}
 
+// Test synthetic functions.
+// CHECK-GCOV: @__llvm_gcov_writeout() unnamed_addr [[EXTERNGCOV:#[0-9]+]]
+// CHECK-GCOV: @__llvm_gcov_reset() unnamed_addr [[EXTERNGCOV]]
+// CHECK-GCOV: @__llvm_gcov_init() unnamed_addr [[EXTERNGCOV]]
+// CHECK-ASAN: @asan.module_ctor() [[EXTERNASAN:#[0-9]+]]
+// CHECK-TSAN: @tsan.module_ctor() [[EXTERNTSAN:#[0-9]+]]
+
 // CHECK-NOM-NOT:  [[NOATTR]] = {{.*}}fn_ret_thunk_extern
 // CHECK-KEEP-NOT: [[NOATTR]] = {{.*}}fn_ret_thunk_extern
 // CHECK: [[EXTERN]] = {{.*}}fn_ret_thunk_extern
+// CHECK-GCOV: [[EXTERNGCOV]] = {{.*}}fn_ret_thunk_extern
+// CHECK-ASAN: [[EXTERNASAN]] = {{.*}}fn_ret_thunk_extern
+// CHECK-TSAN: [[EXTERNTSAN]] = {{.*}}fn_ret_thunk_extern

diff  --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index 54ed0cc3f8d38..24b3b5183da8e 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -7364,6 +7364,8 @@ functions is small.
 - "frame-pointer": **Max**. The value can be 0, 1, or 2. A synthesized function
   will get the "frame-pointer" function attribute, with value being "none",
   "non-leaf", or "all", respectively.
+- "function_return_thunk_extern": The synthesized function will get the
+  ``fn_return_thunk_extern`` function attribute.
 - "uwtable": **Max**. The value can be 0, 1, or 2. If the value is 1, a 
synthesized
   function will get the ``uwtable(sync)`` function attribute, if the value is 
2,
   a synthesized function will get the ``uwtable(async)`` function attribute.

diff  --git a/llvm/lib/IR/Function.cpp b/llvm/lib/IR/Function.cpp
index 53df94366760d

[PATCH] D129709: [clang][CodeGen] add fn_ret_thunk_extern to synthetic fns

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



Comment at: clang/test/CodeGen/attr-function-return.c:9
 // RUN:  --check-prefixes=CHECK,CHECK-EXTERN
+// RUN: %clang_cc1 -std=gnu2x -triple x86_64-linux-gnu %s -emit-llvm -o - \
+// RUN:  -mfunction-return=thunk-extern -fprofile-arcs \

nickdesaulniers wrote:
> MaskRay wrote:
> > I feel that having 3 RUN lines is excessive. Since we already have a test 
> > that asan/tsan/gcov respect getModuleFlag, it is not necessary for a new 
> > one to duplicate all the combinations.
> All three have caused problems for us; I'd prefer to retain each.
Having asan/tsan may invite others to add more sanitizer tests to this 
not-so-related file. I can step back and think that gcov/asan are sufficient.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129709

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


[PATCH] D129591: Modify CXXMethodDecl::isMoveAssignmentOperator() to look through type sugar

2022-07-14 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik updated this revision to Diff 444744.
shafik added a comment.

Adding release notes.


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

https://reviews.llvm.org/D129591

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/AST/DeclCXX.cpp
  clang/test/SemaCXX/cxx0x-defaulted-functions.cpp


Index: clang/test/SemaCXX/cxx0x-defaulted-functions.cpp
===
--- clang/test/SemaCXX/cxx0x-defaulted-functions.cpp
+++ clang/test/SemaCXX/cxx0x-defaulted-functions.cpp
@@ -259,3 +259,28 @@
 
   static_assert(noexcept(A::B()), "");
 }
+
+namespace GH56456 {
+template 
+using RC=T const&;
+template 
+using RV=T&;
+template 
+using RM=T&&;
+
+struct A {
+  A(RC) = default;
+  A(RM) = default;
+
+  auto operator=(RC) -> RV = default;
+  auto operator=(RM) -> RV = default;
+};
+
+struct B {
+  B (RC) = delete;
+  B (RM) = delete;
+
+  auto operator = (RC) -> RV = delete;
+  auto operator = (RM) -> RV = delete;
+};
+}
Index: clang/lib/AST/DeclCXX.cpp
===
--- clang/lib/AST/DeclCXX.cpp
+++ clang/lib/AST/DeclCXX.cpp
@@ -2410,7 +2410,7 @@
 return false;
 
   QualType ParamType = getParamDecl(0)->getType();
-  if (!isa(ParamType))
+  if (!ParamType->isRValueReferenceType())
 return false;
   ParamType = ParamType->getPointeeType();
 
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -186,6 +186,8 @@
 - Clang now checks ODR violations when merging concepts from different modules.
   Note that this may possibly break existing code, and is done so 
intentionally.
   Fixes `Issue 56310 `_.
+- Clang will now look through type sugar when checking a member function is a
+  move assignment operator. Fixes `Issue 56456 
`_.
 
 Improvements to Clang's diagnostics
 ^^^


Index: clang/test/SemaCXX/cxx0x-defaulted-functions.cpp
===
--- clang/test/SemaCXX/cxx0x-defaulted-functions.cpp
+++ clang/test/SemaCXX/cxx0x-defaulted-functions.cpp
@@ -259,3 +259,28 @@
 
   static_assert(noexcept(A::B()), "");
 }
+
+namespace GH56456 {
+template 
+using RC=T const&;
+template 
+using RV=T&;
+template 
+using RM=T&&;
+
+struct A {
+  A(RC) = default;
+  A(RM) = default;
+
+  auto operator=(RC) -> RV = default;
+  auto operator=(RM) -> RV = default;
+};
+
+struct B {
+  B (RC) = delete;
+  B (RM) = delete;
+
+  auto operator = (RC) -> RV = delete;
+  auto operator = (RM) -> RV = delete;
+};
+}
Index: clang/lib/AST/DeclCXX.cpp
===
--- clang/lib/AST/DeclCXX.cpp
+++ clang/lib/AST/DeclCXX.cpp
@@ -2410,7 +2410,7 @@
 return false;
 
   QualType ParamType = getParamDecl(0)->getType();
-  if (!isa(ParamType))
+  if (!ParamType->isRValueReferenceType())
 return false;
   ParamType = ParamType->getPointeeType();
 
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -186,6 +186,8 @@
 - Clang now checks ODR violations when merging concepts from different modules.
   Note that this may possibly break existing code, and is done so intentionally.
   Fixes `Issue 56310 `_.
+- Clang will now look through type sugar when checking a member function is a
+  move assignment operator. Fixes `Issue 56456 `_.
 
 Improvements to Clang's diagnostics
 ^^^
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129709: [clang][CodeGen] add fn_ret_thunk_extern to synthetic fns

2022-07-14 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 444743.
nickdesaulniers added a comment.

- resort langref, oops


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129709

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/attr-function-return.c
  llvm/docs/LangRef.rst
  llvm/lib/IR/Function.cpp


Index: llvm/lib/IR/Function.cpp
===
--- llvm/lib/IR/Function.cpp
+++ llvm/lib/IR/Function.cpp
@@ -354,6 +354,8 @@
 B.addAttribute("frame-pointer", "all");
 break;
   }
+  if (M->getModuleFlag("function_return_thunk_extern"))
+B.addAttribute(Attribute::FnRetThunkExtern);
   F->addFnAttrs(B);
   return F;
 }
Index: llvm/docs/LangRef.rst
===
--- llvm/docs/LangRef.rst
+++ llvm/docs/LangRef.rst
@@ -7364,6 +7364,8 @@
 - "frame-pointer": **Max**. The value can be 0, 1, or 2. A synthesized function
   will get the "frame-pointer" function attribute, with value being "none",
   "non-leaf", or "all", respectively.
+- "function_return_thunk_extern": The synthesized function will get the
+  ``fn_return_thunk_extern`` function attribute.
 - "uwtable": **Max**. The value can be 0, 1, or 2. If the value is 1, a 
synthesized
   function will get the ``uwtable(sync)`` function attribute, if the value is 
2,
   a synthesized function will get the ``uwtable(async)`` function attribute.
Index: clang/test/CodeGen/attr-function-return.c
===
--- clang/test/CodeGen/attr-function-return.c
+++ clang/test/CodeGen/attr-function-return.c
@@ -7,6 +7,15 @@
 // RUN: %clang_cc1 -std=gnu2x -triple x86_64-linux-gnu %s -emit-llvm -o - \
 // RUN:   -Werror=ignored-attributes -mfunction-return=thunk-extern \
 // RUN:   | FileCheck %s --check-prefixes=CHECK,CHECK-EXTERN
+// RUN: %clang_cc1 -std=gnu2x -triple x86_64-linux-gnu %s -emit-llvm -o - \
+// RUN:  -mfunction-return=thunk-extern -fprofile-arcs \
+// RUN:   | FileCheck %s --check-prefix=CHECK-GCOV
+// RUN: %clang_cc1 -std=gnu2x -triple x86_64-linux-gnu %s -emit-llvm -o - \
+// RUN:  -mfunction-return=thunk-extern -fsanitize=address \
+// RUN:   | FileCheck %s --check-prefix=CHECK-ASAN
+// RUN: %clang_cc1 -std=gnu2x -triple x86_64-linux-gnu %s -emit-llvm -o - \
+// RUN:  -mfunction-return=thunk-extern -fsanitize=thread \
+// RUN:   | FileCheck %s --check-prefix=CHECK-TSAN
 
 #if !__has_attribute(function_return)
 #error "missing attribute support for function_return"
@@ -92,6 +101,16 @@
 // CHECK-EXTERN: @no_attrs() [[EXTERN]]
 void no_attrs(void) {}
 
+// Test synthetic functions.
+// CHECK-GCOV: @__llvm_gcov_writeout() unnamed_addr [[EXTERNGCOV:#[0-9]+]]
+// CHECK-GCOV: @__llvm_gcov_reset() unnamed_addr [[EXTERNGCOV]]
+// CHECK-GCOV: @__llvm_gcov_init() unnamed_addr [[EXTERNGCOV]]
+// CHECK-ASAN: @asan.module_ctor() [[EXTERNASAN:#[0-9]+]]
+// CHECK-TSAN: @tsan.module_ctor() [[EXTERNTSAN:#[0-9]+]]
+
 // CHECK-NOM-NOT:  [[NOATTR]] = {{.*}}fn_ret_thunk_extern
 // CHECK-KEEP-NOT: [[NOATTR]] = {{.*}}fn_ret_thunk_extern
 // CHECK: [[EXTERN]] = {{.*}}fn_ret_thunk_extern
+// CHECK-GCOV: [[EXTERNGCOV]] = {{.*}}fn_ret_thunk_extern
+// CHECK-ASAN: [[EXTERNASAN]] = {{.*}}fn_ret_thunk_extern
+// CHECK-TSAN: [[EXTERNTSAN]] = {{.*}}fn_ret_thunk_extern
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -756,6 +756,9 @@
   if (CodeGenOpts.IBTSeal)
 getModule().addModuleFlag(llvm::Module::Override, "ibt-seal", 1);
 
+  if (CodeGenOpts.FunctionReturnThunks)
+getModule().addModuleFlag(llvm::Module::Override, 
"function_return_thunk_extern", 1);
+
   // Add module metadata for return address signing (ignoring
   // non-leaf/all) and stack tagging. These are actually turned on by function
   // attributes, but we use module metadata to emit build attributes. This is


Index: llvm/lib/IR/Function.cpp
===
--- llvm/lib/IR/Function.cpp
+++ llvm/lib/IR/Function.cpp
@@ -354,6 +354,8 @@
 B.addAttribute("frame-pointer", "all");
 break;
   }
+  if (M->getModuleFlag("function_return_thunk_extern"))
+B.addAttribute(Attribute::FnRetThunkExtern);
   F->addFnAttrs(B);
   return F;
 }
Index: llvm/docs/LangRef.rst
===
--- llvm/docs/LangRef.rst
+++ llvm/docs/LangRef.rst
@@ -7364,6 +7364,8 @@
 - "frame-pointer": **Max**. The value can be 0, 1, or 2. A synthesized function
   will get the "frame-pointer" function attribute, with value being "none",
   "non-leaf", or "all", respectively.
+- "function_return_thunk_extern": The synthesized function will get the
+  ``fn_return_thunk_extern`` function attribute.
 - "uwtable": **Max**. The value can be 0, 1, or

[PATCH] D129709: [clang][CodeGen] add fn_ret_thunk_extern to synthetic fns

2022-07-14 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

Thanks for the review!




Comment at: clang/test/CodeGen/attr-function-return.c:9
 // RUN:  --check-prefixes=CHECK,CHECK-EXTERN
+// RUN: %clang_cc1 -std=gnu2x -triple x86_64-linux-gnu %s -emit-llvm -o - \
+// RUN:  -mfunction-return=thunk-extern -fprofile-arcs \

MaskRay wrote:
> I feel that having 3 RUN lines is excessive. Since we already have a test 
> that asan/tsan/gcov respect getModuleFlag, it is not necessary for a new one 
> to duplicate all the combinations.
All three have caused problems for us; I'd prefer to retain each.



Comment at: llvm/lib/IR/Function.cpp:357
   }
+  if (M->getModuleFlag("fn_return_thunk_extern"))
+B.addAttribute(Attribute::FnRetThunkExtern);

MaskRay wrote:
> How about "function_return_thunk_extern"? fn doesn't abbreviate much. Having 
> the `function_return` substring makes it easy for grepping.
Done, but note that this was done to match the Function Attribute.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129709

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


[PATCH] D129709: [clang][CodeGen] add fn_ret_thunk_extern to synthetic fns

2022-07-14 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 444742.
nickdesaulniers marked 2 inline comments as done.
nickdesaulniers added a comment.

- rename md idententifier, sort langref


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129709

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/attr-function-return.c
  llvm/docs/LangRef.rst
  llvm/lib/IR/Function.cpp


Index: llvm/lib/IR/Function.cpp
===
--- llvm/lib/IR/Function.cpp
+++ llvm/lib/IR/Function.cpp
@@ -354,6 +354,8 @@
 B.addAttribute("frame-pointer", "all");
 break;
   }
+  if (M->getModuleFlag("function_return_thunk_extern"))
+B.addAttribute(Attribute::FnRetThunkExtern);
   F->addFnAttrs(B);
   return F;
 }
Index: llvm/docs/LangRef.rst
===
--- llvm/docs/LangRef.rst
+++ llvm/docs/LangRef.rst
@@ -7361,6 +7361,8 @@
 should not be listed because the performance impact of these synthesized
 functions is small.
 
+- "function_return_thunk_extern": The synthesized function will get the
+  ``fn_return_thunk_extern`` function attribute.
 - "frame-pointer": **Max**. The value can be 0, 1, or 2. A synthesized function
   will get the "frame-pointer" function attribute, with value being "none",
   "non-leaf", or "all", respectively.
Index: clang/test/CodeGen/attr-function-return.c
===
--- clang/test/CodeGen/attr-function-return.c
+++ clang/test/CodeGen/attr-function-return.c
@@ -7,6 +7,15 @@
 // RUN: %clang_cc1 -std=gnu2x -triple x86_64-linux-gnu %s -emit-llvm -o - \
 // RUN:   -Werror=ignored-attributes -mfunction-return=thunk-extern \
 // RUN:   | FileCheck %s --check-prefixes=CHECK,CHECK-EXTERN
+// RUN: %clang_cc1 -std=gnu2x -triple x86_64-linux-gnu %s -emit-llvm -o - \
+// RUN:  -mfunction-return=thunk-extern -fprofile-arcs \
+// RUN:   | FileCheck %s --check-prefix=CHECK-GCOV
+// RUN: %clang_cc1 -std=gnu2x -triple x86_64-linux-gnu %s -emit-llvm -o - \
+// RUN:  -mfunction-return=thunk-extern -fsanitize=address \
+// RUN:   | FileCheck %s --check-prefix=CHECK-ASAN
+// RUN: %clang_cc1 -std=gnu2x -triple x86_64-linux-gnu %s -emit-llvm -o - \
+// RUN:  -mfunction-return=thunk-extern -fsanitize=thread \
+// RUN:   | FileCheck %s --check-prefix=CHECK-TSAN
 
 #if !__has_attribute(function_return)
 #error "missing attribute support for function_return"
@@ -92,6 +101,16 @@
 // CHECK-EXTERN: @no_attrs() [[EXTERN]]
 void no_attrs(void) {}
 
+// Test synthetic functions.
+// CHECK-GCOV: @__llvm_gcov_writeout() unnamed_addr [[EXTERNGCOV:#[0-9]+]]
+// CHECK-GCOV: @__llvm_gcov_reset() unnamed_addr [[EXTERNGCOV]]
+// CHECK-GCOV: @__llvm_gcov_init() unnamed_addr [[EXTERNGCOV]]
+// CHECK-ASAN: @asan.module_ctor() [[EXTERNASAN:#[0-9]+]]
+// CHECK-TSAN: @tsan.module_ctor() [[EXTERNTSAN:#[0-9]+]]
+
 // CHECK-NOM-NOT:  [[NOATTR]] = {{.*}}fn_ret_thunk_extern
 // CHECK-KEEP-NOT: [[NOATTR]] = {{.*}}fn_ret_thunk_extern
 // CHECK: [[EXTERN]] = {{.*}}fn_ret_thunk_extern
+// CHECK-GCOV: [[EXTERNGCOV]] = {{.*}}fn_ret_thunk_extern
+// CHECK-ASAN: [[EXTERNASAN]] = {{.*}}fn_ret_thunk_extern
+// CHECK-TSAN: [[EXTERNTSAN]] = {{.*}}fn_ret_thunk_extern
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -756,6 +756,9 @@
   if (CodeGenOpts.IBTSeal)
 getModule().addModuleFlag(llvm::Module::Override, "ibt-seal", 1);
 
+  if (CodeGenOpts.FunctionReturnThunks)
+getModule().addModuleFlag(llvm::Module::Override, 
"function_return_thunk_extern", 1);
+
   // Add module metadata for return address signing (ignoring
   // non-leaf/all) and stack tagging. These are actually turned on by function
   // attributes, but we use module metadata to emit build attributes. This is


Index: llvm/lib/IR/Function.cpp
===
--- llvm/lib/IR/Function.cpp
+++ llvm/lib/IR/Function.cpp
@@ -354,6 +354,8 @@
 B.addAttribute("frame-pointer", "all");
 break;
   }
+  if (M->getModuleFlag("function_return_thunk_extern"))
+B.addAttribute(Attribute::FnRetThunkExtern);
   F->addFnAttrs(B);
   return F;
 }
Index: llvm/docs/LangRef.rst
===
--- llvm/docs/LangRef.rst
+++ llvm/docs/LangRef.rst
@@ -7361,6 +7361,8 @@
 should not be listed because the performance impact of these synthesized
 functions is small.
 
+- "function_return_thunk_extern": The synthesized function will get the
+  ``fn_return_thunk_extern`` function attribute.
 - "frame-pointer": **Max**. The value can be 0, 1, or 2. A synthesized function
   will get the "frame-pointer" function attribute, with value being "none",
   "non-leaf", or "all", respectively.
Index: clang/test/CodeGen/attr-fun

[PATCH] D129772: [clang] Document -femit-compact-unwind option in the User’s Manual

2022-07-14 Thread Jez Ng via Phabricator via cfe-commits
int3 updated this revision to Diff 444740.
int3 retitled this revision from "[clang] Document -femit-compact-unwind flag 
in the User’s Manual" to "[clang] Document -femit-compact-unwind option in the 
User’s Manual".
int3 added a comment.

option


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129772

Files:
  clang/docs/UsersManual.rst


Index: clang/docs/UsersManual.rst
===
--- clang/docs/UsersManual.rst
+++ clang/docs/UsersManual.rst
@@ -843,6 +843,23 @@
 option tells Clang to put double-quotes around the entire filename, which
 is the convention used by NMake and Jom.
 
+.. option:: -femit-dwarf-unwind=
+
+  When to emit DWARF unwind (EH frame) info. This is a Mach-O-specific option.
+
+  Valid values are:
+
+  * ``no-compact-unwind`` - Only emit DWARF unwind when compact unwind 
encodings
+aren't available. This is the default for AArch64.
+  * ``always`` - Always emit DWARF unwind regardless.
+  * ``default`` - Use the platform-specific default (``always`` for all
+non-AArch64-platforms).
+
+``no-compact-unwind`` is a performance optimization -- Clang will emit smaller
+object files that are more quickly processed by the linker. This may cause
+binary compatibility issues on older x86_64 targets, however, so use it with
+caution.
+
 .. _configuration-files:
 
 Configuration files


Index: clang/docs/UsersManual.rst
===
--- clang/docs/UsersManual.rst
+++ clang/docs/UsersManual.rst
@@ -843,6 +843,23 @@
 option tells Clang to put double-quotes around the entire filename, which
 is the convention used by NMake and Jom.
 
+.. option:: -femit-dwarf-unwind=
+
+  When to emit DWARF unwind (EH frame) info. This is a Mach-O-specific option.
+
+  Valid values are:
+
+  * ``no-compact-unwind`` - Only emit DWARF unwind when compact unwind encodings
+aren't available. This is the default for AArch64.
+  * ``always`` - Always emit DWARF unwind regardless.
+  * ``default`` - Use the platform-specific default (``always`` for all
+non-AArch64-platforms).
+
+``no-compact-unwind`` is a performance optimization -- Clang will emit smaller
+object files that are more quickly processed by the linker. This may cause
+binary compatibility issues on older x86_64 targets, however, so use it with
+caution.
+
 .. _configuration-files:
 
 Configuration files
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129048: Rewording the "static_assert" to static assertion

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

In D129048#3652739 , @hctim wrote:

> In D129048#3652689 , @aaron.ballman 
> wrote:
>
>> In D129048#3652679 , @hctim wrote:
>>
>>> Looks like unfortunately this breaks all lots of libcxx tests - which were 
>>> picked up by our sanitizer buildbots:
>>
>> Thanks for letting us know.  Do you happen to know if there's any particular 
>> reason why no email was sent out for the build failure?
>
> No, sorry. Did it not get sent to `codesbyus...@gmail.com`? I see you 
> committed it, but their address is the author of the commit.

That's possible, but I recall getting build failure emails before when I've 
committed on someone's behalf. Oh well, thanks for letting us know and sorry 
for the breakage!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129048

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


[PATCH] D129048: Rewording the "static_assert" to static assertion

2022-07-14 Thread Mitch Phillips via Phabricator via cfe-commits
hctim added a comment.

In D129048#3652689 , @aaron.ballman 
wrote:

> In D129048#3652679 , @hctim wrote:
>
>> Looks like unfortunately this breaks all lots of libcxx tests - which were 
>> picked up by our sanitizer buildbots:
>
> Thanks for letting us know.  Do you happen to know if there's any particular 
> reason why no email was sent out for the build failure?

No, sorry. Did it not get sent to `codesbyus...@gmail.com`? I see you committed 
it, but their address is the author of the commit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129048

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


[PATCH] D129789: [test][CodeGen] Don't miss lifetime markers in lifetime tests

2022-07-14 Thread Vitaly Buka 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 rGa2e01bdcc214: [test][CodeGen] Don't miss lifetime 
markers in lifetime tests (authored by vitalybuka).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129789

Files:
  clang/test/CodeGen/lifetime.c
  clang/test/CodeGen/lifetime2.c

Index: clang/test/CodeGen/lifetime2.c
===
--- clang/test/CodeGen/lifetime2.c
+++ clang/test/CodeGen/lifetime2.c
@@ -1,27 +1,27 @@
-// RUN: %clang_cc1 -no-opaque-pointers -S -emit-llvm -o - -O2 -disable-llvm-passes %s | FileCheck %s -check-prefixes=CHECK,O2
-// RUN: %clang_cc1 -no-opaque-pointers -S -emit-llvm -o - -O2 -disable-lifetime-markers %s \
-// RUN:   | FileCheck %s -check-prefixes=CHECK,O0
-// RUN: %clang_cc1 -no-opaque-pointers -S -emit-llvm -o - -O0 %s | FileCheck %s -check-prefixes=CHECK,O0
+// RUN: %clang_cc1 -no-opaque-pointers -S -emit-llvm -o - -O2 -disable-llvm-passes %s  | FileCheck %s --implicit-check-not="call void @llvm.lifetime" --check-prefixes=CHECK,O2
+// RUN: %clang_cc1 -no-opaque-pointers -S -emit-llvm -o - -O2 -disable-lifetime-markers %s | FileCheck %s --implicit-check-not="call void @llvm.lifetime" --check-prefixes=CHECK
+// RUN: %clang_cc1 -no-opaque-pointers -S -emit-llvm -o - -O0 %s   | FileCheck %s --implicit-check-not="call void @llvm.lifetime" --check-prefixes=CHECK 
 
 extern int bar(char *A, int n);
 
 // CHECK-LABEL: @foo
-// O0-NOT: @llvm.lifetime.start
 int foo (int n) {
   if (n) {
-// O2: @llvm.lifetime.start
+// O2: call void @llvm.lifetime.start.p0i8(i64 100,
 char A[100];
 return bar(A, 1);
+// O2: call void @llvm.lifetime.end.p0i8(i64 100,
   } else {
-// O2: @llvm.lifetime.start
+// O2: call void @llvm.lifetime.start.p0i8(i64 100,
 char A[100];
 return bar(A, 2);
+// O2: call void @llvm.lifetime.end.p0i8(i64 100,
   }
 }
 
 // CHECK-LABEL: @no_goto_bypass
 void no_goto_bypass(void) {
-  // O2: @llvm.lifetime.start.p0i8(i64 1
+  // O2: call void @llvm.lifetime.start.p0i8(i64 1,
   char x;
 l1:
   bar(&x, 1);
@@ -29,14 +29,11 @@
   bar(y, 5);
   goto l1;
   // Infinite loop
-  // O2-NOT: @llvm.lifetime.end.p0i8(
 }
 
 // CHECK-LABEL: @goto_bypass
 void goto_bypass(void) {
   {
-// O2-NOT: @llvm.lifetime.start.p0i8(i64 1
-// O2-NOT: @llvm.lifetime.end.p0i8(i64 1
 char x;
   l1:
 bar(&x, 1);
@@ -48,16 +45,16 @@
 void no_switch_bypass(int n) {
   switch (n) {
   case 1: {
-// O2: @llvm.lifetime.start.p0i8(i64 1
-// O2: @llvm.lifetime.end.p0i8(i64 1
+// O2: call void @llvm.lifetime.start.p0i8(i64 1,
+// O2: call void @llvm.lifetime.end.p0i8(i64 1,
 char x;
 bar(&x, 1);
 break;
   }
   case 2:
 n = n;
-// O2: @llvm.lifetime.start.p0i8(i64 5
-// O2: @llvm.lifetime.end.p0i8(i64 5
+// O2: call void @llvm.lifetime.start.p0i8(i64 5,
+// O2: call void @llvm.lifetime.end.p0i8(i64 5,
 char y[5];
 bar(y, 5);
 break;
@@ -69,8 +66,6 @@
   switch (n) {
   case 1:
 n = n;
-// O2-NOT: @llvm.lifetime.start.p0i8(i64 1
-// O2-NOT: @llvm.lifetime.end.p0i8(i64 1
 char x;
 bar(&x, 1);
 break;
@@ -83,23 +78,18 @@
 // CHECK-LABEL: @indirect_jump
 void indirect_jump(int n) {
   char x;
-  // O2-NOT: @llvm.lifetime
   void *T[] = {&&L};
   goto *T[n];
 L:
   bar(&x, 1);
 }
 
-// O2-LABEL: @jump_backward_over_declaration(
-// O2: %[[p:.*]] = alloca i32*
-// O2: %[[v0:.*]] = bitcast i32** %[[p]] to i8*
-// O2: call void @llvm.lifetime.start.p0i8(i64 {{.*}}, i8* %[[v0]])
-// O2-NOT: call void @llvm.lifetime.start.p0i8(
-
 extern void foo2(int p);
 
+// O2-LABEL: @jump_backward_over_declaration(
 int jump_backward_over_declaration(int a) {
   int *p = 0;
+// O2: call void @llvm.lifetime.start.p0i8(i64 8,
 label1:
   if (p) {
 foo2(*p);
@@ -112,4 +102,5 @@
 goto label1;
   }
   return -1;
+// O2: call void @llvm.lifetime.end.p0i8(i64 8,
 }
Index: clang/test/CodeGen/lifetime.c
===
--- clang/test/CodeGen/lifetime.c
+++ clang/test/CodeGen/lifetime.c
@@ -1,23 +1,21 @@
-// RUN: %clang -S -emit-llvm -o - -O0 %s | FileCheck %s -check-prefix=O0
-// RUN: %clang -S -emit-llvm -o - -O1 %s | FileCheck %s -check-prefix=O1
-// RUN: %clang -S -emit-llvm -o - -O2 %s | FileCheck %s -check-prefix=O2
-// RUN: %clang -S -emit-llvm -o - -O3 %s | FileCheck %s -check-prefix=O3
+// RUN: %clang -S -emit-llvm -o - -O0 %s | FileCheck %s --implicit-check-not="call void @llvm.lifetime" -check-prefixes=CHECK
+// RUN: %clang -S -emit-llvm -o - -O1 %s | FileCheck %s --implicit-check-not="call void @llvm.lifetime" -check-prefixes=CHECK,LIFETIME
+// RUN: %clang -S -emit-llvm -o - -O2 %s | FileCheck %s --implicit-check-not="call void @llvm.lifetime" -check-prefixes=CHECK,LIFETIME
+// RUN: %cla

[clang] a2e01bd - [test][CodeGen] Don't miss lifetime markers in lifetime tests

2022-07-14 Thread Vitaly Buka via cfe-commits

Author: Vitaly Buka
Date: 2022-07-14T11:14:07-07:00
New Revision: a2e01bdcc21429d92cd785053f7cc9f72f1d212a

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

LOG: [test][CodeGen] Don't miss lifetime markers in lifetime tests

Reviewed By: MaskRay

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

Added: 


Modified: 
clang/test/CodeGen/lifetime.c
clang/test/CodeGen/lifetime2.c

Removed: 




diff  --git a/clang/test/CodeGen/lifetime.c b/clang/test/CodeGen/lifetime.c
index cabbe30a91b92..748a496a6e9ea 100644
--- a/clang/test/CodeGen/lifetime.c
+++ b/clang/test/CodeGen/lifetime.c
@@ -1,23 +1,21 @@
-// RUN: %clang -S -emit-llvm -o - -O0 %s | FileCheck %s -check-prefix=O0
-// RUN: %clang -S -emit-llvm -o - -O1 %s | FileCheck %s -check-prefix=O1
-// RUN: %clang -S -emit-llvm -o - -O2 %s | FileCheck %s -check-prefix=O2
-// RUN: %clang -S -emit-llvm -o - -O3 %s | FileCheck %s -check-prefix=O3
+// RUN: %clang -S -emit-llvm -o - -O0 %s | FileCheck %s 
--implicit-check-not="call void @llvm.lifetime" -check-prefixes=CHECK
+// RUN: %clang -S -emit-llvm -o - -O1 %s | FileCheck %s 
--implicit-check-not="call void @llvm.lifetime" -check-prefixes=CHECK,LIFETIME
+// RUN: %clang -S -emit-llvm -o - -O2 %s | FileCheck %s 
--implicit-check-not="call void @llvm.lifetime" -check-prefixes=CHECK,LIFETIME
+// RUN: %clang -S -emit-llvm -o - -O3 %s | FileCheck %s 
--implicit-check-not="call void @llvm.lifetime" -check-prefixes=CHECK,LIFETIME
 
 extern void use(char *a);
 
+// CHECK-LABEL: @helper_no_markers
 __attribute__((always_inline)) void helper_no_markers(void) {
   char a;
+  // LIFETIME: call void @llvm.lifetime.start.p0(i64 1,
   use(&a);
+  // LIFETIME: call void @llvm.lifetime.end.p0(i64 1,
 }
 
+// CHECK-LABEL: @lifetime_test
 void lifetime_test(void) {
-// O0: lifetime_test
-// O1: lifetime_test
-// O2: lifetime_test
-// O3: lifetime_test
-// O0-NOT: @llvm.lifetime.start
-// O1: @llvm.lifetime.start
-// O2: @llvm.lifetime.start
-// O3: @llvm.lifetime.start
+// LIFETIME: call void @llvm.lifetime.start.p0(i64 1,
   helper_no_markers();
+// LIFETIME: call void @llvm.lifetime.end.p0(i64 1,
 }

diff  --git a/clang/test/CodeGen/lifetime2.c b/clang/test/CodeGen/lifetime2.c
index 6a2624f51d2cb..0def7b6de8c20 100644
--- a/clang/test/CodeGen/lifetime2.c
+++ b/clang/test/CodeGen/lifetime2.c
@@ -1,27 +1,27 @@
-// RUN: %clang_cc1 -no-opaque-pointers -S -emit-llvm -o - -O2 
-disable-llvm-passes %s | FileCheck %s -check-prefixes=CHECK,O2
-// RUN: %clang_cc1 -no-opaque-pointers -S -emit-llvm -o - -O2 
-disable-lifetime-markers %s \
-// RUN:   | FileCheck %s -check-prefixes=CHECK,O0
-// RUN: %clang_cc1 -no-opaque-pointers -S -emit-llvm -o - -O0 %s | FileCheck 
%s -check-prefixes=CHECK,O0
+// RUN: %clang_cc1 -no-opaque-pointers -S -emit-llvm -o - -O2 
-disable-llvm-passes %s  | FileCheck %s --implicit-check-not="call void 
@llvm.lifetime" --check-prefixes=CHECK,O2
+// RUN: %clang_cc1 -no-opaque-pointers -S -emit-llvm -o - -O2 
-disable-lifetime-markers %s | FileCheck %s --implicit-check-not="call void 
@llvm.lifetime" --check-prefixes=CHECK
+// RUN: %clang_cc1 -no-opaque-pointers -S -emit-llvm -o - -O0 %s   
| FileCheck %s --implicit-check-not="call void @llvm.lifetime" 
--check-prefixes=CHECK 
 
 extern int bar(char *A, int n);
 
 // CHECK-LABEL: @foo
-// O0-NOT: @llvm.lifetime.start
 int foo (int n) {
   if (n) {
-// O2: @llvm.lifetime.start
+// O2: call void @llvm.lifetime.start.p0i8(i64 100,
 char A[100];
 return bar(A, 1);
+// O2: call void @llvm.lifetime.end.p0i8(i64 100,
   } else {
-// O2: @llvm.lifetime.start
+// O2: call void @llvm.lifetime.start.p0i8(i64 100,
 char A[100];
 return bar(A, 2);
+// O2: call void @llvm.lifetime.end.p0i8(i64 100,
   }
 }
 
 // CHECK-LABEL: @no_goto_bypass
 void no_goto_bypass(void) {
-  // O2: @llvm.lifetime.start.p0i8(i64 1
+  // O2: call void @llvm.lifetime.start.p0i8(i64 1,
   char x;
 l1:
   bar(&x, 1);
@@ -29,14 +29,11 @@ void no_goto_bypass(void) {
   bar(y, 5);
   goto l1;
   // Infinite loop
-  // O2-NOT: @llvm.lifetime.end.p0i8(
 }
 
 // CHECK-LABEL: @goto_bypass
 void goto_bypass(void) {
   {
-// O2-NOT: @llvm.lifetime.start.p0i8(i64 1
-// O2-NOT: @llvm.lifetime.end.p0i8(i64 1
 char x;
   l1:
 bar(&x, 1);
@@ -48,16 +45,16 @@ void goto_bypass(void) {
 void no_switch_bypass(int n) {
   switch (n) {
   case 1: {
-// O2: @llvm.lifetime.start.p0i8(i64 1
-// O2: @llvm.lifetime.end.p0i8(i64 1
+// O2: call void @llvm.lifetime.start.p0i8(i64 1,
+// O2: call void @llvm.lifetime.end.p0i8(i64 1,
 char x;
 bar(&x, 1);
 break;
   }
   case 2:
 n = n;
-// O2: @llvm.lifetime.start.p0i8(i64 5
-// O2: @llvm.lifetime.end.p0i8(i64 5
+// O2: call void @llvm.lifetime

  1   2   3   >