[PATCH] D150253: [RISCV] Add Zvfhmin extension.

2023-05-15 Thread Jianjian Guan via Phabricator via cfe-commits
jacquesguan added a comment.

In D150253#4343699 , @craig.topper 
wrote:

> In D150253#4341545 , @jacquesguan 
> wrote:
>
>> To enable specific EEW for specific insturction in instruction selection, I 
>> will create some parent revisions. Here is the first one. 
>> https://reviews.llvm.org/D150550
>
> @michaelmaitland was also going to be working on supporting Zvfhmin for 
> SiFive. Maybe we can split up and share some of the work?

Yes, in order to avoid duplicate work.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150253

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


[PATCH] D150114: [Headers][doc] Add "add/sub/mul" intrinsic descriptions to avx2intrin.h

2023-05-15 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei added inline comments.



Comment at: clang/lib/Headers/avx2intrin.h:1043
+///corresponding byte of the 256-bit integer vector result (overflow is
+///ignored). For each byte, computes  result = __a - __b .
+///

It better to move it to `\code{.operation}` for consistency. Same for the below.


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

https://reviews.llvm.org/D150114

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


[PATCH] D150221: Add option -fkeep-static-variables to emit all static variables

2023-05-15 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment.

In D150221#4343546 , @efriedma wrote:

> It's not unprecedented to add flags to copy the behavior of other compilers, 
> to make porting easier, especially when it doesn't place much burden on 
> compiler maintainers.  But what compiler preserves the names/values of static 
> variables by default?  It's not the sort of feature I'd expect anyone to 
> advertise.  And we don't really want to encourage people to use global flags 
> for this sort of thing; applying behavior everywhere has weird effects, and 
> users often don't understand the flags they're using.

This is an adaptation of the IBM XL compiler's `-qstatsym` option, which is 
meant to generate symbol table entries for static variables. An artifact of 
that compiler is that static variables are often not discarded even when 
unused. We attempt to achieve the combined effect using 
`-fkeep-static-variables`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150221

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


[PATCH] D150635: [clangd] Implement end-definition-comment inlay hints

2023-05-15 Thread Qingyuan Zheng via Phabricator via cfe-commits
daiyousei-qz added a comment.

Requesting for some advice




