[PATCH] D98237: Option for empty lines after an access modifier.

2021-03-08 Thread Max Sagebaum via Phabricator via cfe-commits
Max_S created this revision.
Max_S requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The current logic for access modifiers in classes ignores the option 
'MaxEmptyLinesToKeep=1'. It is therefore impossible to have a coding style that 
requests one empty line after an access modifier. The patch allows the user to 
configure how many empty lines clang-format should add after an access 
modifier. This will remove lines if there are to many and will add them if 
there are missing.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98237

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -9179,6 +9179,21 @@
Style);
 }
 
+TEST_F(FormatTest, FormatsAfterAccessModifiers) {
+  verifyFormat("class Foo {\n"
+   "private:\n"
+   "  int i;\n"
+   "};");
+
+  FormatStyle StyleWithLine = getLLVMStyle();
+  StyleWithLine.EmptyLinesAfterAccessModifier = 1u;
+  verifyFormat("class Foo {\n"
+   "private:\n"
+   "\n"
+   "  int i;\n"
+   "};", StyleWithLine);
+}
+
 TEST_F(FormatTest, FormatsArrays) {
   verifyFormat("a[a]\n"
" [b] = c;");
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -1281,7 +1281,7 @@
   // Remove empty lines after access specifiers.
   if (PreviousLine && PreviousLine->First->isAccessSpecifier() &&
   (!PreviousLine->InPPDirective || !RootToken.HasUnescapedNewline))
-Newlines = std::min(1u, Newlines);
+Newlines = Style.EmptyLinesAfterAccessModifier + 1u;
 
   if (Newlines)
 Indent = NewlineIndent;
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -586,6 +586,8 @@
 IO.mapOptional("DisableFormat", Style.DisableFormat);
 IO.mapOptional("EmptyLineBeforeAccessModifier",
Style.EmptyLineBeforeAccessModifier);
+IO.mapOptional("EmptyLinesAfterAccessModifier",
+   Style.EmptyLinesAfterAccessModifier);
 IO.mapOptional("ExperimentalAutoDetectBinPacking",
Style.ExperimentalAutoDetectBinPacking);
 IO.mapOptional("FixNamespaceComments", Style.FixNamespaceComments);
@@ -975,6 +977,7 @@
   LLVMStyle.DeriveLineEnding = true;
   LLVMStyle.DerivePointerAlignment = false;
   LLVMStyle.EmptyLineBeforeAccessModifier = FormatStyle::ELBAMS_LogicalBlock;
+  LLVMStyle.EmptyLinesAfterAccessModifier = 0u;
   LLVMStyle.ExperimentalAutoDetectBinPacking = false;
   LLVMStyle.FixNamespaceComments = true;
   LLVMStyle.ForEachMacros.push_back("foreach");
Index: clang/include/clang/Format/Format.h
===
--- clang/include/clang/Format/Format.h
+++ clang/include/clang/Format/Format.h
@@ -1953,6 +1953,9 @@
   /// Defines in which cases to put empty line before access modifiers.
   EmptyLineBeforeAccessModifierStyle EmptyLineBeforeAccessModifier;
 
+  /// Defines how many lines are put after access modifiers.
+  unsigned EmptyLinesAfterAccessModifier;
+
   /// If ``true``, clang-format detects whether function calls and
   /// definitions are formatted with one parameter per line.
   ///
@@ -3201,6 +3204,7 @@
DerivePointerAlignment == R.DerivePointerAlignment &&
DisableFormat == R.DisableFormat &&
EmptyLineBeforeAccessModifier == R.EmptyLineBeforeAccessModifier &&
+   EmptyLinesAfterAccessModifier == R.EmptyLinesAfterAccessModifier &&
ExperimentalAutoDetectBinPacking ==
R.ExperimentalAutoDetectBinPacking &&
FixNamespaceComments == R.FixNamespaceComments &&
Index: clang/docs/ClangFormatStyleOptions.rst
===
--- clang/docs/ClangFormatStyleOptions.rst
+++ clang/docs/ClangFormatStyleOptions.rst
@@ -2195,7 +2195,17 @@
   protected:
   };
 
+**EmptyLinesAfterAccessModifier** (``unsigned``)
+  Defines how many lines are put after access modifiers.
 
+  .. code-block:: c++
+
+ 0: 1:
+ struct Foo {   vs. struct Foo {
+ private:   private:
+   int x;
+ };   int x;
+  

[PATCH] D93938: [clang-format] Fixed AfterEnum handling

2021-03-08 Thread Ally Tiritoglu via Phabricator via cfe-commits
atirit added a comment.

In D93938#2612952 , 
@HazardyKnusperkeks wrote:

> In my opinion you should then, either temporarily deactivate the test, or fix 
> the bug first. A failing test blocks the pipeline and confuses everyone 
> working on the project.



In D93938#2613077 , @curdeius wrote:

> I got confused about this. I know that there was some discussion about this 
> failing test but I thought that the plan was to fix it (as it should). Also, 
> that's what one expects in a revision called "Fixed AfterEnum handling" :).



In D93938#2613079 , @MyDeveloperDay 
wrote:

> +1 we are not going to land this with a failing or removed test

There are two bugs being discussed here. The first is the one fixed here, where 
`AfterEnum` is treated as always `true`. The second I found while adding unit 
tests for the first bug. I was advised that I shouldn't fix two bugs with a 
single differential, especially since the second bug has more to do with 
`AllowShortEnumsOnASingleLine` and how it is overridden by `AfterEnum`. (I 
think a more appropriate title for a diff handling the second bug would be 
"Fixed AllowShortEnumsOnASingleLine handling".) However, if it is acceptable to 
do so, then I'll add commits to fix the second bug as well before asking for 
this to be merged.

I agree with @HazardyKnusperkeks that failing tests should not be merged, and I 
understand that this patch is not ready yet.

Please let me know what you think would be the best course of action here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93938

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


Re: [PATCH] D93938: [clang-format] Fixed AfterEnum handling

2021-03-08 Thread MyDeveloper Day via cfe-commits
+1 we are not going to land this with a failing or removed test


On Tue, 9 Mar 2021 at 07:29, Marek Kurdej via Phabricator <
revi...@reviews.llvm.org> wrote:

> curdeius added a comment.
>
> In D93938#2612952 ,
> @HazardyKnusperkeks wrote:
>
> > In my opinion you should then, either temporarily deactivate the test,
> or fix the bug first. A failing test blocks the pipeline and confuses
> everyone working on the project.
>
> +1
>
> I got confused about this. I know that there was some discussion about
> this failing test but I thought that the plan was to fix it (as it should).
> Also, that's what one expects in a revision called "Fixed AfterEnum
> handling" :).
>
>
> Repository:
>   rG LLVM Github Monorepo
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D93938/new/
>
> https://reviews.llvm.org/D93938
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D93938: [clang-format] Fixed AfterEnum handling

2021-03-08 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added a comment.

In D93938#2612952 , 
@HazardyKnusperkeks wrote:

> In my opinion you should then, either temporarily deactivate the test, or fix 
> the bug first. A failing test blocks the pipeline and confuses everyone 
> working on the project.

+1

I got confused about this. I know that there was some discussion about this 
failing test but I thought that the plan was to fix it (as it should). Also, 
that's what one expects in a revision called "Fixed AfterEnum handling" :).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93938

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


[PATCH] D72235: [clang-tidy] new altera unroll loops check

2021-03-08 Thread Frank Derry Wanye via Phabricator via cfe-commits
ffrankies updated this revision to Diff 329207.
ffrankies added a comment.

- Ran `git-clang-format HEAD^`
- Addressed comments automatically added by the Lint: Pre-merge Checks


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

https://reviews.llvm.org/D72235

Files:
  clang-tools-extra/clang-tidy/altera/AlteraTidyModule.cpp
  clang-tools-extra/clang-tidy/altera/CMakeLists.txt
  clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
  clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/altera-unroll-loops.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/checkers/altera-unroll-loops.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/altera-unroll-loops.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/altera-unroll-loops.cpp
@@ -0,0 +1,516 @@
+// RUN: %check_clang_tidy %s altera-unroll-loops %t -- -config="{CheckOptions: [{key: "altera-unroll-loops.MaxLoopIterations", value: 50}]}" -header-filter=.*
+// RUN: %check_clang_tidy -check-suffix=MULT %s altera-unroll-loops %t -- -config="{CheckOptions: [{key: "altera-unroll-loops.MaxLoopIterations", value: 5}]}" -header-filter=.* "--" -DMULT
+
+#ifdef MULT
+// For loops with *= and /= increments.
+void for_loop_mult_div_increments(int *A) {
+// *=
+#pragma unroll
+  for (int i = 2; i <= 32; i *= 2)
+A[i]++; // OK
+
+#pragma unroll
+  for (int i = 2; i <= 64; i *= 2)
+// CHECK-MESSAGES-MULT: :[[@LINE-1]]:3: warning: loop likely has a large number of iterations and thus cannot be fully unrolled; to partially unroll this loop, use the '#pragma unroll ' directive [altera-unroll-loops]
+A[i]++; // Not OK
+
+// /=
+#pragma unroll
+  for (int i = 32; i >= 2; i /= 2)
+A[i]++; // OK
+
+#pragma unroll
+  for (int i = 64; i >= 2; i /= 2)
+// CHECK-MESSAGES-MULT: :[[@LINE-1]]:3: warning: loop likely has a large number of iterations and thus cannot be fully unrolled; to partially unroll this loop, use the '#pragma unroll ' directive [altera-unroll-loops]
+A[i]++; // Not OK
+}
+#else
+// Cannot determine loop bounds for while loops.
+void while_loops(int *A) {
+  // Recommend unrolling loops that aren't already unrolled.
+  int j = 0;
+  while (j < 2000) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: kernel performance could be improved by unrolling this loop with a '#pragma unroll' directive [altera-unroll-loops]
+A[1] += j;
+j++;
+  }
+
+  do {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: kernel performance could be improved by unrolling this loop with a '#pragma unroll' directive [altera-unroll-loops]
+A[2] += j;
+j++;
+  } while (j < 2000);
+
+// If a while loop is fully unrolled, add a note recommending partial
+// unrolling.
+#pragma unroll
+  while (j < 2000) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: note: full unrolling requested, but loop bounds may not be known; to partially unroll this loop, use the '#pragma unroll ' directive
+A[j]++;
+  }
+
+#pragma unroll
+  do {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: note: full unrolling requested, but loop bounds may not be known; to partially unroll this loop, use the '#pragma unroll ' directive
+A[j]++;
+  } while (j < 2000);
+
+// While loop is partially unrolled, no action needed.
+#pragma unroll 4
+  while (j < 2000) {
+A[j]++;
+  }
+
+#pragma unroll 4
+  do {
+A[j]++;
+  } while (j < 2000);
+}
+
+// Range-based for loops.
+void cxx_for_loops(int *A, int vectorSize) {
+  // Loop with known array size should be unrolled.
+  int a[] = {0, 1, 2, 3, 4, 5};
+  for (int k : a) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: kernel performance could be improved by unrolling this loop with a '#pragma unroll' directive [altera-unroll-loops]
+A[k]++;
+  }
+
+// Loop with known size correctly unrolled.
+#pragma unroll
+  for (int k : a) {
+A[k]++;
+  }
+
+  // Loop with unknown size should be partially unrolled.
+  int b[vectorSize];
+#pragma unroll
+  for (int k : b) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: full unrolling requested, but loop bounds are not known; to partially unroll this loop, use the '#pragma unroll ' directive [altera-unroll-loops]
+k++;
+  }
+
+// Loop with unknown size correctly unrolled.
+#pragma unroll 5
+  for (int k : b) {
+k++;
+  }
+
+  // Loop with large size should be partially unrolled.
+  int c[51];
+#pragma unroll
+  for (int k : c) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: loop likely has a large number of iterations and thus cannot be fully unrolled; to partially unroll this loop, use the '#pragma unroll ' directive [altera-unroll-loops]
+A[k]++;
+  }
+
+// Loop with large size correctly unrolled.
+#pragma unroll 5
+  for (int k : c) {
+A[k]++;
+  }
+}
+
+// Simple for loops.
+void for_loops(int *A, int size) {
+  // Recommend unrolling loops that aren't 

[PATCH] D93938: [clang-format] Fixed AfterEnum handling

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

In D93938#2612908 , @atirit wrote:

> In D93938#2610568 , @curdeius wrote:
>
>> I hadn't had another look, because the CI still shows the test `AfterEnum` 
>> to be failing.
>
> I know the test fails; it's due to a separate bug wherein `AfterEnum: true` 
> and `AllowShortEnumsOnASingleLine: true` produces incorrect behaviour. The 
> unit test has the correct expectation. I've also already mentioned this.
>
> In D93938#2476691 , @atirit wrote:
>
>> The first test fails due to the aforementioned corner case.
>
> I could modify the unit test to expect the currently broken behaviour and 
> then fix the test later alongside a fix for the corner case.

In my opinion you should then, either temporarily deactivate the test, or fix 
the bug first. A failing test blocks the pipeline and confuses everyone working 
on the project.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93938

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


[PATCH] D93594: [X86] Pass to transform amx intrinsics to scalar operation.

2021-03-08 Thread Bing Yu via Phabricator via cfe-commits
yubing updated this revision to Diff 329204.
yubing added a comment.

Fix buildfail when it is -DBUILD_SHARED_LIBS=ON


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93594

Files:
  llvm/include/llvm/CodeGen/Passes.h
  llvm/lib/Target/X86/CMakeLists.txt
  llvm/lib/Target/X86/X86.h
  llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp
  llvm/lib/Target/X86/X86LowerAMXType.cpp
  llvm/lib/Target/X86/X86TargetMachine.cpp
  llvm/test/CodeGen/X86/AMX/amx-low-intrinsics-no-amx-bitcast.ll
  llvm/test/CodeGen/X86/AMX/amx-low-intrinsics.ll
  llvm/test/CodeGen/X86/AMX/amx-type.ll
  llvm/test/CodeGen/X86/O0-pipeline.ll
  llvm/test/CodeGen/X86/opt-pipeline.ll
  llvm/tools/opt/opt.cpp

Index: llvm/tools/opt/opt.cpp
===
--- llvm/tools/opt/opt.cpp
+++ llvm/tools/opt/opt.cpp
@@ -513,7 +513,8 @@
   "expand-reductions","indirectbr-expand",
   "generic-to-nvvm",  "expandmemcmp",
   "loop-reduce",  "lower-amx-type",
-  "polyhedral-info",  "replace-with-veclib"};
+  "lower-amx-intrinsics", "polyhedral-info",
+  "replace-with-veclib"};
   for (const auto  : PassNamePrefix)
 if (Pass.startswith(P))
   return true;
Index: llvm/test/CodeGen/X86/opt-pipeline.ll
===
--- llvm/test/CodeGen/X86/opt-pipeline.ll
+++ llvm/test/CodeGen/X86/opt-pipeline.ll
@@ -24,11 +24,12 @@
 ; CHECK-NEXT: Pre-ISel Intrinsic Lowering
 ; CHECK-NEXT: FunctionPass Manager
 ; CHECK-NEXT:   Expand Atomic instructions
+; CHECK-NEXT:   Dominator Tree Construction
+; CHECK-NEXT:   Natural Loop Information
+; CHECK-NEXT:   Lower AMX intrinsics
 ; CHECK-NEXT:   Lower AMX type for load/store
 ; CHECK-NEXT:   Module Verifier
-; CHECK-NEXT:   Dominator Tree Construction
 ; CHECK-NEXT:   Basic Alias Analysis (stateless AA impl)
-; CHECK-NEXT:   Natural Loop Information
 ; CHECK-NEXT:   Canonicalize natural loops
 ; CHECK-NEXT:   Scalar Evolution Analysis
 ; CHECK-NEXT:   Loop Pass Manager
Index: llvm/test/CodeGen/X86/O0-pipeline.ll
===
--- llvm/test/CodeGen/X86/O0-pipeline.ll
+++ llvm/test/CodeGen/X86/O0-pipeline.ll
@@ -18,6 +18,9 @@
 ; CHECK-NEXT: Pre-ISel Intrinsic Lowering
 ; CHECK-NEXT: FunctionPass Manager
 ; CHECK-NEXT:   Expand Atomic instructions
+; CHECK-NEXT:   Dominator Tree Construction
+; CHECK-NEXT:   Natural Loop Information
+; CHECK-NEXT:   Lower AMX intrinsics
 ; CHECK-NEXT:   Lower AMX type for load/store
 ; CHECK-NEXT:   Module Verifier
 ; CHECK-NEXT:   Lower Garbage Collection Instructions
Index: llvm/test/CodeGen/X86/AMX/amx-type.ll
===
--- llvm/test/CodeGen/X86/AMX/amx-type.ll
+++ llvm/test/CodeGen/X86/AMX/amx-type.ll
@@ -1,5 +1,5 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt -lower-amx-type %s -S | FileCheck %s
+; RUN: opt --codegen-opt-level=2 -mtriple=x86_64 -lower-amx-type %s -S | FileCheck %s
 
 %struct.__tile_str = type { i16, i16, <256 x i32> }
 
Index: llvm/test/CodeGen/X86/AMX/amx-low-intrinsics.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/AMX/amx-low-intrinsics.ll
@@ -0,0 +1,237 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -mtriple=x86_64 -lower-amx-intrinsics %s -S | FileCheck %s
+
+define dso_local void @test_amx_load_non_O0(i16 signext %row, i16 signext %col, i8 *%ptr, i64 %stride, <256 x i32>* %vptr) {
+; CHECK-LABEL: @test_amx_load_non_O0(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:[[TMP0:%.*]] = lshr i16 [[COL:%.*]], 2
+; CHECK-NEXT:[[TMP1:%.*]] = lshr i64 [[STRIDE:%.*]], 2
+; CHECK-NEXT:br label [[TILELOAD_SCALARIZE_ROWS_HEADER:%.*]]
+; CHECK:   tileload.scalarize.rows.header:
+; CHECK-NEXT:[[TILELOAD_SCALARIZE_ROWS_IV:%.*]] = phi i16 [ 0, [[ENTRY:%.*]] ], [ [[TILELOAD_SCALARIZE_ROWS_STEP:%.*]], [[TILELOAD_SCALARIZE_ROWS_LATCH:%.*]] ]
+; CHECK-NEXT:[[VEC_PHI_ROW:%.*]] = phi <256 x i32> [ zeroinitializer, [[ENTRY]] ], [ [[TMP11:%.*]], [[TILELOAD_SCALARIZE_ROWS_LATCH]] ]
+; CHECK-NEXT:br label [[TILELOAD_SCALARIZE_ROWS_BODY:%.*]]
+; CHECK:   tileload.scalarize.rows.body:
+; CHECK-NEXT:br label [[TILELOAD_SCALARIZE_COLS_HEADER:%.*]]
+; CHECK:   tileload.scalarize.cols.header:
+; CHECK-NEXT:[[TILELOAD_SCALARIZE_COLS_IV:%.*]] = phi i16 [ 0, [[TILELOAD_SCALARIZE_ROWS_BODY]] ], [ [[TILELOAD_SCALARIZE_COLS_STEP:%.*]], [[TILELOAD_SCALARIZE_COLS_LATCH:%.*]] ]
+; CHECK-NEXT:[[VEC_PHI:%.*]] = phi <256 x i32> [ [[VEC_PHI_ROW]], [[TILELOAD_SCALARIZE_ROWS_BODY]] ], [ [[TMP11]], [[TILELOAD_SCALARIZE_COLS_LATCH]] ]
+; CHECK-NEXT:br label [[TILELOAD_SCALARIZE_COLS_BODY:%.*]]
+; 

[PATCH] D93938: [clang-format] Fixed AfterEnum handling

2021-03-08 Thread Ally Tiritoglu via Phabricator via cfe-commits
atirit added a comment.

In D93938#2610568 , @curdeius wrote:

> I hadn't had another look, because the CI still shows the test `AfterEnum` to 
> be failing.

I know the test fails; it's due to a separate bug wherein `AfterEnum: true` and 
`AllowShortEnumsOnASingleLine: true` produces incorrect behaviour. The unit 
test has the correct expectation. I've also already mentioned this.

In D93938#2476691 , @atirit wrote:

> The first test fails due to the aforementioned corner case.

I could modify the unit test to expect the currently broken behaviour and then 
fix the test later alongside a fix for the corner case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93938

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


[PATCH] D98134: [WIP][RFC] Introduce callback argument encoding mode into callback metadata

2021-03-08 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 updated this revision to Diff 329191.
tianshilei1992 added a comment.

update llvm doc


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98134

Files:
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/attr-callback.c
  clang/test/CodeGen/callback_annotated.c
  clang/test/CodeGen/callback_openmp.c
  clang/test/CodeGenCXX/attr-callback.cpp
  clang/test/OpenMP/parallel_codegen.cpp
  clang/test/Sema/attr-callback-broken.c
  clang/test/Sema/attr-callback.c
  clang/test/SemaCXX/attr-callback.cpp
  llvm/docs/LangRef.rst
  llvm/include/llvm/IR/AbstractCallSite.h
  llvm/include/llvm/IR/MDBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/lib/IR/AbstractCallSite.cpp
  llvm/lib/IR/MDBuilder.cpp
  llvm/test/Analysis/CallGraph/callback-calls.ll
  llvm/test/Analysis/CallGraph/ignore-callback-uses.ll
  llvm/test/Transforms/Attributor/IPConstantProp/multiple_callbacks.ll
  llvm/test/Transforms/Attributor/IPConstantProp/openmp_parallel_for.ll
  llvm/test/Transforms/Attributor/IPConstantProp/pthreads.ll
  llvm/test/Transforms/Attributor/IPConstantProp/thread_local_acs.ll
  llvm/test/Transforms/Attributor/callbacks.ll
  llvm/test/Transforms/Attributor/noundef.ll
  llvm/test/Transforms/OpenMP/parallel_deletion.ll
  llvm/test/Transforms/OpenMP/parallel_deletion_cg_update.ll
  llvm/test/Transforms/OpenMP/parallel_deletion_remarks.ll
  llvm/test/Transforms/OpenMP/parallel_region_merging.ll
  llvm/unittests/IR/AbstractCallSiteTest.cpp
  llvm/unittests/IR/LegacyPassManagerTest.cpp

Index: llvm/unittests/IR/LegacyPassManagerTest.cpp
===
--- llvm/unittests/IR/LegacyPassManagerTest.cpp
+++ llvm/unittests/IR/LegacyPassManagerTest.cpp
@@ -768,7 +768,7 @@
"}\n"
"\n"
"!0 = !{!1}\n"
-   "!1 = !{i64 0, i64 1, i1 false}";
+   "!1 = !{i64 0, i64 0, i64 1, i1 false}";
 
   SMDiagnostic Err;
   std::unique_ptr M = parseAssemblyString(IR, Err, Context);
Index: llvm/unittests/IR/AbstractCallSiteTest.cpp
===
--- llvm/unittests/IR/AbstractCallSiteTest.cpp
+++ llvm/unittests/IR/AbstractCallSiteTest.cpp
@@ -36,7 +36,7 @@
   "}\n"
   "declare !callback !0 void @broker(i32, void (i8*, ...)*, ...)\n"
   "!0 = !{!1}\n"
-  "!1 = !{i64 1, i64 -1, i1 true}";
+  "!1 = !{i64 0, i64 1, i64 -1, i1 true}";
 
   std::unique_ptr M = parseIR(C, IR);
   ASSERT_TRUE(M);
Index: llvm/test/Transforms/OpenMP/parallel_region_merging.ll
===
--- llvm/test/Transforms/OpenMP/parallel_region_merging.ll
+++ llvm/test/Transforms/OpenMP/parallel_region_merging.ll
@@ -786,7 +786,7 @@
 
 !0 = !{i32 1, !"wchar_size", i32 4}
 !1 = !{!2}
-!2 = !{i64 2, i64 -1, i64 -1, i1 true}
+!2 = !{i64 0, i64 2, i64 -1, i64 -1, i1 true}
 ; CHECK-LABEL: define {{[^@]+}}@merge
 ; CHECK-SAME: (i32 [[A:%.*]]) local_unnamed_addr {
 ; CHECK-NEXT:  entry:
Index: llvm/test/Transforms/OpenMP/parallel_deletion_remarks.ll
===
--- llvm/test/Transforms/OpenMP/parallel_deletion_remarks.ll
+++ llvm/test/Transforms/OpenMP/parallel_deletion_remarks.ll
@@ -96,7 +96,7 @@
 !21 = !DILocation(line: 14, column: 1, scope: !15)
 !22 = !DILocation(line: 16, column: 1, scope: !15)
 !23 = !{!24}
-!24 = !{i64 2, i64 -1, i64 -1, i1 true}
+!24 = !{i64 0, i64 2, i64 -1, i64 -1, i1 true}
 !25 = distinct !DISubprogram(name: ".omp_outlined.", scope: !1, file: !1, line: 9, type: !26, scopeLine: 9, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !33)
 !26 = !DISubroutineType(types: !27)
 !27 = !{null, !28, !28}
Index: llvm/test/Transforms/OpenMP/parallel_deletion_cg_update.ll
===
--- llvm/test/Transforms/OpenMP/parallel_deletion_cg_update.ll
+++ llvm/test/Transforms/OpenMP/parallel_deletion_cg_update.ll
@@ -9,7 +9,7 @@
 ; CHECK:   CS calls function 'd'
 ;
 ; CHECK: Call graph node for function: '.omp_outlined..0'<<{{.*}}>>  #uses=1
-; 
+;
 ; CHECK: Call graph node for function: '.omp_outlined..1'<<{{.*}}>>  #uses=3
 ; CHECK:   CS<{{.*}}> calls function 'd'
 ;
@@ -89,4 +89,4 @@
 !0 = !{i32 1, !"wchar_size", i32 4}
 !1 = !{!"clang version 11.0.0"}
 !2 = !{!3}
-!3 = !{i64 2, i64 -1, i64 -1, i1 true}
+!3 = !{i64 0, i64 2, i64 -1, i64 -1, i1 true}
Index: llvm/test/Transforms/OpenMP/parallel_deletion.ll
===
--- llvm/test/Transforms/OpenMP/parallel_deletion.ll
+++ 

[PATCH] D97990: [clang] Improve diagnostics on implicitly deleted defaulted comparisons

2021-03-08 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added a comment.

You are absolutely right, my bad!!

So we stealth fix this revision to improve the message :D


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97990

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


[PATCH] D97990: [clang] Always provide relevant subobject for 'no viable comparison'

2021-03-08 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 329178.
mizvekov added a comment.

Now this a patch just about improving the diagnostic as rsmith suggested.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97990

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
  clang/test/CXX/class/class.compare/class.compare.default/p2.cpp
  clang/test/CXX/class/class.compare/class.compare.default/p4.cpp
  clang/test/CXX/class/class.compare/class.eq/p2.cpp
  clang/test/CXX/class/class.compare/class.spaceship/p1.cpp
  clang/test/CXX/class/class.compare/class.spaceship/p2.cpp

Index: clang/test/CXX/class/class.compare/class.spaceship/p2.cpp
===
--- clang/test/CXX/class/class.compare/class.spaceship/p2.cpp
+++ clang/test/CXX/class/class.compare/class.spaceship/p2.cpp
@@ -52,7 +52,7 @@
 bool operator<(const A&) const;
   };
   struct B {
-A a; // expected-note {{no viable comparison function for member 'a'}}
+A a; // expected-note {{no viable three-way comparison function for member 'a'}}
 auto operator<=>(const B&) const = default; // expected-warning {{implicitly deleted}}
   };
 }
@@ -159,16 +159,16 @@
 namespace PR48856 {
   struct A {
 auto operator<=>(const A &) const = default; // expected-warning {{implicitly deleted}}
-void (*x)(); // expected-note {{because there is no viable comparison function for member 'x'}}
+void (*x)(); // expected-note {{because there is no viable three-way comparison function for member 'x'}}
   };
 
   struct B {
 auto operator<=>(const B &) const = default; // expected-warning {{implicitly deleted}}
-void (B::*x)();  // expected-note {{because there is no viable comparison function for member 'x'}}
+void (B::*x)();  // expected-note {{because there is no viable three-way comparison function for member 'x'}}
   };
 
   struct C {
 auto operator<=>(const C &) const = default; // expected-warning {{implicitly deleted}}
-int C::*x;   // expected-note {{because there is no viable comparison function for member 'x'}}
+int C::*x;   // expected-note {{because there is no viable three-way comparison function for member 'x'}}
   };
 }
Index: clang/test/CXX/class/class.compare/class.spaceship/p1.cpp
===
--- clang/test/CXX/class/class.compare/class.spaceship/p1.cpp
+++ clang/test/CXX/class/class.compare/class.spaceship/p1.cpp
@@ -78,9 +78,9 @@
   };
 
   // expected-note@#base {{deleted comparison function for base class 'C'}}
-  // expected-note@#base {{no viable comparison function for base class 'D1'}}
+  // expected-note@#base {{no viable three-way comparison function for base class 'D1'}}
   // expected-note@#base {{three-way comparison cannot be synthesized because there is no viable function for '<' comparison}}
-  // expected-note@#base {{no viable comparison function for base class 'D2'}}
+  // expected-note@#base {{no viable three-way comparison function for base class 'D2'}}
   // expected-note@#base {{three-way comparison cannot be synthesized because there is no viable function for '==' comparison}}
   // expected-note@#base {{deleted comparison function for base class 'E'}}
   // expected-note@#base {{implied comparison for base class 'F' is ambiguous}}
@@ -110,9 +110,9 @@
   }
 
   // expected-note@#arr {{deleted comparison function for member 'arr'}}
-  // expected-note@#arr {{no viable comparison function for member 'arr'}}
+  // expected-note@#arr {{no viable three-way comparison function for member 'arr'}}
   // expected-note@#arr {{three-way comparison cannot be synthesized because there is no viable function for '<' comparison}}
-  // expected-note@#arr {{no viable comparison function for member 'arr'}}
+  // expected-note@#arr {{no viable three-way comparison function for member 'arr'}}
   // expected-note@#arr {{three-way comparison cannot be synthesized because there is no viable function for '==' comparison}}
   // expected-note@#arr {{deleted comparison function for member 'arr'}}
   // expected-note@#arr {{implied comparison for member 'arr' is ambiguous}}
