[PATCH] D77334: [AVR] Remove duplicate specification of lib directory

2020-06-18 Thread Dylan McKay via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG03b0831144a9: [AVR] Remove duplicate specification of lib 
directory (authored by dylanmckay).

Changed prior to commit:
  https://reviews.llvm.org/D77334?vs=254606=271915#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77334

Files:
  clang/lib/Driver/ToolChains/AVR.cpp


Index: clang/lib/Driver/ToolChains/AVR.cpp
===
--- clang/lib/Driver/ToolChains/AVR.cpp
+++ clang/lib/Driver/ToolChains/AVR.cpp
@@ -79,8 +79,6 @@
 
 getFilePaths().push_back(LibcRoot + std::string("/lib/") +
  std::string(*FamilyName));
-getFilePaths().push_back(LibcRoot + std::string("/lib/") +
- std::string(*FamilyName));
 getFilePaths().push_back(GCCRoot + std::string("/") +
  std::string(*FamilyName));
 


Index: clang/lib/Driver/ToolChains/AVR.cpp
===
--- clang/lib/Driver/ToolChains/AVR.cpp
+++ clang/lib/Driver/ToolChains/AVR.cpp
@@ -79,8 +79,6 @@
 
 getFilePaths().push_back(LibcRoot + std::string("/lib/") +
  std::string(*FamilyName));
-getFilePaths().push_back(LibcRoot + std::string("/lib/") +
- std::string(*FamilyName));
 getFilePaths().push_back(GCCRoot + std::string("/") +
  std::string(*FamilyName));
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D77334: [AVR] Remove duplicate specification of lib directory

2020-06-18 Thread Dylan McKay via Phabricator via cfe-commits
dylanmckay added a comment.

Sorry, I lost track of this. Committed in 
01741d6dbec11c0a0c8e610f0033831735c78d1e 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77334



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


[clang] 01741d6 - [AVR] Remove duplicate specification of lib directory

2020-06-18 Thread Dylan McKay via cfe-commits

Author: Dylan McKay
Date: 2020-06-19T17:39:18+12:00
New Revision: 01741d6dbec11c0a0c8e610f0033831735c78d1e

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

LOG: [AVR] Remove duplicate specification of lib directory

Reviewers: dylanmckay

Reviewed By: dylanmckay

Subscribers: Jim, cfe-commits

Tags: #clang

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

This was originally committed in
03b0831144a9fe25aac81498b0a1dec82f4ec5df but I missed the commit
attribution.

Patch by Dennis van der Schagt.