Comment at: clang-tools-extra/clangd/unittests/InlayHintTests.cpp:1666
+
+$anon[[struct {
+  int x;

This is unwanted behavior from my understanding. Do you guys have any insight 
how we could fix this? What I can think of is tracking if we are currently 
inside a variable declaration and turning off the hint. However, this would 
have some side effects on
```
auto f = [] {
   struct S {};
};
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150635

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


[PATCH] D150635: [clangd] Implement end-definition-comment inlay hints

2023-05-15 Thread Qingyuan Zheng via Phabricator via cfe-commits
daiyousei-qz updated this revision to Diff 522434.
daiyousei-qz added a comment.

minor naming fix2 (last fix breaks builds)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150635

Files:
  clang-tools-extra/clangd/Config.h
  clang-tools-extra/clangd/ConfigCompile.cpp
  clang-tools-extra/clangd/ConfigFragment.h
  clang-tools-extra/clangd/ConfigYAML.cpp
  clang-tools-extra/clangd/InlayHints.cpp
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
  clang-tools-extra/clangd/unittests/InlayHintTests.cpp

Index: clang-tools-extra/clangd/unittests/InlayHintTests.cpp
===
--- clang-tools-extra/clangd/unittests/InlayHintTests.cpp
+++ clang-tools-extra/clangd/unittests/InlayHintTests.cpp
@@ -77,6 +77,7 @@
   C.InlayHints.Parameters = false;
   C.InlayHints.DeducedTypes = false;
   C.InlayHints.Designators = false;
+  C.InlayHints.EndDefinitionComments = false;
   return C;
 }
 
@@ -122,6 +123,17 @@
   assertHints(InlayHintKind::Designator, AnnotatedSource, Expected...);
 }
 
+template 
+void assertEndDefinitionHints(llvm::StringRef AnnotatedSource,
+  uint32_t MinLines, ExpectedHints... Expected) {
+  Config Cfg;
+  Cfg.InlayHints.EndDefinitionComments = true;
+  Cfg.InlayHints.EndDefinitionCommentMinLines = MinLines;
+  WithContextValue WithCfg(Config::Key, std::move(Cfg));
+  assertHints(InlayHintKind::EndDefinitionComment, AnnotatedSource,
+  Expected...);
+}
+
 TEST(ParameterHints, Smoke) {
   assertParameterHints(R"cpp(
 void foo(int param);
@@ -1550,6 +1562,165 @@
   ExpectedHint{"a: ", "param1"}, ExpectedHint{"b: ", "param2"},
   ExpectedHint{"c: ", "param3"});
 }
+
+TEST(EndDefinitionHints, Functions) {
+  assertEndDefinitionHints(R"cpp(
+$foo[[int foo() {
+  return 41;
+}]]
+$bar[[int bar() {}]]
+
+// No hint because this isn't a definition
+int buz();
+  )cpp",
+   0, ExpectedHint{" /* foo */ ", "foo"},
+   ExpectedHint{" /* bar */ ", "bar"});
+}
+
+TEST(EndDefinitionHints, Methods) {
+  assertEndDefinitionHints(R"cpp(
+class Test {
+public:
+  $ctor[[Test() = default]];
+  $dtor[[~Test() {
+  }]]
+
+  $method[[void method() {}]]
+
+  // No hint because this isn't a definition
+  void method2();
+} x;
+  )cpp",
+   0, ExpectedHint{" /* Test */ ", "ctor"},
+   ExpectedHint{" /* ~Test */ ", "dtor"},
+   ExpectedHint{" /* method */ ", "method"});
+}
+
+TEST(EndDefinitionHints, OverloadedOperators) {
+  assertEndDefinitionHints(R"cpp(
+struct S {
+  $opAdd[[S operator+(int) const {
+return *this;
+  }]]
+
+  $opBool[[operator bool() const {
+return true;
+  }]]
+
+  $opInt[[operator int() const = delete]];
+
+  // No hint because this isn't a definition
+  operator float() const;
+} x;
+  )cpp",
+   0, ExpectedHint{" /* operator+ */ ", "opAdd"},
+   ExpectedHint{" /* operator bool */ ", "opBool"},
+   ExpectedHint{" /* operator int */ ", "opInt"});
+}
+
+TEST(EndDefinitionHints, Namespaces) {
+  assertEndDefinitionHints(
+  R"cpp(
+$anon[[namespace {
+}]]
+
+$ns[[namespace ns {
+  void foo();
+}]]
+  )cpp",
+  0, ExpectedHint{" /* namespace  */ ", "anon"},
+  ExpectedHint{" /* namespace ns */ ", "ns"});
+}
+
+TEST(EndDefinitionHints, Types) {
+  assertEndDefinitionHints(R"cpp(
+$S[[struct S {
+}]];
+
+$C[[class C {
+}]];
+
+$U[[union U {
+}]];
+
+$E1[[enum E1 {
+}]];
+
+$E2[[enum class E2 {
+}]];
+  )cpp",
+   0, ExpectedHint{" /* struct S */ ", "S"},
+   ExpectedHint{" /* class C */ ", "C"},
+   ExpectedHint{" /* union U */ ", "U"},
+   ExpectedHint{" /* enum E1 */ ", "E1"},
+   ExpectedHint{" /* enum class E2 */ ", "E2"});
+}
+
+TEST(EndDefinitionHints, BundledTypeVariableDecl) {
+  assertEndDefinitionHints(
+  R"cpp(
+struct {
+  int x;
+} s;
+
+$anon[[struct {
+  int x;
+}]]
+
+s2;
+  )cpp",
+  0, ExpectedHint{" /* struct  */ ", "anon"});
+}
+
+TEST(EndDefinitionHints, TrailingSemicolon) {
+  assertEndDefinitionHints(R"cpp(
+$S1[[struct S1 {
+}]];
+
+$S2[[struct S2 {
+}]]
+
+;
+
+$S3[[struct S3 {
+}]] ;; ;;
+  )cpp",
+   0, ExpectedHint{" /* struct S1 */ ", "S1"},
+   ExpectedHint{" /* struct S2 */ ", "S2"},
+   ExpectedHint{" /* struct S3 */ ", "S3"});
+}
+
+TEST(EndDefinitionHints, TrailingText) {
+  

[PATCH] D150635: [clangd] Implement end-definition-comment inlay hints

2023-05-15 Thread Qingyuan Zheng via Phabricator via cfe-commits
daiyousei-qz updated this revision to Diff 522432.
daiyousei-qz edited the summary of this revision.
daiyousei-qz added a comment.

minor naming fix


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150635

Files:
  clang-tools-extra/clangd/Config.h
  clang-tools-extra/clangd/ConfigCompile.cpp
  clang-tools-extra/clangd/ConfigFragment.h
  clang-tools-extra/clangd/ConfigYAML.cpp
  clang-tools-extra/clangd/InlayHints.cpp
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
  clang-tools-extra/clangd/unittests/InlayHintTests.cpp

Index: clang-tools-extra/clangd/unittests/InlayHintTests.cpp
===
--- clang-tools-extra/clangd/unittests/InlayHintTests.cpp
+++ clang-tools-extra/clangd/unittests/InlayHintTests.cpp
@@ -77,6 +77,7 @@
   C.InlayHints.Parameters = false;
   C.InlayHints.DeducedTypes = false;
   C.InlayHints.Designators = false;
+  C.InlayHints.EndDefinitionComments = false;
   return C;
 }
 
@@ -122,6 +123,17 @@
   assertHints(InlayHintKind::Designator, AnnotatedSource, Expected...);
 }
 
+template 
+void assertEndDefinitionHints(llvm::StringRef AnnotatedSource,
+  uint32_t MinLines, ExpectedHints... Expected) {
+  Config Cfg;
+  Cfg.InlayHints.EndDefinitionComments = true;
+  Cfg.InlayHints.EndDefinitionCommentMinLines = MinLines;
+  WithContextValue WithCfg(Config::Key, std::move(Cfg));
+  assertHints(InlayHintKind::EndDefinitionComment, AnnotatedSource,
+  Expected...);
+}
+
 TEST(ParameterHints, Smoke) {
   assertParameterHints(R"cpp(
 void foo(int param);
@@ -1550,6 +1562,165 @@
   ExpectedHint{"a: ", "param1"}, ExpectedHint{"b: ", "param2"},
   ExpectedHint{"c: ", "param3"});
 }
+
+TEST(EndDefinitionHints, Functions) {
+  assertEndDefinitionHints(R"cpp(
+$foo[[int foo() {
+  return 41;
+}]]
+$bar[[int bar() {}]]
+
+// No hint because this isn't a definition
+int buz();
+  )cpp",
+   0, ExpectedHint{" /* foo */ ", "foo"},
+   ExpectedHint{" /* bar */ ", "bar"});
+}
+
+TEST(EndDefinitionHints, Methods) {
+  assertEndDefinitionHints(R"cpp(
+class Test {
+public:
+  $ctor[[Test() = default]];
+  $dtor[[~Test() {
+  }]]
+
+  $method[[void method() {}]]
+
+  // No hint because this isn't a definition
+  void method2();
+} x;
+  )cpp",
+   0, ExpectedHint{" /* Test */ ", "ctor"},
+   ExpectedHint{" /* ~Test */ ", "dtor"},
+   ExpectedHint{" /* method */ ", "method"});
+}
+
+TEST(EndDefinitionHints, OverloadedOperators) {
+  assertEndDefinitionHints(R"cpp(
+struct S {
+  $opAdd[[S operator+(int) const {
+return *this;
+  }]]
+
+  $opBool[[operator bool() const {
+return true;
+  }]]
+
+  $opInt[[operator int() const = delete]];
+
+  // No hint because this isn't a definition
+  operator float() const;
+} x;
+  )cpp",
+   0, ExpectedHint{" /* operator+ */ ", "opAdd"},
+   ExpectedHint{" /* operator bool */ ", "opBool"},
+   ExpectedHint{" /* operator int */ ", "opInt"});
+}
+
+TEST(EndDefinitionHints, Namespaces) {
+  assertEndDefinitionHints(
+  R"cpp(
+$anon[[namespace {
+}]]
+
+$ns[[namespace ns {
+  void foo();
+}]]
+  )cpp",
+  0, ExpectedHint{" /* namespace  */ ", "anon"},
+  ExpectedHint{" /* namespace ns */ ", "ns"});
+}
+
+TEST(EndDefinitionHints, Types) {
+  assertEndDefinitionHints(R"cpp(
+$S[[struct S {
+}]];
+
+$C[[class C {
+}]];
+
+$U[[union U {
+}]];
+
+$E1[[enum E1 {
+}]];
+
+$E2[[enum class E2 {
+}]];
+  )cpp",
+   0, ExpectedHint{" /* struct S */ ", "S"},
+   ExpectedHint{" /* class C */ ", "C"},
+   ExpectedHint{" /* union U */ ", "U"},
+   ExpectedHint{" /* enum E1 */ ", "E1"},
+   ExpectedHint{" /* enum class E2 */ ", "E2"});
+}
+
+TEST(EndDefinitionHints, BundledTypeVariableDecl) {
+  assertEndDefinitionHints(
+  R"cpp(
+struct {
+  int x;
+} s;
+
+$anon[[struct {
+  int x;
+}]]
+
+s2;
+  )cpp",
+  0, ExpectedHint{" /* struct  */ ", "anon"});
+}
+
+TEST(EndDefinitionHints, TrailingSemicolon) {
+  assertEndDefinitionHints(R"cpp(
+$S1[[struct S1 {
+}]];
+
+$S2[[struct S2 {
+}]]
+
+;
+
+$S3[[struct S3 {
+}]] ;; ;;
+  )cpp",
+   0, ExpectedHint{" /* struct S1 */ ", "S1"},
+   ExpectedHint{" /* struct S2 */ ", "S2"},
+   ExpectedHint{" /* struct S3 */ ", "S3"});
+}
+

[PATCH] D150635: [clangd] Implement end-definition-comment inlay hints

2023-05-15 Thread Qingyuan Zheng via Phabricator via cfe-commits
daiyousei-qz created this revision.
Herald added subscribers: kadircet, arphaman.
Herald added a project: All.
daiyousei-qz requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150635

Files:
  clang-tools-extra/clangd/Config.h
  clang-tools-extra/clangd/ConfigCompile.cpp
  clang-tools-extra/clangd/ConfigFragment.h
  clang-tools-extra/clangd/ConfigYAML.cpp
  clang-tools-extra/clangd/InlayHints.cpp
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
  clang-tools-extra/clangd/unittests/InlayHintTests.cpp

Index: clang-tools-extra/clangd/unittests/InlayHintTests.cpp
===
--- clang-tools-extra/clangd/unittests/InlayHintTests.cpp
+++ clang-tools-extra/clangd/unittests/InlayHintTests.cpp
@@ -77,6 +77,7 @@
   C.InlayHints.Parameters = false;
   C.InlayHints.DeducedTypes = false;
   C.InlayHints.Designators = false;
+  C.InlayHints.EndDefinitionComments = false;
   return C;
 }
 
@@ -122,6 +123,17 @@
   assertHints(InlayHintKind::Designator, AnnotatedSource, Expected...);
 }
 
+template 
+void assertEndDefinitionHints(llvm::StringRef AnnotatedSource,
+  uint32_t MinLines, ExpectedHints... Expected) {
+  Config Cfg;
+  Cfg.InlayHints.EndDefinitionComments = true;
+  Cfg.InlayHints.EndDefinitionCommentMinLines = MinLines;
+  WithContextValue WithCfg(Config::Key, std::move(Cfg));
+  assertHints(InlayHintKind::EndDefinitionComments, AnnotatedSource,
+  Expected...);
+}
+
 TEST(ParameterHints, Smoke) {
   assertParameterHints(R"cpp(
 void foo(int param);
@@ -1550,6 +1562,165 @@
   ExpectedHint{"a: ", "param1"}, ExpectedHint{"b: ", "param2"},
   ExpectedHint{"c: ", "param3"});
 }
+
+TEST(EndDefinitionHints, Functions) {
+  assertEndDefinitionHints(R"cpp(
+$foo[[int foo() {
+  return 41;
+}]]
+$bar[[int bar() {}]]
+
+// No hint because this isn't a definition
+int buz();
+  )cpp",
+   0, ExpectedHint{" /* foo */ ", "foo"},
+   ExpectedHint{" /* bar */ ", "bar"});
+}
+
+TEST(EndDefinitionHints, Methods) {
+  assertEndDefinitionHints(R"cpp(
+class Test {
+public:
+  $ctor[[Test() = default]];
+  $dtor[[~Test() {
+  }]]
+
+  $method[[void method() {}]]
+
+  // No hint because this isn't a definition
+  void method2();
+} x;
+  )cpp",
+   0, ExpectedHint{" /* Test */ ", "ctor"},
+   ExpectedHint{" /* ~Test */ ", "dtor"},
+   ExpectedHint{" /* method */ ", "method"});
+}
+
+TEST(EndDefinitionHints, OverloadedOperators) {
+  assertEndDefinitionHints(R"cpp(
+struct S {
+  $opAdd[[S operator+(int) const {
+return *this;
+  }]]
+
+  $opBool[[operator bool() const {
+return true;
+  }]]
+
+  $opInt[[operator int() const = delete]];
+
+  // No hint because this isn't a definition
+  operator float() const;
+} x;
+  )cpp",
+   0, ExpectedHint{" /* operator+ */ ", "opAdd"},
+   ExpectedHint{" /* operator bool */ ", "opBool"},
+   ExpectedHint{" /* operator int */ ", "opInt"});
+}
+
+TEST(EndDefinitionHints, Namespaces) {
+  assertEndDefinitionHints(
+  R"cpp(
+$anon[[namespace {
+}]]
+
+$ns[[namespace ns {
+  void foo();
+}]]
+  )cpp",
+  0, ExpectedHint{" /* namespace  */ ", "anon"},
+  ExpectedHint{" /* namespace ns */ ", "ns"});
+}
+
+TEST(EndDefinitionHints, Types) {
+  assertEndDefinitionHints(R"cpp(
+$S[[struct S {
+}]];
+
+$C[[class C {
+}]];
+
+$U[[union U {
+}]];
+
+$E1[[enum E1 {
+}]];
+
+$E2[[enum class E2 {
+}]];
+  )cpp",
+   0, ExpectedHint{" /* struct S */ ", "S"},
+   ExpectedHint{" /* class C */ ", "C"},
+   ExpectedHint{" /* union U */ ", "U"},
+   ExpectedHint{" /* enum E1 */ ", "E1"},
+   ExpectedHint{" /* enum class E2 */ ", "E2"});
+}
+
+TEST(EndDefinitionHints, BundledTypeVariableDecl) {
+  assertEndDefinitionHints(
+  R"cpp(
+struct {
+  int x;
+} s;
+
+$anon[[struct {
+  int x;
+}]]
+
+s2;
+  )cpp",
+  0, ExpectedHint{" /* struct  */ ", "anon"});
+}
+
+TEST(EndDefinitionHints, TrailingSemicolon) {
+  assertEndDefinitionHints(R"cpp(
+$S1[[struct S1 {
+}]];
+
+$S2[[struct S2 {
+}]]
+
+;
+
+$S3[[struct S3 {
+}]] ;; ;;
+  )cpp",
+   0, ExpectedHint{" /* struct S1 */ ", "S1"},
+   ExpectedHint{" /* struct S2 */ ", "S2"},
+   ExpectedHint{" /* 

[PATCH] D143675: Discussion: Darwin Sanitizers Stable ABI

2023-05-15 Thread Roy Sundahl via Phabricator via cfe-commits
rsundahl marked 2 inline comments as done.
rsundahl added a comment.

Suggestions for compiler-rt/docs/asan_abi.md are captured in the successor file 
compiler-rt/docs/ASanABI.rst and marked complete.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143675

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


[PATCH] D143675: Discussion: Darwin Sanitizers Stable ABI

2023-05-15 Thread Roy Sundahl via Phabricator via cfe-commits
rsundahl marked 4 inline comments as done.
rsundahl added a comment.

Suggestions for compiler-rt/docs/asan_abi.md are captured in the successor file 
compiler-rt/docs/ASanABI.rst and marked complete.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143675

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


[PATCH] D143675: Discussion: Darwin Sanitizers Stable ABI

2023-05-15 Thread Roy Sundahl via Phabricator via cfe-commits
rsundahl marked 22 inline comments as done.
rsundahl added a comment.

Thank you for your review and thoughtful input @eugenis, @MaskRay and 
@vitalybuka. I think we're close to having everything incorporated. (@MaskRay, 
the doc files went from .md to .rst and I implemented all of your suggestions 
there.




Comment at: clang/include/clang/Driver/Options.td:1785
HelpText<"Use default code 
inlining logic for the address sanitizer">;
+def fsanitize_address_stable_abi : Flag<["-"], "fsanitize-address-stable-abi">,
+Group,

MaskRay wrote:
> rsundahl wrote:
> > vitalybuka wrote:
> > > how likely you will need thus for  other sanitizers in future
> > > should this be rather -fsanitize-stable-abi which is ignore for now for 
> > > other sanitizers?
> > Thanks @vitalybuka. I agree and made this change. For now I still only 
> > consume the flag if sanitizer=address so that we continue to get the unused 
> > option warning in the other cases and left the test for that warning intact.
> See `BooleanFFlag`. Some existing sanitizer options are not written with the 
> best practice.
> 
> If `-fno-sanitize-stable-abi` is the default, there is usually no need to 
> have a duplicate help message `Disable ...`. Documenting the non-default 
> boolean option suffices.
(Not sure if this is exactly what you meant @MaskRay but I think it's close.)



Comment at: clang/lib/Driver/SanitizerArgs.cpp:1292
+CmdArgs.push_back("-mllvm");
+CmdArgs.push_back("-asan-instrumentation-with-call-threshold=0");
+CmdArgs.push_back("-mllvm");

MaskRay wrote:
> Optional nit: I added `-mllvm=` as an alias in `D143325`. You can use 
> `-mllvm=-asan-instrumentation-with-call-threshold=0` to decrease the 
> number/length of cc1 options.
> 
> Add some comments before `if (StableABI) {` why the two `cl::opt` options are 
> specified.
I couldn't get this one to work. Did I do it wrong? (Couldn't find example in 
the code to go from.)

Tried:
```
  if (StableABI) {
CmdArgs.push_back("-mllvm=-asan-instrumentation-with-call-threshold=0");
CmdArgs.push_back("-mllvm=-asan-max-inline-poisoning-size=0");
  }
```
Got:
```
error: unknown argument: '-mllvm=-asan-instrumentation-with-call-threshold=0'
error: unknown argument: '-mllvm=-asan-max-inline-poisoning-size=0'
```



Comment at: compiler-rt/lib/asan_abi/asan_abi_shim.cpp:41
+
+void __asan_after_dynamic_init(void) {
+__asan_abi_after_dynamic_init();

MaskRay wrote:
> C++ prefers `()` instead of `(void)`.
These are actually "C'
Added:
```
extern "C" {
...
}
```



Comment at: compiler-rt/lib/asan_abi/asan_abi_shim.cpp:486
+// TBD: Fail here
+return (void *) 0;
+}

MaskRay wrote:
> You may apply `clang-format`, which may turn this into `(void *)0`, but 
> `nullptr` likely works better.
clang-format left this as-is. I suspect this is because I also added the extern 
"C" brackets.



Comment at: 
compiler-rt/test/asan_abi/TestCases/Darwin/llvm_interface_symbols.cpp:16
+//
+// RUN:  sed -e ':a' -e 'N' -e '$!ba'  
   \
+// RUN:  -e 's/ //g'   
   \

MaskRay wrote:
> Does Darwin sed accept `;` to combine multiple `-e` into one `-e` with `;`?
I couldn't get the same behavior out of the intersection of GNU an BSD set. 
Tried hard in https://reviews.llvm.org/D138824 and landed with the -e's. iirc 
exactly what the problem was with semicolons, just that I was relieved when I 
found a format that worked for all the platforms.



Comment at: 
compiler-rt/test/asan_abi/TestCases/Darwin/llvm_interface_symbols.cpp:26
+//
+// RUN: cat %t.imports | sort | uniq > %t.imports-sorted
+// RUN: cat %t.exports | sort | uniq > %t.exports-sorted

MaskRay wrote:
> `sort %t.imports`. See `Useless use of cat`
Good point!



Comment at: compiler-rt/test/asan_abi/lit.cfg.py:9
+
+# Get shlex.quote if available (added in 3.3), and fall back to pipes.quote if
+# it's not available.

MaskRay wrote:
> This workaround is unneeded. I sent D150410 to clean up other `lit.cfg.py` 
> files.
Wasn't actually used anyway but good to know!



Comment at: compiler-rt/test/asan_abi/lit.cfg.py:83
+# Only run the tests on supported OSs.
+if config.host_os not in ['Darwin']:
+  config.unsupported = True

thetruestblue wrote:
> MaskRay wrote:
> > `!=`
> The thought here was to leave basic lit patterns in-tact to expand to other 
> OSs if others want to in the future. But if there's no desire for that, it 
> doesn't make a big difference to me. 
I landed on just an else clause. Let me know if that's ok @thetruestblue.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST 

[PATCH] D150597: [clang][AIX] Adding Revised xcoff-roptr CodeGen Test Case

2023-05-15 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast accepted this revision.
hubert.reinterpretcast added a comment.
This revision is now accepted and ready to land.

LGTM; thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150597

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


[clang] 88a720d - [NFC] [C++20] [Modules] Rename ASTContext::getNamedModuleForCodeGen to ASTContext::getCurrentNamedModule

2023-05-15 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2023-05-16T11:24:35+08:00
New Revision: 88a720d19479e4cad186f00a9911714c3d77303a

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

LOG: [NFC] [C++20] [Modules] Rename ASTContext::getNamedModuleForCodeGen to 
ASTContext::getCurrentNamedModule

The original name "ASTContext::getNamedModuleForCodeGen" is not properly
reflecting the usage of the interface. This interface can be used to
judge the current module unit in both sema analysis and code generation.
So the original name was not so correct.

Added: 


Modified: 
clang/include/clang/AST/ASTContext.h
clang/lib/AST/ASTContext.cpp
clang/lib/CodeGen/CGDeclCXX.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/Frontend/ASTUnit.cpp
clang/lib/Sema/SemaModule.cpp

Removed: 




diff  --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index b08eb525602b6..8f0a82a7a50da 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -447,9 +447,8 @@ class ASTContext : public RefCountedBase {
   };
   llvm::DenseMap ModuleInitializers;
 
-  /// For module code-gen cases, this is the top-level (C++20) Named module
-  /// we are building.
-  Module *TopLevelCXXNamedModule = nullptr;
+  /// This is the top-level (C++20) Named module we are building.
+   Module *CurrentCXXNamedModule = nullptr;
 
   static constexpr unsigned ConstantArrayTypesLog2InitSize = 8;
   static constexpr unsigned GeneralTypesLog2InitSize = 9;
@@ -1052,10 +1051,10 @@ class ASTContext : public RefCountedBase {
   ArrayRef getModuleInitializers(Module *M);
 
   /// Set the (C++20) module we are building.
-  void setNamedModuleForCodeGen(Module *M) { TopLevelCXXNamedModule = M; }
+  void setCurrentNamedModule(Module *M);
 
   /// Get module under construction, nullptr if this is not a C++20 module.
-  Module *getNamedModuleForCodeGen() const { return TopLevelCXXNamedModule; }
+  Module *getCurrentNamedModule() const { return CurrentCXXNamedModule; }
 
   TranslationUnitDecl *getTranslationUnitDecl() const {
 return TUDecl->getMostRecentDecl();

diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 7fdbf4d32efe8..3d44f1c33cc80 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -1153,6 +1153,13 @@ ArrayRef 
ASTContext::getModuleInitializers(Module *M) {
   return Inits->Initializers;
 }
 
+void ASTContext::setCurrentNamedModule(Module *M) {
+  assert(M->isModulePurview());
+  assert(!CurrentCXXNamedModule &&
+"We should set named module for ASTContext for only once");
+  CurrentCXXNamedModule = M;
+}
+
 ExternCContextDecl *ASTContext::getExternCContextDecl() const {
   if (!ExternCContext)
 ExternCContext = ExternCContextDecl::Create(*this, 
getTranslationUnitDecl());
@@ -11922,7 +11929,7 @@ bool ASTContext::DeclMustBeEmitted(const Decl *D) {
   // Variables in other module units shouldn't be forced to be emitted.
   auto *VM = VD->getOwningModule();
   if (VM && VM->getTopLevelModule()->isModulePurview() &&
-  VM->getTopLevelModule() != getNamedModuleForCodeGen())
+  VM->getTopLevelModule() != getCurrentNamedModule())
 return false;
 
   // Variables that can be needed in other TUs are required.

diff  --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp
index 9d7284cd0e37d..04e42153519ae 100644
--- a/clang/lib/CodeGen/CGDeclCXX.cpp
+++ b/clang/lib/CodeGen/CGDeclCXX.cpp
@@ -883,12 +883,12 @@ CodeGenModule::EmitCXXGlobalInitFunc() {
   // with priority emitted above.  Module implementation units behave the same
   // way as a non-modular TU with imports.
   llvm::Function *Fn;
-  if (CXX20ModuleInits && getContext().getNamedModuleForCodeGen() &&
-  !getContext().getNamedModuleForCodeGen()->isModuleImplementation()) {
+  if (CXX20ModuleInits && getContext().getCurrentNamedModule() &&
+  !getContext().getCurrentNamedModule()->isModuleImplementation()) {
 SmallString<256> InitFnName;
 llvm::raw_svector_ostream Out(InitFnName);
 cast(getCXXABI().getMangleContext())
-.mangleModuleInitializer(getContext().getNamedModuleForCodeGen(), Out);
+.mangleModuleInitializer(getContext().getCurrentNamedModule(), Out);
 Fn = CreateGlobalInitOrCleanUpFunction(
 FTy, llvm::Twine(InitFnName), FI, SourceLocation(), false,
 llvm::GlobalVariable::ExternalLinkage);

diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 7534304b1878f..d3cde11a7e962 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -529,7 +529,7 @@ static void setVisibilityFromDLLStorageClass(const 
clang::LangOptions ,
 }
 
 void CodeGenModule::Release() {
-  Module *Primary = 

[PATCH] D143675: Discussion: Darwin Sanitizers Stable ABI

2023-05-15 Thread Roy Sundahl via Phabricator via cfe-commits
rsundahl updated this revision to Diff 522417.
rsundahl added a comment.

Applied suggestions from reviewers

Cleaned up options parsing
Moved test into stanalone file fsanitize-stable-abi.c
Changed target triple to arm64-apple-darwin
Changed documentation style from proposal to specification
Changed format of documentation form .md to .rst
Applied clang-format to entire diff
Removed extraneous spaces and lines
Expanded comments to sentences
Switched to static_assert()


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143675

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/SanitizerArgs.h
  clang/lib/Driver/SanitizerArgs.cpp
  clang/test/Driver/fsanitize-stable-abi.c
  compiler-rt/cmake/config-ix.cmake
  compiler-rt/docs/ASanABI.rst
  compiler-rt/lib/asan_abi/CMakeLists.txt
  compiler-rt/lib/asan_abi/asan_abi.cpp
  compiler-rt/lib/asan_abi/asan_abi.h
  compiler-rt/lib/asan_abi/asan_abi_shim.cpp
  compiler-rt/lib/asan_abi/darwin_exclude_symbols.inc
  compiler-rt/test/asan_abi/CMakeLists.txt
  compiler-rt/test/asan_abi/TestCases/Darwin/llvm_interface_symbols.cpp
  compiler-rt/test/asan_abi/TestCases/linkstaticlibrary.cpp
  compiler-rt/test/asan_abi/lit.cfg.py
  compiler-rt/test/asan_abi/lit.site.cfg.py.in

Index: compiler-rt/test/asan_abi/lit.site.cfg.py.in
===
--- /dev/null
+++ compiler-rt/test/asan_abi/lit.site.cfg.py.in
@@ -0,0 +1,18 @@
+@LIT_SITE_CFG_IN_HEADER@
+
+# Tool-specific config options.
+config.name_suffix = "@ASAN_ABI_TEST_CONFIG_SUFFIX@"
+config.target_cflags = "@ASAN_ABI_TEST_TARGET_CFLAGS@"
+config.clang = "@ASAN_ABI_TEST_TARGET_CC@"
+config.bits = "@ASAN_ABI_TEST_BITS@"
+config.arm_thumb = "@COMPILER_RT_ARM_THUMB@"
+config.apple_platform = "@ASAN_ABI_TEST_APPLE_PLATFORM@"
+config.apple_platform_min_deployment_target_flag = "@ASAN_ABI_TEST_MIN_DEPLOYMENT_TARGET_FLAG@"
+config.asan_abi_dynamic = @ASAN_ABI_TEST_DYNAMIC@
+config.target_arch = "@ASAN_ABI_TEST_TARGET_ARCH@"
+
+# Load common config for all compiler-rt lit tests.
+lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured")
+
+# Load tool-specific config that would do the real work.
+lit_config.load_config(config, "@ASAN_ABI_LIT_SOURCE_DIR@/lit.cfg.py")
Index: compiler-rt/test/asan_abi/lit.cfg.py
===
--- /dev/null
+++ compiler-rt/test/asan_abi/lit.cfg.py
@@ -0,0 +1,74 @@
+# -*- Python -*-
+
+import os
+import platform
+import re
+
+import lit.formats
+
+def get_required_attr(config, attr_name):
+  attr_value = getattr(config, attr_name, None)
+  if attr_value is None:
+lit_config.fatal(
+  "No attribute %r in test configuration! You may need to run "
+  "tests from your build directory or add this attribute "
+  "to lit.site.cfg.py " % attr_name)
+  return attr_value
+
+# Setup config name.
+config.name = 'AddressSanitizerABI' + config.name_suffix
+
+# Platform-specific default ASAN_ABI_OPTIONS for lit tests.
+default_asan_abi_opts = list(config.default_sanitizer_opts)
+
+default_asan_abi_opts_str = ':'.join(default_asan_abi_opts)
+if default_asan_abi_opts_str:
+  config.environment['ASAN_ABI_OPTIONS'] = default_asan_abi_opts_str
+  default_asan_abi_opts_str += ':'
+config.substitutions.append(('%env_asan_abi_opts=',
+ 'env ASAN_ABI_OPTIONS=' + default_asan_abi_opts_str))
+
+# Setup source root.
+config.test_source_root = os.path.dirname(__file__)
+
+# GCC-ASan doesn't link in all the necessary libraries automatically, so
+# we have to do it ourselves.
+extra_link_flags = []
+
+# Setup default compiler flags used with -fsanitize=address option.
+# FIXME: Review the set of required flags and check if it can be reduced.
+target_cflags = [get_required_attr(config, "target_cflags")] + extra_link_flags
+target_cxxflags = config.cxx_mode_flags + target_cflags
+clang_asan_abi_static_cflags = (["-fsanitize=address",
+"-fsanitize-stable-abi",
+"-mno-omit-leaf-frame-pointer",
+"-fno-omit-frame-pointer",
+"-fno-optimize-sibling-calls"] +
+config.debug_info_flags + target_cflags)
+clang_asan_abi_static_cxxflags = config.cxx_mode_flags + clang_asan_abi_static_cflags
+
+config.available_features.add("asan_abi-static-runtime")
+clang_asan_abi_cflags = clang_asan_abi_static_cflags
+clang_asan_abi_cxxflags = clang_asan_abi_static_cxxflags
+
+def build_invocation(compile_flags):
+  return " " + " ".join([config.clang] + compile_flags) + " "
+
+config.substitutions.append( ("%clang ", build_invocation(target_cflags)) )
+config.substitutions.append( ("%clangxx ", build_invocation(target_cxxflags)) )
+config.substitutions.append( ("%clang_asan_abi ", build_invocation(clang_asan_abi_cflags)) )

[PATCH] D149562: [clang-format] Stop comment disrupting indentation of Verilog ports

2023-05-15 Thread sstwcw 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 rG369e8762b4d6: [clang-format] Stop comment disrupting 
indentation of Verilog ports (authored by sstwcw).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149562

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/ContinuationIndenter.cpp
  clang/lib/Format/FormatToken.h
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTestVerilog.cpp

Index: clang/unittests/Format/FormatTestVerilog.cpp
===
--- clang/unittests/Format/FormatTestVerilog.cpp
+++ clang/unittests/Format/FormatTestVerilog.cpp
@@ -517,6 +517,15 @@
"(input var x `a, //\n"
" b);\n"
"endmodule");
+  // A line comment shouldn't disrupt the indentation of the port list.
+  verifyFormat("extern module x\n"
+   "(//\n"
+   " output y);");
+  verifyFormat("extern module x\n"
+   "#(//\n"
+   "  parameter x)\n"
+   "(//\n"
+   " output y);");
   // With a concatenation in the names.
   auto Style = getDefaultStyle();
   Style.ColumnLimit = 40;
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -4196,11 +4196,14 @@
 if (FormatTok->is(Keywords.kw_verilogHash)) {
   NewLine();
   nextToken();
-  if (FormatTok->is(tok::l_paren))
+  if (FormatTok->is(tok::l_paren)) {
+FormatTok->setFinalizedType(TT_VerilogMultiLineListLParen);
 parseParens();
+  }
 }
 if (FormatTok->is(tok::l_paren)) {
   NewLine();
+  FormatTok->setFinalizedType(TT_VerilogMultiLineListLParen);
   parseParens();
 }
 
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3312,6 +3312,8 @@
   if (Prev->is(BK_BracedInit) && Prev->opensScope()) {
 Current->SpacesRequiredBefore =
 (Style.Cpp11BracedListStyle && !Style.SpacesInParentheses) ? 0 : 1;
+  } else if (Prev->is(TT_VerilogMultiLineListLParen)) {
+Current->SpacesRequiredBefore = 0;
   } else {
 Current->SpacesRequiredBefore = Style.SpacesBeforeTrailingComments;
   }
Index: clang/lib/Format/FormatToken.h
===
--- clang/lib/Format/FormatToken.h
+++ clang/lib/Format/FormatToken.h
@@ -156,6 +156,9 @@
   /* list of port connections or parameters in a module instantiation */   \
   TYPE(VerilogInstancePortComma)   \
   TYPE(VerilogInstancePortLParen)  \
+  /* A parenthesized list within which line breaks are inserted by the \
+   * formatter, for example the list of ports in a module header. */   \
+  TYPE(VerilogMultiLineListLParen) \
   /* for the base in a number literal, not including the quote */  \
   TYPE(VerilogNumberBase)  \
   /* like `(strong1, pull0)` */\
Index: clang/lib/Format/ContinuationIndenter.cpp
===
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -748,7 +748,8 @@
   !CurrentState.IsCSharpGenericTypeConstraint && Previous.opensScope() &&
   Previous.isNot(TT_ObjCMethodExpr) && Previous.isNot(TT_RequiresClause) &&
   !(Current.MacroParent && Previous.MacroParent) &&
-  (Current.isNot(TT_LineComment) || Previous.is(BK_BracedInit))) {
+  (Current.isNot(TT_LineComment) ||
+   Previous.isOneOf(BK_BracedInit, TT_VerilogMultiLineListLParen))) {
 CurrentState.Indent = State.Column + Spaces;
 CurrentState.IsAligned = true;
   }
Index: clang/include/clang/Format/Format.h
===
--- clang/include/clang/Format/Format.h
+++ clang/include/clang/Format/Format.h
@@ -4019,9 +4019,12 @@
   /// The number of spaces before trailing line comments
   /// (``//`` - comments).
   ///
-  /// This does not affect trailing block comments (``/*`` - comments) as
-  /// those commonly have different usage patterns and a number of special
-  /// cases.
+  /// This does not affect trailing block comments (``/*`` - comments) as those
+  /// commonly have different 

[clang] 369e876 - [clang-format] Stop comment disrupting indentation of Verilog ports

2023-05-15 Thread via cfe-commits

Author: sstwcw
Date: 2023-05-16T02:56:58Z
New Revision: 369e8762b4d658e6e8f8310200aadf043bd7f01e

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

LOG: [clang-format] Stop comment disrupting indentation of Verilog ports

Before:

```
module x
#( //
parameter x)
( //
input y);
endmodule
```

After:

```
module x
#(//
  parameter x)
(//
 input y);
endmodule
```

If the first line in a port or parameter list is not a comment, the
following lines will be aligned to the first line as intended:

```
module x
#(parameter x1,
  parameter x2)
(input y,
 input y2);
endmodule
```

Previously, the indentation would be changed to an extra continuation
indentation relative to the start of the parenthesis or the hash if
the first token inside the parentheses was a comment.  It is a feature
introduced in ddaa9be97839.  The feature enabled one to insert a `//`
comment right after an opening parentheses to put the function
arguments on a new line with a small indentation regardless of how
long the function name is, like this:

```
someFunction(anotherFunction( // Force break.
parameter));
```

People are unlikely to use this feature in a Verilog port list because
the formatter already puts the port list on its own lines.  A comment
at the start of a port list is probably a comment for the port on the
next line.

We also removed the space before the comment so that its indentation
would be same as that for a line comment anywhere else in the port
list.

Reviewed By: HazardyKnusperkeks

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

Added: 


Modified: 
clang/docs/ClangFormatStyleOptions.rst
clang/include/clang/Format/Format.h
clang/lib/Format/ContinuationIndenter.cpp
clang/lib/Format/FormatToken.h
clang/lib/Format/TokenAnnotator.cpp
clang/lib/Format/UnwrappedLineParser.cpp
clang/unittests/Format/FormatTestVerilog.cpp

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index ce4c39694e0c5..56b6b62e3138c 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -5069,9 +5069,12 @@ the configuration (without a prefix: ``Auto``).
   The number of spaces before trailing line comments
   (``//`` - comments).
 
-  This does not affect trailing block comments (``/*`` - comments) as
-  those commonly have 
diff erent usage patterns and a number of special
-  cases.
+  This does not affect trailing block comments (``/*`` - comments) as those
+  commonly have 
diff erent usage patterns and a number of special cases.  In
+  the case of Verilog, it doesn't affect a comment right after the opening
+  parenthesis in the port or parameter list in a module header, because it
+  is probably for the port on the following line instead of the parenthesis
+  it follows.
 
   .. code-block:: c++
 

diff  --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 40f1ae0b49d46..1cc1037562b89 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -4019,9 +4019,12 @@ struct FormatStyle {
   /// The number of spaces before trailing line comments
   /// (``//`` - comments).
   ///
-  /// This does not affect trailing block comments (``/*`` - comments) as
-  /// those commonly have 
diff erent usage patterns and a number of special
-  /// cases.
+  /// This does not affect trailing block comments (``/*`` - comments) as those
+  /// commonly have 
diff erent usage patterns and a number of special cases.  In
+  /// the case of Verilog, it doesn't affect a comment right after the opening
+  /// parenthesis in the port or parameter list in a module header, because it
+  /// is probably for the port on the following line instead of the parenthesis
+  /// it follows.
   /// \code
   ///SpacesBeforeTrailingComments: 3
   ///void f() {

diff  --git a/clang/lib/Format/ContinuationIndenter.cpp 
b/clang/lib/Format/ContinuationIndenter.cpp
index 3ae9d1997880f..f6f6bf61f1c37 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -748,7 +748,8 @@ void ContinuationIndenter::addTokenOnCurrentLine(LineState 
, bool DryRun,
   !CurrentState.IsCSharpGenericTypeConstraint && Previous.opensScope() &&
   Previous.isNot(TT_ObjCMethodExpr) && Previous.isNot(TT_RequiresClause) &&
   !(Current.MacroParent && Previous.MacroParent) &&
-  (Current.isNot(TT_LineComment) || Previous.is(BK_BracedInit))) {
+  (Current.isNot(TT_LineComment) ||
+   Previous.isOneOf(BK_BracedInit, TT_VerilogMultiLineListLParen))) {
 CurrentState.Indent = State.Column + Spaces;
 CurrentState.IsAligned = true;
   }

diff  --git 

[PATCH] D150582: [clangd] Fix test failure when it's built with compiler flags unknown by clang

2023-05-15 Thread Sam James 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 rG4ddae8b94139: [clangd] Fix test failure when its built 
with compiler flags unknown by clang (authored by xry111, committed by 
thesamesam).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150582

Files:
  clang-tools-extra/clangd/test/CMakeLists.txt
  clang-tools-extra/clangd/test/compile_commands.json


Index: clang-tools-extra/clangd/test/compile_commands.json
===
--- /dev/null
+++ clang-tools-extra/clangd/test/compile_commands.json
@@ -0,0 +1 @@
+[]
Index: clang-tools-extra/clangd/test/CMakeLists.txt
===
--- clang-tools-extra/clangd/test/CMakeLists.txt
+++ clang-tools-extra/clangd/test/CMakeLists.txt
@@ -28,6 +28,16 @@
   ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py
   )
 
+# Copy an empty compile_commands.json to override the compile_commands.json
+# in the top level build directory.  Or if a clangd test involves creating a
+# temporary source file in the build directory and run clangd to check it,
+# it can pick up unrecognizable command options when LLVM is built with
+# another compiler or a different version of Clang.
+configure_file(
+  ${CMAKE_CURRENT_SOURCE_DIR}/compile_commands.json
+  ${CMAKE_CURRENT_BINARY_DIR}/compile_commands.json
+)
+
 add_lit_testsuite(check-clangd "Running the Clangd regression tests"
   # clangd doesn't put unittest configs in test/unit like every other project.
   # Because of that, this needs to pass two folders here, while every other


Index: clang-tools-extra/clangd/test/compile_commands.json
===
--- /dev/null
+++ clang-tools-extra/clangd/test/compile_commands.json
@@ -0,0 +1 @@
+[]
Index: clang-tools-extra/clangd/test/CMakeLists.txt
===
--- clang-tools-extra/clangd/test/CMakeLists.txt
+++ clang-tools-extra/clangd/test/CMakeLists.txt
@@ -28,6 +28,16 @@
   ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py
   )
 
+# Copy an empty compile_commands.json to override the compile_commands.json
+# in the top level build directory.  Or if a clangd test involves creating a
+# temporary source file in the build directory and run clangd to check it,
+# it can pick up unrecognizable command options when LLVM is built with
+# another compiler or a different version of Clang.
+configure_file(
+  ${CMAKE_CURRENT_SOURCE_DIR}/compile_commands.json
+  ${CMAKE_CURRENT_BINARY_DIR}/compile_commands.json
+)
+
 add_lit_testsuite(check-clangd "Running the Clangd regression tests"
   # clangd doesn't put unittest configs in test/unit like every other project.
   # Because of that, this needs to pass two folders here, while every other
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 4ddae8b - [clangd] Fix test failure when it's built with compiler flags unknown by clang

2023-05-15 Thread Sam James via cfe-commits

Author: Xi Ruoyao
Date: 2023-05-16T03:56:26+01:00
New Revision: 4ddae8b941398a6579d3a6f25aa39a260e441371

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

LOG: [clangd] Fix test failure when it's built with compiler flags unknown by 
clang

If LLVM is built with a compiler other than clang, the `compile_commands.json`
file may contain compiler flags unknown by clang.  When a clangd test is copied
into the build directory and checked, clangd will pick the unknown flag from
the file and cause a test failure.  Create an empty `compile_commands.json` in
the test directory nested in the build directory to override it.

Reviewed By: thesamesam

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

Added: 
clang-tools-extra/clangd/test/compile_commands.json

Modified: 
clang-tools-extra/clangd/test/CMakeLists.txt

Removed: 




diff  --git a/clang-tools-extra/clangd/test/CMakeLists.txt 
b/clang-tools-extra/clangd/test/CMakeLists.txt
index 6bb578263ffc8..840fe2bdc12b0 100644
--- a/clang-tools-extra/clangd/test/CMakeLists.txt
+++ b/clang-tools-extra/clangd/test/CMakeLists.txt
@@ -28,6 +28,16 @@ configure_lit_site_cfg(
   ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py
   )
 
+# Copy an empty compile_commands.json to override the compile_commands.json
+# in the top level build directory.  Or if a clangd test involves creating a
+# temporary source file in the build directory and run clangd to check it,
+# it can pick up unrecognizable command options when LLVM is built with
+# another compiler or a 
diff erent version of Clang.
+configure_file(
+  ${CMAKE_CURRENT_SOURCE_DIR}/compile_commands.json
+  ${CMAKE_CURRENT_BINARY_DIR}/compile_commands.json
+)
+
 add_lit_testsuite(check-clangd "Running the Clangd regression tests"
   # clangd doesn't put unittest configs in test/unit like every other project.
   # Because of that, this needs to pass two folders here, while every other

diff  --git a/clang-tools-extra/clangd/test/compile_commands.json 
b/clang-tools-extra/clangd/test/compile_commands.json
new file mode 100644
index 0..fe51488c7066f
--- /dev/null
+++ b/clang-tools-extra/clangd/test/compile_commands.json
@@ -0,0 +1 @@
+[]



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


[PATCH] D150582: [clangd] Fix test failure when it's built with compiler flags unknown by clang

2023-05-15 Thread Sam James via Phabricator via cfe-commits
thesamesam accepted this revision.
thesamesam added a comment.
This revision is now accepted and ready to land.

(I even struggled to find docs for the fix we used for clang-tidy, although it 
obviously works.)

Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150582

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


[PATCH] D146054: [RISCV] Add --print-supported-extensions and -march=help support

2023-05-15 Thread Brandon Wu via Phabricator via cfe-commits
4vtomat updated this revision to Diff 522411.
4vtomat added a comment.

Resolved MaskRay's comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146054

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/Frontend/FrontendOptions.h
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/print-supported-extensions.c
  clang/tools/driver/cc1_main.cpp
  llvm/include/llvm/Support/RISCVISAInfo.h
  llvm/lib/Support/RISCVISAInfo.cpp

Index: llvm/lib/Support/RISCVISAInfo.cpp
===
--- llvm/lib/Support/RISCVISAInfo.cpp
+++ llvm/lib/Support/RISCVISAInfo.cpp
@@ -139,6 +139,29 @@
 {"ztso", RISCVExtensionVersion{0, 1}},
 };
 
+void llvm::riscvExtensionsHelp() {
+  errs() << "All available -march extensions for RISC-V\n\n";
+  errs() << '\t' << left_justify("Name", 20) << "Version\n";
+
+  RISCVISAInfo::OrderedExtensionMap ExtMap;
+  for (const auto  : SupportedExtensions)
+ExtMap[E.Name] = { E.Name, E.Version.Major, E.Version.Minor };
+  for (const auto  : ExtMap)
+errs() << format("\t%-20s%d.%d\n", E.first.c_str(), E.second.MajorVersion,
+ E.second.MinorVersion);
+
+  errs() << "\nExperimental extensions\n";
+  ExtMap.clear();
+  for (const auto  : SupportedExperimentalExtensions)
+ExtMap[E.Name] = { E.Name, E.Version.Major, E.Version.Minor };
+  for (const auto  : ExtMap)
+errs() << format("\t%-20s%d.%d\n", E.first.c_str(), E.second.MajorVersion,
+ E.second.MinorVersion);
+
+  errs() << "\nUse -march to specify the target's extension.\n"
+"For example, clang -march=rv32i_v1p0\n";
+}
+
 static bool stripExperimentalPrefix(StringRef ) {
   return Ext.consume_front("experimental-");
 }
Index: llvm/include/llvm/Support/RISCVISAInfo.h
===
--- llvm/include/llvm/Support/RISCVISAInfo.h
+++ llvm/include/llvm/Support/RISCVISAInfo.h
@@ -23,6 +23,8 @@
   unsigned MinorVersion;
 };
 
+void riscvExtensionsHelp();
+
 class RISCVISAInfo {
 public:
   RISCVISAInfo(const RISCVISAInfo &) = delete;
Index: clang/tools/driver/cc1_main.cpp
===
--- clang/tools/driver/cc1_main.cpp
+++ clang/tools/driver/cc1_main.cpp
@@ -38,6 +38,7 @@
 #include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Process.h"
+#include "llvm/Support/RISCVISAInfo.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/TargetSelect.h"
 #include "llvm/Support/TimeProfiler.h"
@@ -182,6 +183,14 @@
   return 0;
 }
 
+/// Print supported extensions of the RISCV target.
+static int print_supported_extensions() {
+  llvm::riscvExtensionsHelp();
+
+  return 0;
+}
+
+
 int cc1_main(ArrayRef Argv, const char *Argv0, void *MainAddr) {
   ensureSufficientStack();
 
@@ -223,6 +232,10 @@
   if (Clang->getFrontendOpts().PrintSupportedCPUs)
 return PrintSupportedCPUs(Clang->getTargetOpts().Triple);
 
+  // --print-supported-extensions takes priority over the actual compilation.
+  if (Clang->getFrontendOpts().PrintSupportedExtensions)
+return print_supported_extensions();
+
   // Infer the builtin include path if unspecified.
   if (Clang->getHeaderSearchOpts().UseBuiltinIncludes &&
   Clang->getHeaderSearchOpts().ResourceDir.empty())
Index: clang/test/Driver/print-supported-extensions.c
===
--- /dev/null
+++ clang/test/Driver/print-supported-extensions.c
@@ -0,0 +1,94 @@
+// Test that --print-supported-extensions lists supported extensions.
+
+// REQUIRES: riscv-registered-target
+
+// RUN: %clang --target=riscv64 --print-supported-extensions 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=CHECK-RISCV
+
+// CHECK-NOT: warning: argument unused during compilation
+// CHECK-RISCV: Target: riscv64
+// CHECK-NEXT: All available -march extensions for RISC-V
+// CHECK-NEXT: 	NameVersion
+// CHECK-NEXT: 	i   2.0
+// CHECK-NEXT: 	e   1.9
+// CHECK-NEXT: 	m   2.0
+// CHECK-NEXT: 	a   2.0
+// CHECK-NEXT: 	f   2.0
+// CHECK-NEXT: 	d   2.0
+// CHECK-NEXT: 	c   2.0
+// CHECK-NEXT: 	v   1.0
+// CHECK-NEXT: 	h   1.0
+// CHECK-NEXT: 	svinval 1.0
+// CHECK-NEXT: 	svnapot 1.0
+// CHECK-NEXT: 	svpbmt  1.0
+// CHECK-NEXT: 	zicbom  1.0
+// CHECK-NEXT: 	zicbop  1.0
+// CHECK-NEXT: 	zicboz  1.0
+// CHECK-NEXT: 	zicsr   2.0
+// CHECK-NEXT: 	zifencei2.0
+// CHECK-NEXT: 	zihintpause 2.0
+// CHECK-NEXT: 	zmmul   1.0
+// CHECK-NEXT: 	zawrs   1.0
+// CHECK-NEXT: 	zfh 1.0
+// CHECK-NEXT: 	zfhmin  1.0
+// CHECK-NEXT: 	zfinx  

[clang] 7f37066 - Revert "[NFC] [C++20] [Modules] Refactor Sema::isModuleUnitOfCurrentTU into"

2023-05-15 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2023-05-16T10:47:53+08:00
New Revision: 7f37066915ab330f153ede708ddc610cf2cb7bdf

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

LOG: Revert "[NFC] [C++20] [Modules] Refactor Sema::isModuleUnitOfCurrentTU 
into"

This reverts commit f109b1016801e2b0dbee278f3c517057c0b1d441 as required
in
https://github.com/llvm/llvm-project/commit/f109b1016801e2b0dbee278f3c517057c0b1d441#commitcomment-113477829.

Added: 


Modified: 
clang/include/clang/AST/ASTContext.h
clang/include/clang/AST/DeclBase.h
clang/include/clang/Sema/Sema.h
clang/lib/AST/ASTContext.cpp
clang/lib/AST/DeclBase.cpp
clang/lib/CodeGen/CGDeclCXX.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/Frontend/ASTUnit.cpp
clang/lib/Sema/SemaLookup.cpp
clang/lib/Sema/SemaModule.cpp
clang/lib/Sema/SemaOverload.cpp
clang/lib/Sema/SemaTemplate.cpp

Removed: 




diff  --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index c2e4847d1d1e8..b08eb525602b6 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -447,8 +447,9 @@ class ASTContext : public RefCountedBase {
   };
   llvm::DenseMap ModuleInitializers;
 
-  /// This is the top-level (C++20) Named module we are building.
-  Module *CurrentCXXNamedModule = nullptr;
+  /// For module code-gen cases, this is the top-level (C++20) Named module
+  /// we are building.
+  Module *TopLevelCXXNamedModule = nullptr;
 
   static constexpr unsigned ConstantArrayTypesLog2InitSize = 8;
   static constexpr unsigned GeneralTypesLog2InitSize = 9;
@@ -1051,10 +1052,10 @@ class ASTContext : public RefCountedBase {
   ArrayRef getModuleInitializers(Module *M);
 
   /// Set the (C++20) module we are building.
-  void setCurrentNamedModule(Module *M);
+  void setNamedModuleForCodeGen(Module *M) { TopLevelCXXNamedModule = M; }
 
   /// Get module under construction, nullptr if this is not a C++20 module.
-  Module *getCurrentNamedModule() const { return CurrentCXXNamedModule; }
+  Module *getNamedModuleForCodeGen() const { return TopLevelCXXNamedModule; }
 
   TranslationUnitDecl *getTranslationUnitDecl() const {
 return TUDecl->getMostRecentDecl();

diff  --git a/clang/include/clang/AST/DeclBase.h 
b/clang/include/clang/AST/DeclBase.h
index f7d5b3a83141a..e0dc6dab7b334 100644
--- a/clang/include/clang/AST/DeclBase.h
+++ b/clang/include/clang/AST/DeclBase.h
@@ -644,9 +644,6 @@ class alignas(8) Decl {
 return getModuleOwnershipKind() > ModuleOwnershipKind::VisibleWhenImported;
   }
 
-  /// Whether this declaration comes from another module unit.
-  bool isInAnotherModuleUnit() const;
-
   /// FIXME: Implement discarding declarations actually in global module
   /// fragment. See [module.global.frag]p3,4 for details.
   bool isDiscardedInGlobalModuleFragment() const { return false; }

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 4d68462e43e3e..5296d7000b5cc 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -2358,6 +2358,9 @@ class Sema final {
 return Entity->getOwningModule();
   }
 
+  // Determine whether the module M belongs to the  current TU.
+  bool isModuleUnitOfCurrentTU(const Module *M) const;
+
   /// Make a merged definition of an existing hidden definition \p ND
   /// visible at the specified location.
   void makeMergedDefinitionVisible(NamedDecl *ND);

diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index e1a230f7588c6..7fdbf4d32efe8 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -1153,13 +1153,6 @@ ArrayRef 
ASTContext::getModuleInitializers(Module *M) {
   return Inits->Initializers;
 }
 
-void ASTContext::setCurrentNamedModule(Module *M) {
-  assert(M->isModulePurview());
-  assert(!CurrentCXXNamedModule &&
- "We should set named module for ASTContext for only once");
-  CurrentCXXNamedModule = M;
-}
-
 ExternCContextDecl *ASTContext::getExternCContextDecl() const {
   if (!ExternCContext)
 ExternCContext = ExternCContextDecl::Create(*this, 
getTranslationUnitDecl());
@@ -11929,7 +11922,7 @@ bool ASTContext::DeclMustBeEmitted(const Decl *D) {
   // Variables in other module units shouldn't be forced to be emitted.
   auto *VM = VD->getOwningModule();
   if (VM && VM->getTopLevelModule()->isModulePurview() &&
-  VM->getTopLevelModule() != getCurrentNamedModule())
+  VM->getTopLevelModule() != getNamedModuleForCodeGen())
 return false;
 
   // Variables that can be needed in other TUs are required.

diff  --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp
index 834beef49a444..f49945f434193 100644
--- a/clang/lib/AST/DeclBase.cpp
+++ 

[clang] 40c3054 - [NFC] [C++20] [Modules] Refactoring b6c7177145bc to make it not

2023-05-15 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2023-05-16T10:34:02+08:00
New Revision: 40c30543892aa6441eea075ba69864e79f5de82e

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

LOG: [NFC] [C++20] [Modules] Refactoring b6c7177145bc to make it not
dependent on f109b10

Given
https://github.com/llvm/llvm-project/commit/f109b1016801e2b0dbee278f3c517057c0b1d441#commitcomment-113477829,
we need to revert f109b10. So it will be better to make this patch not
dependent on f109b10 as much as possible.

Added: 


Modified: 
clang/lib/AST/ASTContext.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index b9919073e8267..e1a230f7588c6 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -11927,7 +11927,9 @@ bool ASTContext::DeclMustBeEmitted(const Decl *D) {
 return false;
 
   // Variables in other module units shouldn't be forced to be emitted.
-  if (VD->isInAnotherModuleUnit())
+  auto *VM = VD->getOwningModule();
+  if (VM && VM->getTopLevelModule()->isModulePurview() &&
+  VM->getTopLevelModule() != getCurrentNamedModule())
 return false;
 
   // Variables that can be needed in other TUs are required.



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


[PATCH] D150614: [clang-format] Ignore first token when finding MustBreak

2023-05-15 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments.



Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:891-895
+for (const FormatToken *Tok = Line->First; Tok; Tok = Tok->Next) {
+  // Ignore the first token, because in this situation, it applies more
+  // to the last token of the previous line.
+  if (Tok == Line->First)
+continue;

We can start from the second token.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150614

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


[PATCH] D150629: [clang-format] Don't allow template to be preceded by closing brace

2023-05-15 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:10682
   verifyFormat("a < 0 ? b : a > 0 ? c : d;");
+  verifyFormat("ratio{-1, 2} < ratio{-1, 3} == -1 / 3 > -1 / 2;");
   verifyFormat("void f() {\n"

Do we need to add a token annotator test?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150629

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


[PATCH] D150629: [clang-format] Don't allow template to be preceded by closing brace

2023-05-15 Thread Emilia Kond via Phabricator via cfe-commits
rymiel created this revision.
rymiel added a project: clang-format.
rymiel added reviewers: HazardyKnusperkeks, owenpan, MyDeveloperDay.
Herald added projects: All, clang.
Herald added a subscriber: cfe-commits.
rymiel requested review of this revision.

This check is similar to the right paren check right below it, but it
doesn't need the overloaded operator check.

This patch prevents brace-initialized objects that are being compared
from being mis-annotated as template parameters.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150629

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
@@ -10679,6 +10679,7 @@
   // Not template parameters.
   verifyFormat("return a < b && c > d;");
   verifyFormat("a < 0 ? b : a > 0 ? c : d;");
+  verifyFormat("ratio{-1, 2} < ratio{-1, 3} == -1 / 3 > -1 / 2;");
   verifyFormat("void f() {\n"
"  while (a < b && c > d) {\n"
"  }\n"
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -144,6 +144,8 @@
 if (Previous.Previous) {
   if (Previous.Previous->Tok.isLiteral())
 return false;
+  if (Previous.Previous->is(tok::r_brace))
+return false;
   if (Previous.Previous->is(tok::r_paren) && Contexts.size() > 1 &&
   (!Previous.Previous->MatchingParen ||
!Previous.Previous->MatchingParen->is(


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -10679,6 +10679,7 @@
   // Not template parameters.
   verifyFormat("return a < b && c > d;");
   verifyFormat("a < 0 ? b : a > 0 ? c : d;");
+  verifyFormat("ratio{-1, 2} < ratio{-1, 3} == -1 / 3 > -1 / 2;");
   verifyFormat("void f() {\n"
"  while (a < b && c > d) {\n"
"  }\n"
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -144,6 +144,8 @@
 if (Previous.Previous) {
   if (Previous.Previous->Tok.isLiteral())
 return false;
+  if (Previous.Previous->is(tok::r_brace))
+return false;
   if (Previous.Previous->is(tok::r_paren) && Contexts.size() > 1 &&
   (!Previous.Previous->MatchingParen ||
!Previous.Previous->MatchingParen->is(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D150539: [clang-format] Handle ud suffixes in IntegerLiteralSeparator

2023-05-15 Thread Owen Pan via Phabricator via cfe-commits
owenpan updated this revision to Diff 522397.
owenpan added a comment.

Addressed the review comment.


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

https://reviews.llvm.org/D150539

Files:
  clang/lib/Format/IntegerLiteralSeparatorFixer.cpp
  clang/unittests/Format/IntegerLiteralSeparatorTest.cpp


Index: clang/unittests/Format/IntegerLiteralSeparatorTest.cpp
===
--- clang/unittests/Format/IntegerLiteralSeparatorTest.cpp
+++ clang/unittests/Format/IntegerLiteralSeparatorTest.cpp
@@ -60,6 +60,24 @@
"hil = 0xABCil;",
Style);
 
+  verifyFormat("bd = 0b1'd;\n"
+   "dh = 1'234h;\n"
+   "dmin = 1'234min;\n"
+   "dns = 1'234ns;\n"
+   "ds = 1'234s;\n"
+   "dus = 1'234us;\n"
+   "hy = 0xA'BCy;",
+   "bd = 0b1d;\n"
+   "dh = 1234h;\n"
+   "dmin = 1234min;\n"
+   "dns = 1234ns;\n"
+   "ds = 1234s;\n"
+   "dus = 1234us;\n"
+   "hy = 0xABCy;",
+   Style);
+
+  verifyFormat("hd = 0xAB'Cd;", "hd = 0xABCd;", Style);
+
   verifyFormat("d = 5'678_km;\n"
"h = 0xD'EF_u16;",
"d = 5678_km;\n"
Index: clang/lib/Format/IntegerLiteralSeparatorFixer.cpp
===
--- clang/lib/Format/IntegerLiteralSeparatorFixer.cpp
+++ clang/lib/Format/IntegerLiteralSeparatorFixer.cpp
@@ -113,7 +113,11 @@
   continue;
 }
 if (Style.isCpp()) {
-  if (const auto Pos = Text.find_first_of("_i"); Pos != StringRef::npos) {
+  // Hex alpha digits a-f/A-F must be at the end of the string literal.
+  StringRef Suffixes = "_himnsuyd";
+  if (const auto Pos =
+  Text.find_first_of(IsBase16 ? Suffixes.drop_back() : Suffixes);
+  Pos != StringRef::npos) {
 Text = Text.substr(0, Pos);
 Length = Pos;
   }


Index: clang/unittests/Format/IntegerLiteralSeparatorTest.cpp
===
--- clang/unittests/Format/IntegerLiteralSeparatorTest.cpp
+++ clang/unittests/Format/IntegerLiteralSeparatorTest.cpp
@@ -60,6 +60,24 @@
"hil = 0xABCil;",
Style);
 
+  verifyFormat("bd = 0b1'd;\n"
+   "dh = 1'234h;\n"
+   "dmin = 1'234min;\n"
+   "dns = 1'234ns;\n"
+   "ds = 1'234s;\n"
+   "dus = 1'234us;\n"
+   "hy = 0xA'BCy;",
+   "bd = 0b1d;\n"
+   "dh = 1234h;\n"
+   "dmin = 1234min;\n"
+   "dns = 1234ns;\n"
+   "ds = 1234s;\n"
+   "dus = 1234us;\n"
+   "hy = 0xABCy;",
+   Style);
+
+  verifyFormat("hd = 0xAB'Cd;", "hd = 0xABCd;", Style);
+
   verifyFormat("d = 5'678_km;\n"
"h = 0xD'EF_u16;",
"d = 5678_km;\n"
Index: clang/lib/Format/IntegerLiteralSeparatorFixer.cpp
===
--- clang/lib/Format/IntegerLiteralSeparatorFixer.cpp
+++ clang/lib/Format/IntegerLiteralSeparatorFixer.cpp
@@ -113,7 +113,11 @@
   continue;
 }
 if (Style.isCpp()) {
-  if (const auto Pos = Text.find_first_of("_i"); Pos != StringRef::npos) {
+  // Hex alpha digits a-f/A-F must be at the end of the string literal.
+  StringRef Suffixes = "_himnsuyd";
+  if (const auto Pos =
+  Text.find_first_of(IsBase16 ? Suffixes.drop_back() : Suffixes);
+  Pos != StringRef::npos) {
 Text = Text.substr(0, Pos);
 Length = Pos;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D150539: [clang-format] Handle ud suffixes in IntegerLiteralSeparator

2023-05-15 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments.



Comment at: clang/lib/Format/IntegerLiteralSeparatorFixer.cpp:116-117
 if (Style.isCpp()) {
-  if (const auto Pos = Text.find_first_of("_i"); Pos != StringRef::npos) {
+  // FIXME: This doesn't work for ud-suffix d from std::chrono::day.
+  if (const auto Pos = Text.find_first_of("_himnsuy");
+  Pos != StringRef::npos) {

HazardyKnusperkeks wrote:
> What about this?
Good idea!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150539

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


[PATCH] D150615: [clang][deps] Do not cache PCM files

2023-05-15 Thread Jan Svoboda via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG94d22b09bbb2: [clang][deps] Do not cache PCM files (authored 
by jansvoboda11).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150615

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


Index: clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
@@ -262,6 +262,9 @@
   SmallString<256> OwnedFilename;
   StringRef Filename = Path.toStringRef(OwnedFilename);
 
+  if (Filename.endswith(".pcm"))
+return getUnderlyingFS().status(Path);
+
   llvm::ErrorOr Result = getOrCreateFileSystemEntry(Filename);
   if (!Result)
 return Result.getError();
@@ -319,6 +322,9 @@
   SmallString<256> OwnedFilename;
   StringRef Filename = Path.toStringRef(OwnedFilename);
 
+  if (Filename.endswith(".pcm"))
+return getUnderlyingFS().openFileForRead(Path);
+
   llvm::ErrorOr Result = getOrCreateFileSystemEntry(Filename);
   if (!Result)
 return Result.getError();


Index: clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
@@ -262,6 +262,9 @@
   SmallString<256> OwnedFilename;
   StringRef Filename = Path.toStringRef(OwnedFilename);
 
+  if (Filename.endswith(".pcm"))
+return getUnderlyingFS().status(Path);
+
   llvm::ErrorOr Result = getOrCreateFileSystemEntry(Filename);
   if (!Result)
 return Result.getError();
@@ -319,6 +322,9 @@
   SmallString<256> OwnedFilename;
   StringRef Filename = Path.toStringRef(OwnedFilename);
 
+  if (Filename.endswith(".pcm"))
+return getUnderlyingFS().openFileForRead(Path);
+
   llvm::ErrorOr Result = getOrCreateFileSystemEntry(Filename);
   if (!Result)
 return Result.getError();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 94d22b0 - [clang][deps] Do not cache PCM files

2023-05-15 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2023-05-15T17:43:54-07:00
New Revision: 94d22b09bbb212773a226726ee03a44edbbe98c7

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

LOG: [clang][deps] Do not cache PCM files

On incremental scan, caching an out-of-date PCM on the VFS layer causes each TU 
and each module to recompile the PCM again. This is huge performance problem. 
Stop caching ".pcm" files.

Reviewed By: Bigcheese

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

Added: 


Modified: 
clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp

Removed: 




diff  --git 
a/clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp 
b/clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
index 0ddb5c24c5e6..31404855e3b1 100644
--- a/clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
+++ b/clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
@@ -262,6 +262,9 @@ DependencyScanningWorkerFilesystem::status(const Twine 
) {
   SmallString<256> OwnedFilename;
   StringRef Filename = Path.toStringRef(OwnedFilename);
 
+  if (Filename.endswith(".pcm"))
+return getUnderlyingFS().status(Path);
+
   llvm::ErrorOr Result = getOrCreateFileSystemEntry(Filename);
   if (!Result)
 return Result.getError();
@@ -319,6 +322,9 @@ DependencyScanningWorkerFilesystem::openFileForRead(const 
Twine ) {
   SmallString<256> OwnedFilename;
   StringRef Filename = Path.toStringRef(OwnedFilename);
 
+  if (Filename.endswith(".pcm"))
+return getUnderlyingFS().openFileForRead(Path);
+
   llvm::ErrorOr Result = getOrCreateFileSystemEntry(Filename);
   if (!Result)
 return Result.getError();



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


[clang] 09c5d69 - Revert "[clang][deps] Only cache files with specific extension"

2023-05-15 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2023-05-15T17:43:53-07:00
New Revision: 09c5d69592f7df4db62063e4dd231a7e154bdac6

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

LOG: Revert "[clang][deps] Only cache files with specific extension"

This reverts commit d1e00b6f136ec71a4c95a7eb4fd81ec0ab547962.

Internally, there were issues with caching stat failures for .framework 
directories. We need some time for investigation to pinpoint what exactly was 
going wrong.

Added: 


Modified: 

clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
clang/unittests/Tooling/DependencyScannerTest.cpp

Removed: 




diff  --git 
a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h 
b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
index 357a5b9423005..4b4e3c7eb2ecd 100644
--- 
a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
+++ 
b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
@@ -269,32 +269,6 @@ class EntryRef {
   }
 };
 
-enum class ScanFile { Yes, No };
-enum class CacheStatFailure { Yes, No };
-
-struct PathPolicy {
-  /// Implies caching of all open and stat results.
-  unsigned Enable : 1;
-  /// Controls whether a file will be scanned for dependency directives.
-  unsigned ScanFile : 1;
-  /// Explicitly disables stat failure caching when false.
-  unsigned CacheStatFailure : 1;
-
-  static PathPolicy fallThrough() { return {false, false, false}; }
-
-  static PathPolicy cache(enum ScanFile SF,
-  enum CacheStatFailure CSF = CacheStatFailure::Yes) {
-return {true, SF == ScanFile::Yes, CSF == CacheStatFailure::Yes};
-  }
-
-private:
-  PathPolicy(bool E, bool SF, bool CSF)
-  : Enable(E), ScanFile(SF), CacheStatFailure(CSF) {}
-};
-
-/// Determine caching and scanning behavior based on file extension.
-PathPolicy getPolicy(StringRef Filename);
-
 /// A virtual file system optimized for the dependency discovery.
 ///
 /// It is primarily designed to work with source files whose contents was
@@ -319,25 +293,24 @@ class DependencyScanningWorkerFilesystem : public 
llvm::vfs::ProxyFileSystem {
   ///
   /// Attempts to use the local and shared caches first, then falls back to
   /// using the underlying filesystem.
-  llvm::ErrorOr getOrCreateFileSystemEntry(StringRef Filename) {
-return getOrCreateFileSystemEntry(Filename, getPolicy(Filename));
-  }
+  llvm::ErrorOr
+  getOrCreateFileSystemEntry(StringRef Filename,
+ bool DisableDirectivesScanning = false);
 
 private:
-  /// Same as the public version, but with explicit PathPolicy parameter.
-  llvm::ErrorOr getOrCreateFileSystemEntry(StringRef Filename,
- PathPolicy Policy);
+  /// Check whether the file should be scanned for preprocessor directives.
+  bool shouldScanForDirectives(StringRef Filename);
 
   /// For a filename that's not yet associated with any entry in the caches,
   /// uses the underlying filesystem to either look up the entry based in the
   /// shared cache indexed by unique ID, or creates new entry from scratch.
   llvm::ErrorOr
-  computeAndStoreResult(StringRef Filename, PathPolicy Policy);
+  computeAndStoreResult(StringRef Filename);
 
   /// Scan for preprocessor directives for the given entry if necessary and
   /// returns a wrapper object with reference semantics.
   EntryRef scanForDirectivesIfNecessary(const CachedFileSystemEntry ,
-StringRef Filename, PathPolicy Policy);
+StringRef Filename, bool Disable);
 
   /// Represents a filesystem entry that has been stat-ed (and potentially 
read)
   /// and that's about to be inserted into the cache as 
`CachedFileSystemEntry`.

diff  --git 
a/clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp 
b/clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
index eb15fc532995c..0ddb5c24c5e6c 100644
--- a/clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
+++ b/clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
@@ -42,8 +42,9 @@ DependencyScanningWorkerFilesystem::readFile(StringRef 
Filename) {
 }
 
 EntryRef DependencyScanningWorkerFilesystem::scanForDirectivesIfNecessary(
-const CachedFileSystemEntry , StringRef Filename, PathPolicy Policy) 
{
-  if (Entry.isError() || Entry.isDirectory() || !Policy.ScanFile)
+const CachedFileSystemEntry , StringRef Filename, bool Disable) {
+  if (Entry.isError() || Entry.isDirectory() || Disable ||
+  !shouldScanForDirectives(Filename))
 return 

[PATCH] D150608: [clang] Convert several OpenMP tests to opaque pointers

2023-05-15 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 added a comment.

In D150608#4344170 , @jdoerfert wrote:

> LG, assuming these are stable now.
>
> We should move them to the update scripts though...

I'm not sure what you mean by this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150608

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


[PATCH] D150114: [Headers][doc] Add "add/sub/mul" intrinsic descriptions to avx2intrin.h

2023-05-15 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/lib/Headers/avx2intrin.h:156
+///A 256-bit vector containing one of the source operands.
+/// \returns A 256-bit vector containing the sums.
 static __inline__ __m256i __DEFAULT_FN_ATTRS256

Why do some return descriptions include the type like [4 x i64] but some don't?



Comment at: clang/lib/Headers/avx2intrin.h:1050
+/// \param __a
+///A 256-bit vector containing the subtrahends.
+/// \param __b

I think minuend and subtrahend are swapped here.


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

https://reviews.llvm.org/D150114

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


[PATCH] D146773: [-Wunsafe-buffer-usage] Make raw (ungrouped) warnings a bit more verbose.

2023-05-15 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:11786
+  "%select{"
+"unsafe operation on raw pointer in expression|"
+"unsafe arithmetic on raw pointer|"

malavikasamak wrote:
> NoQ wrote:
> > The first mode doesn't show up in any tests and it's probably dead code at 
> > this point.
> What do you think of specifying the variable name in these warnings? It could 
> be helpful when there are more than one DREs in a statement.  
These warnings are emitted only when we *cannot* identify the variable; either 
because it's not there at all, or we don't know how to find it. If we could 
figure out the variable, we'd be emitting `warn_unsafe_buffer_variable` 
instead. IIRC, in all of the provided test cases the operand isn't a DRE.

That said, I totally agree that it's a great idea to try a few other things to 
point out the specific subexpression, even if we don't connect the warning 
gadget to a variable. Say, we can try to blame `MemberExpr`s or `CallExpr`s the 
same way we blame DREs, and include their name in the warning. I'll try a few 
things real quick and see how bad it gets.

Note that these are also the things for which we may eventually start providing 
constructive solutions. Say, an unsafe operation on `CallExpr` can be a reason 
to autofix the callee to return a `std::span`. So hopefully these warnings will 
eventually be replaced by better warnings in more and more cases.


Repository:
  rC Clang

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

https://reviews.llvm.org/D146773

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


[PATCH] D147417: [clang-tidy] Do not emit bugprone-exception-escape warnings from coroutines

2023-05-15 Thread Deniz Evrenci via Phabricator via cfe-commits
denizevrenci updated this revision to Diff 522386.
denizevrenci added a comment.

a_shouldNotDiag -> b_shouldNotDiag


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147417

Files:
  clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape-coro.cpp
  clang/include/clang/AST/StmtCXX.h

Index: clang/include/clang/AST/StmtCXX.h
===
--- clang/include/clang/AST/StmtCXX.h
+++ clang/include/clang/AST/StmtCXX.h
@@ -443,6 +443,17 @@
NumParams);
   }
 
+  child_range childrenExclBody() {
+return child_range(getStoredStmts() + SubStmt::Body + 1,
+   getStoredStmts() + SubStmt::FirstParamMove + NumParams);
+  }
+
+  const_child_range childrenExclBody() const {
+return const_child_range(getStoredStmts() + SubStmt::Body + 1,
+ getStoredStmts() + SubStmt::FirstParamMove +
+ NumParams);
+  }
+
   static bool classof(const Stmt *T) {
 return T->getStmtClass() == CoroutineBodyStmtClass;
   }
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape-coro.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape-coro.cpp
@@ -0,0 +1,296 @@
+// RUN: %check_clang_tidy -std=c++20 %s bugprone-exception-escape %t -- \
+// RUN: -- -fexceptions
+
+namespace std {
+
+template  struct coroutine_traits {
+  using promise_type = typename Ret::promise_type;
+};
+
+template  struct coroutine_handle {
+  static coroutine_handle from_address(void *) noexcept;
+  static coroutine_handle from_promise(Promise );
+  constexpr void *address() const noexcept;
+};
+
+template <> struct coroutine_handle {
+  template 
+  coroutine_handle(coroutine_handle) noexcept;
+  static coroutine_handle from_address(void *);
+  constexpr void *address() const noexcept;
+};
+
+struct suspend_always {
+  bool await_ready() noexcept { return false; }
+  void await_suspend(coroutine_handle<>) noexcept {}
+  void await_resume() noexcept {}
+};
+
+struct suspend_never {
+  bool await_ready() noexcept { return true; }
+  void await_suspend(coroutine_handle<>) noexcept {}
+  void await_resume() noexcept {}
+};
+
+} // namespace std
+
+template 
+struct Promise;
+
+template <
+typename T, bool ThrowInTaskConstructor = false,
+bool ThrowInPromiseConstructor = false, bool ThrowInInitialSuspend = false,
+bool ThrowInGetReturnObject = false, bool ThrowInUnhandledException = false>
+struct Task {
+  using promise_type =
+  Promise;
+
+  explicit Task(promise_type ) {
+if constexpr (ThrowInTaskConstructor) {
+  throw 1;
+}
+
+p.return_val = this;
+  }
+
+  T value;
+};
+
+template 
+struct Promise {
+  Promise() {
+if constexpr (ThrowInPromiseConstructor) {
+  throw 1;
+}
+  }
+
+  Task get_return_object() {
+if constexpr (ThrowInGetReturnObject) {
+  throw 1;
+}
+
+return Task{*this};
+  }
+
+  std::suspend_never initial_suspend() const {
+if constexpr (ThrowInInitialSuspend) {
+  throw 1;
+}
+
+return {};
+  }
+
+  std::suspend_never final_suspend() const noexcept { return {}; }
+
+  template  void return_value(U &) {
+return_val->value = static_cast(val);
+  }
+
+  void unhandled_exception() {
+if constexpr (ThrowInUnhandledException) {
+  throw 1;
+}
+  }
+
+  Task *return_val;
+};
+
+struct Evil {
+  ~Evil() noexcept(false) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: an exception may be thrown in function '~Evil' which should not throw exceptions
+throw 42;
+  }
+};
+
+namespace function {
+
+Task a_ShouldNotDiag(const int a, const int b) {
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:11: warning: an exception may be thrown in function 'a_ShouldNotDiag' which should not throw exceptions
+  if (b == 0)
+throw b;
+
+  co_return a / b;
+}
+
+Task b_ShouldNotDiag(const int a, const int b) noexcept {
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:11: warning: an exception may be thrown in function 'b_ShouldNotDiag' which should not throw exceptions
+  if (b == 0)
+throw b;
+
+  co_return a / b;
+}
+
+Task c_ShouldNotDiag(const int a, const int b) {
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:11: warning: an exception may be thrown in function 'c_ShouldNotDiag' which should not throw exceptions
+  if (b == 0)
+throw Evil{};
+
+  co_return a / b;
+}
+
+Task c_ShouldDiag(const int a, const int b) noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: an exception may be thrown in function 'c_ShouldDiag' which should not throw exceptions
+  if (b == 0)
+throw Evil{};
+
+  co_return a / b;
+}
+
+Task d_ShouldNotDiag(const int a, const int b) {
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:17: warning: an 

[PATCH] D149642: [RISCV] Support vreinterpret intrinsics between vector boolean type and m1 vector integer type

2023-05-15 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper 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/D149642/new/

https://reviews.llvm.org/D149642

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


[PATCH] D147417: [clang-tidy] Do not emit bugprone-exception-escape warnings from coroutines

2023-05-15 Thread Deniz Evrenci via Phabricator via cfe-commits
denizevrenci updated this revision to Diff 522381.
denizevrenci added a comment.
Herald added a project: clang.

Address comments. Implement a special case for coroutines in ExceptionAnalyzer


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147417

Files:
  clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape-coro.cpp
  clang/include/clang/AST/StmtCXX.h

Index: clang/include/clang/AST/StmtCXX.h
===
--- clang/include/clang/AST/StmtCXX.h
+++ clang/include/clang/AST/StmtCXX.h
@@ -443,6 +443,17 @@
NumParams);
   }
 
+  child_range childrenExclBody() {
+return child_range(getStoredStmts() + SubStmt::Body + 1,
+   getStoredStmts() + SubStmt::FirstParamMove + NumParams);
+  }
+
+  const_child_range childrenExclBody() const {
+return const_child_range(getStoredStmts() + SubStmt::Body + 1,
+ getStoredStmts() + SubStmt::FirstParamMove +
+ NumParams);
+  }
+
   static bool classof(const Stmt *T) {
 return T->getStmtClass() == CoroutineBodyStmtClass;
   }
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape-coro.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape-coro.cpp
@@ -0,0 +1,296 @@
+// RUN: %check_clang_tidy -std=c++20 %s bugprone-exception-escape %t -- \
+// RUN: -- -fexceptions
+
+namespace std {
+
+template  struct coroutine_traits {
+  using promise_type = typename Ret::promise_type;
+};
+
+template  struct coroutine_handle {
+  static coroutine_handle from_address(void *) noexcept;
+  static coroutine_handle from_promise(Promise );
+  constexpr void *address() const noexcept;
+};
+
+template <> struct coroutine_handle {
+  template 
+  coroutine_handle(coroutine_handle) noexcept;
+  static coroutine_handle from_address(void *);
+  constexpr void *address() const noexcept;
+};
+
+struct suspend_always {
+  bool await_ready() noexcept { return false; }
+  void await_suspend(coroutine_handle<>) noexcept {}
+  void await_resume() noexcept {}
+};
+
+struct suspend_never {
+  bool await_ready() noexcept { return true; }
+  void await_suspend(coroutine_handle<>) noexcept {}
+  void await_resume() noexcept {}
+};
+
+} // namespace std
+
+template 
+struct Promise;
+
+template <
+typename T, bool ThrowInTaskConstructor = false,
+bool ThrowInPromiseConstructor = false, bool ThrowInInitialSuspend = false,
+bool ThrowInGetReturnObject = false, bool ThrowInUnhandledException = false>
+struct Task {
+  using promise_type =
+  Promise;
+
+  explicit Task(promise_type ) {
+if constexpr (ThrowInTaskConstructor) {
+  throw 1;
+}
+
+p.return_val = this;
+  }
+
+  T value;
+};
+
+template 
+struct Promise {
+  Promise() {
+if constexpr (ThrowInPromiseConstructor) {
+  throw 1;
+}
+  }
+
+  Task get_return_object() {
+if constexpr (ThrowInGetReturnObject) {
+  throw 1;
+}
+
+return Task{*this};
+  }
+
+  std::suspend_never initial_suspend() const {
+if constexpr (ThrowInInitialSuspend) {
+  throw 1;
+}
+
+return {};
+  }
+
+  std::suspend_never final_suspend() const noexcept { return {}; }
+
+  template  void return_value(U &) {
+return_val->value = static_cast(val);
+  }
+
+  void unhandled_exception() {
+if constexpr (ThrowInUnhandledException) {
+  throw 1;
+}
+  }
+
+  Task *return_val;
+};
+
+struct Evil {
+  ~Evil() noexcept(false) {
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: an exception may be thrown in function '~Evil' which should not throw exceptions
+throw 42;
+  }
+};
+
+namespace function {
+
+Task a_ShouldNotDiag(const int a, const int b) {
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:11: warning: an exception may be thrown in function 'a_ShouldNotDiag' which should not throw exceptions
+  if (b == 0)
+throw b;
+
+  co_return a / b;
+}
+
+Task b_ShouldNotDiag(const int a, const int b) noexcept {
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:11: warning: an exception may be thrown in function 'a_ShouldNotDiag' which should not throw exceptions
+  if (b == 0)
+throw b;
+
+  co_return a / b;
+}
+
+Task c_ShouldNotDiag(const int a, const int b) {
+  // CHECK-MESSAGES-NOT: :[[@LINE-1]]:11: warning: an exception may be thrown in function 'c_ShouldNotDiag' which should not throw exceptions
+  if (b == 0)
+throw Evil{};
+
+  co_return a / b;
+}
+
+Task c_ShouldDiag(const int a, const int b) noexcept {
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: an exception may be thrown in function 'c_ShouldDiag' which should not throw exceptions
+  if (b == 0)
+throw Evil{};
+
+  co_return a / b;
+}
+
+Task d_ShouldNotDiag(const int 

[PATCH] D150608: [clang] Convert several OpenMP tests to opaque pointers

2023-05-15 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, assuming these are stable now.

We should move them to the update scripts though...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150608

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


[PATCH] D149119: [CMake] Use LLVM own tools in extract_symbols.py

2023-05-15 Thread Igor Kudrin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf649599ea933: [CMake] Use LLVM own tools in 
extract_symbols.py (authored by ikudrin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149119

Files:
  llvm/CMakeLists.txt
  llvm/cmake/modules/AddLLVM.cmake
  llvm/cmake/modules/CrossCompile.cmake
  llvm/tools/llvm-nm/CMakeLists.txt
  llvm/tools/llvm-readobj/CMakeLists.txt
  llvm/tools/llvm-shlib/CMakeLists.txt
  llvm/utils/extract_symbols.py

Index: llvm/utils/extract_symbols.py
===
--- llvm/utils/extract_symbols.py
+++ llvm/utils/extract_symbols.py
@@ -23,30 +23,20 @@
 import multiprocessing
 import argparse
 
-# Define functions which extract a list of pairs of (symbols, is_def) from a
-# library using several different tools. We use subprocess.Popen and yield a
-# symbol at a time instead of using subprocess.check_output and returning a list
-# as, especially on Windows, waiting for the entire output to be ready can take
-# a significant amount of time.
-
-def dumpbin_get_symbols(lib):
-process = subprocess.Popen(['dumpbin','/symbols',lib], bufsize=1,
-   stdout=subprocess.PIPE, stdin=subprocess.PIPE,
-   universal_newlines=True)
-process.stdin.close()
-for line in process.stdout:
-# Look for external symbols
-match = re.match("^.+(SECT|UNDEF).+External\s+\|\s+(\S+).*$", line)
-if match:
-yield (match.group(2), match.group(1) != "UNDEF")
-process.wait()
-
-def nm_get_symbols(lib):
-# -P means the output is in portable format, and -g means we only get global
-# symbols.
-cmd = ['nm','-P','-g']
-if sys.platform.startswith('aix'):
-cmd += ['-Xany','-C','-p']
+# Define a function which extracts a list of pairs of (symbols, is_def) from a
+# library using llvm-nm becuase it can work both with regular and bitcode files.
+# We use subprocess.Popen and yield a symbol at a time instead of using
+# subprocess.check_output and returning a list as, especially on Windows, waiting
+# for the entire output to be ready can take a significant amount of time.
+def nm_get_symbols(tool, lib):
+# '-P' means the output is in portable format,
+# '-g' means we only get global symbols,
+# '-Xany' enforce handling both 32- and 64-bit objects on AIX,
+# '--no-demangle' ensure that C++ symbol names are not demangled; note
+#   that llvm-nm do not demangle by default, but the system nm on AIX does
+#   that, so the behavior may change in the future,
+# '-p' do not waste time sorting the symbols.
+cmd = [tool,'-P','-g','-Xany','--no-demangle','-p']
 process = subprocess.Popen(cmd+[lib], bufsize=1,
stdout=subprocess.PIPE, stdin=subprocess.PIPE,
universal_newlines=True)
@@ -68,61 +58,10 @@
 yield (match.group(1), False)
 process.wait()
 
-def readobj_get_symbols(lib):
-process = subprocess.Popen(['llvm-readobj','--symbols',lib], bufsize=1,
-   stdout=subprocess.PIPE, stdin=subprocess.PIPE,
-   universal_newlines=True)
-process.stdin.close()
-for line in process.stdout:
-# When looking through the output of llvm-readobj we expect to see Name,
-# Section, then StorageClass, so record Name and Section when we see
-# them and decide if this is an external symbol when we see
-# StorageClass.
-match = re.search('Name: (\S+)', line)
-if match:
-name = match.group(1)
-match = re.search('Section: (\S+)', line)
-if match:
-section = match.group(1)
-match = re.search('StorageClass: (\S+)', line)
-if match:
-storageclass = match.group(1)
-if section != 'IMAGE_SYM_ABSOLUTE' and \
-   storageclass == 'External':
-yield (name, section != 'IMAGE_SYM_UNDEFINED')
-process.wait()
-
-# Define functions which determine if the target is 32-bit Windows (as that's
+# Define a function which determines if the target is 32-bit Windows (as that's
 # where calling convention name decoration happens).
-
-def dumpbin_is_32bit_windows(lib):
-# dumpbin /headers can output a huge amount of data (>100MB in a debug
-# build) so we read only up to the 'machine' line then close the output.
-process = subprocess.Popen(['dumpbin','/headers',lib], bufsize=1,
-   stdout=subprocess.PIPE, stdin=subprocess.PIPE,
-   universal_newlines=True)
-process.stdin.close()
-retval = False
-for line in process.stdout:
-match = re.match('.+machine \((\S+)\)', line)
-if match:
-retval = (match.group(1) == 'x86')
-

[PATCH] D146178: [Clang][Sema] Fix comparison of constraint expressions

2023-05-15 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexander-shaposhnikov added a comment.

@erichkeane - I took your example and tried to reduce it further
https://godbolt.org/z/jEx9vdj7K

It's kind of a difficult situation - both gcc and msvc accept it, yet /* very 
very cautiously */ it might happen that the code is actually invalid ...
(i'd need to think about it more), but this is based on the insights from 
@rsmith  and http://eel.is/c++draft/temp.constr#atomic-3.sentence-5 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146178

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


[PATCH] D150608: [clang] Convert several OpenMP tests to opaque pointers

2023-05-15 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 added a comment.

I first manually converted a few tests (mostly with regexes), then I checked 
that the script 

 produces the same result. The result was identical to the letter.
The rest of the tests were converted using the script. There were a few issues 
that I had to resolve manually, one of them is mentioned above.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150608

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


[PATCH] D143967: [DebugInfo][BPF] Add 'btf:type_tag' annotation in DWARF

2023-05-15 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song added a comment.

@dblaikie could you help take a look at this patch? Similar to 
https://reviews.llvm.org/D143966, this patch is the clang frontend change to 
support new btf_type_tag format, as we discussed and agreed with gcc community 
(https://lore.kernel.org/bpf/87r0w9jjoq@oracle.com/). Please let us know if 
you have any questions. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143967

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


[PATCH] D150608: [clang] Convert several OpenMP tests to opaque pointers

2023-05-15 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

Did you manually update these tests?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150608

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


[PATCH] D150340: [SEH]:Fix assertion when try is used inside catch(...) block with /EHa

2023-05-15 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM... but I don't think the IR we're generating is really correct overall; 
see https://github.com/llvm/llvm-project/issues/62723

On a side-note, other open issues related to -EHa/__try:

https://github.com/llvm/llvm-project/issues/62606
D124642 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150340

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


[PATCH] D150615: [clang][deps] Do not cache PCM files

2023-05-15 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added a reviewer: Bigcheese.
Herald added a subscriber: ributzka.
Herald added a project: All.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

On incremental scan, caching an out-of-date PCM on the VFS layer causes each TU 
and each module to recompile the PCM again. This is huge performance problem. 
Stop caching ".pcm" files.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150615

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


Index: clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
@@ -262,6 +262,9 @@
   SmallString<256> OwnedFilename;
   StringRef Filename = Path.toStringRef(OwnedFilename);
 
+  if (Filename.endswith(".pcm"))
+return getUnderlyingFS().status(Path);
+
   llvm::ErrorOr Result = getOrCreateFileSystemEntry(Filename);
   if (!Result)
 return Result.getError();
@@ -319,6 +322,9 @@
   SmallString<256> OwnedFilename;
   StringRef Filename = Path.toStringRef(OwnedFilename);
 
+  if (Filename.endswith(".pcm"))
+return getUnderlyingFS().openFileForRead(Path);
+
   llvm::ErrorOr Result = getOrCreateFileSystemEntry(Filename);
   if (!Result)
 return Result.getError();


Index: clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
@@ -262,6 +262,9 @@
   SmallString<256> OwnedFilename;
   StringRef Filename = Path.toStringRef(OwnedFilename);
 
+  if (Filename.endswith(".pcm"))
+return getUnderlyingFS().status(Path);
+
   llvm::ErrorOr Result = getOrCreateFileSystemEntry(Filename);
   if (!Result)
 return Result.getError();
@@ -319,6 +322,9 @@
   SmallString<256> OwnedFilename;
   StringRef Filename = Path.toStringRef(OwnedFilename);
 
+  if (Filename.endswith(".pcm"))
+return getUnderlyingFS().openFileForRead(Path);
+
   llvm::ErrorOr Result = getOrCreateFileSystemEntry(Filename);
   if (!Result)
 return Result.getError();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D139834: [clang-format] AllowShortCompoundRequirementOnASingleLine

2023-05-15 Thread Emilia Kond via Phabricator via cfe-commits
rymiel accepted this revision.
rymiel added a comment.
This revision is now accepted and ready to land.

I see nothing wrong with this patch alone as it currently stands, since it's a 
quite simple change to the LineJoiner, and I see it as one of the final 
stopgaps in clang-format's support for requires clauses, and I think it 
definitely beats the current buggy behavior where behaviour is conflated with 
BraceWrapping.AfterFunction.
But I'd like other reviewers to maybe have another look?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139834

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


[PATCH] D150608: [clang] Convert several OpenMP tests to opaque pointers

2023-05-15 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 updated this revision to Diff 522342.
barannikov88 added a comment.

Throw in a few more tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150608

Files:
  clang/test/OpenMP/master_taskloop_codegen.cpp
  clang/test/OpenMP/master_taskloop_firstprivate_codegen.cpp
  clang/test/OpenMP/master_taskloop_lastprivate_codegen.cpp
  clang/test/OpenMP/master_taskloop_private_codegen.cpp
  clang/test/OpenMP/master_taskloop_simd_codegen.cpp
  clang/test/OpenMP/master_taskloop_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/master_taskloop_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/master_taskloop_simd_private_codegen.cpp
  clang/test/OpenMP/task_codegen.c
  clang/test/OpenMP/task_firstprivate_codegen.cpp
  clang/test/OpenMP/task_in_task_firstprivate_codegen.cpp
  clang/test/OpenMP/task_private_codegen.cpp
  clang/test/OpenMP/taskloop_codegen.cpp
  clang/test/OpenMP/taskloop_firstprivate_codegen.cpp
  clang/test/OpenMP/taskloop_lastprivate_codegen.cpp
  clang/test/OpenMP/taskloop_private_codegen.cpp
  clang/test/OpenMP/taskloop_simd_codegen.cpp
  clang/test/OpenMP/taskloop_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/taskloop_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/taskloop_simd_private_codegen.cpp

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


[PATCH] D143967: [DebugInfo][BPF] Add 'btf:type_tag' annotation in DWARF

2023-05-15 Thread Eduard Zingerman via Phabricator via cfe-commits
eddyz87 updated this revision to Diff 522338.
eddyz87 edited the summary of this revision.
eddyz87 added a comment.

Changes to avoid attaching type tags to DWARF derived types for 
const/volatile/restrict qualifiers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143967

Files:
  clang/lib/AST/ASTContext.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/test/CodeGen/attr-btf_type_tag-circular.c
  clang/test/CodeGen/attr-btf_type_tag-func-ptr.c
  clang/test/CodeGen/attr-btf_type_tag-func.c
  clang/test/CodeGen/attr-btf_type_tag-similar-type.c
  clang/test/CodeGen/attr-btf_type_tag-typedef-field.c
  clang/test/CodeGen/attr-btf_type_tag-var.c
  clang/test/CodeGen/attr-btf_type_tag-void.c
  llvm/include/llvm/IR/DIBuilder.h
  llvm/lib/IR/DIBuilder.cpp

Index: llvm/lib/IR/DIBuilder.cpp
===
--- llvm/lib/IR/DIBuilder.cpp
+++ llvm/lib/IR/DIBuilder.cpp
@@ -352,6 +352,17 @@
 Annotations);
 }
 
+DIDerivedType *
+DIBuilder::createAnnotationsPlaceholder(DIType *Ty, DINodeArray Annotations) {
+  auto *RetTy =
+  DIDerivedType::getTemporary(
+  VMContext, dwarf::DW_TAG_LLVM_annotation, "", nullptr, 0, nullptr, Ty,
+  0, 0, 0, std::nullopt, DINode::FlagZero, nullptr, Annotations)
+  .release();
+  trackIfUnresolved(RetTy);
+  return RetTy;
+}
+
 DIDerivedType *DIBuilder::createFriend(DIType *Ty, DIType *FriendTy) {
   assert(Ty && "Invalid type!");
   assert(FriendTy && "Invalid friend type!");
Index: llvm/include/llvm/IR/DIBuilder.h
===
--- llvm/include/llvm/IR/DIBuilder.h
+++ llvm/include/llvm/IR/DIBuilder.h
@@ -284,6 +284,9 @@
  DINode::DIFlags Flags = DINode::FlagZero,
  DINodeArray Annotations = nullptr);
 
+DIDerivedType *createAnnotationsPlaceholder(DIType *Ty,
+DINodeArray Annotations);
+
 /// Create debugging information entry for a 'friend'.
 DIDerivedType *createFriend(DIType *Ty, DIType *FriendTy);
 
Index: clang/test/CodeGen/attr-btf_type_tag-void.c
===
--- /dev/null
+++ clang/test/CodeGen/attr-btf_type_tag-void.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple %itanium_abi_triple -debug-info-kind=limited -S -emit-llvm -o - %s | FileCheck %s
+
+#define __tag1 __attribute__((btf_type_tag("tag1")))
+void __tag1 *g;
+
+// CHECK: distinct !DIGlobalVariable(name: "g", scope: ![[#]], file: ![[#]], line: [[#]], type: ![[L1:[0-9]+]], isLocal: false, isDefinition: true)
+// CHECK: ![[L1]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: ![[L2:[0-9]+]], size: [[#]], annotations: ![[L3:[0-9]+]])
+// CHECK: ![[L2]] = !DIBasicType(tag: DW_TAG_unspecified_type, name: "void", annotations: ![[L4:[0-9]+]])
+// CHECK: ![[L4]] = !{![[L5:[0-9]+]]}
+// CHECK: ![[L5]] = !{!"btf:type_tag", !"tag1"}
+// CHECK: ![[L3]] = !{![[L6:[0-9]+]]}
+// CHECK: ![[L6]] = !{!"btf_type_tag", !"tag1"}
Index: clang/test/CodeGen/attr-btf_type_tag-var.c
===
--- clang/test/CodeGen/attr-btf_type_tag-var.c
+++ clang/test/CodeGen/attr-btf_type_tag-var.c
@@ -21,23 +21,30 @@
 const int __tag1 __tag2 volatile * const __tag3  __tag4  volatile * __tag5  __tag6 const volatile * g;
 #endif
 
-// CHECK:  distinct !DIGlobalVariable(name: "g", scope: ![[#]], file: ![[#]], line: [[#]], type: ![[L6:[0-9]+]]
-// CHECK:  ![[L6]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: ![[L7:[0-9]+]], size: [[#]], annotations: ![[L22:[0-9]+]]
-// CHECK:  ![[L7]] = !DIDerivedType(tag: DW_TAG_const_type, baseType: ![[L8:[0-9]+]]
-// CHECK:  ![[L8]] = !DIDerivedType(tag: DW_TAG_volatile_type, baseType: ![[L9:[0-9]+]]
-// CHECK:  ![[L9]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: ![[L10:[0-9]+]], size: [[#]], annotations: ![[L19:[0-9]+]]
-// CHECK:  ![[L10]] = !DIDerivedType(tag: DW_TAG_const_type, baseType: ![[L11:[0-9]+]]
-// CHECK:  ![[L11]] = !DIDerivedType(tag: DW_TAG_volatile_type, baseType: ![[L12:[0-9]+]]
-// CHECK:  ![[L12]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: ![[L13:[0-9]+]], size: [[#]], annotations: ![[L16:[0-9]+]]
-// CHECK:  ![[L13]] = !DIDerivedType(tag: DW_TAG_const_type, baseType: ![[L14:[0-9]+]]
-// CHECK:  ![[L14]] = !DIDerivedType(tag: DW_TAG_volatile_type, baseType: ![[L15:[0-9]+]]
-// CHECK:  ![[L15]] = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed
-// CHECK:  ![[L16]] = !{![[L17:[0-9]+]], ![[L18:[0-9]+]]}
-// CHECK:  ![[L17]] = !{!"btf_type_tag", !"tag1"}
-// CHECK:  ![[L18]] = !{!"btf_type_tag", !"tag2"}
-// CHECK:  ![[L19]] = !{![[L20:[0-9]+]], ![[L21:[0-9]+]]}
-// CHECK:  ![[L20]] = !{!"btf_type_tag", !"tag3"}
-// CHECK:  ![[L21]] = !{!"btf_type_tag", !"tag4"}
-// 

[PATCH] D150614: [clang-format] Ignore first token when finding MustBreak

2023-05-15 Thread Emilia Kond via Phabricator via cfe-commits
rymiel created this revision.
rymiel added a project: clang-format.
rymiel added reviewers: HazardyKnusperkeks, owenpan, MyDeveloperDay.
Herald added projects: All, clang.
Herald added a subscriber: cfe-commits.
rymiel requested review of this revision.

When in ColumnLimit 0, the formatter looks for MustBreakBefore in the
line in order to check if a line is allowed to be merged onto one line.

However, since MustBreakBefore is really a property of the gap between
the token and the one previously, I belive the check is erroneous in
checking all the tokens in a line, since whether the previous line ended
with a forced line break should have no effect on whether the current
line is allowed to merge with the next one.

This patch changes the check to skip the first token in
`LineJoiner.containsMustBreak`.

This patch also changes a test, which is not ideal, but I believe the
test also suffered from this bug. The test case in question sets
AllowShortFunctionsOnASingleLine to "Empty", but the empty function in
said test case isn't merged to a single line, because of the very same
bug this patch fixes.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150614

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -13831,6 +13831,20 @@
 "}",
 format("A()\n:b(0)\n{\n}", NoColumnLimit));
 
+  FormatStyle NoColumnLimitWrapAfterFunction = NoColumnLimit;
+  NoColumnLimitWrapAfterFunction.BreakBeforeBraces = FormatStyle::BS_Custom;
+  NoColumnLimitWrapAfterFunction.BraceWrapping.AfterFunction = true;
+  verifyFormat("class C {\n"
+   "#pragma foo\n"
+   "  int foo { return 0; }\n"
+   "};",
+   NoColumnLimitWrapAfterFunction);
+  verifyFormat("class C {\n"
+   "#pragma foo\n"
+   "  void foo {}\n"
+   "};",
+   NoColumnLimitWrapAfterFunction);
+
   FormatStyle DoNotMergeNoColumnLimit = NoColumnLimit;
   DoNotMergeNoColumnLimit.AllowShortFunctionsOnASingleLine =
   FormatStyle::SFS_None;
@@ -20119,9 +20133,7 @@
"  int i = 5;\n"
"  }\n"
"#ifdef _DEBUG\n"
-   "void bar()\n"
-   "  {\n"
-   "  }\n"
+   "void bar() {}\n"
"#else\n"
"void bar()\n"
"  {\n"
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -888,9 +888,14 @@
   }
 
   bool containsMustBreak(const AnnotatedLine *Line) {
-for (const FormatToken *Tok = Line->First; Tok; Tok = Tok->Next)
+for (const FormatToken *Tok = Line->First; Tok; Tok = Tok->Next) {
+  // Ignore the first token, because in this situation, it applies more
+  // to the last token of the previous line.
+  if (Tok == Line->First)
+continue;
   if (Tok->MustBreakBefore)
 return true;
+}
 return false;
   }
 


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -13831,6 +13831,20 @@
 "}",
 format("A()\n:b(0)\n{\n}", NoColumnLimit));
 
+  FormatStyle NoColumnLimitWrapAfterFunction = NoColumnLimit;
+  NoColumnLimitWrapAfterFunction.BreakBeforeBraces = FormatStyle::BS_Custom;
+  NoColumnLimitWrapAfterFunction.BraceWrapping.AfterFunction = true;
+  verifyFormat("class C {\n"
+   "#pragma foo\n"
+   "  int foo { return 0; }\n"
+   "};",
+   NoColumnLimitWrapAfterFunction);
+  verifyFormat("class C {\n"
+   "#pragma foo\n"
+   "  void foo {}\n"
+   "};",
+   NoColumnLimitWrapAfterFunction);
+
   FormatStyle DoNotMergeNoColumnLimit = NoColumnLimit;
   DoNotMergeNoColumnLimit.AllowShortFunctionsOnASingleLine =
   FormatStyle::SFS_None;
@@ -20119,9 +20133,7 @@
"  int i = 5;\n"
"  }\n"
"#ifdef _DEBUG\n"
-   "void bar()\n"
-   "  {\n"
-   "  }\n"
+   "void bar() {}\n"
"#else\n"
"void bar()\n"
"  {\n"
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -888,9 +888,14 @@
   }
 
   bool containsMustBreak(const AnnotatedLine *Line) {
-for (const 

[PATCH] D150403: [clang-format] Adjust braced list detection (try 2)

2023-05-15 Thread Galen Elias via Phabricator via cfe-commits
galenelias added a comment.

Thanks @HazardyKnusperkeks!  I don't have commit access, so will need someone 
to land this for me.


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

https://reviews.llvm.org/D150403

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


[PATCH] D150608: [clang] Convert several OpenMP tests to opaque pointers

2023-05-15 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 added inline comments.



Comment at: clang/test/OpenMP/task_firstprivate_codegen.cpp:264
 
-// CHECK: alloca i32*,
-// CHECK: [[PRIV_T_VAR_ADDR:%.+]] = alloca i32*,
-// CHECK: [[PRIV_S_ARR_ADDR:%.+]] = alloca [2 x [[S_DOUBLE_TY]]]*,
-// CHECK: [[PRIV_VEC_ADDR:%.+]] = alloca [2 x i32]*,
-// CHECK: [[PRIV_SIVAR_ADDR:%.+]] = alloca i32*,
-// CHECK: [[PRIV_VAR_ADDR:%.+]] = alloca [[S_DOUBLE_TY]]*,
-// CHECK: store void (i8*, ...)* bitcast (void ([[PRIVATES_MAIN_TY]]*, i32**, 
[2 x [[S_DOUBLE_TY]]]**, [2 x i32]**, i32**, [[S_DOUBLE_TY]]**)* 
[[PRIVATES_MAP_FN]] to void (i8*, ...)*), void (i8*, ...)** [[MAP_FN_ADDR:%.+]],
-// CHECK: [[MAP_FN:%.+]] = load void (i8*, ...)*, void (i8*, ...)** 
[[MAP_FN_ADDR]],
+// CHECK: %__context
+// CHECK: [[PRIV_T_VAR_ADDR:%.+]] = alloca ptr,

