[PATCH] D146921: [clang-tidy] Implement cppcoreguidelines F.19

2023-05-05 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL added a comment.

`forwarding reference parameter '' is never forwarded inside the function body 
[cppcoreguidelines-missing-std-forward]`
consider ignoring unnamed parameters, they unused, so nothing to forward.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146921

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


[PATCH] D148094: [clang][CodeGen] Break up TargetInfo.cpp [6/6]

2023-05-05 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 updated this revision to Diff 520034.
barannikov88 edited the summary of this revision.
barannikov88 added a comment.

- Forward declare CodeGenTypes
- Split a few more virtual functions into declaration+definition to not depend 
on transitive includes, which are going to be removed


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148094

Files:
  clang/docs/UsersManual.rst
  clang/lib/CodeGen/ABIInfo.cpp
  clang/lib/CodeGen/ABIInfoImpl.cpp
  clang/lib/CodeGen/ABIInfoImpl.h
  clang/lib/CodeGen/CMakeLists.txt
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/CodeGen/Targets/AArch64.cpp
  clang/lib/CodeGen/Targets/AArch64.h
  clang/lib/CodeGen/Targets/AMDGPU.cpp
  clang/lib/CodeGen/Targets/AMDGPU.h
  clang/lib/CodeGen/Targets/ARC.cpp
  clang/lib/CodeGen/Targets/ARC.h
  clang/lib/CodeGen/Targets/ARM.cpp
  clang/lib/CodeGen/Targets/ARM.h
  clang/lib/CodeGen/Targets/AVR.cpp
  clang/lib/CodeGen/Targets/AVR.h
  clang/lib/CodeGen/Targets/BPF.cpp
  clang/lib/CodeGen/Targets/BPF.h
  clang/lib/CodeGen/Targets/CSKY.cpp
  clang/lib/CodeGen/Targets/CSKY.h
  clang/lib/CodeGen/Targets/Hexagon.cpp
  clang/lib/CodeGen/Targets/Hexagon.h
  clang/lib/CodeGen/Targets/Lanai.cpp
  clang/lib/CodeGen/Targets/Lanai.h
  clang/lib/CodeGen/Targets/LoongArch.cpp
  clang/lib/CodeGen/Targets/LoongArch.h
  clang/lib/CodeGen/Targets/M68k.cpp
  clang/lib/CodeGen/Targets/M68k.h
  clang/lib/CodeGen/Targets/MSP430.cpp
  clang/lib/CodeGen/Targets/MSP430.h
  clang/lib/CodeGen/Targets/Mips.cpp
  clang/lib/CodeGen/Targets/Mips.h
  clang/lib/CodeGen/Targets/NVPTX.cpp
  clang/lib/CodeGen/Targets/NVPTX.h
  clang/lib/CodeGen/Targets/PNaCl.cpp
  clang/lib/CodeGen/Targets/PNaCl.h
  clang/lib/CodeGen/Targets/PPC.cpp
  clang/lib/CodeGen/Targets/PPC.h
  clang/lib/CodeGen/Targets/RISCV.cpp
  clang/lib/CodeGen/Targets/RISCV.h
  clang/lib/CodeGen/Targets/SPIR.cpp
  clang/lib/CodeGen/Targets/SPIR.h
  clang/lib/CodeGen/Targets/Sparc.cpp
  clang/lib/CodeGen/Targets/Sparc.h
  clang/lib/CodeGen/Targets/SystemZ.cpp
  clang/lib/CodeGen/Targets/SystemZ.h
  clang/lib/CodeGen/Targets/TCE.cpp
  clang/lib/CodeGen/Targets/TCE.h
  clang/lib/CodeGen/Targets/VE.cpp
  clang/lib/CodeGen/Targets/VE.h
  clang/lib/CodeGen/Targets/WebAssembly.cpp
  clang/lib/CodeGen/Targets/WebAssembly.h
  clang/lib/CodeGen/Targets/X86.cpp
  clang/lib/CodeGen/Targets/X86.h
  clang/lib/CodeGen/Targets/XCore.cpp
  clang/lib/CodeGen/Targets/XCore.h
  llvm/utils/gn/secondary/clang/lib/CodeGen/BUILD.gn

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


[PATCH] D146921: [clang-tidy] Implement cppcoreguidelines F.19

2023-05-05 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:136
 
+- New :doc:`cppcoreguidelines-missing-std-forward
+  ` check.

Should be after `cppcoreguidelines-misleading-capture-default-by-value`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146921

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


[PATCH] D146921: [clang-tidy] Implement cppcoreguidelines F.19

2023-05-05 Thread Chris Cotter via Phabricator via cfe-commits
ccotter updated this revision to Diff 520032.
ccotter added a comment.