Index: clang/test/CXX/class/class.compare/class.eq/p2.cpp
===
--- clang/test/CXX/class/class.compare/class.eq/p2.cpp
+++ clang/test/CXX/class/class.compare/class.eq/p2.cpp
@@ -18,26 +18,26 @@
 struct H1 {
   bool operator==(const H1 &) const = default;
   bool operator<(const H1 &) const = default; // expected-warning {{implicitly deleted}}
-  // expected-note@-1 {{because there is no viable comparison function}}
+  // 

[PATCH] D93594: [X86] Pass to transform amx intrinsics to scalar operation.

2021-03-08 Thread Bing Yu via Phabricator via cfe-commits
yubing added a comment.

In D93594#2606157 , @RKSimon wrote:

> @yubing I've reverted this as it was failing on a lot of buildbots: 
> http://lab.llvm.org:8011/#/builders/109/builds/9867

Hi, @RKSimon @nicolasvasilache , it seems we haven't told 
libLLVMX86CodeGen.so.13git to link TransformUtils 
inllvm/lib/Target/X86/CMakeLists.txt, That's why we encounter buildfail.
But There is a strange thing which can be observed in build.ninja :
When I cmake  with "-DBUILD_SHARED_LIBS=OFF", libLLVMX86CodeGen.a will still 
link lib/libLLVMTransformUtils.a.
When I cmake  with "-DBUILD_SHARED_LIBS=ON", libLLVMX86CodeGen.so.13git won't 
link TransformUtils.
Is there any difference in build system for static library and shared library?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93594

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


[PATCH] D97068: Run non-filechecked commands in update_cc_test_checks.py

2021-03-08 Thread Giorgis Georgakoudis via Phabricator via cfe-commits
ggeorgakoudis added a comment.

@jroelofs, thank you very much for the much useful information. I will try to 
replicate the problem with the apple triple and fix it, if possible, or 
otherwise use your patch to avoid the issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97068

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


[PATCH] D97068: Run non-filechecked commands in update_cc_test_checks.py

2021-03-08 Thread Jon Roelofs via Phabricator via cfe-commits
jroelofs reopened this revision.
jroelofs added a comment.
This revision is now accepted and ready to land.

Reverted in a24644bb1ce09b40c2d751569dd5bb37ea9c995d 
 to get 
the bots green again. Feel free to re-land with a fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97068

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


[clang] a24644b - Revert "Run non-filechecked commands in update_cc_test_checks.py"

2021-03-08 Thread Jon Roelofs via cfe-commits

Author: Jon Roelofs
Date: 2021-03-08T17:26:24-08:00
New Revision: a24644bb1ce09b40c2d751569dd5bb37ea9c995d

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

LOG: Revert "Run non-filechecked commands in update_cc_test_checks.py"

This reverts commit 60d4c73b30a0e324c6ae314722eb036f70f4b03a.

The new test is broken on macos hosts. Discussion here:
https://reviews.llvm.org/D97068#2611269
https://reviews.llvm.org/D97068#2612675

... revert to green.

Added: 


Modified: 
llvm/utils/update_cc_test_checks.py

Removed: 
clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c
clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c.expected
clang/test/utils/update_cc_test_checks/exec-all-runlines.test



diff  --git a/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c 
b/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c
deleted file mode 100644
index bf18179392dc..
--- a/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c
+++ /dev/null
@@ -1,10 +0,0 @@
-// Check that the non-clang/non-filechecked runlines execute
-// RUN: cp %s %s.copy.c
-// RUN: %clang_cc1 -fopenmp %s.copy.c -emit-llvm-bc -o %t-host.bc
-// RUN: %clang_cc1 -fopenmp -fopenmp-host-ir-file-path %t-host.bc %s.copy.c 
-emit-llvm -o - | FileCheck %s
-
-void use(int);
-
-void test(int a)
-{
-}

diff  --git 
a/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c.expected 
b/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c.expected
deleted file mode 100644
index ffc8caac0f23..
--- a/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c.expected
+++ /dev/null
@@ -1,17 +0,0 @@
-// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
-// Check that the non-clang/non-filechecked runlines execute
-// RUN: cp %s %s.copy.c
-// RUN: %clang_cc1 -fopenmp %s.copy.c -emit-llvm-bc -o %t-host.bc
-// RUN: %clang_cc1 -fopenmp -fopenmp-host-ir-file-path %t-host.bc %s.copy.c 
-emit-llvm -o - | FileCheck %s
-
-void use(int);
-
-// CHECK-LABEL: @test(
-// CHECK-NEXT:  entry:
-// CHECK-NEXT:[[A_ADDR:%.*]] = alloca i32, align 4
-// CHECK-NEXT:store i32 [[A:%.*]], i32* [[A_ADDR]], align 4
-// CHECK-NEXT:ret void
-//
-void test(int a)
-{
-}

diff  --git a/clang/test/utils/update_cc_test_checks/exec-all-runlines.test 
b/clang/test/utils/update_cc_test_checks/exec-all-runlines.test
deleted file mode 100644
index caf39934266c..
--- a/clang/test/utils/update_cc_test_checks/exec-all-runlines.test
+++ /dev/null
@@ -1,8 +0,0 @@
-## Test that non-clang/non-filechecked runlines execute
-
-# RUN: cp %S/Inputs/exec-all-runlines.c %t-generated.c && 
%update_cc_test_checks %t-generated.c
-# RUN: 
diff  -u %S/Inputs/exec-all-runlines.c.expected %t-generated.c
-
-## Check that re-running update_cc_test_checks doesn't change the output
-# RUN: %update_cc_test_checks %t-generated.c
-# RUN: 
diff  -u %S/Inputs/exec-all-runlines.c.expected %t-generated.c

diff  --git a/llvm/utils/update_cc_test_checks.py 
b/llvm/utils/update_cc_test_checks.py
index d084bc6d0795..e5ca91502cf9 100755
--- a/llvm/utils/update_cc_test_checks.py
+++ b/llvm/utils/update_cc_test_checks.py
@@ -203,14 +203,6 @@ def get_function_body(builder, args, filename, clang_args, 
extra_commands,
   'are discouraged in Clang testsuite.', file=sys.stderr)
 sys.exit(1)
 
-def exec_run_line(exe):
-  popen = subprocess.Popen(exe, stdout=subprocess.PIPE, 
stderr=subprocess.PIPE, universal_newlines=True)
-  stdout, stderr = popen.communicate()
-  if popen.returncode != 0:
-sys.stderr.write('Failed to run ' + ' '.join(exe) + '\n')
-sys.stderr.write(stderr)
-sys.stderr.write(stdout)
-sys.exit(3)
 
 def main():
   initial_args, parser = config()
@@ -229,31 +221,25 @@ def main():
   if m:
 triple_in_cmd = m.groups()[0]
 
-  # Parse executable args.
-  exec_args = shlex.split(commands[0])
-  # Execute non-clang runline.
-  if exec_args[0] not in SUBST:
-print('NOTE: Executing non-clang RUN line: ' + l, file=sys.stderr)
-# Replace %s by `filename`.
-exec_args = [i.replace('%s', ti.path) if '%s' in i else i for i in 
exec_args]
-exec_run_line(exec_args)
+  # Apply %clang substitution rule, replace %s by `filename`, and append 
args.clang_args
+  clang_args = shlex.split(commands[0])
+  if clang_args[0] not in SUBST:
+print('WARNING: Skipping non-clang RUN line: ' + l, file=sys.stderr)
 continue
-  # This is a clang runline, apply %clang substitution rule, replace %s by 
`filename`,
-  # and append args.clang_args
-  clang_args = exec_args
   clang_args[0:1] = SUBST[clang_args[0]]
-  clang_args = 

[PATCH] D97068: Run non-filechecked commands in update_cc_test_checks.py

2021-03-08 Thread Jon Roelofs via Phabricator via cfe-commits
jroelofs added a comment.

In D97068#2611696 , @ggeorgakoudis 
wrote:

> In D97068#2611269 , @thakis wrote:
>
>> Looks like this breaks tests on mac: http://45.33.8.238/macm1/5075/step_6.txt
>>
>> Please take a look, and revert for now if it takes a while to fix.
>
> Hey @thakis, it should be an easy fix. I see no check lines are generated and 
> I suspect something may be going wrong with the `cp` runline, but it's hard 
> to know without replicating it. Is there any way you can give me temporary 
> access to the mac machine to test things out?
>
> Otherwise, I will simplify the test to exclude the `cp` runline.

The issue has something to do with Darwin's USER_LABEL_PREFIX mangling 
inserting an `_` prefix. This "fixes" the test, but doesn't solve whatever 
underlying problem is there:

  diff --git 
a/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c 
b/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c
  index bf18179392dc..a0a826c3d0b4 100644
  --- a/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c
  +++ b/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c
  @@ -1,7 +1,7 @@
   // Check that the non-clang/non-filechecked runlines execute
   // RUN: cp %s %s.copy.c
  -// RUN: %clang_cc1 -fopenmp %s.copy.c -emit-llvm-bc -o %t-host.bc
  -// RUN: %clang_cc1 -fopenmp -fopenmp-host-ir-file-path %t-host.bc %s.copy.c 
-emit-llvm -o - | FileCheck %s
  +// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp %s.copy.c 
-emit-llvm-bc -o %t-host.bc
  +// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp 
-fopenmp-host-ir-file-path %t-host.bc %s.copy.c -emit-llvm -o - | FileCheck %s
   
   void use(int);
   
  diff --git 
a/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c.expected 
b/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c.expected
  index ffc8caac0f23..3ad33fc683bd 100644
  --- 
a/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c.expected
  +++ 
b/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c.expected
  @@ -1,8 +1,8 @@
   // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
   // Check that the non-clang/non-filechecked runlines execute
   // RUN: cp %s %s.copy.c
  -// RUN: %clang_cc1 -fopenmp %s.copy.c -emit-llvm-bc -o %t-host.bc
  -// RUN: %clang_cc1 -fopenmp -fopenmp-host-ir-file-path %t-host.bc %s.copy.c 
-emit-llvm -o - | FileCheck %s
  +// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp %s.copy.c 
-emit-llvm-bc -o %t-host.bc
  +// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fopenmp 
-fopenmp-host-ir-file-path %t-host.bc %s.copy.c -emit-llvm -o - | FileCheck %s
   
   void use(int);
   

You should be able to replicate the failure locally by setting an apple triple 
instead, i.e. `-triple x86_64-apple-macosx`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97068

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


[PATCH] D97872: [clang] Don't assert in EmitAggregateCopy on trivial_abi types

2021-03-08 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks updated this revision to Diff 329165.
aeubanks added a comment.

check IR


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97872

Files:
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/test/CodeGenCXX/trivial_abi.cpp


Index: clang/test/CodeGenCXX/trivial_abi.cpp
===
--- clang/test/CodeGenCXX/trivial_abi.cpp
+++ clang/test/CodeGenCXX/trivial_abi.cpp
@@ -262,3 +262,21 @@
 void testExceptionLarge() {
   calleeExceptionLarge(Large(), Large());
 }
+
+// PR42961
+
+// CHECK: define{{.*}} @"_ZN3$_08__invokeEv"()
+// CHECK: %[[RETVAL:.*]] = alloca %[[STRUCT_SMALL]], align 8
+// CHECK: %[[COERCE:.*]] = alloca %[[STRUCT_SMALL]], align 8
+// CHECK: %[[CALL:.*]] = call{{.*}} @"_ZNK3$_0clEv"
+// CHECK: %[[COERCEDIVE:.*]] = getelementptr{{.*}} %[[COERCE]]
+// CHECK: %[[COERCEVALIP:.*]] = inttoptr{{.*}} %[[CALL]]
+// CHECK: %[[RETVALP:.*]] = bitcast %[[STRUCT_SMALL]]* %[[RETVAL]]
+// CHECK: %[[COERCEP:.*]] = bitcast %[[STRUCT_SMALL]]* %[[COERCE]]
+// CHECK: call {{.*}}memcpy{{.*}} %[[RETVALP]]{{.*}} %[[COERCEP]]
+// CHECK: %[[COERCEDIVE1:.*]] = getelementptr{{.*}} %[[RETVAL]]
+// CHECK: %[[TMP:.*]] = load{{.*}} %[[COERCEDIVE1]]
+// CHECK: %[[COERCEVALPI:.*]] = ptrtoint{{.*}} %[[TMP]]
+// CHECK: ret{{.*}} %[[COERCEVALPI]]
+
+Small (*fp)() = []() -> Small { return Small(); };
Index: clang/lib/CodeGen/CGExprAgg.cpp
===
--- clang/lib/CodeGen/CGExprAgg.cpp
+++ clang/lib/CodeGen/CGExprAgg.cpp
@@ -2056,7 +2056,7 @@
   Record->hasTrivialCopyAssignment() ||
   Record->hasTrivialMoveConstructor() ||
   Record->hasTrivialMoveAssignment() ||
-  Record->isUnion()) &&
+  Record->hasAttr() || Record->isUnion()) &&
  "Trying to aggregate-copy a type without a trivial copy/move "
  "constructor or assignment operator");
   // Ignore empty classes in C++.


Index: clang/test/CodeGenCXX/trivial_abi.cpp
===
--- clang/test/CodeGenCXX/trivial_abi.cpp
+++ clang/test/CodeGenCXX/trivial_abi.cpp
@@ -262,3 +262,21 @@
 void testExceptionLarge() {
   calleeExceptionLarge(Large(), Large());
 }
+
+// PR42961
+
+// CHECK: define{{.*}} @"_ZN3$_08__invokeEv"()
+// CHECK: %[[RETVAL:.*]] = alloca %[[STRUCT_SMALL]], align 8
+// CHECK: %[[COERCE:.*]] = alloca %[[STRUCT_SMALL]], align 8
+// CHECK: %[[CALL:.*]] = call{{.*}} @"_ZNK3$_0clEv"
+// CHECK: %[[COERCEDIVE:.*]] = getelementptr{{.*}} %[[COERCE]]
+// CHECK: %[[COERCEVALIP:.*]] = inttoptr{{.*}} %[[CALL]]
+// CHECK: %[[RETVALP:.*]] = bitcast %[[STRUCT_SMALL]]* %[[RETVAL]]
+// CHECK: %[[COERCEP:.*]] = bitcast %[[STRUCT_SMALL]]* %[[COERCE]]
+// CHECK: call {{.*}}memcpy{{.*}} %[[RETVALP]]{{.*}} %[[COERCEP]]
+// CHECK: %[[COERCEDIVE1:.*]] = getelementptr{{.*}} %[[RETVAL]]
+// CHECK: %[[TMP:.*]] = load{{.*}} %[[COERCEDIVE1]]
+// CHECK: %[[COERCEVALPI:.*]] = ptrtoint{{.*}} %[[TMP]]
+// CHECK: ret{{.*}} %[[COERCEVALPI]]
+
+Small (*fp)() = []() -> Small { return Small(); };
Index: clang/lib/CodeGen/CGExprAgg.cpp
===
--- clang/lib/CodeGen/CGExprAgg.cpp
+++ clang/lib/CodeGen/CGExprAgg.cpp
@@ -2056,7 +2056,7 @@
   Record->hasTrivialCopyAssignment() ||
   Record->hasTrivialMoveConstructor() ||
   Record->hasTrivialMoveAssignment() ||
-  Record->isUnion()) &&
+  Record->hasAttr() || Record->isUnion()) &&
  "Trying to aggregate-copy a type without a trivial copy/move "
  "constructor or assignment operator");
   // Ignore empty classes in C++.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D98134: [WIP][RFC] Introduce callback argument encoding mode into callback metadata

2021-03-08 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 updated this revision to Diff 329163.
tianshilei1992 added a comment.

update doc in clang


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98134

Files:
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/attr-callback.c
  clang/test/CodeGen/callback_annotated.c
  clang/test/CodeGen/callback_openmp.c
  clang/test/CodeGenCXX/attr-callback.cpp
  clang/test/OpenMP/parallel_codegen.cpp
  clang/test/Sema/attr-callback-broken.c
  clang/test/Sema/attr-callback.c
  clang/test/SemaCXX/attr-callback.cpp
  llvm/include/llvm/IR/AbstractCallSite.h
  llvm/include/llvm/IR/MDBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/lib/IR/AbstractCallSite.cpp
  llvm/lib/IR/MDBuilder.cpp
  llvm/test/Analysis/CallGraph/callback-calls.ll
  llvm/test/Analysis/CallGraph/ignore-callback-uses.ll
  llvm/test/Transforms/Attributor/IPConstantProp/multiple_callbacks.ll
  llvm/test/Transforms/Attributor/IPConstantProp/openmp_parallel_for.ll
  llvm/test/Transforms/Attributor/IPConstantProp/pthreads.ll
  llvm/test/Transforms/Attributor/IPConstantProp/thread_local_acs.ll
  llvm/test/Transforms/Attributor/callbacks.ll
  llvm/test/Transforms/Attributor/noundef.ll
  llvm/test/Transforms/OpenMP/parallel_deletion.ll
  llvm/test/Transforms/OpenMP/parallel_deletion_cg_update.ll
  llvm/test/Transforms/OpenMP/parallel_deletion_remarks.ll
  llvm/test/Transforms/OpenMP/parallel_region_merging.ll
  llvm/unittests/IR/AbstractCallSiteTest.cpp
  llvm/unittests/IR/LegacyPassManagerTest.cpp

Index: llvm/unittests/IR/LegacyPassManagerTest.cpp
===
--- llvm/unittests/IR/LegacyPassManagerTest.cpp
+++ llvm/unittests/IR/LegacyPassManagerTest.cpp
@@ -768,7 +768,7 @@
"}\n"
"\n"
"!0 = !{!1}\n"
-   "!1 = !{i64 0, i64 1, i1 false}";
+   "!1 = !{i64 0, i64 0, i64 1, i1 false}";
 
   SMDiagnostic Err;
   std::unique_ptr M = parseAssemblyString(IR, Err, Context);
Index: llvm/unittests/IR/AbstractCallSiteTest.cpp
===
--- llvm/unittests/IR/AbstractCallSiteTest.cpp
+++ llvm/unittests/IR/AbstractCallSiteTest.cpp
@@ -36,7 +36,7 @@
   "}\n"
   "declare !callback !0 void @broker(i32, void (i8*, ...)*, ...)\n"
   "!0 = !{!1}\n"
-  "!1 = !{i64 1, i64 -1, i1 true}";
+  "!1 = !{i64 0, i64 1, i64 -1, i1 true}";
 
   std::unique_ptr M = parseIR(C, IR);
   ASSERT_TRUE(M);
Index: llvm/test/Transforms/OpenMP/parallel_region_merging.ll
===
--- llvm/test/Transforms/OpenMP/parallel_region_merging.ll
+++ llvm/test/Transforms/OpenMP/parallel_region_merging.ll
@@ -786,7 +786,7 @@
 
 !0 = !{i32 1, !"wchar_size", i32 4}
 !1 = !{!2}
-!2 = !{i64 2, i64 -1, i64 -1, i1 true}
+!2 = !{i64 0, i64 2, i64 -1, i64 -1, i1 true}
 ; CHECK-LABEL: define {{[^@]+}}@merge
 ; CHECK-SAME: (i32 [[A:%.*]]) local_unnamed_addr {
 ; CHECK-NEXT:  entry:
Index: llvm/test/Transforms/OpenMP/parallel_deletion_remarks.ll
===
--- llvm/test/Transforms/OpenMP/parallel_deletion_remarks.ll
+++ llvm/test/Transforms/OpenMP/parallel_deletion_remarks.ll
@@ -96,7 +96,7 @@
 !21 = !DILocation(line: 14, column: 1, scope: !15)
 !22 = !DILocation(line: 16, column: 1, scope: !15)
 !23 = !{!24}
-!24 = !{i64 2, i64 -1, i64 -1, i1 true}
+!24 = !{i64 0, i64 2, i64 -1, i64 -1, i1 true}
 !25 = distinct !DISubprogram(name: ".omp_outlined.", scope: !1, file: !1, line: 9, type: !26, scopeLine: 9, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !33)
 !26 = !DISubroutineType(types: !27)
 !27 = !{null, !28, !28}
Index: llvm/test/Transforms/OpenMP/parallel_deletion_cg_update.ll
===
--- llvm/test/Transforms/OpenMP/parallel_deletion_cg_update.ll
+++ llvm/test/Transforms/OpenMP/parallel_deletion_cg_update.ll
@@ -9,7 +9,7 @@
 ; CHECK:   CS calls function 'd'
 ;
 ; CHECK: Call graph node for function: '.omp_outlined..0'<<{{.*}}>>  #uses=1
-; 
+;
 ; CHECK: Call graph node for function: '.omp_outlined..1'<<{{.*}}>>  #uses=3
 ; CHECK:   CS<{{.*}}> calls function 'd'
 ;
@@ -89,4 +89,4 @@
 !0 = !{i32 1, !"wchar_size", i32 4}
 !1 = !{!"clang version 11.0.0"}
 !2 = !{!3}
-!3 = !{i64 2, i64 -1, i64 -1, i1 true}
+!3 = !{i64 0, i64 2, i64 -1, i64 -1, i1 true}
Index: llvm/test/Transforms/OpenMP/parallel_deletion.ll
===
--- llvm/test/Transforms/OpenMP/parallel_deletion.ll
+++ 

[clang] dca5737 - Move ObjCARCUtil.h back to llvm/Analysis

2021-03-08 Thread Akira Hatanaka via cfe-commits

Author: Akira Hatanaka
Date: 2021-03-08T16:35:24-08:00
New Revision: dca5737945b9a52d0c66c7ec0cbaa2e15ada69cf

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

LOG: Move ObjCARCUtil.h back to llvm/Analysis

Instead of adding the header to llvm/IR, just duplicate the marker
string in the auto upgrader.

Added: 
llvm/include/llvm/Analysis/ObjCARCUtil.h

Modified: 
clang/lib/CodeGen/CGObjC.cpp
llvm/lib/IR/AutoUpgrade.cpp
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
llvm/lib/Transforms/ObjCARC/ObjCARC.cpp
llvm/lib/Transforms/ObjCARC/ObjCARC.h
llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp
llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
llvm/lib/Transforms/ObjCARC/PtrState.cpp
llvm/lib/Transforms/Utils/InlineFunction.cpp

Removed: 
llvm/include/llvm/IR/ObjCARCUtil.h



diff  --git a/clang/lib/CodeGen/CGObjC.cpp b/clang/lib/CodeGen/CGObjC.cpp
index a5d19291e722..663666b6bf8b 100644
--- a/clang/lib/CodeGen/CGObjC.cpp
+++ b/clang/lib/CodeGen/CGObjC.cpp
@@ -23,7 +23,7 @@
 #include "clang/Basic/Diagnostic.h"
 #include "clang/CodeGen/CGFunctionInfo.h"
 #include "llvm/ADT/STLExtras.h"
-#include "llvm/IR/ObjCARCUtil.h"
+#include "llvm/Analysis/ObjCARCUtil.h"
 #include "llvm/BinaryFormat/MachO.h"
 #include "llvm/IR/DataLayout.h"
 #include "llvm/IR/InlineAsm.h"

diff  --git a/llvm/include/llvm/IR/ObjCARCUtil.h 
b/llvm/include/llvm/Analysis/ObjCARCUtil.h
similarity index 100%
rename from llvm/include/llvm/IR/ObjCARCUtil.h
rename to llvm/include/llvm/Analysis/ObjCARCUtil.h

diff  --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp
index 06268c6eab7a..e0d152b5ec21 100644
--- a/llvm/lib/IR/AutoUpgrade.cpp
+++ b/llvm/lib/IR/AutoUpgrade.cpp
@@ -14,7 +14,6 @@
 
 #include "llvm/IR/AutoUpgrade.h"
 #include "llvm/ADT/StringSwitch.h"
-#include "llvm/IR/ObjCARCUtil.h"
 #include "llvm/IR/Constants.h"
 #include "llvm/IR/DIBuilder.h"
 #include "llvm/IR/DebugInfo.h"
@@ -4039,7 +4038,7 @@ bool llvm::UpgradeDebugInfo(Module ) {
 /// returns true if module is modified.
 static bool UpgradeRetainReleaseMarker(Module ) {
   bool Changed = false;
-  const char *MarkerKey = objcarc::getRVMarkerModuleFlagStr();
+  const char *MarkerKey = "clang.arc.retainAutoreleasedReturnValueMarker";
   NamedMDNode *ModRetainReleaseMarker = M.getNamedMetadata(MarkerKey);
   if (ModRetainReleaseMarker) {
 MDNode *Op = ModRetainReleaseMarker->getOperand(0);

diff  --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp 
b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index 105dfe45bc97..67ec46f49671 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -29,7 +29,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/Triple.h"
 #include "llvm/ADT/Twine.h"
-#include "llvm/IR/ObjCARCUtil.h"
+#include "llvm/Analysis/ObjCARCUtil.h"
 #include "llvm/Analysis/VectorUtils.h"
 #include "llvm/CodeGen/CallingConvLower.h"
 #include "llvm/CodeGen/MachineBasicBlock.h"

diff  --git a/llvm/lib/Transforms/ObjCARC/ObjCARC.cpp 
b/llvm/lib/Transforms/ObjCARC/ObjCARC.cpp
index e1bee811d68e..06b12149f597 100644
--- a/llvm/lib/Transforms/ObjCARC/ObjCARC.cpp
+++ b/llvm/lib/Transforms/ObjCARC/ObjCARC.cpp
@@ -14,7 +14,7 @@
 
 #include "ObjCARC.h"
 #include "llvm-c/Initialization.h"
-#include "llvm/IR/ObjCARCUtil.h"
+#include "llvm/Analysis/ObjCARCUtil.h"
 #include "llvm/IR/IRBuilder.h"
 #include "llvm/IR/InlineAsm.h"
 #include "llvm/IR/Instructions.h"

diff  --git a/llvm/lib/Transforms/ObjCARC/ObjCARC.h 
b/llvm/lib/Transforms/ObjCARC/ObjCARC.h
index 45ce1881ff44..1f9d76969bfd 100644
--- a/llvm/lib/Transforms/ObjCARC/ObjCARC.h
+++ b/llvm/lib/Transforms/ObjCARC/ObjCARC.h
@@ -25,7 +25,7 @@
 #include "ARCRuntimeEntryPoints.h"
 #include "llvm/Analysis/EHPersonalities.h"
 #include "llvm/Analysis/ObjCARCAnalysisUtils.h"
-#include "llvm/IR/ObjCARCUtil.h"
+#include "llvm/Analysis/ObjCARCUtil.h"
 #include "llvm/Transforms/Utils/Local.h"
 
 namespace llvm {

diff  --git a/llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp 
b/llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp
index c9c3fa2993ed..62161b5b6b40 100644
--- a/llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp
+++ b/llvm/lib/Transforms/ObjCARC/ObjCARCContract.cpp
@@ -32,7 +32,7 @@
 #include "llvm/ADT/Statistic.h"
 #include "llvm/Analysis/AliasAnalysis.h"
 #include "llvm/Analysis/EHPersonalities.h"
-#include "llvm/IR/ObjCARCUtil.h"
+#include "llvm/Analysis/ObjCARCUtil.h"
 #include "llvm/IR/Dominators.h"
 #include "llvm/IR/InlineAsm.h"
 #include "llvm/IR/InstIterator.h"

diff  --git a/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp 
b/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
index e0abafed0c89..0769d466be93 100644
--- a/llvm/lib/Transforms/ObjCARC/ObjCARCOpts.cpp
+++ 

[PATCH] D97872: [clang] Don't assert in EmitAggregateCopy on trivial_abi types

2021-03-08 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: clang/test/CodeGenCXX/trivial_abi.cpp:267
+// PR42961
+Small (*fp)() = []() -> Small {};

Please check for the IR for the `__invoke` member of the lambda class. I think 
it's at least a bit interesting that we create two allocas, store to them, 
memcpy from one to the other, and then load out of the second.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97872

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


[PATCH] D97068: Run non-filechecked commands in update_cc_test_checks.py

2021-03-08 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson added a comment.

IMO this should also handle the %t substitution and create a temporary 
directory. Otherwise we end up writing files to whatever the current cwd is.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97068

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


[PATCH] D98104: Update __is_unsigned builtin to match the Standard.

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

LGTM too, once the remaining pending comments are addressed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98104

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


[PATCH] D98095: [clang] Fix ICE on invalid type parameters for concepts

2021-03-08 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 329149.
mizvekov added a comment.

Addressed rsmith's concerns.
Fixed test type name to avoid picking up suggestions from other tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98095

Files:
  clang/lib/Sema/SemaType.cpp
  clang/test/CXX/dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp

Index: clang/test/CXX/dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp
===
--- clang/test/CXX/dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp
+++ clang/test/CXX/dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp
@@ -68,3 +68,11 @@
   True decltype(auto) h = (b);
   static_assert(is_same_v);
 }
+
+namespace PR48593 {
+  template  concept a = true;
+  a auto c = 0; // expected-error{{use of undeclared identifier 'B'}}
+
+  template concept d = true;
+  d<,> auto e = 0; // expected-error{{expected expression}}
+}
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -1256,25 +1256,6 @@
   return OpenCLAccessAttr::Keyword_read_only;
 }
 
-static QualType ConvertConstrainedAutoDeclSpecToType(Sema , DeclSpec ,
- AutoTypeKeyword AutoKW) {
-  assert(DS.isConstrainedAuto());
-  TemplateIdAnnotation *TemplateId = DS.getRepAsTemplateId();
-  TemplateArgumentListInfo TemplateArgsInfo;
-  TemplateArgsInfo.setLAngleLoc(TemplateId->LAngleLoc);
-  TemplateArgsInfo.setRAngleLoc(TemplateId->RAngleLoc);
-  ASTTemplateArgsPtr TemplateArgsPtr(TemplateId->getTemplateArgs(),
- TemplateId->NumArgs);
-  S.translateTemplateArguments(TemplateArgsPtr, TemplateArgsInfo);
-  llvm::SmallVector TemplateArgs;
-  for (auto  : TemplateArgsInfo.arguments())
-TemplateArgs.push_back(ArgLoc.getArgument());
-  return S.Context.getAutoType(
-  QualType(), AutoKW, false, /*IsPack=*/false,
-  cast(TemplateId->Template.get().getAsTemplateDecl()),
-  TemplateArgs);
-}
-
 /// Convert the specified declspec to the appropriate type
 /// object.
 /// \param state Specifies the declarator containing the declaration specifier
@@ -1655,29 +1636,39 @@
 break;
 
   case DeclSpec::TST_auto:
+  case DeclSpec::TST_decltype_auto: {
+auto AutoKW = DS.getTypeSpecType() == DeclSpec::TST_decltype_auto
+  ? AutoTypeKeyword::DecltypeAuto
+  : AutoTypeKeyword::Auto;
+
+ConceptDecl *TypeConstraintConcept = nullptr;
+llvm::SmallVector TemplateArgs;
 if (DS.isConstrainedAuto()) {
-  Result = ConvertConstrainedAutoDeclSpecToType(S, DS,
-AutoTypeKeyword::Auto);
-  break;
+  if (TemplateIdAnnotation *TemplateId = DS.getRepAsTemplateId()) {
+TypeConstraintConcept =
+cast(TemplateId->Template.get().getAsTemplateDecl());
+TemplateArgumentListInfo TemplateArgsInfo;
+TemplateArgsInfo.setLAngleLoc(TemplateId->LAngleLoc);
+TemplateArgsInfo.setRAngleLoc(TemplateId->RAngleLoc);
+ASTTemplateArgsPtr TemplateArgsPtr(TemplateId->getTemplateArgs(),
+   TemplateId->NumArgs);
+S.translateTemplateArguments(TemplateArgsPtr, TemplateArgsInfo);
+for (const auto  : TemplateArgsInfo.arguments())
+  TemplateArgs.push_back(ArgLoc.getArgument());
+  } else {
+declarator.setInvalidType(true);
+  }
 }
-Result = Context.getAutoType(QualType(), AutoTypeKeyword::Auto, false);
+Result = S.Context.getAutoType(QualType(), AutoKW,
+   /*IsDependent*/ false, /*IsPack=*/false,
+   TypeConstraintConcept, TemplateArgs);
 break;
+  }
 
   case DeclSpec::TST_auto_type:
 Result = Context.getAutoType(QualType(), AutoTypeKeyword::GNUAutoType, false);
 break;
 
-  case DeclSpec::TST_decltype_auto:
-if (DS.isConstrainedAuto()) {
-  Result =
-  ConvertConstrainedAutoDeclSpecToType(S, DS,
-   AutoTypeKeyword::DecltypeAuto);
-  break;
-}
-Result = Context.getAutoType(QualType(), AutoTypeKeyword::DecltypeAuto,
- /*IsDependent*/ false);
-break;
-
   case DeclSpec::TST_unknown_anytype:
 Result = Context.UnknownAnyTy;
 break;
@@ -5956,6 +5947,8 @@
   if (!DS.isConstrainedAuto())
 return;
   TemplateIdAnnotation *TemplateId = DS.getRepAsTemplateId();
+  if (!TemplateId)
+return;
   if (DS.getTypeSpecScope().isNotEmpty())
 TL.setNestedNameSpecifierLoc(
 DS.getTypeSpecScope().getWithLocInContext(Context));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[PATCH] D98104: Update __is_unsigned builtin to match the Standard.

2021-03-08 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:1207
 * ``__is_union`` (C++, GNU, Microsoft, Embarcadero)
 * ``__is_unsigned`` (C++, Embarcadero)
+  Returns false for enumeration types. Note, before Clang 13, returned true for

Please add a trailing colon to this line to match the other lines with 
additional text after the parentheses.



Comment at: clang/lib/Sema/SemaExprCXX.cpp:4834
 // Floating points should always return true.
-return !T->isEnumeralType() && (T->isFloatingType() || 
T->isSignedIntegerType());
+return T->isFloatingType() || (T->isSignedIntegerType() && 
!T->isEnumeralType());
   case UTT_IsUnsigned:

Please reflow this line so it fits in 80 columns.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98104

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


[PATCH] D98146: OpaquePtr: Turn inalloca into a type attribute

2021-03-08 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added inline comments.



Comment at: llvm/lib/IR/Attributes.cpp:490
 if (Type *Ty = getValueAsType()) {
-  raw_string_ostream OS(Result);
+  // FIXME: This should never be null
   Result += '(';

arsenm wrote:
> dblaikie wrote:
> > Is it? Could you replace this with an assertion instead? 
> It should never be null, but it is in some cases (I think there are some 
> situations still where callsite attributes are missing byval)
Any chance of clarifying why it is sometimes null today in the comment?



Comment at: llvm/test/Bitcode/compatibility-3.6.ll:408-409
 ; CHECK: declare void @f.param.byval({ i8, i8 }* byval({ i8, i8 }))
-declare void @f.param.inalloca(i8* inalloca)
-; CHECK: declare void @f.param.inalloca(i8* inalloca)
+declare void @f.param.inalloca(i8* inalloca(i8))
+; CHECK: declare void @f.param.inalloca(i8* inalloca(i8))
 declare void @f.param.sret(i8* sret(i8))

arsenm wrote:
> dblaikie wrote:
> > It's confusing to me (though seems to be consistent with the byval change 
> > here - but maybe that's a mistake too) why the textual IR in this file is 
> > being modified - it has no effect (the textual IR is not used by the test) 
> > and the intent is to test compatibility with old IR (which is in the .bc 
> > file that is used) - so maybe it's best to leave the text here in a form 
> > that matches the old bitcode that the test is running against?
> > 
> > (similarly in the other compatibility tests updated in this patch)
> Why do these tests have textual IR in them at all then? I don't think the 
> concept of the text IR corresponding to the old bitcode really exists. I 
> would expect to see the current syntax, but I don't actually see why this has 
> a .ll suffix and isn't just a plain text file with check lines
Seems useful to me to know what we're testing against - without the textual IR, 
how would we know what the CHECKs are meant to be demonstrating? But I do think 
the textual IR should be the old/original IR, not updated IR - so we can see 
the difference.

Not sure how far from my perspective these tests have already come - maybe it's 
only a few mistakes that have been repeated, maybe it's more systemic/a more 
fundamentally different idea about how these tests should be written that other 
developers have taken when making/maintaining these tests.



Comment at: llvm/test/Bitcode/inalloca-upgrade.test:1-7
+RUN: llvm-dis %p/Inputs/inalloca-upgrade.bc -o - | FileCheck %s
+
+Make sure we upgrade old-style IntAttribute inalloca records to a
+fully typed version correctly.
+
+CHECK: call void @bar({ i32*, i8 }* inalloca({ i32*, i8 }) %ptr)
+CHECK: invoke void @bar({ i32*, i8 }* inalloca({ i32*, i8 }) %ptr)

arsenm wrote:
> dblaikie wrote:
> > Isn't this tested by all the compatibility tests already? (since they 
> > contain the old-style inalloca, and verify that when read in it's upgraded 
> > to the new-style) Though I don't mind terribly having a separate test, but 
> > each file/tool execution does add up & it's nice to keep them to a minimum 
> > when test coverage isn't otherwise compromised.
> I was following along with byval, which has its own test like this. I also 
> generally hate the all-in-one style of testing features that are really 
> unrelated. It makes it harder to know what actually broke when one fails.
A single file with many tests for different features related to, say, bitcode 
compatibility, seems good to me.

If the failures are hard to read - there are various FileCheck features which 
can be used to help improve the failure modes (using CHECK-LABEL to isolate one 
checking area from another, so they don't bleed together/get cause the failure 
point to drift a long way from the initial problem).

Having every individual test in a separate file may significantly slow down 
test execution (especially on Windows, where process overhead is higher, if I 
recall correctly) and I think it reduces the chance of finding and grouping 
related tests together - leading to a proliferation of subtly overlapping tests 
rather than a more systematic approach to how a feature is tested. (though 
that's always challenging - different people think in different groupings, etc, 
naming is challenging, etc)


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

https://reviews.llvm.org/D98146

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


[PATCH] D98095: [clang] Fix ICE on invalid type parameters for concepts

2021-03-08 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added inline comments.



Comment at: clang/lib/Sema/SemaType.cpp:5947-5948
   TL.setNameLoc(DS.getTypeSpecTypeLoc());
   if (!DS.isConstrainedAuto())
 return;
   if (DS.getTypeSpecScope().isNotEmpty())

rsmith wrote:
> Given that we recover from an invalid `TemplateId` by creating an 
> unconstrained `AutoType`, it would be more consistent to skip filling in the 
> `NestedNameSpecifierLoc` here in that case too. (That way, we would populate 
> the `NestedNameSpecifierLoc` if and only if we created a constrained 
> `AutoType`.) I think it doesn't matter right now because no-one should look 
> at this information for an unconstrained `AutoType`, but I could imagine we 
> would switch to storing smaller `TypeLoc` data in the future if the type is 
> unconstrained, and if we did, the writes to the `NestedNameSpecifierLoc` 
> below would break.
Good catch, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98095

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


[PATCH] D96033: [clang-repl] Land initial infrastructure for incremental parsing

2021-03-08 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev updated this revision to Diff 329131.
v.g.vassilev marked 2 inline comments as done.
v.g.vassilev added a comment.

Add a lit feature to check if llvm has jit support to selectively run tests.


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

https://reviews.llvm.org/D96033

Files:
  clang/include/clang/CodeGen/CodeGenAction.h
  clang/include/clang/Frontend/FrontendAction.h
  clang/include/clang/Interpreter/Interpreter.h
  clang/include/clang/Interpreter/Transaction.h
  clang/lib/CMakeLists.txt
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/Frontend/FrontendAction.cpp
  clang/lib/Interpreter/CMakeLists.txt
  clang/lib/Interpreter/IncrementalExecutor.cpp
  clang/lib/Interpreter/IncrementalExecutor.h
  clang/lib/Interpreter/IncrementalParser.cpp
  clang/lib/Interpreter/IncrementalParser.h
  clang/lib/Interpreter/Interpreter.cpp
  clang/test/CMakeLists.txt
  clang/test/Interpreter/execute.c
  clang/test/Interpreter/sanity.c
  clang/test/lit.cfg.py
  clang/tools/CMakeLists.txt
  clang/tools/clang-repl/CMakeLists.txt
  clang/tools/clang-repl/ClangRepl.cpp
  clang/unittests/CMakeLists.txt
  clang/unittests/CodeGen/CMakeLists.txt
  clang/unittests/CodeGen/IncrementalProcessingTest.cpp
  clang/unittests/Interpreter/CMakeLists.txt
  clang/unittests/Interpreter/InterpreterTest.cpp

Index: clang/unittests/Interpreter/InterpreterTest.cpp
===
--- /dev/null
+++ clang/unittests/Interpreter/InterpreterTest.cpp
@@ -0,0 +1,92 @@
+//===- unittests/Interpreter/InterpreterTest.cpp --- Interpreter tests ===//
+//
+// 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
+//
+//===--===//
+//
+// Unit tests for Clang's Interpreter library.
+//
+//===--===//
+
+#include "clang/AST/Decl.h"
+#include "clang/AST/DeclGroup.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Interpreter/Interpreter.h"
+
+#include "llvm/ADT/ArrayRef.h"
+
+#include "gtest/gtest.h"
+
+using namespace clang;
+
+namespace {
+
+static std::unique_ptr createInterpreter() {
+  std::vector ClangArgs = {"-Xclang", "-emit-llvm-only"};
+  auto CI = cantFail(clang::IncrementalCompilerBuilder::create(ClangArgs));
+  return cantFail(clang::Interpreter::create(std::move(CI)));
+}
+
+TEST(InterpreterTest, Sanity) {
+  std::unique_ptr Interp = createInterpreter();
+  Transaction (cantFail(Interp->Parse("void g(); void g() {}")));
+  EXPECT_EQ(2U, R1.Decls.size());
+
+  Transaction (cantFail(Interp->Parse("int i;")));
+  EXPECT_EQ(1U, R2.Decls.size());
+}
+
+static std::string DeclToString(DeclGroupRef DGR) {
+  return llvm::cast(DGR.getSingleDecl())->getQualifiedNameAsString();
+}
+
+TEST(InterpreterTest, IncrementalInputTopLevelDecls) {
+  std::unique_ptr Interp = createInterpreter();
+  auto R1OrErr = Interp->Parse("int var1 = 42; int f() { return var1; }");
+  // gtest doesn't expand into explicit bool conversions.
+  EXPECT_TRUE(!!R1OrErr);
+  auto R1 = R1OrErr->Decls;
+  EXPECT_EQ(2U, R1.size());
+  EXPECT_EQ("var1", DeclToString(R1[0]));
+  EXPECT_EQ("f", DeclToString(R1[1]));
+
+  auto R2OrErr = Interp->Parse("int var2 = f();");
+  EXPECT_TRUE(!!R2OrErr);
+  auto R2 = R2OrErr->Decls;
+  EXPECT_EQ(1U, R2.size());
+  EXPECT_EQ("var2", DeclToString(R2[0]));
+}
+
+
+TEST(InterpreterTest, Errors) {
+  std::unique_ptr Interp = createInterpreter();
+  auto Err = Interp->Parse("intentional_error v1 = 42; ").takeError();
+  EXPECT_EQ("Parsing failed.", llvm::toString(std::move(Err)));
+
+  EXPECT_DEATH((void)Interp->Parse("int var1 = 42;"), "");
+}
+
+// Here we test whether the user can mix declarations and statements. The
+// interpreter should be smart enough to recognize the declarations from the
+// statements and wrap the latter into a declaration, producing valid code.
+TEST(InterpreterTest, DeclsAndStatements) {
+  std::unique_ptr Interp = createInterpreter();
+  auto R1OrErr = Interp->Parse(
+  "int var1 = 42; extern \"C\" int printf(const char*, ...);");
+  // gtest doesn't expand into explicit bool conversions.
+  EXPECT_TRUE(!!R1OrErr);
+
+  auto R1 = R1OrErr->Decls;
+  EXPECT_EQ(2U, R1.size());
+
+  // FIXME: Add support for wrapping and running statements.
+  auto R2OrErr =
+Interp->Parse("var1++; printf(\"var1 value is %d\\n\", var1);");
+  EXPECT_FALSE(!!R2OrErr);
+  auto Err = R2OrErr.takeError();
+  EXPECT_EQ("Parsing failed.", llvm::toString(std::move(Err)));
+}
+
+} // end anonymous namespace
Index: clang/unittests/Interpreter/CMakeLists.txt
===
--- /dev/null
+++ clang/unittests/Interpreter/CMakeLists.txt
@@ -0,0 +1,10 @@
+set(LLVM_LINK_COMPONENTS
+  )
+

[PATCH] D98160: [clang] Use decltype((E)) for compound requirement type constraint

2021-03-08 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added inline comments.



Comment at: clang/lib/AST/ASTContext.cpp:5446
   // Build a new, canonical decltype(expr) type.
   Canon = new (*this, TypeAlignment) DependentDecltypeType(*this, e);
   DependentDecltypeTypes.InsertNode(Canon, InsertPos);

rsmith wrote:
> If we don't track the extra parens here too, we can end up giving the same 
> canonical type to dependent `decltype` types with and without implicit 
> parens, even though they can instantiate to different types. (But I think the 
> simplest way to handle this would be to include the parens in the expression; 
> see other comment.)
Good catch, but yeah I'll see about the other solution.



Comment at: clang/lib/Sema/SemaExprCXX.cpp:8643
 QualType MatchedType =
-BuildDecltypeType(E, E->getBeginLoc()).getCanonicalType();
+BuildDecltypeType(E, E->getBeginLoc(), true, true).getCanonicalType();
 llvm::SmallVector Args;

rsmith wrote:
> Instead of adding complexity to the type system to deal with this special 
> case, can you directly create a `ParenExpr` here?
Hmm I thought about that. Since I am a bit unfamiliar with the code there, I 
was not sure it was going to end up being more or less complicated than the 
proposed solution. But I'll give it a shot if that looks simpler to you.



Comment at: 
clang/test/CXX/expr/expr.prim/expr.prim.req/compound-requirement.cpp:97
 template
-concept Large = sizeof(T) >= 4; // expected-note{{because 'sizeof(short) >= 4' 
(2 >= 4) evaluated to false}}
+concept LargeRef = sizeof(typename reference::type) >= 4;
+// expected-note@-1{{because 'sizeof(typename reference::type) >= 4' 
(2 >= 4) evaluated to false}}

