[PATCH] D111154: [WebAssembly] Implementation of table.get/set for reftypes in LLVM IR

2021-10-17 Thread Thomas Lively via Phabricator via cfe-commits
tlively added a comment.

This is looking good! I'll take a more thorough pass through tomorrow so we can 
get this landed.




Comment at: llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp:1455
+  const SDValue ,
+  GlobalAddressSDNode **GA,
+  SDValue ) const {

Would it make sense to use `GlobalAddressSDNode *` here to match using a 
reference for the `Idx` out-param? That would slightly simplify the code below 
as well.



Comment at: llvm/test/CodeGen/WebAssembly/funcref-table_call.ll:25-27
+; CHECK-NEXT: i32.const   0
+; CHECK-NEXT: ref.nullfunc
+; CHECK-NEXT: table.set   __funcref_call_table

pmatos wrote:
> tlively wrote:
> > Do you think it would be a good idea to skip setting this table slot back 
> > to null? I know we discussed this before, but I don't remember what the 
> > pros and cons were.
> So the reason to do this was that if we leave the funcref in the slot, this 
> could create hidden GC roots. Comes from this comment by @wingo : 
> https://reviews.llvm.org/D95425#inline-929792
Ah right, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D54

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


[PATCH] D111863: [libunwind] Add an interface for dynamic .eh_frame registration

2021-10-17 Thread Lang Hames via Phabricator via cfe-commits
lhames accepted this revision.
lhames added a comment.

This looks good to me, but we should get a libunwind contributor to weigh in 
too.

I've been trying to think of a good way to test this, but it's awkward. The 
best strategy that I've come up with, at least for testing within libunwind 
itself, would be to compile a test case with eh-frame tables written in by hand 
(as C arrays, compile it with `-fno-asynchronous-unwind-tables`, patch up the 
tables manually with C code at runtime, and then register/use/deregister them. 
That's all pretty awkward, which is probably why there are no existing tests 
for the dynamic registration APIs.

I think the ORC runtime provides a much more natural way to test this. Did you 
manage to come up with some ORC-runtime based tests in the end?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111863

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


[PATCH] D110129: [DebugInfo] Support typedef with btf_decl_tag attributes

2021-10-17 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song updated this revision to Diff 380276.
yonghong-song retitled this revision from "[DebugInfo] Support typedef with 
btf_tag attributes" to "[DebugInfo] Support typedef with btf_decl_tag 
attributes".
yonghong-song edited the summary of this revision.
yonghong-song added a comment.

- update to use renamed btf_decl_tag instead of btf_tag 
(https://reviews.llvm.org/D111588)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110129

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGen/attr-btf_tag-typedef.c
  llvm/include/llvm/IR/DIBuilder.h
  llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
  llvm/lib/IR/DIBuilder.cpp
  llvm/test/Bitcode/attr-btf_tag-typedef.ll
  llvm/test/DebugInfo/X86/attr-btf_tag-typedef.ll

Index: llvm/test/DebugInfo/X86/attr-btf_tag-typedef.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/X86/attr-btf_tag-typedef.ll
@@ -0,0 +1,69 @@
+; RUN: llc -mtriple=x86_64-linux -filetype=obj -o %t %s
+; RUN: llvm-dwarfdump -debug-info %t | FileCheck %s
+;
+; Source:
+;   #define __tag1 __attribute__((btf_decl_tag("tag1")))
+;   typedef struct { int a; } __s __tag1;
+;   typedef unsigned * __u __tag1;
+;   __s a;
+;   __u u;
+; Compilation flag:
+;   clang -S -g -emit-llvm typedef.c
+
+%struct.__s = type { i32 }
+
+@a = dso_local global %struct.__s zeroinitializer, align 4, !dbg !0
+@u = dso_local global i32* null, align 8, !dbg !5
+
+!llvm.dbg.cu = !{!2}
+!llvm.module.flags = !{!17, !18, !19, !20, !21}
+!llvm.ident = !{!22}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = distinct !DIGlobalVariable(name: "a", scope: !2, file: !3, line: 4, type: !12, isLocal: false, isDefinition: true)
+!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 14.0.0 (https://github.com/llvm/llvm-project.git b9757992b73e823edf1fa699372ff9cd29db6cb7)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !4, splitDebugInlining: false, nameTableKind: None)
+!3 = !DIFile(filename: "typedef.c", directory: "/home/yhs/work/tests/llvm/btf_tag")
+!4 = !{!0, !5}
+!5 = !DIGlobalVariableExpression(var: !6, expr: !DIExpression())
+!6 = distinct !DIGlobalVariable(name: "u", scope: !2, file: !3, line: 5, type: !7, isLocal: false, isDefinition: true)
+!7 = !DIDerivedType(tag: DW_TAG_typedef, name: "__u", file: !3, line: 3, baseType: !8, annotations: !10)
+!8 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !9, size: 64)
+!9 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)
+!10 = !{!11}
+!11 = !{!"btf_decl_tag", !"tag1"}
+!12 = !DIDerivedType(tag: DW_TAG_typedef, name: "__s", file: !3, line: 2, baseType: !13, annotations: !10)
+!13 = distinct !DICompositeType(tag: DW_TAG_structure_type, file: !3, line: 2, size: 32, elements: !14)
+!14 = !{!15}
+!15 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !13, file: !3, line: 2, baseType: !16, size: 32)
+!16 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+
+; CHECK:DW_TAG_typedef
+; CHECK-NEXT: DW_AT_type
+; CHECK-NEXT: DW_AT_name  ("__s")
+; CHECK-NEXT: DW_AT_decl_file
+; CHECK-NEXT: DW_AT_decl_line
+; CHECK-EMPTY:
+; CHECK-NEXT: DW_TAG_LLVM_annotation
+; CHECK-NEXT:   DW_AT_name("btf_decl_tag")
+; CHECK-NEXT:   DW_AT_const_value ("tag1")
+; CHECK-EMPTY:
+; CHECK-NEXT: NULL
+
+; CHECK:DW_TAG_typedef
+; CHECK-NEXT: DW_AT_type
+; CHECK-NEXT: DW_AT_name  ("__u")
+; CHECK-NEXT: DW_AT_decl_file
+; CHECK-NEXT: DW_AT_decl_line
+; CHECK-EMPTY:
+; CHECK-NEXT: DW_TAG_LLVM_annotation
+; CHECK-NEXT:   DW_AT_name("btf_decl_tag")
+; CHECK-NEXT:   DW_AT_const_value ("tag1")
+; CHECK-EMPTY:
+; CHECK-NEXT: NULL
+
+!17 = !{i32 7, !"Dwarf Version", i32 4}
+!18 = !{i32 2, !"Debug Info Version", i32 3}
+!19 = !{i32 1, !"wchar_size", i32 4}
+!20 = !{i32 7, !"uwtable", i32 1}
+!21 = !{i32 7, !"frame-pointer", i32 2}
+!22 = !{!"clang version 14.0.0 (https://github.com/llvm/llvm-project.git b9757992b73e823edf1fa699372ff9cd29db6cb7)"}
Index: llvm/test/Bitcode/attr-btf_tag-typedef.ll
===
--- /dev/null
+++ llvm/test/Bitcode/attr-btf_tag-typedef.ll
@@ -0,0 +1,54 @@
+; RUN: llvm-as < %s | llvm-dis | FileCheck %s
+;
+; Source:
+;   #define __tag1 __attribute__((btf_decl_tag("tag1")))
+;   typedef struct { int a; } __s __tag1;
+;   typedef unsigned * __u __tag1;
+;   __s a;
+;   __u u;
+; Compilation flag:
+;   clang -S -g -emit-llvm typedef.c
+
+%struct.__s = type { i32 }
+
+@a = dso_local global %struct.__s zeroinitializer, align 4, !dbg !0
+@u = dso_local global i32* null, align 8, !dbg !5
+
+!llvm.dbg.cu = !{!2}
+!llvm.module.flags = !{!17, !18, !19, !20, !21}
+!llvm.ident = !{!22}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = distinct 

[PATCH] D110127: [Clang] Support typedef with btf_decl_tag attributes

2021-10-17 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song updated this revision to Diff 380275.
yonghong-song retitled this revision from "[Clang] Support typedef with btf_tag 
attributes" to "[Clang] Support typedef with btf_decl_tag attributes".
yonghong-song edited the summary of this revision.
yonghong-song added a comment.

- rebase based on new btf_decl_tag (https://reviews.llvm.org/D111588)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110127

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/attr-btf_tag.c


Index: clang/test/Sema/attr-btf_tag.c
===
--- clang/test/Sema/attr-btf_tag.c
+++ clang/test/Sema/attr-btf_tag.c
@@ -25,18 +25,26 @@
 
 enum e1 {
   E1
-} __tag1; // expected-error {{'btf_decl_tag' attribute only applies to 
variables, functions, structs, unions, classes, and non-static data members}}
+} __tag1; // expected-error {{'btf_decl_tag' attribute only applies to 
variables, functions, structs, unions, classes, non-static data members, and 
typedefs}}
 
 enum e2 {
   E2
-} __tag_no_arg; // expected-error {{'btf_decl_tag' attribute only applies to 
variables, functions, structs, unions, classes, and non-static data members}}
+} __tag_no_arg; // expected-error {{'btf_decl_tag' attribute only applies to 
variables, functions, structs, unions, classes, non-static data members, and 
typedefs}}
 
 enum e3 {
   E3
-} __tag_2_arg; // expected-error {{'btf_decl_tag' attribute only applies to 
variables, functions, structs, unions, classes, and non-static data members}}
+} __tag_2_arg; // expected-error {{'btf_decl_tag' attribute only applies to 
variables, functions, structs, unions, classes, non-static data members, and 
typedefs}}
 
 int __tag1 __tag2 foo(struct t1 *arg, struct t2 *arg2);
 int __tag2 __tag3 foo(struct t1 *arg, struct t2 *arg2);
 int __tag1 foo(struct t1 *arg __tag1, struct t2 *arg2) {
   return arg->a + arg2->a;
 }
