[clang] 936a67f - [clang-format] Extra spaces surrounding arrow in templated member call in variable decl

2021-12-18 Thread via cfe-commits

Author: mydeveloperday
Date: 2021-12-18T11:38:29Z
New Revision: 936a67f089efd31354cf1f1f3b864b81fb5aad0e

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

LOG: [clang-format] Extra spaces surrounding arrow in templated member call in 
variable decl

https://github.com/llvm/llvm-project/issues/43196

Fixes #43196

-> is incorrectly interpreted as a TrailingReturnArrow if we've seen an auto

```
auto p = new A;
auto x = p -> foo<1>();
```

Reviewed By: curdeius

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

Added: 


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

Removed: 




diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 6fc3a4d5d18ae..5809e4c40070e 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -1679,7 +1679,7 @@ class AnnotatingParser {
   Current.setType(TT_LambdaArrow);
 } else if (Current.is(tok::arrow) && AutoFound && Line.MustBeDeclaration &&
Current.NestingLevel == 0 &&
-   !Current.Previous->is(tok::kw_operator)) {
+   !Current.Previous->isOneOf(tok::kw_operator, tok::identifier)) {
   // not auto operator->() -> xxx;
   Current.setType(TT_TrailingReturnArrow);
 } else if (Current.is(tok::arrow) && Current.Previous &&

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 2b9a72e374144..c2a5fbb5c0d93 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -6780,6 +6780,9 @@ TEST_F(FormatTest, TrailingReturnType) {
 
   // Not trailing return types.
   verifyFormat("void f() { auto a = b->c(); }");
+  verifyFormat("auto a = p->foo();");
+  verifyFormat("int a = p->foo();");
+  verifyFormat("auto lmbd = [] NOEXCEPT -> int { return 0; };");
 }
 
 TEST_F(FormatTest, DeductionGuides) {



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


[PATCH] D115903: [clang-format] Extra spaces surrounding arrow in templated member call in variable decl

2021-12-18 Thread MyDeveloperDay 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 rG936a67f089ef: [clang-format] Extra spaces surrounding arrow 
in templated member call in… (authored by MyDeveloperDay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115903

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -6780,6 +6780,9 @@
 
   // Not trailing return types.
   verifyFormat("void f() { auto a = b->c(); }");
+  verifyFormat("auto a = p->foo();");
+  verifyFormat("int a = p->foo();");
+  verifyFormat("auto lmbd = [] NOEXCEPT -> int { return 0; };");
 }
 
 TEST_F(FormatTest, DeductionGuides) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1679,7 +1679,7 @@
   Current.setType(TT_LambdaArrow);
 } else if (Current.is(tok::arrow) && AutoFound && Line.MustBeDeclaration &&
Current.NestingLevel == 0 &&
-   !Current.Previous->is(tok::kw_operator)) {
+   !Current.Previous->isOneOf(tok::kw_operator, tok::identifier)) {
   // not auto operator->() -> xxx;
   Current.setType(TT_TrailingReturnArrow);
 } else if (Current.is(tok::arrow) && Current.Previous &&


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -6780,6 +6780,9 @@
 
   // Not trailing return types.
   verifyFormat("void f() { auto a = b->c(); }");
+  verifyFormat("auto a = p->foo();");
+  verifyFormat("int a = p->foo();");
+  verifyFormat("auto lmbd = [] NOEXCEPT -> int { return 0; };");
 }
 
 TEST_F(FormatTest, DeductionGuides) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1679,7 +1679,7 @@
   Current.setType(TT_LambdaArrow);
 } else if (Current.is(tok::arrow) && AutoFound && Line.MustBeDeclaration &&
Current.NestingLevel == 0 &&
-   !Current.Previous->is(tok::kw_operator)) {
+   !Current.Previous->isOneOf(tok::kw_operator, tok::identifier)) {
   // not auto operator->() -> xxx;
   Current.setType(TT_TrailingReturnArrow);
 } else if (Current.is(tok::arrow) && Current.Previous &&
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D114583: [clang-format] Adjust braced list detection

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

This is having an impact on code in flang, I don't deny it might be better, but 
it may not be what is wanted.

  -  explicit Expr(const Scalar &x) : u{Constant{x}} {}
  -  explicit Expr(Scalar &&x) : u{Constant{std::move(x)}} {}
  +  explicit Expr(const Scalar &x) : u {
  +Constant { x }
  +  }
  +  {}
  +  explicit Expr(Scalar &&x) : u {
  +Constant { std::move(x) }
  +  }
  +  {}


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114583

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


[PATCH] D115982: [clang][AVR] Implement '__flashN' for variables on different flash banks

2021-12-18 Thread Ben Shi via Phabricator via cfe-commits
benshi001 updated this revision to Diff 395284.

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

https://reviews.llvm.org/D115982

Files:
  clang/lib/Basic/Targets/AVR.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/address-space-avr.c
  clang/test/CodeGen/avr-flash.c
  clang/test/Sema/avr-flash.c

Index: clang/test/Sema/avr-flash.c
===
--- /dev/null
+++ clang/test/Sema/avr-flash.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 %s -triple avr -target-cpu atmega2560 -fsyntax-only -verify
+
+int foo(int n) {
+  static __flash3 const int b[] = {4, 6}; // OK
+  static __flash5 const int c[] = {8, 1}; // expected-error {{unknown type name '__flash5'}}
+  // TODO: It would be better to report "'__flash5' is not supported on atmega2560".
+  return b[n] + c[n];
+}
Index: clang/test/CodeGen/avr-flash.c
===
--- clang/test/CodeGen/avr-flash.c
+++ clang/test/CodeGen/avr-flash.c
@@ -1,6 +1,7 @@
-// RUN: %clang_cc1 -triple avr -emit-llvm-only -verify %s
+// RUN: %clang_cc1 -triple avr -target-cpu atxmega256c3 -emit-llvm-only -verify %s
 
 int foo(void) {
-  static __flash int b[] = {4, 6}; // expected-error {{qualifier 'const' is needed for variables in address space '__flash'}}
-  return b[0];
+  static __flash  int b[] = {4, 6}; // expected-error {{qualifier 'const' is needed for variables in address space '__flash*'}}
+  static __flash3 int c[] = {8, 1}; // expected-error {{qualifier 'const' is needed for variables in address space '__flash*'}}
+  return b[0] + c[1];
 }
Index: clang/test/CodeGen/address-space-avr.c
===
--- clang/test/CodeGen/address-space-avr.c
+++ clang/test/CodeGen/address-space-avr.c
@@ -1,8 +1,11 @@
-// RUN: %clang_cc1 -triple avr -emit-llvm < %s | FileCheck %s
+// RUN: %clang_cc1 -triple avr -target-cpu atmega2560 -emit-llvm < %s | FileCheck %s
 
 // CHECK: @var0 {{.*}} addrspace(1) constant [3 x i16]
+// CHECK: @f3var0 {{.*}} addrspace(4) constant [3 x i16]
 // CHECK: @bar.var2 {{.*}} addrspace(1) constant [3 x i16]
+// CHECK: @bar.f3var2 {{.*}} addrspace(4) constant [3 x i16]
 // CHECK: @var1 {{.*}} addrspace(1) constant [3 x i16]
+// CHECK: @f3var1 {{.*}} addrspace(4) constant [3 x i16]
 
 // CHECK: define{{.*}} void @bar() addrspace(1)
 // CHECK: call addrspace(1) void bitcast (void (...) addrspace(1)* @foo to void (i16) addrspace(1)*)
@@ -11,11 +14,16 @@
 __flash const int var0[] = {999, 888, 777};
 __flash static const int var1[] = {111, 222, 333};
 
+__flash3 const int f3var0[] = {12, 34, 56};
+__flash3 static const int f3var1[] = {52, 64, 96};
+
 int i;
 
 void foo();
 
 void bar() {
   static __flash const int var2[] = {555, 666, 777};
+  static __flash3 const int f3var2[] = {, , 7787};
   foo(var1[i]);
+  foo(f3var1[i]);
 }
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -8282,14 +8282,15 @@
 
   LangAS getGlobalVarAddressSpace(CodeGenModule &CGM,
   const VarDecl *D) const override {
-// Check if a global/static variable is defined within address space 1
+// Check if global/static variable is defined in address space
+// 1~6 (__flash, __flash1, __flash2, __flash3, __flash4, __flash5)
 // but not constant.
 LangAS AS = D->getType().getAddressSpace();
-if (isTargetAddressSpace(AS) && toTargetAddressSpace(AS) == 1 &&
-!D->getType().isConstQualified())
+if (isTargetAddressSpace(AS) && 1 <= toTargetAddressSpace(AS) &&
+toTargetAddressSpace(AS) <= 6 && !D->getType().isConstQualified())
   CGM.getDiags().Report(D->getLocation(),
 diag::err_verify_nonconst_addrspace)
-  << "__flash";
+  << "__flash*";
 return TargetCodeGenInfo::getGlobalVarAddressSpace(CGM, D);
   }
 
Index: clang/lib/Basic/Targets/AVR.cpp
===
--- clang/lib/Basic/Targets/AVR.cpp
+++ clang/lib/Basic/Targets/AVR.cpp
@@ -24,281 +24,282 @@
 struct LLVM_LIBRARY_VISIBILITY MCUInfo {
   const char *Name;
   const char *DefineName;
+  unsigned MaxFlashBank;
 };
 
 // This list should be kept up-to-date with AVRDevices.td in LLVM.
 static MCUInfo AVRMcus[] = {
-{"at90s1200", "__AVR_AT90S1200__"},
-{"attiny11", "__AVR_ATtiny11__"},
-{"attiny12", "__AVR_ATtiny12__"},
-{"attiny15", "__AVR_ATtiny15__"},
-{"attiny28", "__AVR_ATtiny28__"},
-{"at90s2313", "__AVR_AT90S2313__"},
-{"at90s2323", "__AVR_AT90S2323__"},
-{"at90s2333", "__AVR_AT90S2333__"},
-{"at90s2343", "__AVR_AT90S2343__"},
-{"attiny22", "__AVR_ATtiny22__"},
-{"attiny26", "__AVR_ATtiny26__"},
-{"at86rf401", "__AVR_AT86RF401__"},
-{"at90s4414", "__AVR_AT90S4414__"},
-{"at90s4433", "__AVR

[PATCH] D43002: [CodeView] Emit S_OBJNAME record

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

lgtm

Sorry for the delay, I got sick last week and read through email newest to 
oldest.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D43002

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


[PATCH] D115921: [RISCV] Refactor the RISCV ISA extension info and target features to support multiple extension version

2021-12-18 Thread Zixuan Wu via Phabricator via cfe-commits
zixuan-wu created this revision.
zixuan-wu added reviewers: asb, craig.topper, kito-cheng, luismarques, apazos, 
jrtc27, Jim, akuegel.
Herald added subscribers: VincentWu, luke957, achieveartificialintelligence, 
armkevincheng, eric-k256, vkmr, frasercrmck, jdoerfert, evandro, 
sameer.abuasal, s.egerton, benna, psnobl, jocewei, rupprecht, PkmX, arphaman, 
the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, niosHD, 
sabuasal, simoncook, johnrusso, rbar, hiraditya, emaste, qcolombet, MatzeB.
Herald added a reviewer: jhenderson.
Herald added a reviewer: MaskRay.
Herald added a reviewer: sjarus.
zixuan-wu requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

As RISC-V spec supports multiple extension version, refactor the 
SubtargetFeatures and RISCVISAInfo to support it.

RISCVISAInfo can parse arch string like -march with extension version, but 
related SubtargetFeatures don't contain version info in llvm side. For example, 
SubtargetFeature name is "m" when enable 'm' extension with passing 
`-mattr=+m`. After this patch, it would be `-mattr=+m2p0`.

It also handles arch string with version number of attribute section in obj 
file, including assemble and dis-assemble process.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D115921

Files:
  clang/include/clang/Basic/BuiltinsRISCV.def
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/test/CodeGen/RISCV/riscv-attr-builtin-alias-err.c
  clang/test/CodeGen/RISCV/riscv-attr-builtin-alias.c
  clang/test/CodeGen/RISCV/riscv-inline-asm-rvv.c
  clang/test/CodeGen/RISCV/riscv-v-debuginfo.c
  clang/test/CodeGen/RISCV/riscv-v-lifetime.cpp
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb-error.c
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbc.c
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbe.c
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbp.c
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbr.c
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbc.c
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbe.c
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbp.c
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbr.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vaadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vadc.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vand.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vasub.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vcompress.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vcpop.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vdiv.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfabs.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfclass.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfcvt.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfdiv.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfirst.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfmacc.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfmadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfmax.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfmerge.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfmin.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfmsac.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfmsub.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfmul.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfmv.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfncvt.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfneg.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfnmacc.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfnmadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfnmsac.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfnmsub.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfrdiv.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfrec7.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfredmax.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfredmin.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfredsum.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfrsqrt7.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfrsub.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfsgnj.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfslide1down.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfslide1up.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfsqrt.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfsub.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfwadd.c
  clang/test/CodeGen/RI

[clang] 3362fa5 - [clang-format] extern with new line brace without indentation

2021-12-18 Thread via cfe-commits

Author: mydeveloperday
Date: 2021-12-18T14:10:14Z
New Revision: 3362fa59ec406ba1eebe9e9ee59a04b675ef2439

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

LOG: [clang-format] extern with new line brace without indentation

https://github.com/llvm/llvm-project/issues/49804

Interaction between IndentExternBlock and AfterExternBlock means you cannot 
have AfterExternBlock = true and IndentExternBlock = NoIndent/Indent

This patch resolves that
```
BraceWrapping:
  AfterExternBlock: true
IndentExternBlock: AfterExternBlock
```
Fixes: #49804

Reviewed By: HazardyKnusperkeks, curdeius, owenpan

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

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 9ea0db8124863..856efbd91cb01 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -1279,17 +1279,18 @@ void UnwrappedLineParser::parseStructuralElement(bool 
IsTopLevel) {
 if (FormatTok->Tok.is(tok::string_literal)) {
   nextToken();
   if (FormatTok->Tok.is(tok::l_brace)) {
-if (!Style.IndentExternBlock) {
-  if (Style.BraceWrapping.AfterExternBlock) {
-addUnwrappedLine();
-  }
-  unsigned AddLevels = Style.BraceWrapping.AfterExternBlock ? 1u : 0u;
-  parseBlock(/*MustBeDeclaration=*/true, AddLevels);
-} else {
-  unsigned AddLevels =
-  Style.IndentExternBlock == FormatStyle::IEBS_Indent ? 1u : 0u;
-  parseBlock(/*MustBeDeclaration=*/true, AddLevels);
-}
+if (Style.BraceWrapping.AfterExternBlock)
+  addUnwrappedLine();
+// Either we indent or for backwards compatibility we follow the
+// AfterExternBlock style.
+unsigned AddLevels =
+(Style.IndentExternBlock == FormatStyle::IEBS_Indent) ||
+(Style.BraceWrapping.AfterExternBlock &&
+ Style.IndentExternBlock ==
+ FormatStyle::IEBS_AfterExternBlock)
+? 1u
+: 0u;
+parseBlock(/*MustBeDeclaration=*/true, AddLevels);
 addUnwrappedLine();
 return;
   }

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index c2a5fbb5c0d93..2a9de85bf453b 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -3835,36 +3835,66 @@ TEST_F(FormatTest, IndentExternBlockStyle) {
   Style.IndentWidth = 2;
 
   Style.IndentExternBlock = FormatStyle::IEBS_Indent;
-  verifyFormat("extern \"C\" { /*9*/\n}", Style);
+  verifyFormat("extern \"C\" { /*9*/\n"
+   "}",
+   Style);
   verifyFormat("extern \"C\" {\n"
"  int foo10();\n"
"}",
Style);
 
   Style.IndentExternBlock = FormatStyle::IEBS_NoIndent;
-  verifyFormat("extern \"C\" { /*11*/\n}", Style);
+  verifyFormat("extern \"C\" { /*11*/\n"
+   "}",
+   Style);
   verifyFormat("extern \"C\" {\n"
"int foo12();\n"
"}",
Style);
 
-  Style.IndentExternBlock = FormatStyle::IEBS_AfterExternBlock;
   Style.BreakBeforeBraces = FormatStyle::BS_Custom;
   Style.BraceWrapping.AfterExternBlock = true;
-  verifyFormat("extern \"C\"\n{ /*13*/\n}", Style);
+  Style.IndentExternBlock = FormatStyle::IEBS_Indent;
+  verifyFormat("extern \"C\"\n"
+   "{ /*13*/\n"
+   "}",
+   Style);
   verifyFormat("extern \"C\"\n{\n"
"  int foo14();\n"
"}",
Style);
 
-  Style.IndentExternBlock = FormatStyle::IEBS_AfterExternBlock;
-  Style.BreakBeforeBraces = FormatStyle::BS_Custom;
   Style.BraceWrapping.AfterExternBlock = false;
-  verifyFormat("extern \"C\" { /*15*/\n}", Style);
+  Style.IndentExternBlock = FormatStyle::IEBS_NoIndent;
+  verifyFormat("extern \"C\" { /*15*/\n"
+   "}",
+   Style);
   verifyFormat("extern \"C\" {\n"
"int foo16();\n"
"}",
Style);
+
+  Style.BraceWrapping.AfterExternBlock = true;
+  verifyFormat("extern \"C\"\n"
+   "{ /*13*/\n"
+   "}",
+   Style);
+  verifyFormat("extern \"C\"\n"
+   "{\n"
+   "int foo14();\n"
+   "}",
+   Style);
+
+  Style.IndentExternBlock = FormatStyle::IEBS_Indent;
+  verifyFormat("extern \"C\"\n"
+   "{ /*13*/\n"
+   "}",
+   Style);
+  verifyFormat("extern \"C\"\n"
+   "{\n"
+

[PATCH] D115879: [clang-format] extern with new line brace without indentation

2021-12-18 Thread MyDeveloperDay 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 rG3362fa59ec40: [clang-format] extern with new line brace 
without indentation (authored by MyDeveloperDay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115879

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
@@ -3835,36 +3835,66 @@
   Style.IndentWidth = 2;
 
   Style.IndentExternBlock = FormatStyle::IEBS_Indent;
-  verifyFormat("extern \"C\" { /*9*/\n}", Style);
+  verifyFormat("extern \"C\" { /*9*/\n"
+   "}",
+   Style);
   verifyFormat("extern \"C\" {\n"
"  int foo10();\n"
"}",
Style);
 
   Style.IndentExternBlock = FormatStyle::IEBS_NoIndent;
-  verifyFormat("extern \"C\" { /*11*/\n}", Style);
+  verifyFormat("extern \"C\" { /*11*/\n"
+   "}",
+   Style);
   verifyFormat("extern \"C\" {\n"
"int foo12();\n"
"}",
Style);
 
-  Style.IndentExternBlock = FormatStyle::IEBS_AfterExternBlock;
   Style.BreakBeforeBraces = FormatStyle::BS_Custom;
   Style.BraceWrapping.AfterExternBlock = true;
-  verifyFormat("extern \"C\"\n{ /*13*/\n}", Style);
+  Style.IndentExternBlock = FormatStyle::IEBS_Indent;
+  verifyFormat("extern \"C\"\n"
+   "{ /*13*/\n"
+   "}",
+   Style);
   verifyFormat("extern \"C\"\n{\n"
"  int foo14();\n"
"}",
Style);
 
-  Style.IndentExternBlock = FormatStyle::IEBS_AfterExternBlock;
-  Style.BreakBeforeBraces = FormatStyle::BS_Custom;
   Style.BraceWrapping.AfterExternBlock = false;
-  verifyFormat("extern \"C\" { /*15*/\n}", Style);
+  Style.IndentExternBlock = FormatStyle::IEBS_NoIndent;
+  verifyFormat("extern \"C\" { /*15*/\n"
+   "}",
+   Style);
   verifyFormat("extern \"C\" {\n"
"int foo16();\n"
"}",
Style);
+
+  Style.BraceWrapping.AfterExternBlock = true;
+  verifyFormat("extern \"C\"\n"
+   "{ /*13*/\n"
+   "}",
+   Style);
+  verifyFormat("extern \"C\"\n"
+   "{\n"
+   "int foo14();\n"
+   "}",
+   Style);
+
+  Style.IndentExternBlock = FormatStyle::IEBS_Indent;
+  verifyFormat("extern \"C\"\n"
+   "{ /*13*/\n"
+   "}",
+   Style);
+  verifyFormat("extern \"C\"\n"
+   "{\n"
+   "  int foo14();\n"
+   "}",
+   Style);
 }
 
 TEST_F(FormatTest, FormatsInlineASM) {
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1279,17 +1279,18 @@
 if (FormatTok->Tok.is(tok::string_literal)) {
   nextToken();
   if (FormatTok->Tok.is(tok::l_brace)) {
-if (!Style.IndentExternBlock) {
-  if (Style.BraceWrapping.AfterExternBlock) {
-addUnwrappedLine();
-  }
-  unsigned AddLevels = Style.BraceWrapping.AfterExternBlock ? 1u : 0u;
-  parseBlock(/*MustBeDeclaration=*/true, AddLevels);
-} else {
-  unsigned AddLevels =
-  Style.IndentExternBlock == FormatStyle::IEBS_Indent ? 1u : 0u;
-  parseBlock(/*MustBeDeclaration=*/true, AddLevels);
-}
+if (Style.BraceWrapping.AfterExternBlock)
+  addUnwrappedLine();
+// Either we indent or for backwards compatibility we follow the
+// AfterExternBlock style.
+unsigned AddLevels =
+(Style.IndentExternBlock == FormatStyle::IEBS_Indent) ||
+(Style.BraceWrapping.AfterExternBlock &&
+ Style.IndentExternBlock ==
+ FormatStyle::IEBS_AfterExternBlock)
+? 1u
+: 0u;
+parseBlock(/*MustBeDeclaration=*/true, AddLevels);
 addUnwrappedLine();
 return;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D115921: [RISCV] Refactor the RISCV ISA extension info and target features to support multiple extension version

2021-12-18 Thread Luís Marques via Phabricator via cfe-commits
luismarques added a comment.

> enable 'm' extension with passing mattr=+m After this patch, it would be 
> -mattr=+m2p0.

It's not obvious to me that support for extension versions should mean or has 
to mean that we always explicitly specify the version. Why can't we keep 
supporting the option `mattr=+m`, which would be mapped to `mattr=+m,+m2p0`, or 
whatever the current default `m` version happens to be?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115921

___
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-18 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay created this revision.
MyDeveloperDay added reviewers: krasimir, owenpan, HazardyKnusperkeks, curdeius.
MyDeveloperDay added projects: clang, clang-format.
MyDeveloperDay requested review of this revision.

https://github.com/llvm/llvm-project/issues/49846

Fixes #49846


Repository:
  rG LLVM Github Monorepo

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,41 @@
   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);
+}
+
 } // namespace format
 } // end namespace clang
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1826,14 +1826,18 @@
 if (Tok.Previous->isOneOf(TT_LeadingJavaAnnotation, Keywords.kw_instanceof,
   Keywords.kw_as))
   return false;
-if (Style.Language == FormatStyle::LK_JavaScript &&
+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 = PreviousNotConst->getPreviousNonComment();
+
+// For javascript const can be like "let" or "var"
+if (!Style.isJavaScript()){
+  while (PreviousNotConst && PreviousNotConst->is(tok::kw_const))
+PreviousNotConst = PreviousNotConst->getPreviousNonComment();
+}
 
 if (!PreviousNotConst)
   return false;
@@ -1852,10 +1856,28 @@
 PreviousNotConst->is(TT_TypeDeclarationParen))
   return true;
 
-return (!IsPPKeyword &&
-PreviousNotConst->isOneOf(tok::identifier, tok::kw_auto)) ||
-   PreviousNotConst->is(TT_PointerOrReference) ||
-   PreviousNotConst->isSimpleTypeSpecifier();
+// If is a preprocess keyword like #define.
+if (IsPPKeyword)
+  return false;
+
+// int a or auto a.
+if (PreviousNotConst->isOneOf(tok::identifier, tok::kw_auto))
+  return true;
+
+// *a or &a or &&a.
+if (PreviousNotConst->is(TT_PointerOrReference))
+   return true;
+
+// MyClass a;
+if (PreviousNotConst->isSimpleTypeSpecifier())
+return true;
+
+// const a = in JavaScript.
+if (Style.isJavaScript() && PreviousNotConst->is(tok::kw_const))
+  return true;
+
+// Not a StartOfName.
+return false;
   }
 
   /// Determine whether ')' is ending a cast.
Index: clang/include/clang/Format/Format.h
===
--- clang/include/clang/Format/Format.h
+++ clang/include/clang/Format/Format.h
@@ -2669,6 +2669,7 @@
   bool isCpp() const { return Language == LK_Cpp || Language == LK_ObjC; }
   bool isCSharp() const { return Language == LK_CSharp; }
   bool isJson() const { return Language == LK_Json; }
+  bool isJavaScript() const { return Language == LK_JavaScript; }
 
   /// Language, this format style is targeted at.
   /// \version 3.5
___
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-18 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay updated this revision to Diff 395291.
MyDeveloperDay added a comment.

Double check the interaction with the AlignConsecutiveAssignments


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,18 @@
 if (Tok.Previous->isOneOf(TT_LeadingJavaAnnotation, Keywords.kw_instanceof,
   Keywords.kw_as))
   return false;
-if (Style.Language == FormatStyle::LK_JavaScript &&
+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 = PreviousNotConst->getPre

[PATCH] D115924: [ConstantFolding] Unify handling of load from uniform value

2021-12-18 Thread Paul Walker via Phabricator via cfe-commits
paulwalker-arm added a comment.

This patch looks to be breaking the clang-aarch64-sve-vla-2stage buildbot (and 
probably also clang-aarch64-sve-vls-2stage). I've checked this using 
`./bin/clang -DNDEBUG -O3 -w -Werror=date-time -w pr19687.c && ./a.out && echo 
"success"`, which works before this patch but triggers an abort after. This 
happen for both AArch64 and X86.

See https://lab.llvm.org/buildbot/#/builders/198 and 
https://lab.llvm.org/buildbot/#/builders/176/builds/1231.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115924

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


[clang] aeb36ae - Revert "[ConstantFolding] Unify handling of load from uniform value"

2021-12-18 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2021-12-18T20:46:52+01:00
New Revision: aeb36ae0f4cbc5fb1d01921d89a80d62ccc2f058

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

LOG: Revert "[ConstantFolding] Unify handling of load from uniform value"

This reverts commit 9fd4f80e33a4ae4567483819646650f5735286e2.

This breaks SingleSource/Regression/C/gcc-c-torture/execute/pr19687.c
in test-suite. Either the test is incorrect, or clang is generating
incorrect union initialization code. I've submitted
https://reviews.llvm.org/D115994 to fix the test, assuming my
interpretation is correct. Reverting this in the meantime as it
may take some time to resolve.

Added: 


Modified: 
clang/test/CodeGen/aapcs-align.cpp
llvm/include/llvm/Analysis/ConstantFolding.h
llvm/lib/Analysis/ConstantFolding.cpp
llvm/lib/Transforms/IPO/GlobalOpt.cpp
llvm/test/Transforms/InstSimplify/ConstProp/loads.ll

Removed: 
llvm/test/Transforms/GlobalOpt/x86_mmx_load.ll



diff  --git a/clang/test/CodeGen/aapcs-align.cpp 
b/clang/test/CodeGen/aapcs-align.cpp
index 8543081caf233..8950908183efc 100644
--- a/clang/test/CodeGen/aapcs-align.cpp
+++ b/clang/test/CodeGen/aapcs-align.cpp
@@ -134,8 +134,8 @@ void g6() {
   f6m(1, 2, 3, 4, 5, s);
 }
 // CHECK: define{{.*}} void @g6
-// CHECK: call void @f6(i32 1, [4 x i32] [i32 6, i32 7, i32 0, i32 undef])
-// CHECK: call void @f6m(i32 1, i32 2, i32 3, i32 4, i32 5, [4 x i32] [i32 6, 
i32 7, i32 0, i32 undef])
+// CHECK: call void @f6(i32 1, [4 x i32] [i32 6, i32 7, i32 0, i32 0])
+// CHECK: call void @f6m(i32 1, i32 2, i32 3, i32 4, i32 5, [4 x i32] [i32 6, 
i32 7, i32 0, i32 0])
 // CHECK: declare void @f6(i32, [4 x i32])
 // CHECK: declare void @f6m(i32, i32, i32, i32, i32, [4 x i32])
 }

diff  --git a/llvm/include/llvm/Analysis/ConstantFolding.h 
b/llvm/include/llvm/Analysis/ConstantFolding.h
index 3b3a1785d7baa..45fb879f0c1f1 100644
--- a/llvm/include/llvm/Analysis/ConstantFolding.h
+++ b/llvm/include/llvm/Analysis/ConstantFolding.h
@@ -148,12 +148,6 @@ Constant *ConstantFoldLoadFromConstPtr(Constant *C, Type 
*Ty, APInt Offset,
 Constant *ConstantFoldLoadFromConstPtr(Constant *C, Type *Ty,
const DataLayout &DL);
 
-/// If C is a uniform value where all bits are the same (either all zero, all
-/// ones, all undef or all poison), return the corresponding uniform value in
-/// the new type. If the value is not uniform or the result cannot be
-/// represented, return null.
-Constant *ConstantFoldLoadFromUniformValue(Constant *C, Type *Ty);
-
 /// ConstantFoldLoadThroughGEPConstantExpr - Given a constant and a
 /// getelementptr constantexpr, return the constant value being addressed by 
the
 /// constant expression, or null if something is funny and we can't decide.

diff  --git a/llvm/lib/Analysis/ConstantFolding.cpp 
b/llvm/lib/Analysis/ConstantFolding.cpp
index 3fc24d82f8681..fcf4be4a538bc 100644
--- a/llvm/lib/Analysis/ConstantFolding.cpp
+++ b/llvm/lib/Analysis/ConstantFolding.cpp
@@ -106,8 +106,11 @@ Constant *FoldBitCast(Constant *C, Type *DestTy, const 
DataLayout &DL) {
  "Invalid constantexpr bitcast!");
 
   // Catch the obvious splat cases.
-  if (Constant *Res = ConstantFoldLoadFromUniformValue(C, DestTy))
-return Res;
+  if (C->isNullValue() && !DestTy->isX86_MMXTy() && !DestTy->isX86_AMXTy())
+return Constant::getNullValue(DestTy);
+  if (C->isAllOnesValue() && !DestTy->isX86_MMXTy() && !DestTy->isX86_AMXTy() 
&&
+  !DestTy->isPtrOrPtrVectorTy()) // Don't get ones for ptr types!
+return Constant::getAllOnesValue(DestTy);
 
   if (auto *VTy = dyn_cast(C->getType())) {
 // Handle a vector->scalar integer/fp cast.
@@ -359,8 +362,16 @@ Constant *llvm::ConstantFoldLoadThroughBitcast(Constant 
*C, Type *DestTy,
 
 // Catch the obvious splat cases (since all-zeros can coerce non-integral
 // pointers legally).
-if (Constant *Res = ConstantFoldLoadFromUniformValue(C, DestTy))
-  return Res;
+if (C->isNullValue() && !DestTy->isX86_MMXTy() && !DestTy->isX86_AMXTy())
+  return Constant::getNullValue(DestTy);
+if (C->isAllOnesValue() &&
+(DestTy->isIntegerTy() || DestTy->isFloatingPointTy() ||
+ DestTy->isVectorTy()) &&
+!DestTy->isX86_AMXTy() && !DestTy->isX86_MMXTy() &&
+!DestTy->isPtrOrPtrVectorTy())
+  // Get ones when the input is trivial, but
+  // only for supported types inside getAllOnesValue.
+  return Constant::getAllOnesValue(DestTy);
 
 // If the type sizes are the same and a cast is legal, just directly
 // cast the constant.
@@ -693,13 +704,16 @@ Constant *llvm::ConstantFoldLoadFromConstPtr(Constant *C, 
Type *Ty,
Offset, DL))
 return Result;
 
-

[PATCH] D115924: [ConstantFolding] Unify handling of load from uniform value

2021-12-18 Thread Nikita Popov via Phabricator via cfe-commits
nikic added a comment.

@paulwalker-arm Thanks for the report, I've reverted the commit for now. I've 
put up D115994  to either fix the test or be 
told that clang generates incorrect initialization code, I'm not completely 
sure which it is.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115924

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


[clang] 56b2b1b - [NFC][Clang] Remove trailing spaces in `clang/include/clang/Driver/Options.td`

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

Author: Shilei Tian
Date: 2021-12-18T21:32:49-05:00
New Revision: 56b2b1b8fd618775222d589100bad7584d392dcd

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

LOG: [NFC][Clang] Remove trailing spaces in 
`clang/include/clang/Driver/Options.td`

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 9e0832822a0dd..980b563ea023e 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2436,13 +2436,13 @@ def fopenmp_target_debug : Flag<["-"], 
"fopenmp-target-debug">, Group,
   HelpText<"Enable debugging in the OpenMP offloading device RTL">;
 def fno_openmp_target_debug : Flag<["-"], "fno-openmp-target-debug">, 
Group, Flags<[NoArgumentUnused]>;
 def fopenmp_target_debug_EQ : Joined<["-"], "fopenmp-target-debug=">, 
Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
-def fopenmp_assume_teams_oversubscription : Flag<["-"], 
"fopenmp-assume-teams-oversubscription">, 
+def fopenmp_assume_teams_oversubscription : Flag<["-"], 
"fopenmp-assume-teams-oversubscription">,
   Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
-def fopenmp_assume_threads_oversubscription : Flag<["-"], 
"fopenmp-assume-threads-oversubscription">, 
+def fopenmp_assume_threads_oversubscription : Flag<["-"], 
"fopenmp-assume-threads-oversubscription">,
   Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
-def fno_openmp_assume_teams_oversubscription : Flag<["-"], 
"fno-openmp-assume-teams-oversubscription">, 
+def fno_openmp_assume_teams_oversubscription : Flag<["-"], 
"fno-openmp-assume-teams-oversubscription">,
   Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
-def fno_openmp_assume_threads_oversubscription : Flag<["-"], 
"fno-openmp-assume-threads-oversubscription">, 
+def fno_openmp_assume_threads_oversubscription : Flag<["-"], 
"fno-openmp-assume-threads-oversubscription">,
   Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
 defm openmp_target_new_runtime: BoolFOption<"openmp-target-new-runtime",
   LangOpts<"OpenMPTargetNewRuntime">, DefaultTrue,



___
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-18 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 created this revision.
Herald added subscribers: dang, guansong, yaxunl.
tianshilei1992 requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

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.


Repository:
  rG LLVM Github Monorepo

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,
   PosFlag;
 def fno_openmp_target_debug : Flag<["-"], "fno-openmp-target-debug">, 
Group, Flags<[NoArgumentUnused]>;
 def fopenmp_target_debug_EQ : Joined<["-"], "fopenmp-target-debug=">, 
Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
-def fopenmp_assume_teams_oversubscription : Flag<["-"], 
"fopenmp-assume-teams-oversubscription">, 
+def fopenmp_assume_teams_oversubscription : Flag<["-"], 
"fopenmp-assume-teams-oversubscription">,
   Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
-def fopenmp_assume_threads_oversubscription : Flag<["-"], 
"fopenmp-assume-threads-oversubscription">, 
+def fopenmp_assume_threads_oversubscription : Flag<["-"], 
"fopenmp-assume-threads-oversubscription">,
   Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
-def fno_openmp_assume_teams_oversubscription : Flag<["-"], 
"fno-openmp-assume-teams-oversubscription">, 
+def fno_openmp_assume_teams_oversubscription : Flag<["-"], 
"fno-openmp-assume-teams-oversubscription">,
   Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
-def fno_openmp_assume_threads_oversubscription : Flag<["-"], 
"fno-openmp-assume-threads-oversubscription">, 
+def fno_openmp_assume_threads_oversubscription : Flag<["-"], 
"fno-openmp-assume-threads-oversubscription">,
   Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
 defm openmp_target_new_runtime: BoolFOption<"openmp-target-new-runtime",
   LangOpts<"OpenMPTargetNewRuntime">, DefaultTrue,


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,
   PosFlag;
 def fno_openmp_target_debug : Flag<["-"], "fno-openmp-target-debug">, Group, Flags<[NoArgumentUnused]>;
 def fopenmp_target_debug_EQ : Joined<["-"], "fopenmp-target-debug=">, Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
-def fopenmp_assume_teams_oversubscription : Flag<["-"], "fopenmp-assume-teams-oversubscription">, 
+def fopenmp_assume_teams_oversubscription : Flag<["-"], "fopenmp-assume-teams-oversubscription">,
   Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
-def fopenmp_assume_threads_oversubscription : Flag<["-"], "fopenmp-assume-threads-oversubscription">, 
+def fopenmp_assume_threads_oversubscription : Flag<["-"], "fopenmp-assume-threads-oversubscription">,
   Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
-def fno_openmp_assume_teams_oversubscription : Flag<["-"], "fno-openmp-assume-teams-oversubscription">, 
+def fno_openmp_assume_teams_oversubscription : Flag<["-"], "fno-openmp-assume-teams-oversubscription">,
   Group, Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
-def fno_openmp_assume_threads_oversubsc

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

2021-12-18 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 updated this revision to Diff 395313.
tianshilei1992 added a comment.

rebase


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


[PATCH] D115979: [InstrProf] Don't profile merge by default in lightweight mode

2021-12-18 Thread Kyungwoo Lee via Phabricator via cfe-commits
kyulee added a comment.

For clarification, the lightweight pgo does not support merging raw data from 
memory (at runtime) due to missing structural data, but it does support merging 
raw files offline.
Would you update the comment or error message?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115979

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


[PATCH] D14484: [clang-format] Formatting constructor initializer lists by putting them always on different lines

2021-12-18 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

See D108752 .


Repository:
  rL LLVM

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

https://reviews.llvm.org/D14484

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


[PATCH] D90232: [clang-format] Formatting constructor initializer lists by putting them always on different lines (update to D14484)

2021-12-18 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

See D108752 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90232

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