Quuxplusone wrote:
> I think this is too large of a change. How about just keeping the old test 
> code but changing it to
> ```
> template
> concept Large = sizeof(std::decay_t) >= 4; // expected-note{{because... 
> etc}}
> ```
Yeah I thought about that, but on the other hand changing the test to make it a 
bit more strict did not look like a problem to me.
Hmm, we cover this case in the test below anyway, might as well reduce the 
amount of changes I guess.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98160

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


[PATCH] D95043: [clangd] Use Dirty Filesystem for cross file rename.

2021-03-08 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 329126.
njames93 added a comment.

Rebase and remove an addressed FIXME.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95043

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/TUScheduler.h
  clang-tools-extra/clangd/refactor/Rename.cpp
  clang-tools-extra/clangd/refactor/Rename.h
  clang-tools-extra/clangd/unittests/RenameTests.cpp

Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -33,6 +33,19 @@
 using testing::UnorderedElementsAre;
 using testing::UnorderedElementsAreArray;
 
+llvm::IntrusiveRefCntPtr
+createOverlay(llvm::IntrusiveRefCntPtr Base,
+  llvm::IntrusiveRefCntPtr Overlay) {
+  auto OFS =
+  llvm::makeIntrusiveRefCnt(std::move(Base));
+  OFS->pushOverlay(std::move(Overlay));
+  return OFS;
+}
+
+llvm::IntrusiveRefCntPtr getVFSFromAST(ParsedAST ) {
+  return ().getFileManager().getVirtualFileSystem();
+}
+
 // Convert a Range to a Ref.
 Ref refWithRange(const clangd::Range , const std::string ) {
   Ref Result;
@@ -815,7 +828,8 @@
 auto Index = TU.index();
 for (const auto  : Code.points()) {
   auto RenameResult =
-  rename({RenamePos, NewName, AST, testPath(TU.Filename), Index.get()});
+  rename({RenamePos, NewName, AST, testPath(TU.Filename),
+  getVFSFromAST(AST), Index.get()});
   ASSERT_TRUE(bool(RenameResult)) << RenameResult.takeError();
   ASSERT_EQ(1u, RenameResult->GlobalChanges.size());
   EXPECT_EQ(
@@ -1072,7 +1086,8 @@
 }
 auto AST = TU.build();
 llvm::StringRef NewName = Case.NewName;
-auto Results = rename({T.point(), NewName, AST, testPath(TU.Filename)});
+auto Results = rename(
+{T.point(), NewName, AST, testPath(TU.Filename), getVFSFromAST(AST)});
 bool WantRename = true;
 if (T.ranges().empty())
   WantRename = false;
@@ -1101,13 +1116,20 @@
   auto AST = TU.build();
 
   auto Main = testPath("main.cc");
+  auto InMemFS = llvm::makeIntrusiveRefCnt();
+  InMemFS->addFile(testPath("main.cc"), 0,
+   llvm::MemoryBuffer::getMemBuffer(Code.code()));
+  InMemFS->addFile(testPath("other.cc"), 0,
+   llvm::MemoryBuffer::getMemBuffer(Code.code()));
 
   auto Rename = [&](const SymbolIndex *Idx) {
-auto GetDirtyBuffer = [&](PathRef Path) -> llvm::Optional {
-  return Code.code().str(); // Every file has the same content.
-};
-RenameInputs Inputs{Code.point(), "xPrime",AST,   Main,
-Idx,  RenameOptions(), GetDirtyBuffer};
+RenameInputs Inputs{Code.point(),
+"xPrime",
+AST,
+Main,
+createOverlay(getVFSFromAST(AST), InMemFS),
+Idx,
+RenameOptions()};
 auto Results = rename(Inputs);
 EXPECT_TRUE(bool(Results)) << llvm::toString(Results.takeError());
 return std::move(*Results);
@@ -1156,8 +1178,8 @@
   auto AST = TU.build();
   llvm::StringRef NewName = "abcde";
 
-  auto RenameResult =
-  rename({Code.point(), NewName, AST, testPath(TU.Filename)});
+  auto RenameResult = rename(
+  {Code.point(), NewName, AST, testPath(TU.Filename), getVFSFromAST(AST)});
   ASSERT_TRUE(bool(RenameResult)) << RenameResult.takeError() << Code.point();
   ASSERT_EQ(1u, RenameResult->GlobalChanges.size());
   EXPECT_EQ(applyEdits(std::move(RenameResult->GlobalChanges)).front().second,
@@ -1173,7 +1195,8 @@
   )cpp";
   TU.HeaderFilename = "protobuf.pb.h";
   auto AST = TU.build();
-  auto Results = rename({Code.point(), "newName", AST, testPath(TU.Filename)});
+  auto Results = rename({Code.point(), "newName", AST, testPath(TU.Filename),
+ getVFSFromAST(AST)});
   EXPECT_FALSE(Results);
   EXPECT_THAT(llvm::toString(Results.takeError()),
   testing::HasSubstr("not a supported kind"));
@@ -1237,25 +1260,19 @@
 
   Annotations MainCode("class  [[Fo^o]] {};");
   auto MainFilePath = testPath("main.cc");
-  // Dirty buffer for foo.cc.
-  auto GetDirtyBuffer = [&](PathRef Path) -> llvm::Optional {
-if (Path == FooPath)
-  return FooDirtyBuffer.code().str();
-return llvm::None;
-  };
+  llvm::IntrusiveRefCntPtr InMemFS =
+  new llvm::vfs::InMemoryFileSystem;
+  InMemFS->addFile(FooPath, 0,
+   llvm::MemoryBuffer::getMemBuffer(FooDirtyBuffer.code()));
 
   // Run rename on Foo, there is a dirty buffer for foo.cc, rename should
   // respect the dirty buffer.
   TestTU TU = TestTU::withCode(MainCode.code());
   auto AST = TU.build();
   llvm::StringRef 

[PATCH] D98160: [clang] Use decltype((E)) for compound requirement type constraint

2021-03-08 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 329124.
mizvekov added a comment.

Addressing Arthur's concerns:

- Changed `getBaseDecltypeForExpr` to `getDecltypeForParenthesizedExpr`.
- Changed `ImplicitParens` to `Parenthesized`.
- Clarified comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98160

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Type.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/Sema/SemaConcept.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.req/compound-requirement.cpp

Index: clang/test/CXX/expr/expr.prim/expr.prim.req/compound-requirement.cpp
===
--- clang/test/CXX/expr/expr.prim/expr.prim.req/compound-requirement.cpp
+++ clang/test/CXX/expr/expr.prim/expr.prim.req/compound-requirement.cpp
@@ -79,19 +79,34 @@
 template
 constexpr bool is_same_v = true;
 
+template struct reference {
+	using type = T;
+	static constexpr bool value = false;
+};
+template struct reference {
+	using type = T;
+	static constexpr bool value = true;
+};
+
 template
 concept Same = is_same_v;
 
+template concept Ref = reference::value;
+
 template
-concept Large = sizeof(T) >= 4; // expected-note{{because 'sizeof(short) >= 4' (2 >= 4) evaluated to false}}
+concept LargeRef = sizeof(typename reference::type) >= 4;
+// expected-note@-1{{because 'sizeof(typename reference::type) >= 4' (2 >= 4) evaluated to false}}
 
-template requires requires (T t) { { t } -> Large; } // expected-note{{because 'decltype(t)' (aka 'short') does not satisfy 'Large':}}
+template requires requires (T t) {
+  { t } -> Ref;
+  { t } -> LargeRef; // expected-note{{because 'decltype((t))' (aka 'short &') does not satisfy 'LargeRef':}}
+}
 struct r7 {};
 
 using r7i1 = r7;
 using r7i2 = r7; // expected-error{{constraints not satisfied for class template 'r7' [with T = short]}}
 
-template requires requires (T t) { { t } -> Same; }
+template requires requires (T t) { { t } -> Same; }
 struct r8 {};
 
 using r8i1 = r8;
@@ -99,7 +114,8 @@
 
 // Substitution failure in type constraint
 
-template requires requires (T t) { { t } -> Same; } // expected-note{{because 'Same' would be invalid: type 'int' cannot be used prior to '::' because it has no members}}
+template requires requires (T t) { { t } -> Same; }
+// expected-note@-1{{because 'Same' would be invalid: type 'int' cannot be used prior to '::' because it has no members}}
 struct r9 {};
 
 struct M { using type = M; };
@@ -172,4 +188,4 @@
   static_assert(C5);
   template struct C5_check {}; // expected-note{{because 'short' does not satisfy 'C5'}}
   using c5 = C5_check; // expected-error{{constraints not satisfied for class template 'C5_check' [with T = short]}}
-}
\ No newline at end of file
+}
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -8833,13 +8833,36 @@
   return Context.getTypeOfExprType(E);
 }
 
+/// getDecltypeForParenthesizedExpr - Given an expr, will return the type for
+/// that expression, as in [dcl.type.simple]p4 but without taking id-expressions
+/// and class member access into account.
+static QualType getDecltypeForParenthesizedExpr(Sema , Expr *E) {
+  // C++11 [dcl.type.simple]p4:
+  //   [...]
+  QualType T = E->getType();
+  switch (E->getValueKind()) {
+  // - otherwise, if e is an xvalue, decltype(e) is T&&, where T is the
+  //   type of e;
+  case VK_XValue:
+T = S.Context.getRValueReferenceType(T);
+break;
+  // - otherwise, if e is an lvalue, decltype(e) is T&, where T is the
+  //   type of e;
+  case VK_LValue:
+T = S.Context.getLValueReferenceType(T);
+break;
+  //  - otherwise, decltype(e) is the type of e.
+  case VK_RValue:
+break;
+  }
+
+  return T;
+}
+
 /// getDecltypeForExpr - Given an expr, will return the decltype for
 /// that expression, according to the rules in C++11
 /// [dcl.type.simple]p4 and C++11 [expr.lambda.prim]p18.
 static QualType getDecltypeForExpr(Sema , Expr *E) {
-  if (E->isTypeDependent())
-return S.Context.DependentTy;
-
   // C++11 [dcl.type.simple]p4:
   //   The type denoted by decltype(e) is defined as follows:
 
@@ -8897,26 +8920,11 @@
 }
   }
 