Added: 


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

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/AVR.cpp 
b/clang/lib/Driver/ToolChains/AVR.cpp
index 04655d5b1885..a86d6fa9f357 100644
--- a/clang/lib/Driver/ToolChains/AVR.cpp
+++ b/clang/lib/Driver/ToolChains/AVR.cpp
@@ -77,8 +77,6 @@ AVRToolChain::AVRToolChain(const Driver , const 
llvm::Triple ,
 std::string GCCRoot = std::string(GCCInstallation.getInstallPath());
 std::string LibcRoot = AVRLibcRoot.getValue();
 
-getFilePaths().push_back(LibcRoot + std::string("/lib/") +
- std::string(*FamilyName));
 getFilePaths().push_back(LibcRoot + std::string("/lib/") +
  std::string(*FamilyName));
 getFilePaths().push_back(GCCRoot + std::string("/") +



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


[clang] aeaa09e - Revert "[AVR] Remove duplicate specification of lib directory"

2020-06-18 Thread Dylan McKay via cfe-commits

Author: Dylan McKay
Date: 2020-06-19T17:37:15+12:00
New Revision: aeaa09ec10ee41ef2469f4d69320d386d492bf23

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

LOG: Revert "[AVR] Remove duplicate specification of lib directory"

This reverts commit 03b0831144a9fe25aac81498b0a1dec82f4ec5df.

I forgot to attribute the commit originally so I am recommitting in a
subsequent patch.

Added: 


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

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/AVR.cpp 
b/clang/lib/Driver/ToolChains/AVR.cpp
index a86d6fa9f357..04655d5b1885 100644
--- a/clang/lib/Driver/ToolChains/AVR.cpp
+++ b/clang/lib/Driver/ToolChains/AVR.cpp
@@ -77,6 +77,8 @@ AVRToolChain::AVRToolChain(const Driver , const 
llvm::Triple ,
 std::string GCCRoot = std::string(GCCInstallation.getInstallPath());
 std::string LibcRoot = AVRLibcRoot.getValue();
 
+getFilePaths().push_back(LibcRoot + std::string("/lib/") +
+ std::string(*FamilyName));
 getFilePaths().push_back(LibcRoot + std::string("/lib/") +
  std::string(*FamilyName));
 getFilePaths().push_back(GCCRoot + std::string("/") +



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


[clang] 03b0831 - [AVR] Remove duplicate specification of lib directory

2020-06-18 Thread Dylan McKay via cfe-commits

Author: Dylan McKay
Date: 2020-06-19T17:35:09+12:00
New Revision: 03b0831144a9fe25aac81498b0a1dec82f4ec5df

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

LOG: [AVR] Remove duplicate specification of lib directory

Reviewers: dylanmckay

Reviewed By: dylanmckay

Subscribers: Jim, cfe-commits

Tags: #clang

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

Added: 


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

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/AVR.cpp 
b/clang/lib/Driver/ToolChains/AVR.cpp
index 04655d5b1885..a86d6fa9f357 100644
--- a/clang/lib/Driver/ToolChains/AVR.cpp
+++ b/clang/lib/Driver/ToolChains/AVR.cpp
@@ -77,8 +77,6 @@ AVRToolChain::AVRToolChain(const Driver , const 
llvm::Triple ,
 std::string GCCRoot = std::string(GCCInstallation.getInstallPath());
 std::string LibcRoot = AVRLibcRoot.getValue();
 
-getFilePaths().push_back(LibcRoot + std::string("/lib/") +
- std::string(*FamilyName));
 getFilePaths().push_back(LibcRoot + std::string("/lib/") +
  std::string(*FamilyName));
 getFilePaths().push_back(GCCRoot + std::string("/") +



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


[PATCH] D65761: Add Windows Control Flow Guard checks (/guard:cf).

2020-06-18 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

It seems like this pass was added in lib/Transforms but does not have any 
unit-tests (lit tests) provided. It isn't even linked into `opt`. As it is an 
LLVM IR pass it should be tested as such I believe. Can you provide tests for 
this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65761



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


[PATCH] D82141: [sve][acle] Add SVE BFloat16 extensions.

2020-06-18 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli created this revision.
fpetrogalli added reviewers: sdesmalen, ctetreau, efriedma, david-arm.
Herald added subscribers: llvm-commits, cfe-commits, psnobl, rkruppe, 
hiraditya, kristof.beyls, tschuett.
Herald added a reviewer: rengolin.
Herald added projects: clang, LLVM.

List of intrinsics:

svfloat32_t svbfdot[_f32](svfloat32_t op1, svbfloat16_t op2, svbfloat16_t op3)
svfloat32_t svbfdot[_n_f32](svfloat32_t op1, svbfloat16_t op2, bfloat16_t op3)
svfloat32_t svbfdot_lane[_f32](svfloat32_t op1, svbfloat16_t op2, svbfloat16_t 
op3, uint64_t imm_index)

svfloat32_t svbfmmla[_f32](svfloat32_t op1, svbfloat16_t op2, svbfloat16_t op3)

svfloat32_t svbfmlalb[_f32](svfloat32_t op1, svbfloat16_t op2, svbfloat16_t op3)
svfloat32_t svbfmlalb[_n_f32](svfloat32_t op1, svbfloat16_t op2, bfloat16_t op3)
svfloat32_t svbfmlalb_lane[_f32](svfloat32_t op1, svbfloat16_t op2, 
svbfloat16_t op3, uint64_t imm_index)

svfloat32_t svbfmlalt[_f32](svfloat32_t op1, svbfloat16_t op2, svbfloat16_t op3)
svfloat32_t svbfmlalt[_n_f32](svfloat32_t op1, svbfloat16_t op2, bfloat16_t op3)
svfloat32_t svbfmlalt_lane[_f32](svfloat32_t op1, svbfloat16_t op2, 
svbfloat16_t op3, uint64_t imm_index)

svbfloat16_t svcvt_bf16[_f32]_m(svbfloat16_t inactive, svbool_t pg, svfloat32_t 
op)
svbfloat16_t svcvt_bf16[_f32]_x(svbool_t pg, svfloat32_t op)
svbfloat16_t svcvt_bf16[_f32]_z(svbool_t pg, svfloat32_t op)

svbfloat16_t svcvtnt_bf16[_f32]_m(svbfloat16_t even, svbool_t pg, svfloat32_t 
op)
svbfloat16_t svcvtnt_bf16[_f32]_x(svbfloat16_t even, svbool_t pg, svfloat32_t 
op)

For reference, see section 7.2 of "Arm C Language Extensions for SVE - Version 
00bet4"


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82141

Files:
  clang/include/clang/Basic/arm_sve.td
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_bfdot.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_bfmlalb.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_bfmlalt.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_bfmmla.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cvt-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cvtnt.c
  clang/utils/TableGen/SveEmitter.cpp
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/lib/Target/AArch64/SVEInstrFormats.td
  llvm/test/CodeGen/AArch64/sve-intrinsics-bfloat.ll

Index: llvm/test/CodeGen/AArch64/sve-intrinsics-bfloat.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/sve-intrinsics-bfloat.ll
@@ -0,0 +1,243 @@
+; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve,+bf16 -asm-verbose=0 < %s | FileCheck %s
+
+;
+; BFDOT
+;
+
+define  @bfdot_f32( %a,  %b,  %c) nounwind {
+; CHECK-LABEL: bfdot_f32:
+; CHECK-NEXT:  bfdot z0.s, z1.h, z2.h
+; CHECK-NEXT:  ret
+  %out = call  @llvm.aarch64.sve.bfdot.nxv4f32( %a,  %b,  %c)
+  ret  %out
+}
+
+define  @bfdot_lane_0_f32( %a,  %b,  %c) nounwind {
+; CHECK-LABEL: bfdot_lane_0_f32:
+; CHECK-NEXT:  bfdot z0.s, z1.h, z2.h[0]
+; CHECK-NEXT:  ret
+  %out = call  @llvm.aarch64.sve.bfdot.lane.nxv4f32( %a,  %b,  %c, i64 0)
+  ret  %out
+}
+
+define  @bfdot_lane_1_f32( %a,  %b,  %c) nounwind {
+; CHECK-LABEL: bfdot_lane_1_f32:
+; CHECK-NEXT:  bfdot z0.s, z1.h, z2.h[1]
+; CHECK-NEXT:  ret
+  %out = call  @llvm.aarch64.sve.bfdot.lane.nxv4f32( %a,  %b,  %c, i64 1)
+  ret  %out
+}
+
+define  @bfdot_lane_2_f32( %a,  %b,  %c) nounwind {
+; CHECK-LABEL: bfdot_lane_2_f32:
+; CHECK-NEXT:  bfdot z0.s, z1.h, z2.h[2]
+; CHECK-NEXT:  ret
+  %out = call  @llvm.aarch64.sve.bfdot.lane.nxv4f32( %a,  %b,  %c, i64 2)
+  ret  %out
+}
+
+define  @bfdot_lane_3_f32( %a,  %b,  %c) nounwind {
+; CHECK-LABEL: bfdot_lane_3_f32:
+; CHECK-NEXT:  bfdot z0.s, z1.h, z2.h[3]
+; CHECK-NEXT:  ret
+  %out = call  @llvm.aarch64.sve.bfdot.lane.nxv4f32( %a,  %b,  %c, i64 3)
+  ret  %out
+}
+
+;
+; BFMLALB
+;
+
+define  @bfmlalb_f32( %a,  %b,  %c) nounwind {
+; CHECK-LABEL: bfmlalb_f32:
+; CHECK-NEXT:  bfmlalb z0.s, z1.h, z2.h
+; CHECK-NEXT:  ret
+  %out = call  @llvm.aarch64.sve.bfmlalb.nxv4f32( %a,  %b,  %c)
+  ret  %out
+}
+
+define  @bfmlalb_lane_0_f32( %a,  %b,  %c) nounwind {
+; CHECK-LABEL: bfmlalb_lane_0_f32:
+; CHECK-NEXT:  bfmlalb z0.s, z1.h, z2.h[0]
+; CHECK-NEXT:  ret
+  %out = call  @llvm.aarch64.sve.bfmlalb.lane.nxv4f32( %a,  %b,  %c, i64 0)
+  ret  %out
+}
+
+define  @bfmlalb_lane_1_f32( %a,  %b,  %c) nounwind {
+; CHECK-LABEL: bfmlalb_lane_1_f32:
+; CHECK-NEXT:  bfmlalb z0.s, z1.h, z2.h[1]
+; CHECK-NEXT:  ret
+  %out = call  @llvm.aarch64.sve.bfmlalb.lane.nxv4f32( %a,  %b,  %c, i64 1)
+  ret  %out
+}
+
+define  @bfmlalb_lane_2_f32( %a,  %b,  %c) nounwind {
+; CHECK-LABEL: bfmlalb_lane_2_f32:
+; CHECK-NEXT:  bfmlalb z0.s, z1.h, z2.h[2]
+; CHECK-NEXT:  ret
+  %out = call  @llvm.aarch64.sve.bfmlalb.lane.nxv4f32( %a,  %b,  %c, i64 2)
+  ret  %out
+}
+
+define  @bfmlalb_lane_3_f32( %a,  %b,  %c) nounwind {
+; CHECK-LABEL: bfmlalb_lane_3_f32:
+; CHECK-NEXT:  bfmlalb z0.s, 

[PATCH] D80242: [Clang] implement -fno-eliminate-unused-debug-types

2020-06-18 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added inline comments.



Comment at: clang/lib/CodeGen/CGDecl.cpp:103-118
+  case Decl::CXXRecord: // struct/union/class X; [C++]
+if (CGDebugInfo *DI = getDebugInfo())
+  if (CGM.getCodeGenOpts().hasMaybeUnusedDebugInfo() &&
+  cast(D).hasDefinition())
+DI->completeUnusedClass(cast(D));
+return;
   case Decl::Record:// struct/union/class X;

All of these might be able to be collapsed together - using 
"cast(D).hasDefinition()" ... to have a common implementation.



Comment at: clang/lib/CodeGen/CGDecl.cpp:105-107
+  if (CGM.getCodeGenOpts().hasMaybeUnusedDebugInfo() &&
+  cast(D).hasDefinition())
+DI->completeUnusedClass(cast(D));

Any particular reason this one's handled differently from the others?



Comment at: clang/lib/CodeGen/CGDecl.cpp:116
+if (CGDebugInfo *DI = getDebugInfo())
+  if (cast()->getDefinition())
+DI->EmitAndRetainType(getContext().getEnumType(cast()));

I think the right thing to call here (& the other places in this patch) is 
"hasDefinition" rather than "getDefinition" (this will avoid the definition 
being deserialized when it's not needed yet (then if we don't end up emitting 
the type because the flag hasn't been given, it won't be deserialized 
unnecessarily))



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:5385
+  if (getCodeGenOpts().hasMaybeUnusedDebugInfo() && CRD->hasDefinition())
+DI->completeUnusedClass(*CRD);
+  else if (auto *ES = D->getASTContext().getExternalSource())

I think this might not work as intended if the type trips over the other class 
deduplication optimizations (try manually testing with a type that has an 
external VTable?) - and perhaps this codepath should use the EmitAndRetain 
functionality.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80242



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


[clang] 6f9fe31 - More test cleanup for c36b03e32556a966e584386ac7dbb110bc7e4bc5.

2020-06-18 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-06-18T18:17:35-07:00
New Revision: 6f9fe31cff083c3bc93ffe9fa80346c1c594a359

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

LOG: More test cleanup for c36b03e32556a966e584386ac7dbb110bc7e4bc5.

Added: 


Modified: 
clang/test/AST/ast-dump-lambda.cpp

Removed: 




diff  --git a/clang/test/AST/ast-dump-lambda.cpp 
b/clang/test/AST/ast-dump-lambda.cpp
index d5f43c114c85..4b53b17aa284 100644
--- a/clang/test/AST/ast-dump-lambda.cpp
+++ b/clang/test/AST/ast-dump-lambda.cpp
@@ -127,7 +127,7 @@ template  void test(Ts... a) {
 // CHECK-NEXT:   | | | `-CompoundStmt {{.*}} 
 // CHECK-NEXT:   | | `-FieldDecl {{.*}}  col:4{{( imported)?}} 
implicit 'Ts...'
 // CHECK-NEXT:   | |-ParenListExpr {{.*}}  'NULL TYPE'
-// CHECK-NEXT:   | | `-DeclRefExpr {{.*}}  'Ts...' lvalue ParmVar 
{{.*}} 'a' 'Ts...'
+// CHECK-NEXT:   | | `-DeclRefExpr {{.*}}  'Ts' lvalue ParmVar 
{{.*}} 'a' 'Ts...'
 // CHECK-NEXT:   | `-CompoundStmt {{.*}} 
 // CHECK-NEXT:   |-LambdaExpr {{.*}}  '(lambda at 
{{.*}}ast-dump-lambda.cpp:24:3)'
 // CHECK-NEXT:   | |-CXXRecordDecl {{.*}}  col:3{{( imported)?}} 
implicit{{( )?}} class definition
@@ -228,7 +228,7 @@ template  void test(Ts... a) {
 // CHECK-NEXT:   | | |-FieldDecl {{.*}}  col:4{{( imported)?}} 
implicit 'Ts...'
 // CHECK-NEXT:   | | `-FieldDecl {{.*}}  col:10{{( imported)?}} 
implicit 'int':'int'
 // CHECK-NEXT:   | |-ParenListExpr {{.*}}  'NULL TYPE'
-// CHECK-NEXT:   | | `-DeclRefExpr {{.*}}  'Ts...' lvalue ParmVar 
{{.*}} 'a' 'Ts...'
+// CHECK-NEXT:   | | `-DeclRefExpr {{.*}}  'Ts' lvalue ParmVar 
{{.*}} 'a' 'Ts...'
 // CHECK-NEXT:   | |-IntegerLiteral {{.*}}  'int' 12
 // CHECK-NEXT:   | `-CompoundStmt {{.*}} 
 // CHECK-NEXT:   |-LambdaExpr {{.*}}  '(lambda at 
{{.*}}ast-dump-lambda.cpp:30:3)'



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


[clang] 9ca50e8 - [libTooling] Add parser for string representation of `RangeSelector`.

2020-06-18 Thread Yitzhak Mandelbaum via cfe-commits

Author: Yitzhak Mandelbaum
Date: 2020-06-19T01:11:29Z
New Revision: 9ca50e887db7f903c04a90593d2beed8a96794f1

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

LOG: [libTooling] Add parser for string representation of `RangeSelector`.

This patch adds a parser for a `RangeSelector` written as a string. The format
is closely based on the way one would right the selector in C++. This should
enable use of `RangeSelector`s from tools like clang-query and web UIs.

Added: 
clang/include/clang/Tooling/Transformer/Parsing.h
clang/lib/Tooling/Transformer/Parsing.cpp

Modified: 
clang/lib/Tooling/Transformer/CMakeLists.txt
clang/unittests/Tooling/RangeSelectorTest.cpp

Removed: 




diff  --git a/clang/include/clang/Tooling/Transformer/Parsing.h 
b/clang/include/clang/Tooling/Transformer/Parsing.h
new file mode 100644
index ..8e51f595cd5b
--- /dev/null
+++ b/clang/include/clang/Tooling/Transformer/Parsing.h
@@ -0,0 +1,41 @@
+//===--- Parsing.h - Parsing library for Transformer *- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+///
+///  \file
+///  Defines parsing functions for Transformer types.
+///  FIXME: Currently, only supports `RangeSelectors` but parsers for other
+///  Transformer types are under development.
+///
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLING_REFACTOR_PARSING_H_
+#define LLVM_CLANG_TOOLING_REFACTOR_PARSING_H_
+
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Tooling/Transformer/RangeSelector.h"
+#include "llvm/Support/Error.h"
+#include 
+#include 
+
+namespace clang {
+namespace transformer {
+
+/// Parses a string representation of a \c RangeSelector. The grammar of these
+/// strings is closely based on the (sub)grammar of \c RangeSelectors as they'd
+/// appear in C++ code. However, this language constrains the set of 
permissible
+/// strings (for node ids) -- it does not support escapes in the
+/// string. Additionally, the \c charRange combinator is not supported, because
+/// there is no representation of values of type \c CharSourceRange in this
+/// (little) language.
+llvm::Expected parseRangeSelector(llvm::StringRef Input);
+
+} // namespace transformer
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLING_REFACTOR_PARSING_H_

diff  --git a/clang/lib/Tooling/Transformer/CMakeLists.txt 
b/clang/lib/Tooling/Transformer/CMakeLists.txt
index 281af1007a65..150b71b1ffcd 100644
--- a/clang/lib/Tooling/Transformer/CMakeLists.txt
+++ b/clang/lib/Tooling/Transformer/CMakeLists.txt
@@ -4,6 +4,7 @@ set(LLVM_LINK_COMPONENTS
 )
 
 add_clang_library(clangTransformer
+  Parsing.cpp
   RangeSelector.cpp
   RewriteRule.cpp
   SourceCode.cpp

diff  --git a/clang/lib/Tooling/Transformer/Parsing.cpp 
b/clang/lib/Tooling/Transformer/Parsing.cpp
new file mode 100644
index ..1579115b9313
--- /dev/null
+++ b/clang/lib/Tooling/Transformer/Parsing.cpp
@@ -0,0 +1,279 @@
+//===--- Parsing.cpp - Parsing function implementations -*- 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 "clang/Tooling/Transformer/Parsing.h"
+#include "clang/AST/Expr.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Basic/CharInfo.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Lex/Lexer.h"
+#include "clang/Tooling/Transformer/RangeSelector.h"
+#include "clang/Tooling/Transformer/SourceCode.h"
+#include "llvm/ADT/None.h"
+#include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Errc.h"
+#include "llvm/Support/Error.h"
+#include 
+#include 
+#include 
+
+using namespace clang;
+using namespace transformer;
+
+// FIXME: This implementation is entirely separate from that of the AST
+// matchers. Given the similarity of the languages and uses of the two parsers,
+// the two should share a common parsing infrastructure, as should other
+// Transformer types. We intend to unify this implementation soon to share as
+// much as possible with the AST Matchers parsing.
+
+namespace {
+using llvm::Error;
+using llvm::Expected;
+
+template  using RangeSelectorOp = RangeSelector (*)(Ts...);
+
+struct ParseState {
+  // The remaining input to be processed.
+  

LLVM buildmaster will be updated and restarted tonight

2020-06-18 Thread Galina Kistanova via cfe-commits
 Hello everyone,

LLVM buildmaster will be updated and restarted after 8PM PST today.

Thanks

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


[clang] c36b03e - The type of a reference to a non-type template parameter pack should

2020-06-18 Thread Richard Smith via cfe-commits

Author: Richard Smith
Date: 2020-06-18T17:52:13-07:00
New Revision: c36b03e32556a966e584386ac7dbb110bc7e4bc5

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

LOG: The type of a reference to a non-type template parameter pack should
not be a pack expansion type.

Using a pack expansion type for a pack declaration makes sense, but
general expressions should never have pack expansion types. If we have a
pack `T *...V`, then the type of `V` is the type `T *`, which contains
an unexpanded pack, and is a pointer type.

This allows us to better diagnose issues where a template is invalid due
to some non-dependent portion of a dependent type of a non-type template
parameter pack.

Added: 


Modified: 
clang/include/clang/AST/Type.h
clang/lib/AST/ASTContext.cpp
clang/lib/AST/Type.cpp
clang/lib/Sema/SemaExpr.cpp
clang/test/AST/ast-dump-expr-json.cpp
clang/test/AST/ast-dump-expr.cpp
clang/test/Import/pack-expansion-expr/test.cpp
clang/test/SemaTemplate/temp_arg_nontype.cpp

Removed: 




diff  --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index d32e657843da..10b8b41efeeb 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -944,6 +944,12 @@ class QualType {
   /// from non-class types (in C++) or all types (in C).
   QualType getNonLValueExprType(const ASTContext ) const;
 
+  /// Remove an outer pack expansion type (if any) from this type. Used as part
+  /// of converting the type of a declaration to the type of an expression that
+  /// references that expression. It's meaningless for an expression to have a
+  /// pack expansion type.
+  QualType getNonPackExpansionType() const;
+
   /// Return the specified type with any "sugar" removed from
   /// the type.  This takes off typedefs, typeof's etc.  If the outer level of
   /// the type is already concrete, it returns it unmodified.  This is similar

diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 01a737e307d0..2ba643f12a82 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -4724,7 +4724,7 @@ TemplateArgument 
ASTContext::getInjectedTemplateArg(NamedDecl *Param) {
   } else if (auto *NTTP = dyn_cast(Param)) {
 Expr *E = new (*this) DeclRefExpr(
 *this, NTTP, /*enclosing*/ false,
-NTTP->getType().getNonLValueExprType(*this),
+NTTP->getType().getNonPackExpansionType().getNonLValueExprType(*this),
 Expr::getValueKindForType(NTTP->getType()), NTTP->getLocation());
 
 if (NTTP->isParameterPack())

diff  --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index 7dd85d1e16ab..ba0d86befe1b 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -3049,6 +3049,13 @@ StringRef BuiltinType::getName(const PrintingPolicy 
) const {
   llvm_unreachable("Invalid builtin type.");
 }
 
+QualType QualType::getNonPackExpansionType() const {
+  // We never wrap type sugar around a PackExpansionType.
+  if (auto *PET = dyn_cast(getTypePtr()))
+return PET->getPattern();
+  return *this;
+}
+
 QualType QualType::getNonLValueExprType(const ASTContext ) const {
   if (const auto *RefType = getTypePtr()->getAs())
 return RefType->getPointeeType();

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 64cb47eab70a..59e7d88b7691 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -3151,6 +3151,11 @@ ExprResult Sema::BuildDeclarationNameExpr(
   return ExprError();
 ExprValueKind valueKind = VK_RValue;
 
+// In 'T ...V;', the type of the declaration 'V' is 'T...', but the type of
+// a reference to 'V' is simply (unexpanded) 'T'. The type, like the value,
+// is expanded by some outer '...' in the context of the use.
+type = type.getNonPackExpansionType();
+
 switch (D->getKind()) {
 // Ignore all the non-ValueDecl kinds.
 #define ABSTRACT_DECL(kind)

diff  --git a/clang/test/AST/ast-dump-expr-json.cpp 
b/clang/test/AST/ast-dump-expr-json.cpp
index 403ce670f193..245c56cafdae 100644
--- a/clang/test/AST/ast-dump-expr-json.cpp
+++ b/clang/test/AST/ast-dump-expr-json.cpp
@@ -5042,7 +5042,7 @@ void TestNonADLCall3() {
 // CHECK-NEXT: }
 // CHECK-NEXT:},
 // CHECK-NEXT:"type": {
-// CHECK-NEXT: "qualType": "Ts..."
+// CHECK-NEXT: "qualType": "Ts"
 // CHECK-NEXT:},
 // CHECK-NEXT:"valueCategory": "lvalue",
 // CHECK-NEXT:"referencedDecl": {
@@ -6622,7 +6622,7 @@ void TestNonADLCall3() {
 // CHECK-NEXT: }
 // CHECK-NEXT:},
 // CHECK-NEXT:"type": {
-// CHECK-NEXT: "qualType": "Ts..."
+// CHECK-NEXT: "qualType": "Ts"
 // 

[PATCH] D80242: [Clang] implement -fno-eliminate-unused-debug-types

2020-06-18 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 271887.
nickdesaulniers added a comment.

- git clang-format HEAD~


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80242

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/docs/CommandGuide/clang.rst
  clang/docs/UsersManual.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Basic/DebugInfoOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/debug-info-unused-types.c
  clang/test/CodeGen/debug-info-unused-types.cpp
  clang/test/Driver/debug-options.c

Index: clang/test/Driver/debug-options.c
===
--- clang/test/Driver/debug-options.c
+++ clang/test/Driver/debug-options.c
@@ -361,3 +361,12 @@
 // GEMBED_2:  error: invalid argument '-gembed-source' only allowed with '-gdwarf-5'
 // NOGEMBED_5-NOT:  "-gembed-source"
 // NOGEMBED_2-NOT:  error: invalid argument '-gembed-source' only allowed with '-gdwarf-5'
+//
+// RUN: %clang -### -g -fno-eliminate-unused-debug-types -c %s 2>&1 \
+// RUN:| FileCheck -check-prefix=DEBUG_UNUSED_TYPES %s
+// DEBUG_UNUSED_TYPES: "-debug-info-kind=unused-types"
+// DEBUG_UNUSED_TYPES-NOT: "-debug-info-kind=limited"
+// RUN: %clang -### -g -feliminate-unused-debug-types -c %s 2>&1 \
+// RUN:| FileCheck -check-prefix=NO_DEBUG_UNUSED_TYPES %s
+// NO_DEBUG_UNUSED_TYPES: "-debug-info-kind=limited"
+// NO_DEBUG_UNUSED_TYPES-NOT: "-debug-info-kind=unused-types"
Index: clang/test/CodeGen/debug-info-unused-types.cpp
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-unused-types.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang++ -fno-eliminate-unused-debug-types -g -emit-llvm -S -o - %s | FileCheck %s
+// RUN: %clang++ -feliminate-unused-debug-types -g -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+// RUN: %clang++ -g -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+// RUN: %clang++ -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+using foo = int;
+class bar {};
+enum class baz { BAZ };
+
+void quux() {
+  using x = int;
+  class y {};
+  enum class z { Z };
+}
+
+// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "baz"
+// CHECK: !DIEnumerator(name: "BAZ"
+// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "z"
+// CHECK: !DIEnumerator(name: "Z"
+// CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "foo"
+// CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "bar"
+// CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "y"
+
+// NODBG-NOT: !DICompositeType(tag: DW_TAG_enumeration_type, name: "baz"
+// NODBG-NOT: !DIEnumerator(name: "BAZ"
+// NODBG-NOT: !DICompositeType(tag: DW_TAG_enumeration_type, name: "z"
+// NODBG-NOT: !DIEnumerator(name: "Z"
+// NODBG-NOT: !DIDerivedType(tag: DW_TAG_typedef, name: "foo"
+// NODBG-NOT: !DICompositeType(tag: DW_TAG_class_type, name: "bar"
+// NODBG-NOT: !DICompositeType(tag: DW_TAG_class_type, name: "y"
+
+class ;
+enum class ;
+
+// NODBG-NOT: ;
+// NODBG-NOT: ;
Index: clang/test/CodeGen/debug-info-unused-types.c
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-unused-types.c
@@ -0,0 +1,60 @@
+// RUN: %clang -fno-eliminate-unused-debug-types -g -emit-llvm -S -o - %s | FileCheck %s
+// RUN: %clang -feliminate-unused-debug-types -g -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+// RUN: %clang -g -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+// RUN: %clang -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+typedef int my_int;
+struct foo {};
+enum bar { BAR };
+union baz {};
+
+void quux(void) {
+  typedef int x;
+  struct y {};
+  enum z { Z };
+  union w {};
+}
+
+// Check that debug info is emitted for the typedef, struct, enum, and union
+// when -fno-eliminate-unused-debug-types and -g are set.
+
+// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "bar"
+// CHECK: !DIEnumerator(name: "BAR"
+// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "z"
+// CHECK: !DIEnumerator(name: "Z"
+// CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "my_int"
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "foo"
+// CHECK: !DICompositeType(tag: DW_TAG_union_type, name: "baz"
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "y"
+// CHECK: !DICompositeType(tag: DW_TAG_union_type, name: "w"
+
+// Check that debug info is not emitted for the typedef, struct, enum, and
+// union when -fno-eliminate-unused-debug-types and -g are not set. These are
+// 

[PATCH] D82130: [WebAssembly] Adding 64-bit versions of __stack_pointer and other globals

2020-06-18 Thread Derek Schuff via Phabricator via cfe-commits
dschuff added a comment.

Yeah I think a 64-bit version of userstack.ll makes sense.  (a fork or a second 
set of CHECKs, whatever you think would be cleaner). There's also 
`stack-alignment.ll` which covers dynamic stack adjustment.




Comment at: lld/wasm/Driver.cpp:385
+StringRef s = arg->getValue();
+if (s == "wasm32")
+  config->is64 = false;

any particular reason this shouldn't use the more conventional `-m32`/`m64`?
edit: nevermind, this is lld not clang. I'll defer to Sam's opinion on lld 
flags.



Comment at: llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp:84
 WasmSym->setGlobalType(wasm::WasmGlobalType{
-uint8_t(Subtarget.hasAddr64() ? wasm::WASM_TYPE_I64
-  : wasm::WASM_TYPE_I32),
+uint8_t(Subtarget.hasAddr64() && strcmp(Name, "__table_base") != 0
+? wasm::WASM_TYPE_I64

should __table_base stay as i32?


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

https://reviews.llvm.org/D82130



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


[PATCH] D80242: [Clang] implement -fno-eliminate-unused-debug-types

2020-06-18 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 271884.
nickdesaulniers added a comment.

- rebase
- make feature progression of debug-info-kind
- fix docs (define, not declare)
- add driver tests
- use OptOutFFlag tablegen helper
- rename helper to EmitAndRetainType
- dont emit debug info for declarations
- rewrite tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80242

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/docs/CommandGuide/clang.rst
  clang/docs/UsersManual.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Basic/DebugInfoOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/debug-info-unused-types.c
  clang/test/CodeGen/debug-info-unused-types.cpp
  clang/test/Driver/debug-options.c

Index: clang/test/Driver/debug-options.c
===
--- clang/test/Driver/debug-options.c
+++ clang/test/Driver/debug-options.c
@@ -361,3 +361,12 @@
 // GEMBED_2:  error: invalid argument '-gembed-source' only allowed with '-gdwarf-5'
 // NOGEMBED_5-NOT:  "-gembed-source"
 // NOGEMBED_2-NOT:  error: invalid argument '-gembed-source' only allowed with '-gdwarf-5'
+//
+// RUN: %clang -### -g -fno-eliminate-unused-debug-types -c %s 2>&1 \
+// RUN:| FileCheck -check-prefix=DEBUG_UNUSED_TYPES %s
+// DEBUG_UNUSED_TYPES: "-debug-info-kind=unused-types"
+// DEBUG_UNUSED_TYPES-NOT: "-debug-info-kind=limited"
+// RUN: %clang -### -g -feliminate-unused-debug-types -c %s 2>&1 \
+// RUN:| FileCheck -check-prefix=NO_DEBUG_UNUSED_TYPES %s
+// NO_DEBUG_UNUSED_TYPES: "-debug-info-kind=limited"
+// NO_DEBUG_UNUSED_TYPES-NOT: "-debug-info-kind=unused-types"
Index: clang/test/CodeGen/debug-info-unused-types.cpp
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-unused-types.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang++ -fno-eliminate-unused-debug-types -g -emit-llvm -S -o - %s | FileCheck %s
+// RUN: %clang++ -feliminate-unused-debug-types -g -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+// RUN: %clang++ -g -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+// RUN: %clang++ -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+using foo = int;
+class bar {};
+enum class baz { BAZ };
+
+void quux() {
+  using x = int;
+  class y {};
+  enum class z { Z };
+}
+
+// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "baz"
+// CHECK: !DIEnumerator(name: "BAZ"
+// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "z"
+// CHECK: !DIEnumerator(name: "Z"
+// CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "foo"
+// CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "bar"
+// CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "y"
+
+// NODBG-NOT: !DICompositeType(tag: DW_TAG_enumeration_type, name: "baz"
+// NODBG-NOT: !DIEnumerator(name: "BAZ"
+// NODBG-NOT: !DICompositeType(tag: DW_TAG_enumeration_type, name: "z"
+// NODBG-NOT: !DIEnumerator(name: "Z"
+// NODBG-NOT: !DIDerivedType(tag: DW_TAG_typedef, name: "foo"
+// NODBG-NOT: !DICompositeType(tag: DW_TAG_class_type, name: "bar"
+// NODBG-NOT: !DICompositeType(tag: DW_TAG_class_type, name: "y"
+
+class ;
+enum class ;
+
+// NODBG-NOT: ;
+// NODBG-NOT: ;
Index: clang/test/CodeGen/debug-info-unused-types.c
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-unused-types.c
@@ -0,0 +1,60 @@
+// RUN: %clang -fno-eliminate-unused-debug-types -g -emit-llvm -S -o - %s | FileCheck %s
+// RUN: %clang -feliminate-unused-debug-types -g -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+// RUN: %clang -g -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+// RUN: %clang -emit-llvm -S -o - %s | FileCheck --check-prefix=NODBG %s
+typedef int my_int;
+struct foo {};
+enum bar { BAR };
+union baz {};
+
+void quux(void) {
+  typedef int x;
+  struct y {};
+  enum z { Z };
+  union w {};
+}
+
+// Check that debug info is emitted for the typedef, struct, enum, and union
+// when -fno-eliminate-unused-debug-types and -g are set.
+
+// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "bar"
+// CHECK: !DIEnumerator(name: "BAR"
+// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type, name: "z"
+// CHECK: !DIEnumerator(name: "Z"
+// CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "my_int"
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "foo"
+// CHECK: !DICompositeType(tag: DW_TAG_union_type, name: "baz"
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "y"
+// CHECK: 

[PATCH] D80242: [Clang] implement -fno-eliminate-unused-debug-types

2020-06-18 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

Ok, I think I have all feedback addresses locally.  One issue I'm hitting is 
that I'm regressing clang/test/OpenMP/parallel_codegen.cpp.  Specifically, it 
seems it has code like:

  template  


  
  int tmain(T argc) {   


  
typedef double (*chunk_t)[argc[0][0]];
  ...

I'm not sure what type `chunk_t` is exactly, but my brain can't parse it.  
Function pointer that returns double (no parameter list?) array? WTF


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80242



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


[clang] 0f92096 - Revert "Hook up OpenBSD 64-bit PowerPC support"

2020-06-18 Thread Brad Smith via cfe-commits

Author: Brad Smith
Date: 2020-06-18T20:05:39-04:00
New Revision: 0f92096c0a9aa97a2818a8cc8e23e0bfc5d3831f

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

LOG: Revert "Hook up OpenBSD 64-bit PowerPC support"

Added: 


Modified: 
clang/lib/Basic/Targets.cpp
clang/lib/Basic/Targets/OSTargets.h
clang/test/Preprocessor/init.c

Removed: 




diff  --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp
index e6384ddef38d..69133ca31fec 100644
--- a/clang/lib/Basic/Targets.cpp
+++ b/clang/lib/Basic/Targets.cpp
@@ -345,8 +345,6 @@ TargetInfo *AllocateTarget(const llvm::Triple ,
   return new FreeBSDTargetInfo(Triple, Opts);
 case llvm::Triple::NetBSD:
   return new NetBSDTargetInfo(Triple, Opts);
-case llvm::Triple::OpenBSD:
-  return new OpenBSDTargetInfo(Triple, Opts);
 case llvm::Triple::AIX:
   return new AIXPPC64TargetInfo(Triple, Opts);
 default:
@@ -359,8 +357,6 @@ TargetInfo *AllocateTarget(const llvm::Triple ,
   return new LinuxTargetInfo(Triple, Opts);
 case llvm::Triple::NetBSD:
   return new NetBSDTargetInfo(Triple, Opts);
-case llvm::Triple::OpenBSD:
-  return new OpenBSDTargetInfo(Triple, Opts);
 default:
   return new PPC64TargetInfo(Triple, Opts);
 }

diff  --git a/clang/lib/Basic/Targets/OSTargets.h 
b/clang/lib/Basic/Targets/OSTargets.h
index d9e09fbd6937..e57ad7b9eeaf 100644
--- a/clang/lib/Basic/Targets/OSTargets.h
+++ b/clang/lib/Basic/Targets/OSTargets.h
@@ -476,8 +476,6 @@ class LLVM_LIBRARY_VISIBILITY OpenBSDTargetInfo : public 
OSTargetInfo {
 case llvm::Triple::mips64:
 case llvm::Triple::mips64el:
 case llvm::Triple::ppc:
-case llvm::Triple::ppc64:
-case llvm::Triple::ppc64le:
 case llvm::Triple::sparcv9:
   this->MCountName = "_mcount";
   break;

diff  --git a/clang/test/Preprocessor/init.c b/clang/test/Preprocessor/init.c
index 9e085a8f9fe8..d6f3225bd04b 100644
--- a/clang/test/Preprocessor/init.c
+++ b/clang/test/Preprocessor/init.c
@@ -7321,8 +7321,6 @@
 // RUN: %clang_cc1 -E -dM -ffreestanding 
-triple=arm-unknown-openbsd6.1-gnueabi < /dev/null | FileCheck 
-match-full-lines -check-prefix OPENBSD %s
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=i386-unknown-openbsd6.1 < 
/dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-unknown-openbsd6.1 < 
/dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s
-// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-unknown-openbsd6.1 
< /dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s
-// RUN: %clang_cc1 -E -dM -ffreestanding 
-triple=powerpc64le-unknown-openbsd6.1 < /dev/null | FileCheck 
-match-full-lines -check-prefix OPENBSD %s
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=mips64-unknown-openbsd6.1 < 
/dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=mips64el-unknown-openbsd6.1 < 
/dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=sparc64-unknown-openbsd6.1 < 
/dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s



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


[PATCH] D78190: Add Bfloat IR type

2020-06-18 Thread Ties Stuij via Phabricator via cfe-commits
stuij marked an inline comment as done.
stuij added inline comments.



Comment at: llvm/include/llvm-c/Core.h:149
   LLVMHalfTypeKind,/**< 16 bit floating point type */
+  LLVMBFloatTypeKind,  /**< 16 bit brain floating point type */
   LLVMFloatTypeKind,   /**< 32 bit floating point type */

stuij wrote:
> tstellar wrote:
> > Can you move this new enum value to the end of enum definition?  Adding it 
> > here changes the C ABI.
> Yes, np. Will make a patch today.
patch up for review: https://reviews.llvm.org/D82135


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78190



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


[PATCH] D81168: Add support for DeclRefExpr in SyntaxTree, by generating IdExpressions

2020-06-18 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

@eduucaldas

Hi, you can drop `Reviewers:` `Subscribers:` `Tags:` and the text `Summary:` 
from the git commit with the following script:

  arcfilter () {
  arc amend
  git log -1 --pretty=%B | awk '/Reviewers:|Subscribers:/{p=1} 
/Reviewed By:|Differential Revision:/{p=0} !p && !/^Summary:$/ {sub(/^Summary: 
/,"");print}' | git commit --amend --date=now -F -
  }

`Reviewed By: ` is considered important by some people. Please keep the tag. (I 
have updated my script to use `--date=now` (setting author date to committer 
date))

`https://reviews.llvm.org/D80978` contains a git pre-push hook to automate this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81168



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


[clang-tools-extra] 8b0df1c - [NFC] Refactor Registry loops to range for

2020-06-18 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2020-06-19T00:40:10+01:00
New Revision: 8b0df1c1a992d203212901c1139665261e0bbc1c

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

LOG: [NFC] Refactor Registry loops to range for

Added: 


Modified: 
clang-tools-extra/clang-doc/Generators.cpp
clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
clang-tools-extra/clangd/URI.cpp
clang/lib/Frontend/FrontendAction.cpp
clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
clang/lib/Lex/Pragma.cpp
clang/lib/Tooling/CompilationDatabase.cpp
clang/lib/Tooling/Execution.cpp
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-doc/Generators.cpp 
b/clang-tools-extra/clang-doc/Generators.cpp
index 3b7dcf93411a..591d43322342 100644
--- a/clang-tools-extra/clang-doc/Generators.cpp
+++ b/clang-tools-extra/clang-doc/Generators.cpp
@@ -15,11 +15,10 @@ namespace doc {
 
 llvm::Expected>
 findGeneratorByName(llvm::StringRef Format) {
-  for (auto I = GeneratorRegistry::begin(), E = GeneratorRegistry::end();
-   I != E; ++I) {
-if (I->getName() != Format)
+  for (const auto  : GeneratorRegistry::entries()) {
+if (Generator.getName() != Format)
   continue;
-return I->instantiate();
+return Generator.instantiate();
   }
   return createStringError(llvm::inconvertibleErrorCode(),
"can't find generator: " + Format);

diff  --git a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp 
b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
index bf146385e4ff..76cb663c8e2e 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
@@ -115,11 +115,10 @@ ClangTidyOptions ClangTidyOptions::getDefaults() {
   Options.FormatStyle = "none";
   Options.User = llvm::None;
   unsigned Priority = 0;
-  for (ClangTidyModuleRegistry::iterator I = ClangTidyModuleRegistry::begin(),
- E = ClangTidyModuleRegistry::end();
-   I != E; ++I)
+  for (const ClangTidyModuleRegistry::entry  :
+   ClangTidyModuleRegistry::entries())
 Options =
-Options.mergeWith(I->instantiate()->getModuleOptions(), ++Priority);
+Options.mergeWith(Module.instantiate()->getModuleOptions(), 
++Priority);
   return Options;
 }
 

diff  --git a/clang-tools-extra/clangd/URI.cpp 
b/clang-tools-extra/clangd/URI.cpp
index 1a125e73a0ca..2061a5601c58 100644
--- a/clang-tools-extra/clangd/URI.cpp
+++ b/clang-tools-extra/clangd/URI.cpp
@@ -63,11 +63,10 @@ findSchemeByName(llvm::StringRef Scheme) {
   if (Scheme == "file")
 return std::make_unique();
 
-  for (auto I = URISchemeRegistry::begin(), E = URISchemeRegistry::end();
-   I != E; ++I) {
-if (I->getName() != Scheme)
+  for (const auto  : URISchemeRegistry::entries()) {
+if (URIScheme.getName() != Scheme)
   continue;
-return I->instantiate();
+return URIScheme.instantiate();
   }
   return make_string_error("Can't find scheme: " + Scheme);
 }

diff  --git a/clang/lib/Frontend/FrontendAction.cpp 
b/clang/lib/Frontend/FrontendAction.cpp
index dc361b2fdd24..59a968b5c709 100644
--- a/clang/lib/Frontend/FrontendAction.cpp
+++ b/clang/lib/Frontend/FrontendAction.cpp
@@ -157,10 +157,9 @@ FrontendAction::CreateWrappedASTConsumer(CompilerInstance 
,
   bool FoundAllPlugins = true;
   for (const std::string  : CI.getFrontendOpts().AddPluginActions) {
 bool Found = false;
-for (FrontendPluginRegistry::iterator it = FrontendPluginRegistry::begin(),
-  ie = FrontendPluginRegistry::end();
- it != ie; ++it) {
-  if (it->getName() == Arg)
+for (const FrontendPluginRegistry::entry  :
+ FrontendPluginRegistry::entries()) {
+  if (Plugin.getName() == Arg)
 Found = true;
 }
 if (!Found) {
@@ -183,26 +182,24 @@ FrontendAction::CreateWrappedASTConsumer(CompilerInstance 
,
   // or after it (in AfterConsumers)
   std::vector> Consumers;
   std::vector> AfterConsumers;
-  for (FrontendPluginRegistry::iterator it = FrontendPluginRegistry::begin(),
-ie = FrontendPluginRegistry::end();
-   it != ie; ++it) {
-std::unique_ptr P = it->instantiate();
+  for (const FrontendPluginRegistry::entry  :
+   FrontendPluginRegistry::entries()) {
+std::unique_ptr P = Plugin.instantiate();
 PluginASTAction::ActionType ActionType = P->getActionType();
 if (ActionType == PluginASTAction::Cmdline) {
   // This is O(|plugins| * |add_plugins|), but since both numbers are
   // way below 50 in practice, that's ok.
-  for (size_t i = 0, e = CI.getFrontendOpts().AddPluginActions.size();
-   i != e; ++i) {
-if 

[clang] 8b0df1c - [NFC] Refactor Registry loops to range for

2020-06-18 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2020-06-19T00:40:10+01:00
New Revision: 8b0df1c1a992d203212901c1139665261e0bbc1c

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

LOG: [NFC] Refactor Registry loops to range for

Added: 


Modified: 
clang-tools-extra/clang-doc/Generators.cpp
clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
clang-tools-extra/clangd/URI.cpp
clang/lib/Frontend/FrontendAction.cpp
clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
clang/lib/Lex/Pragma.cpp
clang/lib/Tooling/CompilationDatabase.cpp
clang/lib/Tooling/Execution.cpp
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-doc/Generators.cpp 
b/clang-tools-extra/clang-doc/Generators.cpp
index 3b7dcf93411a..591d43322342 100644
--- a/clang-tools-extra/clang-doc/Generators.cpp
+++ b/clang-tools-extra/clang-doc/Generators.cpp
@@ -15,11 +15,10 @@ namespace doc {
 
 llvm::Expected>
 findGeneratorByName(llvm::StringRef Format) {
-  for (auto I = GeneratorRegistry::begin(), E = GeneratorRegistry::end();
-   I != E; ++I) {
-if (I->getName() != Format)
+  for (const auto  : GeneratorRegistry::entries()) {
+if (Generator.getName() != Format)
   continue;
-return I->instantiate();
+return Generator.instantiate();
   }
   return createStringError(llvm::inconvertibleErrorCode(),
"can't find generator: " + Format);

diff  --git a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp 
b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
index bf146385e4ff..76cb663c8e2e 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
@@ -115,11 +115,10 @@ ClangTidyOptions ClangTidyOptions::getDefaults() {
   Options.FormatStyle = "none";
   Options.User = llvm::None;
   unsigned Priority = 0;
-  for (ClangTidyModuleRegistry::iterator I = ClangTidyModuleRegistry::begin(),
- E = ClangTidyModuleRegistry::end();
-   I != E; ++I)
+  for (const ClangTidyModuleRegistry::entry  :
+   ClangTidyModuleRegistry::entries())
 Options =
-Options.mergeWith(I->instantiate()->getModuleOptions(), ++Priority);
+Options.mergeWith(Module.instantiate()->getModuleOptions(), 
++Priority);
   return Options;
 }
 

diff  --git a/clang-tools-extra/clangd/URI.cpp 
b/clang-tools-extra/clangd/URI.cpp
index 1a125e73a0ca..2061a5601c58 100644
--- a/clang-tools-extra/clangd/URI.cpp
+++ b/clang-tools-extra/clangd/URI.cpp
@@ -63,11 +63,10 @@ findSchemeByName(llvm::StringRef Scheme) {
   if (Scheme == "file")
 return std::make_unique();
 
-  for (auto I = URISchemeRegistry::begin(), E = URISchemeRegistry::end();
-   I != E; ++I) {
-if (I->getName() != Scheme)
+  for (const auto  : URISchemeRegistry::entries()) {
+if (URIScheme.getName() != Scheme)
   continue;
-return I->instantiate();
+return URIScheme.instantiate();
   }
   return make_string_error("Can't find scheme: " + Scheme);
 }

diff  --git a/clang/lib/Frontend/FrontendAction.cpp 
b/clang/lib/Frontend/FrontendAction.cpp
index dc361b2fdd24..59a968b5c709 100644
--- a/clang/lib/Frontend/FrontendAction.cpp
+++ b/clang/lib/Frontend/FrontendAction.cpp
@@ -157,10 +157,9 @@ FrontendAction::CreateWrappedASTConsumer(CompilerInstance 
,
   bool FoundAllPlugins = true;
   for (const std::string  : CI.getFrontendOpts().AddPluginActions) {
 bool Found = false;
-for (FrontendPluginRegistry::iterator it = FrontendPluginRegistry::begin(),
-  ie = FrontendPluginRegistry::end();
- it != ie; ++it) {
-  if (it->getName() == Arg)
+for (const FrontendPluginRegistry::entry  :
+ FrontendPluginRegistry::entries()) {
+  if (Plugin.getName() == Arg)
 Found = true;
 }
 if (!Found) {
@@ -183,26 +182,24 @@ FrontendAction::CreateWrappedASTConsumer(CompilerInstance 
,
   // or after it (in AfterConsumers)
   std::vector> Consumers;
   std::vector> AfterConsumers;
-  for (FrontendPluginRegistry::iterator it = FrontendPluginRegistry::begin(),
-ie = FrontendPluginRegistry::end();
-   it != ie; ++it) {
-std::unique_ptr P = it->instantiate();
+  for (const FrontendPluginRegistry::entry  :
+   FrontendPluginRegistry::entries()) {
+std::unique_ptr P = Plugin.instantiate();
 PluginASTAction::ActionType ActionType = P->getActionType();
 if (ActionType == PluginASTAction::Cmdline) {
   // This is O(|plugins| * |add_plugins|), but since both numbers are
   // way below 50 in practice, that's ok.
-  for (size_t i = 0, e = CI.getFrontendOpts().AddPluginActions.size();
-   i != e; ++i) {
-if 

[PATCH] D81816: [PowerPC] Add support for vector bool __int128 for Power10

2020-06-18 Thread Ahsan Saghir via Phabricator via cfe-commits
saghir updated this revision to Diff 271874.
saghir added a reviewer: stefanp.
saghir added a comment.

Updated comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81816

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/DeclSpec.cpp
  clang/test/Parser/altivec-bool-128.c
  clang/test/Parser/cxx-altivec-bool-128.cpp
  clang/test/Parser/p10-vector-bool-128.c

Index: clang/test/Parser/p10-vector-bool-128.c
===
--- /dev/null
+++ clang/test/Parser/p10-vector-bool-128.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple=powerpc64-unknown-linux-gnu -target-cpu pwr10 \
+// RUN:-target-feature +vsx -target-feature +power10-vector \
+// RUN:-fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple=powerpc64le-unknown-linux-gnu -target-cpu pwr10 \
+// RUN:-target-feature +power10-vector -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+// Test legitimate uses of 'vector bool __int128' with VSX.
+__vector bool __int128 v1_bi128;
+__vector __bool __int128 v2_bi128;
+vector bool __int128 v3_bi128;
+vector __bool __int128 v4_bi128;
Index: clang/test/Parser/cxx-altivec-bool-128.cpp
===
--- /dev/null
+++ clang/test/Parser/cxx-altivec-bool-128.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple=powerpc64-unknown-linux-gnu \
+// RUN:-target-feature +altivec -fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -triple=powerpc64le-unknown-linux-gnu \
+// RUN:-target-feature +altivec -fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -triple=powerpc64le-unknown-linux-gnu -target-cpu pwr10 \
+// RUN:-target-feature +altivec -target-feature +vsx \
+// RUN:-target-feature -power10-vector -fsyntax-only -verify %s
+
+#include 
+
+// Test 'vector bool __int128' type.
+
+// These should have errors.
+__vector bool __int128 v1_bi128;  // expected-error {{use of '__int128' with '__vector bool' requires VSX support enabled (on POWER10 or later)}}
+__vector __bool __int128 v2_bi128;// expected-error {{use of '__int128' with '__vector bool' requires VSX support enabled (on POWER10 or later)}}
+vector bool __int128 v3_bi128;// expected-error {{use of '__int128' with '__vector bool' requires VSX support enabled (on POWER10 or later)}}
+vector __bool __int128 v4_bi128;  // expected-error {{use of '__int128' with '__vector bool' requires VSX support enabled (on POWER10 or later)}}
+__vector bool unsigned __int128 v5_bi128; // expected-error {{cannot use 'unsigned' with '__vector bool'}} expected-error {{use of '__int128' with '__vector bool' requires VSX support enabled (on POWER10 or later)}}
+__vector bool signed __int128 v6_bi128;   // expected-error {{cannot use 'signed' with '__vector bool'}} expected-error {{use of '__int128' with '__vector bool' requires VSX support enabled (on POWER10 or later)}}
+vector bool unsigned __int128 v7_bi128;   // expected-error {{cannot use 'unsigned' with '__vector bool'}} expected-error {{use of '__int128' with '__vector bool' requires VSX support enabled (on POWER10 or later)}}
+vector bool signed __int128 v8_bi128; // expected-error {{cannot use 'signed' with '__vector bool'}} expected-error {{use of '__int128' with '__vector bool' requires VSX support enabled (on POWER10 or later)}}
+__vector __bool signed __int128 v9_bi128; // expected-error {{cannot use 'signed' with '__vector bool'}} expected-error {{use of '__int128' with '__vector bool' requires VSX support enabled (on POWER10 or later)}}
+vector __bool signed __int128 v10_bi128;  // expected-error {{cannot use 'signed' with '__vector bool'}} expected-error {{use of '__int128' with '__vector bool' requires VSX support enabled (on POWER10 or later)}}
Index: clang/test/Parser/altivec-bool-128.c
===
--- /dev/null
+++ clang/test/Parser/altivec-bool-128.c
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -triple=powerpc64-unknown-linux-gnu \
+// RUN:-target-feature +altivec -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple=powerpc64le-unknown-linux-gnu \
+// RUN:-target-feature +altivec -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple=powerpc64le-unknown-linux-gnu -target-cpu pwr10 \
+// RUN:-target-feature +altivec -target-feature +vsx \
+// RUN:-target-feature -power10-vector -fsyntax-only -verify %s
+
+// Test 'vector bool __int128' type.
+
+// These should have errors.
+__vector bool __int128 v1_bi128;  // expected-error {{use of '__int128' with '__vector bool' requires VSX support enabled (on POWER10 or later)}}
+__vector __bool __int128 v2_bi128;// expected-error {{use of '__int128' with '__vector bool' requires VSX support enabled (on POWER10 or later)}}
+vector 

[PATCH] D76342: [OpenMP] Implement '#pragma omp tile'

2020-06-18 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added a comment.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76342



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


[clang] 3008609 - Hook up OpenBSD 64-bit PowerPC support

2020-06-18 Thread Brad Smith via cfe-commits

Author: Brad Smith
Date: 2020-06-18T19:19:45-04:00
New Revision: 3008609d4509c3efc577c0ccbe9d80a8a2eef31a

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

LOG: Hook up OpenBSD 64-bit PowerPC support

Added: 


Modified: 
clang/lib/Basic/Targets.cpp
clang/lib/Basic/Targets/OSTargets.h
clang/test/Preprocessor/init.c

Removed: 




diff  --git a/clang/lib/Basic/Targets.cpp b/clang/lib/Basic/Targets.cpp
index 69133ca31fec..e6384ddef38d 100644
--- a/clang/lib/Basic/Targets.cpp
+++ b/clang/lib/Basic/Targets.cpp
@@ -345,6 +345,8 @@ TargetInfo *AllocateTarget(const llvm::Triple ,
   return new FreeBSDTargetInfo(Triple, Opts);
 case llvm::Triple::NetBSD:
   return new NetBSDTargetInfo(Triple, Opts);
+case llvm::Triple::OpenBSD:
+  return new OpenBSDTargetInfo(Triple, Opts);
 case llvm::Triple::AIX:
   return new AIXPPC64TargetInfo(Triple, Opts);
 default:
@@ -357,6 +359,8 @@ TargetInfo *AllocateTarget(const llvm::Triple ,
   return new LinuxTargetInfo(Triple, Opts);
 case llvm::Triple::NetBSD:
   return new NetBSDTargetInfo(Triple, Opts);
+case llvm::Triple::OpenBSD:
+  return new OpenBSDTargetInfo(Triple, Opts);
 default:
   return new PPC64TargetInfo(Triple, Opts);
 }

diff  --git a/clang/lib/Basic/Targets/OSTargets.h 
b/clang/lib/Basic/Targets/OSTargets.h
index e57ad7b9eeaf..d9e09fbd6937 100644
--- a/clang/lib/Basic/Targets/OSTargets.h
+++ b/clang/lib/Basic/Targets/OSTargets.h
@@ -476,6 +476,8 @@ class LLVM_LIBRARY_VISIBILITY OpenBSDTargetInfo : public 
OSTargetInfo {
 case llvm::Triple::mips64:
 case llvm::Triple::mips64el:
 case llvm::Triple::ppc:
+case llvm::Triple::ppc64:
+case llvm::Triple::ppc64le:
 case llvm::Triple::sparcv9:
   this->MCountName = "_mcount";
   break;

diff  --git a/clang/test/Preprocessor/init.c b/clang/test/Preprocessor/init.c
index d6f3225bd04b..9e085a8f9fe8 100644
--- a/clang/test/Preprocessor/init.c
+++ b/clang/test/Preprocessor/init.c
@@ -7321,6 +7321,8 @@
 // RUN: %clang_cc1 -E -dM -ffreestanding 
-triple=arm-unknown-openbsd6.1-gnueabi < /dev/null | FileCheck 
-match-full-lines -check-prefix OPENBSD %s
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=i386-unknown-openbsd6.1 < 
/dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-unknown-openbsd6.1 < 
/dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-unknown-openbsd6.1 
< /dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s
+// RUN: %clang_cc1 -E -dM -ffreestanding 
-triple=powerpc64le-unknown-openbsd6.1 < /dev/null | FileCheck 
-match-full-lines -check-prefix OPENBSD %s
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=mips64-unknown-openbsd6.1 < 
/dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=mips64el-unknown-openbsd6.1 < 
/dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=sparc64-unknown-openbsd6.1 < 
/dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s



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


[PATCH] D81972: [NFC] Cleanup of EmitCXXGlobalInitFunc() and EmitCXXGlobalDtorFunc()

2020-06-18 Thread Xiangling Liao via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGed1b556954eb: [NFC] Cleanup of EmitCXXGlobalInitFunc() and 
EmitCXXGlobalDtorFunc() (authored by Xiangling_L).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81972

Files:
  clang/lib/CodeGen/CGDeclCXX.cpp


Index: clang/lib/CodeGen/CGDeclCXX.cpp
===
--- clang/lib/CodeGen/CGDeclCXX.cpp
+++ clang/lib/CodeGen/CGDeclCXX.cpp
@@ -533,6 +533,22 @@
   CXXThreadLocals.clear();
 }
 
+static SmallString<128> getTransformedFileName(llvm::Module ) {
+  SmallString<128> FileName = llvm::sys::path::filename(M.getName());
+
+  if (FileName.empty())
+FileName = "";
+
+  for (size_t i = 0; i < FileName.size(); ++i) {
+// Replace everything that's not [a-zA-Z0-9._] with a _. This set happens
+// to be the set of C preprocessing numbers.
+if (!isPreprocessingNumberBody(FileName[i]))
+  FileName[i] = '_';
+  }
+
+  return FileName;
+}
+
 void
 CodeGenModule::EmitCXXGlobalInitFunc() {
   while (!CXXGlobalInits.empty() && !CXXGlobalInits.back())
@@ -577,22 +593,12 @@
 PrioritizedCXXGlobalInits.clear();
   }
 
-  // Include the filename in the symbol name. Including "sub_" matches gcc and
-  // makes sure these symbols appear lexicographically behind the symbols with
-  // priority emitted above.
-  SmallString<128> FileName = llvm::sys::path::filename(getModule().getName());
-  if (FileName.empty())
-FileName = "";
-
-  for (size_t i = 0; i < FileName.size(); ++i) {
-// Replace everything that's not [a-zA-Z0-9._] with a _. This set happens
-// to be the set of C preprocessing numbers.
-if (!isPreprocessingNumberBody(FileName[i]))
-  FileName[i] = '_';
-  }
-
+  // Include the filename in the symbol name. Including "sub_" matches gcc
+  // and makes sure these symbols appear lexicographically behind the symbols
+  // with priority emitted above.
   llvm::Function *Fn = CreateGlobalInitOrDestructFunction(
-  FTy, llvm::Twine("_GLOBAL__sub_I_", FileName), FI);
+  FTy,
+  llvm::Twine("_GLOBAL__sub_I_", getTransformedFileName(getModule())), FI);
 
   CodeGenFunction(*this).GenerateCXXGlobalInitFunc(Fn, CXXGlobalInits);
   AddGlobalCtor(Fn);
@@ -631,6 +637,7 @@
 
   CodeGenFunction(*this).GenerateCXXGlobalDtorsFunc(Fn, CXXGlobalDtors);
   AddGlobalDtor(Fn);
+  CXXGlobalDtors.clear();
 }
 
 /// Emit the code necessary to initialize the given global variable.


Index: clang/lib/CodeGen/CGDeclCXX.cpp
===
--- clang/lib/CodeGen/CGDeclCXX.cpp
+++ clang/lib/CodeGen/CGDeclCXX.cpp
@@ -533,6 +533,22 @@
   CXXThreadLocals.clear();
 }
 
+static SmallString<128> getTransformedFileName(llvm::Module ) {
+  SmallString<128> FileName = llvm::sys::path::filename(M.getName());
+
+  if (FileName.empty())
+FileName = "";
+
+  for (size_t i = 0; i < FileName.size(); ++i) {
+// Replace everything that's not [a-zA-Z0-9._] with a _. This set happens
+// to be the set of C preprocessing numbers.
+if (!isPreprocessingNumberBody(FileName[i]))
+  FileName[i] = '_';
+  }
+
+  return FileName;
+}
+
 void
 CodeGenModule::EmitCXXGlobalInitFunc() {
   while (!CXXGlobalInits.empty() && !CXXGlobalInits.back())
@@ -577,22 +593,12 @@
 PrioritizedCXXGlobalInits.clear();
   }
 
-  // Include the filename in the symbol name. Including "sub_" matches gcc and
-  // makes sure these symbols appear lexicographically behind the symbols with
-  // priority emitted above.
-  SmallString<128> FileName = llvm::sys::path::filename(getModule().getName());
-  if (FileName.empty())
-FileName = "";
-
-  for (size_t i = 0; i < FileName.size(); ++i) {
-// Replace everything that's not [a-zA-Z0-9._] with a _. This set happens
-// to be the set of C preprocessing numbers.
-if (!isPreprocessingNumberBody(FileName[i]))
-  FileName[i] = '_';
-  }
-
+  // Include the filename in the symbol name. Including "sub_" matches gcc
+  // and makes sure these symbols appear lexicographically behind the symbols
+  // with priority emitted above.
   llvm::Function *Fn = CreateGlobalInitOrDestructFunction(
-  FTy, llvm::Twine("_GLOBAL__sub_I_", FileName), FI);
+  FTy,
+  llvm::Twine("_GLOBAL__sub_I_", getTransformedFileName(getModule())), FI);
 
   CodeGenFunction(*this).GenerateCXXGlobalInitFunc(Fn, CXXGlobalInits);
   AddGlobalCtor(Fn);
@@ -631,6 +637,7 @@
 
   CodeGenFunction(*this).GenerateCXXGlobalDtorsFunc(Fn, CXXGlobalDtors);
   AddGlobalDtor(Fn);
+  CXXGlobalDtors.clear();
 }
 
 /// Emit the code necessary to initialize the given global variable.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D81816: [PowerPC] Add support for vector bool __int128 for Power10

2020-06-18 Thread Ahsan Saghir via Phabricator via cfe-commits
saghir updated this revision to Diff 271860.
saghir edited the summary of this revision.
saghir added a comment.

Updated comment to reflect the change in allowed types.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81816

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/DeclSpec.cpp
  clang/test/Parser/altivec-bool-128.c
  clang/test/Parser/cxx-altivec-bool-128.cpp
  clang/test/Parser/p10-vector-bool-128.c

Index: clang/test/Parser/p10-vector-bool-128.c
===
--- /dev/null
+++ clang/test/Parser/p10-vector-bool-128.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple=powerpc64-unknown-linux-gnu -target-cpu pwr10 \
+// RUN:-target-feature +vsx -target-feature +power10-vector \
+// RUN:-fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple=powerpc64le-unknown-linux-gnu -target-cpu pwr10 \
+// RUN:-target-feature +power10-vector -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+// Test legitimate uses of 'vector bool __int128' with VSX.
+__vector bool __int128 v1_bi128;
+__vector __bool __int128 v2_bi128;
+vector bool __int128 v3_bi128;
+vector __bool __int128 v4_bi128;
Index: clang/test/Parser/cxx-altivec-bool-128.cpp
===
--- /dev/null
+++ clang/test/Parser/cxx-altivec-bool-128.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple=powerpc64-unknown-linux-gnu \
+// RUN:-target-feature +altivec -fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -triple=powerpc64le-unknown-linux-gnu \
+// RUN:-target-feature +altivec -fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -triple=powerpc64le-unknown-linux-gnu -target-cpu pwr10 \
+// RUN:-target-feature +altivec -target-feature +vsx \
+// RUN:-target-feature -power10-vector -fsyntax-only -verify %s
+
+#include 
+
+// Test 'vector bool __int128' type.
+
+// These should have errors.
+__vector bool __int128 v1_bi128;  // expected-error {{use of '__int128' with '__vector bool' requires VSX support enabled (on POWER10 or later)}}
+__vector __bool __int128 v2_bi128;// expected-error {{use of '__int128' with '__vector bool' requires VSX support enabled (on POWER10 or later)}}
+vector bool __int128 v3_bi128;// expected-error {{use of '__int128' with '__vector bool' requires VSX support enabled (on POWER10 or later)}}
+vector __bool __int128 v4_bi128;  // expected-error {{use of '__int128' with '__vector bool' requires VSX support enabled (on POWER10 or later)}}
+__vector bool unsigned __int128 v5_bi128; // expected-error {{cannot use 'unsigned' with '__vector bool'}} expected-error {{use of '__int128' with '__vector bool' requires VSX support enabled (on POWER10 or later)}}
+__vector bool signed __int128 v6_bi128;   // expected-error {{cannot use 'signed' with '__vector bool'}} expected-error {{use of '__int128' with '__vector bool' requires VSX support enabled (on POWER10 or later)}}
+vector bool unsigned __int128 v7_bi128;   // expected-error {{cannot use 'unsigned' with '__vector bool'}} expected-error {{use of '__int128' with '__vector bool' requires VSX support enabled (on POWER10 or later)}}
+vector bool signed __int128 v8_bi128; // expected-error {{cannot use 'signed' with '__vector bool'}} expected-error {{use of '__int128' with '__vector bool' requires VSX support enabled (on POWER10 or later)}}
+__vector __bool signed __int128 v9_bi128; // expected-error {{cannot use 'signed' with '__vector bool'}} expected-error {{use of '__int128' with '__vector bool' requires VSX support enabled (on POWER10 or later)}}
+vector __bool signed __int128 v10_bi128;  // expected-error {{cannot use 'signed' with '__vector bool'}} expected-error {{use of '__int128' with '__vector bool' requires VSX support enabled (on POWER10 or later)}}
Index: clang/test/Parser/altivec-bool-128.c
===
--- /dev/null
+++ clang/test/Parser/altivec-bool-128.c
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -triple=powerpc64-unknown-linux-gnu \
+// RUN:-target-feature +altivec -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple=powerpc64le-unknown-linux-gnu \
+// RUN:-target-feature +altivec -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple=powerpc64le-unknown-linux-gnu -target-cpu pwr10 \
+// RUN:-target-feature +altivec -target-feature +vsx \
+// RUN:-target-feature -power10-vector -fsyntax-only -verify %s
+
+// Test 'vector bool __int128' type.
+
+// These should have errors.
+__vector bool __int128 v1_bi128;  // expected-error {{use of '__int128' with '__vector bool' requires VSX support enabled (on POWER10 or later)}}
+__vector __bool __int128 v2_bi128;// expected-error {{use of '__int128' with '__vector bool' requires VSX 

[PATCH] D82130: [WebAssembly] Adding 64-bit versions of __stack_pointer and other globals

2020-06-18 Thread Wouter van Oortmerssen via Phabricator via cfe-commits
aardappel created this revision.
aardappel added reviewers: sbc100, dschuff.
Herald added subscribers: llvm-commits, cfe-commits, sunfish, aheejin, 
hiraditya, jgravelle-google.
Herald added projects: clang, LLVM.
aardappel updated this revision to Diff 271859.
aardappel added a comment.

This is a first iteration, probably needs more tests :) I was thinking of 
forking `userstack.ll` since it has most `__stack_pointer` tests, but I am not 
sure if it's that useful. Needs a test that uses the new wasm-ld flag. Opinions 
welcome.


We have 6 globals, all of which except for __table_base are 64-bit under wasm64.


https://reviews.llvm.org/D82130

Files:
  clang/lib/Driver/ToolChains/WebAssembly.cpp
  lld/wasm/Config.h
  lld/wasm/Driver.cpp
  lld/wasm/InputChunks.cpp
  lld/wasm/Options.td
  llvm/include/llvm/BinaryFormat/Wasm.h
  llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.h
  llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyLateEHPrepare.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp
  llvm/test/MC/WebAssembly/stack-ptr.ll
  llvm/test/MC/WebAssembly/wasm64.s

Index: llvm/test/MC/WebAssembly/wasm64.s
===
--- llvm/test/MC/WebAssembly/wasm64.s
+++ llvm/test/MC/WebAssembly/wasm64.s
@@ -51,6 +51,11 @@
 i64.const   0
 f32.store   .L.str# relocatable offset!
 
+### 64-bit SP
+
+global.get  __stack_pointer
+drop
+
 end_function
 
 .section.rodata..L.str,"",@
@@ -62,7 +67,7 @@
 .size   .L.str, 24
 
 .globaltype myglob64, i64
-
+.globaltype __stack_pointer, i64
 
 
 # CHECK:  .functype   test (i64) -> ()
@@ -155,6 +160,11 @@
 # BIN-NEXT: Kind:GLOBAL
 # BIN-NEXT: GlobalType:  I64
 # BIN-NEXT: GlobalMutable:   true
+# BIN-NEXT:   - Module:  env
+# BIN-NEXT: Field:   __stack_pointer
+# BIN-NEXT: Kind:GLOBAL
+# BIN-NEXT: GlobalType:  I64
+# BIN-NEXT: GlobalMutable:   true
 # BIN-NEXT:   - Type:FUNCTION
 # BIN-NEXT: FunctionTypes:   [ 0 ]
 # BIN-NEXT:   - Type:DATACOUNT
@@ -179,12 +189,15 @@
 # BIN-NEXT:   - Type:R_WASM_MEMORY_ADDR_LEB64
 # BIN-NEXT: Index:   1
 # BIN-NEXT: Offset:  0x0078
+# BIN-NEXT:   - Type: R_WASM_GLOBAL_INDEX_LEB
+# BIN-NEXT: Index: 3
+# BIN-NEXT: Offset: 0x0083
 # BIN-NEXT: Functions:
 # BIN-NEXT:   - Index:   0
 # BIN-NEXT: Locals:
 # BIN-NEXT:   - Type:I64
 # BIN-NEXT: Count:   1
-# BIN-NEXT: Body:42002A02001A20002A02001A42808080808080808080002A02001A2380808080002A02001A42002A02808080808080808080001A43420038020043200038020043428080808080808080800038020043238080808000380200434200380280808080808080808B
+# BIN-NEXT: Body:42002A02001A20002A02001A42808080808080808080002A02001A2380808080002A02001A42002A02808080808080808080001A434200380200432000380200434280808080808080808000380200432380808080003802004342003802808080808080808080002381808080001A0B
 # BIN-NEXT:   - Type:DATA
 # BIN-NEXT: Relocations:
 # BIN-NEXT:   - Type:R_WASM_MEMORY_ADDR_I64
@@ -217,6 +230,11 @@
 # BIN-NEXT: Name:myglob64
 # BIN-NEXT: Flags:   [ UNDEFINED ]
 # BIN-NEXT: Global:  0
+# BIN-NEXT:   - Index:   3
+# BIN-NEXT: Kind:GLOBAL
+# BIN-NEXT: Name:__stack_pointer
+# BIN-NEXT: Flags:   [ UNDEFINED ]
+# BIN-NEXT: Global:  1
 # BIN-NEXT: SegmentInfo:
 # BIN-NEXT:   - Index:   0
 # BIN-NEXT: Name:.rodata..L.str
Index: llvm/test/MC/WebAssembly/stack-ptr.ll
===
--- llvm/test/MC/WebAssembly/stack-ptr.ll
+++ llvm/test/MC/WebAssembly/stack-ptr.ll
@@ -1,6 +1,5 @@
-; RUN: llc -filetype=obj %s -o - | obj2yaml | FileCheck %s
-
-target triple = "wasm32-unknown-unknown"
+; RUN: llc --mtriple=wasm32-unknown-unknown -filetype=obj %s -o - | obj2yaml | FileCheck --check-prefixes CHECK,CHK32 %s
+; RUN: llc --mtriple=wasm64-unknown-unknown -filetype=obj %s -o - | obj2yaml | FileCheck --check-prefixes CHECK,CHK64 %s
 
 ; Function that uses explict stack, and should generate a reference to
 ; __stack_pointer, along with the corresponding reloction entry.
@@ -15,7 +14,8 @@
 ; CHECK:   - Module:  env
 ; CHECK: Field:   __stack_pointer
 ; CHECK: Kind:GLOBAL
-; CHECK: GlobalType:  

[PATCH] D82130: [WebAssembly] Adding 64-bit versions of __stack_pointer and other globals

2020-06-18 Thread Wouter van Oortmerssen via Phabricator via cfe-commits
aardappel updated this revision to Diff 271859.

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

https://reviews.llvm.org/D82130

Files:
  clang/lib/Driver/ToolChains/WebAssembly.cpp
  lld/wasm/Config.h
  lld/wasm/Driver.cpp
  lld/wasm/InputChunks.cpp
  lld/wasm/Options.td
  llvm/include/llvm/BinaryFormat/Wasm.h
  llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyFrameLowering.h
  llvm/lib/Target/WebAssembly/WebAssemblyISelDAGToDAG.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyLateEHPrepare.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp
  llvm/test/MC/WebAssembly/stack-ptr.ll
  llvm/test/MC/WebAssembly/wasm64.s

Index: llvm/test/MC/WebAssembly/wasm64.s
===
--- llvm/test/MC/WebAssembly/wasm64.s
+++ llvm/test/MC/WebAssembly/wasm64.s
@@ -51,6 +51,11 @@
 i64.const   0
 f32.store   .L.str# relocatable offset!
 
+### 64-bit SP
+
+global.get  __stack_pointer
+drop
+
 end_function
 
 .section.rodata..L.str,"",@
@@ -62,7 +67,7 @@
 .size   .L.str, 24
 
 .globaltype myglob64, i64
-
+.globaltype __stack_pointer, i64
 
 
 # CHECK:  .functype   test (i64) -> ()
@@ -155,6 +160,11 @@
 # BIN-NEXT: Kind:GLOBAL
 # BIN-NEXT: GlobalType:  I64
 # BIN-NEXT: GlobalMutable:   true
+# BIN-NEXT:   - Module:  env
+# BIN-NEXT: Field:   __stack_pointer
+# BIN-NEXT: Kind:GLOBAL
+# BIN-NEXT: GlobalType:  I64
+# BIN-NEXT: GlobalMutable:   true
 # BIN-NEXT:   - Type:FUNCTION
 # BIN-NEXT: FunctionTypes:   [ 0 ]
 # BIN-NEXT:   - Type:DATACOUNT
@@ -179,12 +189,15 @@
 # BIN-NEXT:   - Type:R_WASM_MEMORY_ADDR_LEB64
 # BIN-NEXT: Index:   1
 # BIN-NEXT: Offset:  0x0078
+# BIN-NEXT:   - Type: R_WASM_GLOBAL_INDEX_LEB
+# BIN-NEXT: Index: 3
+# BIN-NEXT: Offset: 0x0083
 # BIN-NEXT: Functions:
 # BIN-NEXT:   - Index:   0
 # BIN-NEXT: Locals:
 # BIN-NEXT:   - Type:I64
 # BIN-NEXT: Count:   1
-# BIN-NEXT: Body:42002A02001A20002A02001A42808080808080808080002A02001A2380808080002A02001A42002A02808080808080808080001A43420038020043200038020043428080808080808080800038020043238080808000380200434200380280808080808080808B
+# BIN-NEXT: Body:42002A02001A20002A02001A42808080808080808080002A02001A2380808080002A02001A42002A02808080808080808080001A434200380200432000380200434280808080808080808000380200432380808080003802004342003802808080808080808080002381808080001A0B
 # BIN-NEXT:   - Type:DATA
 # BIN-NEXT: Relocations:
 # BIN-NEXT:   - Type:R_WASM_MEMORY_ADDR_I64
@@ -217,6 +230,11 @@
 # BIN-NEXT: Name:myglob64
 # BIN-NEXT: Flags:   [ UNDEFINED ]
 # BIN-NEXT: Global:  0
+# BIN-NEXT:   - Index:   3
+# BIN-NEXT: Kind:GLOBAL
+# BIN-NEXT: Name:__stack_pointer
+# BIN-NEXT: Flags:   [ UNDEFINED ]
+# BIN-NEXT: Global:  1
 # BIN-NEXT: SegmentInfo:
 # BIN-NEXT:   - Index:   0
 # BIN-NEXT: Name:.rodata..L.str
Index: llvm/test/MC/WebAssembly/stack-ptr.ll
===
--- llvm/test/MC/WebAssembly/stack-ptr.ll
+++ llvm/test/MC/WebAssembly/stack-ptr.ll
@@ -1,6 +1,5 @@
-; RUN: llc -filetype=obj %s -o - | obj2yaml | FileCheck %s
-
-target triple = "wasm32-unknown-unknown"
+; RUN: llc --mtriple=wasm32-unknown-unknown -filetype=obj %s -o - | obj2yaml | FileCheck --check-prefixes CHECK,CHK32 %s
+; RUN: llc --mtriple=wasm64-unknown-unknown -filetype=obj %s -o - | obj2yaml | FileCheck --check-prefixes CHECK,CHK64 %s
 
 ; Function that uses explict stack, and should generate a reference to
 ; __stack_pointer, along with the corresponding reloction entry.
@@ -15,7 +14,8 @@
 ; CHECK:   - Module:  env
 ; CHECK: Field:   __stack_pointer
 ; CHECK: Kind:GLOBAL
-; CHECK: GlobalType:  I32
+; CHK32: GlobalType:  I32
+; CHK64: GlobalType:  I64
 ; CHECK: GlobalMutable:   true
 ; CHECK:   - Type:CODE
 ; CHECK: Relocations:
Index: llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp
===
--- llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp
+++ llvm/lib/Target/WebAssembly/WebAssemblyRegStackify.cpp
@@ -248,7 +248,8 @@
   }
 
   // Check for writes to __stack_pointer 

[PATCH] D82130: [WebAssembly] Adding 64-bit versions of __stack_pointer and other globals

2020-06-18 Thread Wouter van Oortmerssen via Phabricator via cfe-commits
aardappel added a comment.

This is a first iteration, probably needs more tests :) I was thinking of 
forking `userstack.ll` since it has most `__stack_pointer` tests, but I am not 
sure if it's that useful. Needs a test that uses the new wasm-ld flag. Opinions 
welcome.


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

https://reviews.llvm.org/D82130



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


[clang] ed1b556 - [NFC] Cleanup of EmitCXXGlobalInitFunc() and EmitCXXGlobalDtorFunc()

2020-06-18 Thread Xiangling Liao via cfe-commits

Author: Xiangling Liao
Date: 2020-06-18T18:49:23-04:00
New Revision: ed1b556954eb2b1bb50db973860b7cf20494ce15

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

LOG: [NFC] Cleanup of EmitCXXGlobalInitFunc() and EmitCXXGlobalDtorFunc()

Tidy up some code of EmitCXXGlobalInitFunc() and EmitCXXGlobalDtorFunc() as the
pre-work of D74166 patch.

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

Added: 


Modified: 
clang/lib/CodeGen/CGDeclCXX.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp
index 2a01aff9f0f2..b4a8d551a5ae 100644
--- a/clang/lib/CodeGen/CGDeclCXX.cpp
+++ b/clang/lib/CodeGen/CGDeclCXX.cpp
@@ -533,6 +533,22 @@ void CodeGenModule::EmitCXXThreadLocalInitFunc() {
   CXXThreadLocals.clear();
 }
 
+static SmallString<128> getTransformedFileName(llvm::Module ) {
+  SmallString<128> FileName = llvm::sys::path::filename(M.getName());
+
+  if (FileName.empty())
+FileName = "";
+
+  for (size_t i = 0; i < FileName.size(); ++i) {
+// Replace everything that's not [a-zA-Z0-9._] with a _. This set happens
+// to be the set of C preprocessing numbers.
+if (!isPreprocessingNumberBody(FileName[i]))
+  FileName[i] = '_';
+  }
+
+  return FileName;
+}
+
 void
 CodeGenModule::EmitCXXGlobalInitFunc() {
   while (!CXXGlobalInits.empty() && !CXXGlobalInits.back())
@@ -577,22 +593,12 @@ CodeGenModule::EmitCXXGlobalInitFunc() {
 PrioritizedCXXGlobalInits.clear();
   }
 
-  // Include the filename in the symbol name. Including "sub_" matches gcc and
-  // makes sure these symbols appear lexicographically behind the symbols with
-  // priority emitted above.
-  SmallString<128> FileName = llvm::sys::path::filename(getModule().getName());
-  if (FileName.empty())
-FileName = "";
-
-  for (size_t i = 0; i < FileName.size(); ++i) {
-// Replace everything that's not [a-zA-Z0-9._] with a _. This set happens
-// to be the set of C preprocessing numbers.
-if (!isPreprocessingNumberBody(FileName[i]))
-  FileName[i] = '_';
-  }
-
+  // Include the filename in the symbol name. Including "sub_" matches gcc
+  // and makes sure these symbols appear lexicographically behind the symbols
+  // with priority emitted above.
   llvm::Function *Fn = CreateGlobalInitOrDestructFunction(
-  FTy, llvm::Twine("_GLOBAL__sub_I_", FileName), FI);
+  FTy,
+  llvm::Twine("_GLOBAL__sub_I_", getTransformedFileName(getModule())), FI);
 
   CodeGenFunction(*this).GenerateCXXGlobalInitFunc(Fn, CXXGlobalInits);
   AddGlobalCtor(Fn);
@@ -631,6 +637,7 @@ void CodeGenModule::EmitCXXGlobalDtorFunc() {
 
   CodeGenFunction(*this).GenerateCXXGlobalDtorsFunc(Fn, CXXGlobalDtors);
   AddGlobalDtor(Fn);
+  CXXGlobalDtors.clear();
 }
 
 /// Emit the code necessary to initialize the given global variable.



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


[PATCH] D82089: [clang-tidy] modernize-loop-convert reverse iteration support

2020-06-18 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

In D82089#2100802 , @Eugene.Zelenko 
wrote:

> It'll be interesting to run improved check over LLVM code base.


I haven't tried running it over llvm, but I have had success using it with 
clangd in my editor, every loop I've tried seems to work a charm.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82089



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


[PATCH] D69088: [Lex] #pragma clang transform

2020-06-18 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added a comment.
Herald added a subscriber: sstefan1.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69088



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


[PATCH] D82089: [clang-tidy] modernize-loop-convert reverse iteration support

2020-06-18 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 271856.
njames93 added a comment.

- Change default c++20 include to `ranges` instead of `algorithm`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82089

Files:
  clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
  clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.h
  clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/modernize-loop-convert.rst
  clang-tools-extra/test/clang-tidy/checkers/modernize-loop-convert-reverse.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/modernize-loop-convert-reverse.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-loop-convert-reverse.cpp
@@ -0,0 +1,120 @@
+// RUN: %check_clang_tidy -std=c++20 -check-suffix=RANGES %s modernize-loop-convert %t
+
+// RUN: %check_clang_tidy -check-suffix=CUSTOM %s modernize-loop-convert %t -- \
+// RUN:   -config="{CheckOptions: [ \
+// RUN:   {key: modernize-loop-convert.MakeReverseRangeFunction, value: 'llvm::reverse'}, \
+// RUN:   {key: modernize-loop-convert.MakeReverseRangeHeader, value: 'llvm/ADT/STLExtras.h'}]}"
+
+// Ensure the check doesn't transform reverse loops when not in c++20 mode or
+// when UseCxx20ReverseRanges has been disabled
+// RUN: clang-tidy %s -checks=-*,modernize-loop-convert -- -std=c++17 | count 0
+
+// RUN: clang-tidy %s -checks=-*,modernize-loop-convert -config="{CheckOptions: \
+// RUN: [{key: modernize-loop-convert.UseCxx20ReverseRanges, value: 'false'}] \
+// RUN: }" -- -std=c++20 | count 0
+
+// RUN: %check_clang_tidy -check-suffix=CUSTOM-NO-HEADER %s modernize-loop-convert %t -- \
+// RUN:   -config="{CheckOptions: [ \
+// RUN:   {key: modernize-loop-convert.MakeReverseRangeFunction, value: 'globalReverse'}]}"
+
+// Ensure we get a warning if we only supply one of the required reverse range arguments.
+// RUN: %check_clang_tidy -check-suffix=BAD-CUSTOM %s modernize-loop-convert %t -- \
+// RUN:   -config="{CheckOptions: [ \
+// RUN:   {key: modernize-loop-convert.MakeReverseRangeHeader, value: 'ranges/v3/views/reverse.hpp'}]}"
+
+// CHECK-MESSAGES-BAD-CUSTOM: warning: modernize-loop-convert: 'MakeReverseRangeHeader' is set but 'MakeReverseRangeFunction' is not, disabling reverse loop transformation
+
+// Make sure appropiate headers are included
+// CHECK-FIXES-RANGES: #include 
+// CHECK-FIXES-CUSTOM: #include "llvm/ADT/STLExtras.h"
+
+// Make sure no header is included in this example
+// CHECK-FIXES-CUSTOM-NO-HEADER-NOT: #include
+
+template 
+struct reversable {
+  using iterator = T *;
+  using const_iterator = const T *;
+
+  iterator begin();
+  iterator end();
+  iterator rbegin();
+  iterator rend();
+
+  const_iterator begin() const;
+  const_iterator end() const;
+  const_iterator rbegin() const;
+  const_iterator rend() const;
+
+  const_iterator cbegin() const;
+  const_iterator cend() const;
+  const_iterator crbegin() const;
+  const_iterator crend() const;
+};
+
+template 
+void observe(const T &);
+template 
+void mutate(T &);
+
+void constContainer(const reversable ) {
+  // CHECK-MESSAGES-RANGES: :[[@LINE+3]]:3: warning: use range-based for loop instead
+  // CHECK-MESSAGES-CUSTOM: :[[@LINE+2]]:3: warning: use range-based for loop instead
+  // CHECK-MESSAGES-CUSTOM-NO-HEADER: :[[@LINE+1]]:3: warning: use range-based for loop instead
+  for (auto I = Numbers.rbegin(), E = Numbers.rend(); I != E; ++I) {
+observe(*I);
+//  CHECK-FIXES-RANGES: for (int Number : std::ranges::reverse_view(Numbers)) {
+// CHECK-FIXES-RANGES-NEXT: observe(Number);
+//  CHECK-FIXES-CUSTOM: for (int Number : llvm::reverse(Numbers)) {
+// CHECK-FIXES-CUSTOM-NEXT: observe(Number);
+//  CHECK-FIXES-CUSTOM-NO-HEADER: for (int Number : globalReverse(Numbers)) {
+// CHECK-FIXES-CUSTOM-NO-HEADER-NEXT: observe(Number);
+  }
+  // CHECK-MESSAGES-RANGES: :[[@LINE+3]]:3: warning: use range-based for loop instead
+  // CHECK-MESSAGES-CUSTOM: :[[@LINE+2]]:3: warning: use range-based for loop instead
+  // CHECK-MESSAGES-CUSTOM-NO-HEADER: :[[@LINE+1]]:3: warning: use range-based for loop instead
+  for (auto I = Numbers.crbegin(), E = Numbers.crend(); I != E; ++I) {
+observe(*I);
+//  CHECK-FIXES-RANGES: for (int Number : std::ranges::reverse_view(Numbers)) {
+// CHECK-FIXES-RANGES-NEXT: observe(Number);
+//  CHECK-FIXES-CUSTOM: for (int Number : llvm::reverse(Numbers)) {
+// CHECK-FIXES-CUSTOM-NEXT: observe(Number);
+//  CHECK-FIXES-CUSTOM-NO-HEADER: for (int Number : globalReverse(Numbers)) {
+// CHECK-FIXES-CUSTOM-NO-HEADER-NEXT: observe(Number);
+  }
+
+  // Ensure these bad loops aren't transformed.
+  for (auto I = Numbers.rbegin(), E = Numbers.end(); I != E; ++I) {
+observe(*I);
+  }
+  for (auto I = 

[PATCH] D81923: [clang-tidy] Add modernize-use-ranges check.

2020-06-18 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 271855.
njames93 added a comment.

Added `IncludeInserter` to include the `` header.
Added support for reverse iteration controlled by config.
Added support for begin/end calls via pointers.
Made the begin/end call matcher more robust if other checks want to use it down 
the line.
Moved the std lib parts out of the test case into header files.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81923

Files:
  clang-tools-extra/clang-tidy/modernize/CMakeLists.txt
  clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tools-extra/clang-tidy/modernize/UseRangesCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseRangesCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/modernize-use-ranges.rst
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/modernize-use-ranges/algorithm
  
clang-tools-extra/test/clang-tidy/checkers/Inputs/modernize-use-ranges/execution
  clang-tools-extra/test/clang-tidy/checkers/Inputs/modernize-use-ranges/vector
  clang-tools-extra/test/clang-tidy/checkers/modernize-use-ranges.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/modernize-use-ranges.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-use-ranges.cpp
@@ -0,0 +1,133 @@
+// RUN: %check_clang_tidy -std=c++20 %s modernize-use-ranges %t -- -- -isystem %S/Inputs/modernize-use-ranges
+
+// Ensure no warnings are generated when not in c++20 mode
+// RUN: clang-tidy %s -checks=-*,modernize-use-ranges --warnings-as-errors=modernize-use-ranges -- -nostdinc++ -std=c++17 -isystem %S/Inputs/modernize-use-ranges
+
+#include 
+#include 
+#include 
+// CHECK-FIXES: #include 
+
+template 
+class smart_pointer {
+public:
+  T *();
+  T *operator->();
+};
+
+void goodBeginEndCalls(const std::vector ) {
+  std::find(Vec.begin(), Vec.end(), 1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: replace find with std::ranges::find
+  std::find(Vec.cbegin(), Vec.cend(), 1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: replace find with std::ranges::find
+  std::find(std::begin(Vec), std::end(Vec), 1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: replace find with std::ranges::find
+  std::find(std::cbegin(Vec), std::cend(Vec), 1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: replace find with std::ranges::find
+  std::find(std::execution::parallel_policy(), Vec.begin(), Vec.end(), 1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: replace find with std::ranges::find
+
+  // CHECK-FIXES:  std::ranges::find(Vec, 1);
+  // CHECK-FIXES-NEXT: //
+  // CHECK-FIXES-NEXT: std::ranges::find(Vec, 1);
+  // CHECK-FIXES-NEXT: //
+  // CHECK-FIXES-NEXT: std::ranges::find(Vec, 1);
+  // CHECK-FIXES-NEXT: //
+  // CHECK-FIXES-NEXT: std::ranges::find(Vec, 1);
+  // CHECK-FIXES-NEXT: //
+  // CHECK-FIXES-NEXT: std::ranges::find(std::execution::parallel_policy(), Vec, 1);
+  // CHECK-FIXES-NEXT: //
+}
+
+void badBeginEndCalls(const std::vector ,
+  const std::vector ) {
+  // end, begin.
+  std::find(Vec.end(), Vec.begin(), 1);
+  std::find(Vec.cend(), Vec.cbegin(), 1);
+  std::find(std::end(Vec), std::begin(Vec), 1);
+  std::find(std::cend(Vec), std::cbegin(Vec), 1);
+
+  // begin, begin.
+  std::find(Vec.begin(), Vec.begin(), 1);
+  // end, end.
+  std::find(Vec.end(), Vec.end(), 1);
+
+  // Different containers, definitely bad, but not what this check is for.
+  std::find(Vec.begin(), Vec2.end(), 1);
+}
+
+void maybeDualArg(const std::vector , std::vector ) {
+  std::equal(Vec1.begin(), Vec1.end(), Vec2.begin());
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: replace equal with std::ranges::equal
+  std::equal(Vec1.begin(), Vec1.end(), Vec2.begin(), Vec2.end());
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: replace equal with std::ranges::equal
+  std::equal(std::execution::sequenced_policy(), Vec1.begin(), Vec1.end(), Vec2.begin());
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: replace equal with std::ranges::equal
+  std::equal(std::execution::unsequenced_policy(), Vec1.begin(), Vec1.end(), Vec2.begin(), Vec2.end());
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: replace equal with std::ranges::equal
+
+  // CHECK-FIXES:  std::ranges::equal(Vec1, Vec2.begin());
+  // CHECK-FIXES-NEXT: //
+  // CHECK-FIXES-NEXT: std::ranges::equal(Vec1, Vec2);
+  // CHECK-FIXES-NEXT: //
+  // CHECK-FIXES-NEXT: std::ranges::equal(std::execution::sequenced_policy(), Vec1, Vec2.begin());
+  // CHECK-FIXES-NEXT: //
+  // CHECK-FIXES-NEXT: std::ranges::equal(std::execution::unsequenced_policy(), Vec1, Vec2);
+  // CHECK-FIXES-NEXT: //
+}
+
+void dualArg(const std::vector , const std::vector ) {
+  std::includes(Vec1.begin(), Vec1.end(), Vec2.begin(), Vec2.end());
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: replace includes 

[clang] d8c9729 - [docs] Regenerate clang/docs/ClangCommandLineReference.rst

2020-06-18 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2020-06-18T14:52:39-07:00
New Revision: d8c9729216032e82adeb4965ae4e118c01f6b321

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

LOG: [docs] Regenerate clang/docs/ClangCommandLineReference.rst

Added: 


Modified: 
clang/docs/ClangCommandLineReference.rst

Removed: 




diff  --git a/clang/docs/ClangCommandLineReference.rst 
b/clang/docs/ClangCommandLineReference.rst
index 1ebcab1651d0..ee842e779e22 100644
--- a/clang/docs/ClangCommandLineReference.rst
+++ b/clang/docs/ClangCommandLineReference.rst
@@ -56,6 +56,18 @@ Pass the comma separated arguments in  to the assembler
 
 .. option:: -Xarch\_ 
 
+.. program:: clang1
+.. option:: -Xarch\_device 
+.. program:: clang
+
+Pass  to the CUDA/HIP device compilation
+
+.. program:: clang2
+.. option:: -Xarch\_host 
+.. program:: clang
+
+Pass  to the CUDA/HIP host compilation
+
 .. option:: -Xcuda-fatbinary 
 
 Pass  to fatbinary invocation
@@ -142,10 +154,6 @@ Compile CUDA code for both host and device (default).  Has 
no effect on non-CUDA
 
 Compile CUDA code for device only
 
-.. option:: --cuda-gpu-arch=, --no-cuda-gpu-arch=
-
-CUDA GPU architecture (e.g. sm\_35).  May be specified more than once.
-
 .. option:: --cuda-host-only
 
 Compile CUDA code for host only.  Has no effect on non-CUDA compilations.
@@ -200,36 +208,16 @@ Trivial automatic variable initialization to zero is only 
here for benchmarks, i
 
 .. option:: -faligned-new=
 
-.. option:: -fcuda-approx-transcendentals, -fno-cuda-approx-transcendentals
-
-Use approximate transcendental functions
-
 .. option:: -fcuda-flush-denormals-to-zero, -fno-cuda-flush-denormals-to-zero
 
 Flush denormal floating point values to zero in CUDA device mode.
 
-.. option:: -fcuda-short-ptr, -fno-cuda-short-ptr
-
-Use 32-bit pointers for accessing const/local/shared address spaces.
-
 .. option:: -ffixed-r19
 
 Reserve register r19 (Hexagon only)
 
-.. option:: -fgpu-allow-device-init, -fno-gpu-allow-device-init
-
-Allow device side init function in HIP
-
-.. option:: -fgpu-rdc, -fcuda-rdc, -fno-gpu-rdc
-
-Generate relocatable device code, also known as separate compilation mode.
-
 .. option:: -fheinous-gnu-extensions
 
-.. option:: -fhip-new-launch-api, -fno-hip-new-launch-api
-
-Use new kernel launching API for HIP.
-
 .. option:: -flat\_namespace
 
 .. option:: -fopenmp-targets=,...
@@ -364,12 +352,12 @@ Don't error out if the detected version of the CUDA 
install is too low for the r
 
 Disable builtin #include directories
 
-.. option:: -nocudainc
-
 .. option:: -nodefaultlibs
 
 .. option:: -nofixprebinding
 
+.. option:: -nogpuinc, -nocudainc
+
 .. option:: -nogpulib, -nocudalib
 
 Do not link device library for CUDA/HIP device compilation
@@ -474,6 +462,10 @@ Only modify files with a filename contained in the 
provided directory path
 
 .. option:: -object
 
+.. option:: --offload-arch=, --cuda-gpu-arch=, 
--no-offload-arch=
+
+CUDA/HIP offloading device architecture (e.g. sm\_35, gfx906).  May be 
specified more than once.
+
 .. option:: -p, --profile
 
 .. option:: -pagezero\_size
@@ -534,6 +526,10 @@ Print the paths used for finding libraries and programs
 
 Print the normalized target triple
 
+.. option:: -print-targets, --print-targets
+
+Print the registered targets
+
 .. option:: -private\_bundle
 
 .. option:: -pthread, -no-pthread
@@ -818,10 +814,6 @@ Print source range spans in numeric form
 
 Discard value names in LLVM IR
 
-.. option:: -fexperimental-isel, -fno-experimental-isel
-
-Enables the experimental global instruction selector
-
 .. option:: -fexperimental-new-pass-manager, -fno-experimental-new-pass-manager
 
 Enables an experimental new pass manager in LLVM.
@@ -830,6 +822,10 @@ Enables an experimental new pass manager in LLVM.
 
 Use separate accesses for consecutive bitfield runs with legal widths and 
alignments.
 
+.. option:: -fglobal-isel, -fexperimental-isel, -fno-global-isel
+
+Enables the global instruction selector
+
 .. option:: -finline-functions, -fno-inline-functions
 
 Inline suitable functions
@@ -886,6 +882,14 @@ Enable control flow integrity (CFI) checks for cross-DSO 
calls.
 
 Generalize pointers in CFI indirect call type signature checks
 
+.. option:: -fsanitize-coverage-blacklist=
+
+Disable sanitizer coverage instrumentation for modules and functions that 
match the provided special case list, even the whitelisted ones
+
+.. option:: -fsanitize-coverage-whitelist=
+
+Restrict sanitizer coverage instrumentation exclusively to modules and 
functions that match the provided special case list, except the blacklisted ones
+
 .. option:: -fsanitize-coverage=,..., 
-fno-sanitize-coverage=,...
 
 Specify the type of coverage instrumentation for Sanitizers
@@ -914,11 +918,7 @@ Enable use-after-destroy 

[PATCH] D74166: [AIX][Frontend] Static init implementation for AIX considering no priority

2020-06-18 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast accepted this revision.
hubert.reinterpretcast marked an inline comment as done.
hubert.reinterpretcast added a comment.

Thanks; LGTM with minor nit.




Comment at: clang/lib/CodeGen/CodeGenModule.h:1060
+
+  /// Add a sterm finalizer to the C++ global cleanup function.
+  void AddCXXStermFinalizerEntry(llvm::FunctionCallee DtorFn) {

Minor nit: "a sterm" should be "an sterm" if "sterm" is pronounced like 
"es-term".




Comment at: clang/test/CodeGenCXX/aix-static-init.cpp:188
+// CHECK: entry:
+// CHECK:   call void @__finalize__ZZN5test41fEvE11staticLocal()
+// CHECK:   call void @__finalize__ZN5test31tE()

Just a comment: The finalization order of static locals in relation to 
non-locals cannot (using the mechanisms available) be guaranteed to be 
consistent with the reverse order of initialization. I don't think that there 
is a clearly "correct" order, so "whatever falls out" is probably okay.


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

https://reviews.llvm.org/D74166



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


[PATCH] D80935: [PowerPC][Power10] Implement Parallel Bits Deposit/Extract Builtins in LLVM/Clang

2020-06-18 Thread Amy Kwan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc45c1611303b: [PowerPC][Power10] Implement Parallel Bits 
Deposit/Extract Builtins in… (authored by amyk).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80935

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Headers/altivec.h
  clang/test/CodeGen/builtins-ppc-p10.c
  clang/test/CodeGen/builtins-ppc-p10vector.c
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/lib/Target/PowerPC/PPCScheduleP9.td
  llvm/test/CodeGen/PowerPC/p10-bit-manip-ops.ll
  llvm/test/MC/Disassembler/PowerPC/p10insts.txt
  llvm/test/MC/PowerPC/p10.s

Index: llvm/test/MC/PowerPC/p10.s
===
--- /dev/null
+++ llvm/test/MC/PowerPC/p10.s
@@ -0,0 +1,17 @@
+# RUN: llvm-mc -triple powerpc64-unknown-linux-gnu --show-encoding %s | \
+# RUN:   FileCheck -check-prefix=CHECK-BE %s
+# RUN: llvm-mc -triple powerpc64le-unknown-linux-gnu --show-encoding %s | \
+# RUN:   FileCheck -check-prefix=CHECK-LE %s
+
+# CHECK-BE: vpdepd 1, 2, 0# encoding: [0x10,0x22,0x05,0xcd]
+# CHECK-LE: vpdepd 1, 2, 0# encoding: [0xcd,0x05,0x22,0x10]
+vpdepd 1, 2, 0
+# CHECK-BE: vpextd 1, 2, 0# encoding: [0x10,0x22,0x05,0x8d]
+# CHECK-LE: vpextd 1, 2, 0# encoding: [0x8d,0x05,0x22,0x10]
+vpextd 1, 2, 0
+# CHECK-BE: pdepd 1, 2, 4 # encoding: [0x7c,0x41,0x21,0x38]
+# CHECK-LE: pdepd 1, 2, 4 # encoding: [0x38,0x21,0x41,0x7c]
+pdepd 1, 2, 4
+# CHECK-BE: pextd 1, 2, 4 # encoding: [0x7c,0x41,0x21,0x78]
+# CHECK-LE: pextd 1, 2, 4 # encoding: [0x78,0x21,0x41,0x7c]
+pextd 1, 2, 4
Index: llvm/test/MC/Disassembler/PowerPC/p10insts.txt
===
--- /dev/null
+++ llvm/test/MC/Disassembler/PowerPC/p10insts.txt
@@ -0,0 +1,14 @@
+# RUN: llvm-mc --disassemble %s -triple powerpc64-unknown-linux-gnu \
+# RUN:   -mcpu=pwr10 | FileCheck %s
+
+# CHECK: vpdepd 1, 2, 0
+0x10 0x22 0x05 0xcd
+
+# CHECK: vpextd 1, 2, 0
+0x10 0x22 0x05 0x8d
+
+# CHECK: pdepd 1, 2, 4
+0x7c 0x41 0x21 0x38
+
+# CHECK: pextd 1, 2, 4
+0x7c 0x41 0x21 0x78
Index: llvm/test/CodeGen/PowerPC/p10-bit-manip-ops.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/p10-bit-manip-ops.ll
@@ -0,0 +1,51 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
+; RUN:   -mcpu=pwr10 -ppc-asm-full-reg-names -ppc-vsr-nums-as-vr < %s | \
+; RUN:   FileCheck %s
+
+; These test cases aim to test the bit manipulation operations on Power10.
+
+declare <2 x i64> @llvm.ppc.altivec.vpdepd(<2 x i64>, <2 x i64>)
+declare <2 x i64> @llvm.ppc.altivec.vpextd(<2 x i64>, <2 x i64>)
+declare i64 @llvm.ppc.pdepd(i64, i64)
+declare i64 @llvm.ppc.pextd(i64, i64)
+
+define <2 x i64> @test_vpdepd(<2 x i64> %a, <2 x i64> %b) {
+; CHECK-LABEL: test_vpdepd:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vpdepd v2, v2, v3
+; CHECK-NEXT:blr
+entry:
+  %tmp = tail call <2 x i64> @llvm.ppc.altivec.vpdepd(<2 x i64> %a, <2 x i64> %b)
+  ret <2 x i64> %tmp
+}
+
+define <2 x i64> @test_vpextd(<2 x i64> %a, <2 x i64> %b) {
+; CHECK-LABEL: test_vpextd:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vpextd v2, v2, v3
+; CHECK-NEXT:blr
+entry:
+  %tmp = tail call <2 x i64> @llvm.ppc.altivec.vpextd(<2 x i64> %a, <2 x i64> %b)
+  ret <2 x i64> %tmp
+}
+
+define i64 @test_pdepd(i64 %a, i64 %b) {
+; CHECK-LABEL: test_pdepd:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:pdepd r3, r3, r4
+; CHECK-NEXT:blr
+entry:
+  %tmp = tail call i64 @llvm.ppc.pdepd(i64 %a, i64 %b)
+  ret i64 %tmp
+}
+
+define i64 @test_pextd(i64 %a, i64 %b) {
+; CHECK-LABEL: test_pextd:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:pextd r3, r3, r4
+; CHECK-NEXT:blr
+entry:
+  %tmp = tail call i64 @llvm.ppc.pextd(i64 %a, i64 %b)
+  ret i64 %tmp
+}
Index: llvm/lib/Target/PowerPC/PPCScheduleP9.td
===
--- llvm/lib/Target/PowerPC/PPCScheduleP9.td
+++ llvm/lib/Target/PowerPC/PPCScheduleP9.td
@@ -41,8 +41,10 @@
   let CompleteModel = 1;
 
   // Do not support QPX (Quad Processing eXtension), SPE (Signal Processing
-  // Engine), prefixed instructions on Power 9 or PC relative mem ops.
-  let UnsupportedFeatures = [HasQPX, HasSPE, PrefixInstrs, PCRelativeMemops];
+  // Engine), prefixed instructions on Power 9, PC relative mem ops, or
+  // instructions introduced in ISA 3.1.
+  let UnsupportedFeatures = [HasQPX, HasSPE, PrefixInstrs, PCRelativeMemops,
+   

[PATCH] D82029: [Coroutines] Ensure co_await promise.final_suspend() does not throw

2020-06-18 Thread Xun Li via Phabricator via cfe-commits
lxfind marked an inline comment as done.
lxfind added inline comments.



Comment at: clang/test/SemaCXX/coroutine-final-suspend-noexcept.cpp:14
+struct coroutine_handle {
+  static coroutine_handle from_address(void *); // expected-note {{must be 
declared with 'noexcept'}}
+};

lewissbaker wrote:
> I'm not sure that we should be _requiring_ the compiler to emit an error for 
> this line.
> 
> The language specification does not require implementations to declare the 
> from_address() method as noexcept, even though Clang now requires standard 
> library implementations to declare this method as noexcept - this is an 
> additional implementation requirement that Clang is placing on standard 
> library implementations for them to be compatible with Clang's coroutines 
> implementation.
> 
> I guess this is probably ok to raise as an error, though, as most users will 
> just be using the compiler-provided implementation and both libc++/libstdc++ 
> are (currently) compatible.
`from_address` is in fact called as part of `co_await 
__promise.final_suspend()`.
Specifically, when this `co_await` is translated into a call to 
`finalSuspendObjAwaiter.await_suspend(handle)`, the handle parameter is 
obtained by calling `from_address`.
Since the specification requires that `co_await __promise.final_suspend()` 
should not be potentially throwing, it must requires `from_address` to be 
declared as `noexcept`.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82029



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


[clang] c45c161 - [PowerPC][Power10] Implement Parallel Bits Deposit/Extract Builtins in LLVM/Clang

2020-06-18 Thread Amy Kwan via cfe-commits

Author: Amy Kwan
Date: 2020-06-18T16:23:56-05:00
New Revision: c45c1611303b4609016fa69c1c987ede3bf92006

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

LOG: [PowerPC][Power10] Implement Parallel Bits Deposit/Extract Builtins in 
LLVM/Clang

This patch implements builtins for the following prototypes:

vector unsigned long long vec_pdep(vector unsigned long long, vector unsigned 
long long);
vector unsigned long long vec_pext(vector unsigned long long, vector unsigned 
long long __b);
unsigned long long __builtin_pdepd (unsigned long long, unsigned long long);
unsigned long long __builtin_pextd (unsigned long long, unsigned long long);

Revision Depends on D80758

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

Added: 
clang/test/CodeGen/builtins-ppc-p10.c
clang/test/CodeGen/builtins-ppc-p10vector.c
llvm/test/CodeGen/PowerPC/p10-bit-manip-ops.ll
llvm/test/MC/Disassembler/PowerPC/p10insts.txt
llvm/test/MC/PowerPC/p10.s

Modified: 
clang/include/clang/Basic/BuiltinsPPC.def
clang/lib/Headers/altivec.h
llvm/include/llvm/IR/IntrinsicsPowerPC.td
llvm/lib/Target/PowerPC/PPCInstrPrefix.td
llvm/lib/Target/PowerPC/PPCScheduleP9.td

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsPPC.def 
b/clang/include/clang/Basic/BuiltinsPPC.def
index 314e1cc05907..30077e2e8d03 100644
--- a/clang/include/clang/Basic/BuiltinsPPC.def
+++ b/clang/include/clang/Basic/BuiltinsPPC.def
@@ -298,6 +298,10 @@ BUILTIN(__builtin_altivec_vrldmi, 
"V2ULLiV2ULLiV2ULLiV2ULLi", "")
 BUILTIN(__builtin_altivec_vrlwnm, "V4UiV4UiV4Ui", "")
 BUILTIN(__builtin_altivec_vrldnm, "V2ULLiV2ULLiV2ULLi", "")
 
+// P10 Vector Parallel Bits built-ins.
+BUILTIN(__builtin_altivec_vpdepd, "V2ULLiV2ULLiV2ULLi", "")
+BUILTIN(__builtin_altivec_vpextd, "V2ULLiV2ULLiV2ULLi", "")
+
 // VSX built-ins.
 
 BUILTIN(__builtin_vsx_lxvd2x, "V2divC*", "")
@@ -470,6 +474,8 @@ BUILTIN(__builtin_divweu, "UiUiUi", "")
 BUILTIN(__builtin_divde, "SLLiSLLiSLLi", "")
 BUILTIN(__builtin_divdeu, "ULLiULLiULLi", "")
 BUILTIN(__builtin_bpermd, "SLLiSLLiSLLi", "")
+BUILTIN(__builtin_pdepd, "ULLiULLiULLi", "")
+BUILTIN(__builtin_pextd, "ULLiULLiULLi", "")
 
 // Vector int128 (un)pack
 BUILTIN(__builtin_unpack_vector_int128, "ULLiV1LLLii", "")

diff  --git a/clang/lib/Headers/altivec.h b/clang/lib/Headers/altivec.h
index 7e231a2a428e..1e1e57cd1ffc 100644
--- a/clang/lib/Headers/altivec.h
+++ b/clang/lib/Headers/altivec.h
@@ -16761,6 +16761,23 @@ static vector signed short __ATTRS_o_ai 
vec_nabs(vector signed short __a) {
 static vector signed char __ATTRS_o_ai vec_nabs(vector signed char __a) {
   return __builtin_altivec_vminsb(__a, -__a);
 }
+
+#ifdef __POWER10_VECTOR__
+/* vec_pdep */
+
+static __inline__ vector unsigned long long __ATTRS_o_ai
+vec_pdep(vector unsigned long long __a, vector unsigned long long __b) {
+  return __builtin_altivec_vpdepd(__a, __b);
+}
+
+/* vec_pext */
+
+static __inline__ vector unsigned long long __ATTRS_o_ai
+vec_pext(vector unsigned long long __a, vector unsigned long long __b) {
+  return __builtin_altivec_vpextd(__a, __b);
+}
+#endif /* __POWER10_VECTOR__ */
+
 #undef __ATTRS_o_ai
 
 #endif /* __ALTIVEC_H */

diff  --git a/clang/test/CodeGen/builtins-ppc-p10.c 
b/clang/test/CodeGen/builtins-ppc-p10.c
new file mode 100644
index ..c21e8026d0c9
--- /dev/null
+++ b/clang/test/CodeGen/builtins-ppc-p10.c
@@ -0,0 +1,15 @@
+// REQUIRES: powerpc-registered-target
+// RUN: %clang_cc1 -triple powerpc64-unknown-unknown -target-cpu pwr10 \
+// RUN: -emit-llvm %s -o - | FileCheck %s
+
+unsigned long long ulla, ullb;
+
+unsigned long long test_pdepd(void) {
+  // CHECK: @llvm.ppc.pdepd
+  return __builtin_pdepd(ulla, ullb);
+}
+
+unsigned long long test_pextd(void) {
+  // CHECK: @llvm.ppc.pextd
+  return __builtin_pextd(ulla, ullb);
+}

diff  --git a/clang/test/CodeGen/builtins-ppc-p10vector.c 
b/clang/test/CodeGen/builtins-ppc-p10vector.c
new file mode 100644
index ..31c24f382f1e
--- /dev/null
+++ b/clang/test/CodeGen/builtins-ppc-p10vector.c
@@ -0,0 +1,20 @@
+// REQUIRES: powerpc-registered-target
+// RUN: %clang_cc1 -target-feature +vsx -target-feature +altivec \
+// RUN:   -target-cpu pwr10 -triple powerpc64le-unknown-unknown -emit-llvm %s \
+// RUN:   -o - | FileCheck %s
+
+#include 
+
+vector unsigned long long vulla, vullb;
+
+vector unsigned long long test_vpdepd(void) {
+  // CHECK: @llvm.ppc.altivec.vpdepd(<2 x i64>
+  // CHECK-NEXT: ret <2 x i64>
+  return vec_pdep(vulla, vullb);
+}
+
+vector unsigned long long test_vpextd(void) {
+  // CHECK: @llvm.ppc.altivec.vpextd(<2 x i64>
+  // CHECK-NEXT: ret <2 x i64>
+  return vec_pext(vulla, vullb);
+}

diff  --git a/llvm/include/llvm/IR/IntrinsicsPowerPC.td 
b/llvm/include/llvm/IR/IntrinsicsPowerPC.td
index 

[PATCH] D82085: [TRE] markTails marks call sites as tailcalls though some of them are not.

2020-06-18 Thread Alexey Lapshin via Phabricator via cfe-commits
avl added a comment.

> It makes sense to teach tail recursion elimination not to depend so heavily 
> on tail markings. But I don't think that implies we want to mess with the 
> markings themselves.

Ok. Thus I need to drop part of this patch related to more strict tail marking, 
and continue with part which changes pre-requisite for TRE.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82085



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


[PATCH] D82029: [Coroutines] Ensure co_await promise.final_suspend() does not throw

2020-06-18 Thread Lewis Baker via Phabricator via cfe-commits
lewissbaker added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:10521
+def err_coroutine_promise_final_suspend_requires_nothrow : Error<
+  "all code generated by co_await __promise.final_suspend() must not throw"
+>;

I'd perhaps word this to be more direct in what the compiler is requiring.
It's possible to have a function that does not throw that is not declared 
noexcept, but what the compiler requires here is that the expression is 
noexcept - or in standardese "not potentially throwing".

So maybe something like:
> the expression 'co_await __promise.final_suspend()' is required to be 
> non-throwing




Comment at: clang/lib/Sema/SemaCoroutine.cpp:662-664
+  for (const auto *D : ThrowingDecls) {
+S.Diag(D->getEndLoc(), diag::note_coroutine_function_declare_noexcept);
+  }

Should we be sorting the ThrowingDecls by something other than the pointer so 
that the error output has a deterministic order here?



Comment at: clang/lib/Sema/SemaExceptionSpec.cpp:1049
 
-  FT = S.ResolveExceptionSpec(Loc.isInvalid() ? E->getBeginLoc() : Loc, FT);
+  if (Loc.isValid() || (Loc.isInvalid() && E)) {
+FT = S.ResolveExceptionSpec(Loc.isInvalid() ? E->getBeginLoc() : Loc, FT);

The function documentation says at least one of E and Loc must be true.
Should this be an assertion, then, rather than a conditional check?



Comment at: clang/test/AST/Inputs/std-coroutine.h:13
 struct coroutine_handle {
-  static coroutine_handle from_address(void *);
+  static coroutine_handle from_address(void *) noexcept;
 };

Note that the actual `std::coroutine_handle::from_address()` method is not 
specified to have a noexcept declaration, even though it is defined as such in 
both libstdc++/libc++ implementation.

See http://eel.is/c++draft/coroutine.handle#export.import-itemdecl:2

Note, however, that the specification doesn't define a co_await expression in 
terms of coroutine_handle::from_address() or coroutine_handle::from_promise(), 
but is rather just defined in terms of some handle 'h' that refers to the 
current coroutine.

See http://eel.is/c++draft/expr.await#3.5

So while technically we shouldn't be requiring the from_address() method to be 
noexcept, I think that it's probably ok since the compiler, at least in theory, 
has control over how it constructs a handle and can choose to call the 
from_address() method assuming that it is defined noexcept, even though it is 
not required to be.




Comment at: clang/test/SemaCXX/coroutine-final-suspend-noexcept.cpp:14
+struct coroutine_handle {
+  static coroutine_handle from_address(void *); // expected-note {{must be 
declared with 'noexcept'}}
+};

I'm not sure that we should be _requiring_ the compiler to emit an error for 
this line.

The language specification does not require implementations to declare the 
from_address() method as noexcept, even though Clang now requires standard 
library implementations to declare this method as noexcept - this is an 
additional implementation requirement that Clang is placing on standard library 
implementations for them to be compatible with Clang's coroutines 
implementation.

I guess this is probably ok to raise as an error, though, as most users will 
just be using the compiler-provided implementation and both libc++/libstdc++ 
are (currently) compatible.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82029



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


[PATCH] D82085: [TRE] markTails marks call sites as tailcalls though some of them are not.

2020-06-18 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

All "tail" needs to mean is "this call does not reference the current 
function's stack."  That's all, no more or less.

The relevant documentation and APIs are a bit confusing.  A "tail" marking is a 
prerequisite for tailcall optimization, but it's not really related to any of 
the other prerequisites for tailcall optimization.  Dropping the "tail" marking 
just because the call isn't in a tail position would involve a bunch of work 
adding and removing "tail" markings, for no benefit.

It makes sense to teach tail recursion elimination not to depend so heavily on 
tail markings.  But I don't think that implies we want to mess with the 
markings themselves.

> I think the confusion happened exactly because "tail" marking was done for 
> all calls(not for the real tailcalls).

I don't think there's any confusion here.  It's just using the tail markings as 
a conservative estimate of capturing because it has to compute them anyway.  
And TRE in general is simplistic code that nobody has spent much time looking 
at in a long time.  There are very few TRE opportunities in C/C++ code anyway.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82085



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


[PATCH] D82126: [libTooling] Change `selection` stencil to handle some cases of text in macros.

2020-06-18 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel created this revision.
ymandel added a reviewer: gribozavr2.
Herald added a project: clang.

Currently, the `selection` stencil validates the selection before extracting the
text. However, this means that any range inside a macro is rejected as an
error. This patch changes the implementation to first try to map the range to
something reasonable. This makes the behavior consistent with handling of ranges
used for selecting portions of the source to edit.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82126

Files:
  clang/lib/Tooling/Transformer/Stencil.cpp
  clang/unittests/Tooling/StencilTest.cpp


Index: clang/unittests/Tooling/StencilTest.cpp
===
--- clang/unittests/Tooling/StencilTest.cpp
+++ clang/unittests/Tooling/StencilTest.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "clang/Tooling/Transformer/Stencil.h"
+#include "clang/AST/ASTTypeTraits.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Tooling/FixIt.h"
 #include "clang/Tooling/Tooling.h"
@@ -373,6 +374,48 @@
   testExpr(Id, "3;", run(SimpleFn), "Bound");
 }
 
+TEST_F(StencilTest, CatOfMacroRangeSucceeds) {
+  StringRef Snippet = R"cpp(
+#define MACRO 3.77
+  double foo(double d);
+  foo(MACRO);)cpp";
+
+  auto StmtMatch =
+  matchStmt(Snippet, callExpr(callee(functionDecl(hasName("foo"))),
+  argumentCountIs(1),
+  hasArgument(0, expr().bind("arg";
+  ASSERT_TRUE(StmtMatch);
+  Stencil S = cat(node("arg"));
+  EXPECT_THAT_EXPECTED(S->eval(StmtMatch->Result), HasValue("MACRO"));
+}
+
+TEST_F(StencilTest, CatOfMacroArgRangeSucceeds) {
+  StringRef Snippet = R"cpp(
+#define MACRO(a, b) a + b
+  MACRO(2, 3);)cpp";
+
+  auto StmtMatch =
+  matchStmt(Snippet, binaryOperator(hasRHS(expr().bind("rhs";
+  ASSERT_TRUE(StmtMatch);
+  Stencil S = cat(node("rhs"));
+  EXPECT_THAT_EXPECTED(S->eval(StmtMatch->Result), HasValue("3"));
+}
+
+TEST_F(StencilTest, CatOfMacroArgSubRangeSucceeds) {
+  StringRef Snippet = R"cpp(
+#define MACRO(a, b) a + b
+  int foo(int);
+  MACRO(2, foo(3));)cpp";
+
+  auto StmtMatch = matchStmt(
+  Snippet, binaryOperator(hasRHS(callExpr(
+   callee(functionDecl(hasName("foo"))), argumentCountIs(1),
+   hasArgument(0, expr().bind("arg"));
+  ASSERT_TRUE(StmtMatch);
+  Stencil S = cat(node("arg"));
+  EXPECT_THAT_EXPECTED(S->eval(StmtMatch->Result), HasValue("3"));
+}
+
 TEST_F(StencilTest, CatOfInvalidRangeFails) {
   StringRef Snippet = R"cpp(
 #define MACRO (3.77)
Index: clang/lib/Tooling/Transformer/Stencil.cpp
===
--- clang/lib/Tooling/Transformer/Stencil.cpp
+++ clang/lib/Tooling/Transformer/Stencil.cpp
@@ -12,6 +12,7 @@
 #include "clang/AST/Expr.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Basic/SourceLocation.h"
 #include "clang/Lex/Lexer.h"
 #include "clang/Tooling/Transformer/SourceCode.h"
 #include "clang/Tooling/Transformer/SourceCodeBuilders.h"
@@ -226,12 +227,14 @@
 
 Error evalData(const SelectorData , const MatchFinder::MatchResult ,
std::string *Result) {
-  auto Range = Data.Selector(Match);
-  if (!Range)
-return Range.takeError();
-  if (auto Err = tooling::validateEditRange(*Range, *Match.SourceManager))
+  auto RawRange = Data.Selector(Match);
+  if (!RawRange)
+return RawRange.takeError();
+  CharSourceRange Range = Lexer::makeFileCharRange(
+  *RawRange, *Match.SourceManager, Match.Context->getLangOpts());
+  if (auto Err = tooling::validateEditRange(Range, *Match.SourceManager))
 return Err;
-  *Result += tooling::getText(*Range, *Match.Context);
+  *Result += tooling::getText(Range, *Match.Context);
   return Error::success();
 }
 


Index: clang/unittests/Tooling/StencilTest.cpp
===
--- clang/unittests/Tooling/StencilTest.cpp
+++ clang/unittests/Tooling/StencilTest.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "clang/Tooling/Transformer/Stencil.h"
+#include "clang/AST/ASTTypeTraits.h"
 #include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Tooling/FixIt.h"
 #include "clang/Tooling/Tooling.h"
@@ -373,6 +374,48 @@
   testExpr(Id, "3;", run(SimpleFn), "Bound");
 }
 
+TEST_F(StencilTest, CatOfMacroRangeSucceeds) {
+  StringRef Snippet = R"cpp(
+#define MACRO 3.77
+  double foo(double d);
+  foo(MACRO);)cpp";
+
+  auto StmtMatch =
+  matchStmt(Snippet, callExpr(callee(functionDecl(hasName("foo"))),
+  argumentCountIs(1),
+  hasArgument(0, expr().bind("arg";
+  ASSERT_TRUE(StmtMatch);
+  Stencil S = cat(node("arg"));
+  

[PATCH] D81466: [SveEmitter] Add builtins for struct loads/stores (ld2/ld3/etc)

2020-06-18 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: clang/lib/CodeGen/CGBuiltin.cpp:7890
+  Value *Predicate = EmitSVEPredicateCast(Ops[0], VTy);
+  Value *BasePtr= Builder.CreateBitCast(Ops[1], VecPtrTy);
+  Value *Offset = Ops.size() > 3 ? Ops[2] : Builder.getInt32(0);

Whitespace.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81466



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


[PATCH] D81959: [HIP] Enable -amdgpu-internalize-symbols

2020-06-18 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc830d517b4e4: [HIP] Enable -amdgpu-internalize-symbols 
(authored by yaxunl).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81959

Files:
  clang/lib/Driver/ToolChains/HIP.cpp
  clang/test/Driver/hip-link-save-temps.hip
  clang/test/Driver/hip-save-temps.hip
  clang/test/Driver/hip-toolchain-no-rdc.hip
  clang/test/Driver/hip-toolchain-rdc-separate.hip
  clang/test/Driver/hip-toolchain-rdc.hip

Index: clang/test/Driver/hip-toolchain-rdc.hip
===
--- clang/test/Driver/hip-toolchain-rdc.hip
+++ clang/test/Driver/hip-toolchain-rdc.hip
@@ -37,7 +37,8 @@
 // CHECK-NOT: "*.llvm-link"
 // CHECK-NOT: ".*opt"
 // CHECK-NOT: ".*llc"
-// CHECK: {{".*lld.*"}} {{.*}} "-o" "[[IMG_DEV1:.*.out]]" [[A_BC1]] [[B_BC1]]
+// CHECK: {{".*lld.*"}} {{.*}} "-mllvm" "-amdgpu-internalize-symbols"
+// CHECK-SAME: "-o" "[[IMG_DEV1:.*.out]]" [[A_BC1]] [[B_BC1]]
 
 // CHECK: [[CLANG]] "-cc1" "-triple" "amdgcn-amd-amdhsa"
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
@@ -62,7 +63,8 @@
 // CHECK-NOT: "*.llvm-link"
 // CHECK-NOT: ".*opt"
 // CHECK-NOT: ".*llc"
-// CHECK: {{".*lld.*"}} {{.*}} "-o" "[[IMG_DEV2:.*.out]]" [[A_BC2]] [[B_BC2]]
+// CHECK: {{".*lld.*"}} {{.*}} "-mllvm" "-amdgpu-internalize-symbols"
+// CHECK-SAME: "-o" "[[IMG_DEV2:.*.out]]" [[A_BC2]] [[B_BC2]]
 
 // CHECK: [[CLANG]] "-cc1" "-triple" "x86_64-unknown-linux-gnu"
 // CHECK-SAME: "-aux-triple" "amdgcn-amd-amdhsa"
Index: clang/test/Driver/hip-toolchain-rdc-separate.hip
===
--- clang/test/Driver/hip-toolchain-rdc-separate.hip
+++ clang/test/Driver/hip-toolchain-rdc-separate.hip
@@ -97,12 +97,14 @@
 // LINK-NOT: "*.llvm-link"
 // LINK-NOT: ".*opt"
 // LINK-NOT: ".*llc"
-// LINK: {{".*lld.*"}} {{.*}} "-o" "[[IMG_DEV1:.*.out]]" "[[A_BC1]]" "[[B_BC1]]"
+// LINK: {{".*lld.*"}} {{.*}} "-mllvm" "-amdgpu-internalize-symbols"
+// LINK-SAME: "-o" "[[IMG_DEV1:.*.out]]" "[[A_BC1]]" "[[B_BC1]]"
 
 // LINK-NOT: "*.llvm-link"
 // LINK-NOT: ".*opt"
 // LINK-NOT: ".*llc"
-// LINK: {{".*lld.*"}} {{.*}} "-o" "[[IMG_DEV2:.*.out]]" "[[A_BC2]]" "[[B_BC2]]"
+// LINK: {{".*lld.*"}} {{.*}} "-mllvm" "-amdgpu-internalize-symbols"
+// LINK-SAME: "-o" "[[IMG_DEV2:.*.out]]" "[[A_BC2]]" "[[B_BC2]]"
 
 // LINK: [[BUNDLER:".*clang-offload-bundler"]] "-type=o"
 // LINK-SAME: "-targets={{.*}},hip-amdgcn-amd-amdhsa-gfx803,hip-amdgcn-amd-amdhsa-gfx900"
Index: clang/test/Driver/hip-toolchain-no-rdc.hip
===
--- clang/test/Driver/hip-toolchain-no-rdc.hip
+++ clang/test/Driver/hip-toolchain-no-rdc.hip
@@ -38,7 +38,8 @@
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
 // CHECK-SAME: "-emit-obj"
 // CHECK-SAME: {{.*}} "-main-file-name" "a.cu"
-// CHECK-SAME: "-fcuda-is-device" "-fcuda-allow-variadic-functions" "-fvisibility" "hidden"
+// CHECK-SAME: "-fcuda-is-device" "-mllvm" "-amdgpu-internalize-symbols"
+// CHECK-SAME: "-fcuda-allow-variadic-functions" "-fvisibility" "hidden"
 // CHECK-SAME: "-fapply-global-visibility-to-externs"
 // CHECK-SAME: "{{.*}}lib1.bc" "{{.*}}lib2.bc"
 // CHECK-SAME: "-target-cpu" "gfx803"
@@ -60,7 +61,8 @@
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
 // CHECK-SAME: "-emit-obj"
 // CHECK-SAME: {{.*}} "-main-file-name" "a.cu"
-// CHECK-SAME: "-fcuda-is-device" "-fcuda-allow-variadic-functions" "-fvisibility" "hidden"
+// CHECK-SAME: "-fcuda-is-device" "-mllvm" "-amdgpu-internalize-symbols"
+// CHECK-SAME: "-fcuda-allow-variadic-functions" "-fvisibility" "hidden"
 // CHECK-SAME: "-fapply-global-visibility-to-externs"
 // CHECK-SAME: "{{.*}}lib1.bc" "{{.*}}lib2.bc"
 // CHECK-SAME: "-target-cpu" "gfx900"
@@ -98,7 +100,8 @@
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
 // CHECK-SAME: "-emit-obj"
 // CHECK-SAME: {{.*}} "-main-file-name" "b.hip"
-// CHECK-SAME: "-fcuda-is-device" "-fcuda-allow-variadic-functions" "-fvisibility" "hidden"
+// CHECK-SAME: "-fcuda-is-device" "-mllvm" "-amdgpu-internalize-symbols"
+// CHECK-SAME: "-fcuda-allow-variadic-functions" "-fvisibility" "hidden"
 // CHECK-SAME: "-fapply-global-visibility-to-externs"
 // CHECK-SAME: "{{.*}}lib1.bc" "{{.*}}lib2.bc"
 // CHECK-SAME: "-target-cpu" "gfx803"
@@ -120,7 +123,8 @@
 // CHECK-SAME: "-aux-triple" "x86_64-unknown-linux-gnu"
 // CHECK-SAME: "-emit-obj"
 // CHECK-SAME: {{.*}} "-main-file-name" "b.hip"
-// CHECK-SAME: "-fcuda-is-device" "-fcuda-allow-variadic-functions" "-fvisibility" "hidden"
+// CHECK-SAME: "-fcuda-is-device" "-mllvm" "-amdgpu-internalize-symbols"
+// CHECK-SAME: "-fcuda-allow-variadic-functions" "-fvisibility" "hidden"
 // CHECK-SAME: "-fapply-global-visibility-to-externs"
 // CHECK-SAME: "{{.*}}lib1.bc" "{{.*}}lib2.bc"
 // CHECK-SAME: "-target-cpu" "gfx900"

[PATCH] D82085: [TRE] markTails marks call sites as tailcalls though some of them are not.

2020-06-18 Thread Layton Kifer via Phabricator via cfe-commits
laytonio added a comment.

Relevant llvm-dev thread. Noncapture use of locals disabling 
TailRecursionElimination 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82085



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


[PATCH] D80833: [CodeView] Add full repro to LF_BUILDINFO record

2020-06-18 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

I took a look. It consistently fails for me on mac and on Windows in a `git 
bash` shell, but it passes in cmd with unxutils. Maybe this needs something 
like  eac56724fd955af0f8521557cacc57a83f371649 
 ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80833



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


[PATCH] D82122: [analyzer][Liveness][RFC][NFC] Propose to turn statement liveness into expression liveness

2020-06-18 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus created this revision.
Szelethus added reviewers: xazax.hun, NoQ, vsavchenko, balazske, martong, 
baloghadamsoftware, dcoughlin.
Szelethus added a project: clang.
Herald added subscribers: cfe-commits, ASDenysPetrov, steakhal, Charusso, 
gamesh411, dkrupp, donat.nagy, mikhail.ramalho, a.sidorin, rnkovacs, szepet, 
whisperity.

I had a bit of fun with the tags.

Liveness analysis calculates the set of live/dead values in the program. 
However, statements don't always have a value associated with them, expressions 
do. For this reason, I found it puzzling why LivenessAnalysis work with "live 
statements", or answers questions such as "is this statement live". After a bit 
of digging, I found that the only client of statement liveness is 
`EnvironmentManager::removeDeadBindings` (the one modified in this patch), and 
the only non-expression statement it queries are `ObjCForCollectionStmt`s, but 
no lit tests crashed on the added asserts.

This patch isn't necesserily intended to be committed -- it more of a request 
for comments whether it would be safe to change statement liveness to strictly 
expression liveness. It would be great, because my ultimate goal is to merge 
the implementation of UninitializedVariable and LivenessAnalaysis, and add 
Reaching Definitions under the same hood, but the statement liveness was very 
much out of place and makes the merge very awkward, if even possible.

I have a number of changes planned, but I didn't want to go too far ahead of 
myself, in case I missed something fundamental that justifies statement 
liveness as it is.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82122

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


Index: clang/lib/StaticAnalyzer/Core/Environment.cpp
===
--- clang/lib/StaticAnalyzer/Core/Environment.cpp
+++ clang/lib/StaticAnalyzer/Core/Environment.cpp
@@ -183,12 +183,18 @@
  F.getTreeFactory());
 
   // Iterate over the block-expr bindings.
-  for (Environment::iterator I = Env.begin(), E = Env.end();
-   I != E; ++I) {
+  for (Environment::iterator I = Env.begin(), E = Env.end(); I != E; ++I) {
 const EnvironmentEntry  = I.getKey();
 const SVal  = I.getData();
 
-if (SymReaper.isLive(BlkExpr.getStmt(), BlkExpr.getLocationContext())) {
+const bool IsBlkExprLive =
+SymReaper.isLive(BlkExpr.getStmt(), BlkExpr.getLocationContext());
+
+assert((isa(BlkExpr.getStmt()) || !IsBlkExprLive) &&
+   "Only Exprs can be live, LivenessAnalysis argues about the liveness 
"
+   "of *values*!");
+
+if (IsBlkExprLive) {
   // Copy the binding to the new map.
   EBMapRef = EBMapRef.add(BlkExpr, X);
 


Index: clang/lib/StaticAnalyzer/Core/Environment.cpp
===
--- clang/lib/StaticAnalyzer/Core/Environment.cpp
+++ clang/lib/StaticAnalyzer/Core/Environment.cpp
@@ -183,12 +183,18 @@
  F.getTreeFactory());
 
   // Iterate over the block-expr bindings.
-  for (Environment::iterator I = Env.begin(), E = Env.end();
-   I != E; ++I) {
+  for (Environment::iterator I = Env.begin(), E = Env.end(); I != E; ++I) {
 const EnvironmentEntry  = I.getKey();
 const SVal  = I.getData();
 
-if (SymReaper.isLive(BlkExpr.getStmt(), BlkExpr.getLocationContext())) {
+const bool IsBlkExprLive =
+SymReaper.isLive(BlkExpr.getStmt(), BlkExpr.getLocationContext());
+
+assert((isa(BlkExpr.getStmt()) || !IsBlkExprLive) &&
+   "Only Exprs can be live, LivenessAnalysis argues about the liveness "
+   "of *values*!");
+
+if (IsBlkExprLive) {
   // Copy the binding to the new map.
   EBMapRef = EBMapRef.add(BlkExpr, X);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80833: [CodeView] Add full repro to LF_BUILDINFO record

2020-06-18 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

Reverted in rG2ae0df5be7408a79524743762b6c74953f31b805 
. I'll 
investigate the issue on my end.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80833



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


[clang] c830d51 - [HIP] Enable -amdgpu-internalize-symbols

2020-06-18 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2020-06-18T16:34:37-04:00
New Revision: c830d517b4e46abb617a80b3967b26546370c928

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

LOG: [HIP] Enable -amdgpu-internalize-symbols

Enable -amdgpu-internalize-symbols to eliminate unused functions and global 
variables
for whole program to speed up compilation and improve performance.

For -fno-gpu-rdc, -amdgpu-internalize-symbols is passed to clang -cc1.

For -fgpu-rdc, -amdgpu-internalize-symbols is passed to lld.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/HIP.cpp
clang/test/Driver/hip-link-save-temps.hip
clang/test/Driver/hip-save-temps.hip
clang/test/Driver/hip-toolchain-no-rdc.hip
clang/test/Driver/hip-toolchain-rdc-separate.hip
clang/test/Driver/hip-toolchain-rdc.hip

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/HIP.cpp 
b/clang/lib/Driver/ToolChains/HIP.cpp
index b76ed7288000..b9143f98f152 100644
--- a/clang/lib/Driver/ToolChains/HIP.cpp
+++ b/clang/lib/Driver/ToolChains/HIP.cpp
@@ -57,8 +57,14 @@ void AMDGCN::Linker::constructLldCommand(Compilation , 
const JobAction ,
   const llvm::opt::ArgList ) 
const {
   // Construct lld command.
   // The output from ld.lld is an HSA code object file.
-  ArgStringList LldArgs{"-flavor","gnu", "--no-undefined",
-"-shared","-o",  Output.getFilename()};
+  ArgStringList LldArgs{"-flavor",
+"gnu",
+"--no-undefined",
+"-shared",
+"-mllvm",
+"-amdgpu-internalize-symbols",
+"-o",
+Output.getFilename()};
   for (auto Input : Inputs)
 LldArgs.push_back(Input.getFilename());
   const char *Lld = Args.MakeArgString(getToolChain().GetProgramPath("lld"));
@@ -143,6 +149,8 @@ void HIPToolChain::addClangTargetOptions(
   if (DriverArgs.hasFlag(options::OPT_fgpu_rdc, options::OPT_fno_gpu_rdc,
  false))
 CC1Args.push_back("-fgpu-rdc");
+  else
+CC1Args.append({"-mllvm", "-amdgpu-internalize-symbols"});
 
   StringRef MaxThreadsPerBlock =
   DriverArgs.getLastArgValue(options::OPT_gpu_max_threads_per_block_EQ);

diff  --git a/clang/test/Driver/hip-link-save-temps.hip 
b/clang/test/Driver/hip-link-save-temps.hip
index 080cafc5e417..304be921ebc6 100644
--- a/clang/test/Driver/hip-link-save-temps.hip
+++ b/clang/test/Driver/hip-link-save-temps.hip
@@ -23,8 +23,10 @@
 // CHECK-NOT: llvm-link
 // CHECK-NOT: opt
 // CHECK-NOT: llc
-// CHECK: "{{.*lld.*}}" {{.*}} "-o" "a.out-hip-amdgcn-amd-amdhsa-gfx900" 
"obj1-hip-amdgcn-amd-amdhsa-gfx900.o" "obj2-hip-amdgcn-amd-amdhsa-gfx900.o"
-// CHECK: "{{.*lld.*}}" {{.*}} "-o" "a.out-hip-amdgcn-amd-amdhsa-gfx906" 
"obj1-hip-amdgcn-amd-amdhsa-gfx906.o" "obj2-hip-amdgcn-amd-amdhsa-gfx906.o"
+// CHECK: "{{.*lld.*}}" {{.*}} "-mllvm" "-amdgpu-internalize-symbols"
+// CHECK-SAME: "-o" "a.out-hip-amdgcn-amd-amdhsa-gfx900" 
"obj1-hip-amdgcn-amd-amdhsa-gfx900.o" "obj2-hip-amdgcn-amd-amdhsa-gfx900.o"
+// CHECK: "{{.*lld.*}}" {{.*}} "-mllvm" "-amdgpu-internalize-symbols"
+// CHECK-SAME: "-o" "a.out-hip-amdgcn-amd-amdhsa-gfx906" 
"obj1-hip-amdgcn-amd-amdhsa-gfx906.o" "obj2-hip-amdgcn-amd-amdhsa-gfx906.o"
 // OUT: "{{.*clang-offload-bundler.*}}" {{.*}} "-outputs=executable.hipfb"
 // OUT: "{{.*ld.*}}" {{.*}} "-o" "executable" {{.*}} "-T" "executable.lk"
 // NOUT: "{{.*clang-offload-bundler.*}}" {{.*}} "-outputs=a.out.hipfb"

diff  --git a/clang/test/Driver/hip-save-temps.hip 
b/clang/test/Driver/hip-save-temps.hip
index a44ee0d23307..1ac506aa6fba 100644
--- a/clang/test/Driver/hip-save-temps.hip
+++ b/clang/test/Driver/hip-save-temps.hip
@@ -35,14 +35,22 @@
 // CHECK: {{".*clang.*"}} "-cc1" {{.*}} "-E" {{.*}} [[CPU:"-target-cpu" 
"gfx900"]] {{.*}}  "-o" "hip-save-temps-hip-amdgcn-amd-amdhsa-gfx900.cui"
 // NORDC: {{".*clang.*"}} "-cc1" {{.*}} "-emit-llvm-bc" {{.*}} [[CPU]] {{.*}} 
"-disable-llvm-passes" {{.*}} "-o" 
"hip-save-temps-hip-amdgcn-amd-amdhsa-gfx900.bc"
 // RDC: {{".*clang.*"}} "-cc1" {{.*}} "-emit-llvm-bc" {{.*}} [[CPU]] {{.*}} 
"-disable-llvm-passes" {{.*}} "-o" 
"hip-save-temps-hip-amdgcn-amd-amdhsa-gfx900.tmp.bc"
-// NORDC: {{".*clang.*"}} "-cc1" {{.*}} "-S" {{.*}} [[CPU]] {{.*}} "-o" 
"hip-save-temps-hip-amdgcn-amd-amdhsa-gfx900.s"
+
+// NORDC: {{".*clang.*"}} "-cc1" {{.*}} "-S"
+// NORDC-SAME: "-mllvm" "-amdgpu-internalize-symbols"
+// NORDC-SAME: [[CPU]]
+// NORDC-SAME: "-o" "hip-save-temps-hip-amdgcn-amd-amdhsa-gfx900.s"
+
 // RDC: {{".*clang.*"}} "-cc1" {{.*}} "-emit-llvm-bc" {{.*}} [[CPU]] {{.*}} 
"-o" "hip-save-temps-hip-amdgcn-amd-amdhsa-gfx900.bc"
 // NORDC: 

[clang] 2ae0df5 - [CodeView] Revert 8374bf43634725dc02a262a77b5f940fca25938c and 403f9537924b8910ed4f741ed96c61f5e657915b

2020-06-18 Thread Alexandre Ganea via cfe-commits

Author: Alexandre Ganea
Date: 2020-06-18T16:18:46-04:00
New Revision: 2ae0df5be7408a79524743762b6c74953f31b805

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

LOG: [CodeView] Revert 8374bf43634725dc02a262a77b5f940fca25938c and 
403f9537924b8910ed4f741ed96c61f5e657915b

This reverts:
8374bf43634725dc02a262a77b5f940fca25938c [CodeView] Fix generated command-line 
expansion in LF_BUILDINFO. Fix the 'pdb' entry which was previously a null 
reference, now an empty string.
403f9537924b8910ed4f741ed96c61f5e657915b [CodeView] Add full repro to 
LF_BUILDINFO record

This is causing the lld/test/COFF/pdb-relative-source-lines.test to fail: 
http://lab.llvm.org:8011/builders/lld-x86_64-win/builds/1096/steps/test-check-all/logs/FAIL%3A%20lld%3A%3Apdb-relative-source-lines.test
And clang/test/CodeGen/debug-info-codeview-buildinfo.c fails as well: 
http://lab.llvm.org:8011/builders/clang-s390x-linux/builds/33346/steps/ninja%20check%201/logs/FAIL%3A%20Clang%3A%3Adebug-info-codeview-buildinfo.c

Added: 


Modified: 
lld/COFF/PDB.cpp
lld/test/COFF/Inputs/pdb_lines_1_relative.yaml
lld/test/COFF/Inputs/pdb_lines_2_relative.yaml
lld/test/COFF/pdb-relative-source-lines.test
llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
llvm/test/DebugInfo/COFF/build-info.ll
llvm/test/DebugInfo/COFF/global-type-hashes.ll
llvm/test/DebugInfo/COFF/types-basic.ll
llvm/test/DebugInfo/COFF/types-data-members.ll

Removed: 
clang/test/CodeGen/debug-info-codeview-buildinfo.c



diff  --git a/clang/test/CodeGen/debug-info-codeview-buildinfo.c 
b/clang/test/CodeGen/debug-info-codeview-buildinfo.c
deleted file mode 100644
index 5d37162b7325..
--- a/clang/test/CodeGen/debug-info-codeview-buildinfo.c
+++ /dev/null
@@ -1,25 +0,0 @@
-// RUN: %clang_cl /c /Z7 /Fo%t.obj -- %s
-// RUN: llvm-pdbutil dump --types %t.obj | FileCheck %s
-// RUN: %clang_cl /c /Z7 /Fo%t.obj -fdebug-compilation-dir . -- %s
-// RUN: llvm-pdbutil dump --types %t.obj | FileCheck %s --check-prefix RELATIVE
-
-int main() { return 42; }
-
-// CHECK:   Types (.debug$T)
-// CHECK: 
-// CHECK: 0x[[PWD:.+]] | LF_STRING_ID [size = {{.+}}] ID: , String: 
[[PWDVAL:.+]]
-// CHECK: 0x[[FILEPATH:.+]] | LF_STRING_ID [size = {{.+}}] ID: , 
String: [[FILEPATHVAL:.+[\\/]debug-info-codeview-buildinfo.c]]
-// CHECK: 0x[[ZIPDB:.+]] | LF_STRING_ID [size = {{.+}}] ID: , String:
-// CHECK: 0x[[TOOL:.+]] | LF_STRING_ID [size = {{.+}}] ID: , String: 
[[TOOLVAL:.+[\\/]clang.*]]
-// CHECK: 0x[[CMDLINE:.+]] | LF_STRING_ID [size = {{.+}}] ID: , 
String: "-cc1
-// CHECK: 0x{{.+}} | LF_BUILDINFO [size = {{.+}}]
-// CHECK:  0x[[PWD]]: `[[PWDVAL]]`
-// CHECK:  0x[[TOOL]]: `[[TOOLVAL]]`
-// CHECK:  0x[[FILEPATH]]: `[[FILEPATHVAL]]`
-// CHECK:  0x[[ZIPDB]]: ``
-// CHECK:  0x[[CMDLINE]]: `"-cc1
-
-// RELATIVE:   Types (.debug$T)
-// RELATIVE: 
-// RELATIVE: 0x{{.+}} | LF_BUILDINFO [size = {{.+}}]
-// RELATIVE:  0x{{.+}}: `.`

diff  --git a/lld/COFF/PDB.cpp b/lld/COFF/PDB.cpp
index 75884ed11308..be6af13f3647 100644
--- a/lld/COFF/PDB.cpp
+++ b/lld/COFF/PDB.cpp
@@ -250,72 +250,6 @@ static void addTypeInfo(pdb::TpiStreamBuilder ,
   });
 }
 
-// LF_BUILDINFO records might contain relative paths, and we want to make them
-// absolute. We do this remapping only after the type records were merged,
-// because the full types graph isn't known during merging. In addition, we 
plan
-// to multi-thread the type merging, and the change below needs to be done
-// atomically, single-threaded.
-
-// A complication could arise when a LF_STRING_ID record already exists with 
the
-// same content as the new absolutized path. In that case, we simply redirect
-// LF_BUILDINFO's CurrentDirectory index to reference the existing LF_STRING_ID
-// record.
-
-static void remapBuildInfo(TypeCollection ) {
-  SimpleTypeSerializer s;
-  idTable.ForEachRecord([&](TypeIndex ti, const CVType ) {
-if (type.kind() != LF_BUILDINFO)
-  return;
-BuildInfoRecord bi;
-cantFail(TypeDeserializer::deserializeAs(const_cast(type), bi));
-
-auto makeAbsoluteRecord =
-[&](BuildInfoRecord::BuildInfoArg recordType) -> Optional {
-  TypeIndex recordTi = bi.getArgs()[recordType];
-  if (recordTi.isNoneType())
-return None;
-  CVType recordRef = idTable.getType(recordTi);
-
-  StringIdRecord record;
-  cantFail(TypeDeserializer::deserializeAs(recordRef, record));
-
-  SmallString<128> abolutizedPath(record.getString());
-  pdbMakeAbsolute(abolutizedPath);
-
-  if (abolutizedPath == record.getString())
-return None; // 

[PATCH] D81168: Add support for DeclRefExpr in SyntaxTree, by generating IdExpressions

2020-06-18 Thread Dmitri Gribenko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1b2f6b4a08ba: Add support for DeclRefExpr in SyntaxTree, by 
generating IdExpressions (authored by eduucaldas, committed by gribozavr).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81168

Files:
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/Nodes.cpp
  clang/unittests/Tooling/Syntax/TreeTest.cpp

Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -485,8 +485,9 @@
 | | |-SimpleDeclarator
 | | | `-x
 | | `-:
-| |-UnknownExpression
-| | `-a
+| |-IdExpression
+| | `-UnqualifiedId
+| |   `-a
 | |-)
 | `-EmptyStatement
 |   `-;
@@ -662,8 +663,9 @@
 |-{
 |-ExpressionStatement
 | |-UnknownExpression
-| | |-UnknownExpression
-| | | `-test
+| | |-IdExpression
+| | | `-UnqualifiedId
+| | |   `-test
 | | |-(
 | | `-)
 | `-;
@@ -675,16 +677,18 @@
 | |-)
 | |-ExpressionStatement
 | | |-UnknownExpression
-| | | |-UnknownExpression
-| | | | `-test
+| | | |-IdExpression
+| | | | `-UnqualifiedId
+| | | |   `-test
 | | | |-(
 | | | `-)
 | | `-;
 | |-else
 | `-ExpressionStatement
 |   |-UnknownExpression
-|   | |-UnknownExpression
-|   | | `-test
+|   | |-IdExpression
+|   | | `-UnqualifiedId
+|   | |   `-test
 |   | |-(
 |   | `-)
 |   `-;
@@ -692,6 +696,509 @@
 )txt"));
 }
 
+TEST_P(SyntaxTreeTest, UnqualifiedId) {
+  if (!GetParam().isCXX()) {
+return;
+  }
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+struct X {
+  // TODO: Expose `id-expression` from `Declarator`
+  friend X operator+(const X&, const X&);
+  operator int();
+};
+template
+void f(T&);
+void test(X x) {
+  x;  // identifier
+  operator+(x, x);// operator-function-id
+  f(x);// template-id
+  // TODO: Expose `id-expression` from `MemberExpr`
+  x.operator int();   // conversion-funtion-id
+  x.~X(); // ~type-name
+}
+)cpp",
+  R"txt(
+*: TranslationUnit
+|-SimpleDeclaration
+| |-struct
+| |-X
+| |-{
+| |-UnknownDeclaration
+| | `-SimpleDeclaration
+| |   |-friend
+| |   |-X
+| |   |-SimpleDeclarator
+| |   | |-operator
+| |   | |-+
+| |   | `-ParametersAndQualifiers
+| |   |   |-(
+| |   |   |-SimpleDeclaration
+| |   |   | |-const
+| |   |   | |-X
+| |   |   | `-SimpleDeclarator
+| |   |   |   `-&
+| |   |   |-,
+| |   |   |-SimpleDeclaration
+| |   |   | |-const
+| |   |   | |-X
+| |   |   | `-SimpleDeclarator
+| |   |   |   `-&
+| |   |   `-)
+| |   `-;
+| |-SimpleDeclaration
+| | |-SimpleDeclarator
+| | | |-operator
+| | | |-int
+| | | `-ParametersAndQualifiers
+| | |   |-(
+| | |   `-)
+| | `-;
+| |-}
+| `-;
+|-TemplateDeclaration
+| |-template
+| |-<
+| |-UnknownDeclaration
+| | |-typename
+| | `-T
+| |->
+| `-SimpleDeclaration
+|   |-void
+|   |-SimpleDeclarator
+|   | |-f
+|   | `-ParametersAndQualifiers
+|   |   |-(
+|   |   |-SimpleDeclaration
+|   |   | |-T
+|   |   | `-SimpleDeclarator
+|   |   |   `-&
+|   |   `-)
+|   `-;
+`-SimpleDeclaration
+  |-void
+  |-SimpleDeclarator
+  | |-test
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   |-SimpleDeclaration
+  |   | |-X
+  |   | `-SimpleDeclarator
+  |   |   `-x
+  |   `-)
+  `-CompoundStatement
+|-{
+|-ExpressionStatement
+| |-IdExpression
+| | `-UnqualifiedId
+| |   `-x
+| `-;
+|-ExpressionStatement
+| |-UnknownExpression
+| | |-IdExpression
+| | | `-UnqualifiedId
+| | |   |-operator
+| | |   `-+
+| | |-(
+| | |-IdExpression
+| | | `-UnqualifiedId
+| | |   `-x
+| | |-,
+| | |-IdExpression
+| | | `-UnqualifiedId
+| | |   `-x
+| | `-)
+| `-;
+|-ExpressionStatement
+| |-UnknownExpression
+| | |-IdExpression
+| | | `-UnqualifiedId
+| | |   |-f
+| | |   |-<
+| | |   |-X
+| | |   `->
+| | |-(
+| | |-IdExpression
+| | | `-UnqualifiedId
+| | |   `-x
+| | `-)
+| `-;
+|-ExpressionStatement
+| |-UnknownExpression
+| | |-UnknownExpression
+| | | |-IdExpression
+| | | | `-UnqualifiedId
+| | | |   `-x
+| | | |-.
+| | | |-operator
+| | | `-int
+| | |-(
+| | `-)
+| `-;
+|-ExpressionStatement
+| |-UnknownExpression
+| | |-UnknownExpression
+| | | |-IdExpression
+| | | | `-UnqualifiedId
+| | | |   `-x
+| | | |-.
+| | | |-~
+| | | `-X
+| | |-(
+| | `-)
+| `-;
+`-}
+)txt"));
+}
+
+TEST_P(SyntaxTreeTest, UnqualifiedIdCxx11OrLater) {
+  if (!GetParam().isCXX11OrLater()) {
+return;
+  }
+  EXPECT_TRUE(treeDumpEqual(
+  

[PATCH] D82085: [TRE] markTails marks call sites as tailcalls though some of them are not.

2020-06-18 Thread Alexey Lapshin via Phabricator via cfe-commits
avl added a comment.

> It's OK to set "tail" on any call that satisfies these requirements (from 
> https://llvm.org/docs/LangRef.html#call-instruction): "Both markers [tail and 
> musttail] imply that the callee does not access allocas from the caller. The 
> tail marker additionally implies that the callee does not access varargs from 
> the caller."



> "tail" does not mean that the call *must* be generated as a tail call. It 
> just means that it's safe to generate it as a tail call if it turns out to be 
> possible (e.g. if the compiler can prove that @noarg doesn't return, or if it 
> can prove that all the code after the call to @noarg has no effect, or so on).

Yes, that is understood: ""tail" does not mean that the call *must* be 
generated as a tail call".
I intended to make picture consistent: when markTails sees function body, it is 
evident that the first call is not a tail call. I agree that a compiler "can 
prove that @noarg doesn't return, or if it can prove that all the code after 
the call to @noarg has no effect" and this first call could become tail-call. 
Probably the suitable strategy, in this case, would be to recalculate marking 
when it is broken(instead of creating false positive marks). There are other 
cases(compiler could add function calls), which could break existing marking 
and then would be necessary to recalculate marking.

Having many false positive "tail" marks could create a confusing picture. 
I would describe the full problem which I am trying to solve.
(I assumed this patch would be the first one for that problem):

cat test.cpp

  int count;
  __attribute__((noinline)) void globalIncrement(const int* param) { count += 
*param; }
  
  void test(int recurseCount)
  {
  if (recurseCount == 0) return;
  {
int temp = 10;
globalIncrement();
  }
  test(recurseCount - 1);
  }

TRE is not done for that test case. There are two reasons for that: 
First is that AllocaDerivedValueTracker does not use the PointerMayBeCaptured 
interface, and it does not see that  is not escaped.
Second is that AllCallsAreTailCalls is used as a pre-requisite for making TRE.
So it requires that all calls would be marked as "tail". This looks too 
restricted.
Instead, it should check that "" is not escaped in globalIncrement() and 
that "test" 
is a tail recursive call not using allocas. I think the confusion happened 
exactly because "tail" marking was done for all calls(not for the real 
tailcalls).

Thus I planned to do the following fixes:

1. cleanup "tail" marking.(this patch)
2. do not use "AllCallsAreTailCalls" as a pre-requisite for TRE.(this patch).
3. use PointerMayBeCaptured inside AllocaDerivedValueTracker.

What do you think about all of this?

It seems to me that it would be good to have consistent "tail" marking. 
But if it does not look like a good idea, I could continue to point 2. and 3.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82085



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


[PATCH] D82118: [clang][module] Improve incomplete-umbrella warning

2020-06-18 Thread Zixu Wang via Phabricator via cfe-commits
zixuw created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

- Upstream methods for action wrappers in generating modules;
- Change the warning message for -Wincomplete-umbrella to report the location 
of the umbrella header;
- Add a fix-it hint to include uncovered headers in the umbrella header.

rdar://57095551


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82118

Files:
  clang/include/clang/Frontend/CompilerInstance.h
  clang/include/clang/Rewrite/Frontend/FrontendActions.h
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/Rewrite/FrontendActions.cpp
  clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  clang/lib/Lex/PPLexerChange.cpp
  clang/test/Modules/Inputs/incomplete-umbrella/normal-module/A1.h
  clang/test/Modules/Inputs/incomplete-umbrella/normal-module/A2.h
  clang/test/Modules/Inputs/incomplete-umbrella/normal-module/Umbrella.h
  clang/test/Modules/Inputs/incomplete-umbrella/normal-module/module.modulemap
  clang/test/Modules/incomplete-umbrella-fixit.m
  clang/test/Modules/incomplete-umbrella.m

Index: clang/test/Modules/incomplete-umbrella.m
===
--- clang/test/Modules/incomplete-umbrella.m
+++ clang/test/Modules/incomplete-umbrella.m
@@ -6,8 +6,12 @@
 #import 
 @import Foo.Private;
 
-// CHECK: warning: umbrella header for module 'Foo' does not include header 'Bar.h'
-// CHECK: warning: umbrella header for module 'Foo.Private' does not include header 'Baz.h'
+// CHECK: While building module 'Foo' imported from {{.*[/\]}}incomplete-umbrella.m:4:
+// CHECK-NEXT: In file included from :1:
+// CHECK-NEXT: {{.*Foo[.]framework[/\]Headers[/\]}}FooPublic.h:2:1: warning: umbrella header for module 'Foo' does not include header 'Bar.h'
+// CHECK: While building module 'Foo' imported from {{.*[/\]}}incomplete-umbrella.m:4:
+// CHECK-NEXT: In file included from :2:
+// CHECK-NEXT: {{.*Foo[.]framework[/\]PrivateHeaders[/\]}}Foo.h:2:1: warning: umbrella header for module 'Foo.Private' does not include header 'Baz.h'
 int foo() {
   int a = BAR_PUBLIC;
   int b = BAZ_PRIVATE;
Index: clang/test/Modules/incomplete-umbrella-fixit.m
===
--- /dev/null
+++ clang/test/Modules/incomplete-umbrella-fixit.m
@@ -0,0 +1,10 @@
+// RUN: rm -rf %t
+// RUN: cp -R %S/Inputs/incomplete-umbrella/normal-module %t
+// RUN: %clang_cc1 -fmodules -fmodule-map-file=%t/module.modulemap -fmodules-cache-path=%t -Wno-everything -Wincomplete-umbrella -fixit %s && FileCheck %t/Umbrella.h --input-file %t/Umbrella.h --match-full-lines
+// RUN: %clang_cc1 -fmodules -fmodule-map-file=%t/module.modulemap -fmodules-cache-path=%t -Wno-everything -Wincomplete-umbrella -Werror %s
+
+@import A;
+
+int foo() {
+  return 0;
+}
Index: clang/test/Modules/Inputs/incomplete-umbrella/normal-module/module.modulemap
===
--- /dev/null
+++ clang/test/Modules/Inputs/incomplete-umbrella/normal-module/module.modulemap
@@ -0,0 +1,4 @@
+module A {
+  umbrella header "Umbrella.h"
+  export *
+}
Index: clang/test/Modules/Inputs/incomplete-umbrella/normal-module/Umbrella.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/incomplete-umbrella/normal-module/Umbrella.h
@@ -0,0 +1,3 @@
+// Umbrella.h
+// CHECK: #import "A1.h"
+// CHECK: #import "A2.h"
Index: clang/test/Modules/Inputs/incomplete-umbrella/normal-module/A2.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/incomplete-umbrella/normal-module/A2.h
@@ -0,0 +1 @@
+// A2.h
Index: clang/test/Modules/Inputs/incomplete-umbrella/normal-module/A1.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/incomplete-umbrella/normal-module/A1.h
@@ -0,0 +1 @@
+// A1.h
Index: clang/lib/Lex/PPLexerChange.cpp
===
--- clang/lib/Lex/PPLexerChange.cpp
+++ clang/lib/Lex/PPLexerChange.cpp
@@ -263,10 +263,11 @@
 }
 
 void Preprocessor::diagnoseMissingHeaderInUmbrellaDir(const Module ) {
-  assert(Mod.getUmbrellaHeader() && "Module must use umbrella header");
-  SourceLocation StartLoc =
-  SourceMgr.getLocForStartOfFile(SourceMgr.getMainFileID());
-  if (getDiagnostics().isIgnored(diag::warn_uncovered_module_header, StartLoc))
+  const auto  = Mod.getUmbrellaHeader();
+  assert(UmbrellaHeader.Entry && "Module must use umbrella header");
+  const FileID  = SourceMgr.translateFile(UmbrellaHeader.Entry);
+  SourceLocation EndLoc = SourceMgr.getLocForEndOfFile(File);
+  if (getDiagnostics().isIgnored(diag::warn_uncovered_module_header, EndLoc))
 return;
 
   ModuleMap  = getHeaderSearchInfo().getModuleMap();
@@ -291,8 +292,26 @@
   // Find the relative path that would access this header.
   

[PATCH] D80833: [CodeView] Add full repro to LF_BUILDINFO record

2020-06-18 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

In D80833#2101690 , @thakis wrote:

> Hm http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/16533 is 
> happy so it's not broken on all Windows machines. Guess I'll take a look on 
> what's going on. You can hold off on the revert for now.


I wonder if the "sed" substitution below could fail on some machines? (see 
lld/test/COFF/pdb-relative-source-lines.test)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80833



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


[clang] 1b2f6b4 - Add support for DeclRefExpr in SyntaxTree, by generating IdExpressions

2020-06-18 Thread Dmitri Gribenko via cfe-commits

Author: Eduardo Caldas
Date: 2020-06-18T21:05:23+02:00
New Revision: 1b2f6b4a08ba74d965dcf7c9fee97d286c0250f8

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

LOG: Add support for DeclRefExpr in SyntaxTree, by generating IdExpressions

Reviewers: gribozavr2

Reviewed By: gribozavr2

Subscribers: hlopko, gribozavr2, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/Tooling/Syntax/Nodes.h
clang/lib/Tooling/Syntax/BuildTree.cpp
clang/lib/Tooling/Syntax/Nodes.cpp
clang/unittests/Tooling/Syntax/TreeTest.cpp

Removed: 




diff  --git a/clang/include/clang/Tooling/Syntax/Nodes.h 
b/clang/include/clang/Tooling/Syntax/Nodes.h
index 7e05aa968f02..139ac9aa8eca 100644
--- a/clang/include/clang/Tooling/Syntax/Nodes.h
+++ b/clang/include/clang/Tooling/Syntax/Nodes.h
@@ -45,6 +45,7 @@ enum class NodeKind : uint16_t {
   BinaryOperatorExpression,
   CxxNullPtrExpression,
   IntegerLiteralExpression,
+  IdExpression,
 
   // Statements.
   UnknownStatement,
@@ -84,7 +85,10 @@ enum class NodeKind : uint16_t {
   ArraySubscript,
   TrailingReturnType,
   ParametersAndQualifiers,
-  MemberPointer
+  MemberPointer,
+  NestedNameSpecifier,
+  NameSpecifier,
+  UnqualifiedId
 };
 /// For debugging purposes.
 llvm::raw_ostream <<(llvm::raw_ostream , NodeKind K);
@@ -150,7 +154,10 @@ enum class NodeRole : uint8_t {
   ArraySubscript_sizeExpression,
   TrailingReturnType_declarator,
   ParametersAndQualifiers_parameter,
-  ParametersAndQualifiers_trailingReturn
+  ParametersAndQualifiers_trailingReturn,
+  IdExpression_id,
+  IdExpression_qualifier,
+  NestedNameSpecifier_specifier
 };
 /// For debugging purposes.
 llvm::raw_ostream <<(llvm::raw_ostream , NodeRole R);
@@ -177,6 +184,56 @@ class Expression : public Tree {
   }
 };
 
+/// A sequence of these specifiers make a `nested-name-specifier`.
+/// e.g. the `std::` or `vector::` in `std::vector::size`.
+class NameSpecifier final : public Tree {
+public:
+  NameSpecifier() : Tree(NodeKind::NameSpecifier) {}
+  static bool classof(const Node *N) {
+return N->kind() == NodeKind::NameSpecifier;
+  }
+};
+
+/// Models a `nested-name-specifier`. C++ [expr.prim.id.qual]
+/// e.g. the `std::vector::` in `std::vector::size`.
+class NestedNameSpecifier final : public Tree {
+public:
+  NestedNameSpecifier() : Tree(NodeKind::NestedNameSpecifier) {}
+  static bool classof(const Node *N) {
+return N->kind() <= NodeKind::NestedNameSpecifier;
+  }
+  std::vector specifiers();
+};
+
+/// Models an `unqualified-id`. C++ [expr.prim.id.unqual]
+/// e.g. the `size` in `std::vector::size`.
+class UnqualifiedId final : public Tree {
+public:
+  UnqualifiedId() : Tree(NodeKind::UnqualifiedId) {}
+  static bool classof(const Node *N) {
+return N->kind() == NodeKind::UnqualifiedId;
+  }
+};
+
+/// Models an `id-expression`, e.g. `std::vector::size`.
+/// C++ [expr.prim.id]
+/// id-expression:
+///   unqualified-id
+///   qualified-id
+/// qualified-id:
+///   nested-name-specifier template_opt unqualified-id
+class IdExpression final : public Expression {
+public:
+  IdExpression() : Expression(NodeKind::IdExpression) {}
+  static bool classof(const Node *N) {
+return N->kind() == NodeKind::IdExpression;
+  }
+  syntax::NestedNameSpecifier *qualifier();
+  // TODO after expose `id-expression` from `DependentScopeDeclRefExpr`:
+  // Add accessor for `template_opt`.
+  syntax::UnqualifiedId *unqualifiedId();
+};
+
 /// An expression of an unknown kind, i.e. one not currently handled by the
 /// syntax tree.
 class UnknownExpression final : public Expression {

diff  --git a/clang/lib/Tooling/Syntax/BuildTree.cpp 
b/clang/lib/Tooling/Syntax/BuildTree.cpp
index 9ce12ac21f8b..3ee66aabfb6d 100644
--- a/clang/lib/Tooling/Syntax/BuildTree.cpp
+++ b/clang/lib/Tooling/Syntax/BuildTree.cpp
@@ -608,6 +608,45 @@ class BuildTreeVisitor : public 
RecursiveASTVisitor {
 return true;
   }
 
+  syntax::NestedNameSpecifier *
+  BuildNestedNameSpecifier(NestedNameSpecifierLoc QualifierLoc) {
+if (!QualifierLoc)
+  return nullptr;
+for (auto it = QualifierLoc; it; it = it.getPrefix()) {
+  auto *NS = new (allocator()) syntax::NameSpecifier;
+  Builder.foldNode(Builder.getRange(it.getLocalSourceRange()), NS, 
nullptr);
+  Builder.markChild(NS, syntax::NodeRole::NestedNameSpecifier_specifier);
+}
+auto *NNS = new (allocator()) syntax::NestedNameSpecifier;
+Builder.foldNode(Builder.getRange(QualifierLoc.getSourceRange()), NNS,
+ nullptr);
+return NNS;
+  }
+
+  bool WalkUpFromDeclRefExpr(DeclRefExpr *S) {
+if (auto *NNS = BuildNestedNameSpecifier(S->getQualifierLoc()))
+  Builder.markChild(NNS, 

[PATCH] D80981: [AST] Fix a crash on accessing a class without definition in constexpr function context.

2020-06-18 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/lib/AST/ExprConstant.cpp:4320
+if (!RD->hasDefinition())
+  return APValue();
 APValue Struct(APValue::UninitStruct(), RD->getNumBases(),

hokein wrote:
> rsmith wrote:
> > hokein wrote:
> > > sammccall wrote:
> > > > This doesn't look all that safe - you're using a `None` value to 
> > > > indicate failure, but no current code path does that and none of the 
> > > > callers seem to check for failure.
> > > > (e.g. `evaluateVarDecl` returns true instead of false).
> > > > Presumably we're going to get a diagnostic somewhere (though it's not 
> > > > completely obvious to me) but can we be sure we won't assume this value 
> > > > has the right type somewhere down the line?
> > > > 
> > > > I get the feeling this is correct and I don't have enough context to 
> > > > understand why... how about you :-)
> > > I don't have a promising explanation neither. 
> > > 
> > > I didn't find a better way to model failures in `getDefaultInitValue`. 
> > > This function is used in multiple places of this file (and I'm not sure 
> > > whether we should change it).
> > > 
> > > @rsmith any thoughts?
> > `APValue()` is a valid representation for an object of class type, 
> > representing a class object that is outside its lifetime, so I think it's 
> > OK to use this representation, if we can be sure that this only happens 
> > along error paths. (It's not ideal, though.)
> > 
> > If we can't be sure this happens only along error paths, then we should 
> > produce a diagnostic here. Perhaps feed an `EvalInfo&` and a source 
> > location into every caller of this function and produce a diagnostic if we 
> > end up querying the default-initialized value of an incomplete-but-valid 
> > class type. Or perhaps we could check that the class is complete and valid 
> > from every caller of this function instead. (I think that we guarantee 
> > that, for a valid complete class type, all transitive subobjects are of 
> > valid complete types, so checking this only once at the top level before 
> > calling into `getDefaultInitValue` should be enough.)
> Thanks for the suggestions.
> 
> oh, yeah, I missed that the `Foo` Decl is invalid, so checking the class decl 
> is valid at every caller of `getDefaultInitValue` should work -- it would 
> also fix other potential issues, looks like here we guarantee that the 
> VarDecl is valid, but don't verify the decl which the VarDecl's type refers 
> to is valid in all callers.  
> 
> Given the fact that the `VarDecl` e is valid and class `Foo` Decl is invalid, 
> another option to fix the crash is to invalidate this `VarDecl`. Should we 
> invalidate the VarDecl if the type of the VarDecl refers to an invalid decl? 
> My gut feeling is that it is worth keeping the VarDecl valid, so that more 
> related AST nodes will be built (for better recovery and diagnostics), though 
> it seems unsafe. 
I think keeping the `VarDecl` valid is probably the better choice, to allow us 
to build downstream uses of it. Also, because variables can be redeclared, we 
could have something like `struct A; extern A v; struct A { invalid; };` -- and 
we can't reasonably retroactively mark `v` as invalid in this case, so we can't 
guarantee that the type of every valid variable is itself valid. (We *could* 
guarantee that the type of every valid variable *definition* is valid, but that 
will lead to inconsistencies where defining the variable causes later behavior 
of references to the variable to change.)

It's really unfortunate that we don't have a good definition of what "valid" 
means for a variable, or really any listing of what invariants we maintain in 
the AST in the presence of invalid nodes. :( This is one of the things I would 
work on if I had time...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80981



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


[PATCH] D82029: [Coroutines] Ensure co_await promise.final_suspend() does not throw

2020-06-18 Thread Xun Li via Phabricator via cfe-commits
lxfind updated this revision to Diff 271801.
lxfind added a comment.
Herald added a subscriber: arphaman.

Address feedback and update failed tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82029

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaCoroutine.cpp
  clang/lib/Sema/SemaExceptionSpec.cpp
  clang/test/AST/Inputs/std-coroutine.h
  clang/test/AST/coroutine-source-location-crash.cpp
  clang/test/Analysis/more-dtors-cfg-output.cpp
  clang/test/CodeGenCXX/ubsan-coroutines.cpp
  clang/test/CodeGenCoroutines/Inputs/coroutine.h
  clang/test/CodeGenCoroutines/coro-alloc.cpp
  clang/test/CodeGenCoroutines/coro-always-inline.cpp
  clang/test/CodeGenCoroutines/coro-await-domination.cpp
  clang/test/CodeGenCoroutines/coro-await-resume-eh.cpp
  clang/test/CodeGenCoroutines/coro-await.cpp
  clang/test/CodeGenCoroutines/coro-dest-slot.cpp
  clang/test/CodeGenCoroutines/coro-gro-nrvo.cpp
  clang/test/CodeGenCoroutines/coro-newpm-pipeline.cpp
  clang/test/CodeGenCoroutines/coro-params.cpp
  clang/test/CodeGenCoroutines/coro-promise-dtor.cpp
  clang/test/CodeGenCoroutines/coro-ret-void.cpp
  clang/test/CodeGenCoroutines/coro-return-voidtype-initlist.cpp
  clang/test/CodeGenCoroutines/coro-return.cpp
  clang/test/CodeGenCoroutines/coro-unhandled-exception.cpp
  clang/test/Index/coroutines.cpp
  clang/test/SemaCXX/Inputs/std-coroutine.h
  clang/test/SemaCXX/co_await-range-for.cpp
  clang/test/SemaCXX/coreturn-eh.cpp
  clang/test/SemaCXX/coreturn.cpp
  clang/test/SemaCXX/coroutine-final-suspend-noexcept.cpp
  clang/test/SemaCXX/coroutine-rvo.cpp
  clang/test/SemaCXX/coroutine-unhandled_exception-warning.cpp
  clang/test/SemaCXX/coroutine-uninitialized-warning-crash.cpp
  clang/test/SemaCXX/coroutines.cpp

Index: clang/test/SemaCXX/coroutines.cpp
===
--- clang/test/SemaCXX/coroutines.cpp
+++ clang/test/SemaCXX/coroutines.cpp
@@ -52,21 +52,24 @@
 };
 
 struct awaitable {
-  bool await_ready();
-  template  void await_suspend(F);
-  void await_resume();
+  bool await_ready() noexcept;
+  template 
+  void await_suspend(F) noexcept;
+  void await_resume() noexcept;
 } a;
 
 struct suspend_always {
-  bool await_ready() { return false; }
-  template  void await_suspend(F);
-  void await_resume() {}
+  bool await_ready() noexcept { return false; }
+  template 
+  void await_suspend(F) noexcept;
+  void await_resume() noexcept {}
 };
 
 struct suspend_never {
-  bool await_ready() { return true; }
-  template  void await_suspend(F);
-  void await_resume() {}
+  bool await_ready() noexcept { return true; }
+  template 
+  void await_suspend(F) noexcept;
+  void await_resume() noexcept {}
 };
 
 struct auto_await_suspend {
@@ -127,7 +130,7 @@
 struct promise {
   void get_return_object();
   suspend_always initial_suspend();
-  suspend_always final_suspend();
+  suspend_always final_suspend() noexcept;
   awaitable yield_value(int); // expected-note 2{{candidate}}
   awaitable yield_value(yielded_thing); // expected-note 2{{candidate}}
   not_awaitable yield_value(void()); // expected-note 2{{candidate}}
@@ -138,7 +141,7 @@
 struct promise_void {
   void get_return_object();
   suspend_always initial_suspend();
-  suspend_always final_suspend();
+  suspend_always final_suspend() noexcept;
   void return_void();
   void unhandled_exception();
 };
@@ -152,13 +155,13 @@
 namespace experimental {
 template 
 struct coroutine_handle {
-  static coroutine_handle from_address(void *);
+  static coroutine_handle from_address(void *) noexcept;
 };
 template <>
 struct coroutine_handle {
   template 
-  coroutine_handle(coroutine_handle);
-  static coroutine_handle from_address(void *);
+  coroutine_handle(coroutine_handle) noexcept;
+  static coroutine_handle from_address(void *) noexcept;
 };
 }} // namespace std::experimental
 
@@ -402,7 +405,7 @@
 
 namespace adl_ns {
 struct coawait_arg_type {};
-awaitable operator co_await(coawait_arg_type);
+awaitable operator co_await(coawait_arg_type) noexcept;
 }
 
 namespace dependent_operator_co_await_lookup {
@@ -434,7 +437,7 @@
 typedef transform_awaitable await_arg;
 coro get_return_object();
 transformed initial_suspend();
-::adl_ns::coawait_arg_type final_suspend();
+::adl_ns::coawait_arg_type final_suspend() noexcept;
 transformed await_transform(transform_awaitable);
 void unhandled_exception();
 void return_void();
@@ -444,7 +447,7 @@
 typedef AwaitArg await_arg;
 coro get_return_object();
 awaitable initial_suspend();
-awaitable final_suspend();
+awaitable final_suspend() noexcept;
 void unhandled_exception();
 void return_void();
   };
@@ -529,7 +532,7 @@
 void return_value(int());
 
 suspend_never initial_suspend();
-suspend_never final_suspend();
+suspend_never final_suspend() noexcept;

[PATCH] D80833: [CodeView] Add full repro to LF_BUILDINFO record

2020-06-18 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Hm http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/16533 is 
happy so it's not broken on all Windows machines. Guess I'll take a look on 
what's going on. You can hold off on the revert for now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80833



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


[PATCH] D80833: [CodeView] Add full repro to LF_BUILDINFO record

2020-06-18 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

In D80833#2101636 , @thakis wrote:

> This is still broken; bots have been red for a few hours now. Can we revert 
> and analyze async, to keep the bots green please?


Yes I will revert, but I don't understand. All the tests pass here on four 
different machines, Windows and Linux, when compiling with different compilers 
and different configurations. I will investigate offline.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80833



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


[PATCH] D82115: [OPENMP50]Codegen for scan directives in parallel for simd regions.

2020-06-18 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev created this revision.
ABataev added a reviewer: jdoerfert.
Herald added subscribers: sstefan1, guansong, yaxunl.
Herald added a project: clang.

Added codegen for scan directives in parallel for simd regions.

Emits the code for the directive with inscan reductions.
Original code:

   #pragma omp parallel for simd reduction(inscan, op : ...)
  for() {
;
#pragma omp scan (in)exclusive(...)

  }

is transformed to something:

   #pragma omp parallel
  {
  size num_iters = ;
   buffer[num_iters];
   #pragma omp for simd
  for (i: 0..) {
;
buffer[i] = red;
  }
   #pragma omp barrier
  for (int k = 0; k != ceil(log2(num_iters)); ++k)
  for (size cnt = last_iter; cnt >= pow(2, k); --k)
buffer[i] op= buffer[i-pow(2,k)];
   #pragma omp for simd
  for (0..) {
red = InclusiveScan ? buffer[i] : buffer[i-1];
;
  }
  }


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82115

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/test/OpenMP/parallel_for_simd_scan_codegen.cpp

Index: clang/test/OpenMP/parallel_for_simd_scan_codegen.cpp
===
--- /dev/null
+++ clang/test/OpenMP/parallel_for_simd_scan_codegen.cpp
@@ -0,0 +1,315 @@
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=50 -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c++ -std=c++11 -triple x86_64-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c++ -triple x86_64-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+
+// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=50 -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -x c++ -std=c++11 -triple x86_64-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -x c++ -triple x86_64-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+void foo();
+void bar();
+
+// CHECK: define void @{{.*}}baz{{.*}}(i32 %n)
+void baz(int n) {
+  static float a[10];
+  static double b;
+
+  // CHECK: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(
+  // CHECK: call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(
+
+  // CHECK: call i8* @llvm.stacksave()
+  // CHECK: [[A_BUF_SIZE:%.+]] = mul nuw i64 10, [[NUM_ELEMS:%[^,]+]]
+
+  // float a_buffer[10][n];
+  // CHECK: [[A_BUF:%.+]] = alloca float, i64 [[A_BUF_SIZE]],
+
+  // double b_buffer[10];
+  // CHECK: [[B_BUF:%.+]] = alloca double, i64 10,
+#pragma omp parallel for simd reduction(inscan, +:a[:n], b)
+  for (int i = 0; i < 10; ++i) {
+// CHECK: call void @__kmpc_for_static_init_4(
+// CHECK: call i8* @llvm.stacksave()
+// CHECK: store float 0.00e+00, float* %
+// CHECK: store double 0.00e+00, double* [[B_PRIV_ADDR:%.+]],
+// CHECK: br label %[[DISPATCH:[^,]+]]
+// CHECK: [[INPUT_PHASE:.+]]:
+// CHECK: call void @{{.+}}foo{{.+}}()
+
+// a_buffer[i][0..n] = a_priv[[0..n];
+// CHECK: [[BASE_IDX_I:%.+]] = load i32, i32* [[IV_ADDR:%.+]],
+// CHECK: [[BASE_IDX:%.+]] = zext i32 [[BASE_IDX_I]] to i64
+// CHECK: [[IDX:%.+]] = mul nsw i64 [[BASE_IDX]], [[NUM_ELEMS]]
+// CHECK: [[A_BUF_IDX:%.+]] = getelementptr inbounds float, float* [[A_BUF]], i64 [[IDX]]
+// CHECK: [[A_PRIV:%.+]] = getelementptr inbounds [10 x float], [10 x float]* [[A_PRIV_ADDR:%.+]], i64 0, i64 0
+// CHECK: [[BYTES:%.+]] = mul nuw i64 [[NUM_ELEMS:%.+]], 4
+// CHECK: [[DEST:%.+]] = bitcast float* [[A_BUF_IDX]] to i8*
+// CHECK: [[SRC:%.+]] = bitcast float* [[A_PRIV]] to i8*
+// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* {{.*}}[[DEST]], i8* {{.*}}[[SRC]], i64 [[BYTES]], i1 false)
+
+// b_buffer[i] = b_priv;
+// CHECK: [[B_BUF_IDX:%.+]] = getelementptr inbounds double, double* [[B_BUF]], i64 [[BASE_IDX]]
+// CHECK: [[B_PRIV:%.+]] = load double, double* [[B_PRIV_ADDR]],
+// CHECK: store double [[B_PRIV]], double* [[B_BUF_IDX]],
+// CHECK: br label %[[LOOP_CONTINUE:.+]]
+
+// CHECK: [[DISPATCH]]:
+// CHECK: br label %[[INPUT_PHASE]]
+// CHECK: [[LOOP_CONTINUE]]:
+// CHECK: call void @llvm.stackrestore(i8* %
+// CHECK: call void @__kmpc_for_static_fini(
+// CHECK: call void @__kmpc_barrier(
+foo();
+#pragma omp scan inclusive(a[:n], b)
+// CHECK: [[LOG2_10:%.+]] = call double @llvm.log2.f64(double 1.00e+01)
+// CHECK: [[CEIL_LOG2_10:%.+]] = call double @llvm.ceil.f64(double [[LOG2_10]])
+// CHECK: [[CEIL_LOG2_10_INT:%.+]] = fptoui double [[CEIL_LOG2_10]] to i32
+// CHECK: br label %[[OUTER_BODY:[^,]+]]
+// CHECK: [[OUTER_BODY]]:
+// CHECK: 

[PATCH] D81678: Introduce partialinit attribute at call sites for stricter poison analysis

2020-06-18 Thread Gui Andrade via Phabricator via cfe-commits
guiand added a comment.

In an email conversation with @rsmith and @eugenis, they raised the issue that 
it's not necessarily wrong to pass aggregate types by value, even when some 
fields are uninit.

A relevant excerpt from Richard:

> In addition to the union case, there's another strange case for passing class 
> types: in C++17 onwards, this example:
> 
> void f(S s);
>  void g() { f(S()); }
> 
> ... results in the parameter to f being constructed in place, rather than by 
> calling the copy constructor. (The same happens for a call to "f({})" in 
> C++11 onwards; it's just a lot more common in C++17.) So it is not the case 
> in general that f cannot be called with a partially-uninitialized S object. 
> :-(

From this, it's probably best for now not to mark aggregate types `frozen`. 
There's potentially some means to have the compiler prove aggregates must be 
frozen, but it's best to land frozen scalars first. And for the purposes of 
msan at least, scalars can account for the majority of the optimizations coming 
out of frozen.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81678



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


[PATCH] D75229: [clang-tidy] Add signal-in-multithreaded-program check

2020-06-18 Thread Kocsis Ábel via Phabricator via cfe-commits
abelkocsis updated this revision to Diff 271789.
abelkocsis added a comment.

Small comment fix


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D75229

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/SignalInMultithreadedProgramCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/SignalInMultithreadedProgramCheck.h
  clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-signal-in-multithreaded-program.rst
  clang-tools-extra/docs/clang-tidy/checks/cert-con37-c.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-in-multithreaded-program-config-std::thread.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-in-multithreaded-program-config-thrd_create.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-in-multithreaded-program-noconfig-std::thread.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-in-multithreaded-program-noconfig-thrd_create.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-in-multithreaded-program-noconfig-thrd_create.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-in-multithreaded-program-noconfig-thrd_create.cpp
@@ -0,0 +1,36 @@
+// RUN: %check_clang_tidy %s bugprone-signal-in-multithreaded-program %t
+
+typedef unsigned long int thrd_t;
+typedef int (*thrd_start_t)(void *);
+typedef int sig_atomic_t;
+#define SIGUSR1 30
+#define NULL 0
+
+void (*signal(int sig, void (*handler)(int)))(int);
+
+int thrd_create(thrd_t *thr, thrd_start_t func, void *arg) { return 0; };
+enum {
+  thrd_success = 0,
+};
+
+volatile sig_atomic_t flag = 0;
+
+void handler(int signum) {
+  flag = 1;
+}
+
+int func(void *data) {
+  while (!flag) {
+  }
+  return 0;
+}
+
+int main(void) {
+  signal(SIGUSR1, handler);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: signal function should not be called in a multithreaded program [bugprone-signal-in-multithreaded-program]
+  thrd_t tid;
+
+  if (thrd_success != thrd_create(, func, NULL)) {
+  }
+  return 0;
+}
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-in-multithreaded-program-noconfig-std::thread.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-in-multithreaded-program-noconfig-std::thread.cpp
@@ -0,0 +1,37 @@
+// RUN: %check_clang_tidy %s bugprone-signal-in-multithreaded-program %t
+
+typedef unsigned long int thrd_t;
+typedef int (*thrd_start_t)(void *);
+typedef int sig_atomic_t;
+#define SIGUSR1 30
+#define NULL 0
+
+void (*signal(int sig, void (*handler)(int)))(int);
+
+volatile sig_atomic_t flag = 0;
+
+void handler(int signum) {
+  flag = 1;
+}
+
+void threadFunction() {}
+
+namespace std {
+class thread {
+public:
+  thread() noexcept;
+  template 
+  explicit thread(Function &, Args &&... args);
+  thread(const thread &) = delete;
+  thread(thread &&) noexcept;
+};
+} // namespace std
+
+int main(void) {
+  signal(SIGUSR1, handler);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: signal function should not be called in a multithreaded program [bugprone-signal-in-multithreaded-program]
+
+  std::thread threadObj(threadFunction);
+
+  return 0;
+}
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-in-multithreaded-program-config-thrd_create.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-in-multithreaded-program-config-thrd_create.cpp
@@ -0,0 +1,38 @@
+// RUN: %check_clang_tidy %s bugprone-signal-in-multithreaded-program %t \
+// RUN: -config='{CheckOptions: \
+// RUN:  [{key: bugprone-signal-in-multithreaded-program.ThreadList, value: "thrd_create"}]}'
+
+typedef unsigned long int thrd_t;
+typedef int (*thrd_start_t)(void *);
+typedef int sig_atomic_t;
+#define SIGUSR1 30
+#define NULL 0
+
+void (*signal(int sig, void (*handler)(int)))(int);
+
+int thrd_create(thrd_t *thr, thrd_start_t func, void *arg) { return 0; };
+enum {
+  thrd_success = 0,
+};
+
+volatile sig_atomic_t flag = 0;
+
+void handler(int signum) {
+  flag = 1;
+}
+
+int func(void *data) {
+  while (!flag) {
+  }
+  return 0;
+}
+
+int main(void) {
+  signal(SIGUSR1, handler);
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: signal function should not be called in a multithreaded program [bugprone-signal-in-multithreaded-program]
+  thrd_t tid;
+
+  if (thrd_success != thrd_create(, func, NULL)) {
+  }
+  return 0;
+}
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-signal-in-multithreaded-program-config-std::thread.cpp

[PATCH] D79796: Sketch support for generating CC1 command line from CompilerInvocation

2020-06-18 Thread Daniel Grumberg via Phabricator via cfe-commits
dang updated this revision to Diff 271790.
dang added a comment.

Address the clang-tidy issues.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79796

Files:
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Frontend/CompilerInvocation.h
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/unittests/Frontend/CMakeLists.txt
  clang/unittests/Frontend/CompilerInvocationTest.cpp
  llvm/include/llvm/Option/OptParser.td
  llvm/utils/TableGen/OptParserEmitter.cpp

Index: llvm/utils/TableGen/OptParserEmitter.cpp
===
--- llvm/utils/TableGen/OptParserEmitter.cpp
+++ llvm/utils/TableGen/OptParserEmitter.cpp
@@ -10,11 +10,13 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/Twine.h"
+#include "llvm/Support/raw_ostream.h"
 #include "llvm/TableGen/Record.h"
 #include "llvm/TableGen/TableGenBackend.h"
 #include 
 #include 
 #include 
+#include 
 
 using namespace llvm;
 
@@ -33,6 +35,210 @@
   return OS;
 }
 
+static const std::string getOptionSpelling(const Record ,
+   size_t ) {
+  std::vector Prefixes = R.getValueAsListOfStrings("Prefixes");
+  StringRef Name = R.getValueAsString("Name");
+  if (Prefixes.empty()) {
+PrefixLength = 0;
+return Name.str();
+  }
+  PrefixLength = Prefixes[0].size();
+  return (Twine(Prefixes[0]) + Twine(Name)).str();
+}
+
+static const std::string getOptionSpelling(const Record ) {
+  size_t PrefixLength;
+  return getOptionSpelling(R, PrefixLength);
+}
+
+static void emitNameUsingSpelling(raw_ostream , const Record ) {
+  size_t PrefixLength;
+  OS << "&";
+  write_cstring(OS, StringRef(getOptionSpelling(R, PrefixLength)));
+  OS << "[" << PrefixLength << "]";
+}
+
+class MarshallingKindInfo {
+public:
+  const Record 
+  const char *MacroName;
+  bool ShouldAlwaysEmit;
+  StringRef KeyPath;
+  StringRef DefaultValue;
+  StringRef NormalizedValuesScope;
+
+  void emit(raw_ostream ) const {
+write_cstring(OS, StringRef(getOptionSpelling(R)));
+OS << ", ";
+OS << ShouldAlwaysEmit;
+OS << ", ";
+OS << KeyPath;
+OS << ", ";
+emitScopedNormalizedValue(OS, DefaultValue);
+OS << ", ";
+emitSpecific(OS);
+  }
+
+  virtual Optional emitValueTable(raw_ostream ) const {
+return None;
+  }
+
+  virtual ~MarshallingKindInfo() = default;
+
+  static std::unique_ptr create(const Record );
+
+protected:
+  void emitScopedNormalizedValue(raw_ostream ,
+ StringRef NormalizedValue) const {
+if (!NormalizedValuesScope.empty())
+  OS << NormalizedValuesScope << "::";
+OS << NormalizedValue;
+  }
+
+  virtual void emitSpecific(raw_ostream ) const = 0;
+  MarshallingKindInfo(const Record , const char *MacroName)
+  : R(R), MacroName(MacroName) {}
+};
+
+class MarshallingFlagInfo final : public MarshallingKindInfo {
+public:
+  bool IsPositive;
+
+  void emitSpecific(raw_ostream ) const override { OS << IsPositive; }
+
+  static std::unique_ptr create(const Record ) {
+std::unique_ptr Ret(new MarshallingFlagInfo(R));
+Ret->IsPositive = R.getValueAsBit("IsPositive");
+return Ret;
+  }
+
+private:
+  MarshallingFlagInfo(const Record )
+  : MarshallingKindInfo(R, "OPTION_WITH_MARSHALLING_FLAG") {}
+};
+
+class MarshallingStringInfo final : public MarshallingKindInfo {
+public:
+  StringRef NormalizerRetTy;
+  StringRef Normalizer;
+  StringRef Denormalizer;
+  int TableIndex = -1;
+  std::vector Values;
+  std::vector NormalizedValues;
+  std::string ValueTableName;
+
+  static constexpr const char *ValueTablePreamble = R"(
+struct SimpleEnumValue {
+  const char *Name;
+  unsigned Value;
+};
+
+struct SimpleEnumValueTable {
+  const SimpleEnumValue *Table;
+  unsigned Size;
+};
+)";
+
+  static constexpr const char *ValueTablesDecl =
+  "static const SimpleEnumValueTable SimpleEnumValueTables[] = ";
+
+  void emitSpecific(raw_ostream ) const override {
+emitScopedNormalizedValue(OS, NormalizerRetTy);
+OS << ", ";
+OS << Normalizer;
+OS << ", ";
+OS << Denormalizer;
+OS << ", ";
+OS << TableIndex;
+  }
+
+  Optional emitValueTable(raw_ostream ) const override {
+if (TableIndex == -1)
+  return {};
+OS << "static const SimpleEnumValue " << ValueTableName << "[] = {\n";
+for (unsigned I = 0, E = Values.size(); I != E; ++I) {
+  OS << "{";
+  write_cstring(OS, Values[I]);
+  OS << ",";
+  OS << "static_cast(";
+  emitScopedNormalizedValue(OS, NormalizedValues[I]);
+  OS << ")},";
+}
+OS << "};\n";
+return StringRef(ValueTableName);
+  }
+
+  static std::unique_ptr create(const Record ) {
+assert(!isa(R.getValueInit("NormalizerRetTy")) &&
+   "String options must have a type");
+
+std::unique_ptr Ret(new MarshallingStringInfo(R));
+Ret->NormalizerRetTy = 

[PATCH] D80833: [CodeView] Add full repro to LF_BUILDINFO record

2020-06-18 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

This is still broken; bots have been red for a few hours now. Can we revert and 
analyze async, to keep the bots green please?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80833



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


[PATCH] D81168: Add support for DeclRefExpr in SyntaxTree, by generating IdExpressions

2020-06-18 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas updated this revision to Diff 271784.
eduucaldas added a comment.

change if -> asserts


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81168

Files:
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/Nodes.cpp
  clang/unittests/Tooling/Syntax/TreeTest.cpp

Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -485,8 +485,9 @@
 | | |-SimpleDeclarator
 | | | `-x
 | | `-:
-| |-UnknownExpression
-| | `-a
+| |-IdExpression
+| | `-UnqualifiedId
+| |   `-a
 | |-)
 | `-EmptyStatement
 |   `-;
@@ -662,8 +663,9 @@
 |-{
 |-ExpressionStatement
 | |-UnknownExpression
-| | |-UnknownExpression
-| | | `-test
+| | |-IdExpression
+| | | `-UnqualifiedId
+| | |   `-test
 | | |-(
 | | `-)
 | `-;
@@ -675,16 +677,18 @@
 | |-)
 | |-ExpressionStatement
 | | |-UnknownExpression
-| | | |-UnknownExpression
-| | | | `-test
+| | | |-IdExpression
+| | | | `-UnqualifiedId
+| | | |   `-test
 | | | |-(
 | | | `-)
 | | `-;
 | |-else
 | `-ExpressionStatement
 |   |-UnknownExpression
-|   | |-UnknownExpression
-|   | | `-test
+|   | |-IdExpression
+|   | | `-UnqualifiedId
+|   | |   `-test
 |   | |-(
 |   | `-)
 |   `-;
@@ -692,6 +696,509 @@
 )txt"));
 }
 
+TEST_P(SyntaxTreeTest, UnqualifiedId) {
+  if (!GetParam().isCXX()) {
+return;
+  }
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+struct X {
+  // TODO: Expose `id-expression` from `Declarator`
+  friend X operator+(const X&, const X&);
+  operator int();
+};
+template
+void f(T&);
+void test(X x) {
+  x;  // identifier
+  operator+(x, x);// operator-function-id
+  f(x);// template-id
+  // TODO: Expose `id-expression` from `MemberExpr`
+  x.operator int();   // conversion-funtion-id
+  x.~X(); // ~type-name
+}
+)cpp",
+  R"txt(
+*: TranslationUnit
+|-SimpleDeclaration
+| |-struct
+| |-X
+| |-{
+| |-UnknownDeclaration
+| | `-SimpleDeclaration
+| |   |-friend
+| |   |-X
+| |   |-SimpleDeclarator
+| |   | |-operator
+| |   | |-+
+| |   | `-ParametersAndQualifiers
+| |   |   |-(
+| |   |   |-SimpleDeclaration
+| |   |   | |-const
+| |   |   | |-X
+| |   |   | `-SimpleDeclarator
+| |   |   |   `-&
+| |   |   |-,
+| |   |   |-SimpleDeclaration
+| |   |   | |-const
+| |   |   | |-X
+| |   |   | `-SimpleDeclarator
+| |   |   |   `-&
+| |   |   `-)
+| |   `-;
+| |-SimpleDeclaration
+| | |-SimpleDeclarator
+| | | |-operator
+| | | |-int
+| | | `-ParametersAndQualifiers
+| | |   |-(
+| | |   `-)
+| | `-;
+| |-}
+| `-;
+|-TemplateDeclaration
+| |-template
+| |-<
+| |-UnknownDeclaration
+| | |-typename
+| | `-T
+| |->
+| `-SimpleDeclaration
+|   |-void
+|   |-SimpleDeclarator
+|   | |-f
+|   | `-ParametersAndQualifiers
+|   |   |-(
+|   |   |-SimpleDeclaration
+|   |   | |-T
+|   |   | `-SimpleDeclarator
+|   |   |   `-&
+|   |   `-)
+|   `-;
+`-SimpleDeclaration
+  |-void
+  |-SimpleDeclarator
+  | |-test
+  | `-ParametersAndQualifiers
+  |   |-(
+  |   |-SimpleDeclaration
+  |   | |-X
+  |   | `-SimpleDeclarator
+  |   |   `-x
+  |   `-)
+  `-CompoundStatement
+|-{
+|-ExpressionStatement
+| |-IdExpression
+| | `-UnqualifiedId
+| |   `-x
+| `-;
+|-ExpressionStatement
+| |-UnknownExpression
+| | |-IdExpression
+| | | `-UnqualifiedId
+| | |   |-operator
+| | |   `-+
+| | |-(
+| | |-IdExpression
+| | | `-UnqualifiedId
+| | |   `-x
+| | |-,
+| | |-IdExpression
+| | | `-UnqualifiedId
+| | |   `-x
+| | `-)
+| `-;
+|-ExpressionStatement
+| |-UnknownExpression
+| | |-IdExpression
+| | | `-UnqualifiedId
+| | |   |-f
+| | |   |-<
+| | |   |-X
+| | |   `->
+| | |-(
+| | |-IdExpression
+| | | `-UnqualifiedId
+| | |   `-x
+| | `-)
+| `-;
+|-ExpressionStatement
+| |-UnknownExpression
+| | |-UnknownExpression
+| | | |-IdExpression
+| | | | `-UnqualifiedId
+| | | |   `-x
+| | | |-.
+| | | |-operator
+| | | `-int
+| | |-(
+| | `-)
+| `-;
+|-ExpressionStatement
+| |-UnknownExpression
+| | |-UnknownExpression
+| | | |-IdExpression
+| | | | `-UnqualifiedId
+| | | |   `-x
+| | | |-.
+| | | |-~
+| | | `-X
+| | |-(
+| | `-)
+| `-;
+`-}
+)txt"));
+}
+
+TEST_P(SyntaxTreeTest, UnqualifiedIdCxx11OrLater) {
+  if (!GetParam().isCXX11OrLater()) {
+return;
+  }
+  EXPECT_TRUE(treeDumpEqual(
+  R"cpp(
+struct X { };
+unsigned operator "" _w(long long unsigned);
+void test(X x) {
+  operator "" _w(1llu);   // 

[PATCH] D77493: [clang-tidy] Add do-not-refer-atomic-twice check

2020-06-18 Thread Endre Fülöp via Phabricator via cfe-commits
gamesh411 added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/bugprone/DoNotReferAtomicTwiceCheck.cpp:21
+  Finder->addMatcher(
+  declRefExpr(hasType(hasUnqualifiedDesugaredType(atomicType())),
+  to(varDecl().bind("atomic")),

I have run the tests and I found that the last bad test case is not detected. I 
have played with clang-query to investigate and I have found that the main 
reason is the other `declRefExpr` that matches is not on the RHS but also on 
LHS, just one level deeper in the AST.

You could patch it further, but IMO that would surely become way too complex to 
understand and maintain in the long run. What I propose is to not try to solve 
everything with ASTMatchers. This problem is inherently symmetric, and there is 
no way match based on the complexity of an expression, which could be used a 
way to deduplicate results.

I propose the following:

use a matcher like this:
```
expr(
  hasDescendant(
declRefExpr(
  to(
varDecl(
  hasType(
hasUnqualifiedDesugaredType(
  atomicType()
)
  )
).bind("varDecl")
  )
).bind("one")
  ),
  hasDescendant(
declRefExpr(
  to(
varDecl(
  equalsBoundNode("varDecl")
)
  ),
  unless(equalsBoundNode("one"))
).bind("other")
  )
);
```
This will match conflicting DeclRefs with every pair-combinations. Then you 
could use bound nodes `one` and `other` and a set data structure to deduplicate 
the reports as needed. Note you should also watch out for expressions where 3 
references exist to the same VarDecl. That case would emit 6 diagnostics, 4 
references 12, etc. (Also 4 references could result in the first 2 then the 
second two being processed, and you would still have duplication. Handling this 
is probably not really worth it, as I would think this case is unlikely in 
real-world code.)

I would consider this approach more customizable because you decide how to 
deduplicate the results. It is also more understandable, as deduplicating with 
Matchers is not really idiomatic in this symmetric case IMHO. I would not go as 
far as to say anything about performance, but I would be surprised to find a 
good, straightforward filtering solution using Matchers.



Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D77493



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


[PATCH] D81282: [builtins] Move more float128-related helpers to GENERIC_TF_SOURCES list

2020-06-18 Thread Anatoly Trosinenko via Phabricator via cfe-commits
atrosinenko added a comment.

@samsonov Something strange happens with the compiler-rt tests: when this patch 
was initially uploaded, the tests were failed with seemingly unrelated 
failures: B59287 . Some tests are broken 
upstream, I concluded.

Today I have rebased the patch onto current master branch, and the tests 
passed, as expected: B60775 . Right, the tests 
were actually broken upstream, I concluded.

Then I rebased some other my patch that were failing with similar messages: 
D81408 . There may be some clang-format issues 
but the thing I not expected were the same test failures I have seen here: 
B60811 . Even more: the B60775 
 build is marked "Passed", but when I click on 
"Build 73581 pre-merge checks (buildkite)" and then go to "Exterenl Link: 
buildkite build" it shows Linux build as failed.

Returning to the original test failures:

  linux > 
cfi-devirt-lld-thinlto-x86_64.cfi-devirt-lld-thinlto-x86_64::anon-namespace.cpp

They contain the following error message:

  ld.lld: error: Invalid summary version 8. Version should be in the range 
[1-7].

This message is seemingly printed by

name=llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  if (Version < 1 || Version > ModuleSummaryIndex::BitcodeSummaryVersion)
return error("Invalid summary version " + Twine(Version) +
 ". Version should be in the range [1-" +
 Twine(ModuleSummaryIndex::BitcodeSummaryVersion) +
 "].");

with `ModuleSummaryIndex::BitcodeSummaryVersion` defined to be 8 in current 
version of repository.

When trying to reproduce this on my local machine, I built LLVM together with 
clang, compiler-rt and lld. The tests passed. Then I modified the `.script` 
file to directly refer to locally built `bin/FileCheck`, `bin/not`, etc. and 
added `-v` option. Turned out, the Clang driver invokes 
`/path/to/build/directory/bin/ld.lld` but after `chmod -x bin/lld` it silently 
falls back to `/usr/bin/ld.lld`. Finally, the build log contains line "-- lld 
project is disabled" suggesting it does use the system-provided ld.lld that 
prints this warning.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81282



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


[PATCH] D81868: [libTooling] Add parser for string representation of `RangeSelector`.

2020-06-18 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added a comment.

Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81868



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


[PATCH] D80935: [PowerPC][Power10] Implement Parallel Bits Deposit/Extract Builtins in LLVM/Clang

2020-06-18 Thread Amy Kwan via Phabricator via cfe-commits
amyk marked an inline comment as done.
amyk added inline comments.



Comment at: llvm/lib/Target/PowerPC/PPCScheduleP9.td:47
+  let UnsupportedFeatures = [HasQPX, HasSPE, PrefixInstrs, PCRelativeMemops,
+ IsISA3_1];
 

lei wrote:
> Are `PrefixInstrs` and `PCRelativeMemops` not part of `IsISA3_1`?
Currently they are not. I believe those will need to be updated in the future 
to be apart of `IsISA3_1`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80935



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


[PATCH] D81868: [libTooling] Add parser for string representation of `RangeSelector`.

2020-06-18 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 271782.
ymandel marked 3 inline comments as done.
ymandel added a comment.

removed Twine argument per clang-tidy warning.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81868

Files:
  clang/include/clang/Tooling/Transformer/Parsing.h
  clang/lib/Tooling/Transformer/CMakeLists.txt
  clang/lib/Tooling/Transformer/Parsing.cpp
  clang/unittests/Tooling/RangeSelectorTest.cpp

Index: clang/unittests/Tooling/RangeSelectorTest.cpp
===
--- clang/unittests/Tooling/RangeSelectorTest.cpp
+++ clang/unittests/Tooling/RangeSelectorTest.cpp
@@ -10,6 +10,7 @@
 #include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Frontend/ASTUnit.h"
 #include "clang/Tooling/Tooling.h"
+#include "clang/Tooling/Transformer/Parsing.h"
 #include "clang/Tooling/Transformer/SourceCode.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Testing/Support/Error.h"
@@ -132,13 +133,36 @@
 int f(int x, int y, int z) { return 3; }
 int g() { return f(/* comment */ 3, 7 /* comment */, 9); }
   )cc";
-  const char *Call = "call";
-  TestMatch Match = matchCode(Code, callExpr().bind(Call));
-  const auto* E = Match.Result.Nodes.getNodeAs(Call);
+  StringRef CallID = "call";
+  ast_matchers::internal::Matcher M = callExpr().bind(CallID);
+  RangeSelector R = before(node(CallID.str()));
+
+  TestMatch Match = matchCode(Code, M);
+  const auto *E = Match.Result.Nodes.getNodeAs(CallID);
   assert(E != nullptr);
   auto ExprBegin = E->getSourceRange().getBegin();
   EXPECT_THAT_EXPECTED(
-  before(node(Call))(Match.Result),
+  R(Match.Result),
+  HasValue(EqualsCharSourceRange(
+  CharSourceRange::getCharRange(ExprBegin, ExprBegin;
+}
+
+TEST(RangeSelectorTest, BeforeOpParsed) {
+  StringRef Code = R"cc(
+int f(int x, int y, int z) { return 3; }
+int g() { return f(/* comment */ 3, 7 /* comment */, 9); }
+  )cc";
+  StringRef CallID = "call";
+  ast_matchers::internal::Matcher M = callExpr().bind(CallID);
+  auto R = parseRangeSelector(R"rs(before(node("call")))rs");
+  ASSERT_THAT_EXPECTED(R, llvm::Succeeded());
+
+  TestMatch Match = matchCode(Code, M);
+  const auto *E = Match.Result.Nodes.getNodeAs(CallID);
+  assert(E != nullptr);
+  auto ExprBegin = E->getSourceRange().getBegin();
+  EXPECT_THAT_EXPECTED(
+  (*R)(Match.Result),
   HasValue(EqualsCharSourceRange(
   CharSourceRange::getCharRange(ExprBegin, ExprBegin;
 }
@@ -169,45 +193,82 @@
HasValue(EqualsCharSourceRange(ExpectedAfter)));
 }
 
-TEST(RangeSelectorTest, RangeOp) {
+// Node-id specific version.
+TEST(RangeSelectorTest, RangeOpNodes) {
   StringRef Code = R"cc(
 int f(int x, int y, int z) { return 3; }
 int g() { return f(/* comment */ 3, 7 /* comment */, 9); }
   )cc";
-  const char *Arg0 = "a0";
-  const char *Arg1 = "a1";
-  StringRef Call = "call";
-  auto Matcher = callExpr(hasArgument(0, expr().bind(Arg0)),
-  hasArgument(1, expr().bind(Arg1)))
- .bind(Call);
+  auto Matcher = callExpr(hasArgument(0, expr().bind("a0")),
+  hasArgument(1, expr().bind("a1")));
+  RangeSelector R = range("a0", "a1");
+  TestMatch Match = matchCode(Code, Matcher);
+  EXPECT_THAT_EXPECTED(select(R, Match), HasValue("3, 7"));
+}
+
+TEST(RangeSelectorTest, RangeOpGeneral) {
+  StringRef Code = R"cc(
+int f(int x, int y, int z) { return 3; }
+int g() { return f(/* comment */ 3, 7 /* comment */, 9); }
+  )cc";
+  auto Matcher = callExpr(hasArgument(0, expr().bind("a0")),
+  hasArgument(1, expr().bind("a1")));
+  RangeSelector R = range(node("a0"), node("a1"));
   TestMatch Match = matchCode(Code, Matcher);
+  EXPECT_THAT_EXPECTED(select(R, Match), HasValue("3, 7"));
+}
 
-  // Node-id specific version:
-  EXPECT_THAT_EXPECTED(select(range(Arg0, Arg1), Match), HasValue("3, 7"));
-  // General version:
-  EXPECT_THAT_EXPECTED(select(range(node(Arg0), node(Arg1)), Match),
-   HasValue("3, 7"));
+TEST(RangeSelectorTest, RangeOpNodesParsed) {
+  StringRef Code = R"cc(
+int f(int x, int y, int z) { return 3; }
+int g() { return f(/* comment */ 3, 7 /* comment */, 9); }
+  )cc";
+  auto Matcher = callExpr(hasArgument(0, expr().bind("a0")),
+  hasArgument(1, expr().bind("a1")));
+  auto R = parseRangeSelector(R"rs(encloseNodes("a0", "a1"))rs");
+  ASSERT_THAT_EXPECTED(R, llvm::Succeeded());
+  TestMatch Match = matchCode(Code, Matcher);
+  EXPECT_THAT_EXPECTED(select(*R, Match), HasValue("3, 7"));
+}
+
+TEST(RangeSelectorTest, RangeOpGeneralParsed) {
+  StringRef Code = R"cc(
+int f(int x, int y, int z) { return 3; }
+int g() { return f(/* comment */ 3, 7 /* comment */, 9); }
+  )cc";
+  auto Matcher = callExpr(hasArgument(0, expr().bind("a0")),
+  

[PATCH] D81885: [Coroutines] Return false on error of buildSuspends

2020-06-18 Thread Xun Li via Phabricator via cfe-commits
lxfind abandoned this revision.
lxfind added a comment.

Makes sense. I will abandon this change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81885



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


[PATCH] D81837: [ARM][bfloat] Removing lowering of bfloat arguments and returns from Clang's CodeGen

2020-06-18 Thread Ties Stuij via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG035795659b60: [ARM][bfloat] Do not coerce bfloat arguments 
and returns to integers (authored by stuij).

Changed prior to commit:
  https://reviews.llvm.org/D81837?vs=271130=271775#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81837

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/arm-bf16-params-returns.c
  clang/test/CodeGen/arm-mangle-bf16.cpp


Index: clang/test/CodeGen/arm-mangle-bf16.cpp
===
--- clang/test/CodeGen/arm-mangle-bf16.cpp
+++ clang/test/CodeGen/arm-mangle-bf16.cpp
@@ -1,8 +1,6 @@
-// RUN: %clang_cc1 -triple aarch64-arm-none-eabi -target-feature +bf16 
-emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK64
-// RUN: %clang_cc1 -triple arm-arm-none-eabi -target-feature +bf16 -mfloat-abi 
hard -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK32-HARD
-// RUN: %clang_cc1 -triple arm-arm-none-eabi -target-feature +bf16 -mfloat-abi 
softfp -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK32-SOFTFP
+// RUN: %clang_cc1 -triple aarch64-arm-none-eabi -target-feature +bf16 
-emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple arm-arm-none-eabi -target-feature +bf16 -mfloat-abi 
hard -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple arm-arm-none-eabi -target-feature +bf16 -mfloat-abi 
softfp -emit-llvm -o - %s | FileCheck %s
 
-// CHECK64: define {{.*}}void @_Z3foou6__bf16(bfloat %b)
-// CHECK32-HARD: define {{.*}}void @_Z3foou6__bf16(bfloat %b)
-// CHECK32-SOFTFP: define {{.*}}void @_Z3foou6__bf16(i32 %b.coerce)
+// CHECK: define {{.*}}void @_Z3foou6__bf16(bfloat %b)
 void foo(__bf16 b) {}
Index: clang/test/CodeGen/arm-bf16-params-returns.c
===
--- clang/test/CodeGen/arm-bf16-params-returns.c
+++ clang/test/CodeGen/arm-bf16-params-returns.c
@@ -1,7 +1,6 @@
 // RUN: %clang_cc1 -triple armv8.6a-arm-none-eabi -target-abi aapcs 
-mfloat-abi hard -target-feature +bf16 -target-feature +neon -emit-llvm -O2 -o 
- %s | opt -S -mem2reg -sroa | FileCheck %s --check-prefix=CHECK32-HARD
-// RUN: %clang_cc1 -triple aarch64-arm-none-eabi -target-abi aapcs -mfloat-abi 
hard -target-feature +bf16 -target-feature +neon -emit-llvm -O2 -o - %s | opt 
-S -mem2reg -sroa | FileCheck %s --check-prefix=CHECK64-HARD
 // RUN: %clang_cc1 -triple armv8.6a-arm-none-eabi -target-abi aapcs 
-mfloat-abi softfp -target-feature +bf16 -target-feature +neon -emit-llvm -O2 
-o - %s | opt -S -mem2reg -sroa | FileCheck %s --check-prefix=CHECK32-SOFTFP
-// RUN: %clang_cc1 -triple aarch64-arm-none-eabi -target-abi aapcs -mfloat-abi 
softfp -target-feature +bf16 -target-feature +neon -emit-llvm -O2 -o - %s | opt 
-S -mem2reg -sroa | FileCheck %s --check-prefix=CHECK64-SOFTFP
+// RUN: %clang_cc1 -triple aarch64-arm-none-eabi -target-abi aapcs 
-target-feature +bf16 -target-feature +neon -emit-llvm -O2 -o - %s | opt -S 
-mem2reg -sroa | FileCheck %s --check-prefix=CHECK64
 
 #include 
 
@@ -11,22 +10,17 @@
 }
 // CHECK32-HARD: define arm_aapcs_vfpcc bfloat @test_ret_bf16(bfloat returned 
%v) {{.*}} {
 // CHECK32-HARD: ret bfloat %v
-// CHECK64-HARD: define bfloat @test_ret_bf16(bfloat returned %v) {{.*}} {
-// CHECK64-HARD: ret bfloat %v
-// CHECK32-SOFTFP: define i32 @test_ret_bf16(i32 [[V0:.*]]) {{.*}} {
-// CHECK32-SOFTFP: %tmp2.0.insert.ext = and i32 [[V0]], 65535
-// CHECK32-SOFTFP: ret i32 %tmp2.0.insert.ext
-// CHECK64-SOFTFP: define bfloat @test_ret_bf16(bfloat returned %v) {{.*}} {
-// CHECK64-SOFTFP: ret bfloat %v
+// CHECK32-SOFTFP: define bfloat @test_ret_bf16(bfloat returned %v) {{.*}} {
+// CHECK32-SOFTFP: ret bfloat %v
+// CHECK64: define bfloat @test_ret_bf16(bfloat returned %v) {{.*}} {
+// CHECK64: ret bfloat %v
 
 bfloat16x4_t test_ret_bf16x4_t(bfloat16x4_t v) {
   return v;
 }
 // CHECK32-HARD: define arm_aapcs_vfpcc <4 x bfloat> @test_ret_bf16x4_t(<4 x 
bfloat> returned %v) {{.*}} {
 // CHECK32-HARD: ret <4 x bfloat> %v
-// CHECK64-HARD: define <4 x bfloat> @test_ret_bf16x4_t(<4 x bfloat> returned 
%v) {{.*}} {
-// CHECK64-HARD: ret <4 x bfloat> %v
 // CHECK32-SOFTFP: define <2 x i32> @test_ret_bf16x4_t(<2 x i32> [[V0:.*]]) 
{{.*}} {
 // CHECK32-SOFTFP: ret <2 x i32> %v
-// CHECK64-SOFTFP: define <4 x bfloat> @test_ret_bf16x4_t(<4 x bfloat> 
returned %v) {{.*}} {
-// CHECK64-SOFTFP: ret <4 x bfloat> %v
+// CHECK64: define <4 x bfloat> @test_ret_bf16x4_t(<4 x bfloat> returned %v) 
{{.*}} {
+// CHECK64: ret <4 x bfloat> %v
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -6265,13 +6265,6 @@
   if (isIllegalVectorType(Ty))
 return coerceIllegalVector(Ty);
 
-  // __bf16 gets passed using the bfloat IR type, or using i32 but
-  // with 

[PATCH] D81311: [RFC] LangRef: Define byref parameter attribute

2020-06-18 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

This LGTM.


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

https://reviews.llvm.org/D81311



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


[PATCH] D82112: [RFC][BPF] Implement getUserCost() for BPFTargetTransformInfo

2020-06-18 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song created this revision.
yonghong-song added a reviewer: ast.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya.
Herald added projects: clang, LLVM.

This patch tries to partially prevent speculative code motion for BPF.

First, some use cases on why we want to prevent speculative code motion.

Use case 1: bpf map value or some other data with a range.

  data = bpf_map_lookup_elem(, );
  if (!data) return 0;
  payload = data->payload;
  len = bpf_probe_read_kernel_str(payload, 16, >comm);
  if (len <= 16) 
payload += len;
  ... 

The compiler may generate code like:

  data = bpf_map_lookup_elem(, );
  if (!data) return 0;
  payload = data->payload;
  len = bpf_probe_read_kernel_str(payload, 16, >comm);
  new_payload = payload + len;
  if (len > 16) 
new_payload = payload
  ... 

The "payload + len" may cause kernel verifier failure as
the "len" can be anything at this moment.

Use case 2: CO-RE relocatons

  field_exist = ... 
  if (field_exist) {
offset = non-memory-access-builtin-expr1;
  } else {
offset = non-memory-access-builtin-expr2;
  }   
  use "offset" to read kernel memory

The compiler may generate code like:

  field_exist = ... 
  offset = non-memory-access-builtin-expr1;
  if (!field_exist)
offset = non-memory-access-builtin-expr2;
  use "offset" to read kernel memory

This may cause failures since if field_exist is false and 
libbpf is not able to perform relation
for "offset = non-memory-access-builtin-expr1".
The instruction itself will be rewritten as
an illegal instruction and this will cause
program load failures.

To address the above issues, people use

  . inline assembly
  . artificial complex control flow

to prevent the above optimizations.

This patch tries to do with a more user friendly way.
BPF backend TargetTransformInfo implements getUserCost()
to return UserCost INT_MAX for TCK_SizeAndLatency
to prevent compiler moving codes speculatively.
An option "adjustopt", false by default, is added to
enable this adjustment.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82112

Files:
  clang/lib/Basic/Targets/BPF.h
  llvm/lib/Target/BPF/BPF.td
  llvm/lib/Target/BPF/BPFSubtarget.cpp
  llvm/lib/Target/BPF/BPFSubtarget.h
  llvm/lib/Target/BPF/BPFTargetMachine.cpp
  llvm/lib/Target/BPF/BPFTargetMachine.h
  llvm/lib/Target/BPF/BPFTargetTransformInfo.h

Index: llvm/lib/Target/BPF/BPFTargetTransformInfo.h
===
--- /dev/null
+++ llvm/lib/Target/BPF/BPFTargetTransformInfo.h
@@ -0,0 +1,51 @@
+//===-- BPFTargetTransformInfo.h - BPF specific TTI -*- 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 a TargetTransformInfo::Concept conforming object specific to the
+// BPF target machine. It uses the target's detailed information to
+// provide more precise answers to certain TTI queries, while letting the
+// target independent and default TTI implementations handle the rest.
+//
+//===--===//
+
+#ifndef LLVM_LIB_TARGET_BPF_BPFTARGETTRANSFORMINFO_H
+#define LLVM_LIB_TARGET_BPF_BPFTARGETTRANSFORMINFO_H
+
+#include "BPFTargetMachine.h"
+#include "llvm/Analysis/TargetTransformInfo.h"
+#include "llvm/CodeGen/BasicTTIImpl.h"
+
+namespace llvm {
+class BPFTTIImpl : public BasicTTIImplBase {
+  typedef BasicTTIImplBase BaseT;
+  typedef TargetTransformInfo TTI;
+  friend BaseT;
+
+  const BPFSubtarget *ST;
+  const BPFTargetLowering *TLI;
+
+  const BPFSubtarget *getST() const { return ST; }
+  const BPFTargetLowering *getTLI() const { return TLI; }
+
+public:
+  explicit BPFTTIImpl(const BPFTargetMachine *TM, const Function )
+  : BaseT(TM, F.getParent()->getDataLayout()), ST(TM->getSubtargetImpl(F)),
+TLI(ST->getTargetLowering()) {}
+
+  unsigned getUserCost(const User *U, ArrayRef Operands,
+   TTI::TargetCostKind CostKind) {
+if (!ST->getHasAdjustOpt() || CostKind != TTI::TCK_SizeAndLatency)
+  return BaseT::getUserCost(U, Operands, CostKind);
+
+return INT_MAX;
+  }
+};
+
+} // end namespace llvm
+
+#endif // LLVM_LIB_TARGET_BPF_BPFTARGETTRANSFORMINFO_H
Index: llvm/lib/Target/BPF/BPFTargetMachine.h
===
--- llvm/lib/Target/BPF/BPFTargetMachine.h
+++ llvm/lib/Target/BPF/BPFTargetMachine.h
@@ -34,6 +34,8 @@
 
   TargetPassConfig *createPassConfig(PassManagerBase ) override;
 
+  TargetTransformInfo getTargetTransformInfo(const Function ) override;
+
   TargetLoweringObjectFile *getObjFileLowering() const override {
 return TLOF.get();
   }
Index: llvm/lib/Target/BPF/BPFTargetMachine.cpp

[PATCH] D81868: [libTooling] Add parser for string representation of `RangeSelector`.

2020-06-18 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 271770.
ymandel marked 3 inline comments as done.
ymandel added a comment.

address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81868

Files:
  clang/include/clang/Tooling/Transformer/Parsing.h
  clang/lib/Tooling/Transformer/CMakeLists.txt
  clang/lib/Tooling/Transformer/Parsing.cpp
  clang/unittests/Tooling/RangeSelectorTest.cpp

Index: clang/unittests/Tooling/RangeSelectorTest.cpp
===
--- clang/unittests/Tooling/RangeSelectorTest.cpp
+++ clang/unittests/Tooling/RangeSelectorTest.cpp
@@ -10,6 +10,7 @@
 #include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Frontend/ASTUnit.h"
 #include "clang/Tooling/Tooling.h"
+#include "clang/Tooling/Transformer/Parsing.h"
 #include "clang/Tooling/Transformer/SourceCode.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Testing/Support/Error.h"
@@ -132,13 +133,36 @@
 int f(int x, int y, int z) { return 3; }
 int g() { return f(/* comment */ 3, 7 /* comment */, 9); }
   )cc";
-  const char *Call = "call";
-  TestMatch Match = matchCode(Code, callExpr().bind(Call));
-  const auto* E = Match.Result.Nodes.getNodeAs(Call);
+  StringRef CallID = "call";
+  ast_matchers::internal::Matcher M = callExpr().bind(CallID);
+  RangeSelector R = before(node(CallID.str()));
+
+  TestMatch Match = matchCode(Code, M);
+  const auto *E = Match.Result.Nodes.getNodeAs(CallID);
   assert(E != nullptr);
   auto ExprBegin = E->getSourceRange().getBegin();
   EXPECT_THAT_EXPECTED(
-  before(node(Call))(Match.Result),
+  R(Match.Result),
+  HasValue(EqualsCharSourceRange(
+  CharSourceRange::getCharRange(ExprBegin, ExprBegin;
+}
+
+TEST(RangeSelectorTest, BeforeOpParsed) {
+  StringRef Code = R"cc(
+int f(int x, int y, int z) { return 3; }
+int g() { return f(/* comment */ 3, 7 /* comment */, 9); }
+  )cc";
+  StringRef CallID = "call";
+  ast_matchers::internal::Matcher M = callExpr().bind(CallID);
+  auto R = parseRangeSelector(R"rs(before(node("call")))rs");
+  ASSERT_THAT_EXPECTED(R, llvm::Succeeded());
+
+  TestMatch Match = matchCode(Code, M);
+  const auto *E = Match.Result.Nodes.getNodeAs(CallID);
+  assert(E != nullptr);
+  auto ExprBegin = E->getSourceRange().getBegin();
+  EXPECT_THAT_EXPECTED(
+  (*R)(Match.Result),
   HasValue(EqualsCharSourceRange(
   CharSourceRange::getCharRange(ExprBegin, ExprBegin;
 }
@@ -169,45 +193,82 @@
HasValue(EqualsCharSourceRange(ExpectedAfter)));
 }
 
-TEST(RangeSelectorTest, RangeOp) {
+// Node-id specific version.
+TEST(RangeSelectorTest, RangeOpNodes) {
   StringRef Code = R"cc(
 int f(int x, int y, int z) { return 3; }
 int g() { return f(/* comment */ 3, 7 /* comment */, 9); }
   )cc";
-  const char *Arg0 = "a0";
-  const char *Arg1 = "a1";
-  StringRef Call = "call";
-  auto Matcher = callExpr(hasArgument(0, expr().bind(Arg0)),
-  hasArgument(1, expr().bind(Arg1)))
- .bind(Call);
+  auto Matcher = callExpr(hasArgument(0, expr().bind("a0")),
+  hasArgument(1, expr().bind("a1")));
+  RangeSelector R = range("a0", "a1");
+  TestMatch Match = matchCode(Code, Matcher);
+  EXPECT_THAT_EXPECTED(select(R, Match), HasValue("3, 7"));
+}
+
+TEST(RangeSelectorTest, RangeOpGeneral) {
+  StringRef Code = R"cc(
+int f(int x, int y, int z) { return 3; }
+int g() { return f(/* comment */ 3, 7 /* comment */, 9); }
+  )cc";
+  auto Matcher = callExpr(hasArgument(0, expr().bind("a0")),
+  hasArgument(1, expr().bind("a1")));
+  RangeSelector R = range(node("a0"), node("a1"));
   TestMatch Match = matchCode(Code, Matcher);
+  EXPECT_THAT_EXPECTED(select(R, Match), HasValue("3, 7"));
+}
 
-  // Node-id specific version:
-  EXPECT_THAT_EXPECTED(select(range(Arg0, Arg1), Match), HasValue("3, 7"));
-  // General version:
-  EXPECT_THAT_EXPECTED(select(range(node(Arg0), node(Arg1)), Match),
-   HasValue("3, 7"));
+TEST(RangeSelectorTest, RangeOpNodesParsed) {
+  StringRef Code = R"cc(
+int f(int x, int y, int z) { return 3; }
+int g() { return f(/* comment */ 3, 7 /* comment */, 9); }
+  )cc";
+  auto Matcher = callExpr(hasArgument(0, expr().bind("a0")),
+  hasArgument(1, expr().bind("a1")));
+  auto R = parseRangeSelector(R"rs(encloseNodes("a0", "a1"))rs");
+  ASSERT_THAT_EXPECTED(R, llvm::Succeeded());
+  TestMatch Match = matchCode(Code, Matcher);
+  EXPECT_THAT_EXPECTED(select(*R, Match), HasValue("3, 7"));
+}
+
+TEST(RangeSelectorTest, RangeOpGeneralParsed) {
+  StringRef Code = R"cc(
+int f(int x, int y, int z) { return 3; }
+int g() { return f(/* comment */ 3, 7 /* comment */, 9); }
+  )cc";
+  auto Matcher = callExpr(hasArgument(0, expr().bind("a0")),
+  hasArgument(1, expr().bind("a1")));
+ 

[PATCH] D81672: [Driver] When forcing a crash call abort to get the correct diagnostic

2020-06-18 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

But that won't work when compiling & crashing with `-fno-integrated-cc1`, would 
it? (or if building with `cmake ... -DCLANG_SPAWN_CC1=1`). In that case, normal 
crashes (not -gen-reproducer) won't go through the `CrashRecoveryContext`.
Try running:

  $ CCC_OVERRIDE_OPTIONS=+-fno-integrated-cc1
  $ py your_build_folder/bin/llvm-lit.py -vv -a clang/test/Driver/crash-report.c

See if the commands issued by the test display the "PLEASE submit a bug report" 
message.


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

https://reviews.llvm.org/D81672



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


[clang] eed45b5 - [OPENMP][DOCS]Update status of supported constructs, NFC.

2020-06-18 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2020-06-18T13:29:33-04:00
New Revision: eed45b5fa2b638360ebfde037d284b9dc69e54c0

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

LOG: [OPENMP][DOCS]Update status of supported constructs, NFC.

Added: 


Modified: 
clang/docs/OpenMPSupport.rst

Removed: 




diff  --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst
index e6c4752ef51c..f56980faaee8 100644
--- a/clang/docs/OpenMPSupport.rst
+++ b/clang/docs/OpenMPSupport.rst
@@ -245,7 +245,7 @@ implementation.
 
+--+--+--+---+
 | misc extension   | pointer/reference to pointer based array 
reductions  | :none:`unclaimed`|
   |
 
+--+--+--+---+
-| misc extension   | prevent new type definitions in clauses   
   | :none:`unclaimed`| 
  |
+| misc extension   | prevent new type definitions in clauses   
   | :good:`done` | 
  |
 
+--+--+--+---+
 | memory model extension   | memory model update (seq_cst, acq_rel, 
release, acquire,...) | :good:`done` |  
 |
 
+--+--+--+---+



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


[clang] 0357956 - [ARM][bfloat] Do not coerce bfloat arguments and returns to integers

2020-06-18 Thread Ties Stuij via cfe-commits

Author: Ties Stuij
Date: 2020-06-18T18:26:01+01:00
New Revision: 035795659b604246b873f659f8feed8084898247

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

LOG: [ARM][bfloat] Do not coerce bfloat arguments and returns to integers

Summary:
As part of moving the argument lowering handling for bfloat arguments and
returns to the backend, this patch removes the code that was responsible for
handling the coercion of those arguments in Clang's Codegen.

Subscribers: kristof.beyls, danielkiss, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/lib/CodeGen/TargetInfo.cpp
clang/test/CodeGen/arm-bf16-params-returns.c
clang/test/CodeGen/arm-mangle-bf16.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/TargetInfo.cpp 
b/clang/lib/CodeGen/TargetInfo.cpp
index 44be42aaefde..9710e676e58f 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -6265,13 +6265,6 @@ ABIArgInfo ARMABIInfo::classifyArgumentType(QualType Ty, 
bool isVariadic,
   if (isIllegalVectorType(Ty))
 return coerceIllegalVector(Ty);
 
-  // __bf16 gets passed using the bfloat IR type, or using i32 but
-  // with the top 16 bits unspecified.
-  if (Ty->isBFloat16Type() && IsFloatABISoftFP) {
-llvm::Type *ResType = llvm::Type::getInt32Ty(getVMContext());
-return ABIArgInfo::getDirect(ResType);
-  }
-
   if (!isAggregateTypeForABI(Ty)) {
 // Treat an enum type as its underlying type.
 if (const EnumType *EnumTy = Ty->getAs()) {
@@ -6475,15 +6468,6 @@ ABIArgInfo ARMABIInfo::classifyReturnType(QualType 
RetTy, bool isVariadic,
   return coerceIllegalVector(RetTy);
   }
 
-  // if we're using the softfp float abi, __bf16 get returned as if it were an
-  // int but with the top 16 bits unspecified.
-  if (RetTy->isBFloat16Type()) {
-llvm::Type *ResType = IsAAPCS_VFP ?
-  llvm::Type::getBFloatTy(getVMContext()) :
-  llvm::Type::getInt32Ty(getVMContext());
-return ABIArgInfo::getDirect(ResType);
-  }
-
   if (!isAggregateTypeForABI(RetTy)) {
 // Treat an enum type as its underlying type.
 if (const EnumType *EnumTy = RetTy->getAs())

diff  --git a/clang/test/CodeGen/arm-bf16-params-returns.c 
b/clang/test/CodeGen/arm-bf16-params-returns.c
index 11e236c51530..ee89bbb96f3f 100644
--- a/clang/test/CodeGen/arm-bf16-params-returns.c
+++ b/clang/test/CodeGen/arm-bf16-params-returns.c
@@ -1,7 +1,6 @@
 // RUN: %clang_cc1 -triple armv8.6a-arm-none-eabi -target-abi aapcs 
-mfloat-abi hard -target-feature +bf16 -target-feature +neon -emit-llvm -O2 -o 
- %s | opt -S -mem2reg -sroa | FileCheck %s --check-prefix=CHECK32-HARD
-// RUN: %clang_cc1 -triple aarch64-arm-none-eabi -target-abi aapcs -mfloat-abi 
hard -target-feature +bf16 -target-feature +neon -emit-llvm -O2 -o - %s | opt 
-S -mem2reg -sroa | FileCheck %s --check-prefix=CHECK64-HARD
 // RUN: %clang_cc1 -triple armv8.6a-arm-none-eabi -target-abi aapcs 
-mfloat-abi softfp -target-feature +bf16 -target-feature +neon -emit-llvm -O2 
-o - %s | opt -S -mem2reg -sroa | FileCheck %s --check-prefix=CHECK32-SOFTFP
-// RUN: %clang_cc1 -triple aarch64-arm-none-eabi -target-abi aapcs -mfloat-abi 
softfp -target-feature +bf16 -target-feature +neon -emit-llvm -O2 -o - %s | opt 
-S -mem2reg -sroa | FileCheck %s --check-prefix=CHECK64-SOFTFP
+// RUN: %clang_cc1 -triple aarch64-arm-none-eabi -target-abi aapcs 
-target-feature +bf16 -target-feature +neon -emit-llvm -O2 -o - %s | opt -S 
-mem2reg -sroa | FileCheck %s --check-prefix=CHECK64
 
 #include 
 
@@ -11,22 +10,17 @@ __bf16 test_ret_bf16(__bf16 v) {
 }
 // CHECK32-HARD: define arm_aapcs_vfpcc bfloat @test_ret_bf16(bfloat returned 
%v) {{.*}} {
 // CHECK32-HARD: ret bfloat %v
-// CHECK64-HARD: define bfloat @test_ret_bf16(bfloat returned %v) {{.*}} {
-// CHECK64-HARD: ret bfloat %v
-// CHECK32-SOFTFP: define i32 @test_ret_bf16(i32 [[V0:.*]]) {{.*}} {
-// CHECK32-SOFTFP: %tmp2.0.insert.ext = and i32 [[V0]], 65535
-// CHECK32-SOFTFP: ret i32 %tmp2.0.insert.ext
-// CHECK64-SOFTFP: define bfloat @test_ret_bf16(bfloat returned %v) {{.*}} {
-// CHECK64-SOFTFP: ret bfloat %v
+// CHECK32-SOFTFP: define bfloat @test_ret_bf16(bfloat returned %v) {{.*}} {
+// CHECK32-SOFTFP: ret bfloat %v
+// CHECK64: define bfloat @test_ret_bf16(bfloat returned %v) {{.*}} {
+// CHECK64: ret bfloat %v
 
 bfloat16x4_t test_ret_bf16x4_t(bfloat16x4_t v) {
   return v;
 }
 // CHECK32-HARD: define arm_aapcs_vfpcc <4 x bfloat> @test_ret_bf16x4_t(<4 x 
bfloat> returned %v) {{.*}} {
 // CHECK32-HARD: ret <4 x bfloat> %v
-// CHECK64-HARD: define <4 x bfloat> @test_ret_bf16x4_t(<4 x bfloat> returned 
%v) {{.*}} {
-// CHECK64-HARD: ret <4 x bfloat> %v
 // CHECK32-SOFTFP: define <2 x i32> @test_ret_bf16x4_t(<2 x i32> [[V0:.*]]) 
{{.*}} {
 // 

[PATCH] D82019: [OPENMP]Fix PR46357: Do not allow types declarations in pragmas.

2020-06-18 Thread Alexey Bataev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG437cbad3b35c: [OPENMP]Fix PR46357: Do not allow types 
declarations in pragmas. (authored by ABataev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82019

Files:
  clang/include/clang/Parse/RAIIObjectsForParser.h
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/test/OpenMP/declare_reduction_ast_print.cpp


Index: clang/test/OpenMP/declare_reduction_ast_print.cpp
===
--- clang/test/OpenMP/declare_reduction_ast_print.cpp
+++ clang/test/OpenMP/declare_reduction_ast_print.cpp
@@ -17,7 +17,11 @@
 {
   struct A { int a; A() : a(0) {} };
   #pragma omp declare reduction(+: A : bar(omp_out, omp_in))
-};
+  #pragma omp declare reduction(-: struct A : bar(omp_out, omp_in))
+}
+// CHECK: namespace N1 {
+// CHECK: #pragma omp declare reduction (+ : N1::A : bar(omp_out, omp_in))
+// CHECK: #pragma omp declare reduction (- : struct A : bar(omp_out, omp_in))
 
 #pragma omp declare reduction(+ : int, char : omp_out *= omp_in)
 // CHECK: #pragma omp declare reduction (+ : int : omp_out *= omp_in){{$}}
Index: clang/lib/Parse/ParseOpenMP.cpp
===
--- clang/lib/Parse/ParseOpenMP.cpp
+++ clang/lib/Parse/ParseOpenMP.cpp
@@ -1824,6 +1824,8 @@
 // Skip last tokens.
 skipUntilPragmaOpenMPEnd(OMPD_begin_declare_variant);
 
+ParsingOpenMPDirectiveRAII NormalScope(*this, /*Value=*/false);
+
 VariantMatchInfo VMI;
 ASTContext  = Actions.getASTContext();
 TI.getAsVariantMatchInfo(ASTCtx, VMI);
@@ -1921,6 +1923,7 @@
 if (!Actions.ActOnStartOpenMPDeclareTargetDirective(DTLoc))
   return DeclGroupPtrTy();
 
+ParsingOpenMPDirectiveRAII NormalScope(*this, /*Value=*/false);
 llvm::SmallVector  Decls;
 DKind = parseOpenMPDirectiveKind(*this);
 while (DKind != OMPD_end_declare_target && Tok.isNot(tok::eof) &&
@@ -2333,6 +2336,7 @@
   // FIXME: We create a bogus CompoundStmt scope to hold the contents of
   // the captured region. Code elsewhere assumes that any FunctionScopeInfo
   // should have at least one compound statement scope within it.
+  ParsingOpenMPDirectiveRAII NormalScope(*this, /*Value=*/false);
   AssociatedStmt = (Sema::CompoundScopeRAII(Actions), ParseStatement());
   AssociatedStmt = Actions.ActOnOpenMPRegionEnd(AssociatedStmt, Clauses);
 } else if (DKind == OMPD_target_update || DKind == OMPD_target_enter_data 
||
Index: clang/lib/Parse/ParseDeclCXX.cpp
===
--- clang/lib/Parse/ParseDeclCXX.cpp
+++ clang/lib/Parse/ParseDeclCXX.cpp
@@ -1681,7 +1681,8 @@
 
   const PrintingPolicy  = Actions.getASTContext().getPrintingPolicy();
   Sema::TagUseKind TUK;
-  if (isDefiningTypeSpecifierContext(DSC) == AllowDefiningTypeSpec::No)
+  if (isDefiningTypeSpecifierContext(DSC) == AllowDefiningTypeSpec::No ||
+  (getLangOpts().OpenMP && OpenMPDirectiveParsing))
 TUK = Sema::TUK_Reference;
   else if (Tok.is(tok::l_brace) ||
(getLangOpts().CPlusPlus && Tok.is(tok::colon)) ||
Index: clang/include/clang/Parse/RAIIObjectsForParser.h
===
--- clang/include/clang/Parse/RAIIObjectsForParser.h
+++ clang/include/clang/Parse/RAIIObjectsForParser.h
@@ -294,9 +294,9 @@
 bool OldVal;
 
   public:
-ParsingOpenMPDirectiveRAII(Parser )
+ParsingOpenMPDirectiveRAII(Parser , bool Value = true)
 : P(P), OldVal(P.OpenMPDirectiveParsing) {
-  P.OpenMPDirectiveParsing = true;
+  P.OpenMPDirectiveParsing = Value;
 }
 
 /// This can be used to restore the state early, before the dtor


Index: clang/test/OpenMP/declare_reduction_ast_print.cpp
===
--- clang/test/OpenMP/declare_reduction_ast_print.cpp
+++ clang/test/OpenMP/declare_reduction_ast_print.cpp
@@ -17,7 +17,11 @@
 {
   struct A { int a; A() : a(0) {} };
   #pragma omp declare reduction(+: A : bar(omp_out, omp_in))
-};
+  #pragma omp declare reduction(-: struct A : bar(omp_out, omp_in))
+}
+// CHECK: namespace N1 {
+// CHECK: #pragma omp declare reduction (+ : N1::A : bar(omp_out, omp_in))
+// CHECK: #pragma omp declare reduction (- : struct A : bar(omp_out, omp_in))
 
 #pragma omp declare reduction(+ : int, char : omp_out *= omp_in)
 // CHECK: #pragma omp declare reduction (+ : int : omp_out *= omp_in){{$}}
Index: clang/lib/Parse/ParseOpenMP.cpp
===
--- clang/lib/Parse/ParseOpenMP.cpp
+++ clang/lib/Parse/ParseOpenMP.cpp
@@ -1824,6 +1824,8 @@
 // Skip last tokens.
 skipUntilPragmaOpenMPEnd(OMPD_begin_declare_variant);
 
+ParsingOpenMPDirectiveRAII NormalScope(*this, /*Value=*/false);
+
  

[PATCH] D80913: [update_cc_test_checks.py] Correctly skip function definitions

2020-06-18 Thread Alexander Richardson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGead7a8beccc1: [update_cc_test_checks.py] Correctly skip 
function definitions (authored by arichardson).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80913

Files:
  clang/test/utils/update_cc_test_checks/Inputs/def-and-decl.c
  clang/test/utils/update_cc_test_checks/Inputs/def-and-decl.c.expected
  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
@@ -76,8 +76,18 @@
 if line is None:
   common.debug('Skipping function without line number:', node['name'], '@', node['loc'])
   return
-# If there is no 'inner' object, it is a function declaration -> skip
-if 'inner' not in node:
+
+# If there is no 'inner' object, it is a function declaration and we can
+# skip it. However, function declarations may also contain an 'inner' list,
+# but in that case it will only contains ParmVarDecls. If we find an entry
+# that is not a ParmVarDecl, we know that this is a function definition.
+has_body = False
+if 'inner' in node:
+  for i in node['inner']:
+if i.get('kind', 'ParmVarDecl') != 'ParmVarDecl':
+  has_body = True
+  break
+if not has_body:
   common.debug('Skipping function without body:', node['name'], '@', node['loc'])
   return
 spell = node['name']
Index: clang/test/utils/update_cc_test_checks/Inputs/def-and-decl.c.expected
===
--- clang/test/utils/update_cc_test_checks/Inputs/def-and-decl.c.expected
+++ clang/test/utils/update_cc_test_checks/Inputs/def-and-decl.c.expected
@@ -2,33 +2,36 @@
 // Check that the CHECK lines are generated before the definition and not the declaration
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu %s -emit-llvm -o - | FileCheck %s
 
-int foo();
+int foo(int arg);
 
-void empty_function();
+void empty_function(void);
 
 // CHECK-LABEL: @main(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[RETVAL:%.*]] = alloca i32, align 4
 // CHECK-NEXT:store i32 0, i32* [[RETVAL]], align 4
 // CHECK-NEXT:call void @empty_function()
-// CHECK-NEXT:[[CALL:%.*]] = call i32 @foo()
+// CHECK-NEXT:[[CALL:%.*]] = call i32 @foo(i32 1)
 // CHECK-NEXT:ret i32 [[CALL]]
 //
 int main() {
   empty_function();
-  return foo();
+  return foo(1);
 }
 
 // CHECK-LABEL: @foo(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:ret i32 1
+// CHECK-NEXT:[[ARG_ADDR:%.*]] = alloca i32, align 4
+// CHECK-NEXT:store i32 [[ARG:%.*]], i32* [[ARG_ADDR]], align 4
+// CHECK-NEXT:[[TMP0:%.*]] = load i32, i32* [[ARG_ADDR]], align 4
+// CHECK-NEXT:ret i32 [[TMP0]]
 //
-int foo() {
-  return 1;
+int foo(int arg) {
+  return arg;
 }
 
 // CHECK-LABEL: @empty_function(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:ret void
 //
-void empty_function() {}
+void empty_function(void) {}
Index: clang/test/utils/update_cc_test_checks/Inputs/def-and-decl.c
===
--- clang/test/utils/update_cc_test_checks/Inputs/def-and-decl.c
+++ clang/test/utils/update_cc_test_checks/Inputs/def-and-decl.c
@@ -1,17 +1,17 @@
 // Check that the CHECK lines are generated before the definition and not the declaration
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu %s -emit-llvm -o - | FileCheck %s
 
-int foo();
+int foo(int arg);
 
-void empty_function();
+void empty_function(void);
 
 int main() {
   empty_function();
-  return foo();
+  return foo(1);
 }
 
-int foo() {
-  return 1;
+int foo(int arg) {
+  return arg;
 }
 
-void empty_function() {}
+void empty_function(void) {}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80914: [update_cc_test_checks.py] Handle C++ methods

2020-06-18 Thread Alexander Richardson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3ce0e92f45f5: [update_cc_test_checks.py] Handle C++ methods 
(authored by arichardson).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80914

Files:
  clang/test/utils/update_cc_test_checks/Inputs/basic-cplusplus.cpp
  clang/test/utils/update_cc_test_checks/Inputs/basic-cplusplus.cpp.expected
  clang/test/utils/update_cc_test_checks/basic-cplusplus.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
@@ -61,11 +61,14 @@
   def parse_clang_ast_json(node):
 node_kind = node['kind']
 # Recurse for the following nodes that can contain nested function decls:
-if node_kind in ('NamespaceDecl', 'LinkageSpecDecl', 'TranslationUnitDecl'):
-  for inner in node['inner']:
-parse_clang_ast_json(inner)
+if node_kind in ('NamespaceDecl', 'LinkageSpecDecl', 'TranslationUnitDecl',
+ 'CXXRecordDecl'):
+  if 'inner' in node:
+for inner in node['inner']:
+  parse_clang_ast_json(inner)
 # Otherwise we ignore everything except functions:
-if node['kind'] != 'FunctionDecl':
+if node_kind not in ('FunctionDecl', 'CXXMethodDecl', 'CXXConstructorDecl',
+ 'CXXDestructorDecl', 'CXXConversionDecl'):
   return
 if node.get('isImplicit') is True and node.get('storageClass') == 'extern':
   common.debug('Skipping builtin function:', node['name'], '@', node['loc'])
Index: clang/test/utils/update_cc_test_checks/basic-cplusplus.test
===
--- /dev/null
+++ clang/test/utils/update_cc_test_checks/basic-cplusplus.test
@@ -0,0 +1,7 @@
+## Test that CHECK lines are generated before the definion and not the declaration
+
+# RUN: cp %S/Inputs/basic-cplusplus.cpp %t.cpp && %update_cc_test_checks %t.cpp
+# RUN: diff -u %S/Inputs/basic-cplusplus.cpp.expected %t.cpp
+## Check that re-running update_cc_test_checks doesn't change the output
+# RUN: %update_cc_test_checks %t.cpp
+# RUN: diff -u %S/Inputs/basic-cplusplus.cpp.expected %t.cpp
Index: clang/test/utils/update_cc_test_checks/Inputs/basic-cplusplus.cpp.expected
===
--- /dev/null
+++ clang/test/utils/update_cc_test_checks/Inputs/basic-cplusplus.cpp.expected
@@ -0,0 +1,80 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// Basic C++ test for update_cc_test_checks
+// RUN: %clang_cc1 -triple=x86_64-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s
+
+class Foo {
+  int x;
+
+public:
+  explicit Foo(int x);
+  ~Foo();
+// CHECK-LABEL: @_ZNK3Foo23function_defined_inlineEi(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[THIS_ADDR:%.*]] = alloca %class.Foo*, align 8
+// CHECK-NEXT:[[ARG_ADDR:%.*]] = alloca i32, align 4
+// CHECK-NEXT:store %class.Foo* [[THIS:%.*]], %class.Foo** [[THIS_ADDR]], align 8
+// CHECK-NEXT:store i32 [[ARG:%.*]], i32* [[ARG_ADDR]], align 4
+// CHECK-NEXT:[[THIS1:%.*]] = load %class.Foo*, %class.Foo** [[THIS_ADDR]], align 8
+// CHECK-NEXT:[[TMP0:%.*]] = load i32, i32* [[ARG_ADDR]], align 4
+// CHECK-NEXT:[[X:%.*]] = getelementptr inbounds [[CLASS_FOO:%.*]], %class.Foo* [[THIS1]], i32 0, i32 0
+// CHECK-NEXT:[[TMP1:%.*]] = load i32, i32* [[X]], align 4
+// CHECK-NEXT:[[ADD:%.*]] = add nsw i32 [[TMP0]], [[TMP1]]
+// CHECK-NEXT:ret i32 [[ADD]]
+//
+  inline int function_defined_inline(int arg) const {
+return arg + x;
+  }
+  inline int function_defined_out_of_line(int arg) const;
+};
+
+// CHECK-LABEL: @_ZN3FooC1Ei(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[THIS_ADDR:%.*]] = alloca %class.Foo*, align 8
+// CHECK-NEXT:[[X_ADDR:%.*]] = alloca i32, align 4
+// CHECK-NEXT:store %class.Foo* [[THIS:%.*]], %class.Foo** [[THIS_ADDR]], align 8
+// CHECK-NEXT:store i32 [[X:%.*]], i32* [[X_ADDR]], align 4
+// CHECK-NEXT:[[THIS1:%.*]] = load %class.Foo*, %class.Foo** [[THIS_ADDR]], align 8
+// CHECK-NEXT:[[TMP0:%.*]] = load i32, i32* [[X_ADDR]], align 4
+// CHECK-NEXT:call void @_ZN3FooC2Ei(%class.Foo* [[THIS1]], i32 [[TMP0]])
+// CHECK-NEXT:ret void
+//
+Foo::Foo(int x) : x(x) {}
+// CHECK-LABEL: @_ZN3FooD1Ev(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[THIS_ADDR:%.*]] = alloca %class.Foo*, align 8
+// CHECK-NEXT:store %class.Foo* [[THIS:%.*]], %class.Foo** [[THIS_ADDR]], align 8
+// CHECK-NEXT:[[THIS1:%.*]] = load %class.Foo*, %class.Foo** [[THIS_ADDR]], align 8
+// CHECK-NEXT:call void @_ZN3FooD2Ev(%class.Foo* [[THIS1]]) #2
+// CHECK-NEXT:ret void
+//
+Foo::~Foo() {}
+// CHECK-LABEL: @_ZNK3Foo28function_defined_out_of_lineEi(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:

[PATCH] D82046: [HIP] Improve check patterns to avoid test failures in case string "opt",etc. happens to be in the InstallDir path in the -### output.

2020-06-18 Thread Hiroshi Yamauchi via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGce82b8e8af6d: [HIP] Improve check patterns to avoid test 
failures in case string opt, etc. (authored by yamauchi).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82046

Files:
  clang/test/Driver/hip-toolchain-no-rdc.hip


Index: clang/test/Driver/hip-toolchain-no-rdc.hip
===
--- clang/test/Driver/hip-toolchain-no-rdc.hip
+++ clang/test/Driver/hip-toolchain-no-rdc.hip
@@ -154,14 +154,14 @@
 // Link host objects.
 //
 
-// LINK-NOT: llvm-link
-// LINK-NOT: opt
-// LINK-NOT: llc
+// LINK-NOT: {{".*/llvm-link"}}
+// LINK-NOT: {{".*/opt"}}
+// LINK-NOT: {{".*/llc"}}
 // LINK: [[LD:".*ld.*"]] {{.*}} [[A_OBJ_HOST]] [[B_OBJ_HOST]]
 // LINK-NOT: "-T" "{{.*}}.lk"
 
-// LKONLY-NOT: llvm-link
-// LKONLY-NOT: opt
-// LKONLY-NOT: llc
+// LKONLY-NOT: {{".*/llvm-link"}}
+// LKONLY-NOT: {{".*/opt"}}
+// LKONLY-NOT: {{".*/llc"}}
 // LKONLY: [[LD:".*ld.*"]] {{.*}} "{{.*/a.o}}" "{{.*/b.o}}"
 // LKONLY-NOT: "-T" "{{.*}}.lk"


Index: clang/test/Driver/hip-toolchain-no-rdc.hip
===
--- clang/test/Driver/hip-toolchain-no-rdc.hip
+++ clang/test/Driver/hip-toolchain-no-rdc.hip
@@ -154,14 +154,14 @@
 // Link host objects.
 //
 
-// LINK-NOT: llvm-link
-// LINK-NOT: opt
-// LINK-NOT: llc
+// LINK-NOT: {{".*/llvm-link"}}
+// LINK-NOT: {{".*/opt"}}
+// LINK-NOT: {{".*/llc"}}
 // LINK: [[LD:".*ld.*"]] {{.*}} [[A_OBJ_HOST]] [[B_OBJ_HOST]]
 // LINK-NOT: "-T" "{{.*}}.lk"
 
-// LKONLY-NOT: llvm-link
-// LKONLY-NOT: opt
-// LKONLY-NOT: llc
+// LKONLY-NOT: {{".*/llvm-link"}}
+// LKONLY-NOT: {{".*/opt"}}
+// LKONLY-NOT: {{".*/llc"}}
 // LKONLY: [[LD:".*ld.*"]] {{.*}} "{{.*/a.o}}" "{{.*/b.o}}"
 // LKONLY-NOT: "-T" "{{.*}}.lk"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75229: [clang-tidy] Add signal-in-multithreaded-program check

2020-06-18 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp:88
 
 // C checkers
 // CON

abelkocsis wrote:
> Eugene.Zelenko wrote:
> > Please use //check// here.
> Should I replace the `// C++ checkers` comment too? I mean to `// C++ checks` 
> instead of `// C++ checkers`?
Sure. It's good idea to keep user and developer terminology consistent.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D75229



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


[clang] 437cbad - [OPENMP]Fix PR46357: Do not allow types declarations in pragmas.

2020-06-18 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2020-06-18T13:17:03-04:00
New Revision: 437cbad3b35c7cf0f49d2bcea0a521651113

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

LOG: [OPENMP]Fix PR46357: Do not allow types declarations in pragmas.

Summary:
Compiler may erroneously treat current context in OpenMP pragmas as the
context where new type declaration/definition is allowed. But the
declartation/definition of the new types in OpenMP pragmas should not be
allowed.

Reviewers: jdoerfert

Subscribers: yaxunl, guansong, sstefan1, cfe-commits, caomhin

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/Parse/RAIIObjectsForParser.h
clang/lib/Parse/ParseDeclCXX.cpp
clang/lib/Parse/ParseOpenMP.cpp
clang/test/OpenMP/declare_reduction_ast_print.cpp

Removed: 




diff  --git a/clang/include/clang/Parse/RAIIObjectsForParser.h 
b/clang/include/clang/Parse/RAIIObjectsForParser.h
index 40351bf71d9f..bc1754614ad9 100644
--- a/clang/include/clang/Parse/RAIIObjectsForParser.h
+++ b/clang/include/clang/Parse/RAIIObjectsForParser.h
@@ -294,9 +294,9 @@ namespace clang {
 bool OldVal;
 
   public:
-ParsingOpenMPDirectiveRAII(Parser )
+ParsingOpenMPDirectiveRAII(Parser , bool Value = true)
 : P(P), OldVal(P.OpenMPDirectiveParsing) {
-  P.OpenMPDirectiveParsing = true;
+  P.OpenMPDirectiveParsing = Value;
 }
 
 /// This can be used to restore the state early, before the dtor

diff  --git a/clang/lib/Parse/ParseDeclCXX.cpp 
b/clang/lib/Parse/ParseDeclCXX.cpp
index 5c41fe7921a6..7a8a94203190 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -1681,7 +1681,8 @@ void Parser::ParseClassSpecifier(tok::TokenKind 
TagTokKind,
 
   const PrintingPolicy  = Actions.getASTContext().getPrintingPolicy();
   Sema::TagUseKind TUK;
-  if (isDefiningTypeSpecifierContext(DSC) == AllowDefiningTypeSpec::No)
+  if (isDefiningTypeSpecifierContext(DSC) == AllowDefiningTypeSpec::No ||
+  (getLangOpts().OpenMP && OpenMPDirectiveParsing))
 TUK = Sema::TUK_Reference;
   else if (Tok.is(tok::l_brace) ||
(getLangOpts().CPlusPlus && Tok.is(tok::colon)) ||

diff  --git a/clang/lib/Parse/ParseOpenMP.cpp b/clang/lib/Parse/ParseOpenMP.cpp
index 5161c7d06cda..6cf50a5794f7 100644
--- a/clang/lib/Parse/ParseOpenMP.cpp
+++ b/clang/lib/Parse/ParseOpenMP.cpp
@@ -1824,6 +1824,8 @@ Parser::DeclGroupPtrTy 
Parser::ParseOpenMPDeclarativeDirectiveWithExtDecl(
 // Skip last tokens.
 skipUntilPragmaOpenMPEnd(OMPD_begin_declare_variant);
 
+ParsingOpenMPDirectiveRAII NormalScope(*this, /*Value=*/false);
+
 VariantMatchInfo VMI;
 ASTContext  = Actions.getASTContext();
 TI.getAsVariantMatchInfo(ASTCtx, VMI);
@@ -1921,6 +1923,7 @@ Parser::DeclGroupPtrTy 
Parser::ParseOpenMPDeclarativeDirectiveWithExtDecl(
 if (!Actions.ActOnStartOpenMPDeclareTargetDirective(DTLoc))
   return DeclGroupPtrTy();
 
+ParsingOpenMPDirectiveRAII NormalScope(*this, /*Value=*/false);
 llvm::SmallVector  Decls;
 DKind = parseOpenMPDirectiveKind(*this);
 while (DKind != OMPD_end_declare_target && Tok.isNot(tok::eof) &&
@@ -2333,6 +2336,7 @@ 
Parser::ParseOpenMPDeclarativeOrExecutableDirective(ParsedStmtContext StmtCtx) {
   // FIXME: We create a bogus CompoundStmt scope to hold the contents of
   // the captured region. Code elsewhere assumes that any FunctionScopeInfo
   // should have at least one compound statement scope within it.
+  ParsingOpenMPDirectiveRAII NormalScope(*this, /*Value=*/false);
   AssociatedStmt = (Sema::CompoundScopeRAII(Actions), ParseStatement());
   AssociatedStmt = Actions.ActOnOpenMPRegionEnd(AssociatedStmt, Clauses);
 } else if (DKind == OMPD_target_update || DKind == OMPD_target_enter_data 
||

diff  --git a/clang/test/OpenMP/declare_reduction_ast_print.cpp 
b/clang/test/OpenMP/declare_reduction_ast_print.cpp
index 8de954efd9e7..b46e1c8da084 100644
--- a/clang/test/OpenMP/declare_reduction_ast_print.cpp
+++ b/clang/test/OpenMP/declare_reduction_ast_print.cpp
@@ -17,7 +17,11 @@ namespace N1
 {
   struct A { int a; A() : a(0) {} };
   #pragma omp declare reduction(+: A : bar(omp_out, omp_in))
-};
+  #pragma omp declare reduction(-: struct A : bar(omp_out, omp_in))
+}
+// CHECK: namespace N1 {
+// CHECK: #pragma omp declare reduction (+ : N1::A : bar(omp_out, omp_in))
+// CHECK: #pragma omp declare reduction (- : struct A : bar(omp_out, omp_in))
 
 #pragma omp declare reduction(+ : int, char : omp_out *= omp_in)
 // CHECK: #pragma omp declare reduction (+ : int : omp_out *= omp_in){{$}}



___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D74166: [AIX][Frontend] Static init implementation for AIX considering no priority

2020-06-18 Thread Jason Liu via Phabricator via cfe-commits
jasonliu accepted this revision.
jasonliu added a comment.
This revision is now accepted and ready to land.

LGTM. But I suggest to wait for @hubert.reinterpretcast to have another scan at 
this before landing.


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

https://reviews.llvm.org/D74166



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


[PATCH] D80301: [yaml][clang-tidy] Fix new line YAML serialization

2020-06-18 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin added a comment.

@njames93 - friendly ping, could you please take another look.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80301



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


[PATCH] D81168: Add support for DeclRefExpr in SyntaxTree, by generating IdExpressions

2020-06-18 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 accepted this revision.
gribozavr2 added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/Tooling/Syntax/Nodes.cpp:182
+  for (auto *C = firstChild(); C; C = C->nextSibling()) {
+if (C->role() == syntax::NodeRole::NestedNameSpecifier_specifier)
+  Children.push_back(llvm::cast(C));

eduucaldas wrote:
> This should be an assert for now, as if that is not true it would be a logic 
> problem. Same reasoning applies to `CompoundStatement`
Yep, feel free to change it to an assert.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81168



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


[PATCH] D81868: [libTooling] Add parser for string representation of `RangeSelector`.

2020-06-18 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 accepted this revision.
gribozavr2 added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/Tooling/Transformer/Parsing.cpp:169
+
+// For consistency with matcher parser and C++ code, node id's are written as
+// strings. However, we do not accept support escaping in the string.

s/matcher/AST matcher/



Comment at: clang/lib/Tooling/Transformer/Parsing.cpp:170
+// For consistency with matcher parser and C++ code, node id's are written as
+// strings. However, we do not accept support escaping in the string.
+static ExpectedProgress parseStringId(ParseState State) {

s/accept//



Comment at: clang/lib/Tooling/Transformer/Parsing.cpp:29
+
+namespace {
+using llvm::Error;

ymandel wrote:
> gribozavr2 wrote:
> > I'm a bit concerned about the abundance of parsers in Clang tooling: we 
> > already have a similar language for dynamic AST matchers. I'm concerned 
> > about both code duplication as such, and that there are multiple ways to do 
> > something.
> > 
> > Code duplication makes it more difficult to carry out horizontal efforts 
> > like improving error reporting.
> > 
> > Multiple ways to do something makes codebase knowledge less reusable. It 
> > might also create language discrepancies that users might notice (for 
> > example, I don't remember if `bind(id)` works in dynamic AST matchers or 
> > not; we would be better off if range selectors were consistent with that).
> > 
> > I don't think this particular change decisively tips the scale towards 
> > refactoring the parser for dynamic AST matchers to be reusable here; 
> > however it is an option worth considering. I think we should be thinking 
> > about the total cost of ownership of this code.
> > 
> > Some future use cases will also need an embeddable language (like AST 
> > matchers for the syntax tree, or parsing stencils from strings).
> Agreed on these points. We'd like to move ahead with this patch, but have 
> made the following changes:
> 1. Added a FIXME in the implementation file indicating intent to merge with 
> AST matcher parser code
> 2. Modified the accepted language for consistency with AST matchers (and C++ 
> code). Node ids must be surrounded by quotes.
> 
> One possible complication is that the stencil format-string parser 
> (forthcoming) will not easily be merged into a lexer-based parser, given that 
> it allows free text for the format string (only the special escape sequences 
> have specified structure). So, we will need to find a way to operate both 
> scannerless and not if we want a unified parser infrastructure. However, we 
> can solve that problem when we come to it.
> We'd like to move ahead with this patch, but have made the following changes

SGTM.

> the stencil format-string parser (forthcoming) will not easily be merged into 
> a lexer-based parser

I'd have to take a closer look to provide a meaningful response, but postponing 
this discussion to the patch that will be adding this code SGTM.



Comment at: clang/unittests/Tooling/RangeSelectorTest.cpp:271
+  ASSERT_THAT_EXPECTED(R, llvm::Succeeded());
+  EXPECT_THAT_EXPECTED(select(*R, Match), HasValue("3;"));
 }

ymandel wrote:
> gribozavr2 wrote:
> > I wonder if we could figure out a more direct testing strategy for a parser 
> > (that does not necessarily involve using the parsed objects) if we had more 
> > advanced parsing infrastructure.
> Indeed. That would certainly be preferable. `Stencil`s support the `toString` 
> operator for just such testing support.  A generic parse tree would also 
> allow direct testing, but then you still need to find a way to test the 
> conversion from parse-tree to stencil. So, ultimately, you want to have some 
> reflection on the type itself.
> 
> I propose that we move `RangeSelector` to implement `MatchComputation` rather 
> than `MatchConsumer` to support `toString` and better tests. WDYT?
> I propose that we move RangeSelector to implement MatchComputation rather 
> than MatchConsumer to support toString and better tests. WDYT?

+1, makes sense. Initially they were separate abstractions because we thought 
we didn't need the complexity everywhere, but turns out we do.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81868



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


[PATCH] D75229: [clang-tidy] Add signal-in-multithreaded-program check

2020-06-18 Thread Kocsis Ábel via Phabricator via cfe-commits
abelkocsis marked an inline comment as done.
abelkocsis added inline comments.



Comment at: clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp:88
 
 // C checkers
 // CON

Eugene.Zelenko wrote:
> Please use //check// here.
Should I replace the `// C++ checkers` comment too? I mean to `// C++ checks` 
instead of `// C++ checkers`?


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D75229



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


[PATCH] D81672: [Driver] When forcing a crash call abort to get the correct diagnostic

2020-06-18 Thread John Brawn via Phabricator via cfe-commits
john.brawn updated this revision to Diff 271757.
john.brawn edited the summary of this revision.
john.brawn added a comment.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.

Moved BugReportMsg printing into CrashRecoveryContext, and stopped printing of 
backtrace when forcing a crash.


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

https://reviews.llvm.org/D81672

Files:
  clang/test/Driver/crash-report-crashfile.m
  clang/test/Driver/crash-report-modules.m
  clang/test/Driver/crash-report-null.test
  clang/tools/driver/driver.cpp
  llvm/include/llvm/Support/CrashRecoveryContext.h
  llvm/include/llvm/Support/PrettyStackTrace.h
  llvm/lib/Support/CrashRecoveryContext.cpp
  llvm/lib/Support/PrettyStackTrace.cpp

Index: llvm/lib/Support/PrettyStackTrace.cpp
===
--- llvm/lib/Support/PrettyStackTrace.cpp
+++ llvm/lib/Support/PrettyStackTrace.cpp
@@ -142,15 +142,9 @@
 static CrashHandlerStringStorage crashHandlerStringStorage;
 #endif
 
-static const char *BugReportMsg =
-"PLEASE submit a bug report to " BUG_REPORT_URL
-" and include the crash backtrace.\n";
-
 /// This callback is run if a fatal signal is delivered to the process, it
 /// prints the pretty stack trace.
 static void CrashHandler(void *) {
-  errs() << BugReportMsg ;
-
 #ifndef __APPLE__
   // On non-apple systems, just emit the crash stack trace to stderr.
   PrintCurStackTrace(errs());
@@ -202,12 +196,6 @@
 
 #endif // ENABLE_BACKTRACES
 
-void llvm::setBugReportMsg(const char *Msg) {
-#if ENABLE_BACKTRACES
-  BugReportMsg = Msg;
-#endif
-}
-
 PrettyStackTraceEntry::PrettyStackTraceEntry() {
 #if ENABLE_BACKTRACES
   // Handle SIGINFO first, because we haven't finished constructing yet.
Index: llvm/lib/Support/CrashRecoveryContext.cpp
===
--- llvm/lib/Support/CrashRecoveryContext.cpp
+++ llvm/lib/Support/CrashRecoveryContext.cpp
@@ -7,11 +7,13 @@
 //===--===//
 
 #include "llvm/Support/CrashRecoveryContext.h"
+#include "llvm/Config/config.h"
 #include "llvm/Config/llvm-config.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/ThreadLocal.h"
+#include "llvm/Support/raw_ostream.h"
 #include 
 #include 
 #if LLVM_ON_UNIX
@@ -27,6 +29,10 @@
 static ManagedStatic<
 sys::ThreadLocal > CurrentContext;
 
+static const char *BugReportMsg =
+"PLEASE submit a bug report to " BUG_REPORT_URL
+" and include the crash backtrace.\n";
+
 struct CrashRecoveryContextImpl {
   // When threads are disabled, this links up all active
   // CrashRecoveryContextImpls.  When threads are enabled there's one thread
@@ -71,6 +77,8 @@
 assert(!Failed && "Crash recovery context already failed!");
 Failed = true;
 
+errs() << BugReportMsg;
+
 if (CRC->DumpStackAndCleanupOnFailure)
   sys::CleanupOnSignal(Context);
 
@@ -86,6 +94,10 @@
 };
 }
 
+void llvm::setBugReportMsg(const char *Msg) {
+  BugReportMsg = Msg;
+}
+
 static ManagedStatic gCrashRecoveryContextMutex;
 static bool gCrashRecoveryEnabled = false;
 
Index: llvm/include/llvm/Support/PrettyStackTrace.h
===
--- llvm/include/llvm/Support/PrettyStackTrace.h
+++ llvm/include/llvm/Support/PrettyStackTrace.h
@@ -37,10 +37,6 @@
   /// \see PrettyStackTraceEntry
   void EnablePrettyStackTraceOnSigInfoForThisThread(bool ShouldEnable = true);
 
-  /// Replaces the generic bug report message that is output upon
-  /// a crash.
-  void setBugReportMsg(const char *Msg);
-
   /// PrettyStackTraceEntry - This class is used to represent a frame of the
   /// "pretty" stack trace that is dumped when a program crashes. You can define
   /// subclasses of this and declare them on the program stack: when they are
Index: llvm/include/llvm/Support/CrashRecoveryContext.h
===
--- llvm/include/llvm/Support/CrashRecoveryContext.h
+++ llvm/include/llvm/Support/CrashRecoveryContext.h
@@ -14,6 +14,10 @@
 namespace llvm {
 class CrashRecoveryContextCleanup;
 
+/// Replaces the generic bug report message that is output upon
+/// a crash.
+void setBugReportMsg(const char *Msg);
+
 /// Crash recovery helper object.
 ///
 /// This class implements support for running operations in a safe context so
Index: clang/tools/driver/driver.cpp
===
--- clang/tools/driver/driver.cpp
+++ clang/tools/driver/driver.cpp
@@ -511,6 +511,10 @@
   for (const auto  : C->getJobs())
 if (const Command *C = dyn_cast())
   FailingCommands.push_back(std::make_pair(-1, C));
+
+  // Crash using abort.
+  llvm::CrashRecoveryContext CRC;
+  CRC.RunSafely([&]() { abort(); });
 }
 

[clang] ce82b8e - [HIP] Improve check patterns to avoid test failures in case string "opt",

2020-06-18 Thread Hiroshi Yamauchi via cfe-commits

Author: Hiroshi Yamauchi
Date: 2020-06-18T10:14:31-07:00
New Revision: ce82b8e8af6d9e95e15624c4fb8af2faac68ff63

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

LOG: [HIP] Improve check patterns to avoid test failures in case string "opt",
etc. happens to be in the InstallDir path in the -### output.

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

Added: 


Modified: 
clang/test/Driver/hip-toolchain-no-rdc.hip

Removed: 




diff  --git a/clang/test/Driver/hip-toolchain-no-rdc.hip 
b/clang/test/Driver/hip-toolchain-no-rdc.hip
index 6bf46a301f99..937da40049e7 100644
--- a/clang/test/Driver/hip-toolchain-no-rdc.hip
+++ b/clang/test/Driver/hip-toolchain-no-rdc.hip
@@ -154,14 +154,14 @@
 // Link host objects.
 //
 
-// LINK-NOT: llvm-link
-// LINK-NOT: opt
-// LINK-NOT: llc
+// LINK-NOT: {{".*/llvm-link"}}
+// LINK-NOT: {{".*/opt"}}
+// LINK-NOT: {{".*/llc"}}
 // LINK: [[LD:".*ld.*"]] {{.*}} [[A_OBJ_HOST]] [[B_OBJ_HOST]]
 // LINK-NOT: "-T" "{{.*}}.lk"
 
-// LKONLY-NOT: llvm-link
-// LKONLY-NOT: opt
-// LKONLY-NOT: llc
+// LKONLY-NOT: {{".*/llvm-link"}}
+// LKONLY-NOT: {{".*/opt"}}
+// LKONLY-NOT: {{".*/llc"}}
 // LKONLY: [[LD:".*ld.*"]] {{.*}} "{{.*/a.o}}" "{{.*/b.o}}"
 // LKONLY-NOT: "-T" "{{.*}}.lk"



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


[clang] 3ce0e92 - [update_cc_test_checks.py] Handle C++ methods

2020-06-18 Thread Alex Richardson via cfe-commits

Author: Alex Richardson
Date: 2020-06-18T18:09:21+01:00
New Revision: 3ce0e92f45f56fc1b93db35dec8c53dceb5c54a5

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

LOG: [update_cc_test_checks.py] Handle C++ methods

Previously the script only handled C input, this change extends the JSON
parsing to to also include C++ function types such as methods, constructors
and destructors.

Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D80914

Added: 
clang/test/utils/update_cc_test_checks/Inputs/basic-cplusplus.cpp
clang/test/utils/update_cc_test_checks/Inputs/basic-cplusplus.cpp.expected
clang/test/utils/update_cc_test_checks/basic-cplusplus.test

Modified: 
llvm/utils/update_cc_test_checks.py

Removed: 




diff  --git a/clang/test/utils/update_cc_test_checks/Inputs/basic-cplusplus.cpp 
b/clang/test/utils/update_cc_test_checks/Inputs/basic-cplusplus.cpp
new file mode 100644
index ..98be350b3937
--- /dev/null
+++ b/clang/test/utils/update_cc_test_checks/Inputs/basic-cplusplus.cpp
@@ -0,0 +1,25 @@
+// Basic C++ test for update_cc_test_checks
+// RUN: %clang_cc1 -triple=x86_64-unknown-linux-gnu -emit-llvm -o - %s | 
FileCheck %s
+
+class Foo {
+  int x;
+
+public:
+  explicit Foo(int x);
+  ~Foo();
+  inline int function_defined_inline(int arg) const {
+return arg + x;
+  }
+  inline int function_defined_out_of_line(int arg) const;
+};
+
+Foo::Foo(int x) : x(x) {}
+Foo::~Foo() {}
+int Foo::function_defined_out_of_line(int arg) const { return x - arg; }
+
+// Call the inline methods to ensure the LLVM IR is generated:
+int main() {
+  Foo f(1);
+  f.function_defined_inline(2);
+  f.function_defined_out_of_line(3);
+}

diff  --git 
a/clang/test/utils/update_cc_test_checks/Inputs/basic-cplusplus.cpp.expected 
b/clang/test/utils/update_cc_test_checks/Inputs/basic-cplusplus.cpp.expected
new file mode 100644
index ..48ee67a7165a
--- /dev/null
+++ b/clang/test/utils/update_cc_test_checks/Inputs/basic-cplusplus.cpp.expected
@@ -0,0 +1,80 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// Basic C++ test for update_cc_test_checks
+// RUN: %clang_cc1 -triple=x86_64-unknown-linux-gnu -emit-llvm -o - %s | 
FileCheck %s
+
+class Foo {
+  int x;
+
+public:
+  explicit Foo(int x);
+  ~Foo();
+// CHECK-LABEL: @_ZNK3Foo23function_defined_inlineEi(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[THIS_ADDR:%.*]] = alloca %class.Foo*, align 8
+// CHECK-NEXT:[[ARG_ADDR:%.*]] = alloca i32, align 4
+// CHECK-NEXT:store %class.Foo* [[THIS:%.*]], %class.Foo** [[THIS_ADDR]], 
align 8
+// CHECK-NEXT:store i32 [[ARG:%.*]], i32* [[ARG_ADDR]], align 4
+// CHECK-NEXT:[[THIS1:%.*]] = load %class.Foo*, %class.Foo** 
[[THIS_ADDR]], align 8
+// CHECK-NEXT:[[TMP0:%.*]] = load i32, i32* [[ARG_ADDR]], align 4
+// CHECK-NEXT:[[X:%.*]] = getelementptr inbounds [[CLASS_FOO:%.*]], 
%class.Foo* [[THIS1]], i32 0, i32 0
+// CHECK-NEXT:[[TMP1:%.*]] = load i32, i32* [[X]], align 4
+// CHECK-NEXT:[[ADD:%.*]] = add nsw i32 [[TMP0]], [[TMP1]]
+// CHECK-NEXT:ret i32 [[ADD]]
+//
+  inline int function_defined_inline(int arg) const {
+return arg + x;
+  }
+  inline int function_defined_out_of_line(int arg) const;
+};
+
+// CHECK-LABEL: @_ZN3FooC1Ei(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[THIS_ADDR:%.*]] = alloca %class.Foo*, align 8
+// CHECK-NEXT:[[X_ADDR:%.*]] = alloca i32, align 4
+// CHECK-NEXT:store %class.Foo* [[THIS:%.*]], %class.Foo** [[THIS_ADDR]], 
align 8
+// CHECK-NEXT:store i32 [[X:%.*]], i32* [[X_ADDR]], align 4
+// CHECK-NEXT:[[THIS1:%.*]] = load %class.Foo*, %class.Foo** 
[[THIS_ADDR]], align 8
+// CHECK-NEXT:[[TMP0:%.*]] = load i32, i32* [[X_ADDR]], align 4
+// CHECK-NEXT:call void @_ZN3FooC2Ei(%class.Foo* [[THIS1]], i32 [[TMP0]])
+// CHECK-NEXT:ret void
+//
+Foo::Foo(int x) : x(x) {}
+// CHECK-LABEL: @_ZN3FooD1Ev(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[THIS_ADDR:%.*]] = alloca %class.Foo*, align 8
+// CHECK-NEXT:store %class.Foo* [[THIS:%.*]], %class.Foo** [[THIS_ADDR]], 
align 8
+// CHECK-NEXT:[[THIS1:%.*]] = load %class.Foo*, %class.Foo** 
[[THIS_ADDR]], align 8
+// CHECK-NEXT:call void @_ZN3FooD2Ev(%class.Foo* [[THIS1]]) #2
+// CHECK-NEXT:ret void
+//
+Foo::~Foo() {}
+// CHECK-LABEL: @_ZNK3Foo28function_defined_out_of_lineEi(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[THIS_ADDR:%.*]] = alloca %class.Foo*, align 8
+// CHECK-NEXT:[[ARG_ADDR:%.*]] = alloca i32, align 4
+// CHECK-NEXT:store %class.Foo* [[THIS:%.*]], %class.Foo** [[THIS_ADDR]], 
align 8
+// CHECK-NEXT:store i32 [[ARG:%.*]], i32* [[ARG_ADDR]], align 4
+// CHECK-NEXT:[[THIS1:%.*]] = load %class.Foo*, %class.Foo** 
[[THIS_ADDR]], align 8
+// CHECK-NEXT:

[clang] ead7a8b - [update_cc_test_checks.py] Correctly skip function definitions

2020-06-18 Thread Alex Richardson via cfe-commits

Author: Alex Richardson
Date: 2020-06-18T18:09:21+01:00
New Revision: ead7a8beccc18c2cbcde980d2f593267d63c5dc2

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

LOG: [update_cc_test_checks.py] Correctly skip function definitions

Function declarations can in fact have an 'inner' node that lists the
ParmVarDecls. It seems like either the JSON output has changed or that I
tested the original JSON parsing change with test files that only have
function definitions without arguments.

Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D80913

Added: 


Modified: 
clang/test/utils/update_cc_test_checks/Inputs/def-and-decl.c
clang/test/utils/update_cc_test_checks/Inputs/def-and-decl.c.expected
llvm/utils/update_cc_test_checks.py

Removed: 




diff  --git a/clang/test/utils/update_cc_test_checks/Inputs/def-and-decl.c 
b/clang/test/utils/update_cc_test_checks/Inputs/def-and-decl.c
index 8e2e4f69fe07..7fc539347e6c 100644
--- a/clang/test/utils/update_cc_test_checks/Inputs/def-and-decl.c
+++ b/clang/test/utils/update_cc_test_checks/Inputs/def-and-decl.c
@@ -1,17 +1,17 @@
 // Check that the CHECK lines are generated before the definition and not the 
declaration
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu %s -emit-llvm -o - | 
FileCheck %s
 
-int foo();
+int foo(int arg);
 
-void empty_function();
+void empty_function(void);
 
 int main() {
   empty_function();
-  return foo();
+  return foo(1);
 }
 
-int foo() {
-  return 1;
+int foo(int arg) {
+  return arg;
 }
 
-void empty_function() {}
+void empty_function(void) {}

diff  --git 
a/clang/test/utils/update_cc_test_checks/Inputs/def-and-decl.c.expected 
b/clang/test/utils/update_cc_test_checks/Inputs/def-and-decl.c.expected
index 07503be84f43..855530abe303 100644
--- a/clang/test/utils/update_cc_test_checks/Inputs/def-and-decl.c.expected
+++ b/clang/test/utils/update_cc_test_checks/Inputs/def-and-decl.c.expected
@@ -2,33 +2,36 @@
 // Check that the CHECK lines are generated before the definition and not the 
declaration
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu %s -emit-llvm -o - | 
FileCheck %s
 
-int foo();
+int foo(int arg);
 
-void empty_function();
+void empty_function(void);
 
 // CHECK-LABEL: @main(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[RETVAL:%.*]] = alloca i32, align 4
 // CHECK-NEXT:store i32 0, i32* [[RETVAL]], align 4
 // CHECK-NEXT:call void @empty_function()
-// CHECK-NEXT:[[CALL:%.*]] = call i32 @foo()
+// CHECK-NEXT:[[CALL:%.*]] = call i32 @foo(i32 1)
 // CHECK-NEXT:ret i32 [[CALL]]
 //
 int main() {
   empty_function();
-  return foo();
+  return foo(1);
 }
 
 // CHECK-LABEL: @foo(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:ret i32 1
+// CHECK-NEXT:[[ARG_ADDR:%.*]] = alloca i32, align 4
+// CHECK-NEXT:store i32 [[ARG:%.*]], i32* [[ARG_ADDR]], align 4
+// CHECK-NEXT:[[TMP0:%.*]] = load i32, i32* [[ARG_ADDR]], align 4
+// CHECK-NEXT:ret i32 [[TMP0]]
 //
-int foo() {
-  return 1;
+int foo(int arg) {
+  return arg;
 }
 
 // CHECK-LABEL: @empty_function(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:ret void
 //
-void empty_function() {}
+void empty_function(void) {}

diff  --git a/llvm/utils/update_cc_test_checks.py 
b/llvm/utils/update_cc_test_checks.py
index 9b236dbd2431..127d3d737576 100755
--- a/llvm/utils/update_cc_test_checks.py
+++ b/llvm/utils/update_cc_test_checks.py
@@ -76,8 +76,18 @@ def parse_clang_ast_json(node):
 if line is None:
   common.debug('Skipping function without line number:', node['name'], 
'@', node['loc'])
   return
-# If there is no 'inner' object, it is a function declaration -> skip
-if 'inner' not in node:
+
+# If there is no 'inner' object, it is a function declaration and we can
+# skip it. However, function declarations may also contain an 'inner' list,
+# but in that case it will only contains ParmVarDecls. If we find an entry
+# that is not a ParmVarDecl, we know that this is a function definition.
+has_body = False
+if 'inner' in node:
+  for i in node['inner']:
+if i.get('kind', 'ParmVarDecl') != 'ParmVarDecl':
+  has_body = True
+  break
+if not has_body:
   common.debug('Skipping function without body:', node['name'], '@', 
node['loc'])
   return
 spell = node['name']



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


[PATCH] D81672: [Driver] When forcing a crash call abort to get the correct diagnostic

2020-06-18 Thread John Brawn via Phabricator via cfe-commits
john.brawn marked an inline comment as done.
john.brawn added inline comments.



Comment at: clang/tools/driver/driver.cpp:518
+  CRC.DumpStackAndCleanupOnFailure = true;
+  CRC.RunSafely([&]() { abort(); });
 }

aganea wrote:
> The only concern I have is that a unrelated call stack will be printed.
> Could you possibly add (and use here) a function along the lines of 
> `emitBugReportMsg() { errs() << BugReportMsg; }`?
I had a go at doing that, but then realised that currently the bug report 
message only exists, and is only printed, when llvm is built with 
LLVM_ENABLE_BACKTRACES=ON which I don't think is what we want. I've instead 
adjusted things so that the bug report message is printed in 
CrashRecoveryContext instead of in the backtrace handler, which also means we 
can get the message without the backtrace here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81672



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


[PATCH] D81304: [llvm][SveEmitter] Emit the bfloat version of `svld1ro`.

2020-06-18 Thread Francesco Petrogalli via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3e59dfc30124: [llvm][SveEmitter] Emit the bfloat version of 
`svld1ro`. (authored by fpetrogalli).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81304

Files:
  clang/include/clang/Basic/AArch64SVEACLETypes.def
  clang/include/clang/Basic/arm_sve.td
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/test/AST/ast-dump-aarch64-sve-types.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1ro-bfloat.c
  clang/unittests/AST/ASTImporterTest.cpp
  clang/unittests/AST/SizelessTypesTest.cpp
  clang/utils/TableGen/SveEmitter.cpp

Index: clang/utils/TableGen/SveEmitter.cpp
===
--- clang/utils/TableGen/SveEmitter.cpp
+++ clang/utils/TableGen/SveEmitter.cpp
@@ -65,7 +65,7 @@
 
 class SVEType {
   TypeSpec TS;
-  bool Float, Signed, Immediate, Void, Constant, Pointer;
+  bool Float, Signed, Immediate, Void, Constant, Pointer, BFloat;
   bool DefaultType, IsScalable, Predicate, PredicatePattern, PrefetchOp;
   unsigned Bitwidth, ElementBitwidth, NumVectors;
 
@@ -74,9 +74,9 @@
 
   SVEType(TypeSpec TS, char CharMod)
   : TS(TS), Float(false), Signed(true), Immediate(false), Void(false),
-Constant(false), Pointer(false), DefaultType(false), IsScalable(true),
-Predicate(false), PredicatePattern(false), PrefetchOp(false),
-Bitwidth(128), ElementBitwidth(~0U), NumVectors(1) {
+Constant(false), Pointer(false), BFloat(false), DefaultType(false),
+IsScalable(true), Predicate(false), PredicatePattern(false),
+PrefetchOp(false), Bitwidth(128), ElementBitwidth(~0U), NumVectors(1) {
 if (!TS.empty())
   applyTypespec();
 applyModifier(CharMod);
@@ -93,9 +93,11 @@
   bool isVoid() const { return Void & !Pointer; }
   bool isDefault() const { return DefaultType; }
   bool isFloat() const { return Float; }
-  bool isInteger() const { return !Float && !Predicate; }
+  bool isBFloat() const { return BFloat; }
+  bool isFloatingPoint() const { return Float || BFloat; }
+  bool isInteger() const { return !isFloatingPoint() && !Predicate; }
   bool isScalarPredicate() const {
-return !Float && Predicate && NumVectors == 0;
+return !isFloatingPoint() && Predicate && NumVectors == 0;
   }
   bool isPredicateVector() const { return Predicate; }
   bool isPredicatePattern() const { return PredicatePattern; }
@@ -362,7 +364,7 @@
 
   if (isVoidPointer())
 S += "v";
-  else if (!Float)
+  else if (!isFloatingPoint())
 switch (ElementBitwidth) {
 case 1: S += "b"; break;
 case 8: S += "c"; break;
@@ -372,15 +374,19 @@
 case 128: S += "LLLi"; break;
 default: llvm_unreachable("Unhandled case!");
 }
-  else
+  else if (isFloat())
 switch (ElementBitwidth) {
 case 16: S += "h"; break;
 case 32: S += "f"; break;
 case 64: S += "d"; break;
 default: llvm_unreachable("Unhandled case!");
 }
+  else if (isBFloat()) {
+assert(ElementBitwidth == 16 && "Not a valid BFloat.");
+S += "y";
+  }
 
-  if (!isFloat()) {
+  if (!isFloatingPoint()) {
 if ((isChar() || isPointer()) && !isVoidPointer()) {
   // Make chars and typed pointers explicitly signed.
   if (Signed)
@@ -421,13 +427,15 @@
   else {
 if (isScalableVector())
   S += "sv";
-if (!Signed && !Float)
+if (!Signed && !isFloatingPoint())
   S += "u";
 
 if (Float)
   S += "float";
 else if (isScalarPredicate() || isPredicateVector())
   S += "bool";
+else if (isBFloat())
+  S += "bfloat";
 else
   S += "int";
 
@@ -481,6 +489,10 @@
   Float = true;
   ElementBitwidth = 64;
   break;
+case 'b':
+  BFloat = true;
+  ElementBitwidth = 16;
+  break;
 default:
   llvm_unreachable("Unhandled type code!");
 }
@@ -534,6 +546,7 @@
   case 'P':
 Signed = true;
 Float = false;
+BFloat = false;
 Predicate = true;
 Bitwidth = 16;
 ElementBitwidth = 1;
@@ -784,7 +797,6 @@
   BaseTypeSpec(BT), Class(Class), Guard(Guard.str()),
   MergeSuffix(MergeSuffix.str()), BaseType(BT, 'd'), Flags(Flags),
   ImmChecks(Checks.begin(), Checks.end()) {
-
   // Types[0] is the return value.
   for (unsigned I = 0; I < Proto.size(); ++I) {
 SVEType T(BaseTypeSpec, Proto[I]);
@@ -848,6 +860,8 @@
   TypeCode = T.isSigned() ? 's' : 'u';
 else if (T.isPredicateVector())
   TypeCode = 'b';
+else if (T.isBFloat())
+  TypeCode = "bf";
 else
   TypeCode = 'f';
 Ret.replace(Pos, NumChars, TypeCode + utostr(T.getElementSizeInBits()));
@@ -923,6 +937,11 @@
 }
   }
 
+  if (T.isBFloat()) {
+assert(T.getElementSizeInBits() == 16 && "Not a valid BFloat.");
+return encodeEltType("EltTyBFloat16");
+ 

[PATCH] D82026: [OPENMP50]Allow nonmonotonic modifier for all schedule kinds.

2020-06-18 Thread Alexey Bataev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4971d0b8ec6e: [OPENMP50]Allow nonmonotonic modifier for all 
schedule kinds. (authored by ABataev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82026

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/for_ast_print.cpp
  clang/test/OpenMP/for_schedule_messages.cpp
  clang/test/OpenMP/schedule_codegen.cpp

Index: clang/test/OpenMP/schedule_codegen.cpp
===
--- clang/test/OpenMP/schedule_codegen.cpp
+++ clang/test/OpenMP/schedule_codegen.cpp
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-unknown-unknown -emit-llvm -fexceptions -fcxx-exceptions -o - %s | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c++ -triple x86_64-unknown-unknown -emit-llvm -fexceptions -fcxx-exceptions -o - %s | FileCheck %s
 
-// RUN: %clang_cc1 -fopenmp-simd -x c++ -triple x86_64-unknown-unknown -emit-llvm -fexceptions -fcxx-exceptions -o - %s | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -x c++ -triple x86_64-unknown-unknown -emit-llvm -fexceptions -fcxx-exceptions -o - %s | FileCheck --check-prefix SIMD-ONLY0 %s
 // SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
 
 int main() {
@@ -134,6 +134,18 @@
 // CHECK: !llvm.access.group
 #pragma omp for simd schedule(nonmonotonic: dynamic)
   for(int i = 0; i < 10; ++i);
+// CHECK: call void @__kmpc_for_static_init_4(%struct.ident_t* {{.+}}, i32 %{{.+}}, i32 1073741858,
+// CHECK: !llvm.access.group
+#pragma omp for simd schedule(nonmonotonic: static)
+  for(int i = 0; i < 10; ++i);
+// CHECK: call void @__kmpc_dispatch_init_4(%struct.ident_t* {{.+}}, i32 %{{.+}}, i32 1073741862,
+// CHECK: !llvm.access.group
+#pragma omp for schedule(nonmonotonic: auto)
+  for(int i = 0; i < 10; ++i);
+// CHECK: call void @__kmpc_dispatch_init_4(%struct.ident_t* {{.+}}, i32 %{{.+}}, i32 1073741861,
+// CHECK: !llvm.access.group
+#pragma omp for simd schedule(nonmonotonic: runtime)
+  for(int i = 0; i < 10; ++i);
 // CHECK: @__kmpc_dispatch_init
 // CHECK-NOT: !llvm.access.group
 // CHECK: @__kmpc_dispatch_next
Index: clang/test/OpenMP/for_schedule_messages.cpp
===
--- clang/test/OpenMP/for_schedule_messages.cpp
+++ clang/test/OpenMP/for_schedule_messages.cpp
@@ -1,6 +1,8 @@
-// RUN: %clang_cc1 -verify -fopenmp %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,omp45 -fopenmp -fopenmp-version=45 %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,omp50 -fopenmp -fopenmp-version=50 %s -Wuninitialized
 
-// RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,omp45 -fopenmp-simd -fopenmp-version=45 %s -Wuninitialized
+// RUN: %clang_cc1 -verify=expected,omp50 -fopenmp-simd -fopenmp-version=50 %s -Wuninitialized
 
 void foo() {
 }
@@ -32,7 +34,7 @@
   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
   #pragma omp for schedule (monotonic, auto // expected-error {{expected ')'}} expected-warning {{missing ':' after schedule modifier - ignoring}} expected-error {{expected 'simd' in OpenMP clause 'schedule'}} expected-note {{to match this '('}}
   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
-  #pragma omp for schedule (nonmonotonic: auto, // expected-error {{expected ')'}} expected-error {{'nonmonotonic' modifier can only be specified with 'dynamic' or 'guided' schedule kind}} expected-note {{to match this '('}}
+  #pragma omp for schedule (nonmonotonic: auto, // expected-error {{expected ')'}} omp45-error {{'nonmonotonic' modifier can only be specified with 'dynamic' or 'guided' schedule kind}} expected-note {{to match this '('}}
   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
   #pragma omp for schedule (auto,  // expected-error {{expected ')'}} expected-note {{to match this '('}}
   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
@@ -61,11 +63,11 @@
   for (int i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
   #pragma omp for schedule (static, N) // expected-error {{argument to 'schedule' clause must be a strictly positive integer value}}
   for (T i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
-  #pragma omp for schedule (nonmonotonic: static) // expected-error {{'nonmonotonic' modifier can only be specified with 'dynamic' or 'guided' schedule kind}}
+  #pragma omp for schedule (nonmonotonic: static) // omp45-error {{'nonmonotonic' modifier can only be specified with 'dynamic' or 'guided' schedule kind}}
   for (T i = ST; i < N; i++) argv[0][i] = argv[0][i] - argv[0][i-ST];
-  #pragma omp for schedule (nonmonotonic: auto) // expected-error {{'nonmonotonic' modifier can only be specified with 'dynamic' or 'guided' schedule 

[PATCH] D74166: [AIX][Frontend] Static init implementation for AIX considering no priority

2020-06-18 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L added inline comments.



Comment at: clang/lib/CodeGen/CGDeclCXX.cpp:345
+// rarely.
+Weights = nullptr;
+  } else if (Kind == GuardKind::VariableGuard && !D->isLocalVarDecl()) {

jasonliu wrote:
> Do we need to change/complicate the interface for this function, just to do a 
> call to Builder.CreateCondBr()?
> Could we call that function directly from where it's needed?
Sure, we can. Thank you for your suggestion. I was hoping to use one function 
to synthesize the guarded init or destruct branch. But I think it seems better 
if we wait for further more usage of guarded destruct branch to do so and not 
complicate stuff in this patch.


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

https://reviews.llvm.org/D74166



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


[PATCH] D81168: Add support for DeclRefExpr in SyntaxTree, by generating IdExpressions

2020-06-18 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas marked 2 inline comments as done.
eduucaldas added inline comments.



Comment at: clang/include/clang/Tooling/Syntax/Nodes.h:190
+return N->kind() == NodeKind::NameSpecifier;
+  }
+};

eduucaldas wrote:
> gribozavr2 wrote:
> > Should there be getters for various parts of the specifier?
> I think not.
Pospone to interface discussion with Yitzhak



Comment at: clang/include/clang/Tooling/Syntax/Nodes.h:214
+return N->kind() == NodeKind::UnqualifiedId;
+  }
+};

gribozavr2 wrote:
> Could you add TODOs about adding accessors?
Pospone to interface discussion with Yitzhak



Comment at: clang/lib/Tooling/Syntax/Nodes.cpp:178
 }
 
+std::vector syntax::NestedNameSpecifier::specifiers() 
{

I was thinking and our problem is bigger than not testing for `NodeRole`s, we 
don't test accessors at all!



Comment at: clang/lib/Tooling/Syntax/Nodes.cpp:182
+  for (auto *C = firstChild(); C; C = C->nextSibling()) {
+if (C->role() == syntax::NodeRole::NestedNameSpecifier_specifier)
+  Children.push_back(llvm::cast(C));

This should be an assert for now, as if that is not true it would be a logic 
problem. Same reasoning applies to `CompoundStatement`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81168



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


[PATCH] D74166: [AIX][Frontend] Static init implementation for AIX considering no priority

2020-06-18 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L updated this revision to Diff 271747.
Xiangling_L marked 3 inline comments as done.
Xiangling_L added a comment.

Removed a redundant header file;
Addressed comments;


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

https://reviews.llvm.org/D74166

Files:
  clang/include/clang/AST/Mangle.h
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/CodeGen/CGCXXABI.h
  clang/lib/CodeGen/CGDeclCXX.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/CodeGen/MicrosoftCXXABI.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/aix-constructor-attribute.cpp
  clang/test/CodeGen/aix-destructor-attribute.cpp
  clang/test/CodeGen/aix-init-priority-attribute.cpp
  clang/test/CodeGen/static-init.cpp
  clang/test/CodeGenCXX/aix-static-init.cpp

Index: clang/test/CodeGenCXX/aix-static-init.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/aix-static-init.cpp
@@ -0,0 +1,193 @@
+// RUN: %clang_cc1 -triple powerpc-ibm-aix-xcoff -S -emit-llvm -x c++ \
+// RUN: -fno-use-cxa-atexit -std=c++2a < %s | \
+// RUN:   FileCheck --check-prefixes=CHECK,CHECK32 %s
+
+// RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -S -emit-llvm -x c++ \
+// RUN: -fno-use-cxa-atexit -std=c++2a < %s | \
+// RUN:   FileCheck --check-prefixes=CHECK,CHECK64 %s
+
+namespace test1 {
+  struct Test1 {
+Test1();
+~Test1();
+  } t1, t2;
+} // namespace test1
+
+namespace test2 {
+  int foo() { return 3; }
+  int x = foo();
+} // namespace test2
+
+namespace test3 {
+  struct Test3 {
+constexpr Test3() {};
+~Test3() {};
+  };
+
+  constinit Test3 t;
+} // namespace test3
+
+namespace test4 {
+  struct Test4 {
+Test4();
+~Test4();
+  };
+
+  void f() {
+static Test4 staticLocal;
+  }
+} // namespace test4
+
+// CHECK: @llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @__sinit8000_clang_1145401da454a7baad10bfe313c46638, i8* null }]
+// CHECK: @llvm.global_dtors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @__sterm8000_clang_1145401da454a7baad10bfe313c46638, i8* null }]
+
+// CHECK: define internal void @__cxx_global_var_init() [[ATTR:#[0-9]+]] {
+// CHECK: entry:
+// CHECK:   call void @_ZN5test15Test1C1Ev(%"struct.test1::Test1"* @_ZN5test12t1E)
+// CHECK:   %0 = call i32 @atexit(void ()* @__dtor__ZN5test12t1E)
+// CHECK:   ret void
+// CHECK: }
+
+// CHECK: define internal void @__dtor__ZN5test12t1E() [[ATTR:#[0-9]+]] {
+// CHECK: entry:
+// CHECK:   call void @_ZN5test15Test1D1Ev(%"struct.test1::Test1"* @_ZN5test12t1E)
+// CHECK:   ret void
+// CHECK: }
+
+// CHECK: declare i32 @atexit(void ()*)
+
+// CHECK: define internal void @__finalize__ZN5test12t1E() [[ATTR:#[0-9]+]] {
+// CHECK: entry:
+// CHECK:   %0 = call i32 @unatexit(void ()* @__dtor__ZN5test12t1E)
+// CHECK:   %needs_destruct = icmp eq i32 %0, 0
+// CHECK:   br i1 %needs_destruct, label %destruct.call, label %destruct.end
+
+// CHECK: destruct.call:
+// CHECK:   call void @__dtor__ZN5test12t1E()
+// CHECK:   br label %destruct.end
+
+// CHECK: destruct.end:
+// CHECK:   ret void
+// CHECK: }
+
+// CHECK: declare i32 @unatexit(void ()*)
+
+// CHECK: define internal void @__cxx_global_var_init.1() [[ATTR:#[0-9]+]] {
+// CHECK: entry:
+// CHECK:   call void @_ZN5test15Test1C1Ev(%"struct.test1::Test1"* @_ZN5test12t2E)
+// CHECK:   %0 = call i32 @atexit(void ()* @__dtor__ZN5test12t2E)
+// CHECK:   ret void
+// CHECK: }
+
+// CHECK: define internal void @__dtor__ZN5test12t2E() [[ATTR:#[0-9]+]] {
+// CHECK: entry:
+// CHECK:   call void @_ZN5test15Test1D1Ev(%"struct.test1::Test1"* @_ZN5test12t2E)
+// CHECK:   ret void
+// CHECK: }
+
+// CHECK: define internal void @__finalize__ZN5test12t2E() [[ATTR:#[0-9]+]] {
+// CHECK: entry:
+// CHECK:   %0 = call i32 @unatexit(void ()* @__dtor__ZN5test12t2E)
+// CHECK:   %needs_destruct = icmp eq i32 %0, 0
+// CHECK:   br i1 %needs_destruct, label %destruct.call, label %destruct.end
+
+// CHECK: destruct.call:
+// CHECK:   call void @__dtor__ZN5test12t2E()
+// CHECK:   br label %destruct.end
+
+// CHECK: destruct.end:
+// CHECK:   ret void
+// CHECK: }
+
+// CHECK: define internal void @__cxx_global_var_init.2() [[ATTR:#[0-9]+]] {
+// CHECK: entry:
+// CHECK32: %call = call i32 @_ZN5test23fooEv()
+// CHECK64: %call = call signext i32 @_ZN5test23fooEv()
+// CHECK:   store i32 %call, i32* @_ZN5test21xE
+// CHECK:   ret void
+// CHECK: }
+
+// CHECK: define internal void @__cxx_global_var_init.3() [[ATTR:#[0-9]+]] {
+// CHECK: entry:
+// CHECK:   %0 = call i32 @atexit(void ()* @__dtor__ZN5test31tE)
+// CHECK:   ret void
+// CHECK: }
+
+// CHECK: define internal void @__dtor__ZN5test31tE() [[ATTR:#[0-9]+]] {
+// CHECK: entry:
+// CHECK:   call void 

  1   2   3   >