+
+typedef unsigned * __u1 __tag1 __tag2;
+typedef struct {
+  int a;
+} __t2 __tag1 __tag2;
+int convert2(__t2 *arg) {
+  return arg->a;
+}
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -22,7 +22,7 @@
 // CHECK-NEXT: Assumption (SubjectMatchRule_function, 
SubjectMatchRule_objc_method)
 // CHECK-NEXT: Availability ((SubjectMatchRule_record, SubjectMatchRule_enum, 
SubjectMatchRule_enum_constant, SubjectMatchRule_field, 
SubjectMatchRule_function, SubjectMatchRule_namespace, 
SubjectMatchRule_objc_category, SubjectMatchRule_objc_implementation, 
SubjectMatchRule_objc_interface, SubjectMatchRule_objc_method, 
SubjectMatchRule_objc_property, SubjectMatchRule_objc_protocol, 
SubjectMatchRule_record, SubjectMatchRule_type_alias, 
SubjectMatchRule_variable))
 // CHECK-NEXT: BPFPreserveAccessIndex (SubjectMatchRule_record)
-// CHECK-NEXT: BTFDeclTag (SubjectMatchRule_variable, 
SubjectMatchRule_function, SubjectMatchRule_record, SubjectMatchRule_field)
+// CHECK-NEXT: BTFDeclTag (SubjectMatchRule_variable, 
SubjectMatchRule_function, SubjectMatchRule_record, SubjectMatchRule_field, 
SubjectMatchRule_type_alias)
 // CHECK-NEXT: BuiltinAlias (SubjectMatchRule_function)
 // CHECK-NEXT: CFAuditedTransfer (SubjectMatchRule_function)
 // CHECK-NEXT: CFConsumed (SubjectMatchRule_variable_is_parameter)
Index: clang/include/clang/Basic/AttrDocs.td
===
--- clang/include/clang/Basic/AttrDocs.td
+++ clang/include/clang/Basic/AttrDocs.td
@@ -2016,9 +2016,10 @@
   let Content = [{
 Clang supports the ``__attribute__((btf_decl_tag("ARGUMENT")))`` attribute for
 all targets. This attribute may be attached to a struct/union, struct/union
-field, function, function parameter or variable declaration. If -g is 
specified,
-the ``ARGUMENT`` info will be preserved in IR and be emitted to dwarf.
-For BPF targets, the ``ARGUMENT`` info will be emitted to .BTF ELF section too.
+field, function, function parameter, variable or typedef declaration. If -g is
+specified, the ``ARGUMENT`` info will be preserved in IR and be emitted to
+dwarf. For BPF targets, the ``ARGUMENT`` info will be emitted to .BTF ELF
+section too.
   }];
 }
 
Index: clang/include/clang/Basic/Attr.td
===
--- clang/include/clang/Basic/Attr.td
+++ clang/include/clang/Basic/Attr.td
@@ -1839,7 +1839,8 @@
 def BTFDeclTag : InheritableAttr {
   let Spellings = [Clang<"btf_decl_tag">];
   let Args = [StringArgument<"BTFDeclTag">];
-  let Subjects = SubjectList<[Var, Function, Record, Field], ErrorDiag>;
+  let Subjects = SubjectList<[Var, Function, Record, 

[PATCH] D111971: [clang] Allocate 2 bits to store the constexpr specifier kind when serializing

2021-10-17 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

Not sure if clangd is the best place to test this. I'm open to other 
suggestions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111971

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


[PATCH] D111971: [clang] Allocate 2 bits to store the constexpr specifier kind when serializing

2021-10-17 Thread Nathan Ridge via Phabricator via cfe-commits
nridge created this revision.
Herald added subscribers: usaxena95, kadircet, arphaman.
nridge requested review of this revision.
Herald added projects: clang, clang-tools-extra.
Herald added a subscriber: cfe-commits.

Now that consteval and constinit are possible values, 1 bit
is no longer enough.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D111971

Files:
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp


Index: clang/lib/Serialization/ASTWriterDecl.cpp
===
--- clang/lib/Serialization/ASTWriterDecl.cpp
+++ clang/lib/Serialization/ASTWriterDecl.cpp
@@ -2260,7 +2260,7 @@
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Defaulted
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ExplicitlyDefaulted
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ImplicitReturnZero
-  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Constexpr
+  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // Constexpr
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // UsesSEHTry
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // SkippedBody
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // MultiVersion
Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -672,6 +672,24 @@
   ElementsAre(AllOf(Diag(Test.range(), "'main' must return 'int'"),
 Not(WithFix(_);
 }
+TEST(DiagnosticsTest, Consteval) {
+  Annotations Header(R"cpp(
+struct Container {
+  consteval Container() {
+Push();
+  }
+  consteval void Push() {}
+};
+  )cpp");
+  Annotations Main(R"cpp(
+#include "a.h"
+constexpr Container c = Container();
+  )cpp");
+  TestTU TU = TestTU::withCode(Main.code());
+  TU.ExtraArgs.push_back("-std=c++20");
+  TU.AdditionalFiles = {{"a.h", std::string(Header.code())}};
+  EXPECT_THAT(*TU.build().getDiagnostics(), IsEmpty());
+}
 
 TEST(ClangdTest, MSAsm) {
   // Parsing MS assembly tries to use the target MCAsmInfo, which we don't 
link.


Index: clang/lib/Serialization/ASTWriterDecl.cpp
===
--- clang/lib/Serialization/ASTWriterDecl.cpp
+++ clang/lib/Serialization/ASTWriterDecl.cpp
@@ -2260,7 +2260,7 @@
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Defaulted
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ExplicitlyDefaulted
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ImplicitReturnZero
-  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Constexpr
+  Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // Constexpr
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // UsesSEHTry
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // SkippedBody
   Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // MultiVersion
Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -672,6 +672,24 @@
   ElementsAre(AllOf(Diag(Test.range(), "'main' must return 'int'"),
 Not(WithFix(_);
 }
+TEST(DiagnosticsTest, Consteval) {
+  Annotations Header(R"cpp(
+struct Container {
+  consteval Container() {
+Push();
+  }
+  consteval void Push() {}
+};
+  )cpp");
+  Annotations Main(R"cpp(
+#include "a.h"
+constexpr Container c = Container();
+  )cpp");
+  TestTU TU = TestTU::withCode(Main.code());
+  TU.ExtraArgs.push_back("-std=c++20");
+  TU.AdditionalFiles = {{"a.h", std::string(Header.code())}};
+  EXPECT_THAT(*TU.build().getDiagnostics(), IsEmpty());
+}
 
 TEST(ClangdTest, MSAsm) {
   // Parsing MS assembly tries to use the target MCAsmInfo, which we don't link.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D105169: [Clang/Test]: Rename enable_noundef_analysis to disable-noundef-analysis and turn it off by default

2021-10-17 Thread Juneyoung Lee via Phabricator via cfe-commits
aqjune added a comment.

It seems the original code has a use of an uninitialized variable.
Line 4420 at seek-preproc.c (function `ff_seek_frame_binary`):

   int64_t pos_min=pos_min, pos_max=pos_max, pos, pos_limit; // pos_min and 
pos_max are self-assigned.
  ...
  if (sti->index_entries) {
 ...
  }
  // pos_min and pos_max are used as arguments below
  pos = ff_gen_search(s, stream_index, target_ts, pos_min, pos_max, pos_limit,
   ts_min, ts_max, flags, , avif->read_timestamp);

https://gist.github.com/aqjune/3bd0ea19bbc12b4744843c0c070e994c

If the branch is not taken, `pos_min` and `pos_max` are read while they are 
still uninitialized.

I guess the variables are self-assigned to avoid warnings?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105169

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


[PATCH] D105169: [Clang/Test]: Rename enable_noundef_analysis to disable-noundef-analysis and turn it off by default

2021-10-17 Thread Juneyoung Lee via Phabricator via cfe-commits
aqjune added a comment.

I can see that `@ff_seek_frame_binary` is the only affected function.
It introduces `llvm.assume` as well as `!nonnull` at a few places and folds 
null pointer checks.
Still investigating..
F19677416: before.ll  F19677415: after.ll 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105169

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


[clang] d245f2e - [clang] Use llvm::erase_if (NFC)

2021-10-17 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2021-10-17T13:50:29-07:00
New Revision: d245f2e8597bfb52c34810a328d42b990e4af1a4

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

LOG: [clang] Use llvm::erase_if (NFC)

Added: 


Modified: 
clang/include/clang/ASTMatchers/ASTMatchersInternal.h
clang/include/clang/Analysis/CloneDetection.h
clang/lib/AST/ASTContext.cpp
clang/lib/AST/CXXInheritance.cpp
clang/lib/AST/CommentSema.cpp
clang/lib/AST/DeclCXX.cpp
clang/lib/AST/ExprConstant.cpp
clang/lib/AST/ExternalASTMerger.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/Driver/Multilib.cpp
clang/lib/Frontend/ASTUnit.cpp
clang/lib/Frontend/CompilerInstance.cpp
clang/lib/Lex/PPMacroExpansion.cpp
clang/lib/Serialization/ModuleManager.cpp
clang/lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp

Removed: 




diff  --git a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h 
b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
index 1a4137cb3628f..f84582c06f780 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -312,8 +312,7 @@ class BoundNodesTreeBuilder {
 
   template 
   bool removeBindings(const ExcludePredicate ) {
-Bindings.erase(std::remove_if(Bindings.begin(), Bindings.end(), Predicate),
-   Bindings.end());
+llvm::erase_if(Bindings, Predicate);
 return !Bindings.empty();
   }
 

diff  --git a/clang/include/clang/Analysis/CloneDetection.h 
b/clang/include/clang/Analysis/CloneDetection.h
index db827c3a6d6ff..0b86c7fd86dd6 100644
--- a/clang/include/clang/Analysis/CloneDetection.h
+++ b/clang/include/clang/Analysis/CloneDetection.h
@@ -235,9 +235,7 @@ class CloneConstraint {
   static void filterGroups(
   std::vector ,
   llvm::function_ref Filter) {
-CloneGroups.erase(
-std::remove_if(CloneGroups.begin(), CloneGroups.end(), Filter),
-CloneGroups.end());
+llvm::erase_if(CloneGroups, Filter);
   }
 
   /// Splits the given CloneGroups until the given Compare function returns 
true

diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 1292cb6eb557c..84b09dcf16a0e 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -9199,13 +9199,9 @@ void getIntersectionOfProtocols(ASTContext ,
 
   // Remove any implied protocols from the list of inherited protocols.
   if (!ImpliedProtocols.empty()) {
-IntersectionSet.erase(
-  std::remove_if(IntersectionSet.begin(),
- IntersectionSet.end(),
- [&](ObjCProtocolDecl *proto) -> bool {
-   return ImpliedProtocols.count(proto) > 0;
- }),
-  IntersectionSet.end());
+llvm::erase_if(IntersectionSet, [&](ObjCProtocolDecl *proto) -> bool {
+  return ImpliedProtocols.count(proto) > 0;
+});
   }
 
   // Sort the remaining protocols by name.
@@ -11719,13 +11715,9 @@ ASTContext::filterFunctionTargetAttrs(const TargetAttr 
*TD) const {
   assert(TD != nullptr);
   ParsedTargetAttr ParsedAttr = TD->parse();
 
-  ParsedAttr.Features.erase(
-  llvm::remove_if(ParsedAttr.Features,
-  [&](const std::string ) {
-return !Target->isValidFeatureName(
-StringRef{Feat}.substr(1));
-  }),
-  ParsedAttr.Features.end());
+  llvm::erase_if(ParsedAttr.Features, [&](const std::string ) {
+return !Target->isValidFeatureName(StringRef{Feat}.substr(1));
+  });
   return ParsedAttr;
 }
 

diff  --git a/clang/lib/AST/CXXInheritance.cpp 
b/clang/lib/AST/CXXInheritance.cpp
index cc787eddad2fc..96a6f344be7c9 100644
--- a/clang/lib/AST/CXXInheritance.cpp
+++ b/clang/lib/AST/CXXInheritance.cpp
@@ -671,9 +671,7 @@ CXXRecordDecl::getFinalOverriders(CXXFinalOverriderMap 
) const {
 
   // FIXME: IsHidden reads from Overriding from the middle of a remove_if
   // over the same sequence! Is this guaranteed to work?
-  Overriding.erase(
-  std::remove_if(Overriding.begin(), Overriding.end(), IsHidden),
-  Overriding.end());
+  llvm::erase_if(Overriding, IsHidden);
 }
   }
 }

diff  --git a/clang/lib/AST/CommentSema.cpp b/clang/lib/AST/CommentSema.cpp
index 7642e73fa1714..e385c5817ef23 100644
--- a/clang/lib/AST/CommentSema.cpp
+++ b/clang/lib/AST/CommentSema.cpp
@@ -236,9 +236,7 @@ void 
Sema::actOnParamCommandDirectionArg(ParamCommandComment *Command,
 
   if (Direction == -1) {
 // Try again with whitespace removed.
-ArgLower.erase(
-std::remove_if(ArgLower.begin(), ArgLower.end(), clang::isWhitespace),
-ArgLower.end());
+llvm::erase_if(ArgLower, clang::isWhitespace);
 Direction = 

[PATCH] D105169: [Clang/Test]: Rename enable_noundef_analysis to disable-noundef-analysis and turn it off by default

2021-10-17 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

I've bisected a crash in generated code down to this commit. The code that 
crashes is clean when run in ubsan. The misbehaviour happens across 4 tested 
architectures (i686, x86_64, armv7, aarch64).

The misbehaviour occurs in this preprocessed source, 
https://martin.st/temp/seek-preproc.c, compiled with `clang -target 
x86_64-linux-gnu -c -O3 seek-preproc.c`.

The whole failing testcase can be reproduced (on e.g. linux) with these steps:

  git clone git://source.ffmpeg.org/ffmpeg
  cd ffmpeg
  ./configure --cc=clang
  make -j4 fate-seek-acodec-flac

(The failing object file is `libavformat/seek.o`.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105169

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


[PATCH] D111797: [clang][scan-build] Use uname -s to detect the operating system.

2021-10-17 Thread Frederic Cambus via Phabricator via cfe-commits
fcambus added a comment.

In D111797#3069103 , @brad wrote:

> I'm not a Perl guy but I'm wondering about simplifying what it is doing there 
> to just `uname -s` eq 'OpenBSD'?

Yes, I think it makes sense. Just sent an updated revision.


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

https://reviews.llvm.org/D111797

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


[PATCH] D111797: [clang][scan-build] Use uname -s to detect the operating system.

2021-10-17 Thread Frederic Cambus via Phabricator via cfe-commits
fcambus updated this revision to Diff 380263.
fcambus added a comment.

Avoid using regexps and use the 'eq' operator for doing string comparison.


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

https://reviews.llvm.org/D111797

Files:
  clang/tools/scan-build/libexec/ccc-analyzer


Index: clang/tools/scan-build/libexec/ccc-analyzer
===
--- clang/tools/scan-build/libexec/ccc-analyzer
+++ clang/tools/scan-build/libexec/ccc-analyzer
@@ -72,7 +72,7 @@
 # If on OSX, use xcrun to determine the SDK root.
 my $UseXCRUN = 0;
 
-if (`uname -a` =~ m/Darwin/) {
+if (`uname -s` eq "Darwin\n") {
   $DefaultCCompiler = 'clang';
   $DefaultCXXCompiler = 'clang++';
   # Older versions of OSX do not have xcrun to
@@ -80,7 +80,7 @@
   if (-x "/usr/bin/xcrun") {
 $UseXCRUN = 1;
   }
-} elsif (`uname -a` =~ m/OpenBSD/) {
+} elsif (`uname -s` eq "OpenBSD\n") {
   $DefaultCCompiler = 'cc';
   $DefaultCXXCompiler = 'c++';
 } else {


Index: clang/tools/scan-build/libexec/ccc-analyzer
===
--- clang/tools/scan-build/libexec/ccc-analyzer
+++ clang/tools/scan-build/libexec/ccc-analyzer
@@ -72,7 +72,7 @@
 # If on OSX, use xcrun to determine the SDK root.
 my $UseXCRUN = 0;
 
-if (`uname -a` =~ m/Darwin/) {
+if (`uname -s` eq "Darwin\n") {
   $DefaultCCompiler = 'clang';
   $DefaultCXXCompiler = 'clang++';
   # Older versions of OSX do not have xcrun to
@@ -80,7 +80,7 @@
   if (-x "/usr/bin/xcrun") {
 $UseXCRUN = 1;
   }
-} elsif (`uname -a` =~ m/OpenBSD/) {
+} elsif (`uname -s` eq "OpenBSD\n") {
   $DefaultCCompiler = 'cc';
   $DefaultCXXCompiler = 'c++';
 } else {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D111797: [clang][scan-build] Use uname -s to detect the operating system.

2021-10-17 Thread Brad Smith via Phabricator via cfe-commits
brad added a comment.

I'm not a Perl guy but I'm wondering about simplifying what it is doing there 
to just `uname -s` eq 'OpenBSD'?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111797

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


[PATCH] D107347: [Sema] haveSameParameterTypes - fix repeated isNull() test

2021-10-17 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 accepted this revision.
xbolva00 added a comment.
This revision is now accepted and ready to land.

LG. Could be changed to the assert in the future….


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D107347

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


[PATCH] D109051: Use Component in OpenBSD::getCompilerRT to find libraries

2021-10-17 Thread Frederic Cambus via Phabricator via cfe-commits
fcambus added a comment.

Any update on this?

For info, we started shipping libraries 

 in the OpenBSD base system using this naming scheme for architectures on which 
we build Clang.


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

https://reviews.llvm.org/D109051

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


[PATCH] D109707: [HIP] [AlwaysInliner] Disable AlwaysInliner to eliminate undefined symbols

2021-10-17 Thread Anshil Gandhi via Phabricator via cfe-commits
gandhi21299 added inline comments.



Comment at: clang/test/CodeGenCUDA/amdgpu-alias-undef-symbols.cu:3
+
+// RUN: %clang -target x86_64-unknown-linux-gnu --offload-arch=gfx906 
--cuda-device-only -nogpulib -nogpuinc -x hip -emit-llvm -S -o - %s \
+// RUN:   -fgpu-rdc -O3 -mllvm -amdgpu-early-inline-all=true -mllvm 
-amdgpu-function-calls=false | \

MaskRay wrote:
> non-driver tests prefer `%clang_cc1`.
> 
> `%clang` invokes the driver and has varying behaviors on different platforms. 
> Include paths/resource dir may be quite different.
Alias is not generated when I make the change to:

```
// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -target-cpu gfx906 -aux-triple 
x86_64-unknown-linux-gnu \
// RUN:   -x hip -fcuda-is-device -fgpu-rdc -O3 -mllvm 
-amdgpu-early-inline-all=true \
// RUN:   -mllvm -amdgpu-function-calls=false -emit-llvm %s -o - | FileCheck %s
```



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109707

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


[PATCH] D108453: [Clang/Test]: Rename enable_noundef_analysis to disable-noundef-analysis and turn it off by default (2)

2021-10-17 Thread Hyeongyu Kim 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 rG8ca4b3ef19fe: [Clang/Test]: Rename enable_noundef_analysis 
to disable-noundef-analysis and… (authored by aqjune, committed by hyeongyukim).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108453

Files:
  clang/test/CXX/except/except.spec/p14-ir.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/blocks-irgen.mm
  clang/test/CodeGen/2005-01-02-ConstantInits.c
  clang/test/CodeGen/2006-05-19-SingleEltReturn.c
  clang/test/CodeGen/2007-06-18-SextAttrAggregate.c
  clang/test/CodeGen/2009-02-13-zerosize-union-field.c
  clang/test/CodeGen/2009-05-04-EnumInreg.c
  clang/test/CodeGen/64bit-swiftcall.c
  clang/test/CodeGen/RISCV/riscv-inline-asm.c
  clang/test/CodeGen/RISCV/riscv32-ilp32-abi.c
  clang/test/CodeGen/RISCV/riscv32-ilp32-ilp32f-abi.c
  clang/test/CodeGen/RISCV/riscv32-ilp32-ilp32f-ilp32d-abi.c
  clang/test/CodeGen/RISCV/riscv32-ilp32d-abi.c
  clang/test/CodeGen/RISCV/riscv32-ilp32f-abi.c
  clang/test/CodeGen/RISCV/riscv32-ilp32f-ilp32d-abi.c
  clang/test/CodeGen/RISCV/riscv64-lp64-abi.c
  clang/test/CodeGen/RISCV/riscv64-lp64-lp64f-abi.c
  clang/test/CodeGen/RISCV/riscv64-lp64-lp64f-lp64d-abi.c
  clang/test/CodeGen/RISCV/riscv64-lp64d-abi.c
  clang/test/CodeGen/RISCV/riscv64-lp64f-lp64d-abi.c
  clang/test/CodeGen/SystemZ/systemz-abi-vector.c
  clang/test/CodeGen/SystemZ/systemz-abi.c
  clang/test/CodeGen/SystemZ/systemz-inline-asm.c
  clang/test/CodeGen/WebAssembly/wasm-arguments.c
  clang/test/CodeGen/WebAssembly/wasm-main_argc_argv.c
  clang/test/CodeGen/X86/avx-union.c
  clang/test/CodeGen/X86/avx512fp16-complex-abi.c
  clang/test/CodeGen/X86/ms-x86-intrinsics.c
  clang/test/CodeGen/X86/strictfp_builtins.c
  clang/test/CodeGen/X86/x86-atomic-long_double.c
  clang/test/CodeGen/X86/x86-inline-asm-min-vector-width.c
  clang/test/CodeGen/X86/x86-long-double.cpp
  clang/test/CodeGen/X86/x86-soft-float.c
  clang/test/CodeGen/X86/x86-vec-i128.c
  clang/test/CodeGen/X86/x86_32-arguments-darwin.c
  clang/test/CodeGen/X86/x86_32-arguments-iamcu.c
  clang/test/CodeGen/X86/x86_32-arguments-linux.c
  clang/test/CodeGen/X86/x86_32-arguments-nommx.c
  clang/test/CodeGen/X86/x86_32-arguments-realign.c
  clang/test/CodeGen/X86/x86_32-arguments-win32.c
  clang/test/CodeGen/X86/x86_64-arguments-nacl.c
  clang/test/CodeGen/X86/x86_64-arguments-win32.c
  clang/test/CodeGen/X86/x86_64-arguments.c
  clang/test/CodeGen/X86/x86_64-longdouble.c
  clang/test/CodeGen/aapcs-align.cpp
  clang/test/CodeGen/aapcs64-align.cpp
  clang/test/CodeGen/aarch64-args.cpp
  clang/test/CodeGen/aarch64-byval-temp.c
  clang/test/CodeGen/aarch64-neon-3v.c
  clang/test/CodeGen/aarch64-neon-across.c
  clang/test/CodeGen/aarch64-neon-dot-product.c
  clang/test/CodeGen/aarch64-neon-extract.c
  clang/test/CodeGen/aarch64-neon-fcvt-intrinsics.c
  clang/test/CodeGen/aarch64-neon-fma.c
  clang/test/CodeGen/aarch64-neon-ldst-one.c
  clang/test/CodeGen/aarch64-neon-scalar-copy.c
  clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem.c
  clang/test/CodeGen/aarch64-neon-tbl.c
  clang/test/CodeGen/aarch64-neon-vcombine.c
  clang/test/CodeGen/aarch64-neon-vget-hilo.c
  clang/test/CodeGen/aarch64-neon-vget.c
  clang/test/CodeGen/aarch64-poly128.c
  clang/test/CodeGen/aarch64-poly64.c
  clang/test/CodeGen/aarch64-strictfp-builtins.c
  clang/test/CodeGen/aarch64-sve-acle-__ARM_FEATURE_SVE_VECTOR_OPERATORS.c
  clang/test/CodeGen/aarch64-sve-acle-__ARM_FEATURE_SVE_VECTOR_OPERATORS.cpp
  clang/test/CodeGen/aarch64-varargs.c
  clang/test/CodeGen/address-space-field1.c
  clang/test/CodeGen/address-space.c
  clang/test/CodeGen/aix-alignment.c
  clang/test/CodeGen/aix-altivec.c
  clang/test/CodeGen/aix-ignore-xcoff-visibility.cpp
  clang/test/CodeGen/aix-return.c
  clang/test/CodeGen/aix-struct-arg.c
  clang/test/CodeGen/aix-vaargs.c
  clang/test/CodeGen/alias.c
  clang/test/CodeGen/align_value.cpp
  clang/test/CodeGen/alloc-align-attr.c
  clang/test/CodeGen/alloc-fns-alignment.c
  clang/test/CodeGen/alloc-size-fnptr.c
  clang/test/CodeGen/arc/arguments.c
  clang/test/CodeGen/arithmetic-fence-builtin.c
  clang/test/CodeGen/arm-aapcs-vfp.c
  clang/test/CodeGen/arm-abi-vector.c
  clang/test/CodeGen/arm-arguments.c
  clang/test/CodeGen/arm-bf16-params-returns.c
  clang/test/CodeGen/arm-byval-align.c
  clang/test/CodeGen/arm-cmse-attr.c
  clang/test/CodeGen/arm-cmse-call.c
  clang/test/CodeGen/arm-float-helpers.c
  clang/test/CodeGen/arm-fp16-arguments.c
  clang/test/CodeGen/arm-homogenous.c
  clang/test/CodeGen/arm-mangle-bf16.cpp
  clang/test/CodeGen/arm-neon-directed-rounding.c
  clang/test/CodeGen/arm-neon-dot-product.c
  clang/test/CodeGen/arm-neon-fma.c
  clang/test/CodeGen/arm-neon-numeric-maxmin.c
  clang/test/CodeGen/arm-neon-vcvtX.c
  clang/test/CodeGen/arm-swiftcall.c
  clang/test/CodeGen/arm-varargs.c
  

[PATCH] D109707: [HIP] [AlwaysInliner] Disable AlwaysInliner to eliminate undefined symbols

2021-10-17 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/test/CodeGenCUDA/amdgpu-alias-undef-symbols.cu:3
+
+// RUN: %clang -target x86_64-unknown-linux-gnu --offload-arch=gfx906 
--cuda-device-only -nogpulib -nogpuinc -x hip -emit-llvm -S -o - %s \
+// RUN:   -fgpu-rdc -O3 -mllvm -amdgpu-early-inline-all=true -mllvm 
-amdgpu-function-calls=false | \

non-driver tests prefer `%clang_cc1`.

`%clang` invokes the driver and has varying behaviors on different platforms. 
Include paths/resource dir may be quite different.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109707

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


[PATCH] D109707: [HIP] [AlwaysInliner] Disable AlwaysInliner to eliminate undefined symbols

2021-10-17 Thread Anshil Gandhi via Phabricator via cfe-commits
gandhi21299 added a comment.

@thakis can you please check if this solution is sufficient? Thanks for 
bringing it up


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109707

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


[PATCH] D109707: [HIP] [AlwaysInliner] Disable AlwaysInliner to eliminate undefined symbols

2021-10-17 Thread Anshil Gandhi via Phabricator via cfe-commits
gandhi21299 updated this revision to Diff 380110.
gandhi21299 added a comment.

added -target option in the test amdgpu-alias-undef-symbols.cu


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109707

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGenCUDA/amdgpu-alias-undef-symbols.cu
  llvm/lib/Target/AMDGPU/AMDGPUAlwaysInlinePass.cpp
  llvm/lib/Target/AMDGPU/AMDGPUResourceUsageAnalysis.cpp
  llvm/test/CodeGen/AMDGPU/inline-calls.ll

Index: llvm/test/CodeGen/AMDGPU/inline-calls.ll
===
--- llvm/test/CodeGen/AMDGPU/inline-calls.ll
+++ llvm/test/CodeGen/AMDGPU/inline-calls.ll
@@ -1,6 +1,6 @@
-; RUN: llc -march=amdgcn -mcpu=tahiti -verify-machineinstrs < %s | FileCheck  %s
-; RUN: llc -march=amdgcn -mcpu=tonga -verify-machineinstrs < %s | FileCheck  %s
-; RUN: llc -march=r600 -mcpu=redwood -verify-machineinstrs < %s | FileCheck %s
+; RUN: llc -mtriple amdgcn-unknown-linux-gnu -mcpu=tahiti -verify-machineinstrs < %s | FileCheck  %s
+; RUN: llc -mtriple amdgcn-unknown-linux-gnu -mcpu=tonga -verify-machineinstrs < %s | FileCheck  %s
+; RUN: llc -mtriple r600-unknown-linux-gnu -mcpu=redwood -verify-machineinstrs < %s | FileCheck %s --check-prefix=R600
 
 ; ALL-NOT: {{^}}func:
 define internal i32 @func(i32 %a) {
@@ -9,7 +9,7 @@
   ret i32 %tmp0
 }
 
-; ALL: {{^}}kernel:
+; CHECK: {{^}}kernel:
 ; GCN-NOT: s_swappc_b64
 define amdgpu_kernel void @kernel(i32 addrspace(1)* %out) {
 entry:
@@ -18,12 +18,13 @@
   ret void
 }
 
-; CHECK-NOT: func_alias
-; ALL-NOT: func_alias
+; CHECK: func_alias
+; R600-NOT: func_alias
 @func_alias = alias i32 (i32), i32 (i32)* @func
 
-; ALL: {{^}}kernel3:
+; CHECK-NOT: {{^}}kernel3:
 ; GCN-NOT: s_swappc_b64
+; R600: {{^}}kernel3:
 define amdgpu_kernel void @kernel3(i32 addrspace(1)* %out) {
 entry:
   %tmp0 = call i32 @func_alias(i32 1)
Index: llvm/lib/Target/AMDGPU/AMDGPUResourceUsageAnalysis.cpp
===
--- llvm/lib/Target/AMDGPU/AMDGPUResourceUsageAnalysis.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPUResourceUsageAnalysis.cpp
@@ -29,6 +29,8 @@
 #include "SIMachineFunctionInfo.h"
 #include "llvm/Analysis/CallGraph.h"
 #include "llvm/CodeGen/TargetPassConfig.h"
+#include "llvm/IR/GlobalAlias.h"
+#include "llvm/IR/GlobalValue.h"
 #include "llvm/Target/TargetMachine.h"
 
 using namespace llvm;
@@ -61,7 +63,8 @@
 assert(Op.getImm() == 0);
 return nullptr;
   }
-
+  if (auto *GA = dyn_cast(Op.getGlobal()))
+return cast(GA->getOperand(0));
   return cast(Op.getGlobal());
 }
 
Index: llvm/lib/Target/AMDGPU/AMDGPUAlwaysInlinePass.cpp
===
--- llvm/lib/Target/AMDGPU/AMDGPUAlwaysInlinePass.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPUAlwaysInlinePass.cpp
@@ -15,6 +15,7 @@
 #include "AMDGPU.h"
 #include "AMDGPUTargetMachine.h"
 #include "Utils/AMDGPUBaseInfo.h"
+#include "llvm/CodeGen/CommandFlags.h"
 #include "llvm/IR/Module.h"
 #include "llvm/Pass.h"
 #include "llvm/Support/CommandLine.h"
@@ -90,9 +91,13 @@
 
   SmallPtrSet FuncsToAlwaysInline;
   SmallPtrSet FuncsToNoInline;
+  Triple TT(M.getTargetTriple());
 
   for (GlobalAlias  : M.aliases()) {
 if (Function* F = dyn_cast(A.getAliasee())) {
+  if (TT.getArch() == Triple::amdgcn &&
+  A.getLinkage() != GlobalValue::InternalLinkage)
+continue;
   A.replaceAllUsesWith(F);
   AliasesToRemove.push_back();
 }
Index: clang/test/CodeGenCUDA/amdgpu-alias-undef-symbols.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/amdgpu-alias-undef-symbols.cu
@@ -0,0 +1,17 @@
+// REQUIRES: amdgpu-registered-target, clang-driver
+
+// RUN: %clang -target x86_64-unknown-linux-gnu --offload-arch=gfx906 --cuda-device-only -nogpulib -nogpuinc -x hip -emit-llvm -S -o - %s \
+// RUN:   -fgpu-rdc -O3 -mllvm -amdgpu-early-inline-all=true -mllvm -amdgpu-function-calls=false | \
+// RUN:   FileCheck %s
+
+#include "Inputs/cuda.h"
+
+// CHECK: %struct.B = type { i8 }
+struct B {
+
+  // CHECK: @_ZN1BC1Ei = hidden unnamed_addr alias void (%struct.B*, i32), void (%struct.B*, i32)* @_ZN1BC2Ei
+  __device__ B(int x);
+};
+
+__device__ B::B(int x) {
+}
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5089,9 +5089,9 @@
   }
 
   // Enable -mconstructor-aliases except on darwin, where we have to work around
-  // a linker bug (see ), and CUDA/AMDGPU device code,
-  // where aliases aren't supported.
-  if (!RawTriple.isOSDarwin() && !RawTriple.isNVPTX() && !RawTriple.isAMDGPU())
+  // a linker bug (see ), and CUDA device code, where
+  // aliases aren't supported.
+  if (!RawTriple.isOSDarwin() && !RawTriple.isNVPTX())
 

[PATCH] D105168: [RISCV] Unify the arch string parsing logic to RISCVISAInfo.

2021-10-17 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng added inline comments.



Comment at: llvm/lib/Support/RISCVISAInfo.cpp:39
+
+static constexpr StringLiteral AllStdExts = "mafdqlcbjtpvn";
+

kito-cheng wrote:
> craig.topper wrote:
> > 'b' shouldn't be in this list anymore?
> I would prefer to keep that for sync with ISA manual, like other unsupported 
> extension like `J`, `T` and ``N`, we remove `B` from `SupportedExtensions`, 
> so keep this should be harmless.
Oh, and it also used for compute the canonical order for `z*` extensions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105168

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


[clang] c8be774 - Bump the value of __STDC_VERSION__ in -std=c2x mode

2021-10-17 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2021-10-17T09:23:43-04:00
New Revision: c8be7743acc7e8ea32ba9985c1d57c38f0eab010

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

LOG: Bump the value of __STDC_VERSION__ in -std=c2x mode

Previously, we reported the same value as for C17, now we report 202000L, which
is the same value currently used by GCC.

Once C23 ships, this value will be bumped to the correct date.

Added: 
clang/test/Preprocessor/c2x.c

Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Frontend/InitPreprocessor.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 263eae83036df..27ff9ddc70a34 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -129,6 +129,9 @@ Windows Support
 C Language Changes in Clang
 ---
 
+- The value of ``__STDC_VERSION__`` has been bumped to ``202000L`` when passing
+  ``-std=c2x`` so that it can be distinguished from C17 mode. This value is
+  expected to change again when C23 is published.
 - Wide multi-characters literals such as ``L'ab'`` that would previously be 
interpreted as ``L'b'``
   are now ill-formed in all language modes. The motivation for this change is 
outlined in
   `P2362 `_.

diff  --git a/clang/lib/Frontend/InitPreprocessor.cpp 
b/clang/lib/Frontend/InitPreprocessor.cpp
index aa94b130cb124..a3e1ca5d5226c 100644
--- a/clang/lib/Frontend/InitPreprocessor.cpp
+++ b/clang/lib/Frontend/InitPreprocessor.cpp
@@ -371,7 +371,10 @@ static void InitializeStandardPredefinedMacros(const 
TargetInfo ,
   //  value is, are implementation-defined.
   // (Removed in C++20.)
   if (!LangOpts.CPlusPlus) {
-if (LangOpts.C17)
+// FIXME: Use correct value for C23.
+if (LangOpts.C2x)
+  Builder.defineMacro("__STDC_VERSION__", "202000L");
+else if (LangOpts.C17)
   Builder.defineMacro("__STDC_VERSION__", "201710L");
 else if (LangOpts.C11)
   Builder.defineMacro("__STDC_VERSION__", "201112L");

diff  --git a/clang/test/Preprocessor/c2x.c b/clang/test/Preprocessor/c2x.c
new file mode 100644
index 0..96fc9273a2868
--- /dev/null
+++ b/clang/test/Preprocessor/c2x.c
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c2x %s
+// expected-no-diagnostics
+
+// FIXME: Test the correct value once C23 ships.
+_Static_assert(__STDC_VERSION__ > 201710L, "Incorrect __STDC_VERSION__");



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


[clang] 2edb89c - Lex arguments for __has_cpp_attribute and friends as expanded tokens

2021-10-17 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2021-10-17T07:54:48-04:00
New Revision: 2edb89c746848c52964537268bf03e7906bf2542

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

LOG: Lex arguments for __has_cpp_attribute and friends as expanded tokens

The C and C++ standards require the argument to __has_cpp_attribute and
__has_c_attribute to be expanded ([cpp.cond]p5). It would make little sense
to expand the argument to those operators but not expand the argument to
__has_attribute and __has_declspec, so those were both also changed in this
patch.

Note that it might make sense for the other builtins to also expand their
argument, but it wasn't as clear to me whether the behavior would be correct
there, and so they were left for a future revision.

Added: 
clang/test/Preprocessor/has_attribute_errors.cpp

Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Lex/PPMacroExpansion.cpp
clang/test/Preprocessor/has_attribute.c
clang/test/Preprocessor/has_attribute.cpp
clang/test/Preprocessor/has_c_attribute.c

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 6501a4870e2a6..263eae83036df 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -110,6 +110,13 @@ Attribute Changes in Clang
   attribute is handled instead, e.g. in ``handleDeclAttribute``.
   (This was changed in order to better support attributes in code completion).
 
+- __has_cpp_attribute, __has_c_attribute, __has_attribute, and __has_declspec
+  will now macro expand their argument. This causes a change in behavior for
+  code using ``__has_cpp_attribute(__clang__::attr)`` (and same for
+  ``__has_c_attribute``) where it would previously expand to ``0`` for all
+  attributes, but will now issue an error due to the expansion of the
+  predefined ``__clang__`` macro.
+
 Windows Support
 ---
 

diff  --git a/clang/lib/Lex/PPMacroExpansion.cpp 
b/clang/lib/Lex/PPMacroExpansion.cpp
index bf19f538647e6..5a0fa5184e38b 100644
--- a/clang/lib/Lex/PPMacroExpansion.cpp
+++ b/clang/lib/Lex/PPMacroExpansion.cpp
@@ -1293,7 +1293,7 @@ static bool EvaluateHasIncludeNext(Token ,
 /// integer values.
 static void EvaluateFeatureLikeBuiltinMacro(llvm::raw_svector_ostream& OS,
 Token , IdentifierInfo *II,
-Preprocessor ,
+Preprocessor , bool ExpandArgs,
 llvm::function_ref<
   int(Token ,
   bool )> Op) {
@@ -1319,7 +1319,10 @@ static void 
EvaluateFeatureLikeBuiltinMacro(llvm::raw_svector_ostream& OS,
   bool SuppressDiagnostic = false;
   while (true) {
 // Parse next token.
-PP.LexUnexpandedToken(Tok);
+if (ExpandArgs)
+  PP.Lex(Tok);
+else
+  PP.LexUnexpandedToken(Tok);
 
 already_lexed:
 switch (Tok.getKind()) {
@@ -1609,21 +1612,21 @@ void Preprocessor::ExpandBuiltinMacro(Token ) {
 OS << CounterValue++;
 Tok.setKind(tok::numeric_constant);
   } else if (II == Ident__has_feature) {
-EvaluateFeatureLikeBuiltinMacro(OS, Tok, II, *this,
+EvaluateFeatureLikeBuiltinMacro(OS, Tok, II, *this, false,
   [this](Token , bool ) -> int {
 IdentifierInfo *II = ExpectFeatureIdentifierInfo(Tok, *this,
diag::err_feature_check_malformed);
 return II && HasFeature(*this, II->getName());
   });
   } else if (II == Ident__has_extension) {
-EvaluateFeatureLikeBuiltinMacro(OS, Tok, II, *this,
+EvaluateFeatureLikeBuiltinMacro(OS, Tok, II, *this, false,
   [this](Token , bool ) -> int {
 IdentifierInfo *II = ExpectFeatureIdentifierInfo(Tok, *this,
diag::err_feature_check_malformed);
 return II && HasExtension(*this, II->getName());
   });
   } else if (II == Ident__has_builtin) {
-EvaluateFeatureLikeBuiltinMacro(OS, Tok, II, *this,
+EvaluateFeatureLikeBuiltinMacro(OS, Tok, II, *this, false,
   [this](Token , bool ) -> int {
 IdentifierInfo *II = ExpectFeatureIdentifierInfo(Tok, *this,
diag::err_feature_check_malformed);
@@ -1675,12 +1678,12 @@ void Preprocessor::ExpandBuiltinMacro(Token ) {
 }
   });
   } else if (II == Ident__is_identifier) {
-EvaluateFeatureLikeBuiltinMacro(OS, Tok, II, *this,
+EvaluateFeatureLikeBuiltinMacro(OS, Tok, II, *this, false,
   [](Token , bool ) -> int {
 return Tok.is(tok::identifier);
   });
   } else if (II == Ident__has_attribute) {
-EvaluateFeatureLikeBuiltinMacro(OS, Tok, II, *this,
+

[PATCH] D110258: [AArch64] Always add -tune-cpu argument to -cc1 driver

2021-10-17 Thread Dave Green via Phabricator via cfe-commits
dmgreen added a comment.

Now that we have the tests on the D111551  
side, I think this patch LGTM.

Do you think it's worth adding something to the release notes? "-mtune now 
actually works for AArch64". But, umm, perhaps better written than that.


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

https://reviews.llvm.org/D110258

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


[clang] 8efa651 - [RISCV][NFC] Fix build error

2021-10-17 Thread Kito Cheng via cfe-commits

Author: Kito Cheng
Date: 2021-10-17T16:38:53+08:00
New Revision: 8efa6512e0662b813ab783ed937768cef28e5a8b

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

LOG: [RISCV][NFC] Fix build error

Added: 


Modified: 
clang/lib/Driver/ToolChains/Arch/RISCV.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp 
b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
index a28348a7af169..6cb6d0b2d1fcc 100644
--- a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -212,7 +212,7 @@ StringRef riscv::getRISCVABI(const ArgList , const 
llvm::Triple ) {
 return "lp64d";
   return "lp64";
 }
-llvm_unreachable();
+llvm_unreachable("unhandled XLen");
   }
 
   // 3. Choose a default based on the triple



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


[PATCH] D105168: [RISCV] Unify the arch string parsing logic to RISCVISAInfo.

2021-10-17 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng added a comment.

Committed with one minor update for version of zba/zbb/zbc/zbs.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105168

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


[clang] ff13189 - [RISCV] Unify the arch string parsing logic to to RISCVISAInfo.

2021-10-17 Thread Kito Cheng via cfe-commits

Author: Kito Cheng
Date: 2021-10-17T16:25:23+08:00
New Revision: ff13189c5d0d96d0f955e9b1e951cf0ddc9e1d92

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

LOG: [RISCV] Unify the arch string parsing logic to to RISCVISAInfo.

How many place you need to modify when implementing a new extension for RISC-V?

At least 7 places as I know:

- Add new SubtargetFeature at RISCV.td
- -march parser in RISCV.cpp
- RISCVTargetInfo::initfeature...@riscv.cpp for handling feature vector.
- RISCVTargetInfo::gettargetdefi...@riscv.cpp for pre-define marco.
- Arch string parser for ELF attribute in RISCVAsmParser.cpp
- ELF attribute emittion in RISCVAsmParser.cpp, and make sure it's in
  canonical order...
- ELF attribute emittion in RISCVTargetStreamer.cpp, and again, must in
  canonical order...

And now, this patch provide an unified infrastructure for handling (almost)
everything of RISC-V arch string.

After this patch, you only need to update 2 places for implement an extension
for RISC-V:
- Add new SubtargetFeature at RISCV.td, hmmm, it's hard to avoid.
- Add new entry to riscvsupportedextens...@riscvisainfo.cpp or
  supportedexperimentalextensi...@riscvisainfo.cpp .

Most codes are come from existing -march parser, but with few new feature/bug
fixes:
- Accept version for -march, e.g. -march=rv32i2p0.
- Reject version info with `p` but without minor version number like `rv32i2p`.

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

Added: 
llvm/include/llvm/Support/RISCVISAInfo.h
llvm/lib/Support/RISCVISAInfo.cpp

Modified: 
clang/include/clang/Basic/DiagnosticCommonKinds.td
clang/lib/Basic/Targets/RISCV.cpp
clang/lib/Basic/Targets/RISCV.h
clang/lib/Driver/ToolChains/Arch/RISCV.cpp
clang/test/Driver/riscv-abi.c
clang/test/Driver/riscv-arch.c
clang/test/Driver/riscv-features.c
llvm/lib/Support/CMakeLists.txt
llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.cpp
llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
llvm/test/MC/RISCV/attribute-arch.s
llvm/test/MC/RISCV/attribute-with-insts.s
llvm/test/MC/RISCV/invalid-attribute.s

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticCommonKinds.td 
b/clang/include/clang/Basic/DiagnosticCommonKinds.td
index 4e21e276c69c5..1ed1c8cd9a19f 100644
--- a/clang/include/clang/Basic/DiagnosticCommonKinds.td
+++ b/clang/include/clang/Basic/DiagnosticCommonKinds.td
@@ -306,6 +306,8 @@ def err_opt_not_valid_without_opt : Error<
   "option '%0' cannot be specified without '%1'">;
 def err_opt_not_valid_on_target : Error<
   "option '%0' cannot be specified on this target">;
+def err_invalid_feature_combination : Error<
+  "invalid feature combination: %0">;
 
 // Source manager
 def err_cannot_open_file : Error<"cannot open file '%0': %1">, DefaultFatal;

diff  --git a/clang/lib/Basic/Targets/RISCV.cpp 
b/clang/lib/Basic/Targets/RISCV.cpp
index 00da8cdaef0b5..83b2fb95b3d1c 100644
--- a/clang/lib/Basic/Targets/RISCV.cpp
+++ b/clang/lib/Basic/Targets/RISCV.cpp
@@ -11,10 +11,12 @@
 
//===--===//
 
 #include "RISCV.h"
+#include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/MacroBuilder.h"
 #include "clang/Basic/TargetBuiltins.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Support/TargetParser.h"
+#include "llvm/Support/raw_ostream.h"
 
 using namespace clang;
 using namespace clang::targets;
@@ -122,6 +124,7 @@ void RISCVTargetInfo::getTargetDefines(const LangOptions 
,
   bool Is64Bit = getTriple().getArch() == llvm::Triple::riscv64;
   Builder.defineMacro("__riscv_xlen", Is64Bit ? "64" : "32");
   StringRef CodeModel = getTargetOpts().CodeModel;
+  unsigned FLen = ISAInfo->getFLen();
   if (CodeModel == "default")
 CodeModel = "small";
 
@@ -142,17 +145,23 @@ void RISCVTargetInfo::getTargetDefines(const LangOptions 
,
 Builder.defineMacro("__riscv_abi_rve");
 
   Builder.defineMacro("__riscv_arch_test");
-  Builder.defineMacro("__riscv_i", "200");
 
-  if (HasM) {
-Builder.defineMacro("__riscv_m", "200");
+  for (auto  : ISAInfo->getExtensions()) {
+auto ExtName = Extension.first;
+auto ExtInfo = Extension.second;
+unsigned Version =
+(ExtInfo.MajorVersion * 100) + (ExtInfo.MinorVersion * 1000);
+
+Builder.defineMacro(Twine("__riscv_", ExtName), Twine(Version));
+  }
+
+  if (ISAInfo->hasExtension("m")) {
 Builder.defineMacro("__riscv_mul");
 Builder.defineMacro("__riscv_div");
 Builder.defineMacro("__riscv_muldiv");
   }
 
-  if (HasA) {
-Builder.defineMacro("__riscv_a", "200");
+  if (ISAInfo->hasExtension("a")) {
 

[PATCH] D105168: [RISCV] Unify the arch string parsing logic to RISCVISAInfo.

2021-10-17 Thread 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 rGff13189c5d0d: [RISCV] Unify the arch string parsing logic to 
to RISCVISAInfo. (authored by Kito Cheng kito.ch...@sifive.com).

Changed prior to commit:
  https://reviews.llvm.org/D105168?vs=379329=380228#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105168

Files:
  clang/include/clang/Basic/DiagnosticCommonKinds.td
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/Basic/Targets/RISCV.h
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/test/Driver/riscv-abi.c
  clang/test/Driver/riscv-arch.c
  clang/test/Driver/riscv-features.c
  llvm/include/llvm/Support/RISCVISAInfo.h
  llvm/lib/Support/CMakeLists.txt
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
  llvm/test/MC/RISCV/attribute-arch.s
  llvm/test/MC/RISCV/attribute-with-insts.s
  llvm/test/MC/RISCV/invalid-attribute.s

Index: llvm/test/MC/RISCV/invalid-attribute.s
===
--- llvm/test/MC/RISCV/invalid-attribute.s
+++ llvm/test/MC/RISCV/invalid-attribute.s
@@ -7,10 +7,10 @@
 # RUN: not llvm-mc %s -triple=riscv64 -filetype=asm 2>&1 | FileCheck %s
 
 .attribute arch, "foo"
-# CHECK: [[@LINE-1]]:18: error: bad arch string foo
+# CHECK: [[@LINE-1]]:18: error: invalid arch name 'foo', string must begin with rv32{i,e,g} or rv64{i,g}
 
 .attribute arch, "rv32i2p0_y2p0"
-# CHECK: [[@LINE-1]]:18: error: bad arch string y2p0
+# CHECK: [[@LINE-1]]:18: error: invalid arch name 'rv32i2p0_y2p0', invalid standard user-level extension 'y'
 
 .attribute stack_align, "16"
 # CHECK: [[@LINE-1]]:25: error: expected numeric constant
Index: llvm/test/MC/RISCV/attribute-with-insts.s
===
--- llvm/test/MC/RISCV/attribute-with-insts.s
+++ llvm/test/MC/RISCV/attribute-with-insts.s
@@ -10,7 +10,7 @@
 # RUN:   | llvm-objdump --triple=riscv64 -d -M no-aliases - \
 # RUN:   | FileCheck -check-prefix=CHECK-INST %s
 
-.attribute arch, "rv64i2p0_m2p0_a2p0_d2p0_c2p0"
+.attribute arch, "rv64i2p0_m2p0_a2p0_f2p0_d2p0_c2p0"
 
 # CHECK-INST: lr.w t0, (t1)
 lr.w t0, (t1)
Index: llvm/test/MC/RISCV/attribute-arch.s
===
--- llvm/test/MC/RISCV/attribute-arch.s
+++ llvm/test/MC/RISCV/attribute-arch.s
@@ -9,9 +9,6 @@
 .attribute arch, "rv32i2"
 # CHECK: attribute  5, "rv32i2p0"
 
-.attribute arch, "rv32i2p"
-# CHECK: attribute  5, "rv32i2p0"
-
 .attribute arch, "rv32i2p0"
 # CHECK: attribute  5, "rv32i2p0"
 
@@ -33,11 +30,11 @@
 .attribute arch, "rv32ima2p0_fdc"
 # CHECK: attribute  5, "rv32i2p0_m2p0_a2p0_f2p0_d2p0_c2p0"
 
-.attribute arch, "rv32ima2p_fdc"
+.attribute arch, "rv32ima2p0_fdc"
 # CHECK: attribute  5, "rv32i2p0_m2p0_a2p0_f2p0_d2p0_c2p0"
 
 .attribute arch, "rv32iv"
-# CHECK: attribute  5, "rv32i2p0_v0p10"
+# CHECK: attribute  5, "rv32i2p0_v0p10_zvlsseg0p10"
 
 .attribute arch, "rv32izba"
 # CHECK: attribute  5, "rv32i2p0_zba1p0"
Index: llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
===
--- llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
+++ llvm/lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
@@ -11,9 +11,11 @@
 //===--===//
 
 #include "RISCVTargetStreamer.h"
+#include "RISCVBaseInfo.h"
 #include "RISCVMCTargetDesc.h"
 #include "llvm/Support/FormattedStream.h"
 #include "llvm/Support/RISCVAttributes.h"
+#include "llvm/Support/RISCVISAInfo.h"
 
 using namespace llvm;
 
@@ -43,53 +45,19 @@
   else
 emitAttribute(RISCVAttrs::STACK_ALIGN, RISCVAttrs::ALIGN_16);
 
-  std::string Arch = "rv32";
-  if (STI.hasFeature(RISCV::Feature64Bit))
-Arch = "rv64";
-  if (STI.hasFeature(RISCV::FeatureRV32E))
-Arch += "e1p9";
-  else
-Arch += "i2p0";
-  if (STI.hasFeature(RISCV::FeatureStdExtM))
-Arch += "_m2p0";
-  if (STI.hasFeature(RISCV::FeatureStdExtA))
-Arch += "_a2p0";
-  if (STI.hasFeature(RISCV::FeatureStdExtF))
-Arch += "_f2p0";
-  if (STI.hasFeature(RISCV::FeatureStdExtD))
-Arch += "_d2p0";
-  if (STI.hasFeature(RISCV::FeatureStdExtC))
-Arch += "_c2p0";
-  if (STI.hasFeature(RISCV::FeatureStdExtV))
-Arch += "_v0p10";
-  if (STI.hasFeature(RISCV::FeatureStdExtZfh))
-Arch += "_zfh0p1";
-  if (STI.hasFeature(RISCV::FeatureStdExtZba))
-Arch += "_zba1p0";
-  if (STI.hasFeature(RISCV::FeatureStdExtZbb))
-Arch += "_zbb1p0";
-  if (STI.hasFeature(RISCV::FeatureStdExtZbc))
-Arch += "_zbc1p0";
-  if 

[PATCH] D105168: [RISCV] Unify the arch string parsing logic to RISCVISAInfo.

2021-10-17 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng added inline comments.



Comment at: llvm/lib/Support/RISCVISAInfo.cpp:39
+
+static constexpr StringLiteral AllStdExts = "mafdqlcbjtpvn";
+

craig.topper wrote:
> 'b' shouldn't be in this list anymore?
I would prefer to keep that for sync with ISA manual, like other unsupported 
extension like `J`, `T` and ``N`, we remove `B` from `SupportedExtensions`, so 
keep this should be harmless.



Comment at: llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp:2089
 else
   return Error(ValueExprLoc, "bad arch string " + Arch);
   }

khchen wrote:
> maybe we could have a NFC patch later to add 
> ```
> // Emit the arch string if needed.
> if (!IsIntegerValue)
>   getTargetStreamer().emitTextAttribute(Tag, ISAInfo->toString());
> ```
> here to reuse `ISAInfo`, and remove 2098~2117 code.
> 
Good point, thanks :)
Let improve that by following patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105168

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


[clang] 1072699 - Use llvm::erase_value (NFC)

2021-10-17 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2021-10-16T23:31:21-07:00
New Revision: 10726992fad771e7c630fc511d85bb81a8d1562e

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

LOG: Use llvm::erase_value (NFC)

Added: 


Modified: 
clang/include/clang/Analysis/Analyses/Dominators.h
clang/include/clang/Basic/JsonSupport.h
clang/include/clang/Sema/ScopeInfo.h
clang/lib/AST/ASTContext.cpp
clang/lib/Sema/SemaExpr.cpp
lld/ELF/Writer.cpp
llvm/include/llvm/TableGen/DirectiveEmitter.h

Removed: 




diff  --git a/clang/include/clang/Analysis/Analyses/Dominators.h 
b/clang/include/clang/Analysis/Analyses/Dominators.h
index 25a5ba9d83fe3..f588a5c7d1d7b 100644
--- a/clang/include/clang/Analysis/Analyses/Dominators.h
+++ b/clang/include/clang/Analysis/Analyses/Dominators.h
@@ -202,7 +202,7 @@ struct ChildrenGetterTy {
 
 auto Children = children(N);
 ChildrenTy Ret{Children.begin(), Children.end()};
-Ret.erase(std::remove(Ret.begin(), Ret.end(), nullptr), Ret.end());
+llvm::erase_value(Ret, nullptr);
 return Ret;
   }
 };

diff  --git a/clang/include/clang/Basic/JsonSupport.h 
b/clang/include/clang/Basic/JsonSupport.h
index 8b02e440df447..6cd3f4d57b846 100644
--- a/clang/include/clang/Basic/JsonSupport.h
+++ b/clang/include/clang/Basic/JsonSupport.h
@@ -70,7 +70,7 @@ inline std::string JsonFormat(StringRef RawSR, bool 
AddQuotes) {
   }
 
   // Remove new-lines.
-  Str.erase(std::remove(Str.begin(), Str.end(), '\n'), Str.end());
+  llvm::erase_value(Str, '\n');
 
   if (!AddQuotes)
 return Str;

diff  --git a/clang/include/clang/Sema/ScopeInfo.h 
b/clang/include/clang/Sema/ScopeInfo.h
index 98ed75acd9d27..5c3bfe7e80cdc 100644
--- a/clang/include/clang/Sema/ScopeInfo.h
+++ b/clang/include/clang/Sema/ScopeInfo.h
@@ -1001,10 +1001,7 @@ class LambdaScopeInfo final :
 return NonODRUsedCapturingExprs.count(CapturingVarExpr);
   }
   void removePotentialCapture(Expr *E) {
-PotentiallyCapturingExprs.erase(
-std::remove(PotentiallyCapturingExprs.begin(),
-PotentiallyCapturingExprs.end(), E),
-PotentiallyCapturingExprs.end());
+llvm::erase_value(PotentiallyCapturingExprs, E);
   }
   void clearPotentialCaptures() {
 PotentiallyCapturingExprs.clear();

diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index d9017b347d812..1292cb6eb557c 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -1125,7 +1125,7 @@ void ASTContext::deduplicateMergedDefinitonsFor(NamedDecl 
*ND) {
   for (Module * : Merged)
 if (!Found.insert(M).second)
   M = nullptr;
-  Merged.erase(std::remove(Merged.begin(), Merged.end(), nullptr), 
Merged.end());
+  llvm::erase_value(Merged, nullptr);
 }
 
 ArrayRef

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 472b15b9ea06b..04f8540fe3b1f 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -16641,8 +16641,7 @@ void Sema::CheckUnusedVolatileAssignment(Expr *E) {
   if (auto *BO = dyn_cast(E->IgnoreParenImpCasts())) {
 if (BO->getOpcode() == BO_Assign) {
   auto  = ExprEvalContexts.back().VolatileAssignmentLHSs;
-  LHSs.erase(std::remove(LHSs.begin(), LHSs.end(), BO->getLHS()),
- LHSs.end());
+  llvm::erase_value(LHSs, BO->getLHS());
 }
   }
 }

diff  --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index 7a3b2747042e4..0e55e9cbdb57b 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -221,8 +221,7 @@ void elf::combineEhSections() {
 }
   }
 
-  std::vector  = inputSections;
-  v.erase(std::remove(v.begin(), v.end(), nullptr), v.end());
+  llvm::erase_value(inputSections, nullptr);
 }
 
 static Defined *addOptionalRegular(StringRef name, SectionBase *sec,

diff  --git a/llvm/include/llvm/TableGen/DirectiveEmitter.h 
b/llvm/include/llvm/TableGen/DirectiveEmitter.h
index 5c4a736eb1074..d73b9ae49235f 100644
--- a/llvm/include/llvm/TableGen/DirectiveEmitter.h
+++ b/llvm/include/llvm/TableGen/DirectiveEmitter.h
@@ -152,7 +152,7 @@ class Clause : public BaseRecord {
   }
   return C;
 });
-N.erase(std::remove(N.begin(), N.end(), '_'), N.end());
+llvm::erase_value(N, '_');
 return N;
   }
 



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