-
-  // C++11 [dcl.type.simple]p4:
-  //   [...]
-  QualType T = E->getType();
-  switch (E->getValueKind()) {
-  // - otherwise, if e is an xvalue, decltype(e) is T&&, where T is the
-  //   type of e;
-  case VK_XValue: T = S.Context.getRValueReferenceType(T); break;
-  // - otherwise, if e is an lvalue, decltype(e) is T&, where T is the
-  //   type of e;
-  case VK_LValue: T = S.Context.getLValueReferenceType(T); break;
-  //  - otherwise, decltype(e) is the type of e.
- 

[PATCH] D97941: [Reland] "Do not apply calling conventions to MSVC entry points"

2021-03-08 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm, thanks!


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

https://reviews.llvm.org/D97941

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


[PATCH] D98160: [clang] Use decltype((E)) for compound requirement type constraint

2021-03-08 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/lib/AST/ASTContext.cpp:5446
   // Build a new, canonical decltype(expr) type.
   Canon = new (*this, TypeAlignment) DependentDecltypeType(*this, e);
   DependentDecltypeTypes.InsertNode(Canon, InsertPos);

If we don't track the extra parens here too, we can end up giving the same 
canonical type to dependent `decltype` types with and without implicit parens, 
even though they can instantiate to different types. (But I think the simplest 
way to handle this would be to include the parens in the expression; see other 
comment.)



Comment at: clang/lib/Sema/SemaExprCXX.cpp:8643
 QualType MatchedType =
-BuildDecltypeType(E, E->getBeginLoc()).getCanonicalType();
+BuildDecltypeType(E, E->getBeginLoc(), true, true).getCanonicalType();
 llvm::SmallVector Args;

Instead of adding complexity to the type system to deal with this special case, 
can you directly create a `ParenExpr` here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98160

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


[PATCH] D98095: [clang] Fix ICE on invalid type parameters for concepts

2021-03-08 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/lib/Sema/SemaType.cpp:1644-1661
+TemplateIdAnnotation *TemplateId = DS.getRepAsTemplateId();
+ConceptDecl *TypeConstraintConcept = nullptr;
+llvm::SmallVector TemplateArgs;
 if (DS.isConstrainedAuto()) {
-  Result = ConvertConstrainedAutoDeclSpecToType(S, DS,
-AutoTypeKeyword::Auto);
-  break;
+  if (TemplateId) {
+TypeConstraintConcept =
+cast(TemplateId->Template.get().getAsTemplateDecl());

Minor style nits: reduce scope of `TemplateId` variable and consistently brace 
the `else` if and only if the `if` is braced.



Comment at: clang/lib/Sema/SemaType.cpp:5947-5948
   TL.setNameLoc(DS.getTypeSpecTypeLoc());
   if (!DS.isConstrainedAuto())
 return;
   if (DS.getTypeSpecScope().isNotEmpty())

Given that we recover from an invalid `TemplateId` by creating an unconstrained 
`AutoType`, it would be more consistent to skip filling in the 
`NestedNameSpecifierLoc` here in that case too. (That way, we would populate 
the `NestedNameSpecifierLoc` if and only if we created a constrained 
`AutoType`.) I think it doesn't matter right now because no-one should look at 
this information for an unconstrained `AutoType`, but I could imagine we would 
switch to storing smaller `TypeLoc` data in the future if the type is 
unconstrained, and if we did, the writes to the `NestedNameSpecifierLoc` below 
would break.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98095

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


[PATCH] D98055: [ExtVectorType] Support conditional select operator for C++.

2021-03-08 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM!




Comment at: clang/lib/Sema/SemaExprCXX.cpp:6172-6174
+  if (IsVectorConditional) {
+return CheckVectorConditionalTypes(Cond, LHS, RHS, QuestionLoc);
+  }




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98055

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


[PATCH] D97990: [clang] Always provide relevant subobject for 'no viable comparison'

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

I don't think this change is right: for

  struct A {
int 
bool operator==(const A&) const = default;
  };

we should warn about the reference member (as we do), but for

  struct A {
int 
bool operator<(const A&) const = default;
  };

... we shouldn't recurse to subobjects because they make no difference. The 
problem in that example is that there's no `operator<=>` for `A`; the fact that 
there's a reference member is irrelevant. I think it would be useful to change 
the diagnostic from

  :3:8: warning: explicitly defaulted relational comparison operator is 
implicitly deleted [-Wdefaulted-function-deleted]
bool operator<(const A &) const = default;
 ^
  :3:8: note: defaulted 'operator<' is implicitly deleted because there 
is no viable comparison function

to something more verbose, such as

  :3:8: warning: explicitly defaulted relational comparison operator is 
implicitly deleted [-Wdefaulted-function-deleted]
bool operator<(const A &) const = default;
 ^
  :3:8: note: defaulted 'operator<' is implicitly deleted because there 
is no viable three-way comparison function for 'A'


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97990

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


[PATCH] D98214: [clang-format] Fix aligning with linebreaks

2021-03-08 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks created this revision.
HazardyKnusperkeks added reviewers: MyDeveloperDay, curdeius, nikola.
HazardyKnusperkeks added a project: clang-format.
HazardyKnusperkeks requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Breaking a string literal or a function calls arguments with
AlignConsecutiveDeclarations or AlignConsecutiveAssignments did misalign
the contiued line. E.g.:

  void foo() {
int myVar = 5;
double x  = 3.14;
auto str  = "Hello"
  "World";
  }

or

  void foo() {
intmyVar = 5;
double x = 3.14;
auto   str = "Hello"
   "World";
  }


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98214

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

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -14297,6 +14297,94 @@
Alignment);
 }
 
+TEST_F(FormatTest, AlignWithLineBreaks) {
+  auto Style = getLLVMStyleWithColumns(120);
+
+  EXPECT_EQ(Style.AlignConsecutiveAssignments, FormatStyle::ACS_None);
+  EXPECT_EQ(Style.AlignConsecutiveDeclarations, FormatStyle::ACS_None);
+  verifyFormat("void foo() {\n"
+   "  int myVar = 5;\n"
+   "  double x = 3.14;\n"
+   "  auto str = \"Hello \"\n"
+   " \"World\";\n"
+   "}",
+   Style);
+
+  // clang-format off
+  verifyFormat("void foo() {\n"
+   "  const int capacityBefore = Entries.capacity();\n"
+   "  const auto newEntry = Entries.emplaceHint(std::piecewise_construct, std::forward_as_tuple(uniqueId),\n"
+   "std::forward_as_tuple(id, uniqueId, name, threadCreation));\n"
+   "  const X newEntry2 = Entries.emplaceHint(std::piecewise_construct, std::forward_as_tuple(uniqueId),\n"
+   "  std::forward_as_tuple(id, uniqueId, name, threadCreation));\n"
+   "}",
+   Style);
+  // clang-format on
+
+  Style.AlignConsecutiveAssignments = FormatStyle::ACS_Consecutive;
+  verifyFormat("void foo() {\n"
+   "  int myVar = 5;\n"
+   "  double x  = 3.14;\n"
+   "  auto str  = \"Hello \"\n"
+   "  \"World\";\n"
+   "}",
+   Style);
+
+  // clang-format off
+  verifyFormat("void foo() {\n"
+   "  const int capacityBefore = Entries.capacity();\n"
+   "  const auto newEntry  = Entries.emplaceHint(std::piecewise_construct, std::forward_as_tuple(uniqueId),\n"
+   " std::forward_as_tuple(id, uniqueId, name, threadCreation));\n"
+   "  const X newEntry2= Entries.emplaceHint(std::piecewise_construct, std::forward_as_tuple(uniqueId),\n"
+   " std::forward_as_tuple(id, uniqueId, name, threadCreation));\n"
+   "}",
+   Style);
+  // clang-format on
+
+  Style.AlignConsecutiveAssignments = FormatStyle::ACS_None;
+  Style.AlignConsecutiveDeclarations = FormatStyle::ACS_Consecutive;
+  verifyFormat("void foo() {\n"
+   "  intmyVar = 5;\n"
+   "  double x = 3.14;\n"
+   "  auto   str = \"Hello \"\n"
+   "   \"World\";\n"
+   "}",
+   Style);
+
+  // clang-format off
+  verifyFormat("void foo() {\n"
+   "  const int  capacityBefore = Entries.capacity();\n"
+   "  const auto newEntry = Entries.emplaceHint(std::piecewise_construct, std::forward_as_tuple(uniqueId),\n"
+   "std::forward_as_tuple(id, uniqueId, name, threadCreation));\n"
+   "  const XnewEntry2 = Entries.emplaceHint(std::piecewise_construct, std::forward_as_tuple(uniqueId),\n"
+   " std::forward_as_tuple(id, uniqueId, name, threadCreation));\n"
+   "}",
+   Style);
+  // clang-format on
+
+  Style.AlignConsecutiveAssignments = FormatStyle::ACS_Consecutive;
+  Style.AlignConsecutiveDeclarations = FormatStyle::ACS_Consecutive;
+
+  verifyFormat("void foo() {\n"
+   "  intmyVar = 5;\n"
+   "  double x = 3.14;\n"
+   "  auto   str   = \"Hello \"\n"
+   " \"World\";\n"
+   "}",
+   Style);
+
+  // clang-format off
+  verifyFormat("void foo() {\n"
+   "  const int  capacityBefore = Entries.capacity();\n"
+   "  const auto newEntry   = Entries.emplaceHint(std::piecewise_construct, 

[PATCH] D88394: [Driver][M68k] (Patch 8/8) Add driver support for M68k

2021-03-08 Thread Min-Yih Hsu 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 rG5509748f2ce5: [cfe][driver][M68k](8/8) Clang driver support 
(authored by myhsu).

Changed prior to commit:
  https://reviews.llvm.org/D88394?vs=327029=329111#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88394

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/CMakeLists.txt
  clang/lib/Driver/ToolChains/Arch/M68k.cpp
  clang/lib/Driver/ToolChains/Arch/M68k.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/test/Driver/m68k-features.cpp
  clang/test/Driver/m68k-sub-archs.cpp

Index: clang/test/Driver/m68k-sub-archs.cpp
===
--- /dev/null
+++ clang/test/Driver/m68k-sub-archs.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang -### -target m68k-unknown-linux -mcpu=68000 %s 2>&1 | FileCheck --check-prefix=CHECK-M00 %s
+// RUN: %clang -### -target m68k-unknown-linux -mcpu=m68000 %s 2>&1 | FileCheck --check-prefix=CHECK-M00 %s
+// RUN: %clang -### -target m68k-unknown-linux -mcpu=M68000 %s 2>&1 | FileCheck --check-prefix=CHECK-M00 %s
+// RUN: %clang -### -target m68k-unknown-linux -m68000 %s 2>&1 | FileCheck --check-prefix=CHECK-M00 %s
+// CHECK-M00: "-target-cpu" "M68000"
+
+// RUN: %clang -### -target m68k-unknown-linux -mcpu=68010 %s 2>&1 | FileCheck --check-prefix=CHECK-M10 %s
+// RUN: %clang -### -target m68k-unknown-linux -mcpu=m68010 %s 2>&1 | FileCheck --check-prefix=CHECK-M10 %s
+// RUN: %clang -### -target m68k-unknown-linux -mcpu=M68010 %s 2>&1 | FileCheck --check-prefix=CHECK-M10 %s
+// RUN: %clang -### -target m68k-unknown-linux -m68010 %s 2>&1 | FileCheck --check-prefix=CHECK-M10 %s
+// CHECK-M10: "-target-cpu" "M68010"
+
+// RUN: %clang -### -target m68k-unknown-linux -mcpu=68020 %s 2>&1 | FileCheck --check-prefix=CHECK-M20 %s
+// RUN: %clang -### -target m68k-unknown-linux -mcpu=m68020 %s 2>&1 | FileCheck --check-prefix=CHECK-M20 %s
+// RUN: %clang -### -target m68k-unknown-linux -mcpu=M68020 %s 2>&1 | FileCheck --check-prefix=CHECK-M20 %s
+// RUN: %clang -### -target m68k-unknown-linux -m68020 %s 2>&1 | FileCheck --check-prefix=CHECK-M20 %s
+// CHECK-M20: "-target-cpu" "M68020"
+
+// RUN: %clang -### -target m68k-unknown-linux -mcpu=68030 %s 2>&1 | FileCheck --check-prefix=CHECK-M30 %s
+// RUN: %clang -### -target m68k-unknown-linux -mcpu=m68030 %s 2>&1 | FileCheck --check-prefix=CHECK-M30 %s
+// RUN: %clang -### -target m68k-unknown-linux -mcpu=M68030 %s 2>&1 | FileCheck --check-prefix=CHECK-M30 %s
+// RUN: %clang -### -target m68k-unknown-linux -m68030 %s 2>&1 | FileCheck --check-prefix=CHECK-M30 %s
+// CHECK-M30: "-target-cpu" "M68030"
+
+// RUN: %clang -### -target m68k-unknown-linux -mcpu=68040 %s 2>&1 | FileCheck --check-prefix=CHECK-M40 %s
+// RUN: %clang -### -target m68k-unknown-linux -mcpu=m68040 %s 2>&1 | FileCheck --check-prefix=CHECK-M40 %s
+// RUN: %clang -### -target m68k-unknown-linux -mcpu=M68040 %s 2>&1 | FileCheck --check-prefix=CHECK-M40 %s
+// RUN: %clang -### -target m68k-unknown-linux -m68040 %s 2>&1 | FileCheck --check-prefix=CHECK-M40 %s
+// CHECK-M40: "-target-cpu" "M68040"
+
+// RUN: %clang -### -target m68k-unknown-linux -mcpu=68060 %s 2>&1 | FileCheck --check-prefix=CHECK-M60 %s
+// RUN: %clang -### -target m68k-unknown-linux -mcpu=m68060 %s 2>&1 | FileCheck --check-prefix=CHECK-M60 %s
+// RUN: %clang -### -target m68k-unknown-linux -mcpu=M68060 %s 2>&1 | FileCheck --check-prefix=CHECK-M60 %s
+// RUN: %clang -### -target m68k-unknown-linux -m68060 %s 2>&1 | FileCheck --check-prefix=CHECK-M60 %s
+// CHECK-M60: "-target-cpu" "M68060"
Index: clang/test/Driver/m68k-features.cpp
===
--- /dev/null
+++ clang/test/Driver/m68k-features.cpp
@@ -0,0 +1,45 @@
+// Check macro definitions
+// RUN: %clang -target m68k-unknown-linux -m68000 -dM -E %s | FileCheck --check-prefix=CHECK-MX %s
+// CHECK-MX: #define __mc68000 1
+// CHECK-MX: #define __mc68000__ 1
+// CHECK-MX: #define mc68000 1
+
+// RUN: %clang -target m68k-unknown-linux -m68010 -dM -E %s | FileCheck --check-prefix=CHECK-MX10 %s
+// CHECK-MX10: #define __mc68000 1
+// CHECK-MX10: #define __mc68000__ 1
+// CHECK-MX10: #define __mc68010 1
+// CHECK-MX10: #define __mc68010__ 1
+// CHECK-MX10: #define mc68000 1
+// CHECK-MX10: #define mc68010 1
+
+// RUN: %clang -target m68k-unknown-linux -m68020 -dM -E %s | FileCheck --check-prefix=CHECK-MX20 %s
+// CHECK-MX20: #define __mc68000 1
+// CHECK-MX20: #define __mc68000__ 1
+// CHECK-MX20: #define __mc68020 1
+// CHECK-MX20: #define __mc68020__ 1
+// CHECK-MX20: #define mc68000 1
+// CHECK-MX20: #define mc68020 1
+
+// RUN: %clang -target m68k-unknown-linux -m68030 -dM -E %s | FileCheck 

[PATCH] D88393: [cfe][M68k] (Patch 7/8) Basic Clang support

2021-03-08 Thread Min-Yih Hsu 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 rG5eb7a5814a5c: [cfe][M68k](7/8) Clang basic support (authored 
by myhsu).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88393

Files:
  clang/include/clang/Basic/Attr.td
  clang/lib/Basic/CMakeLists.txt
  clang/lib/Basic/Targets.cpp
  clang/lib/Basic/Targets/M68k.cpp
  clang/lib/Basic/Targets/M68k.h
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/Sema/SemaDeclAttr.cpp

Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -6641,6 +6641,39 @@
   D->addAttr(::new (S.Context) MipsInterruptAttr(S.Context, AL, Kind));
 }
 
+static void handleM68kInterruptAttr(Sema , Decl *D, const ParsedAttr ) {
+  if (!checkAttributeNumArgs(S, AL, 1))
+return;
+
+  if (!AL.isArgExpr(0)) {
+S.Diag(AL.getLoc(), diag::err_attribute_argument_type)
+<< AL << AANT_ArgumentIntegerConstant;
+return;
+  }
+
+  // FIXME: Check for decl - it should be void ()(void).
+
+  Expr *NumParamsExpr = static_cast(AL.getArgAsExpr(0));
+  auto MaybeNumParams = NumParamsExpr->getIntegerConstantExpr(S.Context);
+  if (!MaybeNumParams) {
+S.Diag(AL.getLoc(), diag::err_attribute_argument_type)
+<< AL << AANT_ArgumentIntegerConstant
+<< NumParamsExpr->getSourceRange();
+return;
+  }
+
+  unsigned Num = MaybeNumParams->getLimitedValue(255);
+  if ((Num & 1) || Num > 30) {
+S.Diag(AL.getLoc(), diag::err_attribute_argument_out_of_bounds)
+<< AL << (int)MaybeNumParams->getSExtValue()
+<< NumParamsExpr->getSourceRange();
+return;
+  }
+
+  D->addAttr(::new (S.Context) M68kInterruptAttr(S.Context, AL, Num));
+  D->addAttr(UsedAttr::CreateImplicit(S.Context));
+}
+
 static void handleAnyX86InterruptAttr(Sema , Decl *D, const ParsedAttr ) {
   // Semantic checks for a function with the 'interrupt' attribute.
   // a) Must be a function.
@@ -6913,6 +6946,9 @@
   case llvm::Triple::mips:
 handleMipsInterruptAttr(S, D, AL);
 break;
+  case llvm::Triple::m68k:
+handleM68kInterruptAttr(S, D, AL);
+break;
   case llvm::Triple::x86:
   case llvm::Triple::x86_64:
 handleAnyX86InterruptAttr(S, D, AL);
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -8049,6 +8049,43 @@
   return false;
 }
 
+//===--===//
+// M68k ABI Implementation
+//===--===//
+
+namespace {
+
+class M68kTargetCodeGenInfo : public TargetCodeGenInfo {
+public:
+  M68kTargetCodeGenInfo(CodeGenTypes )
+  : TargetCodeGenInfo(std::make_unique(CGT)) {}
+  void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
+   CodeGen::CodeGenModule ) const override;
+};
+
+} // namespace
+
+void M68kTargetCodeGenInfo::setTargetAttributes(
+const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule ) const {
+  if (const auto *FD = dyn_cast_or_null(D)) {
+if (const auto *attr = FD->getAttr()) {
+  // Handle 'interrupt' attribute:
+  llvm::Function *F = cast(GV);
+
+  // Step 1: Set ISR calling convention.
+  F->setCallingConv(llvm::CallingConv::M68k_INTR);
+
+  // Step 2: Add attributes goodness.
+  F->addFnAttr(llvm::Attribute::NoInline);
+
+  // Step 3: Emit ISR vector alias.
+  unsigned Num = attr->getNumber() / 2;
+  llvm::GlobalAlias::create(llvm::Function::ExternalLinkage,
+"__isr_" + Twine(Num), F);
+}
+  }
+}
+
 //===--===//
 // AVR ABI Implementation.
 //===--===//
@@ -10876,6 +10913,8 @@
 
   case llvm::Triple::le32:
 return SetCGInfo(new PNaClTargetCodeGenInfo(Types));
+  case llvm::Triple::m68k:
+return SetCGInfo(new M68kTargetCodeGenInfo(Types));
   case llvm::Triple::mips:
   case llvm::Triple::mipsel:
 if (Triple.getOS() == llvm::Triple::NaCl)
Index: clang/lib/Basic/Targets/M68k.h
===
--- /dev/null
+++ clang/lib/Basic/Targets/M68k.h
@@ -0,0 +1,57 @@
+//===--- M68k.h - Declare M68k target feature support ---*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file declares M68k TargetInfo objects.
+//

[clang] 5eb7a58 - [cfe][M68k](7/8) Clang basic support

2021-03-08 Thread Min-Yih Hsu via cfe-commits

Author: Min-Yih Hsu
Date: 2021-03-08T12:30:57-08:00
New Revision: 5eb7a5814a5c629378ba2a4a45fc65cd7f183c9c

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

LOG: [cfe][M68k](7/8) Clang basic support

This is the first patch supporting M68k in Clang
 - Register M68k as a target
 - Target specific CodeGen support
 - Target specific attribute support

Authors: myhsu, m4yers, glaubitz

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

Added: 
clang/lib/Basic/Targets/M68k.cpp
clang/lib/Basic/Targets/M68k.h

Modified: 
clang/include/clang/Basic/Attr.td
clang/lib/Basic/CMakeLists.txt
clang/lib/Basic/Targets.cpp
clang/lib/CodeGen/TargetInfo.cpp
clang/lib/Sema/SemaDeclAttr.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 8afa676c133f..9625e7f8f322 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -368,6 +368,7 @@ def TargetBPF : TargetArch<["bpfel", "bpfeb"]>;
 def TargetMips32 : TargetArch<["mips", "mipsel"]>;
 def TargetAnyMips : TargetArch<["mips", "mipsel", "mips64", "mips64el"]>;
 def TargetMSP430 : TargetArch<["msp430"]>;
+def TargetM68k : TargetArch<["m68k"]>;
 def TargetRISCV : TargetArch<["riscv32", "riscv64"]>;
 def TargetX86 : TargetArch<["x86"]>;
 def TargetAnyX86 : TargetArch<["x86", "x86_64"]>;
@@ -772,8 +773,9 @@ def Annotate : InheritableParamAttr {
 }
 
 def ARMInterrupt : InheritableAttr, TargetSpecificAttr {
-  // NOTE: If you add any additional spellings, MSP430Interrupt's,
-  // MipsInterrupt's and AnyX86Interrupt's spellings must match.
+  // NOTE: If you add any additional spellings, M68kInterrupt's,
+  // MSP430Interrupt's, MipsInterrupt's and AnyX86Interrupt's spellings
+  // must match.
   let Spellings = [GCC<"interrupt">];
   let Args = [EnumArgument<"Interrupt", "InterruptType",
["IRQ", "FIQ", "SWI", "ABORT", "UNDEF", ""],
@@ -1524,8 +1526,8 @@ def MSABI : DeclOrTypeAttr {
 }
 
 def MSP430Interrupt : InheritableAttr, TargetSpecificAttr {
-  // NOTE: If you add any additional spellings, ARMInterrupt's, MipsInterrupt's
-  // and AnyX86Interrupt's spellings must match.
+  // NOTE: If you add any additional spellings, ARMInterrupt's, 
M68kInterrupt's,
+  // MipsInterrupt's and AnyX86Interrupt's spellings must match.
   let Spellings = [GCC<"interrupt">];
   let Args = [UnsignedArgument<"Number">];
   let ParseKind = "Interrupt";
@@ -1541,7 +1543,8 @@ def Mips16 : InheritableAttr, 
TargetSpecificAttr {
 
 def MipsInterrupt : InheritableAttr, TargetSpecificAttr {
   // NOTE: If you add any additional spellings, ARMInterrupt's,
-  // MSP430Interrupt's and AnyX86Interrupt's spellings must match.
+  // M68kInterrupt's, MSP430Interrupt's and AnyX86Interrupt's spellings
+  // must match.
   let Spellings = [GCC<"interrupt">];
   let Subjects = SubjectList<[Function]>;
   let Args = [EnumArgument<"Interrupt", "InterruptType",
@@ -1573,6 +1576,16 @@ def MipsShortCall : InheritableAttr, 
TargetSpecificAttr {
   let Documentation = [MipsShortCallStyleDocs];
 }
 
+def M68kInterrupt : InheritableAttr, TargetSpecificAttr {
+  // NOTE: If you add any additional spellings, ARMInterrupt's, MipsInterrupt's
+  // MSP430Interrupt's and AnyX86Interrupt's spellings must match.
+  let Spellings = [GNU<"interrupt">];
+  let Args = [UnsignedArgument<"Number">];
+  let ParseKind = "Interrupt";
+  let HasCustomParsing = 1;
+  let Documentation = [Undocumented];
+}
+
 def Mode : Attr {
   let Spellings = [GCC<"mode">];
   let Subjects = SubjectList<[Var, Enum, TypedefName, Field], ErrorDiag>;
@@ -2777,7 +2790,7 @@ def LTOVisibilityPublic : InheritableAttr {
 
 def AnyX86Interrupt : InheritableAttr, TargetSpecificAttr {
   // NOTE: If you add any additional spellings, ARMInterrupt's,
-  // MSP430Interrupt's and MipsInterrupt's spellings must match.
+  // M68kInterrupt's, MSP430Interrupt's and MipsInterrupt's spellings must 
match.
   let Spellings = [GCC<"interrupt">];
   let Subjects = SubjectList<[HasFunctionProto]>;
   let ParseKind = "Interrupt";

diff  --git a/clang/lib/Basic/CMakeLists.txt b/clang/lib/Basic/CMakeLists.txt
index 709505d502ed..a3a8f8d68962 100644
--- a/clang/lib/Basic/CMakeLists.txt
+++ b/clang/lib/Basic/CMakeLists.txt
@@ -78,6 +78,7 @@ add_clang_library(clangBasic
   Targets/Hexagon.cpp
   Targets/Lanai.cpp
   Targets/Le64.cpp
+  Targets/M68k.cpp
   Targets/MSP430.cpp
   Targets/Mips.cpp
   Targets/NVPTX.cpp

diff  --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp
index 159af12a90fa..793a471194fe 100644
--- a/clang/lib/Basic/Targets.cpp
+++ b/clang/lib/Basic/Targets.cpp
@@ -22,6 +22,7 @@
 #include "Targets/Hexagon.h"
 #include "Targets/Lanai.h"
 #include "Targets/Le64.h"
+#include "Targets/M68k.h"
 

[clang] 5509748 - [cfe][driver][M68k](8/8) Clang driver support

2021-03-08 Thread Min-Yih Hsu via cfe-commits

Author: Min-Yih Hsu
Date: 2021-03-08T12:30:57-08:00
New Revision: 5509748f2ce5e06bda7da754297d09a0e68a1f30

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

LOG: [cfe][driver][M68k](8/8) Clang driver support

Add M68k-specific toolchain and driver configurations / options.

Authors: myhsu, m4yers, glaubitz

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

Added: 
clang/lib/Driver/ToolChains/Arch/M68k.cpp
clang/lib/Driver/ToolChains/Arch/M68k.h
clang/test/Driver/m68k-features.cpp
clang/test/Driver/m68k-sub-archs.cpp

Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/CMakeLists.txt
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/lib/Driver/ToolChains/Gnu.cpp
clang/lib/Driver/ToolChains/Linux.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 9172215bc512..8e71aff2e96d 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -160,6 +160,8 @@ def m_hexagon_Features_Group : OptionGroup<"">,
 // These are explicitly handled.
 def m_hexagon_Features_HVX_Group : OptionGroup<"">,
Group, DocName<"Hexagon">;
+def m_m68k_Features_Group: OptionGroup<"">,
+   Group, DocName<"M68k">;
 def m_mips_Features_Group : OptionGroup<"">,
 Group, DocName<"MIPS">;
 def m_ppc_Features_Group : OptionGroup<"">,
@@ -3895,6 +3897,13 @@ def mnvs : Flag<["-"], "mnvs">, 
Group,
 def mno_nvs : Flag<["-"], "mno-nvs">, Group,
   Flags<[CC1Option]>, HelpText<"Disable generation of new-value stores">;
 
+// M68k features flags
+def m68000 : Flag<["-"], "m68000">, Group;
+def m68010 : Flag<["-"], "m68010">, Group;
+def m68020 : Flag<["-"], "m68020">, Group;
+def m68030 : Flag<["-"], "m68030">, Group;
+def m68040 : Flag<["-"], "m68040">, Group;
+def m68060 : Flag<["-"], "m68060">, Group;
 
 // X86 feature flags
 def mx87 : Flag<["-"], "mx87">, Group;

diff  --git a/clang/lib/Driver/CMakeLists.txt b/clang/lib/Driver/CMakeLists.txt
index 7542daf3b8f7..f59141f9e19f 100644
--- a/clang/lib/Driver/CMakeLists.txt
+++ b/clang/lib/Driver/CMakeLists.txt
@@ -26,6 +26,7 @@ add_clang_library(clangDriver
   ToolChain.cpp
   ToolChains/Arch/AArch64.cpp
   ToolChains/Arch/ARM.cpp
+  ToolChains/Arch/M68k.cpp
   ToolChains/Arch/Mips.cpp
   ToolChains/Arch/PPC.cpp
   ToolChains/Arch/RISCV.cpp

diff  --git a/clang/lib/Driver/ToolChains/Arch/M68k.cpp 
b/clang/lib/Driver/ToolChains/Arch/M68k.cpp
new file mode 100644
index ..66c9f5c87bfb
--- /dev/null
+++ b/clang/lib/Driver/ToolChains/Arch/M68k.cpp
@@ -0,0 +1,93 @@
+//===--- M68k.cpp - M68k Helpers for Tools ---*- 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
+//
+//===--===//
+
+#include "M68k.h"
+#include "ToolChains/CommonArgs.h"
+#include "clang/Driver/Driver.h"
+#include "clang/Driver/DriverDiagnostic.h"
+#include "clang/Driver/Options.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringSwitch.h"
+#include "llvm/Option/ArgList.h"
+#include "llvm/Support/Host.h"
+#include "llvm/Support/Regex.h"
+#include 
+
+using namespace clang::driver;
+using namespace clang::driver::tools;
+using namespace clang;
+using namespace llvm::opt;
+
+/// getM68kTargetCPU - Get the (LLVM) name of the 68000 cpu we are targeting.
+std::string m68k::getM68kTargetCPU(const ArgList ) {
+  if (Arg *A = Args.getLastArg(clang::driver::options::OPT_mcpu_EQ)) {
+// The canonical CPU name is captalize. However, we allow
+// starting with lower case or numbers only
+StringRef CPUName = A->getValue();
+
+if (CPUName == "native") {
+  std::string CPU = std::string(llvm::sys::getHostCPUName());
+  if (!CPU.empty() && CPU != "generic")
+return CPU;
+}
+
+if (CPUName == "common")
+  return "generic";
+
+return llvm::StringSwitch(CPUName)
+.Cases("m68000", "68000", "M68000")
+.Cases("m68010", "68010", "M68010")
+.Cases("m68020", "68020", "M68020")
+.Cases("m68030", "68030", "M68030")
+.Cases("m68040", "68040", "M68040")
+.Cases("m68060", "68060", "M68060")
+.Default(CPUName.str());
+  }
+  // FIXME: Throw error when multiple sub-architecture flag exist
+  if (Args.hasArg(clang::driver::options::OPT_m68000))
+return "M68000";
+  if (Args.hasArg(clang::driver::options::OPT_m68010))
+return "M68010";
+  if (Args.hasArg(clang::driver::options::OPT_m68020))

[PATCH] D97941: [Reland] "Do not apply calling conventions to MSVC entry points"

2021-03-08 Thread Elizabeth Andrews via Phabricator via cfe-commits
eandrews added inline comments.



Comment at: clang/lib/Sema/SemaDecl.cpp:11206-11207
+} else if (FT->getCallConv() != CC_X86StdCall) {
+  // Default calling convention for WinMain, wWinMain and DllMain is
+  // __stdcall
+  FT = Context.adjustFunctionType(

rnk wrote:
> This should only be done on 32-bit x86 platforms. I think i686-window-msvc is 
> the more special case platform here, so I would recommend making the helper 
> something like `isDefaultStdCall`, which is true for i686-windows-msvc, false 
> for mingw and non-x86 triples, and false for main/wmain.
Thanks for the review @rnk! I think I made the change you requested. 


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

https://reviews.llvm.org/D97941

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


[PATCH] D98142: [clang] Don't set CLANG_DEFAULT_UNWINDLIB to none if rtlib is set to compiler-rt

2021-03-08 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe81d813717b2: [clang] Dont set CLANG_DEFAULT_UNWINDLIB 
to none if rtlib is set to compiler-rt (authored by mstorsjo).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98142

Files:
  clang/CMakeLists.txt


Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -262,8 +262,6 @@
 if (CLANG_DEFAULT_UNWINDLIB STREQUAL "")
   if (CLANG_DEFAULT_RTLIB STREQUAL "libgcc")
 set (CLANG_DEFAULT_UNWINDLIB "libgcc" CACHE STRING "" FORCE)
-  elseif (CLANG_DEFAULT_RTLIB STREQUAL "compiler-rt")
-set (CLANG_DEFAULT_UNWINDLIB "none" CACHE STRING "" FORCE)
   endif()
 endif()
 
@@ -273,7 +271,7 @@
 CLANG_DEFAULT_UNWINDLIB STREQUAL "libunwind"))
   message(WARNING "Resetting default unwindlib to use platform default")
   set(CLANG_DEFAULT_UNWINDLIB "" CACHE STRING
-"Default unwind library to use (\"none\" \"libgcc\" or \"libunwind\", 
empty for none)" FORCE)
+"Default unwind library to use (\"none\" \"libgcc\" or \"libunwind\", 
empty to match runtime library.)" FORCE)
 endif()
 
 set(CLANG_DEFAULT_OBJCOPY "objcopy" CACHE STRING


Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -262,8 +262,6 @@
 if (CLANG_DEFAULT_UNWINDLIB STREQUAL "")
   if (CLANG_DEFAULT_RTLIB STREQUAL "libgcc")
 set (CLANG_DEFAULT_UNWINDLIB "libgcc" CACHE STRING "" FORCE)
-  elseif (CLANG_DEFAULT_RTLIB STREQUAL "compiler-rt")
-set (CLANG_DEFAULT_UNWINDLIB "none" CACHE STRING "" FORCE)
   endif()
 endif()
 
@@ -273,7 +271,7 @@
 CLANG_DEFAULT_UNWINDLIB STREQUAL "libunwind"))
   message(WARNING "Resetting default unwindlib to use platform default")
   set(CLANG_DEFAULT_UNWINDLIB "" CACHE STRING
-"Default unwind library to use (\"none\" \"libgcc\" or \"libunwind\", empty for none)" FORCE)
+"Default unwind library to use (\"none\" \"libgcc\" or \"libunwind\", empty to match runtime library.)" FORCE)
 endif()
 
 set(CLANG_DEFAULT_OBJCOPY "objcopy" CACHE STRING
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] e81d813 - [clang] Don't set CLANG_DEFAULT_UNWINDLIB to none if rtlib is set to compiler-rt

2021-03-08 Thread Martin Storsjö via cfe-commits

Author: Martin Storsjö
Date: 2021-03-08T22:29:54+02:00
New Revision: e81d813717b2ef227c5b995057153d2cca027afb

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

LOG: [clang] Don't set CLANG_DEFAULT_UNWINDLIB to none if rtlib is set to 
compiler-rt

002dd47bdd674fad8186650f07458b1e062545df was meant to not be any
functional change, but it turned out it was.

With CLANG_DEFAULT_RTLIB set to compiler-rt, CLANG_DEFAULT_UNWINDLIB used
to bet set to an empty string, but now was set to "none".

If one only overrode rtlib to libgcc, one previously would get libgcc
as unwind lib, but now didn't. This caused test failures, fixed in
41476d89b82647c1ff690fdc805c859262d571e5.

Secondly, for the android target, the previous default was to link
libunwind, which this now changed.

Reinstate the exact same behaviour as before (removing the previously
typoed cmake check) and fix the option comment in one place to match
the other one above.

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

Added: 


Modified: 
clang/CMakeLists.txt

Removed: 




diff  --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index f0fa61a0c3f7..4695dc8a46ff 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -262,8 +262,6 @@ set(CLANG_DEFAULT_UNWINDLIB "" CACHE STRING
 if (CLANG_DEFAULT_UNWINDLIB STREQUAL "")
   if (CLANG_DEFAULT_RTLIB STREQUAL "libgcc")
 set (CLANG_DEFAULT_UNWINDLIB "libgcc" CACHE STRING "" FORCE)
-  elseif (CLANG_DEFAULT_RTLIB STREQUAL "compiler-rt")
-set (CLANG_DEFAULT_UNWINDLIB "none" CACHE STRING "" FORCE)
   endif()
 endif()
 
@@ -273,7 +271,7 @@ if (NOT(CLANG_DEFAULT_UNWINDLIB STREQUAL "" OR
 CLANG_DEFAULT_UNWINDLIB STREQUAL "libunwind"))
   message(WARNING "Resetting default unwindlib to use platform default")
   set(CLANG_DEFAULT_UNWINDLIB "" CACHE STRING
-"Default unwind library to use (\"none\" \"libgcc\" or \"libunwind\", 
empty for none)" FORCE)
+"Default unwind library to use (\"none\" \"libgcc\" or \"libunwind\", 
empty to match runtime library.)" FORCE)
 endif()
 
 set(CLANG_DEFAULT_OBJCOPY "objcopy" CACHE STRING



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


[PATCH] D97941: [Reland] "Do not apply calling conventions to MSVC entry points"

2021-03-08 Thread Elizabeth Andrews via Phabricator via cfe-commits
eandrews updated this revision to Diff 329099.
eandrews edited the summary of this revision.
eandrews added a comment.

Implemented review comment to restrict  __stdcall default calling convention 
(for WinMain, wWinMain, and DllMain) to 32 bit Windows.


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

https://reviews.llvm.org/D97941

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/CodeGenCXX/default_calling_conv.cpp

Index: clang/test/CodeGenCXX/default_calling_conv.cpp
===
--- clang/test/CodeGenCXX/default_calling_conv.cpp
+++ clang/test/CodeGenCXX/default_calling_conv.cpp
@@ -4,6 +4,9 @@
 // RUN: %clang_cc1 -triple i486-unknown-linux-gnu -mrtd -emit-llvm -o - %s | FileCheck %s --check-prefix=STDCALL --check-prefix=ALL
 // RUN: %clang_cc1 -triple i986-unknown-linux-gnu -fdefault-calling-conv=vectorcall -emit-llvm -o - %s | FileCheck %s --check-prefix=VECTORCALL --check-prefix=ALL
 // RUN: %clang_cc1 -triple i986-unknown-linux-gnu -fdefault-calling-conv=regcall -emit-llvm -o - %s | FileCheck %s --check-prefix=REGCALL --check-prefix=ALL
+// RUN: %clang_cc1 -triple i686-pc-win32 -fdefault-calling-conv=vectorcall -emit-llvm -o - %s -DWINDOWS | FileCheck %s --check-prefix=WIN32
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -fdefault-calling-conv=vectorcall -emit-llvm -o - %s -DWINDOWS | FileCheck %s --check-prefix=WIN64
+// RUN: %clang_cc1 -triple i686-pc-win32 -emit-llvm -o - %s -DEXPLICITCC | FileCheck %s --check-prefix=EXPLICITCC
 
 // CDECL: define{{.*}} void @_Z5test1v
 // FASTCALL: define{{.*}} x86_fastcallcc void @_Z5test1v
@@ -50,3 +53,45 @@
 int main() {
   return 1;
 }
+
+#ifdef WINDOWS
+// WIN32: define dso_local i32 @wmain
+// WIN64: define dso_local i32 @wmain
+int wmain() {
+  return 1;
+}
+// WIN32: define dso_local x86_stdcallcc i32 @WinMain
+// WIN64: define dso_local i32 @WinMain
+int WinMain() {
+  return 1;
+}
+// WIN32: define dso_local x86_stdcallcc i32 @wWinMain
+// WIN64: define dso_local i32 @wWinMain
+int wWinMain() {
+  return 1;
+}
+// WIN32: define dso_local x86_stdcallcc i32 @DllMain
+// WIN64: define dso_local i32 @DllMain
+int DllMain() {
+  return 1;
+}
+#endif // Windows
+
+#ifdef EXPLICITCC
+// EXPLICITCC: define dso_local x86_fastcallcc i32 @wmain
+int __fastcall wmain() {
+  return 1;
+}
+// EXPLICITCC: define dso_local x86_fastcallcc i32 @WinMain
+int __fastcall WinMain() {
+  return 1;
+}
+// EXPLICITCC: define dso_local x86_fastcallcc i32 @wWinMain
+int __fastcall wWinMain() {
+  return 1;
+}
+// EXPLICITCC: define dso_local x86_fastcallcc i32 @DllMain
+int __fastcall DllMain() {
+  return 1;
+}
+#endif // ExplicitCC
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -11169,6 +11169,25 @@
   }
 }
 
+static bool isDefaultStdCall(FunctionDecl *FD, Sema ) {
+
+  // Default calling convention for main and wmain is __cdecl
+  if (FD->getName() == "main" || FD->getName() == "wmain")
+return false;
+
+  // Default calling convention for MinGW is __cdecl
+  const llvm::Triple  = S.Context.getTargetInfo().getTriple();
+  if (T.isWindowsGNUEnvironment())
+return false;
+
+  // Default calling convention for WinMain, wWinMain and DllMain
+  // is __stdcall on 32 bit Windows
+  if (T.isOSWindows() && T.getArch() == llvm::Triple::x86)
+return true;
+
+  return false;
+}
+
 void Sema::CheckMSVCRTEntryPoint(FunctionDecl *FD) {
   QualType T = FD->getType();
   assert(T->isFunctionType() && "function decl is not of function type");
@@ -11183,6 +11202,21 @@
 if (FD->getName() != "DllMain")
   FD->setHasImplicitReturnZero(true);
 
+  // Explicity specified calling conventions are applied to MSVC entry points
+  if (!hasExplicitCallingConv(T)) {
+if (isDefaultStdCall(FD, *this)) {
+  if (FT->getCallConv() != CC_X86StdCall) {
+FT = Context.adjustFunctionType(
+FT, FT->getExtInfo().withCallingConv(CC_X86StdCall));
+FD->setType(QualType(FT, 0));
+  }
+} else if (FT->getCallConv() != CC_C) {
+  FT = Context.adjustFunctionType(FT,
+  FT->getExtInfo().withCallingConv(CC_C));
+  FD->setType(QualType(FT, 0));
+}
+  }
+
   if (!FD->isInvalidDecl() && FD->getDescribedFunctionTemplate()) {
 Diag(FD->getLocation(), diag::err_mainlike_template_decl) << FD;
 FD->setInvalidDecl();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D96875: [flang][driver] Add -fdebug-module-writer option

2021-03-08 Thread Arnamoy B via Phabricator via cfe-commits
arnamoy10 updated this revision to Diff 329100.
arnamoy10 added a comment.

Rebasing on main


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

https://reviews.llvm.org/D96875

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/CompilerInvocation.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/test/Flang-Driver/driver-help.f90
  flang/test/Semantics/mod-file-rewriter.f90

Index: flang/test/Semantics/mod-file-rewriter.f90
===
--- flang/test/Semantics/mod-file-rewriter.f90
+++ flang/test/Semantics/mod-file-rewriter.f90
@@ -1,8 +1,8 @@
 ! RUN: rm -fr %t && mkdir %t && cd %t
-! RUN: %f18 -fsyntax-only -fdebug-module-writer %s 2>&1 | FileCheck %s --check-prefix CHECK_CHANGED
-! RUN: %f18 -fsyntax-only -fdebug-module-writer %s 2>&1 | FileCheck %s --check-prefix CHECK_UNCHANGED
-! RUN: %f18 -fsyntax-only -fdebug-module-writer %p/Inputs/mod-file-unchanged.f90 2>&1 | FileCheck %s --check-prefix CHECK_UNCHANGED
-! RUN: %f18 -fsyntax-only -fdebug-module-writer %p/Inputs/mod-file-changed.f90 2>&1 | FileCheck %s --check-prefix CHECK_CHANGED
+! RUN: %flang_fc1 -fsyntax-only -fdebug-module-writer %s 2>&1 | FileCheck %s --check-prefix CHECK_CHANGED
+! RUN: %flang_fc1 -fsyntax-only -fdebug-module-writer %s 2>&1 | FileCheck %s --check-prefix CHECK_UNCHANGED
+! RUN: %flang_fc1 -fsyntax-only -fdebug-module-writer %p/Inputs/mod-file-unchanged.f90 2>&1 | FileCheck %s --check-prefix CHECK_UNCHANGED
+! RUN: %flang_fc1 -fsyntax-only -fdebug-module-writer %p/Inputs/mod-file-changed.f90 2>&1 | FileCheck %s --check-prefix CHECK_CHANGED
 
 module m
   real :: x(10)
Index: flang/test/Flang-Driver/driver-help.f90
===
--- flang/test/Flang-Driver/driver-help.f90
+++ flang/test/Flang-Driver/driver-help.f90
@@ -66,6 +66,7 @@
 ! HELP-FC1-NEXT: -fdebug-dump-symbolsDump symbols after the semantic analysis
 ! HELP-FC1-NEXT: -fdebug-measure-parse-tree
 ! HELP-FC1-NEXT: Measure the parse tree
+! HELP-FC1-NEXT: -fdebug-module-writer   Enable debug messages while writing module files
 ! HELP-FC1-NEXT: -fdebug-pre-fir-treeDump the pre-FIR tree
 ! HELP-FC1-NEXT: -fdebug-unparse-with-symbols
 ! HELP-FC1-NEXT:Unparse and stop.
Index: flang/lib/Frontend/FrontendActions.cpp
===
--- flang/lib/Frontend/FrontendActions.cpp
+++ flang/lib/Frontend/FrontendActions.cpp
@@ -126,7 +126,8 @@
   // Prepare semantics
   setSemantics(std::make_unique(
   ci.invocation().semanticsContext(), parseTree,
-  ci.parsing().cooked().AsCharBlock()));
+  ci.parsing().cooked().AsCharBlock(),
+  ci.invocation().debugModuleDir()));
   auto  = this->semantics();
 
   // Run semantic checks
Index: flang/lib/Frontend/CompilerInvocation.cpp
===
--- flang/lib/Frontend/CompilerInvocation.cpp
+++ flang/lib/Frontend/CompilerInvocation.cpp
@@ -291,9 +291,10 @@
 
 /// Parses all semantic related arguments and populates the variables
 /// options accordingly.
-static void parseSemaArgs(std::string , llvm::opt::ArgList ,
+static void parseSemaArgs(CompilerInvocation , llvm::opt::ArgList ,
 clang::DiagnosticsEngine ) {
 
+  // -J/module-dir option
   auto moduleDirList =
   args.getAllArgValues(clang::driver::options::OPT_module_dir);
   // User can only specify -J/-module-dir once
@@ -305,7 +306,12 @@
 diags.Report(diagID);
   }
   if (moduleDirList.size() == 1)
-moduleDir = moduleDirList[0];
+res.SetModuleDir(moduleDirList[0]);
+
+  // -fdebug-module-writer option
+  if (args.hasArg(clang::driver::options::OPT_fdebug_module_writer)) {
+res.SetDebugModuleDir(true);
+  }
 }
 
 /// Parses all Dialect related arguments and populates the variables
@@ -380,7 +386,7 @@
   // Parse the preprocessor args
   parsePreprocessorArgs(res.preprocessorOpts(), args);
   // Parse semantic args
-  parseSemaArgs(res.moduleDir(), args, diags);
+  parseSemaArgs(res, args, diags);
   // Parse dialect arguments
   parseDialectArgs(res, args, diags);
 
@@ -493,7 +499,6 @@
   semanticsContext_ = std::make_unique(
   defaultKinds(), fortranOptions.features, allCookedSources);
 
-  auto  = moduleDir();
-  semanticsContext_->set_moduleDirectory(moduleDirJ)
+  semanticsContext_->set_moduleDirectory(moduleDir())
   .set_searchDirectories(fortranOptions.searchDirectories);
 }
Index: flang/include/flang/Frontend/CompilerInvocation.h
===
--- flang/include/flang/Frontend/CompilerInvocation.h
+++ flang/include/flang/Frontend/CompilerInvocation.h
@@ -69,6 +69,8 @@
   // of options.
   std::string moduleDir_ = ".";
 
+  bool debugModuleDir_ = false;
+
   // Fortran Dialect options
  

[PATCH] D72841: Add support for pragma float_control, to control precision and exception behavior at the source level

2021-03-08 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.
Herald added subscribers: jansvoboda11, dexonsmith.

I got a bug report about this patch, see 
https://bugs.llvm.org/show_bug.cgi?id=49479.  I put a patch to fix it here, 
https://reviews.llvm.org/D98211


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72841

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


[PATCH] D98211: Solve PR49479, File scope fp pragma should propagate to functions nested in struct, and initialization expressions

2021-03-08 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added inline comments.



Comment at: clang/lib/Parse/ParseDeclCXX.cpp:3419
 // delayed attributes.
 
 SourceLocation SavedPrevTokLocation = PrevTokLocation;

I remember worrying about this issue when I wrote the initial patch but I can't 
remember what my thinking was in putting this in. Nobody remarked about its 
presence or absence as far as I have found. Now that I read over the #pragma 
float_control in the C standard it seems clear that it should apply to these 
expressions. And why would the command line options take effect but not the 
pragma, doesn't make sense.



Comment at: clang/test/CodeGen/fp-floatcontrol-stack.cpp:241
+
+#pragma clang fp reassociate(on)
+struct MyComplex {

this is the test case from the bug report


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98211

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


[PATCH] D98211: Solve PR49479, File scope fp pragma should propagate to functions nested in struct, and initialization expressions

2021-03-08 Thread Melanie Blower via Phabricator via cfe-commits
mibintc created this revision.
mibintc added reviewers: kpn, erichkeane, rjmccall.
mibintc requested review of this revision.
Herald added a project: clang.

Currently, the CurFPFeatures state is set to command line settings before 
semantic analysis of the nested member functions and initialization 
expressions, that's not correct.  This patch fixes that.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98211

Files:
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/test/CodeGen/fp-floatcontrol-stack.cpp


Index: clang/test/CodeGen/fp-floatcontrol-stack.cpp
===
--- clang/test/CodeGen/fp-floatcontrol-stack.cpp
+++ clang/test/CodeGen/fp-floatcontrol-stack.cpp
@@ -212,8 +212,7 @@
 #endif
 float y();
 class ON {
-  // Settings for top level class initializer revert to command line
-  // source pragma's do not pertain.
+  // Settings for top level class initializer use program source setting.
   float z = 2 + y() * 7;
 //CHECK-LABEL: define {{.*}} void @_ZN2ONC2Ev{{.*}}
 #if DEFAULT
@@ -224,11 +223,10 @@
 //CHECK-DEBSTRICT: call float {{.*}}llvm.fmuladd
 #endif
 #if NOHONOR
-//CHECK-NOHONOR: call nnan ninf float @llvm.fmuladd{{.*}}
+//CHECK-NOHONOR: call float {{.*}}llvm.fmuladd
 #endif
 #if FAST
-//CHECK-FAST: fmul fast float
-//CHECK-FAST: fadd fast float
+//CHECK-FAST: float {{.*}}llvm.fmuladd{{.*}}
 #endif
 };
 ON on;
@@ -236,18 +234,28 @@
 class OFF {
   float w = 2 + y() * 7;
 //CHECK-LABEL: define {{.*}} void @_ZN3OFFC2Ev{{.*}}
-#if DEFAULT
-//CHECK-DDEFAULT: call float {{.*}}llvm.fmuladd
-#endif
-#if EBSTRICT
-//CHECK-DEBSTRICT: call float {{.*}}llvm.fmuladd
-#endif
-#if NOHONOR
-//CHECK-NOHONOR: call nnan ninf float @llvm.fmuladd{{.*}}
-#endif
-#if FAST
-//CHECK-FAST: fmul fast float
-//CHECK-FAST: fadd fast float
-#endif
+//CHECK: call float {{.*}}llvm.fmuladd
 };
 OFF off;
+
+#pragma clang fp reassociate(on)
+struct MyComplex {
+  float xx;
+  float yy;
+  MyComplex(float x, float y) {
+xx = x;
+yy = y;
+  }
+  MyComplex() {}
+  const MyComplex operator+(const MyComplex other) const {
+//CHECK-LABEL: define {{.*}} @_ZNK9MyComplexplES_
+//CHECK: fadd reassoc float
+//CHECK: fadd reassoc float
+return MyComplex(xx + other.xx, yy + other.yy);
+  }
+};
+MyComplex useAdd() {
+  MyComplex a (1, 3);
+  MyComplex b (2, 4);
+   return a + b;
+}
Index: clang/lib/Parse/ParseDeclCXX.cpp
===
--- clang/lib/Parse/ParseDeclCXX.cpp
+++ clang/lib/Parse/ParseDeclCXX.cpp
@@ -3417,15 +3417,6 @@
 // declarations and the lexed inline method definitions, along with any
 // delayed attributes.
 
-// Save the state of Sema.FPFeatures, and change the setting
-// to the levels specified on the command line.  Previous level
-// will be restored when the RAII object is destroyed.
-Sema::FPFeaturesStateRAII SaveFPFeaturesState(Actions);
-FPOptionsOverride NewOverrides;
-Actions.CurFPFeatures = NewOverrides.applyOverrides(getLangOpts());
-Actions.FpPragmaStack.Act(Tok.getLocation(), Sema::PSK_Reset, StringRef(),
-  {} /*unused*/);
-
 SourceLocation SavedPrevTokLocation = PrevTokLocation;
 ParseLexedPragmas(getCurrentClass());
 ParseLexedAttributes(getCurrentClass());


Index: clang/test/CodeGen/fp-floatcontrol-stack.cpp
===
--- clang/test/CodeGen/fp-floatcontrol-stack.cpp
+++ clang/test/CodeGen/fp-floatcontrol-stack.cpp
@@ -212,8 +212,7 @@
 #endif
 float y();
 class ON {
-  // Settings for top level class initializer revert to command line
-  // source pragma's do not pertain.
+  // Settings for top level class initializer use program source setting.
   float z = 2 + y() * 7;
 //CHECK-LABEL: define {{.*}} void @_ZN2ONC2Ev{{.*}}
 #if DEFAULT
@@ -224,11 +223,10 @@
 //CHECK-DEBSTRICT: call float {{.*}}llvm.fmuladd
 #endif
 #if NOHONOR
-//CHECK-NOHONOR: call nnan ninf float @llvm.fmuladd{{.*}}
+//CHECK-NOHONOR: call float {{.*}}llvm.fmuladd
 #endif
 #if FAST
-//CHECK-FAST: fmul fast float
-//CHECK-FAST: fadd fast float
+//CHECK-FAST: float {{.*}}llvm.fmuladd{{.*}}
 #endif
 };
 ON on;
@@ -236,18 +234,28 @@
 class OFF {
   float w = 2 + y() * 7;
 //CHECK-LABEL: define {{.*}} void @_ZN3OFFC2Ev{{.*}}
-#if DEFAULT
-//CHECK-DDEFAULT: call float {{.*}}llvm.fmuladd
-#endif
-#if EBSTRICT
-//CHECK-DEBSTRICT: call float {{.*}}llvm.fmuladd
-#endif
-#if NOHONOR
-//CHECK-NOHONOR: call nnan ninf float @llvm.fmuladd{{.*}}
-#endif
-#if FAST
-//CHECK-FAST: fmul fast float
-//CHECK-FAST: fadd fast float
-#endif
+//CHECK: call float {{.*}}llvm.fmuladd
 };
 OFF off;
+
+#pragma clang fp reassociate(on)
+struct MyComplex {
+  float xx;
+  float yy;
+  MyComplex(float x, float y) {
+xx = x;
+yy = y;
+  }
+  MyComplex() {}
+  const MyComplex operator+(const MyComplex other) 

[PATCH] D93031: Enable fexec-charset option

2021-03-08 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan marked 3 inline comments as done.
abhina.sreeskantharajan added inline comments.



Comment at: clang/include/clang/Lex/LiteralTranslator.h:30-31
+
+class LiteralTranslator {
+public:
+  llvm::StringRef InternalCharset;

tahonermann wrote:
> I don't know the LLVM style guides well, but I suspect a class with all 
> public members should be defined using `struct` and not include access 
> specifiers.
I've made these private.



Comment at: clang/include/clang/Lex/LiteralTranslator.h:37
+
+  llvm::CharSetConverter *getConversionTable(const char *Codepage);
+  CharsetTableStatusCode findOrCreateExecCharsetTable(const char *To);

tahonermann wrote:
> `getConversionTable()` is logically `const`.  Perhaps `ExecCharsetTables` 
> should be `mutable`.
> 
> From a terminology stand point, this function is misnamed.  It doesn't return 
> a table, it returns a converter for an encoding.  I suggest:
>   llvm::CharSetConverter *getCharSetConverter(const char *Encoding) const;
I've renamed this function to getConverter


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93031

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


[PATCH] D89986: [AIX] do not emit visibility attribute into IR when there is -mignore-xcoff-visibility

2021-03-08 Thread Digger Lin via Phabricator via cfe-commits
DiggerLin added a comment.

Gentle ping . @jansvoboda11 .  Do you have any comment on it the last update on 
 "added -round-trip-args functionality for the lang opt 
"-mignore-xcoff-visibility" ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89986

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


[PATCH] D89986: [AIX] do not emit visibility attribute into IR when there is -mignore-xcoff-visibility

2021-03-08 Thread Lei Huang via Phabricator via cfe-commits
lei added a comment.

Instead of waiting a day or two, can you please directly ping reviewers who had 
concerns related to the round-trip-args behaviour to get feedback?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89986

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


[PATCH] D72235: [clang-tidy] new altera unroll loops check

2021-03-08 Thread Frank Derry Wanye via Phabricator via cfe-commits
ffrankies updated this revision to Diff 329082.
ffrankies marked 6 inline comments as done.
ffrankies added a comment.

Rebased with the latest main branch to fix patch application errors.


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

https://reviews.llvm.org/D72235

Files:
  clang-tools-extra/clang-tidy/altera/AlteraTidyModule.cpp
  clang-tools-extra/clang-tidy/altera/CMakeLists.txt
  clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
  clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/altera-unroll-loops.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/checkers/altera-unroll-loops.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/altera-unroll-loops.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/altera-unroll-loops.cpp
@@ -0,0 +1,518 @@
+// RUN: %check_clang_tidy %s altera-unroll-loops %t -- -config="{CheckOptions: [{key: "altera-unroll-loops.MaxLoopIterations", value: 50}]}" -header-filter=.*
+// RUN: %check_clang_tidy -check-suffix=MULT %s altera-unroll-loops %t -- -config="{CheckOptions: [{key: "altera-unroll-loops.MaxLoopIterations", value: 5}]}" -header-filter=.* "--" -DMULT
+
+#ifdef MULT
+// For loops with *= and /= increments.
+void for_loop_mult_div_increments(int *A) {
+// *=
+#pragma unroll
+for (int i = 2; i <= 32; i *= 2)
+A[i]++;  // OK
+
+#pragma unroll
+for (int i = 2; i <= 64; i *= 2)
+// CHECK-MESSAGES-MULT: :[[@LINE-1]]:5: warning: loop likely has a large number of iterations and thus cannot be fully unrolled; to partially unroll this loop, use the '#pragma unroll ' directive [altera-unroll-loops]
+A[i]++;  // Not OK
+
+// /=
+#pragma unroll
+for (int i = 32; i >= 2; i /= 2)
+A[i]++;  // OK
+
+#pragma unroll
+for (int i = 64; i >= 2; i /= 2)
+// CHECK-MESSAGES-MULT: :[[@LINE-1]]:5: warning: loop likely has a large number of iterations and thus cannot be fully unrolled; to partially unroll this loop, use the '#pragma unroll ' directive [altera-unroll-loops]
+A[i]++;  // Not OK
+}
+#else
+// Cannot determine loop bounds for while loops.
+void while_loops(int *A) {
+// Recommend unrolling loops that aren't already unrolled.
+int j = 0;
+while (j < 2000) {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: kernel performance could be improved by unrolling this loop with a '#pragma unroll' directive [altera-unroll-loops]
+A[1] += j;
+j++;
+}
+
+do {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: kernel performance could be improved by unrolling this loop with a '#pragma unroll' directive [altera-unroll-loops]
+A[2] += j;
+j++;
+} while (j < 2000);
+
+// If a while loop is fully unrolled, add a note recommending partial
+// unrolling.
+#pragma unroll
+while (j < 2000) {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: note: full unrolling requested, but loop bounds may not be known; to partially unroll this loop, use the '#pragma unroll ' directive
+A[j]++;
+}
+
+#pragma unroll
+do {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: note: full unrolling requested, but loop bounds may not be known; to partially unroll this loop, use the '#pragma unroll ' directive
+A[j]++;
+} while (j < 2000);
+
+// While loop is partially unrolled, no action needed.
+#pragma unroll 4
+while (j < 2000) {
+A[j]++;
+}
+
+#pragma unroll 4
+do {
+A[j]++;
+} while (j < 2000);
+}
+
+// Range-based for loops.
+void cxx_for_loops(int *A, int vectorSize) {
+// Loop with known array size should be unrolled.
+int a[] = { 0, 1, 2, 3, 4, 5 };
+for (int k : a) {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: kernel performance could be improved by unrolling this loop with a '#pragma unroll' directive [altera-unroll-loops]
+A[k]++;
+}
+
+// Loop with known size correctly unrolled.
+#pragma unroll
+for (int k : a) {
+A[k]++;
+}
+
+// Loop with unknown size should be partially unrolled.
+int b[vectorSize];
+#pragma unroll
+for (int k : b) {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: full unrolling requested, but loop bounds are not known; to partially unroll this loop, use the '#pragma unroll ' directive [altera-unroll-loops]
+k++;
+}
+
+// Loop with unknown size correctly unrolled.
+#pragma unroll 5
+for (int k : b) {
+k++;
+}
+
+// Loop with large size should be partially unrolled.
+int c[51];
+#pragma unroll
+for (int k : c) {
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: loop likely has a large number of iterations and thus cannot be fully unrolled; to partially unroll this loop, use the '#pragma unroll ' directive [altera-unroll-loops]
+A[k]++;
+}
+
+// Loop with 

[PATCH] D98193: [CUDA][HIP] Allow non-ODR use of host var in device

2021-03-08 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/test/SemaCUDA/device-use-host-var.cu:41
   *out = global_const_var;
+  *out = global_const_struct_var.x;
 

I do not think it should be allowed. We end up instantiating the variable on 
device, even though the variable should be host-only.

Right now we allow it, but end up with an `.extern .const` which will make 
ptxas fail:
https://godbolt.org/z/sx9845

If we do allow it, we'll need to make sure that we only use the value, but do 
not allow instantiating the variable.



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

https://reviews.llvm.org/D98193

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


[PATCH] D98142: [clang] Don't set CLANG_DEFAULT_UNWINDLIB to none if rtlib is set to compiler-rt

2021-03-08 Thread Petr Hosek via Phabricator via cfe-commits
phosek accepted this revision.
phosek added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98142

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


[PATCH] D98142: [clang] Don't set CLANG_DEFAULT_UNWINDLIB to none if rtlib is set to compiler-rt

2021-03-08 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added a comment.
This revision is now accepted and ready to land.

The merit is less CMake magic.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98142

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


[PATCH] D96975: [Sema] Add some basic lambda capture fix-its

2021-03-08 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 329075.
njames93 added a comment.

Prevent explicit 'this' capture fix-it if default capture mode is '=' and not 
in c++20 mode.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96975

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/CXX/drs/dr6xx.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p12.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p2-generic-lambda-1y.cpp
  clang/test/SemaCXX/cxx1y-generic-lambdas-capturing.cpp
  clang/test/SemaCXX/cxx1y-generic-lambdas.cpp
  clang/test/SemaCXX/cxx1y-init-captures.cpp
  clang/test/SemaCXX/cxx1z-constexpr-lambdas.cpp
  clang/test/SemaCXX/lambda-expressions.cpp
  clang/test/SemaCXX/lambda-invalid-capture.cpp
  clang/test/SemaObjCXX/capturing-flexible-array-in-block.mm

Index: clang/test/SemaObjCXX/capturing-flexible-array-in-block.mm
===
--- clang/test/SemaObjCXX/capturing-flexible-array-in-block.mm
+++ clang/test/SemaObjCXX/capturing-flexible-array-in-block.mm
@@ -5,5 +5,5 @@
   struct { int x; int y[]; } a; // expected-note 3 {{'a' declared here}}
   ^{return a.x;}(); // expected-error {{cannot refer to declaration of structure variable with flexible array member inside block}}
   [=] {return a.x;}(); // expected-error {{variable 'a' with flexible array member cannot be captured in a lambda expression}}
-  [] {return a.x;}(); // expected-error {{variable 'a' cannot be implicitly captured in a lambda with no capture-default}} expected-note {{here}}
+  [] {return a.x;}(); // expected-error {{variable 'a' cannot be implicitly captured in a lambda with no capture-default}} expected-note {{here}} expected-note 2 {{capture 'a' by}} expected-note 2 {{default capture by}}
 }
Index: clang/test/SemaCXX/lambda-invalid-capture.cpp
===
--- clang/test/SemaCXX/lambda-invalid-capture.cpp
+++ clang/test/SemaCXX/lambda-invalid-capture.cpp
@@ -18,7 +18,7 @@
 }
 
 int pr43080(int i) { // expected-note {{declared here}}
-  return [] { // expected-note {{begins here}}
+  return [] {// expected-note {{begins here}} expected-note 2 {{capture 'i' by}} expected-note 2 {{default capture by}}
 return sizeof i <
   i; // expected-error {{variable 'i' cannot be implicitly captured in a lambda with no capture-default specified}}
   }();
Index: clang/test/SemaCXX/lambda-expressions.cpp
===
--- clang/test/SemaCXX/lambda-expressions.cpp
+++ clang/test/SemaCXX/lambda-expressions.cpp
@@ -12,17 +12,17 @@
 virtual C& Overload(float);
 
 void ImplicitThisCapture() {
-  [](){(void)Member;}; // expected-error {{'this' cannot be implicitly captured in this context}}
-  const int var = [](){(void)Member; return 0;}(); // expected-error {{'this' cannot be implicitly captured in this context}}
+  []() { (void)Member; }; // expected-error {{'this' cannot be implicitly captured in this context}} expected-note {{explicitly capture 'this'}}
+  const int var = []() {(void)Member; return 0; }(); // expected-error {{'this' cannot be implicitly captured in this context}} expected-note {{explicitly capture 'this'}}
   [&](){(void)Member;};
 
   [this](){(void)Member;};
   [this]{[this]{};};
   []{[this]{};};// expected-error {{'this' cannot be implicitly captured in this context}}
   []{Overload(3);};
-  []{Overload();}; // expected-error {{'this' cannot be implicitly captured in this context}}
+  [] { Overload(); }; // expected-error {{'this' cannot be implicitly captured in this context}} expected-note {{explicitly capture 'this'}}
   []{(void)typeid(Overload());};
-  []{(void)typeid(Overload(.5f));};// expected-error {{'this' cannot be implicitly captured in this context}}
+  [] { (void)typeid(Overload(.5f)); }; // expected-error {{'this' cannot be implicitly captured in this context}} expected-note {{explicitly capture 'this'}}
 }
   };
 
@@ -47,14 +47,14 @@
 namespace ImplicitCapture {
   void test() {
 int a = 0; // expected-note 5 {{declared}}
-[]() { return a; }; // expected-error {{variable 'a' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{begins here}}
+[]() { return a; }; // expected-error {{variable 'a' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{begins here}} expected-note 2 {{capture 'a' by}} expected-note 2 {{default capture by}}
 [&]() { return a; };
 [=]() { return a; };
 [=]() { int* b =  }; // expected-error {{cannot initialize a variable of type 'int *' with an rvalue of type 'const int *'}}
 [=]() { return [&]() { return a; }; };
-[]() { return [&]() { return a; }; }; // 

[PATCH] D94554: [clangd] Add a Filesystem that overlays Dirty files.

2021-03-08 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 329070.
njames93 marked 2 inline comments as done.
njames93 added a comment.

Address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94554

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/DraftStore.cpp
  clang-tools-extra/clangd/DraftStore.h
  clang-tools-extra/clangd/unittests/DraftStoreTests.cpp

Index: clang-tools-extra/clangd/unittests/DraftStoreTests.cpp
===
--- clang-tools-extra/clangd/unittests/DraftStoreTests.cpp
+++ clang-tools-extra/clangd/unittests/DraftStoreTests.cpp
@@ -24,20 +24,20 @@
 
   EXPECT_EQ("25", DS.addDraft(File, "25", ""));
   EXPECT_EQ("25", DS.getDraft(File)->Version);
-  EXPECT_EQ("", DS.getDraft(File)->Contents);
+  EXPECT_EQ("", *DS.getDraft(File)->Contents);
 
   EXPECT_EQ("26", DS.addDraft(File, "", "x"));
   EXPECT_EQ("26", DS.getDraft(File)->Version);
-  EXPECT_EQ("x", DS.getDraft(File)->Contents);
+  EXPECT_EQ("x", *DS.getDraft(File)->Contents);
 
   EXPECT_EQ("27", DS.addDraft(File, "", "x")) << "no-op change";
   EXPECT_EQ("27", DS.getDraft(File)->Version);
-  EXPECT_EQ("x", DS.getDraft(File)->Contents);
+  EXPECT_EQ("x", *DS.getDraft(File)->Contents);
 
   // We allow versions to go backwards.
   EXPECT_EQ("7", DS.addDraft(File, "7", "y"));
   EXPECT_EQ("7", DS.getDraft(File)->Version);
-  EXPECT_EQ("y", DS.getDraft(File)->Contents);
+  EXPECT_EQ("y", *DS.getDraft(File)->Contents);
 }
 
 } // namespace
Index: clang-tools-extra/clangd/DraftStore.h
===
--- clang-tools-extra/clangd/DraftStore.h
+++ clang-tools-extra/clangd/DraftStore.h
@@ -13,6 +13,7 @@
 #include "support/Path.h"
 #include "clang/Basic/LLVM.h"
 #include "llvm/ADT/StringMap.h"
+#include "llvm/Support/VirtualFileSystem.h"
 #include 
 #include 
 #include 
@@ -27,7 +28,7 @@
 class DraftStore {
 public:
   struct Draft {
-std::string Contents;
+std::shared_ptr Contents;
 std::string Version;
   };
 
@@ -47,9 +48,15 @@
   /// Remove the draft from the store.
   void removeDraft(PathRef File);
 
+  llvm::IntrusiveRefCntPtr asVFS() const;
+
 private:
+  struct DraftAndTime {
+Draft Draft;
+std::time_t MTime;
+  };
   mutable std::mutex Mutex;
-  llvm::StringMap Drafts;
+  llvm::StringMap Drafts;
 };
 
 } // namespace clangd
Index: clang-tools-extra/clangd/DraftStore.cpp
===
--- clang-tools-extra/clangd/DraftStore.cpp
+++ clang-tools-extra/clangd/DraftStore.cpp
@@ -11,6 +11,8 @@
 #include "support/Logger.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/Errc.h"
+#include "llvm/Support/VirtualFileSystem.h"
+#include 
 
 namespace clang {
 namespace clangd {
@@ -22,7 +24,7 @@
   if (It == Drafts.end())
 return None;
 
-  return It->second;
+  return It->second.Draft;
 }
 
 std::vector DraftStore::getActiveFiles() const {
@@ -75,10 +77,11 @@
  llvm::StringRef Contents) {
   std::lock_guard Lock(Mutex);
 
-  Draft  = Drafts[File];
-  updateVersion(D, Version);
-  D.Contents = Contents.str();
-  return D.Version;
+  auto  = Drafts[File];
+  updateVersion(D.Draft, Version);
+  std::time();
+  D.Draft.Contents = std::make_shared(Contents);
+  return D.Draft.Version;
 }
 
 void DraftStore::removeDraft(PathRef File) {
@@ -87,5 +90,39 @@
   Drafts.erase(File);
 }
 
+namespace {
+
+/// A read only MemoryBuffer shares ownership of a ref counted string. The
+/// shared string object must not be modified while an owned by this buffer.
+class SharedStringBuffer : public llvm::MemoryBuffer {
+  const std::shared_ptr BufferContents;
+  const std::string Name;
+
+public:
+  BufferKind getBufferKind() const override {
+return MemoryBuffer::MemoryBuffer_Malloc;
+  }
+
+  StringRef getBufferIdentifier() const override { return Name; }
+
+  SharedStringBuffer(std::shared_ptr Data, StringRef Name)
+  : BufferContents(std::move(Data)), Name(Name) {
+assert(BufferContents && "Can't create from empty shared_ptr");
+MemoryBuffer::init(BufferContents->c_str(),
+   BufferContents->c_str() + BufferContents->size(),
+   /*RequiresNullTerminator=*/true);
+  }
+};
+} // namespace
+
+llvm::IntrusiveRefCntPtr DraftStore::asVFS() const {
+  auto MemFS = llvm::makeIntrusiveRefCnt();
+  std::lock_guard Guard(Mutex);
+  for (const auto  : Drafts)
+MemFS->addFile(Draft.getKey(), Draft.getValue().MTime,
+   std::make_unique(
+   Draft.getValue().Draft.Contents, Draft.getKey()));
+  return MemFS;
+}
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/ClangdServer.h

[PATCH] D94554: [clangd] Add a Filesystem that overlays Dirty files.

2021-03-08 Thread Nathan James via Phabricator via cfe-commits
njames93 marked 11 inline comments as done.
njames93 added inline comments.



Comment at: clang-tools-extra/clangd/ClangdServer.h:389
+
+  class DirtyFS : public ThreadsafeFS {
+  public:

sammccall wrote:
> njames93 wrote:
> > Probably needs moving to its own place, but wasn't sure where best to put 
> > it.
> I think ClangdServer is fine, but this can be a unique_ptr with 
> the class moved to the implementation file
How about privately inheriting from ThreadsafeFS :P
I agree, hiding the impl in the cpp is probably a much nicer way.



Comment at: clang-tools-extra/clangd/DraftStore.cpp:80
 
-  Draft  = Drafts[File];
-  updateVersion(D, Version);
-  D.Contents = Contents.str();
-  return D.Version;
+  auto Res = Drafts.try_emplace(File);
+  auto  = Res.first->getValue();

sammccall wrote:
> we don't need try_emplace here, we overwrite the whole value regardless.
> Can we use `Draft  = Drafts[File]` again?
I changed this because in an older version I wanted to set the UniqueID on the 
first time the file was added, however now we don't do that (or check the 
return value for insertion at all) its safe to go back to the `operator[]` 
access.



Comment at: clang-tools-extra/clangd/DraftStore.cpp:287
+for (const auto  : DS.Drafts) {
+  // Query the base filesystem for file uniqueids.
+  auto BaseStatus = BaseView->status(KV.getKey());

njames93 wrote:
> sammccall wrote:
> > njames93 wrote:
> > > sammccall wrote:
> > > > doing IO in view() doesn't seem obviously OK.
> > > > 
> > > > what's the practical consequence of the overlay's inodes not matching 
> > > > that of the underlying FS? (It seems reasonable to say that the files 
> > > > always have different identity, and may/may not have the same content)
> > > It's probably not necessary, but I know preambles use the UniqueID. It 
> > > may just be safer to create a uniqueID for each item in the DraftStore 
> > > and leave it at that.
> > The biggest risks I can see with this approach:
> >  - in build-preamble-from-dirty-FS mode, would opening a draft cause the 
> > preamble to be considered invalid and needing rebuilding? My read of 
> > PrecompiledPreamble::CanReuse is no (UniqueIDs are not stored)
> >  - when parsing, if the file can be read through the overlay *and* 
> > underlying via different paths (e.g. hardlinks), these won't be 
> > deduplicated. However giving them the same inode only changes the nature of 
> > the bug: the file would get whichever content was read first.
> > 
> > So I think it's as good as we can expect.
> Unfortunately in the current implementation, opening a draft will invalidate 
> and preambles that use the underlying file. 
> This is due to the last modification times not matching. 
> This could be addressed by querying the TFS on the textDocument/didOpen 
> request to get the actual last modification time, but we shouldn't really be 
> doing any kind of IO on that thread.
@sammccall Any further comments with regard to this. Is calling IO to get 
modification time in didOpen ok, or just accept opening a file would invalidate 
a preamble if the DirtyFS was used for preambles.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94554

___
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-03-08 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

Godbolt appears to be OK with the code for both gcc and clang: 
https://godbolt.org/z/enec44

Debug build does assert here:

  clang++: /work/llvm/repo/clang/lib/Sema/SemaTemplateInstantiate.cpp:3630: 
void clang::LocalInstantiationScope::InstantiatedLocal(const clang::Decl *, 
clang::Decl *): Assertion `Current->LocalDecls.find(D) == 
Current->LocalDecls.end() && "Instantiated local in inner and outer scopes"' 
failed.
  ...
   #12 0x7f8aa3941b9f 
clang::LocalInstantiationScope::InstantiatedLocal(clang::Decl const*, 
clang::Decl*) /work/llvm/repo/clang/lib/Sema/SemaTemplateInstantiate.cpp:3627:5
   #13 0x7f8aa39bd090 addInstantiatedParametersToScope(clang::Sema&, 
clang::FunctionDecl*, clang::FunctionDecl const*, 
clang::LocalInstantiationScope&, clang::MultiLevelTemplateArgumentList const&) 
/work/llvm/repo/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp:4293:7
   #14 0x7f8aa39be985 
clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, 
clang::FunctionDecl*, bool, bool, bool) 
/work/llvm/repo/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp:4869:9
   #15 0x7f8aa3929378 clang::Sema::DeduceReturnType(clang::FunctionDecl*, 
clang::SourceLocation, bool)::$_10::operator()() const 
/work/llvm/repo/clang/lib/Sema/SemaTemplateDeduction.cpp:5025:5
   #16 0x7f8aa3929335 void llvm::function_ref::callback_fn(long) 
/work/llvm/repo/llvm/include/llvm/ADT/STLExtras.h:185:5
   #17 0x7f8aa28d9ff9 llvm::function_ref::operator()() const 
/work/llvm/repo/llvm/include/llvm/ADT/STLExtras.h:209:5
   #18 0x7f8aa28c4b0d 
clang::runWithSufficientStackSpace(llvm::function_ref, 
llvm::function_ref) 
/work/llvm/repo/clang/include/clang/Basic/Stack.h:52:3
   #19 0x7f8aa28b1de4 
clang::Sema::runWithSufficientStackSpace(clang::SourceLocation, 
llvm::function_ref) //work/llvm/repo/clang/lib/Sema/Sema.cpp:458:1
   #20 0x7f8aa3851a7f clang::Sema::DeduceReturnType(clang::FunctionDecl*, 
clang::SourceLocation, bool) 
/work/llvm/repo/clang/lib/Sema/SemaTemplateDeduction.cpp:5028:25
   #21 0x7f8aa2fe10a4 clang::Sema::DiagnoseUseOfDecl(clang::NamedDecl*, 
llvm::ArrayRef, clang::ObjCInterfaceDecl const*, bool, 
bool, clang::ObjCInterfaceDecl*) /llvm/repo/clang/lib/Sema/SemaExpr.cpp:291:9
   #22 0x7f8aa35e47eb CreateFunctionRefExpr(clang::Sema&, 
clang::FunctionDecl*, clang::NamedDecl*, clang::Expr const*, bool, 
clang::SourceLocation, clang::DeclarationNameLoc const&) 
/work/llvm/repo/clang/lib/Sema/SemaOverload.cpp:65:28
   #23 0x7f8aa35ecba0 
clang::Sema::BuildCallToObjectOfClassType(clang::Scope*, clang::Expr*, 
clang::SourceLocation, llvm::MutableArrayRef, 
clang::SourceLocation) /work/llvm/repo/clang/lib/Sema/SemaOverload.cpp:14630:22
   #24 0x7f8aa2fe7574 clang::Sema::BuildCallExpr(clang::Scope*, 
clang::Expr*, clang::SourceLocation, llvm::MutableArrayRef, 
clang::SourceLocation, clang::Expr*, bool, bool) 
/work/llvm/repo/clang/lib/Sema/SemaExpr.cpp:6396:
  ...


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] D97850: Fix PCM read from ModuleCache for ext4 filesystem

2021-03-08 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor added a comment.

It seems we already hit this issue before and decided to add a workaround: 
https://reviews.llvm.org/D86823


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97850

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


[PATCH] D96975: [Sema] Add some basic lambda capture fix-its

2021-03-08 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 329066.
njames93 added a comment.

Update to not offer Default capture fix if other variables are also captured.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96975

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/CXX/drs/dr6xx.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p12.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p2-generic-lambda-1y.cpp
  clang/test/SemaCXX/cxx1y-generic-lambdas-capturing.cpp
  clang/test/SemaCXX/cxx1y-generic-lambdas.cpp
  clang/test/SemaCXX/cxx1y-init-captures.cpp
  clang/test/SemaCXX/cxx1z-constexpr-lambdas.cpp
  clang/test/SemaCXX/lambda-expressions.cpp
  clang/test/SemaCXX/lambda-invalid-capture.cpp
  clang/test/SemaObjCXX/capturing-flexible-array-in-block.mm

Index: clang/test/SemaObjCXX/capturing-flexible-array-in-block.mm
===
--- clang/test/SemaObjCXX/capturing-flexible-array-in-block.mm
+++ clang/test/SemaObjCXX/capturing-flexible-array-in-block.mm
@@ -5,5 +5,5 @@
   struct { int x; int y[]; } a; // expected-note 3 {{'a' declared here}}
   ^{return a.x;}(); // expected-error {{cannot refer to declaration of structure variable with flexible array member inside block}}
   [=] {return a.x;}(); // expected-error {{variable 'a' with flexible array member cannot be captured in a lambda expression}}
-  [] {return a.x;}(); // expected-error {{variable 'a' cannot be implicitly captured in a lambda with no capture-default}} expected-note {{here}}
+  [] {return a.x;}(); // expected-error {{variable 'a' cannot be implicitly captured in a lambda with no capture-default}} expected-note {{here}} expected-note 2 {{capture 'a' by}} expected-note 2 {{default capture by}}
 }
Index: clang/test/SemaCXX/lambda-invalid-capture.cpp
===
--- clang/test/SemaCXX/lambda-invalid-capture.cpp
+++ clang/test/SemaCXX/lambda-invalid-capture.cpp
@@ -18,7 +18,7 @@
 }
 
 int pr43080(int i) { // expected-note {{declared here}}
-  return [] { // expected-note {{begins here}}
+  return [] {// expected-note {{begins here}} expected-note 2 {{capture 'i' by}} expected-note 2 {{default capture by}}
 return sizeof i <
   i; // expected-error {{variable 'i' cannot be implicitly captured in a lambda with no capture-default specified}}
   }();
Index: clang/test/SemaCXX/lambda-expressions.cpp
===
--- clang/test/SemaCXX/lambda-expressions.cpp
+++ clang/test/SemaCXX/lambda-expressions.cpp
@@ -12,17 +12,17 @@
 virtual C& Overload(float);
 
 void ImplicitThisCapture() {
-  [](){(void)Member;}; // expected-error {{'this' cannot be implicitly captured in this context}}
-  const int var = [](){(void)Member; return 0;}(); // expected-error {{'this' cannot be implicitly captured in this context}}
+  []() { (void)Member; }; // expected-error {{'this' cannot be implicitly captured in this context}} expected-note {{explicitly capture 'this'}}
+  const int var = []() {(void)Member; return 0; }(); // expected-error {{'this' cannot be implicitly captured in this context}} expected-note {{explicitly capture 'this'}}
   [&](){(void)Member;};
 
   [this](){(void)Member;};
   [this]{[this]{};};
   []{[this]{};};// expected-error {{'this' cannot be implicitly captured in this context}}
   []{Overload(3);};
-  []{Overload();}; // expected-error {{'this' cannot be implicitly captured in this context}}
+  [] { Overload(); }; // expected-error {{'this' cannot be implicitly captured in this context}} expected-note {{explicitly capture 'this'}}
   []{(void)typeid(Overload());};
-  []{(void)typeid(Overload(.5f));};// expected-error {{'this' cannot be implicitly captured in this context}}
+  [] { (void)typeid(Overload(.5f)); }; // expected-error {{'this' cannot be implicitly captured in this context}} expected-note {{explicitly capture 'this'}}
 }
   };
 
@@ -47,14 +47,14 @@
 namespace ImplicitCapture {
   void test() {
 int a = 0; // expected-note 5 {{declared}}
-[]() { return a; }; // expected-error {{variable 'a' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{begins here}}
+[]() { return a; }; // expected-error {{variable 'a' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{begins here}} expected-note 2 {{capture 'a' by}} expected-note 2 {{default capture by}}
 [&]() { return a; };
 [=]() { return a; };
 [=]() { int* b =  }; // expected-error {{cannot initialize a variable of type 'int *' with an rvalue of type 'const int *'}}
 [=]() { return [&]() { return a; }; };
-[]() { return [&]() { return a; }; }; // expected-error 

[PATCH] D97068: Run non-filechecked commands in update_cc_test_checks.py

2021-03-08 Thread Giorgis Georgakoudis via Phabricator via cfe-commits
ggeorgakoudis added a comment.

In D97068#2611269 , @thakis wrote:

> Looks like this breaks tests on mac: http://45.33.8.238/macm1/5075/step_6.txt
>
> Please take a look, and revert for now if it takes a while to fix.

Hey @thakis, it should be an easy fix. I see no check lines are generated and I 
suspect something may be going wrong with the `cp` runline, but it's hard to 
know without replicating it. Is there any way you can give me temporary access 
to the mac machine to test things out?

Otherwise, I will simplify the test to exclude the `cp` runline.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97068

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


[PATCH] D98191: [flang][driver] Add support for `-fdebug-dump-symbols-sources`

2021-03-08 Thread Tim Keith via Phabricator via cfe-commits
tskeith added a comment.

`-fget-symbols-sources` is not a debug option, it's intended for integrating 
with IDEs like vscode. So I think the original name is better. Unlike the 
"dump" options it actually is an action and not something that is intended to 
produce debug output on the way to doing something else.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98191

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


[PATCH] D97831: [Clang][Sema] Implement GCC -Wcast-function-type

2021-03-08 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

ping?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97831

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


[PATCH] D89986: [AIX] do not emit visibility attribute into IR when there is -mignore-xcoff-visibility

2021-03-08 Thread Sean Fertile via Phabricator via cfe-commits
sfertile accepted this revision.
sfertile added a subscriber: Xiangling_L.
sfertile added a comment.

> discussed with sean offline, the we do not call the 
> emitGlobalDtorWithCXAAtExit() in AIX. so we do not have the problem for the 
> "__dso_handle"

I initially had concerns with the places clang introduces non-default 
visibility in codegen. The few cases I was worried we would hit were related to 
static init , but that was before @Xiangling_L static init related work.   
After those changes I have no other concerns. I would wait a day or two to 
ensure that there are no more comments  related to the round-trip-args 
behaviour but otherwise LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89986

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


[PATCH] D96280: [clang][cli] Round-trip the whole CompilerInvocation

2021-03-08 Thread Alan Phipps via Phabricator via cfe-commits
alanphipps added a comment.

We also encounter a build failure on the Mac related to above but in a 
different file:
clang/lib/CodeGen/CGStmtOpenMP.cpp:1916:3: error: too few template arguments 
for class template 'SmallVector'
SmallVector EffectiveArgs;
^
clang/include/clang/Basic/LLVM.h:35:42: note: template is declared here
template class SmallVector;


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96280

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


[PATCH] D98030: [IR] Add vscale_range IR function attribute

2021-03-08 Thread Peter Waller via Phabricator via cfe-commits
peterwaller-arm added inline comments.



Comment at: llvm/lib/IR/Attributes.cpp:570
+Result += utostr(MinValue);
+Result += ',';
+Result += utostr(MaxValue);

Nit: The only other precedent I can see for this is `allocsize`. Grepping the 
code I found this is always written in tests as `allocsize(x, y)`, however, it 
prints as `allocsize(x,y)` (no space) when done with `-emit-llvm`, regardless 
of how it was formatted as input. I figure that is an oversight and this should 
have the space.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98030

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


[PATCH] D91281: [CUDA][HIP] Diagnose reference of host variable

2021-03-08 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D91281#2609766 , @yaxunl wrote:

> In D91281#2607082 , @yaxunl wrote:
>
>> @tra I got some issue with this patch. There are cases that an expression 
>> using a host variable is compile-time constant, e.g.
>>
>>   int x;
>>   __device__ void fun() {
>> sizeof(x);
>>   }
>>
>> Do we want to allow that? Thanks.
>
> It seems we should only diagnose ODR-use 
> (https://en.cppreference.com/w/cpp/language/definition) of host variable in 
> device functions.

Fix in https://reviews.llvm.org/D98193


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91281

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


[PATCH] D98193: [CUDA][HIP] Allow non-ODR use of host var in device

2021-03-08 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added a reviewer: tra.
yaxunl requested review of this revision.

https://reviews.llvm.org/D98193

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaCUDA/device-use-host-var.cu

Index: clang/test/SemaCUDA/device-use-host-var.cu
===
--- clang/test/SemaCUDA/device-use-host-var.cu
+++ clang/test/SemaCUDA/device-use-host-var.cu
@@ -5,6 +5,11 @@
 
 #include "Inputs/cuda.h"
 
+struct A {
+  int x;
+  A() {}
+};
+
 int global_host_var;
 __device__ int global_dev_var;
 __constant__ int global_constant_var;
@@ -12,6 +17,9 @@
 constexpr int global_constexpr_var = 1;
 const int global_const_var = 1;
 
+A global_host_struct_var;
+const A global_const_struct_var;
+
 template
 __global__ void kernel(F f) { f(); } // dev-note2 {{called by 'kernel<(lambda}}
 
@@ -24,11 +32,13 @@
   const int _const_var = global_const_var;
 
   *out = global_host_var; // dev-error {{reference to __host__ variable 'global_host_var' in __device__ function}}
+  *out = global_host_struct_var.x; // dev-error {{reference to __host__ variable 'global_host_struct_var' in __device__ function}}
   *out = global_dev_var;
   *out = global_constant_var;
   *out = global_shared_var;
   *out = global_constexpr_var;
   *out = global_const_var;
+  *out = global_const_struct_var.x;
 
   *out = ref_host_var;
   *out = ref_dev_var;
@@ -36,6 +46,12 @@
   *out = ref_shared_var;
   *out = ref_constexpr_var;
   *out = ref_const_var;
+ 
+  // Check non-ODR use of host varirables are allowed. 
+  *out = sizeof(global_host_var);
+  *out = sizeof(global_host_struct_var.x);
+  decltype(global_host_var) var1;
+  decltype(global_host_struct_var.x) var2;
 }
 
 __global__ void global_fun(int *out) {
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -354,24 +354,6 @@
 
   diagnoseUseOfInternalDeclInInlineFunction(*this, D, Loc);
 
-  // CUDA/HIP: Diagnose invalid references of host global variables in device
-  // functions. Reference of device global variables in host functions is
-  // allowed through shadow variables therefore it is not diagnosed.
-  if (LangOpts.CUDAIsDevice) {
-auto *FD = dyn_cast_or_null(CurContext);
-auto Target = IdentifyCUDATarget(FD);
-if (FD && Target != CFT_Host) {
-  const auto *VD = dyn_cast(D);
-  if (VD && VD->hasGlobalStorage() && !VD->hasAttr() &&
-  !VD->hasAttr() && !VD->hasAttr() &&
-  !VD->getType()->isCUDADeviceBuiltinSurfaceType() &&
-  !VD->getType()->isCUDADeviceBuiltinTextureType() &&
-  !VD->isConstexpr() && !VD->getType().isConstQualified())
-targetDiag(*Locs.begin(), diag::err_ref_bad_target)
-<< /*host*/ 2 << /*variable*/ 1 << VD << Target;
-}
-  }
-
   if (LangOpts.SYCLIsDevice || (LangOpts.OpenMP && LangOpts.OpenMPIsDevice)) {
 if (auto *VD = dyn_cast(D))
   checkDeviceDecl(VD, Loc);
@@ -18284,6 +18266,24 @@
 }
 break;
   }
+
+  // CUDA/HIP: Diagnose invalid references of host global variables in device
+  // functions. Reference of device global variables in host functions is
+  // allowed through shadow variables therefore it is not diagnosed.
+  if (SemaRef.LangOpts.CUDAIsDevice) {
+auto *FD = dyn_cast_or_null(SemaRef.CurContext);
+auto Target = SemaRef.IdentifyCUDATarget(FD);
+if (FD && Target != Sema::CFT_Host) {
+  if (Var && Var->hasGlobalStorage() && !Var->hasAttr() &&
+  !Var->hasAttr() &&
+  !Var->hasAttr() &&
+  !Var->getType()->isCUDADeviceBuiltinSurfaceType() &&
+  !Var->getType()->isCUDADeviceBuiltinTextureType() &&
+  !Var->isConstexpr() && !Var->getType().isConstQualified())
+SemaRef.targetDiag(Loc, diag::err_ref_bad_target)
+<< /*host*/ 2 << /*variable*/ 1 << Var << Target;
+}
+  }
 }
 
 /// Mark a variable referenced, and check whether it is odr-used
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D98191: [flang][driver] Add support for `-fdebug-dump-symbols-sources`

2021-03-08 Thread Arnamoy B via Phabricator via cfe-commits
arnamoy10 added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98191

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


[PATCH] D97960: [clang-tidy] bugprone-signal-handler improvements: display call chain

2021-03-08 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

I think call stack may be useful for other checks too. May be code should be 
moved to utilities?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97960

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


[PATCH] D98191: [flang][driver] Add support for `-fdebug-dump-symbols-sources`

2021-03-08 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski created this revision.
Herald added a reviewer: sscalpone.
Herald added subscribers: jansvoboda11, dang.
awarzynski requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Note that the original spelling in `f18` is `-fget-symbols-sources`. The
new driver will only support the new spelling, which is also added to
`f18` as an alias for the existing one.

Tests are updated to use the new spelling and to use `%flang_fc1`
instead of `%f18`. This way both the new and the current driver are
tested.

As:

- both `-fsyntax-only` and `-fdebug-dump-symbols-sources` are action flags, and
- the new driver will only consider the right-most action flag,

`RUN` lines in tests are updated so that the tests work with both
`f18` (requires both flags) and `flang-new` (only considers the last
action flag).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98191

Files:
  clang/include/clang/Driver/Options.td
  flang/include/flang/Frontend/FrontendActions.h
  flang/include/flang/Frontend/FrontendOptions.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  flang/test/Flang-Driver/driver-help.f90
  flang/test/Semantics/getsymbols01.f90
  flang/test/Semantics/getsymbols02.f90
  flang/test/Semantics/getsymbols03-a.f90
  flang/test/Semantics/getsymbols04.f90
  flang/test/Semantics/getsymbols05.f90
  flang/tools/f18/f18.cpp

Index: flang/tools/f18/f18.cpp
===
--- flang/tools/f18/f18.cpp
+++ flang/tools/f18/f18.cpp
@@ -628,7 +628,8 @@
 args.pop_front();
   }
   driver.getDefinitionArgs = {arguments[0], arguments[1], arguments[2]};
-} else if (arg == "-fget-symbols-sources") {
+} else if (arg == "-fget-symbols-sources" ||
+arg == "-fdebug-dump-symbols-sources") {
   driver.getSymbolsSources = true;
 } else if (arg == "-byteswapio") {
   driver.byteswapio = true; // TODO: Pass to lowering, generate call
Index: flang/test/Semantics/getsymbols05.f90
===
--- flang/test/Semantics/getsymbols05.f90
+++ flang/test/Semantics/getsymbols05.f90
@@ -9,7 +9,7 @@
   x = y
 end program
 
-! RUN: %f18 -fget-symbols-sources -fsyntax-only %s 2>&1 | FileCheck %s
+! RUN: %flang_fc1 -fsyntax-only -fdebug-dump-symbols-sources %s 2>&1 | FileCheck %s
 ! CHECK:x:{{.*}}getsymbols05.f90, 3, 14-15
 ! CHECK:x:{{.*}}getsymbols05.f90, 6, 16-17
 ! CHECK:y:{{.*}}getsymbols05.f90, 4, 14-15
Index: flang/test/Semantics/getsymbols04.f90
===
--- flang/test/Semantics/getsymbols04.f90
+++ flang/test/Semantics/getsymbols04.f90
@@ -6,7 +6,7 @@
   x = y
 end program
 
-! RUN: %f18 -fget-symbols-sources -fsyntax-only %s 2>&1 | FileCheck %s
+! RUN: %flang_fc1 -fsyntax-only -fdebug-dump-symbols-sources %s 2>&1 | FileCheck %s
 ! CHECK:x:{{.*}}getsymbols04.f90, 3, 14-15
 ! CHECK:x:{{.*}}getsymbols04.f90, 5, 11-12
 ! CHECK:y:{{.*}}getsymbols04.f90, 4, 14-15
Index: flang/test/Semantics/getsymbols03-a.f90
===
--- flang/test/Semantics/getsymbols03-a.f90
+++ flang/test/Semantics/getsymbols03-a.f90
@@ -7,7 +7,7 @@
  x = f
 end program
 
-! RUN: %f18 -fget-symbols-sources -fsyntax-only %s 2>&1 | FileCheck %s
+! RUN: %flang_fc1 -fsyntax-only -fdebug-dump-symbols-sources %s 2>&1 | FileCheck %s
 ! CHECK:f:{{.*}}getsymbols03-b.f90, 2, 12-13
 ! CHECK:main:{{.*}}getsymbols03-a.f90, 4, 9-13
 ! CHECK:mm3:{{.*}}getsymbols03-a.f90, 5, 6-9
Index: flang/test/Semantics/getsymbols02.f90
===
--- flang/test/Semantics/getsymbols02.f90
+++ flang/test/Semantics/getsymbols02.f90
@@ -7,8 +7,8 @@
 i = callget5()
 ENDPROGRAM
 
-! RUN: %f18 -fsyntax-only %S/Inputs/getsymbols02-a.f90
-! RUN: %f18 -fsyntax-only %S/Inputs/getsymbols02-b.f90
-! RUN: %f18 -fget-symbols-sources -fsyntax-only %s 2>&1 | FileCheck %s
+! RUN: %flang_fc1 -fsyntax-only %S/Inputs/getsymbols02-a.f90
+! RUN: %flang_fc1 -fsyntax-only %S/Inputs/getsymbols02-b.f90
+! RUN: %flang_fc1 -fsyntax-only -fdebug-dump-symbols-sources %s 2>&1 | FileCheck %s
 ! CHECK: callget5: .{{[/\\]}}mm2b.mod,
 ! CHECK: get5: .{{[/\\]}}mm2a.mod,
Index: flang/test/Semantics/getsymbols01.f90
===
--- flang/test/Semantics/getsymbols01.f90
+++ flang/test/Semantics/getsymbols01.f90
@@ -15,7 +15,7 @@
  end function
 end module
 
-! RUN: %f18 -fget-symbols-sources -fsyntax-only %s 2>&1 | FileCheck %s
+! RUN: %flang_fc1 -fsyntax-only -fdebug-dump-symbols-sources %s 2>&1 | FileCheck %s
 ! CHECK-COUNT-1:f:{{.*}}getsymbols01.f90, 12, 26-27
 ! CHECK-COUNT-1:mm1:{{.*}}getsymbols01.f90, 2, 8-11
 ! CHECK-COUNT-1:s:{{.*}}getsymbols01.f90, 5, 18-19
Index: flang/test/Flang-Driver/driver-help.f90

[PATCH] D97198: [OpenMP][Clang][NVPTX] Only build one bitcode library for each SM

2021-03-08 Thread Shilei Tian via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc41ae246ac67: [OpenMP][Clang][NVPTX] Only build one bitcode 
library for each SM (authored by tianshilei1992).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97198

Files:
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/test/Driver/Inputs/libomptarget/libomptarget-nvptx-cuda_102-sm_35.bc
  clang/test/Driver/Inputs/libomptarget/libomptarget-nvptx-sm_35.bc
  clang/test/Driver/openmp-offload-gpu.c
  openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt
  openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.cu

Index: openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.cu
===
--- openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.cu
+++ openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.cu
@@ -53,46 +53,28 @@
   return (double)nsecs * __kmpc_impl_get_wtick();
 }
 
-// In Cuda 9.0, __ballot(1) from Cuda 8.0 is replaced with __activemask().
 DEVICE __kmpc_impl_lanemask_t __kmpc_impl_activemask() {
-#if CUDA_VERSION < 9020
-  return __nvvm_vote_ballot(1);
-#else
   unsigned int Mask;
   asm volatile("activemask.b32 %0;" : "=r"(Mask));
   return Mask;
-#endif
 }
 
-// In Cuda 9.0, the *_sync() version takes an extra argument 'mask'.
 DEVICE int32_t __kmpc_impl_shfl_sync(__kmpc_impl_lanemask_t Mask, int32_t Var,
  int32_t SrcLane) {
-#if CUDA_VERSION >= 9000
   return __nvvm_shfl_sync_idx_i32(Mask, Var, SrcLane, 0x1f);
-#else
-  return __nvvm_shfl_idx_i32(Var, SrcLane, 0x1f);
-#endif // CUDA_VERSION
 }
 
 DEVICE int32_t __kmpc_impl_shfl_down_sync(__kmpc_impl_lanemask_t Mask,
   int32_t Var, uint32_t Delta,
   int32_t Width) {
   int32_t T = ((WARPSIZE - Width) << 8) | 0x1f;
-#if CUDA_VERSION >= 9000
   return __nvvm_shfl_sync_down_i32(Mask, Var, Delta, T);
-#else
-  return __nvvm_shfl_down_i32(Var, Delta, T);
-#endif // CUDA_VERSION
 }
 
 DEVICE void __kmpc_impl_syncthreads() { __syncthreads(); }
 
 DEVICE void __kmpc_impl_syncwarp(__kmpc_impl_lanemask_t Mask) {
-#if CUDA_VERSION >= 9000
   __nvvm_bar_warp_sync(Mask);
-#else
-  // In Cuda < 9.0 no need to sync threads in warps.
-#endif // CUDA_VERSION
 }
 
 // NVPTX specific kernel initialization
Index: openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt
===
--- openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt
+++ openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt
@@ -137,6 +137,7 @@
  -Xclang -emit-llvm-bc
  -Xclang -aux-triple -Xclang ${aux_triple}
  -fopenmp -fopenmp-cuda-mode -Xclang -fopenmp-is-device
+ -Xclang -target-feature -Xclang +ptx61
  -D__CUDACC__
  -I${devicertl_base_directory}
  -I${devicertl_nvptx_directory}/src)
@@ -150,81 +151,51 @@
 # Create target to build all Bitcode libraries.
 add_custom_target(omptarget-nvptx-bc)
 
-# This map is from clang/lib/Driver/ToolChains/Cuda.cpp.
-# The last element is the default case.
-set(cuda_version_list 112 111 110 102 101 100 92 91 90 80)
-set(ptx_feature_list 70 70 70 65 64 63 61 61 60 42)
-# The following two lines of ugly code is not needed when the minimal CMake
-# version requirement is 3.17+.
-list(LENGTH cuda_version_list num_version_supported)
-math(EXPR loop_range "${num_version_supported} - 1")
-
-# Generate a Bitcode library for all the compute capabilities the user
-# requested and all PTX version we know for now.
+# Generate a Bitcode library for all the compute capabilities the user requested
 foreach(sm ${nvptx_sm_list})
-  set(sm_flags -Xclang -target-cpu -Xclang sm_${sm} "-D__CUDA_ARCH__=${sm}0")
-
-  # Uncomment the following code and remove those ugly part if the feature
-  # is available.
-  # foreach(cuda_version ptx_num IN ZIP_LISTS cuda_version_list ptx_feature_list)
-  foreach(itr RANGE ${loop_range})
-list(GET cuda_version_list ${itr} cuda_version)
-list(GET ptx_feature_list ${itr} ptx_num)
-set(cuda_flags ${sm_flags})
-list(APPEND cuda_flags -Xclang -target-feature -Xclang +ptx${ptx_num})
-if("${cuda_version}" MATCHES "^([0-9]+)([0-9])$")
-  set(cuda_version_major ${CMAKE_MATCH_1})
-  set(cuda_version_minor ${CMAKE_MATCH_2})
-else()
-  libomptarget_error_say(
-"Unrecognized CUDA version format: ${cuda_version}")
-endif()
-list(APPEND cuda_flags
-  "-DCUDA_VERSION=${cuda_version_major}0${cuda_version_minor}0")
-
-set(bc_files "")
-foreach(src ${cuda_src_files})
-  get_filename_component(infile ${src} ABSOLUTE)
-  get_filename_component(outfile ${src} NAME)
-  set(outfile "${outfile}-cuda_${cuda_version}-sm_${sm}.bc")
-
-  add_custom_command(OUTPUT 

[clang] c41ae24 - [OpenMP][Clang][NVPTX] Only build one bitcode library for each SM

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

Author: Shilei Tian
Date: 2021-03-08T12:03:04-05:00
New Revision: c41ae246ac673e97ec1abdc2b9cbe1989f8682fe

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

LOG: [OpenMP][Clang][NVPTX] Only build one bitcode library for each SM

In D97003, CUDA 9.2 is the minimum requirement for OpenMP offloading on
NVPTX target. We don't need to have macros in source code to select right 
functions
based on CUDA version. we don't need to compile multiple bitcode libraries of
different CUDA versions for each SM. We don't need to worry about future
compatibility with newer CUDA version.

`-target-feature +ptx61` is used in this patch, which corresponds to the highest
PTX version that CUDA 9.2 can support.

Reviewed By: jdoerfert

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

Added: 
clang/test/Driver/Inputs/libomptarget/libomptarget-nvptx-sm_35.bc

Modified: 
clang/lib/Driver/ToolChains/Cuda.cpp
clang/test/Driver/openmp-offload-gpu.c
openmp/libomptarget/deviceRTLs/nvptx/CMakeLists.txt
openmp/libomptarget/deviceRTLs/nvptx/src/target_impl.cu

Removed: 
clang/test/Driver/Inputs/libomptarget/libomptarget-nvptx-cuda_102-sm_35.bc



diff  --git a/clang/lib/Driver/ToolChains/Cuda.cpp 
b/clang/lib/Driver/ToolChains/Cuda.cpp
index ce7a46921be5..de47c82d73de 100644
--- a/clang/lib/Driver/ToolChains/Cuda.cpp
+++ b/clang/lib/Driver/ToolChains/Cuda.cpp
@@ -711,7 +711,6 @@ void CudaToolChain::addClangTargetOptions(
   CC1Args.push_back(DriverArgs.MakeArgString(LibDeviceFile));
 
   clang::CudaVersion CudaInstallationVersion = CudaInstallation.version();
-  std::string CudaVersionStr;
 
   // New CUDA versions often introduce new instructions that are only supported
   // by new PTX version, so we need to raise PTX level to enable them in NVPTX
@@ -720,7 +719,6 @@ void CudaToolChain::addClangTargetOptions(
   switch (CudaInstallationVersion) {
 #define CASE_CUDA_VERSION(CUDA_VER, PTX_VER)   
\
   case CudaVersion::CUDA_##CUDA_VER:   
\
-CudaVersionStr = #CUDA_VER;
\
 PtxFeature = "+ptx" #PTX_VER;  
\
 break;
 CASE_CUDA_VERSION(112, 72);
@@ -734,9 +732,6 @@ void CudaToolChain::addClangTargetOptions(
 CASE_CUDA_VERSION(90, 60);
 #undef CASE_CUDA_VERSION
   default:
-// If unknown CUDA version, we take it as CUDA 8.0. Same assumption is also
-// made in libomptarget/deviceRTLs.
-CudaVersionStr = "80";
 PtxFeature = "+ptx42";
   }
   CC1Args.append({"-target-feature", PtxFeature});
@@ -757,8 +752,7 @@ void CudaToolChain::addClangTargetOptions(
   return;
 }
 
-std::string BitcodeSuffix =
-"nvptx-cuda_" + CudaVersionStr + "-" + GpuArch.str();
+std::string BitcodeSuffix = "nvptx-" + GpuArch.str();
 addOpenMPDeviceRTL(getDriver(), DriverArgs, CC1Args, BitcodeSuffix,
getTriple());
   }

diff  --git 
a/clang/test/Driver/Inputs/libomptarget/libomptarget-nvptx-cuda_102-sm_35.bc 
b/clang/test/Driver/Inputs/libomptarget/libomptarget-nvptx-sm_35.bc
similarity index 100%
rename from 
clang/test/Driver/Inputs/libomptarget/libomptarget-nvptx-cuda_102-sm_35.bc
rename to clang/test/Driver/Inputs/libomptarget/libomptarget-nvptx-sm_35.bc

diff  --git a/clang/test/Driver/openmp-offload-gpu.c 
b/clang/test/Driver/openmp-offload-gpu.c
index f8f063503a9e..5537c4d78682 100644
--- a/clang/test/Driver/openmp-offload-gpu.c
+++ b/clang/test/Driver/openmp-offload-gpu.c
@@ -164,7 +164,7 @@
 // RUN:   -fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 
2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-BCLIB-USER %s
 
-// CHK-BCLIB: 
clang{{.*}}-triple{{.*}}nvptx64-nvidia-cuda{{.*}}-mlink-builtin-bitcode{{.*}}libomptarget-nvptx-cuda_102-sm_35.bc
+// CHK-BCLIB: 
clang{{.*}}-triple{{.*}}nvptx64-nvidia-cuda{{.*}}-mlink-builtin-bitcode{{.*}}libomptarget-nvptx-sm_35.bc
 // CHK-BCLIB-USER: 
clang{{.*}}-triple{{.*}}nvptx64-nvidia-cuda{{.*}}-mlink-builtin-bitcode{{.*}}libomptarget-nvptx-test.bc
 // CHK-BCLIB-NOT: {{error:|warning:}}
 
@@ -177,7 +177,7 @@
 // RUN:   -fopenmp-relocatable-target -save-temps -no-canonical-prefixes %s 
2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-BCLIB-WARN %s
 
-// CHK-BCLIB-WARN: No library 'libomptarget-nvptx-cuda_102-sm_35.bc' found in 
the default clang lib directory or in LIBRARY_PATH. Please use 
--libomptarget-nvptx-bc-path to specify nvptx bitcode library.
+// CHK-BCLIB-WARN: No library 'libomptarget-nvptx-sm_35.bc' found in the 
default clang lib directory or in LIBRARY_PATH. Please use 
--libomptarget-nvptx-bc-path to specify nvptx bitcode library.
 
 /// 

[PATCH] D94554: [clangd] Add a Filesystem that overlays Dirty files.

2021-03-08 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Thanks, LG!




Comment at: clang-tools-extra/clangd/ClangdServer.h:389
+
+  class DirtyFS : public ThreadsafeFS {
+  public:

njames93 wrote:
> Probably needs moving to its own place, but wasn't sure where best to put it.
I think ClangdServer is fine, but this can be a unique_ptr with 
the class moved to the implementation file



Comment at: clang-tools-extra/clangd/DraftStore.cpp:80
 
-  Draft  = Drafts[File];
-  updateVersion(D, Version);
-  D.Contents = Contents.str();
-  return D.Version;
+  auto Res = Drafts.try_emplace(File);
+  auto  = Res.first->getValue();

we don't need try_emplace here, we overwrite the whole value regardless.
Can we use `Draft  = Drafts[File]` again?



Comment at: clang-tools-extra/clangd/DraftStore.cpp:83
+  updateVersion(D.Draft, Version);
+  time();
+  D.Draft.Contents = std::make_shared(Contents);

nit: std::time() (and std::time_t)



Comment at: clang-tools-extra/clangd/DraftStore.cpp:113
+MemoryBuffer::init(BufferContents->c_str(),
+   BufferContents->c_str() + BufferContents->size(), true);
+  }

nit: /*RequiresNullTerminator=*/


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94554

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


[PATCH] D98113: [Driver] Also search FilePaths for compiler-rt before falling back

2021-03-08 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added a comment.

In D98113#2610775 , @abidh wrote:

> In D98113#2609027 , @jrtc27 wrote:
>
>> One thing that is currently rather ugly about BareMetal is that it ignores 
>> the AddArch argument. Once you have a sysroot, the architecture suffix is 
>> rather unnecessary, and given compiler-rt uses 
>> LLVM_ENABLE_PER_TARGET_RUNTIME_DIR to decide both whether to add a suffix 
>> and whether to add `lib/${OS}` to the install path, that means you can't 
>> nicely point compiler-rt at the sysroot as the install directory (well, 
>> unless you do something like make COMPILER_RT_OUTPUT_DIR point at the 
>> sysroot not the libdir and set COMPILER_RT_OS_DIR to `.` (or maybe the empty 
>> string also works)).
>
> Agree that setting the compiler-rt installation directory is not ideal. I 
> remember I ended up doing some post installation steps to make sure that 
> libraries were in right folder.
>
> Regarding this patch, currently Baremetal toolchain looks for compiler-rt in 
> a multilib specific directory. Does that not solve the problem of finding 
> compiler-rt for any given arch/abi combination automatically?

So, technically yes for RISC-V I believe we can do that. However that support 
code only really exists for RISC-V, and we have other architectures too we need 
to extend. This approach is entirely general with no lists of arch-specific 
combinations needed, and far more flexible. I also believe that conceptually 
compiler-rt does belong in the sysroot, not with the compiler. The 
libgcc-with-gcc model kind of makes sense for GCC given you have to configure 
GCC for a specific architecture, but for Clang there is no such coupling. This 
allows you to, say, use a system-provided Clang with your own bare-metal 
sysroot (not that that's our use-case, but it's a sensible one). The other way 
to see that compiler-rt doesn't really belong with the compiler is to look at 
the bootstrapping process: compiler-rt depends on a libc, typically newlib, 
which then depends on your compiler. So you have to build Clang, then build 
newlib, then go back and build compiler-rt to add it to your Clang. That gets 
rather annoying to manage in CI jobs.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98113

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


[PATCH] D96975: [Sema] Add some basic lambda capture fix-its

2021-03-08 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:17489
+  : false;
+// We can't use default capture by copy if any captures already specified
+// capture by copy.

njames93 wrote:
> sammccall wrote:
> > While it's technically possible to transform `[, ]` to `[=, , ]`, 
> > it seems very unlikely the user actually wants this: we should capture the 
> > new variable by copy and make that the default, even though so far we've 
> > been listing captures explicitly and by reference.
> > 
> > On the other hand, transforming `[a, b]` to `[=]` seems more useful, but 
> > isn't supported.
> > 
> > I'd suggest just leaving both cases out - only offer a default capture if 
> > there are no explicit captures already.
> Transforming `[a, b]` to `[=]` is not a good idea imo. We would be replacing 
> perfectly legal, non ambiguous code.
> 
> The reason default capture fix-its are emitted last is because more often 
> than not they wont be the users intentions, however It's still nice to show 
> that it is a possibility.
> 
> 
I don't think fixits are for surfacing code transformations that are unlikely 
to be what the user wants.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96975

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


[PATCH] D96975: [Sema] Add some basic lambda capture fix-its

2021-03-08 Thread Nathan James via Phabricator via cfe-commits
njames93 added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:17444
+if (CXXRecordDecl *RD = T->getAsCXXRecordDecl()) {
+  if (RD->hasSimpleCopyConstructor())
+return true;

sammccall wrote:
> I suspect you need to handle the case where RD is incomplete
I thought that could be skipped, but yeah you're right you could have a lambda 
parameter be an incomplete type if you're only referencing it.



Comment at: clang/lib/Sema/SemaExpr.cpp:17489
+  : false;
+// We can't use default capture by copy if any captures already specified
+// capture by copy.

sammccall wrote:
> While it's technically possible to transform `[, ]` to `[=, , ]`, it 
> seems very unlikely the user actually wants this: we should capture the new 
> variable by copy and make that the default, even though so far we've been 
> listing captures explicitly and by reference.
> 
> On the other hand, transforming `[a, b]` to `[=]` seems more useful, but 
> isn't supported.
> 
> I'd suggest just leaving both cases out - only offer a default capture if 
> there are no explicit captures already.
Transforming `[a, b]` to `[=]` is not a good idea imo. We would be replacing 
perfectly legal, non ambiguous code.

The reason default capture fix-its are emitted last is because more often than 
not they wont be the users intentions, however It's still nice to show that it 
is a possibility.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96975

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


[PATCH] D97068: Run non-filechecked commands in update_cc_test_checks.py

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

Looks like this breaks tests on mac: http://45.33.8.238/macm1/5075/step_6.txt

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97068

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


[PATCH] D97960: [clang-tidy] bugprone-signal-handler improvements: display call chain

2021-03-08 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 329017.
balazske added a comment.

Adding test of notes.
Tests are re-arranged significantly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97960

Files:
  clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.h
  clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-handler-minimal.c
  clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-handler-posix.c
  clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-handler.c
  clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-handler.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-handler.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-handler.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-handler.cpp
@@ -11,132 +11,198 @@
 void signal(int, callback_t);
 }
 
-struct S {
+struct Signal {
   static void signal(int, callback_t);
-  static void handler(int);
+};
 
-  S() = default;
-  S(int) {
-std::other_call();
-// Should be fixed.
-// CHECK-MESSAGES-NOT: :[[@LINE-2]]:5: warning: 'other_call' may not be asynchronous-safe; calling it from a signal handler may be dangerous [bugprone-signal-handler]
-  };
+
+
+struct S_operator {
   int operator-() const {
 std::other_call();
-// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'other_call' may not be asynchronous-safe; calling it from a signal handler may be dangerous [bugprone-signal-handler]
+// CHECK-NOTES: :[[@LINE-1]]:5: warning: system call 'other_call' may not be asynchronous-safe; calling it from a signal handler may be dangerous [bugprone-signal-handler]
+// CHECK-NOTES: :[[@LINE-2]]:5: note: function 'other_call' called here from 'operator-'
+// CHECK-NOTES: :[[@LINE+7]]:3: note: function 'operator-' called here from 'handler_operator'
+// CHECK-NOTES: :[[@LINE+10]]:23: note: function 'handler_operator' registered here as signal handler
   }
 };
 
-struct TestMemberInit {
+extern "C" void handler_operator(int) {
+  S_operator S;
+  -S;
+}
+
+void test_operator() {
+  std::signal(SIGINT, handler_operator);
+}
+
+
+
+struct S_constructor {
+  S_constructor() = default;
+  S_constructor(int) {
+std::other_call();
+// Should be fixed.
+// CHECK-NOTES-NOT: :[[@LINE-2]]:5: warning: system call 'other_call' may not be asynchronous-safe; calling it from a signal handler may be dangerous [bugprone-signal-handler]
+  };
+};
+
+extern "C" void handler_constructor(int) {
+  S_constructor S(0);
+}
+
+void test_constructor() {
+  std::signal(SIGINT, handler_constructor);
+}
+
+
+
+struct S_MemberInit {
   static int memberInit() {
 std::other_call();
 // Should be fixed.
-// CHECK-MESSAGES-NOT: :[[@LINE-2]]:5: warning: 'other_call' may not be asynchronous-safe; calling it from a signal handler may be dangerous [bugprone-signal-handler]
+// CHECK-NOTES-NOT: :[[@LINE-2]]:5: warning: system call 'other_call' may not be asynchronous-safe; calling it from a signal handler may be dangerous [bugprone-signal-handler]
   }
   int M = memberInit();
 };
 
+extern "C" void handler_MemberInit(int) {
+  S_MemberInit S;
+}
+
+void test_MemberInit() {
+  std::signal(SIGINT, handler_MemberInit);
+}
+
+
+
 int defaultInit() {
   std::other_call();
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'other_call' may not be asynchronous-safe; calling it from a signal handler may be dangerous [bugprone-signal-handler]
+  // CHECK-NOTES: :[[@LINE-1]]:3: warning: system call 'other_call' may not be asynchronous-safe; calling it from a signal handler may be dangerous [bugprone-signal-handler]
+  // CHECK-NOTES: :[[@LINE-2]]:3: note: function 'other_call' called here from 'defaultInit'
+  // CHECK-NOTES: :[[@LINE+4]]:30: note: function 'defaultInit' called here from 'handler_DefaultInit'
+  // CHECK-NOTES: :[[@LINE+11]]:23: note: function 'handler_DefaultInit' registered here as signal handler
 }
 
-void testDefaultInit(int I = defaultInit()) {
+void callDefaultInit(int I = defaultInit()) {
 }
 
-void S::handler(int) {
+extern "C" void handler_DefaultInit(int) {
+  callDefaultInit();
+}
+
+void test_DefaultInit() {
+  std::signal(SIGINT, handler_DefaultInit);
+}
+
+
+
+extern "C" void handler_UnsafeFunction(int) {
   std::other_call();
+  // CHECK-NOTES: :[[@LINE-1]]:3: warning: system call 'other_call' may not be asynchronous-safe; calling it from a signal handler may be dangerous [bugprone-signal-handler]
+  // CHECK-NOTES: :[[@LINE-2]]:3: note: function 'other_call' called here from 'handler_UnsafeFunction'
+  // CHECK-NOTES: :[[@LINE+4]]:23: note: function 'handler_UnsafeFunction' registered here as signal handler
 }
 
-extern "C" {
+void test_UnsafeFunction() {
+  std::signal(SIGINT, handler_UnsafeFunction);
+}
 
-void handler_abort(int) {
-  

[PATCH] D95458: [PowerPC] Exploit xxsplti32dx (constant materialization) for scalars

2021-03-08 Thread Albion Fung via Phabricator via cfe-commits
Conanap updated this revision to Diff 329015.
Conanap marked 3 inline comments as done.
Conanap added a comment.

Updated some comments.


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

https://reviews.llvm.org/D95458

Files:
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/lib/Target/PowerPC/PPCISelLowering.h
  llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
  llvm/lib/Target/PowerPC/PPCInstrInfo.td
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/test/CodeGen/PowerPC/constant-pool.ll
  llvm/test/CodeGen/PowerPC/p10-splatImm-CPload-pcrel.ll
  llvm/test/CodeGen/PowerPC/pcrel-call-linkage-leaf.ll
  llvm/test/CodeGen/PowerPC/pcrel-linkeropt.ll
  llvm/test/CodeGen/PowerPC/pcrel.ll

Index: llvm/test/CodeGen/PowerPC/pcrel.ll
===
--- llvm/test/CodeGen/PowerPC/pcrel.ll
+++ llvm/test/CodeGen/PowerPC/pcrel.ll
@@ -8,13 +8,14 @@
 
 ; Constant Pool Index.
 ; CHECK-S-LABEL: ConstPool
-; CHECK-S:   plfd f1, .LCPI0_0@PCREL(0), 1
+; CHECK-S:   xxsplti32dx vs1, 0, 1081002676
+; CHECK-S-NEXT:   xxsplti32dx vs1, 1, 962072674
 ; CHECK-S:   blr
 
 ; CHECK-O-LABEL: ConstPool
-; CHECK-O:   plfd 1, 0(0), 1
-; CHECK-O-NEXT:  R_PPC64_PCREL34  .rodata.cst8
-; CHECK-O:   blr
+; CHECK-O:   xxsplti32dx 1, 0, 1081002676
+; CHECK-O-NEXT:  xxsplti32dx 1, 1, 962072674
+; CHECK-O-NEXT:  blr
 define dso_local double @ConstPool() local_unnamed_addr {
   entry:
 ret double 0x406ECAB439581062
Index: llvm/test/CodeGen/PowerPC/pcrel-linkeropt.ll
===
--- llvm/test/CodeGen/PowerPC/pcrel-linkeropt.ll
+++ llvm/test/CodeGen/PowerPC/pcrel-linkeropt.ll
@@ -35,6 +35,9 @@
 @FuncPtrOut = external local_unnamed_addr global void (...)*, align 8
 
 define dso_local void @ReadWrite8() local_unnamed_addr #0 {
+; In this test the stb r3, 0(r4) cannot be optimized because it
+; uses the register r3 and that register is defined by lbz r3, 0(r3)
+; which is defined between the pld and the stb.
 ; CHECK-LABEL: ReadWrite8:
 ; CHECK:   # %bb.0: # %entry
 ; CHECK-NEXT:pld r3, input8@got@pcrel(0), 1
@@ -44,9 +47,6 @@
 ; CHECK-NEXT:lbz r3, 0(r3)
 ; CHECK-NEXT:stb r3, 0(r4)
 ; CHECK-NEXT:blr
-; In this test the stb r3, 0(r4) cannot be optimized because it
-; uses the register r3 and that register is defined by lbz r3, 0(r3)
-; which is defined between the pld and the stb.
 entry:
   %0 = load i8, i8* @input8, align 1
   store i8 %0, i8* @output8, align 1
@@ -54,6 +54,9 @@
 }
 
 define dso_local void @ReadWrite16() local_unnamed_addr #0 {
+; In this test the sth r3, 0(r4) cannot be optimized because it
+; uses the register r3 and that register is defined by lhz r3, 0(r3)
+; which is defined between the pld and the sth.
 ; CHECK-LABEL: ReadWrite16:
 ; CHECK:   # %bb.0: # %entry
 ; CHECK-NEXT:pld r3, input16@got@pcrel(0), 1
@@ -63,9 +66,6 @@
 ; CHECK-NEXT:lhz r3, 0(r3)
 ; CHECK-NEXT:sth r3, 0(r4)
 ; CHECK-NEXT:blr
-; In this test the sth r3, 0(r4) cannot be optimized because it
-; uses the register r3 and that register is defined by lhz r3, 0(r3)
-; which is defined between the pld and the sth.
 entry:
   %0 = load i16, i16* @input16, align 2
   store i16 %0, i16* @output16, align 2
@@ -144,7 +144,8 @@
 ; CHECK:   # %bb.0: # %entry
 ; CHECK-NEXT:pld r3, inputf64@got@pcrel(0), 1
 ; CHECK-NEXT:  .Lpcrel5:
-; CHECK-NEXT:plfd f1, .LCPI6_0@PCREL(0), 1
+; CHECK-NEXT:xxsplti32dx vs1, 0, 1075524403
+; CHECK-NEXT:xxsplti32dx vs1, 1, 858993459
 ; CHECK-NEXT:.reloc .Lpcrel5-8,R_PPC64_PCREL_OPT,.-(.Lpcrel5-8)
 ; CHECK-NEXT:lfd f0, 0(r3)
 ; CHECK-NEXT:pld r3, outputf64@got@pcrel(0), 1
Index: llvm/test/CodeGen/PowerPC/pcrel-call-linkage-leaf.ll
===
--- llvm/test/CodeGen/PowerPC/pcrel-call-linkage-leaf.ll
+++ llvm/test/CodeGen/PowerPC/pcrel-call-linkage-leaf.ll
@@ -173,7 +173,9 @@
 ; CHECK-LARGE: add r2, r2, r12
 ; CHECK-S-NOT:   .localentry
 ; CHECK-ALL:   # %bb.0: # %entry
-; CHECK-S-NEXT:plfd f1, .LCPI7_0@PCREL(0), 1
+; CHECK-S-NEXT:xxsplti32dx vs1, 0, 1078011044
+; CHECK-S-NEXT:xxsplti32dx vs1, 1, -337824948
+; CHECK-S-NEXT:# kill: def $f1 killed $f1 killed $vsl1
 ; CHECK-S-NEXT:blr
 entry:
   ret double 0x404124A4EBDD334C
Index: llvm/test/CodeGen/PowerPC/p10-splatImm-CPload-pcrel.ll
===
--- llvm/test/CodeGen/PowerPC/p10-splatImm-CPload-pcrel.ll
+++ llvm/test/CodeGen/PowerPC/p10-splatImm-CPload-pcrel.ll
@@ -122,19 +122,23 @@
 define dso_local double @testDoubleNonRepresentableScalar() local_unnamed_addr {
 ; CHECK-LE-LABEL: testDoubleNonRepresentableScalar:
 ; CHECK-LE:   # %bb.0: # %entry
-; CHECK-LE-NEXT:plfd f1, .LCPI3_0@PCREL(0), 1
+; CHECK-LE-NEXT:xxsplti32dx vs1, 0, 1081435463
+; CHECK-LE-NEXT:xxsplti32dx vs1, 1, -1374389535
+; CHECK-LE-NEXT:# kill: def $f1 

[clang] c454200 - AArch64/MacOS: switch default CPU to apple-a13.

2021-03-08 Thread Tim Northover via cfe-commits

Author: Tim Northover
Date: 2021-03-08T15:47:05Z
New Revision: c4542005dae203dc4cb4e4be22628d4e24b4d5b6

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

LOG: AArch64/MacOS: switch default CPU to apple-a13.

The DevKits had A12 processors, but they're all gone now and real hardware has
an A13.

Added: 


Modified: 
clang/lib/Driver/ToolChains/Arch/AArch64.cpp
clang/test/Driver/aarch64-mac-cpus.c
clang/test/Preprocessor/aarch64-target-features.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp 
b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
index a5e632fd8cdb..0789bb222a26 100644
--- a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -50,8 +50,8 @@ std::string aarch64::getAArch64TargetCPU(const ArgList ,
 
   if (Triple.isTargetMachineMac() &&
   Triple.getArch() == llvm::Triple::aarch64) {
-// Apple Silicon macs default to A12 CPUs.
-return "apple-a12";
+// Apple Silicon macs default to A13 CPUs.
+return "apple-a13";
   }
 
   // Make sure we pick the appropriate Apple CPU if -arch is used or when

diff  --git a/clang/test/Driver/aarch64-mac-cpus.c 
b/clang/test/Driver/aarch64-mac-cpus.c
index 437c38376545..8d7b51ec96cf 100644
--- a/clang/test/Driver/aarch64-mac-cpus.c
+++ b/clang/test/Driver/aarch64-mac-cpus.c
@@ -1,4 +1,4 @@
-// arm64 Mac-based targets default to Apple A12.
+// arm64 Mac-based targets default to Apple A13.
 
 // RUN: %clang -target arm64-apple-macos -### -c %s 2>&1 | 
FileCheck %s
 // RUN: %clang -target arm64-apple-ios-macabi-### -c %s 2>&1 | 
FileCheck %s
@@ -12,8 +12,8 @@
 // RUN: %clang -target arm64-apple-macos -mcpu=apple-a7  -### -c %s 2>&1 | 
FileCheck --check-prefix=EXPLICIT-A7 %s
 // RUN: %clang -target arm64-apple-macos -mcpu=apple-a13 -### -c %s 2>&1 | 
FileCheck --check-prefix=EXPLICIT-A13 %s
 
-// CHECK: "-cc1"{{.*}} "-triple" "arm64{{.*}}" "-target-cpu" "apple-a12"
-// CHECK-SAME: "-target-feature" "+v8.3a"
+// CHECK: "-cc1"{{.*}} "-triple" "arm64{{.*}}" "-target-cpu" "apple-a13"
+// CHECK-SAME: "-target-feature" "+v8.4a"
 
 // EXPLICIT-A11: "-cc1"{{.*}} "-triple" "arm64{{.*}}" "-target-cpu" "apple-a11"
 // EXPLICIT-A7: "-cc1"{{.*}} "-triple" "arm64{{.*}}" "-target-cpu" "apple-a7"

diff  --git a/clang/test/Preprocessor/aarch64-target-features.c 
b/clang/test/Preprocessor/aarch64-target-features.c
index 430508cf4233..3c7b56d75553 100644
--- a/clang/test/Preprocessor/aarch64-target-features.c
+++ b/clang/test/Preprocessor/aarch64-target-features.c
@@ -255,7 +255,7 @@
 // CHECK-MCPU-CARMEL: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+v8.2a" "-target-feature" "+fp-armv8" "-target-feature" "+neon" 
"-target-feature" "+crc" "-target-feature" "+crypto" "-target-feature" 
"+fullfp16" "-target-feature" "+ras" "-target-feature" "+lse" "-target-feature" 
"+rdm" "-target-feature" "+sha2" "-target-feature" "+aes"
 
 // RUN: %clang -target x86_64-apple-macosx -arch arm64 -### -c %s 2>&1 | 
FileCheck --check-prefix=CHECK-ARCH-ARM64 %s
-// CHECK-ARCH-ARM64: "-target-cpu" "apple-a12" "-target-feature" "+v8.3a" 
"-target-feature" "+fp-armv8" "-target-feature" "+neon" "-target-feature" 
"+crc" "-target-feature" "+crypto" "-target-feature" "+fullfp16" 
"-target-feature" "+ras" "-target-feature" "+lse" "-target-feature" "+rdm" 
"-target-feature" "+rcpc" "-target-feature" "+zcm" "-target-feature" "+zcz"
+// CHECK-ARCH-ARM64: "-target-cpu" "apple-a13" "-target-feature" "+v8.4a" 
"-target-feature" "+fp-armv8" "-target-feature" "+neon" "-target-feature" 
"+crc" "-target-feature" "+crypto" "-target-feature" "+dotprod" 
"-target-feature" "+fullfp16" "-target-feature" "+ras" "-target-feature" "+lse" 
"-target-feature" "+rdm" "-target-feature" "+rcpc" "-target-feature" "+zcm" 
"-target-feature" "+zcz" "-target-feature" "+fp16fml"
 
 // RUN: %clang -target x86_64-apple-macosx -arch arm64_32 -### -c %s 2>&1 | 
FileCheck --check-prefix=CHECK-ARCH-ARM64_32 %s
 // CHECK-ARCH-ARM64_32: "-target-cpu" "apple-s4" "-target-feature" "+v8.3a" 
"-target-feature" "+fp-armv8" "-target-feature" "+neon" "-target-feature" 
"+crc" "-target-feature" "+crypto" "-target-feature" "+fullfp16" 
"-target-feature" "+ras" "-target-feature" "+lse" "-target-feature" "+rdm" 
"-target-feature" "+rcpc" "-target-feature" "+zcm" "-target-feature" "+zcz" 
"-target-feature" "+sha2" "-target-feature" "+aes"



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


[PATCH] D96975: [Sema] Add some basic lambda capture fix-its

2021-03-08 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 329011.
njames93 marked 8 inline comments as done.
njames93 added a comment.

Address more comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96975

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/CXX/drs/dr6xx.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p12.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p2-generic-lambda-1y.cpp
  clang/test/SemaCXX/cxx1y-generic-lambdas-capturing.cpp
  clang/test/SemaCXX/cxx1y-generic-lambdas.cpp
  clang/test/SemaCXX/cxx1y-init-captures.cpp
  clang/test/SemaCXX/cxx1z-constexpr-lambdas.cpp
  clang/test/SemaCXX/lambda-expressions.cpp
  clang/test/SemaCXX/lambda-invalid-capture.cpp
  clang/test/SemaObjCXX/capturing-flexible-array-in-block.mm

Index: clang/test/SemaObjCXX/capturing-flexible-array-in-block.mm
===
--- clang/test/SemaObjCXX/capturing-flexible-array-in-block.mm
+++ clang/test/SemaObjCXX/capturing-flexible-array-in-block.mm
@@ -5,5 +5,5 @@
   struct { int x; int y[]; } a; // expected-note 3 {{'a' declared here}}
   ^{return a.x;}(); // expected-error {{cannot refer to declaration of structure variable with flexible array member inside block}}
   [=] {return a.x;}(); // expected-error {{variable 'a' with flexible array member cannot be captured in a lambda expression}}
-  [] {return a.x;}(); // expected-error {{variable 'a' cannot be implicitly captured in a lambda with no capture-default}} expected-note {{here}}
+  [] { return a.x; }(); // expected-error {{variable 'a' cannot be implicitly captured in a lambda with no capture-default}} expected-note {{here}} expected-note 4 {{capture}}
 }
Index: clang/test/SemaCXX/lambda-invalid-capture.cpp
===
--- clang/test/SemaCXX/lambda-invalid-capture.cpp
+++ clang/test/SemaCXX/lambda-invalid-capture.cpp
@@ -18,7 +18,7 @@
 }
 
 int pr43080(int i) { // expected-note {{declared here}}
-  return [] { // expected-note {{begins here}}
+  return [] {// expected-note {{begins here}} expected-note 4 {{capture}}
 return sizeof i <
   i; // expected-error {{variable 'i' cannot be implicitly captured in a lambda with no capture-default specified}}
   }();
Index: clang/test/SemaCXX/lambda-expressions.cpp
===
--- clang/test/SemaCXX/lambda-expressions.cpp
+++ clang/test/SemaCXX/lambda-expressions.cpp
@@ -12,17 +12,17 @@
 virtual C& Overload(float);
 
 void ImplicitThisCapture() {
-  [](){(void)Member;}; // expected-error {{'this' cannot be implicitly captured in this context}}
-  const int var = [](){(void)Member; return 0;}(); // expected-error {{'this' cannot be implicitly captured in this context}}
+  []() { (void)Member; }; // expected-error {{'this' cannot be implicitly captured in this context}} expected-note {{explicitly capture 'this'}}
+  const int var = []() {(void)Member; return 0; }(); // expected-error {{'this' cannot be implicitly captured in this context}} expected-note {{explicitly capture 'this'}}
   [&](){(void)Member;};
 
   [this](){(void)Member;};
   [this]{[this]{};};
   []{[this]{};};// expected-error {{'this' cannot be implicitly captured in this context}}
   []{Overload(3);};
-  []{Overload();}; // expected-error {{'this' cannot be implicitly captured in this context}}
+  [] { Overload(); }; // expected-error {{'this' cannot be implicitly captured in this context}} expected-note {{explicitly capture 'this'}}
   []{(void)typeid(Overload());};
-  []{(void)typeid(Overload(.5f));};// expected-error {{'this' cannot be implicitly captured in this context}}
+  [] { (void)typeid(Overload(.5f)); }; // expected-error {{'this' cannot be implicitly captured in this context}} expected-note {{explicitly capture 'this'}}
 }
   };
 
@@ -47,14 +47,14 @@
 namespace ImplicitCapture {
   void test() {
 int a = 0; // expected-note 5 {{declared}}
-[]() { return a; }; // expected-error {{variable 'a' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{begins here}}
+[]() { return a; }; // expected-error {{variable 'a' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{begins here}} expected-note 4 {{capture}}
 [&]() { return a; };
 [=]() { return a; };
 [=]() { int* b =  }; // expected-error {{cannot initialize a variable of type 'int *' with an rvalue of type 'const int *'}}
 [=]() { return [&]() { return a; }; };
-[]() { return [&]() { return a; }; }; // expected-error {{variable 'a' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{lambda expression begins here}}
-[]() 

[PATCH] D97107: Replace func name with regex in update_cc_test_checks

2021-03-08 Thread Giorgis Georgakoudis via Phabricator via cfe-commits
ggeorgakoudis updated this revision to Diff 329008.
ggeorgakoudis added a comment.

Change regex to avoid failing windows test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97107

Files:
  clang/test/utils/update_cc_test_checks/Inputs/generated-funcs-regex.c
  clang/test/utils/update_cc_test_checks/Inputs/generated-funcs-regex.c.expected
  clang/test/utils/update_cc_test_checks/generated-funcs-regex.test
  llvm/utils/UpdateTestChecks/common.py

Index: llvm/utils/UpdateTestChecks/common.py
===
--- llvm/utils/UpdateTestChecks/common.py
+++ llvm/utils/UpdateTestChecks/common.py
@@ -30,6 +30,8 @@
help='Activate CHECK line generation from this point forward')
   parser.add_argument('--disable', action='store_false', dest='enabled',
   help='Deactivate CHECK line generation from this point forward')
+  parser.add_argument('--replace-function-regex', nargs='+', default=[],
+  help='List of regular expressions to replace matching function names')
   args = parser.parse_args()
   global _verbose
   _verbose = args.verbose
@@ -264,6 +266,8 @@
 self._record_args = flags.function_signature
 self._check_attributes = flags.check_attributes
 self._scrubber_args = scrubber_args
+# Strip double-quotes if input was read by UTC_ARGS
+self._replace_function_regex = list(map(lambda x: x.strip('"'), flags.replace_function_regex))
 self._func_dict = {}
 self._func_order = {}
 for tuple in run_list:
@@ -331,6 +335,30 @@
   self._func_dict[prefix][func] = None
   continue
 
+# Replace function names matching the regex.
+for regex in self._replace_function_regex:
+  # Pattern that matches capture groups in the regex in leftmost order.
+  group_regex = re.compile('\(.*?\)')
+  # Replace function name with regex.
+  match = re.match(regex, func)
+  if match:
+func_repl = regex
+# Replace any capture groups with their matched strings.
+for g in match.groups():
+  func_repl = group_regex.sub(g, func_repl, count=1)
+func = '{{' + func_repl + '}}'
+
+  # Replace all calls to regex matching functions.
+  matches = re.finditer(regex, scrubbed_body)
+  for match in matches:
+func_repl = regex
+# Replace any capture groups with their matched strings.
+for g in match.groups():
+func_repl = group_regex.sub(g, func_repl, count=1)
+# Substitute function call names that match the regex with the same
+# capture groups set.
+scrubbed_body = re.sub(func_repl, '{{' + func_repl + '}}', scrubbed_body)
+
 self._func_dict[prefix][func] = function_body(
 scrubbed_body, scrubbed_extra, args_and_sig, attrs)
 self._func_order[prefix].append(func)
@@ -633,6 +661,8 @@
   continue  # Don't add default values
 autogenerated_note_args += action.option_strings[0] + ' '
 if action.const is None:  # action takes a parameter
+  if action.nargs == '+':
+value = ' '.join(map(lambda v: '"' + v.strip('"') + '"', value))
   autogenerated_note_args += '%s ' % value
   if autogenerated_note_args:
 autogenerated_note_args = ' %s %s' % (UTC_ARGS_KEY, autogenerated_note_args[:-1])
Index: clang/test/utils/update_cc_test_checks/generated-funcs-regex.test
===
--- /dev/null
+++ clang/test/utils/update_cc_test_checks/generated-funcs-regex.test
@@ -0,0 +1,9 @@
+## Test that CHECK lines are generated for clang-generated functions replaced
+## by regex
+
+## RUN: cp %S/Inputs/generated-funcs-regex.c %t-generated-funcs-regex.c && %update_cc_test_checks --include-generated-funcs --replace-function-regex "__([a-z]+)_offloading_[a-z0-9]+_[a-z0-9]+_(.*)_l[0-9]+" -- %t-generated-funcs-regex.c
+# RUN: diff -u %S/Inputs/generated-funcs-regex.c.expected %t-generated-funcs-regex.c
+
+## Check that re-running update_cc_test_checks doesn't change the output
+# RUN: %update_cc_test_checks %t-generated-funcs-regex.c
+# RUN: diff -u %S/Inputs/generated-funcs-regex.c.expected %t-generated-funcs-regex.c
Index: clang/test/utils/update_cc_test_checks/Inputs/generated-funcs-regex.c.expected
===
--- /dev/null
+++ clang/test/utils/update_cc_test_checks/Inputs/generated-funcs-regex.c.expected
@@ -0,0 +1,36 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --include-generated-funcs --replace-function-regex "__([a-z]+)_offloading_[a-z0-9]+_[a-z0-9]+_(.*)_l[0-9]+"
+// RUN: %clang_cc1 -fopenmp %s -emit-llvm -o - | FileCheck %s
+
+void __test_offloading_42_abcdef_bar_l123();
+void use(int);
+

[PATCH] D97068: Run non-filechecked commands in update_cc_test_checks.py

2021-03-08 Thread Giorgis Georgakoudis 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 rG60d4c73b30a0: Run non-filechecked commands in 
update_cc_test_checks.py (authored by ggeorgakoudis).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97068

Files:
  clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c
  clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c.expected
  clang/test/utils/update_cc_test_checks/exec-all-runlines.test
  llvm/utils/update_cc_test_checks.py

Index: llvm/utils/update_cc_test_checks.py
===
--- llvm/utils/update_cc_test_checks.py
+++ llvm/utils/update_cc_test_checks.py
@@ -203,6 +203,14 @@
   'are discouraged in Clang testsuite.', file=sys.stderr)
 sys.exit(1)
 
+def exec_run_line(exe):
+  popen = subprocess.Popen(exe, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
+  stdout, stderr = popen.communicate()
+  if popen.returncode != 0:
+sys.stderr.write('Failed to run ' + ' '.join(exe) + '\n')
+sys.stderr.write(stderr)
+sys.stderr.write(stdout)
+sys.exit(3)
 
 def main():
   initial_args, parser = config()
@@ -221,25 +229,31 @@
   if m:
 triple_in_cmd = m.groups()[0]
 
-  # Apply %clang substitution rule, replace %s by `filename`, and append args.clang_args
-  clang_args = shlex.split(commands[0])
-  if clang_args[0] not in SUBST:
-print('WARNING: Skipping non-clang RUN line: ' + l, file=sys.stderr)
+  # Parse executable args.
+  exec_args = shlex.split(commands[0])
+  # Execute non-clang runline.
+  if exec_args[0] not in SUBST:
+print('NOTE: Executing non-clang RUN line: ' + l, file=sys.stderr)
+# Replace %s by `filename`.
+exec_args = [i.replace('%s', ti.path) if '%s' in i else i for i in exec_args]
+exec_run_line(exec_args)
 continue
+  # This is a clang runline, apply %clang substitution rule, replace %s by `filename`,
+  # and append args.clang_args
+  clang_args = exec_args
   clang_args[0:1] = SUBST[clang_args[0]]
-  clang_args = [ti.path if i == '%s' else i for i in clang_args] + ti.args.clang_args
-
-  # Permit piping the output through opt
-  if not (len(commands) == 2 or
-  (len(commands) == 3 and commands[1].startswith('opt'))):
-print('WARNING: Skipping non-clang RUN line: ' + l, file=sys.stderr)
+  clang_args = [i.replace('%s', ti.path) if '%s' in i else i for i in clang_args] + ti.args.clang_args
 
   # Extract -check-prefix in FileCheck args
   filecheck_cmd = commands[-1]
   common.verify_filecheck_prefixes(filecheck_cmd)
   if not filecheck_cmd.startswith('FileCheck '):
-print('WARNING: Skipping non-FileChecked RUN line: ' + l, file=sys.stderr)
+print('NOTE: Executing non-FileChecked clang RUN line: ' + l, file=sys.stderr)
+# Execute non-filechecked clang runline.
+exe = [ti.args.clang] + clang_args
+exec_run_line(exe)
 continue
+
   check_prefixes = [item for m in common.CHECK_PREFIX_RE.finditer(filecheck_cmd)
for item in m.group(1).split(',')]
   if not check_prefixes:
Index: clang/test/utils/update_cc_test_checks/exec-all-runlines.test
===
--- /dev/null
+++ clang/test/utils/update_cc_test_checks/exec-all-runlines.test
@@ -0,0 +1,8 @@
+## Test that non-clang/non-filechecked runlines execute
+
+# RUN: cp %S/Inputs/exec-all-runlines.c %t-generated.c && %update_cc_test_checks %t-generated.c
+# RUN: diff -u %S/Inputs/exec-all-runlines.c.expected %t-generated.c
+
+## Check that re-running update_cc_test_checks doesn't change the output
+# RUN: %update_cc_test_checks %t-generated.c
+# RUN: diff -u %S/Inputs/exec-all-runlines.c.expected %t-generated.c
Index: clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c.expected
===
--- /dev/null
+++ clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c.expected
@@ -0,0 +1,17 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// Check that the non-clang/non-filechecked runlines execute
+// RUN: cp %s %s.copy.c
+// RUN: %clang_cc1 -fopenmp %s.copy.c -emit-llvm-bc -o %t-host.bc
+// RUN: %clang_cc1 -fopenmp -fopenmp-host-ir-file-path %t-host.bc %s.copy.c -emit-llvm -o - | FileCheck %s
+
+void use(int);
+
+// CHECK-LABEL: @test(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[A_ADDR:%.*]] = alloca i32, align 4
+// CHECK-NEXT:store i32 [[A:%.*]], i32* [[A_ADDR]], align 4
+// CHECK-NEXT:ret void
+//
+void test(int a)
+{
+}
Index: clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c

[clang] 60d4c73 - Run non-filechecked commands in update_cc_test_checks.py

2021-03-08 Thread Giorgis Georgakoudis via cfe-commits

Author: Giorgis Georgakoudis
Date: 2021-03-08T07:18:01-08:00
New Revision: 60d4c73b30a0e324c6ae314722eb036f70f4b03a

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

LOG: Run non-filechecked commands in update_cc_test_checks.py

Some tests in clang require running non-filechecked commands to generate the 
actual filecheck input. For example, tests for openmp offloading require 
generating the host bc without any checking, before running the clang command 
to actually generate the filechecked IR of the target device. This patch 
enables `update_cc_test_checks.py` to run non-filechecked run lines in-place.

Reviewed By: jdoerfert

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

Added: 
clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c
clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c.expected
clang/test/utils/update_cc_test_checks/exec-all-runlines.test

Modified: 
llvm/utils/update_cc_test_checks.py

Removed: 




diff  --git a/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c 
b/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c
new file mode 100644
index ..bf18179392dc
--- /dev/null
+++ b/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c
@@ -0,0 +1,10 @@
+// Check that the non-clang/non-filechecked runlines execute
+// RUN: cp %s %s.copy.c
+// RUN: %clang_cc1 -fopenmp %s.copy.c -emit-llvm-bc -o %t-host.bc
+// RUN: %clang_cc1 -fopenmp -fopenmp-host-ir-file-path %t-host.bc %s.copy.c 
-emit-llvm -o - | FileCheck %s
+
+void use(int);
+
+void test(int a)
+{
+}

diff  --git 
a/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c.expected 
b/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c.expected
new file mode 100644
index ..ffc8caac0f23
--- /dev/null
+++ b/clang/test/utils/update_cc_test_checks/Inputs/exec-all-runlines.c.expected
@@ -0,0 +1,17 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// Check that the non-clang/non-filechecked runlines execute
+// RUN: cp %s %s.copy.c
+// RUN: %clang_cc1 -fopenmp %s.copy.c -emit-llvm-bc -o %t-host.bc
+// RUN: %clang_cc1 -fopenmp -fopenmp-host-ir-file-path %t-host.bc %s.copy.c 
-emit-llvm -o - | FileCheck %s
+
+void use(int);
+
+// CHECK-LABEL: @test(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[A_ADDR:%.*]] = alloca i32, align 4
+// CHECK-NEXT:store i32 [[A:%.*]], i32* [[A_ADDR]], align 4
+// CHECK-NEXT:ret void
+//
+void test(int a)
+{
+}

diff  --git a/clang/test/utils/update_cc_test_checks/exec-all-runlines.test 
b/clang/test/utils/update_cc_test_checks/exec-all-runlines.test
new file mode 100644
index ..caf39934266c
--- /dev/null
+++ b/clang/test/utils/update_cc_test_checks/exec-all-runlines.test
@@ -0,0 +1,8 @@
+## Test that non-clang/non-filechecked runlines execute
+
+# RUN: cp %S/Inputs/exec-all-runlines.c %t-generated.c && 
%update_cc_test_checks %t-generated.c
+# RUN: 
diff  -u %S/Inputs/exec-all-runlines.c.expected %t-generated.c
+
+## Check that re-running update_cc_test_checks doesn't change the output
+# RUN: %update_cc_test_checks %t-generated.c
+# RUN: 
diff  -u %S/Inputs/exec-all-runlines.c.expected %t-generated.c

diff  --git a/llvm/utils/update_cc_test_checks.py 
b/llvm/utils/update_cc_test_checks.py
index e5ca91502cf9..d084bc6d0795 100755
--- a/llvm/utils/update_cc_test_checks.py
+++ b/llvm/utils/update_cc_test_checks.py
@@ -203,6 +203,14 @@ def get_function_body(builder, args, filename, clang_args, 
extra_commands,
   'are discouraged in Clang testsuite.', file=sys.stderr)
 sys.exit(1)
 
+def exec_run_line(exe):
+  popen = subprocess.Popen(exe, stdout=subprocess.PIPE, 
stderr=subprocess.PIPE, universal_newlines=True)
+  stdout, stderr = popen.communicate()
+  if popen.returncode != 0:
+sys.stderr.write('Failed to run ' + ' '.join(exe) + '\n')
+sys.stderr.write(stderr)
+sys.stderr.write(stdout)
+sys.exit(3)
 
 def main():
   initial_args, parser = config()
@@ -221,25 +229,31 @@ def main():
   if m:
 triple_in_cmd = m.groups()[0]
 
-  # Apply %clang substitution rule, replace %s by `filename`, and append 
args.clang_args
-  clang_args = shlex.split(commands[0])
-  if clang_args[0] not in SUBST:
-print('WARNING: Skipping non-clang RUN line: ' + l, file=sys.stderr)
+  # Parse executable args.
+  exec_args = shlex.split(commands[0])
+  # Execute non-clang runline.
+  if exec_args[0] not in SUBST:
+print('NOTE: Executing non-clang RUN line: ' + l, file=sys.stderr)
+# Replace %s by `filename`.
+exec_args = [i.replace('%s', ti.path) if '%s' in i else i for i in 
exec_args]
+exec_run_line(exec_args)
 continue
+

[PATCH] D97068: Run non-filechecked commands in update_cc_test_checks.py

2021-03-08 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, thx!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97068

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


[PATCH] D97411: [DebugInfo] Add an attribute to force type info to be emitted for types that are required to be complete.

2021-03-08 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

In D97411#2598625 , @akhuang wrote:

> I started looking into some diffs of debug info in libc++ tests, but it's 
> pretty hard to tell what's different - as far as I can see, there are just a 
> bunch of `__hash_value_type`s and `__value_type`s.

This is a job for llvm-dva!  See the preliminary patch at D88661 
, although it's getting a bit old and might 
not apply/build cleanly.

(llvm-dva is undergoing an internal review at the moment, we hope to have a 
proper reviewable patch series up soon-ish.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97411

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


[PATCH] D89986: [AIX] do not emit visibility attribute into IR when there is -mignore-xcoff-visibility

2021-03-08 Thread Digger Lin via Phabricator via cfe-commits
DiggerLin updated this revision to Diff 328998.
DiggerLin marked an inline comment as done.
DiggerLin added a comment.

added extra comment back.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89986

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/LangOptions.def
  clang/lib/AST/Decl.cpp
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/aix-ignore-xcoff-visibility.cpp
  clang/test/CodeGen/aix-visibility-inlines-hidden.cpp

Index: clang/test/CodeGen/aix-visibility-inlines-hidden.cpp
===
--- /dev/null
+++ clang/test/CodeGen/aix-visibility-inlines-hidden.cpp
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -mcmodel=large -emit-llvm -o - -x c++ %s  | \
+// RUN: FileCheck -check-prefix=NOVISIBILITY-IR %s
+
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -mcmodel=large \
+// RUN:-fvisibility-inlines-hidden -emit-llvm -o - -x c++ %s  | \
+// RUN: FileCheck -check-prefix=NOVISIBILITY-IR %s
+
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -mcmodel=large -fvisibility-inlines-hidden \
+// RUN:-fvisibility default -emit-llvm -o - -x c++ %s  | \
+// RUN: FileCheck -check-prefix=VISIBILITY-IR %s
+
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -mcmodel=large -mignore-xcoff-visibility -emit-llvm \
+// RUN:-fvisibility-inlines-hidden -fvisibility default -o - -x c++ %s  | \
+// RUN: FileCheck -check-prefix=NOVISIBILITY-IR %s
+
+int x = 66;
+__attribute__((__noinline__)) inline void f() {
+  x = 55;
+}
+
+#pragma GCC visibility push(hidden)
+__attribute__((__noinline__)) inline void foo() {
+  x = 55;
+}
+#pragma GCC visibility pop
+
+int bar() {
+  f();
+  foo();
+  return x;
+}
+
+// VISIBILITY-IR: define linkonce_odr hidden void @_Z1fv()
+// NOVISIBILITY-IR:   define linkonce_odr void @_Z1fv()
+
+// VISIBILITY-IR: define linkonce_odr hidden void @_Z3foov()
+// NOVISIBILITY-IR:   define linkonce_odr void @_Z3foov()
Index: clang/test/CodeGen/aix-ignore-xcoff-visibility.cpp
===
--- clang/test/CodeGen/aix-ignore-xcoff-visibility.cpp
+++ clang/test/CodeGen/aix-ignore-xcoff-visibility.cpp
@@ -1,26 +1,19 @@
-// REQUIRES: powerpc-registered-target
-// RUN: %clang_cc1 -triple powerpc-unknown-aix -o - -x c++ -S  %s  |\
-// RUN:   FileCheck --check-prefix=IGNOREVISIBILITY-ASM %s
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -emit-llvm -o - -x c++ %s  | \
+// RUN: FileCheck -check-prefix=NOVISIBILITY-IR %s
 
-// RUN: %clang_cc1 -triple powerpc-unknown-aix -mignore-xcoff-visibility -o - -x c++ -S %s  | \
-// RUN: FileCheck -check-prefix=IGNOREVISIBILITY-ASM %s
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -emit-llvm -round-trip-args -o - -x c++ %s  | \
+// RUN: FileCheck -check-prefix=NOVISIBILITY-IR %s
 
-// RUN: %clang_cc1 -triple powerpc-unknown-aix -mignore-xcoff-visibility -fvisibility default -o - -x c++ -S %s  | \
-// RUN: FileCheck -check-prefix=IGNOREVISIBILITY-ASM %s
-
-// RUN: %clang_cc1 -triple powerpc-unknown-aix -fvisibility default -o - -x c++ -S %s  | \
-// RUN: FileCheck -check-prefix=VISIBILITY-ASM %s
-
-// RUN: %clang_cc1 -triple powerpc-unknown-aix -mignore-xcoff-visibility -fvisibility default -o - -x c++ -S %s  | \
-// RUN: FileCheck -check-prefix=IGNOREVISIBILITY-ASM %s
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -mignore-xcoff-visibility -fvisibility default -emit-llvm -o - -x c++ %s  | \
+// RUN: FileCheck -check-prefix=NOVISIBILITY-IR %s
 
-// RUN: %clang_cc1 -triple powerpc-unknown-aix -fvisibility default -o - -x c++ -S %s  | \
-// RUN: FileCheck -check-prefix=VISIBILITY-ASM %s
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -mignore-xcoff-visibility -fvisibility default -emit-llvm -round-trip-args -o - -x c++ %s  | \
+// RUN: FileCheck -check-prefix=NOVISIBILITY-IR %s
 
-// RUN: %clang_cc1 -triple powerpc-unknown-aix -mignore-xcoff-visibility -fvisibility default -emit-llvm -o - -x c++ %s  | \
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -fvisibility default -emit-llvm -o - -x c++ %s  | \
 // RUN: FileCheck -check-prefix=VISIBILITY-IR %s
 
-// RUN: %clang_cc1 -triple powerpc-unknown-aix -fvisibility default -emit-llvm -o - -x c++ %s  | \
+// RUN: %clang_cc1 -triple powerpc-unknown-aix -fvisibility default -round-trip-args -emit-llvm -o - -x c++ %s  | \
 // RUN: FileCheck -check-prefix=VISIBILITY-IR %s
 
 __attribute__((visibility("hidden"))) void foo_h(int *p) {
@@ -70,28 +63,11 @@
 // VISIBILITY-IR:define weak_odr protected i32 @_ZN5basicIiE7getdataEv(%class.basic* {{[^,]*}} %this)
 // VISIBILITY-IR:define hidden void @_Z7prambarv()
 
-// VISIBILITY-ASM: .globl  _Z5foo_hPi[DS],hidden
-// VISIBILITY-ASM: .globl  ._Z5foo_hPi,hidden
-// VISIBILITY-ASM: .globl  _Z3barv[DS],protected
-// VISIBILITY-ASM: .globl  ._Z3barv,protected
-// 

[PATCH] D89986: [AIX] do not emit visibility attribute into IR when there is -mignore-xcoff-visibility

2021-03-08 Thread Digger Lin via Phabricator via cfe-commits
DiggerLin marked an inline comment as done.
DiggerLin added a comment.






Comment at: clang/lib/Frontend/CompilerInvocation.cpp:3630
+  // no -fvisibility=* option.
+  if (T.isOSAIX() && (Args.hasArg(OPT_mignore_xcoff_visibility) ||
+  !Args.hasArg(OPT_fvisibility)))

daltenty wrote:
> No sure if we intended to move this block? Regardless, we should probably 
> preserve the extra comments that got added.
in original patch https://reviews.llvm.org/D87451 , the 
-mignore-xcoff-visibility is CodeGenOpt, in the new patch, we change the option 
"-mignore-xcoff-visibility" as LangOpt. 
I will add the extra comment back.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89986

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


[PATCH] D96265: [PowerPC] Change target data layout for 16-byte stack alignment

2021-03-08 Thread Ahsan Saghir 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 rGacce401068e7: [PowerPC] Change target data layout for 
16-byte stack alignment (authored by saghir).

Changed prior to commit:
  https://reviews.llvm.org/D96265?vs=323451=328994#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96265

Files:
  clang/lib/Basic/Targets/PPC.h
  clang/test/CodeGen/target-data.c
  lld/test/ELF/common-archive-lookup.s
  llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
  llvm/test/CodeGen/PowerPC/P10-stack-alignment.ll

Index: llvm/test/CodeGen/PowerPC/P10-stack-alignment.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/P10-stack-alignment.ll
@@ -0,0 +1,214 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN:   -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | \
+; RUN:   FileCheck %s --check-prefix=CHECK-LE
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu \
+; RUN:   -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | \
+; RUN:   FileCheck %s --check-prefix=CHECK-BE
+; RUN: opt --passes=sroa,loop-vectorize,loop-unroll,instcombine -S \
+; RUN: -vectorizer-maximize-bandwidth --mtriple=powerpc64le-- -mcpu=pwr10 < %s | \
+; RUN: FileCheck %s --check-prefix=CHECK-OPT
+
+target datalayout = "e-m:e-i64:64-n32:64-S128-v256:256:256-v512:512:512"
+
+define dso_local signext i32 @test_32byte_vector() nounwind {
+; CHECK-LE-LABEL: test_32byte_vector:
+; CHECK-LE:   # %bb.0: # %entry
+; CHECK-LE-NEXT:mflr r0
+; CHECK-LE-NEXT:std r30, -16(r1)
+; CHECK-LE-NEXT:mr r30, r1
+; CHECK-LE-NEXT:std r0, 16(r1)
+; CHECK-LE-NEXT:clrldi r0, r1, 59
+; CHECK-LE-NEXT:subfic r0, r0, -96
+; CHECK-LE-NEXT:stdux r1, r1, r0
+; CHECK-LE-NEXT:addis r3, r2, .LCPI0_0@toc@ha
+; CHECK-LE-NEXT:addis r4, r2, .LCPI0_1@toc@ha
+; CHECK-LE-NEXT:addi r3, r3, .LCPI0_0@toc@l
+; CHECK-LE-NEXT:addi r4, r4, .LCPI0_1@toc@l
+; CHECK-LE-NEXT:lvx v2, 0, r3
+; CHECK-LE-NEXT:lvx v3, 0, r4
+; CHECK-LE-NEXT:addi r4, r1, 48
+; CHECK-LE-NEXT:addi r3, r1, 32
+; CHECK-LE-NEXT:stvx v2, 0, r4
+; CHECK-LE-NEXT:stvx v3, 0, r3
+; CHECK-LE-NEXT:bl test
+; CHECK-LE-NEXT:nop
+; CHECK-LE-NEXT:lwa r3, 32(r1)
+; CHECK-LE-NEXT:mr r1, r30
+; CHECK-LE-NEXT:ld r0, 16(r1)
+; CHECK-LE-NEXT:ld r30, -16(r1)
+; CHECK-LE-NEXT:mtlr r0
+; CHECK-LE-NEXT:blr
+;
+; CHECK-BE-LABEL: test_32byte_vector:
+; CHECK-BE:   # %bb.0: # %entry
+; CHECK-BE-NEXT:mflr r0
+; CHECK-BE-NEXT:std r30, -16(r1)
+; CHECK-BE-NEXT:std r0, 16(r1)
+; CHECK-BE-NEXT:clrldi r0, r1, 59
+; CHECK-BE-NEXT:mr r30, r1
+; CHECK-BE-NEXT:subfic r0, r0, -192
+; CHECK-BE-NEXT:stdux r1, r1, r0
+; CHECK-BE-NEXT:lis r3, -8192
+; CHECK-BE-NEXT:li r4, 5
+; CHECK-BE-NEXT:lis r5, -16384
+; CHECK-BE-NEXT:lis r6, -32768
+; CHECK-BE-NEXT:ori r3, r3, 1
+; CHECK-BE-NEXT:rldic r4, r4, 32, 29
+; CHECK-BE-NEXT:ori r5, r5, 1
+; CHECK-BE-NEXT:ori r6, r6, 1
+; CHECK-BE-NEXT:rldic r3, r3, 3, 29
+; CHECK-BE-NEXT:ori r4, r4, 6
+; CHECK-BE-NEXT:rldic r5, r5, 2, 30
+; CHECK-BE-NEXT:rldic r6, r6, 1, 31
+; CHECK-BE-NEXT:std r3, 152(r1)
+; CHECK-BE-NEXT:addi r3, r1, 128
+; CHECK-BE-NEXT:std r4, 144(r1)
+; CHECK-BE-NEXT:std r5, 136(r1)
+; CHECK-BE-NEXT:std r6, 128(r1)
+; CHECK-BE-NEXT:bl test
+; CHECK-BE-NEXT:nop
+; CHECK-BE-NEXT:lwa r3, 128(r1)
+; CHECK-BE-NEXT:mr r1, r30
+; CHECK-BE-NEXT:ld r0, 16(r1)
+; CHECK-BE-NEXT:ld r30, -16(r1)
+; CHECK-BE-NEXT:mtlr r0
+; CHECK-BE-NEXT:blr
+entry:
+  %a = alloca <8 x i32>, align 32
+  %0 = bitcast <8 x i32>* %a to i8*
+  call void @llvm.lifetime.start.p0i8(i64 32, i8* %0)
+  store <8 x i32> , <8 x i32>* %a, align 32
+  call void @test(<8 x i32>* %a)
+  %1 = load <8 x i32>, <8 x i32>* %a, align 32
+  %vecext = extractelement <8 x i32> %1, i32 0
+  %2 = bitcast <8 x i32>* %a to i8*
+  call void @llvm.lifetime.end.p0i8(i64 32, i8* %2)
+  ret i32 %vecext
+}
+
+define dso_local signext i32 @test_32byte_aligned_vector() nounwind {
+; CHECK-LE-LABEL: test_32byte_aligned_vector:
+; CHECK-LE:   # %bb.0: # %entry
+; CHECK-LE-NEXT:mflr r0
+; CHECK-LE-NEXT:std r30, -16(r1)
+; CHECK-LE-NEXT:mr r30, r1
+; CHECK-LE-NEXT:std r0, 16(r1)
+; CHECK-LE-NEXT:clrldi r0, r1, 59
+; CHECK-LE-NEXT:subfic r0, r0, -64
+; CHECK-LE-NEXT:stdux r1, r1, r0
+; CHECK-LE-NEXT:addis r3, r2, .LCPI1_0@toc@ha
+; CHECK-LE-NEXT:addi r3, r3, .LCPI1_0@toc@l
+; CHECK-LE-NEXT:lvx v2, 0, r3
+; CHECK-LE-NEXT:addi r3, r1, 32
+; CHECK-LE-NEXT:stvx v2, 0, r3
+; CHECK-LE-NEXT:bl test1
+; CHECK-LE-NEXT:nop
+; CHECK-LE-NEXT:lwa 

[PATCH] D98156: [clang/mac] Accept -why_load and make -whyload an alias for it

2021-03-08 Thread Nico Weber 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 rG203731d2c82b: [clang/mac] Accept -why_load and make -whyload 
an alias for it (authored by thakis).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98156

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Darwin.cpp


Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -417,7 +417,7 @@
   Args.AddAllArgs(CmdArgs, options::OPT_sectalign);
   Args.AddAllArgs(CmdArgs, options::OPT_sectobjectsymbols);
   Args.AddAllArgs(CmdArgs, options::OPT_segcreate);
-  Args.AddLastArg(CmdArgs, options::OPT_whyload);
+  Args.AddLastArg(CmdArgs, options::OPT_why_load);
   Args.AddLastArg(CmdArgs, options::OPT_whatsloaded);
   Args.AddAllArgs(CmdArgs, options::OPT_dylinker__install__name);
   Args.AddLastArg(CmdArgs, options::OPT_dylinker);
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3700,7 +3700,8 @@
 def weak__library : Separate<["-"], "weak_library">, Flags<[LinkerInput]>;
 def weak__reference__mismatches : Separate<["-"], "weak_reference_mismatches">;
 def whatsloaded : Flag<["-"], "whatsloaded">;
-def whyload : Flag<["-"], "whyload">;
+def why_load : Flag<["-"], "why_load">;
+def whyload : Flag<["-"], "whyload">, Alias;
 def w : Flag<["-"], "w">, HelpText<"Suppress all warnings">, 
Flags<[CC1Option]>,
   MarshallingInfoFlag>;
 def x : JoinedOrSeparate<["-"], "x">, Flags<[NoXarchOption,CC1Option]>,


Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -417,7 +417,7 @@
   Args.AddAllArgs(CmdArgs, options::OPT_sectalign);
   Args.AddAllArgs(CmdArgs, options::OPT_sectobjectsymbols);
   Args.AddAllArgs(CmdArgs, options::OPT_segcreate);
-  Args.AddLastArg(CmdArgs, options::OPT_whyload);
+  Args.AddLastArg(CmdArgs, options::OPT_why_load);
   Args.AddLastArg(CmdArgs, options::OPT_whatsloaded);
   Args.AddAllArgs(CmdArgs, options::OPT_dylinker__install__name);
   Args.AddLastArg(CmdArgs, options::OPT_dylinker);
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3700,7 +3700,8 @@
 def weak__library : Separate<["-"], "weak_library">, Flags<[LinkerInput]>;
 def weak__reference__mismatches : Separate<["-"], "weak_reference_mismatches">;
 def whatsloaded : Flag<["-"], "whatsloaded">;
-def whyload : Flag<["-"], "whyload">;
+def why_load : Flag<["-"], "why_load">;
+def whyload : Flag<["-"], "whyload">, Alias;
 def w : Flag<["-"], "w">, HelpText<"Suppress all warnings">, Flags<[CC1Option]>,
   MarshallingInfoFlag>;
 def x : JoinedOrSeparate<["-"], "x">, Flags<[NoXarchOption,CC1Option]>,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 203731d - [clang/mac] Accept -why_load and make -whyload an alias for it

2021-03-08 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2021-03-08T09:11:01-05:00
New Revision: 203731d2c82bc1ba0cfaeb8f3d38e696158ca2cd

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

LOG: [clang/mac] Accept -why_load and make -whyload an alias for it

>From `man ld`:

 -why_load   Log why each object file in a static library is loaded.
 That is, what symbol was needed.
 Also called -whyload for compatibility.

`-why_load` is the spelling preferred by the linker and `-whyload` an old
compatibility setting. clang should accept the preferred form, and map both
forms to the preferred form.

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Darwin.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 441c22caf96f..9172215bc512 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3700,7 +3700,8 @@ def weak__framework : Separate<["-"], "weak_framework">, 
Flags<[LinkerInput]>;
 def weak__library : Separate<["-"], "weak_library">, Flags<[LinkerInput]>;
 def weak__reference__mismatches : Separate<["-"], "weak_reference_mismatches">;
 def whatsloaded : Flag<["-"], "whatsloaded">;
-def whyload : Flag<["-"], "whyload">;
+def why_load : Flag<["-"], "why_load">;
+def whyload : Flag<["-"], "whyload">, Alias;
 def w : Flag<["-"], "w">, HelpText<"Suppress all warnings">, 
Flags<[CC1Option]>,
   MarshallingInfoFlag>;
 def x : JoinedOrSeparate<["-"], "x">, Flags<[NoXarchOption,CC1Option]>,

diff  --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index eb7bd4aec898..91241ff9bd81 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -417,7 +417,7 @@ void darwin::Linker::AddLinkArgs(Compilation , const 
ArgList ,
   Args.AddAllArgs(CmdArgs, options::OPT_sectalign);
   Args.AddAllArgs(CmdArgs, options::OPT_sectobjectsymbols);
   Args.AddAllArgs(CmdArgs, options::OPT_segcreate);
-  Args.AddLastArg(CmdArgs, options::OPT_whyload);
+  Args.AddLastArg(CmdArgs, options::OPT_why_load);
   Args.AddLastArg(CmdArgs, options::OPT_whatsloaded);
   Args.AddAllArgs(CmdArgs, options::OPT_dylinker__install__name);
   Args.AddLastArg(CmdArgs, options::OPT_dylinker);



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


[PATCH] D96975: [Sema] Add some basic lambda capture fix-its

2021-03-08 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:17453
+}
+return T.isPODType(Sema.getASTContext());
+  }();

sammccall wrote:
> POD is rarely precisely the right concept (and deprecated for that reason).
> Is isTriviallyCopyableType() just as good here?
Also, maybe `if (T->isTriviallyCopyableType(Sema.getASTContext())) return 
true;` at the top and just `return false;` here? This saves us the necessity to 
iterate through the ctors.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96975

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


[PATCH] D96586: [analyzer][CTU][NFC] Add an extra regression test

2021-03-08 Thread Gabor Marton via Phabricator via cfe-commits
martong accepted this revision.
martong added a comment.

Thanks for the test!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96586

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


[PATCH] D96975: [Sema] Add some basic lambda capture fix-its

2021-03-08 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:17457
+  SmallString<32> FixBuffer;
+  StringRef Separator = LSI->NumExplicitCaptures > 0 ? ", " : "";
+  if (Var->getDeclName().isIdentifier() && !Var->getName().empty()) {

sammccall wrote:
> This logic assumes there's no default capture, whic his reasonable but not 
> locally obvious - add an assert?
I think this is the same as https://reviews.llvm.org/D96975#inline-920917 
(which is done), am I wrong?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96975

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


[PATCH] D98143: [HIP] Diagnose aggregate args containing half types

2021-03-08 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 328979.
yaxunl added a comment.

fix test and clang-tidy warnings


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

https://reviews.llvm.org/D98143

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/Headers/__clang_hip_cmath.h
  clang/lib/Sema/SemaDecl.cpp
  clang/test/SemaCUDA/half-arg.cu

Index: clang/test/SemaCUDA/half-arg.cu
===
--- /dev/null
+++ clang/test/SemaCUDA/half-arg.cu
@@ -0,0 +1,136 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -fno-hip-allow-half-arg -x hip %s
+// RUN: %clang_cc1 -std=c++11 -fcuda-is-device -fsyntax-only -verify -fno-hip-allow-half-arg -x hip %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify=allow -x hip %s
+
+// allow-no-diagnostics
+
+#include "Inputs/cuda.h"
+
+// Check _Float16/__fp16 or structs containing them are not allowed as function
+// parameter in HIP host functions.
+
+typedef _Float16 half;
+
+typedef _Float16 half2 __attribute__((ext_vector_type(2)));
+
+struct A { // expected-note 4{{within field or base class of type 'A' declared here}}
+  _Float16 x; // expected-note 7{{field of illegal type '_Float16' declared here}}
+};
+
+struct B { // expected-note {{within field or base class of type 'B' declared here}}
+  _Float16 x[2]; // expected-note {{field of illegal type '_Float16 [2]' declared here}}
+};
+
+struct C { // expected-note {{within field or base class of type 'C' declared here}}
+  _Float16 x[2][2]; // expected-note {{field of illegal type '_Float16 [2][2]' declared here}}
+};
+
+struct D { // expected-note {{within field or base class of type 'D' declared here}}
+  A x; // expected-note {{within field or base class of type 'A' declared here}}
+};
+
+struct E : public A { // expected-note {{within field or base class of type 'E' declared here}}
+};
+
+struct F : virtual public A { // expected-note {{within field or base class of type 'F' declared here}}
+};
+
+struct G { // expected-note {{within field or base class of type 'G' declared here}}
+  __fp16 x; // expected-note {{field of illegal type '__fp16' declared here}}
+};
+
+struct H {
+  void f(A x);
+  // expected-error@-1 {{Invalid function parameter type: 'A'}}
+};
+
+template
+struct I {
+  T x;
+  void f(T x);
+  // expected-error@-1 {{Invalid function parameter type: 'A'}}
+};
+
+struct J { // expected-note {{within field or base class of type 'J' declared here}}
+  half2 v; // expected-note {{field of illegal type 'half2' (vector of 2 '_Float16' values) declared here}}
+};
+
+struct empty {};
+
+struct K : public empty {
+  int x;
+};
+
+struct undefined;
+
+void fa1(_Float16 x);
+// expected-error@-1 {{Invalid function parameter type: '_Float16'}}
+
+void fa2(A x);
+// expected-error@-1 {{Invalid function parameter type: 'A'}}
+
+void fa3(B x);
+// expected-error@-1 {{Invalid function parameter type: 'B'}}
+
+void fa4(C x);
+// expected-error@-1 {{Invalid function parameter type: 'C'}}
+
+void fa5(D x);
+// expected-error@-1 {{Invalid function parameter type: 'D'}}
+
+void fa6(E x);
+// expected-error@-1 {{Invalid function parameter type: 'E'}}
+
+void fa7(F x);
+// expected-error@-1 {{Invalid function parameter type: 'F'}}
+
+void fa8(G x);
+// expected-error@-1 {{Invalid function parameter type: 'G'}}
+
+template void fa9(T x);
+// expected-error@-1 {{Invalid function parameter type: 'A'}}
+// expected-note@-2 {{candidate template ignored: substitution failure [with T = A]}}
+void fa9_caller() {
+  A x;
+  fa9(x);
+  // expected-error@-1 {{no matching function for call to 'fa9'}}
+  // expected-note@-2 {{in instantiation of function template specialization 'fa9' requested here}}
+}
+
+void fa10() {
+  I x;
+  // expected-note@-1 {{in instantiation of template class 'I' requested here}}
+}
+
+void fa11(half x);
+// expected-error@-1 {{Invalid function parameter type: 'half' (aka '_Float16')}}
+
+void fa12(half2 x);
+// expected-error@-1 {{Invalid function parameter type: 'half2' (vector of 2 '_Float16' values)}}
+
+void fa13(J x);
+// expected-error@-1 {{Invalid function parameter type: 'J'}}
+
+void fa14(int x, _Float16 y);
+// expected-error@-1 {{Invalid function parameter type: '_Float16'}}
+
+_Float16 fa15();
+// expected-error@-1 {{Invalid function return type: '_Float16'}}
+
+void fa16(K x);
+
+undefined fa17();
+
+// Check reference or pointers to _Float16/__fp16 or structs containing
+// them are allowed as function parameters in HIP host functions.
+
+void fb1(_Float16 );
+void fb2(_Float16 *x);
+void fb3(A );
+void fb4(A *x);
+
+// Check device function can use _Float16/__fp16 or struct containing
+// them as parameter type.
+__device__ void fc1(A x);
+__global__ void fc2(A x);
+__host__ __device__ void fc3(A x);
Index: clang/lib/Sema/SemaDecl.cpp
===
--- 

[PATCH] D96975: [Sema] Add some basic lambda capture fix-its

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

Nice fixes! A few drive-by comments from me, up to you though.




Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:7459-7460
 "capture-default specified">;
+  def note_lambda_variable_capture_fixit : Note<
+"capture variable %0 by %select{value|reference}1">;
+  def note_lambda_default_capture_fixit : Note<

njames93 wrote:
> Does the variable name need attaching to the note, given the note is attached 
> to a fix-it containing the name of the variable already?
perhaps not, but I don't think it hurts



Comment at: clang/lib/Sema/SemaExpr.cpp:17435
+  // known not to be copy constructible.
+  bool ShouldOfferCopyFix = [&] {
+// Offer a Copy fix even if the type is dependent.

this lambda looks like it could/should be a standalone function



Comment at: clang/lib/Sema/SemaExpr.cpp:17444
+if (CXXRecordDecl *RD = T->getAsCXXRecordDecl()) {
+  if (RD->hasSimpleCopyConstructor())
+return true;

I suspect you need to handle the case where RD is incomplete



Comment at: clang/lib/Sema/SemaExpr.cpp:17453
+}
+return T.isPODType(Sema.getASTContext());
+  }();

POD is rarely precisely the right concept (and deprecated for that reason).
Is isTriviallyCopyableType() just as good here?



Comment at: clang/lib/Sema/SemaExpr.cpp:17457
+  SmallString<32> FixBuffer;
+  StringRef Separator = LSI->NumExplicitCaptures > 0 ? ", " : "";
+  if (Var->getDeclName().isIdentifier() && !Var->getName().empty()) {

This logic assumes there's no default capture, whic his reasonable but not 
locally obvious - add an assert?



Comment at: clang/lib/Sema/SemaExpr.cpp:17489
+  : false;
+// We can't use default capture by copy if any captures already specified
+// capture by copy.

While it's technically possible to transform `[, ]` to `[=, , ]`, it 
seems very unlikely the user actually wants this: we should capture the new 
variable by copy and make that the default, even though so far we've been 
listing captures explicitly and by reference.

On the other hand, transforming `[a, b]` to `[=]` seems more useful, but isn't 
supported.

I'd suggest just leaving both cases out - only offer a default capture if there 
are no explicit captures already.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96975

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


[PATCH] D96975: [Sema] Add some basic lambda capture fix-its

2021-03-08 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:17447
+  if (RD->hasUserDeclaredCopyConstructor())
+for (CXXConstructorDecl *Ctor : RD->ctors()) {
+  if (Ctor->isCopyConstructor())

(braces are not needed here, too)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96975

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


[PATCH] D98034: [clang-tidy] Use-after-move: Ignore moves inside a try_emplace.

2021-03-08 Thread Martin Böhme via Phabricator via cfe-commits
mboehme added a comment.

First of all, sorry for submitting this change prematurely. I don't contribute 
to LLVM/Clang regularly and forgot that reviews should be kept open for a while 
after a reviewer has approved them to give others a chance to chime in. I 
jumped the gun here -- apologies.

In D98034#2606642 , @njames93 wrote:

> In D98034#2606535 , @mboehme wrote:
>
>> In D98034#2606488 , @njames93 wrote:
>>
>>> While `try_emplace` is a special case, it's may not be the only special 
>>> case in someone's codebase, this should be extended with options to let 
>>> users handle their special containers.
>>
>> Sorry, I didn't see your comment before submitting.
>>
>> I agree that there may be other cases of "maybe move" functions, but 
>> try_emplace seems to be the most common case. Handling "maybe move" 
>> functions more general would require some way of annotating them; I felt it 
>> was useful to get the try_emplace case handled first.
>
> The canonical way of doing this in clang-tidy is to add an option to the 
> check which takes a semi-colon delimited list.
> `clang::tidy::utils::options::parseStringList` can then turn that into a 
> vector of string.
> Annoyingly the hasAnyName matcher needs a vector of StringRef's so most 
> checks do something like this
>
>   hasAnyName(SmallVector(
> StringLikeClasses.begin(), StringLikeClasses.end())
>
> As you are reading options, you will need to override the storeOptions method 
> in the check to then store the value read from config, `serializeStringList` 
> is your friend here.
> The documentation will also need updating to describe the option and what it 
> does.

I think I shouldn't just use a `functionDecl(hasAnyName())` matcher with a 
string list; here's why.

In the case of `try_emplace`, it makes sense to match on any method (or even a 
free function) with that name. I was originally restricting myself to only the 
standard map types, but as @sammccall pointed out to me, someone using this 
pretty unique name in their own code is very likely to be using the same 
semantics as the standard map types.

This may not be true for all methods that a user might want to specify though. 
Say a user has

  class MyClass {
  public:
bool Insert(OtherClass &&);
  };

where, as for `try_emplace`, the boolean return value says whether the 
insertion actually happened.

We wouldn't simply want to ignore `std::move` arguments on any method called 
`Insert`. It's likely that there are other methods called `Insert` in the 
codebase that take an rvalue reference and move from it unconditionally, and we 
want the check to look at those.

So we'd want the user to be able to specify the qualified name 
`MyClass::Insert` as the function to ignore. This makes the matcher a bit more 
interesting as we'd need to work out when seeing a string like this whether 
`MyClass` is a class name or a namespace name. Or we might simply do something 
like

  anyOf(
  // maybe `MyClass` is a namespace...
  functionDecl(hasName("MyClass::Insert")),
  // ...or maybe it's a class
  cxxMethodDecl(ofClass(hasName("MyClass")), hasName("Insert"))
  )

I assume there isn't an existing matcher that does this -- or are you aware of 
one?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98034

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


  1   2   >