- fix merge


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146921

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/MissingStdForwardCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/MissingStdForwardCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/missing-std-forward.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/missing-std-forward.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/missing-std-forward.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/missing-std-forward.cpp
@@ -0,0 +1,150 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-missing-std-forward %t
+
+// NOLINTBEGIN
+namespace std {
+
+template  struct remove_reference  { using type = T; };
+template  struct remove_reference  { using type = T; };
+template  struct remove_reference { using type = T; };
+
+template  using remove_reference_t = typename remove_reference::type;
+
+template  constexpr T &(remove_reference_t ) noexcept;
+template  constexpr T &(remove_reference_t &) noexcept;
+template  constexpr remove_reference_t &(T &);
+
+} // namespace std
+// NOLINTEND
+
+struct S {
+  S();
+  S(const S&);
+  S(S&&) noexcept;
+  S& operator=(const S&);
+  S& operator=(S&&) noexcept;
+};
+
+template 
+void consumes_all(Ts&&...);
+
+namespace positive_cases {
+
+template 
+void does_not_forward(T&& t) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: forwarding reference parameter 't' is never forwarded inside the function body [cppcoreguidelines-missing-std-forward]
+  T other = t;
+}
+
+template 
+void does_not_forward_invoked(T&& t) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: forwarding reference parameter 't' is never forwarded inside the function body [cppcoreguidelines-missing-std-forward]
+  T other = t();
+}
+
+template 
+void forwards_pairwise(T&& t) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: forwarding reference parameter 't' is never forwarded inside the function body [cppcoreguidelines-missing-std-forward]
+  auto first = std::forward(t.first);
+  auto second = std::forward(t.second);
+}
+
+template 
+void does_not_forward_pack(Ts&&... ts) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:36: warning: forwarding reference parameter 'ts' is never forwarded inside the function body [cppcoreguidelines-missing-std-forward]
+  consumes_all(ts...);
+}
+
+template 
+class AClass {
+
+  template 
+  AClass(U&& u) : data(u) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: forwarding reference parameter 'u' is never forwarded inside the function body [cppcoreguidelines-missing-std-forward]
+
+  template 
+  AClass& operator=(U&& u) { }
+  // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: forwarding reference parameter 'u' is never forwarded inside the function body [cppcoreguidelines-missing-std-forward]
+
+  template 
+  void mixed_params(T&& t, U&& u) {
+// CHECK-MESSAGES: :[[@LINE-1]]:32: warning: forwarding reference parameter 'u' is never forwarded inside the function body [cppcoreguidelines-missing-std-forward]
+T other1 = std::move(t);
+U other2 = std::move(u);
+  }
+
+  T data;
+};
+
+template 
+void does_not_forward_in_evaluated_code(T&& t) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:45: warning: forwarding reference parameter 't' is never forwarded inside the function body [cppcoreguidelines-missing-std-forward]
+  using result_t = decltype(std::forward(t));
+  unsigned len = sizeof(std::forward(t));
+  T other = t;
+}
+
+template 
+void lambda_value_capture(T&& t) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: forwarding reference parameter 't' is never forwarded inside the function body [cppcoreguidelines-missing-std-forward]
+  [=]() { T other = std::forward(t); };
+}
+
+template 
+void lambda_value_reference(T&& t) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: forwarding reference parameter 't' is never forwarded inside the function body [cppcoreguidelines-missing-std-forward]
+  [&]() { T other = std::forward(t); };
+}
+
+} // namespace positive_cases
+
+namespace negative_cases {
+
+template 
+void just_a_decl(T&);
+
+template 
+void does_forward(T&& t) {
+  T other = std::forward(t);
+}
+
+template 
+void does_forward_pack(Ts&&... ts) {
+  consumes_all(std::forward(ts)...);
+}
+
+void pass_by_value(S s) {
+  S other = std::move(s);
+}
+
+void lvalue_ref(S& s) {
+  S other = std::move(s);
+}
+
+void rvalue_ref(S&& s) {
+  S other = std::move(s);
+}
+
+template 
+void templated_rvalue_ref(std::remove_reference_t&& t) {
+  T other = std::move(t);

[PATCH] D149518: [clang][NFC] Optimize clang::ASTNodeKind::isBaseOf

2023-05-05 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL updated this revision to Diff 520031.
PiotrZSL added a comment.

Rebase without changes, just because some testcase in this baseline looks to 
fail.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149518

Files:
  clang/include/clang/AST/ASTTypeTraits.h
  clang/lib/AST/ASTTypeTraits.cpp


Index: clang/lib/AST/ASTTypeTraits.cpp
===
--- clang/lib/AST/ASTTypeTraits.cpp
+++ clang/lib/AST/ASTTypeTraits.cpp
@@ -56,10 +56,23 @@
 {NKI_None, "ObjCProtocolLoc"},
 };
 
+bool ASTNodeKind::isBaseOf(ASTNodeKind Other) const {
+  return isBaseOf(KindId, Other.KindId);
+}
+
 bool ASTNodeKind::isBaseOf(ASTNodeKind Other, unsigned *Distance) const {
   return isBaseOf(KindId, Other.KindId, Distance);
 }
 
+bool ASTNodeKind::isBaseOf(NodeKindId Base, NodeKindId Derived) {
+  if (Base == NKI_None || Derived == NKI_None)
+return false;
+  while (Derived != Base && Derived != NKI_None) {
+Derived = AllKindInfo[Derived].ParentId;
+  }
+  return Derived == Base;
+}
+
 bool ASTNodeKind::isBaseOf(NodeKindId Base, NodeKindId Derived,
unsigned *Distance) {
   if (Base == NKI_None || Derived == NKI_None) return false;
@@ -96,7 +109,7 @@
 ASTNodeKind ASTNodeKind::getMostDerivedCommonAncestor(ASTNodeKind Kind1,
   ASTNodeKind Kind2) {
   NodeKindId Parent = Kind1.KindId;
-  while (!isBaseOf(Parent, Kind2.KindId, nullptr) && Parent != NKI_None) {
+  while (!isBaseOf(Parent, Kind2.KindId) && Parent != NKI_None) {
 Parent = AllKindInfo[Parent].ParentId;
   }
   return ASTNodeKind(Parent);
Index: clang/include/clang/AST/ASTTypeTraits.h
===
--- clang/include/clang/AST/ASTTypeTraits.h
+++ clang/include/clang/AST/ASTTypeTraits.h
@@ -77,10 +77,13 @@
   /// Returns \c true only for the default \c ASTNodeKind()
   constexpr bool isNone() const { return KindId == NKI_None; }
 
+  /// Returns \c true if \c this is a base kind of (or same as) \c Other.
+  bool isBaseOf(ASTNodeKind Other) const;
+
   /// Returns \c true if \c this is a base kind of (or same as) \c Other.
   /// \param Distance If non-null, used to return the distance between \c this
   /// and \c Other in the class hierarchy.
-  bool isBaseOf(ASTNodeKind Other, unsigned *Distance = nullptr) const;
+  bool isBaseOf(ASTNodeKind Other, unsigned *Distance) const;
 
   /// String representation of the kind.
   StringRef asStringRef() const;
@@ -166,6 +169,10 @@
   /// Use getFromNodeKind() to construct the kind.
   constexpr ASTNodeKind(NodeKindId KindId) : KindId(KindId) {}
 
+  /// Returns \c true if \c Base is a base kind of (or same as) \c
+  ///   Derived.
+  static bool isBaseOf(NodeKindId Base, NodeKindId Derived);
+
   /// Returns \c true if \c Base is a base kind of (or same as) \c
   ///   Derived.
   /// \param Distance If non-null, used to return the distance between \c Base


Index: clang/lib/AST/ASTTypeTraits.cpp
===
--- clang/lib/AST/ASTTypeTraits.cpp
+++ clang/lib/AST/ASTTypeTraits.cpp
@@ -56,10 +56,23 @@
 {NKI_None, "ObjCProtocolLoc"},
 };
 
+bool ASTNodeKind::isBaseOf(ASTNodeKind Other) const {
+  return isBaseOf(KindId, Other.KindId);
+}
+
 bool ASTNodeKind::isBaseOf(ASTNodeKind Other, unsigned *Distance) const {
   return isBaseOf(KindId, Other.KindId, Distance);
 }
 
+bool ASTNodeKind::isBaseOf(NodeKindId Base, NodeKindId Derived) {
+  if (Base == NKI_None || Derived == NKI_None)
+return false;
+  while (Derived != Base && Derived != NKI_None) {
+Derived = AllKindInfo[Derived].ParentId;
+  }
+  return Derived == Base;
+}
+
 bool ASTNodeKind::isBaseOf(NodeKindId Base, NodeKindId Derived,
unsigned *Distance) {
   if (Base == NKI_None || Derived == NKI_None) return false;
@@ -96,7 +109,7 @@
 ASTNodeKind ASTNodeKind::getMostDerivedCommonAncestor(ASTNodeKind Kind1,
   ASTNodeKind Kind2) {
   NodeKindId Parent = Kind1.KindId;
-  while (!isBaseOf(Parent, Kind2.KindId, nullptr) && Parent != NKI_None) {
+  while (!isBaseOf(Parent, Kind2.KindId) && Parent != NKI_None) {
 Parent = AllKindInfo[Parent].ParentId;
   }
   return ASTNodeKind(Parent);
Index: clang/include/clang/AST/ASTTypeTraits.h
===
--- clang/include/clang/AST/ASTTypeTraits.h
+++ clang/include/clang/AST/ASTTypeTraits.h
@@ -77,10 +77,13 @@
   /// Returns \c true only for the default \c ASTNodeKind()
   constexpr bool isNone() const { return KindId == NKI_None; }
 
+  /// Returns \c true if \c this is a base kind of (or same as) \c Other.
+  bool isBaseOf(ASTNodeKind Other) const;
+
   /// Returns \c true if \c this is a base kind of (or same as) \c Other.
   /// \param Distance If 

[PATCH] D150017: [Clang][BPF] Type print btf_type_tag properly

2023-05-05 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song created this revision.
yonghong-song added reviewers: ast, aaron.ballman.
Herald added a project: All.
yonghong-song requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

When running bcc tool execsnoop ([1]) which is built with latest llvm,
I hit the following error:

  $ sudo ./execsnoop.py
  /virtual/main.c:99:157: error: expected ')' 
data.ppid = ({ typeof(pid_t) _val; __builtin_memset(&_val, 0, 
sizeof(_val)); bpf_probe_read(&_val, sizeof(_val),
   (void *)&({ typeof(struct task_struct  btf_type_tag(rcu)*) _val; 
__builtin_memset(&_val, 0, sizeof(_val));
  ^   
bpf_probe_read(&_val, sizeof(_val), (void *)>real_parent); _val; 
})->tgid); _val; }); 

The failure reason is due to that the bcc rewriter printed type like

  struct task_struct  btf_type_tag(rcu)*

where the compiler cannot recognize what 'btf_type_tag(rcu)' is.

The above type is printed in [2] by UnaryOperator->getType().getAsString() 
(from clang)
in function ProbeVisitor::VisitUnaryOperator.

The original source type looks like ([3])

  struct task_struct {
... 
struct task_struct __rcu*real_parent;
... 
  }
  where '__rcu' is a macro expanding to '__attribute__((btf_type_tag("rcu")))'.

Let us print btf_type_tag properly in clang so bcc tools and broader type 
printing
will work properly.

With this patch, the above rewrited source code looks like

  data.ppid = ({ typeof(pid_t) _val; __builtin_memset(&_val, 0, sizeof(_val)); 
bpf_probe_read(&_val, sizeof(_val),
 (void *)&({ typeof(struct task_struct  
__attribute__((btf_type_tag("rcu")))*) _val; __builtin_memset(&_val, 0, 
sizeof(_val));
  bpf_probe_read(&_val, sizeof(_val), (void *)>real_parent); _val; 
})->tgid); _val; }); 

and execsnoop.py tool can run properly.

  [1] https://github.com/iovisor/bcc/blob/master/tools/exitsnoop.py
  [2] 
https://github.com/iovisor/bcc/blob/master/src/cc/frontends/clang/b_frontend_action.cc
  [3] https://github.com/torvalds/linux/blob/master/include/linux/sched.h


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150017

Files:
  clang/lib/AST/TypePrinter.cpp
  clang/test/AST/ast-dump-bpf-attr.c
  clang/test/Sema/attr-btf_type_tag.c
  clang/test/SemaCXX/sugar-common-types.cpp


Index: clang/test/SemaCXX/sugar-common-types.cpp
===
--- clang/test/SemaCXX/sugar-common-types.cpp
+++ clang/test/SemaCXX/sugar-common-types.cpp
@@ -95,7 +95,7 @@
 using SBTF3 = ::SS1 [[clang::btf_type_tag("2")]];
 
 N t21 = 0 ? (SBTF1){} : (SBTF3){}; // expected-error {{from 'SS1'}}
-N t22 = 0 ? (SBTF1){} : (SBTF2){}; // expected-error {{from 'SS1 
btf_type_tag(1)' (aka 'SS1')}}
+N t22 = 0 ? (SBTF1){} : (SBTF2){}; // expected-error {{from 'SS1 
__attribute__((btf_type_tag("1")))' (aka 'SS1')}}
 
 using QX = const SB1 *;
 using QY = const ::SB1 *;
Index: clang/test/Sema/attr-btf_type_tag.c
===
--- clang/test/Sema/attr-btf_type_tag.c
+++ clang/test/Sema/attr-btf_type_tag.c
@@ -28,8 +28,8 @@
 int g1 = _Generic((int *)0, int __tag1 *: 0);
 int g2 = _Generic((int __tag1 *)0, int *: 0);
 int g3 = _Generic(0,
-  int __tag1 * : 0, // expected-note {{compatible type 'int  
btf_type_tag(tag1)*' (aka 'int *') specified here}}
-  int * : 0, // expected-error {{type 'int *' in generic 
association compatible with previously specified type 'int  
btf_type_tag(tag1)*' (aka 'int *')}}
+  int __tag1 * : 0, // expected-note {{compatible type 'int  
__attribute__((btf_type_tag("tag1")))*' (aka 'int *') specified here}}
+  int * : 0, // expected-error {{type 'int *' in generic 
association compatible with previously specified type 'int  
__attribute__((btf_type_tag("tag1")))*' (aka 'int *')}}
   default : 0);
 
 // The btf_type_tag attribute will be ignored during overloadable type matching
Index: clang/test/AST/ast-dump-bpf-attr.c
===
--- /dev/null
+++ clang/test/AST/ast-dump-bpf-attr.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -triple bpf-pc-linux-gnu -ast-dump  %s \
+// RUN: | FileCheck --strict-whitespace %s
+
+int __attribute__((btf_type_tag("rcu"))) * g;
+// CHECK: VarDecl{{.*}}g 'int  __attribute__((btf_type_tag("rcu")))*'
Index: clang/lib/AST/TypePrinter.cpp
===
--- clang/lib/AST/TypePrinter.cpp
+++ clang/lib/AST/TypePrinter.cpp
@@ -1845,7 +1845,7 @@
 void TypePrinter::printBTFTagAttributedBefore(const BTFTagAttributedType *T,
   raw_ostream ) {
   printBefore(T->getWrappedType(), OS);
-  OS << " btf_type_tag(" << T->getAttr()->getBTFTypeTag() << ")";
+  OS << " __attribute__((btf_type_tag(\"" << T->getAttr()->getBTFTypeTag() << 
"\")))";
 }
 
 void 

[PATCH] D148094: [clang][CodeGen] Break up TargetInfo.cpp [6/6]

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

I think it should be ready for review now.

One point to note.
I didn't follow IWYU rule in target *.cpp files -- they include the smallest set
of headers for now. My memory suggests me that IWYU is a requirement,
but I couldn't find a proof in the coding standard. It now says
"include as little as possible" 
 and 
further elaborates:

> You must include all of the header files that you are using — you can include
> them either directly **or indirectly through another header file**.

I also think it is easier to fix compiler errors afterwards than to try to 
figure out
the necessary or reasonable set of includes. Please let me know if you disagree.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148094

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


[PATCH] D146921: [clang-tidy] Implement cppcoreguidelines F.19

2023-05-05 Thread Chris Cotter via Phabricator via cfe-commits
ccotter added a comment.

Note, @PiotrZSL I don't have commit access, so if you're happy with the 
updates, could you please land this for me?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146921

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


[PATCH] D146921: [clang-tidy] Implement cppcoreguidelines F.19

2023-05-05 Thread Chris Cotter via Phabricator via cfe-commits
ccotter updated this revision to Diff 520027.
ccotter added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146921

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/MissingStdForwardCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/MissingStdForwardCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/missing-std-forward.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/missing-std-forward.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/missing-std-forward.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/missing-std-forward.cpp
@@ -0,0 +1,150 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-missing-std-forward %t
+
+// NOLINTBEGIN
+namespace std {
+
+template  struct remove_reference  { using type = T; };
+template  struct remove_reference  { using type = T; };
+template  struct remove_reference { using type = T; };
+
+template  using remove_reference_t = typename remove_reference::type;
+
+template  constexpr T &(remove_reference_t ) noexcept;
+template  constexpr T &(remove_reference_t &) noexcept;
+template  constexpr remove_reference_t &(T &);
+
+} // namespace std
+// NOLINTEND
+
+struct S {
+  S();
+  S(const S&);
+  S(S&&) noexcept;
+  S& operator=(const S&);
+  S& operator=(S&&) noexcept;
+};
+
+template 
+void consumes_all(Ts&&...);
+
+namespace positive_cases {
+
+template 
+void does_not_forward(T&& t) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: forwarding reference parameter 't' is never forwarded inside the function body [cppcoreguidelines-missing-std-forward]
+  T other = t;
+}
+
+template 
+void does_not_forward_invoked(T&& t) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: forwarding reference parameter 't' is never forwarded inside the function body [cppcoreguidelines-missing-std-forward]
+  T other = t();
+}
+
+template 
+void forwards_pairwise(T&& t) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: forwarding reference parameter 't' is never forwarded inside the function body [cppcoreguidelines-missing-std-forward]
+  auto first = std::forward(t.first);
+  auto second = std::forward(t.second);
+}
+
+template 
+void does_not_forward_pack(Ts&&... ts) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:36: warning: forwarding reference parameter 'ts' is never forwarded inside the function body [cppcoreguidelines-missing-std-forward]
+  consumes_all(ts...);
+}
+
+template 
+class AClass {
+
+  template 
+  AClass(U&& u) : data(u) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: forwarding reference parameter 'u' is never forwarded inside the function body [cppcoreguidelines-missing-std-forward]
+
+  template 
+  AClass& operator=(U&& u) { }
+  // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: forwarding reference parameter 'u' is never forwarded inside the function body [cppcoreguidelines-missing-std-forward]
+
+  template 
+  void mixed_params(T&& t, U&& u) {
+// CHECK-MESSAGES: :[[@LINE-1]]:32: warning: forwarding reference parameter 'u' is never forwarded inside the function body [cppcoreguidelines-missing-std-forward]
+T other1 = std::move(t);
+U other2 = std::move(u);
+  }
+
+  T data;
+};
+
+template 
+void does_not_forward_in_evaluated_code(T&& t) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:45: warning: forwarding reference parameter 't' is never forwarded inside the function body [cppcoreguidelines-missing-std-forward]
+  using result_t = decltype(std::forward(t));
+  unsigned len = sizeof(std::forward(t));
+  T other = t;
+}
+
+template 
+void lambda_value_capture(T&& t) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: forwarding reference parameter 't' is never forwarded inside the function body [cppcoreguidelines-missing-std-forward]
+  [=]() { T other = std::forward(t); };
+}
+
+template 
+void lambda_value_reference(T&& t) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: forwarding reference parameter 't' is never forwarded inside the function body [cppcoreguidelines-missing-std-forward]
+  [&]() { T other = std::forward(t); };
+}
+
+} // namespace positive_cases
+
+namespace negative_cases {
+
+template 
+void just_a_decl(T&);
+
+template 
+void does_forward(T&& t) {
+  T other = std::forward(t);
+}
+
+template 
+void does_forward_pack(Ts&&... ts) {
+  consumes_all(std::forward(ts)...);
+}
+
+void pass_by_value(S s) {
+  S other = std::move(s);
+}
+
+void lvalue_ref(S& s) {
+  S other = std::move(s);
+}
+
+void rvalue_ref(S&& s) {
+  S other = std::move(s);
+}
+
+template 
+void templated_rvalue_ref(std::remove_reference_t&& t) {
+  T other = std::move(t);
+}
+

[PATCH] D146921: [clang-tidy] Implement cppcoreguidelines F.19

2023-05-05 Thread Chris Cotter via Phabricator via cfe-commits
ccotter added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/MissingStdForwardCheck.cpp:70
+  Finder->addMatcher(
+  parmVarDecl(
+  parmVarDecl().bind("param"), isTemplateTypeOfFunction(),

PiotrZSL wrote:
> maybe think like: "functionDecl(forEachDescendant(parmVarDecl" could work.
Not sure if I see any advantages of `forEachDescendant` over what I have here - 
I think I'll leave it as is.



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/MissingStdForwardCheck.cpp:71
+  parmVarDecl(
+  parmVarDecl().bind("param"), isTemplateTypeOfFunction(),
+  hasAncestor(functionDecl(isDefinition(), ToParam,

PiotrZSL wrote:
> PiotrZSL wrote:
> > probably this could be named like isTemplateTypeParameter, current name 
> > suggest more that it's a FunctionDecl matcher, not ParmVarDecl.
> consider excluding system code, or code inside std namespace.
Why specifically do this in this check, but not others (very few seem to do 
this)?



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/MissingStdForwardCheck.cpp:72
+  parmVarDecl().bind("param"), isTemplateTypeOfFunction(),
+  hasAncestor(functionDecl(isDefinition(), ToParam,
+   
unless(hasDescendant(ForwardCallMatcher),

PiotrZSL wrote:
> maybe we should skip also template instances.
Not sure I follow. Can you give an example?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146921

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


[PATCH] D146921: [clang-tidy] Implement cppcoreguidelines F.19

2023-05-05 Thread Chris Cotter via Phabricator via cfe-commits
ccotter updated this revision to Diff 520026.
ccotter marked 6 inline comments as done.
ccotter added a comment.

- feedback


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146921

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/MissingStdForwardCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/MissingStdForwardCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/missing-std-forward.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/missing-std-forward.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/missing-std-forward.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/missing-std-forward.cpp
@@ -0,0 +1,150 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-missing-std-forward %t
+
+// NOLINTBEGIN
+namespace std {
+
+template  struct remove_reference  { using type = T; };
+template  struct remove_reference  { using type = T; };
+template  struct remove_reference { using type = T; };
+
+template  using remove_reference_t = typename remove_reference::type;
+
+template  constexpr T &(remove_reference_t ) noexcept;
+template  constexpr T &(remove_reference_t &) noexcept;
+template  constexpr remove_reference_t &(T &);
+
+} // namespace std
+// NOLINTEND
+
+struct S {
+  S();
+  S(const S&);
+  S(S&&) noexcept;
+  S& operator=(const S&);
+  S& operator=(S&&) noexcept;
+};
+
+template 
+void consumes_all(Ts&&...);
+
+namespace positive_cases {
+
+template 
+void does_not_forward(T&& t) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: forwarding reference parameter 't' is never forwarded inside the function body [cppcoreguidelines-missing-std-forward]
+  T other = t;
+}
+
+template 
+void does_not_forward_invoked(T&& t) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: forwarding reference parameter 't' is never forwarded inside the function body [cppcoreguidelines-missing-std-forward]
+  T other = t();
+}
+
+template 
+void forwards_pairwise(T&& t) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: forwarding reference parameter 't' is never forwarded inside the function body [cppcoreguidelines-missing-std-forward]
+  auto first = std::forward(t.first);
+  auto second = std::forward(t.second);
+}
+
+template 
+void does_not_forward_pack(Ts&&... ts) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:36: warning: forwarding reference parameter 'ts' is never forwarded inside the function body [cppcoreguidelines-missing-std-forward]
+  consumes_all(ts...);
+}
+
+template 
+class AClass {
+
+  template 
+  AClass(U&& u) : data(u) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: forwarding reference parameter 'u' is never forwarded inside the function body [cppcoreguidelines-missing-std-forward]
+
+  template 
+  AClass& operator=(U&& u) { }
+  // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: forwarding reference parameter 'u' is never forwarded inside the function body [cppcoreguidelines-missing-std-forward]
+
+  template 
+  void mixed_params(T&& t, U&& u) {
+// CHECK-MESSAGES: :[[@LINE-1]]:32: warning: forwarding reference parameter 'u' is never forwarded inside the function body [cppcoreguidelines-missing-std-forward]
+T other1 = std::move(t);
+U other2 = std::move(u);
+  }
+
+  T data;
+};
+
+template 
+void does_not_forward_in_evaluated_code(T&& t) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:45: warning: forwarding reference parameter 't' is never forwarded inside the function body [cppcoreguidelines-missing-std-forward]
+  using result_t = decltype(std::forward(t));
+  unsigned len = sizeof(std::forward(t));
+  T other = t;
+}
+
+template 
+void lambda_value_capture(T&& t) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: forwarding reference parameter 't' is never forwarded inside the function body [cppcoreguidelines-missing-std-forward]
+  [=]() { T other = std::forward(t); };
+}
+
+template 
+void lambda_value_reference(T&& t) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: forwarding reference parameter 't' is never forwarded inside the function body [cppcoreguidelines-missing-std-forward]
+  [&]() { T other = std::forward(t); };
+}
+
+} // namespace positive_cases
+
+namespace negative_cases {
+
+template 
+void just_a_decl(T&);
+
+template 
+void does_forward(T&& t) {
+  T other = std::forward(t);
+}
+
+template 
+void does_forward_pack(Ts&&... ts) {
+  consumes_all(std::forward(ts)...);
+}
+
+void pass_by_value(S s) {
+  S other = std::move(s);
+}
+
+void lvalue_ref(S& s) {
+  S other = std::move(s);
+}
+
+void rvalue_ref(S&& s) {
+  S other = std::move(s);
+}
+
+template 
+void 

[PATCH] D148094: [DRAFT][clang][CodeGen] Break up TargetInfo.cpp [6/6]

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

Move interface comments to the header file


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148094

Files:
  clang/docs/UsersManual.rst
  clang/lib/CodeGen/ABIInfo.cpp
  clang/lib/CodeGen/ABIInfoImpl.cpp
  clang/lib/CodeGen/ABIInfoImpl.h
  clang/lib/CodeGen/CMakeLists.txt
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/CodeGen/Targets/AArch64.cpp
  clang/lib/CodeGen/Targets/AArch64.h
  clang/lib/CodeGen/Targets/AMDGPU.cpp
  clang/lib/CodeGen/Targets/AMDGPU.h
  clang/lib/CodeGen/Targets/ARC.cpp
  clang/lib/CodeGen/Targets/ARC.h
  clang/lib/CodeGen/Targets/ARM.cpp
  clang/lib/CodeGen/Targets/ARM.h
  clang/lib/CodeGen/Targets/AVR.cpp
  clang/lib/CodeGen/Targets/AVR.h
  clang/lib/CodeGen/Targets/BPF.cpp
  clang/lib/CodeGen/Targets/BPF.h
  clang/lib/CodeGen/Targets/CSKY.cpp
  clang/lib/CodeGen/Targets/CSKY.h
  clang/lib/CodeGen/Targets/Hexagon.cpp
  clang/lib/CodeGen/Targets/Hexagon.h
  clang/lib/CodeGen/Targets/Lanai.cpp
  clang/lib/CodeGen/Targets/Lanai.h
  clang/lib/CodeGen/Targets/LoongArch.cpp
  clang/lib/CodeGen/Targets/LoongArch.h
  clang/lib/CodeGen/Targets/M68k.cpp
  clang/lib/CodeGen/Targets/M68k.h
  clang/lib/CodeGen/Targets/MSP430.cpp
  clang/lib/CodeGen/Targets/MSP430.h
  clang/lib/CodeGen/Targets/Mips.cpp
  clang/lib/CodeGen/Targets/Mips.h
  clang/lib/CodeGen/Targets/NVPTX.cpp
  clang/lib/CodeGen/Targets/NVPTX.h
  clang/lib/CodeGen/Targets/PNaCl.cpp
  clang/lib/CodeGen/Targets/PNaCl.h
  clang/lib/CodeGen/Targets/PPC.cpp
  clang/lib/CodeGen/Targets/PPC.h
  clang/lib/CodeGen/Targets/RISCV.cpp
  clang/lib/CodeGen/Targets/RISCV.h
  clang/lib/CodeGen/Targets/SPIR.cpp
  clang/lib/CodeGen/Targets/SPIR.h
  clang/lib/CodeGen/Targets/Sparc.cpp
  clang/lib/CodeGen/Targets/Sparc.h
  clang/lib/CodeGen/Targets/SystemZ.cpp
  clang/lib/CodeGen/Targets/SystemZ.h
  clang/lib/CodeGen/Targets/TCE.cpp
  clang/lib/CodeGen/Targets/TCE.h
  clang/lib/CodeGen/Targets/VE.cpp
  clang/lib/CodeGen/Targets/VE.h
  clang/lib/CodeGen/Targets/WebAssembly.cpp
  clang/lib/CodeGen/Targets/WebAssembly.h
  clang/lib/CodeGen/Targets/X86.cpp
  clang/lib/CodeGen/Targets/X86.h
  clang/lib/CodeGen/Targets/XCore.cpp
  clang/lib/CodeGen/Targets/XCore.h
  llvm/utils/gn/secondary/clang/lib/CodeGen/BUILD.gn

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


[clang] 5b388f8 - [C++20] [Modules] Don't check input files for C++20 Modules

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

Author: Chuanqi Xu
Date: 2023-05-06T11:17:15+08:00
New Revision: 5b388f86aa9ce65778677ae56587867d6786355e

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

LOG: [C++20] [Modules] Don't check input files for C++20 Modules

Close https://github.com/llvm/llvm-project/issues/62269

Currently, the compiler will emit errors when we compile C++20 modules
if the referenced files changed or got removed. This is because we reuse
the existing logic from Clang implicit modules. It is helpful for clang
implicit modules since it is implicit and we want to be sure things
don't go wrong. But it is not necessary for C++20 modules. The C++20
modules is explicit and it is build systems' responsibility to maintain
the dependencies. So the check in the compiler side may be an overkill.

Added: 
clang/test/Modules/cxx20-no-check-input.cppm

Modified: 
clang/include/clang/Serialization/ModuleFile.h
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp

Removed: 




diff  --git a/clang/include/clang/Serialization/ModuleFile.h 
b/clang/include/clang/Serialization/ModuleFile.h
index 871fdd0a48381..45fb75df8a435 100644
--- a/clang/include/clang/Serialization/ModuleFile.h
+++ b/clang/include/clang/Serialization/ModuleFile.h
@@ -164,6 +164,9 @@ class ModuleFile {
   /// Whether this precompiled header is a relocatable PCH file.
   bool RelocatablePCH = false;
 
+  /// Whether this mdoule file is a standard c++ module.
+  bool StandardCXXModule = false;
+
   /// Whether timestamps are included in this module file.
   bool HasTimestamps = false;
 

diff  --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index 13fec49e841cc..9c31f9db14679 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -2389,12 +2389,15 @@ InputFile ASTReader::getInputFile(ModuleFile , 
unsigned ID, bool Complain) {
   StringRef Filename = FI.Filename;
   uint64_t StoredContentHash = FI.ContentHash;
 
+  // For standard C++ modules, we don't need to check the inputs.
+  bool SkipChecks = F.StandardCXXModule;
+
   OptionalFileEntryRefDegradesToFileEntryPtr File = OptionalFileEntryRef(
   expectedToOptional(FileMgr.getFileRef(Filename, /*OpenFile=*/false)));
 
   // For an overridden file, create a virtual file with the stored
   // size/timestamp.
-  if ((Overridden || Transient) && !File)
+  if ((Overridden || Transient || SkipChecks) && !File)
 File = FileMgr.getVirtualFileRef(Filename, StoredSize, StoredTime);
 
   if (!File) {
@@ -2417,7 +2420,7 @@ InputFile ASTReader::getInputFile(ModuleFile , unsigned 
ID, bool Complain) {
   // PCH.
   SourceManager  = getSourceManager();
   // FIXME: Reject if the overrides are 
diff erent.
-  if ((!Overridden && !Transient) && SM.isFileOverridden(File)) {
+  if ((!Overridden && !Transient) && !SkipChecks && SM.isFileOverridden(File)) 
{
 if (Complain)
   Error(diag::err_fe_pch_file_overridden, Filename);
 
@@ -2476,7 +2479,7 @@ InputFile ASTReader::getInputFile(ModuleFile , unsigned 
ID, bool Complain) {
   };
 
   bool IsOutOfDate = false;
-  auto FileChange = HasInputFileChanged();
+  auto FileChange = SkipChecks ? Change{Change::None} : HasInputFileChanged();
   // For an overridden file, there is nothing to validate.
   if (!Overridden && FileChange.Kind != Change::None) {
 if (Complain && !Diags.isDiagnosticInFlight()) {
@@ -2821,7 +2824,7 @@ ASTReader::ReadControlBlock(ModuleFile ,
 return VersionMismatch;
   }
 
-  bool hasErrors = Record[6];
+  bool hasErrors = Record[7];
   if (hasErrors && !DisableValidation) {
 // If requested by the caller and the module hasn't already been read
 // or compiled, mark modules on error as out-of-date.
@@ -2845,7 +2848,9 @@ ASTReader::ReadControlBlock(ModuleFile ,
   if (F.RelocatablePCH)
 F.BaseDirectory = isysroot.empty() ? "/" : isysroot;
 
-  F.HasTimestamps = Record[5];
+  F.StandardCXXModule = Record[5];
+
+  F.HasTimestamps = Record[6];
 
   const std::string  = getClangFullRepositoryVersion();
   StringRef ASTBranch = Blob;

diff  --git a/clang/lib/Serialization/ASTWriter.cpp 
b/clang/lib/Serialization/ASTWriter.cpp
index 94c851d2dbf16..e124cb4c5f81d 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -1243,6 +1243,8 @@ void ASTWriter::WriteControlBlock(Preprocessor , 
ASTContext ,
   MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16)); // Clang 
maj.
   MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16)); // Clang 
min.
   MetadataAbbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // 
Relocatable
+  // Standard C++ module
+  

[PATCH] D141907: [CMake] Ensure `CLANG_RESOURCE_DIR` is respected

2023-05-05 Thread Tom Stellard via Phabricator via cfe-commits
tstellar accepted this revision.
tstellar added a comment.
This revision is now accepted and ready to land.

Thanks for the patch.  I've tested this and it works for my build 
configuration.  LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141907

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


[PATCH] D149867: [M68k] Add Clang support for the new M68k_RTD CC

2023-05-05 Thread Sheng via Phabricator via cfe-commits
0x59616e added a comment.

I didn't see any issue here. Let's wait for the approval from other (more 
senior) reviewers.


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

https://reviews.llvm.org/D149867

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


[PATCH] D149647: [NFC][Clang]Fix static analyzer tool remarks about large copies by values

2023-05-05 Thread Soumi Manna via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbabe8629d73f: [NFC][Clang] Fix static analyzer tool remarks 
about large copies by values in… (authored by Manna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149647

Files:
  clang/lib/Format/Format.cpp


Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -3485,7 +3485,7 @@
 if (Style.InsertBraces) {
   FormatStyle S = Expanded;
   S.InsertBraces = true;
-  Passes.emplace_back([&, S](const Environment ) {
+  Passes.emplace_back([&, S = std::move(S)](const Environment ) {
 return BracesInserter(Env, S).process(/*SkipAnnotation=*/true);
   });
 }
@@ -3493,7 +3493,7 @@
 if (Style.RemoveBracesLLVM) {
   FormatStyle S = Expanded;
   S.RemoveBracesLLVM = true;
-  Passes.emplace_back([&, S](const Environment ) {
+  Passes.emplace_back([&, S = std::move(S)](const Environment ) {
 return BracesRemover(Env, S).process(/*SkipAnnotation=*/true);
   });
 }
@@ -3501,7 +3501,7 @@
 if (Style.RemoveSemicolon) {
   FormatStyle S = Expanded;
   S.RemoveSemicolon = true;
-  Passes.emplace_back([&, S](const Environment ) {
+  Passes.emplace_back([&, S = std::move(S)](const Environment ) {
 return SemiRemover(Env, S).process(/*SkipAnnotation=*/true);
   });
 }


Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -3485,7 +3485,7 @@
 if (Style.InsertBraces) {
   FormatStyle S = Expanded;
   S.InsertBraces = true;
-  Passes.emplace_back([&, S](const Environment ) {
+  Passes.emplace_back([&, S = std::move(S)](const Environment ) {
 return BracesInserter(Env, S).process(/*SkipAnnotation=*/true);
   });
 }
@@ -3493,7 +3493,7 @@
 if (Style.RemoveBracesLLVM) {
   FormatStyle S = Expanded;
   S.RemoveBracesLLVM = true;
-  Passes.emplace_back([&, S](const Environment ) {
+  Passes.emplace_back([&, S = std::move(S)](const Environment ) {
 return BracesRemover(Env, S).process(/*SkipAnnotation=*/true);
   });
 }
@@ -3501,7 +3501,7 @@
 if (Style.RemoveSemicolon) {
   FormatStyle S = Expanded;
   S.RemoveSemicolon = true;
-  Passes.emplace_back([&, S](const Environment ) {
+  Passes.emplace_back([&, S = std::move(S)](const Environment ) {
 return SemiRemover(Env, S).process(/*SkipAnnotation=*/true);
   });
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] babe862 - [NFC][Clang] Fix static analyzer tool remarks about large copies by values in Format.cpp file

2023-05-05 Thread via cfe-commits

Author: Manna, Soumi
Date: 2023-05-05T18:55:49-07:00
New Revision: babe8629d73fb52bf85516222cd484da0eed6c12

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

LOG: [NFC][Clang] Fix static analyzer tool remarks about large copies by values 
in Format.cpp file

Reported by Static Analyzer Tool, Coverity:

Inside "Format.cpp" file, in 
clang::format::internal::reformat(clang::format::FormatStyle const &, 
llvm::StringRef, llvm::ArrayRef, unsigned int, unsigned 
int, unsigned int, llvm::StringRef, clang::format::FormattingAttemptStatus 
*)::[lambda(clang::format::Environment const &) (instance 4)]::operator 
()(clang::format::Environment const &): A very large function call parameter 
exceeding the high threshold is passed by value.

pass_by_value: Capturing variable S of type clang::format::FormatStyle (size 
808 bytes) by value, which exceeds the high threshold of 512 bytes

This patch uses original code but with an init capture that does a move instead 
of a copy.

Reviewed By: tahonermann, erichkeane, MyDeveloperDay, owenpan, 
HazardyKnusperkeks

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

Added: 


Modified: 
clang/lib/Format/Format.cpp

Removed: 




diff  --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index f7c82c581bfc9..ae3f822a2b323 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -3485,7 +3485,7 @@ reformat(const FormatStyle , StringRef Code,
 if (Style.InsertBraces) {
   FormatStyle S = Expanded;
   S.InsertBraces = true;
-  Passes.emplace_back([&, S](const Environment ) {
+  Passes.emplace_back([&, S = std::move(S)](const Environment ) {
 return BracesInserter(Env, S).process(/*SkipAnnotation=*/true);
   });
 }
@@ -3493,7 +3493,7 @@ reformat(const FormatStyle , StringRef Code,
 if (Style.RemoveBracesLLVM) {
   FormatStyle S = Expanded;
   S.RemoveBracesLLVM = true;
-  Passes.emplace_back([&, S](const Environment ) {
+  Passes.emplace_back([&, S = std::move(S)](const Environment ) {
 return BracesRemover(Env, S).process(/*SkipAnnotation=*/true);
   });
 }
@@ -3501,7 +3501,7 @@ reformat(const FormatStyle , StringRef Code,
 if (Style.RemoveSemicolon) {
   FormatStyle S = Expanded;
   S.RemoveSemicolon = true;
-  Passes.emplace_back([&, S](const Environment ) {
+  Passes.emplace_back([&, S = std::move(S)](const Environment ) {
 return SemiRemover(Env, S).process(/*SkipAnnotation=*/true);
   });
 }



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


[PATCH] D150013: [Clang] Respect `-L` options when compiling directly for AMDGPU

2023-05-05 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 created this revision.
jhuber6 added reviewers: tra, yaxunl, JonChesterfield.
Herald added subscribers: kosarev, kerbowa, tpr, dstuttard, jvesely, kzhuravl.
Herald added a project: All.
jhuber6 requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, wdng.
Herald added a project: clang.

The AMDGPU linker is `lld`, which has full support for standard features
like static libraries. Previously the AMDGPU toolchain did not forward
`-L` arguments so we could not tell it where to find certain libraries.
This patch simply forwards it like the other toolchains.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150013

Files:
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/test/Driver/amdgpu-toolchain.c


Index: clang/test/Driver/amdgpu-toolchain.c
===
--- clang/test/Driver/amdgpu-toolchain.c
+++ clang/test/Driver/amdgpu-toolchain.c
@@ -11,6 +11,6 @@
 // DWARF_VER: "-dwarf-version=5"
 
 // RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx906 -nogpulib \
-// RUN:   -flto -fconvergent-functions %s 2>&1 | FileCheck -check-prefix=LTO %s
+// RUN:   -L. -flto -fconvergent-functions %s 2>&1 | FileCheck 
-check-prefix=LTO %s
 // LTO: clang{{.*}} "-flto=full"{{.*}}"-fconvergent-functions"
-// LTO: ld.lld{{.*}}-plugin-opt=mcpu=gfx906
+// LTO: ld.lld{{.*}}"-L."{{.*}}"-plugin-opt=mcpu=gfx906"
Index: clang/lib/Driver/ToolChains/AMDGPU.cpp
===
--- clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -544,6 +544,7 @@
   ArgStringList CmdArgs;
   addLinkerCompressDebugSectionsOption(getToolChain(), Args, CmdArgs);
   AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs, JA);
+  Args.AddAllArgs(CmdArgs, options::OPT_L);
   if (C.getDriver().isUsingLTO())
 addLTOOptions(getToolChain(), Args, CmdArgs, Output, Inputs[0],
   C.getDriver().getLTOMode() == LTOK_Thin);


Index: clang/test/Driver/amdgpu-toolchain.c
===
--- clang/test/Driver/amdgpu-toolchain.c
+++ clang/test/Driver/amdgpu-toolchain.c
@@ -11,6 +11,6 @@
 // DWARF_VER: "-dwarf-version=5"
 
 // RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx906 -nogpulib \
-// RUN:   -flto -fconvergent-functions %s 2>&1 | FileCheck -check-prefix=LTO %s
+// RUN:   -L. -flto -fconvergent-functions %s 2>&1 | FileCheck -check-prefix=LTO %s
 // LTO: clang{{.*}} "-flto=full"{{.*}}"-fconvergent-functions"
-// LTO: ld.lld{{.*}}-plugin-opt=mcpu=gfx906
+// LTO: ld.lld{{.*}}"-L."{{.*}}"-plugin-opt=mcpu=gfx906"
Index: clang/lib/Driver/ToolChains/AMDGPU.cpp
===
--- clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -544,6 +544,7 @@
   ArgStringList CmdArgs;
   addLinkerCompressDebugSectionsOption(getToolChain(), Args, CmdArgs);
   AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs, JA);
+  Args.AddAllArgs(CmdArgs, options::OPT_L);
   if (C.getDriver().isUsingLTO())
 addLTOOptions(getToolChain(), Args, CmdArgs, Output, Inputs[0],
   C.getDriver().getLTOMode() == LTOK_Thin);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D149946: [LoongArch] Define `ual` feature and override `allowsMisalignedMemoryAccesses`

2023-05-05 Thread Lu Weining via Phabricator via cfe-commits
SixWeining added a comment.

Thanks @rengolin and @peter.smith. I just added a new test to show options 
remain unused on a target that does not support them.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149946

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


[PATCH] D148094: [DRAFT][clang][CodeGen] Break up TargetInfo.cpp [6/6]

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

- Rebase on top of the stack
- Fix a header comment
- Split some virtual functions to avoid extra includes in header files
- Forward declare a few classes and add necessary includes (IWYU, header files 
only)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148094

Files:
  clang/docs/UsersManual.rst
  clang/lib/CodeGen/ABIInfo.cpp
  clang/lib/CodeGen/ABIInfoImpl.cpp
  clang/lib/CodeGen/ABIInfoImpl.h
  clang/lib/CodeGen/CMakeLists.txt
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/CodeGen/Targets/AArch64.cpp
  clang/lib/CodeGen/Targets/AArch64.h
  clang/lib/CodeGen/Targets/AMDGPU.cpp
  clang/lib/CodeGen/Targets/AMDGPU.h
  clang/lib/CodeGen/Targets/ARC.cpp
  clang/lib/CodeGen/Targets/ARC.h
  clang/lib/CodeGen/Targets/ARM.cpp
  clang/lib/CodeGen/Targets/ARM.h
  clang/lib/CodeGen/Targets/AVR.cpp
  clang/lib/CodeGen/Targets/AVR.h
  clang/lib/CodeGen/Targets/BPF.cpp
  clang/lib/CodeGen/Targets/BPF.h
  clang/lib/CodeGen/Targets/CSKY.cpp
  clang/lib/CodeGen/Targets/CSKY.h
  clang/lib/CodeGen/Targets/Hexagon.cpp
  clang/lib/CodeGen/Targets/Hexagon.h
  clang/lib/CodeGen/Targets/Lanai.cpp
  clang/lib/CodeGen/Targets/Lanai.h
  clang/lib/CodeGen/Targets/LoongArch.cpp
  clang/lib/CodeGen/Targets/LoongArch.h
  clang/lib/CodeGen/Targets/M68k.cpp
  clang/lib/CodeGen/Targets/M68k.h
  clang/lib/CodeGen/Targets/MSP430.cpp
  clang/lib/CodeGen/Targets/MSP430.h
  clang/lib/CodeGen/Targets/Mips.cpp
  clang/lib/CodeGen/Targets/Mips.h
  clang/lib/CodeGen/Targets/NVPTX.cpp
  clang/lib/CodeGen/Targets/NVPTX.h
  clang/lib/CodeGen/Targets/PNaCl.cpp
  clang/lib/CodeGen/Targets/PNaCl.h
  clang/lib/CodeGen/Targets/PPC.cpp
  clang/lib/CodeGen/Targets/PPC.h
  clang/lib/CodeGen/Targets/RISCV.cpp
  clang/lib/CodeGen/Targets/RISCV.h
  clang/lib/CodeGen/Targets/SPIR.cpp
  clang/lib/CodeGen/Targets/SPIR.h
  clang/lib/CodeGen/Targets/Sparc.cpp
  clang/lib/CodeGen/Targets/Sparc.h
  clang/lib/CodeGen/Targets/SystemZ.cpp
  clang/lib/CodeGen/Targets/SystemZ.h
  clang/lib/CodeGen/Targets/TCE.cpp
  clang/lib/CodeGen/Targets/TCE.h
  clang/lib/CodeGen/Targets/VE.cpp
  clang/lib/CodeGen/Targets/VE.h
  clang/lib/CodeGen/Targets/WebAssembly.cpp
  clang/lib/CodeGen/Targets/WebAssembly.h
  clang/lib/CodeGen/Targets/X86.cpp
  clang/lib/CodeGen/Targets/X86.h
  clang/lib/CodeGen/Targets/XCore.cpp
  clang/lib/CodeGen/Targets/XCore.h
  llvm/utils/gn/secondary/clang/lib/CodeGen/BUILD.gn

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


[PATCH] D149946: [LoongArch] Define `ual` feature and override `allowsMisalignedMemoryAccesses`

2023-05-05 Thread Lu Weining via Phabricator via cfe-commits
SixWeining updated this revision to Diff 520014.
SixWeining added a comment.

Add a test to show related options remain unused on a target that does not 
support them.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149946

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
  clang/test/Driver/loongarch-default-features.c
  clang/test/Driver/loongarch-march.c
  clang/test/Driver/loongarch-mdouble-float.c
  clang/test/Driver/loongarch-mfpu.c
  clang/test/Driver/loongarch-msingle-float.c
  clang/test/Driver/loongarch-msoft-float.c
  clang/test/Driver/loongarch-munaligned-access.c
  clang/test/Driver/munaligned-access-unused.c
  llvm/include/llvm/TargetParser/LoongArchTargetParser.def
  llvm/include/llvm/TargetParser/LoongArchTargetParser.h
  llvm/lib/Target/LoongArch/LoongArch.td
  llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
  llvm/lib/Target/LoongArch/LoongArchISelLowering.h
  llvm/lib/Target/LoongArch/LoongArchSubtarget.h
  llvm/test/CodeGen/LoongArch/calling-conv-lp64d.ll
  llvm/test/CodeGen/LoongArch/ir-instruction/atomicrmw-fp.ll
  llvm/test/CodeGen/LoongArch/tail-calls.ll
  llvm/test/CodeGen/LoongArch/unaligned-access.ll
  llvm/test/CodeGen/LoongArch/unaligned-memcpy-inline.ll

Index: llvm/test/CodeGen/LoongArch/unaligned-memcpy-inline.ll
===
--- /dev/null
+++ llvm/test/CodeGen/LoongArch/unaligned-memcpy-inline.ll
@@ -0,0 +1,97 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
+
+;; Test how memcpy is optimized when ual is turned off which is similar to AArch64/arm64-misaligned-memcpy-inline.ll.
+
+; RUN: llc --mtriple=loongarch32 --mattr=-ual < %s | FileCheck %s --check-prefix=LA32
+; RUN: llc --mtriple=loongarch64 --mattr=-ual < %s | FileCheck %s --check-prefix=LA64
+
+;; Small (16 bytes here) unaligned memcpy() should be a function call if
+;; ual is turned off.
+define void @t0(ptr %out, ptr %in) {
+; LA32-LABEL: t0:
+; LA32:   # %bb.0: # %entry
+; LA32-NEXT:addi.w $sp, $sp, -16
+; LA32-NEXT:.cfi_def_cfa_offset 16
+; LA32-NEXT:st.w $ra, $sp, 12 # 4-byte Folded Spill
+; LA32-NEXT:.cfi_offset 1, -4
+; LA32-NEXT:ori $a2, $zero, 16
+; LA32-NEXT:bl %plt(memcpy)
+; LA32-NEXT:ld.w $ra, $sp, 12 # 4-byte Folded Reload
+; LA32-NEXT:addi.w $sp, $sp, 16
+; LA32-NEXT:ret
+;
+; LA64-LABEL: t0:
+; LA64:   # %bb.0: # %entry
+; LA64-NEXT:addi.d $sp, $sp, -16
+; LA64-NEXT:.cfi_def_cfa_offset 16
+; LA64-NEXT:st.d $ra, $sp, 8 # 8-byte Folded Spill
+; LA64-NEXT:.cfi_offset 1, -8
+; LA64-NEXT:ori $a2, $zero, 16
+; LA64-NEXT:bl %plt(memcpy)
+; LA64-NEXT:ld.d $ra, $sp, 8 # 8-byte Folded Reload
+; LA64-NEXT:addi.d $sp, $sp, 16
+; LA64-NEXT:ret
+entry:
+  call void @llvm.memcpy.p0.p0.i64(ptr %out, ptr %in, i64 16, i1 false)
+  ret void
+}
+
+;; Small (16 bytes here) aligned memcpy() should be inlined even if
+;; ual is turned off.
+define void @t1(ptr align 8 %out, ptr align 8 %in) {
+; LA32-LABEL: t1:
+; LA32:   # %bb.0: # %entry
+; LA32-NEXT:ld.w $a2, $a1, 12
+; LA32-NEXT:st.w $a2, $a0, 12
+; LA32-NEXT:ld.w $a2, $a1, 8
+; LA32-NEXT:st.w $a2, $a0, 8
+; LA32-NEXT:ld.w $a2, $a1, 4
+; LA32-NEXT:st.w $a2, $a0, 4
+; LA32-NEXT:ld.w $a1, $a1, 0
+; LA32-NEXT:st.w $a1, $a0, 0
+; LA32-NEXT:ret
+;
+; LA64-LABEL: t1:
+; LA64:   # %bb.0: # %entry
+; LA64-NEXT:ld.d $a2, $a1, 8
+; LA64-NEXT:st.d $a2, $a0, 8
+; LA64-NEXT:ld.d $a1, $a1, 0
+; LA64-NEXT:st.d $a1, $a0, 0
+; LA64-NEXT:ret
+entry:
+  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %out, ptr align 8 %in, i64 16, i1 false)
+  ret void
+}
+
+;; Tiny (4 bytes here) unaligned memcpy() should be inlined with byte sized
+;; loads and stores if ual is turned off.
+define void @t2(ptr %out, ptr %in) {
+; LA32-LABEL: t2:
+; LA32:   # %bb.0: # %entry
+; LA32-NEXT:ld.b $a2, $a1, 3
+; LA32-NEXT:st.b $a2, $a0, 3
+; LA32-NEXT:ld.b $a2, $a1, 2
+; LA32-NEXT:st.b $a2, $a0, 2
+; LA32-NEXT:ld.b $a2, $a1, 1
+; LA32-NEXT:st.b $a2, $a0, 1
+; LA32-NEXT:ld.b $a1, $a1, 0
+; LA32-NEXT:st.b $a1, $a0, 0
+; LA32-NEXT:ret
+;
+; LA64-LABEL: t2:
+; LA64:   # %bb.0: # %entry
+; LA64-NEXT:ld.b $a2, $a1, 3
+; LA64-NEXT:st.b $a2, $a0, 3
+; LA64-NEXT:ld.b $a2, $a1, 2
+; LA64-NEXT:st.b $a2, $a0, 2
+; LA64-NEXT:ld.b $a2, $a1, 1
+; LA64-NEXT:st.b $a2, $a0, 1
+; LA64-NEXT:ld.b $a1, $a1, 0
+; LA64-NEXT:st.b $a1, $a0, 0
+; LA64-NEXT:ret
+entry:
+  call void @llvm.memcpy.p0.p0.i64(ptr %out, ptr %in, i64 4, i1 false)
+  ret void
+}
+
+declare void @llvm.memcpy.p0.p0.i64(ptr nocapture, ptr nocapture readonly, i64, i1)
Index: llvm/test/CodeGen/LoongArch/unaligned-access.ll
===
--- /dev/null

[PATCH] D149647: [NFC][Clang]Fix static analyzer tool remarks about large copies by values

2023-05-05 Thread Soumi Manna via Phabricator via cfe-commits
Manna added a comment.

>> Thanks again for catching our oops @HazardyKnusperkeks!

Yup, Thank you @HazardyKnusperkeks!


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

https://reviews.llvm.org/D149647

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


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

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



Comment at: llvm/include/llvm/IR/IntrinsicsRISCV.td:1418
 
+  def int_riscv_vreinterpret_v
+: DefaultAttrsIntrinsic<[llvm_anyvector_ty],

craig.topper wrote:
> Do we need an intrinsic?
> 
> m1 -> mask  is bitcast m1 vscale type to  and a 
> llvm.experimental.vector.extract
> mask -> m1 is llvm.experimental.vector.insert to  and a 
> bitcast.
oops there's no experimental in the insert/extract names.


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] D149642: [RISCV] Support vreinterpret intrinsics between vector boolean type and m1 vector integer type

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



Comment at: llvm/include/llvm/IR/IntrinsicsRISCV.td:1418
 
+  def int_riscv_vreinterpret_v
+: DefaultAttrsIntrinsic<[llvm_anyvector_ty],

Do we need an intrinsic?

m1 -> mask  is bitcast m1 vscale type to  and a 
llvm.experimental.vector.extract
mask -> m1 is llvm.experimental.vector.insert to  and a 
bitcast.


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] D149642: [RISCV] Support vreinterpret intrinsics between vector boolean type and m1 vector integer type

2023-05-05 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng added inline comments.



Comment at: 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vreinterpret.c:1
-// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 2
 // REQUIRES: riscv-registered-target

` UTC_ARGS: --version 2`?



Comment at: 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vreinterpret.c:10-13
+// CHECK-RV64-LABEL: define dso_local  
@test_vreinterpret_v_i8mf8_u8mf8
+// CHECK-RV64-SAME: ( [[SRC:%.*]]) #[[ATTR0:[0-9]+]] {
 // CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:ret  [[SRC]]

Why their are so many unrelated diff?


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] D147875: [clang][Diagnostics] Show line numbers when printing code snippets

2023-05-05 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert 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:
> 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;
```


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] D141907: [CMake] Ensure `CLANG_RESOURCE_DIR` is respected

2023-05-05 Thread Junchang Liu via Phabricator via cfe-commits
paperchalice added inline comments.



Comment at: cmake/Modules/GetClangResourceDir.cmake:13
+  if(DEFINED CLANG_RESOURCE_DIR AND NOT CLANG_RESOURCE_DIR STREQUAL "")
+set(ret_dir bin/${CLANG_RESOURCE_DIR})
+  else()

tstellar wrote:
> tstellar wrote:
> > tstellar wrote:
> > > paperchalice wrote:
> > > > tstellar wrote:
> > > > > Why is the bin prefix here?
> > > > See 
> > > > https://clang.llvm.org/doxygen/classclang_1_1driver_1_1Driver.html#acda8dfdf4f80efa84df98157e1779152
> > > > `GetResourcesPath` will return `/lib/` when 
> > > > `CLANG_RESOURCE_DIR` is empty, `/bin/CLANG_RESOURCE_DIR` 
> > > > otherwise.
> > > > 
> > > `GetResourcesPath` calls `sys::path::parent_path` twice on the path to 
> > > the clang executable which is going to give you `/usr ` on most Linux 
> > > systems, so it's returning `/CLANG_RESOURCE_DIR` not 
> > > `/bin/CLANG_RESOURCE_DIR`.
> > Sorry, you are correct.  I was looking at the wrong branch.  It's really 
> > strange that it does that.
> @paperchalice Can you update the description of the CLANG_RESOURCE_DIR cache 
> variable in clang/CMakeLists.txt to mention that the path should be relative 
> to the directory with the clang executable.
Already in [[ 
https://github.com/llvm/llvm-project/blob/c5fefbc8dbc49d1c3133615b46fc9a3ca93dcdc2/clang/CMakeLists.txt#LL178C53-L178C53
 | codebase ]]:
```
set(CLANG_RESOURCE_DIR "" CACHE STRING
  "Relative directory from the Clang binary to its resource files.")
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141907

___
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-05 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added inline comments.



Comment at: clang/include/clang/Driver/Options.td:2544
+defm diagnostics_show_line_numbers : 
BoolFOption<"diagnostics-show-line-numbers",
+  DiagnosticOpts<"ShowLineNumbers">, DefaultTrue,
+  NegFlag,

aaron.ballman wrote:
> I'm hopeful that defaulting this to true (which matches the GCC behavior) is 
> reasonable, but I'm a bit worried about how downstreams will react to this. 
> Specifically, I'm wondering about things like clang-cl integration in MSVC or 
> clang use in Xcode, where diagnostics are being displayed other than on the 
> command line.
I don't like line number margins that much, but I think it should be Ok. What 
I've seen of compiler output parsers, they mainly concentrate on the 
`:[:]: : ` lines and ignore code snippets. 
After all, once they have the source location, they can just look at the file.



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;

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.


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] D148093: [clang][CodeGen] Break up TargetInfo.cpp [5/6]

2023-05-05 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 updated this revision to Diff 520004.
barannikov88 edited the summary of this revision.
barannikov88 added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148093

Files:
  clang/lib/CodeGen/ABIInfo.h
  clang/lib/CodeGen/TargetInfo.cpp


Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -125,7 +125,7 @@
 /// registers when expanded?
 ///
 /// This is intended to be the basis of a reasonable basic implementation
-/// of should{Pass,Return}IndirectlyForSwift.
+/// of should{Pass,Return}Indirectly.
 ///
 /// For most targets, a limit of four total registers is reasonable; this
 /// limits the amount of code required in order to move around the value
@@ -134,15 +134,14 @@
 /// immediately within the callee.  But some targets may need to further
 /// limit the register count due to an inability to support that many
 /// return registers.
-static bool occupiesMoreThan(CodeGenTypes ,
- ArrayRef scalarTypes,
- unsigned maxAllRegisters) {
+bool SwiftABIInfo::occupiesMoreThan(ArrayRef scalarTypes,
+unsigned maxAllRegisters) const {
   unsigned intCount = 0, fpCount = 0;
   for (llvm::Type *type : scalarTypes) {
 if (type->isPointerTy()) {
   intCount++;
 } else if (auto intTy = dyn_cast(type)) {
-  auto ptrWidth = cgt.getTarget().getPointerWidth(LangAS::Default);
+  auto ptrWidth = CGT.getTarget().getPointerWidth(LangAS::Default);
   intCount += (intTy->getBitWidth() + ptrWidth - 1) / ptrWidth;
 } else {
   assert(type->isVectorTy() || type->isFloatingPointTy());
@@ -155,7 +154,7 @@
 
 bool SwiftABIInfo::shouldPassIndirectly(ArrayRef ComponentTys,
 bool AsReturnValue) const {
-  return occupiesMoreThan(CGT, ComponentTys, /*total=*/4);
+  return occupiesMoreThan(ComponentTys, /*total=*/4);
 }
 
 bool SwiftABIInfo::isLegalVectorType(CharUnits VectorSize, llvm::Type *EltTy,
@@ -1246,7 +1245,7 @@
 // integer registers and three fp registers.  Oddly, it'll use up to
 // four vector registers for vectors, but those can overlap with the
 // scalar registers.
-return occupiesMoreThan(CGT, ComponentTys, /*total=*/3);
+return occupiesMoreThan(ComponentTys, /*total=*/3);
   }
 };
 
Index: clang/lib/CodeGen/ABIInfo.h
===
--- clang/lib/CodeGen/ABIInfo.h
+++ clang/lib/CodeGen/ABIInfo.h
@@ -120,6 +120,9 @@
 CodeGenTypes 
 bool SwiftErrorInRegister;
 
+bool occupiesMoreThan(ArrayRef scalarTypes,
+  unsigned maxAllRegisters) const;
+
   public:
 SwiftABIInfo(CodeGen::CodeGenTypes , bool SwiftErrorInRegister)
 : CGT(CGT), SwiftErrorInRegister(SwiftErrorInRegister) {}


Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -125,7 +125,7 @@
 /// registers when expanded?
 ///
 /// This is intended to be the basis of a reasonable basic implementation
-/// of should{Pass,Return}IndirectlyForSwift.
+/// of should{Pass,Return}Indirectly.
 ///
 /// For most targets, a limit of four total registers is reasonable; this
 /// limits the amount of code required in order to move around the value
@@ -134,15 +134,14 @@
 /// immediately within the callee.  But some targets may need to further
 /// limit the register count due to an inability to support that many
 /// return registers.
-static bool occupiesMoreThan(CodeGenTypes ,
- ArrayRef scalarTypes,
- unsigned maxAllRegisters) {
+bool SwiftABIInfo::occupiesMoreThan(ArrayRef scalarTypes,
+unsigned maxAllRegisters) const {
   unsigned intCount = 0, fpCount = 0;
   for (llvm::Type *type : scalarTypes) {
 if (type->isPointerTy()) {
   intCount++;
 } else if (auto intTy = dyn_cast(type)) {
-  auto ptrWidth = cgt.getTarget().getPointerWidth(LangAS::Default);
+  auto ptrWidth = CGT.getTarget().getPointerWidth(LangAS::Default);
   intCount += (intTy->getBitWidth() + ptrWidth - 1) / ptrWidth;
 } else {
   assert(type->isVectorTy() || type->isFloatingPointTy());
@@ -155,7 +154,7 @@
 
 bool SwiftABIInfo::shouldPassIndirectly(ArrayRef ComponentTys,
 bool AsReturnValue) const {
-  return occupiesMoreThan(CGT, ComponentTys, /*total=*/4);
+  return occupiesMoreThan(ComponentTys, /*total=*/4);
 }
 
 bool SwiftABIInfo::isLegalVectorType(CharUnits VectorSize, llvm::Type *EltTy,
@@ -1246,7 +1245,7 @@
 // integer registers and three fp registers.  Oddly, it'll use up to
 // four 

[PATCH] D149978: [Clang][NVPTX] Allow passing arguments to the linker while standalone

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

In D149978#4323457 , @jhuber6 wrote:

> In D149978#4323452 , @tra wrote:
>
>>> I've discovered that LLVM adds -Wl,-fcolor-diagnostics
>>
>> Can you tell me where it's done?
>
> `llvm/cmake/modules/HandleLLVMOptions.cmake:994`

This might have to do something with

  # Handle common options used by all runtimes.
  include(AddLLVM)

in `runtimes/CMakeLists.txt`

which is totally wrong in my opinion.
In a standalone build (not sure about runtimes build) AddLLVM determines flags 
for building LLVM itself, not for building runtime libraries.
The results of the tests of the //host// toolchain therefore affect the 
invocation of the //target// toolchain.
I came across this once in https://reviews.llvm.org/D146920#4240370


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149978

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


[PATCH] D149978: [Clang][NVPTX] Allow passing arguments to the linker while standalone

2023-05-05 Thread Artem Belevich via Phabricator via cfe-commits
tra requested changes to this revision.
tra added a comment.
This revision now requires changes to proceed.

In D149978#4323457 , @jhuber6 wrote:

> `llvm/cmake/modules/HandleLLVMOptions.cmake:994`

I do not think that we should work around this particular source of options in 
clang driver.

This sounds like something that may need to be dealt with in cmake.
The root cause is that cmake assumes that if the linker accepts the flag for 
target X, it will accept that flag for target Y. Or that the flags will be used 
only for compiling for the default target. Considering that clang is a 
cross-compiler, neither of the assumptions is universally true.

We may need to add a concept of per-offload-arch options that would be checked 
with specific `--target=...`. It's a bigger can of worms than just filtering 
the argument out, but I think we'll need to deal with it sooner or later 
anyways.

As a short-term stop-gap solution, I would suggest adding a cmake knob to 
disable linker color output altogether. This should unblock you and would not 
affect anybody else until we have a better fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149978

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


[PATCH] D103930: [clang][HeaderSearch] Fix implicit module when using header maps

2023-05-05 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir added a comment.

In D103930#4310061 , @ivanmurashko 
wrote:

> Friendly ping
>
> @arphaman, @jansvoboda11, I have made the patch buildable on all platforms 
> and have all tests passed. There was also a small fix (temp path for modules 
> artefact) at the test that could fix its run on some platforms. Could you 
> look at it? Does it have any issues on your side?

I was actually looking at this issue myself today, and @jansvoboda11 mentioned 
this patch. I'll kick off some testing on our side and see what it turns up.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103930

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


[PATCH] D149980: Remove unused basic_android_tree/mipsel-linux-android

2023-05-05 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8f0eee16d9b4: Remove unused 
basic_android_tree/mipsel-linux-android (authored by AdityaK 
1894981+hiradi...@users.noreply.github.com).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149980

Files:
  clang/test/Driver/Inputs/basic_android_tree/mipsel-linux-android/bin/.keep
  
clang/test/Driver/Inputs/basic_android_tree/mipsel-linux-android/include/c++/4.4.3/.keep
  clang/test/Driver/Inputs/basic_android_tree/mipsel-linux-android/lib/.keep




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


[clang] 8f0eee1 - Remove unused basic_android_tree/mipsel-linux-android

2023-05-05 Thread via cfe-commits

Author: AdityaK
Date: 2023-05-05T15:50:22-07:00
New Revision: 8f0eee16d9b420c0b5339bf9c386dc6cbbf29b42

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

LOG: Remove unused basic_android_tree/mipsel-linux-android

Reviewers: danalbert, enh, pirama, srhines

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

Added: 


Modified: 


Removed: 
clang/test/Driver/Inputs/basic_android_tree/mipsel-linux-android/bin/.keep

clang/test/Driver/Inputs/basic_android_tree/mipsel-linux-android/include/c++/4.4.3/.keep
clang/test/Driver/Inputs/basic_android_tree/mipsel-linux-android/lib/.keep



diff  --git 
a/clang/test/Driver/Inputs/basic_android_tree/mipsel-linux-android/bin/.keep 
b/clang/test/Driver/Inputs/basic_android_tree/mipsel-linux-android/bin/.keep
deleted file mode 100644
index e69de29bb2d1d..0

diff  --git 
a/clang/test/Driver/Inputs/basic_android_tree/mipsel-linux-android/include/c++/4.4.3/.keep
 
b/clang/test/Driver/Inputs/basic_android_tree/mipsel-linux-android/include/c++/4.4.3/.keep
deleted file mode 100644
index e69de29bb2d1d..0

diff  --git 
a/clang/test/Driver/Inputs/basic_android_tree/mipsel-linux-android/lib/.keep 
b/clang/test/Driver/Inputs/basic_android_tree/mipsel-linux-android/lib/.keep
deleted file mode 100644
index e69de29bb2d1d..0



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


[PATCH] D149978: [Clang][NVPTX] Allow passing arguments to the linker while standalone

2023-05-05 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D149978#4323452 , @tra wrote:

>> I've discovered that LLVM adds -Wl,-fcolor-diagnostics
>
> Can you tell me where it's done?

`llvm/cmake/modules/HandleLLVMOptions.cmake:994`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149978

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


[PATCH] D149978: [Clang][NVPTX] Allow passing arguments to the linker while standalone

2023-05-05 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

> I've discovered that LLVM adds -Wl,-fcolor-diagnostics

Can you tell me where it's done?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149978

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


[PATCH] D149920: ms inline asm: recognize case-insensitive JMP and CALL as TargetLowering::C_Address

2023-05-05 Thread Fangrui Song via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8afd831b456a: ms inline asm: recognize case-insensitive JMP 
and CALL as TargetLowering… (authored by MaskRay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149920

Files:
  clang/test/CodeGen/ms-inline-asm-functions.c
  llvm/include/llvm/CodeGen/TargetLowering.h
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/test/CodeGen/X86/inline-asm-function-call-pic.ll

Index: llvm/test/CodeGen/X86/inline-asm-function-call-pic.ll
===
--- llvm/test/CodeGen/X86/inline-asm-function-call-pic.ll
+++ llvm/test/CodeGen/X86/inline-asm-function-call-pic.ll
@@ -15,6 +15,7 @@
 ;   __asm {
 ;   call static_func
 ;   call extern_func
+;   jmp extern_func
 ;   shr eax, 0
 ;   shr ebx, 0
 ;   shr ecx, 0
@@ -40,6 +41,7 @@
 ; CHECK-EMPTY:
 ; CHECK-NEXT:calll static_func
 ; CHECK-NEXT:calll extern_func@PLT
+; CHECK-NEXT:jmp extern_func@PLT
 ; CHECK-NEXT:shrl $0, %eax
 ; CHECK-NEXT:shrl $0, %ebx
 ; CHECK-NEXT:shrl $0, %ecx
@@ -52,7 +54,8 @@
 ; CHECK-NEXT:#NO_APP
 entry:
   %call = tail call i32 @static_func()
-  tail call void asm sideeffect inteldialect "call dword ptr ${0:P}\0A\09call dword ptr ${1:P}\0A\09shr eax, $$0\0A\09shr ebx, $$0\0A\09shr ecx, $$0\0A\09shr edx, $$0\0A\09shr edi, $$0\0A\09shr esi, $$0\0A\09shr ebp, $$0\0A\09shr esp, $$0", "*m,*m,~{eax},~{ebp},~{ebx},~{ecx},~{edi},~{edx},~{flags},~{esi},~{esp},~{dirflag},~{fpsr},~{flags}"(ptr nonnull elementtype(i32 (...)) @static_func, ptr nonnull elementtype(i32 (...)) @extern_func) #0
+;; We test call, CALL, and jmp.
+  tail call void asm sideeffect inteldialect "call ${0:P}\0A\09CALL ${1:P}\0A\09jmp ${1:P}\0A\09shr eax, $$0\0A\09shr ebx, $$0\0A\09shr ecx, $$0\0A\09shr edx, $$0\0A\09shr edi, $$0\0A\09shr esi, $$0\0A\09shr ebp, $$0\0A\09shr esp, $$0", "*m,*m,~{eax},~{ebp},~{ebx},~{ecx},~{edi},~{edx},~{flags},~{esi},~{esp},~{dirflag},~{fpsr},~{flags}"(ptr nonnull elementtype(i32 (...)) @static_func, ptr nonnull elementtype(i32 (...)) @extern_func) #0
   ret void
 }
 
Index: llvm/lib/Target/X86/X86ISelLowering.cpp
===
--- llvm/lib/Target/X86/X86ISelLowering.cpp
+++ llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -33944,12 +33944,9 @@
 // "call dword ptr "
 auto TmpStr = AsmStr.substr(0, I);
 I = TmpStr.rfind(':');
-if (I == StringRef::npos)
-  return TmpStr;
-
-assert(I < TmpStr.size() && "Unexpected inline asm string!");
-auto Asm = TmpStr.drop_front(I + 1);
-return Asm;
+if (I != StringRef::npos)
+  TmpStr = TmpStr.substr(I + 1);
+return TmpStr.take_while(llvm::isAlpha);
   }
 
   return StringRef();
@@ -33957,12 +33954,13 @@
 
 bool X86TargetLowering::isInlineAsmTargetBranch(
 const SmallVectorImpl , unsigned OpNo) const {
-  StringRef InstrStr = getInstrStrFromOpNo(AsmStrs, OpNo);
-
-  if (InstrStr.contains("call"))
-return true;
-
-  return false;
+  // In a __asm block, __asm inst foo where inst is CALL or JMP should be
+  // changed from indirect TargetLowering::C_Memory to direct
+  // TargetLowering::C_Address.
+  // We don't need to special case LOOP* and Jcc, which cannot target a memory
+  // location.
+  StringRef Inst = getInstrStrFromOpNo(AsmStrs, OpNo);
+  return Inst.equals_insensitive("call") || Inst.equals_insensitive("jmp");
 }
 
 /// Provide custom lowering hooks for some operations.
Index: llvm/include/llvm/CodeGen/TargetLowering.h
===
--- llvm/include/llvm/CodeGen/TargetLowering.h
+++ llvm/include/llvm/CodeGen/TargetLowering.h
@@ -3624,15 +3624,13 @@
   /// legal.  It is frequently not legal in PIC relocation models.
   virtual bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const;
 
-  /// Return true if the operand with index OpNo corresponding to a target
-  /// branch, for example, in following case
+  /// On x86, return true if the operand with index OpNo is a CALL or JUMP
+  /// instruction, which can use either a memory constraint or an address
+  /// constraint. -fasm-blocks "__asm call foo" lowers to
+  /// call void asm sideeffect inteldialect "call ${0:P}", "*m..."
   ///
-  /// call void asm "lea r8, $0\0A\09call qword ptr ${1:P}\0A\09ret",
-  ///   "*m,*m,~{r8},~{dirflag},~{fpsr},~{flags}"
-  ///([9 x i32]* @Arr), void (...)* @sincos_asm)
-  ///
-  /// the operand $1 (sincos_asm) is target branch in inline asm, but the
-  /// operand $0 (Arr) is not.
+  /// This function is used by a hack to choose the address constraint,
+  /// lowering to a direct call.
   virtual bool
   isInlineAsmTargetBranch(const SmallVectorImpl ,
   unsigned OpNo) const {
Index: 

[clang] 8afd831 - ms inline asm: recognize case-insensitive JMP and CALL as TargetLowering::C_Address

2023-05-05 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2023-05-05T15:32:32-07:00
New Revision: 8afd831b456a46677e638cdf00dd649fbd5ca0a1

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

LOG: ms inline asm: recognize case-insensitive JMP and CALL as 
TargetLowering::C_Address

In a `__asm` block, a symbol reference is usually a memory constraint
(indirect TargetLowering::C_Memory) [LOOP]. CALL and JUMP instructions are 
special
that `__asm call k` can be an address constraint, if `k` is a function.

Clang always gives us indirect TargetLowering::C_Memory and need to convert it
to direct TargetLowering::C_Address. D133914 implements this conversion, but
does not consider JMP or case-insensitive CALL. This patch implements the 
missing
cases, so that `__asm jmp k` (`jmp ${0:P}`) will correctly lower to `jmp _k`
instead of `jmp dword ptr [_k]`.

(`__asm call k` lowered to `call dword ptr ${0:P}` and is fixed by D149695 to
lower to `call ${0:P}` instead.)

[LOOP]: Some instructions like LOOP{,E,NE} and Jcc always use an address
constraint (`loop _k` instead of `loop dword ptr [_k]`).

After this patch and D149579, all the following cases will be correct.
```
int k(int);
int (*kptr)(int);
...
__asm call k; // correct without this patch
__asm CALL k; // correct, but needs this patch to be compatible with D149579
__asm jmp k;  // correct, but needs this patch to be compatible with D149579
__asm call kptr; // will be fixed by D149579.  "Broken case" in 
clang/test/CodeGen/ms-inline-asm-functions.c
__asm jmp kptr;  // will be fixed by this patch and D149579
```

Reviewed By: pengfei

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

Added: 


Modified: 
clang/test/CodeGen/ms-inline-asm-functions.c
llvm/include/llvm/CodeGen/TargetLowering.h
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/X86/inline-asm-function-call-pic.ll

Removed: 




diff  --git a/clang/test/CodeGen/ms-inline-asm-functions.c 
b/clang/test/CodeGen/ms-inline-asm-functions.c
index ad6a385279dc..26eaf144adf2 100644
--- a/clang/test/CodeGen/ms-inline-asm-functions.c
+++ b/clang/test/CodeGen/ms-inline-asm-functions.c
@@ -32,8 +32,20 @@ int foo(void) {
 
 int bar(void) {
   // CHECK-LABEL: _bar:
-  __asm jmp k;
-  // CHECK: jmp _k
+  __asm {
+jmp k
+ja k
+JAE k
+LOOP k
+loope k
+loopne k
+  };
+  // CHECK:  jmp _k
+  // CHECK-NEXT: ja  _k
+  // CHECK-NEXT: jae _k
+  // CHECK-NEXT: loop_k
+  // CHECK-NEXT: loope   _k
+  // CHECK-NEXT: loopne  _k
 }
 
 int baz(void) {

diff  --git a/llvm/include/llvm/CodeGen/TargetLowering.h 
b/llvm/include/llvm/CodeGen/TargetLowering.h
index 4c5e18192ea2..355091146d24 100644
--- a/llvm/include/llvm/CodeGen/TargetLowering.h
+++ b/llvm/include/llvm/CodeGen/TargetLowering.h
@@ -3624,15 +3624,13 @@ class TargetLowering : public TargetLoweringBase {
   /// legal.  It is frequently not legal in PIC relocation models.
   virtual bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const;
 
-  /// Return true if the operand with index OpNo corresponding to a target
-  /// branch, for example, in following case
+  /// On x86, return true if the operand with index OpNo is a CALL or JUMP
+  /// instruction, which can use either a memory constraint or an address
+  /// constraint. -fasm-blocks "__asm call foo" lowers to
+  /// call void asm sideeffect inteldialect "call ${0:P}", "*m..."
   ///
-  /// call void asm "lea r8, $0\0A\09call qword ptr ${1:P}\0A\09ret",
-  ///   "*m,*m,~{r8},~{dirflag},~{fpsr},~{flags}"
-  ///([9 x i32]* @Arr), void (...)* @sincos_asm)
-  ///
-  /// the operand $1 (sincos_asm) is target branch in inline asm, but the
-  /// operand $0 (Arr) is not.
+  /// This function is used by a hack to choose the address constraint,
+  /// lowering to a direct call.
   virtual bool
   isInlineAsmTargetBranch(const SmallVectorImpl ,
   unsigned OpNo) const {

diff  --git a/llvm/lib/Target/X86/X86ISelLowering.cpp 
b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 2c7dce0d3612..19a9b402c930 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -33944,12 +33944,9 @@ static StringRef getInstrStrFromOpNo(const 
SmallVectorImpl ,
 // "call dword ptr "
 auto TmpStr = AsmStr.substr(0, I);
 I = TmpStr.rfind(':');
-if (I == StringRef::npos)
-  return TmpStr;
-
-assert(I < TmpStr.size() && "Unexpected inline asm string!");
-auto Asm = TmpStr.drop_front(I + 1);
-return Asm;
+if (I != StringRef::npos)
+  TmpStr = TmpStr.substr(I + 1);
+return TmpStr.take_while(llvm::isAlpha);
   }
 
   return StringRef();
@@ -33957,12 +33954,13 @@ static StringRef getInstrStrFromOpNo(const 
SmallVectorImpl ,
 
 bool 

[PATCH] D150001: [clang] Fix initializer_list matching failures with modules

2023-05-05 Thread Alan Zhao via Phabricator via cfe-commits
ayzhao created this revision.
Herald added a project: All.
ayzhao requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Previously, if a class with a defined public virtual destructor is
declared before including  and initializer_list is
provided via a Clang module, then overload resolution would fail for
std::initializer_list. This is because when Clang sees the virtual
destructor, Clang creates an implicit NamespaceDecl for std to
implicitly declare a std::bad_alloc. That NamespaceDecl is not added to
the translation unit's lookup table, so when the module containing
std::initializer_list is imported later, that module's std NamespaceDecl
can't find the previous std NamespaceDecl during redeclaration lookup,
causing overload resolution to fail.

To fix this, implicitly created std NamespaceDecls are now added to the
lookup map. At the same time, their IdentifierNamespace members are
cleared to prevent regular name lookups from finding it.

Fixes 60929


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150001

Files:
  clang/include/clang/AST/DeclBase.h
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/Modules/match_initializer_list.cpp


Index: clang/test/Modules/match_initializer_list.cpp
===
--- /dev/null
+++ clang/test/Modules/match_initializer_list.cpp
@@ -0,0 +1,19 @@
+// RUN: rm -rf %t
+//
+// RUN: %clang_cc1 -x c++ -fmodules -fmodules-cache-path=%t \
+// RUN: -I %S/Inputs/initializer_list \
+// RUN: -fmodule-map-file=%S/Inputs/initializer_list/direct.modulemap \
+// RUN: %s -verify
+
+// expected-no-diagnostics
+
+class C {
+  public:
+  virtual ~C() {}
+};
+
+#include "Inputs/initializer_list/direct.h"
+
+void takesInitList(std::initializer_list);
+
+void passesInitList() { takesInitList({0}); }
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -11567,6 +11567,8 @@
 ().get("std"),
 /*PrevDecl=*/nullptr, /*Nested=*/false);
 getStdNamespace()->setImplicit(true);
+Context.getTranslationUnitDecl()->addDecl(getStdNamespace());
+getStdNamespace()->clearIdentifierNamespace();
   }
 
   return getStdNamespace();
Index: clang/include/clang/AST/DeclBase.h
===
--- clang/include/clang/AST/DeclBase.h
+++ clang/include/clang/AST/DeclBase.h
@@ -1172,6 +1172,12 @@
 }
   }
 
+  /// Clears the namespace of this declaration.
+  ///
+  /// This is useful if we want this declaration to be available for
+  /// redeclaration lookup but otherwise hidden for ordinary name lookups.
+  void clearIdentifierNamespace() { IdentifierNamespace = 0; }
+
   enum FriendObjectKind {
 FOK_None,  ///< Not a friend object.
 FOK_Declared,  ///< A friend of a previously-declared entity.


Index: clang/test/Modules/match_initializer_list.cpp
===
--- /dev/null
+++ clang/test/Modules/match_initializer_list.cpp
@@ -0,0 +1,19 @@
+// RUN: rm -rf %t
+//
+// RUN: %clang_cc1 -x c++ -fmodules -fmodules-cache-path=%t \
+// RUN: -I %S/Inputs/initializer_list \
+// RUN: -fmodule-map-file=%S/Inputs/initializer_list/direct.modulemap \
+// RUN: %s -verify
+
+// expected-no-diagnostics
+
+class C {
+  public:
+  virtual ~C() {}
+};
+
+#include "Inputs/initializer_list/direct.h"
+
+void takesInitList(std::initializer_list);
+
+void passesInitList() { takesInitList({0}); }
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -11567,6 +11567,8 @@
 ().get("std"),
 /*PrevDecl=*/nullptr, /*Nested=*/false);
 getStdNamespace()->setImplicit(true);
+Context.getTranslationUnitDecl()->addDecl(getStdNamespace());
+getStdNamespace()->clearIdentifierNamespace();
   }
 
   return getStdNamespace();
Index: clang/include/clang/AST/DeclBase.h
===
--- clang/include/clang/AST/DeclBase.h
+++ clang/include/clang/AST/DeclBase.h
@@ -1172,6 +1172,12 @@
 }
   }
 
+  /// Clears the namespace of this declaration.
+  ///
+  /// This is useful if we want this declaration to be available for
+  /// redeclaration lookup but otherwise hidden for ordinary name lookups.
+  void clearIdentifierNamespace() { IdentifierNamespace = 0; }
+
   enum FriendObjectKind {
 FOK_None,  ///< Not a friend object.
 FOK_Declared,  ///< A friend of a previously-declared entity.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D149978: [Clang][NVPTX] Allow passing arguments to the linker while standalone

2023-05-05 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D149978#4323328 , @tra wrote:

>> The latter is a little difficult,
>
> The more we dig, the more we want GPU-capable lld. :-)

My thoughts exactly. I had a small chat with @MaskRay about how difficult it 
would be to spin up support for NVPTX. But it would probably be a reasonably 
large project, and considering who I work for would be difficult for me to do 
it as more than a hobby.




Comment at: clang/lib/Driver/ToolChains/Cuda.cpp:641
+  // by nvlink.
+  if (llvm::any_of(II.getInputArg().getValues(), [](StringRef Arg) {
+return Arg.equals("--color-diagnostics");

tra wrote:
> Can there ever be more than one value returned by 
> `II.getInputArg().getValues()`?
> 
> If so, we probably don't want to skip all of them if one of them is 
> `--color-diagnostics`. We may want to ignore only singleton 
> `--color-diagnostics` and let all other combinations error out.
Yeah, you can do `-Wl,arg1,arg2,arg3`. This was just because I couldn't think 
of an easy way to separate them out, considering that we rely on 
`renderAsInput` we'd need to create an entirely new arg. Which is doable, but I 
wasn't sure if it was worth the effort.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149978

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


[PATCH] D149647: [NFC][Clang]Fix static analyzer tool remarks about large copies by values

2023-05-05 Thread Soumi Manna via Phabricator via cfe-commits
Manna added a comment.

Thank you everyone for reviews and comments.


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

https://reviews.llvm.org/D149647

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


[PATCH] D149867: [M68k] Add Clang support for the new M68k_RTD CC

2023-05-05 Thread Min-Yih Hsu via Phabricator via cfe-commits
myhsu updated this revision to Diff 519983.
myhsu added a comment.

Minor updates. NFC.


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

https://reviews.llvm.org/D149867

Files:
  clang/lib/Basic/Targets/M68k.cpp
  clang/lib/Basic/Targets/M68k.h
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/mrtd.c
  clang/test/Sema/mrtd.c

Index: clang/test/Sema/mrtd.c
===
--- clang/test/Sema/mrtd.c
+++ clang/test/Sema/mrtd.c
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 -DMRTD -mrtd -triple i386-unknown-unknown -verify %s
+// RUN: %clang_cc1 -DMRTD -mrtd -triple m68k-unknown-unknown -verify %s
 // RUN: %clang_cc1 -triple i386-unknown-unknown -verify %s
+// RUN: %clang_cc1 -triple m68k-unknown-unknown -verify %s
 
 #ifndef MRTD
 // expected-note@+5 {{previous declaration is here}}
Index: clang/test/CodeGen/mrtd.c
===
--- clang/test/CodeGen/mrtd.c
+++ clang/test/CodeGen/mrtd.c
@@ -1,20 +1,26 @@
-// RUN: %clang_cc1 -mrtd -triple i386-unknown-unknown -std=c89 -emit-llvm -o - %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -mrtd -triple i386-unknown-unknown -std=c89 -emit-llvm -o - %s 2>&1 | FileCheck --check-prefixes=CHECK,X86 %s
+// RUN: %clang_cc1 -mrtd -triple m68k-unknown-unknown -std=c89 -emit-llvm -o - %s 2>&1 | FileCheck --check-prefixes=CHECK,M68k %s
 
-// CHECK: mrtd.c:10:3: warning: function with no prototype cannot use the stdcall calling convention
+// CHECK: mrtd.c:13:3: warning: function with no prototype cannot use the stdcall calling convention
 
 void baz(int arg);
 
-// CHECK: define{{.*}} x86_stdcallcc void @foo(i32 noundef %arg) [[NUW:#[0-9]+]]
+// X86: define{{.*}} x86_stdcallcc void @foo(i32 noundef %arg) [[NUW:#[0-9]+]]
+// M68k: define{{.*}} m68k_rtdcc void @foo(i32 noundef %arg)
 void foo(int arg) {
-// CHECK: call x86_stdcallcc i32 @bar(
+// X86: call x86_stdcallcc i32 @bar(
+// M68k: call m68k_rtdcc i32 @bar(
   bar(arg);
-// CHECK: call x86_stdcallcc void @baz(i32
+// X86: call x86_stdcallcc void @baz(i32
+// M68k: call m68k_rtdcc void @baz(i32
   baz(arg);
 }
 
-// CHECK: declare x86_stdcallcc i32 @bar(...)
+// X86: declare x86_stdcallcc i32 @bar(...)
+// M68k: declare m68k_rtdcc i32 @bar(...)
 
-// CHECK: declare x86_stdcallcc void @baz(i32 noundef)
+// X86: declare x86_stdcallcc void @baz(i32 noundef)
+// M68k: declare m68k_rtdcc void @baz(i32 noundef)
 
 void qux(int arg, ...) { }
 // CHECK: define{{.*}} void @qux(i32 noundef %arg, ...)
@@ -22,7 +28,8 @@
 void quux(int a1, int a2, int a3) {
   qux(a1, a2, a3);
 }
-// CHECK-LABEL: define{{.*}} x86_stdcallcc void @quux
+// X86-LABEL: define{{.*}} x86_stdcallcc void @quux
+// M68k-LABEL: define{{.*}} m68k_rtdcc void @quux
 // CHECK: call void (i32, ...) @qux
 
-// CHECK: attributes [[NUW]] = { noinline nounwind{{.*}} }
+// X86: attributes [[NUW]] = { noinline nounwind{{.*}} }
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -553,9 +553,10 @@
   if (Arg *A = Args.getLastArg(OPT_fdefault_calling_conv_EQ)) {
 auto DefaultCC = LangOpts.getDefaultCallingConv();
 
-bool emitError = (DefaultCC == LangOptions::DCC_FastCall ||
-  DefaultCC == LangOptions::DCC_StdCall) &&
- Arch != llvm::Triple::x86;
+bool emitError =
+DefaultCC == LangOptions::DCC_FastCall && Arch != llvm::Triple::x86;
+emitError |= DefaultCC == LangOptions::DCC_StdCall &&
+ Arch != llvm::Triple::m68k && Arch != llvm::Triple::x86;
 emitError |= (DefaultCC == LangOptions::DCC_VectorCall ||
   DefaultCC == LangOptions::DCC_RegCall) &&
  !T.isX86();
@@ -3747,7 +3748,7 @@
   Diags.Report(diag::err_drv_argument_not_allowed_with)
   << A->getSpelling() << "-fdefault-calling-conv";
 else {
-  if (T.getArch() != llvm::Triple::x86)
+  if (T.getArch() != llvm::Triple::x86 && T.getArch() != llvm::Triple::m68k)
 Diags.Report(diag::err_drv_argument_not_allowed_with)
 << A->getSpelling() << T.getTriple();
   else
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -48,7 +48,10 @@
 unsigned CodeGenTypes::ClangCallConvToLLVMCallConv(CallingConv CC) {
   switch (CC) {
   default: return llvm::CallingConv::C;
-  case CC_X86StdCall: return llvm::CallingConv::X86_StdCall;
+  case CC_X86StdCall:
+return CGM.getTriple().getArch() == llvm::Triple::m68k
+   ? llvm::CallingConv::M68k_RTD
+   : llvm::CallingConv::X86_StdCall;
   case CC_X86FastCall: return llvm::CallingConv::X86_FastCall;
   case CC_X86RegCall: return llvm::CallingConv::X86_RegCall;
   case 

[PATCH] D149978: [Clang][NVPTX] Allow passing arguments to the linker while standalone

2023-05-05 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

> The latter is a little difficult,

The more we dig, the more we want GPU-capable lld. :-)




Comment at: clang/lib/Driver/ToolChains/Cuda.cpp:641
+  // by nvlink.
+  if (llvm::any_of(II.getInputArg().getValues(), [](StringRef Arg) {
+return Arg.equals("--color-diagnostics");

Can there ever be more than one value returned by 
`II.getInputArg().getValues()`?

If so, we probably don't want to skip all of them if one of them is 
`--color-diagnostics`. We may want to ignore only singleton 
`--color-diagnostics` and let all other combinations error out.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149978

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


[PATCH] D148092: [clang][CodeGen] Break up TargetInfo.cpp [4/6]

2023-05-05 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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148092

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


[PATCH] D149867: [M68k] Add Clang support for the new M68k_RTD CC

2023-05-05 Thread Min-Yih Hsu via Phabricator via cfe-commits
myhsu updated this revision to Diff 519982.
myhsu added a comment.

Introduce `m68k_rtdcc` the textual LLVM IR designation for M68k_RTD


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

https://reviews.llvm.org/D149867

Files:
  clang/lib/Basic/Targets/M68k.cpp
  clang/lib/Basic/Targets/M68k.h
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/mrtd.c
  clang/test/Sema/mrtd.c

Index: clang/test/Sema/mrtd.c
===
--- clang/test/Sema/mrtd.c
+++ clang/test/Sema/mrtd.c
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 -DMRTD -mrtd -triple i386-unknown-unknown -verify %s
+// RUN: %clang_cc1 -DMRTD -mrtd -triple m68k-unknown-unknown -verify %s
 // RUN: %clang_cc1 -triple i386-unknown-unknown -verify %s
+// RUN: %clang_cc1 -triple m68k-unknown-unknown -verify %s
 
 #ifndef MRTD
 // expected-note@+5 {{previous declaration is here}}
Index: clang/test/CodeGen/mrtd.c
===
--- clang/test/CodeGen/mrtd.c
+++ clang/test/CodeGen/mrtd.c
@@ -1,20 +1,26 @@
-// RUN: %clang_cc1 -mrtd -triple i386-unknown-unknown -std=c89 -emit-llvm -o - %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -mrtd -triple i386-unknown-unknown -std=c89 -emit-llvm -o - %s 2>&1 | FileCheck --check-prefixes=CHECK,X86 %s
+// RUN: %clang_cc1 -mrtd -triple m68k-unknown-unknown -std=c89 -emit-llvm -o - %s 2>&1 | FileCheck --check-prefixes=CHECK,M68k %s
 
-// CHECK: mrtd.c:10:3: warning: function with no prototype cannot use the stdcall calling convention
+// CHECK: mrtd.c:13:3: warning: function with no prototype cannot use the stdcall calling convention
 
 void baz(int arg);
 
-// CHECK: define{{.*}} x86_stdcallcc void @foo(i32 noundef %arg) [[NUW:#[0-9]+]]
+// X86: define{{.*}} x86_stdcallcc void @foo(i32 noundef %arg) [[NUW:#[0-9]+]]
+// M68k: define{{.*}} m68k_rtdcc void @foo(i32 noundef %arg)
 void foo(int arg) {
-// CHECK: call x86_stdcallcc i32 @bar(
+// X86: call x86_stdcallcc i32 @bar(
+// M68k: call m68k_rtdcc i32 @bar(
   bar(arg);
-// CHECK: call x86_stdcallcc void @baz(i32
+// X86: call x86_stdcallcc void @baz(i32
+// M68k: call m68k_rtdcc void @baz(i32
   baz(arg);
 }
 
-// CHECK: declare x86_stdcallcc i32 @bar(...)
+// X86: declare x86_stdcallcc i32 @bar(...)
+// M68k: declare m68k_rtdcc i32 @bar(...)
 
-// CHECK: declare x86_stdcallcc void @baz(i32 noundef)
+// X86: declare x86_stdcallcc void @baz(i32 noundef)
+// M68k: declare m68k_rtdcc void @baz(i32 noundef)
 
 void qux(int arg, ...) { }
 // CHECK: define{{.*}} void @qux(i32 noundef %arg, ...)
@@ -22,7 +28,8 @@
 void quux(int a1, int a2, int a3) {
   qux(a1, a2, a3);
 }
-// CHECK-LABEL: define{{.*}} x86_stdcallcc void @quux
+// X86-LABEL: define{{.*}} x86_stdcallcc void @quux
+// M68k-LABEL: define{{.*}} m68k_rtdcc void @quux
 // CHECK: call void (i32, ...) @qux
 
-// CHECK: attributes [[NUW]] = { noinline nounwind{{.*}} }
+// X86: attributes [[NUW]] = { noinline nounwind{{.*}} }
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -553,9 +553,10 @@
   if (Arg *A = Args.getLastArg(OPT_fdefault_calling_conv_EQ)) {
 auto DefaultCC = LangOpts.getDefaultCallingConv();
 
-bool emitError = (DefaultCC == LangOptions::DCC_FastCall ||
-  DefaultCC == LangOptions::DCC_StdCall) &&
- Arch != llvm::Triple::x86;
+bool emitError =
+DefaultCC == LangOptions::DCC_FastCall && Arch != llvm::Triple::x86;
+emitError |= DefaultCC == LangOptions::DCC_StdCall &&
+ !(Arch == llvm::Triple::m68k || Arch == llvm::Triple::x86);
 emitError |= (DefaultCC == LangOptions::DCC_VectorCall ||
   DefaultCC == LangOptions::DCC_RegCall) &&
  !T.isX86();
@@ -3747,7 +3748,7 @@
   Diags.Report(diag::err_drv_argument_not_allowed_with)
   << A->getSpelling() << "-fdefault-calling-conv";
 else {
-  if (T.getArch() != llvm::Triple::x86)
+  if (T.getArch() != llvm::Triple::x86 && T.getArch() != llvm::Triple::m68k)
 Diags.Report(diag::err_drv_argument_not_allowed_with)
 << A->getSpelling() << T.getTriple();
   else
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -48,7 +48,10 @@
 unsigned CodeGenTypes::ClangCallConvToLLVMCallConv(CallingConv CC) {
   switch (CC) {
   default: return llvm::CallingConv::C;
-  case CC_X86StdCall: return llvm::CallingConv::X86_StdCall;
+  case CC_X86StdCall:
+return CGM.getTriple().getArch() == llvm::Triple::m68k
+   ? llvm::CallingConv::M68k_RTD
+   : llvm::CallingConv::X86_StdCall;
   case CC_X86FastCall: return llvm::CallingConv::X86_FastCall;
   case CC_X86RegCall: return 

[PATCH] D149647: [NFC][Clang]Fix static analyzer tool remarks about large copies by values

2023-05-05 Thread Tom Honermann via Phabricator via cfe-commits
tahonermann accepted this revision.
tahonermann added a comment.
This revision is now accepted and ready to land.

Looks good. Thanks again for catching our oops @HazardyKnusperkeks!


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

https://reviews.llvm.org/D149647

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


[PATCH] D149999: [clang-tidy] [test] Narrow down a special case to MSVC mode

2023-05-05 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.
mstorsjo added reviewers: alvinhochun, aaron.ballman, hans.
Herald added subscribers: PiotrZSL, carlosgalvezp, xazax.hun.
Herald added a project: All.
mstorsjo requested review of this revision.
Herald added a project: clang-tools-extra.

For MinGW targets, size_t isn't a compiler defined type, just like
for unix targets.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D14

Files:
  
clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-standard-types.h


Index: 
clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-standard-types.h
===
--- 
clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-standard-types.h
+++ 
clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-standard-types.h
@@ -9,7 +9,7 @@
 typedef unsigned short  uint16_t;   // NOLINT
 typedef unsigned long   uint32_t;   // NOLINT
 typedef unsigned long long  uint64_t;   // NOLINT
-#ifndef _WIN32
+#ifndef _MSC_VER
 typedef unsigned long long  size_t; // NOLINT
 #endif
 typedef longintptr_t;   // NOLINT


Index: clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-standard-types.h
===
--- clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-standard-types.h
+++ clang-tools-extra/test/clang-tidy/checkers/readability/identifier-naming-standard-types.h
@@ -9,7 +9,7 @@
 typedef unsigned short  uint16_t;   // NOLINT
 typedef unsigned long   uint32_t;   // NOLINT
 typedef unsigned long long  uint64_t;   // NOLINT
-#ifndef _WIN32
+#ifndef _MSC_VER
 typedef unsigned long long  size_t; // NOLINT
 #endif
 typedef longintptr_t;   // NOLINT
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D149997: [clang] [test] Narrow down MSVC specific behaviours from "any windows" to only MSVC/clang-cl

2023-05-05 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.
mstorsjo added reviewers: aaron.ballman, hans.
Herald added a project: All.
mstorsjo requested review of this revision.
Herald added a project: clang.

This fixes running tests with a toolchain that defaults to a MinGW
target.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149997

Files:
  clang/test/C/drs/dr1xx.c
  clang/test/Driver/experimental-library-flag.cpp
  clang/test/SemaCXX/attr-trivial-abi.cpp


Index: clang/test/SemaCXX/attr-trivial-abi.cpp
===
--- clang/test/SemaCXX/attr-trivial-abi.cpp
+++ clang/test/SemaCXX/attr-trivial-abi.cpp
@@ -5,11 +5,11 @@
 // Should not crash.
 template 
 class __attribute__((trivial_abi)) a { a(a &&); };
-#ifdef _WIN64
-// On Windows, to be trivial-for-calls, an object must be trivially copyable.
+#if defined(_WIN64) && defined(_MSC_VER)
+// On Windows/MSVC, to be trivial-for-calls, an object must be trivially 
copyable.
 // (And it is only trivially relocatable, currently, if it is trivial for 
calls.)
 // In this case, it is suppressed by an explicitly defined move constructor.
-// Similar concerns apply to later tests that have #ifdef _WIN64.
+// Similar concerns apply to later tests that have #if defined(_WIN64) && 
defined(_MSC_VER).
 static_assert(!__is_trivially_relocatable(a), "");
 #else
 static_assert(__is_trivially_relocatable(a), "");
@@ -137,7 +137,7 @@
   CopyDeleted(const CopyDeleted &) = delete;
   CopyDeleted(CopyDeleted &&) = default;
 };
-#ifdef _WIN64
+#if defined(_WIN64) && defined(_MSC_VER)
 static_assert(!__is_trivially_relocatable(CopyDeleted), "");
 #else
 static_assert(__is_trivially_relocatable(CopyDeleted), "");
@@ -163,7 +163,7 @@
 struct __attribute__((trivial_abi)) S20 {
   int & // a member of rvalue reference type deletes the copy constructor.
 };
-#ifdef _WIN64
+#if defined(_WIN64) && defined(_MSC_VER)
 static_assert(!__is_trivially_relocatable(S20), "");
 #else
 static_assert(__is_trivially_relocatable(S20), "");
Index: clang/test/Driver/experimental-library-flag.cpp
===
--- clang/test/Driver/experimental-library-flag.cpp
+++ clang/test/Driver/experimental-library-flag.cpp
@@ -1,6 +1,6 @@
 // On some platforms, -stdlib=libc++ is currently ignored, so 
-lc++experimental is not added.
 // Once -stdlib=libc++ works on those, this XFAIL can be removed.
-// XFAIL: target={{.*-windows.*}}, target={{.*-(ps4|ps5)}}
+// XFAIL: target={{.*-windows-msvc.*}}, target={{.*-(ps4|ps5)}}
 
 // For some reason, this fails with a core dump on AIX. This needs to be 
investigated.
 // UNSUPPORTED: target={{.*}}-aix{{.*}}
Index: clang/test/C/drs/dr1xx.c
===
--- clang/test/C/drs/dr1xx.c
+++ clang/test/C/drs/dr1xx.c
@@ -235,7 +235,7 @@
 * type at this point.
 */
 Val = sizeof(enum E)
-#ifndef _WIN32
+#ifndef _MSC_VER
 /* expected-error@-2 {{invalid application of 'sizeof' to an incomplete 
type 'enum E'}} */
 /* expected-note@-12 {{definition of 'enum E' is not complete until the 
closing '}'}} */
 #endif


Index: clang/test/SemaCXX/attr-trivial-abi.cpp
===
--- clang/test/SemaCXX/attr-trivial-abi.cpp
+++ clang/test/SemaCXX/attr-trivial-abi.cpp
@@ -5,11 +5,11 @@
 // Should not crash.
 template 
 class __attribute__((trivial_abi)) a { a(a &&); };
-#ifdef _WIN64
-// On Windows, to be trivial-for-calls, an object must be trivially copyable.
+#if defined(_WIN64) && defined(_MSC_VER)
+// On Windows/MSVC, to be trivial-for-calls, an object must be trivially copyable.
 // (And it is only trivially relocatable, currently, if it is trivial for calls.)
 // In this case, it is suppressed by an explicitly defined move constructor.
-// Similar concerns apply to later tests that have #ifdef _WIN64.
+// Similar concerns apply to later tests that have #if defined(_WIN64) && defined(_MSC_VER).
 static_assert(!__is_trivially_relocatable(a), "");
 #else
 static_assert(__is_trivially_relocatable(a), "");
@@ -137,7 +137,7 @@
   CopyDeleted(const CopyDeleted &) = delete;
   CopyDeleted(CopyDeleted &&) = default;
 };
-#ifdef _WIN64
+#if defined(_WIN64) && defined(_MSC_VER)
 static_assert(!__is_trivially_relocatable(CopyDeleted), "");
 #else
 static_assert(__is_trivially_relocatable(CopyDeleted), "");
@@ -163,7 +163,7 @@
 struct __attribute__((trivial_abi)) S20 {
   int & // a member of rvalue reference type deletes the copy constructor.
 };
-#ifdef _WIN64
+#if defined(_WIN64) && defined(_MSC_VER)
 static_assert(!__is_trivially_relocatable(S20), "");
 #else
 static_assert(__is_trivially_relocatable(S20), "");
Index: clang/test/Driver/experimental-library-flag.cpp
===
--- clang/test/Driver/experimental-library-flag.cpp
+++ clang/test/Driver/experimental-library-flag.cpp
@@ 

[PATCH] D149978: [Clang][NVPTX] Allow passing arguments to the linker while standalone

2023-05-05 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 519977.
jhuber6 added a comment.

Putting up the hack that works around my problem with `libc`. Definitely not a 
good solution though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149978

Files:
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/test/Driver/cuda-cross-compiling.c


Index: clang/test/Driver/cuda-cross-compiling.c
===
--- clang/test/Driver/cuda-cross-compiling.c
+++ clang/test/Driver/cuda-cross-compiling.c
@@ -77,3 +77,12 @@
 // RUN:   | FileCheck -check-prefix=LOWERING %s
 
 // LOWERING: -cc1" "-triple" "nvptx64-nvidia-cuda" {{.*}} "-mllvm" 
"--nvptx-lower-global-ctor-dtor"
+
+//
+// Test passing arguments directly to nvlink.
+//
+// RUN: %clang -target nvptx64-nvidia-cuda -Wl,-v -Wl,--color-diagnostics -### 
%s 2>&1 \
+// RUN:   | FileCheck -check-prefix=LINKER-ARGS %s
+
+// LINKER-ARGS: nvlink{{.*}}"-v"
+// LINKER-ARGS-NOT: nvlink{{.*}}"--color-diagnostics"
Index: clang/lib/Driver/ToolChains/Cuda.cpp
===
--- clang/lib/Driver/ToolChains/Cuda.cpp
+++ clang/lib/Driver/ToolChains/Cuda.cpp
@@ -607,36 +607,43 @@
   continue;
 }
 
-// Currently, we only pass the input files to the linker, we do not pass
-// any libraries that may be valid only for the host.
-if (!II.isFilename())
-  continue;
-
 // The 'nvlink' application performs RDC-mode linking when given a '.o'
 // file and device linking when given a '.cubin' file. We always want to
 // perform device linking, so just rename any '.o' files.
 // FIXME: This should hopefully be removed if NVIDIA updates their tooling.
-auto InputFile = getToolChain().getInputFilename(II);
-if (llvm::sys::path::extension(InputFile) != ".cubin") {
-  // If there are no actions above this one then this is direct input and 
we
-  // can copy it. Otherwise the input is internal so a `.cubin` file should
-  // exist.
-  if (II.getAction() && II.getAction()->getInputs().size() == 0) {
-const char *CubinF =
-Args.MakeArgString(getToolChain().getDriver().GetTemporaryPath(
-llvm::sys::path::stem(InputFile), "cubin"));
-if (std::error_code EC =
-llvm::sys::fs::copy_file(InputFile, C.addTempFile(CubinF)))
-  continue;
+if (II.isFilename()) {
+  auto InputFile = getToolChain().getInputFilename(II);
+  if (llvm::sys::path::extension(InputFile) != ".cubin") {
+// If there are no actions above this one then this is direct input and
+// we can copy it. Otherwise the input is internal so a `.cubin` file
+// should exist.
+if (II.getAction() && II.getAction()->getInputs().size() == 0) {
+  const char *CubinF =
+  Args.MakeArgString(getToolChain().getDriver().GetTemporaryPath(
+  llvm::sys::path::stem(InputFile), "cubin"));
+  if (std::error_code EC =
+  llvm::sys::fs::copy_file(InputFile, C.addTempFile(CubinF)))
+continue;
 
-CmdArgs.push_back(CubinF);
+  CmdArgs.push_back(CubinF);
+} else {
+  SmallString<256> Filename(InputFile);
+  llvm::sys::path::replace_extension(Filename, "cubin");
+  CmdArgs.push_back(Args.MakeArgString(Filename));
+}
   } else {
-SmallString<256> Filename(InputFile);
-llvm::sys::path::replace_extension(Filename, "cubin");
-CmdArgs.push_back(Args.MakeArgString(Filename));
+CmdArgs.push_back(Args.MakeArgString(InputFile));
   }
-} else {
-  CmdArgs.push_back(Args.MakeArgString(InputFile));
+  continue;
+} else if (!II.isNothing()) {
+  // This option is commonly passed by LLVM by default, but isn't supported
+  // by nvlink.
+  if (llvm::any_of(II.getInputArg().getValues(), [](StringRef Arg) {
+return Arg.equals("--color-diagnostics");
+  }))
+continue;
+  // Render any remaining arguments as input to nvlink.
+  II.getInputArg().renderAsInput(Args, CmdArgs);
 }
   }
 


Index: clang/test/Driver/cuda-cross-compiling.c
===
--- clang/test/Driver/cuda-cross-compiling.c
+++ clang/test/Driver/cuda-cross-compiling.c
@@ -77,3 +77,12 @@
 // RUN:   | FileCheck -check-prefix=LOWERING %s
 
 // LOWERING: -cc1" "-triple" "nvptx64-nvidia-cuda" {{.*}} "-mllvm" "--nvptx-lower-global-ctor-dtor"
+
+//
+// Test passing arguments directly to nvlink.
+//
+// RUN: %clang -target nvptx64-nvidia-cuda -Wl,-v -Wl,--color-diagnostics -### %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=LINKER-ARGS %s
+
+// LINKER-ARGS: nvlink{{.*}}"-v"
+// LINKER-ARGS-NOT: nvlink{{.*}}"--color-diagnostics"
Index: clang/lib/Driver/ToolChains/Cuda.cpp

[PATCH] D149718: [NFC][Clang] Fix Coverity issues of copy without assign

2023-05-05 Thread Tom Honermann via Phabricator via cfe-commits
tahonermann requested changes to this revision.
tahonermann added a comment.
This revision now requires changes to proceed.

This looks good with one exception; I think the changes for class 
`SemaDiagnosticBuilder` are not what was intended.




Comment at: clang/include/clang/Analysis/BodyFarm.h:41-44
   BodyFarm(const BodyFarm ) = delete;
 
+  /// Delete copy assignment operator.
+  BodyFarm =(const BodyFarm ) = delete;

This looks fine; move constructor and assignment declarations are inhibited.



Comment at: clang/include/clang/Sema/ParsedAttr.h:704
   /// Move the given pool's allocations to this pool.
   AttributePool(AttributePool &) = default;
 

This class has a move constructor, but the implicit declaration of a move 
assignment operator will be inhibited due to the presence of this and other 
special member functions. That means that an attempted move assignment will 
find the deleted copy assignment. That is ok; if support for move assignment is 
desired some day, it can be added then.



Comment at: clang/include/clang/Sema/ParsedAttr.h:915-916
   ParsedAttributes(AttributeFactory ) : pool(factory) {}
   ParsedAttributes(const ParsedAttributes &) = delete;
+  ParsedAttributes =(const ParsedAttributes &) = delete;
 

This looks fine; move constructor and assignment declarations are inhibited.



Comment at: clang/include/clang/Sema/Sema.h:1786
 SemaDiagnosticBuilder(SemaDiagnosticBuilder &);
+SemaDiagnosticBuilder =(SemaDiagnosticBuilder &);
 SemaDiagnosticBuilder(const SemaDiagnosticBuilder &) = default;

Since this class declares a move constructor, the declaration of the implicit 
move assignment operator is inhibited and the implicitly declared assignment 
operator is defined as deleted. This change declares a move assignment operator 
but doesn't define it (perhaps `= delete` was intended?). If support for 
assignment is not desired, then I think a declaration of a deleted copy 
assignment operator is all that is needed (matching the change made for 
`Strategy` below). Otherwise, I think a defaulted copy assignment operator 
should be declared and a move assignment operator should be defined that 
implements the same behavior as the move constructor.



Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:764-766
   Strategy(const Strategy &) = delete; // Let's avoid copies.
+  Strategy =(const Strategy &) = delete;
   Strategy(Strategy &&) = default;

This is ok. The implicit move assignment declaration is inhibited and since 
copy assignment is deleted, no assignment is supported. If move assignment is 
desired someday, it can be added.



Comment at: clang/lib/Serialization/ASTWriterStmt.cpp:44-45
 
 ASTStmtWriter(const ASTStmtWriter&) = delete;
+ASTStmtWriter =(const ASTStmtWriter &) = delete;
 

This looks fine; implicit move construction and assignment declarations are 
inhibited.


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

https://reviews.llvm.org/D149718

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


[PATCH] D149461: [NFC] ][CLANG] Fix static code analyzer concerns

2023-05-05 Thread Soumi Manna via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG07996804a0c0: [NFC] ][CLANG] Fix static code analyzer 
concerns (authored by Manna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149461

Files:
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp


Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -1884,7 +1884,7 @@
 
   // If the file didn't exist, we can still create a module if we were 
given
   // enough information in the module map.
-  for (auto U : M->MissingHeaders) {
+  for (const auto  : M->MissingHeaders) {
 // Check that we were given enough information to build a module
 // without this file existing on disk.
 if (!U.Size || (!U.ModTime && IncludeTimestamps)) {
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -4425,7 +4425,7 @@
   Id->second->setOutOfDate(true);
   }
   // Mark selectors as out of date.
-  for (auto Sel : SelectorGeneration)
+  for (const auto  : SelectorGeneration)
 SelectorOutOfDate[Sel.first] = true;
 
   // Resolve any unresolved module exports.
@@ -7693,7 +7693,7 @@
   };
 
   if (isa(DC)) {
-for (auto Lexical : TULexicalDecls)
+for (const auto  : TULexicalDecls)
   Visit(Lexical.first, Lexical.second);
   } else {
 auto I = LexicalDecls.find(DC);
Index: clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
@@ -1128,7 +1128,7 @@
   const auto I = FunctionGlobalizedDecls.find(CGF.CurFn);
   if (I != FunctionGlobalizedDecls.end()) {
 // Deallocate the memory for each globalized VLA object
-for (auto AddrSizePair :
+for (const auto  :
  llvm::reverse(I->getSecond().EscapedVariableLengthDeclsAddrs)) {
   CGF.EmitRuntimeCall(OMPBuilder.getOrCreateRuntimeFunction(
   CGM.getModule(), OMPRTL___kmpc_free_shared),


Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -1884,7 +1884,7 @@
 
   // If the file didn't exist, we can still create a module if we were given
   // enough information in the module map.
-  for (auto U : M->MissingHeaders) {
+  for (const auto  : M->MissingHeaders) {
 // Check that we were given enough information to build a module
 // without this file existing on disk.
 if (!U.Size || (!U.ModTime && IncludeTimestamps)) {
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -4425,7 +4425,7 @@
   Id->second->setOutOfDate(true);
   }
   // Mark selectors as out of date.
-  for (auto Sel : SelectorGeneration)
+  for (const auto  : SelectorGeneration)
 SelectorOutOfDate[Sel.first] = true;
 
   // Resolve any unresolved module exports.
@@ -7693,7 +7693,7 @@
   };
 
   if (isa(DC)) {
-for (auto Lexical : TULexicalDecls)
+for (const auto  : TULexicalDecls)
   Visit(Lexical.first, Lexical.second);
   } else {
 auto I = LexicalDecls.find(DC);
Index: clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
@@ -1128,7 +1128,7 @@
   const auto I = FunctionGlobalizedDecls.find(CGF.CurFn);
   if (I != FunctionGlobalizedDecls.end()) {
 // Deallocate the memory for each globalized VLA object
-for (auto AddrSizePair :
+for (const auto  :
  llvm::reverse(I->getSecond().EscapedVariableLengthDeclsAddrs)) {
   CGF.EmitRuntimeCall(OMPBuilder.getOrCreateRuntimeFunction(
   CGM.getModule(), OMPRTL___kmpc_free_shared),
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 0799680 - [NFC] ][CLANG] Fix static code analyzer concerns

2023-05-05 Thread via cfe-commits

Author: Manna, Soumi
Date: 2023-05-05T14:34:36-07:00
New Revision: 07996804a0c0290a4ee5d964a94333894c7792c2

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

LOG: [NFC] ][CLANG] Fix static code analyzer concerns

Reported by Coverity:

1. Inside "ASTReader.cpp" file,  in 
clang::ASTReader::FindExternalLexicalDecls(clang::DeclContext const *, 
llvm::function_ref, llvm::SmallVectorImpl &): Using the auto keyword without an & causes a copy.

auto_causes_copy: Using the auto keyword without an & causes the copy of an 
object of type pair.

2. Inside "ASTReader.cpp" file, in clang::ASTReader::ReadAST(llvm::StringRef, 
clang::serialization::ModuleKind, clang::SourceLocation, unsigned int, 
llvm::SmallVectorImpl *): Using the auto 
keyword without an & causes a copy.

auto_causes_copy: Using the auto keyword without an & causes the copy of an 
object of type DenseMapPair.

3. Inside "CGOpenMPRuntimeGPU.cpp" file, in 
clang::CodeGen::CGOpenMPRuntimeGPU::emitGenericVarsEpilog(clang::CodeGen::CodeGenFunction
 &, bool): Using the auto keyword without an & causes a copy.

auto_causes_copy: Using the auto keyword without an & causes the copy of an 
object of type pair.

4. Inside "ASTWriter.cpp" file, in 
clang::ASTWriter::WriteHeaderSearch(clang::HeaderSearch const &): Using the 
auto keyword without an & causes a copy.

auto_causes_copy: Using the auto keyword without an & causes the copy of an 
object of type UnresolvedHeaderDirective.

Reviewed By: tahonermann

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

Added: 


Modified: 
clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
index 3f231703aa651..68c4fc872e3b8 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
@@ -1128,7 +1128,7 @@ void 
CGOpenMPRuntimeGPU::emitGenericVarsEpilog(CodeGenFunction ,
   const auto I = FunctionGlobalizedDecls.find(CGF.CurFn);
   if (I != FunctionGlobalizedDecls.end()) {
 // Deallocate the memory for each globalized VLA object
-for (auto AddrSizePair :
+for (const auto  :
  llvm::reverse(I->getSecond().EscapedVariableLengthDeclsAddrs)) {
   CGF.EmitRuntimeCall(OMPBuilder.getOrCreateRuntimeFunction(
   CGM.getModule(), OMPRTL___kmpc_free_shared),

diff  --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index 6a7bc22d3b7b3..13fec49e841cc 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -4425,7 +4425,7 @@ ASTReader::ASTReadResult ASTReader::ReadAST(StringRef 
FileName,
   Id->second->setOutOfDate(true);
   }
   // Mark selectors as out of date.
-  for (auto Sel : SelectorGeneration)
+  for (const auto  : SelectorGeneration)
 SelectorOutOfDate[Sel.first] = true;
 
   // Resolve any unresolved module exports.
@@ -7693,7 +7693,7 @@ void ASTReader::FindExternalLexicalDecls(
   };
 
   if (isa(DC)) {
-for (auto Lexical : TULexicalDecls)
+for (const auto  : TULexicalDecls)
   Visit(Lexical.first, Lexical.second);
   } else {
 auto I = LexicalDecls.find(DC);

diff  --git a/clang/lib/Serialization/ASTWriter.cpp 
b/clang/lib/Serialization/ASTWriter.cpp
index 3d738149febcb..94c851d2dbf16 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -1884,7 +1884,7 @@ void ASTWriter::WriteHeaderSearch(const HeaderSearch ) 
{
 
   // If the file didn't exist, we can still create a module if we were 
given
   // enough information in the module map.
-  for (auto U : M->MissingHeaders) {
+  for (const auto  : M->MissingHeaders) {
 // Check that we were given enough information to build a module
 // without this file existing on disk.
 if (!U.Size || (!U.ModTime && IncludeTimestamps)) {



___
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-05 Thread Eli Friedman via Phabricator via cfe-commits
efriedma 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;

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;
}
```


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] D149978: [Clang][NVPTX] Allow passing arguments to the linker while standalone

2023-05-05 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D149978#4323221 , @tra wrote:

> In D149978#4323210 , @jhuber6 wrote:
>
>> Somewhat annoying, I've discovered that LLVM adds `-Wl,-fcolor-diagnostics` 
>> which obviously isn't supported by `nvlink` so it fails while including this 
>> in `libc`'s CMake. Any clue if there's a way to work around that?
>
> I guess the options are to either filter out the automatically added option 
> or to avoid adding that particular argument if we know that the target is 
> NVPTX. The latter would probably be preferable as there would be only one 
> place where the decision is made.

The latter is a little difficult, the logic adds it based off of the host 
linker, but we explicitly override the host triple when we build via 
`--target=`. So there's be no way to turn it off in LLVM unless it's a blanket 
check on building `libc`. And since it's a global flag I can't just disable it 
only for the target. So I think the options are, either filter it out manually 
here or make a new flag called `-Xcuda-nvlink`, which I wouldn't like to do.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149978

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


[PATCH] D149978: [Clang][NVPTX] Allow passing arguments to the linker while standalone

2023-05-05 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

In D149978#4323210 , @jhuber6 wrote:

> Somewhat annoying, I've discovered that LLVM adds `-Wl,-fcolor-diagnostics` 
> which obviously isn't supported by `nvlink` so it fails while including this 
> in `libc`'s CMake. Any clue if there's a way to work around that?

I guess the options are to either filter out the automatically added option or 
to avoid adding that particular argument if we know that the target is NVPTX. 
The latter would probably be preferable as there would be only one place where 
the decision is made.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149978

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


[PATCH] D149978: [Clang][NVPTX] Allow passing arguments to the linker while standalone

2023-05-05 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

The main reason I made this patch was to allow passing 
`--suppress-stack-size-warning` to `nvlink`. But it turns out it's a little 
more difficult there.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149978

___
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-05 Thread Congcong Cai via Phabricator via cfe-commits
HerrCai0907 added a comment.

> So I'm still not sure this is the 'right' away about it. I think we should 
> instead properly handle the containsErrors case and just always create a 
> non-dependent sized array, except with the RecoveryExpr having the correct 
> type.

You are right. Fix as your suggestion.


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] D149612: [Sema] avoid merge error type

2023-05-05 Thread Congcong Cai via Phabricator via cfe-commits
HerrCai0907 updated this revision to Diff 519972.
HerrCai0907 added a comment.

update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149612

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaType.cpp
  clang/test/AST/ast-dump-types-errors-json.cpp
  clang/test/AST/ast-dump-types-errors.cpp
  clang/test/Sema/merge-decls.c

Index: clang/test/Sema/merge-decls.c
===
--- clang/test/Sema/merge-decls.c
+++ clang/test/Sema/merge-decls.c
@@ -91,3 +91,7 @@
   int x[5];
   test7_f(); // expected-warning {{incompatible pointer types passing 'int (*)[5]' to parameter of type 'int (*)[10]}}
 }
+
+char d;
+char x[sizeof(d.data) == 8]; // expected-error {{member reference base type 'char' is not a structure or union}}
+char x[sizeof(d.data) == 4]; // expected-error {{member reference base type 'char' is not a structure or union}}
Index: clang/test/AST/ast-dump-types-errors.cpp
===
--- clang/test/AST/ast-dump-types-errors.cpp
+++ clang/test/AST/ast-dump-types-errors.cpp
@@ -2,5 +2,5 @@
 
 void test() {
   using ContainsErrors = int[sizeof(undef())];
-  // CHECK: DependentSizedArrayType {{.*}} contains-errors dependent
+  // CHECK: ConstantArrayType {{.*}} 'int[0]' contains-errors dependent 0
 }
Index: clang/test/AST/ast-dump-types-errors-json.cpp
===
--- clang/test/AST/ast-dump-types-errors-json.cpp
+++ clang/test/AST/ast-dump-types-errors-json.cpp
@@ -24,18 +24,19 @@
 // CHECK-NEXT:  },
 // CHECK-NEXT:  "name": "TestContainsErrors",
 // CHECK-NEXT:  "type": {
-// CHECK-NEXT:   "qualType": "int[sizeof ((undef))]"
+// CHECK-NEXT:   "qualType": "int[0]"
 // CHECK-NEXT:  },
 // CHECK-NEXT:  "inner": [
 // CHECK-NEXT:   {
 // CHECK-NEXT:"id": "0x{{.*}}",
-// CHECK-NEXT:"kind": "DependentSizedArrayType",
+// CHECK-NEXT:"kind": "ConstantArrayType",
 // CHECK-NEXT:"type": {
-// CHECK-NEXT: "qualType": "int[sizeof ((undef))]"
+// CHECK-NEXT: "qualType": "int[0]"
 // CHECK-NEXT:},
 // CHECK-NEXT:"containsErrors": true,
 // CHECK-NEXT:"isDependent": true,
 // CHECK-NEXT:"isInstantiationDependent": true,
+// CHECK-NEXT:"size": 0,
 // CHECK-NEXT:"inner": [
 // CHECK-NEXT: {
 // CHECK-NEXT:  "id": "0x{{.*}}",
@@ -43,96 +44,6 @@
 // CHECK-NEXT:  "type": {
 // CHECK-NEXT:   "qualType": "int"
 // CHECK-NEXT:  }
-// CHECK-NEXT: },
-// CHECK-NEXT: {
-// CHECK-NEXT:  "id": "0x{{.*}}",
-// CHECK-NEXT:  "kind": "UnaryExprOrTypeTraitExpr",
-// CHECK-NEXT:  "range": {
-// CHECK-NEXT:   "begin": {
-// CHECK-NEXT:"offset": {{[0-9]+}},
-// CHECK-NEXT:"col": 32,
-// CHECK-NEXT:"tokLen": 6
-// CHECK-NEXT:   },
-// CHECK-NEXT:   "end": {
-// CHECK-NEXT:"offset": {{[0-9]+}},
-// CHECK-NEXT:"col": 46,
-// CHECK-NEXT:"tokLen": 1
-// CHECK-NEXT:   }
-// CHECK-NEXT:  },
-// CHECK-NEXT:  "type": {
-// CHECK-NEXT:   "qualType": "unsigned long"
-// CHECK-NEXT:  },
-// CHECK-NEXT:  "valueCategory": "prvalue",
-// CHECK-NEXT:  "name": "sizeof",
-// CHECK-NEXT:  "inner": [
-// CHECK-NEXT:   {
-// CHECK-NEXT:"id": "0x{{.*}}",
-// CHECK-NEXT:"kind": "ParenExpr",
-// CHECK-NEXT:"range": {
-// CHECK-NEXT: "begin": {
-// CHECK-NEXT:  "offset": {{[0-9]+}},
-// CHECK-NEXT:  "col": 38,
-// CHECK-NEXT:  "tokLen": 1
-// CHECK-NEXT: },
-// CHECK-NEXT: "end": {
-// CHECK-NEXT:  "offset": {{[0-9]+}},
-// CHECK-NEXT:  "col": 46,
-// CHECK-NEXT:  "tokLen": 1
-// CHECK-NEXT: }
-// CHECK-NEXT:},
-// CHECK-NEXT:"type": {
-// CHECK-NEXT: "qualType": ""
-// CHECK-NEXT:},
-// CHECK-NEXT:"valueCategory": "lvalue",
-// CHECK-NEXT:"inner": [
-// CHECK-NEXT: {
-// CHECK-NEXT:  "id": "0x{{.*}}",
-// CHECK-NEXT:  "kind": "RecoveryExpr",
-// CHECK-NEXT:  "range": {
-// CHECK-NEXT:   "begin": {
-// CHECK-NEXT:"offset": {{[0-9]+}},
-// CHECK-NEXT:"col": 39,
-// CHECK-NEXT:"tokLen": 5
-// CHECK-NEXT:   },
-// CHECK-NEXT:   "end": {
-// CHECK-NEXT:"offset": {{[0-9]+}},
-// CHECK-NEXT:"col": 45,
-// CHECK-NEXT:"tokLen": 1
-// CHECK-NEXT:   }
-// CHECK-NEXT:  },
-// CHECK-NEXT:  "type": {
-// CHECK-NEXT:   "qualType": ""
-// CHECK-NEXT:  },
-// CHECK-NEXT:  "valueCategory": "lvalue",
-// CHECK-NEXT:  "inner": [
-// CHECK-NEXT:   {
-// CHECK-NEXT:"id": "0x{{.*}}",
-// CHECK-NEXT:"kind": "UnresolvedLookupExpr",
-// CHECK-NEXT:"range": {
-// CHECK-NEXT:  

[PATCH] D149978: [Clang][NVPTX] Allow passing arguments to the linker while standalone

2023-05-05 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

Somewhat annoying, I've discovered that LLVM adds `-Wl,-fcolor-diagnostics` 
which obviously isn't supported by `nvlink` so it fails while including this in 
`libc`'s CMake. Any clue if there's a way to work around that?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149978

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


[PATCH] D149461: [NFC] ][CLANG] Fix static code analyzer concerns

2023-05-05 Thread Soumi Manna via Phabricator via cfe-commits
Manna added a comment.

In D149461#4323175 , @tahonermann 
wrote:

> These changes look good to me and I agree with not making a change for the 
> `KnownHeaders` case.



>> I agree with not making a change for the `KnownHeaders` case.

Yup. I closed them as a false positive.

Thanks @tahonermann for reviews!


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

https://reviews.llvm.org/D149461

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


[PATCH] D149461: [NFC] ][CLANG] Fix static code analyzer concerns

2023-05-05 Thread Tom Honermann via Phabricator via cfe-commits
tahonermann accepted this revision.
tahonermann added a comment.
This revision is now accepted and ready to land.

These changes look good to me and I agree with not making a change for the 
`KnownHeaders` case.




Comment at: clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp:1131-1132
 // Deallocate the memory for each globalized VLA object
-for (auto AddrSizePair :
+for (const auto  :
  llvm::reverse(I->getSecond().EscapedVariableLengthDeclsAddrs)) {
   CGF.EmitRuntimeCall(OMPBuilder.getOrCreateRuntimeFunction(

`EscapedVariableLengthDeclsAddrs` is a `llvm::SmallVector`; this looks like a 
good change.



Comment at: clang/lib/Serialization/ASTReader.cpp:4428
   // Mark selectors as out of date.
-  for (auto Sel : SelectorGeneration)
+  for (const auto  : SelectorGeneration)
 SelectorOutOfDate[Sel.first] = true;

Manna wrote:
> Here Object of type is `DenseMapPair`.  `SelectorGeneration`  returns 
> `llvm::DenseMap' in `ASTReader.h' file.
Yes, looks like a good change.



Comment at: clang/lib/Serialization/ASTReader.cpp:7696
   if (isa(DC)) {
-for (auto Lexical : TULexicalDecls)
+for (const auto  : TULexicalDecls)
   Visit(Lexical.first, Lexical.second);

Manna wrote:
> This returns `std::vector` in 
> 'ASTReader.h` file
Yes, this looks like a good change.



Comment at: clang/lib/Serialization/ASTWriter.cpp:1887
   // enough information in the module map.
-  for (auto U : M->MissingHeaders) {
+  for (const auto  : M->MissingHeaders) {
 // Check that we were given enough information to build a module

Manna wrote:
> This returns ` SmallVector` in `Module.h' file
> 
> 
> 
Yes, looks like a good change.


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

https://reviews.llvm.org/D149461

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


[PATCH] D149776: Re-land "[AMDGPU] Define data layout entries for buffers""

2023-05-05 Thread Krzysztof Drewniak via Phabricator via cfe-commits
krzysz00 added a comment.

From a quick skim of the backtrace, I think this comes down to the fact that 
there isn't a defined way to stick a `p7` into registers (or, equivalently, 
there's no `MVT::i160`) and that getting said pointers to that point was 
supposed to never happen (in that they were meant to expand to `{ptr 
addrspace(8), i32}` or similar at the IR level.)

It looks like there's code up in `opt` that's actually querying those same 
hooks that I didn't know about. I'll go looking for a workaround.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149776

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


[PATCH] D149694: [Clang] Update warning on some designator initializer cases involving unions

2023-05-05 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik updated this revision to Diff 519960.
shafik added a comment.

- Apply clang-format


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

https://reviews.llvm.org/D149694

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaInit.cpp
  clang/test/SemaCXX/cxx2b-designated-initializers.cpp


Index: clang/test/SemaCXX/cxx2b-designated-initializers.cpp
===
--- clang/test/SemaCXX/cxx2b-designated-initializers.cpp
+++ clang/test/SemaCXX/cxx2b-designated-initializers.cpp
@@ -19,3 +19,27 @@
 }
 
 } // end namespace PR61118
+
+namespace GH62156 {
+union U1 {
+   int x;
+   float y;
+};
+
+struct NonTrivial {
+  NonTrivial();
+  ~NonTrivial();
+};
+
+union U2 {
+   NonTrivial x;
+   float y;
+};
+
+void f() {
+   U1 u{.x=2,  // expected-note {{previous initialization is here}}
+.y=1}; // expected-error {{initializer partially overrides prior 
initialization of this subobject}}
+   new U2{.x = NonTrivial{}, // expected-note {{previous initialization is 
here}}
+  .y=1}; // expected-error {{initializer would partially override 
prior initialization of object of type 'NonTrivial' with non-trivial 
destruction}}
+}
+}
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -393,12 +393,15 @@
 
   /// Diagnose that OldInit (or part thereof) has been overridden by NewInit.
   void diagnoseInitOverride(Expr *OldInit, SourceRange NewInitRange,
+bool UnionOverride = false,
 bool FullyOverwritten = true) {
 // Overriding an initializer via a designator is valid with C99 designated
 // initializers, but ill-formed with C++20 designated initializers.
-unsigned DiagID = SemaRef.getLangOpts().CPlusPlus
-  ? diag::ext_initializer_overrides
-  : diag::warn_initializer_overrides;
+unsigned DiagID =
+SemaRef.getLangOpts().CPlusPlus
+? (UnionOverride ? diag::ext_initializer_union_overrides
+ : diag::ext_initializer_overrides)
+: diag::warn_initializer_overrides;
 
 if (InOverloadResolution && SemaRef.getLangOpts().CPlusPlus) {
   // In overload resolution, we have to strictly enforce the rules, and so
@@ -2544,6 +2547,7 @@
 // subobject [0].b.
 diagnoseInitOverride(ExistingInit,
  SourceRange(D->getBeginLoc(), DIE->getEndLoc()),
+ /*UnionOverride=*/false,
  /*FullyOverwritten=*/false);
 
 if (!VerifyOnly) {
@@ -2689,7 +2693,10 @@
   if (ExistingInit) {
 // We're about to throw away an initializer, emit warning.
 diagnoseInitOverride(
-ExistingInit, SourceRange(D->getBeginLoc(), DIE->getEndLoc()));
+ExistingInit, SourceRange(D->getBeginLoc(), DIE->getEndLoc()),
+/*UnionOverride=*/true,
+/*FullyOverwritten=*/SemaRef.getLangOpts().CPlusPlus ? false
+ : true);
   }
 
   // remove existing initializer
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -186,6 +186,8 @@
   "this subobject">, InGroup;
 def ext_initializer_overrides : ExtWarn,
   InGroup, SFINAEFailure;
+def ext_initializer_union_overrides : 
ExtWarn,
+  InGroup, DefaultError, SFINAEFailure;
 def err_initializer_overrides_destructed : Error<
   "initializer would partially override prior initialization of object of "
   "type %1 with non-trivial destruction">;


Index: clang/test/SemaCXX/cxx2b-designated-initializers.cpp
===
--- clang/test/SemaCXX/cxx2b-designated-initializers.cpp
+++ clang/test/SemaCXX/cxx2b-designated-initializers.cpp
@@ -19,3 +19,27 @@
 }
 
 } // end namespace PR61118
+
+namespace GH62156 {
+union U1 {
+   int x;
+   float y;
+};
+
+struct NonTrivial {
+  NonTrivial();
+  ~NonTrivial();
+};
+
+union U2 {
+   NonTrivial x;
+   float y;
+};
+
+void f() {
+   U1 u{.x=2,  // expected-note {{previous initialization is here}}
+.y=1}; // expected-error {{initializer partially overrides prior initialization of this subobject}}
+   new U2{.x = NonTrivial{}, // expected-note {{previous initialization is here}}
+  .y=1}; // expected-error {{initializer would partially override prior initialization of object of type 'NonTrivial' with non-trivial destruction}}
+}
+}
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ 

[PATCH] D146342: [-Wunsafe-buffer-usage] Move the whole analysis to the end of a translation unit

2023-05-05 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 updated this revision to Diff 519958.
ziqingluo-90 marked an inline comment as done.

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

https://reviews.llvm.org/D146342

Files:
  clang/include/clang/Sema/AnalysisBasedWarnings.h
  clang/lib/Sema/AnalysisBasedWarnings.cpp
  clang/lib/Sema/Sema.cpp
  clang/test/SemaCXX/warn-unsafe-buffer-usage-objc-method-traversal.mm
  clang/test/SemaCXX/warn-unsafe-buffer-usage.cpp

Index: clang/test/SemaCXX/warn-unsafe-buffer-usage.cpp
===
--- clang/test/SemaCXX/warn-unsafe-buffer-usage.cpp
+++ clang/test/SemaCXX/warn-unsafe-buffer-usage.cpp
@@ -220,11 +220,11 @@
 void testTemplate(int * p) {
   int *a[10];
   foo(f(p, , a, a)[1]); // expected-warning{{unsafe buffer access}}
-  // expected-note@-1{{in instantiation of function template specialization 'f' requested here}}
+  // FIXME: expected note@-1{{in instantiation of function template specialization 'f' requested here}}
 
   const int **q = const_cast();
 
-  testPointerArithmetic(p, q, p); //expected-note{{in instantiation of}}
+  testPointerArithmetic(p, q, p); //FIXME: expected note{{in instantiation of}}
 }
 
 void testPointerToMember() {
@@ -315,7 +315,7 @@
   foo(ar[5]);   // expected-note{{used in buffer access here}}
 }
 
-template void fArr(int t[]); // expected-note {{in instantiation of}}
+template void fArr(int t[]); // FIXME: expected note {{in instantiation of}}
 
 int testReturn(int t[]) {
   // expected-warning@-1{{'t' is an unsafe pointer used for buffer access}}
Index: clang/test/SemaCXX/warn-unsafe-buffer-usage-objc-method-traversal.mm
===
--- /dev/null
+++ clang/test/SemaCXX/warn-unsafe-buffer-usage-objc-method-traversal.mm
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -std=c++20 -Wno-objc-root-class -Wno-return-type -Wunsafe-buffer-usage %s -verify %s
+
+// This test is to show that ObjC methods are traversed by the
+// end-of-TU analysis properly.  Particularly, a method body will not
+// be repeatedly visited whenever a method prototype of it is visited.
+
+@interface I
++ f:(int *) p; // duplicated method prototype declaration
+
++ f:(int *) p;
+
++ f:(int *) p;
+@end
+
+@implementation I
++ f:(int *) p { // expected-warning{{'p' is an unsafe pointer used for buffer access}}
+  int tmp;
+  tmp = p[5];  // expected-note{{used in buffer access here}}
+}
+@end
Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -1426,6 +1426,8 @@
 }
   }
 
+  AnalysisWarnings.IssueWarnings(Context.getTranslationUnitDecl());
+
   // Check we've noticed that we're no longer parsing the initializer for every
   // variable. If we miss cases, then at best we have a performance issue and
   // at worst a rejects-valid bug.
Index: clang/lib/Sema/AnalysisBasedWarnings.cpp
===
--- clang/lib/Sema/AnalysisBasedWarnings.cpp
+++ clang/lib/Sema/AnalysisBasedWarnings.cpp
@@ -13,6 +13,7 @@
 //===--===//
 
 #include "clang/Sema/AnalysisBasedWarnings.h"
+#include "clang/AST/Decl.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/EvaluatedExprVisitor.h"
@@ -25,6 +26,8 @@
 #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"
 #include "clang/Analysis/Analyses/Consumed.h"
@@ -2290,6 +2293,111 @@
 S.Diag(D.Loc, D.PD);
 }
 
+void clang::sema::AnalysisBasedWarnings::IssueWarnings(
+const TranslationUnitDecl *TU) {
+  if (!TU)
+return; // This is unexpected, give up quietly.
+
+  DiagnosticsEngine  = S.getDiagnostics();
+  const bool EmitFixits =
+  Diags.getDiagnosticOptions().ShowFixits && S.getLangOpts().CPlusPlus20;
+
+  if (S.hasUncompilableErrorOccurred() || Diags.getIgnoreAllWarnings())
+// exit if having uncompilable errors or ignoring all warnings:
+return;
+
+  // An AST Visitor that calls analyzers on each callable definition:
+  class CallableVisitor : public RecursiveASTVisitor {
+  private:
+Sema 
+const bool EmitFixits;
+// Will be set to true iff visiting a `LambdaExpr`:
+bool IsVisitingLambda = false;
+
+  public:
+CallableVisitor(Sema , bool EmitFixits) : S(S), EmitFixits(EmitFixits) {}
+
+bool TraverseDecl(Decl *Node) {
+  if (!Node)
+return true;
+
+  // Do not analyze any `Decl` if we are going to just ignore them.
+  DiagnosticsEngine  = S.getDiagnostics();
+
+  if (Diags.getSuppressSystemWarnings() &&
+  

[PATCH] D146342: [-Wunsafe-buffer-usage] Move the whole analysis to the end of a translation unit

2023-05-05 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 marked an inline comment as done.
ziqingluo-90 added inline comments.



Comment at: clang/lib/Sema/AnalysisBasedWarnings.cpp:2363-2364
+  if (isa(Node)) {
+// to visit implicit children of `LambdaExpr`s:
+IsVisitingLambda = true;
+

NoQ wrote:
> I suspect that you might have reinvented `shouldVisitLambdaBody()`.
I tried `shouldVisitLambdaBody`  but it didn't work (I didn't look into why 
though)


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

https://reviews.llvm.org/D146342

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


[PATCH] D149978: [Clang][NVPTX] Allow passing arguments to the linker while standalone

2023-05-05 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 519957.
jhuber6 added a comment.

Addressing comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149978

Files:
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/test/Driver/cuda-cross-compiling.c


Index: clang/test/Driver/cuda-cross-compiling.c
===
--- clang/test/Driver/cuda-cross-compiling.c
+++ clang/test/Driver/cuda-cross-compiling.c
@@ -77,3 +77,11 @@
 // RUN:   | FileCheck -check-prefix=LOWERING %s
 
 // LOWERING: -cc1" "-triple" "nvptx64-nvidia-cuda" {{.*}} "-mllvm" 
"--nvptx-lower-global-ctor-dtor"
+
+//
+// Test passing arguments directly to nvlink.
+//
+// RUN: %clang -target nvptx64-nvidia-cuda -Wl,-v -### %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=LINKER-ARGS %s
+
+// LINKER-ARGS: nvlink{{.*}}"-v"
Index: clang/lib/Driver/ToolChains/Cuda.cpp
===
--- clang/lib/Driver/ToolChains/Cuda.cpp
+++ clang/lib/Driver/ToolChains/Cuda.cpp
@@ -607,36 +607,37 @@
   continue;
 }
 
-// Currently, we only pass the input files to the linker, we do not pass
-// any libraries that may be valid only for the host.
-if (!II.isFilename())
-  continue;
-
 // The 'nvlink' application performs RDC-mode linking when given a '.o'
 // file and device linking when given a '.cubin' file. We always want to
 // perform device linking, so just rename any '.o' files.
 // FIXME: This should hopefully be removed if NVIDIA updates their tooling.
-auto InputFile = getToolChain().getInputFilename(II);
-if (llvm::sys::path::extension(InputFile) != ".cubin") {
-  // If there are no actions above this one then this is direct input and 
we
-  // can copy it. Otherwise the input is internal so a `.cubin` file should
-  // exist.
-  if (II.getAction() && II.getAction()->getInputs().size() == 0) {
-const char *CubinF =
-Args.MakeArgString(getToolChain().getDriver().GetTemporaryPath(
-llvm::sys::path::stem(InputFile), "cubin"));
-if (std::error_code EC =
-llvm::sys::fs::copy_file(InputFile, C.addTempFile(CubinF)))
-  continue;
+if (II.isFilename()) {
+  auto InputFile = getToolChain().getInputFilename(II);
+  if (llvm::sys::path::extension(InputFile) != ".cubin") {
+// If there are no actions above this one then this is direct input and
+// we can copy it. Otherwise the input is internal so a `.cubin` file
+// should exist.
+if (II.getAction() && II.getAction()->getInputs().size() == 0) {
+  const char *CubinF =
+  Args.MakeArgString(getToolChain().getDriver().GetTemporaryPath(
+  llvm::sys::path::stem(InputFile), "cubin"));
+  if (std::error_code EC =
+  llvm::sys::fs::copy_file(InputFile, C.addTempFile(CubinF)))
+continue;
 
-CmdArgs.push_back(CubinF);
+  CmdArgs.push_back(CubinF);
+} else {
+  SmallString<256> Filename(InputFile);
+  llvm::sys::path::replace_extension(Filename, "cubin");
+  CmdArgs.push_back(Args.MakeArgString(Filename));
+}
   } else {
-SmallString<256> Filename(InputFile);
-llvm::sys::path::replace_extension(Filename, "cubin");
-CmdArgs.push_back(Args.MakeArgString(Filename));
+CmdArgs.push_back(Args.MakeArgString(InputFile));
   }
-} else {
-  CmdArgs.push_back(Args.MakeArgString(InputFile));
+  continue;
+} else if (!II.isNothing()) {
+  // Render any remaining arguments as input to nvlink.
+  II.getInputArg().renderAsInput(Args, CmdArgs);
 }
   }
 


Index: clang/test/Driver/cuda-cross-compiling.c
===
--- clang/test/Driver/cuda-cross-compiling.c
+++ clang/test/Driver/cuda-cross-compiling.c
@@ -77,3 +77,11 @@
 // RUN:   | FileCheck -check-prefix=LOWERING %s
 
 // LOWERING: -cc1" "-triple" "nvptx64-nvidia-cuda" {{.*}} "-mllvm" "--nvptx-lower-global-ctor-dtor"
+
+//
+// Test passing arguments directly to nvlink.
+//
+// RUN: %clang -target nvptx64-nvidia-cuda -Wl,-v -### %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=LINKER-ARGS %s
+
+// LINKER-ARGS: nvlink{{.*}}"-v"
Index: clang/lib/Driver/ToolChains/Cuda.cpp
===
--- clang/lib/Driver/ToolChains/Cuda.cpp
+++ clang/lib/Driver/ToolChains/Cuda.cpp
@@ -607,36 +607,37 @@
   continue;
 }
 
-// Currently, we only pass the input files to the linker, we do not pass
-// any libraries that may be valid only for the host.
-if (!II.isFilename())
-  continue;
-
 // The 'nvlink' application performs RDC-mode linking when given a '.o'
 // file and device linking when given a '.cubin' file. We always want to
 

[PATCH] D149978: [Clang][NVPTX] Allow passing arguments to the linker while standalone

2023-05-05 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 marked an inline comment as done.
jhuber6 added inline comments.



Comment at: clang/lib/Driver/ToolChains/Cuda.cpp:594
-  // Add paths specified in LIBRARY_PATH environment variable as -L options.
-  addDirectoryList(Args, CmdArgs, "-L", "LIBRARY_PATH");
-

tra wrote:
> Is removal of this line intentional? 
No, thanks that was from when I originally tried to use `AddLinkerInput` but it 
didn't work because of the `cubin` thing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149978

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


[PATCH] D149983: AMDGPU: Add basic gfx942 target

2023-05-05 Thread Konstantin Zhuravlyov via Phabricator via cfe-commits
kzhuravl created this revision.
kzhuravl added reviewers: arsenm, msearles, rampitec, t-tye.
Herald added subscribers: kosarev, mattd, gchakrabarti, asavonic, foad, 
kerbowa, hiraditya, tpr, dstuttard, yaxunl, jvesely, emaste.
Herald added a reviewer: jhenderson.
Herald added a reviewer: MaskRay.
Herald added a project: All.
kzhuravl requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, wdng, jholewinski.
Herald added projects: clang, LLVM.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149983

Files:
  clang/include/clang/Basic/Cuda.h
  clang/lib/Basic/Cuda.cpp
  clang/lib/Basic/Targets/NVPTX.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/test/CodeGenOpenCL/amdgpu-features.cl
  clang/test/Driver/amdgpu-macros.cl
  clang/test/Driver/amdgpu-mcpu.cl
  clang/test/Misc/target-invalid-cpu-note.c
  llvm/docs/AMDGPUUsage.rst
  llvm/include/llvm/BinaryFormat/ELF.h
  llvm/include/llvm/TargetParser/TargetParser.h
  llvm/lib/Object/ELFObjectFile.cpp
  llvm/lib/ObjectYAML/ELFYAML.cpp
  llvm/lib/Target/AMDGPU/AMDGPU.td
  llvm/lib/Target/AMDGPU/GCNProcessors.td
  llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp
  llvm/lib/TargetParser/TargetParser.cpp
  llvm/test/CodeGen/AMDGPU/directive-amdgcn-target.ll
  llvm/test/CodeGen/AMDGPU/elf-header-flags-mach.ll
  llvm/test/Object/AMDGPU/elf-header-flags-mach.yaml
  llvm/test/tools/llvm-objdump/ELF/AMDGPU/subtarget.ll
  llvm/test/tools/llvm-readobj/ELF/amdgpu-elf-headers.test
  llvm/tools/llvm-readobj/ELFDumper.cpp

Index: llvm/tools/llvm-readobj/ELFDumper.cpp
===
--- llvm/tools/llvm-readobj/ELFDumper.cpp
+++ llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -1589,6 +1589,7 @@
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX90C),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX940),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX941),
+  LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX942),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1010),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1011),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1012),
@@ -1650,6 +1651,7 @@
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX90C),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX940),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX941),
+  LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX942),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1010),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1011),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1012),
Index: llvm/test/tools/llvm-readobj/ELF/amdgpu-elf-headers.test
===
--- llvm/test/tools/llvm-readobj/ELF/amdgpu-elf-headers.test
+++ llvm/test/tools/llvm-readobj/ELF/amdgpu-elf-headers.test
@@ -214,6 +214,15 @@
 # RUN: yaml2obj %s -o %t -DABI_VERSION=2 -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX941
 # RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=ALL,KNOWN-ABI-VERSION,SINGLE-FLAG --match-full-lines -DABI_VERSION=2 -DFILE=%t -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX941 -DFLAG_VALUE=0x4B
 
+# RUN: yaml2obj %s -o %t -DABI_VERSION=0 -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX942
+# RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=ALL,KNOWN-ABI-VERSION,SINGLE-FLAG --match-full-lines -DABI_VERSION=0 -DFILE=%t -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX942 -DFLAG_VALUE=0x4C
+
+# RUN: yaml2obj %s -o %t -DABI_VERSION=1 -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX942
+# RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=ALL,KNOWN-ABI-VERSION,SINGLE-FLAG --match-full-lines -DABI_VERSION=1 -DFILE=%t -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX942 -DFLAG_VALUE=0x4C
+
+# RUN: yaml2obj %s -o %t -DABI_VERSION=2 -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX942
+# RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=ALL,KNOWN-ABI-VERSION,SINGLE-FLAG --match-full-lines -DABI_VERSION=2 -DFILE=%t -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX942 -DFLAG_VALUE=0x4C
+
 # RUN: yaml2obj %s -o %t -DABI_VERSION=0 -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX1010
 # RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=ALL,KNOWN-ABI-VERSION,SINGLE-FLAG --match-full-lines -DABI_VERSION=0 -DFILE=%t -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX1010 -DFLAG_VALUE=0x33
 
Index: llvm/test/tools/llvm-objdump/ELF/AMDGPU/subtarget.ll
===
--- llvm/test/tools/llvm-objdump/ELF/AMDGPU/subtarget.ll
+++ llvm/test/tools/llvm-objdump/ELF/AMDGPU/subtarget.ll
@@ -85,6 +85,11 @@
 
 ; --GFX9---
 ;
+; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx942 -filetype=obj -O0 -o %t.o %s
+; RUN: llvm-objdump -D --arch-name=amdgcn --mcpu=gfx942 %t.o > %t-specify.txt
+; RUN: llvm-objdump -D %t.o > %t-detect.txt
+; RUN: diff %t-specify.txt %t-detect.txt
+
 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx941 -filetype=obj -O0 

[PATCH] D149982: AMDGPU: Add basic gfx941 target

2023-05-05 Thread Konstantin Zhuravlyov via Phabricator via cfe-commits
kzhuravl created this revision.
kzhuravl added reviewers: arsenm, msearles, rampitec, t-tye.
Herald added subscribers: kosarev, mattd, gchakrabarti, asavonic, foad, 
kerbowa, hiraditya, tpr, dstuttard, yaxunl, jvesely, emaste.
Herald added a reviewer: jhenderson.
Herald added a reviewer: MaskRay.
Herald added a project: All.
kzhuravl requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, wdng, jholewinski.
Herald added projects: clang, LLVM.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149982

Files:
  clang/include/clang/Basic/Cuda.h
  clang/lib/Basic/Cuda.cpp
  clang/lib/Basic/Targets/NVPTX.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/test/CodeGenOpenCL/amdgpu-features.cl
  clang/test/Driver/amdgpu-macros.cl
  clang/test/Driver/amdgpu-mcpu.cl
  clang/test/Misc/target-invalid-cpu-note.c
  llvm/docs/AMDGPUUsage.rst
  llvm/include/llvm/BinaryFormat/ELF.h
  llvm/include/llvm/TargetParser/TargetParser.h
  llvm/lib/Object/ELFObjectFile.cpp
  llvm/lib/ObjectYAML/ELFYAML.cpp
  llvm/lib/Target/AMDGPU/AMDGPU.td
  llvm/lib/Target/AMDGPU/GCNProcessors.td
  llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp
  llvm/lib/TargetParser/TargetParser.cpp
  llvm/test/CodeGen/AMDGPU/directive-amdgcn-target.ll
  llvm/test/CodeGen/AMDGPU/elf-header-flags-mach.ll
  llvm/test/Object/AMDGPU/elf-header-flags-mach.yaml
  llvm/test/tools/llvm-objdump/ELF/AMDGPU/subtarget.ll
  llvm/test/tools/llvm-readobj/ELF/amdgpu-elf-headers.test
  llvm/tools/llvm-readobj/ELFDumper.cpp

Index: llvm/tools/llvm-readobj/ELFDumper.cpp
===
--- llvm/tools/llvm-readobj/ELFDumper.cpp
+++ llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -1588,6 +1588,7 @@
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX90A),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX90C),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX940),
+  LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX941),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1010),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1011),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1012),
@@ -1648,6 +1649,7 @@
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX90A),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX90C),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX940),
+  LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX941),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1010),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1011),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1012),
Index: llvm/test/tools/llvm-readobj/ELF/amdgpu-elf-headers.test
===
--- llvm/test/tools/llvm-readobj/ELF/amdgpu-elf-headers.test
+++ llvm/test/tools/llvm-readobj/ELF/amdgpu-elf-headers.test
@@ -205,6 +205,15 @@
 # RUN: yaml2obj %s -o %t -DABI_VERSION=2 -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX940
 # RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=ALL,KNOWN-ABI-VERSION,SINGLE-FLAG --match-full-lines -DABI_VERSION=2 -DFILE=%t -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX940 -DFLAG_VALUE=0x40
 
+# RUN: yaml2obj %s -o %t -DABI_VERSION=0 -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX941
+# RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=ALL,KNOWN-ABI-VERSION,SINGLE-FLAG --match-full-lines -DABI_VERSION=0 -DFILE=%t -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX941 -DFLAG_VALUE=0x4B
+
+# RUN: yaml2obj %s -o %t -DABI_VERSION=1 -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX941
+# RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=ALL,KNOWN-ABI-VERSION,SINGLE-FLAG --match-full-lines -DABI_VERSION=1 -DFILE=%t -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX941 -DFLAG_VALUE=0x4B
+
+# RUN: yaml2obj %s -o %t -DABI_VERSION=2 -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX941
+# RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=ALL,KNOWN-ABI-VERSION,SINGLE-FLAG --match-full-lines -DABI_VERSION=2 -DFILE=%t -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX941 -DFLAG_VALUE=0x4B
+
 # RUN: yaml2obj %s -o %t -DABI_VERSION=0 -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX1010
 # RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=ALL,KNOWN-ABI-VERSION,SINGLE-FLAG --match-full-lines -DABI_VERSION=0 -DFILE=%t -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX1010 -DFLAG_VALUE=0x33
 
Index: llvm/test/tools/llvm-objdump/ELF/AMDGPU/subtarget.ll
===
--- llvm/test/tools/llvm-objdump/ELF/AMDGPU/subtarget.ll
+++ llvm/test/tools/llvm-objdump/ELF/AMDGPU/subtarget.ll
@@ -85,6 +85,11 @@
 
 ; --GFX9---
 ;
+; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx941 -filetype=obj -O0 -o %t.o %s
+; RUN: llvm-objdump -D --arch-name=amdgcn --mcpu=gfx941 %t.o > %t-specify.txt
+; RUN: llvm-objdump -D %t.o > %t-detect.txt
+; RUN: diff %t-specify.txt %t-detect.txt
+
 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx940 -filetype=obj -O0 

[PATCH] D149946: [LoongArch] Define `ual` feature and override `allowsMisalignedMemoryAccesses`

2023-05-05 Thread Peter Smith via Phabricator via cfe-commits
peter.smith added a comment.

No objections for moving out m_arm_Features_Group or adding the alias. It looks 
like that is currently unused i.e. no driver filters out the 
m_arm_Features_Group. I can't comment on the LoongArch specific parts of the 
patch.

I think you may want to note in the help that the option is not universally 
supported. Perhaps add a test to show that it remains unused on a target that 
does not support it. For example for an x86_64 target:

  clang: warning: argument unused during compilation: '-munaligned-access' 
[-Wunused-command-line-argument]




Comment at: clang/include/clang/Driver/Options.td:3656
-def munaligned_access : Flag<["-"], "munaligned-access">, 
Group,
-  HelpText<"Allow memory accesses to be unaligned (AArch32/AArch64 only)">;
-def mno_unaligned_access : Flag<["-"], "mno-unaligned-access">, 
Group,

I think this is AArch32/AArch64/LoongArch only. I don't think this patch adds 
support for all other Targets.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149946

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


[PATCH] D149981: [clang][AST][NFC] Factor out check for structural equivalence of names.

2023-05-05 Thread David Stone via Phabricator via cfe-commits
davidstone created this revision.
Herald added a subscriber: martong.
Herald added a project: All.
davidstone requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

We have four places that we try to decide which name to use for the test for 
structural equivalence, and in each of those we evaluate 
`getTypedefNameForAnonDecl` twice. Pull out the check into a function to reduce 
duplication and evaluate things only once.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149981

Files:
  clang/lib/AST/ASTStructuralEquivalence.cpp


Index: clang/lib/AST/ASTStructuralEquivalence.cpp
===
--- clang/lib/AST/ASTStructuralEquivalence.cpp
+++ clang/lib/AST/ASTStructuralEquivalence.cpp
@@ -1453,19 +1453,25 @@
   return true;
 }
 
+static bool NameIsStructurallyEquivalent(const TagDecl , const TagDecl ) 
{
+  auto GetName = [](const TagDecl ) -> const IdentifierInfo * {
+if (const IdentifierInfo *Name = D.getIdentifier()) {
+  return Name;
+}
+if (const TypedefNameDecl *TypedefName = D.getTypedefNameForAnonDecl()) {
+  return TypedefName->getIdentifier();
+}
+return nullptr;
+  };
+  return IsStructurallyEquivalent(GetName(D1), GetName(D2));
+}
+
 /// Determine structural equivalence of two records.
 static bool IsStructurallyEquivalent(StructuralEquivalenceContext ,
  RecordDecl *D1, RecordDecl *D2) {
-
-  // Check for equivalent structure names.
-  IdentifierInfo *Name1 = D1->getIdentifier();
-  if (!Name1 && D1->getTypedefNameForAnonDecl())
-Name1 = D1->getTypedefNameForAnonDecl()->getIdentifier();
-  IdentifierInfo *Name2 = D2->getIdentifier();
-  if (!Name2 && D2->getTypedefNameForAnonDecl())
-Name2 = D2->getTypedefNameForAnonDecl()->getIdentifier();
-  if (!IsStructurallyEquivalent(Name1, Name2))
+  if (!NameIsStructurallyEquivalent(*D1, *D2)) {
 return false;
+  }
 
   if (D1->isUnion() != D2->isUnion()) {
 if (Context.Complain) {
@@ -1727,16 +1733,9 @@
 /// Determine structural equivalence of two enums.
 static bool IsStructurallyEquivalent(StructuralEquivalenceContext ,
  EnumDecl *D1, EnumDecl *D2) {
-
-  // Check for equivalent enum names.
-  IdentifierInfo *Name1 = D1->getIdentifier();
-  if (!Name1 && D1->getTypedefNameForAnonDecl())
-Name1 = D1->getTypedefNameForAnonDecl()->getIdentifier();
-  IdentifierInfo *Name2 = D2->getIdentifier();
-  if (!Name2 && D2->getTypedefNameForAnonDecl())
-Name2 = D2->getTypedefNameForAnonDecl()->getIdentifier();
-  if (!IsStructurallyEquivalent(Name1, Name2))
+  if (!NameIsStructurallyEquivalent(*D1, *D2)) {
 return false;
+  }
 
   // Compare the definitions of these two enums. If either or both are
   // incomplete (i.e. forward declared), we assume that they are equivalent.


Index: clang/lib/AST/ASTStructuralEquivalence.cpp
===
--- clang/lib/AST/ASTStructuralEquivalence.cpp
+++ clang/lib/AST/ASTStructuralEquivalence.cpp
@@ -1453,19 +1453,25 @@
   return true;
 }
 
+static bool NameIsStructurallyEquivalent(const TagDecl , const TagDecl ) {
+  auto GetName = [](const TagDecl ) -> const IdentifierInfo * {
+if (const IdentifierInfo *Name = D.getIdentifier()) {
+  return Name;
+}
+if (const TypedefNameDecl *TypedefName = D.getTypedefNameForAnonDecl()) {
+  return TypedefName->getIdentifier();
+}
+return nullptr;
+  };
+  return IsStructurallyEquivalent(GetName(D1), GetName(D2));
+}
+
 /// Determine structural equivalence of two records.
 static bool IsStructurallyEquivalent(StructuralEquivalenceContext ,
  RecordDecl *D1, RecordDecl *D2) {
-
-  // Check for equivalent structure names.
-  IdentifierInfo *Name1 = D1->getIdentifier();
-  if (!Name1 && D1->getTypedefNameForAnonDecl())
-Name1 = D1->getTypedefNameForAnonDecl()->getIdentifier();
-  IdentifierInfo *Name2 = D2->getIdentifier();
-  if (!Name2 && D2->getTypedefNameForAnonDecl())
-Name2 = D2->getTypedefNameForAnonDecl()->getIdentifier();
-  if (!IsStructurallyEquivalent(Name1, Name2))
+  if (!NameIsStructurallyEquivalent(*D1, *D2)) {
 return false;
+  }
 
   if (D1->isUnion() != D2->isUnion()) {
 if (Context.Complain) {
@@ -1727,16 +1733,9 @@
 /// Determine structural equivalence of two enums.
 static bool IsStructurallyEquivalent(StructuralEquivalenceContext ,
  EnumDecl *D1, EnumDecl *D2) {
-
-  // Check for equivalent enum names.
-  IdentifierInfo *Name1 = D1->getIdentifier();
-  if (!Name1 && D1->getTypedefNameForAnonDecl())
-Name1 = D1->getTypedefNameForAnonDecl()->getIdentifier();
-  IdentifierInfo *Name2 = D2->getIdentifier();
-  if (!Name2 && D2->getTypedefNameForAnonDecl())
-Name2 = D2->getTypedefNameForAnonDecl()->getIdentifier();
-  if 

[PATCH] D149980: Remove unused basic_android_tree/mipsel-linux-android

2023-05-05 Thread Aditya Kumar via Phabricator via cfe-commits
hiraditya created this revision.
hiraditya added reviewers: danalbert, enh, pirama, srhines.
Herald added subscribers: danielkiss, atanasyan, jrtc27, arichardson, sdardis.
Herald added a project: All.
hiraditya requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149980

Files:
  clang/test/Driver/Inputs/basic_android_tree/mipsel-linux-android/bin/.keep
  
clang/test/Driver/Inputs/basic_android_tree/mipsel-linux-android/include/c++/4.4.3/.keep
  clang/test/Driver/Inputs/basic_android_tree/mipsel-linux-android/lib/.keep




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


[PATCH] D149978: [Clang][NVPTX] Allow passing arguments to the linker while standalone

2023-05-05 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/lib/Driver/ToolChains/Cuda.cpp:594
-  // Add paths specified in LIBRARY_PATH environment variable as -L options.
-  addDirectoryList(Args, CmdArgs, "-L", "LIBRARY_PATH");
-

Is removal of this line intentional? 



Comment at: clang/lib/Driver/ToolChains/Cuda.cpp:634
   }
-} else {
-  CmdArgs.push_back(Args.MakeArgString(InputFile));
+  continue;
 }

I'd prefer to replace it with 
```
if (II.isFileName()) {
  do stuff...
} else {
  if (!II.isNothing()
  II.getInputArg().renderAsInput(Args, CmdArgs); 
}
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149978

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


[PATCH] D149978: [Clang][NVPTX] Allow passing arguments to the linker while standalone

2023-05-05 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 created this revision.
jhuber6 added reviewers: JonChesterfield, tra, yaxunl, MaskRay.
Herald added subscribers: mattd, gchakrabarti, asavonic.
Herald added a project: All.
jhuber6 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

We support standalone compilation for the NVPTX architecture using
'nvlink' as our linker. Because of the special handling required to
transform input files to cubins, as nvlink expects for some reason, we
didn't use the standard `AddLinkerInput` method. However, this also
meant that we weren't forwarding options passed with `-Wl` to the
linker. Add this support in for the standalone toolchain path.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149978

Files:
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/test/Driver/cuda-cross-compiling.c


Index: clang/test/Driver/cuda-cross-compiling.c
===
--- clang/test/Driver/cuda-cross-compiling.c
+++ clang/test/Driver/cuda-cross-compiling.c
@@ -77,3 +77,11 @@
 // RUN:   | FileCheck -check-prefix=LOWERING %s
 
 // LOWERING: -cc1" "-triple" "nvptx64-nvidia-cuda" {{.*}} "-mllvm" 
"--nvptx-lower-global-ctor-dtor"
+
+//
+// Test passing arguments directly to nvlink.
+//
+// RUN: %clang -target nvptx64-nvidia-cuda -Wl,-v -### %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=LINKER-ARGS %s
+
+// LINKER-ARGS: nvlink{{.*}}"-v"
Index: clang/lib/Driver/ToolChains/Cuda.cpp
===
--- clang/lib/Driver/ToolChains/Cuda.cpp
+++ clang/lib/Driver/ToolChains/Cuda.cpp
@@ -590,9 +590,6 @@
   CmdArgs.push_back("-arch");
   CmdArgs.push_back(Args.MakeArgString(GPUArch));
 
-  // Add paths specified in LIBRARY_PATH environment variable as -L options.
-  addDirectoryList(Args, CmdArgs, "-L", "LIBRARY_PATH");
-
   // Add paths for the default clang library path.
   SmallString<256> DefaultLibPath =
   llvm::sys::path::parent_path(TC.getDriver().Dir);
@@ -607,37 +604,42 @@
   continue;
 }
 
-// Currently, we only pass the input files to the linker, we do not pass
-// any libraries that may be valid only for the host.
-if (!II.isFilename())
-  continue;
-
 // The 'nvlink' application performs RDC-mode linking when given a '.o'
 // file and device linking when given a '.cubin' file. We always want to
 // perform device linking, so just rename any '.o' files.
 // FIXME: This should hopefully be removed if NVIDIA updates their tooling.
-auto InputFile = getToolChain().getInputFilename(II);
-if (llvm::sys::path::extension(InputFile) != ".cubin") {
-  // If there are no actions above this one then this is direct input and 
we
-  // can copy it. Otherwise the input is internal so a `.cubin` file should
-  // exist.
-  if (II.getAction() && II.getAction()->getInputs().size() == 0) {
-const char *CubinF =
-Args.MakeArgString(getToolChain().getDriver().GetTemporaryPath(
-llvm::sys::path::stem(InputFile), "cubin"));
-if (std::error_code EC =
-llvm::sys::fs::copy_file(InputFile, C.addTempFile(CubinF)))
-  continue;
+if (II.isFilename()) {
+  auto InputFile = getToolChain().getInputFilename(II);
+  if (llvm::sys::path::extension(InputFile) != ".cubin") {
+// If there are no actions above this one then this is direct input and
+// we can copy it. Otherwise the input is internal so a `.cubin` file
+// should exist.
+if (II.getAction() && II.getAction()->getInputs().size() == 0) {
+  const char *CubinF =
+  Args.MakeArgString(getToolChain().getDriver().GetTemporaryPath(
+  llvm::sys::path::stem(InputFile), "cubin"));
+  if (std::error_code EC =
+  llvm::sys::fs::copy_file(InputFile, C.addTempFile(CubinF)))
+continue;
 
-CmdArgs.push_back(CubinF);
+  CmdArgs.push_back(CubinF);
+} else {
+  SmallString<256> Filename(InputFile);
+  llvm::sys::path::replace_extension(Filename, "cubin");
+  CmdArgs.push_back(Args.MakeArgString(Filename));
+}
   } else {
-SmallString<256> Filename(InputFile);
-llvm::sys::path::replace_extension(Filename, "cubin");
-CmdArgs.push_back(Args.MakeArgString(Filename));
+CmdArgs.push_back(Args.MakeArgString(InputFile));
   }
-} else {
-  CmdArgs.push_back(Args.MakeArgString(InputFile));
+  continue;
 }
+
+// In some error cases, the input could be Nothing; skip those.
+if (II.isNothing())
+  continue;
+
+// Render any remaining arguments as input to nvlink.
+II.getInputArg().renderAsInput(Args, CmdArgs);
   }
 
   C.addCommand(std::make_unique(


Index: clang/test/Driver/cuda-cross-compiling.c
===
--- 

[PATCH] D144999: [RFC][MC][MachO]Only emits compact-unwind format for "canonical" personality symbols. For the rest, use DWARFs.

2023-05-05 Thread Vy Nguyen via Phabricator via cfe-commits
oontvoo updated this revision to Diff 519939.
oontvoo added a comment.

addressed review comments:

- added explanation on why we left out _gcc personality
- updated more clang tests

hopefully should be all green now!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144999

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/femit-dwarf-unwind.c
  clang/test/Driver/femit-dwarf-unwind.s
  clang/tools/driver/cc1as_main.cpp
  lld/MachO/UnwindInfoSection.cpp
  lld/test/MachO/Inputs/eh-frame-x86_64-r.o
  lld/test/MachO/compact-unwind-both-local-and-dylib-personality.s
  lld/test/MachO/compact-unwind-generated.test
  lld/test/MachO/compact-unwind-lsda-folding.s
  lld/test/MachO/compact-unwind-stack-ind.s
  lld/test/MachO/compact-unwind.s
  lld/test/MachO/eh-frame-personality-dedup.s
  lld/test/MachO/eh-frame.s
  lld/test/MachO/icf-only-lsda-folded.s
  lld/test/MachO/icf.s
  lld/test/MachO/invalid/compact-unwind-bad-reloc.s
  lld/test/MachO/invalid/compact-unwind-personalities.s
  llvm/include/llvm/MC/MCAsmBackend.h
  llvm/include/llvm/MC/MCContext.h
  llvm/include/llvm/MC/MCTargetOptions.h
  llvm/include/llvm/MC/MCTargetOptionsCommandFlags.h
  llvm/lib/MC/MCAsmBackend.cpp
  llvm/lib/MC/MCContext.cpp
  llvm/lib/MC/MCStreamer.cpp
  llvm/lib/MC/MCTargetOptionsCommandFlags.cpp
  llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp
  llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
  llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackendDarwin.h
  llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
  llvm/test/CodeGen/X86/2014-08-29-CompactUnwind.ll
  llvm/test/CodeGen/X86/compact-unwind.ll
  llvm/test/MC/AArch64/arm64-leaf-compact-unwind.s
  llvm/test/MC/MachO/AArch64/emit-dwarf-unwind.s
  llvm/test/MC/MachO/ARM/compact-unwind-armv7k.s
  llvm/test/MC/X86/compact-unwind.s

Index: llvm/test/MC/X86/compact-unwind.s
===
--- llvm/test/MC/X86/compact-unwind.s
+++ llvm/test/MC/X86/compact-unwind.s
@@ -1,4 +1,4 @@
-# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin10.0 %s | llvm-objdump --unwind-info - | FileCheck %s
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin10.0 %s -emit-compact-unwind-non-canonical=true | llvm-objdump --unwind-info - | FileCheck %s
 
 	.section	__TEXT,__text,regular,pure_instructions
 	.macosx_version_min 10, 10
Index: llvm/test/MC/MachO/ARM/compact-unwind-armv7k.s
===
--- llvm/test/MC/MachO/ARM/compact-unwind-armv7k.s
+++ llvm/test/MC/MachO/ARM/compact-unwind-armv7k.s
@@ -1,4 +1,4 @@
-@ RUN: llvm-mc -triple=thumbv7k-apple-watchos2.0.0 -filetype=obj -o %t < %s && llvm-objdump --unwind-info %t | FileCheck %s
+@ RUN: llvm-mc -triple=thumbv7k-apple-watchos2.0.0 -emit-compact-unwind-non-canonical=true -filetype=obj -o %t < %s && llvm-objdump --unwind-info %t | FileCheck %s
 
 @ CHECK: Contents of __compact_unwind section:
 
Index: llvm/test/MC/MachO/AArch64/emit-dwarf-unwind.s
===
--- llvm/test/MC/MachO/AArch64/emit-dwarf-unwind.s
+++ llvm/test/MC/MachO/AArch64/emit-dwarf-unwind.s
@@ -1,11 +1,11 @@
 // RUN: rm -rf %t; mkdir %t
-// RUN: llvm-mc -triple x86_64-apple-macos11.0 %s -filetype=obj -o %t/x86_64.o
+// RUN: llvm-mc -triple x86_64-apple-macos11.0 %s -filetype=obj -o %t/x86_64.o -emit-compact-unwind-non-canonical=true
 // RUN: llvm-objdump --macho --dwarf=frames %t/x86_64.o | FileCheck %s --check-prefix TWO-FDES
-// RUN: llvm-mc -triple arm64-apple-macos11.0 %s -filetype=obj -o %t/arm64.o
+// RUN: llvm-mc -triple arm64-apple-macos11.0 %s -filetype=obj -o %t/arm64.o -emit-compact-unwind-non-canonical=true
 // RUN: llvm-objdump --macho --dwarf=frames %t/arm64.o | FileCheck %s --check-prefix ONE-FDE
-// RUN: llvm-mc -triple x86_64-apple-macos11.0 %s -filetype=obj --emit-dwarf-unwind no-compact-unwind -o %t/x86_64-no-dwarf.o
+// RUN: llvm-mc -triple x86_64-apple-macos11.0 %s -filetype=obj --emit-dwarf-unwind no-compact-unwind -o %t/x86_64-no-dwarf.o -emit-compact-unwind-non-canonical=true
 // RUN: llvm-objdump --macho --dwarf=frames %t/x86_64-no-dwarf.o | FileCheck %s --check-prefix ONE-FDE
-// RUN: llvm-mc -triple arm64-apple-macos11.0 %s -filetype=obj --emit-dwarf-unwind always -o %t/arm64-dwarf.o
+// RUN: llvm-mc -triple arm64-apple-macos11.0 %s -filetype=obj --emit-dwarf-unwind always -o %t/arm64-dwarf.o -emit-compact-unwind-non-canonical=true
 // RUN: llvm-objdump --macho --dwarf=frames %t/arm64-dwarf.o | FileCheck %s --check-prefix TWO-FDES
 
 // TWO-FDES: FDE
Index: llvm/test/MC/AArch64/arm64-leaf-compact-unwind.s
===
--- llvm/test/MC/AArch64/arm64-leaf-compact-unwind.s
+++ 

[PATCH] D149922: Fix nullptr dereference found by Coverity static analysis tool

2023-05-05 Thread Soumi Manna via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6e0c44174823: [NFC][CLANG] Fix nullptr dereference found by 
Coverity static analysis tool (authored by Manna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149922

Files:
  clang/lib/AST/ASTContext.cpp


Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -2859,10 +2859,8 @@
   if (Ty->isPointerType())
 return true;
 
-  if (Ty->isMemberPointerType()) {
-const auto *MPT = Ty->getAs();
+  if (const auto *MPT = Ty->getAs())
 return !ABI->getMemberPointerInfo(MPT).HasPadding;
-  }
 
   if (Ty->isRecordType()) {
 const RecordDecl *Record = Ty->castAs()->getDecl();


Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -2859,10 +2859,8 @@
   if (Ty->isPointerType())
 return true;
 
-  if (Ty->isMemberPointerType()) {
-const auto *MPT = Ty->getAs();
+  if (const auto *MPT = Ty->getAs())
 return !ABI->getMemberPointerInfo(MPT).HasPadding;
-  }
 
   if (Ty->isRecordType()) {
 const RecordDecl *Record = Ty->castAs()->getDecl();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 6e0c441 - [NFC][CLANG] Fix nullptr dereference found by Coverity static analysis tool

2023-05-05 Thread via cfe-commits

Author: Manna, Soumi
Date: 2023-05-05T11:57:33-07:00
New Revision: 6e0c44174823260fd74d14d036eaf1c64fa5eded

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

LOG: [NFC][CLANG] Fix nullptr dereference found by Coverity static analysis tool

Reported by Coverity:

  In clang::ASTContext::hasUniqueObjectRepresentations(clang::QualType, bool): 
Return value of function which returns null is dereferenced without checking.

  (Ty->isMemberPointerType()) {
//returned_null: getAs returns nullptr.
//var_assigned: Assigning: MPT = nullptr return value from getAs.
  const auto *MPT = Ty->getAs();

 //dereference: Dereferencing a pointer that might be nullptr MPT when 
calling getMemberPointerInfo. (The virtual call resolves to
 ::ItaniumCXXABI::getMemberPointerInfo.)
  return !ABI->getMemberPointerInfo(MPT).HasPadding;
}

ABIs assume the parameter passed to `getMemberPointerInfo` is non-null.
This patch checks type by doing a `if (const auto *MPT = 
Ty->getAs())` instead.

Reviewed By: erichkeane

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

Added: 


Modified: 
clang/lib/AST/ASTContext.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 3a72c3d25794..de65c3cc47b9 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -2859,10 +2859,8 @@ bool ASTContext::hasUniqueObjectRepresentations(
   if (Ty->isPointerType())
 return true;
 
-  if (Ty->isMemberPointerType()) {
-const auto *MPT = Ty->getAs();
+  if (const auto *MPT = Ty->getAs())
 return !ABI->getMemberPointerInfo(MPT).HasPadding;
-  }
 
   if (Ty->isRecordType()) {
 const RecordDecl *Record = Ty->castAs()->getDecl();



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


[PATCH] D146030: [clang][Interp] Handle LambdaExprs

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



Comment at: clang/lib/AST/Interp/ByteCodeEmitter.cpp:56-57
+  const Record *R = P.getOrCreateRecord(MD->getParent());
+  llvm::DenseMap _LambdaCaptures;
+  FieldDecl *_LambdaThisCapture;
+

UB alert -- `_L` is reserved; let's pick names without leading underscores or 
shadowing.



Comment at: clang/lib/AST/Interp/ByteCodeEmitter.h:73-74
   llvm::DenseMap Params;
+  /// Lambda captures.
+  llvm::DenseMap> LambdaCaptures;
+  unsigned *LambdaThisCapture;

Can you add comments explaining what the `unsigned, bool` pair is encoding?



Comment at: clang/lib/AST/Interp/ByteCodeEmitter.h:75
+  llvm::DenseMap> LambdaCaptures;
+  unsigned *LambdaThisCapture;
   /// Local descriptors.

Why is this a pointer? Since it's not really implemented, I'd recommend 
removing this for now and adding it back when you add support for capturing 
`this`.



Comment at: clang/test/AST/Interp/lambda.cpp:92
+  static_assert(foo() == 1); // expected-error {{not an integral constant 
expression}}
+}
+

How about some tests like:
```
constexpr int call_thru_func_ptr(int i) {
  auto l = [](int i) { return i; };
  int (*fp)(int) = l;
  return fp(i);  
}
static_assert(call_thru_func_ptr(12) == 12);

constexpr int call_through_copied_lambda(auto lam, int i) {
  auto copy = lam;
  return copy(i);
}

constexpr int call_through_copied_lambda(auto lam) {
  auto copy = lam;
  return copy();
}

void func() {
  constexpr int i = 12;
  static_assert(call_through_copied_lambda([i]() { return i; }) == 12);
}
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146030

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

This patch appears to *include* the changes in D144911 
 (e.g. 
llvm/test/CodeGen/NVPTX/bf16-instructions.ll is added by both patches). Can you 
update it as an incremental patch that actually excludes it?


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] D142991: [clang-tidy] Add --fix-mode and --nolint-prefix options

2023-05-05 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added inline comments.
Herald added a subscriber: PiotrZSL.



Comment at: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp:58
+  (Lexer::getIndentationForLine(Loc, Loc.getManager()) + "/* " +
+   NoLintPrefix + "NOLINTNEXTLINE(" + Error.DiagnosticName + ") */\n")
+  .str());

Note that if the NOLINT is being inserted into a macro definition, we also need 
a backslash before the newline.



Comment at: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h:245
+/// Controls how clang-tidy applies fixes.
+enum FixType {
+  /// Only apply fix-its.

Generally in Clang and adjacent projects we reserve the word "Type" to refer to 
C++ types. For other uses, we use a synonym - like "Kind" or "Mode".

I think "FixMode" will work well here, WDYT?



Comment at: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h:251
+  /// Add NOLINT if fix-it is not available.
+  FT_FixItOrNoLint
+};

I think it would be better to use an enum class and avoid prefixing.

(There are a lot of plain enums in Clang because Clang was originally developed 
in C++03.)



Comment at: 
clang-tools-extra/test/clang-tidy/infrastructure/fix-mode-nolint.cpp:2
+// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
+// RUN: clang-tidy %t.cpp 
-checks='-*,modernize-use-trailing-return-type,readability-identifier-length' 
-fix -fix-mode=nolint -nolint-prefix='FIXME: ' -export-fixes=%t.yaml -- > 
%t.msg 2>&1
+// RUN: FileCheck -input-file=%t.cpp %s

Could you add a second clang-tidy invocation over the fixed file to show that 
no warnings are produced? That would prove that the comments are inserted in 
the right place.

(here and in the other test)



Comment at: 
clang-tools-extra/test/clang-tidy/infrastructure/fix-mode-nolint.cpp:7
+
+// CHECK: /* FIXME: NOLINTNEXTLINE(modernize-use-trailing-return-type) */
+// CHECK-NEXT: int func() {

WDYT about making the comment style configurable? I think many people working 
in C++ will prefer //-style comments.





Comment at: 
clang-tools-extra/test/clang-tidy/infrastructure/fix-mode-nolint.cpp:18
+  return i;
+}

Could you add more tests, specifically tests with macros?

- A test where the problem is reported in the macro expansion, the warning is 
attached to the macro definition.

- A test where the problem is reported in the macro expansion, but the warning 
is attached to the tokens in the macro argument.

The SourceLocation computations are quite subtle with macros so these cases are 
worth covering.

Note that when inserting NOLINTs into a macro definition, one has to use `/* 
*/`-style comments.


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

https://reviews.llvm.org/D142991

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


[PATCH] D149579: [X86][MC] Fix parsing Intel syntax indirect branch with symbol only

2023-05-05 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: llvm/test/MC/X86/intel-syntax-branch.s:61-67
+  // FIXME: MASM does not accept this syntax and GAS assembles this as a direct
+  //call/jump instead of indirect. Consider making this syntax an 
error?
+  call [offset fn_ref]
+  jmp [offset fn_ref]
+  // CHECK-32-LABEL: t7:
+  // CHECK-32: calll *fn_ref
+  // CHECK-32: jmpl *fn_ref

alvinhochun wrote:
> About the `call [offset fn_ref]` case, do you think we should reject it since 
> MASM does not accept this syntax and GAS appears to behave oddly with it? The 
> `ms-inline-asm-functions.c` test does generate `call [offset _kptr]` so this 
> will also need to be changed.
Yes, I think we should reject `call [offset fn_ref]`. Confirmed with a MinGW 
dev (lh_mouse) that this is invalid.



Comment at: llvm/test/MC/X86/intel-syntax-branch.s:48
+  call dword ptr fn_ref
+  jmp dword ptr fn_ref
+  // CHECK-32-LABEL: t5:

alvinhochun wrote:
> MaskRay wrote:
> > ICC and MSVC parse this differently.
> > 
> > Is this syntax valid?
> MASM ml.exe assembles this as `jmp dword ptr [fn_ref]` in my test, so does 
> GAS. I don't know how valid this syntax is though.
LG. cl.exe compiles `void (*kptr)(); ... __asm call kptr;` to `callDWORD 
PTR _kptr`, so it seems that the bracket can be omitted.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149579

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


[PATCH] D147591: [clang][Interp] Handle CXXTemporaryObjectExprs

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



Comment at: clang/test/AST/Interp/records.cpp:317-318
 {
-  auto T = Test(Arr, Pos);
+  Test(Arr, Pos);
   // End of scope, should destroy Test.
 }

Nit: nothing actually tests that this object is destroyed correctly. Here's an 
interesting test to consider:
```
struct S {
  constexpr S() {}
  constexpr ~S() noexcept(false) { throw 12; }
};

constexpr int f() {
  S{};
  return 12;
}

static_assert(f() == 12);
```
That should fail because `~S()` would hit the `throw` expression and thus is 
not valid. Note, you'll need to add `-Wno-invalid-constexpr` to your test to 
avoid the warning-defaults-to-error about the destructor never producing a 
constant expression.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147591

___
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-05 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/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.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.cpp
  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 

[PATCH] D144999: [RFC][MC][MachO]Only emits compact-unwind format for "canonical" personality symbols. For the rest, use DWARFs.

2023-05-05 Thread Vy Nguyen via Phabricator via cfe-commits
oontvoo marked an inline comment as done.
oontvoo added a comment.

In D144999#4319964 , @jyknight wrote:

> I wonder if we actually need to define a clang frontend flag for this; I 
> suspect nobody will ever want to specify it, since the only non-canonical 
> personality clang will ever generate that changes behavior is the pure-C 
> destructor-only personality, `__gnu_personality_v0`. Otherwise, it could only 
> arise from assembly or IR.
>
> For a test-case, can just use `-mllvm -emit-compact-unwind-non-canonical`.

Per offline discussion, passing it via `-mllvm` doesn't work because  
llvm-flags that populate MCTargetOptions flags aren't registered in Clang, so 
it needs to be at least a clang cc1 option.




Comment at: lld/MachO/UnwindInfoSection.cpp:364
   cu.encoding = target->modeDwarfEncoding | d->unwindEntry->outSecOff;
-  const FDE  = cast(d->getFile())->fdes[d->unwindEntry];
   cu.functionLength = fde.funcLength;

int3 wrote:
> seems like this was accidentally deleted?
yes - good catch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144999

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


[PATCH] D149846: [clang][Interp] Check inc/dec family of ops for initialization

2023-05-05 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!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149846

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


[PATCH] D149723: [clang-tidy] Optimize performance of RenamerClangTidyCheck

2023-05-05 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL updated this revision to Diff 519924.
PiotrZSL marked 3 inline comments as done.
PiotrZSL added a comment.

Use operator  + instead of hash_combine.
Use TraverseAST.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149723

Files:
  clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
  clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h

Index: clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h
===
--- clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h
+++ clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h
@@ -102,24 +102,26 @@
 NamingCheckFailure() = default;
   };
 
-  using NamingCheckId = std::pair;
+  using NamingCheckId = std::pair;
 
   using NamingCheckFailureMap =
   llvm::DenseMap;
 
   /// Check Macros for style violations.
-  void checkMacro(SourceManager , const Token ,
+  void checkMacro(const SourceManager , const Token ,
   const MacroInfo *MI);
 
   /// Add a usage of a macro if it already has a violation.
   void expandMacro(const Token , const MacroInfo *MI);
 
   void addUsage(const RenamerClangTidyCheck::NamingCheckId ,
-SourceRange Range, SourceManager *SourceMgr = nullptr);
+SourceRange Range, const SourceManager *SourceMgr = nullptr);
 
   /// Convenience method when the usage to be added is a NamedDecl.
   void addUsage(const NamedDecl *Decl, SourceRange Range,
-SourceManager *SourceMgr = nullptr);
+const SourceManager *SourceMgr = nullptr);
+
+  void checkNamedDecl(const NamedDecl *Decl, const SourceManager );
 
 protected:
   /// Overridden by derived classes, returns information about if and how a Decl
Index: clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
===
--- clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
+++ clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
@@ -9,6 +9,7 @@
 #include "RenamerClangTidyCheck.h"
 #include "ASTUtils.h"
 #include "clang/AST/CXXInheritance.h"
+#include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Basic/CharInfo.h"
 #include "clang/Frontend/CompilerInstance.h"
@@ -43,9 +44,8 @@
 assert(Val != getEmptyKey() && "Cannot hash the empty key!");
 assert(Val != getTombstoneKey() && "Cannot hash the tombstone key!");
 
-std::hash SecondHash;
 return DenseMapInfo::getHashValue(Val.first) +
-   SecondHash(Val.second);
+   DenseMapInfo::getHashValue(Val.second);
   }
 
   static bool isEqual(const NamingCheckId , const NamingCheckId ) {
@@ -61,153 +61,6 @@
 
 namespace clang::tidy {
 
-namespace {
-
-/// Callback supplies macros to RenamerClangTidyCheck::checkMacro
-class RenamerClangTidyCheckPPCallbacks : public PPCallbacks {
-public:
-  RenamerClangTidyCheckPPCallbacks(Preprocessor *PP,
-   RenamerClangTidyCheck *Check)
-  : PP(PP), Check(Check) {}
-
-  /// MacroDefined calls checkMacro for macros in the main file
-  void MacroDefined(const Token ,
-const MacroDirective *MD) override {
-if (MD->getMacroInfo()->isBuiltinMacro())
-  return;
-if (PP->getSourceManager().isWrittenInBuiltinFile(
-MacroNameTok.getLocation()))
-  return;
-if (PP->getSourceManager().isWrittenInCommandLineFile(
-MacroNameTok.getLocation()))
-  return;
-Check->checkMacro(PP->getSourceManager(), MacroNameTok, MD->getMacroInfo());
-  }
-
-  /// MacroExpands calls expandMacro for macros in the main file
-  void MacroExpands(const Token , const MacroDefinition ,
-SourceRange /*Range*/,
-const MacroArgs * /*Args*/) override {
-Check->expandMacro(MacroNameTok, MD.getMacroInfo());
-  }
-
-private:
-  Preprocessor *PP;
-  RenamerClangTidyCheck *Check;
-};
-
-} // namespace
-
-RenamerClangTidyCheck::RenamerClangTidyCheck(StringRef CheckName,
- ClangTidyContext *Context)
-: ClangTidyCheck(CheckName, Context),
-  AggressiveDependentMemberLookup(
-  Options.getLocalOrGlobal("AggressiveDependentMemberLookup", false)) {}
-RenamerClangTidyCheck::~RenamerClangTidyCheck() = default;
-
-void RenamerClangTidyCheck::storeOptions(ClangTidyOptions::OptionMap ) {
-  Options.store(Opts, "AggressiveDependentMemberLookup",
-AggressiveDependentMemberLookup);
-}
-
-void RenamerClangTidyCheck::registerMatchers(MatchFinder *Finder) {
-  Finder->addMatcher(namedDecl().bind("decl"), this);
-  Finder->addMatcher(usingDecl().bind("using"), this);
-  Finder->addMatcher(declRefExpr().bind("declRef"), this);
-  Finder->addMatcher(cxxConstructorDecl(unless(isImplicit())).bind("classRef"),
- this);
-  

[PATCH] D149723: [clang-tidy] Optimize performance of RenamerClangTidyCheck

2023-05-05 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL marked 3 inline comments as done.
PiotrZSL added inline comments.



Comment at: clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp:47
 
-std::hash SecondHash;
-return DenseMapInfo::getHashValue(Val.first) +
-   SecondHash(Val.second);
+return hash_combine(
+DenseMapInfo::getHashValue(Val.first),

njames93 wrote:
> What's the purpose of using hash_combine instead of just adding the 2 hashes 
> together, there is enough entropy in the hashes that a simple operation makes 
> more sense?
Habit, hash_combine sounded better here, I can change this to +.



Comment at: clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp:201
 
-addUsage(Decl->getParent(), Decl->getNameInfo().getSourceRange(),
- Result.SourceManager);
+  bool shouldVisitTemplateInstantiations() const { return true; }
+

njames93 wrote:
> What is the reason for visiting template instantiations?
Tests were failing, some method overrides are known only when we visit template 
instances. Without this code related to "Fix overridden methods"  (line 281) 
were not executed properly.
And as an result overridden virtual methods in template classes were not 
"fixed". Previously it worked in same way.



Comment at: clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp:495
+  AggressiveDependentMemberLookup);
+  Visitor.TraverseDecl(const_cast(Decl));
 }

njames93 wrote:
> Instead of this nasty const cast, you can just use 
> `Visitor.TraverseAST(*Result.Context);`
Yes I know, but it looked strange when we register matcher for something, and 
then in check we don't use that something.
I can change this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149723

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


[PATCH] D149518: [clang] Optimize clang::ASTNodeKind::isBaseOf

2023-05-05 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.

Oh wow, I'm surprised that calculating the distance has that much compile time 
impact. Great catch! Please add `NFC` to the commit summary so folks know why 
there are no tests.

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149518

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


[PATCH] D149497: [RISCV] Add scheduling information for Zba and Zbb to RISCVSchedSiFive7.td

2023-05-05 Thread Michael Maitland 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 rGf9fa8a599704: [RISCV] Add scheduling information for Zba and 
Zbb to RISCVSchedSiFive7.td (authored by michaelmaitland).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149497

Files:
  llvm/lib/Target/RISCV/RISCVSchedSiFive7.td


Index: llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
===
--- llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
+++ llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
@@ -76,6 +76,35 @@
   let ResourceCycles = [1, 15];
 }
 
+// Bitmanip
+let Latency = 3 in {
+// Rotates are in the late-B ALU.
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+
+// clz[w]/ctz[w] are in the late-B ALU.
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+
+// cpop[w] look exactly like multiply.
+def : WriteRes;
+def : WriteRes;
+
+// orc.b is in the late-B ALU.
+def : WriteRes;
+
+// rev8 is in the late-A and late-B ALUs.
+def : WriteRes;
+
+// shNadd[.uw] is on the early-B and late-B ALUs.
+def : WriteRes;
+def : WriteRes;
+}
+
 // Memory
 def : WriteRes;
 def : WriteRes;
@@ -279,11 +308,25 @@
 
 def : ReadAdvance;
 
+// Bitmanip
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+
 
//===--===//
 // Unsupported extensions
 defm : UnsupportedSchedV;
-defm : UnsupportedSchedZba;
-defm : UnsupportedSchedZbb;
 defm : UnsupportedSchedZbc;
 defm : UnsupportedSchedZbs;
 defm : UnsupportedSchedZbkb;


Index: llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
===
--- llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
+++ llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
@@ -76,6 +76,35 @@
   let ResourceCycles = [1, 15];
 }
 
+// Bitmanip
+let Latency = 3 in {
+// Rotates are in the late-B ALU.
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+
+// clz[w]/ctz[w] are in the late-B ALU.
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+
+// cpop[w] look exactly like multiply.
+def : WriteRes;
+def : WriteRes;
+
+// orc.b is in the late-B ALU.
+def : WriteRes;
+
+// rev8 is in the late-A and late-B ALUs.
+def : WriteRes;
+
+// shNadd[.uw] is on the early-B and late-B ALUs.
+def : WriteRes;
+def : WriteRes;
+}
+
 // Memory
 def : WriteRes;
 def : WriteRes;
@@ -279,11 +308,25 @@
 
 def : ReadAdvance;
 
+// Bitmanip
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+
 //===--===//
 // Unsupported extensions
 defm : UnsupportedSchedV;
-defm : UnsupportedSchedZba;
-defm : UnsupportedSchedZbb;
 defm : UnsupportedSchedZbc;
 defm : UnsupportedSchedZbs;
 defm : UnsupportedSchedZbkb;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D149497: [RISCV] Add scheduling information for Zba and Zbb to RISCVSchedSiFive7.td

2023-05-05 Thread Michael Maitland via Phabricator via cfe-commits
michaelmaitland updated this revision to Diff 519921.
michaelmaitland added a comment.

Rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149497

Files:
  llvm/lib/Target/RISCV/RISCVSchedSiFive7.td


Index: llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
===
--- llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
+++ llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
@@ -76,6 +76,35 @@
   let ResourceCycles = [1, 15];
 }
 
+// Bitmanip
+let Latency = 3 in {
+// Rotates are in the late-B ALU.
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+
+// clz[w]/ctz[w] are in the late-B ALU.
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+
+// cpop[w] look exactly like multiply.
+def : WriteRes;
+def : WriteRes;
+
+// orc.b is in the late-B ALU.
+def : WriteRes;
+
+// rev8 is in the late-A and late-B ALUs.
+def : WriteRes;
+
+// shNadd[.uw] is on the early-B and late-B ALUs.
+def : WriteRes;
+def : WriteRes;
+}
+
 // Memory
 def : WriteRes;
 def : WriteRes;
@@ -279,11 +308,25 @@
 
 def : ReadAdvance;
 
+// Bitmanip
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+
 
//===--===//
 // Unsupported extensions
 defm : UnsupportedSchedV;
-defm : UnsupportedSchedZba;
-defm : UnsupportedSchedZbb;
 defm : UnsupportedSchedZbc;
 defm : UnsupportedSchedZbs;
 defm : UnsupportedSchedZbkb;


Index: llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
===
--- llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
+++ llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
@@ -76,6 +76,35 @@
   let ResourceCycles = [1, 15];
 }
 
+// Bitmanip
+let Latency = 3 in {
+// Rotates are in the late-B ALU.
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+
+// clz[w]/ctz[w] are in the late-B ALU.
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+
+// cpop[w] look exactly like multiply.
+def : WriteRes;
+def : WriteRes;
+
+// orc.b is in the late-B ALU.
+def : WriteRes;
+
+// rev8 is in the late-A and late-B ALUs.
+def : WriteRes;
+
+// shNadd[.uw] is on the early-B and late-B ALUs.
+def : WriteRes;
+def : WriteRes;
+}
+
 // Memory
 def : WriteRes;
 def : WriteRes;
@@ -279,11 +308,25 @@
 
 def : ReadAdvance;
 
+// Bitmanip
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+
 //===--===//
 // Unsupported extensions
 defm : UnsupportedSchedV;
-defm : UnsupportedSchedZba;
-defm : UnsupportedSchedZbb;
 defm : UnsupportedSchedZbc;
 defm : UnsupportedSchedZbs;
 defm : UnsupportedSchedZbkb;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D149497: [RISCV] Add scheduling information for Zba and Zbb to RISCVSchedSiFive7.td

2023-05-05 Thread Michael Maitland via Phabricator via cfe-commits
michaelmaitland added a comment.

This revision needs to be reopened because it was committed with changes that 
are not relevant to this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149497

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


[PATCH] D149514: Check if First argument in _builtin_assume_aligned_ is of pointer type

2023-05-05 Thread Aaron Ballman via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0b3d73787704: Check if First argument in 
_builtin_assume_aligned_ is of pointer type (authored by Ris-Bali, committed by 
aaron.ballman).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149514

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/builtin-assume-aligned.c


Index: clang/test/Sema/builtin-assume-aligned.c
===
--- clang/test/Sema/builtin-assume-aligned.c
+++ clang/test/Sema/builtin-assume-aligned.c
@@ -71,6 +71,25 @@
   return a[0];
 }
 
+int test14(int *a, int b) {
+  a = (int *)__builtin_assume_aligned(b, 32); // expected-error {{incompatible 
integer to pointer conversion passing 'int' to parameter of type 'const void *}}
+}
+
+int test15(int *b) {
+  int arr[3] = {1, 2, 3};
+  b = (int *)__builtin_assume_aligned(arr, 32);
+  return b[0];
+}
+
+int val(int x) {
+  return x;
+}
+
+int test16(int *b) {
+  b = (int *)__builtin_assume_aligned(val, 32);
+  return b[0];
+}
+
 void test_void_assume_aligned(void) __attribute__((assume_aligned(32))); // 
expected-warning {{'assume_aligned' attribute only applies to return values 
that are pointers}}
 int test_int_assume_aligned(void) __attribute__((assume_aligned(16))); // 
expected-warning {{'assume_aligned' attribute only applies to return values 
that are pointers}}
 void *test_ptr_assume_aligned(void) __attribute__((assume_aligned(64))); // 
no-warning
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -8100,8 +8100,9 @@
   {
 ExprResult FirstArgResult =
 DefaultFunctionArrayLvalueConversion(FirstArg);
-if (FirstArgResult.isInvalid())
+if (checkBuiltinArgument(*this, TheCall, 0))
   return true;
+/// In-place updation of FirstArg by checkBuiltinArgument is ignored.
 TheCall->setArg(0, FirstArgResult.get());
   }
 
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -2829,8 +2829,6 @@
   case Builtin::BI__builtin_assume_aligned: {
 const Expr *Ptr = E->getArg(0);
 Value *PtrValue = EmitScalarExpr(Ptr);
-if (PtrValue->getType() != VoidPtrTy)
-  PtrValue = EmitCastToVoidPtr(PtrValue);
 Value *OffsetValue =
   (E->getNumArgs() > 2) ? EmitScalarExpr(E->getArg(2)) : nullptr;
 
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -368,6 +368,9 @@
   (`#62207 `_)
 - Fix lambdas and other anonymous function names not respecting 
``-fdebug-prefix-map``
   (`#62192 `_)
+- Fix crash when attempting to pass a non-pointer type as first argument of
+  ``__builtin_assume_aligned``.
+  (`#62305 `_) 
 
 Bug Fixes to Compiler Builtins
 ^^


Index: clang/test/Sema/builtin-assume-aligned.c
===
--- clang/test/Sema/builtin-assume-aligned.c
+++ clang/test/Sema/builtin-assume-aligned.c
@@ -71,6 +71,25 @@
   return a[0];
 }
 
+int test14(int *a, int b) {
+  a = (int *)__builtin_assume_aligned(b, 32); // expected-error {{incompatible integer to pointer conversion passing 'int' to parameter of type 'const void *}}
+}
+
+int test15(int *b) {
+  int arr[3] = {1, 2, 3};
+  b = (int *)__builtin_assume_aligned(arr, 32);
+  return b[0];
+}
+
+int val(int x) {
+  return x;
+}
+
+int test16(int *b) {
+  b = (int *)__builtin_assume_aligned(val, 32);
+  return b[0];
+}
+
 void test_void_assume_aligned(void) __attribute__((assume_aligned(32))); // expected-warning {{'assume_aligned' attribute only applies to return values that are pointers}}
 int test_int_assume_aligned(void) __attribute__((assume_aligned(16))); // expected-warning {{'assume_aligned' attribute only applies to return values that are pointers}}
 void *test_ptr_assume_aligned(void) __attribute__((assume_aligned(64))); // no-warning
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -8100,8 +8100,9 @@
   {
 ExprResult FirstArgResult =
 DefaultFunctionArrayLvalueConversion(FirstArg);
-if (FirstArgResult.isInvalid())
+if (checkBuiltinArgument(*this, TheCall, 0))
   return true;
+/// In-place updation of FirstArg by checkBuiltinArgument is ignored.
 TheCall->setArg(0, 

[clang] 0b3d737 - Check if First argument in _builtin_assume_aligned_ is of pointer type

2023-05-05 Thread Aaron Ballman via cfe-commits

Author: Rishabh Bali
Date: 2023-05-05T13:11:16-04:00
New Revision: 0b3d737877040a4eae03e47223f9a9ddfd7bd182

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

LOG: Check if First argument in _builtin_assume_aligned_ is of pointer type

Currently clang doesn't verify if the first argument in
`_builtin_assume_aligned` is of pointer type. This leads to an
assertion build failure. This patch aims to add a check if the first
argument is of pointer type or not and diagnose it with
diag::err_typecheck_convert_incompatible if its not of pointer type.

Fixes https://github.com/llvm/llvm-project/issues/62305
Differential Revision: https://reviews.llvm.org/D149514

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/Sema/SemaChecking.cpp
clang/test/Sema/builtin-assume-aligned.c

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index a41917a5ed66a..910a853eafc81 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -368,6 +368,9 @@ Bug Fixes in This Version
   (`#62207 `_)
 - Fix lambdas and other anonymous function names not respecting 
``-fdebug-prefix-map``
   (`#62192 `_)
+- Fix crash when attempting to pass a non-pointer type as first argument of
+  ``__builtin_assume_aligned``.
+  (`#62305 `_) 
 
 Bug Fixes to Compiler Builtins
 ^^

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 5952ac4ff5ac4..03d6574ef3bcf 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -2829,8 +2829,6 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
   case Builtin::BI__builtin_assume_aligned: {
 const Expr *Ptr = E->getArg(0);
 Value *PtrValue = EmitScalarExpr(Ptr);
-if (PtrValue->getType() != VoidPtrTy)
-  PtrValue = EmitCastToVoidPtr(PtrValue);
 Value *OffsetValue =
   (E->getNumArgs() > 2) ? EmitScalarExpr(E->getArg(2)) : nullptr;
 

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 63c5b25b27262..a759cf30eeafd 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -8100,8 +8100,9 @@ bool Sema::SemaBuiltinAssumeAligned(CallExpr *TheCall) {
   {
 ExprResult FirstArgResult =
 DefaultFunctionArrayLvalueConversion(FirstArg);
-if (FirstArgResult.isInvalid())
+if (checkBuiltinArgument(*this, TheCall, 0))
   return true;
+/// In-place updation of FirstArg by checkBuiltinArgument is ignored.
 TheCall->setArg(0, FirstArgResult.get());
   }
 

diff  --git a/clang/test/Sema/builtin-assume-aligned.c 
b/clang/test/Sema/builtin-assume-aligned.c
index a5dd7e387181e..c2e4f9d659dd4 100644
--- a/clang/test/Sema/builtin-assume-aligned.c
+++ b/clang/test/Sema/builtin-assume-aligned.c
@@ -71,6 +71,25 @@ int test13(int *a) {
   return a[0];
 }
 
+int test14(int *a, int b) {
+  a = (int *)__builtin_assume_aligned(b, 32); // expected-error {{incompatible 
integer to pointer conversion passing 'int' to parameter of type 'const void *}}
+}
+
+int test15(int *b) {
+  int arr[3] = {1, 2, 3};
+  b = (int *)__builtin_assume_aligned(arr, 32);
+  return b[0];
+}
+
+int val(int x) {
+  return x;
+}
+
+int test16(int *b) {
+  b = (int *)__builtin_assume_aligned(val, 32);
+  return b[0];
+}
+
 void test_void_assume_aligned(void) __attribute__((assume_aligned(32))); // 
expected-warning {{'assume_aligned' attribute only applies to return values 
that are pointers}}
 int test_int_assume_aligned(void) __attribute__((assume_aligned(16))); // 
expected-warning {{'assume_aligned' attribute only applies to return values 
that are pointers}}
 void *test_ptr_assume_aligned(void) __attribute__((assume_aligned(64))); // 
no-warning



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


[PATCH] D149596: [AIX][TLS] Relax front end diagnostics to accept the local-exec TLS model

2023-05-05 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!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149596

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


[PATCH] D149514: Check if First argument in _builtin_assume_aligned_ is of pointer type

2023-05-05 Thread Rishabh Bali via Phabricator via cfe-commits
Ris-Bali added a comment.

Name : Rishabh Bali
Github Username : Ris-Bali
email-id : rishabhsb...@gmail.com


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

https://reviews.llvm.org/D149514

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


[PATCH] D149514: Check if First argument in _builtin_assume_aligned_ is of pointer type

2023-05-05 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, thank you! Do you need someone to commit on your behalf? If so, what name 
and email address would you like used for patch attribution?


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

https://reviews.llvm.org/D149514

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


[clang] 8394694 - [RISCV] Add sifive-x280 processor with all of its extensions

2023-05-05 Thread Michael Maitland via cfe-commits

Author: Michael Maitland
Date: 2023-05-05T10:02:28-07:00
New Revision: 839469436afcbdf5bb6dc9b081b1bcf3a1b22fea

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

LOG: [RISCV] Add sifive-x280 processor with all of its extensions

Add sifive-x280 processor that uses the SiFive7 scheduler model.

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

Added: 


Modified: 
clang/test/Driver/riscv-cpus.c
clang/test/Misc/target-invalid-cpu-note.c
llvm/docs/ReleaseNotes.rst
llvm/lib/Target/RISCV/RISCVProcessors.td

Removed: 




diff  --git a/clang/test/Driver/riscv-cpus.c b/clang/test/Driver/riscv-cpus.c
index 76325311668d8..a484b07ce330a 100644
--- a/clang/test/Driver/riscv-cpus.c
+++ b/clang/test/Driver/riscv-cpus.c
@@ -167,6 +167,20 @@
 // MTUNE-E31-MCPU-E76-SAME: "-target-feature" "+zicsr" "-target-feature" 
"+zifencei"
 // MTUNE-E31-MCPU-E76-SAME: "-tune-cpu" "sifive-e76"
 
+// mcpu with default march include experimental extensions
+// RUN: %clang -target riscv64 -### -c %s 2>&1 
-menable-experimental-extensions -mcpu=sifive-x280 | FileCheck 
-check-prefix=MCPU-SIFIVE-X280 %s
+// MCPU-SIFIVE-X280: "-nostdsysteminc" "-target-cpu" "sifive-x280"
+// MCPU-SIFIVE-X280-SAME: "-target-feature" "+m" "-target-feature" "+a" 
"-target-feature" "+f" "-target-feature" "+d"
+// MCPU-SIFIVE-X280-SAME: "-target-feature" "+c" "-target-feature" "+v"
+// MCPU-SIFIVE-X280-SAME: "-target-feature" "+zicsr" "-target-feature" 
"+zifencei"
+// MCPU-SIFIVE-X280-SAME: "-target-feature" "+zfh"
+// MCPU-SIFIVE-X280-SAME: "-target-feature" "+zba" "-target-feature" "+zbb"
+// MCPU-SIFIVE-X280-SAME: "-target-feature" "+experimental-zvfh"
+// MCPU-SIFIVE-X280-SAME: "-target-feature" "+zvl128b"
+// MCPU-SIFIVE-X280-SAME: "-target-feature" "+zvl256b" "-target-feature" 
"+zvl32b"
+// MCPU-SIFIVE-X280-SAME: "-target-feature" "+zvl512b" "-target-feature" 
"+zvl64b"
+// MCPU-SIFIVE-X280-SAME: "-target-abi" "lp64d"
+
 // Check failed cases
 
 // RUN: %clang --target=riscv32 -### -c %s 2>&1 -mcpu=generic-rv321 | 
FileCheck -check-prefix=FAIL-MCPU-NAME %s

diff  --git a/clang/test/Misc/target-invalid-cpu-note.c 
b/clang/test/Misc/target-invalid-cpu-note.c
index 1f205163a966e..ddc639dc60a80 100644
--- a/clang/test/Misc/target-invalid-cpu-note.c
+++ b/clang/test/Misc/target-invalid-cpu-note.c
@@ -85,7 +85,7 @@
 
 // RUN: not %clang_cc1 -triple riscv64 -target-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix RISCV64
 // RISCV64: error: unknown target CPU 'not-a-cpu'
-// RISCV64-NEXT: note: valid target CPU values are: generic-rv64, rocket-rv64, 
sifive-s21, sifive-s51, sifive-s54, sifive-s76, sifive-u54, sifive-u74{{$}}
+// RISCV64-NEXT: note: valid target CPU values are: generic-rv64, rocket-rv64, 
sifive-s21, sifive-s51, sifive-s54, sifive-s76, sifive-u54, sifive-u74, 
sifive-x280{{$}}
 
 // RUN: not %clang_cc1 -triple riscv32 -tune-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix TUNE-RISCV32
 // TUNE-RISCV32: error: unknown target CPU 'not-a-cpu'
@@ -93,4 +93,4 @@
 
 // RUN: not %clang_cc1 -triple riscv64 -tune-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix TUNE-RISCV64
 // TUNE-RISCV64: error: unknown target CPU 'not-a-cpu'
-// TUNE-RISCV64-NEXT: note: valid target CPU values are: generic-rv64, 
rocket-rv64, sifive-s21, sifive-s51, sifive-s54, sifive-s76, sifive-u54, 
sifive-u74, generic, rocket, sifive-7-series{{$}}
+// TUNE-RISCV64-NEXT: note: valid target CPU values are: generic-rv64, 
rocket-rv64, sifive-s21, sifive-s51, sifive-s54, sifive-s76, sifive-u54, 
sifive-u74, sifive-x280, generic, rocket, sifive-7-series{{$}}

diff  --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst
index c764a50f88b22..845cee9e75455 100644
--- a/llvm/docs/ReleaseNotes.rst
+++ b/llvm/docs/ReleaseNotes.rst
@@ -175,6 +175,7 @@ Changes to the RISC-V Backend
   ``RISCV::parseCPU``. The ``CPUKind`` enum is no longer part of the
   RISCVTargetParser.h interface. Similar for ``parseTuneCPUkind`` and
   ``checkTuneCPUKind``.
+* Add sifive-x280 processor.
 
 Changes to the WebAssembly Backend
 --

diff  --git a/llvm/lib/Target/RISCV/RISCVProcessors.td 
b/llvm/lib/Target/RISCV/RISCVProcessors.td
index 67b0364aa2fd7..69edacc4058c1 100644
--- a/llvm/lib/Target/RISCV/RISCVProcessors.td
+++ b/llvm/lib/Target/RISCV/RISCVProcessors.td
@@ -166,6 +166,22 @@ def SIFIVE_U74 : RISCVProcessorModel<"sifive-u74",
   FeatureStdExtC],
  [TuneSiFive7]>;
 
+def SIFIVE_X280 : RISCVProcessorModel<"sifive-x280", SiFive7Model,
+  [Feature64Bit,
+   FeatureStdExtZifencei,
+   

[PATCH] D149867: [M68k] Add Clang support for the new M68k_RTD CC

2023-05-05 Thread Min-Yih Hsu via Phabricator via cfe-commits
myhsu added inline comments.



Comment at: clang/test/CodeGen/mrtd.c:9
+// X86: define{{.*}} x86_stdcallcc void @foo(i32 noundef %arg) [[NUW:#[0-9]+]]
+// M68k: define{{.*}} cc104 void @foo(i32 noundef %arg)
 void foo(int arg) {

0x59616e wrote:
> 0x59616e wrote:
> > Just curious, why do we have to use such an arcane name instead of a more 
> > lucid one , such as `m68k_rtdcc`.
> I guess this involves more work ?
> I guess this involves more work ?

Yes because it requires changes to (LLVM IR's) AsmReader/Writer. But it's not 
hard and I can do that. The reason I didn't do that was simply because this CC 
is rare so the arcane name's impact on (our) productivity will be low.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149867

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


[PATCH] D148689: [clang][Interp] Handle PredefinedExprs

2023-05-05 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik accepted this revision.
shafik added a comment.

LGTM


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

https://reviews.llvm.org/D148689

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


[PATCH] D146764: [clang] Make predefined expressions string literals under -fms-extensions

2023-05-05 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.

Presuming that the issues found by precommit CI were resolved (current failures 
are unrelated to your changes), this LGTM but still needs a release note.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146764

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


  1   2   >