barannikov88 wrote:
> There is a bunch of `alloca ptr,` before the next CHECK lines. The exect 
> number differs between tests.
> I couldn't find a better solution than to rely on the name of one of them.
> 
E.g.:
```
  %.part_id..addr.i = alloca ptr, align 8
  %.privates..addr.i = alloca ptr, align 8
  %.copy_fn..addr.i = alloca ptr, align 8
  %.task_t..addr.i = alloca ptr, align 8
  %__context.addr.i = alloca ptr, align 8
  %.firstpriv.ptr.addr.i = alloca ptr, align 8
  %.firstpriv.ptr.addr1.i = alloca ptr, align 8
  %.firstpriv.ptr.addr2.i = alloca ptr, align 8
  %ref.tmp.i = alloca %class.anon.0, align 8
```
and we need to match the `firstpriv` ones. It so happens that in all tests 
`%__context` precedes the interesting lines.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150608

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


[PATCH] D150253: [RISCV] Add Zvfhmin extension.

2023-05-15 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a subscriber: michaelmaitland.
craig.topper added a comment.

In D150253#4341545 , @jacquesguan 
wrote:

> To enable specific EEW for specific insturction in instruction selection, I 
> will create some parent revisions. Here is the first one. 
> https://reviews.llvm.org/D150550

