[PATCH] D104242: Alters a lit test to simplify and avoid a buildbot error

2021-06-14 Thread Fred Grim via Phabricator via cfe-commits
feg208 added a comment.

I don’t have commit rights currently. Could I get someone to land this on my 
behalf?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104242

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


[PATCH] D104275: [compiler-rt][hwasan] Add SHADOW_OFFSET macro

2021-06-14 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added inline comments.



Comment at: compiler-rt/lib/hwasan/hwasan_mapping.h:57
 
 extern uptr kAliasRegionStart;
 

Maybe the following to minimize code which compiles only on limited set of 
platforms?

```
inline uptr GetShadowOffset() {
  return SANITIZER_FUCHSIA ? 0 : __hwasan_shadow_memory_dynamic_address;
}
```



Comment at: compiler-rt/lib/hwasan/hwasan_mapping.h:59
 
 inline uptr MemToShadow(uptr untagged_addr) {
+  return (untagged_addr >> kShadowScale) + SHADOW_OFFSET

> clang-tidy: error: expected ';' after return statement 
> [clang-diagnostic-error]
please fix


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104275

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


[PATCH] D104097: [analyzer] Fix calculating offset for fields with an empty type

2021-06-14 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

This looks correct, thanks!

I think there are some weird rules with respect to `[[no_unique_address]]` on 
two consecutive fields when there's only one other field in the structure, eg.

  struct S {
  char c;
  [[no_unique_address]] Empty e1, e2;
  };

will have a size of two bytes according to 
https://en.cppreference.com/w/cpp/language/attributes/no_unique_address.

It's probably worth a test case to see if we still calculate padding correctly 
in such cases but I don't insist.


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

https://reviews.llvm.org/D104097

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


[PATCH] D103928: [IR] make -warn-frame-size into a module attr

2021-06-14 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added inline comments.



Comment at: llvm/test/Linker/warn-stack-frame.ll:6
+
+; CHECK-MISMATCH: error: linking module flags 'warn-stack-size': IDs have 
conflicting values
+

If you like, you could make this a function attribute instead, that way it'd be 
compatible with LTO even when the value varies between compilations?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103928

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


[PATCH] D104046: [analyzer] Simplify the process of producing notes for stores

2021-06-14 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

Looks great, thanks!




Comment at: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp:1299
+  } else if (SI.Value.isUndef()) {
+OS << "uninitialized value";
+

This isn't new but oof this note is terrible.

I don't think we have any tests where it's actually emitted. I suspect that 
this shouldn't happen in practice unless `core` checkers are disabled.

Now that I think of it, our actual warning for undef passed into function says 
"function call argument is an uninitialized value" which is almost as bad as 
this.

Just sayin' :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104046

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


[PATCH] D103961: [analyzer] Extract InlinedFunctionCallHandler

2021-06-14 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103961

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


[PATCH] D104279: [asan] Remove Asan, Ubsan support of RTEMS and Myriad

2021-06-14 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka created this revision.
Herald added subscribers: phosek, jfb, fedor.sergeev, hiraditya, krytarowski, 
mgorny.
vitalybuka requested review of this revision.
Herald added projects: clang, Sanitizers, LLVM.
Herald added subscribers: llvm-commits, Sanitizers, cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D104279

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/sanitizer-ld.c
  compiler-rt/lib/asan/CMakeLists.txt
  compiler-rt/lib/asan/asan_errors.cpp
  compiler-rt/lib/asan/asan_flags.cpp
  compiler-rt/lib/asan/asan_flags.inc
  compiler-rt/lib/asan/asan_interceptors.cpp
  compiler-rt/lib/asan/asan_interceptors.h
  compiler-rt/lib/asan/asan_interceptors_memintrinsics.cpp
  compiler-rt/lib/asan/asan_internal.h
  compiler-rt/lib/asan/asan_malloc_linux.cpp
  compiler-rt/lib/asan/asan_malloc_local.h
  compiler-rt/lib/asan/asan_mapping.h
  compiler-rt/lib/asan/asan_mapping_myriad.h
  compiler-rt/lib/asan/asan_new_delete.cpp
  compiler-rt/lib/asan/asan_poisoning.cpp
  compiler-rt/lib/asan/asan_poisoning.h
  compiler-rt/lib/asan/asan_rtems.cpp
  compiler-rt/lib/asan/asan_rtl.cpp
  compiler-rt/lib/asan/asan_shadow_setup.cpp
  compiler-rt/lib/asan/asan_thread.cpp
  compiler-rt/lib/interception/interception.h
  compiler-rt/lib/sanitizer_common/CMakeLists.txt
  compiler-rt/lib/sanitizer_common/sanitizer_common.cpp
  compiler-rt/lib/sanitizer_common/sanitizer_common_libcdep.cpp
  compiler-rt/lib/sanitizer_common/sanitizer_errno.h
  compiler-rt/lib/sanitizer_common/sanitizer_platform.h
  compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h
  compiler-rt/lib/sanitizer_common/sanitizer_rtems.cpp
  compiler-rt/lib/sanitizer_common/sanitizer_rtems.h
  compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.h
  compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_markup.cpp
  compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_report.cpp
  compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_rtems.h
  compiler-rt/lib/ubsan/ubsan_platform.h
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/test/Instrumentation/AddressSanitizer/basic-myriad.ll
  llvm/utils/gn/secondary/compiler-rt/lib/asan/BUILD.gn
  llvm/utils/gn/secondary/compiler-rt/lib/sanitizer_common/BUILD.gn

Index: llvm/utils/gn/secondary/compiler-rt/lib/sanitizer_common/BUILD.gn
===
--- llvm/utils/gn/secondary/compiler-rt/lib/sanitizer_common/BUILD.gn
+++ llvm/utils/gn/secondary/compiler-rt/lib/sanitizer_common/BUILD.gn
@@ -111,8 +111,6 @@
 "sanitizer_quarantine.h",
 "sanitizer_report_decorator.h",
 "sanitizer_ring_buffer.h",
-"sanitizer_rtems.cpp",
-"sanitizer_rtems.h",
 "sanitizer_solaris.cpp",
 "sanitizer_stackdepot.cpp",
 "sanitizer_stackdepot.h",
@@ -142,7 +140,6 @@
 "sanitizer_symbolizer_markup.cpp",
 "sanitizer_symbolizer_posix_libcdep.cpp",
 "sanitizer_symbolizer_report.cpp",
-"sanitizer_symbolizer_rtems.h",
 "sanitizer_symbolizer_win.cpp",
 "sanitizer_termination.cpp",
 "sanitizer_thread_registry.cpp",
Index: llvm/utils/gn/secondary/compiler-rt/lib/asan/BUILD.gn
===
--- llvm/utils/gn/secondary/compiler-rt/lib/asan/BUILD.gn
+++ llvm/utils/gn/secondary/compiler-rt/lib/asan/BUILD.gn
@@ -74,7 +74,6 @@
 "asan_lock.h",
 "asan_mac.cpp",
 "asan_malloc_linux.cpp",
-"asan_malloc_local.h",
 "asan_malloc_mac.cpp",
 "asan_malloc_win.cpp",
 "asan_mapping.h",
@@ -87,7 +86,6 @@
 "asan_premap_shadow.h",
 "asan_report.cpp",
 "asan_report.h",
-"asan_rtems.cpp",
 "asan_rtl.cpp",
 "asan_scariness_score.h",
 "asan_shadow_setup.cpp",
Index: llvm/test/Instrumentation/AddressSanitizer/basic-myriad.ll
===
--- llvm/test/Instrumentation/AddressSanitizer/basic-myriad.ll
+++ /dev/null
@@ -1,85 +0,0 @@
-; Test basic address sanitizer instrumentation for Myriad.
-;
-; RUN: opt -asan -asan-module -enable-new-pm=0 -S  < %s | FileCheck %s
-; RUN: opt -passes='asan-pipeline' -S  < %s | FileCheck %s
-
-target triple = "sparc-myriad-rtems"
-target datalayout = "E-m:e-p:32:32-i64:64-f128:64-n32-S64"
-; CHECK: @llvm.global_ctors = {{.*}}@asan.module_ctor
-
-define i32 @test_load(i32* %a) sanitize_address {
-; CHECK-LABEL: @test_load
-; CHECK-NOT: load
-; CHECK:   ptrtoint i32* %a to i32
-; CHECK:   %[[LOAD_ADDR:[^ ]*]] = and i32 %{{.*}}, -1073741825
-; CHECK:   lshr i32 %{{.*}}, 29
-; CHECK:   icmp eq i32 %{{.*}}, 4
-; CHECK:   br i1 %{{.*}}, label %{{.*}}, label %{{.*}}!prof ![[PROF:[0-9]+]]
-;
-; This block checks whether the shadow byte is 0.
-; CHECK:   lshr i32 %[[LOAD_ADDR]], 5
-; CHECK:   add i32 %{{.*}}, -1694498816
-; CHECK:   %[[LOAD_SHADOW_PTR:[^ ]*]] = inttoptr
-; CHECK:   %[[LOAD_SHADOW:[^ ]*]] = load i8, i8* %[[LOAD_SHADOW_PTR]]
-; CHECK:   icmp ne i8
-; CHECK:   br i1 %{{.*}}, label 

[PATCH] D103644: [analyzer] Refactor StoreSiteFinder and extract DefaultStoreHandler

2021-06-14 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

Great, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103644

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


[PATCH] D104135: [analyzer] Decouple NoteTag from its Factory

2021-06-14 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: 
clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h:777
   static bool classof(const ProgramPointTag *T) {
 return T->getTagKind() == 
   }

vsavchenko wrote:
> NoQ wrote:
> > NoQ wrote:
> > > It sounds like `NoteTag` `isn't` despite inheriting from it.
> > Wait nvm, `DataTag` doesn't provide a `classof` at all. This means we can't 
> > write `isa` at all, right?
> Yes, it's purely abstract.  `ProgramPointTag` also doesn't have `classof`
Something being purely abstract isn't a problem on its own; there are a lot of 
abstract classes that implement `classof()`, such as `Expr`. It's more of an 
artifact of the current implementation strategy.

Ok np though, this doesn't seem to be a real problem.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104135

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


[PATCH] D103750: [analyzer] Handle std::make_unique for SmartPtrModeling

2021-06-14 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/SmartPtrModeling.cpp:207
+
+const auto PtrVal = C.getSValBuilder().conjureSymbolVal(
+Call.getOriginExpr(), C.getLocationContext(),

Can you do a `getConjuredHeapSymbolVal()` instead? That'd give us the right 
memory space as well as the extra bit of information that the new symbol 
doesn't alias with any previous symbols.

I get it that it doesn't accept the type but it's perfectly ok for you to teach 
it how to accept the type.



Comment at: clang/test/Analysis/smart-ptr-text-output.cpp:339
+void makeUniqueForOverwriteReturnsNullUniquePtr() {
+  auto P = std::make_unique_for_overwrite(); // expected-note 
{{std::unique_ptr 'P' constructed by std::make_unique_for_overwrite is null}}
+  *P;   // expected-warning 
{{Dereference of null smart pointer 'P' [alpha.cplusplus.SmartPtr]}}

Mmm wait a sec, that doesn't look like what the spec says.

https://en.cppreference.com/w/cpp/memory/unique_ptr/make_unique:
> Same as (1), except that the object is default-initialized. This overload 
> participates in overload resolution only if T is not an array type. The 
> function is equivalent to `unique_ptr(new T)`

It zero-initializes the //pointee//, not the //pointer//.

The difference between `std::make_unique()` and 
`std::make_unique_for_overwrite()` is the difference between 
value-initialization (invoking the default constructor) and zero-initialization 
(simply filling the buffer with `0`s).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103750

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


[PATCH] D98068: Do not merge LocalInstantiationScope for template specialization

2021-06-14 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG79f9cfbc21e0: Do not merge LocalInstantiationScope for 
template specialization (authored by yaxunl).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98068

Files:
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/SemaCXX/recursive-lambda.cpp


Index: clang/test/SemaCXX/recursive-lambda.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/recursive-lambda.cpp
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify %s
+
+// expected-no-diagnostics
+
+// Check recursive instantiation of lambda does not cause assertion.
+// lambda function `f` in `fun1` is instantiated twice: first
+// as f(f, Number<1>), then as f(f, Number<0>). The
+// LocalInstantiationScopes of these two instantiations both contain
+// `f` and `i`. However, since they are not merged, clang should not
+// assert for that.
+
+template 
+struct Number
+{
+   static constexpr unsigned value = v;
+};
+
+template 
+constexpr auto fun1(Number = Number<0>{}, Number  = Number<1>{})
+{
+  constexpr unsigned a = 0;
+  auto f = [&](auto fs, auto i) {
+if constexpr(i.value > 0)
+{
+  (void)a;
+  return fs(fs, Number{});
+}
+(void)a;
+  };
+
+  return f(f, Number{});
+}
+
+
+void fun2() {
+  fun1();
+}
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -4890,10 +4890,13 @@
   // Introduce a new scope where local variable instantiations will be
   // recorded, unless we're actually a member function within a local
   // class, in which case we need to merge our results with the parent
-  // scope (of the enclosing function).
+  // scope (of the enclosing function). The exception is instantiating
+  // a function template specialization, since the template to be
+  // instantiated already has references to locals properly substituted.
   bool MergeWithParentScope = false;
   if (CXXRecordDecl *Rec = dyn_cast(Function->getDeclContext()))
-MergeWithParentScope = Rec->isLocalClass();
+MergeWithParentScope =
+Rec->isLocalClass() && !Function->isFunctionTemplateSpecialization();
 
   LocalInstantiationScope Scope(*this, MergeWithParentScope);
 


Index: clang/test/SemaCXX/recursive-lambda.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/recursive-lambda.cpp
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify %s
+
+// expected-no-diagnostics
+
+// Check recursive instantiation of lambda does not cause assertion.
+// lambda function `f` in `fun1` is instantiated twice: first
+// as f(f, Number<1>), then as f(f, Number<0>). The
+// LocalInstantiationScopes of these two instantiations both contain
+// `f` and `i`. However, since they are not merged, clang should not
+// assert for that.
+
+template 
+struct Number
+{
+   static constexpr unsigned value = v;
+};
+
+template 
+constexpr auto fun1(Number = Number<0>{}, Number  = Number<1>{})
+{
+  constexpr unsigned a = 0;
+  auto f = [&](auto fs, auto i) {
+if constexpr(i.value > 0)
+{
+  (void)a;
+  return fs(fs, Number{});
+}
+(void)a;
+  };
+
+  return f(f, Number{});
+}
+
+
+void fun2() {
+  fun1();
+}
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -4890,10 +4890,13 @@
   // Introduce a new scope where local variable instantiations will be
   // recorded, unless we're actually a member function within a local
   // class, in which case we need to merge our results with the parent
-  // scope (of the enclosing function).
+  // scope (of the enclosing function). The exception is instantiating
+  // a function template specialization, since the template to be
+  // instantiated already has references to locals properly substituted.
   bool MergeWithParentScope = false;
   if (CXXRecordDecl *Rec = dyn_cast(Function->getDeclContext()))
-MergeWithParentScope = Rec->isLocalClass();
+MergeWithParentScope =
+Rec->isLocalClass() && !Function->isFunctionTemplateSpecialization();
 
   LocalInstantiationScope Scope(*this, MergeWithParentScope);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 79f9cfb - Do not merge LocalInstantiationScope for template specialization

2021-06-14 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2021-06-14T23:28:04-04:00
New Revision: 79f9cfbc21e02555258523ea77c3dd389891cfb3

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

LOG: Do not merge LocalInstantiationScope for template specialization

A lambda in a function template may be recursively instantiated. The recursive
lambda will cause a lambda function instantiated multiple times, one inside 
another.
The inner LocalInstantiationScope should not be marked as MergeWithParentScope
since it already has references to locals properly substituted, otherwise it 
causes
assertion due to the check for duplicate locals in merged 
LocalInstantiationScope.

Reviewed by: Richard Smith

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

Added: 
clang/test/SemaCXX/recursive-lambda.cpp

Modified: 
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp 
b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index 8de09def4d52a..b2590d3deaad7 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -4890,10 +4890,13 @@ void Sema::InstantiateFunctionDefinition(SourceLocation 
PointOfInstantiation,
   // Introduce a new scope where local variable instantiations will be
   // recorded, unless we're actually a member function within a local
   // class, in which case we need to merge our results with the parent
-  // scope (of the enclosing function).
+  // scope (of the enclosing function). The exception is instantiating
+  // a function template specialization, since the template to be
+  // instantiated already has references to locals properly substituted.
   bool MergeWithParentScope = false;
   if (CXXRecordDecl *Rec = dyn_cast(Function->getDeclContext()))
-MergeWithParentScope = Rec->isLocalClass();
+MergeWithParentScope =
+Rec->isLocalClass() && !Function->isFunctionTemplateSpecialization();
 
   LocalInstantiationScope Scope(*this, MergeWithParentScope);
 

diff  --git a/clang/test/SemaCXX/recursive-lambda.cpp 
b/clang/test/SemaCXX/recursive-lambda.cpp
new file mode 100644
index 0..58087628db988
--- /dev/null
+++ b/clang/test/SemaCXX/recursive-lambda.cpp
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify %s
+
+// expected-no-diagnostics
+
+// Check recursive instantiation of lambda does not cause assertion.
+// lambda function `f` in `fun1` is instantiated twice: first
+// as f(f, Number<1>), then as f(f, Number<0>). The
+// LocalInstantiationScopes of these two instantiations both contain
+// `f` and `i`. However, since they are not merged, clang should not
+// assert for that.
+
+template 
+struct Number
+{
+   static constexpr unsigned value = v;
+};
+
+template 
+constexpr auto fun1(Number = Number<0>{}, Number  = Number<1>{})
+{
+  constexpr unsigned a = 0;
+  auto f = [&](auto fs, auto i) {
+if constexpr(i.value > 0)
+{
+  (void)a;
+  return fs(fs, Number{});
+}
+(void)a;
+  };
+
+  return f(f, Number{});
+}
+
+
+void fun2() {
+  fun1();
+}



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


[PATCH] D101868: [clang-format] Adds a formatter for aligning arrays of structs

2021-06-14 Thread Fred Grim via Phabricator via cfe-commits
feg208 added inline comments.



Comment at: clang/test/Format/struct-array-initializer.cpp:5
+// RUN: grep -Ev "// *[A-Z-]+:" %s \
+// RUN:   | clang-format -style="{BasedOnStyle: LLVM, AlignArrayOfStructures: 
Left}" %s \
+// RUN:   | FileCheck -strict-whitespace -check-prefix=CHECK2 %s

vitalybuka wrote:
> This test is very flaky https://lab.llvm.org/buildbot/#/builders/109 
> 
> ```
>  TEST 'Clang :: Format/struct-array-initializer.cpp' 
> FAILED 
> Script:
> --
> : 'RUN: at line 1';   grep -Ev "// *[A-Z-]+:" 
> /b/1/clang-x86_64-debian-fast/llvm.src/clang/test/Format/struct-array-initializer.cpp
> | /b/1/clang-x86_64-debian-fast/llvm.obj/bin/clang-format 
> -style="{BasedOnStyle: LLVM, AlignArrayOfStructures: Right}" 
> /b/1/clang-x86_64-debian-fast/llvm.src/clang/test/Format/struct-array-initializer.cpp
> | /b/1/clang-x86_64-debian-fast/llvm.obj/bin/FileCheck -strict-whitespace 
> -check-prefix=CHECK1 
> /b/1/clang-x86_64-debian-fast/llvm.src/clang/test/Format/struct-array-initializer.cpp
> : 'RUN: at line 4';   grep -Ev "// *[A-Z-]+:" 
> /b/1/clang-x86_64-debian-fast/llvm.src/clang/test/Format/struct-array-initializer.cpp
> | /b/1/clang-x86_64-debian-fast/llvm.obj/bin/clang-format 
> -style="{BasedOnStyle: LLVM, AlignArrayOfStructures: Left}" 
> /b/1/clang-x86_64-debian-fast/llvm.src/clang/test/Format/struct-array-initializer.cpp
> | /b/1/clang-x86_64-debian-fast/llvm.obj/bin/FileCheck -strict-whitespace 
> -check-prefix=CHECK2 
> /b/1/clang-x86_64-debian-fast/llvm.src/clang/test/Format/struct-array-initializer.cpp
> --
> Exit Code: 141
> Command Output (stderr):
> --
> + : 'RUN: at line 1'
> + /b/1/clang-x86_64-debian-fast/llvm.obj/bin/clang-format 
> '-style={BasedOnStyle: LLVM, AlignArrayOfStructures: Right}' 
> /b/1/clang-x86_64-debian-fast/llvm.src/clang/test/Format/struct-array-initializer.cpp
> + grep -Ev '// *[A-Z-]+:' 
> /b/1/clang-x86_64-debian-fast/llvm.src/clang/test/Format/struct-array-initializer.cpp
> + /b/1/clang-x86_64-debian-fast/llvm.obj/bin/FileCheck -strict-whitespace 
> -check-prefix=CHECK1 
> /b/1/clang-x86_64-debian-fast/llvm.src/clang/test/Format/struct-array-initializer.cpp
> --
> 
> ```
Yeah. I added you to a review to alter it to something I think will be less of 
an issue. Thanks by the by for getting the unused NetWidth variable


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101868

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


[PATCH] D104275: [compiler-rt][hwasan] Add SHADOW_OFFSET macro

2021-06-14 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan created this revision.
leonardchan added reviewers: vitalybuka, eugenis.
leonardchan added a project: Sanitizers.
Herald added a subscriber: dberris.
leonardchan requested review of this revision.
Herald added a subscriber: Sanitizers.

Similar to `SHADOW_OFFSET` on asan, we can use this for hwasan so platforms 
that use a constant value for the start of shadow memory can just use the 
constant rather than access a global.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D104275

Files:
  compiler-rt/lib/hwasan/hwasan_allocator.h
  compiler-rt/lib/hwasan/hwasan_mapping.h


Index: compiler-rt/lib/hwasan/hwasan_mapping.h
===
--- compiler-rt/lib/hwasan/hwasan_mapping.h
+++ compiler-rt/lib/hwasan/hwasan_mapping.h
@@ -37,6 +37,12 @@
 constexpr uptr kShadowScale = 4;
 constexpr uptr kShadowAlignment = 1ULL << kShadowScale;
 
+#if SANITIZER_FUCHSIA
+#  define SHADOW_OFFSET (0)
+#else
+#  define SHADOW_OFFSET __hwasan_shadow_memory_dynamic_address
+#endif
+
 namespace __hwasan {
 
 extern uptr kLowMemStart;
@@ -51,11 +57,10 @@
 extern uptr kAliasRegionStart;
 
 inline uptr MemToShadow(uptr untagged_addr) {
-  return (untagged_addr >> kShadowScale) +
- __hwasan_shadow_memory_dynamic_address;
+  return (untagged_addr >> kShadowScale) + SHADOW_OFFSET
 }
 inline uptr ShadowToMem(uptr shadow_addr) {
-  return (shadow_addr - __hwasan_shadow_memory_dynamic_address) << 
kShadowScale;
+  return (shadow_addr - SHADOW_OFFSET) << kShadowScale;
 }
 inline uptr MemToShadowSize(uptr size) {
   return size >> kShadowScale;
Index: compiler-rt/lib/hwasan/hwasan_allocator.h
===
--- compiler-rt/lib/hwasan/hwasan_allocator.h
+++ compiler-rt/lib/hwasan/hwasan_allocator.h
@@ -114,7 +114,7 @@
   // Aliases are mapped next to shadow so that the upper bits match the shadow
   // base.
   return (addr >> kTaggableRegionCheckShift) ==
- (__hwasan_shadow_memory_dynamic_address >> kTaggableRegionCheckShift);
+ (SHADOW_OFFSET >> kTaggableRegionCheckShift);
 #endif
   return true;
 }


Index: compiler-rt/lib/hwasan/hwasan_mapping.h
===
--- compiler-rt/lib/hwasan/hwasan_mapping.h
+++ compiler-rt/lib/hwasan/hwasan_mapping.h
@@ -37,6 +37,12 @@
 constexpr uptr kShadowScale = 4;
 constexpr uptr kShadowAlignment = 1ULL << kShadowScale;
 
+#if SANITIZER_FUCHSIA
+#  define SHADOW_OFFSET (0)
+#else
+#  define SHADOW_OFFSET __hwasan_shadow_memory_dynamic_address
+#endif
+
 namespace __hwasan {
 
 extern uptr kLowMemStart;
@@ -51,11 +57,10 @@
 extern uptr kAliasRegionStart;
 
 inline uptr MemToShadow(uptr untagged_addr) {
-  return (untagged_addr >> kShadowScale) +
- __hwasan_shadow_memory_dynamic_address;
+  return (untagged_addr >> kShadowScale) + SHADOW_OFFSET
 }
 inline uptr ShadowToMem(uptr shadow_addr) {
-  return (shadow_addr - __hwasan_shadow_memory_dynamic_address) << kShadowScale;
+  return (shadow_addr - SHADOW_OFFSET) << kShadowScale;
 }
 inline uptr MemToShadowSize(uptr size) {
   return size >> kShadowScale;
Index: compiler-rt/lib/hwasan/hwasan_allocator.h
===
--- compiler-rt/lib/hwasan/hwasan_allocator.h
+++ compiler-rt/lib/hwasan/hwasan_allocator.h
@@ -114,7 +114,7 @@
   // Aliases are mapped next to shadow so that the upper bits match the shadow
   // base.
   return (addr >> kTaggableRegionCheckShift) ==
- (__hwasan_shadow_memory_dynamic_address >> kTaggableRegionCheckShift);
+ (SHADOW_OFFSET >> kTaggableRegionCheckShift);
 #endif
   return true;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D101868: [clang-format] Adds a formatter for aligning arrays of structs

2021-06-14 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added inline comments.



Comment at: clang/test/Format/struct-array-initializer.cpp:5
+// RUN: grep -Ev "// *[A-Z-]+:" %s \
+// RUN:   | clang-format -style="{BasedOnStyle: LLVM, AlignArrayOfStructures: 
Left}" %s \
+// RUN:   | FileCheck -strict-whitespace -check-prefix=CHECK2 %s

This test is very flaky https://lab.llvm.org/buildbot/#/builders/109 

```
 TEST 'Clang :: Format/struct-array-initializer.cpp' FAILED 

Script:
--
: 'RUN: at line 1';   grep -Ev "// *[A-Z-]+:" 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/Format/struct-array-initializer.cpp
| /b/1/clang-x86_64-debian-fast/llvm.obj/bin/clang-format 
-style="{BasedOnStyle: LLVM, AlignArrayOfStructures: Right}" 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/Format/struct-array-initializer.cpp
| /b/1/clang-x86_64-debian-fast/llvm.obj/bin/FileCheck -strict-whitespace 
-check-prefix=CHECK1 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/Format/struct-array-initializer.cpp
: 'RUN: at line 4';   grep -Ev "// *[A-Z-]+:" 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/Format/struct-array-initializer.cpp
| /b/1/clang-x86_64-debian-fast/llvm.obj/bin/clang-format 
-style="{BasedOnStyle: LLVM, AlignArrayOfStructures: Left}" 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/Format/struct-array-initializer.cpp
| /b/1/clang-x86_64-debian-fast/llvm.obj/bin/FileCheck -strict-whitespace 
-check-prefix=CHECK2 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/Format/struct-array-initializer.cpp
--
Exit Code: 141
Command Output (stderr):
--
+ : 'RUN: at line 1'
+ /b/1/clang-x86_64-debian-fast/llvm.obj/bin/clang-format 
'-style={BasedOnStyle: LLVM, AlignArrayOfStructures: Right}' 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/Format/struct-array-initializer.cpp
+ grep -Ev '// *[A-Z-]+:' 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/Format/struct-array-initializer.cpp
+ /b/1/clang-x86_64-debian-fast/llvm.obj/bin/FileCheck -strict-whitespace 
-check-prefix=CHECK1 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/Format/struct-array-initializer.cpp
--

```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101868

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


[PATCH] D104118: [OpenCL] Use DW_LANG_OpenCL language tag for OpenCL C

2021-06-14 Thread ChenZheng via Phabricator via cfe-commits
shchenz added inline comments.



Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:579
 LangTag = llvm::dwarf::DW_LANG_ObjC;
+  } else if (LO.OpenCL && CGM.getCodeGenOpts().DwarfVersion >= 5) {
+LangTag = llvm::dwarf::DW_LANG_OpenCL;

I think for non-strict DWARF mode, we still can generate `DW_LANG_OpenCL` for 
the DWARF version lower than 5? Seems we also need to fix above 
`DW_LANG_C_plus_plus_14` and `DW_LANG_C_plus_plus_11`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104118

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


[clang] b8919fb - [NFC][sanitizer] clang-format some code

2021-06-14 Thread Vitaly Buka via cfe-commits

Author: Vitaly Buka
Date: 2021-06-14T18:05:22-07:00
New Revision: b8919fb0eac15d13c5f56d3d30ce378a588dd78c

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

LOG: [NFC][sanitizer] clang-format some code

Added: 


Modified: 
clang/lib/Driver/ToolChains/CommonArgs.cpp
compiler-rt/lib/asan/asan_interceptors.cpp
compiler-rt/lib/asan/asan_internal.h
compiler-rt/lib/asan/asan_malloc_linux.cpp
compiler-rt/lib/asan/asan_mapping.h
compiler-rt/lib/asan/asan_mapping_myriad.h
compiler-rt/lib/asan/asan_new_delete.cpp
compiler-rt/lib/asan/asan_poisoning.cpp
compiler-rt/lib/asan/asan_rtl.cpp
compiler-rt/lib/asan/asan_shadow_setup.cpp
compiler-rt/lib/interception/interception.h
compiler-rt/lib/sanitizer_common/sanitizer_errno.h
compiler-rt/lib/sanitizer_common/sanitizer_platform.h
compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h
compiler-rt/lib/sanitizer_common/sanitizer_stacktrace.h
compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_markup.cpp
compiler-rt/lib/ubsan/ubsan_platform.h
llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index a1aab21c944ba..c123625bb817c 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -771,10 +771,9 @@ void tools::linkSanitizerRuntimeDeps(const ToolChain ,
   }
   CmdArgs.push_back("-lm");
   // There's no libdl on all OSes.
-  if (!TC.getTriple().isOSFreeBSD() &&
-  !TC.getTriple().isOSNetBSD() &&
+  if (!TC.getTriple().isOSFreeBSD() && !TC.getTriple().isOSNetBSD() &&
   !TC.getTriple().isOSOpenBSD() &&
-   TC.getTriple().getOS() != llvm::Triple::RTEMS)
+  TC.getTriple().getOS() != llvm::Triple::RTEMS)
 CmdArgs.push_back("-ldl");
   // Required for backtrace on some OSes
   if (TC.getTriple().isOSFreeBSD() ||

diff  --git a/compiler-rt/lib/asan/asan_interceptors.cpp 
b/compiler-rt/lib/asan/asan_interceptors.cpp
index 9db7db89fa1a1..6182400ce783c 100644
--- a/compiler-rt/lib/asan/asan_interceptors.cpp
+++ b/compiler-rt/lib/asan/asan_interceptors.cpp
@@ -28,20 +28,20 @@
 // really defined to replace libc functions.
 #if !SANITIZER_FUCHSIA && !SANITIZER_RTEMS
 
-#if SANITIZER_POSIX
-#include "sanitizer_common/sanitizer_posix.h"
-#endif
+#  if SANITIZER_POSIX
+#include "sanitizer_common/sanitizer_posix.h"
+#  endif
 
-#if ASAN_INTERCEPT__UNWIND_RAISEEXCEPTION || \
-ASAN_INTERCEPT__SJLJ_UNWIND_RAISEEXCEPTION
-#include 
-#endif
+#  if ASAN_INTERCEPT__UNWIND_RAISEEXCEPTION || \
+  ASAN_INTERCEPT__SJLJ_UNWIND_RAISEEXCEPTION
+#include 
+#  endif
 
-#if defined(__i386) && SANITIZER_LINUX
-#define ASAN_PTHREAD_CREATE_VERSION "GLIBC_2.1"
-#elif defined(__mips__) && SANITIZER_LINUX
-#define ASAN_PTHREAD_CREATE_VERSION "GLIBC_2.2"
-#endif
+#  if defined(__i386) && SANITIZER_LINUX
+#define ASAN_PTHREAD_CREATE_VERSION "GLIBC_2.1"
+#  elif defined(__mips__) && SANITIZER_LINUX
+#define ASAN_PTHREAD_CREATE_VERSION "GLIBC_2.2"
+#  endif
 
 namespace __asan {
 

diff  --git a/compiler-rt/lib/asan/asan_internal.h 
b/compiler-rt/lib/asan/asan_internal.h
index cfb54927c6cf4..e9c1c5a325f35 100644
--- a/compiler-rt/lib/asan/asan_internal.h
+++ b/compiler-rt/lib/asan/asan_internal.h
@@ -35,11 +35,11 @@
 // If set, values like allocator chunk size, as well as defaults for some flags
 // will be changed towards less memory overhead.
 #ifndef ASAN_LOW_MEMORY
-# if SANITIZER_IOS || SANITIZER_ANDROID || SANITIZER_RTEMS
-#  define ASAN_LOW_MEMORY 1
-# else
-#  define ASAN_LOW_MEMORY 0
-# endif
+#  if SANITIZER_IOS || SANITIZER_ANDROID || SANITIZER_RTEMS
+#define ASAN_LOW_MEMORY 1
+#  else
+#define ASAN_LOW_MEMORY 0
+#  endif
 #endif
 
 #ifndef ASAN_DYNAMIC

diff  --git a/compiler-rt/lib/asan/asan_malloc_linux.cpp 
b/compiler-rt/lib/asan/asan_malloc_linux.cpp
index 9c3f0a5338ee5..b15b32e5699c4 100644
--- a/compiler-rt/lib/asan/asan_malloc_linux.cpp
+++ b/compiler-rt/lib/asan/asan_malloc_linux.cpp
@@ -17,14 +17,14 @@
 #if SANITIZER_FREEBSD || SANITIZER_FUCHSIA || SANITIZER_LINUX || \
 SANITIZER_NETBSD || SANITIZER_RTEMS || SANITIZER_SOLARIS
 
-#include "sanitizer_common/sanitizer_allocator_checks.h"
-#include "sanitizer_common/sanitizer_errno.h"
-#include "sanitizer_common/sanitizer_tls_get_addr.h"
-#include "asan_allocator.h"
-#include "asan_interceptors.h"
-#include "asan_internal.h"
-#include "asan_malloc_local.h"
-#include "asan_stack.h"
+#  include "asan_allocator.h"
+#  include "asan_interceptors.h"
+#  include "asan_internal.h"
+#  include "asan_malloc_local.h"
+#  include "asan_stack.h"
+#  include "sanitizer_common/sanitizer_allocator_checks.h"
+#  include 

[PATCH] D103845: [compiler-rt][hwasan] Add newline between record_addr lines on frame record dumps

2021-06-14 Thread Leonard Chan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG312011899ac3: [compiler-rt][hwasan] Add newline between 
record_addr lines on frame record… (authored by leonardchan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103845

Files:
  compiler-rt/lib/hwasan/hwasan_report.cpp


Index: compiler-rt/lib/hwasan/hwasan_report.cpp
===
--- compiler-rt/lib/hwasan/hwasan_report.cpp
+++ compiler-rt/lib/hwasan/hwasan_report.cpp
@@ -236,12 +236,12 @@
 frame_desc.append("  record_addr:0x%zx record:0x%zx",
   reinterpret_cast(record_addr), record);
 if (SymbolizedStack *frame = Symbolizer::GetOrInit()->SymbolizePC(pc)) {
-  RenderFrame(_desc, " %F %L\n", 0, frame->info.address, 
>info,
+  RenderFrame(_desc, " %F %L", 0, frame->info.address, >info,
   common_flags()->symbolize_vs_style,
   common_flags()->strip_path_prefix);
   frame->ClearAll();
 }
-Printf("%s", frame_desc.data());
+Printf("%s\n", frame_desc.data());
 frame_desc.clear();
   }
 }


Index: compiler-rt/lib/hwasan/hwasan_report.cpp
===
--- compiler-rt/lib/hwasan/hwasan_report.cpp
+++ compiler-rt/lib/hwasan/hwasan_report.cpp
@@ -236,12 +236,12 @@
 frame_desc.append("  record_addr:0x%zx record:0x%zx",
   reinterpret_cast(record_addr), record);
 if (SymbolizedStack *frame = Symbolizer::GetOrInit()->SymbolizePC(pc)) {
-  RenderFrame(_desc, " %F %L\n", 0, frame->info.address, >info,
+  RenderFrame(_desc, " %F %L", 0, frame->info.address, >info,
   common_flags()->symbolize_vs_style,
   common_flags()->strip_path_prefix);
   frame->ClearAll();
 }
-Printf("%s", frame_desc.data());
+Printf("%s\n", frame_desc.data());
 frame_desc.clear();
   }
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D104082: [CodeGen] Don't create a fake FunctionDecl when generating block/block_byref copy/dispose helper functions

2021-06-14 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

C++ non-virtual thunks and global initialization functions (`_GLOBAL__sub_I_*`) 
have only linkage names.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104082

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


Re: [PATCH] D104099: [NewPM] Remove SpeculateAroundPHIs pass from pipeline

2021-06-14 Thread Wei Mi via cfe-commits
On Mon, Jun 14, 2021 at 4:04 PM Xinliang David Li 
wrote:

>
>
> On Mon, Jun 14, 2021 at 3:59 PM Roman Lebedev via Phabricator <
> revi...@reviews.llvm.org> wrote:
>
>> lebedev.ri added a subscriber: MaskRay.
>> lebedev.ri added a comment.
>>
>> In D104099#2815531 , @wenlei
>> wrote:
>>
>> > In D104099#2814167 ,
>> @davidxl wrote:
>> >
>> >> Adding Wei to help measure performance impact on our internal
>> workloads.  Also add Wenlei to help measure impact with FB's workloads.
>> >
>> > Measured perf using FB internal workload w/ and w/o this pass, result
>> is neutral.
>>
>> Thank you for checking!
>>
>> So far, it seems the reaction to this proposal has been overwhelmingly
>> positive.
>> Does anyone else wish to chime in? Should i land this? @asbirlea @MaskRay
>> ?
>>
>
> Wei is doing more measurement @google. Please wait for the response.
>
> David
>

Start doing the test. Will report back.

Wei.


>
>
>>
>> Repository:
>>   rG LLVM Github Monorepo
>>
>> CHANGES SINCE LAST ACTION
>>   https://reviews.llvm.org/D104099/new/
>>
>> https://reviews.llvm.org/D104099
>>
>>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D104248: [compiler-rt][hwasan] Refactor Thread::Init

2021-06-14 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 352015.
leonardchan marked an inline comment as not done.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104248

Files:
  compiler-rt/lib/hwasan/hwasan_linux.cpp
  compiler-rt/lib/hwasan/hwasan_thread.cpp
  compiler-rt/lib/hwasan/hwasan_thread.h


Index: compiler-rt/lib/hwasan/hwasan_thread.h
===
--- compiler-rt/lib/hwasan/hwasan_thread.h
+++ compiler-rt/lib/hwasan/hwasan_thread.h
@@ -23,8 +23,13 @@
 
 class Thread {
  public:
-  void Init(uptr stack_buffer_start, uptr stack_buffer_size);  // Must be 
called from the thread itself.
+  void Init(uptr stack_buffer_start, uptr stack_buffer_size);
   void InitRandomState();
+  void InitStackAndTls();
+
+  // Must be called from the thread itself.
+  void InitStackRingBuffer(uptr stack_buffer_start, uptr stack_buffer_size);
+
   void Destroy();
 
   uptr stack_top() { return stack_top_; }
Index: compiler-rt/lib/hwasan/hwasan_thread.cpp
===
--- compiler-rt/lib/hwasan/hwasan_thread.cpp
+++ compiler-rt/lib/hwasan/hwasan_thread.cpp
@@ -44,6 +44,11 @@
   if (auto sz = flags()->heap_history_size)
 heap_allocations_ = HeapAllocationsRingBuffer::New(sz);
 
+  InitStackAndTls();
+  InitStackRingBuffer(stack_buffer_start, stack_buffer_size);
+}
+
+void Thread::InitStackRingBuffer(uptr stack_buffer_start, uptr 
stack_buffer_size) {
   HwasanTSDThreadInit();  // Only needed with interceptors.
   uptr *ThreadLong = GetCurrentThreadLongPtr();
   // The following implicitly sets (this) as the current thread.
@@ -55,13 +60,6 @@
   // ScopedTaggingDisable needs GetCurrentThread to be set up.
   ScopedTaggingDisabler disabler;
 
-  uptr tls_size;
-  uptr stack_size;
-  GetThreadStackAndTls(IsMainThread(), _bottom_, _size, 
_begin_,
-   _size);
-  stack_top_ = stack_bottom_ + stack_size;
-  tls_end_ = tls_begin_ + tls_size;
-
   if (stack_bottom_) {
 int local;
 CHECK(AddrIsInStack((uptr)));
Index: compiler-rt/lib/hwasan/hwasan_linux.cpp
===
--- compiler-rt/lib/hwasan/hwasan_linux.cpp
+++ compiler-rt/lib/hwasan/hwasan_linux.cpp
@@ -427,6 +427,14 @@
   HandleDeadlySignal(info, context, GetTid(), , nullptr);
 }
 
+void Thread::InitStackAndTls() {
+  uptr tls_size;
+  uptr stack_size;
+  GetThreadStackAndTls(IsMainThread(), _bottom_, _size, 
_begin_,
+   _size);
+  stack_top_ = stack_bottom_ + stack_size;
+  tls_end_ = tls_begin_ + tls_size;
+}
 
 } // namespace __hwasan
 


Index: compiler-rt/lib/hwasan/hwasan_thread.h
===
--- compiler-rt/lib/hwasan/hwasan_thread.h
+++ compiler-rt/lib/hwasan/hwasan_thread.h
@@ -23,8 +23,13 @@
 
 class Thread {
  public:
-  void Init(uptr stack_buffer_start, uptr stack_buffer_size);  // Must be called from the thread itself.
+  void Init(uptr stack_buffer_start, uptr stack_buffer_size);
   void InitRandomState();
+  void InitStackAndTls();
+
+  // Must be called from the thread itself.
+  void InitStackRingBuffer(uptr stack_buffer_start, uptr stack_buffer_size);
+
   void Destroy();
 
   uptr stack_top() { return stack_top_; }
Index: compiler-rt/lib/hwasan/hwasan_thread.cpp
===
--- compiler-rt/lib/hwasan/hwasan_thread.cpp
+++ compiler-rt/lib/hwasan/hwasan_thread.cpp
@@ -44,6 +44,11 @@
   if (auto sz = flags()->heap_history_size)
 heap_allocations_ = HeapAllocationsRingBuffer::New(sz);
 
+  InitStackAndTls();
+  InitStackRingBuffer(stack_buffer_start, stack_buffer_size);
+}
+
+void Thread::InitStackRingBuffer(uptr stack_buffer_start, uptr stack_buffer_size) {
   HwasanTSDThreadInit();  // Only needed with interceptors.
   uptr *ThreadLong = GetCurrentThreadLongPtr();
   // The following implicitly sets (this) as the current thread.
@@ -55,13 +60,6 @@
   // ScopedTaggingDisable needs GetCurrentThread to be set up.
   ScopedTaggingDisabler disabler;
 
-  uptr tls_size;
-  uptr stack_size;
-  GetThreadStackAndTls(IsMainThread(), _bottom_, _size, _begin_,
-   _size);
-  stack_top_ = stack_bottom_ + stack_size;
-  tls_end_ = tls_begin_ + tls_size;
-
   if (stack_bottom_) {
 int local;
 CHECK(AddrIsInStack((uptr)));
Index: compiler-rt/lib/hwasan/hwasan_linux.cpp
===
--- compiler-rt/lib/hwasan/hwasan_linux.cpp
+++ compiler-rt/lib/hwasan/hwasan_linux.cpp
@@ -427,6 +427,14 @@
   HandleDeadlySignal(info, context, GetTid(), , nullptr);
 }
 
+void Thread::InitStackAndTls() {
+  uptr tls_size;
+  uptr stack_size;
+  GetThreadStackAndTls(IsMainThread(), _bottom_, _size, _begin_,
+   _size);
+  stack_top_ = stack_bottom_ + stack_size;
+  tls_end_ = tls_begin_ 

Re: [PATCH] D104099: [NewPM] Remove SpeculateAroundPHIs pass from pipeline

2021-06-14 Thread Xinliang David Li via cfe-commits
On Mon, Jun 14, 2021 at 3:59 PM Roman Lebedev via Phabricator <
revi...@reviews.llvm.org> wrote:

> lebedev.ri added a subscriber: MaskRay.
> lebedev.ri added a comment.
>
> In D104099#2815531 , @wenlei
> wrote:
>
> > In D104099#2814167 , @davidxl
> wrote:
> >
> >> Adding Wei to help measure performance impact on our internal
> workloads.  Also add Wenlei to help measure impact with FB's workloads.
> >
> > Measured perf using FB internal workload w/ and w/o this pass, result is
> neutral.
>
> Thank you for checking!
>
> So far, it seems the reaction to this proposal has been overwhelmingly
> positive.
> Does anyone else wish to chime in? Should i land this? @asbirlea @MaskRay ?
>

Wei is doing more measurement @google. Please wait for the response.

David


>
> Repository:
>   rG LLVM Github Monorepo
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D104099/new/
>
> https://reviews.llvm.org/D104099
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D104099: [NewPM] Remove SpeculateAroundPHIs pass from pipeline

2021-06-14 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a subscriber: MaskRay.
lebedev.ri added a comment.

In D104099#2815531 , @wenlei wrote:

> In D104099#2814167 , @davidxl wrote:
>
>> Adding Wei to help measure performance impact on our internal workloads.  
>> Also add Wenlei to help measure impact with FB's workloads.
>
> Measured perf using FB internal workload w/ and w/o this pass, result is 
> neutral.

Thank you for checking!

So far, it seems the reaction to this proposal has been overwhelmingly positive.
Does anyone else wish to chime in? Should i land this? @asbirlea @MaskRay ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104099

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


[PATCH] D97085: [OpenMP] libomp: implement OpenMP 5.1 inoutset task dependence type

2021-06-14 Thread Andrey Churbanov via Phabricator via cfe-commits
AndreyChurbanov updated this revision to Diff 352010.
AndreyChurbanov added a comment.

Fixed backwards compatibility problem introduced by previous version of the 
patch.
That is restored the size of task dependence flag to 8 bits in clang, and 
instead changed the size of the flag in the library from 32 to 8 bits.
Fixed two tests so that they set all 8 bits of the flag.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97085

Files:
  openmp/runtime/src/kmp.h
  openmp/runtime/src/kmp_taskdeps.cpp
  openmp/runtime/src/kmp_taskdeps.h
  openmp/runtime/test/tasking/hidden_helper_task/common.h
  openmp/runtime/test/tasking/hidden_helper_task/depend.cpp
  openmp/runtime/test/tasking/hidden_helper_task/gtid.cpp
  openmp/runtime/test/tasking/omp51_task_dep_inoutset.c

Index: openmp/runtime/test/tasking/omp51_task_dep_inoutset.c
===
--- /dev/null
+++ openmp/runtime/test/tasking/omp51_task_dep_inoutset.c
@@ -0,0 +1,258 @@
+// RUN: %libomp-compile-and-run
+// RUN: %libomp-cxx-compile-and-run
+// UNSUPPORTED: gcc
+
+// Tests OMP 5.0 task dependences "mutexinoutset" and 5.1 "inoutset",
+// emulates compiler codegen for new dep kinds
+// Mutually exclusive tasks get same input dependency info array
+//
+// Task tree created:
+//  task0 - task1 (in)
+// \
+//task2 - task3 (inoutset)
+// /
+//  task3 - task4 (in)
+//   /
+//  task6 <-->task7  (mutexinoutset)
+//   \/
+//   task8 (in)
+//
+#include 
+#include 
+
+#ifdef _WIN32
+#include 
+#define mysleep(n) Sleep(n)
+#else
+#include 
+#define mysleep(n) usleep((n)*1000)
+#endif
+
+// to check the # of concurrent tasks (must be 1 for MTX, <3 for other kinds)
+static int volatile checker = 0;
+static int err = 0;
+#ifndef DELAY
+#define DELAY 100
+#endif
+
+// ---
+// internal data to emulate compiler codegen
+typedef struct DEP {
+  size_t addr;
+  size_t len;
+  unsigned char flags;
+} dep;
+typedef struct task {
+  void** shareds;
+  void* entry;
+  int part_id;
+  void* destr_thunk;
+  int priority;
+  long long device_id;
+  int f_priv;
+} task_t;
+#define TIED 1
+typedef int(*entry_t)(int, task_t*);
+typedef struct ID {
+  int reserved_1;
+  int flags;
+  int reserved_2;
+  int reserved_3;
+  char *psource;
+} id;
+// thunk routine for tasks with MTX dependency
+int thunk_m(int gtid, task_t* ptask) {
+  int th = omp_get_thread_num();
+  #pragma omp atomic
+++checker;
+  printf("task _%d, th %d\n", ptask->f_priv, th);
+  if (checker != 1) { // no more than 1 task at a time
+err++;
+printf("Error1, checker %d != 1\n", checker);
+  }
+  mysleep(DELAY);
+  if (checker != 1) { // no more than 1 task at a time
+err++;
+printf("Error2, checker %d != 1\n", checker);
+  }
+  #pragma omp atomic
+--checker;
+  return 0;
+}
+// thunk routine for tasks with inoutset dependency
+int thunk_s(int gtid, task_t* ptask) {
+  int th = omp_get_thread_num();
+  #pragma omp atomic
+++checker;
+  printf("task _%d, th %d\n", ptask->f_priv, th);
+  if (checker > 2) { // no more than 2 tasks concurrently
+err++;
+printf("Error1, checker %d > 2\n", checker);
+  }
+  mysleep(DELAY);
+  if (checker > 2) { // no more than 2 tasks concurrently
+err++;
+printf("Error2, checker %d > 2\n", checker);
+  }
+  #pragma omp atomic
+--checker;
+  return 0;
+}
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+int __kmpc_global_thread_num(id*);
+extern task_t* __kmpc_omp_task_alloc(id *loc, int gtid, int flags,
+ size_t sz, size_t shar, entry_t rtn);
+int
+__kmpc_omp_task_with_deps(id *loc, int gtid, task_t *task, int nd, dep *dep_lst,
+  int nd_noalias, dep *noalias_dep_lst);
+static id loc = {0, 2, 0, 0, ";file;func;0;0;;"};
+#ifdef __cplusplus
+} // extern "C"
+#endif
+// End of internal data
+// ---
+
+int main()
+{
+  int i1,i2,i3;
+  omp_set_num_threads(4);
+  omp_set_dynamic(0);
+  #pragma omp parallel
+  {
+#pragma omp single nowait
+{
+  dep sdep[2];
+  task_t *ptr;
+  int gtid = __kmpc_global_thread_num();
+  int t = omp_get_thread_num();
+  #pragma omp task depend(in: i1, i2)
+  { int th = omp_get_thread_num();
+printf("task 0_%d, th %d\n", t, th);
+#pragma omp atomic
+  ++checker;
+if (checker > 2) { // no more than 2 tasks concurrently
+  err++;
+  printf("Error1, checker %d > 2\n", checker);
+}
+mysleep(DELAY);
+if (checker > 2) { // no more than 2 tasks concurrently
+  err++;
+  printf("Error1, checker %d > 2\n", checker);
+}
+#pragma omp atomic
+  --checker;
+  }
+  #pragma omp task depend(in: i1, 

[PATCH] D104088: Add clang frontend flags for MIP

2021-06-14 Thread Ellis Hoag via Phabricator via cfe-commits
ellis updated this revision to Diff 352007.
ellis added a comment.

MIP does not support windows


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104088

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/lib/Driver/ToolChains/Darwin.h
  clang/lib/Driver/ToolChains/DragonFly.cpp
  clang/lib/Driver/ToolChains/FreeBSD.cpp
  clang/lib/Driver/ToolChains/Fuchsia.cpp
  clang/lib/Driver/ToolChains/Fuchsia.h
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/lib/Driver/ToolChains/Linux.h
  clang/lib/Driver/ToolChains/NetBSD.cpp
  clang/lib/Driver/ToolChains/Solaris.cpp
  clang/test/CMakeLists.txt
  clang/test/Driver/clang-mip-flags.c

Index: clang/test/Driver/clang-mip-flags.c
===
--- /dev/null
+++ clang/test/Driver/clang-mip-flags.c
@@ -0,0 +1,45 @@
+// REQUIRES: clang-driver
+// UNSUPPORTED: windows-msvc
+
+// RUN: %clang -### -fmachine-profile-use=/path/to/profile.mip %s 2>&1 | FileCheck %s --check-prefix USE
+// USE: "-cc1"
+// USE-SAME: "-mllvm" "-machine-profile-use=/path/to/profile.mip"
+// USE-SAME: "-mllvm" "-link-unit-name=a.out"
+
+// RUN: %clang -### -fmachine-profile-use=/path/to/profile.mip -o my-executable %s 2>&1 | FileCheck %s --check-prefix USE-OUTPUT
+// RUN: %clang -### -fmachine-profile-use=/path/to/profile.mip -fmachine-profile-link-unit-name=my-executable %s 2>&1 | FileCheck %s --check-prefix USE-OUTPUT
+// USE-OUTPUT: "-cc1"
+// USE-OUTPUT-SAME: "-mllvm" "-link-unit-name=my-executable"
+
+// RUN: %clang -### -fmachine-profile-generate %s 2>&1 | FileCheck %s --check-prefix GEN
+// RUN: %clang -### -fno-machine-profile-generate -fmachine-profile-generate %s 2>&1 | FileCheck %s --check-prefix GEN
+// GEN: "-cc1"
+// GEN-SAME: "-mllvm" "-enable-machine-instrumentation"
+// GEN-SAME: "-mllvm" "-link-unit-name=a.out"
+
+// RUN: %clang -### %s 2>&1 | FileCheck %s --check-prefix NOGEN
+// RUN: %clang -### -fno-machine-profile-generate %s 2>&1 | FileCheck %s --check-prefix NOGEN
+// RUN: %clang -### -fmachine-profile-generate -fno-machine-profile-generate %s 2>&1 | FileCheck %s --check-prefix NOGEN
+// NOGEN-NOT: "-enable-machine-instrumentation"
+
+// RUN: %clang -### -fmachine-profile-generate -fmachine-profile-function-coverage %s 2>&1 | FileCheck %s --check-prefix FUNCCOV
+// FUNCCOV: "-cc1"
+// FUNCCOV-SAME: "-mllvm" "-enable-machine-function-coverage"
+
+// RUN: %clang -### -fmachine-profile-generate -fmachine-profile-block-coverage %s 2>&1 | FileCheck %s --check-prefix BLOCKCOV
+// BLOCKCOV: "-cc1"
+// BLOCKCOV-SAME: "-mllvm" "-enable-machine-block-coverage"
+
+// RUN: %clang -### -fmachine-profile-generate %s 2>&1 | FileCheck %s --check-prefix FULL
+// RUN: %clang -### -fmachine-profile-generate -fmachine-profile-call-graph %s 2>&1 | FileCheck %s --check-prefix FULL
+// FULL: "-cc1"
+// FULL-SAME: "-mllvm" "-enable-machine-call-graph"
+
+// RUN: %clang -### -fmachine-profile-generate -fmachine-profile-runtime-buffer=1024 %s 2>&1 | FileCheck %s --check-prefix RUNTIMEBUF
+// RUNTIMEBUF: "-cc1"
+// RUNTIMEBUF-SAME: "-mllvm" "-machine-profile-runtime-buffer=1024"
+
+// RUN: %clang -### -fmachine-profile-generate -fmachine-profile-function-group-count=22 -fmachine-profile-selected-function-group=11 %s 2>&1 | FileCheck %s --check-prefix GEN-GROUPS
+// GEN-GROUPS: "-cc1"
+// GEN-GROUPS-SAME: "-mllvm" "-machine-profile-function-group-count=22"
+// GEN-GROUPS-SAME: "-mllvm" "-machine-profile-selected-function-group=11"
Index: clang/test/CMakeLists.txt
===
--- clang/test/CMakeLists.txt
+++ clang/test/CMakeLists.txt
@@ -118,6 +118,7 @@
 llvm-lto2
 llvm-modextract
 llvm-nm
+llvm-mipdata
 llvm-objcopy
 llvm-objdump
 llvm-profdata
Index: clang/lib/Driver/ToolChains/Solaris.cpp
===
--- clang/lib/Driver/ToolChains/Solaris.cpp
+++ clang/lib/Driver/ToolChains/Solaris.cpp
@@ -149,6 +149,7 @@
   CmdArgs.push_back(Args.MakeArgString(getToolChain().GetFilePath("crtn.o")));
 
   getToolChain().addProfileRTLibs(Args, CmdArgs);
+  getToolChain().addMachineProfileRTLibs(Args, CmdArgs);
 
   const char *Exec = Args.MakeArgString(getToolChain().GetLinkerPath());
   C.addCommand(std::make_unique(JA, *this, ResponseFileSupport::None(),
Index: clang/lib/Driver/ToolChains/NetBSD.cpp
===
--- clang/lib/Driver/ToolChains/NetBSD.cpp
+++ clang/lib/Driver/ToolChains/NetBSD.cpp
@@ -337,6 +337,7 @@
   }
 
   ToolChain.addProfileRTLibs(Args, CmdArgs);
+  ToolChain.addMachineProfileRTLibs(Args, CmdArgs);
 
   const char *Exec = 

[PATCH] D99696: [clang] NRVO: Improvements and handling of more cases.

2021-06-14 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added a comment.

In D99696#2817126 , @rjmccall wrote:

> When `__block` variables get moved to the heap, they're supposed to be moved 
> if possible, not copied.  It looks like PerformMoveOrCopyInitialization 
> requires NRVO info to be passed in to ever do a move.  Maybe it's being 
> passed in wrong when building `__block` copy expressions in some situation.

Found the culprit, that functionality was implemented in checkEscapingByref, 
and it was a bit of a shocker that such a thing was just hiding in a function 
with such an unassuming name :)
Also surprising to find here another user of the two-step overload resolution, 
that also escaped our radar.
There is a C++ proposal (P2266 ) to replace 
that mechanism with something much simpler.

So since this is an ObjectiveC thing, how is the semantics of this interaction 
defined, just in terms of C++ NRVO?
As this reuses `PerformMoveOrCopyInitialization`, it is also affected by the 
change going into C++20 where the restriction on only converting constructors 
was lifted. Was this accidental and nobody noticed?

For this patch I am going to revert to the original behavior, but I think this 
could be revisited in the future so it gets aligned with the C++2b rules after 
P2266 , which would be just having VarRef be an 
XValue unconditionally and perform the regular copy initialization.

> Was there really not a test case covering those semantics?

Nope...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99696

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


[clang] 0577f4b - [Hexagon] Add HVX and control register names to Hexagon target

2021-06-14 Thread Krzysztof Parzyszek via cfe-commits

Author: Krzysztof Parzyszek
Date: 2021-06-14T17:14:37-05:00
New Revision: 0577f4b1789eff410f5b28434a4f7854a50dc639

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

LOG: [Hexagon] Add HVX and control register names to Hexagon target

Added: 
clang/test/CodeGen/hexagon-inline-asm-reg-names.c

Modified: 
clang/lib/Basic/Targets/Hexagon.cpp

Removed: 




diff  --git a/clang/lib/Basic/Targets/Hexagon.cpp 
b/clang/lib/Basic/Targets/Hexagon.cpp
index d1613fb229307..9c37dee7e89a4 100644
--- a/clang/lib/Basic/Targets/Hexagon.cpp
+++ b/clang/lib/Basic/Targets/Hexagon.cpp
@@ -132,14 +132,37 @@ bool 
HexagonTargetInfo::handleTargetFeatures(std::vector ,
 }
 
 const char *const HexagonTargetInfo::GCCRegNames[] = {
-"r0",  "r1",  "r2",  "r3",  "r4",  "r5",  "r6",  "r7",  "r8",
-"r9",  "r10", "r11", "r12", "r13", "r14", "r15", "r16", "r17",
-"r18", "r19", "r20", "r21", "r22", "r23", "r24", "r25", "r26",
-"r27", "r28", "r29", "r30", "r31", "p0",  "p1",  "p2",  "p3",
-"sa0", "lc0", "sa1", "lc1", "m0",  "m1",  "usr", "ugp", "cs0", "cs1",
+// Scalar registers:
+"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11",
+"r12", "r13", "r14", "r15", "r16", "r17", "r18", "r19", "r20", "r21",
+"r22", "r23", "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31",
 "r1:0", "r3:2", "r5:4", "r7:6", "r9:8", "r11:10", "r13:12", "r15:14",
 "r17:16", "r19:18", "r21:20", "r23:22", "r25:24", "r27:26", "r29:28",
-"r31:30"
+"r31:30",
+// Predicate registers:
+"p0", "p1", "p2", "p3",
+// Control registers:
+"c0", "c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8", "c9", "c10", "c11",
+"c12", "c13", "c14", "c15", "c16", "c17", "c18", "c19", "c20", "c21",
+"c22", "c23", "c24", "c25", "c26", "c27", "c28", "c29", "c30", "c31",
+"c1:0", "c3:2", "c5:4", "c7:6", "c9:8", "c11:10", "c13:12", "c15:14",
+"c17:16", "c19:18", "c21:20", "c23:22", "c25:24", "c27:26", "c29:28",
+"c31:30",
+// Control register aliases:
+"sa0", "lc0", "sa1", "lc1", "p3:0", "m0",  "m1",  "usr", "pc", "ugp",
+"gp", "cs0", "cs1", "upcyclelo", "upcyclehi", "framelimit", "framekey",
+"pktcountlo", "pktcounthi", "utimerlo", "utimerhi",
+"upcycle", "pktcount", "utimer",
+// HVX vector registers:
+"v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", "v8", "v9", "v10", "v11",
+"v12", "v13", "v14", "v15", "v16", "v17", "v18", "v19", "v20", "v21",
+"v22", "v23", "v24", "v25", "v26", "v27", "v28", "v29", "v30", "v31",
+"v1:0", "v3:2", "v5:4", "v7:6", "v9:8", "v11:10", "v13:12", "v15:14",
+"v17:16", "v19:18", "v21:20", "v23:22", "v25:24", "v27:26", "v29:28",
+"v31:30",
+"v3:0", "v7:4", "v11:8", "v15:12", "v19:16", "v23:20", "v27:24", "v31:28",
+// HVX vector predicates:
+"q0", "q1", "q2", "q3",
 };
 
 ArrayRef HexagonTargetInfo::getGCCRegNames() const {

diff  --git a/clang/test/CodeGen/hexagon-inline-asm-reg-names.c 
b/clang/test/CodeGen/hexagon-inline-asm-reg-names.c
new file mode 100644
index 0..2a107eba613c7
--- /dev/null
+++ b/clang/test/CodeGen/hexagon-inline-asm-reg-names.c
@@ -0,0 +1,922 @@
+// RUN: %clang_cc1 -triple hexagon-unknown-elf -target-feature +hvx 
-target-feature +hvx-length128b -emit-llvm -o - %s | FileCheck %s
+
+void test_r0() {
+  // CHECK: define {{.*}}void @test_r0
+  // CHECK: call void asm sideeffect "nop", "~{r0}"()
+  asm("nop" ::: "r0");
+}
+void test_r1() {
+  // CHECK: define {{.*}}void @test_r1
+  // CHECK: call void asm sideeffect "nop", "~{r1}"()
+  asm("nop" ::: "r1");
+}
+void test_r2() {
+  // CHECK: define {{.*}}void @test_r2
+  // CHECK: call void asm sideeffect "nop", "~{r2}"()
+  asm("nop" ::: "r2");
+}
+void test_r3() {
+  // CHECK: define {{.*}}void @test_r3
+  // CHECK: call void asm sideeffect "nop", "~{r3}"()
+  asm("nop" ::: "r3");
+}
+void test_r4() {
+  // CHECK: define {{.*}}void @test_r4
+  // CHECK: call void asm sideeffect "nop", "~{r4}"()
+  asm("nop" ::: "r4");
+}
+void test_r5() {
+  // CHECK: define {{.*}}void @test_r5
+  // CHECK: call void asm sideeffect "nop", "~{r5}"()
+  asm("nop" ::: "r5");
+}
+void test_r6() {
+  // CHECK: define {{.*}}void @test_r6
+  // CHECK: call void asm sideeffect "nop", "~{r6}"()
+  asm("nop" ::: "r6");
+}
+void test_r7() {
+  // CHECK: define {{.*}}void @test_r7
+  // CHECK: call void asm sideeffect "nop", "~{r7}"()
+  asm("nop" ::: "r7");
+}
+void test_r8() {
+  // CHECK: define {{.*}}void @test_r8
+  // CHECK: call void asm sideeffect "nop", "~{r8}"()
+  asm("nop" ::: "r8");
+}
+void test_r9() {
+  // CHECK: define {{.*}}void @test_r9
+  // CHECK: call void asm sideeffect "nop", "~{r9}"()
+  asm("nop" ::: "r9");
+}
+void test_r10() {
+  // CHECK: define {{.*}}void @test_r10
+  // CHECK: call void asm 

[PATCH] D104258: [OPENMP]Fix PR50699: capture locals in combine directrives for aligned clause.

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

LG


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104258

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


[PATCH] D103845: [compiler-rt][hwasan] Add newline between record_addr lines on frame record dumps

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

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103845

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


[PATCH] D98068: Exampt asserts for recursive lambdas about LocalInstantiationScope

2021-06-14 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 351990.
yaxunl edited the summary of this revision.
yaxunl added a comment.

Revised by Richard's comments.


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

https://reviews.llvm.org/D98068

Files:
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/SemaCXX/recursive-lambda.cpp


Index: clang/test/SemaCXX/recursive-lambda.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/recursive-lambda.cpp
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify %s
+
+// expected-no-diagnostics
+
+// Check recursive instantiation of lambda does not cause assertion.
+// lambda function `f` in `fun1` is instantiated twice: first
+// as f(f, Number<1>), then as f(f, Number<0>). The
+// LocalInstantiationScopes of these two instantiations both contain
+// `f` and `i`. However, since they are not merged, clang should not
+// assert for that.
+
+template 
+struct Number
+{
+   static constexpr unsigned value = v;
+};
+
+template 
+constexpr auto fun1(Number = Number<0>{}, Number  = Number<1>{})
+{
+  constexpr unsigned a = 0;
+  auto f = [&](auto fs, auto i) {
+if constexpr(i.value > 0)
+{
+  (void)a;
+  return fs(fs, Number{});
+}
+(void)a;
+  };
+
+  return f(f, Number{});
+}
+
+
+void fun2() {
+  fun1();
+}
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -4890,10 +4890,13 @@
   // Introduce a new scope where local variable instantiations will be
   // recorded, unless we're actually a member function within a local
   // class, in which case we need to merge our results with the parent
-  // scope (of the enclosing function).
+  // scope (of the enclosing function). The exception is instantiating
+  // a function template specialization, since the template to be
+  // instantiated already has references to locals properly substituted.
   bool MergeWithParentScope = false;
   if (CXXRecordDecl *Rec = dyn_cast(Function->getDeclContext()))
-MergeWithParentScope = Rec->isLocalClass();
+MergeWithParentScope =
+Rec->isLocalClass() && !Function->isFunctionTemplateSpecialization();
 
   LocalInstantiationScope Scope(*this, MergeWithParentScope);
 


Index: clang/test/SemaCXX/recursive-lambda.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/recursive-lambda.cpp
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify %s
+
+// expected-no-diagnostics
+
+// Check recursive instantiation of lambda does not cause assertion.
+// lambda function `f` in `fun1` is instantiated twice: first
+// as f(f, Number<1>), then as f(f, Number<0>). The
+// LocalInstantiationScopes of these two instantiations both contain
+// `f` and `i`. However, since they are not merged, clang should not
+// assert for that.
+
+template 
+struct Number
+{
+   static constexpr unsigned value = v;
+};
+
+template 
+constexpr auto fun1(Number = Number<0>{}, Number  = Number<1>{})
+{
+  constexpr unsigned a = 0;
+  auto f = [&](auto fs, auto i) {
+if constexpr(i.value > 0)
+{
+  (void)a;
+  return fs(fs, Number{});
+}
+(void)a;
+  };
+
+  return f(f, Number{});
+}
+
+
+void fun2() {
+  fun1();
+}
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -4890,10 +4890,13 @@
   // Introduce a new scope where local variable instantiations will be
   // recorded, unless we're actually a member function within a local
   // class, in which case we need to merge our results with the parent
-  // scope (of the enclosing function).
+  // scope (of the enclosing function). The exception is instantiating
+  // a function template specialization, since the template to be
+  // instantiated already has references to locals properly substituted.
   bool MergeWithParentScope = false;
   if (CXXRecordDecl *Rec = dyn_cast(Function->getDeclContext()))
-MergeWithParentScope = Rec->isLocalClass();
+MergeWithParentScope =
+Rec->isLocalClass() && !Function->isFunctionTemplateSpecialization();
 
   LocalInstantiationScope Scope(*this, MergeWithParentScope);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D104253: [Clang][Codegen] emit noprofile IR Fn Attr for no_instrument_function Fn Attr

2021-06-14 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

In D104253#2817695 , @MaskRay wrote:

> `__attribute__((no_instrument_function))` seems specific to 
> `-finstrument-functions`.  Somehow `gcc -pg` uses it as well.
>
> The name may not be generic, so it may be odd to exclude various 
> instrumentations under this generic attribute.
>
> clang -fprofile-instr-generate (frontend coverage/PGO; AIUI only Apples uses 
> it for PGO) / clang -fprofile-generate (IR PGO; most users use this) / clang 
> -fprofile-arcs / gcc -fprofile-arcs are 4 different instrumentation 
> approaches.
> Their user-facing options are similar enough and the instrumented output has 
> similarity (so a user not wanting one instr will certainly not want other 
> instr) so I think they warrant similar function attribute.
>
> Perhaps a good idea to file a feature request on 
> https://gcc.gnu.org/bugzilla/buglist.cgi?bug_status=__open__=gcov-profile_id=304970=gcc
>  and check what function attributes GCC wants to use.

Done; thanks for the advice: 
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80223#c6.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104253

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


[PATCH] D102875: [PowerPC] Add PowerPC compare and multiply related builtins and instrinsics for XL compatibility

2021-06-14 Thread Victor Huang via Phabricator via cfe-commits
NeHuang updated this revision to Diff 351989.
NeHuang added a comment.

Rebased the patch with changes in https://reviews.llvm.org/D104125


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102875

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Basic/Targets/PPC.cpp
  clang/lib/Basic/Targets/PPC.h
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-ppc-xlcompat-compare-64bit-only.c
  clang/test/CodeGen/builtins-ppc-xlcompat-compare.c
  clang/test/CodeGen/builtins-ppc-xlcompat-multiply-64bit-only.c
  clang/test/CodeGen/builtins-ppc-xlcompat-multiply.c
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCInstr64Bit.td
  llvm/lib/Target/PowerPC/PPCInstrInfo.td
  llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-compare-64bit-only.ll
  llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-compare.ll
  llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-multiply-64bit-only.ll
  llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-multiply.ll

Index: llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-multiply.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-multiply.ll
@@ -0,0 +1,52 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpcle-unknown-linux-gnu \
+; RUN: -mcpu=pwr9 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | FileCheck %s --check-prefix=CHECK-32
+; RUN: llc -verify-machineinstrs -mtriple=powerpc-unknown-linux-gnu \
+; RUN: -mcpu=pwr9 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | FileCheck %s --check-prefix=CHECK-32
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN: -mcpu=pwr9 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | FileCheck %s --check-prefix=CHECK-64
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu \
+; RUN: -mcpu=pwr9 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | FileCheck %s --check-prefix=CHECK-64
+
+; Function Attrs: noinline nounwind optnone
+define dso_local signext i32 @test_builtin_ppc_mulhw(i32 %a, i32%b) #0 {
+; CHECK-32-LABEL: test_builtin_ppc_mulhw:
+; CHECK-32:   # %bb.0: # %entry
+; CHECK-32-NEXT:mulhw r3, r3, r4
+; CHECK-32-NEXT:blr
+;
+; CHECK-64-LABEL: test_builtin_ppc_mulhw:
+; CHECK-64:   # %bb.0: # %entry
+; CHECK-64-NEXT:mulhw r3, r3, r4
+; CHECK-64-NEXT:extsw r3, r3
+; CHECK-64-NEXT:blr
+entry:
+  %0 = call i32 @llvm.ppc.mulhw(i32 %a, i32 %b)
+  ret i32 %0
+}
+
+; Function Attrs: nounwind readnone
+declare i32 @llvm.ppc.mulhw(i32, i32) #1
+
+; Function Attrs: noinline nounwind optnone
+define dso_local zeroext i32 @test_builtin_ppc_mulhwu(i32 %a, i32%b) #0 {
+; CHECK-32-LABEL: test_builtin_ppc_mulhwu:
+; CHECK-32:   # %bb.0: # %entry
+; CHECK-32-NEXT:mulhwu r3, r3, r4
+; CHECK-32-NEXT:blr
+;
+; CHECK-64-LABEL: test_builtin_ppc_mulhwu:
+; CHECK-64:   # %bb.0: # %entry
+; CHECK-64-NEXT:mulhwu r3, r3, r4
+; CHECK-64-NEXT:clrldi r3, r3, 32
+; CHECK-64-NEXT:blr
+entry:
+  %0 = call i32 @llvm.ppc.mulhwu(i32 %a, i32 %b)
+  ret i32 %0
+}
+
+; Function Attrs: nounwind readnone
+declare i32 @llvm.ppc.mulhwu(i32, i32) #1
+
+attributes #0 = { noinline nounwind optnone "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="pwr9" "target-features"="+altivec,+bpermd,+crypto,+direct-move,+extdiv,+htm,+power8-vector,+power9-vector,+vsx,-privileged,-rop-protect,-spe" }
+attributes #1 = { nounwind readnone }
Index: llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-multiply-64bit-only.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-multiply-64bit-only.ll
@@ -0,0 +1,80 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN: -mcpu=pwr9 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu \
+; RUN: -mcpu=pwr9 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | FileCheck %s
+
+; Function Attrs: noinline nounwind optnone
+define dso_local i64 @test_builtin_ppc_mulhd(i64 %a, i64 %b) #0 {
+; CHECK-LABEL: test_builtin_ppc_mulhd:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:mulhd r3, r3, r4
+; CHECK-NEXT:blr
+entry:
+  %0 = call i64 @llvm.ppc.mulhd(i64 %a, i64 %b)
+  ret i64 %0
+}
+
+; Function Attrs: nounwind readnone
+declare i64 @llvm.ppc.mulhd(i64, i64) #1
+
+; Function Attrs: noinline nounwind optnone
+define dso_local i64 @test_builtin_ppc_mulhdu(i64 %a, i64 %b) #0 {
+; CHECK-LABEL: test_builtin_ppc_mulhdu:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:mulhdu r3, r3, r4
+; CHECK-NEXT:blr
+entry:
+  %0 = call i64 

[clang] 00dbf8c - Adding some of the documents for C11.

2021-06-14 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2021-06-14T16:43:44-04:00
New Revision: 00dbf8c83218829633b9f2ec1ee94a1f3b8dd29c

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

LOG: Adding some of the documents for C11.

This is not the complete set of language-related documents for C11, but
is about 75% complete.

Added: 


Modified: 
clang/www/c_status.html

Removed: 




diff  --git a/clang/www/c_status.html b/clang/www/c_status.html
index f68344c47c082..73321a9306202 100644
--- a/clang/www/c_status.html
+++ b/clang/www/c_status.html
@@ -91,6 +91,189 @@ C11 implementation status
 Clang implements a significant portion of the ISO 9899:2011 (C11) standard, 
but the status of individual proposals is still under investigation.
 You can use Clang in C11 mode with the -std=c11 option (use 
-std=c1x in Clang 3.0 and earlier).
 
+
+List of features and minimum Clang version with support
+
+
+ 
+Language Feature
+C11 Proposal
+Available in Clang?
+ 
+
+  A finer-grained specification for sequencing
+  http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1252.htm;>N1252
+  Unknown
+
+
+  Clarification of expressions
+  http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1282.pdf;>N1282
+  Unknown
+
+
+  Extending the lifetime of temporary objects (factored approach)
+  http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1285.htm;>N1285
+  Unknown
+
+
+  Requiring signed char to have no padding bits
+  http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1310.htm;>N1310
+  Unknown
+
+
+  Initializing static or external variables
+  http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1311.pdf;>N1311
+  Unknown
+
+
+  Conversion between pointers and floating types
+  http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1316.htm;>N1316
+  Yes
+
+
+  Adding TR 19769 to the C Standard Library
+  http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1326.pdf;>N1326
+  Clang 3.3
+
+
+  Static assertions
+  http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1330.pdf;>N1330
+  Yes
+
+
+  Parallel memory sequencing model proposal
+  http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1349.htm;>N1349
+  Unknown
+
+
+  Analyzability (#1, #4 - conditionally normative)
+  http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1350.htm;>N1350
+  Unknown
+
+
+  FLT_EVAL_METHOD issues (first change only)
+  http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1353.pdf;>N1353
+  Unknown
+
+
+  _Bool bit-fields
+  http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1356.htm;>N1356
+  Unknown
+
+
+  Technical corrigendum for C1X
+  http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1359.htm;>N1359
+  Unknown
+
+
+  Benign typedef redefinition
+  http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1360.htm;>N1360
+  Clang 3.1
+
+
+  Thread-local storage
+  http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1364.htm;>N1364
+  Clang 3.3
+
+
+  Constant expressions
+  http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1365.htm;>N1365
+  Unknown
+
+
+  Contractions and expression evaluation methods
+  http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1367.htm;>N1367
+  Unknown
+
+
+  FLT_EVAL_METHOD and return
+  http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1382.htm;>N1382
+  Unknown
+
+
+  Floating-point to int/_Bool conversions
+  http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1391.htm;>N1391
+  Unknown
+
+
+  Analyzability (along the lines)
+  http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1394.htm;>N1394
+  Unknown
+
+
+  Wide function returns (alternate proposal)
+  http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1396.htm;>N1396
+  Unknown
+
+
+  Alignment
+
+  
+http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1397.htm;>N1397
+Clang 3.2
+  
+  
+http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1447.htm;>N1447
+Clang 3.2
+  
+
+  Anonymous member-structures and unions (modulo "name lookup")
+  http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1406.pdf;>N1406
+  Yes
+
+
+  Completeness of types
+  http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1439.pdf;>N1439
+  Unknown
+
+
+  Generic macro facility
+  http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1441.htm;>N1441
+  Yes
+
+
+  Dependency ordering for C memory model
+  http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1444.htm;>N1444
+  Unknown
+
+
+ 

[PATCH] D99483: [clang][AIX] Define __STDC_NO_ATOMICS__ for c11 and above

2021-06-14 Thread Jinsong Ji via Phabricator via cfe-commits
jsji added a comment.

Done in https://reviews.llvm.org/D103707?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99483

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


[PATCH] D104242: Removes an unused variable and alters a lit test to simplify and avoid a buildbot error

2021-06-14 Thread Fred Grim via Phabricator via cfe-commits
feg208 updated this revision to Diff 351982.
feg208 added a comment.

Looks like the dead code is removed in main


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104242

Files:
  clang/test/Format/struct-array-initializer.cpp


Index: clang/test/Format/struct-array-initializer.cpp
===
--- clang/test/Format/struct-array-initializer.cpp
+++ clang/test/Format/struct-array-initializer.cpp
@@ -1,9 +1,5 @@
-// RUN: grep -Ev "// *[A-Z-]+:" %s \
-// RUN:   | clang-format -style="{BasedOnStyle: LLVM, AlignArrayOfStructures: 
Right}" %s \
-// RUN:   | FileCheck -strict-whitespace -check-prefix=CHECK1 %s
-// RUN: grep -Ev "// *[A-Z-]+:" %s \
-// RUN:   | clang-format -style="{BasedOnStyle: LLVM, AlignArrayOfStructures: 
Left}" %s \
-// RUN:   | FileCheck -strict-whitespace -check-prefix=CHECK2 %s
+// RUN: clang-format -style="{BasedOnStyle: LLVM, AlignArrayOfStructures: 
Right}" %s | FileCheck -strict-whitespace -check-prefix=CHECK1 %s
+// RUN: clang-format -style="{BasedOnStyle: LLVM, AlignArrayOfStructures: 
Left}" %s | FileCheck -strict-whitespace -check-prefix=CHECK2 %s
 struct test {
   int a;
   int b;


Index: clang/test/Format/struct-array-initializer.cpp
===
--- clang/test/Format/struct-array-initializer.cpp
+++ clang/test/Format/struct-array-initializer.cpp
@@ -1,9 +1,5 @@
-// RUN: grep -Ev "// *[A-Z-]+:" %s \
-// RUN:   | clang-format -style="{BasedOnStyle: LLVM, AlignArrayOfStructures: Right}" %s \
-// RUN:   | FileCheck -strict-whitespace -check-prefix=CHECK1 %s
-// RUN: grep -Ev "// *[A-Z-]+:" %s \
-// RUN:   | clang-format -style="{BasedOnStyle: LLVM, AlignArrayOfStructures: Left}" %s \
-// RUN:   | FileCheck -strict-whitespace -check-prefix=CHECK2 %s
+// RUN: clang-format -style="{BasedOnStyle: LLVM, AlignArrayOfStructures: Right}" %s | FileCheck -strict-whitespace -check-prefix=CHECK1 %s
+// RUN: clang-format -style="{BasedOnStyle: LLVM, AlignArrayOfStructures: Left}" %s | FileCheck -strict-whitespace -check-prefix=CHECK2 %s
 struct test {
   int a;
   int b;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D104242: Removes an unused variable and alters a lit test to simplify and avoid a buildbot error

2021-06-14 Thread Fred Grim via Phabricator via cfe-commits
feg208 added a comment.

In D104242#2817815 , 
@HazardyKnusperkeks wrote:

> Could you split this into two diffs? Or are those two changes in any way 
> related?

I can if you'd like. They are related in the sense that the dead code yielded 
warnings in the buildbot logs that necessitated this change set.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104242

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


[PATCH] D104261: Thread safety analysis: Always warn when dropping locks on back edges

2021-06-14 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added inline comments.



Comment at: clang/lib/Analysis/ThreadSafety.cpp:868
 ThreadSafetyHandler ) const override {
-if (!managed() && !asserted() && !negative() && !isUniversal()) {
+if (!asserted() && !negative() && !isUniversal()) {
   Handler.handleMutexHeldEndOfScope("mutex", toString(), loc(), JoinLoc,

One might ask: what about asserted capabilities? I plan to introduce a warning 
when they are released, because that can't be consistent, and then they can't 
disappear on back edges without warning.

For negative capabilities we'd presumably see a warning for the "positive" 
capability instead.

Not sure how universal capabilities are typically used. Presumably one could 
release such a capability in a loop? Then on the other hand, code using such 
capabilities is probably not very interested in false negatives.



Comment at: clang/lib/Analysis/ThreadSafety.cpp:2227-2228
 /// \param LEK2 The error message to report if a mutex is missing from Lset2
 void ThreadSafetyAnalyzer::intersectAndWarn(FactSet ,
 const FactSet ,
 SourceLocation JoinLoc,

Presumably we should call these `EntrySet` and `ExitSet` instead? The second 
parameter is always the exit set of an existing block, the first parameter the 
entry set of a (sometimes new) block.



Comment at: clang/test/SemaCXX/warn-thread-safety-analysis.cpp:643
 sls_mu.Lock();  // \
-  // expected-note {{the other acquisition of mutex 'sls_mu' is here}}
+  // expected-warning {{mutex 'sls_mu' is acquired exclusively and shared 
in the same scope}}
   } while (getBool());

These are just swapped because I'm merging the branches in a different order 
now. I think that's Ok.



Comment at: clang/test/SemaCXX/warn-thread-safety-analysis.cpp:2788
+  // We have to warn on this join point despite the lock being managed ...
+  for (unsigned i = 1; i < 10; ++i) { // expected-warning {{expecting mutex 
'mu' to be held at start of each loop}}
+x = 1; // ... because we might miss that this doesn't always happen under 
lock.

This warning is new.



Comment at: clang/test/SemaCXX/warn-thread-safety-analysis.cpp:2813
+  scope.Unlock();
+  continue; // expected-warning {{expecting mutex 'mu' to be held at start 
of each loop}}
+}

This is also new.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104261

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


[PATCH] D98068: Exampt asserts for recursive lambdas about LocalInstantiationScope

2021-06-14 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

I think this is the wrong solution; I think the assertion is correct and is 
observing a problem elsewhere. Imagine if we had something like:

  template
  void f() {
auto a = [] (auto recurse, auto x) {
  auto b = [] (auto) {
refer to local decl in a
  };
  if constexpr (recurse)
a(false_type(), b)
  else
x(0)
}
a(true_type(), a)
  }

We would then have a local instantiation scope stack that looks like:

  f
  f::a::operator()::a>
  f::a::operator()::a::operator()::a>::b>
  f::a::operator()::a>::operator()::b::operator()

... so the reference from the `true_type` version of `b` to the local decl in 
`a` would find the local from the enclosing `false_type` class, which is wrong. 
That's the kind of bug that I think this assertion is defending against, and it 
looks like we have that bug here. (As it happens, this will never actually 
cause problems, because all references from b to enclosing locals already got 
substituted when instantiating the `operator()` function template, but that's 
actually kind of the point -- the local instantiation scope stack is wrong.)

I think the real problem is that the local instantiation scope for the 
instantiation of a generic lambda's call operator from the instantiated call 
operator template should never be merged with its parent. Merging the contexts 
cannot be necessary  -- we can have left the parent instantiation before we 
instantiate a specialization of the call operator template, so there cannot be 
any references from the call operator template to enclosing locals that require 
substitution. I think the bug is in `InstantiateFunctionDefinition`, somewhere 
around line 4863:

  // Introduce a new scope where local variable instantiations will be
  // recorded, unless we're actually a member function within a local
  // class, in which case we need to merge our results with the parent
  // scope (of the enclosing function).
  bool MergeWithParentScope = false;
  if (CXXRecordDecl *Rec = dyn_cast(Function->getDeclContext()))
MergeWithParentScope = Rec->isLocalClass();
  
  LocalInstantiationScope Scope(*this, MergeWithParentScope);

While we do need the enclosing local instantiation scope when we're 
instantiating a non-template member of a local class, or when we're 
instantiating the definition of a member function template as a member function 
template (that is, when instantiating a generic lambda to form a generic 
lambda), we do not need the enclosing local instantiation scope when 
re-substituting into the result of such a local substitution. That is, we do 
not want a local instantiation scope if we're instantiating a function template 
specialization, because the template we're instantiating already had references 
to locals properly substituted. I'd try a change like this to the above code:

  -MergeWithParentScope = Rec->isLocalClass();
  +MergeWithParentScope = Rec->isLocalClass() && 
!Function->isFunctionTemplateSpecialization();


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

https://reviews.llvm.org/D98068

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


[PATCH] D104261: Thread safety analysis: Always warn when dropping locks on back edges

2021-06-14 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert created this revision.
aaronpuchert added reviewers: aaron.ballman, delesley.
aaronpuchert requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

We allow branches to join where one holds a managed lock but the other
doesn't, but we can't do so for back edges: because there we can't drop
them from the lockset, as we have already analyzed the loop with the
larger lockset. So we can't allow dropping managed locks on back edges.

We move the managed() check from handleRemovalFromIntersection up to
intersectAndWarn, where we additionally check if we're on a back edge if
we're removing from the first lock set (the entry set of the next block)
but not if we're removing from the second lock set (the exit set of the
previous block). Now that the order of arguments matters, I had to swap
them in one invocation, which also causes some minor differences in the
tests.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D104261

Files:
  clang/lib/Analysis/ThreadSafety.cpp
  clang/test/SemaCXX/warn-thread-safety-analysis.cpp

Index: clang/test/SemaCXX/warn-thread-safety-analysis.cpp
===
--- clang/test/SemaCXX/warn-thread-safety-analysis.cpp
+++ clang/test/SemaCXX/warn-thread-safety-analysis.cpp
@@ -636,11 +636,11 @@
 
 void shared_fun_1() {
   sls_mu.ReaderLock(); // \
-// expected-warning {{mutex 'sls_mu' is acquired exclusively and shared in the same scope}}
+// expected-note {{the other acquisition of mutex 'sls_mu' is here}}
   do {
 sls_mu.Unlock();
 sls_mu.Lock();  // \
-  // expected-note {{the other acquisition of mutex 'sls_mu' is here}}
+  // expected-warning {{mutex 'sls_mu' is acquired exclusively and shared in the same scope}}
   } while (getBool());
   sls_mu.Unlock();
 }
@@ -695,11 +695,11 @@
 
 void shared_bad_0() {
   sls_mu.Lock();  // \
-// expected-warning {{mutex 'sls_mu' is acquired exclusively and shared in the same scope}}
+// expected-note {{the other acquisition of mutex 'sls_mu' is here}}
   do {
 sls_mu.Unlock();
 sls_mu.ReaderLock();  // \
-  // expected-note {{the other acquisition of mutex 'sls_mu' is here}}
+  // expected-warning {{mutex 'sls_mu' is acquired exclusively and shared in the same scope}}
   } while (getBool());
   sls_mu.Unlock();
 }
@@ -2773,6 +2773,48 @@
   x = 2; // expected-warning {{writing variable 'x' requires holding mutex 'mu' exclusively}}
 }
 
+void loopAcquire() {
+  RelockableMutexLock scope(, DeferTraits{});
+  for (unsigned i = 1; i < 10; ++i) {
+x = 1; // expected-warning {{writing variable 'x' requires holding mutex 'mu' exclusively}}
+if (i == 5)
+  scope.Lock();
+  }
+}
+
+void loopRelease() {
+  RelockableMutexLock scope(, ExclusiveTraits{}); // expected-note {{mutex acquired here}}
+  // We have to warn on this join point despite the lock being managed ...
+  for (unsigned i = 1; i < 10; ++i) { // expected-warning {{expecting mutex 'mu' to be held at start of each loop}}
+x = 1; // ... because we might miss that this doesn't always happen under lock.
+if (i == 5)
+  scope.Unlock();
+  }
+}
+
+void loopAcquireContinue() {
+  RelockableMutexLock scope(, DeferTraits{});
+  for (unsigned i = 1; i < 10; ++i) {
+x = 1; // expected-warning {{writing variable 'x' requires holding mutex 'mu' exclusively}}
+if (i == 5) {
+  scope.Lock();
+  continue;
+}
+  }
+}
+
+void loopReleaseContinue() {
+  RelockableMutexLock scope(, ExclusiveTraits{}); // expected-note {{mutex acquired here}}
+  // We have to warn on this join point despite the lock being managed ...
+  for (unsigned i = 1; i < 10; ++i) {
+x = 1; // ... because we might miss that this doesn't always happen under lock.
+if (i == 5) {
+  scope.Unlock();
+  continue; // expected-warning {{expecting mutex 'mu' to be held at start of each loop}}
+}
+  }
+}
+
 void exclusiveSharedJoin() {
   RelockableMutexLock scope(, DeferTraits{});
   if (b)
Index: clang/lib/Analysis/ThreadSafety.cpp
===
--- clang/lib/Analysis/ThreadSafety.cpp
+++ clang/lib/Analysis/ThreadSafety.cpp
@@ -865,7 +865,7 @@
   handleRemovalFromIntersection(const FactSet , FactManager ,
 SourceLocation JoinLoc, LockErrorKind LEK,
 ThreadSafetyHandler ) const override {
-if (!managed() && !asserted() && !negative() && !isUniversal()) {
+if (!asserted() && !negative() && !isUniversal()) {
   Handler.handleMutexHeldEndOfScope("mutex", toString(), loc(), JoinLoc,
 LEK);
 }
@@ -2239,7 +2239,7 @@
 if (Iter1 != FSet1.end()) {
   if (join(FactMan[*Iter1], LDat2) && LEK1 == LEK_LockedSomePredecessors)
 *Iter1 = Fact;
-} else {
+} else if (!LDat2.managed()) {
   

[PATCH] D104242: Removes an unused variable and alters a lit test to simplify and avoid a buildbot error

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

Could you split this into two diffs? Or are those two changes in any way 
related?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104242

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


[PATCH] D102478: [Matrix] Emit assumption that matrix indices are valid.

2021-06-14 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Just a couple of nits here, basically see how much we can put in the 'cheap to 
check' branch.




Comment at: clang/lib/CodeGen/CGExpr.cpp:1944
+llvm::Value *Idx = LV.getMatrixIdx();
+const auto MatTy = LV.getType()->getAs();
+llvm::MatrixBuilder MB(Builder);

I think the linter here is right, we require const auto * here.



Comment at: clang/lib/CodeGen/CGExpr.cpp:1946
+llvm::MatrixBuilder MB(Builder);
+if (CGM.getCodeGenOpts().OptimizationLevel > 0)
+  MB.CreateIndexAssumption(Idx, MatTy->getNumElementsFlattened());

Is it worth putting the MatrixBuilder line inside of this branch too?  Perhaps 
all the added code?



Comment at: clang/lib/CodeGen/CGExpr.cpp:2092
+  llvm::MatrixBuilder MB(Builder);
+  if (CGM.getCodeGenOpts().OptimizationLevel > 0)
+MB.CreateIndexAssumption(Idx, MatTy->getNumElementsFlattened());

Same here on both.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102478

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


[PATCH] D104258: [OPENMP]Fix PR50699: capture locals in combine directrives for aligned clause.

2021-06-14 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104258

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


[PATCH] D104258: [OPENMP]Fix PR50699: capture locals in combine directrives for aligned clause.

2021-06-14 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev created this revision.
ABataev added reviewers: lebedev.ri, jdoerfert.
Herald added subscribers: guansong, yaxunl.
ABataev requested review of this revision.
Herald added a subscriber: sstefan1.
Herald added a project: clang.

Need to capture locals in aligned clauses for the combined directives to
be fix the crash in the codegen.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D104258

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/parallel_for_simd_aligned_codegen.cpp

Index: clang/test/OpenMP/parallel_for_simd_aligned_codegen.cpp
===
--- /dev/null
+++ clang/test/OpenMP/parallel_for_simd_aligned_codegen.cpp
@@ -0,0 +1,346 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature --include-generated-funcs --replace-value-regex "__omp_offloading_[0-9a-z]+_[0-9a-z]+" "reduction_size[.].+[.]" "pl_cond[.].+[.|,]" --prefix-filecheck-ir-name _
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK1
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix=CHECK2
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++11 -DLAMBDA -triple x86_64-unknown-linux -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK3
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -fblocks -DBLOCKS -triple x86_64-unknown-linux -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK4
+
+// RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s --implicit-check-not="{{__kmpc|__tgt}}"
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple x86_64-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -triple x86_64-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --implicit-check-not="{{__kmpc|__tgt}}"
+// RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -std=c++11 -DLAMBDA -triple x86_64-unknown-linux -emit-llvm %s -o - | FileCheck %s --implicit-check-not="{{__kmpc|__tgt}}"
+// RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -fblocks -DBLOCKS -triple x86_64-unknown-linux -emit-llvm %s -o - | FileCheck %s --implicit-check-not="{{__kmpc|__tgt}}"
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+void foo(float *c) {
+#pragma omp parallel for simd aligned(c)
+  for (int i = 0; i < 10; ++i);
+}
+
+#endif
+
+// CHECK1-LABEL: define {{[^@]+}}@_Z3fooPf
+// CHECK1-SAME: (float* [[C:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK1-NEXT:  entry:
+// CHECK1-NEXT:[[C_ADDR:%.*]] = alloca float*, align 8
+// CHECK1-NEXT:store float* [[C]], float** [[C_ADDR]], align 8
+// CHECK1-NEXT:call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* @[[GLOB2:[0-9]+]], i32 1, void (i32*, i32*, ...)* bitcast (void (i32*, i32*, float**)* @.omp_outlined. to void (i32*, i32*, ...)*), float** [[C_ADDR]])
+// CHECK1-NEXT:ret void
+//
+//
+// CHECK1-LABEL: define {{[^@]+}}@.omp_outlined.
+// CHECK1-SAME: (i32* noalias [[DOTGLOBAL_TID_:%.*]], i32* noalias [[DOTBOUND_TID_:%.*]], float** nonnull align 8 dereferenceable(8) [[C:%.*]]) #[[ATTR1:[0-9]+]] {
+// CHECK1-NEXT:  entry:
+// CHECK1-NEXT:[[DOTGLOBAL_TID__ADDR:%.*]] = alloca i32*, align 8
+// CHECK1-NEXT:[[DOTBOUND_TID__ADDR:%.*]] = alloca i32*, align 8
+// CHECK1-NEXT:[[C_ADDR:%.*]] = alloca float**, align 8
+// CHECK1-NEXT:[[DOTOMP_IV:%.*]] = alloca i32, align 4
+// CHECK1-NEXT:[[TMP:%.*]] = alloca i32, align 4
+// CHECK1-NEXT:[[DOTOMP_LB:%.*]] = alloca i32, align 4
+// CHECK1-NEXT:[[DOTOMP_UB:%.*]] = alloca i32, align 4
+// CHECK1-NEXT:[[DOTOMP_STRIDE:%.*]] = alloca i32, align 4
+// CHECK1-NEXT:[[DOTOMP_IS_LAST:%.*]] = alloca i32, align 4
+// CHECK1-NEXT:[[I:%.*]] = alloca i32, align 4
+// CHECK1-NEXT:store i32* [[DOTGLOBAL_TID_]], i32** [[DOTGLOBAL_TID__ADDR]], align 8
+// CHECK1-NEXT:store i32* [[DOTBOUND_TID_]], i32** [[DOTBOUND_TID__ADDR]], align 8
+// CHECK1-NEXT:store float** [[C]], float*** [[C_ADDR]], align 8
+// CHECK1-NEXT:[[TMP0:%.*]] = load float**, float*** [[C_ADDR]], align 8
+// CHECK1-NEXT:[[TMP1:%.*]] = load float*, float** [[TMP0]], align 8
+// CHECK1-NEXT:call void @llvm.assume(i1 true) [ "align"(float* [[TMP1]], i64 16) ]
+// CHECK1-NEXT:store i32 0, i32* [[DOTOMP_LB]], align 4
+// CHECK1-NEXT:store i32 9, i32* [[DOTOMP_UB]], align 4
+// CHECK1-NEXT:store i32 1, i32* [[DOTOMP_STRIDE]], align 4
+// CHECK1-NEXT:store i32 0, i32* [[DOTOMP_IS_LAST]], align 4
+// CHECK1-NEXT:[[TMP2:%.*]] = load i32*, i32** [[DOTGLOBAL_TID__ADDR]], align 8
+// CHECK1-NEXT:[[TMP3:%.*]] = load i32, i32* [[TMP2]], align 4
+// CHECK1-NEXT:call void 

[PATCH] D103772: [clang-cl] Reenable /Zc:twoPhase by default if targetting MSVC 2017 Update 3 or newer

2021-06-14 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

If we look back at the original intention of our MSVC compatibility work, we 
tried to accept as much invalid code as necessary to parse "system headers". 
System headers were widely interpreted to bethe MSVC STL, ATL, and the Windows 
SDK. So, even if MSVC defaults to delayed template parsing, if system headers 
parse with /Zc:twoPhase enabled, maybe we could pick a different default. We'd 
document the behavior change, of course. Delayed template parsing is an ongoing 
source of bugs (https://llvm.org/pr50676) and maintenance overhead, so it would 
be worth diverging from MSVC a bit if possible.

So... maybe we should go ahead with this anyway. As I understand it, all these 
headers parse correctly in the presence of /Zc:twoPhase, and the RTTI issue has 
been resolved (?), so we should be OK. I think.


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

https://reviews.llvm.org/D103772

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


[PATCH] D104253: [Clang][Codegen] emit noprofile IR Fn Attr for no_instrument_function Fn Attr

2021-06-14 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

`__attribute__((no_instrument_function))` seems specific to 
`-finstrument-functions`.  Somehow `gcc -pg` uses it as well.

The name may not be generic, so it may be odd to exclude various 
instrumentations under this generic attribute.

clang -fprofile-instr-generate (frontend coverage/PGO; AIUI only Apples uses it 
for PGO) / clang -fprofile-generate (IR PGO; most users use this) / clang 
-fprofile-arcs / gcc -fprofile-arcs are 4 different instrumentation approaches,
I think they are similar enough that warrant a similar function attribute.

Perhaps a good idea to file a feature request on 
https://gcc.gnu.org/bugzilla/buglist.cgi?bug_status=__open__=gcov-profile_id=304970=gcc
 and check what function attributes GCC wants to use.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104253

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


[PATCH] D102478: [Matrix] Emit assumption that matrix indices are valid.

2021-06-14 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added a comment.

ping :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102478

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


[PATCH] D104253: [Clang][Codegen] emit noprofile IR Fn Attr for no_instrument_function Fn Attr

2021-06-14 Thread Marco Elver via Phabricator via cfe-commits
melver added a comment.

In D104253#2817673 , @void wrote:

> What are your thoughts on adding a `noprofile` function attribute in the FE? 
> @MaskRay suggested filing a bug with gcov (below) to get their take on it.
>
>   
> https://gcc.gnu.org/bugzilla/buglist.cgi?bug_status=__open__=gcov-profile_id=304970=gcc

How similar is all this stuff?  Looking at 
https://gcc.gnu.org/onlinedocs/gcc/Instrumentation-Options.html

If `no_instrument_function` is the catchall for this profile/gcov/pg 
instrumentation, I don't think anybody will object.

The result is 1) pg/-fprofile/gcov stuff, 2) sanitizers. (1) is suppressible 
via `no_instrument_function`, (2) via `no_sanitize*`. This appears consistent 
vs. having `no_instrument_function`+`noprofile`+`no_sanitize*`

As a user, this is the intuitive behaviour I'd expect at least.

But asking GCC folks (Martin helped us with no_sanitize_coverage) for input is 
reasonable.




Comment at: clang/test/CodeGen/fprofile-instrument.c:5
+
+int __attribute__((__no_instrument_function__))
+__attribute__((no_instrument_function))

Only one of the spellings should be required.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104253

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


[PATCH] D103845: [compiler-rt][hwasan] Add newline between record_addr lines on frame record dumps

2021-06-14 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 351961.
leonardchan edited the summary of this revision.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103845

Files:
  compiler-rt/lib/hwasan/hwasan_report.cpp


Index: compiler-rt/lib/hwasan/hwasan_report.cpp
===
--- compiler-rt/lib/hwasan/hwasan_report.cpp
+++ compiler-rt/lib/hwasan/hwasan_report.cpp
@@ -236,12 +236,12 @@
 frame_desc.append("  record_addr:0x%zx record:0x%zx",
   reinterpret_cast(record_addr), record);
 if (SymbolizedStack *frame = Symbolizer::GetOrInit()->SymbolizePC(pc)) {
-  RenderFrame(_desc, " %F %L\n", 0, frame->info.address, 
>info,
+  RenderFrame(_desc, " %F %L", 0, frame->info.address, >info,
   common_flags()->symbolize_vs_style,
   common_flags()->strip_path_prefix);
   frame->ClearAll();
 }
-Printf("%s", frame_desc.data());
+Printf("%s\n", frame_desc.data());
 frame_desc.clear();
   }
 }


Index: compiler-rt/lib/hwasan/hwasan_report.cpp
===
--- compiler-rt/lib/hwasan/hwasan_report.cpp
+++ compiler-rt/lib/hwasan/hwasan_report.cpp
@@ -236,12 +236,12 @@
 frame_desc.append("  record_addr:0x%zx record:0x%zx",
   reinterpret_cast(record_addr), record);
 if (SymbolizedStack *frame = Symbolizer::GetOrInit()->SymbolizePC(pc)) {
-  RenderFrame(_desc, " %F %L\n", 0, frame->info.address, >info,
+  RenderFrame(_desc, " %F %L", 0, frame->info.address, >info,
   common_flags()->symbolize_vs_style,
   common_flags()->strip_path_prefix);
   frame->ClearAll();
 }
-Printf("%s", frame_desc.data());
+Printf("%s\n", frame_desc.data());
 frame_desc.clear();
   }
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D104253: [Clang][Codegen] emit noprofile IR Fn Attr for no_instrument_function Fn Attr

2021-06-14 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 351960.
nickdesaulniers added a comment.

- rename new test from fprofile-generate.c to fprofile-instrument.c; 
-fprofile-generate is the driver opt, -fprofile-instrument is the frontend opt.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104253

Files:
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/test/CodeGen/fprofile-instrument.c


Index: clang/test/CodeGen/fprofile-instrument.c
===
--- /dev/null
+++ clang/test/CodeGen/fprofile-instrument.c
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -fprofile-instrument=llvm -disable-llvm-passes \
+// RUN:   -emit-llvm -o - %s | FileCheck %s
+int g(int);
+
+int __attribute__((__no_instrument_function__))
+__attribute__((no_instrument_function))
+no_instr(int a) {
+// CHECK: define {{.*}} i32 @no_instr(i32 %a) [[ATTR:#[0-9]+]]
+  int sum = 0;
+  for (int i = 0; i < a; i++)
+sum += g(i);
+  return sum;
+}
+
+int instr(int a) {
+// CHECK: define {{.*}} i32 @instr(i32 %a) [[ATTR2:#[0-9]+]]
+  int sum = 0;
+  for (int i = 0; i < a; i++)
+sum += g(i);
+  return sum;
+}
+// CHECK: attributes [[ATTR]] = {{.*}} noprofile
+// CHECK-NOT: attributes [[ATTR2]] = {{.*}} noprofile
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -893,6 +893,9 @@
   if (D && D->hasAttr())
 Fn->addFnAttr("cfi-canonical-jump-table");
 
+  if (D && D->hasAttr())
+Fn->addFnAttr(llvm::Attribute::NoProfile);
+
   if (getLangOpts().OpenCL) {
 // Add metadata for a kernel function.
 if (const FunctionDecl *FD = dyn_cast_or_null(D))


Index: clang/test/CodeGen/fprofile-instrument.c
===
--- /dev/null
+++ clang/test/CodeGen/fprofile-instrument.c
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -fprofile-instrument=llvm -disable-llvm-passes \
+// RUN:   -emit-llvm -o - %s | FileCheck %s
+int g(int);
+
+int __attribute__((__no_instrument_function__))
+__attribute__((no_instrument_function))
+no_instr(int a) {
+// CHECK: define {{.*}} i32 @no_instr(i32 %a) [[ATTR:#[0-9]+]]
+  int sum = 0;
+  for (int i = 0; i < a; i++)
+sum += g(i);
+  return sum;
+}
+
+int instr(int a) {
+// CHECK: define {{.*}} i32 @instr(i32 %a) [[ATTR2:#[0-9]+]]
+  int sum = 0;
+  for (int i = 0; i < a; i++)
+sum += g(i);
+  return sum;
+}
+// CHECK: attributes [[ATTR]] = {{.*}} noprofile
+// CHECK-NOT: attributes [[ATTR2]] = {{.*}} noprofile
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -893,6 +893,9 @@
   if (D && D->hasAttr())
 Fn->addFnAttr("cfi-canonical-jump-table");
 
+  if (D && D->hasAttr())
+Fn->addFnAttr(llvm::Attribute::NoProfile);
+
   if (getLangOpts().OpenCL) {
 // Add metadata for a kernel function.
 if (const FunctionDecl *FD = dyn_cast_or_null(D))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D104248: [compiler-rt][hwasan] Refactor Thread::Init

2021-06-14 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan marked an inline comment as not done.
leonardchan added inline comments.



Comment at: compiler-rt/lib/hwasan/hwasan_linux.cpp:430
 
+void Thread::Init(uptr stack_buffer_start, uptr stack_buffer_size) {
+  CHECK_EQ(0, unique_id_);  // try to catch bad stack reuse

leonardchan wrote:
> mcgrathr wrote:
> > Most of this code can actually be reused for Fuchsia (just not necessarily 
> > in Thread::Init).
> > It's probably better to split it up for reuse rather than just moving the 
> > whole thing to linux-specific.
> So maybe something like the current patch? Then on Fuchsia we could (1) have 
> a custom implementation of `InitStackAndTls`, (2) wrap the call to 
> `Thread::InitStackRingBuffer` in `Thread::Init` with a `#if 
> SANITIZER_FUCHSIA` so it's not called before thread creation, then (2) call 
> `Thread::InitStackRingBuffer` in the `__sanitizer_thread_start_hook` hook.
Sorry. Meant wrapping with a `#if !SANITIZER_FUCHSIA`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104248

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


[PATCH] D104253: [Clang][Codegen] emit noprofile IR Fn Attr for no_instrument_function Fn Attr

2021-06-14 Thread Bill Wendling via Phabricator via cfe-commits
void added a comment.

What are your thoughts on adding a `noprofile` function attribute in the FE? 
@MaskRay suggested filing a bug with gcov (below) to get their take on it.

  
https://gcc.gnu.org/bugzilla/buglist.cgi?bug_status=__open__=gcov-profile_id=304970=gcc


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104253

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


[PATCH] D104248: [compiler-rt][hwasan] Move Thread::Init into hwasan_linux.cpp

2021-06-14 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added inline comments.



Comment at: compiler-rt/lib/hwasan/hwasan_linux.cpp:430
 
+void Thread::Init(uptr stack_buffer_start, uptr stack_buffer_size) {
+  CHECK_EQ(0, unique_id_);  // try to catch bad stack reuse

mcgrathr wrote:
> Most of this code can actually be reused for Fuchsia (just not necessarily in 
> Thread::Init).
> It's probably better to split it up for reuse rather than just moving the 
> whole thing to linux-specific.
So maybe something like the current patch? Then on Fuchsia we could (1) have a 
custom implementation of `InitStackAndTls`, (2) wrap the call to 
`Thread::InitStackRingBuffer` in `Thread::Init` with a `#if SANITIZER_FUCHSIA` 
so it's not called before thread creation, then (2) call 
`Thread::InitStackRingBuffer` in the `__sanitizer_thread_start_hook` hook.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104248

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


[PATCH] D104248: [compiler-rt][hwasan] Move Thread::Init into hwasan_linux.cpp

2021-06-14 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 351957.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104248

Files:
  compiler-rt/lib/hwasan/hwasan_linux.cpp
  compiler-rt/lib/hwasan/hwasan_thread.cpp
  compiler-rt/lib/hwasan/hwasan_thread.h


Index: compiler-rt/lib/hwasan/hwasan_thread.h
===
--- compiler-rt/lib/hwasan/hwasan_thread.h
+++ compiler-rt/lib/hwasan/hwasan_thread.h
@@ -23,8 +23,13 @@
 
 class Thread {
  public:
-  void Init(uptr stack_buffer_start, uptr stack_buffer_size);  // Must be 
called from the thread itself.
+  void Init(uptr stack_buffer_start, uptr stack_buffer_size);
   void InitRandomState();
+  void InitStackAndTls();
+
+  // Must be called from the thread itself.
+  void InitStackRingBuffer(uptr stack_buffer_start, uptr stack_buffer_size);
+
   void Destroy();
 
   uptr stack_top() { return stack_top_; }
Index: compiler-rt/lib/hwasan/hwasan_thread.cpp
===
--- compiler-rt/lib/hwasan/hwasan_thread.cpp
+++ compiler-rt/lib/hwasan/hwasan_thread.cpp
@@ -44,6 +44,11 @@
   if (auto sz = flags()->heap_history_size)
 heap_allocations_ = HeapAllocationsRingBuffer::New(sz);
 
+  InitStackAndTls();
+  InitStackAndRingBuffer(stack_buffer_start, stack_buffer_size);
+}
+
+void Thread::InitStackRingBuffer(uptr stack_buffer_start, uptr 
stack_buffer_size) {
   HwasanTSDThreadInit();  // Only needed with interceptors.
   uptr *ThreadLong = GetCurrentThreadLongPtr();
   // The following implicitly sets (this) as the current thread.
@@ -55,13 +60,6 @@
   // ScopedTaggingDisable needs GetCurrentThread to be set up.
   ScopedTaggingDisabler disabler;
 
-  uptr tls_size;
-  uptr stack_size;
-  GetThreadStackAndTls(IsMainThread(), _bottom_, _size, 
_begin_,
-   _size);
-  stack_top_ = stack_bottom_ + stack_size;
-  tls_end_ = tls_begin_ + tls_size;
-
   if (stack_bottom_) {
 int local;
 CHECK(AddrIsInStack((uptr)));
Index: compiler-rt/lib/hwasan/hwasan_linux.cpp
===
--- compiler-rt/lib/hwasan/hwasan_linux.cpp
+++ compiler-rt/lib/hwasan/hwasan_linux.cpp
@@ -427,6 +427,14 @@
   HandleDeadlySignal(info, context, GetTid(), , nullptr);
 }
 
+void Thread::InitStackAndTls() {
+  uptr tls_size;
+  uptr stack_size;
+  GetThreadStackAndTls(IsMainThread(), _bottom_, _size, 
_begin_,
+   _size);
+  stack_top_ = stack_bottom_ + stack_size;
+  tls_end_ = tls_begin_ + tls_size;
+}
 
 } // namespace __hwasan
 


Index: compiler-rt/lib/hwasan/hwasan_thread.h
===
--- compiler-rt/lib/hwasan/hwasan_thread.h
+++ compiler-rt/lib/hwasan/hwasan_thread.h
@@ -23,8 +23,13 @@
 
 class Thread {
  public:
-  void Init(uptr stack_buffer_start, uptr stack_buffer_size);  // Must be called from the thread itself.
+  void Init(uptr stack_buffer_start, uptr stack_buffer_size);
   void InitRandomState();
+  void InitStackAndTls();
+
+  // Must be called from the thread itself.
+  void InitStackRingBuffer(uptr stack_buffer_start, uptr stack_buffer_size);
+
   void Destroy();
 
   uptr stack_top() { return stack_top_; }
Index: compiler-rt/lib/hwasan/hwasan_thread.cpp
===
--- compiler-rt/lib/hwasan/hwasan_thread.cpp
+++ compiler-rt/lib/hwasan/hwasan_thread.cpp
@@ -44,6 +44,11 @@
   if (auto sz = flags()->heap_history_size)
 heap_allocations_ = HeapAllocationsRingBuffer::New(sz);
 
+  InitStackAndTls();
+  InitStackAndRingBuffer(stack_buffer_start, stack_buffer_size);
+}
+
+void Thread::InitStackRingBuffer(uptr stack_buffer_start, uptr stack_buffer_size) {
   HwasanTSDThreadInit();  // Only needed with interceptors.
   uptr *ThreadLong = GetCurrentThreadLongPtr();
   // The following implicitly sets (this) as the current thread.
@@ -55,13 +60,6 @@
   // ScopedTaggingDisable needs GetCurrentThread to be set up.
   ScopedTaggingDisabler disabler;
 
-  uptr tls_size;
-  uptr stack_size;
-  GetThreadStackAndTls(IsMainThread(), _bottom_, _size, _begin_,
-   _size);
-  stack_top_ = stack_bottom_ + stack_size;
-  tls_end_ = tls_begin_ + tls_size;
-
   if (stack_bottom_) {
 int local;
 CHECK(AddrIsInStack((uptr)));
Index: compiler-rt/lib/hwasan/hwasan_linux.cpp
===
--- compiler-rt/lib/hwasan/hwasan_linux.cpp
+++ compiler-rt/lib/hwasan/hwasan_linux.cpp
@@ -427,6 +427,14 @@
   HandleDeadlySignal(info, context, GetTid(), , nullptr);
 }
 
+void Thread::InitStackAndTls() {
+  uptr tls_size;
+  uptr stack_size;
+  GetThreadStackAndTls(IsMainThread(), _bottom_, _size, _begin_,
+   _size);
+  stack_top_ = stack_bottom_ + stack_size;
+  tls_end_ = tls_begin_ + tls_size;
+}
 
 } // namespace __hwasan
 

[PATCH] D104253: [Clang][Codegen] emit noprofile IR Fn Attr for no_instrument_function Fn Attr

2021-06-14 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 351956.
nickdesaulniers added a comment.

- add -disable-llvm-passes to unit test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104253

Files:
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/test/CodeGen/fprofile-generate.c


Index: clang/test/CodeGen/fprofile-generate.c
===
--- /dev/null
+++ clang/test/CodeGen/fprofile-generate.c
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -fprofile-instrument=llvm -disable-llvm-passes \
+// RUN:   -emit-llvm -o - %s | FileCheck %s
+int g(int);
+
+int __attribute__((__no_instrument_function__))
+__attribute__((no_instrument_function))
+no_instr(int a) {
+// CHECK: define {{.*}} i32 @no_instr(i32 %a) [[ATTR:#[0-9]+]]
+  int sum = 0;
+  for (int i = 0; i < a; i++)
+sum += g(i);
+  return sum;
+}
+
+int instr(int a) {
+// CHECK: define {{.*}} i32 @instr(i32 %a) [[ATTR2:#[0-9]+]]
+  int sum = 0;
+  for (int i = 0; i < a; i++)
+sum += g(i);
+  return sum;
+}
+// CHECK: attributes [[ATTR]] = {{.*}} noprofile
+// CHECK-NOT: attributes [[ATTR2]] = {{.*}} noprofile
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -893,6 +893,9 @@
   if (D && D->hasAttr())
 Fn->addFnAttr("cfi-canonical-jump-table");
 
+  if (D && D->hasAttr())
+Fn->addFnAttr(llvm::Attribute::NoProfile);
+
   if (getLangOpts().OpenCL) {
 // Add metadata for a kernel function.
 if (const FunctionDecl *FD = dyn_cast_or_null(D))


Index: clang/test/CodeGen/fprofile-generate.c
===
--- /dev/null
+++ clang/test/CodeGen/fprofile-generate.c
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -fprofile-instrument=llvm -disable-llvm-passes \
+// RUN:   -emit-llvm -o - %s | FileCheck %s
+int g(int);
+
+int __attribute__((__no_instrument_function__))
+__attribute__((no_instrument_function))
+no_instr(int a) {
+// CHECK: define {{.*}} i32 @no_instr(i32 %a) [[ATTR:#[0-9]+]]
+  int sum = 0;
+  for (int i = 0; i < a; i++)
+sum += g(i);
+  return sum;
+}
+
+int instr(int a) {
+// CHECK: define {{.*}} i32 @instr(i32 %a) [[ATTR2:#[0-9]+]]
+  int sum = 0;
+  for (int i = 0; i < a; i++)
+sum += g(i);
+  return sum;
+}
+// CHECK: attributes [[ATTR]] = {{.*}} noprofile
+// CHECK-NOT: attributes [[ATTR2]] = {{.*}} noprofile
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -893,6 +893,9 @@
   if (D && D->hasAttr())
 Fn->addFnAttr("cfi-canonical-jump-table");
 
+  if (D && D->hasAttr())
+Fn->addFnAttr(llvm::Attribute::NoProfile);
+
   if (getLangOpts().OpenCL) {
 // Add metadata for a kernel function.
 if (const FunctionDecl *FD = dyn_cast_or_null(D))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D104248: [compiler-rt][hwasan] Move Thread::Init into hwasan_linux.cpp

2021-06-14 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 351953.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104248

Files:
  compiler-rt/lib/hwasan/hwasan_thread.cpp
  compiler-rt/lib/hwasan/hwasan_thread.h


Index: compiler-rt/lib/hwasan/hwasan_thread.h
===
--- compiler-rt/lib/hwasan/hwasan_thread.h
+++ compiler-rt/lib/hwasan/hwasan_thread.h
@@ -23,8 +23,13 @@
 
 class Thread {
  public:
-  void Init(uptr stack_buffer_start, uptr stack_buffer_size);  // Must be 
called from the thread itself.
+  void Init(uptr stack_buffer_start, uptr stack_buffer_size);
   void InitRandomState();
+  void InitStackAndTls();
+
+  // Must be called from the thread itself.
+  void InitStackRingBuffer(uptr stack_buffer_start, uptr stack_buffer_size);
+
   void Destroy();
 
   uptr stack_top() { return stack_top_; }
Index: compiler-rt/lib/hwasan/hwasan_thread.cpp
===
--- compiler-rt/lib/hwasan/hwasan_thread.cpp
+++ compiler-rt/lib/hwasan/hwasan_thread.cpp
@@ -44,6 +44,20 @@
   if (auto sz = flags()->heap_history_size)
 heap_allocations_ = HeapAllocationsRingBuffer::New(sz);
 
+  InitStackAndTls();
+  InitStackAndRingBuffer(stack_buffer_start, stack_buffer_size);
+}
+
+void Thread::InitStackAndTls() {
+  uptr tls_size;
+  uptr stack_size;
+  GetThreadStackAndTls(IsMainThread(), _bottom_, _size, 
_begin_,
+   _size);
+  stack_top_ = stack_bottom_ + stack_size;
+  tls_end_ = tls_begin_ + tls_size;
+}
+
+void Thread::InitStackRingBuffer(uptr stack_buffer_start, uptr 
stack_buffer_size) {
   HwasanTSDThreadInit();  // Only needed with interceptors.
   uptr *ThreadLong = GetCurrentThreadLongPtr();
   // The following implicitly sets (this) as the current thread.
@@ -55,13 +69,6 @@
   // ScopedTaggingDisable needs GetCurrentThread to be set up.
   ScopedTaggingDisabler disabler;
 
-  uptr tls_size;
-  uptr stack_size;
-  GetThreadStackAndTls(IsMainThread(), _bottom_, _size, 
_begin_,
-   _size);
-  stack_top_ = stack_bottom_ + stack_size;
-  tls_end_ = tls_begin_ + tls_size;
-
   if (stack_bottom_) {
 int local;
 CHECK(AddrIsInStack((uptr)));


Index: compiler-rt/lib/hwasan/hwasan_thread.h
===
--- compiler-rt/lib/hwasan/hwasan_thread.h
+++ compiler-rt/lib/hwasan/hwasan_thread.h
@@ -23,8 +23,13 @@
 
 class Thread {
  public:
-  void Init(uptr stack_buffer_start, uptr stack_buffer_size);  // Must be called from the thread itself.
+  void Init(uptr stack_buffer_start, uptr stack_buffer_size);
   void InitRandomState();
+  void InitStackAndTls();
+
+  // Must be called from the thread itself.
+  void InitStackRingBuffer(uptr stack_buffer_start, uptr stack_buffer_size);
+
   void Destroy();
 
   uptr stack_top() { return stack_top_; }
Index: compiler-rt/lib/hwasan/hwasan_thread.cpp
===
--- compiler-rt/lib/hwasan/hwasan_thread.cpp
+++ compiler-rt/lib/hwasan/hwasan_thread.cpp
@@ -44,6 +44,20 @@
   if (auto sz = flags()->heap_history_size)
 heap_allocations_ = HeapAllocationsRingBuffer::New(sz);
 
+  InitStackAndTls();
+  InitStackAndRingBuffer(stack_buffer_start, stack_buffer_size);
+}
+
+void Thread::InitStackAndTls() {
+  uptr tls_size;
+  uptr stack_size;
+  GetThreadStackAndTls(IsMainThread(), _bottom_, _size, _begin_,
+   _size);
+  stack_top_ = stack_bottom_ + stack_size;
+  tls_end_ = tls_begin_ + tls_size;
+}
+
+void Thread::InitStackRingBuffer(uptr stack_buffer_start, uptr stack_buffer_size) {
   HwasanTSDThreadInit();  // Only needed with interceptors.
   uptr *ThreadLong = GetCurrentThreadLongPtr();
   // The following implicitly sets (this) as the current thread.
@@ -55,13 +69,6 @@
   // ScopedTaggingDisable needs GetCurrentThread to be set up.
   ScopedTaggingDisabler disabler;
 
-  uptr tls_size;
-  uptr stack_size;
-  GetThreadStackAndTls(IsMainThread(), _bottom_, _size, _begin_,
-   _size);
-  stack_top_ = stack_bottom_ + stack_size;
-  tls_end_ = tls_begin_ + tls_size;
-
   if (stack_bottom_) {
 int local;
 CHECK(AddrIsInStack((uptr)));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D104240: [OPENMP][C++20]Add support for CXXRewrittenBinaryOperator in ranged for loops.

2021-06-14 Thread Alexey Bataev 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 rG4e155608796b: [OPENMP][C++20]Add support for 
CXXRewrittenBinaryOperator in ranged for loops. (authored by ABataev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104240

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/for_ast_print_cxx20.cpp

Index: clang/test/OpenMP/for_ast_print_cxx20.cpp
===
--- /dev/null
+++ clang/test/OpenMP/for_ast_print_cxx20.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -verify -fopenmp --std=c++20 -ast-print %s -Wsign-conversion | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++20 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -std=c++20 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
+
+// RUN: %clang_cc1 -verify -fopenmp-simd --std=c++20 -ast-print %s -Wsign-conversion | FileCheck %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++20 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -std=c++20 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+template  class iterator {
+public:
+  T *() const;
+  iterator ++();
+};
+template 
+bool operator==(const iterator &, const iterator &);
+template 
+unsigned long operator-(const iterator &, const iterator &);
+template 
+iterator operator+(const iterator &, unsigned long);
+class vector {
+public:
+  vector();
+  iterator begin();
+  iterator end();
+};
+// CHECK: void foo() {
+void foo() {
+// CHECK-NEXT: vector vec;
+  vector vec;
+// CHECK-NEXT: #pragma omp for
+#pragma omp for
+// CHECK-NEXT: for (int i : vec)
+  for (int i : vec)
+;
+}
+#endif
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -7668,53 +7668,43 @@
   Condition = S;
   S = getExprAsWritten(S);
   SourceLocation CondLoc = S->getBeginLoc();
-  if (auto *BO = dyn_cast(S)) {
-if (BO->isRelationalOp()) {
-  if (getInitLCDecl(BO->getLHS()) == LCDecl)
-return setUB(BO->getRHS(),
- (BO->getOpcode() == BO_LT || BO->getOpcode() == BO_LE),
- (BO->getOpcode() == BO_LT || BO->getOpcode() == BO_GT),
- BO->getSourceRange(), BO->getOperatorLoc());
-  if (getInitLCDecl(BO->getRHS()) == LCDecl)
-return setUB(BO->getLHS(),
- (BO->getOpcode() == BO_GT || BO->getOpcode() == BO_GE),
- (BO->getOpcode() == BO_LT || BO->getOpcode() == BO_GT),
- BO->getSourceRange(), BO->getOperatorLoc());
-} else if (IneqCondIsCanonical && BO->getOpcode() == BO_NE)
-  return setUB(
-  getInitLCDecl(BO->getLHS()) == LCDecl ? BO->getRHS() : BO->getLHS(),
-  /*LessOp=*/llvm::None,
-  /*StrictOp=*/true, BO->getSourceRange(), BO->getOperatorLoc());
+  auto & = [this, IneqCondIsCanonical](
+   BinaryOperatorKind Opcode, const Expr *LHS,
+   const Expr *RHS, SourceRange SR,
+   SourceLocation OpLoc) -> llvm::Optional {
+if (BinaryOperator::isRelationalOp(Opcode)) {
+  if (getInitLCDecl(LHS) == LCDecl)
+return setUB(const_cast(RHS),
+ (Opcode == BO_LT || Opcode == BO_LE),
+ (Opcode == BO_LT || Opcode == BO_GT), SR, OpLoc);
+  if (getInitLCDecl(RHS) == LCDecl)
+return setUB(const_cast(LHS),
+ (Opcode == BO_GT || Opcode == BO_GE),
+ (Opcode == BO_LT || Opcode == BO_GT), SR, OpLoc);
+} else if (IneqCondIsCanonical && Opcode == BO_NE) {
+  return setUB(const_cast(getInitLCDecl(LHS) == LCDecl ? RHS : LHS),
+   /*LessOp=*/llvm::None,
+   /*StrictOp=*/true, SR, OpLoc);
+}
+return llvm::None;
+  };
+  llvm::Optional Res;
+  if (auto *RBO = dyn_cast(S)) {
+CXXRewrittenBinaryOperator::DecomposedForm DF = RBO->getDecomposedForm();
+Res = CheckAndSetCond(DF.Opcode, DF.LHS, DF.RHS, RBO->getSourceRange(),
+  RBO->getOperatorLoc());
+  } else if (auto *BO = dyn_cast(S)) {
+Res = CheckAndSetCond(BO->getOpcode(), BO->getLHS(), BO->getRHS(),
+  BO->getSourceRange(), BO->getOperatorLoc());
   } else if (auto *CE = dyn_cast(S)) {
 if (CE->getNumArgs() == 2) {
-  auto Op = CE->getOperator();
-  switch (Op) {
-  case OO_Greater:
-  case OO_GreaterEqual:
-  case OO_Less:
-  case OO_LessEqual:
-if (getInitLCDecl(CE->getArg(0)) == LCDecl)
-  return setUB(CE->getArg(1), Op == OO_Less || Op == OO_LessEqual,
-   Op == OO_Less || Op == OO_Greater, CE->getSourceRange(),

[clang] 4e15560 - [OPENMP][C++20]Add support for CXXRewrittenBinaryOperator in ranged for loops.

2021-06-14 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2021-06-14T11:50:27-07:00
New Revision: 4e155608796b79d7e369f4e42980ce670bff7172

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

LOG: [OPENMP][C++20]Add support for CXXRewrittenBinaryOperator in ranged for 
loops.

Added support for CXXRewrittenBinaryOperator as a condition in ranged
for loops. This is a new kind of expression, need to extend support for
  C++20 constructs.
It fixes PR49970: range-based for compilation fails for libstdc++ vector
with -std=c++20.

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

Added: 
clang/test/OpenMP/for_ast_print_cxx20.cpp

Modified: 
clang/lib/Sema/SemaOpenMP.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index a67f0910bd07a..0e39b8ef572dc 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -7668,53 +7668,43 @@ bool OpenMPIterationSpaceChecker::checkAndSetCond(Expr 
*S) {
   Condition = S;
   S = getExprAsWritten(S);
   SourceLocation CondLoc = S->getBeginLoc();
-  if (auto *BO = dyn_cast(S)) {
-if (BO->isRelationalOp()) {
-  if (getInitLCDecl(BO->getLHS()) == LCDecl)
-return setUB(BO->getRHS(),
- (BO->getOpcode() == BO_LT || BO->getOpcode() == BO_LE),
- (BO->getOpcode() == BO_LT || BO->getOpcode() == BO_GT),
- BO->getSourceRange(), BO->getOperatorLoc());
-  if (getInitLCDecl(BO->getRHS()) == LCDecl)
-return setUB(BO->getLHS(),
- (BO->getOpcode() == BO_GT || BO->getOpcode() == BO_GE),
- (BO->getOpcode() == BO_LT || BO->getOpcode() == BO_GT),
- BO->getSourceRange(), BO->getOperatorLoc());
-} else if (IneqCondIsCanonical && BO->getOpcode() == BO_NE)
-  return setUB(
-  getInitLCDecl(BO->getLHS()) == LCDecl ? BO->getRHS() : BO->getLHS(),
-  /*LessOp=*/llvm::None,
-  /*StrictOp=*/true, BO->getSourceRange(), BO->getOperatorLoc());
+  auto & = [this, IneqCondIsCanonical](
+   BinaryOperatorKind Opcode, const Expr *LHS,
+   const Expr *RHS, SourceRange SR,
+   SourceLocation OpLoc) -> llvm::Optional {
+if (BinaryOperator::isRelationalOp(Opcode)) {
+  if (getInitLCDecl(LHS) == LCDecl)
+return setUB(const_cast(RHS),
+ (Opcode == BO_LT || Opcode == BO_LE),
+ (Opcode == BO_LT || Opcode == BO_GT), SR, OpLoc);
+  if (getInitLCDecl(RHS) == LCDecl)
+return setUB(const_cast(LHS),
+ (Opcode == BO_GT || Opcode == BO_GE),
+ (Opcode == BO_LT || Opcode == BO_GT), SR, OpLoc);
+} else if (IneqCondIsCanonical && Opcode == BO_NE) {
+  return setUB(const_cast(getInitLCDecl(LHS) == LCDecl ? RHS : 
LHS),
+   /*LessOp=*/llvm::None,
+   /*StrictOp=*/true, SR, OpLoc);
+}
+return llvm::None;
+  };
+  llvm::Optional Res;
+  if (auto *RBO = dyn_cast(S)) {
+CXXRewrittenBinaryOperator::DecomposedForm DF = RBO->getDecomposedForm();
+Res = CheckAndSetCond(DF.Opcode, DF.LHS, DF.RHS, RBO->getSourceRange(),
+  RBO->getOperatorLoc());
+  } else if (auto *BO = dyn_cast(S)) {
+Res = CheckAndSetCond(BO->getOpcode(), BO->getLHS(), BO->getRHS(),
+  BO->getSourceRange(), BO->getOperatorLoc());
   } else if (auto *CE = dyn_cast(S)) {
 if (CE->getNumArgs() == 2) {
-  auto Op = CE->getOperator();
-  switch (Op) {
-  case OO_Greater:
-  case OO_GreaterEqual:
-  case OO_Less:
-  case OO_LessEqual:
-if (getInitLCDecl(CE->getArg(0)) == LCDecl)
-  return setUB(CE->getArg(1), Op == OO_Less || Op == OO_LessEqual,
-   Op == OO_Less || Op == OO_Greater, CE->getSourceRange(),
-   CE->getOperatorLoc());
-if (getInitLCDecl(CE->getArg(1)) == LCDecl)
-  return setUB(CE->getArg(0), Op == OO_Greater || Op == 
OO_GreaterEqual,
-   Op == OO_Less || Op == OO_Greater, CE->getSourceRange(),
-   CE->getOperatorLoc());
-break;
-  case OO_ExclaimEqual:
-if (IneqCondIsCanonical)
-  return setUB(getInitLCDecl(CE->getArg(0)) == LCDecl ? CE->getArg(1)
-  : CE->getArg(0),
-   /*LessOp=*/llvm::None,
-   /*StrictOp=*/true, CE->getSourceRange(),
-   CE->getOperatorLoc());
-break;
-  default:
-break;
-  }
+  Res = CheckAndSetCond(
+  BinaryOperator::getOverloadedOpcode(CE->getOperator()), 
CE->getArg(0),
+  

[PATCH] D104253: [Clang][Codegen] emit noprofile IR Fn Attr for no_instrument_function Fn Attr

2021-06-14 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers created this revision.
nickdesaulniers added reviewers: MaskRay, melver, void.
Herald added a subscriber: wenlei.
nickdesaulniers requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

noprofile IR attribute already exists to prevent profiling with PGO;
emit that when a function uses the no_instrument_function function
attribute.

The Linux kernel would like to avoid compiler generated code in
functions annotated with such attribute. We already respect this for
libcalls to fentry() and mcount().

Link: 
https://lore.kernel.org/lkml/cakwvodmpti93n2l0_yqkrzldmpxzror7zggszonyaw2pgsh...@mail.gmail.com/
Signed-off-by: Nick Desaulniers 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D104253

Files:
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/test/CodeGen/fprofile-generate.c


Index: clang/test/CodeGen/fprofile-generate.c
===
--- /dev/null
+++ clang/test/CodeGen/fprofile-generate.c
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -fprofile-instrument=llvm -emit-llvm -o - %s | FileCheck %s
+int g(int);
+
+int __attribute__((__no_instrument_function__))
+__attribute__((no_instrument_function))
+no_instr(int a) {
+// CHECK: define {{.*}} i32 @no_instr(i32 %a) [[ATTR:#[0-9]+]]
+  int sum = 0;
+  for (int i = 0; i < a; i++)
+sum += g(i);
+  return sum;
+}
+
+int instr(int a) {
+// CHECK: define {{.*}} i32 @instr(i32 %a) [[ATTR2:#[0-9]+]]
+  int sum = 0;
+  for (int i = 0; i < a; i++)
+sum += g(i);
+  return sum;
+}
+// CHECK: attributes [[ATTR]] = {{.*}} noprofile
+// CHECK-NOT: attributes [[ATTR2]] = {{.*}} noprofile
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -893,6 +893,9 @@
   if (D && D->hasAttr())
 Fn->addFnAttr("cfi-canonical-jump-table");
 
+  if (D && D->hasAttr())
+Fn->addFnAttr(llvm::Attribute::NoProfile);
+
   if (getLangOpts().OpenCL) {
 // Add metadata for a kernel function.
 if (const FunctionDecl *FD = dyn_cast_or_null(D))


Index: clang/test/CodeGen/fprofile-generate.c
===
--- /dev/null
+++ clang/test/CodeGen/fprofile-generate.c
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -fprofile-instrument=llvm -emit-llvm -o - %s | FileCheck %s
+int g(int);
+
+int __attribute__((__no_instrument_function__))
+__attribute__((no_instrument_function))
+no_instr(int a) {
+// CHECK: define {{.*}} i32 @no_instr(i32 %a) [[ATTR:#[0-9]+]]
+  int sum = 0;
+  for (int i = 0; i < a; i++)
+sum += g(i);
+  return sum;
+}
+
+int instr(int a) {
+// CHECK: define {{.*}} i32 @instr(i32 %a) [[ATTR2:#[0-9]+]]
+  int sum = 0;
+  for (int i = 0; i < a; i++)
+sum += g(i);
+  return sum;
+}
+// CHECK: attributes [[ATTR]] = {{.*}} noprofile
+// CHECK-NOT: attributes [[ATTR2]] = {{.*}} noprofile
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -893,6 +893,9 @@
   if (D && D->hasAttr())
 Fn->addFnAttr("cfi-canonical-jump-table");
 
+  if (D && D->hasAttr())
+Fn->addFnAttr(llvm::Attribute::NoProfile);
+
   if (getLangOpts().OpenCL) {
 // Add metadata for a kernel function.
 if (const FunctionDecl *FD = dyn_cast_or_null(D))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D104248: [compiler-rt][hwasan] Move Thread::Init into hwasan_linux.cpp

2021-06-14 Thread Roland McGrath via Phabricator via cfe-commits
mcgrathr added inline comments.



Comment at: compiler-rt/lib/hwasan/hwasan_linux.cpp:430
 
+void Thread::Init(uptr stack_buffer_start, uptr stack_buffer_size) {
+  CHECK_EQ(0, unique_id_);  // try to catch bad stack reuse

Most of this code can actually be reused for Fuchsia (just not necessarily in 
Thread::Init).
It's probably better to split it up for reuse rather than just moving the whole 
thing to linux-specific.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104248

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


[PATCH] D103615: [Clang] Add option for vector compare compatibility.

2021-06-14 Thread Bardia Mahjour via Phabricator via cfe-commits
bmahjour added inline comments.



Comment at: clang/include/clang/Basic/LangOptions.h:248
+  enum class VectorCompareCompatKind {
+// Default clang behaviour.
+// All vector compares produce scalars except vector Pixel and vector bool.

How about adding `Default = Mixed` at the end and moving the comment with it?



Comment at: clang/include/clang/Basic/LangOptions.h:249
+// Default clang behaviour.
+// All vector compares produce scalars except vector Pixel and vector bool.
+// The types vector Pixel and vector bool return vector results.

Pixel -> pixel



Comment at: clang/include/clang/Basic/LangOptions.h:250
+// All vector compares produce scalars except vector Pixel and vector bool.
+// The types vector Pixel and vector bool return vector results.
+Mixed,

[nit] Pixel -> pixel



Comment at: clang/lib/Sema/SemaExpr.cpp:12221
+  // which behavior is prefered.
+  switch (getLangOpts().getVectorCompareCompat()) {
+  case LangOptions::VectorCompareCompatKind::Mixed:

Check for `getLangOpts().AltiVec` before the switch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103615

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


[PATCH] D104248: [compiler-rt][hwasan] Move Thread::Init into hwasan_linux.cpp

2021-06-14 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan created this revision.
leonardchan added reviewers: eugenis, vitalybuka, pcc.
leonardchan added a project: Sanitizers.
Herald added a subscriber: dberris.
leonardchan requested review of this revision.
Herald added a subscriber: Sanitizers.

This allows for other implementations to define their own version of 
`Thread::Init`. This will be the case for Fuchsia where much of the thread 
initialization can be broken up between different thread hooks 
(`__sanitizer_before_thread_create_hook`, `__sanitizer_thread_create_hook`, 
`__sanitizer_thread_start_hook`). Namely, setting up the heap ring buffer and 
stack info and can be setup before thread creation. The stack ring buffer can 
also be setup before thread creation, but storing it into `__hwasan_tls` can 
only be done on the thread start hook since it's only then we can access 
`__hwasan_tls` for that thread correctly.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D104248

Files:
  compiler-rt/lib/hwasan/hwasan_linux.cpp
  compiler-rt/lib/hwasan/hwasan_thread.cpp

Index: compiler-rt/lib/hwasan/hwasan_thread.cpp
===
--- compiler-rt/lib/hwasan/hwasan_thread.cpp
+++ compiler-rt/lib/hwasan/hwasan_thread.cpp
@@ -34,51 +34,6 @@
 stack_allocations_->push(0);
 }
 
-void Thread::Init(uptr stack_buffer_start, uptr stack_buffer_size) {
-  CHECK_EQ(0, unique_id_);  // try to catch bad stack reuse
-  CHECK_EQ(0, stack_top_);
-  CHECK_EQ(0, stack_bottom_);
-
-  static u64 unique_id;
-  unique_id_ = unique_id++;
-  if (auto sz = flags()->heap_history_size)
-heap_allocations_ = HeapAllocationsRingBuffer::New(sz);
-
-  HwasanTSDThreadInit();  // Only needed with interceptors.
-  uptr *ThreadLong = GetCurrentThreadLongPtr();
-  // The following implicitly sets (this) as the current thread.
-  stack_allocations_ = new (ThreadLong)
-  StackAllocationsRingBuffer((void *)stack_buffer_start, stack_buffer_size);
-  // Check that it worked.
-  CHECK_EQ(GetCurrentThread(), this);
-
-  // ScopedTaggingDisable needs GetCurrentThread to be set up.
-  ScopedTaggingDisabler disabler;
-
-  uptr tls_size;
-  uptr stack_size;
-  GetThreadStackAndTls(IsMainThread(), _bottom_, _size, _begin_,
-   _size);
-  stack_top_ = stack_bottom_ + stack_size;
-  tls_end_ = tls_begin_ + tls_size;
-
-  if (stack_bottom_) {
-int local;
-CHECK(AddrIsInStack((uptr)));
-CHECK(MemIsApp(stack_bottom_));
-CHECK(MemIsApp(stack_top_ - 1));
-  }
-
-  if (flags()->verbose_threads) {
-if (IsMainThread()) {
-  Printf("sizeof(Thread): %zd sizeof(HeapRB): %zd sizeof(StackRB): %zd\n",
- sizeof(Thread), heap_allocations_->SizeInBytes(),
- stack_allocations_->size() * sizeof(uptr));
-}
-Print("Creating  : ");
-  }
-}
-
 void Thread::ClearShadowForThreadStackAndTLS() {
   if (stack_top_ != stack_bottom_)
 TagMemory(stack_bottom_, stack_top_ - stack_bottom_, 0);
Index: compiler-rt/lib/hwasan/hwasan_linux.cpp
===
--- compiler-rt/lib/hwasan/hwasan_linux.cpp
+++ compiler-rt/lib/hwasan/hwasan_linux.cpp
@@ -427,6 +427,50 @@
   HandleDeadlySignal(info, context, GetTid(), , nullptr);
 }
 
+void Thread::Init(uptr stack_buffer_start, uptr stack_buffer_size) {
+  CHECK_EQ(0, unique_id_);  // try to catch bad stack reuse
+  CHECK_EQ(0, stack_top_);
+  CHECK_EQ(0, stack_bottom_);
+
+  static u64 unique_id;
+  unique_id_ = unique_id++;
+  if (auto sz = flags()->heap_history_size)
+heap_allocations_ = HeapAllocationsRingBuffer::New(sz);
+
+  HwasanTSDThreadInit();  // Only needed with interceptors.
+  uptr *ThreadLong = GetCurrentThreadLongPtr();
+  // The following implicitly sets (this) as the current thread.
+  stack_allocations_ = new (ThreadLong)
+  StackAllocationsRingBuffer((void *)stack_buffer_start, stack_buffer_size);
+  // Check that it worked.
+  CHECK_EQ(GetCurrentThread(), this);
+
+  // ScopedTaggingDisable needs GetCurrentThread to be set up.
+  ScopedTaggingDisabler disabler;
+
+  uptr tls_size;
+  uptr stack_size;
+  GetThreadStackAndTls(IsMainThread(), _bottom_, _size, _begin_,
+   _size);
+  stack_top_ = stack_bottom_ + stack_size;
+  tls_end_ = tls_begin_ + tls_size;
+
+  if (stack_bottom_) {
+int local;
+CHECK(AddrIsInStack((uptr)));
+CHECK(MemIsApp(stack_bottom_));
+CHECK(MemIsApp(stack_top_ - 1));
+  }
+
+  if (flags()->verbose_threads) {
+if (IsMainThread()) {
+  Printf("sizeof(Thread): %zd sizeof(HeapRB): %zd sizeof(StackRB): %zd\n",
+ sizeof(Thread), heap_allocations_->SizeInBytes(),
+ stack_allocations_->size() * sizeof(uptr));
+}
+Print("Creating  : ");
+  }
+}
 
 } // namespace __hwasan
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D98068: Exampt asserts for recursive lambdas about LocalInstantiationScope

2021-06-14 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 351934.
yaxunl retitled this revision from "Remove asserts for LocalInstantiationScope" 
to "Exampt asserts for recursive lambdas about LocalInstantiationScope".
yaxunl edited the summary of this revision.
yaxunl added a comment.

re-enable the assert but with exception for recursive lambda functions


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

https://reviews.llvm.org/D98068

Files:
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/test/SemaCXX/recursive-lambda.cpp


Index: clang/test/SemaCXX/recursive-lambda.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/recursive-lambda.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify %s
+
+// expected-no-diagnostics
+
+// Check recursive instantiation of lambda does not cause assertion.
+// lambda function `f` in `fun1` is instantiated twice: first
+// as f(f, Number<1>), then as f(f, Number<0>). The
+// LocalInstantiationScopes of these two instantiations both contain
+// `f` and `i`. Clang should not assert for that.
+
+template 
+struct Number
+{
+   static constexpr unsigned value = v;
+};
+
+template 
+constexpr auto fun1(Number = Number<0>{}, Number  = Number<1>{})
+{
+  auto f = [&](auto fs, auto i) {
+if constexpr(i.value > 0)
+{
+  return fs(fs, Number{});
+}
+  };
+
+  return f(f, Number{});
+}
+
+
+void fun2() {
+  fun1();
+}
Index: clang/lib/Sema/SemaTemplateInstantiate.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -3624,11 +3624,13 @@
   llvm::PointerUnion  = LocalDecls[D];
   if (Stored.isNull()) {
 #ifndef NDEBUG
-// It should not be present in any surrounding scope either.
+// It should not be present in any surrounding scope either except for
+// recursive lambda functions.
 LocalInstantiationScope *Current = this;
 while (Current->CombineWithOuterScope && Current->Outer) {
   Current = Current->Outer;
-  assert(Current->LocalDecls.find(D) == Current->LocalDecls.end() &&
+  assert((isLambdaCallOperator(D->getDeclContext()) ||
+  Current->LocalDecls.find(D) == Current->LocalDecls.end()) &&
  "Instantiated local in inner and outer scopes");
 }
 #endif
@@ -3649,10 +3651,12 @@
 
 void LocalInstantiationScope::MakeInstantiatedLocalArgPack(const Decl *D) {
 #ifndef NDEBUG
-  // This should be the first time we've been told about this decl.
+  // This should be the first time we've been told about this decl except for
+  // recursive lambda functions.
   for (LocalInstantiationScope *Current = this;
Current && Current->CombineWithOuterScope; Current = Current->Outer)
-assert(Current->LocalDecls.find(D) == Current->LocalDecls.end() &&
+assert((isLambdaCallOperator(D->getDeclContext()) ||
+Current->LocalDecls.find(D) == Current->LocalDecls.end()) &&
"Creating local pack after instantiation of local");
 #endif
 


Index: clang/test/SemaCXX/recursive-lambda.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/recursive-lambda.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify %s
+
+// expected-no-diagnostics
+
+// Check recursive instantiation of lambda does not cause assertion.
+// lambda function `f` in `fun1` is instantiated twice: first
+// as f(f, Number<1>), then as f(f, Number<0>). The
+// LocalInstantiationScopes of these two instantiations both contain
+// `f` and `i`. Clang should not assert for that.
+
+template 
+struct Number
+{
+   static constexpr unsigned value = v;
+};
+
+template 
+constexpr auto fun1(Number = Number<0>{}, Number  = Number<1>{})
+{
+  auto f = [&](auto fs, auto i) {
+if constexpr(i.value > 0)
+{
+  return fs(fs, Number{});
+}
+  };
+
+  return f(f, Number{});
+}
+
+
+void fun2() {
+  fun1();
+}
Index: clang/lib/Sema/SemaTemplateInstantiate.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -3624,11 +3624,13 @@
   llvm::PointerUnion  = LocalDecls[D];
   if (Stored.isNull()) {
 #ifndef NDEBUG
-// It should not be present in any surrounding scope either.
+// It should not be present in any surrounding scope either except for
+// recursive lambda functions.
 LocalInstantiationScope *Current = this;
 while (Current->CombineWithOuterScope && Current->Outer) {
   Current = Current->Outer;
-  assert(Current->LocalDecls.find(D) == Current->LocalDecls.end() &&
+  assert((isLambdaCallOperator(D->getDeclContext()) ||
+  Current->LocalDecls.find(D) == Current->LocalDecls.end()) &&
  "Instantiated local in inner and outer scopes");
 }
 #endif
@@ -3649,10 +3651,12 @@
 
 void 

[PATCH] D104240: [OPENMP][C++20]Add support for CXXRewrittenBinaryOperator in ranged for loops.

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

LG, thanks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104240

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


[PATCH] D103936: [compiler-rt][hwasan] Define fuchsia implementations of required hwasan functions

2021-06-14 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 351931.
leonardchan marked 10 inline comments as done.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103936

Files:
  compiler-rt/lib/hwasan/CMakeLists.txt
  compiler-rt/lib/hwasan/hwasan_fuchsia.cpp


Index: compiler-rt/lib/hwasan/hwasan_fuchsia.cpp
===
--- /dev/null
+++ compiler-rt/lib/hwasan/hwasan_fuchsia.cpp
@@ -0,0 +1,68 @@
+//===-- hwasan_fuchsia.cpp --*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+///
+/// \file
+/// This file is a part of HWAddressSanitizer and contains Fuchsia-specific
+/// code.
+///
+//===--===//
+
+#include "sanitizer_common/sanitizer_fuchsia.h"
+#if SANITIZER_FUCHSIA
+
+#include "hwasan.h"
+#include "hwasan_interface_internal.h"
+#include "hwasan_report.h"
+#include "hwasan_thread.h"
+#include "hwasan_thread_list.h"
+
+namespace __hwasan {
+
+bool InitShadow() {
+  // TODO(leonardchan): Remove the runtime variable altogether once we 
implement
+  // something similar to SHADOW_OFFSET for hwasan. Ideally, the runtime would
+  // just know this value is zero everywhere it's used.
+  __hwasan_shadow_memory_dynamic_address = 0;
+
+  // Call this explicitly to set the ShadowBounds global so we can reference it
+  // now. Otherwise, ShadowBounds will be a zero-initialized global.
+  ShadowBounds = __sanitizer_shadow_bounds();
+  CHECK_NE(__sanitizer::ShadowBounds.shadow_limit, 0);
+
+  return true;
+}
+
+bool MemIsApp(uptr p) {
+  CHECK(GetTagFromPointer(p) == 0);
+  return __sanitizer::ShadowBounds.shadow_limit <= p &&
+ p <= __sanitizer::GetMaxUserVirtualAddress();
+}
+
+// Not implemented because Fuchsia does not use signal handlers.
+void HwasanOnDeadlySignal(int signo, void *info, void *context) {}
+
+// Not implemented because Fuchsia does not use interceptors.
+void InitializeInterceptors() {}
+
+// Not implemented because this is only relevant for Android.
+void AndroidTestTlsSlot() {}
+
+// TSD was normally used on linux as a means of calling the hwasan thread exit
+// handler passed to pthread_key_create. This is not needed on Fuchsia because
+// we will be using __sanitizer_thread_exit_hook.
+void HwasanTSDInit() {}
+void HwasanTSDThreadInit() {}
+
+// On linux, this just would call `atexit(HwasanAtExit)`. The functions in
+// HwasanAtExit are unimplemented for Fuchsia and effectively no-ops, so this
+// function is unneeded.
+void InstallAtExitHandler() {}
+
+}  // namespace __hwasan
+
+#endif  // SANITIZER_FUCHSIA
Index: compiler-rt/lib/hwasan/CMakeLists.txt
===
--- compiler-rt/lib/hwasan/CMakeLists.txt
+++ compiler-rt/lib/hwasan/CMakeLists.txt
@@ -7,6 +7,7 @@
   hwasan_allocation_functions.cpp
   hwasan_dynamic_shadow.cpp
   hwasan_exceptions.cpp
+  hwasan_fuchsia.cpp
   hwasan_globals.cpp
   hwasan_interceptors.cpp
   hwasan_interceptors_vfork.S


Index: compiler-rt/lib/hwasan/hwasan_fuchsia.cpp
===
--- /dev/null
+++ compiler-rt/lib/hwasan/hwasan_fuchsia.cpp
@@ -0,0 +1,68 @@
+//===-- hwasan_fuchsia.cpp --*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+///
+/// \file
+/// This file is a part of HWAddressSanitizer and contains Fuchsia-specific
+/// code.
+///
+//===--===//
+
+#include "sanitizer_common/sanitizer_fuchsia.h"
+#if SANITIZER_FUCHSIA
+
+#include "hwasan.h"
+#include "hwasan_interface_internal.h"
+#include "hwasan_report.h"
+#include "hwasan_thread.h"
+#include "hwasan_thread_list.h"
+
+namespace __hwasan {
+
+bool InitShadow() {
+  // TODO(leonardchan): Remove the runtime variable altogether once we implement
+  // something similar to SHADOW_OFFSET for hwasan. Ideally, the runtime would
+  // just know this value is zero everywhere it's used.
+  __hwasan_shadow_memory_dynamic_address = 0;
+
+  // Call this explicitly to set the ShadowBounds global so we can reference it
+  // now. Otherwise, ShadowBounds will be a zero-initialized global.
+  ShadowBounds = __sanitizer_shadow_bounds();
+  CHECK_NE(__sanitizer::ShadowBounds.shadow_limit, 0);
+
+  return true;
+}
+
+bool MemIsApp(uptr p) {
+  

[PATCH] D94500: [clang-format] Rework Whitesmiths mode to use line-level values in UnwrappedLineParser

2021-06-14 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a subscriber: tstellar.
MyDeveloperDay added a comment.

I think we've missed the deadline for 12.0.1 which I believe was last friday. I 
did a practice merge and it didn't quite go in cleanly to 12.0.X branch

Normally we would mark the bug in the bug tracker for the next release, this is 
what I did for another bug and @tstellar I think picked it up and merge it for 
us.

I'm not sure if we are doing a 12.0.2 release but I've added that as the 
"Blocks" tag in the bug tracker, one of us can merge it if Tom wants us to.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94500

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


[clang] d650ccf - [NFC] Remove unused variable

2021-06-14 Thread Vitaly Buka via cfe-commits

Author: Vitaly Buka
Date: 2021-06-14T10:57:26-07:00
New Revision: d650ccf6390bb1e4454dd735cfcec9eda9af8ca3

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

LOG: [NFC] Remove unused variable

To fix 'set but not used' warning on sanitizer-x86_64-linux-android bot.

Added: 


Modified: 
clang/lib/Format/WhitespaceManager.cpp

Removed: 




diff  --git a/clang/lib/Format/WhitespaceManager.cpp 
b/clang/lib/Format/WhitespaceManager.cpp
index 222c4c4e8e29a..b079eac9803c4 100644
--- a/clang/lib/Format/WhitespaceManager.cpp
+++ b/clang/lib/Format/WhitespaceManager.cpp
@@ -1068,9 +1068,6 @@ void 
WhitespaceManager::alignArrayInitializersLeftJustified(
 Changes[CellIter->Index].Spaces = CellDescs.InitialSpaces;
   ++CellIter;
   for (auto i = 1U; i < CellDescs.CellCount; i++, ++CellIter) {
-unsigned NetWidth = 0U;
-if (isSplitCell(*CellIter))
-  NetWidth = getNetWidth(Cells.begin(), CellIter, CellDescs.InitialSpaces);
 auto MaxNetWidth = getMaximumNetWidth(
 Cells.begin(), CellIter, CellDescs.InitialSpaces, CellDescs.CellCount);
 auto ThisNetWidth =



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


[PATCH] D103899: [OpenMP] Fix C-only clang assert on parsing use_allocator clause of target directive

2021-06-14 Thread Alexey Bataev 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 rG44f197e94b83: [OpenMP] Fix C-only clang assert on parsing 
use_allocator clause of target… (authored by ABataev).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103899

Files:
  clang/lib/Parse/ParseOpenMP.cpp
  clang/test/OpenMP/target_uses_allocators.c


Index: clang/test/OpenMP/target_uses_allocators.c
===
--- /dev/null
+++ clang/test/OpenMP/target_uses_allocators.c
@@ -0,0 +1,44 @@
+// Test host codegen.
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=50  -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu
+
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+enum omp_allocator_handle_t {
+  omp_null_allocator = 0,
+  omp_default_mem_alloc = 1,
+  omp_large_cap_mem_alloc = 2,
+  omp_const_mem_alloc = 3,
+  omp_high_bw_mem_alloc = 4,
+  omp_low_lat_mem_alloc = 5,
+  omp_cgroup_mem_alloc = 6,
+  omp_pteam_mem_alloc = 7,
+  omp_thread_mem_alloc = 8,
+  KMP_ALLOCATOR_MAX_HANDLE = __UINTPTR_MAX__
+};
+
+// CHECK: define {{.*}}[[FIE:@.+]]()
+void fie() {
+  int x;
+  #pragma omp target uses_allocators(omp_null_allocator) 
allocate(omp_null_allocator: x) firstprivate(x)
+  {}
+  #pragma omp target uses_allocators(omp_default_mem_alloc) 
allocate(omp_default_mem_alloc: x) firstprivate(x)
+  {}
+  #pragma omp target uses_allocators(omp_large_cap_mem_alloc) 
allocate(omp_large_cap_mem_alloc: x) firstprivate(x)
+  {}
+  #pragma omp target uses_allocators(omp_const_mem_alloc) 
allocate(omp_const_mem_alloc: x) firstprivate(x)
+  {}
+  #pragma omp target uses_allocators(omp_high_bw_mem_alloc) 
allocate(omp_high_bw_mem_alloc: x) firstprivate(x)
+  {}
+  #pragma omp target uses_allocators(omp_low_lat_mem_alloc) 
allocate(omp_low_lat_mem_alloc: x) firstprivate(x)
+  {}
+  #pragma omp target uses_allocators(omp_cgroup_mem_alloc) 
allocate(omp_cgroup_mem_alloc: x) firstprivate(x)
+  {}
+  #pragma omp target uses_allocators(omp_pteam_mem_alloc) 
allocate(omp_pteam_mem_alloc: x) firstprivate(x)
+  {}
+}
+
+#endif
Index: clang/lib/Parse/ParseOpenMP.cpp
===
--- clang/lib/Parse/ParseOpenMP.cpp
+++ clang/lib/Parse/ParseOpenMP.cpp
@@ -2708,7 +2708,8 @@
 return nullptr;
   SmallVector Data;
   do {
-ExprResult Allocator = ParseCXXIdExpression();
+ExprResult Allocator =
+getLangOpts().CPlusPlus ? ParseCXXIdExpression() : ParseExpression();
 if (Allocator.isInvalid()) {
   SkipUntil(tok::comma, tok::r_paren, tok::annot_pragma_openmp_end,
 StopBeforeMatch);
@@ -2720,7 +2721,8 @@
   BalancedDelimiterTracker T(*this, tok::l_paren,
  tok::annot_pragma_openmp_end);
   T.consumeOpen();
-  ExprResult AllocatorTraits = ParseCXXIdExpression();
+  ExprResult AllocatorTraits =
+  getLangOpts().CPlusPlus ? ParseCXXIdExpression() : ParseExpression();
   T.consumeClose();
   if (AllocatorTraits.isInvalid()) {
 SkipUntil(tok::comma, tok::r_paren, tok::annot_pragma_openmp_end,


Index: clang/test/OpenMP/target_uses_allocators.c
===
--- /dev/null
+++ clang/test/OpenMP/target_uses_allocators.c
@@ -0,0 +1,44 @@
+// Test host codegen.
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=50  -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu
+
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+enum omp_allocator_handle_t {
+  omp_null_allocator = 0,
+  omp_default_mem_alloc = 1,
+  omp_large_cap_mem_alloc = 2,
+  omp_const_mem_alloc = 3,
+  omp_high_bw_mem_alloc = 4,
+  omp_low_lat_mem_alloc = 5,
+  omp_cgroup_mem_alloc = 6,
+  omp_pteam_mem_alloc = 7,
+  omp_thread_mem_alloc = 8,
+  KMP_ALLOCATOR_MAX_HANDLE = __UINTPTR_MAX__
+};
+
+// CHECK: define {{.*}}[[FIE:@.+]]()
+void fie() {
+  int x;
+  #pragma omp target 

[clang] 44f197e - [OpenMP] Fix C-only clang assert on parsing use_allocator clause of target directive

2021-06-14 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2021-06-14T10:36:27-07:00
New Revision: 44f197e94b83d389b59ce6a2a1977f972e6d34e3

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

LOG: [OpenMP] Fix C-only clang assert on parsing use_allocator clause of target 
directive

The parser code assumes building with C++ compiler and asserts when using clang 
(not clang++) on C file. I made the code dependent on input language. This 
shows up for amdgpu target.

Reviewed By: ABataev

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

Added: 
clang/test/OpenMP/target_uses_allocators.c

Modified: 
clang/lib/Parse/ParseOpenMP.cpp

Removed: 




diff  --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index d3a456fca49c..d2152fd11793 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -2708,7 +2708,8 @@ OMPClause 
*Parser::ParseOpenMPUsesAllocatorClause(OpenMPDirectiveKind DKind) {
 return nullptr;
   SmallVector Data;
   do {
-ExprResult Allocator = ParseCXXIdExpression();
+ExprResult Allocator =
+getLangOpts().CPlusPlus ? ParseCXXIdExpression() : ParseExpression();
 if (Allocator.isInvalid()) {
   SkipUntil(tok::comma, tok::r_paren, tok::annot_pragma_openmp_end,
 StopBeforeMatch);
@@ -2720,7 +2721,8 @@ OMPClause 
*Parser::ParseOpenMPUsesAllocatorClause(OpenMPDirectiveKind DKind) {
   BalancedDelimiterTracker T(*this, tok::l_paren,
  tok::annot_pragma_openmp_end);
   T.consumeOpen();
-  ExprResult AllocatorTraits = ParseCXXIdExpression();
+  ExprResult AllocatorTraits =
+  getLangOpts().CPlusPlus ? ParseCXXIdExpression() : ParseExpression();
   T.consumeClose();
   if (AllocatorTraits.isInvalid()) {
 SkipUntil(tok::comma, tok::r_paren, tok::annot_pragma_openmp_end,

diff  --git a/clang/test/OpenMP/target_uses_allocators.c 
b/clang/test/OpenMP/target_uses_allocators.c
new file mode 100644
index ..5d1aaa37d845
--- /dev/null
+++ b/clang/test/OpenMP/target_uses_allocators.c
@@ -0,0 +1,44 @@
+// Test host codegen.
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=50  -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c++ -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu
+
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+enum omp_allocator_handle_t {
+  omp_null_allocator = 0,
+  omp_default_mem_alloc = 1,
+  omp_large_cap_mem_alloc = 2,
+  omp_const_mem_alloc = 3,
+  omp_high_bw_mem_alloc = 4,
+  omp_low_lat_mem_alloc = 5,
+  omp_cgroup_mem_alloc = 6,
+  omp_pteam_mem_alloc = 7,
+  omp_thread_mem_alloc = 8,
+  KMP_ALLOCATOR_MAX_HANDLE = __UINTPTR_MAX__
+};
+
+// CHECK: define {{.*}}[[FIE:@.+]]()
+void fie() {
+  int x;
+  #pragma omp target uses_allocators(omp_null_allocator) 
allocate(omp_null_allocator: x) firstprivate(x)
+  {}
+  #pragma omp target uses_allocators(omp_default_mem_alloc) 
allocate(omp_default_mem_alloc: x) firstprivate(x)
+  {}
+  #pragma omp target uses_allocators(omp_large_cap_mem_alloc) 
allocate(omp_large_cap_mem_alloc: x) firstprivate(x)
+  {}
+  #pragma omp target uses_allocators(omp_const_mem_alloc) 
allocate(omp_const_mem_alloc: x) firstprivate(x)
+  {}
+  #pragma omp target uses_allocators(omp_high_bw_mem_alloc) 
allocate(omp_high_bw_mem_alloc: x) firstprivate(x)
+  {}
+  #pragma omp target uses_allocators(omp_low_lat_mem_alloc) 
allocate(omp_low_lat_mem_alloc: x) firstprivate(x)
+  {}
+  #pragma omp target uses_allocators(omp_cgroup_mem_alloc) 
allocate(omp_cgroup_mem_alloc: x) firstprivate(x)
+  {}
+  #pragma omp target uses_allocators(omp_pteam_mem_alloc) 
allocate(omp_pteam_mem_alloc: x) firstprivate(x)
+  {}
+}
+
+#endif



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


[PATCH] D94500: [clang-format] Rework Whitesmiths mode to use line-level values in UnwrappedLineParser

2021-06-14 Thread Tim Wojtulewicz via Phabricator via cfe-commits
timwoj added a comment.

> A crash (https://bugs.llvm.org/show_bug.cgi?id=50663) in 12.0.1 is fixed by 
> your changes here when merged to the 12 branch, I'm not sure if this needs to 
> be backported to 12 I guess it might depend on if we think it's critical 
> enough or if there will more 12 release candidates before 13 @timwoj any 
> thoughts?

It should apply cleanly to 12.0 as far as I know, since if I remember right I 
had asked if it could be merged before 12.0 was released. I don't have a whole 
lot of free cycles at the moment to help with it if it needs a lot of changes 
though. My vote is yes to backport it, if it counts for anything.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94500

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


[PATCH] D103623: [Clang] Test case for -Wunused-but-set-variable, warn for volatile.

2021-06-14 Thread George Burgess IV via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG20f7b5f3f9c8: [Clang] Test case for 
-Wunused-but-set-variable, warn for volatile. (authored by mbenfield, committed 
by george.burgess.iv).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103623

Files:
  clang/test/Sema/warn-unused-but-set-variables.c


Index: clang/test/Sema/warn-unused-but-set-variables.c
===
--- clang/test/Sema/warn-unused-but-set-variables.c
+++ clang/test/Sema/warn-unused-but-set-variables.c
@@ -23,6 +23,10 @@
   int a;
   w = (a = 0);
 
+  // Following gcc, warn for a volatile variable.
+  volatile int b; // expected-warning{{variable 'b' set but not used}}
+  b = 0;
+
   int x;
   x = 0;
   return x;


Index: clang/test/Sema/warn-unused-but-set-variables.c
===
--- clang/test/Sema/warn-unused-but-set-variables.c
+++ clang/test/Sema/warn-unused-but-set-variables.c
@@ -23,6 +23,10 @@
   int a;
   w = (a = 0);
 
+  // Following gcc, warn for a volatile variable.
+  volatile int b; // expected-warning{{variable 'b' set but not used}}
+  b = 0;
+
   int x;
   x = 0;
   return x;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 20f7b5f - [Clang] Test case for -Wunused-but-set-variable, warn for volatile.

2021-06-14 Thread George Burgess IV via cfe-commits

Author: Michael Benfield
Date: 2021-06-14T10:25:59-07:00
New Revision: 20f7b5f3f9c8ebbbe7bf6648c824b815385d4bf7

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

LOG: [Clang] Test case for -Wunused-but-set-variable, warn for volatile.

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

Added: 


Modified: 
clang/test/Sema/warn-unused-but-set-variables.c

Removed: 




diff  --git a/clang/test/Sema/warn-unused-but-set-variables.c 
b/clang/test/Sema/warn-unused-but-set-variables.c
index 93595a251df0..a8d05243321f 100644
--- a/clang/test/Sema/warn-unused-but-set-variables.c
+++ b/clang/test/Sema/warn-unused-but-set-variables.c
@@ -23,6 +23,10 @@ int f0() {
   int a;
   w = (a = 0);
 
+  // Following gcc, warn for a volatile variable.
+  volatile int b; // expected-warning{{variable 'b' set but not used}}
+  b = 0;
+
   int x;
   x = 0;
   return x;



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


[PATCH] D103702: [AArch64][SVE] Wire up vscale_range attribute to SVE min/max vector queries

2021-06-14 Thread Paul Walker via Phabricator via cfe-commits
paulwalker-arm added inline comments.



Comment at: llvm/lib/Target/AArch64/AArch64Subtarget.h:298-299
+   bool LittleEndian,
+   unsigned MinSVEVectorSizeInBitsOverride = 0,
+   unsigned MaxSVEVectorSizeInBitsOverride = 0);
 

Out of interest are these defaults ever relied upon?



Comment at: llvm/lib/Target/AArch64/AArch64TargetMachine.cpp:380-386
+  assert(MinSVEVectorSize % 128 == 0 &&
+ "SVE requires vector length in multiples of 128!");
+  assert(MaxSVEVectorSize % 128 == 0 &&
+ "SVE requires vector length in multiples of 128!");
+  assert((MaxSVEVectorSize >= MinSVEVectorSize ||
+  MaxSVEVectorSize == 0) &&
+ "Minimum SVE vector size should not be larger than its maximum!");

These asserts are fine but you'll see from the original implementations of 
`getM..SVEVectorSizeInBits` that I do not rely on the user passing the correct 
values.  Instead I also always process the sizes to ensure the values of 
`MinSVEVectorSize` and `MaxSVEVectorSize`are sane.  Can you do likewise here?



Comment at: llvm/lib/Target/AArch64/AArch64TargetMachine.cpp:357
+  Attribute VScaleRangeAttr = F.getFnAttribute(Attribute::VScaleRange);
+  if (VScaleRangeAttr.isValid())
+std::tie(MinSVEVectorSize, MaxSVEVectorSize) =

bsmith wrote:
> paulwalker-arm wrote:
> > I don't know if this is possible but I feel we need a `HasSVE` like check 
> > here?
> I'm not sure this is really doable here without picking apart the feature 
> string, I think it makes more sense to just set the values and assert when 
> using the accessors without SVE enabled.
Fair enough.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103702

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


[PATCH] D104125: [PowerPC] Moving defineXLCompatMacros() definition

2021-06-14 Thread Lei Huang via Phabricator via cfe-commits
lei accepted this revision.
lei added a comment.
This revision is now accepted and ready to land.

LGTM
Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104125

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


[PATCH] D104242: Removes an unused variable and alters a lit test to simplify and avoid a buildbot error

2021-06-14 Thread Fred Grim via Phabricator via cfe-commits
feg208 created this revision.
feg208 added reviewers: HazardyKnusperkeks, Bigcheese.
feg208 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D104242

Files:
  clang/lib/Format/WhitespaceManager.cpp
  clang/test/Format/struct-array-initializer.cpp


Index: clang/test/Format/struct-array-initializer.cpp
===
--- clang/test/Format/struct-array-initializer.cpp
+++ clang/test/Format/struct-array-initializer.cpp
@@ -1,9 +1,5 @@
-// RUN: grep -Ev "// *[A-Z-]+:" %s \
-// RUN:   | clang-format -style="{BasedOnStyle: LLVM, AlignArrayOfStructures: 
Right}" %s \
-// RUN:   | FileCheck -strict-whitespace -check-prefix=CHECK1 %s
-// RUN: grep -Ev "// *[A-Z-]+:" %s \
-// RUN:   | clang-format -style="{BasedOnStyle: LLVM, AlignArrayOfStructures: 
Left}" %s \
-// RUN:   | FileCheck -strict-whitespace -check-prefix=CHECK2 %s
+// RUN: clang-format -style="{BasedOnStyle: LLVM, AlignArrayOfStructures: 
Right}" %s | FileCheck -strict-whitespace -check-prefix=CHECK1 %s
+// RUN: clang-format -style="{BasedOnStyle: LLVM, AlignArrayOfStructures: 
Left}" %s | FileCheck -strict-whitespace -check-prefix=CHECK2 %s
 struct test {
   int a;
   int b;
Index: clang/lib/Format/WhitespaceManager.cpp
===
--- clang/lib/Format/WhitespaceManager.cpp
+++ clang/lib/Format/WhitespaceManager.cpp
@@ -1068,9 +1068,6 @@
 Changes[CellIter->Index].Spaces = CellDescs.InitialSpaces;
   ++CellIter;
   for (auto i = 1U; i < CellDescs.CellCount; i++, ++CellIter) {
-unsigned NetWidth = 0U;
-if (isSplitCell(*CellIter))
-  NetWidth = getNetWidth(Cells.begin(), CellIter, CellDescs.InitialSpaces);
 auto MaxNetWidth = getMaximumNetWidth(
 Cells.begin(), CellIter, CellDescs.InitialSpaces, CellDescs.CellCount);
 auto ThisNetWidth =


Index: clang/test/Format/struct-array-initializer.cpp
===
--- clang/test/Format/struct-array-initializer.cpp
+++ clang/test/Format/struct-array-initializer.cpp
@@ -1,9 +1,5 @@
-// RUN: grep -Ev "// *[A-Z-]+:" %s \
-// RUN:   | clang-format -style="{BasedOnStyle: LLVM, AlignArrayOfStructures: Right}" %s \
-// RUN:   | FileCheck -strict-whitespace -check-prefix=CHECK1 %s
-// RUN: grep -Ev "// *[A-Z-]+:" %s \
-// RUN:   | clang-format -style="{BasedOnStyle: LLVM, AlignArrayOfStructures: Left}" %s \
-// RUN:   | FileCheck -strict-whitespace -check-prefix=CHECK2 %s
+// RUN: clang-format -style="{BasedOnStyle: LLVM, AlignArrayOfStructures: Right}" %s | FileCheck -strict-whitespace -check-prefix=CHECK1 %s
+// RUN: clang-format -style="{BasedOnStyle: LLVM, AlignArrayOfStructures: Left}" %s | FileCheck -strict-whitespace -check-prefix=CHECK2 %s
 struct test {
   int a;
   int b;
Index: clang/lib/Format/WhitespaceManager.cpp
===
--- clang/lib/Format/WhitespaceManager.cpp
+++ clang/lib/Format/WhitespaceManager.cpp
@@ -1068,9 +1068,6 @@
 Changes[CellIter->Index].Spaces = CellDescs.InitialSpaces;
   ++CellIter;
   for (auto i = 1U; i < CellDescs.CellCount; i++, ++CellIter) {
-unsigned NetWidth = 0U;
-if (isSplitCell(*CellIter))
-  NetWidth = getNetWidth(Cells.begin(), CellIter, CellDescs.InitialSpaces);
 auto MaxNetWidth = getMaximumNetWidth(
 Cells.begin(), CellIter, CellDescs.InitialSpaces, CellDescs.CellCount);
 auto ThisNetWidth =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D103702: [AArch64][SVE] Wire up vscale_range attribute to SVE min/max vector queries

2021-06-14 Thread Bradley Smith via Phabricator via cfe-commits
bsmith added inline comments.



Comment at: llvm/lib/Target/AArch64/AArch64Subtarget.cpp:226
+ : SVEVectorBitsMaxOpt),
   TargetTriple(TT), FrameLowering(),
   InstrInfo(initializeSubtargetDependencies(FS, CPU)), TSInfo(),

sdesmalen wrote:
> nit: Does this need an assert that Min|MaxSVEVectorSizeInBits is zero when 
> SVE is not enabled in the feature string?
In principal you could, however I'm not sure it adds any value, as the 
accessors already assert that SVE is enabled. (And in principal this is a 
generic attribute, not an SVE one).



Comment at: llvm/lib/Target/AArch64/AArch64TargetMachine.cpp:357
+  Attribute VScaleRangeAttr = F.getFnAttribute(Attribute::VScaleRange);
+  if (VScaleRangeAttr.isValid())
+std::tie(MinSVEVectorSize, MaxSVEVectorSize) =

paulwalker-arm wrote:
> I don't know if this is possible but I feel we need a `HasSVE` like check 
> here?
I'm not sure this is really doable here without picking apart the feature 
string, I think it makes more sense to just set the values and assert when 
using the accessors without SVE enabled.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103702

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


[PATCH] D103702: [AArch64][SVE] Wire up vscale_range attribute to SVE min/max vector queries

2021-06-14 Thread Bradley Smith via Phabricator via cfe-commits
bsmith updated this revision to Diff 351910.
bsmith marked 7 inline comments as done.
bsmith added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

- Move attribute/command line logic into AArch64TargetMachine.
- Fix issue with subtarget key appending integers.
- Add end-to-end test.
- Make new subtarget options optional.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103702

Files:
  clang/test/CodeGen/aarch64-sve-vector-bits-codegen.c
  llvm/lib/Target/AArch64/AArch64Subtarget.cpp
  llvm/lib/Target/AArch64/AArch64Subtarget.h
  llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
  llvm/test/CodeGen/AArch64/sve-vscale-attr.ll

Index: llvm/test/CodeGen/AArch64/sve-vscale-attr.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/sve-vscale-attr.ll
@@ -0,0 +1,144 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s | FileCheck %s --check-prefixes=CHECK,CHECK-NOARG
+; RUN: llc -aarch64-sve-vector-bits-min=512 < %s | FileCheck %s --check-prefixes=CHECK,CHECK-ARG
+
+target triple = "aarch64-unknown-linux-gnu"
+
+define void @func_vscale_none(<16 x i32>* %a, <16 x i32>* %b) #0 {
+; CHECK-NOARG-LABEL: func_vscale_none:
+; CHECK-NOARG:   // %bb.0:
+; CHECK-NOARG-NEXT:ldp q0, q1, [x0]
+; CHECK-NOARG-NEXT:ldp q2, q3, [x1]
+; CHECK-NOARG-NEXT:ldp q4, q5, [x0, #32]
+; CHECK-NOARG-NEXT:ldp q7, q6, [x1, #32]
+; CHECK-NOARG-NEXT:add v1.4s, v1.4s, v3.4s
+; CHECK-NOARG-NEXT:add v0.4s, v0.4s, v2.4s
+; CHECK-NOARG-NEXT:add v2.4s, v5.4s, v6.4s
+; CHECK-NOARG-NEXT:add v3.4s, v4.4s, v7.4s
+; CHECK-NOARG-NEXT:stp q3, q2, [x0, #32]
+; CHECK-NOARG-NEXT:stp q0, q1, [x0]
+; CHECK-NOARG-NEXT:ret
+;
+; CHECK-ARG-LABEL: func_vscale_none:
+; CHECK-ARG:   // %bb.0:
+; CHECK-ARG-NEXT:ptrue p0.s, vl16
+; CHECK-ARG-NEXT:ld1w { z0.s }, p0/z, [x0]
+; CHECK-ARG-NEXT:ld1w { z1.s }, p0/z, [x1]
+; CHECK-ARG-NEXT:add z0.s, p0/m, z0.s, z1.s
+; CHECK-ARG-NEXT:st1w { z0.s }, p0, [x0]
+; CHECK-ARG-NEXT:ret
+  %op1 = load <16 x i32>, <16 x i32>* %a
+  %op2 = load <16 x i32>, <16 x i32>* %b
+  %res = add <16 x i32> %op1, %op2
+  store <16 x i32> %res, <16 x i32>* %a
+  ret void
+}
+
+attributes #0 = { "target-features"="+sve" }
+
+define void @func_vscale1_1(<16 x i32>* %a, <16 x i32>* %b) #1 {
+; CHECK-LABEL: func_vscale1_1:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:ldp q0, q1, [x0]
+; CHECK-NEXT:ldp q2, q3, [x1]
+; CHECK-NEXT:ldp q4, q5, [x0, #32]
+; CHECK-NEXT:ldp q7, q6, [x1, #32]
+; CHECK-NEXT:add v1.4s, v1.4s, v3.4s
+; CHECK-NEXT:add v0.4s, v0.4s, v2.4s
+; CHECK-NEXT:add v2.4s, v5.4s, v6.4s
+; CHECK-NEXT:add v3.4s, v4.4s, v7.4s
+; CHECK-NEXT:stp q3, q2, [x0, #32]
+; CHECK-NEXT:stp q0, q1, [x0]
+; CHECK-NEXT:ret
+  %op1 = load <16 x i32>, <16 x i32>* %a
+  %op2 = load <16 x i32>, <16 x i32>* %b
+  %res = add <16 x i32> %op1, %op2
+  store <16 x i32> %res, <16 x i32>* %a
+  ret void
+}
+
+attributes #1 = { "target-features"="+sve" vscale_range(1,1) }
+
+define void @func_vscale2_2(<16 x i32>* %a, <16 x i32>* %b) #2 {
+; CHECK-LABEL: func_vscale2_2:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:ptrue p0.s, vl8
+; CHECK-NEXT:add x8, x0, #32 // =32
+; CHECK-NEXT:add x9, x1, #32 // =32
+; CHECK-NEXT:ld1w { z0.s }, p0/z, [x0]
+; CHECK-NEXT:ld1w { z1.s }, p0/z, [x8]
+; CHECK-NEXT:ld1w { z2.s }, p0/z, [x1]
+; CHECK-NEXT:ld1w { z3.s }, p0/z, [x9]
+; CHECK-NEXT:add z0.s, p0/m, z0.s, z2.s
+; CHECK-NEXT:add z1.s, p0/m, z1.s, z3.s
+; CHECK-NEXT:st1w { z0.s }, p0, [x0]
+; CHECK-NEXT:st1w { z1.s }, p0, [x8]
+; CHECK-NEXT:ret
+  %op1 = load <16 x i32>, <16 x i32>* %a
+  %op2 = load <16 x i32>, <16 x i32>* %b
+  %res = add <16 x i32> %op1, %op2
+  store <16 x i32> %res, <16 x i32>* %a
+  ret void
+}
+
+attributes #2 = { "target-features"="+sve" vscale_range(2,2) }
+
+define void @func_vscale2_4(<16 x i32>* %a, <16 x i32>* %b) #3 {
+; CHECK-LABEL: func_vscale2_4:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:ptrue p0.s, vl8
+; CHECK-NEXT:add x8, x0, #32 // =32
+; CHECK-NEXT:add x9, x1, #32 // =32
+; CHECK-NEXT:ld1w { z0.s }, p0/z, [x0]
+; CHECK-NEXT:ld1w { z1.s }, p0/z, [x8]
+; CHECK-NEXT:ld1w { z2.s }, p0/z, [x1]
+; CHECK-NEXT:ld1w { z3.s }, p0/z, [x9]
+; CHECK-NEXT:add z0.s, p0/m, z0.s, z2.s
+; CHECK-NEXT:add z1.s, p0/m, z1.s, z3.s
+; CHECK-NEXT:st1w { z0.s }, p0, [x0]
+; CHECK-NEXT:st1w { z1.s }, p0, [x8]
+; CHECK-NEXT:ret
+  %op1 = load <16 x i32>, <16 x i32>* %a
+  %op2 = load <16 x i32>, <16 x i32>* %b
+  %res = add <16 x i32> %op1, %op2
+  store <16 x i32> %res, <16 x i32>* %a
+  ret void
+}
+
+attributes #3 = { "target-features"="+sve" vscale_range(2,4) }
+
+define void @func_vscale4_4(<16 x i32>* %a, <16 x i32>* %b) #4 {
+; CHECK-LABEL: 

[PATCH] D104240: [OPENMP][C++20]Add support for CXXRewrittenBinaryOperator in ranged for loops.

2021-06-14 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev created this revision.
ABataev added reviewers: jdoerfert, mikerice.
Herald added subscribers: guansong, yaxunl.
ABataev requested review of this revision.
Herald added a subscriber: sstefan1.
Herald added a project: clang.

Added support for CXXRewrittenBinaryOperator as a condition in ranged
for loops. This is a new kind of expression, need to extend support for

  C++20 constructs.

It fixes PR49970: range-based for compilation fails for libstdc++ vector
with -std=c++20.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D104240

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/for_ast_print_cxx20.cpp

Index: clang/test/OpenMP/for_ast_print_cxx20.cpp
===
--- /dev/null
+++ clang/test/OpenMP/for_ast_print_cxx20.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -verify -fopenmp --std=c++20 -ast-print %s -Wsign-conversion | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++20 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -std=c++20 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
+
+// RUN: %clang_cc1 -verify -fopenmp-simd --std=c++20 -ast-print %s -Wsign-conversion | FileCheck %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++20 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -std=c++20 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+template  class iterator {
+public:
+  T *() const;
+  iterator ++();
+};
+template 
+bool operator==(const iterator &, const iterator &);
+template 
+unsigned long operator-(const iterator &, const iterator &);
+template 
+iterator operator+(const iterator &, unsigned long);
+class vector {
+public:
+  vector();
+  iterator begin();
+  iterator end();
+};
+// CHECK: void foo() {
+void foo() {
+// CHECK-NEXT: vector vec;
+  vector vec;
+// CHECK-NEXT: #pragma omp for
+#pragma omp for
+// CHECK-NEXT: for (int i : vec)
+  for (int i : vec)
+;
+}
+#endif
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -7668,53 +7668,43 @@
   Condition = S;
   S = getExprAsWritten(S);
   SourceLocation CondLoc = S->getBeginLoc();
-  if (auto *BO = dyn_cast(S)) {
-if (BO->isRelationalOp()) {
-  if (getInitLCDecl(BO->getLHS()) == LCDecl)
-return setUB(BO->getRHS(),
- (BO->getOpcode() == BO_LT || BO->getOpcode() == BO_LE),
- (BO->getOpcode() == BO_LT || BO->getOpcode() == BO_GT),
- BO->getSourceRange(), BO->getOperatorLoc());
-  if (getInitLCDecl(BO->getRHS()) == LCDecl)
-return setUB(BO->getLHS(),
- (BO->getOpcode() == BO_GT || BO->getOpcode() == BO_GE),
- (BO->getOpcode() == BO_LT || BO->getOpcode() == BO_GT),
- BO->getSourceRange(), BO->getOperatorLoc());
-} else if (IneqCondIsCanonical && BO->getOpcode() == BO_NE)
-  return setUB(
-  getInitLCDecl(BO->getLHS()) == LCDecl ? BO->getRHS() : BO->getLHS(),
-  /*LessOp=*/llvm::None,
-  /*StrictOp=*/true, BO->getSourceRange(), BO->getOperatorLoc());
+  auto & = [this, IneqCondIsCanonical](
+   BinaryOperatorKind Opcode, const Expr *LHS,
+   const Expr *RHS, SourceRange SR,
+   SourceLocation OpLoc) -> llvm::Optional {
+if (BinaryOperator::isRelationalOp(Opcode)) {
+  if (getInitLCDecl(LHS) == LCDecl)
+return setUB(const_cast(RHS),
+ (Opcode == BO_LT || Opcode == BO_LE),
+ (Opcode == BO_LT || Opcode == BO_GT), SR, OpLoc);
+  if (getInitLCDecl(RHS) == LCDecl)
+return setUB(const_cast(LHS),
+ (Opcode == BO_GT || Opcode == BO_GE),
+ (Opcode == BO_LT || Opcode == BO_GT), SR, OpLoc);
+} else if (IneqCondIsCanonical && Opcode == BO_NE) {
+  return setUB(const_cast(getInitLCDecl(LHS) == LCDecl ? RHS : LHS),
+   /*LessOp=*/llvm::None,
+   /*StrictOp=*/true, SR, OpLoc);
+}
+return llvm::None;
+  };
+  llvm::Optional Res;
+  if (auto *RBO = dyn_cast(S)) {
+CXXRewrittenBinaryOperator::DecomposedForm DF = RBO->getDecomposedForm();
+Res = CheckAndSetCond(DF.Opcode, DF.LHS, DF.RHS, RBO->getSourceRange(),
+  RBO->getOperatorLoc());
+  } else if (auto *BO = dyn_cast(S)) {
+Res = CheckAndSetCond(BO->getOpcode(), BO->getLHS(), BO->getRHS(),
+  BO->getSourceRange(), BO->getOperatorLoc());
   } else if (auto *CE = dyn_cast(S)) {
 if (CE->getNumArgs() == 2) {
-  auto Op = CE->getOperator();
-  switch (Op) {
-  case OO_Greater:
-  case OO_GreaterEqual:
-  case OO_Less:
-  case OO_LessEqual:
-if (getInitLCDecl(CE->getArg(0)) == LCDecl)
-  

[PATCH] D103087: [clang-tidy] performances-unnecessary-* checks: Extend isOnlyUsedAsConst to expressions and catch const methods returning non-const references/pointers.

2021-06-14 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added a comment.

In D103087#2813901 , @flx wrote:

> In D103087#2793673 , @ymandel wrote:
>
>> I have some concerns about the cost of this checks as it used matching over 
>> entire contexts quite extensively.  At this point, the facilities involved 
>> seem quite close to doing dataflow analysis and I wonder if you might be 
>> better off with a very different implementation. Regardless, have you done 
>> any perfomance testing to see the impact on real code?
>
> That's a fair point. Is there prior art in terms of dataflow analysis in 
> ClangTidy or LLVM I could take a look at?

Added Dmitri to speak to prior art.

> In terms of measuring performance, do you have suggestions how to measure 
> this? I can add a counter that counts the recursion depth that is reached to 
> see how often this happens in practice.

I would simply run clang-tidy over a reasonable size set of files and see the 
timing w/ and w/o this change. But, I think that clang-tidy may have some 
built-in perf monitoring as well (specifically, a way to display the cost of 
each check, or the top most costly ones).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103087

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


[PATCH] D104116: AMD k8 family does not support SSE4.x which are required by x86-64-v2+

2021-06-14 Thread Stella Stamenova via Phabricator via cfe-commits
stella.stamenova added a comment.

This change is generating warnings when building with clang:

  /usr/bin/clang++ -DCLANG_ROUND_TRIP_CC1_ARGS=ON -DGTEST_HAS_RTTI=0 -D_DEBUG 
-D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS 
-D__STDC_LIMIT_MACROS -Itools/clang/lib/Basic 
-I/mnt/vss/_work/1/s/clang/lib/Basic -I/mnt/vss/_work/1/s/clang/include 
-Itools/clang/include -Iinclude -I/mnt/vss/_work/1/s/llvm/include -fPIC 
-fvisibility-inlines-hidden -Werror -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 -fno-common -Woverloaded-virtual 
-Wno-nested-anon-types -g  -fno-exceptions -fno-rtti -std=c++14 -MD -MT 
tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Targets/X86.cpp.o -MF 
tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Targets/X86.cpp.o.d -o 
tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Targets/X86.cpp.o -c 
/mnt/vss/_work/1/s/clang/lib/Basic/Targets/X86.cpp
  /mnt/vss/_work/1/s/clang/lib/Basic/Targets/X86.cpp:396:11: error: enumeration 
values 'CK_x86_64_v2', 'CK_x86_64_v3', and 'CK_x86_64_v4' not handled in switch 
[-Werror,-Wswitch]
switch (CPU) {

Rather than removing the cases from the switch entirely, they should still be 
handled without defining k8.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104116

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


[PATCH] D103021: [clang-tidy] performance-unnecessary-copy-initialization: Search whole function body for variable initializations.

2021-06-14 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp:98-101
   auto Matches =
   match(findAll(declStmt(has(varDecl(equalsNode(
 .bind("declStmt")),
+Body, Context);

flx wrote:
> ymandel wrote:
> > flx wrote:
> > > ymandel wrote:
> > > > Consider inspecting the `DeclContext`s instead, which should be much 
> > > > more efficient than searching the entire block.  Pass the 
> > > > `FunctionDecl` as an argument instead of `Body`, since it is a 
> > > > `DeclContext`.  e.g. `const DeclContext `
> > > > 
> > > > Then, either
> > > > 1. Call `Fun.containsDecl(InitializingVar)`, or
> > > > 2. Search through the contexts yourself; something like:
> > > > ```
> > > > DeclContext* DC = InitializingVar->getDeclContext(); 
> > > > while (DC != nullptr && DC != )
> > > >   DC = DC->getLexicalParent();
> > > > if (DC == nullptr)
> > > >   // The reference or pointer is not initialized anywhere witin the 
> > > > function. We
> > > >   // assume its pointee is not modified then.
> > > >   return true;
> > > > ```
> > > Are #1 and #2 equivalent? From the implementation and comment I cannot 
> > > tell whether #1 would cover cases where the variable is not declared 
> > > directly in the function, but in child block:
> > > 
> > > ```
> > > void Fun() {
> > >  {
> > >var i;
> > >{
> > >  i.usedHere();
> > >}  
> > >  } 
> > > }
> > > ```
> > > 
> > > I'm also reading this as an optimization to more quickly determine 
> > > whether we can stop here. We still need to find the matches for the next 
> > > steps, but I  think I could then limit matching to the DeclContext I 
> > > found here. Is this correct? For this I would actually need the 
> > > DeclContext result from #2.
> > A. I think you're right that #2 is more suited to what you need. I wasn't 
> > sure, so included both. Agreed that the comments are ambiguous.
> > B. yes, this is just an optimization. it may be premature for that matter; 
> > just that match can be expensive and this seemed a more direct expression 
> > of the algorithm.
> I was not able to pass the (possibly more narrow) DeclContext to the match 
> function as scope since match does not support DeclContexts.
> 
> I implemented  isDeclaredInFunction() which iterates through the decl 
> contexts as you suggested. I'm not sure though whether we should start with 
> VarDecl::getDeclContext() or VarDecl::getLexicalDeclContext()?
> 
> While looking at VarDecl::getLexicalDeclContext() I discovered is VarDecl has 
> the following method:
> 
> ```
>   /// Returns true for local variable declarations other than parameters. 
>
>   /// Note that this includes static variables inside of functions. It also   
>
>   /// includes variables inside blocks.   
>
>   /// 
>
>   ///   void foo() { int x; static int y; extern int z; } 
>
>   bool isLocalVarDecl() const;
> ```
> 
> I think this is exactly what we'd want here. What do you think?
> 
You mean instead of `isDeclaredInFunction`?  If so -- yes, that seems right.  
But, if so, are you still planning to bind "declStmt" with the `match`, or will 
you replace that with something more direct?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103021

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


[PATCH] D104222: [clang-format] [PR50702] Lamdba processing does not respect AfterClass and AfterNamespace

2021-06-14 Thread Zhihao Yuan via Phabricator via cfe-commits
lichray added a comment.

LGTM


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

https://reviews.llvm.org/D104222

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


[PATCH] D104222: [clang-format] [PR50702] Lamdba processing does not respect AfterClass and AfterNamespace

2021-06-14 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay updated this revision to Diff 351895.
MyDeveloperDay added a comment.

Remove unused functions


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

https://reviews.llvm.org/D104222

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

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -18856,8 +18856,7 @@
"  });\n"
"});",
LLVMWithBeforeLambdaBody);
-  verifyFormat("void Fct()\n"
-   "{\n"
+  verifyFormat("void Fct() {\n"
"  return {[]()\n"
"  {\n"
"return 17;\n"
@@ -19061,6 +19060,16 @@
"  });\n"
"});",
LLVMWithBeforeLambdaBody);
+
+  LLVMWithBeforeLambdaBody.AllowShortLambdasOnASingleLine =
+  FormatStyle::ShortLambdaStyle::SLS_None;
+  verifyFormat("namespace test {\n"
+   "class Test {\n"
+   "public:\n"
+   "  Test() = default;\n"
+   "};\n"
+   "} // namespace test",
+   LLVMWithBeforeLambdaBody);
 }
 
 TEST_F(FormatTest, LambdaWithLineComments) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3557,42 +3557,11 @@
   return Tok.Children.empty() && ShortLambdaOption != FormatStyle::SLS_None;
 }
 
-static bool
-isItAInlineLambdaAllowed(const FormatToken ,
- FormatStyle::ShortLambdaStyle ShortLambdaOption) {
-  return (ShortLambdaOption == FormatStyle::SLS_Inline &&
-  IsFunctionArgument(Tok)) ||
- (ShortLambdaOption == FormatStyle::SLS_All);
-}
-
-static bool isOneChildWithoutMustBreakBefore(const FormatToken ) {
-  if (Tok.Children.size() != 1)
-return false;
-  FormatToken *curElt = Tok.Children[0]->First;
-  while (curElt) {
-if (curElt->MustBreakBefore)
-  return false;
-curElt = curElt->Next;
-  }
-  return true;
-}
 static bool isAllmanLambdaBrace(const FormatToken ) {
   return (Tok.is(tok::l_brace) && Tok.is(BK_Block) &&
   !Tok.isOneOf(TT_ObjCBlockLBrace, TT_DictLiteral));
 }
 
-static bool isAllmanBraceIncludedBreakableLambda(
-const FormatToken , FormatStyle::ShortLambdaStyle ShortLambdaOption) {
-  if (!isAllmanLambdaBrace(Tok))
-return false;
-
-  if (isItAnEmptyLambdaAllowed(Tok, ShortLambdaOption))
-return false;
-
-  return !isItAInlineLambdaAllowed(Tok, ShortLambdaOption) ||
- !isOneChildWithoutMustBreakBefore(Tok);
-}
-
 bool TokenAnnotator::mustBreakBefore(const AnnotatedLine ,
  const FormatToken ) {
   const FormatToken  = *Right.Previous;
@@ -3754,13 +3723,6 @@
   if (Right.is(TT_InlineASMBrace))
 return Right.HasUnescapedNewline;
 
-  auto ShortLambdaOption = Style.AllowShortLambdasOnASingleLine;
-  if (Style.BraceWrapping.BeforeLambdaBody &&
-  (isAllmanBraceIncludedBreakableLambda(Left, ShortLambdaOption) ||
-   isAllmanBraceIncludedBreakableLambda(Right, ShortLambdaOption))) {
-return true;
-  }
-
   if (isAllmanBrace(Left) || isAllmanBrace(Right))
 return (Line.startsWith(tok::kw_enum) && Style.BraceWrapping.AfterEnum) ||
(Line.startsWith(tok::kw_typedef, tok::kw_enum) &&
@@ -4186,7 +4148,7 @@
 return false;
 
   auto ShortLambdaOption = Style.AllowShortLambdasOnASingleLine;
-  if (Style.BraceWrapping.BeforeLambdaBody) {
+  if (Style.BraceWrapping.BeforeLambdaBody && Right.is(TT_LambdaLBrace)) {
 if (isAllmanLambdaBrace(Left))
   return !isItAnEmptyLambdaAllowed(Left, ShortLambdaOption);
 if (isAllmanLambdaBrace(Right))
@@ -4198,7 +4160,6 @@
  Right.isMemberAccess() ||
  Right.isOneOf(TT_TrailingReturnArrow, TT_LambdaArrow, tok::lessless,
tok::colon, tok::l_square, tok::at) ||
- (Style.BraceWrapping.BeforeLambdaBody && Right.is(TT_LambdaLBrace)) ||
  (Left.is(tok::r_paren) &&
   Right.isOneOf(tok::identifier, tok::kw_const)) ||
  (Left.is(tok::l_paren) && !Right.is(tok::r_paren)) ||
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D103792: [clang][AST] Set correct DeclContext in ASTImporter lookup table for template params.

2021-06-14 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added inline comments.



Comment at: clang/lib/AST/ASTImporter.cpp:5961-5962
 
   if (Error Err = ImportDeclParts(D, DC, LexicalDC, Name, ToD, Loc))
 return std::move(Err);
 

martong wrote:
> Do you think that the alternative approach that is used with 
> `TypedefNameDecl` could work here?
> ```
>   // Do not import the DeclContext, we will import it once the TypedefNameDecl
>   // is created.
>   if (Error Err = ImportDeclParts(D, Name, ToD, Loc))
> return std::move(Err);
> ```
> With that perhaps we could avoid the hassle with the `update`. Could you 
> please investigate that?
The problem is not with the DC of the `FunctionTemplateDecl`, it is with the 
template parameters. It looks not safe to pass nullptr as `DeclContext` for 
these, this is only possible if the import is done. (Probably the solution in 
`TypedefNameDecl` is not perfect: If something exists already in the "To TU" 
that was not imported, specially a namespace that contains a typedef with same 
name, it may not be found before the import.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103792

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


[PATCH] D104222: [clang-format] [PR50702] Lamdba processing does not respect AfterClass and AfterNamespace

2021-06-14 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

@Wawha do you have a project that perhaps uses this work your did? I would like 
to ensure I didn't break anything


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104222

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


[PATCH] D99696: [clang] NRVO: Improvements and handling of more cases.

2021-06-14 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

When `__block` variables get moved to the heap, they're supposed to be moved if 
possible, not copied.  It looks like PerformMoveOrCopyInitialization requires 
NRVO info to be passed in to ever do a move.  Maybe it's being passed in wrong 
when building `__block` copy expressions in some situation.

Was there really not a test case covering those semantics?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99696

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


[PATCH] D103605: [analyzer] Introduce a new interface for tracking

2021-06-14 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

In D103605#2816979 , @Szelethus wrote:

> Sorry for the absence, took my time to catch up with this series! Really 
> interesting insight into how a new interface is being designed! I need some 
> time to digest things, but can't wait to help on the remaining patches.

Hey, thanks!  Here is one example of how it can be useful for checkers (D104136 
), maybe it can help to form a full picture.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103605

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


[PATCH] D103605: [analyzer] Introduce a new interface for tracking

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

Sorry for the absence, took my time to catch up with this series! Really 
interesting insight into how a new interface is being designed! I need some 
time to digest things, but can't wait to help on the remaining patches.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103605

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


[PATCH] D104222: [clang-format] [PR50702] Lamdba processing does not respect AfterClass and AfterNamespace

2021-06-14 Thread Francois JEAN via Phabricator via cfe-commits
Wawha added inline comments.



Comment at: clang/lib/Format/TokenAnnotator.cpp:3760
-  (isAllmanBraceIncludedBreakableLambda(Left, ShortLambdaOption) ||
-   isAllmanBraceIncludedBreakableLambda(Right, ShortLambdaOption))) {
-return true;

Without this code, you should be able to remove functions 
isAllmanBraceIncludedBreakableLambda(), isItAInlineLambdaAllowed() and 
isOneChildWithoutMustBreakBefore().

Thank you for the fix.

When I implement that part, I have some difficulty to handle inline lambda and 
BreakBeforeLambdaBody. At the beginning, I implement the solution without 
inline lambda option (not yet present). But I have to handle it before merging 
the patch. And, this modification was added at this moment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104222

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


[PATCH] D99696: [clang] NRVO: Improvements and handling of more cases.

2021-06-14 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

Since it seems more discussion is needed here, I've reverted in 
c60dd3b2626a4d9eefd9f82f9a406b0d28d3fd72 
. Since 
they were hard to tease apart, the revert is for both D99696 
 and D99005 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99696

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


[clang] c60dd3b - Revert "[clang] NRVO: Improvements and handling of more cases."

2021-06-14 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2021-06-14T16:46:58+02:00
New Revision: c60dd3b2626a4d9eefd9f82f9a406b0d28d3fd72

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

LOG: Revert "[clang] NRVO: Improvements and handling of more cases."

This change caused build errors related to move-only __block variables,
see discussion on https://reviews.llvm.org/D99696

> This expands NRVO propagation for more cases:
>
> Parse analysis improvement:
> * Lambdas and Blocks with dependent return type can have their variables
>   marked as NRVO Candidates.
>
> Variable instantiation improvements:
> * Fixes crash when instantiating NRVO variables in Blocks.
> * Functions, Lambdas, and Blocks which have auto return type have their
>   variables' NRVO status propagated. For Blocks with non-auto return type,
>   as a limitation, this propagation does not consider the actual return
>   type.
>
> This also implements exclusion of VarDecls which are references to
> dependent types.
>
> Signed-off-by: Matheus Izvekov 
>
> Reviewed By: Quuxplusone
>
> Differential Revision: https://reviews.llvm.org/D99696

This also reverts the follow-on change which was hard to tease apart
form the one above:

> "[clang] Implement P2266 Simpler implicit move"
>
> This Implements 
> [[http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2266r1.html|P2266 
> Simpler implicit move]].
>
> Signed-off-by: Matheus Izvekov 
>
> Reviewed By: Quuxplusone
>
> Differential Revision: https://reviews.llvm.org/D99005

This reverts commits 1e50c3d785f4563873ab1ce86559f2a1285b5678 and
bf20631782183cd19e0bb7219e908c2bbb01a75f.

Added: 


Modified: 
clang/include/clang/Sema/Sema.h
clang/lib/Sema/Sema.cpp
clang/lib/Sema/SemaCoroutine.cpp
clang/lib/Sema/SemaExprCXX.cpp
clang/lib/Sema/SemaStmt.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/lib/Sema/SemaType.cpp
clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p7-cxx14.cpp
clang/test/CXX/drs/dr3xx.cpp
clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4-cxx14.cpp
clang/test/CXX/temp/temp.decls/temp.mem/p5.cpp
clang/test/CodeGen/nrvo-tracking.cpp
clang/test/SemaCXX/constant-expression-cxx11.cpp
clang/test/SemaCXX/constant-expression-cxx14.cpp
clang/test/SemaCXX/coroutine-rvo.cpp
clang/test/SemaCXX/coroutines.cpp
clang/test/SemaCXX/deduced-return-type-cxx14.cpp
clang/test/SemaCXX/return-stack-addr.cpp
clang/test/SemaCXX/warn-return-std-move.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index db389922ae3a1..6ade9d7691266 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -3455,6 +3455,12 @@ class Sema final {
   bool DiagnoseMultipleUserDefinedConversion(Expr *From, QualType ToType);
   bool isSameOrCompatibleFunctionType(CanQualType Param, CanQualType Arg);
 
+  ExprResult PerformMoveOrCopyInitialization(const InitializedEntity ,
+ const VarDecl *NRVOCandidate,
+ QualType ResultType,
+ Expr *Value,
+ bool AllowNRVO = true);
+
   bool CanPerformAggregateInitializationForOverloadResolution(
   const InitializedEntity , InitListExpr *From);
 
@@ -4754,30 +4760,28 @@ class Sema final {
SourceLocation Loc,
unsigned NumParams);
 
-  struct NamedReturnInfo {
-const VarDecl *Candidate;
-
-enum Status : uint8_t { None, MoveEligible, MoveEligibleAndCopyElidable };
-Status S;
-
-bool isMoveEligible() const { return S != None; };
-bool isCopyElidable() const { return S == MoveEligibleAndCopyElidable; }
+  enum CopyElisionSemanticsKind {
+CES_Strict = 0,
+CES_AllowParameters = 1,
+CES_AllowDifferentTypes = 2,
+CES_AllowExceptionVariables = 4,
+CES_AllowRValueReferenceType = 8,
+CES_ImplicitlyMovableCXX11CXX14CXX17 =
+(CES_AllowParameters | CES_AllowDifferentTypes),
+CES_ImplicitlyMovableCXX20 =
+(CES_AllowParameters | CES_AllowDifferentTypes |
+ CES_AllowExceptionVariables | CES_AllowRValueReferenceType),
   };
-  NamedReturnInfo getNamedReturnInfo(Expr *, bool ForceCXX2b = false);
-  NamedReturnInfo getNamedReturnInfo(const VarDecl *VD,
- bool ForceCXX20 = false);
-  const VarDecl *getCopyElisionCandidate(NamedReturnInfo ,
- QualType ReturnType);
 
-  ExprResult PerformMoveOrCopyInitialization(const InitializedEntity ,
- const 

[PATCH] D102325: [clang-tidy] cppcoreguidelines-virtual-base-class-destructor: a new check

2021-06-14 Thread Marco Gartmann via Phabricator via cfe-commits
mgartmann added a comment.

Thanks a lot for your feedback, @aaron.ballman!

I was able to incorporate it in the updated diff.

On your advice, I also ran this check on a large open source project using the 
`run-clang-tidy.py` script. I decided to do it on the llvm project itself as 
follows:

  marco@nb:~/llvm-project/build$ python3 run-clang-tidy.py 
-checks="-*,cppcoreguidelines-virtual-class-destructor"  -header-filter=".*" > 
result.txt
  marco@nb:~/llvm-project/build$ cat result.txt | grep "private and prevents" | 
wc -l
  797

Most of these 797 lines are duplicates, since these warnings come from header 
files included in (apparently) many other files. 
Deduplicated, the following seven destructors were private and triggered this 
check's warning:

- llvm-project/llvm/include/llvm/Analysis/RegionInfo.h:1024:23: warning: 
destructor of 'RegionInfoBase>' is private 
...
- llvm-project/llvm/include/llvm/Analysis/RegionInfo.h:674:7: warning: 
destructor of 'RegionInfoBase' is private ...
- llvm-project/llvm/include/llvm/CodeGen/MachineRegionInfo.h:177:23: warning: 
destructor of 'RegionInfoBase>' is 
private ...
- llvm-project/llvm/lib/Target/AVR/MCTargetDesc/AVRMCExpr.h:19:7: warning: 
destructor of 'AVRMCExpr' is private ...
- llvm-project/llvm/utils/unittest/googletest/include/gtest/gtest.h:1257:18: 
warning: destructor of 'UnitTest' is private ...
- llvm-project/llvm/lib/CodeGen/InlineSpiller.cpp:159:7: warning: destructor of 
'InlineSpiller' is private ...
- llvm-project/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp:387:7: 
warning: destructor of 'X86MCInstrAnalysis' is private ...

I assume that these destructors are private by on purpose. Please correct me if 
I am wrong. 
A programmer working on the LLVM project would therefore see seven warnings for 
private destructors over the whole project.

Is this number of private destructors which are flagged acceptable to you?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102325

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


[PATCH] D102325: [clang-tidy] cppcoreguidelines-virtual-base-class-destructor: a new check

2021-06-14 Thread Marco Gartmann via Phabricator via cfe-commits
mgartmann updated this revision to Diff 351869.
mgartmann marked 10 inline comments as done.
mgartmann added a comment.

- changed name of check to `cppcoreguidelines-virtual-class-destructor`
- removed matcher for class or struct in AST matcher
- changed string concatenations to use `llvm::twine`
- adjusted documentation and removed unnecessary semicolons in it


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102325

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/VirtualClassDestructorCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/VirtualClassDestructorCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-virtual-class-destructor.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-virtual-class-destructor.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-virtual-class-destructor.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-virtual-class-destructor.cpp
@@ -0,0 +1,204 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-virtual-class-destructor %t -- --fix-notes
+
+// CHECK-MESSAGES: :[[@LINE+4]]:8: warning: destructor of 'PrivateVirtualBaseStruct' is private and prevents using the type [cppcoreguidelines-virtual-class-destructor]
+// CHECK-MESSAGES: :[[@LINE+3]]:8: note: make it public and virtual
+// CHECK-MESSAGES: :[[@LINE+2]]:8: note: make it protected
+// As we have 2 conflicting fixes in notes, no fix is applied.
+struct PrivateVirtualBaseStruct {
+  virtual void f();
+
+private:
+  virtual ~PrivateVirtualBaseStruct() {}
+};
+
+struct PublicVirtualBaseStruct { // OK
+  virtual void f();
+  virtual ~PublicVirtualBaseStruct() {}
+};
+
+// CHECK-MESSAGES: :[[@LINE+2]]:8: warning: destructor of 'ProtectedVirtualBaseStruct' is protected and virtual [cppcoreguidelines-virtual-class-destructor]
+// CHECK-MESSAGES: :[[@LINE+1]]:8: note: make it protected and non-virtual
+struct ProtectedVirtualBaseStruct {
+  virtual void f();
+
+protected:
+  virtual ~ProtectedVirtualBaseStruct() {}
+  // CHECK-FIXES: ~ProtectedVirtualBaseStruct() {}
+};
+
+// CHECK-MESSAGES: :[[@LINE+2]]:8: warning: destructor of 'ProtectedVirtualDefaultBaseStruct' is protected and virtual [cppcoreguidelines-virtual-class-destructor]
+// CHECK-MESSAGES: :[[@LINE+1]]:8: note: make it protected and non-virtual
+struct ProtectedVirtualDefaultBaseStruct {
+  virtual void f();
+
+protected:
+  virtual ~ProtectedVirtualDefaultBaseStruct() = default;
+  // CHECK-FIXES: ~ProtectedVirtualDefaultBaseStruct() = default;
+};
+
+// CHECK-MESSAGES: :[[@LINE+4]]:8: warning: destructor of 'PrivateNonVirtualBaseStruct' is private and prevents using the type [cppcoreguidelines-virtual-class-destructor]
+// CHECK-MESSAGES: :[[@LINE+3]]:8: note: make it public and virtual
+// CHECK-MESSAGES: :[[@LINE+2]]:8: note: make it protected
+// As we have 2 conflicting fixes in notes, no fix is applied.
+struct PrivateNonVirtualBaseStruct {
+  virtual void f();
+
+private:
+  ~PrivateNonVirtualBaseStruct() {}
+};
+
+// CHECK-MESSAGES: :[[@LINE+2]]:8: warning: destructor of 'PublicNonVirtualBaseStruct' is public and non-virtual [cppcoreguidelines-virtual-class-destructor]
+// CHECK-MESSAGES: :[[@LINE+1]]:8: note: make it public and virtual
+struct PublicNonVirtualBaseStruct {
+  virtual void f();
+  ~PublicNonVirtualBaseStruct() {}
+  // CHECK-FIXES: virtual ~PublicNonVirtualBaseStruct() {}
+};
+
+struct PublicNonVirtualNonBaseStruct { // OK according to C.35, since this struct does not have any virtual methods.
+  void f();
+  ~PublicNonVirtualNonBaseStruct() {}
+};
+
+// CHECK-MESSAGES: :[[@LINE+4]]:8: warning: destructor of 'PublicImplicitNonVirtualBaseStruct' is public and non-virtual [cppcoreguidelines-virtual-class-destructor]
+// CHECK-MESSAGES: :[[@LINE+3]]:8: note: make it public and virtual
+// CHECK-FIXES: struct PublicImplicitNonVirtualBaseStruct {
+// CHECK-FIXES-NEXT: virtual ~PublicImplicitNonVirtualBaseStruct() = default;
+struct PublicImplicitNonVirtualBaseStruct {
+  virtual void f();
+};
+
+// CHECK-MESSAGES: :[[@LINE+5]]:8: warning: destructor of 'PublicASImplicitNonVirtualBaseStruct' is public and non-virtual [cppcoreguidelines-virtual-class-destructor]
+// CHECK-MESSAGES: :[[@LINE+4]]:8: note: make it public and virtual
+// CHECK-FIXES: struct PublicASImplicitNonVirtualBaseStruct {
+// CHECK-FIXES-NEXT: virtual ~PublicASImplicitNonVirtualBaseStruct() = default;
+// CHECK-FIXES-NEXT: private:
+struct PublicASImplicitNonVirtualBaseStruct {
+private:
+  virtual void f();
+};
+
+struct ProtectedNonVirtualBaseStruct { // OK
+  virtual void f();
+
+protected:

[PATCH] D104198: [Matrix] Add documentation for compound assignment and type conversion of matrix types

2021-06-14 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added a comment.

Thanks for the patch! some comments inline.




Comment at: clang/docs/LanguageExtensions.rst:527
+The matrix type extension supports compound assignments for addition, 
subtraction, and multiplication, provided
+their types are consistent.
+

it might also be helpful to include an example with matrix / scalar operations? 
Division is also supported for matrix/scalar combinations (but not for 
matrix/matrix)



Comment at: clang/docs/LanguageExtensions.rst:533
+
+  void f(m4x4_t a, m4x4_t b) {
+a += b;

perhaps return the result, so it is not a no-op?



Comment at: clang/docs/LanguageExtensions.rst:547
+
+  void f1(ix5x5 i, fx5x5 f) {
+f = (fx5x5)i;

can we instead return the casted value, so the code is not a no-op?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104198

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


[PATCH] D99696: [clang] NRVO: Improvements and handling of more cases.

2021-06-14 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

> @hans: FYI, that looks related to the immediately following D99005 
> , not D99696 
>  specifically.

No, my test case passes at 0d9e8f5f4b68252c6caa1ef81a30777b2f5d7242 
 but fails 
at 1e50c3d785f4563873ab1ce86559f2a1285b5678 
 (D99696 
), so this does seem to be the one that 
introduced the problem.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99696

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


[PATCH] D99696: [clang] NRVO: Improvements and handling of more cases.

2021-06-14 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added a comment.

@hans: FYI, that looks related to the immediately following D99005 
, not D99696  
specifically. I suspect that reverting D99005  
(but leaving D99696  in trunk) would suffice 
to fix that symptom. But I agree I don't see why it should be happening. That 
block code looks reasonable to me at first glance and wasn't intended to be 
affected by D99005  AFAIK.
@mizvekov: See why I'm skeptical about merging big patches back-to-back and/or 
on Fridays? ;)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99696

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


[PATCH] D98068: Remove asserts for LocalInstantiationScope

2021-06-14 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

ping

I will provide a detailed description of the issue:

What happen are:

First, fun1 is instantiated as `fun1<0,1>`, which calls lambda function `f(f, 
Number<1>)`.

This causes lambda function `f` instantiated as `f(f, Number<1>)`. clang uses 
LocalInstantiationScope to track local variable instantiations, i.e., map var 
decls in the template to the corresponding var decls in the instantiation. In 
this case, clang adds two decls to the map: `fs` -> `f`, and `i` -> 
instantiation of `i` with type `Number<1>`.

This further causes instantiation of lambda function `f` as `f(f, Number<0>)` 
since `f` contains call of `fs(fs, Number<0>`.  clang adds two decls to its 
LocalInstantiationScope: `fs` -> `f`, and `i` -> instantiation of `i` with 
`Number<0>`.

Since `f` is lambda function, clang assumes its instantiation sees the decls in 
the LocalInstantiationScope of its enclosing template function instantiation, 
i.e. `f(f,Number<1>)`. However, clang assumes each decl can only show up in 
LocalInstantiationScope and any enclosing LocalInstantiationScope once, and 
clang checks and asserts that. In this case, since `f` shows up in 
LocalInstantiationScope of `f(f, Number<0>)` and `f(f, Number<1>)` twice. This 
causes assertion.

`LocalInstantiationScope' has a data member `CombineWithOuterScope`, which 
determines whether a template function instantiation sees the var decls 
instantiated in its enclosing function template instantiation. For non-lambda 
functions, this is false, therefor non-lambda functions will not have such 
issue. For non-recursive lambda function instantiation, such issue will not 
happen since the var decls will not show up twice.

Functionally, it seems to be OK to have var decls show up twice in 
`LocalInstantiationScope` for recursive labmda instantiations. For the inner 
level lambda instantiation, when looking up the var decls, the local var 
instantiation will be found first. The var instantiation in the outer 
LocalInstantiationScope will not be found. This is like the inner instantiation 
hides the outer instantiation. To me, it seems we only need to disable the 
assertion for the specific case of recursive lambda instantiation.

Any thoughts? Thanks.


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

https://reviews.llvm.org/D98068

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


[PATCH] D99696: [clang] NRVO: Improvements and handling of more cases.

2021-06-14 Thread Hans Wennborg via Phabricator via cfe-commits
hans added subscribers: rjmccall, hans.
hans added a comment.

We're seeing new build errors in Chromium after this 
(http://crbug.com/1219457). Here's a reduced example:

  $ cat /tmp/a.mm
  #include 
  
  struct Callback {
// Move-only!
Callback(const Callback&) = delete;
Callback& operator=(const Callback&) = delete;
Callback(Callback&&) = default;
Callback& operator=(Callback&&) = default;
  
void operator()() {}
  };
  
  void f(Callback c) {
__block auto x = std::move(c);
  
(void)^(void) {
  x();
};
  }
  
  $ build.release/bin/clang++ -c /tmp/a.mm -target x86_64-apple-darwin10 
-stdlib=libc++
  /tmp/a.mm:14:16: error: call to deleted constructor of 'Callback'
__block auto x = std::move(c);
 ^
  /tmp/a.mm:5:3: note: 'Callback' has been explicitly marked deleted here
Callback(const Callback&) = delete;
^
  1 error generated.

I don't know enough about blocks to know whether the new error makes sense or 
not.

+rjmccall who knows about blocks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99696

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


[PATCH] D104116: AMD k8 family does not support SSE4.x which are required by x86-64-v2+

2021-06-14 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

In D104116#2816291 , @RKSimon wrote:

> This leaves the question - what hardware should we align each of the 
> CK_x86_64_v* targets with?

I'm not quite sure I get it. If I understand correctly, each `CK_x86_64_v*` 
implies a mimal set of requirements, but doesn't map to a particular hardware, 
right?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104116

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


[PATCH] D104104: [clang][deps] NFC: Handle `DependencyOutputOptions` only once

2021-06-14 Thread Jan Svoboda 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 rGf95ff8162721: [clang][deps] NFC: Handle 
`DependencyOutputOptions` only once (authored by jansvoboda11).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104104

Files:
  clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h
  clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
  clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
  clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp


Index: clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
===
--- clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -173,11 +173,13 @@
   for (const Module *M : DirectModularDeps)
 handleTopLevelModule(M);
 
+  MDC.Consumer.handleDependencyOutputOpts(*MDC.Opts);
+
   for (auto & : MDC.ModularDeps)
 MDC.Consumer.handleModuleDependency(I.second);
 
   for (auto & : MDC.FileDeps)
-MDC.Consumer.handleFileDependency(*MDC.Opts, I);
+MDC.Consumer.handleFileDependency(I);
 
   for (auto & : DirectPrebuiltModularDeps)
 MDC.Consumer.handlePrebuiltModuleDependency(PrebuiltModuleDep{I});
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
@@ -32,11 +32,12 @@
   : DependencyFileGenerator(*Opts), Opts(std::move(Opts)), C(C) {}
 
   void finishedMainFile(DiagnosticsEngine ) override {
+C.handleDependencyOutputOpts(*Opts);
 llvm::SmallString<256> CanonPath;
 for (const auto  : getDependencies()) {
   CanonPath = File;
   llvm::sys::path::remove_dots(CanonPath, /*remove_dot_dot=*/true);
-  C.handleFileDependency(*Opts, CanonPath);
+  C.handleFileDependency(CanonPath);
 }
   }
 
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
@@ -54,10 +54,12 @@
   /// Prints out all of the gathered dependencies into a string.
   class MakeDependencyPrinterConsumer : public DependencyConsumer {
   public:
-void handleFileDependency(const DependencyOutputOptions ,
-  StringRef File) override {
-  if (!this->Opts)
-this->Opts = std::make_unique(Opts);
+void
+handleDependencyOutputOpts(const DependencyOutputOptions ) override {
+  this->Opts = std::make_unique(Opts);
+}
+
+void handleFileDependency(StringRef File) override {
   Dependencies.push_back(std::string(File));
 }
 
@@ -74,8 +76,7 @@
 void handleContextHash(std::string Hash) override {}
 
 void printDependencies(std::string ) {
-  if (!Opts)
-return;
+  assert(Opts && "Handled dependency output options.");
 
   class DependencyPrinter : public DependencyFileGenerator {
   public:
@@ -128,8 +129,10 @@
 FullDependencyPrinterConsumer(const llvm::StringSet<> )
 : AlreadySeen(AlreadySeen) {}
 
-void handleFileDependency(const DependencyOutputOptions ,
-  StringRef File) override {
+void
+handleDependencyOutputOpts(const DependencyOutputOptions ) override {}
+
+void handleFileDependency(StringRef File) override {
   Dependencies.push_back(std::string(File));
 }
 
Index: clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h
===
--- clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h
+++ clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h
@@ -34,8 +34,10 @@
 public:
   virtual ~DependencyConsumer() {}
 
-  virtual void handleFileDependency(const DependencyOutputOptions ,
-StringRef Filename) = 0;
+  virtual void
+  handleDependencyOutputOpts(const DependencyOutputOptions ) = 0;
+
+  virtual void handleFileDependency(StringRef Filename) = 0;
 
   virtual void handlePrebuiltModuleDependency(PrebuiltModuleDep PMD) = 0;
 


Index: clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
===
--- clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -173,11 +173,13 @@
   for (const Module *M : DirectModularDeps)
 handleTopLevelModule(M);
 
+  MDC.Consumer.handleDependencyOutputOpts(*MDC.Opts);
+
   for (auto & : 

[PATCH] D104106: [clang][deps] NFC: Stop using moved-from object

2021-06-14 Thread Jan Svoboda 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 rG85208b96b85f: [clang][deps] NFC: Stop using moved-from 
object (authored by jansvoboda11).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104106

Files:
  clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp


Index: clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
@@ -171,8 +171,8 @@
 // invocation to the collector. The options in the invocation are reset,
 // which ensures that the compiler won't create new dependency collectors,
 // and thus won't write out the extra '.d' files to disk.
-auto Opts = std::make_unique(
-std::move(Compiler.getInvocation().getDependencyOutputOpts()));
+auto Opts = std::make_unique();
+std::swap(*Opts, Compiler.getInvocation().getDependencyOutputOpts());
 // We need at least one -MT equivalent for the generator of make dependency
 // files to work.
 if (Opts->Targets.empty())


Index: clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
@@ -171,8 +171,8 @@
 // invocation to the collector. The options in the invocation are reset,
 // which ensures that the compiler won't create new dependency collectors,
 // and thus won't write out the extra '.d' files to disk.
-auto Opts = std::make_unique(
-std::move(Compiler.getInvocation().getDependencyOutputOpts()));
+auto Opts = std::make_unique();
+std::swap(*Opts, Compiler.getInvocation().getDependencyOutputOpts());
 // We need at least one -MT equivalent for the generator of make dependency
 // files to work.
 if (Opts->Targets.empty())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >