[PATCH] D115967: [clang-format][NFC] Handle wrapping after => in mustBreakBefore()

2021-12-19 Thread Owen Pan via Phabricator via cfe-commits
owenpan marked an inline comment as done.
owenpan added inline comments.



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:1641
 case tok::equal:
-  // Fat arrows (=>) have tok::TokenKind tok::equal but TokenType
-  // TT_FatArrow. They always start an expression or a child block if
-  // followed by a curly brace.
   if (FormatTok->is(TT_FatArrow)) {
+tryToParseCSharpLambda();

owenpan wrote:
> HazardyKnusperkeks wrote:
> > Should we add the isCSharp check?
> No. It was not there before, and adding it would fail several JavaScript test 
> cases.
> Should we add the isCSharp check?

Added checking for either JavaScript or C#.


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

https://reviews.llvm.org/D115967

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


[PATCH] D115967: [clang-format][NFC] Handle wrapping after => in mustBreakBefore()

2021-12-19 Thread Owen Pan via Phabricator via cfe-commits
owenpan updated this revision to Diff 395380.
owenpan added a comment.

Additional cleanups:

- Restrict parsing `=>` to JavaScript and C#.
- Rename `tryToParseCSharpLambda` to `tryToParseChildBlock`.
- Remove redundant caret `case`.


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

https://reviews.llvm.org/D115967

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/lib/Format/UnwrappedLineParser.h

Index: clang/lib/Format/UnwrappedLineParser.h
===
--- clang/lib/Format/UnwrappedLineParser.h
+++ clang/lib/Format/UnwrappedLineParser.h
@@ -138,7 +138,7 @@
   // https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/where-generic-type-constraint
   void parseCSharpGenericTypeConstraint();
   bool tryToParseLambda();
-  bool tryToParseCSharpLambda();
+  bool tryToParseChildBlock();
   bool tryToParseLambdaIntroducer();
   bool tryToParsePropertyAccessor();
   void tryToParseJSFunction();
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1638,19 +1638,9 @@
   break;
 }
 case tok::equal:
-  // Fat arrows (=>) have tok::TokenKind tok::equal but TokenType
-  // TT_FatArrow. They always start an expression or a child block if
-  // followed by a curly brace.
-  if (FormatTok->is(TT_FatArrow)) {
-nextToken();
-if (FormatTok->is(tok::l_brace)) {
-  // C# may break after => if the next character is a newline.
-  if (Style.isCSharp() && Style.BraceWrapping.AfterFunction == true) {
-// calling `addUnwrappedLine()` here causes odd parsing errors.
-FormatTok->MustBreakBefore = true;
-  }
-  parseChildBlock();
-}
+  if ((Style.Language == FormatStyle::LK_JavaScript || Style.isCSharp()) &&
+  FormatTok->is(TT_FatArrow)) {
+tryToParseChildBlock();
 break;
   }
 
@@ -1726,7 +1716,7 @@
   // Try to parse the property accessor:
   // https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/properties
   Tokens->setPosition(StoredPosition);
-  if (!IsTrivialPropertyAccessor && Style.BraceWrapping.AfterFunction == true)
+  if (!IsTrivialPropertyAccessor && Style.BraceWrapping.AfterFunction)
 addUnwrappedLine();
   nextToken();
   do {
@@ -1941,18 +1931,15 @@
   return true;
 }
 
-bool UnwrappedLineParser::tryToParseCSharpLambda() {
-  // Fat arrows (=>) have tok::TokenKind tok::equal but TokenType
-  // TT_FatArrow. They always start an expression or a child block if
-  // followed by a curly brace.
+bool UnwrappedLineParser::tryToParseChildBlock() {
+  assert(Style.Language == FormatStyle::LK_JavaScript || Style.isCSharp());
+  assert(FormatTok->is(TT_FatArrow));
+  // Fat arrows (=>) have tok::TokenKind tok::equal but TokenType TT_FatArrow.
+  // They always start an expression or a child block if followed by a curly
+  // brace.
   nextToken();
   if (FormatTok->isNot(tok::l_brace))
 return false;
-  // C# may break after => if the next character is a newline.
-  if (Style.BraceWrapping.AfterFunction) {
-// calling `addUnwrappedLine()` here causes odd parsing errors.
-FormatTok->MustBreakBefore = true;
-  }
   parseChildBlock();
   return true;
 }
@@ -1965,24 +1952,17 @@
   // FIXME: Once we have an expression parser in the UnwrappedLineParser,
   // replace this by using parseAssignmentExpression() inside.
   do {
-if (Style.isCSharp() && FormatTok->is(TT_FatArrow))
-  if (tryToParseCSharpLambda())
-continue;
+if (Style.isCSharp() && FormatTok->is(TT_FatArrow) &&
+tryToParseChildBlock())
+  continue;
 if (Style.Language == FormatStyle::LK_JavaScript) {
   if (FormatTok->is(Keywords.kw_function) ||
   FormatTok->startsSequence(Keywords.kw_async, Keywords.kw_function)) {
 tryToParseJSFunction();
 continue;
   }
-  if (FormatTok->is(TT_FatArrow)) {
-nextToken();
-// Fat arrows can be followed by simple expressions or by child blocks
-// in curly braces.
-if (FormatTok->is(tok::l_brace)) {
-  parseChildBlock();
-  continue;
-}
-  }
+  if (FormatTok->is(TT_FatArrow) && tryToParseChildBlock())
+continue;
   if (FormatTok->is(tok::l_brace)) {
 // Could be a method inside of a braced list `{a() { return 1; }}`.
 if (tryToParseBracedList())
@@ -1997,12 +1977,6 @@
   return !HasError;
 }
 switch (FormatTok->Tok.getKind()) {
-case tok::caret:
-  nextToken();
-  if (FormatTok->is(tok::l_brace)) {
-parseChildBlock();
-  }
-  break;
 case tok::l_square:
   if (Style.isCSharp())
 parseSquare();
@@ -2094,7 +2068,7 @@
   break;
 case 

[PATCH] D115430: [Clang][RISCV] Fix upper bound of RISC-V V type in debug info

2021-12-19 Thread Jianjian Guan via Phabricator via cfe-commits
jacquesguan added a comment.

Sorry, I should use --author="Luhaocong " in my 
git command, and I will pay attention next time to land revision that created 
by other one.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115430

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


[PATCH] D115430: [Clang][RISCV] Fix upper bound of RISC-V V type in debug info

2021-12-19 Thread Jianjian Guan via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9c11e9528683: [Clang][RISCV] Fix upper bound of RISC-V V 
type in debug info (authored by jacquesguan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115430

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGen/RISCV/riscv-v-debuginfo.c


Index: clang/test/CodeGen/RISCV/riscv-v-debuginfo.c
===
--- clang/test/CodeGen/RISCV/riscv-v-debuginfo.c
+++ clang/test/CodeGen/RISCV/riscv-v-debuginfo.c
@@ -9,7 +9,7 @@
 }
 
 // !DISubrange(lowerBound: 0, upperBound: !DIExpression(DW_OP_bregx, 7202, 0, 
DW_OP_con
-// DEBUGINFO: stu, 2, DW_OP_div, DW_OP_constu, 2, DW_OP_mul))
+// DEBUGINFO: stu, 2, DW_OP_div, DW_OP_constu, 2, DW_OP_mul, DW_OP_constu, 1, 
DW_OP_minus))
 
 __rvv_int16mf2_t f2(__rvv_int16mf2_t arg_0, __rvv_int16mf2_t arg_1, int64_t 
arg_2) {
   __rvv_int16mf2_t ret;
@@ -17,7 +17,7 @@
 }
 
 // !DISubrange(lowerBound: 0, upperBound: !DIExpression(DW_OP_bregx, 7202, 0, 
DW_OP_con
-// DEBUGINFO: stu, 2, DW_OP_div, DW_OP_constu, 2, DW_OP_div))
+// DEBUGINFO: stu, 2, DW_OP_div, DW_OP_constu, 2, DW_OP_div, DW_OP_constu, 1, 
DW_OP_minus))
 
 __rvv_int32mf2_t f3(__rvv_int32mf2_t arg_0, __rvv_int32mf2_t arg_1, int64_t 
arg_2) {
   __rvv_int32mf2_t ret;
@@ -25,4 +25,4 @@
 }
 
 // !DISubrange(lowerBound: 0, upperBound: !DIExpression(DW_OP_bregx, 7202, 0, 
DW_OP_con
-// DEBUGINFO: stu, 4, DW_OP_div, DW_OP_constu, 2, DW_OP_div))
+// DEBUGINFO: stu, 4, DW_OP_div, DW_OP_constu, 2, DW_OP_div, DW_OP_constu, 1, 
DW_OP_minus))
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -768,7 +768,7 @@
   }
 
   // Element count = (VLENB / SEW) x LMUL
-  SmallVector Expr(
+  SmallVector Expr(
   // The DW_OP_bregx operation has two operands: a register which is
   // specified by an unsigned LEB128 number, followed by a signed 
LEB128
   // offset.
@@ -782,6 +782,8 @@
 Expr.push_back(llvm::dwarf::DW_OP_div);
   else
 Expr.push_back(llvm::dwarf::DW_OP_mul);
+  // Element max index = count - 1
+  Expr.append({llvm::dwarf::DW_OP_constu, 1, llvm::dwarf::DW_OP_minus});
 
   auto *LowerBound =
   llvm::ConstantAsMetadata::get(llvm::ConstantInt::getSigned(


Index: clang/test/CodeGen/RISCV/riscv-v-debuginfo.c
===
--- clang/test/CodeGen/RISCV/riscv-v-debuginfo.c
+++ clang/test/CodeGen/RISCV/riscv-v-debuginfo.c
@@ -9,7 +9,7 @@
 }
 
 // !DISubrange(lowerBound: 0, upperBound: !DIExpression(DW_OP_bregx, 7202, 0, DW_OP_con
-// DEBUGINFO: stu, 2, DW_OP_div, DW_OP_constu, 2, DW_OP_mul))
+// DEBUGINFO: stu, 2, DW_OP_div, DW_OP_constu, 2, DW_OP_mul, DW_OP_constu, 1, DW_OP_minus))
 
 __rvv_int16mf2_t f2(__rvv_int16mf2_t arg_0, __rvv_int16mf2_t arg_1, int64_t arg_2) {
   __rvv_int16mf2_t ret;
@@ -17,7 +17,7 @@
 }
 
 // !DISubrange(lowerBound: 0, upperBound: !DIExpression(DW_OP_bregx, 7202, 0, DW_OP_con
-// DEBUGINFO: stu, 2, DW_OP_div, DW_OP_constu, 2, DW_OP_div))
+// DEBUGINFO: stu, 2, DW_OP_div, DW_OP_constu, 2, DW_OP_div, DW_OP_constu, 1, DW_OP_minus))
 
 __rvv_int32mf2_t f3(__rvv_int32mf2_t arg_0, __rvv_int32mf2_t arg_1, int64_t arg_2) {
   __rvv_int32mf2_t ret;
@@ -25,4 +25,4 @@
 }
 
 // !DISubrange(lowerBound: 0, upperBound: !DIExpression(DW_OP_bregx, 7202, 0, DW_OP_con
-// DEBUGINFO: stu, 4, DW_OP_div, DW_OP_constu, 2, DW_OP_div))
+// DEBUGINFO: stu, 4, DW_OP_div, DW_OP_constu, 2, DW_OP_div, DW_OP_constu, 1, DW_OP_minus))
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -768,7 +768,7 @@
   }
 
   // Element count = (VLENB / SEW) x LMUL
-  SmallVector Expr(
+  SmallVector Expr(
   // The DW_OP_bregx operation has two operands: a register which is
   // specified by an unsigned LEB128 number, followed by a signed LEB128
   // offset.
@@ -782,6 +782,8 @@
 Expr.push_back(llvm::dwarf::DW_OP_div);
   else
 Expr.push_back(llvm::dwarf::DW_OP_mul);
+  // Element max index = count - 1
+  Expr.append({llvm::dwarf::DW_OP_constu, 1, llvm::dwarf::DW_OP_minus});
 
   auto *LowerBound =
   llvm::ConstantAsMetadata::get(llvm::ConstantInt::getSigned(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 9c11e95 - [Clang][RISCV] Fix upper bound of RISC-V V type in debug info

2021-12-19 Thread via cfe-commits

Author: jacquesguan
Date: 2021-12-20T14:25:06+08:00
New Revision: 9c11e952868342dfbf0efedd246dac6191ee98d7

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

LOG: [Clang][RISCV] Fix upper bound of RISC-V V type in debug info

The UpperBound of RVV type in debug info should be elements count minus one,
as the LowerBound start from zero.

Reviewed By: HsiangKai

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

Added: 


Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp
clang/test/CodeGen/RISCV/riscv-v-debuginfo.c

Removed: 




diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 0de089b448093..89ec9f1b7e8fd 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -768,7 +768,7 @@ llvm::DIType *CGDebugInfo::CreateType(const BuiltinType 
*BT) {
   }
 
   // Element count = (VLENB / SEW) x LMUL
-  SmallVector Expr(
+  SmallVector Expr(
   // The DW_OP_bregx operation has two operands: a register which is
   // specified by an unsigned LEB128 number, followed by a signed 
LEB128
   // offset.
@@ -782,6 +782,8 @@ llvm::DIType *CGDebugInfo::CreateType(const BuiltinType 
*BT) {
 Expr.push_back(llvm::dwarf::DW_OP_div);
   else
 Expr.push_back(llvm::dwarf::DW_OP_mul);
+  // Element max index = count - 1
+  Expr.append({llvm::dwarf::DW_OP_constu, 1, llvm::dwarf::DW_OP_minus});
 
   auto *LowerBound =
   llvm::ConstantAsMetadata::get(llvm::ConstantInt::getSigned(

diff  --git a/clang/test/CodeGen/RISCV/riscv-v-debuginfo.c 
b/clang/test/CodeGen/RISCV/riscv-v-debuginfo.c
index b5ed0c56848b1..f0e405aa79c66 100644
--- a/clang/test/CodeGen/RISCV/riscv-v-debuginfo.c
+++ b/clang/test/CodeGen/RISCV/riscv-v-debuginfo.c
@@ -9,7 +9,7 @@ __rvv_int16m2_t f1(__rvv_int16m2_t arg_0, __rvv_int16m2_t 
arg_1, int64_t arg_2)
 }
 
 // !DISubrange(lowerBound: 0, upperBound: !DIExpression(DW_OP_bregx, 7202, 0, 
DW_OP_con
-// DEBUGINFO: stu, 2, DW_OP_div, DW_OP_constu, 2, DW_OP_mul))
+// DEBUGINFO: stu, 2, DW_OP_div, DW_OP_constu, 2, DW_OP_mul, DW_OP_constu, 1, 
DW_OP_minus))
 
 __rvv_int16mf2_t f2(__rvv_int16mf2_t arg_0, __rvv_int16mf2_t arg_1, int64_t 
arg_2) {
   __rvv_int16mf2_t ret;
@@ -17,7 +17,7 @@ __rvv_int16mf2_t f2(__rvv_int16mf2_t arg_0, __rvv_int16mf2_t 
arg_1, int64_t arg_
 }
 
 // !DISubrange(lowerBound: 0, upperBound: !DIExpression(DW_OP_bregx, 7202, 0, 
DW_OP_con
-// DEBUGINFO: stu, 2, DW_OP_div, DW_OP_constu, 2, DW_OP_div))
+// DEBUGINFO: stu, 2, DW_OP_div, DW_OP_constu, 2, DW_OP_div, DW_OP_constu, 1, 
DW_OP_minus))
 
 __rvv_int32mf2_t f3(__rvv_int32mf2_t arg_0, __rvv_int32mf2_t arg_1, int64_t 
arg_2) {
   __rvv_int32mf2_t ret;
@@ -25,4 +25,4 @@ __rvv_int32mf2_t f3(__rvv_int32mf2_t arg_0, __rvv_int32mf2_t 
arg_1, int64_t arg_
 }
 
 // !DISubrange(lowerBound: 0, upperBound: !DIExpression(DW_OP_bregx, 7202, 0, 
DW_OP_con
-// DEBUGINFO: stu, 4, DW_OP_div, DW_OP_constu, 2, DW_OP_div))
+// DEBUGINFO: stu, 4, DW_OP_div, DW_OP_constu, 2, DW_OP_div, DW_OP_constu, 1, 
DW_OP_minus))



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


[PATCH] D115990: AlignConsecutiveDeclarations not working for 'const' keyword in JavsScript

2021-12-19 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments.



Comment at: clang/lib/Format/TokenAnnotator.cpp:1839
+PreviousNotConst = PreviousNotConst->getPreviousNonComment();
+}
 

Remove braces.



Comment at: clang/lib/Format/TokenAnnotator.cpp:1875
+// const a = in JavaScript.
+if (Style.isJavaScript() && PreviousNotConst->is(tok::kw_const))
+  return true;

curdeius wrote:
> Nit.
+1


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

https://reviews.llvm.org/D115990

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


[PATCH] D116016: [Clang] [PowerPC] Emit module flag for current float abi

2021-12-19 Thread Qiu Chaofan via Phabricator via cfe-commits
qiucf added a comment.

In D116016#3202148 , @MaskRay wrote:

>> This is part of the efforts adding .gnu_attribute support for PowerPC. In 
>> Clang, an extra metadata field will be added as float-abi to show current 
>> long double format. So backend can emit .gnu_attribute section data from 
>> this metadata.
>
> How does .gnu_attribute work with the metadata?

Planned way to do is check the module flag in ASM printer, like

  if (flt == "doubledouble")
OutStreamer->emitGNUAttribute(4, 5);
  else if (flt == "ieeequad")
OutStreamer->emitGNUAttribute(4, 13);
  else if (flt == "ieeedouble")
OutStreamer->emitGNUAttribute(4, 9);

Currently this doesn't look like the most elegant way, and doesn't fully match 
behavior of GCC. (In GCC, if no floating operations exist, the attributes won't 
be generated) But since the floating abi option applies to the whole module, 
adding them to module flags are more reasonable than function attributes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116016

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


[PATCH] D116016: [Clang] [PowerPC] Emit module flag for current float abi

2021-12-19 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

> This is part of the efforts adding .gnu_attribute support for PowerPC. In 
> Clang, an extra metadata field will be added as float-abi to show current 
> long double format. So backend can emit .gnu_attribute section data from this 
> metadata.

How does .gnu_attribute work with the metadata?




Comment at: clang/test/CodeGen/ppc64-float-abi-attr.c:9
+
+// CHECK: !{{[0-9]+}} = !{i32 1, !"float-abi", !"doubledouble"}
+// IEEE: !{{[0-9]+}} = !{i32 1, !"float-abi", !"ieeequad"}

`![[#]]`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116016

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


[PATCH] D116016: [Clang] [PowerPC] Emit module flag for current float abi

2021-12-19 Thread Qiu Chaofan via Phabricator via cfe-commits
qiucf created this revision.
qiucf added reviewers: nemanjai, jsji, shchenz, PowerPC, uweigand, MaskRay.
Herald added subscribers: steven.zhang, kbarton.
qiucf requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

This is part of the efforts adding `.gnu_attribute` support for PowerPC. In 
Clang, an extra metadata field will be added as `float-abi` to show current 
`long double` format. So backend can emit `.gnu_attribute` section data from 
this metadata.

Note: This patch will break 50+ more LIT tests in `clang/test/OpenMP`. They're 
all trivial changes since only the referenced metadata numbers are changed. 
They're not included in this review since it's quite large so that browser 
cannot load them easily.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116016

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/ppc64-float-abi-attr.c


Index: clang/test/CodeGen/ppc64-float-abi-attr.c
===
--- /dev/null
+++ clang/test/CodeGen/ppc64-float-abi-attr.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple powerpc64le-unknown-linux-gnu %s -emit-llvm -o - | 
FileCheck %s
+// RUN: %clang_cc1 -triple powerpc64le-unknown-linux-gnu %s -emit-llvm 
-mabi=ieeelongdouble -o - | FileCheck %s --check-prefix=IEEE
+// RUN: %clang_cc1 -triple powerpc64le-unknown-linux-gnu %s -emit-llvm 
-mlong-double-64 -o - | FileCheck %s --check-prefix=LDBL64
+
+long double foo(long double a, long double b) {
+  return a + b;
+}
+
+// CHECK: !{{[0-9]+}} = !{i32 1, !"float-abi", !"doubledouble"}
+// IEEE: !{{[0-9]+}} = !{i32 1, !"float-abi", !"ieeequad"}
+// LDBL64: !{{[0-9]+}} = !{i32 1, !"float-abi", !"ieeedouble"}
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -5030,6 +5030,10 @@
 
   bool initDwarfEHRegSizeTable(CodeGen::CodeGenFunction ,
llvm::Value *Address) const override;
+
+  void emitTargetMetadata(CodeGen::CodeGenModule ,
+  const llvm::MapVector
+  ) const override;
 };
 
 class PPC64TargetCodeGenInfo : public DefaultTargetCodeGenInfo {
@@ -5443,6 +5447,22 @@
  /*IsAIX*/ false);
 }
 
+void PPC64_SVR4_TargetCodeGenInfo::emitTargetMetadata(
+CodeGen::CodeGenModule ,
+const llvm::MapVector ) const {
+  llvm::LLVMContext  = CGM.getLLVMContext();
+  const auto *flt = ().getLongDoubleFormat();
+  if (flt == ::APFloat::PPCDoubleDouble())
+CGM.getModule().addModuleFlag(llvm::Module::Error, "float-abi",
+  llvm::MDString::get(Ctx, "doubledouble"));
+  else if (flt == ::APFloat::IEEEquad())
+CGM.getModule().addModuleFlag(llvm::Module::Error, "float-abi",
+  llvm::MDString::get(Ctx, "ieeequad"));
+  else if (flt == ::APFloat::IEEEdouble())
+CGM.getModule().addModuleFlag(llvm::Module::Error, "float-abi",
+  llvm::MDString::get(Ctx, "ieeedouble"));
+}
+
 bool
 PPC64TargetCodeGenInfo::initDwarfEHRegSizeTable(CodeGen::CodeGenFunction ,
 llvm::Value *Address) const {


Index: clang/test/CodeGen/ppc64-float-abi-attr.c
===
--- /dev/null
+++ clang/test/CodeGen/ppc64-float-abi-attr.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple powerpc64le-unknown-linux-gnu %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -triple powerpc64le-unknown-linux-gnu %s -emit-llvm -mabi=ieeelongdouble -o - | FileCheck %s --check-prefix=IEEE
+// RUN: %clang_cc1 -triple powerpc64le-unknown-linux-gnu %s -emit-llvm -mlong-double-64 -o - | FileCheck %s --check-prefix=LDBL64
+
+long double foo(long double a, long double b) {
+  return a + b;
+}
+
+// CHECK: !{{[0-9]+}} = !{i32 1, !"float-abi", !"doubledouble"}
+// IEEE: !{{[0-9]+}} = !{i32 1, !"float-abi", !"ieeequad"}
+// LDBL64: !{{[0-9]+}} = !{i32 1, !"float-abi", !"ieeedouble"}
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -5030,6 +5030,10 @@
 
   bool initDwarfEHRegSizeTable(CodeGen::CodeGenFunction ,
llvm::Value *Address) const override;
+
+  void emitTargetMetadata(CodeGen::CodeGenModule ,
+  const llvm::MapVector
+  ) const override;
 };
 
 class PPC64TargetCodeGenInfo : public DefaultTargetCodeGenInfo {
@@ -5443,6 +5447,22 @@
  /*IsAIX*/ false);
 }
 
+void PPC64_SVR4_TargetCodeGenInfo::emitTargetMetadata(
+CodeGen::CodeGenModule ,
+const llvm::MapVector ) const {
+  llvm::LLVMContext  = 

[PATCH] D116015: [PowerPC] Add generic fnmsub intrinsic

2021-12-19 Thread Qiu Chaofan via Phabricator via cfe-commits
qiucf created this revision.
qiucf added reviewers: rzurob, jsji, nemanjai, shchenz, PowerPC.
Herald added subscribers: kbarton, hiraditya.
qiucf requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Currently in Clang, we have various builtins for `fnmsub` operation:

- `__builtin_vsx_xvnmsubasp`/`__builtin_vsx_xvnmsubadp` for float/double 
vector, they'll be transformed into `-fma(a, b, -c)` in LLVM IR
- `__builtin_ppc_fnmsubs`/`__builtin_ppc_fnmsub` for float/double scalar, 
they'll generate corresponding intrinsic in IR

But for the vector version of builtin, the 3 op chain may be recognized as 
expensive by some passes (like early cse). We need some way to keep the fnmsub 
form until code generation.

This new intrinsics, `llvm.ppc.nmsub.*`, can replace previous 
`llvm.ppc.fnmsub(s)` intrinsic. But now we've not enabled VSX FMA mutation 
pass, and `int_ppc_fnmsub(s)` generates M-form, we can replace them after 
fixing the pass.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116015

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-ppc-fma.c
  clang/test/CodeGen/builtins-ppc-fpconstrained.c
  clang/test/CodeGen/builtins-ppc-vsx.c
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-math.ll

Index: llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-math.ll
===
--- llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-math.ll
+++ llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-math.ll
@@ -142,6 +142,105 @@
 
 declare float @llvm.ppc.fnmsubs(float, float, float)
 
+define dso_local float @nmsub_f32(float %f, float %f2, float %f3) {
+; CHECK-PWR8-LABEL: nmsub_f32:
+; CHECK-PWR8:   # %bb.0: # %entry
+; CHECK-PWR8-NEXT:xsnmsubasp 3, 1, 2
+; CHECK-PWR8-NEXT:fmr 1, 3
+; CHECK-PWR8-NEXT:blr
+;
+; CHECK-NOVSX-LABEL: nmsub_f32:
+; CHECK-NOVSX:   # %bb.0: # %entry
+; CHECK-NOVSX-NEXT:fnmsubs 1, 1, 2, 3
+; CHECK-NOVSX-NEXT:blr
+;
+; CHECK-PWR7-LABEL: nmsub_f32:
+; CHECK-PWR7:   # %bb.0: # %entry
+; CHECK-PWR7-NEXT:fnmsubs 1, 1, 2, 3
+; CHECK-PWR7-NEXT:blr
+entry:
+  %0 = tail call float @llvm.ppc.nmsub.f32(float %f, float %f2, float %f3)
+  ret float %0
+}
+
+declare float @llvm.ppc.nmsub.f32(float, float, float)
+
+define dso_local double @nmsub_f64(double %f, double %f2, double %f3) {
+; CHECK-PWR8-LABEL: nmsub_f64:
+; CHECK-PWR8:   # %bb.0: # %entry
+; CHECK-PWR8-NEXT:xsnmsubadp 3, 1, 2
+; CHECK-PWR8-NEXT:fmr 1, 3
+; CHECK-PWR8-NEXT:blr
+;
+; CHECK-NOVSX-LABEL: nmsub_f64:
+; CHECK-NOVSX:   # %bb.0: # %entry
+; CHECK-NOVSX-NEXT:fnmsub 1, 1, 2, 3
+; CHECK-NOVSX-NEXT:blr
+;
+; CHECK-PWR7-LABEL: nmsub_f64:
+; CHECK-PWR7:   # %bb.0: # %entry
+; CHECK-PWR7-NEXT:xsnmsubadp 3, 1, 2
+; CHECK-PWR7-NEXT:fmr 1, 3
+; CHECK-PWR7-NEXT:blr
+entry:
+  %0 = tail call double @llvm.ppc.nmsub.f64(double %f, double %f2, double %f3)
+  ret double %0
+}
+
+declare double @llvm.ppc.nmsub.f64(double, double, double)
+
+define dso_local <4 x float> @nmsub_v4f32(<4 x float> %f, <4 x float> %f2, <4 x float> %f3) {
+; CHECK-PWR8-LABEL: nmsub_v4f32:
+; CHECK-PWR8:   # %bb.0: # %entry
+; CHECK-PWR8-NEXT:xvnmsubasp 36, 34, 35
+; CHECK-PWR8-NEXT:vmr 2, 4
+; CHECK-PWR8-NEXT:blr
+;
+; CHECK-NOVSX-LABEL: nmsub_v4f32:
+; CHECK-NOVSX:   # %bb.0: # %entry
+; CHECK-NOVSX-NEXT:fnmsubs 1, 1, 5, 9
+; CHECK-NOVSX-NEXT:fnmsubs 2, 2, 6, 10
+; CHECK-NOVSX-NEXT:fnmsubs 3, 3, 7, 11
+; CHECK-NOVSX-NEXT:fnmsubs 4, 4, 8, 12
+; CHECK-NOVSX-NEXT:blr
+;
+; CHECK-PWR7-LABEL: nmsub_v4f32:
+; CHECK-PWR7:   # %bb.0: # %entry
+; CHECK-PWR7-NEXT:xvnmsubasp 36, 34, 35
+; CHECK-PWR7-NEXT:vmr 2, 4
+; CHECK-PWR7-NEXT:blr
+entry:
+  %0 = tail call <4 x float> @llvm.ppc.nmsub.v4f32(<4 x float> %f, <4 x float> %f2, <4 x float> %f3)
+  ret <4 x float> %0
+}
+
+declare <4 x float> @llvm.ppc.nmsub.v4f32(<4 x float>, <4 x float>, <4 x float>)
+
+define dso_local <2 x double> @nmsub_v2f64(<2 x double> %f, <2 x double> %f2, <2 x double> %f3) {
+; CHECK-PWR8-LABEL: nmsub_v2f64:
+; CHECK-PWR8:   # %bb.0: # %entry
+; CHECK-PWR8-NEXT:xvnmsubadp 36, 34, 35
+; CHECK-PWR8-NEXT:vmr 2, 4
+; CHECK-PWR8-NEXT:blr
+;
+; CHECK-NOVSX-LABEL: nmsub_v2f64:
+; CHECK-NOVSX:   # %bb.0: # %entry
+; CHECK-NOVSX-NEXT:fnmsub 1, 1, 3, 5
+; CHECK-NOVSX-NEXT:fnmsub 2, 2, 4, 6
+; CHECK-NOVSX-NEXT:blr
+;
+; CHECK-PWR7-LABEL: nmsub_v2f64:
+; CHECK-PWR7:   # %bb.0: # %entry
+; CHECK-PWR7-NEXT:xvnmsubadp 36, 34, 35
+; CHECK-PWR7-NEXT:vmr 2, 4
+; CHECK-PWR7-NEXT:blr
+entry:
+  %0 = tail call <2 x double> @llvm.ppc.nmsub.v2f64(<2 x double> %f, <2 x double> %f2, <2 x double> %f3)
+  ret <2 x double> %0
+}
+
+declare <2 x double> @llvm.ppc.nmsub.v2f64(<2 x double>, <2 x double>, <2 x 

[PATCH] D115430: [Clang][RISCV] Fix upper bound of RISC-V V type in debug info

2021-12-19 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai accepted this revision.
HsiangKai added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115430

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


[PATCH] D116014: Remove the signed version of createExpression

2021-12-19 Thread Shao-Ce SUN via Phabricator via cfe-commits
achieveartificialintelligence created this revision.
achieveartificialintelligence added a reviewer: dexonsmith.
Herald added a reviewer: deadalnix.
Herald added a subscriber: hiraditya.
achieveartificialintelligence requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Fix a TODO. Remove the callers of this signed version and delete.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116014

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  llvm/bindings/ocaml/debuginfo/debuginfo_ocaml.c
  llvm/include/llvm-c/DebugInfo.h
  llvm/include/llvm/IR/DIBuilder.h
  llvm/lib/IR/DIBuilder.cpp
  llvm/lib/IR/DebugInfo.cpp

Index: llvm/lib/IR/DebugInfo.cpp
===
--- llvm/lib/IR/DebugInfo.cpp
+++ llvm/lib/IR/DebugInfo.cpp
@@ -1436,14 +1436,14 @@
 }
 
 LLVMMetadataRef LLVMDIBuilderCreateExpression(LLVMDIBuilderRef Builder,
-  int64_t *Addr, size_t Length) {
-  return wrap(unwrap(Builder)->createExpression(ArrayRef(Addr,
-  Length)));
+  uint64_t *Addr, size_t Length) {
+  return wrap(
+  unwrap(Builder)->createExpression(ArrayRef(Addr, Length)));
 }
 
 LLVMMetadataRef
 LLVMDIBuilderCreateConstantValueExpression(LLVMDIBuilderRef Builder,
-   int64_t Value) {
+   uint64_t Value) {
   return wrap(unwrap(Builder)->createConstantValueExpression(Value));
 }
 
Index: llvm/lib/IR/DIBuilder.cpp
===
--- llvm/lib/IR/DIBuilder.cpp
+++ llvm/lib/IR/DIBuilder.cpp
@@ -821,12 +821,6 @@
   return DIExpression::get(VMContext, Addr);
 }
 
-DIExpression *DIBuilder::createExpression(ArrayRef Signed) {
-  // TODO: Remove the callers of this signed version and delete.
-  SmallVector Addr(Signed.begin(), Signed.end());
-  return createExpression(Addr);
-}
-
 template 
 static DISubprogram *getSubprogram(bool IsDistinct, Ts &&...Args) {
   if (IsDistinct)
Index: llvm/include/llvm/IR/DIBuilder.h
===
--- llvm/include/llvm/IR/DIBuilder.h
+++ llvm/include/llvm/IR/DIBuilder.h
@@ -698,7 +698,6 @@
 /// variable which has a complex address expression for its address.
 /// \param AddrAn array of complex address operations.
 DIExpression *createExpression(ArrayRef Addr = None);
-DIExpression *createExpression(ArrayRef Addr);
 
 /// Create an expression for a variable that does not have an address, but
 /// does have a constant value.
Index: llvm/include/llvm-c/DebugInfo.h
===
--- llvm/include/llvm-c/DebugInfo.h
+++ llvm/include/llvm-c/DebugInfo.h
@@ -1102,7 +1102,7 @@
  * \param Length  Length of the address operation array.
  */
 LLVMMetadataRef LLVMDIBuilderCreateExpression(LLVMDIBuilderRef Builder,
-  int64_t *Addr, size_t Length);
+  uint64_t *Addr, size_t Length);
 
 /**
  * Create a new descriptor for the specified variable that does not have an
@@ -1112,7 +1112,7 @@
  */
 LLVMMetadataRef
 LLVMDIBuilderCreateConstantValueExpression(LLVMDIBuilderRef Builder,
-   int64_t Value);
+   uint64_t Value);
 
 /**
  * Create a new descriptor for the specified variable.
Index: llvm/bindings/ocaml/debuginfo/debuginfo_ocaml.c
===
--- llvm/bindings/ocaml/debuginfo/debuginfo_ocaml.c
+++ llvm/bindings/ocaml/debuginfo/debuginfo_ocaml.c
@@ -865,7 +865,7 @@
 LLVMMetadataRef llvm_dibuild_create_constant_value_expression(value Builder,
   value Value) {
   return LLVMDIBuilderCreateConstantValueExpression(DIBuilder_val(Builder),
-(int64_t)Int_val(Value));
+(uint64_t)Int_val(Value));
 }
 
 LLVMMetadataRef llvm_dibuild_create_global_variable_expression_native(
Index: clang/lib/CodeGen/CGDebugInfo.h
===
--- clang/lib/CodeGen/CGDebugInfo.h
+++ clang/lib/CodeGen/CGDebugInfo.h
@@ -363,7 +363,7 @@
   /// Extended dereferencing mechanism is has the following format:
   /// DW_OP_constu  DW_OP_swap DW_OP_xderef
   void AppendAddressSpaceXDeref(unsigned AddressSpace,
-SmallVectorImpl ) const;
+SmallVectorImpl ) const;
 
   /// A helper function to collect debug info for the default elements of a
   /// block.
Index: 

[PATCH] D112534: [PoC][RISCV] Use an attribute to declare C intrinsics with different policy.

2021-12-19 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai updated this revision to Diff 395365.
HsiangKai added a comment.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.

In riscv-insert-vsetvli, use the policy argument. No use implicit-def maskedoff 
to adjust the setting.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112534

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/riscv_vector.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/RISCV/rvv-intrinsics/vadd-policy.c
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/utils/TableGen/RISCVVEmitter.cpp
  llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp

Index: llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
===
--- llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
+++ llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
@@ -401,49 +401,18 @@
 INITIALIZE_PASS(RISCVInsertVSETVLI, DEBUG_TYPE, RISCV_INSERT_VSETVLI_NAME,
 false, false)
 
-static MachineInstr *elideCopies(MachineInstr *MI,
- const MachineRegisterInfo *MRI) {
-  while (true) {
-if (!MI->isFullCopy())
-  return MI;
-if (!Register::isVirtualRegister(MI->getOperand(1).getReg()))
-  return nullptr;
-MI = MRI->getVRegDef(MI->getOperand(1).getReg());
-if (!MI)
-  return nullptr;
-  }
-}
-
 static VSETVLIInfo computeInfoForInstr(const MachineInstr , uint64_t TSFlags,
const MachineRegisterInfo *MRI) {
   VSETVLIInfo InstrInfo;
   unsigned NumOperands = MI.getNumExplicitOperands();
   bool HasPolicy = RISCVII::hasVecPolicyOp(TSFlags);
-
-  // Default to tail agnostic unless the destination is tied to a source.
-  // Unless the source is undef. In that case the user would have some control
-  // over the tail values. Some pseudo instructions force a tail agnostic policy
-  // despite having a tied def.
-  bool ForceTailAgnostic = RISCVII::doesForceTailAgnostic(TSFlags);
   bool TailAgnostic = true;
+  bool MaskAgnostic = false;
   // If the instruction has policy argument, use the argument.
   if (HasPolicy) {
 const MachineOperand  = MI.getOperand(MI.getNumExplicitOperands() - 1);
 TailAgnostic = Op.getImm() & 0x1;
-  }
-
-  unsigned UseOpIdx;
-  if (!(ForceTailAgnostic || (HasPolicy && TailAgnostic)) &&
-  MI.isRegTiedToUseOperand(0, )) {
-TailAgnostic = false;
-// If the tied operand is an IMPLICIT_DEF we can keep TailAgnostic.
-const MachineOperand  = MI.getOperand(UseOpIdx);
-MachineInstr *UseMI = MRI->getVRegDef(UseMO.getReg());
-if (UseMI) {
-  UseMI = elideCopies(UseMI, MRI);
-  if (UseMI && UseMI->isImplicitDef())
-TailAgnostic = true;
-}
+MaskAgnostic = Op.getImm() & 0x2;
   }
 
   // Remove the tail policy so we can find the SEW and VL.
@@ -476,8 +445,8 @@
 }
   } else
 InstrInfo.setAVLReg(RISCV::NoRegister);
-  InstrInfo.setVTYPE(VLMul, SEW, /*TailAgnostic*/ TailAgnostic,
- /*MaskAgnostic*/ false, MaskRegOp, StoreOp);
+  InstrInfo.setVTYPE(VLMul, SEW, TailAgnostic, MaskAgnostic, MaskRegOp,
+ StoreOp);
 
   return InstrInfo;
 }
Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -204,6 +204,10 @@
   // Emit the macros for mapping C/C++ intrinsic function to builtin functions.
   void emitIntrinsicFuncDef(raw_ostream ) const;
 
+  // Emit the declarations for mapping C/C++ intrinsic function to builtin
+  // functions.
+  void emitIntrinsicWithPolicyFuncDef(raw_ostream ) const;
+
   // Emit the mangled function definition.
   void emitMangledFuncDef(raw_ostream ) const;
 };
@@ -835,9 +839,10 @@
   if (isMask()) {
 if (hasVL()) {
   OS << "  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);\n";
-  if (hasPolicy())
-OS << "  Ops.push_back(ConstantInt::get(Ops.back()->getType(),"
-   " TAIL_UNDISTURBED));\n";
+  if (hasPolicy()) {
+OS << "  Ops.push_back(ConstantInt::get(Ops.back()->getType(), "
+  "PolicyValue));\n";
+  }
 } else {
   OS << "  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end());\n";
 }
@@ -865,12 +870,32 @@
   OS << "__builtin_rvv_" << getBuiltinName() << ")))\n";
   OS << OutputType->getTypeStr() << " " << getName() << "(";
   // Emit function arguments
-  if (!InputTypes.empty()) {
+  ListSeparator LS;
+  for (unsigned i = 0; i < InputTypes.size(); ++i)
+OS << LS << InputTypes[i]->getTypeStr();
+  OS << ");\n";
+}
+
+void RVVIntrinsic::emitIntrinsicWithPolicyFuncDef(raw_ostream ) const {
+  if (!isMask())
+return;
+
+  static const char *const PolicySuffix[] = {"tumu", 

[PATCH] D115790: [Coroutines] Set presplit attribute in Clang

2021-12-19 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

In D115790#3199905 , @ezhulenev wrote:

> There are two places where in MLIR you can put an attribute to coroutine 
> functions:
>
> 1. 
> https://github.com/llvm/llvm-project/blob/main/mlir/lib/Dialect/Async/Transforms/AsyncToAsyncRuntime.cpp#L126
>
> This is the point when coroutine functions are created, and you can attach 
> attribute to the `func` argument
>
> 2. 
> https://github.com/llvm/llvm-project/blob/main/mlir/lib/Conversion/AsyncToLLVM/AsyncToLLVM.cpp#L325
>
> Another options is to attach attribute to the `op->getParentOfType` 
> when async runtime operations lowered to `coro.id` intrinsic.
>
> /cc @mehdi_amini to chime in what option is better. I'm not sure though what 
> type of MLIR attribute will be translated to LLVM `"coroutine.presplit"="0"`, 
> `UnitAttr`? Or it must be `IntegerAttr`.
>
> I'm on vacation with limjted access to computer until the end of the year, I 
> can take a look at it myself ~late Dec or early Jan.

Hi, thanks for looking into this. In this func, 
https://github.com/llvm/llvm-project/blob/main/mlir/lib/Dialect/Async/Transforms/AsyncToAsyncRuntime.cpp#L126,
 I tried to write:

  func.setAttr("coroutine.presplit", "0");

But it shows that we could only set the attribute for argument and result type 
instead of the function itself. How could we make it?


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

https://reviews.llvm.org/D115790

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


[PATCH] D115430: [Clang][RISCV] Fix upper bound of RISC-V V type in debug info

2021-12-19 Thread Haocong Lu via Phabricator via cfe-commits
Luhaocong added a comment.

ping. Hi everyone, can you please help me review?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115430

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


[PATCH] D115998: [Clang] Add helper text to fopenmp_version_EQ to make it show in help menu

2021-12-19 Thread Shilei Tian via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0060060fef5d: [Clang] Add helper text to fopenmp_version_EQ 
to make it show in help menu (authored by tianshilei1992).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115998

Files:
  clang/include/clang/Driver/Options.td


Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2395,7 +2395,8 @@
 def fopenmp : Flag<["-"], "fopenmp">, Group, Flags<[CC1Option, 
NoArgumentUnused, FlangOption, FC1Option]>,
   HelpText<"Parse OpenMP pragmas and generate parallel code.">;
 def fno_openmp : Flag<["-"], "fno-openmp">, Group, 
Flags<[NoArgumentUnused]>;
-def fopenmp_version_EQ : Joined<["-"], "fopenmp-version=">, Group, 
Flags<[CC1Option, NoArgumentUnused]>;
+def fopenmp_version_EQ : Joined<["-"], "fopenmp-version=">, Group, 
Flags<[CC1Option, NoArgumentUnused]>,
+  HelpText<"Set OpenMP version (e.g. 45 for OpenMP 4.5, 50 for OpenMP 5.0). 
Default value is 50.">;
 defm openmp_extensions: BoolFOption<"openmp-extensions",
   LangOpts<"OpenMPExtensions">, DefaultTrue,
   PosFlagIndex: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2395,7 +2395,8 @@
 def fopenmp : Flag<["-"], "fopenmp">, Group, Flags<[CC1Option, NoArgumentUnused, FlangOption, FC1Option]>,
   HelpText<"Parse OpenMP pragmas and generate parallel code.">;
 def fno_openmp : Flag<["-"], "fno-openmp">, Group, Flags<[NoArgumentUnused]>;
-def fopenmp_version_EQ : Joined<["-"], "fopenmp-version=">, Group, Flags<[CC1Option, NoArgumentUnused]>;
+def fopenmp_version_EQ : Joined<["-"], "fopenmp-version=">, Group, Flags<[CC1Option, NoArgumentUnused]>,
+  HelpText<"Set OpenMP version (e.g. 45 for OpenMP 4.5, 50 for OpenMP 5.0). Default value is 50.">;
 defm openmp_extensions: BoolFOption<"openmp-extensions",
   LangOpts<"OpenMPExtensions">, DefaultTrue,
   PosFlag___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 0060060 - [Clang] Add helper text to fopenmp_version_EQ to make it show in help menu

2021-12-19 Thread Shilei Tian via cfe-commits

Author: Shilei Tian
Date: 2021-12-19T22:07:24-05:00
New Revision: 0060060fef5da582799a706b6ba8c6ec9fcda2a2

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

LOG: [Clang] Add helper text to fopenmp_version_EQ to make it show in help menu

For now if we check `clang --help`, it doesn't show `-fopenmp-version`. This 
option
should be visible to users. In addition, it is not set to hidden in
`clang/include/clang/Driver/Options.td` as well. The reason it doesn't show is
there is no corresponding helper text. This patch simply adds it.

Reviewed By: jdoerfert

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 980b563ea023e..964ab15129642 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2395,7 +2395,8 @@ def fomit_frame_pointer : Flag<["-"], 
"fomit-frame-pointer">, Group;
 def fopenmp : Flag<["-"], "fopenmp">, Group, Flags<[CC1Option, 
NoArgumentUnused, FlangOption, FC1Option]>,
   HelpText<"Parse OpenMP pragmas and generate parallel code.">;
 def fno_openmp : Flag<["-"], "fno-openmp">, Group, 
Flags<[NoArgumentUnused]>;
-def fopenmp_version_EQ : Joined<["-"], "fopenmp-version=">, Group, 
Flags<[CC1Option, NoArgumentUnused]>;
+def fopenmp_version_EQ : Joined<["-"], "fopenmp-version=">, Group, 
Flags<[CC1Option, NoArgumentUnused]>,
+  HelpText<"Set OpenMP version (e.g. 45 for OpenMP 4.5, 50 for OpenMP 5.0). 
Default value is 50.">;
 defm openmp_extensions: BoolFOption<"openmp-extensions",
   LangOpts<"OpenMPExtensions">, DefaultTrue,
   PosFlaghttps://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D115503: [DebugInfo][Clang] record the access flag for class/struct/union types.

2021-12-19 Thread Esme Yi via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG18f087c21cdb: [DebugInfo][Clang] record the access flag for 
class/struct/union types. (authored by Esme).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115503

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/debug-info-access.cpp


Index: clang/test/CodeGenCXX/debug-info-access.cpp
===
--- clang/test/CodeGenCXX/debug-info-access.cpp
+++ clang/test/CodeGenCXX/debug-info-access.cpp
@@ -25,6 +25,43 @@
   void priv_default();
 };
 
+class C {
+public:
+  // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "D",{{.*}} 
flags: DIFlagPublic | DIFlagTypePassByValue,
+  struct D {
+  };
+protected:
+  // CHECK: !DICompositeType(tag: DW_TAG_union_type, name: "E",{{.*}} flags: 
DIFlagProtected | DIFlagTypePassByValue,
+  union E {
+  };
+private:
+  // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "J",{{.*}} 
flags: DIFlagTypePassByValue,
+  struct J {
+  };
+public:
+  D d;
+  E e;
+  J j;
+};
+
+struct F {
+private:
+  // CHECK: !DICompositeType(tag: DW_TAG_union_type, name: "G",{{.*}} flags: 
DIFlagPrivate | DIFlagTypePassByValue,
+  union G {
+  };
+public:
+  G g;
+};
+
+union H {
+private:
+  // CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "I",{{.*}} flags: 
DIFlagPrivate | DIFlagTypePassByValue,
+  class I {
+  };
+public:
+  I i;
+};
+
 union U {
   // CHECK-DAG: !DISubprogram(name: "union_pub_default",{{.*}} line: 
[[@LINE+1]],{{.*}} flags: DIFlagPrototyped,
   void union_pub_default();
@@ -33,7 +70,6 @@
   int union_priv;
 };
 
-
 // CHECK: !DISubprogram(name: "free",
 // CHECK-SAME:  flags: DIFlagPrototyped,
 // CHECK-SAME:  spFlags: DISPFlagDefinition
@@ -42,3 +78,6 @@
 U u;
 A a;
 B b;
+C c;
+F f;
+H h;
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -3633,6 +3633,9 @@
 // Record exports it symbols to the containing structure.
 if (CXXRD->isAnonymousStructOrUnion())
 Flags |= llvm::DINode::FlagExportSymbols;
+
+Flags |= getAccessFlag(CXXRD->getAccess(),
+   dyn_cast(CXXRD->getDeclContext()));
   }
 
   llvm::DINodeArray Annotations = CollectBTFDeclTagAnnotations(D);


Index: clang/test/CodeGenCXX/debug-info-access.cpp
===
--- clang/test/CodeGenCXX/debug-info-access.cpp
+++ clang/test/CodeGenCXX/debug-info-access.cpp
@@ -25,6 +25,43 @@
   void priv_default();
 };
 
+class C {
+public:
+  // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "D",{{.*}} flags: DIFlagPublic | DIFlagTypePassByValue,
+  struct D {
+  };
+protected:
+  // CHECK: !DICompositeType(tag: DW_TAG_union_type, name: "E",{{.*}} flags: DIFlagProtected | DIFlagTypePassByValue,
+  union E {
+  };
+private:
+  // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "J",{{.*}} flags: DIFlagTypePassByValue,
+  struct J {
+  };
+public:
+  D d;
+  E e;
+  J j;
+};
+
+struct F {
+private:
+  // CHECK: !DICompositeType(tag: DW_TAG_union_type, name: "G",{{.*}} flags: DIFlagPrivate | DIFlagTypePassByValue,
+  union G {
+  };
+public:
+  G g;
+};
+
+union H {
+private:
+  // CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "I",{{.*}} flags: DIFlagPrivate | DIFlagTypePassByValue,
+  class I {
+  };
+public:
+  I i;
+};
+
 union U {
   // CHECK-DAG: !DISubprogram(name: "union_pub_default",{{.*}} line: [[@LINE+1]],{{.*}} flags: DIFlagPrototyped,
   void union_pub_default();
@@ -33,7 +70,6 @@
   int union_priv;
 };
 
-
 // CHECK: !DISubprogram(name: "free",
 // CHECK-SAME:  flags: DIFlagPrototyped,
 // CHECK-SAME:  spFlags: DISPFlagDefinition
@@ -42,3 +78,6 @@
 U u;
 A a;
 B b;
+C c;
+F f;
+H h;
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -3633,6 +3633,9 @@
 // Record exports it symbols to the containing structure.
 if (CXXRD->isAnonymousStructOrUnion())
 Flags |= llvm::DINode::FlagExportSymbols;
+
+Flags |= getAccessFlag(CXXRD->getAccess(),
+   dyn_cast(CXXRD->getDeclContext()));
   }
 
   llvm::DINodeArray Annotations = CollectBTFDeclTagAnnotations(D);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 18f087c - [DebugInfo][Clang] record the access flag for class/struct/union types.

2021-12-19 Thread via cfe-commits

Author: Esme-Yi
Date: 2021-12-20T02:40:42Z
New Revision: 18f087c21cdb08fec77adff47a528a5a335807d9

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

LOG: [DebugInfo][Clang] record the access flag for class/struct/union types.

Summary: This patch records the access flag for
class/struct/union types in the clang part.

The summary of binary size change and debug info size change due to the 
DW_AT_accessibility attribute are as the following table. They are built with 
flags of `clang -O0 -g` (no -gz).

| section | before | after | change | % |
| .debug_loc | 929821 | 929821 |0|0|
|.debug_abbrev | 5885289 | 5971547 |+86258|+1.466%|
|.debug_info | 497613455 | 498122074 |+508619|+0.102%|
|.debug_ranges | 45731664 | 45731664 |0|0|
|.debug_str | 233842595 | 233839388 |-3207| -0.001%|
|.debug_line | 149773166 | 149764583 |-8583|-0.006%|
|total (debug) |933775990 |934359077|+583087 |+0.062%|

|total (binary) |1394617288 | 1395200024| +582736|+0.042%|

Reviewed By: dblaikie, shchenz

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

Added: 


Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp
clang/test/CodeGenCXX/debug-info-access.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 7f48b27183085..0de089b448093 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -3633,6 +3633,9 @@ llvm::DICompositeType 
*CGDebugInfo::CreateLimitedType(const RecordType *Ty) {
 // Record exports it symbols to the containing structure.
 if (CXXRD->isAnonymousStructOrUnion())
 Flags |= llvm::DINode::FlagExportSymbols;
+
+Flags |= getAccessFlag(CXXRD->getAccess(),
+   dyn_cast(CXXRD->getDeclContext()));
   }
 
   llvm::DINodeArray Annotations = CollectBTFDeclTagAnnotations(D);

diff  --git a/clang/test/CodeGenCXX/debug-info-access.cpp 
b/clang/test/CodeGenCXX/debug-info-access.cpp
index 0759ee1d13bd8..cd5328be0a85c 100644
--- a/clang/test/CodeGenCXX/debug-info-access.cpp
+++ b/clang/test/CodeGenCXX/debug-info-access.cpp
@@ -25,6 +25,43 @@ class B : public A {
   void priv_default();
 };
 
+class C {
+public:
+  // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "D",{{.*}} 
flags: DIFlagPublic | DIFlagTypePassByValue,
+  struct D {
+  };
+protected:
+  // CHECK: !DICompositeType(tag: DW_TAG_union_type, name: "E",{{.*}} flags: 
DIFlagProtected | DIFlagTypePassByValue,
+  union E {
+  };
+private:
+  // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "J",{{.*}} 
flags: DIFlagTypePassByValue,
+  struct J {
+  };
+public:
+  D d;
+  E e;
+  J j;
+};
+
+struct F {
+private:
+  // CHECK: !DICompositeType(tag: DW_TAG_union_type, name: "G",{{.*}} flags: 
DIFlagPrivate | DIFlagTypePassByValue,
+  union G {
+  };
+public:
+  G g;
+};
+
+union H {
+private:
+  // CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "I",{{.*}} flags: 
DIFlagPrivate | DIFlagTypePassByValue,
+  class I {
+  };
+public:
+  I i;
+};
+
 union U {
   // CHECK-DAG: !DISubprogram(name: "union_pub_default",{{.*}} line: 
[[@LINE+1]],{{.*}} flags: DIFlagPrototyped,
   void union_pub_default();
@@ -33,7 +70,6 @@ union U {
   int union_priv;
 };
 
-
 // CHECK: !DISubprogram(name: "free",
 // CHECK-SAME:  flags: DIFlagPrototyped,
 // CHECK-SAME:  spFlags: DISPFlagDefinition
@@ -42,3 +78,6 @@ void free() {}
 U u;
 A a;
 B b;
+C c;
+F f;
+H h;



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


[PATCH] D115709: [RISCV] Remove Zvamo Extention

2021-12-19 Thread Shao-Ce SUN via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG68bc6d7cae6d: [RISCV] Remove Zvamo Extention (authored by 
achieveartificialintelligence).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115709

Files:
  clang/test/Driver/riscv-arch.c
  clang/test/Preprocessor/riscv-target-features.c
  llvm/include/llvm/IR/IntrinsicsRISCV.td
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/RISCV.td
  llvm/lib/Target/RISCV/RISCVInstrFormatsV.td
  llvm/lib/Target/RISCV/RISCVInstrInfoV.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
  llvm/lib/Target/RISCV/RISCVSchedRocket.td
  llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
  llvm/lib/Target/RISCV/RISCVSubtarget.h
  llvm/test/CodeGen/RISCV/attributes.ll
  llvm/test/CodeGen/RISCV/rvv/vamoadd-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vamoadd-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vamoand-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vamoand-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vamomax-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vamomax-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vamomaxu-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vamomaxu-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vamomin-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vamomin-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vamominu-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vamominu-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vamoor-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vamoor-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vamoswap-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vamoswap-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vamoxor-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vamoxor-rv64.ll
  llvm/test/MC/RISCV/attribute-arch-invalid.s
  llvm/test/MC/RISCV/attribute-arch.s
  llvm/test/MC/RISCV/rvv/zvamo.s

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


[PATCH] D115709: [RISCV] Remove Zvamo Extention

2021-12-19 Thread ShihPo Hung via Phabricator via cfe-commits
arcbbb accepted this revision.
arcbbb added a comment.
This revision is now accepted and ready to land.

LGTM too. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115709

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


[PATCH] D115709: [RISCV] Remove Zvamo Extention

2021-12-19 Thread Shao-Ce SUN via Phabricator via cfe-commits
achieveartificialintelligence added a comment.

In D115709#3200212 , @craig.topper 
wrote:

> LGTM

Should I land it now?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115709

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


[PATCH] D116011: [Clang] Own the CommandLineArgs in CodeGenOptions

2021-12-19 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea created this revision.
aganea added reviewers: hans, aheejin, jansvoboda11.
Herald added a subscriber: dexonsmith.
aganea requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

As reported in PR52704: https://github.com/llvm/llvm-project/issues/52704

Since the round-tripping generates function-local arguments, before this patch 
accessing `CodeGenOptions.CommandLineArgs` or `MCTargetOptions.CommandLineArgs` 
used to keep references on free'd data.

+@hans for the `CC1Command` change which otherwise blocks the usage 
`append_range`. This was unconsistent with how `CommandLineArgs` were passed 
around in other places (without the terminating `nullptr` element).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116011

Files:
  clang/include/clang/Basic/CodeGenOptions.h
  clang/lib/Driver/Job.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  llvm/include/llvm/MC/MCTargetOptions.h


Index: llvm/include/llvm/MC/MCTargetOptions.h
===
--- llvm/include/llvm/MC/MCTargetOptions.h
+++ llvm/include/llvm/MC/MCTargetOptions.h
@@ -64,7 +64,7 @@
   std::string SplitDwarfFile;
 
   const char *Argv0 = nullptr;
-  ArrayRef CommandLineArgs;
+  ArrayRef CommandLineArgs;
 
   /// Additional paths to search for `.include` directives when using the
   /// integrated assembler.
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -4520,7 +4520,7 @@
 
   // Store the command-line for using in the CodeView backend.
   Res.getCodeGenOpts().Argv0 = Argv0;
-  Res.getCodeGenOpts().CommandLineArgs = CommandLineArgs;
+  append_range(Res.getCodeGenOpts().CommandLineArgs, CommandLineArgs);
 
   FixupInvocation(Res, Diags, Args, DashX);
 
Index: clang/lib/Driver/Job.cpp
===
--- clang/lib/Driver/Job.cpp
+++ clang/lib/Driver/Job.cpp
@@ -387,7 +387,6 @@
   SmallVector Argv;
   Argv.push_back(getExecutable());
   Argv.append(getArguments().begin(), getArguments().end());
-  Argv.push_back(nullptr);
 
   // This flag simply indicates that the program couldn't start, which isn't
   // applicable here.
Index: clang/include/clang/Basic/CodeGenOptions.h
===
--- clang/include/clang/Basic/CodeGenOptions.h
+++ clang/include/clang/Basic/CodeGenOptions.h
@@ -395,7 +395,7 @@
   /// Executable and command-line used to create a given CompilerInvocation.
   /// Most of the time this will be the full -cc1 command.
   const char *Argv0 = nullptr;
-  ArrayRef CommandLineArgs;
+  std::vector CommandLineArgs;
 
   /// The minimum hotness value a diagnostic needs in order to be included in
   /// optimization diagnostics.


Index: llvm/include/llvm/MC/MCTargetOptions.h
===
--- llvm/include/llvm/MC/MCTargetOptions.h
+++ llvm/include/llvm/MC/MCTargetOptions.h
@@ -64,7 +64,7 @@
   std::string SplitDwarfFile;
 
   const char *Argv0 = nullptr;
-  ArrayRef CommandLineArgs;
+  ArrayRef CommandLineArgs;
 
   /// Additional paths to search for `.include` directives when using the
   /// integrated assembler.
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -4520,7 +4520,7 @@
 
   // Store the command-line for using in the CodeView backend.
   Res.getCodeGenOpts().Argv0 = Argv0;
-  Res.getCodeGenOpts().CommandLineArgs = CommandLineArgs;
+  append_range(Res.getCodeGenOpts().CommandLineArgs, CommandLineArgs);
 
   FixupInvocation(Res, Diags, Args, DashX);
 
Index: clang/lib/Driver/Job.cpp
===
--- clang/lib/Driver/Job.cpp
+++ clang/lib/Driver/Job.cpp
@@ -387,7 +387,6 @@
   SmallVector Argv;
   Argv.push_back(getExecutable());
   Argv.append(getArguments().begin(), getArguments().end());
-  Argv.push_back(nullptr);
 
   // This flag simply indicates that the program couldn't start, which isn't
   // applicable here.
Index: clang/include/clang/Basic/CodeGenOptions.h
===
--- clang/include/clang/Basic/CodeGenOptions.h
+++ clang/include/clang/Basic/CodeGenOptions.h
@@ -395,7 +395,7 @@
   /// Executable and command-line used to create a given CompilerInvocation.
   /// Most of the time this will be the full -cc1 command.
   const char *Argv0 = nullptr;
-  ArrayRef CommandLineArgs;
+  std::vector CommandLineArgs;
 
   /// The minimum hotness value a diagnostic needs in order to be included in
   /// optimization diagnostics.
___
cfe-commits mailing list

[PATCH] D116008: [clang-format] Fix wrong indentation of namespace identifiers after a concept declaration.

2021-12-19 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116008

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


[PATCH] D116008: [clang-format] Fix wrong indentation of namespace identifiers after a concept declaration.

2021-12-19 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius updated this revision to Diff 395355.
curdeius added a comment.

Undo unrelated changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116008

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -3548,6 +3548,14 @@
"} // namespace in\n"
"} // namespace out",
Style));
+
+  Style.NamespaceIndentation = FormatStyle::NI_None;
+  verifyFormat("template \n"
+   "concept a_concept = X<>;\n"
+   "namespace B {\n"
+   "struct b_struct {};\n"
+   "} // namespace B\n",
+   Style);
 }
 
 TEST_F(FormatTest, NamespaceMacros) {
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1438,7 +1438,7 @@
   break;
 case tok::kw_concept:
   parseConcept();
-  break;
+  return;
 case tok::kw_requires:
   parseRequires();
   break;


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -3548,6 +3548,14 @@
"} // namespace in\n"
"} // namespace out",
Style));
+
+  Style.NamespaceIndentation = FormatStyle::NI_None;
+  verifyFormat("template \n"
+   "concept a_concept = X<>;\n"
+   "namespace B {\n"
+   "struct b_struct {};\n"
+   "} // namespace B\n",
+   Style);
 }
 
 TEST_F(FormatTest, NamespaceMacros) {
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1438,7 +1438,7 @@
   break;
 case tok::kw_concept:
   parseConcept();
-  break;
+  return;
 case tok::kw_requires:
   parseRequires();
   break;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D116008: [clang-format] Fix wrong indentation of namespace identifiers after a concept declaration.

2021-12-19 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius created this revision.
curdeius added reviewers: MyDeveloperDay, HazardyKnusperkeks, owenpan.
curdeius requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Before this patch, the code:

  template 
  concept a_concept = X<>;
  namespace B {
  struct b_struct {};
  } // namespace B

with config:

  NamespaceIndentation: None

was wrongly indented inside namespace B, giving:

  template 
  concept a_concept = X<>;
  namespace B {
struct b_struct {};
  } // namespace B

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116008

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

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -3548,6 +3548,14 @@
"} // namespace in\n"
"} // namespace out",
Style));
+
+  Style.NamespaceIndentation = FormatStyle::NI_None;
+  verifyFormat("template \n"
+   "concept a_concept = X<>;\n"
+   "namespace B {\n"
+   "struct b_struct {};\n"
+   "} // namespace B\n",
+   Style);
 }
 
 TEST_F(FormatTest, NamespaceMacros) {
@@ -19430,15 +19438,13 @@
 TEST_F(FormatTest, CountsUTF8CharactersProperly) {
   verifyFormat("\"Однажды в студёную зимнюю пору...\"",
getLLVMStyleWithColumns(35));
-  verifyFormat("\"一 二 三 四 五 六 七 八 九 十\"",
-   getLLVMStyleWithColumns(31));
+  verifyFormat("\"一 二 三 四 五 六 七 八 九 十\"", getLLVMStyleWithColumns(31));
   verifyFormat("// Однажды в студёную зимнюю пору...",
getLLVMStyleWithColumns(36));
   verifyFormat("// 一 二 三 四 五 六 七 八 九 十", getLLVMStyleWithColumns(32));
   verifyFormat("/* Однажды в студёную зимнюю пору... */",
getLLVMStyleWithColumns(39));
-  verifyFormat("/* 一 二 三 四 五 六 七 八 九 十 */",
-   getLLVMStyleWithColumns(35));
+  verifyFormat("/* 一 二 三 四 五 六 七 八 九 十 */", getLLVMStyleWithColumns(35));
 }
 
 TEST_F(FormatTest, SplitsUTF8Strings) {
@@ -19458,21 +19464,20 @@
 "\"пору,\"",
 format("\"Однажды, в студёную зимнюю пору,\"",
getLLVMStyleWithColumns(13)));
+  EXPECT_EQ("\"一 二 三 \"\n"
+"\"四 五六 \"\n"
+"\"七 八 九 \"\n"
+"\"十\"",
+format("\"一 二 三 四 五六 七 八 九 十\"", getLLVMStyleWithColumns(11)));
   EXPECT_EQ(
-  "\"一 二 三 \"\n"
-  "\"四 五六 \"\n"
-  "\"七 八 九 \"\n"
-  "\"十\"",
-  format("\"一 二 三 四 五六 七 八 九 十\"", getLLVMStyleWithColumns(11)));
-  EXPECT_EQ("\"一\t\"\n"
-"\"二 \t\"\n"
-"\"三 四 \"\n"
-"\"五\t\"\n"
-"\"六 \t\"\n"
-"\"七 \"\n"
-"\"八九十\tqq\"",
-format("\"一\t二 \t三 四 五\t六 \t七 八九十\tqq\"",
-   getLLVMStyleWithColumns(11)));
+  "\"一\t\"\n"
+  "\"二 \t\"\n"
+  "\"三 四 \"\n"
+  "\"五\t\"\n"
+  "\"六 \t\"\n"
+  "\"七 \"\n"
+  "\"八九十\tqq\"",
+  format("\"一\t二 \t三 四 五\t六 \t七 八九十\tqq\"", getLLVMStyleWithColumns(11)));
 
   // UTF8 character in an escape sequence.
   EXPECT_EQ("\"aa\"\n"
@@ -19517,16 +19522,16 @@
 format("/* Гляжу, поднимается медленно в гору\n"
" * Лошадка, везущая хворосту воз. */",
getLLVMStyleWithColumns(13)));
-  EXPECT_EQ(
-  "/* 一二三\n"
-  " * 四五六七\n"
-  " * 八  九\n"
-  " * 十  */",
-  format("/* 一二三 四五六七 八  九 十  */", getLLVMStyleWithColumns(9)));
+  EXPECT_EQ("/* 一二三\n"
+" * 四五六七\n"
+" * 八  九\n"
+" * 十  */",
+format("/* 一二三 四五六七 八  九 十  */", getLLVMStyleWithColumns(9)));
   EXPECT_EQ("/* 𝓣𝓮𝓼𝓽 𝔣𝔬𝔲𝔯\n"
 " * 𝕓𝕪𝕥𝕖\n"
 " * 𝖀𝕿𝕱-𝟠 */",
-format("/* 𝓣𝓮𝓼𝓽 𝔣𝔬𝔲𝔯 𝕓𝕪𝕥𝕖 𝖀𝕿𝕱-𝟠 */", getLLVMStyleWithColumns(12)));
+format("/* 𝓣𝓮𝓼𝓽 𝔣𝔬𝔲𝔯 𝕓𝕪𝕥𝕖 𝖀𝕿𝕱-𝟠 */",
+   getLLVMStyleWithColumns(12)));
 }
 
 #endif // _MSC_VER
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ 

[PATCH] D116007: [clang-format] Fix BreakBeforeBraces: Attach ignored with trailing requires-expression of function.

2021-12-19 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius created this revision.
curdeius added reviewers: MyDeveloperDay, HazardyKnusperkeks, owenpan.
curdeius requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116007

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

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -16914,6 +16914,49 @@
Style);
 }
 
+TEST_F(FormatTest, AttachBraceBreaking) {
+  FormatStyle BraceStyle = getLLVMStyle();
+  BraceStyle.BreakBeforeBraces = FormatStyle::BS_Attach;
+  verifyFormat("namespace a {\n"
+   "class A {\n"
+   "  void f() {\n"
+   "if (true) {\n"
+   "  a();\n"
+   "  b();\n"
+   "} else {\n"
+   "  a();\n"
+   "}\n"
+   "  }\n"
+   "  void g() { return; }\n"
+   "};\n"
+   "struct B {\n"
+   "  int x;\n"
+   "};\n"
+   "} // namespace a\n",
+   BraceStyle);
+  verifyFormat("enum X {\n"
+   "  Y = 0,\n"
+   "}\n",
+   BraceStyle);
+  verifyFormat("struct S {\n"
+   "  int Type;\n"
+   "  union {\n"
+   "int x;\n"
+   "double y;\n"
+   "  } Value;\n"
+   "  class C {\n"
+   "MyFavoriteType Value;\n"
+   "  } Class;\n"
+   "}\n",
+   BraceStyle);
+  // https://llvm.org/PR48968
+  verifyFormat("void f() requires requires { a; } {\n"
+   "  a();\n"
+   "  b();\n"
+   "}\n",
+   BraceStyle);
+}
+
 TEST_F(FormatTest, LinuxBraceBreaking) {
   FormatStyle LinuxBraceStyle = getLLVMStyle();
   LinuxBraceStyle.BreakBeforeBraces = FormatStyle::BS_Linux;
@@ -17348,6 +17391,13 @@
"  }\n"
"}\n",
BreakBeforeBraceShortIfs);
+  // https://llvm.org/PR48968
+  verifyFormat("void f() requires requires { a; }\n"
+   "{\n"
+   "  a();\n"
+   "  b();\n"
+   "}\n",
+   BreakBeforeBraceShortIfs);
 }
 
 TEST_F(FormatTest, WhitesmithsBraceBreaking) {
@@ -22483,6 +22533,15 @@
"}",
Style);
 
+  // https://llvm.org/PR48968
+  verifyFormat("void f() requires requires {\n"
+   "  a;\n"
+   "} {\n"
+   "  a();\n"
+   "  b();\n"
+   "}\n",
+   Style);
+
   verifyFormat(
   "template  int g(T i) requires Concept1 && Concept2 {\n"
   "  //...\n"
Index: clang/lib/Format/UnwrappedLineParser.h
===
--- clang/lib/Format/UnwrappedLineParser.h
+++ clang/lib/Format/UnwrappedLineParser.h
@@ -117,8 +117,10 @@
   bool parseStructLike();
   void parseConcept();
   void parseRequires();
-  void parseRequiresExpression(unsigned int OriginalLevel);
-  void parseConstraintExpression(unsigned int OriginalLevel);
+  void parseRequiresExpression(unsigned int OriginalLevel,
+   bool InTrailingRequire = false);
+  void parseConstraintExpression(unsigned int OriginalLevel,
+ bool InTrailingRequire = false);
   void parseJavaEnumBody();
   // Parses a record (aka class) as a top level element. If ParseAsExpr is true,
   // parses the record as a child block, i.e. if the class declaration is an
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -2547,7 +2547,8 @@
   }
 }
 
-void UnwrappedLineParser::parseRequiresExpression(unsigned int OriginalLevel) {
+void UnwrappedLineParser::parseRequiresExpression(unsigned int OriginalLevel,
+  bool InTrailingRequire) {
   // requires (R range)
   if (FormatTok->Tok.is(tok::l_paren)) {
 parseParens();
@@ -2564,12 +2565,12 @@
 parseBlock();
 addUnwrappedLine();
   } else {
-parseConstraintExpression(OriginalLevel);
+parseConstraintExpression(OriginalLevel, InTrailingRequire);
   }
 }
 
-void UnwrappedLineParser::parseConstraintExpression(
-unsigned int OriginalLevel) {
+void UnwrappedLineParser::parseConstraintExpression(unsigned int OriginalLevel,
+bool InTrailingRequire) {
   // requires Id && Id || Id
   while (
   FormatTok->isOneOf(tok::identifier, tok::kw_requires, 

[PATCH] D112019: [clang-format] [PR51412] AlignConsecutiveMacros fights with Visual Studio and resource.h

2021-12-19 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added a comment.

Please review the descriptions.
Looks good, but I'm wondering if there are better names for these options.
E.g. when `AlignConsecutiveMacrosIgnoreMax` is true, then 
`AlignConsecutiveMacrosMinWidth` is not minimum width, but required/fixed width 
except for long macro names.




Comment at: clang/docs/ClangFormatStyleOptions.rst:547-550
+  Macros beyond ``AlignConsecutiveMacrosMinWidth`` break the
+  ConsecutiveMacroAlignment streak, When used in conjuction
+  With ``AlignConsecutiveMacrosMinWidth`` this allows longer macros to
+  not cause shorter macros to align.

Please add full stops at the end of sentences and fix capitals (like in With). 
(in Format.h of course and regenerate)
Commenting here as it's easier to see the end result.
Please check descriptions of other options too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112019

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


[PATCH] D115959: [clangd] Fix undefined behavior when generating error message at rename with an invalid name

2021-12-19 Thread Aleksandr Platonov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG555eacf75f21: [clangd] Fix undefined behavior when 
generating error message at rename with an… (authored by ArcsinX).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115959

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


Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -1060,6 +1060,11 @@
   )cpp",
"conflict", !HeaderFile, "Conflict"},
 
+  {R"cpp(
+int V^ar;
+  )cpp",
+   "\"const\" is a keyword", !HeaderFile, "const"},
+
   {R"cpp(// Trying to rename into the same name, SameName == SameName.
 void func() {
   int S^ameName;
Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -455,7 +455,7 @@
 }
 
 llvm::Error makeError(InvalidName Reason) {
-  auto Message = [](InvalidName Reason) {
+  auto Message = [](const InvalidName ) {
 switch (Reason.K) {
 case InvalidName::Keywords:
   return llvm::formatv("the chosen name \"{0}\" is a keyword",
@@ -733,7 +733,7 @@
 return makeError(ReasonToReject::SameName);
   auto Invalid = checkName(RenameDecl, RInputs.NewName);
   if (Invalid)
-return makeError(*Invalid);
+return makeError(std::move(*Invalid));
 
   auto Reject = renameable(RenameDecl, RInputs.MainFilePath, RInputs.Index);
   if (Reject)


Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -1060,6 +1060,11 @@
   )cpp",
"conflict", !HeaderFile, "Conflict"},
 
+  {R"cpp(
+int V^ar;
+  )cpp",
+   "\"const\" is a keyword", !HeaderFile, "const"},
+
   {R"cpp(// Trying to rename into the same name, SameName == SameName.
 void func() {
   int S^ameName;
Index: clang-tools-extra/clangd/refactor/Rename.cpp
===
--- clang-tools-extra/clangd/refactor/Rename.cpp
+++ clang-tools-extra/clangd/refactor/Rename.cpp
@@ -455,7 +455,7 @@
 }
 
 llvm::Error makeError(InvalidName Reason) {
-  auto Message = [](InvalidName Reason) {
+  auto Message = [](const InvalidName ) {
 switch (Reason.K) {
 case InvalidName::Keywords:
   return llvm::formatv("the chosen name \"{0}\" is a keyword",
@@ -733,7 +733,7 @@
 return makeError(ReasonToReject::SameName);
   auto Invalid = checkName(RenameDecl, RInputs.NewName);
   if (Invalid)
-return makeError(*Invalid);
+return makeError(std::move(*Invalid));
 
   auto Reject = renameable(RenameDecl, RInputs.MainFilePath, RInputs.Index);
   if (Reject)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 555eacf - [clangd] Fix undefined behavior when generating error message at rename with an invalid name

2021-12-19 Thread Aleksandr Platonov via cfe-commits

Author: Aleksandr Platonov
Date: 2021-12-19T22:28:26+03:00
New Revision: 555eacf75f21cd1dfc6363d73ad187b730349543

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

LOG: [clangd] Fix undefined behavior when generating error message at rename 
with an invalid name

`Message()` lambda uses `Reason.Details` as an input parameter for 
`llvm::formatv()`, but `Reason` in `Message()` is a local object.
Return value of `llvm::formatv()` contains references to its input arguments, 
thus `Message()` returns an object which contains a reference to `Details` 
field of the local object `Reason`.
This patch fixes this behavior by passing `Reason` as a reference to 
`Message()` to ensure that return value of `Message()` contains references to 
alive object and also prevents copying of `InvalidName` structure at passing it 
to `makeError()`.

Provided test passes on Linux+GCC with or without this patch, but fails on 
Windows+VisualStudio without this patch.

Reviewed By: sammccall

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

Added: 


Modified: 
clang-tools-extra/clangd/refactor/Rename.cpp
clang-tools-extra/clangd/unittests/RenameTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/refactor/Rename.cpp 
b/clang-tools-extra/clangd/refactor/Rename.cpp
index 76182375ea170..5e157db5900af 100644
--- a/clang-tools-extra/clangd/refactor/Rename.cpp
+++ b/clang-tools-extra/clangd/refactor/Rename.cpp
@@ -455,7 +455,7 @@ std::string toString(InvalidName::Kind K) {
 }
 
 llvm::Error makeError(InvalidName Reason) {
-  auto Message = [](InvalidName Reason) {
+  auto Message = [](const InvalidName ) {
 switch (Reason.K) {
 case InvalidName::Keywords:
   return llvm::formatv("the chosen name \"{0}\" is a keyword",
@@ -733,7 +733,7 @@ llvm::Expected rename(const RenameInputs 
) {
 return makeError(ReasonToReject::SameName);
   auto Invalid = checkName(RenameDecl, RInputs.NewName);
   if (Invalid)
-return makeError(*Invalid);
+return makeError(std::move(*Invalid));
 
   auto Reject = renameable(RenameDecl, RInputs.MainFilePath, RInputs.Index);
   if (Reject)

diff  --git a/clang-tools-extra/clangd/unittests/RenameTests.cpp 
b/clang-tools-extra/clangd/unittests/RenameTests.cpp
index f062f91c94378..26b3d7ad1c6c0 100644
--- a/clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ b/clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -1060,6 +1060,11 @@ TEST(RenameTest, Renameable) {
   )cpp",
"conflict", !HeaderFile, "Conflict"},
 
+  {R"cpp(
+int V^ar;
+  )cpp",
+   "\"const\" is a keyword", !HeaderFile, "const"},
+
   {R"cpp(// Trying to rename into the same name, SameName == SameName.
 void func() {
   int S^ameName;



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


[PATCH] D115998: [Clang] Add helper text to fopenmp_version_EQ to make it show in help menu

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

LG


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115998

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


[PATCH] D115990: AlignConsecutiveDeclarations not working for 'const' keyword in JavsScript

2021-12-19 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius accepted this revision.
curdeius added a comment.
This revision is now accepted and ready to land.

LGTM! Optional nit comment.




Comment at: clang/lib/Format/TokenAnnotator.cpp:1875
+// const a = in JavaScript.
+if (Style.isJavaScript() && PreviousNotConst->is(tok::kw_const))
+  return true;

Nit.


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

https://reviews.llvm.org/D115990

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


[PATCH] D116003: [NFC] Specify targets for clang stack-protector-guard.c

2021-12-19 Thread Qiu Chaofan via Phabricator via cfe-commits
qiucf created this revision.
qiucf added reviewers: tejohnson, MaskRay, lkail, nickdesaulniers.
qiucf requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The run line of `stack-protector-guard.c` doesn't specify the triple, which 
means it depends on the platform running the test. This makes some failure 
hidden.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116003

Files:
  clang/test/CodeGen/stack-protector-guard.c


Index: clang/test/CodeGen/stack-protector-guard.c
===
--- clang/test/CodeGen/stack-protector-guard.c
+++ clang/test/CodeGen/stack-protector-guard.c
@@ -1,8 +1,28 @@
-// RUN: %clang_cc1 -mstack-protector-guard=sysreg \
-// RUN:-mstack-protector-guard-reg=sp_el0 \
-// RUN:-mstack-protector-guard-offset=1024 \
-// RUN:-emit-llvm %s -o - | FileCheck %s
-// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck --check-prefix=CHECK-NONE %s
+// RUN: %clang_cc1 -mstack-protector-guard=sysreg -triple 
x86_64-unknown-unknown \
+// RUN:   -mstack-protector-guard-reg=sp_el0 
-mstack-protector-guard-offset=1024 \
+// RUN:   -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -mstack-protector-guard=sysreg -triple 
powerpc64le-linux-gnu \
+// RUN:   -mstack-protector-guard-reg=sp_el0 
-mstack-protector-guard-offset=1024 \
+// RUN:   -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -mstack-protector-guard=sysreg -triple arm-eabi-c \
+// RUN:   -mstack-protector-guard-reg=sp_el0 
-mstack-protector-guard-offset=1024 \
+// RUN:   -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -mstack-protector-guard=sysreg -triple thumbv7-eabi-c \
+// RUN:-mstack-protector-guard-reg=sp_el0 
-mstack-protector-guard-offset=1024 \
+// RUN:-emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -mstack-protector-guard=sysreg -triple aarch64-linux-gnu \
+// RUN:   -mstack-protector-guard-reg=sp_el0 
-mstack-protector-guard-offset=1024 \
+// RUN:   -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm %s -triple x86_64-unknown-unknown -o - \
+// RUN:   | FileCheck --check-prefix=CHECK-NONE %s
+// RUN: %clang_cc1 -emit-llvm %s -triple powerpc64le-linux-gnu -o - \
+// RUN:   | FileCheck --check-prefix=CHECK-NONE %s
+// RUN: %clang_cc1 -emit-llvm %s -triple arm-eabi-c -o - \
+// RUN:   | FileCheck --check-prefix=CHECK-NONE %s
+// RUN: %clang_cc1 -emit-llvm %s -triple thumbv7-eabi-c -o - \
+// RUN:   | FileCheck --check-prefix=CHECK-NONE %s
+// RUN: %clang_cc1 -emit-llvm %s -triple aarch64-linux-gnu -o - \
+// RUN:   | FileCheck --check-prefix=CHECK-NONE %s
 void foo(int*);
 void bar(int x) {
   int baz[x];


Index: clang/test/CodeGen/stack-protector-guard.c
===
--- clang/test/CodeGen/stack-protector-guard.c
+++ clang/test/CodeGen/stack-protector-guard.c
@@ -1,8 +1,28 @@
-// RUN: %clang_cc1 -mstack-protector-guard=sysreg \
-// RUN:-mstack-protector-guard-reg=sp_el0 \
-// RUN:-mstack-protector-guard-offset=1024 \
-// RUN:-emit-llvm %s -o - | FileCheck %s
-// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck --check-prefix=CHECK-NONE %s
+// RUN: %clang_cc1 -mstack-protector-guard=sysreg -triple x86_64-unknown-unknown \
+// RUN:   -mstack-protector-guard-reg=sp_el0 -mstack-protector-guard-offset=1024 \
+// RUN:   -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -mstack-protector-guard=sysreg -triple powerpc64le-linux-gnu \
+// RUN:   -mstack-protector-guard-reg=sp_el0 -mstack-protector-guard-offset=1024 \
+// RUN:   -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -mstack-protector-guard=sysreg -triple arm-eabi-c \
+// RUN:   -mstack-protector-guard-reg=sp_el0 -mstack-protector-guard-offset=1024 \
+// RUN:   -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -mstack-protector-guard=sysreg -triple thumbv7-eabi-c \
+// RUN:-mstack-protector-guard-reg=sp_el0 -mstack-protector-guard-offset=1024 \
+// RUN:-emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -mstack-protector-guard=sysreg -triple aarch64-linux-gnu \
+// RUN:   -mstack-protector-guard-reg=sp_el0 -mstack-protector-guard-offset=1024 \
+// RUN:   -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm %s -triple x86_64-unknown-unknown -o - \
+// RUN:   | FileCheck --check-prefix=CHECK-NONE %s
+// RUN: %clang_cc1 -emit-llvm %s -triple powerpc64le-linux-gnu -o - \
+// RUN:   | FileCheck --check-prefix=CHECK-NONE %s
+// RUN: %clang_cc1 -emit-llvm %s -triple arm-eabi-c -o - \
+// RUN:   | FileCheck --check-prefix=CHECK-NONE %s
+// RUN: %clang_cc1 -emit-llvm %s -triple thumbv7-eabi-c -o - \
+// RUN:   | FileCheck --check-prefix=CHECK-NONE %s
+// RUN: %clang_cc1 -emit-llvm %s -triple aarch64-linux-gnu -o - \
+// RUN:   | FileCheck --check-prefix=CHECK-NONE %s
 void foo(int*);
 void bar(int x) {
   int baz[x];
___

[PATCH] D115886: [CodeGen] remove creation of FP cast function attribute

2021-12-19 Thread Sanjay Patel via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1965cc469539: [CodeGen] remove creation of FP cast function 
attribute (authored by spatel).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115886

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/test/CodeGen/no-junk-ftrunc.c


Index: clang/test/CodeGen/no-junk-ftrunc.c
===
--- clang/test/CodeGen/no-junk-ftrunc.c
+++ clang/test/CodeGen/no-junk-ftrunc.c
@@ -1,11 +1,12 @@
 // RUN: %clang_cc1 -S -fno-strict-float-cast-overflow %s -emit-llvm -o - | 
FileCheck %s --check-prefix=NOSTRICT
 
 // When compiling with non-standard semantics, use intrinsics to inhibit the 
optimizer.
+// This used to require a function attribute, so we check that it is NOT here 
anymore.
 
 // NOSTRICT-LABEL: main
 // NOSTRICT: call i32 @llvm.fptosi.sat.i32.f64
 // NOSTRICT: call i32 @llvm.fptoui.sat.i32.f64
-// NOSTRICT: attributes #0 = {{.*}}"strict-float-cast-overflow"="false"{{.*}}
+// NOSTRICT-NOT: strict-float-cast-overflow
 
 // The workaround attribute is not applied by default.
 
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -1831,11 +1831,6 @@
 if (LangOpts.getFPExceptionMode() == LangOptions::FPE_Ignore)
   FuncAttrs.addAttribute("no-trapping-math", "true");
 
-// Strict (compliant) code is the default, so only add this attribute to
-// indicate that we are trying to workaround a problem case.
-if (!CodeGenOpts.StrictFloatCastOverflow)
-  FuncAttrs.addAttribute("strict-float-cast-overflow", "false");
-
 // TODO: Are these all needed?
 // unsafe/inf/nan/nsz are handled by instruction-level FastMathFlags.
 if (LangOpts.NoHonorInfs)


Index: clang/test/CodeGen/no-junk-ftrunc.c
===
--- clang/test/CodeGen/no-junk-ftrunc.c
+++ clang/test/CodeGen/no-junk-ftrunc.c
@@ -1,11 +1,12 @@
 // RUN: %clang_cc1 -S -fno-strict-float-cast-overflow %s -emit-llvm -o - | FileCheck %s --check-prefix=NOSTRICT
 
 // When compiling with non-standard semantics, use intrinsics to inhibit the optimizer.
+// This used to require a function attribute, so we check that it is NOT here anymore.
 
 // NOSTRICT-LABEL: main
 // NOSTRICT: call i32 @llvm.fptosi.sat.i32.f64
 // NOSTRICT: call i32 @llvm.fptoui.sat.i32.f64
-// NOSTRICT: attributes #0 = {{.*}}"strict-float-cast-overflow"="false"{{.*}}
+// NOSTRICT-NOT: strict-float-cast-overflow
 
 // The workaround attribute is not applied by default.
 
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -1831,11 +1831,6 @@
 if (LangOpts.getFPExceptionMode() == LangOptions::FPE_Ignore)
   FuncAttrs.addAttribute("no-trapping-math", "true");
 
-// Strict (compliant) code is the default, so only add this attribute to
-// indicate that we are trying to workaround a problem case.
-if (!CodeGenOpts.StrictFloatCastOverflow)
-  FuncAttrs.addAttribute("strict-float-cast-overflow", "false");
-
 // TODO: Are these all needed?
 // unsafe/inf/nan/nsz are handled by instruction-level FastMathFlags.
 if (LangOpts.NoHonorInfs)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 1965cc4 - [CodeGen] remove creation of FP cast function attribute

2021-12-19 Thread Sanjay Patel via cfe-commits

Author: Sanjay Patel
Date: 2021-12-19T11:55:00-05:00
New Revision: 1965cc469539979d66c6a7f9d1c73000a795f8f0

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

LOG: [CodeGen] remove creation of FP cast function attribute

This is the last cleanup step resulting from D115804 .
Now that clang uses intrinsics when we're in the special FP mode,
we don't need a function attribute as an indicator to the backend.
The LLVM part of the change is in D115885.

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

Added: 


Modified: 
clang/lib/CodeGen/CGCall.cpp
clang/test/CodeGen/no-junk-ftrunc.c

Removed: 




diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index e4526ff30bdd8..b202326cf7575 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -1831,11 +1831,6 @@ void 
CodeGenModule::getDefaultFunctionAttributes(StringRef Name,
 if (LangOpts.getFPExceptionMode() == LangOptions::FPE_Ignore)
   FuncAttrs.addAttribute("no-trapping-math", "true");
 
-// Strict (compliant) code is the default, so only add this attribute to
-// indicate that we are trying to workaround a problem case.
-if (!CodeGenOpts.StrictFloatCastOverflow)
-  FuncAttrs.addAttribute("strict-float-cast-overflow", "false");
-
 // TODO: Are these all needed?
 // unsafe/inf/nan/nsz are handled by instruction-level FastMathFlags.
 if (LangOpts.NoHonorInfs)

diff  --git a/clang/test/CodeGen/no-junk-ftrunc.c 
b/clang/test/CodeGen/no-junk-ftrunc.c
index 6ae6d30fca434..62491fbfa7cd4 100644
--- a/clang/test/CodeGen/no-junk-ftrunc.c
+++ b/clang/test/CodeGen/no-junk-ftrunc.c
@@ -1,11 +1,12 @@
 // RUN: %clang_cc1 -S -fno-strict-float-cast-overflow %s -emit-llvm -o - | 
FileCheck %s --check-prefix=NOSTRICT
 
 // When compiling with non-standard semantics, use intrinsics to inhibit the 
optimizer.
+// This used to require a function attribute, so we check that it is NOT here 
anymore.
 
 // NOSTRICT-LABEL: main
 // NOSTRICT: call i32 @llvm.fptosi.sat.i32.f64
 // NOSTRICT: call i32 @llvm.fptoui.sat.i32.f64
-// NOSTRICT: attributes #0 = {{.*}}"strict-float-cast-overflow"="false"{{.*}}
+// NOSTRICT-NOT: strict-float-cast-overflow
 
 // The workaround attribute is not applied by default.
 



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


[PATCH] D114425: [clang] Add __builtin_bswap128

2021-12-19 Thread Nikolas Klauser via Phabricator via cfe-commits
philnik updated this revision to Diff 395338.
philnik added a comment.

Guarding test now


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114425

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/Builtins.def
  clang/lib/AST/ExprConstant.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins.cpp
  clang/test/Sema/constant-builtins-2.c


Index: clang/test/Sema/constant-builtins-2.c
===
--- clang/test/Sema/constant-builtins-2.c
+++ clang/test/Sema/constant-builtins-2.c
@@ -216,6 +216,9 @@
 int h3 = __builtin_bswap16(0x1234) == 0x3412 ? 1 : f();
 int h4 = __builtin_bswap32(0x1234) == 0x3412 ? 1 : f();
 int h5 = __builtin_bswap64(0x1234) == 0x3412 ? 1 : f();
+#if defined(__SIZEOF_INT128__)
+int h6 = __builtin_bswap128(0x1234) == (((__int128)0x3412) << 112) ? 1 : f();
+#endif
 extern long int bi0;
 extern __typeof__(__builtin_expect(0, 0)) bi0;
 
Index: clang/test/CodeGen/builtins.cpp
===
--- clang/test/CodeGen/builtins.cpp
+++ clang/test/CodeGen/builtins.cpp
@@ -20,6 +20,10 @@
 decltype(__builtin_bswap32(0)) bswap32 = 42;
 extern uint64_t bswap64;
 decltype(__builtin_bswap64(0)) bswap64 = 42;
+#ifdef __SIZEOF_INT128__
+extern __uint128_t bswap128;
+decltype(__builtin_bswap128(0)) bswap128 = 42;
+#endif
 
 #ifdef __clang__
 extern uint8_t bitrev8;
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -2905,7 +2905,8 @@
   }
   case Builtin::BI__builtin_bswap16:
   case Builtin::BI__builtin_bswap32:
-  case Builtin::BI__builtin_bswap64: {
+  case Builtin::BI__builtin_bswap64:
+  case Builtin::BI__builtin_bswap128: {
 return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::bswap));
   }
   case Builtin::BI__builtin_bitreverse8:
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -11640,7 +11640,8 @@
 
   case Builtin::BI__builtin_bswap16:
   case Builtin::BI__builtin_bswap32:
-  case Builtin::BI__builtin_bswap64: {
+  case Builtin::BI__builtin_bswap64:
+  case Builtin::BI__builtin_bswap128: {
 APSInt Val;
 if (!EvaluateInteger(E->getArg(0), Val, Info))
   return false;
Index: clang/include/clang/Basic/Builtins.def
===
--- clang/include/clang/Basic/Builtins.def
+++ clang/include/clang/Basic/Builtins.def
@@ -512,6 +512,7 @@
 BUILTIN(__builtin_bswap16, "UsUs", "nc")
 BUILTIN(__builtin_bswap32, "UZiUZi", "nc")
 BUILTIN(__builtin_bswap64, "UWiUWi", "nc")
+BUILTIN(__builtin_bswap128, "ULLLiULLLi", "nc")
 
 BUILTIN(__builtin_bitreverse8, "UcUc", "nc")
 BUILTIN(__builtin_bitreverse16, "UsUs", "nc")
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -59,6 +59,8 @@
 - Maximum _ExtInt size was decreased from 16,777,215 bits to 8,388,608 bits.
   Motivation for this was discussed in PR51829.
 
+- The builtin ``__builtin_bswap128`` was added.
+
 New Compiler Flags
 --
 


Index: clang/test/Sema/constant-builtins-2.c
===
--- clang/test/Sema/constant-builtins-2.c
+++ clang/test/Sema/constant-builtins-2.c
@@ -216,6 +216,9 @@
 int h3 = __builtin_bswap16(0x1234) == 0x3412 ? 1 : f();
 int h4 = __builtin_bswap32(0x1234) == 0x3412 ? 1 : f();
 int h5 = __builtin_bswap64(0x1234) == 0x3412 ? 1 : f();
+#if defined(__SIZEOF_INT128__)
+int h6 = __builtin_bswap128(0x1234) == (((__int128)0x3412) << 112) ? 1 : f();
+#endif
 extern long int bi0;
 extern __typeof__(__builtin_expect(0, 0)) bi0;
 
Index: clang/test/CodeGen/builtins.cpp
===
--- clang/test/CodeGen/builtins.cpp
+++ clang/test/CodeGen/builtins.cpp
@@ -20,6 +20,10 @@
 decltype(__builtin_bswap32(0)) bswap32 = 42;
 extern uint64_t bswap64;
 decltype(__builtin_bswap64(0)) bswap64 = 42;
+#ifdef __SIZEOF_INT128__
+extern __uint128_t bswap128;
+decltype(__builtin_bswap128(0)) bswap128 = 42;
+#endif
 
 #ifdef __clang__
 extern uint8_t bitrev8;
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -2905,7 +2905,8 @@
   }
   case Builtin::BI__builtin_bswap16:
   case Builtin::BI__builtin_bswap32:
-  case Builtin::BI__builtin_bswap64: {
+  case Builtin::BI__builtin_bswap64:
+  case Builtin::BI__builtin_bswap128: {
 return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::bswap));
   }
   case 

[PATCH] D114425: [clang] Add __builtin_bswap128

2021-12-19 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added inline comments.



Comment at: clang/test/Sema/constant-builtins-2.c:219
 int h5 = __builtin_bswap64(0x1234) == 0x3412 ? 1 : f();
+int h6 = __builtin_bswap128(0x1234) == (((__int128)0x3412) << 112) ? 1 : f();
 extern long int bi0;

```
#if defined(__SIZEOF_INT128__)
```
?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114425

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


[PATCH] D116001: [clang-format] add regression tests for braced lists

2021-12-19 Thread Krasimir Georgiev via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3a3fcd6a23ad: [clang-format] add regression tests for braced 
lists (authored by krasimir).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116001

Files:
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -11515,6 +11515,17 @@
"  };\n"
"};");
   verifyFormat("#define A {a, a},");
+  // Don't confuse braced list initializers with compound statements.
+  verifyFormat(
+  "class A {\n"
+  "  A() : a{} {}\n"
+  "  A(int b) : b(b) {}\n"
+  "  A(int a, int b) : a(a), bs{{bs...}} { f(); }\n"
+  "  int a, b;\n"
+  "  explicit Expr(const Scalar ) : u{Constant{x}} {}\n"
+  "  explicit Expr(Scalar &) : u{Constant{std::move(x)}} 
"
+  "{}\n"
+  "};");
 
   // Avoid breaking between equal sign and opening brace
   FormatStyle AvoidBreakingFirstArgument = getLLVMStyle();


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -11515,6 +11515,17 @@
"  };\n"
"};");
   verifyFormat("#define A {a, a},");
+  // Don't confuse braced list initializers with compound statements.
+  verifyFormat(
+  "class A {\n"
+  "  A() : a{} {}\n"
+  "  A(int b) : b(b) {}\n"
+  "  A(int a, int b) : a(a), bs{{bs...}} { f(); }\n"
+  "  int a, b;\n"
+  "  explicit Expr(const Scalar ) : u{Constant{x}} {}\n"
+  "  explicit Expr(Scalar &) : u{Constant{std::move(x)}} "
+  "{}\n"
+  "};");
 
   // Avoid breaking between equal sign and opening brace
   FormatStyle AvoidBreakingFirstArgument = getLLVMStyle();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 3a3fcd6 - [clang-format] add regression tests for braced lists

2021-12-19 Thread Krasimir Georgiev via cfe-commits

Author: Krasimir Georgiev
Date: 2021-12-19T16:07:07+01:00
New Revision: 3a3fcd6a23ad2c0f420a2f6bfde7541233790a30

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

LOG: [clang-format] add regression tests for braced lists

Depends on https://reviews.llvm.org/D116000.

Added test cases from the comments on https://reviews.llvm.org/D114583.

Reviewed By: MyDeveloperDay

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

Added: 


Modified: 
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index d12796e32e577..9325f622d228e 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -11515,6 +11515,17 @@ TEST_F(FormatTest, LayoutCxx11BraceInitializers) {
"  };\n"
"};");
   verifyFormat("#define A {a, a},");
+  // Don't confuse braced list initializers with compound statements.
+  verifyFormat(
+  "class A {\n"
+  "  A() : a{} {}\n"
+  "  A(int b) : b(b) {}\n"
+  "  A(int a, int b) : a(a), bs{{bs...}} { f(); }\n"
+  "  int a, b;\n"
+  "  explicit Expr(const Scalar ) : u{Constant{x}} {}\n"
+  "  explicit Expr(Scalar &) : u{Constant{std::move(x)}} 
"
+  "{}\n"
+  "};");
 
   // Avoid breaking between equal sign and opening brace
   FormatStyle AvoidBreakingFirstArgument = getLLVMStyle();



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


[PATCH] D116000: Revert "[clang-format] Adjust braced list detection"

2021-12-19 Thread Krasimir Georgiev via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd96bf6ea4618: Revert [clang-format] Adjust braced list 
detection (authored by krasimir).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116000

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -11867,27 +11867,6 @@
"  f(v);\n"
"}");
 
-  verifyFormat("void foo() {\n"
-   "  { // asdf\n"
-   "{ int a; }\n"
-   "  }\n"
-   "  {\n"
-   "{ int b; }\n"
-   "  }\n"
-   "}");
-  verifyFormat("namespace n {\n"
-   "void foo() {\n"
-   "  {\n"
-   "{\n"
-   "  statement();\n"
-   "  if (false) {\n"
-   "  }\n"
-   "}\n"
-   "  }\n"
-   "  {}\n"
-   "}\n"
-   "} // namespace n");
-
   // Long lists should be formatted in columns even if they are nested.
   verifyFormat(
   "vector x = function({1, 22, 333, , 5, 66, 777,\n"
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -578,14 +578,17 @@
   // BlockKind later if we parse a braced list (where all blocks
   // inside are by default braced lists), or when we explicitly detect
   // blocks (for example while parsing lambdas).
+  // FIXME: Some of these do not apply to JS, e.g. "} {" can never be a
+  // braced list in JS.
   ProbablyBracedList =
   (Style.Language == FormatStyle::LK_JavaScript &&
NextTok->isOneOf(Keywords.kw_of, Keywords.kw_in,
 Keywords.kw_as)) ||
   (Style.isCpp() && NextTok->is(tok::l_paren)) ||
   NextTok->isOneOf(tok::comma, tok::period, tok::colon,
-   tok::r_paren, tok::r_square, tok::ellipsis) ||
-  (NextTok->isOneOf(tok::l_brace, tok::identifier) &&
+   tok::r_paren, tok::r_square, tok::l_brace,
+   tok::ellipsis) ||
+  (NextTok->is(tok::identifier) &&
!PrevTok->isOneOf(tok::semi, tok::r_brace, tok::l_brace)) ||
   (NextTok->is(tok::semi) &&
(!ExpectClassBody || LBraceStack.size() != 1)) ||
@@ -2861,7 +2864,7 @@
   // class Foo implements {bar: number} { }
   nextToken();
   if (FormatTok->is(tok::l_brace)) {
-parseBracedList();
+tryToParseBracedList();
 continue;
   }
 }


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -11867,27 +11867,6 @@
"  f(v);\n"
"}");
 
-  verifyFormat("void foo() {\n"
-   "  { // asdf\n"
-   "{ int a; }\n"
-   "  }\n"
-   "  {\n"
-   "{ int b; }\n"
-   "  }\n"
-   "}");
-  verifyFormat("namespace n {\n"
-   "void foo() {\n"
-   "  {\n"
-   "{\n"
-   "  statement();\n"
-   "  if (false) {\n"
-   "  }\n"
-   "}\n"
-   "  }\n"
-   "  {}\n"
-   "}\n"
-   "} // namespace n");
-
   // Long lists should be formatted in columns even if they are nested.
   verifyFormat(
   "vector x = function({1, 22, 333, , 5, 66, 777,\n"
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -578,14 +578,17 @@
   // BlockKind later if we parse a braced list (where all blocks
   // inside are by default braced lists), or when we explicitly detect
   // blocks (for example while parsing lambdas).
+  // FIXME: Some of these do not apply to JS, e.g. "} {" can never be a
+  // braced list in JS.
   ProbablyBracedList =
   (Style.Language == FormatStyle::LK_JavaScript &&
NextTok->isOneOf(Keywords.kw_of, Keywords.kw_in,
 Keywords.kw_as)) ||
   (Style.isCpp() && NextTok->is(tok::l_paren)) ||
 

[clang] d96bf6e - Revert "[clang-format] Adjust braced list detection"

2021-12-19 Thread Krasimir Georgiev via cfe-commits

Author: Krasimir Georgiev
Date: 2021-12-19T16:04:42+01:00
New Revision: d96bf6ea461810f7def54541dbcb7ceaecd2d065

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

LOG: Revert "[clang-format] Adjust braced list detection"

It appears that this regressed the formatting of initializer lists in some
cases, see comments on https://reviews.llvm.org/D114583. I'll follow-up
by adding regression tests for these.

This reverts commit c41b3b0fa0f4f70aad8deaf48bcd42a04385066c.

Reviewed By: MyDeveloperDay

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

Added: 


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

Removed: 




diff  --git a/clang/lib/Format/UnwrappedLineParser.cpp 
b/clang/lib/Format/UnwrappedLineParser.cpp
index 856efbd91cb01..c34d515a32d65 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -578,14 +578,17 @@ void UnwrappedLineParser::calculateBraceTypes(bool 
ExpectClassBody) {
   // BlockKind later if we parse a braced list (where all blocks
   // inside are by default braced lists), or when we explicitly detect
   // blocks (for example while parsing lambdas).
+  // FIXME: Some of these do not apply to JS, e.g. "} {" can never be a
+  // braced list in JS.
   ProbablyBracedList =
   (Style.Language == FormatStyle::LK_JavaScript &&
NextTok->isOneOf(Keywords.kw_of, Keywords.kw_in,
 Keywords.kw_as)) ||
   (Style.isCpp() && NextTok->is(tok::l_paren)) ||
   NextTok->isOneOf(tok::comma, tok::period, tok::colon,
-   tok::r_paren, tok::r_square, tok::ellipsis) ||
-  (NextTok->isOneOf(tok::l_brace, tok::identifier) &&
+   tok::r_paren, tok::r_square, tok::l_brace,
+   tok::ellipsis) ||
+  (NextTok->is(tok::identifier) &&
!PrevTok->isOneOf(tok::semi, tok::r_brace, tok::l_brace)) ||
   (NextTok->is(tok::semi) &&
(!ExpectClassBody || LBraceStack.size() != 1)) ||
@@ -2861,7 +2864,7 @@ void UnwrappedLineParser::parseRecord(bool ParseAsExpr) {
   // class Foo implements {bar: number} { }
   nextToken();
   if (FormatTok->is(tok::l_brace)) {
-parseBracedList();
+tryToParseBracedList();
 continue;
   }
 }

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 2a9de85bf453b..d12796e32e577 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -11867,27 +11867,6 @@ TEST_F(FormatTest, FormatsBracedListsInColumnLayout) {
"  f(v);\n"
"}");
 
-  verifyFormat("void foo() {\n"
-   "  { // asdf\n"
-   "{ int a; }\n"
-   "  }\n"
-   "  {\n"
-   "{ int b; }\n"
-   "  }\n"
-   "}");
-  verifyFormat("namespace n {\n"
-   "void foo() {\n"
-   "  {\n"
-   "{\n"
-   "  statement();\n"
-   "  if (false) {\n"
-   "  }\n"
-   "}\n"
-   "  }\n"
-   "  {}\n"
-   "}\n"
-   "} // namespace n");
-
   // Long lists should be formatted in columns even if they are nested.
   verifyFormat(
   "vector x = function({1, 22, 333, , 5, 66, 777,\n"



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


[PATCH] D115990: AlignConsecutiveDeclarations not working for 'const' keyword in JavsScript

2021-12-19 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay updated this revision to Diff 395329.
MyDeveloperDay added a comment.

clang-format the file


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

https://reviews.llvm.org/D115990

Files:
  clang/include/clang/Format/Format.h
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTestJS.cpp

Index: clang/unittests/Format/FormatTestJS.cpp
===
--- clang/unittests/Format/FormatTestJS.cpp
+++ clang/unittests/Format/FormatTestJS.cpp
@@ -2696,5 +2696,115 @@
   verifyFormat("x = 1_000_000 + 12;", "x = 1_000_000   + 12;");
 }
 
+TEST_F(FormatTestJS, AlignConsecutiveDeclarations) {
+  FormatStyle Style = getGoogleStyle(FormatStyle::LK_JavaScript);
+  Style.AlignConsecutiveDeclarations = FormatStyle::ACS_Consecutive;
+  verifyFormat("letletVariable = 5;\n"
+   "double constVariable = 10;",
+   Style);
+
+  verifyFormat("let   letVariable = 5;\n"
+   "const constVariable = 10;",
+   Style);
+
+  verifyFormat("let  letVariable = 5;\n"
+   "static const constVariable = 10;",
+   Style);
+
+  verifyFormat("letletVariable = 5;\n"
+   "static var constVariable = 10;",
+   Style);
+
+  verifyFormat("let letVariable = 5;\n"
+   "var constVariable = 10;",
+   Style);
+
+  verifyFormat("double letVariable = 5;\n"
+   "varconstVariable = 10;",
+   Style);
+
+  verifyFormat("const letVariable = 5;\n"
+   "var   constVariable = 10;",
+   Style);
+
+  verifyFormat("int letVariable = 5;\n"
+   "int constVariable = 10;",
+   Style);
+}
+
+TEST_F(FormatTestJS, AlignConsecutiveAssignments) {
+  FormatStyle Style = getGoogleStyle(FormatStyle::LK_JavaScript);
+
+  Style.AlignConsecutiveAssignments = FormatStyle::ACS_Consecutive;
+  verifyFormat("let letVariable  = 5;\n"
+   "double constVariable = 10;",
+   Style);
+
+  verifyFormat("let letVariable = 5;\n"
+   "const constVariable = 10;",
+   Style);
+
+  verifyFormat("let letVariable= 5;\n"
+   "static const constVariable = 10;",
+   Style);
+
+  verifyFormat("let letVariable  = 5;\n"
+   "static var constVariable = 10;",
+   Style);
+
+  verifyFormat("let letVariable   = 5;\n"
+   "var constVariable = 10;",
+   Style);
+
+  verifyFormat("double letVariable = 5;\n"
+   "var constVariable  = 10;",
+   Style);
+
+  verifyFormat("const letVariable = 5;\n"
+   "var constVariable = 10;",
+   Style);
+
+  verifyFormat("int letVariable   = 5;\n"
+   "int constVariable = 10;",
+   Style);
+}
+
+TEST_F(FormatTestJS, AlignConsecutiveAssignmentsAndDeclarations) {
+  FormatStyle Style = getGoogleStyle(FormatStyle::LK_JavaScript);
+  Style.AlignConsecutiveDeclarations = FormatStyle::ACS_Consecutive;
+  Style.AlignConsecutiveAssignments = FormatStyle::ACS_Consecutive;
+  verifyFormat("letletVariable   = 5;\n"
+   "double constVariable = 10;",
+   Style);
+
+  verifyFormat("let   letVariable   = 5;\n"
+   "const constVariable = 10;",
+   Style);
+
+  verifyFormat("let  letVariable   = 5;\n"
+   "static const constVariable = 10;",
+   Style);
+
+  verifyFormat("letletVariable   = 5;\n"
+   "static var constVariable = 10;",
+   Style);
+
+  verifyFormat("let letVariable   = 5;\n"
+   "var constVariable = 10;",
+   Style);
+
+  verifyFormat("double letVariable   = 5;\n"
+   "varconstVariable = 10;",
+   Style);
+
+  verifyFormat("const letVariable   = 5;\n"
+   "var   constVariable = 10;",
+   Style);
+
+  verifyFormat("int letVariable   = 5;\n"
+   "int constVariable = 10;",
+   Style);
+}
+
 } // namespace format
 } // end namespace clang
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1826,14 +1826,17 @@
 if (Tok.Previous->isOneOf(TT_LeadingJavaAnnotation, Keywords.kw_instanceof,
   Keywords.kw_as))
   return false;
-if (Style.Language == FormatStyle::LK_JavaScript &&
-Tok.Previous->is(Keywords.kw_in))
+if (Style.isJavaScript() && Tok.Previous->is(Keywords.kw_in))
   return false;
 
 // Skip "const" as it does not have an influence on whether this is a name.
 FormatToken *PreviousNotConst = Tok.getPreviousNonComment();
-while (PreviousNotConst && PreviousNotConst->is(tok::kw_const))
-  PreviousNotConst = 

[PATCH] D116000: Revert "[clang-format] Adjust braced list detection"

2021-12-19 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay added a comment.
This revision is now accepted and ready to land.

I think we have to do this as the fix broke more than it fixed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116000

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


[PATCH] D116001: [clang-format] add regression tests for braced lists

2021-12-19 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

thanks for picking this one up (and finding it in the first place)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116001

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


[PATCH] D116001: [clang-format] add regression tests for braced lists

2021-12-19 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116001

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


[PATCH] D116001: [clang-format] add regression tests for braced lists

2021-12-19 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir created this revision.
krasimir requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Depends on https://reviews.llvm.org/D116000.

Added test cases from the comments on https://reviews.llvm.org/D114583.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116001

Files:
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -11515,6 +11515,17 @@
"  };\n"
"};");
   verifyFormat("#define A {a, a},");
+  // Don't confuse braced list initializers with compound statements.
+  verifyFormat(
+  "class A {\n"
+  "  A() : a{} {}\n"
+  "  A(int b) : b(b) {}\n"
+  "  A(int a, int b) : a(a), bs{{bs...}} { f(); }\n"
+  "  int a, b;\n"
+  "  explicit Expr(const Scalar ) : u{Constant{x}} {}\n"
+  "  explicit Expr(Scalar &) : u{Constant{std::move(x)}} 
"
+  "{}\n"
+  "};");
 
   // Avoid breaking between equal sign and opening brace
   FormatStyle AvoidBreakingFirstArgument = getLLVMStyle();


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -11515,6 +11515,17 @@
"  };\n"
"};");
   verifyFormat("#define A {a, a},");
+  // Don't confuse braced list initializers with compound statements.
+  verifyFormat(
+  "class A {\n"
+  "  A() : a{} {}\n"
+  "  A(int b) : b(b) {}\n"
+  "  A(int a, int b) : a(a), bs{{bs...}} { f(); }\n"
+  "  int a, b;\n"
+  "  explicit Expr(const Scalar ) : u{Constant{x}} {}\n"
+  "  explicit Expr(Scalar &) : u{Constant{std::move(x)}} "
+  "{}\n"
+  "};");
 
   // Avoid breaking between equal sign and opening brace
   FormatStyle AvoidBreakingFirstArgument = getLLVMStyle();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D115429: [Clang] Implement the rest of __builtin_elementwise_* functions.

2021-12-19 Thread Jun Zhang via Phabricator via cfe-commits
junaire added a comment.

Hi, @aaron.ballman  I'm sorry for not updating the patch in time because I'm 
preparing for my school final exam :-(
One thing I want to mention is that `__builtin_elementwise_roundeven` is 
actually been added in the RFC during the code review. You can find it in 
D111529 .

> "Prevailing rounding mode" is not super-useful, other than as a spelling for 
> round-to-nearest-ties-to-even (IEEE 754 default rounding). Outside of a 
> FENV_ACCESS ON context, there's not even really a notion of "prevailing 
> rounding mode" to appeal to. I assume the intent is for this to lower to e.g. 
> x86 ROUND* with the dynamic rounding-mode immediate.
>
> I would recommend adding __builtin_elementwise_roundeven(T x) instead, which 
> would statically bind IEEE default rounding (following TS 18661-1 naming) 
> without having to appeal to prevailing rounding mode, and can still lower to 
> ROUND* on x86 outside of FENV_ACCESS ON contexts, which is the norm for 
> vector code (and FRINTN unconditionally on armv8). I think we can punt on 
> rint/nearbyint for now, and add them in the future if there's a need.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115429

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


[PATCH] D115429: [Clang] Implement the rest of __builtin_elementwise_* functions.

2021-12-19 Thread Jun Zhang via Phabricator via cfe-commits
junaire updated this revision to Diff 395323.
junaire added a comment.

Format the patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115429

Files:
  clang/include/clang/Basic/Builtins.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-elementwise-math.c
  clang/test/Sema/builtins-elementwise-math.c

Index: clang/test/Sema/builtins-elementwise-math.c
===
--- clang/test/Sema/builtins-elementwise-math.c
+++ clang/test/Sema/builtins-elementwise-math.c
@@ -156,3 +156,66 @@
   uv = __builtin_elementwise_ceil(uv);
   // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}}
 }
+
+void test_builtin_elementwise_floor(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) {
+
+  struct Foo s = __builtin_elementwise_floor(f);
+  // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}}
+
+  i = __builtin_elementwise_floor();
+  // expected-error@-1 {{too few arguments to function call, expected 1, have 0}}
+
+  i = __builtin_elementwise_floor(i);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'int')}}
+
+  i = __builtin_elementwise_floor(f, f);
+  // expected-error@-1 {{too many arguments to function call, expected 1, have 2}}
+
+  u = __builtin_elementwise_floor(u);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}}
+
+  uv = __builtin_elementwise_floor(uv);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}}
+}
+
+void test_builtin_elementwise_roundeven(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) {
+
+  struct Foo s = __builtin_elementwise_roundeven(f);
+  // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}}
+
+  i = __builtin_elementwise_roundeven();
+  // expected-error@-1 {{too few arguments to function call, expected 1, have 0}}
+
+  i = __builtin_elementwise_roundeven(i);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'int')}}
+
+  i = __builtin_elementwise_roundeven(f, f);
+  // expected-error@-1 {{too many arguments to function call, expected 1, have 2}}
+
+  u = __builtin_elementwise_roundeven(u);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}}
+
+  uv = __builtin_elementwise_roundeven(uv);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}}
+}
+
+void test_builtin_elementwise_trunc(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) {
+
+  struct Foo s = __builtin_elementwise_trunc(f);
+  // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}}
+
+  i = __builtin_elementwise_trunc();
+  // expected-error@-1 {{too few arguments to function call, expected 1, have 0}}
+
+  i = __builtin_elementwise_trunc(i);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'int')}}
+
+  i = __builtin_elementwise_trunc(f, f);
+  // expected-error@-1 {{too many arguments to function call, expected 1, have 2}}
+
+  u = __builtin_elementwise_trunc(u);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}}
+
+  uv = __builtin_elementwise_trunc(uv);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}}
+}
Index: clang/test/CodeGen/builtins-elementwise-math.c
===
--- clang/test/CodeGen/builtins-elementwise-math.c
+++ clang/test/CodeGen/builtins-elementwise-math.c
@@ -205,3 +205,51 @@
   // CHECK-NEXT: call <4 x float> @llvm.ceil.v4f32(<4 x float> [[VF1]])
   vf2 = __builtin_elementwise_ceil(vf1);
 }
+
+void test_builtin_elementwise_floor(float f1, float f2, double d1, double d2,
+float4 vf1, float4 vf2) {
+  // CHECK-LABEL: define void @test_builtin_elementwise_floor(
+  // CHECK:  [[F1:%.+]] = load float, float* %f1.addr, align 4
+  // CHECK-NEXT:  call float @llvm.floor.f32(float [[F1]])
+  f2 = __builtin_elementwise_floor(f1);
+
+  // CHECK:  [[D1:%.+]] = load double, double* %d1.addr, align 8
+  // CHECK-NEXT: call double @llvm.floor.f64(double [[D1]])
+  d2 = __builtin_elementwise_floor(d1);
+
+  // CHECK:  [[VF1:%.+]] = load <4 x float>, <4 x float>* %vf1.addr, align 16
+  // CHECK-NEXT: call <4 x float> @llvm.floor.v4f32(<4 x float> [[VF1]])
+  vf2 = __builtin_elementwise_floor(vf1);
+}
+
+void test_builtin_elementwise_roundeven(float f1, float f2, double d1, double d2,
+float4 vf1, float4 vf2) {
+  // 

[PATCH] D115429: [Clang] Implement the rest of __builtin_elementwise_* functions.

2021-12-19 Thread Jun Zhang via Phabricator via cfe-commits
junaire updated this revision to Diff 395322.
junaire added a comment.

Add a helper function to resue code. I'm not good at naming functions,
so I just oveloaded `emitUnaryBuiltin`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115429

Files:
  clang/include/clang/Basic/Builtins.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-elementwise-math.c
  clang/test/Sema/builtins-elementwise-math.c

Index: clang/test/Sema/builtins-elementwise-math.c
===
--- clang/test/Sema/builtins-elementwise-math.c
+++ clang/test/Sema/builtins-elementwise-math.c
@@ -156,3 +156,66 @@
   uv = __builtin_elementwise_ceil(uv);
   // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}}
 }
+
+void test_builtin_elementwise_floor(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) {
+
+  struct Foo s = __builtin_elementwise_floor(f);
+  // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}}
+
+  i = __builtin_elementwise_floor();
+  // expected-error@-1 {{too few arguments to function call, expected 1, have 0}}
+
+  i = __builtin_elementwise_floor(i);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'int')}}
+
+  i = __builtin_elementwise_floor(f, f);
+  // expected-error@-1 {{too many arguments to function call, expected 1, have 2}}
+
+  u = __builtin_elementwise_floor(u);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}}
+
+  uv = __builtin_elementwise_floor(uv);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}}
+}
+
+void test_builtin_elementwise_roundeven(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) {
+
+  struct Foo s = __builtin_elementwise_roundeven(f);
+  // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}}
+
+  i = __builtin_elementwise_roundeven();
+  // expected-error@-1 {{too few arguments to function call, expected 1, have 0}}
+
+  i = __builtin_elementwise_roundeven(i);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'int')}}
+
+  i = __builtin_elementwise_roundeven(f, f);
+  // expected-error@-1 {{too many arguments to function call, expected 1, have 2}}
+
+  u = __builtin_elementwise_roundeven(u);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}}
+
+  uv = __builtin_elementwise_roundeven(uv);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}}
+}
+
+void test_builtin_elementwise_trunc(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) {
+
+  struct Foo s = __builtin_elementwise_trunc(f);
+  // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}}
+
+  i = __builtin_elementwise_trunc();
+  // expected-error@-1 {{too few arguments to function call, expected 1, have 0}}
+
+  i = __builtin_elementwise_trunc(i);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'int')}}
+
+  i = __builtin_elementwise_trunc(f, f);
+  // expected-error@-1 {{too many arguments to function call, expected 1, have 2}}
+
+  u = __builtin_elementwise_trunc(u);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}}
+
+  uv = __builtin_elementwise_trunc(uv);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}}
+}
Index: clang/test/CodeGen/builtins-elementwise-math.c
===
--- clang/test/CodeGen/builtins-elementwise-math.c
+++ clang/test/CodeGen/builtins-elementwise-math.c
@@ -205,3 +205,51 @@
   // CHECK-NEXT: call <4 x float> @llvm.ceil.v4f32(<4 x float> [[VF1]])
   vf2 = __builtin_elementwise_ceil(vf1);
 }
+
+void test_builtin_elementwise_floor(float f1, float f2, double d1, double d2,
+float4 vf1, float4 vf2) {
+  // CHECK-LABEL: define void @test_builtin_elementwise_floor(
+  // CHECK:  [[F1:%.+]] = load float, float* %f1.addr, align 4
+  // CHECK-NEXT:  call float @llvm.floor.f32(float [[F1]])
+  f2 = __builtin_elementwise_floor(f1);
+
+  // CHECK:  [[D1:%.+]] = load double, double* %d1.addr, align 8
+  // CHECK-NEXT: call double @llvm.floor.f64(double [[D1]])
+  d2 = __builtin_elementwise_floor(d1);
+
+  // CHECK:  [[VF1:%.+]] = load <4 x float>, <4 x float>* %vf1.addr, align 16
+  // CHECK-NEXT: call <4 x float> @llvm.floor.v4f32(<4 x float> [[VF1]])
+  vf2 = __builtin_elementwise_floor(vf1);
+}
+
+void test_builtin_elementwise_roundeven(float f1, float f2, double d1, 

[PATCH] D116000: Revert "[clang-format] Adjust braced list detection"

2021-12-19 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir created this revision.
krasimir requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

It appears that this regressed the formatting of initializer lists in some
cases, see comments on https://reviews.llvm.org/D114583. I'll follow-up
by adding regression tests for these.

This reverts commit c41b3b0fa0f4f70aad8deaf48bcd42a04385066c 
.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116000

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -11867,27 +11867,6 @@
"  f(v);\n"
"}");
 
-  verifyFormat("void foo() {\n"
-   "  { // asdf\n"
-   "{ int a; }\n"
-   "  }\n"
-   "  {\n"
-   "{ int b; }\n"
-   "  }\n"
-   "}");
-  verifyFormat("namespace n {\n"
-   "void foo() {\n"
-   "  {\n"
-   "{\n"
-   "  statement();\n"
-   "  if (false) {\n"
-   "  }\n"
-   "}\n"
-   "  }\n"
-   "  {}\n"
-   "}\n"
-   "} // namespace n");
-
   // Long lists should be formatted in columns even if they are nested.
   verifyFormat(
   "vector x = function({1, 22, 333, , 5, 66, 777,\n"
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -578,14 +578,17 @@
   // BlockKind later if we parse a braced list (where all blocks
   // inside are by default braced lists), or when we explicitly detect
   // blocks (for example while parsing lambdas).
+  // FIXME: Some of these do not apply to JS, e.g. "} {" can never be a
+  // braced list in JS.
   ProbablyBracedList =
   (Style.Language == FormatStyle::LK_JavaScript &&
NextTok->isOneOf(Keywords.kw_of, Keywords.kw_in,
 Keywords.kw_as)) ||
   (Style.isCpp() && NextTok->is(tok::l_paren)) ||
   NextTok->isOneOf(tok::comma, tok::period, tok::colon,
-   tok::r_paren, tok::r_square, tok::ellipsis) ||
-  (NextTok->isOneOf(tok::l_brace, tok::identifier) &&
+   tok::r_paren, tok::r_square, tok::l_brace,
+   tok::ellipsis) ||
+  (NextTok->is(tok::identifier) &&
!PrevTok->isOneOf(tok::semi, tok::r_brace, tok::l_brace)) ||
   (NextTok->is(tok::semi) &&
(!ExpectClassBody || LBraceStack.size() != 1)) ||
@@ -2861,7 +2864,7 @@
   // class Foo implements {bar: number} { }
   nextToken();
   if (FormatTok->is(tok::l_brace)) {
-parseBracedList();
+tryToParseBracedList();
 continue;
   }
 }


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -11867,27 +11867,6 @@
"  f(v);\n"
"}");
 
-  verifyFormat("void foo() {\n"
-   "  { // asdf\n"
-   "{ int a; }\n"
-   "  }\n"
-   "  {\n"
-   "{ int b; }\n"
-   "  }\n"
-   "}");
-  verifyFormat("namespace n {\n"
-   "void foo() {\n"
-   "  {\n"
-   "{\n"
-   "  statement();\n"
-   "  if (false) {\n"
-   "  }\n"
-   "}\n"
-   "  }\n"
-   "  {}\n"
-   "}\n"
-   "} // namespace n");
-
   // Long lists should be formatted in columns even if they are nested.
   verifyFormat(
   "vector x = function({1, 22, 333, , 5, 66, 777,\n"
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -578,14 +578,17 @@
   // BlockKind later if we parse a braced list (where all blocks
   // inside are by default braced lists), or when we explicitly detect
   // blocks (for example while parsing lambdas).
+  // FIXME: Some of these do not apply to JS, e.g. "} {" can never be a
+  // braced list in JS.
   ProbablyBracedList =
   (Style.Language == FormatStyle::LK_JavaScript &&

[PATCH] D114425: [clang] Add __builtin_bswap128

2021-12-19 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

Looks fine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114425

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


[PATCH] D115804: [CodeGen] use saturating FP casts when compiling with "no-strict-float-cast-overflow"

2021-12-19 Thread Sanjay Patel via Phabricator via cfe-commits
spatel added subscribers: kpn, sepavloff, andrew.w.kaylor.
spatel added a comment.

In D115804#3201044 , @craig.topper 
wrote:

> What's the plan for constrained intrinsics versions of these intrinsics? The 
> IRBuilder calls for CreateFPToSI and CreateFPToUI are strict FP aware, but 
> this new code isn't.

Not sure. cc'ing @kpn @sepavloff @andrew.w.kaylor  
The saturating intrinsics implement non-standard behavior for C languages 
AFAIK, so we might want to warn if someone tries to use 
"-fno-strict-float-cast-overflow" and "-ffp-exception-behavior=strict" at the 
same time? Or we try to support that corner case by adding even more FP 
intrinsics?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115804

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


[PATCH] D114425: [clang] Add __builtin_bswap128

2021-12-19 Thread Nikolas Klauser via Phabricator via cfe-commits
philnik updated this revision to Diff 395319.
philnik added a comment.

Added constexpr test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114425

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/Builtins.def
  clang/lib/AST/ExprConstant.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins.cpp
  clang/test/Sema/constant-builtins-2.c


Index: clang/test/Sema/constant-builtins-2.c
===
--- clang/test/Sema/constant-builtins-2.c
+++ clang/test/Sema/constant-builtins-2.c
@@ -216,6 +216,7 @@
 int h3 = __builtin_bswap16(0x1234) == 0x3412 ? 1 : f();
 int h4 = __builtin_bswap32(0x1234) == 0x3412 ? 1 : f();
 int h5 = __builtin_bswap64(0x1234) == 0x3412 ? 1 : f();
+int h6 = __builtin_bswap128(0x1234) == (((__int128)0x3412) << 112) ? 1 : f();
 extern long int bi0;
 extern __typeof__(__builtin_expect(0, 0)) bi0;
 
Index: clang/test/CodeGen/builtins.cpp
===
--- clang/test/CodeGen/builtins.cpp
+++ clang/test/CodeGen/builtins.cpp
@@ -20,6 +20,10 @@
 decltype(__builtin_bswap32(0)) bswap32 = 42;
 extern uint64_t bswap64;
 decltype(__builtin_bswap64(0)) bswap64 = 42;
+#ifdef __SIZEOF_INT128__
+extern __uint128_t bswap128;
+decltype(__builtin_bswap128(0)) bswap128 = 42;
+#endif
 
 #ifdef __clang__
 extern uint8_t bitrev8;
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -2905,7 +2905,8 @@
   }
   case Builtin::BI__builtin_bswap16:
   case Builtin::BI__builtin_bswap32:
-  case Builtin::BI__builtin_bswap64: {
+  case Builtin::BI__builtin_bswap64:
+  case Builtin::BI__builtin_bswap128: {
 return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::bswap));
   }
   case Builtin::BI__builtin_bitreverse8:
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -11640,7 +11640,8 @@
 
   case Builtin::BI__builtin_bswap16:
   case Builtin::BI__builtin_bswap32:
-  case Builtin::BI__builtin_bswap64: {
+  case Builtin::BI__builtin_bswap64:
+  case Builtin::BI__builtin_bswap128: {
 APSInt Val;
 if (!EvaluateInteger(E->getArg(0), Val, Info))
   return false;
Index: clang/include/clang/Basic/Builtins.def
===
--- clang/include/clang/Basic/Builtins.def
+++ clang/include/clang/Basic/Builtins.def
@@ -512,6 +512,7 @@
 BUILTIN(__builtin_bswap16, "UsUs", "nc")
 BUILTIN(__builtin_bswap32, "UZiUZi", "nc")
 BUILTIN(__builtin_bswap64, "UWiUWi", "nc")
+BUILTIN(__builtin_bswap128, "ULLLiULLLi", "nc")
 
 BUILTIN(__builtin_bitreverse8, "UcUc", "nc")
 BUILTIN(__builtin_bitreverse16, "UsUs", "nc")
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -59,6 +59,8 @@
 - Maximum _ExtInt size was decreased from 16,777,215 bits to 8,388,608 bits.
   Motivation for this was discussed in PR51829.
 
+- The builtin ``__builtin_bswap128`` was added.
+
 New Compiler Flags
 --
 


Index: clang/test/Sema/constant-builtins-2.c
===
--- clang/test/Sema/constant-builtins-2.c
+++ clang/test/Sema/constant-builtins-2.c
@@ -216,6 +216,7 @@
 int h3 = __builtin_bswap16(0x1234) == 0x3412 ? 1 : f();
 int h4 = __builtin_bswap32(0x1234) == 0x3412 ? 1 : f();
 int h5 = __builtin_bswap64(0x1234) == 0x3412 ? 1 : f();
+int h6 = __builtin_bswap128(0x1234) == (((__int128)0x3412) << 112) ? 1 : f();
 extern long int bi0;
 extern __typeof__(__builtin_expect(0, 0)) bi0;
 
Index: clang/test/CodeGen/builtins.cpp
===
--- clang/test/CodeGen/builtins.cpp
+++ clang/test/CodeGen/builtins.cpp
@@ -20,6 +20,10 @@
 decltype(__builtin_bswap32(0)) bswap32 = 42;
 extern uint64_t bswap64;
 decltype(__builtin_bswap64(0)) bswap64 = 42;
+#ifdef __SIZEOF_INT128__
+extern __uint128_t bswap128;
+decltype(__builtin_bswap128(0)) bswap128 = 42;
+#endif
 
 #ifdef __clang__
 extern uint8_t bitrev8;
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -2905,7 +2905,8 @@
   }
   case Builtin::BI__builtin_bswap16:
   case Builtin::BI__builtin_bswap32:
-  case Builtin::BI__builtin_bswap64: {
+  case Builtin::BI__builtin_bswap64:
+  case Builtin::BI__builtin_bswap128: {
 return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::bswap));
   }
   case Builtin::BI__builtin_bitreverse8:
Index: clang/lib/AST/ExprConstant.cpp

[PATCH] D115959: [clangd] Fix undefined behavior when generating error message at rename with an invalid name

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

Yikes, thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115959

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


[PATCH] D114425: [clang] Add __builtin_bswap128

2021-12-19 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added a comment.

please can you add a constexpr test? Existing bswap tests are in 
clang/test/Sema/constant-builtins-2.c


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114425

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


[PATCH] D114425: [clang] Add __builtin_bswap128

2021-12-19 Thread Nikolas Klauser via Phabricator via cfe-commits
philnik updated this revision to Diff 395316.
philnik added a comment.

Is that enough or do you want something more?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114425

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/Builtins.def
  clang/lib/AST/ExprConstant.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins.cpp


Index: clang/test/CodeGen/builtins.cpp
===
--- clang/test/CodeGen/builtins.cpp
+++ clang/test/CodeGen/builtins.cpp
@@ -20,6 +20,10 @@
 decltype(__builtin_bswap32(0)) bswap32 = 42;
 extern uint64_t bswap64;
 decltype(__builtin_bswap64(0)) bswap64 = 42;
+#ifdef __SIZEOF_INT128__
+extern __uint128_t bswap128;
+decltype(__builtin_bswap128(0)) bswap128 = 42;
+#endif
 
 #ifdef __clang__
 extern uint8_t bitrev8;
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -2905,7 +2905,8 @@
   }
   case Builtin::BI__builtin_bswap16:
   case Builtin::BI__builtin_bswap32:
-  case Builtin::BI__builtin_bswap64: {
+  case Builtin::BI__builtin_bswap64:
+  case Builtin::BI__builtin_bswap128: {
 return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::bswap));
   }
   case Builtin::BI__builtin_bitreverse8:
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -11640,7 +11640,8 @@
 
   case Builtin::BI__builtin_bswap16:
   case Builtin::BI__builtin_bswap32:
-  case Builtin::BI__builtin_bswap64: {
+  case Builtin::BI__builtin_bswap64:
+  case Builtin::BI__builtin_bswap128: {
 APSInt Val;
 if (!EvaluateInteger(E->getArg(0), Val, Info))
   return false;
Index: clang/include/clang/Basic/Builtins.def
===
--- clang/include/clang/Basic/Builtins.def
+++ clang/include/clang/Basic/Builtins.def
@@ -512,6 +512,7 @@
 BUILTIN(__builtin_bswap16, "UsUs", "nc")
 BUILTIN(__builtin_bswap32, "UZiUZi", "nc")
 BUILTIN(__builtin_bswap64, "UWiUWi", "nc")
+BUILTIN(__builtin_bswap128, "ULLLiULLLi", "nc")
 
 BUILTIN(__builtin_bitreverse8, "UcUc", "nc")
 BUILTIN(__builtin_bitreverse16, "UsUs", "nc")
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -59,6 +59,8 @@
 - Maximum _ExtInt size was decreased from 16,777,215 bits to 8,388,608 bits.
   Motivation for this was discussed in PR51829.
 
+- The builtin ``__builtin_bswap128`` was added.
+
 New Compiler Flags
 --
 


Index: clang/test/CodeGen/builtins.cpp
===
--- clang/test/CodeGen/builtins.cpp
+++ clang/test/CodeGen/builtins.cpp
@@ -20,6 +20,10 @@
 decltype(__builtin_bswap32(0)) bswap32 = 42;
 extern uint64_t bswap64;
 decltype(__builtin_bswap64(0)) bswap64 = 42;
+#ifdef __SIZEOF_INT128__
+extern __uint128_t bswap128;
+decltype(__builtin_bswap128(0)) bswap128 = 42;
+#endif
 
 #ifdef __clang__
 extern uint8_t bitrev8;
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -2905,7 +2905,8 @@
   }
   case Builtin::BI__builtin_bswap16:
   case Builtin::BI__builtin_bswap32:
-  case Builtin::BI__builtin_bswap64: {
+  case Builtin::BI__builtin_bswap64:
+  case Builtin::BI__builtin_bswap128: {
 return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::bswap));
   }
   case Builtin::BI__builtin_bitreverse8:
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -11640,7 +11640,8 @@
 
   case Builtin::BI__builtin_bswap16:
   case Builtin::BI__builtin_bswap32:
-  case Builtin::BI__builtin_bswap64: {
+  case Builtin::BI__builtin_bswap64:
+  case Builtin::BI__builtin_bswap128: {
 APSInt Val;
 if (!EvaluateInteger(E->getArg(0), Val, Info))
   return false;
Index: clang/include/clang/Basic/Builtins.def
===
--- clang/include/clang/Basic/Builtins.def
+++ clang/include/clang/Basic/Builtins.def
@@ -512,6 +512,7 @@
 BUILTIN(__builtin_bswap16, "UsUs", "nc")
 BUILTIN(__builtin_bswap32, "UZiUZi", "nc")
 BUILTIN(__builtin_bswap64, "UWiUWi", "nc")
+BUILTIN(__builtin_bswap128, "ULLLiULLLi", "nc")
 
 BUILTIN(__builtin_bitreverse8, "UcUc", "nc")
 BUILTIN(__builtin_bitreverse16, "UsUs", "nc")
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -59,6 +59,8 @@
 - Maximum 

[PATCH] D114425: [clang] Add __builtin_bswap128

2021-12-19 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

Please update Release Notes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114425

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


[PATCH] D114425: [clang] Add __builtin_bswap128

2021-12-19 Thread Nikolas Klauser via Phabricator via cfe-commits
philnik added a comment.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114425

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