@michaelmaitland was also going to be working on supporting Zvfhmin for SiFive. 
Maybe we can split up and share some of the work?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150253

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


[PATCH] D150608: [clang] Convert several OpenMP tests to opaque pointers

2023-05-15 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 added inline comments.



Comment at: clang/test/OpenMP/task_firstprivate_codegen.cpp:264
 
-// CHECK: alloca i32*,
-// CHECK: [[PRIV_T_VAR_ADDR:%.+]] = alloca i32*,
-// CHECK: [[PRIV_S_ARR_ADDR:%.+]] = alloca [2 x [[S_DOUBLE_TY]]]*,
-// CHECK: [[PRIV_VEC_ADDR:%.+]] = alloca [2 x i32]*,
-// CHECK: [[PRIV_SIVAR_ADDR:%.+]] = alloca i32*,
-// CHECK: [[PRIV_VAR_ADDR:%.+]] = alloca [[S_DOUBLE_TY]]*,
-// CHECK: store void (i8*, ...)* bitcast (void ([[PRIVATES_MAIN_TY]]*, i32**, 
[2 x [[S_DOUBLE_TY]]]**, [2 x i32]**, i32**, [[S_DOUBLE_TY]]**)* 
[[PRIVATES_MAP_FN]] to void (i8*, ...)*), void (i8*, ...)** [[MAP_FN_ADDR:%.+]],
-// CHECK: [[MAP_FN:%.+]] = load void (i8*, ...)*, void (i8*, ...)** 
[[MAP_FN_ADDR]],
+// CHECK: %__context
+// CHECK: [[PRIV_T_VAR_ADDR:%.+]] = alloca ptr,

There is a bunch of `alloca ptr,` before the next CHECK lines. The exect number 
differs between tests.
I couldn't find a better solution than to rely on the name of one of them.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150608

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


[PATCH] D150494: [clang][modules] NFC: Only sort interesting identifiers

2023-05-15 Thread Jan Svoboda via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf60cc473b82b: [clang][modules] NFC: Only sort interesting 
identifiers (authored by jansvoboda11).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150494

Files:
  clang/lib/Serialization/ASTWriter.cpp


Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -3645,13 +3645,13 @@
 // file.
 SmallVector IIs;
 for (const auto  : PP.getIdentifierTable())
-  IIs.push_back(ID.second);
-// Sort the identifiers lexicographically before getting them references so
+  if (Trait.isInterestingNonMacroIdentifier(ID.second))
+IIs.push_back(ID.second);
+// Sort the identifiers lexicographically before getting the references so
 // that their order is stable.
 llvm::sort(IIs, llvm::deref>());
 for (const IdentifierInfo *II : IIs)
-  if (Trait.isInterestingNonMacroIdentifier(II))
-getIdentifierRef(II);
+  getIdentifierRef(II);
 
 // Create the on-disk hash table representation. We only store offsets
 // for identifiers that appear here for the first time.


Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -3645,13 +3645,13 @@
 // file.
 SmallVector IIs;
 for (const auto  : PP.getIdentifierTable())
-  IIs.push_back(ID.second);
-// Sort the identifiers lexicographically before getting them references so
+  if (Trait.isInterestingNonMacroIdentifier(ID.second))
+IIs.push_back(ID.second);
+// Sort the identifiers lexicographically before getting the references so
 // that their order is stable.
 llvm::sort(IIs, llvm::deref>());
 for (const IdentifierInfo *II : IIs)
-  if (Trait.isInterestingNonMacroIdentifier(II))
-getIdentifierRef(II);
+  getIdentifierRef(II);
 
 // Create the on-disk hash table representation. We only store offsets
 // for identifiers that appear here for the first time.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] f60cc47 - [clang][modules] NFC: Only sort interesting identifiers

2023-05-15 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2023-05-15T13:28:10-07:00
New Revision: f60cc473b82b16edc448199c84e612c1e5c3014c

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

LOG: [clang][modules] NFC: Only sort interesting identifiers

In 9c254184 `ASTWriter` stopped writing identifiers that are not interesting. 
Taking it a bit further, we don't need to sort the whole identifier table, just 
the interesting identifiers. This reduces the size of sorted vector from ~10k 
(including lots of builtins) to 2 (`__VA_ARGS__` and `__VA_OPT__`) in a typical 
Xcode project, improving `clang-scan-deps` performance.

Reviewed By: benlangmuir

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

Added: 


Modified: 
clang/lib/Serialization/ASTWriter.cpp

Removed: 




diff  --git a/clang/lib/Serialization/ASTWriter.cpp 
b/clang/lib/Serialization/ASTWriter.cpp
index 06d758b36c59d..07a577a009995 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -3645,13 +3645,13 @@ void ASTWriter::WriteIdentifierTable(Preprocessor ,
 // file.
 SmallVector IIs;
 for (const auto  : PP.getIdentifierTable())
-  IIs.push_back(ID.second);
-// Sort the identifiers lexicographically before getting them references so
+  if (Trait.isInterestingNonMacroIdentifier(ID.second))
+IIs.push_back(ID.second);
+// Sort the identifiers lexicographically before getting the references so
 // that their order is stable.
 llvm::sort(IIs, llvm::deref>());
 for (const IdentifierInfo *II : IIs)
-  if (Trait.isInterestingNonMacroIdentifier(II))
-getIdentifierRef(II);
+  getIdentifierRef(II);
 
 // Create the on-disk hash table representation. We only store offsets
 // for identifiers that appear here for the first time.



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


[PATCH] D148997: [clang] Add a new annotation token: annot_repl_input_end

2023-05-15 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev accepted this revision.
v.g.vassilev added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks for putting so much efforts into this!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148997

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


[PATCH] D150539: [clang-format] Handle ud suffixes in IntegerLiteralSeparator

2023-05-15 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks accepted this revision.
HazardyKnusperkeks added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/Format/IntegerLiteralSeparatorFixer.cpp:116-117
 if (Style.isCpp()) {
-  if (const auto Pos = Text.find_first_of("_i"); Pos != StringRef::npos) {
+  // FIXME: This doesn't work for ud-suffix d from std::chrono::day.
+  if (const auto Pos = Text.find_first_of("_himnsuy");
+  Pos != StringRef::npos) {

What about this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150539

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


[PATCH] D146178: [Clang][Sema] Fix comparison of constraint expressions

2023-05-15 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

There is probably more reduction work to be done, but I hit the end of my day 
here:

https://godbolt.org/z/Tzfx31asK


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146178

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


[PATCH] D148995: [clang-tidy] Extract areStatementsIdentical

2023-05-15 Thread Piotr Zegar via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6ccb8061724f: [clang-tidy] Extract areStatementsIdentical 
(authored by PiotrZSL).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148995

Files:
  clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
  clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp
  clang-tools-extra/clang-tidy/utils/ASTUtils.cpp
  clang-tools-extra/clang-tidy/utils/ASTUtils.h

Index: clang-tools-extra/clang-tidy/utils/ASTUtils.h
===
--- clang-tools-extra/clang-tidy/utils/ASTUtils.h
+++ clang-tools-extra/clang-tidy/utils/ASTUtils.h
@@ -36,6 +36,10 @@
 // FIXME: false-negative if the entire range is fully expanded from a macro.
 bool rangeCanBeFixed(SourceRange Range, const SourceManager *SM);
 
+// Check if statements are same
+bool areStatementsIdentical(const Stmt *FirstStmt, const Stmt *SecondStmt,
+const ASTContext , bool Canonical = false);
+
 } // namespace clang::tidy::utils
 
 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ASTUTILS_H
Index: clang-tools-extra/clang-tidy/utils/ASTUtils.cpp
===
--- clang-tools-extra/clang-tidy/utils/ASTUtils.cpp
+++ clang-tools-extra/clang-tidy/utils/ASTUtils.cpp
@@ -88,4 +88,29 @@
  !utils::rangeContainsMacroExpansion(Range, SM);
 }
 
+bool areStatementsIdentical(const Stmt *FirstStmt, const Stmt *SecondStmt,
+const ASTContext , bool Canonical) {
+  if (!FirstStmt || !SecondStmt)
+return false;
+
+  if (FirstStmt == SecondStmt)
+return true;
+
+  if (FirstStmt->getStmtClass() != FirstStmt->getStmtClass())
+return false;
+
+  if (isa(FirstStmt) && isa(SecondStmt)) {
+// If we have errors in expressions, we will be unable
+// to accurately profile and compute hashes for each statements.
+if (llvm::cast(FirstStmt)->containsErrors() ||
+llvm::cast(SecondStmt)->containsErrors())
+  return false;
+  }
+
+  llvm::FoldingSetNodeID DataFirst, DataSecond;
+  FirstStmt->Profile(DataFirst, Context, Canonical);
+  SecondStmt->Profile(DataSecond, Context, Canonical);
+  return DataFirst == DataSecond;
+}
+
 } // namespace clang::tidy::utils
Index: clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp
===
--- clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp
+++ clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "LoopConvertUtils.h"
+#include "../utils/ASTUtils.h"
 #include "clang/Basic/IdentifierTable.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/Lambda.h"
@@ -190,13 +191,7 @@
 
 /// Returns true when two Exprs are equivalent.
 bool areSameExpr(ASTContext *Context, const Expr *First, const Expr *Second) {
-  if (!First || !Second)
-return false;
-
-  llvm::FoldingSetNodeID FirstID, SecondID;
-  First->Profile(FirstID, *Context, true);
-  Second->Profile(SecondID, *Context, true);
-  return FirstID == SecondID;
+  return utils::areStatementsIdentical(First, Second, *Context, true);
 }
 
 /// Returns the DeclRefExpr represented by E, or NULL if there isn't one.
Index: clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "BranchCloneCheck.h"
+#include "../utils/ASTUtils.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Analysis/CloneDetection.h"
@@ -16,26 +17,6 @@
 using namespace clang;
 using namespace clang::ast_matchers;
 
-/// Returns true when the statements are Type I clones of each other.
-static bool areStatementsIdentical(const Stmt *LHS, const Stmt *RHS,
-   const ASTContext ) {
-  if (isa(LHS) && isa(RHS)) {
-// If we have errors in expressions, we will be unable
-// to accurately profile and compute hashes for each
-// of the left and right statements.
-const auto *LHSExpr = llvm::cast(LHS);
-const auto *RHSExpr = llvm::cast(RHS);
-if (LHSExpr->containsErrors() && RHSExpr->containsErrors()) {
-  return false;
-}
-  }
-
-  llvm::FoldingSetNodeID DataLHS, DataRHS;
-  LHS->Profile(DataLHS, Context, false);
-  RHS->Profile(DataRHS, Context, false);
-  return (DataLHS == DataRHS);
-}
-
 namespace {
 /// A branch in a switch may consist of several statements; while a branch in
 /// an if/else if/else chain is one statement (which may be a CompoundStmt).
@@ -55,8 

[clang-tools-extra] 6ccb806 - [clang-tidy] Extract areStatementsIdentical

2023-05-15 Thread Piotr Zegar via cfe-commits

Author: Piotr Zegar
Date: 2023-05-15T20:05:12Z
New Revision: 6ccb8061724fb6ee0b2598764656410ce3f2472c

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

LOG: [clang-tidy] Extract areStatementsIdentical

Move areStatementsIdentical from BranchCloneCheck into ASTUtils.
Add small improvments. Use it in LoopConvertUtils.

Reviewed By: carlosgalvezp

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp
clang-tools-extra/clang-tidy/utils/ASTUtils.cpp
clang-tools-extra/clang-tidy/utils/ASTUtils.h

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
index df232e9a64cd0..7657ca7380b6f 100644
--- a/clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "BranchCloneCheck.h"
+#include "../utils/ASTUtils.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Analysis/CloneDetection.h"
@@ -16,26 +17,6 @@
 using namespace clang;
 using namespace clang::ast_matchers;
 
-/// Returns true when the statements are Type I clones of each other.
-static bool areStatementsIdentical(const Stmt *LHS, const Stmt *RHS,
-   const ASTContext ) {
-  if (isa(LHS) && isa(RHS)) {
-// If we have errors in expressions, we will be unable
-// to accurately profile and compute hashes for each
-// of the left and right statements.
-const auto *LHSExpr = llvm::cast(LHS);
-const auto *RHSExpr = llvm::cast(RHS);
-if (LHSExpr->containsErrors() && RHSExpr->containsErrors()) {
-  return false;
-}
-  }
-
-  llvm::FoldingSetNodeID DataLHS, DataRHS;
-  LHS->Profile(DataLHS, Context, false);
-  RHS->Profile(DataRHS, Context, false);
-  return (DataLHS == DataRHS);
-}
-
 namespace {
 /// A branch in a switch may consist of several statements; while a branch in
 /// an if/else if/else chain is one statement (which may be a CompoundStmt).
@@ -55,8 +36,9 @@ static bool areSwitchBranchesIdentical(const SwitchBranch LHS,
 // NOTE: We strip goto labels and annotations in addition to stripping
 // the `case X:` or `default:` labels, but it is very unlikely that this
 // would cause false positives in real-world code.
-if (!areStatementsIdentical(LHS[I]->stripLabelLikeStatements(),
-RHS[I]->stripLabelLikeStatements(), Context)) {
+if 
(!tidy::utils::areStatementsIdentical(LHS[I]->stripLabelLikeStatements(),
+ 
RHS[I]->stripLabelLikeStatements(),
+ Context)) {
   return false;
 }
   }
@@ -89,8 +71,8 @@ void BranchCloneCheck::check(const MatchFinder::MatchResult 
) {
 
 if (!isa(Else)) {
   // Just a simple if with no `else if` branch.
-  if (areStatementsIdentical(Then->IgnoreContainers(),
- Else->IgnoreContainers(), Context)) {
+  if (utils::areStatementsIdentical(Then->IgnoreContainers(),
+Else->IgnoreContainers(), Context)) {
 diag(IS->getBeginLoc(), "if with identical then and else branches");
 diag(IS->getElseLoc(), "else branch starts here", DiagnosticIDs::Note);
   }
@@ -130,9 +112,9 @@ void BranchCloneCheck::check(const MatchFinder::MatchResult 
) {
   int NumCopies = 1;
 
   for (size_t J = I + 1; J < N; J++) {
-if (KnownAsClone[J] ||
-!areStatementsIdentical(Branches[I]->IgnoreContainers(),
-Branches[J]->IgnoreContainers(), Context))
+if (KnownAsClone[J] || !utils::areStatementsIdentical(
+   Branches[I]->IgnoreContainers(),
+   Branches[J]->IgnoreContainers(), Context))
   continue;
 
 NumCopies++;
@@ -160,7 +142,8 @@ void BranchCloneCheck::check(const MatchFinder::MatchResult 
) {
 
   if (const auto *CO = Result.Nodes.getNodeAs("condOp")) {
 // We do not try to detect chains of ?: operators.
-if (areStatementsIdentical(CO->getTrueExpr(), CO->getFalseExpr(), Context))
+if (utils::areStatementsIdentical(CO->getTrueExpr(), CO->getFalseExpr(),
+  Context))
   diag(CO->getQuestionLoc(),
"conditional operator with identical true and false expressions");
 

diff  --git a/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp 

[PATCH] D147266: [AArch64] Sink operands to allow for bitselect instructions

2023-05-15 Thread Pranav Kant via Phabricator via cfe-commits
pranavk added inline comments.



Comment at: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp:14361-14363
+  for (unsigned Idx = 0; Idx < MainAnd->getNumOperands(); Idx++) {
+if (MainAnd->getOperand(Idx) != IA) {
+  Ops.push_back(>getOperandUse(Idx));

pranavk wrote:
> dmgreen wrote:
> > I think this can avoid the loop if we just use
> > `Ops.push_back(>getOperandUse(MainAnd->getOperand(0) == IA ? 1 : 
> > 0));`
> llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
Done. this was left as part of my final refactoring. Uploaded new patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147266

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


[PATCH] D147266: [AArch64] Sink operands to allow for bitselect instructions

2023-05-15 Thread Pranav Kant via Phabricator via cfe-commits
pranavk added inline comments.



Comment at: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp:14361-14363
+  for (unsigned Idx = 0; Idx < MainAnd->getNumOperands(); Idx++) {
+if (MainAnd->getOperand(Idx) != IA) {
+  Ops.push_back(>getOperandUse(Idx));

dmgreen wrote:
> I think this can avoid the loop if we just use
> `Ops.push_back(>getOperandUse(MainAnd->getOperand(0) == IA ? 1 : 
> 0));`
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147266

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


[PATCH] D147266: [AArch64] Sink operands to allow for bitselect instructions

2023-05-15 Thread Pranav Kant via Phabricator via cfe-commits
pranavk updated this revision to Diff 522309.
pranavk marked 3 inline comments as done.
pranavk added a comment.

address reviewer comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147266

Files:
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/test/CodeGen/AArch64/aarch64-bit-gen.ll

Index: llvm/test/CodeGen/AArch64/aarch64-bit-gen.ll
===
--- llvm/test/CodeGen/AArch64/aarch64-bit-gen.ll
+++ llvm/test/CodeGen/AArch64/aarch64-bit-gen.ll
@@ -144,3 +144,55 @@
   %or = or <16 x i8> %and, %and1
   ret <16 x i8> %or
 }
+
+define <4 x i32> @test_bit_sink_operand(<4 x i32> %src, <4 x i32> %dst, <4 x i32> %mask, i32 %scratch) {
+; CHECK-LABEL: test_bit_sink_operand:
+; CHECK:   // %bb.0: // %entry
+; CHECK-NEXT:sub sp, sp, #32
+; CHECK-NEXT:.cfi_def_cfa_offset 32
+; CHECK-NEXT:cmp w0, #0
+; CHECK-NEXT:mov w8, wzr
+; CHECK-NEXT:cinc w9, w0, lt
+; CHECK-NEXT:asr w9, w9, #1
+; CHECK-NEXT:  .LBB11_1: // %do.body
+; CHECK-NEXT:// =>This Inner Loop Header: Depth=1
+; CHECK-NEXT:bit v1.16b, v0.16b, v2.16b
+; CHECK-NEXT:add x10, sp, #16
+; CHECK-NEXT:bfi x10, x8, #2, #2
+; CHECK-NEXT:mov x11, sp
+; CHECK-NEXT:bfi x11, x8, #2, #2
+; CHECK-NEXT:add w8, w8, #1
+; CHECK-NEXT:cmp w8, #5
+; CHECK-NEXT:str q1, [sp, #16]
+; CHECK-NEXT:str w0, [x10]
+; CHECK-NEXT:ldr q1, [sp, #16]
+; CHECK-NEXT:str q0, [sp]
+; CHECK-NEXT:str w9, [x11]
+; CHECK-NEXT:ldr q0, [sp]
+; CHECK-NEXT:b.ne .LBB11_1
+; CHECK-NEXT:  // %bb.2: // %do.end
+; CHECK-NEXT:mov v0.16b, v1.16b
+; CHECK-NEXT:add sp, sp, #32
+; CHECK-NEXT:ret
+
+entry:
+  %0 = xor <4 x i32> %mask, 
+  %div = sdiv i32 %scratch, 2
+  br label %do.body
+
+do.body:
+  %dst.addr.0 = phi <4 x i32> [ %dst, %entry ], [ %vecins, %do.body ]
+  %src.addr.0 = phi <4 x i32> [ %src, %entry ], [ %vecins1, %do.body ]
+  %i.0 = phi i32 [ 0, %entry ], [ %inc, %do.body ]
+  %vbsl3.i = and <4 x i32> %src.addr.0, %mask
+  %vbsl4.i = and <4 x i32> %dst.addr.0, %0
+  %vbsl5.i = or <4 x i32> %vbsl3.i, %vbsl4.i
+  %vecins = insertelement <4 x i32> %vbsl5.i, i32 %scratch, i32 %i.0
+  %vecins1 = insertelement <4 x i32> %src.addr.0, i32 %div, i32 %i.0
+  %inc = add nuw nsw i32 %i.0, 1
+  %exitcond.not = icmp eq i32 %inc, 5
+  br i1 %exitcond.not, label %do.end, label %do.body
+
+do.end:
+  ret <4 x i32> %vecins
+}
Index: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
===
--- llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -14332,6 +14332,43 @@
 
 return true;
   }
+  case Instruction::Or: {
+// Pattern: Or(And(MaskValue, A), And(Not(MaskValue), B)) ->
+// bitselect(MaskValue, A, B) where Not(MaskValue) = Xor(MaskValue, -1)
+if (Subtarget->hasNEON()) {
+  Instruction *OtherAnd, *IA, *IB;
+  Value *MaskValue;
+  // MainAnd refers to And instruction that has 'Not' as one of its operands
+  if (match(I, m_c_Or(m_OneUse(m_Instruction(OtherAnd)),
+  m_OneUse(m_c_And(m_OneUse(m_Not(m_Value(MaskValue))),
+   m_Instruction(IA)) {
+if (match(OtherAnd,
+  m_c_And(m_Specific(MaskValue), m_Instruction(IB {
+  Instruction *MainAnd = I->getOperand(0) == OtherAnd
+ ? cast(I->getOperand(1))
+ : cast(I->getOperand(0));
+
+  // Both Ands should be in same basic block as Or
+  if (I->getParent() != MainAnd->getParent() ||
+  I->getParent() != OtherAnd->getParent())
+return false;
+
+  // Non-mask operands of both Ands should also be in same basic block
+  if (I->getParent() != IA->getParent() ||
+  I->getParent() != IB->getParent())
+return false;
+
+  Ops.push_back(>getOperandUse(MainAnd->getOperand(0) == IA ? 1 : 0));
+  Ops.push_back(>getOperandUse(0));
+  Ops.push_back(>getOperandUse(1));
+
+  return true;
+}
+  }
+}
+
+return false;
+  }
   case Instruction::Mul: {
 int NumZExts = 0, NumSExts = 0;
 for (auto  : I->operands()) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D150221: Add option -fkeep-static-variables to emit all static variables

2023-05-15 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

It's not unprecedented to add flags to copy the behavior of other compilers, to 
make porting easier, especially when it doesn't place much burden on compiler 
maintainers.  But what compiler preserves the names/values of static variables 
by default?  It's not the sort of feature I'd expect anyone to advertise.  And 
we don't really want to encourage people to use global flags for this sort of 
thing; applying behavior everywhere has weird effects, and users often don't 
understand the flags they're using.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150221

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


[PATCH] D150490: Enable frame pointer for all non-leaf functions on riscv64 Android

2023-05-15 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D150490#4343442 , @craig.topper 
wrote:

> In D150490#4343145 , @enh wrote:
>
>> In D150490#4343128 , @hiraditya 
>> wrote:
>>
 Is there more context on why Android enables the frame pointer?
>>>
>>> From what i gathered, this is more of an effort to have parity such that 
>>> existing build flag overrides continue to be consistent.
>>
>> well, when i said that on the internal chat, i thought you were asking "why 
>> do we say what clang already says?" :-)
>>
>> if the question was actually "is there more context on why Android enables 
>> the frame pointer?" i'd have said something like "because Android developers 
>> [OS and app developers alike] do so much debugging from the field, where all 
>> we get is a crash report for something we probably can't repro locally, that 
>> having good _and_ cheap unwinds is super important to us".
>
> Thanks. I suspected that was the answer, but I wanted to check that it made 
> sense to copy AArch64.

Enabling the frame pointer is fine. We probably should revert ancient 
conventions by using `-fasynchronous-unwind-tables`...


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

https://reviews.llvm.org/D150490

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


[PATCH] D146178: [Clang][Sema] Fix comparison of constraint expressions

2023-05-15 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D146178#4343477 , 
@alexander-shaposhnikov wrote:

> @erichkeane - I'll have stable internet ~soon and will try to look into the 
> reported issue (but help would be greatly appreciated).
> To the best of my knowledge there are other problems with libstdc++'s ranges 
> (even without this diff), but yeah, this regression is unfortunate.

I've been working on a reduction most of the day, I'll share it when I get it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146178

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


[PATCH] D150603: adding bf16 support to NVPTX

2023-05-15 Thread Kushan Ahmadian via Phabricator via cfe-commits
kushanam abandoned this revision.
kushanam added a comment.

redundant revision again on D144911 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150603

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


[PATCH] D150603: adding bf16 support to NVPTX

2023-05-15 Thread Kushan Ahmadian via Phabricator via cfe-commits
kushanam created this revision.
Herald added subscribers: mattd, gchakrabarti, asavonic, hiraditya.
Herald added a project: All.
kushanam requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, jdoerfert, jholewinski.
Herald added projects: clang, LLVM.

Currently, bf16 has been scatteredly added to the PTX codegen. This patch aims 
to complete the set of instructions and code path required to support bf16 data 
type.

Depends on D144911 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150603

Files:
  clang/include/clang/Basic/BuiltinsNVPTX.def
  llvm/include/llvm/IR/IntrinsicsNVVM.td
  llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXInstPrinter.cpp
  llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
  llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.cpp
  llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.h
  llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
  llvm/lib/Target/NVPTX/NVPTXInstrInfo.td
  llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
  llvm/lib/Target/NVPTX/NVPTXMCExpr.cpp
  llvm/lib/Target/NVPTX/NVPTXMCExpr.h
  llvm/lib/Target/NVPTX/NVPTXRegisterInfo.td
  llvm/lib/Target/NVPTX/NVPTXSubtarget.cpp
  llvm/lib/Target/NVPTX/NVPTXSubtarget.h
  llvm/lib/Target/NVPTX/NVPTXTargetTransformInfo.cpp
  llvm/test/CodeGen/NVPTX/bf16-instructions.ll

Index: llvm/test/CodeGen/NVPTX/bf16-instructions.ll
===
--- /dev/null
+++ llvm/test/CodeGen/NVPTX/bf16-instructions.ll
@@ -0,0 +1,88 @@
+; RUN: llc < %s -march=nvptx64 -mcpu=sm_80 -mattr=+ptx70 | FileCheck %s
+; RUN: %if ptxas-11.0 %{ llc < %s -march=nvptx64 -mcpu=sm_80 -mattr=+ptx70 | %ptxas-verify -arch=sm_80 %}
+
+
+; CHECK-LABEL: test_fadd(
+; CHECK-DAG:  ld.param.b16[[A:%h[0-9]+]], [test_fadd_param_0];
+; CHECK-DAG:  ld.param.b16[[B:%h[0-9]+]], [test_fadd_param_1];
+; CHECK-NEXT: add.rn.bf16 [[R:%f[0-9]+]], [[A]], [[B]];
+; CHECK-NEXT: st.param.b16[func_retval0+0], [[R]];
+; CHECK-NEXT: ret;
+
+define bfloat @test_fadd(bfloat %0, bfloat %1) {
+  %3 = fadd bfloat %0, %1 
+  ret bfloat %3
+}
+
+; CHECK-LABEL: test_fsub(
+; CHECK-DAG:  ld.param.b16[[A:%h[0-9]+]], [test_fsub_param_0];
+; CHECK-DAG:  ld.param.b16[[B:%h[0-9]+]], [test_fsub_param_1];
+; CHECK-NEXT: sub.rn.bf16 [[R:%f[0-9]+]], [[A]], [[B]];
+; CHECK-NEXT: st.param.b16[func_retval0+0], [[R]];
+; CHECK-NEXT: ret;
+
+define bfloat @test_fsub(bfloat %0, bfloat %1) {
+  %3 = fsub bfloat %0, %1 
+  ret bfloat %3
+}
+
+; CHECK-LABEL: test_faddx2(
+; CHECK-DAG:  ld.param.b32[[A:%hh[0-9]+]], [test_faddx2_param_0];
+; CHECK-DAG:  ld.param.b32[[B:%hh[0-9]+]], [test_faddx2_param_1];
+; CHECK-NEXT: add.rn.bf16x2   [[R:%f[0-9]+]], [[A]], [[B]];
+
+; CHECK:  st.param.b32[func_retval0+0], [[R]];
+; CHECK:  ret;
+
+define <2 x bfloat> @test_faddx2(<2 x bfloat> %a, <2 x bfloat> %b) #0 {
+  %r = fadd <2 x bfloat> %a, %b
+  ret <2 x bfloat> %r
+}
+
+; CHECK-LABEL: test_fsubx2(
+; CHECK-DAG:  ld.param.b32[[A:%hh[0-9]+]], [test_fsubx2_param_0];
+; CHECK-DAG:  ld.param.b32[[B:%hh[0-9]+]], [test_fsubx2_param_1];
+; CHECK-NEXT: sub.rn.bf16x2   [[R:%f[0-9]+]], [[A]], [[B]];
+
+; CHECK:  st.param.b32[func_retval0+0], [[R]];
+; CHECK:  ret;
+
+define <2 x bfloat> @test_fsubx2(<2 x bfloat> %a, <2 x bfloat> %b) #0 {
+  %r = fsub <2 x bfloat> %a, %b
+  ret <2 x bfloat> %r
+}
+
+; CHECK-LABEL: test_fmulx2(
+; CHECK-DAG:  ld.param.b32[[A:%hh[0-9]+]], [test_fmulx2_param_0];
+; CHECK-DAG:  ld.param.b32[[B:%hh[0-9]+]], [test_fmulx2_param_1];
+; CHECK-NEXT: mul.rn.bf16x2   [[R:%f[0-9]+]], [[A]], [[B]];
+
+; CHECK:  st.param.b32[func_retval0+0], [[R]];
+; CHECK:  ret;
+
+define <2 x bfloat> @test_fmul(<2 x bfloat> %a, <2 x bfloat> %b) #0 {
+  %r = fmul <2 x bfloat> %a, %b
+  ret <2 x bfloat> %r
+}
+
+; CHECK-LABEL: test_fdiv(
+; CHECK-DAG:  ld.param.b32[[A:%hh[0-9]+]], [test_fdiv_param_0];
+; CHECK-DAG:  ld.param.b32[[B:%hh[0-9]+]], [test_fdiv_param_1];
+; CHECK-DAG:  mov.b32 {[[A0:%h[0-9]+]], [[A1:%h[0-9]+]]}, [[A]]
+; CHECK-DAG:  mov.b32 {[[B0:%h[0-9]+]], [[B1:%h[0-9]+]]}, [[B]]
+; CHECK-DAG:  cvt.f32.bf16 [[FA0:%f[0-9]+]], [[A0]];
+; CHECK-DAG:  cvt.f32.bf16 [[FA1:%f[0-9]+]], [[A1]];
+; CHECK-DAG:  cvt.f32.bf16 [[FB0:%f[0-9]+]], [[B0]];
+; CHECK-DAG:  cvt.f32.bf16 [[FB1:%f[0-9]+]], [[B1]];
+; CHECK-DAG:  div.rn.f32  [[FR0:%f[0-9]+]], [[FA0]], [[FB0]];
+; CHECK-DAG:  div.rn.f32  [[FR1:%f[0-9]+]], [[FA1]], [[FB1]];
+; CHECK-DAG:  cvt.rn.bf16.f32  [[R0:%h[0-9]+]], [[FR0]];
+; CHECK-DAG:  cvt.rn.bf16.f32  [[R1:%h[0-9]+]], [[FR1]];
+; CHECK-NEXT: mov.b32 [[R:%hh[0-9]+]], {[[R0]], [[R1]]}
+; CHECK-NEXT: st.param.b32[func_retval0+0], [[R]];
+; CHECK-NEXT: ret;
+
+define <2 x bfloat> @test_fdiv(<2 x bfloat> %a, <2 x bfloat> %b) #0 {
+  %r = fdiv <2 x bfloat> %a, %b
+  ret <2 x bfloat> %r
+}
Index: 

[PATCH] D146178: [Clang][Sema] Fix comparison of constraint expressions

2023-05-15 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexander-shaposhnikov added a comment.

@erichkeane - I'll have stable internet ~soon and will try to look into the 
reported issue (but help would be greatly appreciated).
To the best of my knowledge there are other problems with libstdc++'s ranges 
(even without this diff), but yeah, this regression is unfortunate.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146178

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


[PATCH] D150602: [clang-tidy] Move formatDereference to FixitHintUtils

2023-05-15 Thread Mike Crowe via Phabricator via cfe-commits
mikecrowe created this revision.
mikecrowe added reviewers: njames93, carlosgalvezp, PiotrZSL.
Herald added a subscriber: xazax.hun.
Herald added a project: All.
mikecrowe requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

I'd like to use RedundantStringCStrCheck's formatDereference function
from the up-coming modernize-use-std-print check. Let's move it to
FixItHintUtils so that the implementation can be shared.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150602

Files:
  clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
  clang-tools-extra/clang-tidy/utils/FixItHintUtils.cpp
  clang-tools-extra/clang-tidy/utils/FixItHintUtils.h

Index: clang-tools-extra/clang-tidy/utils/FixItHintUtils.h
===
--- clang-tools-extra/clang-tidy/utils/FixItHintUtils.h
+++ clang-tools-extra/clang-tidy/utils/FixItHintUtils.h
@@ -44,6 +44,9 @@
   DeclSpec::TQ Qualifier,
   QualifierTarget CT = QualifierTarget::Pointee,
   QualifierPolicy CP = QualifierPolicy::Left);
+
+// \brief Format a pointer to an expression
+std::string formatDereference(const Expr , const ASTContext );
 } // namespace clang::tidy::utils::fixit
 
 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_FIXITHINTUTILS_H
Index: clang-tools-extra/clang-tidy/utils/FixItHintUtils.cpp
===
--- clang-tools-extra/clang-tidy/utils/FixItHintUtils.cpp
+++ clang-tools-extra/clang-tidy/utils/FixItHintUtils.cpp
@@ -9,7 +9,9 @@
 #include "FixItHintUtils.h"
 #include "LexerUtils.h"
 #include "clang/AST/ASTContext.h"
+#include "clang/AST/ExprCXX.h"
 #include "clang/AST/Type.h"
+#include "clang/Tooling/FixIt.h"
 #include 
 
 namespace clang::tidy::utils::fixit {
@@ -221,4 +223,46 @@
 
   return std::nullopt;
 }
+
+// Return true if expr needs to be put in parens when it is an argument of a
+// prefix unary operator, e.g. when it is a binary or ternary operator
+// syntactically.
+bool needParensAfterUnaryOperator(const Expr ) {
+  if (isa() ||
+  isa()) {
+return true;
+  }
+  if (const auto *Op = dyn_cast()) {
+return Op->getNumArgs() == 2 && Op->getOperator() != OO_PlusPlus &&
+   Op->getOperator() != OO_MinusMinus && Op->getOperator() != OO_Call &&
+   Op->getOperator() != OO_Subscript;
+  }
+  return false;
+}
+
+// Format a pointer to an expression: prefix with '*' but simplify
+// when it already begins with '&'.  Return empty string on failure.
+std::string formatDereference(const Expr , const ASTContext ) {
+  if (const auto *Op = dyn_cast()) {
+if (Op->getOpcode() == UO_AddrOf) {
+  // Strip leading '&'.
+  return std::string(
+  tooling::fixit::getText(*Op->getSubExpr()->IgnoreParens(), Context));
+}
+  }
+  StringRef Text = tooling::fixit::getText(ExprNode, Context);
+
+  if (Text.empty())
+return std::string();
+
+  // Remove remaining '->' from overloaded operator call
+  Text.consume_back("->");
+
+  // Add leading '*'.
+  if (needParensAfterUnaryOperator(ExprNode)) {
+return (llvm::Twine("*(") + Text + ")").str();
+  }
+  return (llvm::Twine("*") + Text).str();
+}
+
 } // namespace clang::tidy::utils::fixit
Index: clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
@@ -11,6 +11,7 @@
 //===--===//
 
 #include "RedundantStringCStrCheck.h"
+#include "../utils/FixItHintUtils.h"
 #include "../utils/Matchers.h"
 #include "../utils/OptionsUtils.h"
 #include "clang/Lex/Lexer.h"
@@ -22,49 +23,6 @@
 
 namespace {
 
-// Return true if expr needs to be put in parens when it is an argument of a
-// prefix unary operator, e.g. when it is a binary or ternary operator
-// syntactically.
-bool needParensAfterUnaryOperator(const Expr ) {
-  if (isa() ||
-  isa()) {
-return true;
-  }
-  if (const auto *Op = dyn_cast()) {
-return Op->getNumArgs() == 2 && Op->getOperator() != OO_PlusPlus &&
-   Op->getOperator() != OO_MinusMinus && Op->getOperator() != OO_Call &&
-   Op->getOperator() != OO_Subscript;
-  }
-  return false;
-}
-
-// Format a pointer to an expression: prefix with '*' but simplify
-// when it already begins with '&'.  Return empty string on failure.
-std::string
-formatDereference(const ast_matchers::MatchFinder::MatchResult ,
-  const Expr ) {
-  if (const auto *Op = dyn_cast()) {
-if (Op->getOpcode() == UO_AddrOf) {
-  // Strip leading '&'.
-  return std::string(tooling::fixit::getText(
-  *Op->getSubExpr()->IgnoreParens(), *Result.Context));
-}
-  }
-  

[PATCH] D132247: [clang] Fix emitVoidPtrVAArg for non-zero default alloca address space

2023-05-15 Thread Jessica Clarke via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG74f207883bc5: [clang] Fix emitVoidPtrVAArg for non-zero 
default alloca address space (authored by jrtc27).

Changed prior to commit:
  https://reviews.llvm.org/D132247?vs=454033=522295#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132247

Files:
  clang/lib/CodeGen/TargetInfo.cpp


Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -401,8 +401,10 @@
 
   // Cast the address we've calculated to the right type.
   llvm::Type *DirectTy = CGF.ConvertTypeForMem(ValueTy), *ElementTy = DirectTy;
-  if (IsIndirect)
-DirectTy = DirectTy->getPointerTo(0);
+  if (IsIndirect) {
+unsigned AllocaAS = CGF.CGM.getDataLayout().getAllocaAddrSpace();
+DirectTy = DirectTy->getPointerTo(AllocaAS);
+  }
 
   Address Addr = emitVoidPtrDirectVAArg(CGF, VAListAddr, DirectTy, DirectSize,
 DirectAlign, SlotSizeAndAlign,


Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -401,8 +401,10 @@
 
   // Cast the address we've calculated to the right type.
   llvm::Type *DirectTy = CGF.ConvertTypeForMem(ValueTy), *ElementTy = DirectTy;
-  if (IsIndirect)
-DirectTy = DirectTy->getPointerTo(0);
+  if (IsIndirect) {
+unsigned AllocaAS = CGF.CGM.getDataLayout().getAllocaAddrSpace();
+DirectTy = DirectTy->getPointerTo(AllocaAS);
+  }
 
   Address Addr = emitVoidPtrDirectVAArg(CGF, VAListAddr, DirectTy, DirectSize,
 DirectAlign, SlotSizeAndAlign,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 74f2078 - [clang] Fix emitVoidPtrVAArg for non-zero default alloca address space

2023-05-15 Thread Jessica Clarke via cfe-commits

Author: Jessica Clarke
Date: 2023-05-15T20:26:49+01:00
New Revision: 74f207883bc5fe2a7300c4b4f1ff080a107ab148

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

LOG: [clang] Fix emitVoidPtrVAArg for non-zero default alloca address space

Indirect arguments are passed on the stack and so va_arg should use the
default alloca address space, not hard-code 0, for pointers to those.
The only in-tree target with a non-zero default alloca address space is
AMDGPU, but that does not support variadic arguments, so we cannot test
this upstream. However, downstream in CHERI LLVM (and Morello LLVM, a
further fork of that) we have targets that do both and so require this
change.

Reviewed By: arsenm

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

Added: 


Modified: 
clang/lib/CodeGen/TargetInfo.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/TargetInfo.cpp 
b/clang/lib/CodeGen/TargetInfo.cpp
index ff4d516090ea4..9fb5d9ae75f0a 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -401,8 +401,10 @@ static Address emitVoidPtrVAArg(CodeGenFunction , 
Address VAListAddr,
 
   // Cast the address we've calculated to the right type.
   llvm::Type *DirectTy = CGF.ConvertTypeForMem(ValueTy), *ElementTy = DirectTy;
-  if (IsIndirect)
-DirectTy = DirectTy->getPointerTo(0);
+  if (IsIndirect) {
+unsigned AllocaAS = CGF.CGM.getDataLayout().getAllocaAddrSpace();
+DirectTy = DirectTy->getPointerTo(AllocaAS);
+  }
 
   Address Addr = emitVoidPtrDirectVAArg(CGF, VAListAddr, DirectTy, DirectSize,
 DirectAlign, SlotSizeAndAlign,



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


[PATCH] D149612: [Sema] avoid merge error type

2023-05-15 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D149612#4343440 , @HerrCai0907 
wrote:

> Maybe return `QualType()` as a temporary solution to avoid crash? @erichkeane

I'm not sure at the moment... I'd like to have aaron take a look and chat it 
over with him.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149612

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


[PATCH] D139010: [clang][WebAssembly] Implement support for table types and builtins

2023-05-15 Thread Thomas Lively via Phabricator via cfe-commits
tlively added a comment.

Thanks for the ping, will take a look.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139010

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


[PATCH] D150490: Enable frame pointer for all non-leaf functions on riscv64 Android

2023-05-15 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

In D150490#4343145 , @enh wrote:

> In D150490#4343128 , @hiraditya 
> wrote:
>
>>> Is there more context on why Android enables the frame pointer?
>>
>> From what i gathered, this is more of an effort to have parity such that 
>> existing build flag overrides continue to be consistent.
>
> well, when i said that on the internal chat, i thought you were asking "why 
> do we say what clang already says?" :-)
>
> if the question was actually "is there more context on why Android enables 
> the frame pointer?" i'd have said something like "because Android developers 
> [OS and app developers alike] do so much debugging from the field, where all 
> we get is a crash report for something we probably can't repro locally, that 
> having good _and_ cheap unwinds is super important to us".

Thanks. I suspected that was the answer, but I wanted to check that it made 
sense to copy AArch64.


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

https://reviews.llvm.org/D150490

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


[PATCH] D149612: [Sema] avoid merge error type

2023-05-15 Thread Congcong Cai via Phabricator via cfe-commits
HerrCai0907 added a comment.

Maybe return `QualType()` as a temporary solution to avoid crash? @erichkeane


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149612

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


[PATCH] D149516: [Sema] `setInvalidDecl` for error deduction declaration

2023-05-15 Thread Congcong Cai via Phabricator via cfe-commits
HerrCai0907 added a comment.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149516

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


[clang] 86c7e33 - Re-land "[-Wunsafe-buffer-usage] Remove an unnecessary const-qualifier"

2023-05-15 Thread via cfe-commits

Author: ziqingluo-90
Date: 2023-05-15T12:10:13-07:00
New Revision: 86c7e33b3fd0cc231b09b5af21ef42842f0ff97b

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

LOG: Re-land "[-Wunsafe-buffer-usage] Remove an unnecessary const-qualifier"

Re-land 7a0900fd3e2d34bc1d513a97cf8fbdc1754252d7, which includes too
much clang-format changes.  This re-land gets rid of the format changes.

Added: 


Modified: 
clang/include/clang/Sema/AnalysisBasedWarnings.h
clang/lib/Sema/AnalysisBasedWarnings.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/AnalysisBasedWarnings.h 
b/clang/include/clang/Sema/AnalysisBasedWarnings.h
index c73506894db9d..020ddd36cf73e 100644
--- a/clang/include/clang/Sema/AnalysisBasedWarnings.h
+++ b/clang/include/clang/Sema/AnalysisBasedWarnings.h
@@ -97,7 +97,7 @@ class AnalysisBasedWarnings {
  const Decl *D, QualType BlockType);
 
   // Issue warnings that require whole-translation-unit analysis.
-  void IssueWarnings(const TranslationUnitDecl *D);
+  void IssueWarnings(TranslationUnitDecl *D);
 
   Policy getDefaultPolicy() { return DefaultPolicy; }
 

diff  --git a/clang/lib/Sema/AnalysisBasedWarnings.cpp 
b/clang/lib/Sema/AnalysisBasedWarnings.cpp
index 4d96f3b9ab32b..11fd39af825e7 100644
--- a/clang/lib/Sema/AnalysisBasedWarnings.cpp
+++ b/clang/lib/Sema/AnalysisBasedWarnings.cpp
@@ -2340,7 +2340,7 @@ class CallableVisitor : public 
RecursiveASTVisitor {
 };
 
 void clang::sema::AnalysisBasedWarnings::IssueWarnings(
-const TranslationUnitDecl *TU) {
+ TranslationUnitDecl *TU) {
   if (!TU)
 return; // This is unexpected, give up quietly.
 
@@ -2370,9 +2370,7 @@ void clang::sema::AnalysisBasedWarnings::IssueWarnings(
   // reasoning. Check if any of them is enabled at all before scanning the AST:
   if (!Diags.isIgnored(diag::warn_unsafe_buffer_operation, SourceLocation()) ||
   !Diags.isIgnored(diag::warn_unsafe_buffer_variable, SourceLocation())) {
-CallableVisitor(CallAnalyzers)
-.TraverseTranslationUnitDecl(
-std::remove_const_t(TU));
+CallableVisitor(CallAnalyzers).TraverseTranslationUnitDecl(TU);
   }
 }
 



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


[PATCH] D149976: adding bf16 support to NVPTX

2023-05-15 Thread Kushan Ahmadian via Phabricator via cfe-commits
kushanam updated this revision to Diff 522290.
kushanam added a comment.

Adressing review changes and removing bf16 registers


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149976

Files:
  clang/include/clang/Basic/BuiltinsNVPTX.def
  llvm/include/llvm/IR/IntrinsicsNVVM.td
  llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXInstPrinter.cpp
  llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
  llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.cpp
  llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.h
  llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
  llvm/lib/Target/NVPTX/NVPTXInstrInfo.td
  llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
  llvm/lib/Target/NVPTX/NVPTXMCExpr.cpp
  llvm/lib/Target/NVPTX/NVPTXMCExpr.h
  llvm/lib/Target/NVPTX/NVPTXRegisterInfo.td
  llvm/lib/Target/NVPTX/NVPTXSubtarget.cpp
  llvm/lib/Target/NVPTX/NVPTXSubtarget.h
  llvm/lib/Target/NVPTX/NVPTXTargetTransformInfo.cpp
  llvm/test/CodeGen/NVPTX/bf16-instructions.ll

Index: llvm/test/CodeGen/NVPTX/bf16-instructions.ll
===
--- /dev/null
+++ llvm/test/CodeGen/NVPTX/bf16-instructions.ll
@@ -0,0 +1,88 @@
+; RUN: llc < %s -march=nvptx64 -mcpu=sm_80 -mattr=+ptx70 | FileCheck %s
+; RUN: %if ptxas-11.0 %{ llc < %s -march=nvptx64 -mcpu=sm_80 -mattr=+ptx70 | %ptxas-verify -arch=sm_80 %}
+
+
+; CHECK-LABEL: test_fadd(
+; CHECK-DAG:  ld.param.b16[[A:%h[0-9]+]], [test_fadd_param_0];
+; CHECK-DAG:  ld.param.b16[[B:%h[0-9]+]], [test_fadd_param_1];
+; CHECK-NEXT: add.rn.bf16 [[R:%f[0-9]+]], [[A]], [[B]];
+; CHECK-NEXT: st.param.b16[func_retval0+0], [[R]];
+; CHECK-NEXT: ret;
+
+define bfloat @test_fadd(bfloat %0, bfloat %1) {
+  %3 = fadd bfloat %0, %1 
+  ret bfloat %3
+}
+
+; CHECK-LABEL: test_fsub(
+; CHECK-DAG:  ld.param.b16[[A:%h[0-9]+]], [test_fsub_param_0];
+; CHECK-DAG:  ld.param.b16[[B:%h[0-9]+]], [test_fsub_param_1];
+; CHECK-NEXT: sub.rn.bf16 [[R:%f[0-9]+]], [[A]], [[B]];
+; CHECK-NEXT: st.param.b16[func_retval0+0], [[R]];
+; CHECK-NEXT: ret;
+
+define bfloat @test_fsub(bfloat %0, bfloat %1) {
+  %3 = fsub bfloat %0, %1 
+  ret bfloat %3
+}
+
+; CHECK-LABEL: test_faddx2(
+; CHECK-DAG:  ld.param.b32[[A:%hh[0-9]+]], [test_faddx2_param_0];
+; CHECK-DAG:  ld.param.b32[[B:%hh[0-9]+]], [test_faddx2_param_1];
+; CHECK-NEXT: add.rn.bf16x2   [[R:%f[0-9]+]], [[A]], [[B]];
+
+; CHECK:  st.param.b32[func_retval0+0], [[R]];
+; CHECK:  ret;
+
+define <2 x bfloat> @test_faddx2(<2 x bfloat> %a, <2 x bfloat> %b) #0 {
+  %r = fadd <2 x bfloat> %a, %b
+  ret <2 x bfloat> %r
+}
+
+; CHECK-LABEL: test_fsubx2(
+; CHECK-DAG:  ld.param.b32[[A:%hh[0-9]+]], [test_fsubx2_param_0];
+; CHECK-DAG:  ld.param.b32[[B:%hh[0-9]+]], [test_fsubx2_param_1];
+; CHECK-NEXT: sub.rn.bf16x2   [[R:%f[0-9]+]], [[A]], [[B]];
+
+; CHECK:  st.param.b32[func_retval0+0], [[R]];
+; CHECK:  ret;
+
+define <2 x bfloat> @test_fsubx2(<2 x bfloat> %a, <2 x bfloat> %b) #0 {
+  %r = fsub <2 x bfloat> %a, %b
+  ret <2 x bfloat> %r
+}
+
+; CHECK-LABEL: test_fmulx2(
+; CHECK-DAG:  ld.param.b32[[A:%hh[0-9]+]], [test_fmulx2_param_0];
+; CHECK-DAG:  ld.param.b32[[B:%hh[0-9]+]], [test_fmulx2_param_1];
+; CHECK-NEXT: mul.rn.bf16x2   [[R:%f[0-9]+]], [[A]], [[B]];
+
+; CHECK:  st.param.b32[func_retval0+0], [[R]];
+; CHECK:  ret;
+
+define <2 x bfloat> @test_fmul(<2 x bfloat> %a, <2 x bfloat> %b) #0 {
+  %r = fmul <2 x bfloat> %a, %b
+  ret <2 x bfloat> %r
+}
+
+; CHECK-LABEL: test_fdiv(
+; CHECK-DAG:  ld.param.b32[[A:%hh[0-9]+]], [test_fdiv_param_0];
+; CHECK-DAG:  ld.param.b32[[B:%hh[0-9]+]], [test_fdiv_param_1];
+; CHECK-DAG:  mov.b32 {[[A0:%h[0-9]+]], [[A1:%h[0-9]+]]}, [[A]]
+; CHECK-DAG:  mov.b32 {[[B0:%h[0-9]+]], [[B1:%h[0-9]+]]}, [[B]]
+; CHECK-DAG:  cvt.f32.bf16 [[FA0:%f[0-9]+]], [[A0]];
+; CHECK-DAG:  cvt.f32.bf16 [[FA1:%f[0-9]+]], [[A1]];
+; CHECK-DAG:  cvt.f32.bf16 [[FB0:%f[0-9]+]], [[B0]];
+; CHECK-DAG:  cvt.f32.bf16 [[FB1:%f[0-9]+]], [[B1]];
+; CHECK-DAG:  div.rn.f32  [[FR0:%f[0-9]+]], [[FA0]], [[FB0]];
+; CHECK-DAG:  div.rn.f32  [[FR1:%f[0-9]+]], [[FA1]], [[FB1]];
+; CHECK-DAG:  cvt.rn.bf16.f32  [[R0:%h[0-9]+]], [[FR0]];
+; CHECK-DAG:  cvt.rn.bf16.f32  [[R1:%h[0-9]+]], [[FR1]];
+; CHECK-NEXT: mov.b32 [[R:%hh[0-9]+]], {[[R0]], [[R1]]}
+; CHECK-NEXT: st.param.b32[func_retval0+0], [[R]];
+; CHECK-NEXT: ret;
+
+define <2 x bfloat> @test_fdiv(<2 x bfloat> %a, <2 x bfloat> %b) #0 {
+  %r = fdiv <2 x bfloat> %a, %b
+  ret <2 x bfloat> %r
+}
Index: llvm/lib/Target/NVPTX/NVPTXTargetTransformInfo.cpp
===
--- llvm/lib/Target/NVPTX/NVPTXTargetTransformInfo.cpp
+++ llvm/lib/Target/NVPTX/NVPTXTargetTransformInfo.cpp
@@ -204,6 +204,14 @@
   return {Intrinsic::fma, FTZ_MustBeOff, true};
 case 

[PATCH] D148827: -fsanitize=function: support C

2023-05-15 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 522287.
MaskRay added a comment.

rebase the final patch in the series


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148827

Files:
  clang/docs/UndefinedBehaviorSanitizer.rst
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/test/CodeGen/ubsan-function.c
  compiler-rt/test/ubsan/TestCases/TypeCheck/Function/c.c


Index: compiler-rt/test/ubsan/TestCases/TypeCheck/Function/c.c
===
--- /dev/null
+++ compiler-rt/test/ubsan/TestCases/TypeCheck/Function/c.c
@@ -0,0 +1,14 @@
+// RUN: %clang -g -fsanitize=function %s -o %t
+// RUN: %run %t 2>&1 | FileCheck %s --check-prefix=CHECK 
--implicit-check-not='runtime error:'
+
+void f(void (*fp)(int (*)[])) { fp(0); }
+
+void callee0(int (*a)[]) {}
+void callee1(int (*a)[1]) {}
+
+int main() {
+  int a[1];
+  f(callee0);
+  // CHECK: runtime error: call to function callee1 through pointer to 
incorrect function type 'void (*)(int (*)[])'
+  f(callee1); // compatible type in C, but flagged
+}
Index: clang/test/CodeGen/ubsan-function.c
===
--- /dev/null
+++ clang/test/CodeGen/ubsan-function.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -emit-llvm -triple x86_64 -std=c17 -fsanitize=function %s 
-o - | FileCheck %s
+
+// CHECK-LABEL: define{{.*}} @call_no_prototype(
+// CHECK-NOT: __ubsan_handle_function_type_mismatch
+void call_no_prototype(void (*f)()) { f(); }
+
+// CHECK-LABEL: define{{.*}} @call_prototype(
+// CHECK: __ubsan_handle_function_type_mismatch
+void call_prototype(void (*f)(void)) { f(); }
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -572,10 +572,11 @@
 CodeGenFunction::getUBSanFunctionTypeHash(QualType Ty) const {
   // Remove any (C++17) exception specifications, to allow calling e.g. a
   // noexcept function through a non-noexcept pointer.
-  auto ProtoTy = getContext().getFunctionTypeWithExceptionSpec(Ty, EST_None);
+  if (!isa(Ty))
+Ty = getContext().getFunctionTypeWithExceptionSpec(Ty, EST_None);
   std::string Mangled;
   llvm::raw_string_ostream Out(Mangled);
-  CGM.getCXXABI().getMangleContext().mangleTypeName(ProtoTy, Out, false);
+  CGM.getCXXABI().getMangleContext().mangleTypeName(Ty, Out, false);
   return llvm::ConstantInt::get(CGM.Int32Ty,
 
static_cast(llvm::xxHash64(Mangled)));
 }
@@ -945,7 +946,7 @@
 
   // If we are checking function types, emit a function type signature as
   // prologue data.
-  if (FD && getLangOpts().CPlusPlus && SanOpts.has(SanitizerKind::Function)) {
+  if (FD && SanOpts.has(SanitizerKind::Function)) {
 if (llvm::Constant *PrologueSig = getPrologueSignature(CGM, FD)) {
   llvm::LLVMContext  = Fn->getContext();
   llvm::MDBuilder MDB(Ctx);
Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -5349,8 +5349,9 @@
 
   CGCallee Callee = OrigCallee;
 
-  if (getLangOpts().CPlusPlus && SanOpts.has(SanitizerKind::Function) &&
-  (!TargetDecl || !isa(TargetDecl))) {
+  if (SanOpts.has(SanitizerKind::Function) &&
+  (!TargetDecl || !isa(TargetDecl)) &&
+  !isa(PointeeType)) {
 if (llvm::Constant *PrefixSig =
 CGM.getTargetCodeGenInfo().getUBSanFunctionSignature(CGM)) {
   SanitizerScope SanScope(this);
Index: clang/docs/UndefinedBehaviorSanitizer.rst
===
--- clang/docs/UndefinedBehaviorSanitizer.rst
+++ clang/docs/UndefinedBehaviorSanitizer.rst
@@ -100,7 +100,7 @@
  by Clang (and by ISO/IEC/IEEE 60559 / IEEE 754) as producing either an
  infinity or NaN value, so is not included in ``-fsanitize=undefined``.
   -  ``-fsanitize=function``: Indirect call of a function through a
- function pointer of the wrong type (C++ only).
+ function pointer of the wrong type.
   -  ``-fsanitize=implicit-unsigned-integer-truncation``,
  ``-fsanitize=implicit-signed-integer-truncation``: Implicit conversion 
from
  integer of larger bit width to smaller bit width, if that results in data


Index: compiler-rt/test/ubsan/TestCases/TypeCheck/Function/c.c
===
--- /dev/null
+++ compiler-rt/test/ubsan/TestCases/TypeCheck/Function/c.c
@@ -0,0 +1,14 @@
+// RUN: %clang -g -fsanitize=function %s -o %t
+// RUN: %run %t 2>&1 | FileCheck %s --check-prefix=CHECK --implicit-check-not='runtime error:'
+
+void f(void (*fp)(int (*)[])) { fp(0); }
+
+void callee0(int (*a)[]) {}
+void callee1(int (*a)[1]) {}
+
+int main() {
+  int a[1];
+  f(callee0);
+  // CHECK: runtime error: call 

[PATCH] D148785: -fsanitize=function: use type hashes instead of RTTI objects

2023-05-15 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 522286.
MaskRay marked 2 inline comments as done.
MaskRay added a comment.

rename a variable


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148785

Files:
  clang/docs/UndefinedBehaviorSanitizer.rst
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Driver/SanitizerArgs.cpp
  clang/test/CodeGen/ubsan-function.cpp
  clang/test/CodeGenCXX/catch-undef-behavior.cpp
  clang/test/CodeGenCXX/ubsan-function-noexcept.cpp
  clang/test/Driver/fsanitize.c
  compiler-rt/lib/ubsan/ubsan_handlers.cpp
  compiler-rt/lib/ubsan/ubsan_handlers.h
  compiler-rt/lib/ubsan/ubsan_handlers_cxx.cpp
  compiler-rt/lib/ubsan/ubsan_handlers_cxx.h
  compiler-rt/lib/ubsan/ubsan_interface.inc
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/test/CodeGen/AArch64/func-sanitizer.ll
  llvm/test/CodeGen/AArch64/patchable-function-entry-bti.ll
  llvm/test/CodeGen/X86/func-sanitizer.ll
  llvm/test/CodeGen/X86/patchable-function-entry-ibt.ll

Index: llvm/test/CodeGen/X86/patchable-function-entry-ibt.ll
===
--- llvm/test/CodeGen/X86/patchable-function-entry-ibt.ll
+++ llvm/test/CodeGen/X86/patchable-function-entry-ibt.ll
@@ -1,9 +1,6 @@
 ; RUN: llc -mtriple=i686 %s -o - | FileCheck --check-prefixes=CHECK,32 %s
 ; RUN: llc -mtriple=x86_64 %s -o - | FileCheck --check-prefixes=CHECK,64 %s
 
-@_ZTIFvvE = linkonce_odr constant i32 1
-@__llvm_rtti_proxy = private unnamed_addr constant ptr @_ZTIFvvE
-
 ;; -fpatchable-function-entry=0 -fcf-protection=branch
 define void @f0() "patchable-function-entry"="0" {
 ; CHECK-LABEL: f0:
@@ -91,7 +88,7 @@
 ; CHECK-NEXT: .Ltmp{{.*}}:
 ; CHECK-NEXT:   nop
 ; CHECK-NEXT:   .long   3238382334
-; CHECK-NEXT:   .long   .L__llvm_rtti_proxy-sanitize_function
+; CHECK-NEXT:   .long   42
 ; CHECK-NEXT: sanitize_function:
 ; CHECK-NEXT: .Lfunc_begin{{.*}}:
 ; CHECK-NEXT:   .cfi_startproc
@@ -107,4 +104,4 @@
 !llvm.module.flags = !{!0}
 
 !0 = !{i32 8, !"cf-protection-branch", i32 1}
-!1 = !{i32 3238382334, ptr @__llvm_rtti_proxy}
+!1 = !{i32 3238382334, i32 42}
Index: llvm/test/CodeGen/X86/func-sanitizer.ll
===
--- llvm/test/CodeGen/X86/func-sanitizer.ll
+++ llvm/test/CodeGen/X86/func-sanitizer.ll
@@ -2,17 +2,14 @@
 
 ; CHECK:  .type _Z3funv,@function
 ; CHECK-NEXT:   .long   3238382334  # 0xc105cafe
-; CHECK-NEXT:   .long   .L__llvm_rtti_proxy-_Z3funv
+; CHECK-NEXT:   .long   42
 ; CHECK-NEXT: _Z3funv:
 ; CHECK-NEXT:   .cfi_startproc
 ; CHECK-NEXT:   # %bb.0:
 ; CHECK-NEXT:   retq
 
-@i = linkonce_odr constant i32 1
-@__llvm_rtti_proxy = private unnamed_addr constant ptr @i
-
 define dso_local void @_Z3funv() !func_sanitize !0 {
   ret void
 }
 
-!0 = !{i32 3238382334, ptr @__llvm_rtti_proxy}
+!0 = !{i32 3238382334, i32 42}
Index: llvm/test/CodeGen/AArch64/patchable-function-entry-bti.ll
===
--- llvm/test/CodeGen/AArch64/patchable-function-entry-bti.ll
+++ llvm/test/CodeGen/AArch64/patchable-function-entry-bti.ll
@@ -1,8 +1,5 @@
 ; RUN: llc -mtriple=aarch64 %s -o - | FileCheck %s
 
-@_ZTIFvvE = linkonce_odr constant i32 2
-@__llvm_rtti_proxy = private unnamed_addr constant ptr @_ZTIFvvE
-
 define void @f0() "patchable-function-entry"="0" "branch-target-enforcement"="true" {
 ; CHECK-LABEL: f0:
 ; CHECK-NEXT: .Lfunc_begin0:
@@ -94,7 +91,7 @@
 ; CHECK-NEXT: .Ltmp{{.*}}:
 ; CHECK-NEXT:   nop
 ; CHECK-NEXT:   .word   3238382334  // 0xc105cafe
-; CHECK-NEXT:   .word   .L__llvm_rtti_proxy-sanitize_function
+; CHECK-NEXT:   .word   42
 ; CHECK-NEXT: sanitize_function:
 ; CHECK-NEXT: .Lfunc_begin{{.*}}:
 ; CHECK-NEXT:   .cfi_startproc
@@ -106,4 +103,4 @@
   ret void
 }
 
-!0 = !{i32 3238382334, ptr @__llvm_rtti_proxy}
+!0 = !{i32 3238382334, i32 42}
Index: llvm/test/CodeGen/AArch64/func-sanitizer.ll
===
--- llvm/test/CodeGen/AArch64/func-sanitizer.ll
+++ llvm/test/CodeGen/AArch64/func-sanitizer.ll
@@ -2,21 +2,13 @@
 
 ; CHECK-LABEL: .type _Z3funv,@function
 ; CHECK-NEXT:.word   3238382334  // 0xc105cafe
-; CHECK-NEXT:.word   .L__llvm_rtti_proxy-_Z3funv
+; CHECK-NEXT:.word   42
 ; CHECK-NEXT:  _Z3funv:
 ; CHECK-NEXT:  // %bb.0:
 ; CHECK-NEXT:ret
 
-; CHECK:   .section .rodata,"a",@progbits
-; CHECK-LABEL: .L__llvm_rtti_proxy:
-; CHECK-NEXT:.xword  _ZTIFvvE
-; CHECK-NEXT:.size   .L__llvm_rtti_proxy, 8
-
-@_ZTIFvvE = linkonce_odr constant i32 1
-@__llvm_rtti_proxy = private unnamed_addr constant ptr @_ZTIFvvE
-
 define dso_local void @_Z3funv() nounwind !func_sanitize !0 {
   ret void
 }
 
-!0 = !{i32 3238382334, ptr @__llvm_rtti_proxy}
+!0 = !{i32 3238382334, i32 42}
Index: llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp

[PATCH] D150352: [clang][dataflow] Don't analyze templated declarations.

2023-05-15 Thread Martin Böhme via Phabricator via cfe-commits
mboehme added a subscriber: amyk.
mboehme added a comment.

In D150352#4342480 , @uabelho wrote:

> Hello,
>
>   
> ../../clang-tools-extra/clang-tidy/bugprone/UncheckedOptionalAccessCheck.cpp:43:27:
>  error: 'build' is deprecated: Use the version that takes a const Decl & 
> instead [-Werror,-Wdeprecated-declarations]
> ControlFlowContext::build(, *FuncDecl.getBody(), ASTCtx);
> ^
>   ../../clang/include/clang/Analysis/FlowSensitive/ControlFlowContext.h:41:3: 
> note: 'build' has been explicitly marked deprecated here
> LLVM_DEPRECATED("Use the version that takes a const Decl & instead", "")
> ^
>   ../include/llvm/Support/Compiler.h:143:50: note: expanded from macro 
> 'LLVM_DEPRECATED'
>   #define LLVM_DEPRECATED(MSG, FIX) __attribute__((deprecated(MSG, FIX)))
>^
>   1 error generated.

Sorry for the breakage. I ran `check-clang` and fixed all the deprecation 
warnings, so I'm not sure how I missed this one.

Thank you to @amyk for the fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150352

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


[PATCH] D148785: -fsanitize=function: use type hashes instead of RTTI objects

2023-05-15 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay marked 2 inline comments as done.
MaskRay added a comment.

In D148785#4343112 , @peter.smith 
wrote:

> Should `HANDLER(__ubsan_handle_function_type_mismatch,"function")` be added 
> to ubsan_minimal_runtime if this is supported in the minimal runtime?

Thanks for the comments.

`compiler-rt/lib/ubsan_minimal/ubsan_minimal_handlers.cpp` has 
`HANDLER(function_type_mismatch, "function-type-mismatch")` and with this patch 
`clang++ -fsanitize=function -fsanitize-minimal-runtime` works.




Comment at: clang/lib/CodeGen/CGExpr.cpp:5382
+  getPointerAlign());
   llvm::Value *CalleeRTTIMatch =
+  Builder.CreateICmpEQ(CalleeTypeHash, TypeHash);

peter.smith wrote:
> Would CalleeTypeHashMatch be a better name?
Thanks for the suggestion. Adopted.



Comment at: clang/lib/CodeGen/CodeGenFunction.h:120
   SANITIZER_CHECK(FloatCastOverflow, float_cast_overflow, 0)   
\
-  SANITIZER_CHECK(FunctionTypeMismatch, function_type_mismatch, 1) 
\
+  SANITIZER_CHECK(FunctionTypeMismatch, function_type_mismatch, 0) 
\
   SANITIZER_CHECK(ImplicitConversion, implicit_conversion, 0)  
\

peter.smith wrote:
> Presumably the signature is different to the original v0 shouldn't it be 2; 
> or is it effectively so long since the last one that we can reuse the 
> original without fear?
The signature is identical to the original v0, so we just "downgrade" the 
version.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148785

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


[clang] f39fd75 - Revert "[-Wunsafe-buffer-usage] Remove an unnecessary const-qualifier"

2023-05-15 Thread via cfe-commits

Author: ziqingluo-90
Date: 2023-05-15T11:47:00-07:00
New Revision: f39fd750ab59cb2482688168b25db303dbebdb09

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

LOG: Revert "[-Wunsafe-buffer-usage] Remove an unnecessary const-qualifier"

This reverts commit 7a0900fd3e2d34bc1d513a97cf8fbdc1754252d7.

The commit includes too much clang-format changes.

Added: 


Modified: 
clang/include/clang/Sema/AnalysisBasedWarnings.h
clang/lib/Sema/AnalysisBasedWarnings.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/AnalysisBasedWarnings.h 
b/clang/include/clang/Sema/AnalysisBasedWarnings.h
index 7d0fa9541c35..c73506894db9 100644
--- a/clang/include/clang/Sema/AnalysisBasedWarnings.h
+++ b/clang/include/clang/Sema/AnalysisBasedWarnings.h
@@ -24,7 +24,7 @@ class FunctionDecl;
 class QualType;
 class Sema;
 namespace sema {
-class FunctionScopeInfo;
+  class FunctionScopeInfo;
 }
 
 namespace sema {
@@ -38,7 +38,6 @@ class AnalysisBasedWarnings {
 unsigned enableCheckUnreachable : 1;
 unsigned enableThreadSafetyAnalysis : 1;
 unsigned enableConsumedAnalysis : 1;
-
   public:
 Policy();
 void disableCheckFallThrough() { enableCheckFallThrough = 0; }
@@ -52,7 +51,7 @@ class AnalysisBasedWarnings {
   std::unique_ptr IPData;
 
   enum VisitFlag { NotVisited = 0, Visited = 1, Pending = 2 };
-  llvm::DenseMap VisitedFD;
+  llvm::DenseMap VisitedFD;
 
   /// \name Statistics
   /// @{
@@ -94,11 +93,11 @@ class AnalysisBasedWarnings {
   AnalysisBasedWarnings(Sema );
   ~AnalysisBasedWarnings();
 
-  void IssueWarnings(Policy P, FunctionScopeInfo *fscope, const Decl *D,
- QualType BlockType);
+  void IssueWarnings(Policy P, FunctionScopeInfo *fscope,
+ const Decl *D, QualType BlockType);
 
   // Issue warnings that require whole-translation-unit analysis.
-  void IssueWarnings(TranslationUnitDecl *D);
+  void IssueWarnings(const TranslationUnitDecl *D);
 
   Policy getDefaultPolicy() { return DefaultPolicy; }
 

diff  --git a/clang/lib/Sema/AnalysisBasedWarnings.cpp 
b/clang/lib/Sema/AnalysisBasedWarnings.cpp
index c2b6d362d966..4d96f3b9ab32 100644
--- a/clang/lib/Sema/AnalysisBasedWarnings.cpp
+++ b/clang/lib/Sema/AnalysisBasedWarnings.cpp
@@ -1,5 +1,4 @@
-//=- AnalysisBasedWarnings.cpp - Sema warnings based on libAnalysis -*- C++
-//-*-=//
+//=- AnalysisBasedWarnings.cpp - Sema warnings based on libAnalysis -*- C++ 
-*-=//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -27,6 +26,7 @@
 #include "clang/AST/StmtCXX.h"
 #include "clang/AST/StmtObjC.h"
 #include "clang/AST/StmtVisitor.h"
+#include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/AST/Type.h"
 #include "clang/Analysis/Analyses/CFGReachabilityAnalysis.h"
 #include "clang/Analysis/Analyses/CalledOnceCheck.h"
@@ -64,60 +64,61 @@ using namespace clang;
 
//===--===//
 
 namespace {
-class UnreachableCodeHandler : public reachable_code::Callback {
-  Sema 
-  SourceRange PreviousSilenceableCondVal;
-
-public:
-  UnreachableCodeHandler(Sema ) : S(s) {}
-
-  void HandleUnreachable(reachable_code::UnreachableKind UK, SourceLocation L,
- SourceRange SilenceableCondVal, SourceRange R1,
- SourceRange R2, bool HasFallThroughAttr) override {
-// If the diagnosed code is `[[fallthrough]];` and
-// `-Wunreachable-code-fallthrough` is  enabled, suppress `code will never
-// be executed` warning to avoid generating diagnostic twice
-if (HasFallThroughAttr &&
-!S.getDiagnostics().isIgnored(diag::warn_unreachable_fallthrough_attr,
-  SourceLocation()))
-  return;
-
-// Avoid reporting multiple unreachable code diagnostics that are
-// triggered by the same conditional value.
-if (PreviousSilenceableCondVal.isValid() && SilenceableCondVal.isValid() &&
-PreviousSilenceableCondVal == SilenceableCondVal)
-  return;
-PreviousSilenceableCondVal = SilenceableCondVal;
-
-unsigned diag = diag::warn_unreachable;
-switch (UK) {
-case reachable_code::UK_Break:
-  diag = diag::warn_unreachable_break;
-  break;
-case reachable_code::UK_Return:
-  diag = diag::warn_unreachable_return;
-  break;
-case reachable_code::UK_Loop_Increment:
-  diag = diag::warn_unreachable_loop_increment;
-  break;
-case reachable_code::UK_Other:
-  break;
-}
+  class UnreachableCodeHandler : public reachable_code::Callback {
+Sema 
+SourceRange PreviousSilenceableCondVal;
+
+  public:
+UnreachableCodeHandler(Sema ) : S(s) {}
+
+void 

[PATCH] D150221: Add option -fkeep-static-variables to emit all static variables

2023-05-15 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added reviewers: rjmccall, efriedma.
aaron.ballman added subscribers: efriedma, rjmccall.
aaron.ballman added a comment.

In D150221#4338500 , @qianzhen wrote:

> This is useful in keeping the static variables in a patchable function 
> (https://clang.llvm.org/docs/AttributeReference.html#patchable-function-entry),
>  so that they can be directly addressed by a hot patch when the optimization 
> to merge them is enabled 
> (https://llvm.org/docs/doxygen/GlobalMerge_8cpp_source.html).

I would expect that the user could write `__attribute__((used))` themselves in 
that case rather than use the heavy hammer of keeping all statics in the TU, 
right?

In D150221#4332280 , 
@hubert.reinterpretcast wrote:

> In D150221#4332142 , @erichkeane 
> wrote:
>
>>> This is intended to prevent "excessive transformation" to enable migration 
>>> of existing applications (using a non-Clang compiler) where users further 
>>> manipulate the object or assembly after compilation.
>>
>> I don't get what you mean by this?  I don't currently see motivation for 
>> this?
>
> The intent is to apply the `__attribute__((__used__))` semantic to static 
> variables (since the front-end is likely to discard them). Additional reasons 
> for using `__attribute__((__used__))` applies: The compiler cannot optimize 
> with the assumption that it sees all direct accesses to the variable.

The part I'm having a hard time understanding is why this should be a TU-level 
option when the user can write `__attribute__((used))` on any static that 
matters to them that is being dropped? This feels like a heavy hammer.

Adding @rjmccall and @efriedma as codegen code owners.




Comment at: clang/lib/CodeGen/CodeGenModule.cpp:2201-2210
+  if ((CodeGenOpts.KeepStaticConsts || CodeGenOpts.KeepStaticVariables) && D &&
+  isa(D)) {
 const auto *VD = cast(D);
-if (VD->getType().isConstQualified() &&
-VD->getStorageDuration() == SD_Static)
-  addUsedOrCompilerUsedGlobal(GV);
+if (VD->getStorageDuration() == SD_Static) {
+  if (CodeGenOpts.KeepStaticVariables)
+addUsedOrCompilerUsedGlobal(GV);
+  else if (CodeGenOpts.KeepStaticConsts && 
VD->getType().isConstQualified())

Reformatted with whatever clang-format does for that, as I doubt I have the 
formatting correct.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:3096
+return true;
+  else if (CodeGenOpts.KeepStaticConsts && 
VD->getType().isConstQualified())
+return true;

cebowleratibm wrote:
> Fold to a single return.
Yup, similar suggestion here as above.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150221

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


[PATCH] D149976: adding bf16 support to NVPTX

2023-05-15 Thread Kushan Ahmadian via Phabricator via cfe-commits
kushanam updated this revision to Diff 522284.
kushanam added a comment.

Addressing review changed and removing bf16 registers

Depends on D144911 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149976

Files:
  clang/include/clang/Basic/BuiltinsNVPTX.def
  llvm/include/llvm/IR/IntrinsicsNVVM.td
  llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXInstPrinter.cpp
  llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
  llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.cpp
  llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.h
  llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
  llvm/lib/Target/NVPTX/NVPTXInstrInfo.td
  llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
  llvm/lib/Target/NVPTX/NVPTXMCExpr.cpp
  llvm/lib/Target/NVPTX/NVPTXMCExpr.h
  llvm/lib/Target/NVPTX/NVPTXRegisterInfo.td
  llvm/lib/Target/NVPTX/NVPTXSubtarget.cpp
  llvm/lib/Target/NVPTX/NVPTXSubtarget.h
  llvm/lib/Target/NVPTX/NVPTXTargetTransformInfo.cpp
  llvm/test/CodeGen/NVPTX/bf16-instructions.ll

Index: llvm/test/CodeGen/NVPTX/bf16-instructions.ll
===
--- /dev/null
+++ llvm/test/CodeGen/NVPTX/bf16-instructions.ll
@@ -0,0 +1,88 @@
+; RUN: llc < %s -march=nvptx64 -mcpu=sm_80 -mattr=+ptx70 | FileCheck %s
+; RUN: %if ptxas-11.0 %{ llc < %s -march=nvptx64 -mcpu=sm_80 -mattr=+ptx70 | %ptxas-verify -arch=sm_80 %}
+
+
+; CHECK-LABEL: test_fadd(
+; CHECK-DAG:  ld.param.b16[[A:%h[0-9]+]], [test_fadd_param_0];
+; CHECK-DAG:  ld.param.b16[[B:%h[0-9]+]], [test_fadd_param_1];
+; CHECK-NEXT: add.rn.bf16 [[R:%f[0-9]+]], [[A]], [[B]];
+; CHECK-NEXT: st.param.b16[func_retval0+0], [[R]];
+; CHECK-NEXT: ret;
+
+define bfloat @test_fadd(bfloat %0, bfloat %1) {
+  %3 = fadd bfloat %0, %1 
+  ret bfloat %3
+}
+
+; CHECK-LABEL: test_fsub(
+; CHECK-DAG:  ld.param.b16[[A:%h[0-9]+]], [test_fsub_param_0];
+; CHECK-DAG:  ld.param.b16[[B:%h[0-9]+]], [test_fsub_param_1];
+; CHECK-NEXT: sub.rn.bf16 [[R:%f[0-9]+]], [[A]], [[B]];
+; CHECK-NEXT: st.param.b16[func_retval0+0], [[R]];
+; CHECK-NEXT: ret;
+
+define bfloat @test_fsub(bfloat %0, bfloat %1) {
+  %3 = fsub bfloat %0, %1 
+  ret bfloat %3
+}
+
+; CHECK-LABEL: test_faddx2(
+; CHECK-DAG:  ld.param.b32[[A:%hh[0-9]+]], [test_faddx2_param_0];
+; CHECK-DAG:  ld.param.b32[[B:%hh[0-9]+]], [test_faddx2_param_1];
+; CHECK-NEXT: add.rn.bf16x2   [[R:%f[0-9]+]], [[A]], [[B]];
+
+; CHECK:  st.param.b32[func_retval0+0], [[R]];
+; CHECK:  ret;
+
+define <2 x bfloat> @test_faddx2(<2 x bfloat> %a, <2 x bfloat> %b) #0 {
+  %r = fadd <2 x bfloat> %a, %b
+  ret <2 x bfloat> %r
+}
+
+; CHECK-LABEL: test_fsubx2(
+; CHECK-DAG:  ld.param.b32[[A:%hh[0-9]+]], [test_fsubx2_param_0];
+; CHECK-DAG:  ld.param.b32[[B:%hh[0-9]+]], [test_fsubx2_param_1];
+; CHECK-NEXT: sub.rn.bf16x2   [[R:%f[0-9]+]], [[A]], [[B]];
+
+; CHECK:  st.param.b32[func_retval0+0], [[R]];
+; CHECK:  ret;
+
+define <2 x bfloat> @test_fsubx2(<2 x bfloat> %a, <2 x bfloat> %b) #0 {
+  %r = fsub <2 x bfloat> %a, %b
+  ret <2 x bfloat> %r
+}
+
+; CHECK-LABEL: test_fmulx2(
+; CHECK-DAG:  ld.param.b32[[A:%hh[0-9]+]], [test_fmulx2_param_0];
+; CHECK-DAG:  ld.param.b32[[B:%hh[0-9]+]], [test_fmulx2_param_1];
+; CHECK-NEXT: mul.rn.bf16x2   [[R:%f[0-9]+]], [[A]], [[B]];
+
+; CHECK:  st.param.b32[func_retval0+0], [[R]];
+; CHECK:  ret;
+
+define <2 x bfloat> @test_fmul(<2 x bfloat> %a, <2 x bfloat> %b) #0 {
+  %r = fmul <2 x bfloat> %a, %b
+  ret <2 x bfloat> %r
+}
+
+; CHECK-LABEL: test_fdiv(
+; CHECK-DAG:  ld.param.b32[[A:%hh[0-9]+]], [test_fdiv_param_0];
+; CHECK-DAG:  ld.param.b32[[B:%hh[0-9]+]], [test_fdiv_param_1];
+; CHECK-DAG:  mov.b32 {[[A0:%h[0-9]+]], [[A1:%h[0-9]+]]}, [[A]]
+; CHECK-DAG:  mov.b32 {[[B0:%h[0-9]+]], [[B1:%h[0-9]+]]}, [[B]]
+; CHECK-DAG:  cvt.f32.bf16 [[FA0:%f[0-9]+]], [[A0]];
+; CHECK-DAG:  cvt.f32.bf16 [[FA1:%f[0-9]+]], [[A1]];
+; CHECK-DAG:  cvt.f32.bf16 [[FB0:%f[0-9]+]], [[B0]];
+; CHECK-DAG:  cvt.f32.bf16 [[FB1:%f[0-9]+]], [[B1]];
+; CHECK-DAG:  div.rn.f32  [[FR0:%f[0-9]+]], [[FA0]], [[FB0]];
+; CHECK-DAG:  div.rn.f32  [[FR1:%f[0-9]+]], [[FA1]], [[FB1]];
+; CHECK-DAG:  cvt.rn.bf16.f32  [[R0:%h[0-9]+]], [[FR0]];
+; CHECK-DAG:  cvt.rn.bf16.f32  [[R1:%h[0-9]+]], [[FR1]];
+; CHECK-NEXT: mov.b32 [[R:%hh[0-9]+]], {[[R0]], [[R1]]}
+; CHECK-NEXT: st.param.b32[func_retval0+0], [[R]];
+; CHECK-NEXT: ret;
+
+define <2 x bfloat> @test_fdiv(<2 x bfloat> %a, <2 x bfloat> %b) #0 {
+  %r = fdiv <2 x bfloat> %a, %b
+  ret <2 x bfloat> %r
+}
Index: llvm/lib/Target/NVPTX/NVPTXTargetTransformInfo.cpp
===
--- llvm/lib/Target/NVPTX/NVPTXTargetTransformInfo.cpp
+++ llvm/lib/Target/NVPTX/NVPTXTargetTransformInfo.cpp
@@ -204,6 +204,14 @@
   return 

[PATCH] D150479: [clang][modules][deps] Allow skipping submodule definitions

2023-05-15 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir added inline comments.



Comment at: clang/test/ClangScanDeps/modules-private-framework-submodule.c:43
 // CHECK-NEXT:   "context-hash": "{{.*}}",
-// CHECK-NEXT:   "module-name": "FW2_Private"
+// CHECK-NEXT:   "module-name": "FW2"
 // CHECK-NEXT: }

jansvoboda11 wrote:
> benlangmuir wrote:
> > Does this lose any test coverage for the FW2_Private case?
> This still tests the same general code path, just a more specific case of it. 
> I can keep this test as is and create new one specifically to test the 
> "explicit submodule" case if that makes more sense to you.
Yeah, my preference would be to add a case instead of modifying this one, 
unless there is somewhere else we're already testing the same thing. The exact 
behaviour of FW2.Private vs FW2_Private vs FW2Private is all subtlely different


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150479

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


[PATCH] D150494: [clang][modules] NFC: Only sort interesting identifiers

2023-05-15 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added inline comments.



Comment at: clang/lib/Serialization/ASTWriter.cpp:3646
 // file.
 SmallVector IIs;
 for (const auto  : PP.getIdentifierTable())

ributzka wrote:
> Would it make sense to reduce the size of the SmallVector too?
That would most likely regress serialization of real (non-scanning) PCMs, so 
I'd prefer to leave this be.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150494

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


[PATCH] D149976: adding bf16 support to NVPTX

2023-05-15 Thread Kushan Ahmadian via Phabricator via cfe-commits
kushanam abandoned this revision.
kushanam added a comment.

Redundant to D144911 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149976

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


[PATCH] D150479: [clang][modules][deps] Allow skipping submodule definitions

2023-05-15 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added inline comments.



Comment at: clang/test/ClangScanDeps/modules-private-framework-submodule.c:43
 // CHECK-NEXT:   "context-hash": "{{.*}}",
-// CHECK-NEXT:   "module-name": "FW2_Private"
+// CHECK-NEXT:   "module-name": "FW2"
 // CHECK-NEXT: }

benlangmuir wrote:
> Does this lose any test coverage for the FW2_Private case?
This still tests the same general code path, just a more specific case of it. I 
can keep this test as is and create new one specifically to test the "explicit 
submodule" case if that makes more sense to you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150479

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


[PATCH] D149976: adding bf16 support to NVPTX

2023-05-15 Thread Kushan Ahmadian via Phabricator via cfe-commits
kushanam updated this revision to Diff 522283.
kushanam added a comment.

Addressing the review changed adn removing bf16 specific registers


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149976

Files:
  clang/include/clang/Basic/BuiltinsNVPTX.def
  llvm/include/llvm/IR/IntrinsicsNVVM.td
  llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXInstPrinter.cpp
  llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
  llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.cpp
  llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.h
  llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
  llvm/lib/Target/NVPTX/NVPTXInstrInfo.td
  llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
  llvm/lib/Target/NVPTX/NVPTXMCExpr.cpp
  llvm/lib/Target/NVPTX/NVPTXMCExpr.h
  llvm/lib/Target/NVPTX/NVPTXRegisterInfo.td
  llvm/lib/Target/NVPTX/NVPTXSubtarget.cpp
  llvm/lib/Target/NVPTX/NVPTXSubtarget.h
  llvm/lib/Target/NVPTX/NVPTXTargetTransformInfo.cpp
  llvm/test/CodeGen/NVPTX/bf16-instructions.ll

Index: llvm/test/CodeGen/NVPTX/bf16-instructions.ll
===
--- /dev/null
+++ llvm/test/CodeGen/NVPTX/bf16-instructions.ll
@@ -0,0 +1,88 @@
+; RUN: llc < %s -march=nvptx64 -mcpu=sm_80 -mattr=+ptx70 | FileCheck %s
+; RUN: %if ptxas-11.0 %{ llc < %s -march=nvptx64 -mcpu=sm_80 -mattr=+ptx70 | %ptxas-verify -arch=sm_80 %}
+
+
+; CHECK-LABEL: test_fadd(
+; CHECK-DAG:  ld.param.b16[[A:%h[0-9]+]], [test_fadd_param_0];
+; CHECK-DAG:  ld.param.b16[[B:%h[0-9]+]], [test_fadd_param_1];
+; CHECK-NEXT: add.rn.bf16 [[R:%f[0-9]+]], [[A]], [[B]];
+; CHECK-NEXT: st.param.b16[func_retval0+0], [[R]];
+; CHECK-NEXT: ret;
+
+define bfloat @test_fadd(bfloat %0, bfloat %1) {
+  %3 = fadd bfloat %0, %1 
+  ret bfloat %3
+}
+
+; CHECK-LABEL: test_fsub(
+; CHECK-DAG:  ld.param.b16[[A:%h[0-9]+]], [test_fsub_param_0];
+; CHECK-DAG:  ld.param.b16[[B:%h[0-9]+]], [test_fsub_param_1];
+; CHECK-NEXT: sub.rn.bf16 [[R:%f[0-9]+]], [[A]], [[B]];
+; CHECK-NEXT: st.param.b16[func_retval0+0], [[R]];
+; CHECK-NEXT: ret;
+
+define bfloat @test_fsub(bfloat %0, bfloat %1) {
+  %3 = fsub bfloat %0, %1 
+  ret bfloat %3
+}
+
+; CHECK-LABEL: test_faddx2(
+; CHECK-DAG:  ld.param.b32[[A:%hh[0-9]+]], [test_faddx2_param_0];
+; CHECK-DAG:  ld.param.b32[[B:%hh[0-9]+]], [test_faddx2_param_1];
+; CHECK-NEXT: add.rn.bf16x2   [[R:%f[0-9]+]], [[A]], [[B]];
+
+; CHECK:  st.param.b32[func_retval0+0], [[R]];
+; CHECK:  ret;
+
+define <2 x bfloat> @test_faddx2(<2 x bfloat> %a, <2 x bfloat> %b) #0 {
+  %r = fadd <2 x bfloat> %a, %b
+  ret <2 x bfloat> %r
+}
+
+; CHECK-LABEL: test_fsubx2(
+; CHECK-DAG:  ld.param.b32[[A:%hh[0-9]+]], [test_fsubx2_param_0];
+; CHECK-DAG:  ld.param.b32[[B:%hh[0-9]+]], [test_fsubx2_param_1];
+; CHECK-NEXT: sub.rn.bf16x2   [[R:%f[0-9]+]], [[A]], [[B]];
+
+; CHECK:  st.param.b32[func_retval0+0], [[R]];
+; CHECK:  ret;
+
+define <2 x bfloat> @test_fsubx2(<2 x bfloat> %a, <2 x bfloat> %b) #0 {
+  %r = fsub <2 x bfloat> %a, %b
+  ret <2 x bfloat> %r
+}
+
+; CHECK-LABEL: test_fmulx2(
+; CHECK-DAG:  ld.param.b32[[A:%hh[0-9]+]], [test_fmulx2_param_0];
+; CHECK-DAG:  ld.param.b32[[B:%hh[0-9]+]], [test_fmulx2_param_1];
+; CHECK-NEXT: mul.rn.bf16x2   [[R:%f[0-9]+]], [[A]], [[B]];
+
+; CHECK:  st.param.b32[func_retval0+0], [[R]];
+; CHECK:  ret;
+
+define <2 x bfloat> @test_fmul(<2 x bfloat> %a, <2 x bfloat> %b) #0 {
+  %r = fmul <2 x bfloat> %a, %b
+  ret <2 x bfloat> %r
+}
+
+; CHECK-LABEL: test_fdiv(
+; CHECK-DAG:  ld.param.b32[[A:%hh[0-9]+]], [test_fdiv_param_0];
+; CHECK-DAG:  ld.param.b32[[B:%hh[0-9]+]], [test_fdiv_param_1];
+; CHECK-DAG:  mov.b32 {[[A0:%h[0-9]+]], [[A1:%h[0-9]+]]}, [[A]]
+; CHECK-DAG:  mov.b32 {[[B0:%h[0-9]+]], [[B1:%h[0-9]+]]}, [[B]]
+; CHECK-DAG:  cvt.f32.bf16 [[FA0:%f[0-9]+]], [[A0]];
+; CHECK-DAG:  cvt.f32.bf16 [[FA1:%f[0-9]+]], [[A1]];
+; CHECK-DAG:  cvt.f32.bf16 [[FB0:%f[0-9]+]], [[B0]];
+; CHECK-DAG:  cvt.f32.bf16 [[FB1:%f[0-9]+]], [[B1]];
+; CHECK-DAG:  div.rn.f32  [[FR0:%f[0-9]+]], [[FA0]], [[FB0]];
+; CHECK-DAG:  div.rn.f32  [[FR1:%f[0-9]+]], [[FA1]], [[FB1]];
+; CHECK-DAG:  cvt.rn.bf16.f32  [[R0:%h[0-9]+]], [[FR0]];
+; CHECK-DAG:  cvt.rn.bf16.f32  [[R1:%h[0-9]+]], [[FR1]];
+; CHECK-NEXT: mov.b32 [[R:%hh[0-9]+]], {[[R0]], [[R1]]}
+; CHECK-NEXT: st.param.b32[func_retval0+0], [[R]];
+; CHECK-NEXT: ret;
+
+define <2 x bfloat> @test_fdiv(<2 x bfloat> %a, <2 x bfloat> %b) #0 {
+  %r = fdiv <2 x bfloat> %a, %b
+  ret <2 x bfloat> %r
+}
Index: llvm/lib/Target/NVPTX/NVPTXTargetTransformInfo.cpp
===
--- llvm/lib/Target/NVPTX/NVPTXTargetTransformInfo.cpp
+++ llvm/lib/Target/NVPTX/NVPTXTargetTransformInfo.cpp
@@ -204,6 +204,14 @@
   return {Intrinsic::fma, FTZ_MustBeOff, true};
 case 

[PATCH] D146358: [clang][AST] Print name instead of type when diagnosing uninitialized subobject in constexpr variables

2023-05-15 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM! Did you end up requesting commit access? If not, now is probably a good 
time: https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access




Comment at: clang/lib/AST/ExprConstant.cpp:2357-2361
+if (SubobjectDecl) {
+  Info.FFDiag(DiagLoc, diag::note_constexpr_uninitialized) << 
SubobjectDecl;
+  Info.Note(SubobjectDecl->getLocation(),
+diag::note_constexpr_subobject_declared_here);
+}

hazohelet wrote:
> tbaeder wrote:
> > aaron.ballman wrote:
> > > hazohelet wrote:
> > > > aaron.ballman wrote:
> > > > > Hmm, this breaks one of the contracts of our constexpr evaluation 
> > > > > engine, doesn't it? My understanding is that if constexpr evaluation 
> > > > > fails, we will have emitted a note diagnostic for why it failed. But 
> > > > > if the caller doesn't pass a nonnull `SubobjectDecl`, we'll return 
> > > > > `false` but we won't issue a diagnostic.
> > > > > 
> > > > > I'm surprised no tests lost notes as a result of this change, that 
> > > > > suggests we're missing test coverage for the cases where nullptr is 
> > > > > passed in explicitly to this function.
> > > > Yeah, I was looking into when `SubobjectDecl` can be null here. I 
> > > > `assert`ed the non-nullness of `SubobjectDecl` before and found that 
> > > > there exists two lines of code 
> > > > (https://github.com/llvm/llvm-project/blob/22a3f974d35da89247c0396594f2e4cd592742eb/clang/test/SemaCXX/attr-weak.cpp#L49
> > > >  and 
> > > > https://github.com/llvm/llvm-project/blob/abf4a8cb15d4faf04ee0da14e37d7349d3bde9a1/clang/test/CodeGenCXX/weak-external.cpp#L97)
> > > >  in the test codes that nulls here.
> > > > It seems they are doing the same thing, doing comparison against a 
> > > > pointer to a `[[gnu::weak]]` member. A simple reproducing code is here: 
> > > > https://godbolt.org/z/qn997n85n
> > > > As you can see from the compiler explorer, there's no note emitted here 
> > > > before the patch.
> > > > I inserted some `printf` into the code before this patch  and confirmed 
> > > > `Info.FFDiag(DiagLoc, diag::note_constexpr_uninitialized) << true << 
> > > > Type` was actually called when compiling the reproducing code and that 
> > > > somehow it is ignored. FWIW, `SubobjectLoc.isValid()` was `false` here.
> > > > It seems they are doing the same thing, doing comparison against a 
> > > > pointer to a [[gnu::weak]] member. A simple reproducing code is here: 
> > > > https://godbolt.org/z/qn997n85n
> > > > As you can see from the compiler explorer, there's no note emitted here 
> > > > before the patch.
> > > 
> > > I see a note generated there:
> > > ```
> > > :4:41: note: comparison against pointer to weak member 
> > > 'Weak::weak_method' can only be performed at runtime
> > > constexpr bool val = ::weak_method != nullptr;
> > > ^
> > > ```
> > > The situations I'm concerned about are the changes to 
> > > ExprConstant.cpp:2270 or line 2399 and so on.
> > The `FFDiag` call can just stay as it was, right? And then only the 
> > `Info.Note` call needs to be conditional for whether we have  a 
> > `SubobjectDecl`.
> In my understanding, the concern is that there could be note loss when 
> `Value.hasValue()` evaluates to `false` and at the same time `SubobjectDecl` 
> is `nullptr` explicitly passed in this change. 
> `[[gnu::weak]]` member pointer comparison is the only example of this 
> happening in the clang test codes where `Subobject` is `nullptr` passed at 
> ExprConstant.cpp:2454 in `CheckFullyInitialized`. In this case the 
> "uninitialized subobject" note was not displayed before this patch as well 
> because there is another note issued elsewhere. Thus, the note loss does not 
> happen.
> 
> BTW, I checked where the `[[gnu::weak]]` note is issued and I think there 
> might be a mistake in the return statements. The `return true` should be 
> `return false` because the constexpr evaluator fails to evaluate the 
> expression, right? Correct me if I am wrong. Here's the reference:
> https://github.com/llvm/llvm-project/blob/e58a49300e757ff61142f6abd227bd1437c1cf87/clang/lib/AST/ExprConstant.cpp#L13140-L13151
> 
> If we change them to `false`, `CheckFullyInitialized` will not be called in 
> this scenario, and we will  have no test cases where `SubobjectDecl` is 
> `nullptr` and at the same time `Value.hasValue()` is `false`. I am unsure 
> whether this is due to the lack of test coverage or it is guaranteed that 
> this condition does not hold here.
> 
> > The `FFDiag` call can just stay as it was, right? And then only the 
> > `Info.Note` call needs to be conditional for whether we have  a 
> > `SubobjectDecl`.
> If `SubobjectDecl` is null, it would cause segfault when the `FFDiag` note is 
> displayed, I think.
> 
> The best way I can think of would be to `assert(SubobjectDecl)` here, 

[PATCH] D150479: [clang][modules][deps] Allow skipping submodule definitions

2023-05-15 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir added inline comments.



Comment at: clang/test/ClangScanDeps/modules-private-framework-submodule.c:43
 // CHECK-NEXT:   "context-hash": "{{.*}}",
-// CHECK-NEXT:   "module-name": "FW2_Private"
+// CHECK-NEXT:   "module-name": "FW2"
 // CHECK-NEXT: }

Does this lose any test coverage for the FW2_Private case?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150479

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


[PATCH] D150446: [analyzer] Check ArraySubscriptExprs in ArrayBoundCheckerV2

2023-05-15 Thread Donát Nagy via Phabricator via cfe-commits
donat.nagy planned changes to this revision.
donat.nagy added a comment.

I started to create tests to demonstrate the differences from the baseline, and 
it turns out that my patch is handling multidimensional arrays incorrectly. 
I'll debug this issue and upload a fixed version of this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150446

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


[PATCH] D150478: [clang][modules][deps] Parse "FW_Private" module map even after loading "FW" PCM

2023-05-15 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir accepted this revision.
benlangmuir added a comment.
This revision is now accepted and ready to land.

LGTM. I ran into a similar issue in a downstream branch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150478

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


[PATCH] D150494: [clang][modules] NFC: Only sort interesting identifiers

2023-05-15 Thread Juergen Ributzka via Phabricator via cfe-commits
ributzka added inline comments.



Comment at: clang/lib/Serialization/ASTWriter.cpp:3646
 // file.
 SmallVector IIs;
 for (const auto  : PP.getIdentifierTable())

Would it make sense to reduce the size of the SmallVector too?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150494

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


[PATCH] D149160: [clang][analyzer] Handle special value AT_FDCWD in affected standard functions

2023-05-15 Thread Balázs Benics via Phabricator via cfe-commits
steakhal accepted this revision.
steakhal 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/D149160/new/

https://reviews.llvm.org/D149160

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


[PATCH] D150597: [clang][AIX] Adding Revised xcoff-roptr CodeGen Test Case

2023-05-15 Thread Qiongsi Wu via Phabricator via cfe-commits
qiongsiwu1 created this revision.
qiongsiwu1 added reviewers: hubert.reinterpretcast, stephenpeckham.
qiongsiwu1 added a project: clang.
Herald added a subscriber: nemanjai.
Herald added a project: All.
qiongsiwu1 requested review of this revision.
Herald added a subscriber: cfe-commits.

https://reviews.llvm.org/D150586 removed a problematic test cases that caused 
failures on non-ppc buildbots. This patch revises the test case and adds it 
back.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150597

Files:
  clang/test/CodeGen/PowerPC/aix-roptr.c


Index: clang/test/CodeGen/PowerPC/aix-roptr.c
===
--- /dev/null
+++ clang/test/CodeGen/PowerPC/aix-roptr.c
@@ -0,0 +1,26 @@
+// REQUIRES: powerpc-registered-target
+// RUN: %clang_cc1 -triple=powerpc-ibm-aix-xcoff -mxcoff-roptr -fdata-sections 
\
+// RUN: -S <%s | FileCheck %s --check-prefix=CHECK32
+// RUN: %clang_cc1 -triple=powerpc64-ibm-aix-xcoff -mxcoff-roptr 
-fdata-sections \
+// RUN: -S <%s | FileCheck %s --check-prefix=CHECK64
+// RUN: not %clang_cc1 -triple=powerpc-ibm-aix-xcoff -mxcoff-roptr \
+// RUN: -S <%s 2>&1 | FileCheck %s --check-prefix=DATA_SECTION_ERR
+// RUN: not %clang_cc1 -triple=powerpc64-ibm-aix-xcoff -mxcoff-roptr \
+// RUN: -S <%s 2>&1 | FileCheck %s --check-prefix=DATA_SECTION_ERR
+// RUN: not %clang_cc1 -triple=powerpc64le-unknown-linux-gnu -mxcoff-roptr \
+// RUN: %s 2>&1 | FileCheck %s --check-prefix=TARGET_ROPTR_ERR
+
+char c1 = 10;
+char* const c1_ptr = 
+// CHECK32: .csect c1_ptr[RO],2
+// CHECK32-NEXT:   .globl  c1_ptr[RO]
+// CHECK32-NEXT:   .align  2
+// CHECK32-NEXT:   .vbyte  4, c1[RW]
+
+// CHECK64: .csect c1_ptr[RO],3
+// CHECK64-NEXT:   .globl  c1_ptr[RO]
+// CHECK64-NEXT:   .align  3
+// CHECK64-NEXT:   .vbyte  8, c1[RW]
+
+// DATA_SECTION_ERR: error: -mxcoff-roptr is supported only with 
-fdata-sections
+// TARGET_ROPTR_ERR: error: unsupported option '-mxcoff-roptr' for target 
'powerpc64le-unknown-linux-gnu'


Index: clang/test/CodeGen/PowerPC/aix-roptr.c
===
--- /dev/null
+++ clang/test/CodeGen/PowerPC/aix-roptr.c
@@ -0,0 +1,26 @@
+// REQUIRES: powerpc-registered-target
+// RUN: %clang_cc1 -triple=powerpc-ibm-aix-xcoff -mxcoff-roptr -fdata-sections \
+// RUN: -S <%s | FileCheck %s --check-prefix=CHECK32
+// RUN: %clang_cc1 -triple=powerpc64-ibm-aix-xcoff -mxcoff-roptr -fdata-sections \
+// RUN: -S <%s | FileCheck %s --check-prefix=CHECK64
+// RUN: not %clang_cc1 -triple=powerpc-ibm-aix-xcoff -mxcoff-roptr \
+// RUN: -S <%s 2>&1 | FileCheck %s --check-prefix=DATA_SECTION_ERR
+// RUN: not %clang_cc1 -triple=powerpc64-ibm-aix-xcoff -mxcoff-roptr \
+// RUN: -S <%s 2>&1 | FileCheck %s --check-prefix=DATA_SECTION_ERR
+// RUN: not %clang_cc1 -triple=powerpc64le-unknown-linux-gnu -mxcoff-roptr \
+// RUN: %s 2>&1 | FileCheck %s --check-prefix=TARGET_ROPTR_ERR
+
+char c1 = 10;
+char* const c1_ptr = 
+// CHECK32: .csect c1_ptr[RO],2
+// CHECK32-NEXT:	.globl	c1_ptr[RO]
+// CHECK32-NEXT:	.align	2
+// CHECK32-NEXT:	.vbyte	4, c1[RW]
+
+// CHECK64: .csect c1_ptr[RO],3
+// CHECK64-NEXT:	.globl	c1_ptr[RO]
+// CHECK64-NEXT:	.align	3
+// CHECK64-NEXT:	.vbyte	8, c1[RW]
+
+// DATA_SECTION_ERR: error: -mxcoff-roptr is supported only with -fdata-sections
+// TARGET_ROPTR_ERR: error: unsupported option '-mxcoff-roptr' for target 'powerpc64le-unknown-linux-gnu'
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D147732: [AMDGPU] Add type mangling for {read, write, readfirst, perm}lane intrinsics

2023-05-15 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D147732#4343146 , @jrbyrnes wrote:

> Hi @yaxunl thanks for the comment.
>
> I looked into AutoUpgrade, and it catches upgrades of this type (unmangled -> 
> mangled) by default (via remangleIntrinsicFunction). I've included tests to 
> demonstrate. Is this the desired effect, or are you asking to blacklist these 
> intrinstics from being upgraded?

That is the desired effect. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147732

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


[PATCH] D147875: [clang][Diagnostics] Show line numbers when printing code snippets

2023-05-15 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/Frontend/TextDiagnostic.cpp:1121-1138
+static unsigned getNumDisplayWidth(unsigned N) {
+  if (N < 10)
+return 1;
+  if (N < 100)
+return 2;
+  if (N < 1'000)
+return 3;

aaronpuchert wrote:
> aaronpuchert wrote:
> > efriedma wrote:
> > > aaron.ballman wrote:
> > > > jrtc27 wrote:
> > > > > kwk wrote:
> > > > > > This function screamed at me to be generalized so I gave it a try: 
> > > > > > https://gist.github.com/kwk/7e408065ea291e49fea4a83cf90a9cdf
> > > > > I don't think I want floating point arithmetic in my compiler... 
> > > > > Something like:
> > > > > 
> > > > > ```
> > > > > unsigned L, M;
> > > > > for (L = 1U, M = 10U; N >= M && M != ~0U; ++L)
> > > > > M = (M > ((~0U) / 10U)) ? (~0U) : (M * 10U);
> > > > > 
> > > > > return (L);
> > > > > ```
> > > > > 
> > > > > is the generalised form (without all the redundant parentheses I 
> > > > > added during debugging).
> > > > Cleaned up a bit:
> > > > ```
> > > > constexpr unsigned getNumDisplayWidth(unsigned N) {
> > > >   unsigned L = 1U, M = 10U;
> > > >   constexpr unsigned Upper = ~0U / 10U;
> > > >   for (; N >= M && M != ~0U; ++L)
> > > > M = M > Upper ? ~0U : M * 10U;
> > > >   return L;
> > > > }
> > > > ```
> > > > https://godbolt.org/z/szTYsEM4v
> > > Slightly less efficient, but easier to read:
> > > 
> > > ```
> > > unsigned getNumDisplayWidth(unsigned N) {
> > >   unsigned Width = 1;
> > >   for (; N >= 10; ++Width)
> > > N /= 10;
> > >   return Width;
> > > }
> > > ```
> > I'd suggest to replace `~0U` by `std::numeric_limits::max()`. And 
> > if we're looking at ``, why not ask it directly how far we need to 
> > go?
> > ```
> > static unsigned getNumDisplayWidth(unsigned N) {
> >   unsigned L = 1u, M = 10u;
> >   constexpr unsigned Max = std::numeric_limits::digits10 + 1;
> >   for (; M <= N && L != Max; ++L)
> > M *= 10u;
> >   return L;
> > }
> > ```
> > This will let the overflow happen, but that should be fine for unsigned 
> > arithmetic. Without overflow:
> > ```
> > static unsigned getNumDisplayWidth(unsigned N) {
> >   unsigned L = 1u, M = 10u;
> >   while (M <= N && L++ != std::numeric_limits::digits10)
> > M *= 10u;
> >   return L;
> > }
> > ```
> > The trick is that the increment is done even if the comparison fails and we 
> > exit the loop.
> Though pre-increment also does it if we change the right-hand side:
> ```
>   while (M <= N && ++L != std::numeric_limits::digits10 + 1)
> M *= 10u;
> ```
+1 to the final suggestion that's fully generalized.


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

https://reviews.llvm.org/D147875

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


[PATCH] D150111: [clang][Interp] Implement lambda static invokers

2023-05-15 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/AST/Interp/ByteCodeEmitter.cpp:100-103
+  bool IsEligibleForCompilation =
+  FuncDecl->isConstexpr() ||
+  (isa(FuncDecl) &&
+   cast(FuncDecl)->isLambdaStaticInvoker());

I don't like the `isa` followed by a `cast` code smell, but rewriting it to use 
`dyn_cast` is perhaps kind of ugly:
```
bool IsEligibleForCompilation = false;
if (const auto *MD = dyn_cast())
  IsEligibleForCompilation = MD->isLambdaStaticInvoker();
if (!IsEligibleForCompilation)
  IsEligibleForCompilation = FuncDecl->isConstexpr();
```
WDYT?



Comment at: clang/lib/AST/Interp/ByteCodeStmtGen.cpp:125-126
+
+// We do the lvalue-to-rvalue conversion manually here, so no need
+// to care about references.
+PrimType ParamType = this->classify(PVD->getType()).value_or(PT_Ptr);

Why do we need to do lvalue-to-rvalue conversion at all? The caller of the 
lambda function call operator would have already performed that conversion, 
right?


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

https://reviews.llvm.org/D150111

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


[PATCH] D150490: Enable frame pointer for all non-leaf functions on riscv64 Android

2023-05-15 Thread Elliott Hughes via Phabricator via cfe-commits
enh added a comment.

In D150490#4343128 , @hiraditya wrote:

>> Is there more context on why Android enables the frame pointer?
>
> From what i gathered, this is more of an effort to have parity such that 
> existing build flag overrides continue to be consistent.

well, when i said that on the internal chat, i thought you were asking "why do 
we say what clang already says?" :-)

if the question was actually "is there more context on why Android enables the 
frame pointer?" i'd have said something like "because Android developers [OS 
and app developers alike] do so much debugging from the field, where all we get 
is a crash report for something we probably can't repro locally, that having 
good _and_ cheap unwinds is super important to us".


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

https://reviews.llvm.org/D150490

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


  1   2   3   >