diff options
| author | Amir Ayupov <aaupov@fb.com> | 2024-12-14 22:37:18 -0800 |
|---|---|---|
| committer | Amir Ayupov <aaupov@fb.com> | 2024-12-14 22:37:18 -0800 |
| commit | 6eeb042b3c2149ae81168ff3cf45a2513e560343 (patch) | |
| tree | 886b43fb94de7bafc3aef3d80b33563531f474ef | |
| parent | 74352341f90078f7ace3c3814d18365b71fbe65c (diff) | |
| parent | 97f43364cc8599bfc64f4f83fb81c7cd0242a1a4 (diff) | |
[𝘀𝗽𝗿] changes introduced through rebaseusers/aaupov/spr/main.bolt-fix-counts-aggregation-in-merge-fdata
Created using spr 1.3.4
[skip ci]
168 files changed, 1784 insertions, 1273 deletions
diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index 86be15b72fb6..9ef0713ef8af 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -94,3 +94,6 @@ b6262880b34629e9d7a72b5a42f315a3c9ed8139 39c7dc7207e76e72da21cf4fedda21b5311bf62d e80bc777749331e9519575f416c342f7626dd14d 7e5cd8f1b6c5263ed5e2cc03d60c8779a8d3e9f7 + +# NFC: clang-format test_demangle.pass.cpp but keep test "lines" +d33bf2e9df578ff7e44fd22504d6ad5a122b7ee6 diff --git a/.github/workflows/build-ci-container-windows.yml b/.github/workflows/build-ci-container-windows.yml index 898cdce097e9..bba34066a97c 100644 --- a/.github/workflows/build-ci-container-windows.yml +++ b/.github/workflows/build-ci-container-windows.yml @@ -68,8 +68,8 @@ jobs: name: container - name: Push Container run: | - docker load -i ${{ needs.build-ci-container.outptus.container-filename }} - docker tag ${{ steps.vars.outputs.container-name-tag }} ${{ steps.vars.outputs.container-name }}:latest + docker load -i ${{ needs.build-ci-container-windows.outputs.container-filename }} + docker tag ${{ needs.build-ci-container-windows.outputs.container-name-tag }} ${{ needs.build-ci-container-windows.outputs.container-name }}:latest docker login -u ${{ github.actor }} -p $env:GITHUB_TOKEN ghcr.io - docker push ${{ needs.build-ci-container.outputs.container-name-tag }} - docker push ${{ needs.build-ci-container.outputs.container-name }}:latest + docker push ${{ needs.build-ci-container-windows.outputs.container-name-tag }} + docker push ${{ needs.build-ci-container-windows.outputs.container-name }}:latest diff --git a/.github/workflows/build-ci-container.yml b/.github/workflows/build-ci-container.yml index f037a91f6e5d..23bbb6ddef9e 100644 --- a/.github/workflows/build-ci-container.yml +++ b/.github/workflows/build-ci-container.yml @@ -80,8 +80,8 @@ jobs: - name: Push Container run: | - podman load -i ${{ needs.build-ci-container.outptus.container-filename }} - podman tag ${{ steps.vars.outputs.container-name-tag }} ${{ steps.vars.outputs.container-name }}:latest + podman load -i ${{ needs.build-ci-container.outputs.container-filename }} + podman tag ${{ needs.build-ci-container.outputs.container-name-tag }} ${{ needs.build-ci-container.outputs.container-name }}:latest podman login -u ${{ github.actor }} -p $GITHUB_TOKEN ghcr.io podman push ${{ needs.build-ci-container.outputs.container-name-tag }} podman push ${{ needs.build-ci-container.outputs.container-name }}:latest diff --git a/bolt/lib/Core/DebugNames.cpp b/bolt/lib/Core/DebugNames.cpp index f33ca83023a0..366c22c38e61 100644 --- a/bolt/lib/Core/DebugNames.cpp +++ b/bolt/lib/Core/DebugNames.cpp @@ -143,7 +143,8 @@ static bool shouldIncludeVariable(const DWARFUnit &Unit, const DIE &Die) { Unit.getFormParams().Format); for (const DWARFExpression::Operation &Expr : LocExpr) if (Expr.getCode() == dwarf::DW_OP_addrx || - Expr.getCode() == dwarf::DW_OP_form_tls_address) + Expr.getCode() == dwarf::DW_OP_form_tls_address || + Expr.getCode() == dwarf::DW_OP_GNU_push_tls_address) return true; return false; } diff --git a/bolt/test/X86/dwarf5-debug-names-gnu-push-tls-address.s b/bolt/test/X86/dwarf5-debug-names-gnu-push-tls-address.s new file mode 100644 index 000000000000..3f6ce71a7994 --- /dev/null +++ b/bolt/test/X86/dwarf5-debug-names-gnu-push-tls-address.s @@ -0,0 +1,327 @@ +# RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %s -o %tmain.o +# RUN: %clang %cflags -gdwarf-5 %tmain.o -o %tmain.exe +# RUN: llvm-bolt %tmain.exe -o %tmain.exe.bolt --update-debug-sections +# RUN: llvm-dwarfdump --debug-names --debug-info %tmain.exe.bolt > %tlog.txt +# RUN: cat %tlog.txt | FileCheck -check-prefix=BOLT %s + +## This test checks that BOLT correctly generates .debug_names section when there is DW_TAG_variable +## with DW_OP_GNU_push_tls_address in DW_AT_location. + +# BOLT: [[DIEOFFSET:0x[0-9a-f]*]]: DW_TAG_variable +# BOLT-NEXT: DW_AT_name ("x") +# BOLT-NEXT: DW_AT_type ({{.+}} "int") +# BOLT-NEXT: DW_AT_external (true) +# BOLT-NEXT: DW_AT_decl_file ("gnu_tls_push/main.cpp") +# BOLT-NEXT: DW_AT_decl_line (1) +# BOLT-NEXT: DW_AT_location (DW_OP_const8u 0x0, DW_OP_GNU_push_tls_address) +# BOLT: Hash: 0x2B61D +# BOLT-NEXT: String: {{.+}} "x" +# BOLT-NEXT: Entry @ {{.+}} { +# BOLT-NEXT: Abbrev: {{.+}} +# BOLT-NEXT: Tag: DW_TAG_variable +# BOLT-NEXT: DW_IDX_die_offset: [[DIEOFFSET]] +# BOLT-NEXT: DW_IDX_parent: <parent not indexed> + +## thread_local int x = 0; +## int main() { +## x = 10; +## return x; +## } + .text + .file "main.cpp" + .file 0 "gnu_tls_push" "main.cpp" md5 0x551db97d5e23dc6a81abdc5ade4d9d71 + .globl main # -- Begin function main + .p2align 4, 0x90 + .type main,@function +main: # @main +.Lfunc_begin0: + .loc 0 2 0 # main.cpp:2:0 + .cfi_startproc +# %bb.0: # %entry + pushq %rbp + .cfi_def_cfa_offset 16 + .cfi_offset %rbp, -16 + movq %rsp, %rbp + .cfi_def_cfa_register %rbp + movl $0, -4(%rbp) +.Ltmp0: + .loc 0 3 3 prologue_end # main.cpp:3:3 + movq %fs:0, %rax + leaq x@TPOFF(%rax), %rax + .loc 0 3 5 is_stmt 0 # main.cpp:3:5 + movl $10, (%rax) + .loc 0 4 10 is_stmt 1 # main.cpp:4:10 + movq %fs:0, %rax + leaq x@TPOFF(%rax), %rax + movl (%rax), %eax + .loc 0 4 3 epilogue_begin is_stmt 0 # main.cpp:4:3 + popq %rbp + .cfi_def_cfa %rsp, 8 + retq +.Ltmp1: +.Lfunc_end0: + .size main, .Lfunc_end0-main + .cfi_endproc + # -- End function + .section .text._ZTW1x,"axG",@progbits,_ZTW1x,comdat + .hidden _ZTW1x # -- Begin function _ZTW1x + .weak _ZTW1x + .p2align 4, 0x90 + .type _ZTW1x,@function +_ZTW1x: # @_ZTW1x +.Lfunc_begin1: + .cfi_startproc +# %bb.0: + pushq %rbp + .cfi_def_cfa_offset 16 + .cfi_offset %rbp, -16 + movq %rsp, %rbp + .cfi_def_cfa_register %rbp + movq %fs:0, %rax + leaq x@TPOFF(%rax), %rax + popq %rbp + .cfi_def_cfa %rsp, 8 + retq +.Lfunc_end1: + .size _ZTW1x, .Lfunc_end1-_ZTW1x + .cfi_endproc + # -- End function + .type x,@object # @x + .section .tbss,"awT",@nobits + .globl x + .p2align 2, 0x0 +x: + .long 0 # 0x0 + .size x, 4 + + .section .debug_abbrev,"",@progbits + .byte 1 # Abbreviation Code + .byte 17 # DW_TAG_compile_unit + .byte 1 # DW_CHILDREN_yes + .byte 37 # DW_AT_producer + .byte 37 # DW_FORM_strx1 + .byte 19 # DW_AT_language + .byte 5 # DW_FORM_data2 + .byte 3 # DW_AT_name + .byte 37 # DW_FORM_strx1 + .byte 114 # DW_AT_str_offsets_base + .byte 23 # DW_FORM_sec_offset + .byte 16 # DW_AT_stmt_list + .byte 23 # DW_FORM_sec_offset + .byte 27 # DW_AT_comp_dir + .byte 37 # DW_FORM_strx1 + .byte 17 # DW_AT_low_pc + .byte 27 # DW_FORM_addrx + .byte 18 # DW_AT_high_pc + .byte 6 # DW_FORM_data4 + .byte 115 # DW_AT_addr_base + .byte 23 # DW_FORM_sec_offset + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 2 # Abbreviation Code + .byte 52 # DW_TAG_variable + .byte 0 # DW_CHILDREN_no + .byte 3 # DW_AT_name + .byte 37 # DW_FORM_strx1 + .byte 73 # DW_AT_type + .byte 19 # DW_FORM_ref4 + .byte 63 # DW_AT_external + .byte 25 # DW_FORM_flag_present + .byte 58 # DW_AT_decl_file + .byte 11 # DW_FORM_data1 + .byte 59 # DW_AT_decl_line + .byte 11 # DW_FORM_data1 + .byte 2 # DW_AT_location + .byte 24 # DW_FORM_exprloc + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 3 # Abbreviation Code + .byte 36 # DW_TAG_base_type + .byte 0 # DW_CHILDREN_no + .byte 3 # DW_AT_name + .byte 37 # DW_FORM_strx1 + .byte 62 # DW_AT_encoding + .byte 11 # DW_FORM_data1 + .byte 11 # DW_AT_byte_size + .byte 11 # DW_FORM_data1 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 4 # Abbreviation Code + .byte 46 # DW_TAG_subprogram + .byte 0 # DW_CHILDREN_no + .byte 17 # DW_AT_low_pc + .byte 27 # DW_FORM_addrx + .byte 18 # DW_AT_high_pc + .byte 6 # DW_FORM_data4 + .byte 64 # DW_AT_frame_base + .byte 24 # DW_FORM_exprloc + .byte 3 # DW_AT_name + .byte 37 # DW_FORM_strx1 + .byte 58 # DW_AT_decl_file + .byte 11 # DW_FORM_data1 + .byte 59 # DW_AT_decl_line + .byte 11 # DW_FORM_data1 + .byte 73 # DW_AT_type + .byte 19 # DW_FORM_ref4 + .byte 63 # DW_AT_external + .byte 25 # DW_FORM_flag_present + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 0 # EOM(3) + .section .debug_info,"",@progbits +.Lcu_begin0: + .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit +.Ldebug_info_start0: + .short 5 # DWARF version number + .byte 1 # DWARF Unit Type + .byte 8 # Address Size (in bytes) + .long .debug_abbrev # Offset Into Abbrev. Section + .byte 1 # Abbrev [1] 0xc:0x3e DW_TAG_compile_unit + .byte 0 # DW_AT_producer + .short 33 # DW_AT_language + .byte 1 # DW_AT_name + .long .Lstr_offsets_base0 # DW_AT_str_offsets_base + .long .Lline_table_start0 # DW_AT_stmt_list + .byte 2 # DW_AT_comp_dir + .byte 0 # DW_AT_low_pc + .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc + .long .Laddr_table_base0 # DW_AT_addr_base + .byte 2 # Abbrev [2] 0x23:0x13 DW_TAG_variable + .byte 3 # DW_AT_name + .long 54 # DW_AT_type + # DW_AT_external + .byte 0 # DW_AT_decl_file + .byte 1 # DW_AT_decl_line + .byte 10 # DW_AT_location + .byte 14 + .quad x@DTPOFF + .byte 224 + .byte 3 # Abbrev [3] 0x36:0x4 DW_TAG_base_type + .byte 4 # DW_AT_name + .byte 5 # DW_AT_encoding + .byte 4 # DW_AT_byte_size + .byte 4 # Abbrev [4] 0x3a:0xf DW_TAG_subprogram + .byte 0 # DW_AT_low_pc + .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc + .byte 1 # DW_AT_frame_base + .byte 86 + .byte 5 # DW_AT_name + .byte 0 # DW_AT_decl_file + .byte 2 # DW_AT_decl_line + .long 54 # DW_AT_type + # DW_AT_external + .byte 0 # End Of Children Mark +.Ldebug_info_end0: + .section .debug_str_offsets,"",@progbits + .long 28 # Length of String Offsets Set + .short 5 + .short 0 +.Lstr_offsets_base0: + .section .debug_str,"MS",@progbits,1 +.Linfo_string0: + .asciz "clang version 17.0.4" # string offset=0 +.Linfo_string1: + .asciz "main.cpp" # string offset=137 +.Linfo_string2: + .asciz "gnu_tls_push" # string offset=146 +.Linfo_string3: + .asciz "x" # string offset=184 +.Linfo_string4: + .asciz "int" # string offset=186 +.Linfo_string5: + .asciz "main" # string offset=190 + .section .debug_str_offsets,"",@progbits + .long .Linfo_string0 + .long .Linfo_string1 + .long .Linfo_string2 + .long .Linfo_string3 + .long .Linfo_string4 + .long .Linfo_string5 + .section .debug_addr,"",@progbits + .long .Ldebug_addr_end0-.Ldebug_addr_start0 # Length of contribution +.Ldebug_addr_start0: + .short 5 # DWARF version number + .byte 8 # Address size + .byte 0 # Segment selector size +.Laddr_table_base0: + .quad .Lfunc_begin0 +.Ldebug_addr_end0: + .section .debug_names,"",@progbits + .long .Lnames_end0-.Lnames_start0 # Header: unit length +.Lnames_start0: + .short 5 # Header: version + .short 0 # Header: padding + .long 1 # Header: compilation unit count + .long 0 # Header: local type unit count + .long 0 # Header: foreign type unit count + .long 3 # Header: bucket count + .long 3 # Header: name count + .long .Lnames_abbrev_end0-.Lnames_abbrev_start0 # Header: abbreviation table size + .long 8 # Header: augmentation string size + .ascii "LLVM0700" # Header: augmentation string + .long .Lcu_begin0 # Compilation unit 0 + .long 1 # Bucket 0 + .long 2 # Bucket 1 + .long 3 # Bucket 2 + .long 177693 # Hash in Bucket 0 + .long 2090499946 # Hash in Bucket 1 + .long 193495088 # Hash in Bucket 2 + .long .Linfo_string3 # String in Bucket 0: x + .long .Linfo_string5 # String in Bucket 1: main + .long .Linfo_string4 # String in Bucket 2: int + .long .Lnames1-.Lnames_entries0 # Offset in Bucket 0 + .long .Lnames2-.Lnames_entries0 # Offset in Bucket 1 + .long .Lnames0-.Lnames_entries0 # Offset in Bucket 2 +.Lnames_abbrev_start0: + .byte 1 # Abbrev code + .byte 52 # DW_TAG_variable + .byte 3 # DW_IDX_die_offset + .byte 19 # DW_FORM_ref4 + .byte 4 # DW_IDX_parent + .byte 25 # DW_FORM_flag_present + .byte 0 # End of abbrev + .byte 0 # End of abbrev + .byte 2 # Abbrev code + .byte 46 # DW_TAG_subprogram + .byte 3 # DW_IDX_die_offset + .byte 19 # DW_FORM_ref4 + .byte 4 # DW_IDX_parent + .byte 25 # DW_FORM_flag_present + .byte 0 # End of abbrev + .byte 0 # End of abbrev + .byte 3 # Abbrev code + .byte 36 # DW_TAG_base_type + .byte 3 # DW_IDX_die_offset + .byte 19 # DW_FORM_ref4 + .byte 4 # DW_IDX_parent + .byte 25 # DW_FORM_flag_present + .byte 0 # End of abbrev + .byte 0 # End of abbrev + .byte 0 # End of abbrev list +.Lnames_abbrev_end0: +.Lnames_entries0: +.Lnames1: +.L2: + .byte 1 # Abbreviation code + .long 35 # DW_IDX_die_offset + .byte 0 # DW_IDX_parent + # End of list: x +.Lnames2: +.L0: + .byte 2 # Abbreviation code + .long 58 # DW_IDX_die_offset + .byte 0 # DW_IDX_parent + # End of list: main +.Lnames0: +.L1: + .byte 3 # Abbreviation code + .long 54 # DW_IDX_die_offset + .byte 0 # DW_IDX_parent + # End of list: int + .p2align 2, 0x0 +.Lnames_end0: + .ident "clang version 17.0.4 (https://git.internal.tfbnw.net/repos/git/rw/osmeta/external/llvm-project 8d1fd9f463cb31caf429b83cf7a5baea5f67e54a)" + .section ".note.GNU-stack","",@progbits + .addrsig + .section .debug_line,"",@progbits +.Lline_table_start0: diff --git a/clang-tools-extra/clang-tidy/bugprone/UncheckedOptionalAccessCheck.h b/clang-tools-extra/clang-tidy/bugprone/UncheckedOptionalAccessCheck.h index 2d1570f7df8a..e2fcccbfefb2 100644 --- a/clang-tools-extra/clang-tidy/bugprone/UncheckedOptionalAccessCheck.h +++ b/clang-tools-extra/clang-tidy/bugprone/UncheckedOptionalAccessCheck.h @@ -12,7 +12,6 @@ #include "../ClangTidyCheck.h" #include "clang/ASTMatchers/ASTMatchFinder.h" #include "clang/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.h" -#include <optional> namespace clang::tidy::bugprone { @@ -26,8 +25,7 @@ class UncheckedOptionalAccessCheck : public ClangTidyCheck { public: UncheckedOptionalAccessCheck(StringRef Name, ClangTidyContext *Context) : ClangTidyCheck(Name, Context), - ModelOptions{ - Options.getLocalOrGlobal("IgnoreSmartPointerDereference", false)} {} + ModelOptions{Options.get("IgnoreSmartPointerDereference", false)} {} void registerMatchers(ast_matchers::MatchFinder *Finder) override; void check(const ast_matchers::MatchFinder::MatchResult &Result) override; bool isLanguageVersionSupported(const LangOptions &LangOpts) const override { diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp index 225e867c9b24..d665c47d12bb 100644 --- a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp +++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp @@ -277,7 +277,7 @@ ProTypeMemberInitCheck::ProTypeMemberInitCheck(StringRef Name, ClangTidyContext *Context) : ClangTidyCheck(Name, Context), IgnoreArrays(Options.get("IgnoreArrays", false)), - UseAssignment(Options.getLocalOrGlobal("UseAssignment", false)) {} + UseAssignment(Options.get("UseAssignment", false)) {} void ProTypeMemberInitCheck::registerMatchers(MatchFinder *Finder) { auto IsUserProvidedNonDelegatingConstructor = diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/RvalueReferenceParamNotMovedCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/RvalueReferenceParamNotMovedCheck.cpp index 7db9e29e8fd0..8c386d5bc794 100644 --- a/clang-tools-extra/clang-tidy/cppcoreguidelines/RvalueReferenceParamNotMovedCheck.cpp +++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/RvalueReferenceParamNotMovedCheck.cpp @@ -119,11 +119,10 @@ void RvalueReferenceParamNotMovedCheck::check( RvalueReferenceParamNotMovedCheck::RvalueReferenceParamNotMovedCheck( StringRef Name, ClangTidyContext *Context) : ClangTidyCheck(Name, Context), - AllowPartialMove(Options.getLocalOrGlobal("AllowPartialMove", false)), - IgnoreUnnamedParams( - Options.getLocalOrGlobal("IgnoreUnnamedParams", false)), + AllowPartialMove(Options.get("AllowPartialMove", false)), + IgnoreUnnamedParams(Options.get("IgnoreUnnamedParams", false)), IgnoreNonDeducedTemplateTypes( - Options.getLocalOrGlobal("IgnoreNonDeducedTemplateTypes", false)) {} + Options.get("IgnoreNonDeducedTemplateTypes", false)) {} void RvalueReferenceParamNotMovedCheck::storeOptions( ClangTidyOptions::OptionMap &Opts) { diff --git a/clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.cpp b/clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.cpp index dc6e0cf9c7d1..94cb7ec38087 100644 --- a/clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.cpp +++ b/clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.cpp @@ -77,7 +77,7 @@ InefficientVectorOperationCheck::InefficientVectorOperationCheck( : ClangTidyCheck(Name, Context), VectorLikeClasses(utils::options::parseStringList( Options.get("VectorLikeClasses", "::std::vector"))), - EnableProto(Options.getLocalOrGlobal("EnableProto", false)) {} + EnableProto(Options.get("EnableProto", false)) {} void InefficientVectorOperationCheck::storeOptions( ClangTidyOptions::OptionMap &Opts) { diff --git a/clang-tools-extra/clang-tidy/readability/RedundantAccessSpecifiersCheck.h b/clang-tools-extra/clang-tidy/readability/RedundantAccessSpecifiersCheck.h index a5389d063f6c..566e5ea63798 100644 --- a/clang-tools-extra/clang-tidy/readability/RedundantAccessSpecifiersCheck.h +++ b/clang-tools-extra/clang-tidy/readability/RedundantAccessSpecifiersCheck.h @@ -21,8 +21,7 @@ class RedundantAccessSpecifiersCheck : public ClangTidyCheck { public: RedundantAccessSpecifiersCheck(StringRef Name, ClangTidyContext *Context) : ClangTidyCheck(Name, Context), - CheckFirstDeclaration( - Options.getLocalOrGlobal("CheckFirstDeclaration", false)) {} + CheckFirstDeclaration(Options.get("CheckFirstDeclaration", false)) {} bool isLanguageVersionSupported(const LangOptions &LangOpts) const override { return LangOpts.CPlusPlus; } diff --git a/clang-tools-extra/clang-tidy/readability/RedundantCastingCheck.cpp b/clang-tools-extra/clang-tidy/readability/RedundantCastingCheck.cpp index b9ff0e81cbc5..4d5adbe02f52 100644 --- a/clang-tools-extra/clang-tidy/readability/RedundantCastingCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/RedundantCastingCheck.cpp @@ -94,7 +94,7 @@ RedundantCastingCheck::RedundantCastingCheck(StringRef Name, ClangTidyContext *Context) : ClangTidyCheck(Name, Context), IgnoreMacros(Options.getLocalOrGlobal("IgnoreMacros", true)), - IgnoreTypeAliases(Options.getLocalOrGlobal("IgnoreTypeAliases", false)) {} + IgnoreTypeAliases(Options.get("IgnoreTypeAliases", false)) {} void RedundantCastingCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) { Options.store(Opts, "IgnoreMacros", IgnoreMacros); diff --git a/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp b/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp index 88e4886cd0df..9104723c7f1c 100644 --- a/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp +++ b/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp @@ -397,7 +397,7 @@ RenamerClangTidyCheck::RenamerClangTidyCheck(StringRef CheckName, ClangTidyContext *Context) : ClangTidyCheck(CheckName, Context), AggressiveDependentMemberLookup( - Options.getLocalOrGlobal("AggressiveDependentMemberLookup", false)) {} + Options.get("AggressiveDependentMemberLookup", false)) {} RenamerClangTidyCheck::~RenamerClangTidyCheck() = default; void RenamerClangTidyCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) { diff --git a/clang-tools-extra/docs/clang-tidy/index.rst b/clang-tools-extra/docs/clang-tidy/index.rst index a4233d5d8e26..f053e57e8d4c 100644 --- a/clang-tools-extra/docs/clang-tidy/index.rst +++ b/clang-tools-extra/docs/clang-tidy/index.rst @@ -9,7 +9,7 @@ See also: .. toctree:: :maxdepth: 1 - The list of clang-tidy checks <checks/list> + List of Clang-Tidy Checks <checks/list> Clang-tidy IDE/Editor Integrations <Integrations> Getting Involved <Contributing> External Clang-Tidy Examples <ExternalClang-TidyExamples> @@ -21,7 +21,7 @@ static analysis. :program:`clang-tidy` is modular and provides a convenient interface for writing new checks. -Using clang-tidy +Using Clang-Tidy ================ :program:`clang-tidy` is a `LibTooling`_-based tool, and it's easier to work diff --git a/clang/include/clang/Basic/Builtins.h b/clang/include/clang/Basic/Builtins.h index a9bb6efe850c..e27d8ccce736 100644 --- a/clang/include/clang/Basic/Builtins.h +++ b/clang/include/clang/Basic/Builtins.h @@ -55,7 +55,6 @@ struct HeaderDesc { #undef HEADER } ID; - constexpr HeaderDesc() : ID() {} constexpr HeaderDesc(HeaderID ID) : ID(ID) {} const char *getName() const; @@ -69,140 +68,14 @@ enum ID { FirstTSBuiltin }; -// The info used to represent each builtin. struct Info { - // Rather than store pointers to the string literals describing these four - // aspects of builtins, we store offsets into a common string table. - struct StrOffsets { - int Name; - int Type; - int Attributes; - int Features; - } Offsets; - + llvm::StringLiteral Name; + const char *Type, *Attributes; + const char *Features; HeaderDesc Header; LanguageID Langs; }; -// The storage for `N` builtins. This contains a single pointer to the string -// table used for these builtins and an array of metadata for each builtin. -template <size_t N> struct Storage { - const char *StringTable; - - std::array<Info, N> Infos; - - // A constexpr function to construct the storage for a a given string table in - // the first argument and an array in the second argument. This is *only* - // expected to be used at compile time, we should mark it `consteval` when - // available. - // - // The `Infos` array is particularly special. This function expects an array - // of `Info` structs, where the string offsets of each entry refer to the - // *sizes* of those strings rather than their offsets, and for the target - // string to be in the provided string table at an offset the sum of all - // previous string sizes. This function walks the `Infos` array computing the - // running sum and replacing the sizes with the actual offsets in the string - // table that should be used. This arrangement is designed to make it easy to - // expand `.def` and `.inc` files with X-macros to construct both the string - // table and the `Info` structs in the arguments to this function. - static constexpr Storage<N> Make(const char *Strings, - std::array<Info, N> Infos) { - // Translate lengths to offsets. - int Offset = 0; - for (auto &I : Infos) { - Info::StrOffsets NewOffsets = {}; - NewOffsets.Name = Offset; - Offset += I.Offsets.Name; - NewOffsets.Type = Offset; - Offset += I.Offsets.Type; - NewOffsets.Attributes = Offset; - Offset += I.Offsets.Attributes; - NewOffsets.Features = Offset; - Offset += I.Offsets.Features; - I.Offsets = NewOffsets; - } - return {Strings, Infos}; - } -}; - -// A detail macro used below to emit a string literal that, after string literal -// concatenation, ends up triggering the `-Woverlength-strings` warning. While -// the warning is useful in general to catch accidentally excessive strings, -// here we are creating them intentionally. -// -// This relies on a subtle aspect of `_Pragma`: that the *diagnostic* ones don't -// turn into actual tokens that would disrupt string literal concatenation. -#ifdef __clang__ -#define CLANG_BUILTIN_DETAIL_STR_TABLE(S) \ - _Pragma("clang diagnostic push") \ - _Pragma("clang diagnostic ignored \"-Woverlength-strings\"") \ - S _Pragma("clang diagnostic pop") -#else -#define CLANG_BUILTIN_DETAIL_STR_TABLE(S) S -#endif - -// A macro that can be used with `Builtins.def` and similar files as an X-macro -// to add the string arguments to a builtin string table. This is typically the -// target for the `BUILTIN`, `LANGBUILTIN`, or `LIBBUILTIN` macros in those -// files. -#define CLANG_BUILTIN_STR_TABLE(ID, TYPE, ATTRS) \ - CLANG_BUILTIN_DETAIL_STR_TABLE(#ID "\0" TYPE "\0" ATTRS "\0" /*FEATURE*/ "\0") - -// A macro that can be used with target builtin `.def` and `.inc` files as an -// X-macro to add the string arguments to a builtin string table. this is -// typically the target for the `TARGET_BUILTIN` macro. -#define CLANG_TARGET_BUILTIN_STR_TABLE(ID, TYPE, ATTRS, FEATURE) \ - CLANG_BUILTIN_DETAIL_STR_TABLE(#ID "\0" TYPE "\0" ATTRS "\0" FEATURE "\0") - -// A macro that can be used with target builtin `.def` and `.inc` files as an -// X-macro to add the string arguments to a builtin string table. this is -// typically the target for the `TARGET_HEADER_BUILTIN` macro. We can't delegate -// to `TARGET_BUILTIN` because the `FEATURE` string changes position. -#define CLANG_TARGET_HEADER_BUILTIN_STR_TABLE(ID, TYPE, ATTRS, HEADER, LANGS, \ - FEATURE) \ - CLANG_BUILTIN_DETAIL_STR_TABLE(#ID "\0" TYPE "\0" ATTRS "\0" FEATURE "\0") - -// A detail macro used internally to compute the desired string table -// `StrOffsets` struct for arguments to `Storage::Make`. -#define CLANG_BUILTIN_DETAIL_STR_OFFSETS(ID, TYPE, ATTRS) \ - Builtin::Info::StrOffsets { \ - sizeof(#ID), sizeof(TYPE), sizeof(ATTRS), sizeof("") \ - } - -// A detail macro used internally to compute the desired string table -// `StrOffsets` struct for arguments to `Storage::Make`. -#define CLANG_TARGET_BUILTIN_DETAIL_STR_OFFSETS(ID, TYPE, ATTRS, FEATURE) \ - Builtin::Info::StrOffsets { \ - sizeof(#ID), sizeof(TYPE), sizeof(ATTRS), sizeof(FEATURE) \ - } - -// A set of macros that can be used with builtin `.def' files as an X-macro to -// create an `Info` struct for a particular builtin. It both computes the -// `StrOffsets` value for the string table (the lengths here, translated to -// offsets by the Storage::Make function), and the other metadata for each -// builtin. -// -// There is a corresponding macro for each of `BUILTIN`, `LANGBUILTIN`, -// `LIBBUILTIN`, `TARGET_BUILTIN`, and `TARGET_HEADER_BUILTIN`. -#define CLANG_BUILTIN_ENTRY(ID, TYPE, ATTRS) \ - Builtin::Info{CLANG_BUILTIN_DETAIL_STR_OFFSETS(ID, TYPE, ATTRS), \ - HeaderDesc::NO_HEADER, ALL_LANGUAGES}, -#define CLANG_LANGBUILTIN_ENTRY(ID, TYPE, ATTRS, LANG) \ - Builtin::Info{CLANG_BUILTIN_DETAIL_STR_OFFSETS(ID, TYPE, ATTRS), \ - HeaderDesc::NO_HEADER, LANG}, -#define CLANG_LIBBUILTIN_ENTRY(ID, TYPE, ATTRS, HEADER, LANG) \ - Builtin::Info{CLANG_BUILTIN_DETAIL_STR_OFFSETS(ID, TYPE, ATTRS), \ - HeaderDesc::HEADER, LANG}, -#define CLANG_TARGET_BUILTIN_ENTRY(ID, TYPE, ATTRS, FEATURE) \ - Builtin::Info{ \ - CLANG_TARGET_BUILTIN_DETAIL_STR_OFFSETS(ID, TYPE, ATTRS, FEATURE), \ - HeaderDesc::NO_HEADER, ALL_LANGUAGES}, -#define CLANG_TARGET_HEADER_BUILTIN_ENTRY(ID, TYPE, ATTRS, HEADER, LANG, \ - FEATURE) \ - Builtin::Info{ \ - CLANG_TARGET_BUILTIN_DETAIL_STR_OFFSETS(ID, TYPE, ATTRS, FEATURE), \ - HeaderDesc::HEADER, LANG}, - /// Holds information about both target-independent and /// target-specific builtins, allowing easy queries by clients. /// @@ -210,11 +83,8 @@ template <size_t N> struct Storage { /// AuxTSRecords. Their IDs are shifted up by TSRecords.size() and need to /// be translated back with getAuxBuiltinID() before use. class Context { - const char *TSStrTable = nullptr; - const char *AuxTSStrTable = nullptr; - - llvm::ArrayRef<Info> TSInfos; - llvm::ArrayRef<Info> AuxTSInfos; + llvm::ArrayRef<Info> TSRecords; + llvm::ArrayRef<Info> AuxTSRecords; public: Context() = default; @@ -230,13 +100,10 @@ public: /// Return the identifier name for the specified builtin, /// e.g. "__builtin_abs". - llvm::StringRef getName(unsigned ID) const; + llvm::StringRef getName(unsigned ID) const { return getRecord(ID).Name; } /// Get the type descriptor string for the specified builtin. - const char *getTypeString(unsigned ID) const; - - /// Get the attributes descriptor string for the specified builtin. - const char *getAttributesString(unsigned ID) const; + const char *getTypeString(unsigned ID) const { return getRecord(ID).Type; } /// Return true if this function is a target-specific builtin. bool isTSBuiltin(unsigned ID) const { @@ -245,40 +112,40 @@ public: /// Return true if this function has no side effects. bool isPure(unsigned ID) const { - return strchr(getAttributesString(ID), 'U') != nullptr; + return strchr(getRecord(ID).Attributes, 'U') != nullptr; } /// Return true if this function has no side effects and doesn't /// read memory. bool isConst(unsigned ID) const { - return strchr(getAttributesString(ID), 'c') != nullptr; + return strchr(getRecord(ID).Attributes, 'c') != nullptr; } /// Return true if we know this builtin never throws an exception. bool isNoThrow(unsigned ID) const { - return strchr(getAttributesString(ID), 'n') != nullptr; + return strchr(getRecord(ID).Attributes, 'n') != nullptr; } /// Return true if we know this builtin never returns. bool isNoReturn(unsigned ID) const { - return strchr(getAttributesString(ID), 'r') != nullptr; + return strchr(getRecord(ID).Attributes, 'r') != nullptr; } /// Return true if we know this builtin can return twice. bool isReturnsTwice(unsigned ID) const { - return strchr(getAttributesString(ID), 'j') != nullptr; + return strchr(getRecord(ID).Attributes, 'j') != nullptr; } /// Returns true if this builtin does not perform the side-effects /// of its arguments. bool isUnevaluated(unsigned ID) const { - return strchr(getAttributesString(ID), 'u') != nullptr; + return strchr(getRecord(ID).Attributes, 'u') != nullptr; } /// Return true if this is a builtin for a libc/libm function, /// with a "__builtin_" prefix (e.g. __builtin_abs). bool isLibFunction(unsigned ID) const { - return strchr(getAttributesString(ID), 'F') != nullptr; + return strchr(getRecord(ID).Attributes, 'F') != nullptr; } /// Determines whether this builtin is a predefined libc/libm @@ -289,21 +156,21 @@ public: /// they do not, but they are recognized as builtins once we see /// a declaration. bool isPredefinedLibFunction(unsigned ID) const { - return strchr(getAttributesString(ID), 'f') != nullptr; + return strchr(getRecord(ID).Attributes, 'f') != nullptr; } /// Returns true if this builtin requires appropriate header in other /// compilers. In Clang it will work even without including it, but we can emit /// a warning about missing header. bool isHeaderDependentFunction(unsigned ID) const { - return strchr(getAttributesString(ID), 'h') != nullptr; + return strchr(getRecord(ID).Attributes, 'h') != nullptr; } /// Determines whether this builtin is a predefined compiler-rt/libgcc /// function, such as "__clear_cache", where we know the signature a /// priori. bool isPredefinedRuntimeFunction(unsigned ID) const { - return strchr(getAttributesString(ID), 'i') != nullptr; + return strchr(getRecord(ID).Attributes, 'i') != nullptr; } /// Determines whether this builtin is a C++ standard library function @@ -311,7 +178,7 @@ public: /// specialization, where the signature is determined by the standard library /// declaration. bool isInStdNamespace(unsigned ID) const { - return strchr(getAttributesString(ID), 'z') != nullptr; + return strchr(getRecord(ID).Attributes, 'z') != nullptr; } /// Determines whether this builtin can have its address taken with no @@ -325,33 +192,33 @@ public: /// Determines whether this builtin has custom typechecking. bool hasCustomTypechecking(unsigned ID) const { - return strchr(getAttributesString(ID), 't') != nullptr; + return strchr(getRecord(ID).Attributes, 't') != nullptr; } /// Determines whether a declaration of this builtin should be recognized /// even if the type doesn't match the specified signature. bool allowTypeMismatch(unsigned ID) const { - return strchr(getAttributesString(ID), 'T') != nullptr || + return strchr(getRecord(ID).Attributes, 'T') != nullptr || hasCustomTypechecking(ID); } /// Determines whether this builtin has a result or any arguments which /// are pointer types. bool hasPtrArgsOrResult(unsigned ID) const { - return strchr(getTypeString(ID), '*') != nullptr; + return strchr(getRecord(ID).Type, '*') != nullptr; } /// Return true if this builtin has a result or any arguments which are /// reference types. bool hasReferenceArgsOrResult(unsigned ID) const { - return strchr(getTypeString(ID), '&') != nullptr || - strchr(getTypeString(ID), 'A') != nullptr; + return strchr(getRecord(ID).Type, '&') != nullptr || + strchr(getRecord(ID).Type, 'A') != nullptr; } /// If this is a library function that comes from a specific /// header, retrieve that header name. const char *getHeaderName(unsigned ID) const { - return getInfo(ID).Header.getName(); + return getRecord(ID).Header.getName(); } /// Determine whether this builtin is like printf in its @@ -376,25 +243,27 @@ public: /// Such functions can be const when the MathErrno lang option and FP /// exceptions are disabled. bool isConstWithoutErrnoAndExceptions(unsigned ID) const { - return strchr(getAttributesString(ID), 'e') != nullptr; + return strchr(getRecord(ID).Attributes, 'e') != nullptr; } bool isConstWithoutExceptions(unsigned ID) const { - return strchr(getAttributesString(ID), 'g') != nullptr; + return strchr(getRecord(ID).Attributes, 'g') != nullptr; } - const char *getRequiredFeatures(unsigned ID) const; + const char *getRequiredFeatures(unsigned ID) const { + return getRecord(ID).Features; + } unsigned getRequiredVectorWidth(unsigned ID) const; /// Return true if builtin ID belongs to AuxTarget. bool isAuxBuiltinID(unsigned ID) const { - return ID >= (Builtin::FirstTSBuiltin + TSInfos.size()); + return ID >= (Builtin::FirstTSBuiltin + TSRecords.size()); } /// Return real builtin ID (i.e. ID it would have during compilation /// for AuxTarget). - unsigned getAuxBuiltinID(unsigned ID) const { return ID - TSInfos.size(); } + unsigned getAuxBuiltinID(unsigned ID) const { return ID - TSRecords.size(); } /// Returns true if this is a libc/libm function without the '__builtin_' /// prefix. @@ -406,20 +275,16 @@ public: /// Return true if this function can be constant evaluated by Clang frontend. bool isConstantEvaluated(unsigned ID) const { - return strchr(getAttributesString(ID), 'E') != nullptr; + return strchr(getRecord(ID).Attributes, 'E') != nullptr; } /// Returns true if this is an immediate (consteval) function bool isImmediate(unsigned ID) const { - return strchr(getAttributesString(ID), 'G') != nullptr; + return strchr(getRecord(ID).Attributes, 'G') != nullptr; } private: - std::pair<const char *, const Info &> getStrTableAndInfo(unsigned ID) const; - - const Info &getInfo(unsigned ID) const { - return getStrTableAndInfo(ID).second; - } + const Info &getRecord(unsigned ID) const; /// Helper function for isPrintfLike and isScanfLike. bool isLike(unsigned ID, unsigned &FormatIdx, bool &HasVAListArg, diff --git a/clang/include/clang/Basic/BuiltinsPPC.def b/clang/include/clang/Basic/BuiltinsPPC.def index bb7d54bbb793..161df386f00f 100644 --- a/clang/include/clang/Basic/BuiltinsPPC.def +++ b/clang/include/clang/Basic/BuiltinsPPC.def @@ -1138,6 +1138,5 @@ UNALIASED_CUSTOM_BUILTIN(mma_pmxvbf16ger2nn, "vW512*VVi15i15i3", true, // FIXME: Obviously incomplete. #undef BUILTIN -#undef TARGET_BUILTIN #undef CUSTOM_BUILTIN #undef UNALIASED_CUSTOM_BUILTIN diff --git a/clang/include/clang/Basic/TargetInfo.h b/clang/include/clang/Basic/TargetInfo.h index 52a1ac978139..82bd537b242c 100644 --- a/clang/include/clang/Basic/TargetInfo.h +++ b/clang/include/clang/Basic/TargetInfo.h @@ -16,7 +16,6 @@ #include "clang/Basic/AddressSpaces.h" #include "clang/Basic/BitmaskEnum.h" -#include "clang/Basic/Builtins.h" #include "clang/Basic/CFProtectionOptions.h" #include "clang/Basic/CodeGenOptions.h" #include "clang/Basic/LLVM.h" @@ -1010,11 +1009,10 @@ public: virtual void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const = 0; - /// Return information about target-specific builtins for the current primary - /// target, and info about which builtins are non-portable across the current - /// set of primary and secondary targets. - virtual std::pair<const char *, ArrayRef<Builtin::Info>> - getTargetBuiltinStorage() const = 0; + /// Return information about target-specific builtins for + /// the current primary target, and info about which builtins are non-portable + /// across the current set of primary and secondary targets. + virtual ArrayRef<Builtin::Info> getTargetBuiltins() const = 0; /// Returns target-specific min and max values VScale_Range. virtual std::optional<std::pair<unsigned, unsigned>> diff --git a/clang/lib/Analysis/ThreadSafetyCommon.cpp b/clang/lib/Analysis/ThreadSafetyCommon.cpp index 211e940ce8b8..050daee1168d 100644 --- a/clang/lib/Analysis/ThreadSafetyCommon.cpp +++ b/clang/lib/Analysis/ThreadSafetyCommon.cpp @@ -135,14 +135,30 @@ CapabilityExpr SExprBuilder::translateAttrExpr(const Expr *AttrExp, Ctx.NumArgs = CE->getNumArgs(); Ctx.FunArgs = CE->getArgs(); } else if (const auto *CE = dyn_cast<CallExpr>(DeclExp)) { - Ctx.NumArgs = CE->getNumArgs(); - Ctx.FunArgs = CE->getArgs(); + // Calls to operators that are members need to be treated like member calls. + if (isa<CXXOperatorCallExpr>(CE) && isa<CXXMethodDecl>(D)) { + Ctx.SelfArg = CE->getArg(0); + Ctx.SelfArrow = false; + Ctx.NumArgs = CE->getNumArgs() - 1; + Ctx.FunArgs = CE->getArgs() + 1; + } else { + Ctx.NumArgs = CE->getNumArgs(); + Ctx.FunArgs = CE->getArgs(); + } } else if (const auto *CE = dyn_cast<CXXConstructExpr>(DeclExp)) { Ctx.SelfArg = nullptr; // Will be set below Ctx.NumArgs = CE->getNumArgs(); Ctx.FunArgs = CE->getArgs(); } + // Usually we want to substitute the self-argument for "this", but lambdas + // are an exception: "this" on or in a lambda call operator doesn't refer + // to the lambda, but to captured "this" in the context it was created in. + // This can happen for operator calls and member calls, so fix it up here. + if (const auto *CMD = dyn_cast<CXXMethodDecl>(D)) + if (CMD->getParent()->isLambda()) + Ctx.SelfArg = nullptr; + if (Self) { assert(!Ctx.SelfArg && "Ambiguous self argument"); assert(isa<FunctionDecl>(D) && "Self argument requires function"); diff --git a/clang/lib/Basic/Builtins.cpp b/clang/lib/Basic/Builtins.cpp index c991139b8d5a..8dd1888db298 100644 --- a/clang/lib/Basic/Builtins.cpp +++ b/clang/lib/Basic/Builtins.cpp @@ -29,93 +29,54 @@ const char *HeaderDesc::getName() const { llvm_unreachable("Unknown HeaderDesc::HeaderID enum"); } -static constexpr auto BuiltinStorage = - Builtin::Storage<Builtin::FirstTSBuiltin>::Make( - CLANG_BUILTIN_STR_TABLE("not a builtin function", "", "") -#define BUILTIN CLANG_BUILTIN_STR_TABLE +static constexpr Builtin::Info BuiltinInfo[] = { + {"not a builtin function", nullptr, nullptr, nullptr, HeaderDesc::NO_HEADER, + ALL_LANGUAGES}, +#define BUILTIN(ID, TYPE, ATTRS) \ + {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES}, +#define LANGBUILTIN(ID, TYPE, ATTRS, LANGS) \ + {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, LANGS}, +#define LIBBUILTIN(ID, TYPE, ATTRS, HEADER, LANGS) \ + {#ID, TYPE, ATTRS, nullptr, HeaderDesc::HEADER, LANGS}, #include "clang/Basic/Builtins.inc" - , - {CLANG_BUILTIN_ENTRY("not a builtin function", "", "") -#define BUILTIN CLANG_BUILTIN_ENTRY -#define LANGBUILTIN CLANG_LANGBUILTIN_ENTRY -#define LIBBUILTIN CLANG_LIBBUILTIN_ENTRY -#include "clang/Basic/Builtins.inc" - }); +}; -std::pair<const char *, const Builtin::Info &> -Builtin::Context::getStrTableAndInfo(unsigned ID) const { +const Builtin::Info &Builtin::Context::getRecord(unsigned ID) const { if (ID < Builtin::FirstTSBuiltin) - return {BuiltinStorage.StringTable, BuiltinStorage.Infos[ID]}; - assert( - ((ID - Builtin::FirstTSBuiltin) < (TSInfos.size() + AuxTSInfos.size())) && - "Invalid builtin ID!"); + return BuiltinInfo[ID]; + assert(((ID - Builtin::FirstTSBuiltin) < + (TSRecords.size() + AuxTSRecords.size())) && + "Invalid builtin ID!"); if (isAuxBuiltinID(ID)) - return {AuxTSStrTable, - AuxTSInfos[getAuxBuiltinID(ID) - Builtin::FirstTSBuiltin]}; - return {TSStrTable, TSInfos[ID - Builtin::FirstTSBuiltin]}; -} - -static llvm::StringRef getStrFromTable(const char *StrTable, int Offset) { - return &StrTable[Offset]; -} - -/// Return the identifier name for the specified builtin, -/// e.g. "__builtin_abs". -llvm::StringRef Builtin::Context::getName(unsigned ID) const { - const auto &[StrTable, I] = getStrTableAndInfo(ID); - return getStrFromTable(StrTable, I.Offsets.Name); -} - -const char *Builtin::Context::getTypeString(unsigned ID) const { - const auto &[StrTable, I] = getStrTableAndInfo(ID); - return getStrFromTable(StrTable, I.Offsets.Type).data(); -} - -const char *Builtin::Context::getAttributesString(unsigned ID) const { - const auto &[StrTable, I] = getStrTableAndInfo(ID); - return getStrFromTable(StrTable, I.Offsets.Attributes).data(); -} - -const char *Builtin::Context::getRequiredFeatures(unsigned ID) const { - const auto &[StrTable, I] = getStrTableAndInfo(ID); - return getStrFromTable(StrTable, I.Offsets.Features).data(); + return AuxTSRecords[getAuxBuiltinID(ID) - Builtin::FirstTSBuiltin]; + return TSRecords[ID - Builtin::FirstTSBuiltin]; } void Builtin::Context::InitializeTarget(const TargetInfo &Target, const TargetInfo *AuxTarget) { - assert(TSStrTable == nullptr && "Already initialized target?"); - assert(TSInfos.empty() && "Already initialized target?"); - std::tie(TSStrTable, TSInfos) = Target.getTargetBuiltinStorage(); - if (AuxTarget) { - std::tie(AuxTSStrTable, AuxTSInfos) = AuxTarget->getTargetBuiltinStorage(); - } + assert(TSRecords.empty() && "Already initialized target?"); + TSRecords = Target.getTargetBuiltins(); + if (AuxTarget) + AuxTSRecords = AuxTarget->getTargetBuiltins(); } bool Builtin::Context::isBuiltinFunc(llvm::StringRef FuncName) { bool InStdNamespace = FuncName.consume_front("std-"); - const char *StrTable = BuiltinStorage.StringTable; for (unsigned i = Builtin::NotBuiltin + 1; i != Builtin::FirstTSBuiltin; ++i) { - const auto &I = BuiltinStorage.Infos[i]; - if (FuncName == getStrFromTable(StrTable, I.Offsets.Name) && - (bool)strchr(getStrFromTable(StrTable, I.Offsets.Attributes).data(), - 'z') == InStdNamespace) - return strchr(getStrFromTable(StrTable, I.Offsets.Attributes).data(), - 'f') != nullptr; + if (FuncName == BuiltinInfo[i].Name && + (bool)strchr(BuiltinInfo[i].Attributes, 'z') == InStdNamespace) + return strchr(BuiltinInfo[i].Attributes, 'f') != nullptr; } return false; } /// Is this builtin supported according to the given language options? -static bool builtinIsSupported(const char *StrTable, - const Builtin::Info &BuiltinInfo, +static bool builtinIsSupported(const Builtin::Info &BuiltinInfo, const LangOptions &LangOpts) { - auto AttributesStr = - getStrFromTable(StrTable, BuiltinInfo.Offsets.Attributes); - /* Builtins Unsupported */ - if (LangOpts.NoBuiltin && strchr(AttributesStr.data(), 'f') != nullptr) + if (LangOpts.NoBuiltin && strchr(BuiltinInfo.Attributes, 'f') != nullptr) return false; /* CorBuiltins Unsupported */ if (!LangOpts.Coroutines && (BuiltinInfo.Langs & COR_LANG)) @@ -162,7 +123,7 @@ static bool builtinIsSupported(const char *StrTable, if (!LangOpts.CPlusPlus && BuiltinInfo.Langs == CXX_LANG) return false; /* consteval Unsupported */ - if (!LangOpts.CPlusPlus20 && strchr(AttributesStr.data(), 'G') != nullptr) + if (!LangOpts.CPlusPlus20 && strchr(BuiltinInfo.Attributes, 'G') != nullptr) return false; return true; } @@ -173,23 +134,20 @@ static bool builtinIsSupported(const char *StrTable, void Builtin::Context::initializeBuiltins(IdentifierTable &Table, const LangOptions& LangOpts) { // Step #1: mark all target-independent builtins with their ID's. - for (const auto &&[Index, I] : - llvm::enumerate(llvm::ArrayRef(BuiltinStorage.Infos).drop_front())) - if (builtinIsSupported(BuiltinStorage.StringTable, I, LangOpts)) { - Table.get(getStrFromTable(BuiltinStorage.StringTable, I.Offsets.Name)) - .setBuiltinID(Index + 1); + for (unsigned i = Builtin::NotBuiltin + 1; i != Builtin::FirstTSBuiltin; ++i) + if (builtinIsSupported(BuiltinInfo[i], LangOpts)) { + Table.get(BuiltinInfo[i].Name).setBuiltinID(i); } // Step #2: Register target-specific builtins. - for (const auto &&[Index, I] : llvm::enumerate(TSInfos)) - if (builtinIsSupported(TSStrTable, I, LangOpts)) - Table.get(getStrFromTable(TSStrTable, I.Offsets.Name)) - .setBuiltinID(Index + Builtin::FirstTSBuiltin); + for (unsigned i = 0, e = TSRecords.size(); i != e; ++i) + if (builtinIsSupported(TSRecords[i], LangOpts)) + Table.get(TSRecords[i].Name).setBuiltinID(i + Builtin::FirstTSBuiltin); // Step #3: Register target-specific builtins for AuxTarget. - for (const auto &&[Index, I] : llvm::enumerate(AuxTSInfos)) - Table.get(getStrFromTable(AuxTSStrTable, I.Offsets.Name)) - .setBuiltinID(Index + Builtin::FirstTSBuiltin + TSInfos.size()); + for (unsigned i = 0, e = AuxTSRecords.size(); i != e; ++i) + Table.get(AuxTSRecords[i].Name) + .setBuiltinID(i + Builtin::FirstTSBuiltin + TSRecords.size()); // Step #4: Unregister any builtins specified by -fno-builtin-foo. for (llvm::StringRef Name : LangOpts.NoBuiltinFuncs) { @@ -206,7 +164,7 @@ void Builtin::Context::initializeBuiltins(IdentifierTable &Table, } unsigned Builtin::Context::getRequiredVectorWidth(unsigned ID) const { - const char *WidthPos = ::strchr(getAttributesString(ID), 'V'); + const char *WidthPos = ::strchr(getRecord(ID).Attributes, 'V'); if (!WidthPos) return 0; @@ -229,7 +187,7 @@ bool Builtin::Context::isLike(unsigned ID, unsigned &FormatIdx, assert(::toupper(Fmt[0]) == Fmt[1] && "Format string is not in the form \"xX\""); - const char *Like = ::strpbrk(getAttributesString(ID), Fmt); + const char *Like = ::strpbrk(getRecord(ID).Attributes, Fmt); if (!Like) return false; @@ -256,7 +214,7 @@ bool Builtin::Context::isScanfLike(unsigned ID, unsigned &FormatIdx, bool Builtin::Context::performsCallback(unsigned ID, SmallVectorImpl<int> &Encoding) const { - const char *CalleePos = ::strchr(getAttributesString(ID), 'C'); + const char *CalleePos = ::strchr(getRecord(ID).Attributes, 'C'); if (!CalleePos) return false; diff --git a/clang/lib/Basic/Targets/AArch64.cpp b/clang/lib/Basic/Targets/AArch64.cpp index 858f83d090d7..53e102bbe446 100644 --- a/clang/lib/Basic/Targets/AArch64.cpp +++ b/clang/lib/Basic/Targets/AArch64.cpp @@ -26,39 +26,35 @@ using namespace clang; using namespace clang::targets; -static constexpr int NumBuiltins = - clang::AArch64::LastTSBuiltin - Builtin::FirstTSBuiltin; - -static constexpr auto BuiltinStorage = Builtin::Storage<NumBuiltins>::Make( -#define BUILTIN CLANG_BUILTIN_STR_TABLE -#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_STR_TABLE -#include "clang/Basic/BuiltinsNEON.def" -#define BUILTIN CLANG_BUILTIN_STR_TABLE -#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_STR_TABLE -#include "clang/Basic/BuiltinsSVE.def" -#define BUILTIN CLANG_BUILTIN_STR_TABLE -#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_STR_TABLE -#include "clang/Basic/BuiltinsSME.def" -#define BUILTIN CLANG_BUILTIN_STR_TABLE -#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_STR_TABLE -#define TARGET_HEADER_BUILTIN CLANG_TARGET_HEADER_BUILTIN_STR_TABLE -#include "clang/Basic/BuiltinsAArch64.def" - , { -#define BUILTIN CLANG_BUILTIN_ENTRY -#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_ENTRY +static constexpr Builtin::Info BuiltinInfo[] = { +#define BUILTIN(ID, TYPE, ATTRS) \ + {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES}, +#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \ + {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::NO_HEADER, ALL_LANGUAGES}, #include "clang/Basic/BuiltinsNEON.def" -#define BUILTIN CLANG_BUILTIN_ENTRY -#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_ENTRY + +#define BUILTIN(ID, TYPE, ATTRS) \ + {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES}, +#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \ + {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::NO_HEADER, ALL_LANGUAGES}, #include "clang/Basic/BuiltinsSVE.def" -#define BUILTIN CLANG_BUILTIN_ENTRY -#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_ENTRY + +#define BUILTIN(ID, TYPE, ATTRS) \ + {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES}, +#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \ + {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::NO_HEADER, ALL_LANGUAGES}, #include "clang/Basic/BuiltinsSME.def" -#define BUILTIN CLANG_BUILTIN_ENTRY -#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_ENTRY -#define LANGBUILTIN CLANG_LANGBUILTIN_ENTRY -#define TARGET_HEADER_BUILTIN CLANG_TARGET_HEADER_BUILTIN_ENTRY + +#define BUILTIN(ID, TYPE, ATTRS) \ + {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES}, +#define LANGBUILTIN(ID, TYPE, ATTRS, LANG) \ + {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, LANG}, +#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \ + {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::NO_HEADER, ALL_LANGUAGES}, +#define TARGET_HEADER_BUILTIN(ID, TYPE, ATTRS, HEADER, LANGS, FEATURE) \ + {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::HEADER, LANGS}, #include "clang/Basic/BuiltinsAArch64.def" - }); +}; void AArch64TargetInfo::setArchFeatures() { if (*ArchInfo == llvm::AArch64::ARMV8R) { @@ -701,9 +697,9 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions &Opts, } } -std::pair<const char *, ArrayRef<Builtin::Info>> -AArch64TargetInfo::getTargetBuiltinStorage() const { - return {BuiltinStorage.StringTable, BuiltinStorage.Infos}; +ArrayRef<Builtin::Info> AArch64TargetInfo::getTargetBuiltins() const { + return llvm::ArrayRef(BuiltinInfo, clang::AArch64::LastTSBuiltin - + Builtin::FirstTSBuiltin); } std::optional<std::pair<unsigned, unsigned>> diff --git a/clang/lib/Basic/Targets/AArch64.h b/clang/lib/Basic/Targets/AArch64.h index a3ce04e249e3..68a8b1ebad8c 100644 --- a/clang/lib/Basic/Targets/AArch64.h +++ b/clang/lib/Basic/Targets/AArch64.h @@ -180,8 +180,7 @@ public: void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override; - std::pair<const char *, ArrayRef<Builtin::Info>> - getTargetBuiltinStorage() const override; + ArrayRef<Builtin::Info> getTargetBuiltins() const override; std::optional<std::pair<unsigned, unsigned>> getVScaleRange(const LangOptions &LangOpts) const override; diff --git a/clang/lib/Basic/Targets/AMDGPU.cpp b/clang/lib/Basic/Targets/AMDGPU.cpp index 21281e7201b0..99f8f2944e27 100644 --- a/clang/lib/Basic/Targets/AMDGPU.cpp +++ b/clang/lib/Basic/Targets/AMDGPU.cpp @@ -88,18 +88,13 @@ const LangASMap AMDGPUTargetInfo::AMDGPUDefIsPrivMap = { } // namespace targets } // namespace clang -static constexpr int NumBuiltins = - clang::AMDGPU::LastTSBuiltin - Builtin::FirstTSBuiltin; - -static constexpr auto BuiltinStorage = Builtin::Storage<NumBuiltins>::Make( -#define BUILTIN CLANG_BUILTIN_STR_TABLE -#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_STR_TABLE -#include "clang/Basic/BuiltinsAMDGPU.def" - , { -#define BUILTIN CLANG_BUILTIN_ENTRY -#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_ENTRY +static constexpr Builtin::Info BuiltinInfo[] = { +#define BUILTIN(ID, TYPE, ATTRS) \ + {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES}, +#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \ + {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::NO_HEADER, ALL_LANGUAGES}, #include "clang/Basic/BuiltinsAMDGPU.def" - }); +}; const char *const AMDGPUTargetInfo::GCCRegNames[] = { "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", "v8", @@ -271,9 +266,9 @@ void AMDGPUTargetInfo::adjust(DiagnosticsEngine &Diags, LangOptions &Opts) { !isAMDGCN(getTriple())); } -std::pair<const char *, ArrayRef<Builtin::Info>> -AMDGPUTargetInfo::getTargetBuiltinStorage() const { - return {BuiltinStorage.StringTable, BuiltinStorage.Infos}; +ArrayRef<Builtin::Info> AMDGPUTargetInfo::getTargetBuiltins() const { + return llvm::ArrayRef(BuiltinInfo, + clang::AMDGPU::LastTSBuiltin - Builtin::FirstTSBuiltin); } void AMDGPUTargetInfo::getTargetDefines(const LangOptions &Opts, diff --git a/clang/lib/Basic/Targets/AMDGPU.h b/clang/lib/Basic/Targets/AMDGPU.h index 8068184a0d41..ea4189cdea47 100644 --- a/clang/lib/Basic/Targets/AMDGPU.h +++ b/clang/lib/Basic/Targets/AMDGPU.h @@ -257,8 +257,7 @@ public: StringRef CPU, const std::vector<std::string> &FeatureVec) const override; - std::pair<const char *, ArrayRef<Builtin::Info>> - getTargetBuiltinStorage() const override; + ArrayRef<Builtin::Info> getTargetBuiltins() const override; bool useFP16ConversionIntrinsics() const override { return false; } diff --git a/clang/lib/Basic/Targets/ARC.h b/clang/lib/Basic/Targets/ARC.h index d84daf2e527c..7f3d0aa15ab8 100644 --- a/clang/lib/Basic/Targets/ARC.h +++ b/clang/lib/Basic/Targets/ARC.h @@ -40,10 +40,7 @@ public: void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override; - std::pair<const char *, ArrayRef<Builtin::Info>> - getTargetBuiltinStorage() const override { - return {nullptr, {}}; - } + ArrayRef<Builtin::Info> getTargetBuiltins() const override { return {}; } BuiltinVaListKind getBuiltinVaListKind() const override { return TargetInfo::VoidPtrBuiltinVaList; diff --git a/clang/lib/Basic/Targets/ARM.cpp b/clang/lib/Basic/Targets/ARM.cpp index fb10bc8249e9..370444057b42 100644 --- a/clang/lib/Basic/Targets/ARM.cpp +++ b/clang/lib/Basic/Targets/ARM.cpp @@ -1071,34 +1071,31 @@ void ARMTargetInfo::getTargetDefines(const LangOptions &Opts, } } -static constexpr int NumBuiltins = - clang::ARM::LastTSBuiltin - Builtin::FirstTSBuiltin; - -static constexpr auto BuiltinStorage = Builtin::Storage<NumBuiltins>::Make( -#define BUILTIN CLANG_BUILTIN_STR_TABLE -#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_STR_TABLE +static constexpr Builtin::Info BuiltinInfo[] = { +#define BUILTIN(ID, TYPE, ATTRS) \ + {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES}, +#define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) \ + {#ID, TYPE, ATTRS, nullptr, HeaderDesc::HEADER, ALL_LANGUAGES}, +#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \ + {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::NO_HEADER, ALL_LANGUAGES}, #include "clang/Basic/BuiltinsNEON.def" -#define BUILTIN CLANG_BUILTIN_STR_TABLE -#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_STR_TABLE -#define TARGET_HEADER_BUILTIN CLANG_TARGET_HEADER_BUILTIN_STR_TABLE -#include "clang/Basic/BuiltinsARM.def" - , { -#define BUILTIN CLANG_BUILTIN_ENTRY -#define LIBBUILTIN CLANG_LIBBUILTIN_ENTRY -#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_ENTRY -#include "clang/Basic/BuiltinsNEON.def" -#define BUILTIN CLANG_BUILTIN_ENTRY -#define LANGBUILTIN CLANG_LANGBUILTIN_ENTRY -#define LIBBUILTIN CLANG_LIBBUILTIN_ENTRY -#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_ENTRY -#define TARGET_HEADER_BUILTIN CLANG_TARGET_HEADER_BUILTIN_ENTRY +#define BUILTIN(ID, TYPE, ATTRS) \ + {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES}, +#define LANGBUILTIN(ID, TYPE, ATTRS, LANG) \ + {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, LANG}, +#define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) \ + {#ID, TYPE, ATTRS, nullptr, HeaderDesc::HEADER, ALL_LANGUAGES}, +#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \ + {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::NO_HEADER, ALL_LANGUAGES}, +#define TARGET_HEADER_BUILTIN(ID, TYPE, ATTRS, HEADER, LANGS, FEATURE) \ + {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::HEADER, LANGS}, #include "clang/Basic/BuiltinsARM.def" - }); +}; -std::pair<const char *, ArrayRef<Builtin::Info>> -ARMTargetInfo::getTargetBuiltinStorage() const { - return {BuiltinStorage.StringTable, BuiltinStorage.Infos}; +ArrayRef<Builtin::Info> ARMTargetInfo::getTargetBuiltins() const { + return llvm::ArrayRef(BuiltinInfo, + clang::ARM::LastTSBuiltin - Builtin::FirstTSBuiltin); } bool ARMTargetInfo::isCLZForZeroUndef() const { return false; } diff --git a/clang/lib/Basic/Targets/ARM.h b/clang/lib/Basic/Targets/ARM.h index 71f44f7248f6..55ecb99d82d8 100644 --- a/clang/lib/Basic/Targets/ARM.h +++ b/clang/lib/Basic/Targets/ARM.h @@ -196,8 +196,7 @@ public: void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override; - std::pair<const char *, ArrayRef<Builtin::Info>> - getTargetBuiltinStorage() const override; + ArrayRef<Builtin::Info> getTargetBuiltins() const override; bool isCLZForZeroUndef() const override; BuiltinVaListKind getBuiltinVaListKind() const override; diff --git a/clang/lib/Basic/Targets/AVR.h b/clang/lib/Basic/Targets/AVR.h index f19dee3a8823..df1f8d171efb 100644 --- a/clang/lib/Basic/Targets/AVR.h +++ b/clang/lib/Basic/Targets/AVR.h @@ -63,10 +63,7 @@ public: void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override; - std::pair<const char *, ArrayRef<Builtin::Info>> - getTargetBuiltinStorage() const override { - return {nullptr, {}}; - } + ArrayRef<Builtin::Info> getTargetBuiltins() const override { return {}; } bool allowsLargerPreferedTypeAlignment() const override { return false; } diff --git a/clang/lib/Basic/Targets/BPF.cpp b/clang/lib/Basic/Targets/BPF.cpp index b62e79259018..f4684765b7ff 100644 --- a/clang/lib/Basic/Targets/BPF.cpp +++ b/clang/lib/Basic/Targets/BPF.cpp @@ -19,16 +19,11 @@ using namespace clang; using namespace clang::targets; -static constexpr int NumBuiltins = - clang::BPF::LastTSBuiltin - Builtin::FirstTSBuiltin; - -static constexpr auto BuiltinStorage = Builtin::Storage<NumBuiltins>::Make( -#define BUILTIN CLANG_BUILTIN_STR_TABLE -#include "clang/Basic/BuiltinsBPF.inc" - , { -#define BUILTIN CLANG_BUILTIN_ENTRY +static constexpr Builtin::Info BuiltinInfo[] = { +#define BUILTIN(ID, TYPE, ATTRS) \ + {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES}, #include "clang/Basic/BuiltinsBPF.inc" - }); +}; void BPFTargetInfo::getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const { @@ -86,9 +81,9 @@ void BPFTargetInfo::fillValidCPUList(SmallVectorImpl<StringRef> &Values) const { Values.append(std::begin(ValidCPUNames), std::end(ValidCPUNames)); } -std::pair<const char *, ArrayRef<Builtin::Info>> -BPFTargetInfo::getTargetBuiltinStorage() const { - return {BuiltinStorage.StringTable, BuiltinStorage.Infos}; +ArrayRef<Builtin::Info> BPFTargetInfo::getTargetBuiltins() const { + return llvm::ArrayRef(BuiltinInfo, + clang::BPF::LastTSBuiltin - Builtin::FirstTSBuiltin); } bool BPFTargetInfo::handleTargetFeatures(std::vector<std::string> &Features, diff --git a/clang/lib/Basic/Targets/BPF.h b/clang/lib/Basic/Targets/BPF.h index 8f5c0e31aa87..27a4b5f31497 100644 --- a/clang/lib/Basic/Targets/BPF.h +++ b/clang/lib/Basic/Targets/BPF.h @@ -58,8 +58,7 @@ public: bool handleTargetFeatures(std::vector<std::string> &Features, DiagnosticsEngine &Diags) override; - std::pair<const char *, ArrayRef<Builtin::Info>> - getTargetBuiltinStorage() const override; + ArrayRef<Builtin::Info> getTargetBuiltins() const override; std::string_view getClobbers() const override { return ""; } diff --git a/clang/lib/Basic/Targets/CSKY.cpp b/clang/lib/Basic/Targets/CSKY.cpp index e698508a2370..c8bf8b9234d2 100644 --- a/clang/lib/Basic/Targets/CSKY.cpp +++ b/clang/lib/Basic/Targets/CSKY.cpp @@ -139,6 +139,10 @@ bool CSKYTargetInfo::handleTargetFeatures(std::vector<std::string> &Features, return true; } +ArrayRef<Builtin::Info> CSKYTargetInfo::getTargetBuiltins() const { + return ArrayRef<Builtin::Info>(); +} + ArrayRef<const char *> CSKYTargetInfo::getGCCRegNames() const { static const char *const GCCRegNames[] = { // Integer registers diff --git a/clang/lib/Basic/Targets/CSKY.h b/clang/lib/Basic/Targets/CSKY.h index 59c83340b8c3..94d4eeb9a1ff 100644 --- a/clang/lib/Basic/Targets/CSKY.h +++ b/clang/lib/Basic/Targets/CSKY.h @@ -73,10 +73,7 @@ public: unsigned getMinGlobalAlign(uint64_t, bool HasNonWeakDef) const override; - std::pair<const char *, ArrayRef<Builtin::Info>> - getTargetBuiltinStorage() const override { - return {nullptr, {}}; - } + ArrayRef<Builtin::Info> getTargetBuiltins() const override; BuiltinVaListKind getBuiltinVaListKind() const override { return VoidPtrBuiltinVaList; diff --git a/clang/lib/Basic/Targets/DirectX.h b/clang/lib/Basic/Targets/DirectX.h index 3e6e84b0d9e6..ab22d1281a4d 100644 --- a/clang/lib/Basic/Targets/DirectX.h +++ b/clang/lib/Basic/Targets/DirectX.h @@ -72,10 +72,7 @@ public: return Feature == "directx"; } - std::pair<const char *, ArrayRef<Builtin::Info>> - getTargetBuiltinStorage() const override { - return {nullptr, {}}; - } + ArrayRef<Builtin::Info> getTargetBuiltins() const override { return {}; } std::string_view getClobbers() const override { return ""; } diff --git a/clang/lib/Basic/Targets/Hexagon.cpp b/clang/lib/Basic/Targets/Hexagon.cpp index 70059d68c562..0282ac812c30 100644 --- a/clang/lib/Basic/Targets/Hexagon.cpp +++ b/clang/lib/Basic/Targets/Hexagon.cpp @@ -198,19 +198,15 @@ ArrayRef<TargetInfo::GCCRegAlias> HexagonTargetInfo::getGCCRegAliases() const { return llvm::ArrayRef(GCCRegAliases); } -static constexpr int NumBuiltins = - clang::Hexagon::LastTSBuiltin - Builtin::FirstTSBuiltin; - -static constexpr auto BuiltinStorage = Builtin::Storage<NumBuiltins>::Make( -#define BUILTIN CLANG_BUILTIN_STR_TABLE -#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_STR_TABLE -#include "clang/Basic/BuiltinsHexagon.def" - , { -#define BUILTIN CLANG_BUILTIN_ENTRY -#define LIBBUILTIN CLANG_LIBBUILTIN_ENTRY -#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_ENTRY +static constexpr Builtin::Info BuiltinInfo[] = { +#define BUILTIN(ID, TYPE, ATTRS) \ + {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES}, +#define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) \ + {#ID, TYPE, ATTRS, nullptr, HEADER, ALL_LANGUAGES}, +#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \ + {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::NO_HEADER, ALL_LANGUAGES}, #include "clang/Basic/BuiltinsHexagon.def" - }); +}; bool HexagonTargetInfo::hasFeature(StringRef Feature) const { std::string VS = "hvxv" + HVXVersion; @@ -268,7 +264,7 @@ void HexagonTargetInfo::fillValidCPUList( Values.push_back(Suffix.Name); } -std::pair<const char *, ArrayRef<Builtin::Info>> -HexagonTargetInfo::getTargetBuiltinStorage() const { - return {BuiltinStorage.StringTable, BuiltinStorage.Infos}; +ArrayRef<Builtin::Info> HexagonTargetInfo::getTargetBuiltins() const { + return llvm::ArrayRef(BuiltinInfo, clang::Hexagon::LastTSBuiltin - + Builtin::FirstTSBuiltin); } diff --git a/clang/lib/Basic/Targets/Hexagon.h b/clang/lib/Basic/Targets/Hexagon.h index 2230735b8971..7f053ab7e488 100644 --- a/clang/lib/Basic/Targets/Hexagon.h +++ b/clang/lib/Basic/Targets/Hexagon.h @@ -66,8 +66,7 @@ public: BoolWidth = BoolAlign = 8; } - std::pair<const char *, ArrayRef<Builtin::Info>> - getTargetBuiltinStorage() const override; + ArrayRef<Builtin::Info> getTargetBuiltins() const override; bool validateAsmConstraint(const char *&Name, TargetInfo::ConstraintInfo &Info) const override { diff --git a/clang/lib/Basic/Targets/Lanai.h b/clang/lib/Basic/Targets/Lanai.h index f37b0fdb0873..f7e439c7c9e1 100644 --- a/clang/lib/Basic/Targets/Lanai.h +++ b/clang/lib/Basic/Targets/Lanai.h @@ -78,10 +78,7 @@ public: return TargetInfo::VoidPtrBuiltinVaList; } - std::pair<const char *, ArrayRef<Builtin::Info>> - getTargetBuiltinStorage() const override { - return {nullptr, {}}; - } + ArrayRef<Builtin::Info> getTargetBuiltins() const override { return {}; } bool validateAsmConstraint(const char *&Name, TargetInfo::ConstraintInfo &info) const override { diff --git a/clang/lib/Basic/Targets/LoongArch.cpp b/clang/lib/Basic/Targets/LoongArch.cpp index 7c714000af42..d36186aa9c2f 100644 --- a/clang/lib/Basic/Targets/LoongArch.cpp +++ b/clang/lib/Basic/Targets/LoongArch.cpp @@ -270,18 +270,13 @@ void LoongArchTargetInfo::getTargetDefines(const LangOptions &Opts, Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8"); } -static constexpr int NumBuiltins = - clang::LoongArch::LastTSBuiltin - Builtin::FirstTSBuiltin; - -static constexpr auto BuiltinStorage = Builtin::Storage<NumBuiltins>::Make( -#define BUILTIN CLANG_BUILTIN_STR_TABLE -#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_STR_TABLE -#include "clang/Basic/BuiltinsLoongArch.def" - , { -#define BUILTIN CLANG_BUILTIN_ENTRY -#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_ENTRY +static constexpr Builtin::Info BuiltinInfo[] = { +#define BUILTIN(ID, TYPE, ATTRS) \ + {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES}, +#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \ + {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::NO_HEADER, ALL_LANGUAGES}, #include "clang/Basic/BuiltinsLoongArch.def" - }); +}; bool LoongArchTargetInfo::initFeatureMap( llvm::StringMap<bool> &Features, DiagnosticsEngine &Diags, StringRef CPU, @@ -308,9 +303,9 @@ bool LoongArchTargetInfo::hasFeature(StringRef Feature) const { .Default(false); } -std::pair<const char *, ArrayRef<Builtin::Info>> -LoongArchTargetInfo::getTargetBuiltinStorage() const { - return {BuiltinStorage.StringTable, BuiltinStorage.Infos}; +ArrayRef<Builtin::Info> LoongArchTargetInfo::getTargetBuiltins() const { + return llvm::ArrayRef(BuiltinInfo, clang::LoongArch::LastTSBuiltin - + Builtin::FirstTSBuiltin); } bool LoongArchTargetInfo::handleTargetFeatures( diff --git a/clang/lib/Basic/Targets/LoongArch.h b/clang/lib/Basic/Targets/LoongArch.h index 1bb82667cb51..abaa05aa42d4 100644 --- a/clang/lib/Basic/Targets/LoongArch.h +++ b/clang/lib/Basic/Targets/LoongArch.h @@ -70,8 +70,7 @@ public: void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override; - std::pair<const char *, ArrayRef<Builtin::Info>> - getTargetBuiltinStorage() const override; + ArrayRef<Builtin::Info> getTargetBuiltins() const override; BuiltinVaListKind getBuiltinVaListKind() const override { return TargetInfo::VoidPtrBuiltinVaList; diff --git a/clang/lib/Basic/Targets/M68k.cpp b/clang/lib/Basic/Targets/M68k.cpp index 5670c6309e71..b5b29fd86756 100644 --- a/clang/lib/Basic/Targets/M68k.cpp +++ b/clang/lib/Basic/Targets/M68k.cpp @@ -115,10 +115,9 @@ void M68kTargetInfo::getTargetDefines(const LangOptions &Opts, Builder.defineMacro("__HAVE_68881__"); } -std::pair<const char *, ArrayRef<Builtin::Info>> -M68kTargetInfo::getTargetBuiltinStorage() const { +ArrayRef<Builtin::Info> M68kTargetInfo::getTargetBuiltins() const { // FIXME: Implement. - return {nullptr, {}}; + return {}; } bool M68kTargetInfo::hasFeature(StringRef Feature) const { diff --git a/clang/lib/Basic/Targets/M68k.h b/clang/lib/Basic/Targets/M68k.h index c68b2ab132ea..b732add77e03 100644 --- a/clang/lib/Basic/Targets/M68k.h +++ b/clang/lib/Basic/Targets/M68k.h @@ -44,8 +44,7 @@ public: void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override; - std::pair<const char *, ArrayRef<Builtin::Info>> - getTargetBuiltinStorage() const override; + ArrayRef<Builtin::Info> getTargetBuiltins() const override; bool hasFeature(StringRef Feature) const override; ArrayRef<const char *> getGCCRegNames() const override; ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override; diff --git a/clang/lib/Basic/Targets/MSP430.h b/clang/lib/Basic/Targets/MSP430.h index 462bcdfaa9b2..2266ada25c1d 100644 --- a/clang/lib/Basic/Targets/MSP430.h +++ b/clang/lib/Basic/Targets/MSP430.h @@ -50,10 +50,9 @@ public: void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override; - std::pair<const char *, ArrayRef<Builtin::Info>> - getTargetBuiltinStorage() const override { + ArrayRef<Builtin::Info> getTargetBuiltins() const override { // FIXME: Implement. - return {nullptr, {}}; + return {}; } bool allowsLargerPreferedTypeAlignment() const override { return false; } diff --git a/clang/lib/Basic/Targets/Mips.cpp b/clang/lib/Basic/Targets/Mips.cpp index b4f137b2c195..174bc9d2ab99 100644 --- a/clang/lib/Basic/Targets/Mips.cpp +++ b/clang/lib/Basic/Targets/Mips.cpp @@ -20,17 +20,13 @@ using namespace clang; using namespace clang::targets; -static constexpr int NumBuiltins = - clang::Mips::LastTSBuiltin - Builtin::FirstTSBuiltin; - -static constexpr auto BuiltinStorage = Builtin::Storage<NumBuiltins>::Make( -#define BUILTIN CLANG_BUILTIN_STR_TABLE -#include "clang/Basic/BuiltinsMips.def" - , { -#define BUILTIN CLANG_BUILTIN_ENTRY -#define LIBBUILTIN CLANG_LIBBUILTIN_ENTRY +static constexpr Builtin::Info BuiltinInfo[] = { +#define BUILTIN(ID, TYPE, ATTRS) \ + {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES}, +#define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) \ + {#ID, TYPE, ATTRS, nullptr, HeaderDesc::HEADER, ALL_LANGUAGES}, #include "clang/Basic/BuiltinsMips.def" - }); +}; bool MipsTargetInfo::processorSupportsGPR64() const { return llvm::StringSwitch<bool>(CPU) @@ -227,9 +223,9 @@ bool MipsTargetInfo::hasFeature(StringRef Feature) const { .Default(false); } -std::pair<const char *, ArrayRef<Builtin::Info>> -MipsTargetInfo::getTargetBuiltinStorage() const { - return {BuiltinStorage.StringTable, BuiltinStorage.Infos}; +ArrayRef<Builtin::Info> MipsTargetInfo::getTargetBuiltins() const { + return llvm::ArrayRef(BuiltinInfo, + clang::Mips::LastTSBuiltin - Builtin::FirstTSBuiltin); } unsigned MipsTargetInfo::getUnwindWordWidth() const { diff --git a/clang/lib/Basic/Targets/Mips.h b/clang/lib/Basic/Targets/Mips.h index 2749b5d43a45..8acaf56523b2 100644 --- a/clang/lib/Basic/Targets/Mips.h +++ b/clang/lib/Basic/Targets/Mips.h @@ -197,8 +197,7 @@ public: void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override; - std::pair<const char *, ArrayRef<Builtin::Info>> - getTargetBuiltinStorage() const override; + ArrayRef<Builtin::Info> getTargetBuiltins() const override; bool hasFeature(StringRef Feature) const override; diff --git a/clang/lib/Basic/Targets/NVPTX.cpp b/clang/lib/Basic/Targets/NVPTX.cpp index 1d490d9f1299..dbc3fec36576 100644 --- a/clang/lib/Basic/Targets/NVPTX.cpp +++ b/clang/lib/Basic/Targets/NVPTX.cpp @@ -20,19 +20,15 @@ using namespace clang; using namespace clang::targets; -static constexpr int NumBuiltins = - clang::NVPTX::LastTSBuiltin - Builtin::FirstTSBuiltin; - -static constexpr auto BuiltinStorage = Builtin::Storage<NumBuiltins>::Make( -#define BUILTIN CLANG_BUILTIN_STR_TABLE -#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_STR_TABLE -#include "clang/Basic/BuiltinsNVPTX.def" - , { -#define BUILTIN CLANG_BUILTIN_ENTRY -#define LIBBUILTIN CLANG_LIBBUILTIN_ENTRY -#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_ENTRY +static constexpr Builtin::Info BuiltinInfo[] = { +#define BUILTIN(ID, TYPE, ATTRS) \ + {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES}, +#define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) \ + {#ID, TYPE, ATTRS, nullptr, HeaderDesc::HEADER, ALL_LANGUAGES}, +#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \ + {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::NO_HEADER, ALL_LANGUAGES}, #include "clang/Basic/BuiltinsNVPTX.def" - }); +}; const char *const NVPTXTargetInfo::GCCRegNames[] = {"r0"}; @@ -299,7 +295,7 @@ void NVPTXTargetInfo::getTargetDefines(const LangOptions &Opts, } } -std::pair<const char *, ArrayRef<Builtin::Info>> -NVPTXTargetInfo::getTargetBuiltinStorage() const { - return {BuiltinStorage.StringTable, BuiltinStorage.Infos}; +ArrayRef<Builtin::Info> NVPTXTargetInfo::getTargetBuiltins() const { + return llvm::ArrayRef(BuiltinInfo, + clang::NVPTX::LastTSBuiltin - Builtin::FirstTSBuiltin); } diff --git a/clang/lib/Basic/Targets/NVPTX.h b/clang/lib/Basic/Targets/NVPTX.h index 6520f441b416..d81b89a7f24a 100644 --- a/clang/lib/Basic/Targets/NVPTX.h +++ b/clang/lib/Basic/Targets/NVPTX.h @@ -74,8 +74,7 @@ public: void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override; - std::pair<const char *, ArrayRef<Builtin::Info>> - getTargetBuiltinStorage() const override; + ArrayRef<Builtin::Info> getTargetBuiltins() const override; bool useFP16ConversionIntrinsics() const override { return false; } diff --git a/clang/lib/Basic/Targets/PNaCl.h b/clang/lib/Basic/Targets/PNaCl.h index 20c0892fbf8c..7e0e10aa362d 100644 --- a/clang/lib/Basic/Targets/PNaCl.h +++ b/clang/lib/Basic/Targets/PNaCl.h @@ -52,10 +52,7 @@ public: return Feature == "pnacl"; } - std::pair<const char *, ArrayRef<Builtin::Info>> - getTargetBuiltinStorage() const override { - return {nullptr, {}}; - } + ArrayRef<Builtin::Info> getTargetBuiltins() const override { return {}; } BuiltinVaListKind getBuiltinVaListKind() const override { return TargetInfo::PNaClABIBuiltinVaList; diff --git a/clang/lib/Basic/Targets/PPC.cpp b/clang/lib/Basic/Targets/PPC.cpp index 6aa36839afa8..1448069173b5 100644 --- a/clang/lib/Basic/Targets/PPC.cpp +++ b/clang/lib/Basic/Targets/PPC.cpp @@ -19,19 +19,15 @@ using namespace clang; using namespace clang::targets; -static constexpr int NumBuiltins = - clang::PPC::LastTSBuiltin - Builtin::FirstTSBuiltin; - -static constexpr auto BuiltinStorage = Builtin::Storage<NumBuiltins>::Make( -#define BUILTIN CLANG_BUILTIN_STR_TABLE -#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_STR_TABLE -#include "clang/Basic/BuiltinsPPC.def" - , { -#define BUILTIN CLANG_BUILTIN_ENTRY -#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_ENTRY -#define LIBBUILTIN CLANG_LIBBUILTIN_ENTRY +static constexpr Builtin::Info BuiltinInfo[] = { +#define BUILTIN(ID, TYPE, ATTRS) \ + {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES}, +#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \ + {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::NO_HEADER, ALL_LANGUAGES}, +#define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) \ + {#ID, TYPE, ATTRS, nullptr, HeaderDesc::HEADER, ALL_LANGUAGES}, #include "clang/Basic/BuiltinsPPC.def" - }); +}; /// handleTargetFeatures - Perform initialization based on the user /// configured set of features. @@ -931,9 +927,9 @@ void PPCTargetInfo::adjust(DiagnosticsEngine &Diags, LangOptions &Opts) { MaxAtomicInlineWidth = 128; } -std::pair<const char *, ArrayRef<Builtin::Info>> -PPCTargetInfo::getTargetBuiltinStorage() const { - return {BuiltinStorage.StringTable, BuiltinStorage.Infos}; +ArrayRef<Builtin::Info> PPCTargetInfo::getTargetBuiltins() const { + return llvm::ArrayRef(BuiltinInfo, + clang::PPC::LastTSBuiltin - Builtin::FirstTSBuiltin); } bool PPCTargetInfo::validateCpuSupports(StringRef FeatureStr) const { diff --git a/clang/lib/Basic/Targets/PPC.h b/clang/lib/Basic/Targets/PPC.h index b58375f6f379..3cd0fcad1729 100644 --- a/clang/lib/Basic/Targets/PPC.h +++ b/clang/lib/Basic/Targets/PPC.h @@ -187,8 +187,7 @@ public: StringRef getABI() const override { return ABI; } - std::pair<const char *, ArrayRef<Builtin::Info>> - getTargetBuiltinStorage() const override; + ArrayRef<Builtin::Info> getTargetBuiltins() const override; bool isCLZForZeroUndef() const override { return false; } diff --git a/clang/lib/Basic/Targets/RISCV.cpp b/clang/lib/Basic/Targets/RISCV.cpp index 0add1dfdb2f5..a541dfedc9b8 100644 --- a/clang/lib/Basic/Targets/RISCV.cpp +++ b/clang/lib/Basic/Targets/RISCV.cpp @@ -240,28 +240,22 @@ void RISCVTargetInfo::getTargetDefines(const LangOptions &Opts, } } -static constexpr int NumBuiltins = - clang::RISCV::LastTSBuiltin - Builtin::FirstTSBuiltin; - -static constexpr auto BuiltinStorage = Builtin::Storage<NumBuiltins>::Make( -#define BUILTIN CLANG_BUILTIN_STR_TABLE -#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_STR_TABLE -#include "clang/Basic/BuiltinsRISCVVector.def" -#define BUILTIN CLANG_BUILTIN_STR_TABLE -#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_STR_TABLE -#include "clang/Basic/BuiltinsRISCV.inc" - , { -#define BUILTIN CLANG_BUILTIN_ENTRY -#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_ENTRY +static constexpr Builtin::Info BuiltinInfo[] = { +#define BUILTIN(ID, TYPE, ATTRS) \ + {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES}, +#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \ + {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::NO_HEADER, ALL_LANGUAGES}, #include "clang/Basic/BuiltinsRISCVVector.def" -#define BUILTIN CLANG_BUILTIN_ENTRY -#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_ENTRY +#define BUILTIN(ID, TYPE, ATTRS) \ + {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES}, +#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \ + {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::NO_HEADER, ALL_LANGUAGES}, #include "clang/Basic/BuiltinsRISCV.inc" - }); +}; -std::pair<const char *, ArrayRef<Builtin::Info>> -RISCVTargetInfo::getTargetBuiltinStorage() const { - return {BuiltinStorage.StringTable, BuiltinStorage.Infos}; +ArrayRef<Builtin::Info> RISCVTargetInfo::getTargetBuiltins() const { + return llvm::ArrayRef(BuiltinInfo, + clang::RISCV::LastTSBuiltin - Builtin::FirstTSBuiltin); } bool RISCVTargetInfo::initFeatureMap( diff --git a/clang/lib/Basic/Targets/RISCV.h b/clang/lib/Basic/Targets/RISCV.h index a168952e6c6f..68f10e74ba98 100644 --- a/clang/lib/Basic/Targets/RISCV.h +++ b/clang/lib/Basic/Targets/RISCV.h @@ -62,8 +62,7 @@ public: void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override; - std::pair<const char *, ArrayRef<Builtin::Info>> - getTargetBuiltinStorage() const override; + ArrayRef<Builtin::Info> getTargetBuiltins() const override; BuiltinVaListKind getBuiltinVaListKind() const override { return TargetInfo::VoidPtrBuiltinVaList; diff --git a/clang/lib/Basic/Targets/SPIR.cpp b/clang/lib/Basic/Targets/SPIR.cpp index b0e1fa35cca6..040303983594 100644 --- a/clang/lib/Basic/Targets/SPIR.cpp +++ b/clang/lib/Basic/Targets/SPIR.cpp @@ -81,9 +81,8 @@ SPIRV64AMDGCNTargetInfo::convertConstraint(const char *&Constraint) const { return AMDGPUTI.convertConstraint(Constraint); } -std::pair<const char *, ArrayRef<Builtin::Info>> -SPIRV64AMDGCNTargetInfo::getTargetBuiltinStorage() const { - return AMDGPUTI.getTargetBuiltinStorage(); +ArrayRef<Builtin::Info> SPIRV64AMDGCNTargetInfo::getTargetBuiltins() const { + return AMDGPUTI.getTargetBuiltins(); } void SPIRV64AMDGCNTargetInfo::getTargetDefines(const LangOptions &Opts, diff --git a/clang/lib/Basic/Targets/SPIR.h b/clang/lib/Basic/Targets/SPIR.h index f25c0cb93e65..85e4bd920d85 100644 --- a/clang/lib/Basic/Targets/SPIR.h +++ b/clang/lib/Basic/Targets/SPIR.h @@ -159,10 +159,7 @@ public: // memcpy as per section 3 of the SPIR spec. bool useFP16ConversionIntrinsics() const override { return false; } - std::pair<const char *, ArrayRef<Builtin::Info>> - getTargetBuiltinStorage() const override { - return {nullptr, {}}; - } + ArrayRef<Builtin::Info> getTargetBuiltins() const override { return {}; } std::string_view getClobbers() const override { return ""; } @@ -411,8 +408,7 @@ public: std::string convertConstraint(const char *&Constraint) const override; - std::pair<const char *, ArrayRef<Builtin::Info>> - getTargetBuiltinStorage() const override; + ArrayRef<Builtin::Info> getTargetBuiltins() const override; void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override; diff --git a/clang/lib/Basic/Targets/Sparc.h b/clang/lib/Basic/Targets/Sparc.h index 480073fae35c..9c529a5bc5e7 100644 --- a/clang/lib/Basic/Targets/Sparc.h +++ b/clang/lib/Basic/Targets/Sparc.h @@ -48,10 +48,9 @@ public: bool hasFeature(StringRef Feature) const override; - std::pair<const char *, ArrayRef<Builtin::Info>> - getTargetBuiltinStorage() const override { + ArrayRef<Builtin::Info> getTargetBuiltins() const override { // FIXME: Implement! - return {nullptr, {}}; + return {}; } BuiltinVaListKind getBuiltinVaListKind() const override { return TargetInfo::VoidPtrBuiltinVaList; diff --git a/clang/lib/Basic/Targets/SystemZ.cpp b/clang/lib/Basic/Targets/SystemZ.cpp index ffc55a80db9d..06f08db2eadd 100644 --- a/clang/lib/Basic/Targets/SystemZ.cpp +++ b/clang/lib/Basic/Targets/SystemZ.cpp @@ -20,18 +20,13 @@ using namespace clang; using namespace clang::targets; -static constexpr int NumBuiltins = - clang::SystemZ::LastTSBuiltin - Builtin::FirstTSBuiltin; - -static constexpr auto BuiltinStorage = Builtin::Storage<NumBuiltins>::Make( -#define BUILTIN CLANG_BUILTIN_STR_TABLE -#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_STR_TABLE -#include "clang/Basic/BuiltinsSystemZ.def" - , { -#define BUILTIN CLANG_BUILTIN_ENTRY -#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_ENTRY +static constexpr Builtin::Info BuiltinInfo[] = { +#define BUILTIN(ID, TYPE, ATTRS) \ + {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES}, +#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \ + {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::NO_HEADER, ALL_LANGUAGES}, #include "clang/Basic/BuiltinsSystemZ.def" - }); +}; const char *const SystemZTargetInfo::GCCRegNames[] = { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", @@ -175,7 +170,7 @@ void SystemZTargetInfo::getTargetDefines(const LangOptions &Opts, Builder.defineMacro("__VEC__", "10304"); } -std::pair<const char *, ArrayRef<Builtin::Info>> -SystemZTargetInfo::getTargetBuiltinStorage() const { - return {BuiltinStorage.StringTable, BuiltinStorage.Infos}; +ArrayRef<Builtin::Info> SystemZTargetInfo::getTargetBuiltins() const { + return llvm::ArrayRef(BuiltinInfo, clang::SystemZ::LastTSBuiltin - + Builtin::FirstTSBuiltin); } diff --git a/clang/lib/Basic/Targets/SystemZ.h b/clang/lib/Basic/Targets/SystemZ.h index 04e00bac6447..e6405f174f66 100644 --- a/clang/lib/Basic/Targets/SystemZ.h +++ b/clang/lib/Basic/Targets/SystemZ.h @@ -99,8 +99,7 @@ public: void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override; - std::pair<const char *, ArrayRef<Builtin::Info>> - getTargetBuiltinStorage() const override; + ArrayRef<Builtin::Info> getTargetBuiltins() const override; ArrayRef<const char *> getGCCRegNames() const override; diff --git a/clang/lib/Basic/Targets/TCE.h b/clang/lib/Basic/Targets/TCE.h index 52a2b13fe280..d6280b02f07b 100644 --- a/clang/lib/Basic/Targets/TCE.h +++ b/clang/lib/Basic/Targets/TCE.h @@ -95,10 +95,7 @@ public: bool hasFeature(StringRef Feature) const override { return Feature == "tce"; } - std::pair<const char *, ArrayRef<Builtin::Info>> - getTargetBuiltinStorage() const override { - return {nullptr, {}}; - } + ArrayRef<Builtin::Info> getTargetBuiltins() const override { return {}; } std::string_view getClobbers() const override { return ""; } diff --git a/clang/lib/Basic/Targets/VE.cpp b/clang/lib/Basic/Targets/VE.cpp index f54ddc00f6f6..67cae8faf605 100644 --- a/clang/lib/Basic/Targets/VE.cpp +++ b/clang/lib/Basic/Targets/VE.cpp @@ -18,16 +18,11 @@ using namespace clang; using namespace clang::targets; -static constexpr int NumBuiltins = - clang::VE::LastTSBuiltin - Builtin::FirstTSBuiltin; - -static constexpr auto BuiltinStorage = Builtin::Storage<NumBuiltins>::Make( -#define BUILTIN CLANG_BUILTIN_STR_TABLE -#include "clang/Basic/BuiltinsVE.def" - , { -#define BUILTIN CLANG_BUILTIN_ENTRY +static constexpr Builtin::Info BuiltinInfo[] = { +#define BUILTIN(ID, TYPE, ATTRS) \ + {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES}, #include "clang/Basic/BuiltinsVE.def" - }); +}; void VETargetInfo::getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const { @@ -44,7 +39,7 @@ void VETargetInfo::getTargetDefines(const LangOptions &Opts, Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8"); } -std::pair<const char *, ArrayRef<Builtin::Info>> -VETargetInfo::getTargetBuiltinStorage() const { - return {BuiltinStorage.StringTable, BuiltinStorage.Infos}; +ArrayRef<Builtin::Info> VETargetInfo::getTargetBuiltins() const { + return llvm::ArrayRef(BuiltinInfo, + clang::VE::LastTSBuiltin - Builtin::FirstTSBuiltin); } diff --git a/clang/lib/Basic/Targets/VE.h b/clang/lib/Basic/Targets/VE.h index d2b0cd6de4d5..7e8fdf6096ef 100644 --- a/clang/lib/Basic/Targets/VE.h +++ b/clang/lib/Basic/Targets/VE.h @@ -55,8 +55,7 @@ public: bool hasSjLjLowering() const override { return true; } - std::pair<const char *, ArrayRef<Builtin::Info>> - getTargetBuiltinStorage() const override; + ArrayRef<Builtin::Info> getTargetBuiltins() const override; BuiltinVaListKind getBuiltinVaListKind() const override { return TargetInfo::VoidPtrBuiltinVaList; diff --git a/clang/lib/Basic/Targets/WebAssembly.cpp b/clang/lib/Basic/Targets/WebAssembly.cpp index 14f1ac20747f..7b0fd0c841ba 100644 --- a/clang/lib/Basic/Targets/WebAssembly.cpp +++ b/clang/lib/Basic/Targets/WebAssembly.cpp @@ -20,19 +20,15 @@ using namespace clang; using namespace clang::targets; -static constexpr int NumBuiltins = - clang::WebAssembly::LastTSBuiltin - Builtin::FirstTSBuiltin; - -static constexpr auto BuiltinStorage = Builtin::Storage<NumBuiltins>::Make( -#define BUILTIN CLANG_BUILTIN_STR_TABLE -#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_STR_TABLE -#include "clang/Basic/BuiltinsWebAssembly.def" - , { -#define BUILTIN CLANG_BUILTIN_ENTRY -#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_ENTRY -#define LIBBUILTIN CLANG_LIBBUILTIN_ENTRY +static constexpr Builtin::Info BuiltinInfo[] = { +#define BUILTIN(ID, TYPE, ATTRS) \ + {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES}, +#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \ + {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::NO_HEADER, ALL_LANGUAGES}, +#define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) \ + {#ID, TYPE, ATTRS, nullptr, HeaderDesc::HEADER, ALL_LANGUAGES}, #include "clang/Basic/BuiltinsWebAssembly.def" - }); +}; static constexpr llvm::StringLiteral ValidCPUNames[] = { {"mvp"}, {"bleeding-edge"}, {"generic"}, {"lime1"}}; @@ -364,9 +360,9 @@ bool WebAssemblyTargetInfo::handleTargetFeatures( return true; } -std::pair<const char *, ArrayRef<Builtin::Info>> -WebAssemblyTargetInfo::getTargetBuiltinStorage() const { - return {BuiltinStorage.StringTable, BuiltinStorage.Infos}; +ArrayRef<Builtin::Info> WebAssemblyTargetInfo::getTargetBuiltins() const { + return llvm::ArrayRef(BuiltinInfo, clang::WebAssembly::LastTSBuiltin - + Builtin::FirstTSBuiltin); } void WebAssemblyTargetInfo::adjust(DiagnosticsEngine &Diags, diff --git a/clang/lib/Basic/Targets/WebAssembly.h b/clang/lib/Basic/Targets/WebAssembly.h index 6ce2bb00e5f2..0a14da6a277b 100644 --- a/clang/lib/Basic/Targets/WebAssembly.h +++ b/clang/lib/Basic/Targets/WebAssembly.h @@ -120,8 +120,7 @@ private: bool setCPU(const std::string &Name) final { return isValidCPUName(Name); } - std::pair<const char *, ArrayRef<Builtin::Info>> - getTargetBuiltinStorage() const final; + ArrayRef<Builtin::Info> getTargetBuiltins() const final; BuiltinVaListKind getBuiltinVaListKind() const final { return VoidPtrBuiltinVaList; diff --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp index 0b071573aa1e..1b16888a0711 100644 --- a/clang/lib/Basic/Targets/X86.cpp +++ b/clang/lib/Basic/Targets/X86.cpp @@ -23,45 +23,31 @@ namespace clang { namespace targets { -// The x86-32 builtins are a subset and prefix of the x86-64 builtins. -static constexpr int NumX86Builtins = - X86::LastX86CommonBuiltin - Builtin::FirstTSBuiltin + 1; -static constexpr int NumX86_64Builtins = - X86::LastTSBuiltin - Builtin::FirstTSBuiltin; -static_assert(NumX86Builtins < NumX86_64Builtins); - -static constexpr auto BuiltinStorage = - Builtin::Storage<NumX86_64Builtins>::Make( -#define BUILTIN CLANG_BUILTIN_STR_TABLE -#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_STR_TABLE -#define TARGET_HEADER_BUILTIN CLANG_TARGET_HEADER_BUILTIN_STR_TABLE +static constexpr Builtin::Info BuiltinInfoX86[] = { +#define BUILTIN(ID, TYPE, ATTRS) \ + {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES}, +#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \ + {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::NO_HEADER, ALL_LANGUAGES}, +#define TARGET_HEADER_BUILTIN(ID, TYPE, ATTRS, HEADER, LANGS, FEATURE) \ + {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::HEADER, LANGS}, #include "clang/Basic/BuiltinsX86.def" -#define BUILTIN CLANG_BUILTIN_STR_TABLE -#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_STR_TABLE -#define TARGET_HEADER_BUILTIN CLANG_TARGET_HEADER_BUILTIN_STR_TABLE +#define BUILTIN(ID, TYPE, ATTRS) \ + {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES}, +#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \ + {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::NO_HEADER, ALL_LANGUAGES}, +#define TARGET_HEADER_BUILTIN(ID, TYPE, ATTRS, HEADER, LANGS, FEATURE) \ + {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::HEADER, LANGS}, #include "clang/Basic/BuiltinsX86.inc" -#define BUILTIN CLANG_BUILTIN_STR_TABLE -#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_STR_TABLE -#define TARGET_HEADER_BUILTIN CLANG_TARGET_HEADER_BUILTIN_STR_TABLE +#define BUILTIN(ID, TYPE, ATTRS) \ + {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES}, +#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \ + {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::NO_HEADER, ALL_LANGUAGES}, +#define TARGET_HEADER_BUILTIN(ID, TYPE, ATTRS, HEADER, LANGS, FEATURE) \ + {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::HEADER, LANGS}, #include "clang/Basic/BuiltinsX86_64.def" - , { -#define BUILTIN CLANG_BUILTIN_ENTRY -#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_ENTRY -#define TARGET_HEADER_BUILTIN CLANG_TARGET_HEADER_BUILTIN_ENTRY -#include "clang/Basic/BuiltinsX86.def" - -#define BUILTIN CLANG_BUILTIN_ENTRY -#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_ENTRY -#define TARGET_HEADER_BUILTIN CLANG_TARGET_HEADER_BUILTIN_ENTRY -#include "clang/Basic/BuiltinsX86.inc" - -#define BUILTIN CLANG_BUILTIN_ENTRY -#define TARGET_BUILTIN CLANG_TARGET_BUILTIN_ENTRY -#define TARGET_HEADER_BUILTIN CLANG_TARGET_HEADER_BUILTIN_ENTRY -#include "clang/Basic/BuiltinsX86_64.def" - }); +}; static const char *const GCCRegNames[] = { "ax", "dx", "cx", "bx", "si", "di", "bp", "sp", @@ -1878,14 +1864,12 @@ ArrayRef<TargetInfo::AddlRegName> X86TargetInfo::getGCCAddlRegNames() const { return llvm::ArrayRef(AddlRegNames); } -std::pair<const char *, ArrayRef<Builtin::Info>> -X86_32TargetInfo::getTargetBuiltinStorage() const { - // Only use the relevant prefix of the infos, the string table base is common. - return {BuiltinStorage.StringTable, - llvm::ArrayRef(BuiltinStorage.Infos).take_front(NumX86Builtins)}; +ArrayRef<Builtin::Info> X86_32TargetInfo::getTargetBuiltins() const { + return llvm::ArrayRef(BuiltinInfoX86, clang::X86::LastX86CommonBuiltin - + Builtin::FirstTSBuiltin + 1); } -std::pair<const char *, ArrayRef<Builtin::Info>> -X86_64TargetInfo::getTargetBuiltinStorage() const { - return {BuiltinStorage.StringTable, BuiltinStorage.Infos}; +ArrayRef<Builtin::Info> X86_64TargetInfo::getTargetBuiltins() const { + return llvm::ArrayRef(BuiltinInfoX86, + X86::LastTSBuiltin - Builtin::FirstTSBuiltin); } diff --git a/clang/lib/Basic/Targets/X86.h b/clang/lib/Basic/Targets/X86.h index 385d9e87a4e3..3ed36c8fa724 100644 --- a/clang/lib/Basic/Targets/X86.h +++ b/clang/lib/Basic/Targets/X86.h @@ -508,8 +508,7 @@ public: MaxAtomicInlineWidth = 64; } - std::pair<const char *, ArrayRef<Builtin::Info>> - getTargetBuiltinStorage() const override; + ArrayRef<Builtin::Info> getTargetBuiltins() const override; bool hasBitIntType() const override { return true; } size_t getMaxBitIntWidth() const override { @@ -813,8 +812,7 @@ public: MaxAtomicInlineWidth = 128; } - std::pair<const char *, ArrayRef<Builtin::Info>> - getTargetBuiltinStorage() const override; + ArrayRef<Builtin::Info> getTargetBuiltins() const override; bool hasBitIntType() const override { return true; } size_t getMaxBitIntWidth() const override { diff --git a/clang/lib/Basic/Targets/XCore.cpp b/clang/lib/Basic/Targets/XCore.cpp index 403d421d0c06..fd377bbfb90e 100644 --- a/clang/lib/Basic/Targets/XCore.cpp +++ b/clang/lib/Basic/Targets/XCore.cpp @@ -18,17 +18,13 @@ using namespace clang; using namespace clang::targets; -static constexpr int NumBuiltins = - XCore::LastTSBuiltin - Builtin::FirstTSBuiltin; - -static constexpr auto BuiltinStorage = Builtin::Storage<NumBuiltins>::Make( -#define BUILTIN CLANG_BUILTIN_STR_TABLE -#include "clang/Basic/BuiltinsXCore.def" - , { -#define BUILTIN CLANG_BUILTIN_ENTRY -#define LIBBUILTIN CLANG_LIBBUILTIN_ENTRY +static constexpr Builtin::Info BuiltinInfo[] = { +#define BUILTIN(ID, TYPE, ATTRS) \ + {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES}, +#define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) \ + {#ID, TYPE, ATTRS, nullptr, HeaderDesc::HEADER, ALL_LANGUAGES}, #include "clang/Basic/BuiltinsXCore.def" - }); +}; void XCoreTargetInfo::getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const { @@ -36,7 +32,7 @@ void XCoreTargetInfo::getTargetDefines(const LangOptions &Opts, Builder.defineMacro("__XS1B__"); } -std::pair<const char *, ArrayRef<Builtin::Info>> -XCoreTargetInfo::getTargetBuiltinStorage() const { - return {BuiltinStorage.StringTable, BuiltinStorage.Infos}; +ArrayRef<Builtin::Info> XCoreTargetInfo::getTargetBuiltins() const { + return llvm::ArrayRef(BuiltinInfo, + clang::XCore::LastTSBuiltin - Builtin::FirstTSBuiltin); } diff --git a/clang/lib/Basic/Targets/XCore.h b/clang/lib/Basic/Targets/XCore.h index 1082990d74b2..84fd59d1a71e 100644 --- a/clang/lib/Basic/Targets/XCore.h +++ b/clang/lib/Basic/Targets/XCore.h @@ -43,8 +43,7 @@ public: void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override; - std::pair<const char *, ArrayRef<Builtin::Info>> - getTargetBuiltinStorage() const override; + ArrayRef<Builtin::Info> getTargetBuiltins() const override; BuiltinVaListKind getBuiltinVaListKind() const override { return TargetInfo::VoidPtrBuiltinVaList; diff --git a/clang/lib/Driver/ToolChains/OHOS.cpp b/clang/lib/Driver/ToolChains/OHOS.cpp index c9a532771b99..6e1a09ae908b 100644 --- a/clang/lib/Driver/ToolChains/OHOS.cpp +++ b/clang/lib/Driver/ToolChains/OHOS.cpp @@ -19,8 +19,8 @@ #include "llvm/ProfileData/InstrProf.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Path.h" -#include "llvm/Support/ScopedPrinter.h" #include "llvm/Support/VirtualFileSystem.h" +#include "llvm/Support/ScopedPrinter.h" using namespace clang::driver; using namespace clang::driver::toolchains; @@ -58,9 +58,11 @@ static bool findOHOSMuslMultilibs(const Driver &D, return false; } -static bool findOHOSMultilibs(const Driver &D, const ToolChain &TC, - const llvm::Triple &TargetTriple, StringRef Path, - const ArgList &Args, DetectedMultilibs &Result) { +static bool findOHOSMultilibs(const Driver &D, + const ToolChain &TC, + const llvm::Triple &TargetTriple, + StringRef Path, const ArgList &Args, + DetectedMultilibs &Result) { Multilib::flags_list Flags; bool IsA7 = false; if (const Arg *A = Args.getLastArg(options::OPT_mcpu_EQ)) @@ -170,7 +172,8 @@ OHOS::OHOS(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) Paths); } -ToolChain::RuntimeLibType OHOS::GetRuntimeLibType(const ArgList &Args) const { +ToolChain::RuntimeLibType OHOS::GetRuntimeLibType( + const ArgList &Args) const { if (Arg *A = Args.getLastArg(clang::driver::options::OPT_rtlib_EQ)) { StringRef Value = A->getValue(); if (Value != "compiler-rt") @@ -181,19 +184,20 @@ ToolChain::RuntimeLibType OHOS::GetRuntimeLibType(const ArgList &Args) const { return ToolChain::RLT_CompilerRT; } -ToolChain::CXXStdlibType OHOS::GetCXXStdlibType(const ArgList &Args) const { +ToolChain::CXXStdlibType +OHOS::GetCXXStdlibType(const ArgList &Args) const { if (Arg *A = Args.getLastArg(options::OPT_stdlib_EQ)) { StringRef Value = A->getValue(); if (Value != "libc++") getDriver().Diag(diag::err_drv_invalid_stdlib_name) - << A->getAsString(Args); + << A->getAsString(Args); } return ToolChain::CST_Libcxx; } void OHOS::AddClangSystemIncludeArgs(const ArgList &DriverArgs, - ArgStringList &CC1Args) const { + ArgStringList &CC1Args) const { const Driver &D = getDriver(); const llvm::Triple &Triple = getTriple(); std::string SysRoot = computeSysRoot(); @@ -254,7 +258,7 @@ void OHOS::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs, } void OHOS::AddCXXStdlibLibArgs(const ArgList &Args, - ArgStringList &CmdArgs) const { + ArgStringList &CmdArgs) const { switch (GetCXXStdlibType(Args)) { case ToolChain::CST_Libcxx: CmdArgs.push_back("-lc++"); @@ -287,8 +291,7 @@ ToolChain::path_list OHOS::getRuntimePaths() const { // First try the triple passed to driver as --target=<triple>. P.assign(D.ResourceDir); - llvm::sys::path::append(P, "lib", D.getTargetTriple(), - SelectedMultilib.gccSuffix()); + llvm::sys::path::append(P, "lib", D.getTargetTriple(), SelectedMultilib.gccSuffix()); Paths.push_back(P.c_str()); // Second try the normalized triple. @@ -337,20 +340,26 @@ std::string OHOS::getDynamicLinker(const ArgList &Args) const { std::string OHOS::getCompilerRT(const ArgList &Args, StringRef Component, FileType Type) const { - std::string CRTBasename = - buildCompilerRTBasename(Args, Component, Type, /*AddArch=*/false); - SmallString<128> Path(getDriver().ResourceDir); llvm::sys::path::append(Path, "lib", getMultiarchTriple(getTriple()), - SelectedMultilib.gccSuffix(), CRTBasename); - if (getVFS().exists(Path)) - return std::string(Path); - - std::string NewPath = ToolChain::getCompilerRT(Args, Component, Type); - if (getVFS().exists(NewPath)) - return NewPath; - - return std::string(Path); + SelectedMultilib.gccSuffix()); + const char *Prefix = + Type == ToolChain::FT_Object ? "" : "lib"; + const char *Suffix; + switch (Type) { + case ToolChain::FT_Object: + Suffix = ".o"; + break; + case ToolChain::FT_Static: + Suffix = ".a"; + break; + case ToolChain::FT_Shared: + Suffix = ".so"; + break; + } + llvm::sys::path::append( + Path, Prefix + Twine("clang_rt.") + Component + Suffix); + return static_cast<std::string>(Path.str()); } void OHOS::addExtraOpts(llvm::opt::ArgStringList &CmdArgs) const { @@ -387,7 +396,7 @@ SanitizerMask OHOS::getSupportedSanitizers() const { // TODO: Make a base class for Linux and OHOS and move this there. void OHOS::addProfileRTLibs(const llvm::opt::ArgList &Args, - llvm::opt::ArgStringList &CmdArgs) const { + llvm::opt::ArgStringList &CmdArgs) const { // Add linker option -u__llvm_profile_runtime to cause runtime // initialization module to be linked in. if (needsProfileRT(Args)) @@ -404,8 +413,7 @@ ToolChain::path_list OHOS::getArchSpecificLibPaths() const { return Paths; } -ToolChain::UnwindLibType -OHOS::GetUnwindLibType(const llvm::opt::ArgList &Args) const { +ToolChain::UnwindLibType OHOS::GetUnwindLibType(const llvm::opt::ArgList &Args) const { if (Args.getLastArg(options::OPT_unwindlib_EQ)) return Generic_ELF::GetUnwindLibType(Args); return GetDefaultUnwindLibType(); diff --git a/clang/lib/Interpreter/Interpreter.cpp b/clang/lib/Interpreter/Interpreter.cpp index 6cd60a9bcf4f..fa4c1439c926 100644 --- a/clang/lib/Interpreter/Interpreter.cpp +++ b/clang/lib/Interpreter/Interpreter.cpp @@ -719,9 +719,7 @@ llvm::Error Interpreter::LoadDynamicLibrary(const char *name) { if (auto DLSG = llvm::orc::DynamicLibrarySearchGenerator::Load( name, DL.getGlobalPrefix())) - // FIXME: Eventually we should put each library in its own JITDylib and - // turn off process symbols by default. - EE->getProcessSymbolsJITDylib()->addGenerator(std::move(*DLSG)); + EE->getMainJITDylib().addGenerator(std::move(*DLSG)); else return DLSG.takeError(); diff --git a/clang/test/Interpreter/Inputs/vector b/clang/test/Interpreter/Inputs/vector deleted file mode 100644 index 4fc5d04f4718..000000000000 --- a/clang/test/Interpreter/Inputs/vector +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef VECTOR -#define VECTOR -namespace std { -template <typename> -class vector { -public: - vector(); -}; -} // namespace std -#endif // VECTOR diff --git a/clang/test/Interpreter/crash.cpp b/clang/test/Interpreter/crash.cpp deleted file mode 100644 index 9a606983524d..000000000000 --- a/clang/test/Interpreter/crash.cpp +++ /dev/null @@ -1,20 +0,0 @@ -// REQUIRES: host-supports-jit, x86_64-linux - -// RUN: rm -rf %t -// RUN: mkdir -p %t -// -// RUN: split-file %s %t -// -// RUN: %clang++ -Xclang -nostdsysteminc -I%S/Inputs/ -std=c++20 -fPIC -c %t/vec.cpp -o %t/vec.o -// RUN: %clang++ -shared %t/vec.o -o %t/vec.so -// -// RUN: cat %t/Test.cpp | LD_LIBRARY_PATH=%t:$LD_LIBRARY_PATH clang-repl - -//--- vec.cpp -#include <vector> - -//--- Test.cpp -%lib vec.so -#include <vector> -std::vector<int> v; -%quit diff --git a/clang/test/SemaCXX/msvc-pragma-function-no-builtin-attr.cpp b/clang/test/SemaCXX/msvc-pragma-function-no-builtin-attr.cpp index 066c66884e33..7262ffd079a9 100644 --- a/clang/test/SemaCXX/msvc-pragma-function-no-builtin-attr.cpp +++ b/clang/test/SemaCXX/msvc-pragma-function-no-builtin-attr.cpp @@ -18,10 +18,10 @@ int bar() { struct A { int foo() = delete; - // CHECK: CXXMethodDecl {{.*}} foo 'int ()' delete + // CHECK: CXXMethodDecl {{.*}} foo {{.*}} delete // CHECK-NOT: NoBuiltinAttr A() = default; - // CHECK: CXXConstructorDecl {{.*}} A 'void ()' default + // CHECK: CXXConstructorDecl {{.*}} A {{.*}} default // CHECK-NOT: NoBuiltinAttr }; diff --git a/clang/test/SemaCXX/warn-thread-safety-analysis.cpp b/clang/test/SemaCXX/warn-thread-safety-analysis.cpp index 8477200456d9..3c52c8165d85 100644 --- a/clang/test/SemaCXX/warn-thread-safety-analysis.cpp +++ b/clang/test/SemaCXX/warn-thread-safety-analysis.cpp @@ -1593,8 +1593,12 @@ namespace substitution_test { void unlockData() UNLOCK_FUNCTION(mu); void doSomething() EXCLUSIVE_LOCKS_REQUIRED(mu) { } + void operator()() EXCLUSIVE_LOCKS_REQUIRED(mu) { } + + MyData operator+(const MyData& other) const SHARED_LOCKS_REQUIRED(mu, other.mu); }; + MyData operator-(const MyData& a, const MyData& b) SHARED_LOCKS_REQUIRED(a.mu, b.mu); class DataLocker { public: @@ -1607,6 +1611,27 @@ namespace substitution_test { public: void foo(MyData* d) EXCLUSIVE_LOCKS_REQUIRED(d->mu) { } + void subst(MyData& d) { + d.doSomething(); // expected-warning {{calling function 'doSomething' requires holding mutex 'd.mu' exclusively}} + d(); // expected-warning {{calling function 'operator()' requires holding mutex 'd.mu' exclusively}} + d.operator()(); // expected-warning {{calling function 'operator()' requires holding mutex 'd.mu' exclusively}} + + d.lockData(); + d.doSomething(); + d(); + d.operator()(); + d.unlockData(); + } + + void binop(MyData& a, MyData& b) EXCLUSIVE_LOCKS_REQUIRED(a.mu) { + a + b; // expected-warning {{calling function 'operator+' requires holding mutex 'b.mu'}} + // expected-note@-1 {{found near match 'a.mu'}} + b + a; // expected-warning {{calling function 'operator+' requires holding mutex 'b.mu'}} + // expected-note@-1 {{found near match 'a.mu'}} + a - b; // expected-warning {{calling function 'operator-' requires holding mutex 'b.mu'}} + // expected-note@-1 {{found near match 'a.mu'}} + } + void bar1(MyData* d) { d->lockData(); foo(d); @@ -5172,9 +5197,13 @@ class Foo { }; func1(); // expected-warning {{calling function 'operator()' requires holding mutex 'mu_' exclusively}} + func1.operator()(); // expected-warning {{calling function 'operator()' requires holding mutex 'mu_' exclusively}} func2(); + func2.operator()(); func3(); mu_.Unlock(); + func3.operator()(); + mu_.Unlock(); } }; diff --git a/clang/unittests/AST/ASTImporterTest.cpp b/clang/unittests/AST/ASTImporterTest.cpp index abf07d094e62..f3f314b723df 100644 --- a/clang/unittests/AST/ASTImporterTest.cpp +++ b/clang/unittests/AST/ASTImporterTest.cpp @@ -9657,7 +9657,7 @@ TEST_P(ASTImporterOptionSpecificTestBase, ImportConflictTypeAliasTemplate) { AST_MATCHER(ClassTemplateSpecializationDecl, hasInstantiatedFromMember) { if (auto Instantiate = Node.getInstantiatedFrom()) { if (auto *FromPartialSpecialization = - Instantiate.get<ClassTemplatePartialSpecializationDecl *>()) { + cast<ClassTemplatePartialSpecializationDecl *>(Instantiate)) { return nullptr != FromPartialSpecialization->getInstantiatedFromMember(); } } diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp index 4b15e7b7da33..663b00ca7af6 100644 --- a/clang/unittests/Format/FormatTestJS.cpp +++ b/clang/unittests/Format/FormatTestJS.cpp @@ -1753,6 +1753,10 @@ TEST_F(FormatTestJS, ClassDeclarations) { " x: {y: Z;} = {};\n" " private y: {y: Z;} = {};\n" "}"); + verifyFormat("class Foo {\n" + " private addGrammarCheckOneboxProductInfo(\n" + " productInfo: {[key: string]: string;}) {}\n" + "}"); // ':' is not a type declaration here. verifyFormat("class X {\n" diff --git a/libcxx/include/__utility/forward_like.h b/libcxx/include/__utility/forward_like.h index 0206ce23a566..67bdf6d054ea 100644 --- a/libcxx/include/__utility/forward_like.h +++ b/libcxx/include/__utility/forward_like.h @@ -12,6 +12,7 @@ #include <__config> #include <__type_traits/conditional.h> +#include <__type_traits/is_base_of.h> #include <__type_traits/is_const.h> #include <__type_traits/is_reference.h> #include <__type_traits/remove_reference.h> @@ -39,6 +40,22 @@ forward_like(_LIBCPP_LIFETIMEBOUND _Up&& __ux) noexcept -> _ForwardLike<_Tp, _Up return static_cast<_ForwardLike<_Tp, _Up>>(__ux); } +// This function is used for `deducing this` cases where you want to make sure the operation is performed on the class +// itself and not on a derived class. For example +// struct S { +// template <class Self> +// void func(Self&& self) { +// // This will always call `do_something` of S instead of any class derived from S. +// std::__forward_as<Self, S>(self).do_something(); +// } +// }; +template <class _Tp, class _As, class _Up> +[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _ForwardLike<_Tp, _As> +__forward_as(_LIBCPP_LIFETIMEBOUND _Up&& __val) noexcept { + static_assert(is_base_of_v<_As, remove_reference_t<_Up>>); + return static_cast<_ForwardLike<_Tp, _As>>(__val); +} + #endif // _LIBCPP_STD_VER >= 23 _LIBCPP_END_NAMESPACE_STD diff --git a/libcxx/include/variant b/libcxx/include/variant index 9006e7ca35b0..fd91bd293910 100644 --- a/libcxx/include/variant +++ b/libcxx/include/variant @@ -1311,14 +1311,12 @@ public: template <__variant_visit_barrier_tag = __variant_visit_barrier_tag{}, class _Self, class _Visitor> _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) visit(this _Self&& __self, _Visitor&& __visitor) { - using _VariantT = _OverrideRef<_Self&&, _CopyConst<remove_reference_t<_Self>, variant>>; - return std::visit(std::forward<_Visitor>(__visitor), (_VariantT)__self); + return std::visit(std::forward<_Visitor>(__visitor), std::__forward_as<_Self, variant>(__self)); } template <class _Rp, class _Self, class _Visitor> _LIBCPP_HIDE_FROM_ABI constexpr _Rp visit(this _Self&& __self, _Visitor&& __visitor) { - using _VariantT = _OverrideRef<_Self&&, _CopyConst<remove_reference_t<_Self>, variant>>; - return std::visit<_Rp>(std::forward<_Visitor>(__visitor), (_VariantT)__self); + return std::visit<_Rp>(std::forward<_Visitor>(__visitor), std::__forward_as<_Self, variant>(__self)); } # endif diff --git a/libcxx/test/std/utilities/meta/derived_from_integral_constant.compile.pass.cpp b/libcxx/test/std/utilities/meta/derived_from_integral_constant.compile.pass.cpp new file mode 100644 index 000000000000..4209bd6be654 --- /dev/null +++ b/libcxx/test/std/utilities/meta/derived_from_integral_constant.compile.pass.cpp @@ -0,0 +1,112 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03 + +// Check that type traits derive from integral_constant + +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS + +#include <cstddef> +#include <type_traits> + +#include "test_macros.h" + +static_assert(std::is_base_of<std::false_type, std::is_void<int>>::value, ""); +static_assert(std::is_base_of<std::true_type, std::is_integral<int>>::value, ""); +static_assert(std::is_base_of<std::false_type, std::is_floating_point<int>>::value, ""); +static_assert(std::is_base_of<std::false_type, std::is_array<int>>::value, ""); +static_assert(std::is_base_of<std::false_type, std::is_enum<int>>::value, ""); +static_assert(std::is_base_of<std::false_type, std::is_union<int>>::value, ""); +static_assert(std::is_base_of<std::false_type, std::is_class<int>>::value, ""); +static_assert(std::is_base_of<std::false_type, std::is_function<int>>::value, ""); +static_assert(std::is_base_of<std::false_type, std::is_pointer<int>>::value, ""); +static_assert(std::is_base_of<std::false_type, std::is_lvalue_reference<int>>::value, ""); +static_assert(std::is_base_of<std::false_type, std::is_rvalue_reference<int>>::value, ""); +static_assert(std::is_base_of<std::false_type, std::is_member_object_pointer<int>>::value, ""); +static_assert(std::is_base_of<std::false_type, std::is_member_function_pointer<int>>::value, ""); +static_assert(std::is_base_of<std::true_type, std::is_fundamental<int>>::value, ""); +static_assert(std::is_base_of<std::true_type, std::is_arithmetic<int>>::value, ""); +static_assert(std::is_base_of<std::true_type, std::is_scalar<int>>::value, ""); +static_assert(std::is_base_of<std::false_type, std::is_object<int&>>::value, ""); +static_assert(std::is_base_of<std::false_type, std::is_compound<int>>::value, ""); +static_assert(std::is_base_of<std::false_type, std::is_reference<int>>::value, ""); +static_assert(std::is_base_of<std::false_type, std::is_member_pointer<int>>::value, ""); +static_assert(std::is_base_of<std::false_type, std::is_const<int>>::value, ""); +static_assert(std::is_base_of<std::false_type, std::is_volatile<int>>::value, ""); +static_assert(std::is_base_of<std::true_type, std::is_trivial<int>>::value, ""); +static_assert(std::is_base_of<std::true_type, std::is_trivially_copyable<int>>::value, ""); +static_assert(std::is_base_of<std::true_type, std::is_standard_layout<int>>::value, ""); +static_assert(std::is_base_of<std::true_type, std::is_pod<int>>::value, ""); +static_assert(std::is_base_of<std::false_type, std::is_empty<int>>::value, ""); +static_assert(std::is_base_of<std::false_type, std::is_polymorphic<int>>::value, ""); +static_assert(std::is_base_of<std::false_type, std::is_abstract<int>>::value, ""); +static_assert(std::is_base_of<std::true_type, std::is_signed<int>>::value, ""); +static_assert(std::is_base_of<std::false_type, std::is_unsigned<int>>::value, ""); +static_assert(std::is_base_of<std::true_type, std::is_constructible<int>>::value, ""); +static_assert(std::is_base_of<std::true_type, std::is_trivially_constructible<int>>::value, ""); +static_assert(std::is_base_of<std::true_type, std::is_nothrow_constructible<int>>::value, ""); +static_assert(std::is_base_of<std::true_type, std::is_default_constructible<int>>::value, ""); +static_assert(std::is_base_of<std::true_type, std::is_trivially_default_constructible<int>>::value, ""); +static_assert(std::is_base_of<std::true_type, std::is_nothrow_default_constructible<int>>::value, ""); +static_assert(std::is_base_of<std::true_type, std::is_copy_constructible<int>>::value, ""); +static_assert(std::is_base_of<std::true_type, std::is_trivially_copy_constructible<int>>::value, ""); +static_assert(std::is_base_of<std::true_type, std::is_nothrow_copy_constructible<int>>::value, ""); +static_assert(std::is_base_of<std::true_type, std::is_move_constructible<int>>::value, ""); +static_assert(std::is_base_of<std::true_type, std::is_trivially_move_constructible<int>>::value, ""); +static_assert(std::is_base_of<std::true_type, std::is_nothrow_move_constructible<int>>::value, ""); +static_assert(std::is_base_of<std::false_type, std::is_assignable<int, int>>::value, ""); +static_assert(std::is_base_of<std::false_type, std::is_trivially_assignable<int, int>>::value, ""); +static_assert(std::is_base_of<std::false_type, std::is_nothrow_assignable<int, int>>::value, ""); +static_assert(std::is_base_of<std::true_type, std::is_copy_assignable<int>>::value, ""); +static_assert(std::is_base_of<std::true_type, std::is_trivially_copy_assignable<int>>::value, ""); +static_assert(std::is_base_of<std::true_type, std::is_nothrow_copy_assignable<int>>::value, ""); +static_assert(std::is_base_of<std::true_type, std::is_move_assignable<int>>::value, ""); +static_assert(std::is_base_of<std::true_type, std::is_trivially_move_assignable<int>>::value, ""); +static_assert(std::is_base_of<std::true_type, std::is_nothrow_move_assignable<int>>::value, ""); +static_assert(std::is_base_of<std::true_type, std::is_destructible<int>>::value, ""); +static_assert(std::is_base_of<std::true_type, std::is_trivially_destructible<int>>::value, ""); +static_assert(std::is_base_of<std::true_type, std::is_nothrow_destructible<int>>::value, ""); +static_assert(std::is_base_of<std::false_type, std::has_virtual_destructor<int>>::value, ""); +static_assert(std::is_base_of<std::integral_constant<std::size_t, 1>, std::alignment_of<char>>::value, ""); +static_assert(std::is_base_of<std::integral_constant<std::size_t, 0>, std::rank<char>>::value, ""); +static_assert(std::is_base_of<std::integral_constant<std::size_t, 0>, std::extent<char>>::value, ""); +static_assert(std::is_base_of<std::true_type, std::is_same<int, int>>::value, ""); +static_assert(std::is_base_of<std::false_type, std::is_base_of<int, int>>::value, ""); +static_assert(std::is_base_of<std::true_type, std::is_convertible<int, int>>::value, ""); +#if TEST_STD_VER <= 20 +static_assert(std::is_base_of<std::true_type, std::is_literal_type<int>>::value, ""); +#endif +#if TEST_STD_VER >= 14 +static_assert(std::is_base_of<std::false_type, std::is_null_pointer<int>>::value, ""); +static_assert(std::is_base_of<std::false_type, std::is_final<int>>::value, ""); +#endif +#if TEST_STD_VER >= 17 +static_assert(std::is_base_of<std::true_type, std::has_unique_object_representations<int>>::value, ""); +static_assert(std::is_base_of<std::false_type, std::is_aggregate<int>>::value, ""); +static_assert(std::is_base_of<std::false_type, std::is_swappable_with<int, int>>::value, ""); +static_assert(std::is_base_of<std::true_type, std::is_swappable<int>>::value, ""); +static_assert(std::is_base_of<std::false_type, std::is_nothrow_swappable_with<int, int>>::value, ""); +static_assert(std::is_base_of<std::true_type, std::is_nothrow_swappable<int>>::value, ""); +static_assert(std::is_base_of<std::false_type, std::is_invocable<int>>::value, ""); +static_assert(std::is_base_of<std::false_type, std::is_invocable_r<int, int>>::value, ""); +static_assert(std::is_base_of<std::false_type, std::is_nothrow_invocable<int, int>>::value, ""); +static_assert(std::is_base_of<std::false_type, std::is_nothrow_invocable_r<int, int>>::value, ""); +#endif +#if TEST_STD_VER >= 20 +static_assert(std::is_base_of<std::false_type, std::is_bounded_array<int>>::value, ""); +static_assert(std::is_base_of<std::false_type, std::is_unbounded_array<int>>::value, ""); +static_assert(std::is_base_of<std::true_type, std::is_nothrow_convertible<int, int>>::value, ""); +#endif +#if TEST_STD_VER >= 23 +static_assert(std::is_base_of<std::true_type, std::is_implicit_lifetime<int>>::value, ""); +static_assert(std::is_base_of<std::false_type, std::is_scoped_enum<int>>::value, ""); +#endif +#if TEST_STD_VER >= 26 +static_assert(std::is_base_of<std::false_type, std::is_virtual_base_of<int, int>>::value, ""); +#endif diff --git a/libcxxabi/test/test_demangle.pass.cpp b/libcxxabi/test/test_demangle.pass.cpp index 9e8a7c358fbc..67b9df212ff3 100644 --- a/libcxxabi/test/test_demangle.pass.cpp +++ b/libcxxabi/test/test_demangle.pass.cpp @@ -9,7 +9,8 @@ // This test is too big for most embedded devices. // XFAIL: LIBCXX-PICOLIBC-FIXME -// This test exercises support for char array initializer lists added in dd8b266ef. +// This test exercises support for char array initializer lists added in +// dd8b266ef. // UNSUPPORTED: using-built-library-before-llvm-20 // Android's long double on x86[-64] is (64/128)-bits instead of Linux's usual @@ -32,9 +33,8 @@ // Is long double fp128? #define LDBL_FP128 (__LDBL_MANT_DIG__ == 113) -// clang-format off -const char* cases[][2] = -{ +const char *cases[][2] = { + // clang-format off {"_Z1A", "A"}, {"_Z1Av", "A()"}, {"_Z1A1B1C", "A(B, C)"}, @@ -30245,16 +30245,17 @@ const char* cases[][2] = {"_Z1fDSDRj", "f(_Sat unsigned _Fract)"}, {"_Z1fDSDRl", "f(_Sat long _Fract)"}, {"_Z1fDSDRm", "f(_Sat unsigned long _Fract)"}, + // clang-format on }; -// clang-format on const unsigned N = sizeof(cases) / sizeof(cases[0]); struct FPLiteralCase { - const char* mangled; + const char *mangled; // There are four possible demanglings of a given float. std::string expecting[4]; } fp_literal_cases[] = { + // clang-format off {"_ZN5test01gIfEEvRAszplcvT__ELf40a00000E_c", { "void test0::g<float>(char (&) [sizeof ((float)() + 0x1.4p+2f)])", @@ -30280,15 +30281,17 @@ struct FPLiteralCase { #endif #if LDBL_FP128 // A 32-character FP literal of long double type - {"3FooILeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeEE", {"Foo<-0x1.eeeeeeeeeeeeeeeeeeeeeeeeeeeep+12015L>"}}, + {"3FooILeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeEE", + {"Foo<-0x1.eeeeeeeeeeeeeeeeeeeeeeeeeeeep+12015L>"}}, #endif + // clang-format on }; const unsigned NF = sizeof(fp_literal_cases) / sizeof(fp_literal_cases[0]); -const unsigned NEF = sizeof(fp_literal_cases[0].expecting) / sizeof(fp_literal_cases[0].expecting[0]); +const unsigned NEF = sizeof(fp_literal_cases[0].expecting) / + sizeof(fp_literal_cases[0].expecting[0]); - -const char* invalid_cases[] = -{ +const char *invalid_cases[] = { + // clang-format off "_ZIPPreEncode", "Agentt", "NSoERj5E=Y1[uM:ga", @@ -30299,7 +30302,7 @@ const char* invalid_cases[] = #if !LDBL_FP80 "_ZN5test01hIfEEvRAcvjplstT_Le4001a000000000000000E_c", #endif - // The following test cases were found by libFuzzer+ASAN + // The following test cases were found by libFuzzer+ASAN "\x44\x74\x70\x74\x71\x75\x34\x43\x41\x72\x4D\x6E\x65\x34\x9F\xC1\x43\x41\x72\x4D\x6E\x77\x38\x9A\x8E\x44\x6F\x64\x6C\x53\xF9\x5F\x70\x74\x70\x69\x45\x34\xD3\x73\x9E\x2A\x37", "\x4D\x41\x72\x63\x4E\x39\x44\x76\x72\x4D\x34\x44\x53\x4B\x6F\x44\x54\x6E\x61\x37\x47\x77\x78\x38\x43\x27\x41\x5F\x73\x70\x69\x45*", "\x41\x64\x6E\x32*", @@ -30345,128 +30348,114 @@ const char* invalid_cases[] = "_ZGI3Foo", "_ZGIW3Foov", "W1x", + // clang-format on }; const unsigned NI = sizeof(invalid_cases) / sizeof(invalid_cases[0]); -void test() -{ - std::size_t len = 0; - char* buf = nullptr; - bool failed = false; - for (unsigned i = 0; i < N; ++i) - { - int status; - char* demang = - __cxxabiv1::__cxa_demangle(cases[i][0], buf, &len, &status); - if (!demang || std::strcmp(demang, cases[i][1]) != 0) - { - std::fprintf(stderr, "ERROR demangling %s\n" - "expected: %s\n" - "got: %d, %s\n", - cases[i][0], cases[i][1], status, - demang ? demang : "(null)"); - failed = true; - } - if (demang) - buf = demang; +void test() { + std::size_t len = 0; + char *buf = nullptr; + bool failed = false; + for (unsigned i = 0; i < N; ++i) { + int status; + char *demang = __cxxabiv1::__cxa_demangle(cases[i][0], buf, &len, &status); + if (!demang || std::strcmp(demang, cases[i][1]) != 0) { + std::fprintf(stderr, + "ERROR demangling %s\n" + "expected: %s\n" + "got: %d, %s\n", + cases[i][0], cases[i][1], status, + demang ? demang : "(null)"); + failed = true; } - free(buf); - assert(!failed && "demangle failed"); + if (demang) + buf = demang; + } + free(buf); + assert(!failed && "demangle failed"); } -void test_invalid_cases() -{ - std::size_t len = 0; - char* buf = nullptr; - bool passed = false; - for (unsigned i = 0; i < NI; ++i) - { - int status; - char* demang = - __cxxabiv1::__cxa_demangle(invalid_cases[i], buf, &len, &status); - if (status != -2) - { - std::printf("%s should be invalid but is not\n", invalid_cases[i]); - std::printf("Got: %d, %s\n", status, demang ? demang : "(null)"); - passed = true; - } - if (demang) - buf = demang; +void test_invalid_cases() { + std::size_t len = 0; + char *buf = nullptr; + bool passed = false; + for (unsigned i = 0; i < NI; ++i) { + int status; + char *demang = + __cxxabiv1::__cxa_demangle(invalid_cases[i], buf, &len, &status); + if (status != -2) { + std::printf("%s should be invalid but is not\n", invalid_cases[i]); + std::printf("Got: %d, %s\n", status, demang ? demang : "(null)"); + passed = true; } - free(buf); - assert(!passed && "demangle did not fail"); + if (demang) + buf = demang; + } + free(buf); + assert(!passed && "demangle did not fail"); } const char *const xfail_cases[] = { // Sentinel value - nullptr + nullptr, }; -void test_xfail_cases() -{ - std::size_t len = 0; - char* buf = nullptr; - for (const char *c_str : xfail_cases) - { - if (!c_str) - break; - int status; - char* demang = __cxxabiv1::__cxa_demangle(c_str, buf, &len, &status); - if (status != -2) - { - std::printf("%s was documented as xfail but passed\n", c_str); - std::printf("Got status = %d\n", status); - assert(status == -2); - } - else - { - buf = demang; - } +void test_xfail_cases() { + std::size_t len = 0; + char *buf = nullptr; + for (const char *c_str : xfail_cases) { + if (!c_str) + break; + int status; + char *demang = __cxxabiv1::__cxa_demangle(c_str, buf, &len, &status); + if (status != -2) { + std::printf("%s was documented as xfail but passed\n", c_str); + std::printf("Got status = %d\n", status); + assert(status == -2); + } else { + buf = demang; } - free(buf); + } + free(buf); } -void testFPLiterals() -{ - std::size_t len = 0; - char* buf = nullptr; - for (unsigned i = 0; i < NF; ++i) - { - FPLiteralCase *fpCase = fp_literal_cases+i; - int status; - char* demang = __cxxabiv1::__cxa_demangle(fpCase->mangled, buf, &len, &status); - if (demang == 0) - { - std::printf("%s -> %s\n", fpCase->mangled, fpCase->expecting[0].c_str()); - std::printf("Got instead: NULL, %d\n", status); - assert(false); - continue; - } - std::string *e_beg = fpCase->expecting; - std::string *e_end = fpCase->expecting + NEF; - if (std::find(e_beg, e_end, demang) == e_end) - { - std::printf("%s -> %s\n", fpCase->mangled, fpCase->expecting[0].c_str()); - std::printf("Got instead: %s\n", demang); - assert(false); - continue; - } - buf = demang; +void testFPLiterals() { + std::size_t len = 0; + char *buf = nullptr; + for (unsigned i = 0; i < NF; ++i) { + FPLiteralCase *fpCase = fp_literal_cases + i; + int status; + char *demang = + __cxxabiv1::__cxa_demangle(fpCase->mangled, buf, &len, &status); + if (demang == 0) { + std::printf("%s -> %s\n", fpCase->mangled, fpCase->expecting[0].c_str()); + std::printf("Got instead: NULL, %d\n", status); + assert(false); + continue; } - free(buf); + std::string *e_beg = fpCase->expecting; + std::string *e_end = fpCase->expecting + NEF; + if (std::find(e_beg, e_end, demang) == e_end) { + std::printf("%s -> %s\n", fpCase->mangled, fpCase->expecting[0].c_str()); + std::printf("Got instead: %s\n", demang); + assert(false); + continue; + } + buf = demang; + } + free(buf); } -int main(int, char**) -{ - std::printf("Testing %d symbols.\n", N); - { - timer t; - test(); - test_invalid_cases(); - test_xfail_cases(); - testFPLiterals(); - } +int main(int, char **) { + std::printf("Testing %d symbols.\n", N); + { + timer t; + test(); + test_invalid_cases(); + test_xfail_cases(); + testFPLiterals(); + } #if 0 std::string input; while (std::cin) @@ -30502,5 +30491,5 @@ int main(int, char**) } #endif - return 0; + return 0; } diff --git a/lld/MachO/Arch/ARM64.cpp b/lld/MachO/Arch/ARM64.cpp index 882873ae5de0..bf458e392be8 100644 --- a/lld/MachO/Arch/ARM64.cpp +++ b/lld/MachO/Arch/ARM64.cpp @@ -202,7 +202,7 @@ InputSection *ARM64::getThunkBranchTarget(InputSection *thunk) const { assert(thunk->relocs.size() == 1 && "expected a single reloc on ARM64 ICF thunk"); auto &reloc = thunk->relocs[0]; - assert(reloc.referent.is<InputSection *>() && + assert(isa<InputSection *>(reloc.referent) && "ARM64 thunk reloc is expected to point to an InputSection"); return reloc.referent.dyn_cast<InputSection *>(); diff --git a/lld/MachO/ConcatOutputSection.cpp b/lld/MachO/ConcatOutputSection.cpp index e89cafe0d1e6..6a9301f84a03 100644 --- a/lld/MachO/ConcatOutputSection.cpp +++ b/lld/MachO/ConcatOutputSection.cpp @@ -145,7 +145,7 @@ bool TextOutputSection::needsThunks() const { for (Reloc &r : isec->relocs) { if (!target->hasAttr(r.type, RelocAttrBits::BRANCH)) continue; - auto *sym = r.referent.get<Symbol *>(); + auto *sym = cast<Symbol *>(r.referent); // Pre-populate the thunkMap and memoize call site counts for every // InputSection and ThunkInfo. We do this for the benefit of // estimateStubsInRangeVA(). @@ -297,7 +297,7 @@ void TextOutputSection::finalize() { backwardBranchRange < callVA ? callVA - backwardBranchRange : 0; uint64_t highVA = callVA + forwardBranchRange; // Calculate our call referent address - auto *funcSym = r.referent.get<Symbol *>(); + auto *funcSym = cast<Symbol *>(r.referent); ThunkInfo &thunkInfo = thunkMap[funcSym]; // The referent is not reachable, so we need to use a thunk ... if (funcSym->isInStubs() && callVA >= stubsInRangeVA) { diff --git a/lld/MachO/EhFrame.cpp b/lld/MachO/EhFrame.cpp index 55a85f316cdd..2446b49b5098 100644 --- a/lld/MachO/EhFrame.cpp +++ b/lld/MachO/EhFrame.cpp @@ -114,7 +114,7 @@ static void createSubtraction(PointerUnion<Symbol *, InputSection *> a, auto minuend = b; if (Invert) std::swap(subtrahend, minuend); - assert(subtrahend.is<Symbol *>()); + assert(isa<Symbol *>(subtrahend)); Reloc subtrahendReloc(target->subtractorRelocType, /*pcrel=*/false, length, off, /*addend=*/0, subtrahend); Reloc minuendReloc(target->unsignedRelocType, /*pcrel=*/false, length, off, diff --git a/lld/MachO/ICF.cpp b/lld/MachO/ICF.cpp index 32dd44ab729e..75702b9c15e7 100644 --- a/lld/MachO/ICF.cpp +++ b/lld/MachO/ICF.cpp @@ -115,16 +115,16 @@ bool ICF::equalsConstant(const ConcatInputSection *ia, return false; if (ra.offset != rb.offset) return false; - if (ra.referent.is<Symbol *>() != rb.referent.is<Symbol *>()) + if (isa<Symbol *>(ra.referent) != isa<Symbol *>(rb.referent)) return false; InputSection *isecA, *isecB; uint64_t valueA = 0; uint64_t valueB = 0; - if (ra.referent.is<Symbol *>()) { - const auto *sa = ra.referent.get<Symbol *>(); - const auto *sb = rb.referent.get<Symbol *>(); + if (isa<Symbol *>(ra.referent)) { + const auto *sa = cast<Symbol *>(ra.referent); + const auto *sb = cast<Symbol *>(rb.referent); if (sa->kind() != sb->kind()) return false; // ICF runs before Undefineds are treated (and potentially converted into @@ -143,8 +143,8 @@ bool ICF::equalsConstant(const ConcatInputSection *ia, isecB = db->isec(); valueB = db->value; } else { - isecA = ra.referent.get<InputSection *>(); - isecB = rb.referent.get<InputSection *>(); + isecA = cast<InputSection *>(ra.referent); + isecB = cast<InputSection *>(rb.referent); } // Typically, we should not encounter sections marked with `keepUnique` at @@ -167,7 +167,7 @@ bool ICF::equalsConstant(const ConcatInputSection *ia, return ra.addend == rb.addend; // Else we have two literal sections. References to them are equal iff their // offsets in the output section are equal. - if (ra.referent.is<Symbol *>()) + if (isa<Symbol *>(ra.referent)) // For symbol relocs, we compare the contents at the symbol address. We // don't do `getOffset(value + addend)` because value + addend may not be // a valid offset in the literal section. @@ -195,12 +195,12 @@ bool ICF::equalsVariable(const ConcatInputSection *ia, if (ra.referent == rb.referent) return true; const ConcatInputSection *isecA, *isecB; - if (ra.referent.is<Symbol *>()) { + if (isa<Symbol *>(ra.referent)) { // Matching DylibSymbols are already filtered out by the // identical-referent check above. Non-matching DylibSymbols were filtered // out in equalsConstant(). So we can safely cast to Defined here. - const auto *da = cast<Defined>(ra.referent.get<Symbol *>()); - const auto *db = cast<Defined>(rb.referent.get<Symbol *>()); + const auto *da = cast<Defined>(cast<Symbol *>(ra.referent)); + const auto *db = cast<Defined>(cast<Symbol *>(rb.referent)); if (da->isAbsolute()) return true; isecA = dyn_cast<ConcatInputSection>(da->isec()); @@ -208,8 +208,8 @@ bool ICF::equalsVariable(const ConcatInputSection *ia, return true; // literal sections were checked in equalsConstant. isecB = cast<ConcatInputSection>(db->isec()); } else { - const auto *sa = ra.referent.get<InputSection *>(); - const auto *sb = rb.referent.get<InputSection *>(); + const auto *sa = cast<InputSection *>(ra.referent); + const auto *sb = cast<InputSection *>(rb.referent); isecA = dyn_cast<ConcatInputSection>(sa); if (!isecA) return true; diff --git a/lld/MachO/InputFiles.cpp b/lld/MachO/InputFiles.cpp index c3f7c434ffca..9adfbc9d3f6f 100644 --- a/lld/MachO/InputFiles.cpp +++ b/lld/MachO/InputFiles.cpp @@ -1291,7 +1291,7 @@ static CIE parseCIE(const InputSection *isec, const EhReader &reader, const auto *personalityReloc = isec->getRelocAt(personalityAddrOff); if (!personalityReloc) reader.failOn(off, "Failed to locate relocation for personality symbol"); - cie.personalitySymbol = personalityReloc->referent.get<macho::Symbol *>(); + cie.personalitySymbol = cast<macho::Symbol *>(personalityReloc->referent); } return cie; } @@ -1338,12 +1338,12 @@ targetSymFromCanonicalSubtractor(const InputSection *isec, assert(target->hasAttr(minuend.type, RelocAttrBits::UNSIGNED)); // Note: pcSym may *not* be exactly at the PC; there's usually a non-zero // addend. - auto *pcSym = cast<Defined>(subtrahend.referent.get<macho::Symbol *>()); + auto *pcSym = cast<Defined>(cast<macho::Symbol *>(subtrahend.referent)); Defined *target = cast_or_null<Defined>(minuend.referent.dyn_cast<macho::Symbol *>()); if (!pcSym) { auto *targetIsec = - cast<ConcatInputSection>(minuend.referent.get<InputSection *>()); + cast<ConcatInputSection>(cast<InputSection *>(minuend.referent)); target = findSymbolAtOffset(targetIsec, minuend.addend); } if (Invert) diff --git a/lld/MachO/InputSection.cpp b/lld/MachO/InputSection.cpp index c1b3297f321f..07e39b04cba4 100644 --- a/lld/MachO/InputSection.cpp +++ b/lld/MachO/InputSection.cpp @@ -226,13 +226,13 @@ void ConcatInputSection::writeTo(uint8_t *buf) { const bool needsFixup = config->emitChainedFixups && target->hasAttr(r.type, RelocAttrBits::UNSIGNED); if (target->hasAttr(r.type, RelocAttrBits::SUBTRAHEND)) { - const Symbol *fromSym = r.referent.get<Symbol *>(); + const Symbol *fromSym = cast<Symbol *>(r.referent); const Reloc &minuend = relocs[++i]; uint64_t minuendVA; if (const Symbol *toSym = minuend.referent.dyn_cast<Symbol *>()) minuendVA = toSym->getVA() + minuend.addend; else { - auto *referentIsec = minuend.referent.get<InputSection *>(); + auto *referentIsec = cast<InputSection *>(minuend.referent); assert(!::shouldOmitFromOutput(referentIsec)); minuendVA = referentIsec->getVA(minuend.addend); } diff --git a/lld/MachO/MarkLive.cpp b/lld/MachO/MarkLive.cpp index c26c3aa32119..4f67f3a2d802 100644 --- a/lld/MachO/MarkLive.cpp +++ b/lld/MachO/MarkLive.cpp @@ -160,7 +160,7 @@ void MarkLiveImpl<RecordWhyLive>::markTransitively() { if (auto *s = r.referent.dyn_cast<Symbol *>()) addSym(s, entry); else - enqueue(r.referent.get<InputSection *>(), r.addend, entry); + enqueue(cast<InputSection *>(r.referent), r.addend, entry); } for (Defined *d : getInputSection(entry)->symbols) addSym(d, entry); @@ -183,7 +183,7 @@ void MarkLiveImpl<RecordWhyLive>::markTransitively() { enqueue(isec, 0, makeEntry(referentIsec, nullptr)); } } else { - auto *referentIsec = r.referent.get<InputSection *>(); + auto *referentIsec = cast<InputSection *>(r.referent); if (referentIsec->isLive(r.addend)) enqueue(isec, 0, makeEntry(referentIsec, nullptr)); } diff --git a/lld/MachO/ObjC.cpp b/lld/MachO/ObjC.cpp index ff13e8eb4b5c..272197b34e11 100644 --- a/lld/MachO/ObjC.cpp +++ b/lld/MachO/ObjC.cpp @@ -263,7 +263,7 @@ void ObjcCategoryChecker::parseCategory(const ConcatInputSection *catIsec) { if (!classReloc) return; - auto *classSym = classReloc->referent.get<Symbol *>(); + auto *classSym = cast<Symbol *>(classReloc->referent); if (auto *d = dyn_cast<Defined>(classSym)) if (!classMap.count(d)) parseClass(d); @@ -603,7 +603,7 @@ void ObjcCategoryMerger::tryEraseDefinedAtIsecOffset( if (!reloc) return; - Defined *sym = dyn_cast_or_null<Defined>(reloc->referent.get<Symbol *>()); + Defined *sym = dyn_cast_or_null<Defined>(cast<Symbol *>(reloc->referent)); if (!sym) return; @@ -675,7 +675,7 @@ void ObjcCategoryMerger::parseProtocolListInfo( if (!reloc) return; - auto *ptrListSym = dyn_cast_or_null<Defined>(reloc->referent.get<Symbol *>()); + auto *ptrListSym = dyn_cast_or_null<Defined>(cast<Symbol *>(reloc->referent)); assert(ptrListSym && "Protocol list reloc does not have a valid Defined"); // Theoretically protocol count can be either 32b or 64b, depending on @@ -707,7 +707,7 @@ void ObjcCategoryMerger::parseProtocolListInfo( const Reloc *reloc = ptrListSym->isec()->getRelocAt(off); assert(reloc && "No reloc found at protocol list offset"); - auto *listSym = dyn_cast_or_null<Defined>(reloc->referent.get<Symbol *>()); + auto *listSym = dyn_cast_or_null<Defined>(cast<Symbol *>(reloc->referent)); assert(listSym && "Protocol list reloc does not have a valid Defined"); ptrList.allPtrs.push_back(listSym); @@ -745,7 +745,7 @@ bool ObjcCategoryMerger::parsePointerListInfo(const ConcatInputSection *isec, if (!reloc) return true; - auto *ptrListSym = dyn_cast_or_null<Defined>(reloc->referent.get<Symbol *>()); + auto *ptrListSym = dyn_cast_or_null<Defined>(cast<Symbol *>(reloc->referent)); assert(ptrListSym && "Reloc does not have a valid Defined"); uint32_t thisStructSize = *reinterpret_cast<const uint32_t *>( diff --git a/lld/MachO/Relocations.cpp b/lld/MachO/Relocations.cpp index e8ede19d1fda..aac0e1bd3c9e 100644 --- a/lld/MachO/Relocations.cpp +++ b/lld/MachO/Relocations.cpp @@ -27,7 +27,7 @@ InputSection *Reloc::getReferentInputSection() const { return d->isec(); return nullptr; } else { - return referent.get<InputSection *>(); + return cast<InputSection *>(referent); } } @@ -38,7 +38,7 @@ StringRef Reloc::getReferentString() const { return cisec->getStringRefAtOffset(addend); } - auto *sym = dyn_cast<Defined>(referent.get<Symbol *>()); + auto *sym = dyn_cast<Defined>(cast<Symbol *>(referent)); assert(sym && "referent must be a Defined symbol"); auto *symIsec = sym->isec(); diff --git a/lld/MachO/SyntheticSections.cpp b/lld/MachO/SyntheticSections.cpp index 24844c2f3a1e..28fb8047cacd 100644 --- a/lld/MachO/SyntheticSections.cpp +++ b/lld/MachO/SyntheticSections.cpp @@ -1990,7 +1990,7 @@ void InitOffsetsSection::setUp() { if (rel.addend != 0) error(isec->getLocation(rel.offset) + ": relocation addend is not representable in __init_offsets"); - if (rel.referent.is<InputSection *>()) + if (isa<InputSection *>(rel.referent)) error(isec->getLocation(rel.offset) + ": unexpected section relocation"); @@ -2136,12 +2136,12 @@ void ObjCMethListSection::writeRelativeOffsetForIsec( symVA = selRef->getVA(); assert(selRef->data.size() == target->wordSize && "Expected one selref per ConcatInputSection"); - } else if (reloc->referent.is<Symbol *>()) { - auto *def = dyn_cast_or_null<Defined>(reloc->referent.get<Symbol *>()); + } else if (auto *sym = dyn_cast<Symbol *>(reloc->referent)) { + auto *def = dyn_cast_or_null<Defined>(sym); assert(def && "Expected all syms in __objc_methlist to be defined"); symVA = def->getVA(); } else { - auto *isec = reloc->referent.get<InputSection *>(); + auto *isec = cast<InputSection *>(reloc->referent); symVA = isec->getVA(reloc->addend); } diff --git a/lld/MachO/UnwindInfoSection.cpp b/lld/MachO/UnwindInfoSection.cpp index 7033481d6014..624464e41d77 100644 --- a/lld/MachO/UnwindInfoSection.cpp +++ b/lld/MachO/UnwindInfoSection.cpp @@ -390,7 +390,7 @@ void UnwindInfoSectionImpl::relocateCompactUnwind( cu.encoding = support::endian::read32le(buf + cuLayout.encodingOffset); for (const Reloc &r : d->unwindEntry()->relocs) { if (r.offset == cuLayout.personalityOffset) - cu.personality = r.referent.get<Symbol *>(); + cu.personality = cast<Symbol *>(r.referent); else if (r.offset == cuLayout.lsdaOffset) cu.lsda = r.getReferentInputSection(); } diff --git a/lld/wasm/Config.h b/lld/wasm/Config.h index eb32ce80f4a3..0c2ba3eebffc 100644 --- a/lld/wasm/Config.h +++ b/lld/wasm/Config.h @@ -43,7 +43,7 @@ enum class BuildIdKind { None, Fast, Sha1, Hexstring, Uuid }; // Most fields are direct mapping from the command line options // and such fields have the same name as the corresponding options. // Most fields are initialized by the driver. -struct Configuration { +struct Config { bool allowMultipleDefinition; bool bsymbolic; bool checkFeatures; @@ -126,11 +126,18 @@ struct Configuration { llvm::SmallVector<uint8_t, 0> buildIdVector; }; +struct ConfigWrapper { + Config c; + Config *operator->() { return &c; } +}; + // The only instance of Configuration struct. -extern Configuration *config; +extern ConfigWrapper config; // The Ctx object hold all other (non-configuration) global state. struct Ctx { + Config &arg; + llvm::SmallVector<ObjFile *, 0> objectFiles; llvm::SmallVector<StubFile *, 0> stubFiles; llvm::SmallVector<SharedFile *, 0> sharedFiles; @@ -156,6 +163,7 @@ struct Ctx { 0> whyExtractRecords; + Ctx(); void reset(); }; diff --git a/lld/wasm/Driver.cpp b/lld/wasm/Driver.cpp index 00b5c82d9c77..02471950fb51 100644 --- a/lld/wasm/Driver.cpp +++ b/lld/wasm/Driver.cpp @@ -44,7 +44,7 @@ using namespace llvm::sys; using namespace llvm::wasm; namespace lld::wasm { -Configuration *config; +ConfigWrapper config; Ctx ctx; void errorOrWarn(const llvm::Twine &msg) { @@ -54,7 +54,11 @@ void errorOrWarn(const llvm::Twine &msg) { error(msg); } +Ctx::Ctx() : arg(config.c) {} + void Ctx::reset() { + arg.~Config(); + new (&arg) Config(); objectFiles.clear(); stubFiles.clear(); sharedFiles.clear(); @@ -92,6 +96,7 @@ static void initLLVM() { class LinkerDriver { public: + LinkerDriver(Ctx &); void linkerMain(ArrayRef<const char *> argsArr); private: @@ -99,6 +104,8 @@ private: void addFile(StringRef path); void addLibrary(StringRef name); + Ctx &ctx; + // True if we are in --whole-archive and --no-whole-archive. bool inWholeArchive = false; @@ -122,19 +129,19 @@ static bool hasZOption(opt::InputArgList &args, StringRef key) { bool link(ArrayRef<const char *> args, llvm::raw_ostream &stdoutOS, llvm::raw_ostream &stderrOS, bool exitEarly, bool disableOutput) { // This driver-specific context will be freed later by unsafeLldMain(). - auto *ctx = new CommonLinkerContext; + auto *context = new CommonLinkerContext; - ctx->e.initialize(stdoutOS, stderrOS, exitEarly, disableOutput); - ctx->e.cleanupCallback = []() { wasm::ctx.reset(); }; - ctx->e.logName = args::getFilenameWithoutExe(args[0]); - ctx->e.errorLimitExceededMsg = "too many errors emitted, stopping now (use " - "-error-limit=0 to see all errors)"; + context->e.initialize(stdoutOS, stderrOS, exitEarly, disableOutput); + context->e.cleanupCallback = []() { ctx.reset(); }; + context->e.logName = args::getFilenameWithoutExe(args[0]); + context->e.errorLimitExceededMsg = + "too many errors emitted, stopping now (use " + "-error-limit=0 to see all errors)"; - config = make<Configuration>(); symtab = make<SymbolTable>(); initLLVM(); - LinkerDriver().linkerMain(args); + LinkerDriver(ctx).linkerMain(args); return errorCount() == 0; } @@ -1256,6 +1263,8 @@ static void checkZOptions(opt::InputArgList &args) { warn("unknown -z value: " + StringRef(arg->getValue())); } +LinkerDriver::LinkerDriver(Ctx &ctx) : ctx(ctx) {} + void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) { WasmOptTable parser; opt::InputArgList args = parser.parse(argsArr.slice(1)); @@ -1324,10 +1333,10 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) { // Fail early if the output file or map file is not writable. If a user has a // long link, e.g. due to a large LTO link, they do not wish to run it and // find that it failed because there was a mistake in their command-line. - if (auto e = tryCreateFile(config->outputFile)) - error("cannot open output file " + config->outputFile + ": " + e.message()); - if (auto e = tryCreateFile(config->mapFile)) - error("cannot open map file " + config->mapFile + ": " + e.message()); + if (auto e = tryCreateFile(ctx.arg.outputFile)) + error("cannot open output file " + ctx.arg.outputFile + ": " + e.message()); + if (auto e = tryCreateFile(ctx.arg.mapFile)) + error("cannot open map file " + ctx.arg.mapFile + ": " + e.message()); if (errorCount()) return; @@ -1336,11 +1345,11 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) { symtab->trace(arg->getValue()); for (auto *arg : args.filtered(OPT_export_if_defined)) - config->exportedSymbols.insert(arg->getValue()); + ctx.arg.exportedSymbols.insert(arg->getValue()); for (auto *arg : args.filtered(OPT_export)) { - config->exportedSymbols.insert(arg->getValue()); - config->requiredExports.push_back(arg->getValue()); + ctx.arg.exportedSymbols.insert(arg->getValue()); + ctx.arg.requiredExports.push_back(arg->getValue()); } createSyntheticSymbols(); @@ -1358,17 +1367,17 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) { // Handle the `--export <sym>` options // This works like --undefined but also exports the symbol if its found - for (auto &iter : config->exportedSymbols) + for (auto &iter : ctx.arg.exportedSymbols) handleUndefined(iter.first(), "--export"); Symbol *entrySym = nullptr; - if (!config->relocatable && !config->entry.empty()) { - entrySym = handleUndefined(config->entry, "--entry"); + if (!ctx.arg.relocatable && !ctx.arg.entry.empty()) { + entrySym = handleUndefined(ctx.arg.entry, "--entry"); if (entrySym && entrySym->isDefined()) entrySym->forceExport = true; else error("entry symbol not defined (pass --no-entry to suppress): " + - config->entry); + ctx.arg.entry); } // If the user code defines a `__wasm_call_dtors` function, remember it so @@ -1376,10 +1385,10 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) { // `__wasm_call_ctors` which we synthesize, `__wasm_call_dtors` is defined // by libc/etc., because destructors are registered dynamically with // `__cxa_atexit` and friends. - if (!config->relocatable && !config->shared && + if (!ctx.arg.relocatable && !ctx.arg.shared && !WasmSym::callCtors->isUsedInRegularObj && - WasmSym::callCtors->getName() != config->entry && - !config->exportedSymbols.count(WasmSym::callCtors->getName())) { + WasmSym::callCtors->getName() != ctx.arg.entry && + !ctx.arg.exportedSymbols.count(WasmSym::callCtors->getName())) { if (Symbol *callDtors = handleUndefined("__wasm_call_dtors", "<internal>")) { if (auto *callDtorsFunc = dyn_cast<DefinedFunction>(callDtors)) { @@ -1437,7 +1446,7 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) { writeWhyExtract(); // Bail out if normal linked output is skipped due to LTO. - if (config->thinLTOIndexOnly) + if (ctx.arg.thinLTOIndexOnly) return; createOptionalSymbols(); @@ -1452,13 +1461,13 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) { if (!wrapped.empty()) wrapSymbols(wrapped); - for (auto &iter : config->exportedSymbols) { + for (auto &iter : ctx.arg.exportedSymbols) { Symbol *sym = symtab->find(iter.first()); if (sym && sym->isDefined()) sym->forceExport = true; } - if (!config->relocatable && !ctx.isPic) { + if (!ctx.arg.relocatable && !ctx.isPic) { // Add synthetic dummies for weak undefined functions. Must happen // after LTO otherwise functions may not yet have signatures. symtab->handleWeakUndefines(); diff --git a/llvm/include/llvm/Analysis/PtrUseVisitor.h b/llvm/include/llvm/Analysis/PtrUseVisitor.h index bbe2741f44fc..c9d3874e7dd9 100644 --- a/llvm/include/llvm/Analysis/PtrUseVisitor.h +++ b/llvm/include/llvm/Analysis/PtrUseVisitor.h @@ -64,6 +64,9 @@ public: /// Is the pointer escaped at some point? bool isEscaped() const { return EscapedInfo != nullptr; } + /// Is the pointer escaped into a read-only nocapture call at some point? + bool isEscapedReadOnly() const { return EscapedReadOnly != nullptr; } + /// Get the instruction causing the visit to abort. /// \returns a pointer to the instruction causing the abort if one is /// available; otherwise returns null. @@ -74,6 +77,10 @@ public: /// is available; otherwise returns null. Instruction *getEscapingInst() const { return EscapedInfo; } + /// Get the instruction causing the pointer to escape which is a read-only + /// nocapture call. + Instruction *getEscapedReadOnlyInst() const { return EscapedReadOnly; } + /// Mark the visit as aborted. Intended for use in a void return. /// \param I The instruction which caused the visit to abort, if available. void setAborted(Instruction *I) { @@ -88,6 +95,12 @@ public: EscapedInfo = I; } + /// Mark the pointer as escaped into a readonly-nocapture call. + void setEscapedReadOnly(Instruction *I) { + assert(I && "Expected a valid pointer in setEscapedReadOnly"); + EscapedReadOnly = I; + } + /// Mark the pointer as escaped, and the visit as aborted. Intended /// for use in a void return. /// \param I The instruction which both escapes the pointer and aborts the @@ -100,6 +113,7 @@ public: private: Instruction *AbortedInfo = nullptr; Instruction *EscapedInfo = nullptr; + Instruction *EscapedReadOnly = nullptr; }; protected: diff --git a/llvm/include/llvm/Transforms/Utils/SSAUpdater.h b/llvm/include/llvm/Transforms/Utils/SSAUpdater.h index 73649766a953..989cf0b2d0e7 100644 --- a/llvm/include/llvm/Transforms/Utils/SSAUpdater.h +++ b/llvm/include/llvm/Transforms/Utils/SSAUpdater.h @@ -188,6 +188,13 @@ public: /// Return false if a sub-class wants to keep one of the loads/stores /// after the SSA construction. virtual bool shouldDelete(Instruction *I) const { return true; } + + /// Return the value to use for the point in the code that the alloca is + /// positioned. This will only be used if an Alloca is included in Insts, + /// otherwise the value of a uninitialized load will be assumed to be poison. + virtual Value *getValueToUseForAlloca(Instruction *AI) const { + return nullptr; + } }; } // end namespace llvm diff --git a/llvm/lib/Target/AArch64/AArch64ExpandPseudoInsts.cpp b/llvm/lib/Target/AArch64/AArch64ExpandPseudoInsts.cpp index 0ce4b8971625..bd542f62dccb 100644 --- a/llvm/lib/Target/AArch64/AArch64ExpandPseudoInsts.cpp +++ b/llvm/lib/Target/AArch64/AArch64ExpandPseudoInsts.cpp @@ -1149,7 +1149,7 @@ bool AArch64ExpandPseudo::expandMultiVecPseudo( bool AArch64ExpandPseudo::expandFormTuplePseudo( MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, MachineBasicBlock::iterator &NextMBBI, unsigned Size) { - assert(Size == 2 || Size == 4 && "Invalid Tuple Size"); + assert((Size == 2 || Size == 4) && "Invalid Tuple Size"); MachineInstr &MI = *MBBI; Register ReturnTuple = MI.getOperand(0).getReg(); diff --git a/llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp b/llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp index e5baffc0f064..6e1f188bb3d3 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp @@ -1181,8 +1181,8 @@ bool AMDGPURegisterBankInfo::applyMappingDynStackAlloc( // Guard in case the stack growth direction ever changes with scratch // instructions. - if (TFI.getStackGrowthDirection() == TargetFrameLowering::StackGrowsDown) - return false; + assert(TFI.getStackGrowthDirection() == TargetFrameLowering::StackGrowsUp && + "Stack grows upwards for AMDGPU"); Register Dst = MI.getOperand(0).getReg(); Register AllocSize = MI.getOperand(1).getReg(); diff --git a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp index 88f7fe0a98d1..7256eec89008 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp @@ -1560,7 +1560,7 @@ static const char RegAllocOptNotSupportedMessage[] = bool GCNPassConfig::addRegAssignAndRewriteFast() { if (!usingDefaultRegAlloc()) - report_fatal_error(RegAllocOptNotSupportedMessage, /*GenCrashDiag=*/false); + report_fatal_error(RegAllocOptNotSupportedMessage); addPass(&GCNPreRALongBranchRegID); @@ -1586,7 +1586,7 @@ bool GCNPassConfig::addRegAssignAndRewriteFast() { bool GCNPassConfig::addRegAssignAndRewriteOptimized() { if (!usingDefaultRegAlloc()) - report_fatal_error(RegAllocOptNotSupportedMessage, /*GenCrashDiag=*/false); + report_fatal_error(RegAllocOptNotSupportedMessage); addPass(&GCNPreRALongBranchRegID); diff --git a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp index 8dfebd36a962..7da93f90341d 100644 --- a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp +++ b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp @@ -4041,17 +4041,15 @@ SDValue SITargetLowering::lowerDYNAMIC_STACKALLOCImpl(SDValue Op, Chain = SP.getValue(1); MaybeAlign Alignment = cast<ConstantSDNode>(Tmp3)->getMaybeAlignValue(); const TargetFrameLowering *TFL = Subtarget->getFrameLowering(); - unsigned Opc = - TFL->getStackGrowthDirection() == TargetFrameLowering::StackGrowsUp - ? ISD::ADD - : ISD::SUB; + assert(TFL->getStackGrowthDirection() == TargetFrameLowering::StackGrowsUp && + "Stack grows upwards for AMDGPU"); SDValue ScaledSize = DAG.getNode( ISD::SHL, dl, VT, Size, DAG.getConstant(Subtarget->getWavefrontSizeLog2(), dl, MVT::i32)); Align StackAlign = TFL->getStackAlign(); - Tmp1 = DAG.getNode(Opc, dl, VT, SP, ScaledSize); // Value + Tmp1 = DAG.getNode(ISD::ADD, dl, VT, SP, ScaledSize); // Value if (Alignment && *Alignment > StackAlign) { Tmp1 = DAG.getNode( ISD::AND, dl, VT, Tmp1, diff --git a/llvm/lib/Target/ARM/ARMConstantIslandPass.cpp b/llvm/lib/Target/ARM/ARMConstantIslandPass.cpp index 89eb49ed416a..e41e02a560db 100644 --- a/llvm/lib/Target/ARM/ARMConstantIslandPass.cpp +++ b/llvm/lib/Target/ARM/ARMConstantIslandPass.cpp @@ -1323,7 +1323,8 @@ bool ARMConstantIslands::findAvailableWater(CPUser &U, unsigned UserOffset, MachineBasicBlock *UserBB = U.MI->getParent(); BBInfoVector &BBInfo = BBUtils->getBBInfo(); const Align CPEAlign = getCPEAlign(U.CPEMI); - unsigned MinNoSplitDisp = BBInfo[UserBB->getNumber()].postOffset(CPEAlign); + unsigned MinNoSplitDisp = + BBInfo[UserBB->getNumber()].postOffset(CPEAlign) - UserOffset; if (CloserWater && MinNoSplitDisp > U.getMaxDisp() / 2) return false; for (water_iterator IP = std::prev(WaterList.end()), B = WaterList.begin();; diff --git a/llvm/lib/Target/SystemZ/SystemZInstrInfo.td b/llvm/lib/Target/SystemZ/SystemZInstrInfo.td index d6cddeb8b6c3..e70ae5dadcb0 100644 --- a/llvm/lib/Target/SystemZ/SystemZInstrInfo.td +++ b/llvm/lib/Target/SystemZ/SystemZInstrInfo.td @@ -951,10 +951,10 @@ def IILL : BinaryRI<"iill", 0xA53, insertll, GR32, imm32ll16>; def IILH : BinaryRI<"iilh", 0xA52, insertlh, GR32, imm32lh16>; def IIHL : BinaryRI<"iihl", 0xA51, insertll, GRH32, imm32ll16>; def IIHH : BinaryRI<"iihh", 0xA50, insertlh, GRH32, imm32lh16>; -def IILL64 : BinaryAliasRI<insertll, GR64, imm64ll16>; -def IILH64 : BinaryAliasRI<insertlh, GR64, imm64lh16>; -def IIHL64 : BinaryAliasRI<inserthl, GR64, imm64hl16>; -def IIHH64 : BinaryAliasRI<inserthh, GR64, imm64hh16>; +def IILL64 : BinaryAliasRI<insertll64, GR64, imm64ll16>; +def IILH64 : BinaryAliasRI<insertlh64, GR64, imm64lh16>; +def IIHL64 : BinaryAliasRI<inserthl64, GR64, imm64hl16>; +def IIHH64 : BinaryAliasRI<inserthh64, GR64, imm64hh16>; // ...likewise for 32-bit immediates. For GR32s this is a general // full-width move. (We use IILF rather than something like LLILF diff --git a/llvm/lib/Target/SystemZ/SystemZOperators.td b/llvm/lib/Target/SystemZ/SystemZOperators.td index 90fb4e5f370d..15b334b042d2 100644 --- a/llvm/lib/Target/SystemZ/SystemZOperators.td +++ b/llvm/lib/Target/SystemZ/SystemZOperators.td @@ -757,20 +757,18 @@ defm block_or : block_op<or>; defm block_xor : block_op<xor>; // Insertions. -def inserti8 : PatFrag<(ops node:$src1, node:$src2), - (or (and node:$src1, -256), node:$src2)>; -def insertll : PatFrag<(ops node:$src1, node:$src2), - (or (and node:$src1, 0xffffffffffff0000), node:$src2)>; -def insertlh : PatFrag<(ops node:$src1, node:$src2), - (or (and node:$src1, 0xffffffff0000ffff), node:$src2)>; -def inserthl : PatFrag<(ops node:$src1, node:$src2), - (or (and node:$src1, 0xffff0000ffffffff), node:$src2)>; -def inserthh : PatFrag<(ops node:$src1, node:$src2), - (or (and node:$src1, 0x0000ffffffffffff), node:$src2)>; -def insertlf : PatFrag<(ops node:$src1, node:$src2), - (or (and node:$src1, 0xffffffff00000000), node:$src2)>; -def inserthf : PatFrag<(ops node:$src1, node:$src2), - (or (and node:$src1, 0x00000000ffffffff), node:$src2)>; +class insert_imm<int mask> : PatFrag<(ops node:$src1, node:$src2), + (or (and node:$src1, mask), node:$src2)>; + +def inserti8 : insert_imm<-256>; +def insertll : insert_imm<0xffff0000>; +def insertlh : insert_imm<0x0000ffff>; +def insertll64 : insert_imm<0xffffffffffff0000>; +def insertlh64 : insert_imm<0xffffffff0000ffff>; +def inserthl64 : insert_imm<0xffff0000ffffffff>; +def inserthh64 : insert_imm<0x0000ffffffffffff>; +def insertlf : insert_imm<0xffffffff00000000>; +def inserthf : insert_imm<0x00000000ffffffff>; // ORs that can be treated as insertions. def or_as_inserti8 : PatFrag<(ops node:$src1, node:$src2), diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index 290c41a5bf03..7d23176c493a 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -56568,14 +56568,11 @@ static SDValue matchPMADDWD(SelectionDAG &DAG, SDNode *N, Op0H = Op0->getOperand(i + 1), Op1H = Op1->getOperand(i + 1); // TODO: Be more tolerant to undefs. APInt Idx0L, Idx0H, Idx1L, Idx1H; - if (!sd_match(Op0L, m_BinOp(ISD::EXTRACT_VECTOR_ELT, m_Value(), - m_ConstInt(Idx0L))) || - !sd_match(Op0H, m_BinOp(ISD::EXTRACT_VECTOR_ELT, m_Value(), - m_ConstInt(Idx0H))) || - !sd_match(Op1L, m_BinOp(ISD::EXTRACT_VECTOR_ELT, m_Value(), - m_ConstInt(Idx1L))) || - !sd_match(Op1H, m_BinOp(ISD::EXTRACT_VECTOR_ELT, m_Value(), - m_ConstInt(Idx1H)))) + SDValue Vec0L, Vec0H, Vec1L, Vec1H; + if (!sd_match(Op0L, m_ExtractElt(m_Value(Vec0L), m_ConstInt(Idx0L))) || + !sd_match(Op0H, m_ExtractElt(m_Value(Vec0H), m_ConstInt(Idx0H))) || + !sd_match(Op1L, m_ExtractElt(m_Value(Vec1L), m_ConstInt(Idx1L))) || + !sd_match(Op1H, m_ExtractElt(m_Value(Vec1H), m_ConstInt(Idx1H)))) return SDValue(); // Commutativity of mul allows factors of a product to reorder. if (Idx0L.getZExtValue() > Idx1L.getZExtValue()) @@ -56594,14 +56591,13 @@ static SDValue matchPMADDWD(SelectionDAG &DAG, SDNode *N, // First time an extract_elt's source vector is visited. Must be a MUL // with 2X number of vector elements than the BUILD_VECTOR. // Both extracts must be from same MUL. - Mul = Op0L->getOperand(0); - if (Mul->getOpcode() != ISD::MUL || + Mul = Vec0L; + if (Mul.getOpcode() != ISD::MUL || Mul.getValueType().getVectorNumElements() != 2 * e) return SDValue(); } // Check that the extract is from the same MUL previously seen. - if (Mul != Op0L->getOperand(0) || Mul != Op1L->getOperand(0) || - Mul != Op0H->getOperand(0) || Mul != Op1H->getOperand(0)) + if (Mul != Vec0L || Mul != Vec1L || Mul != Vec0H || Mul != Vec1H) return SDValue(); } @@ -56681,14 +56677,10 @@ static SDValue matchPMADDWD_2(SelectionDAG &DAG, SDNode *N, // TODO: Be more tolerant to undefs. SDValue N00In, N01In, N10In, N11In; APInt IdxN00, IdxN01, IdxN10, IdxN11; - if (!sd_match(N00Elt, m_BinOp(ISD::EXTRACT_VECTOR_ELT, m_Value(N00In), - m_ConstInt(IdxN00))) || - !sd_match(N01Elt, m_BinOp(ISD::EXTRACT_VECTOR_ELT, m_Value(N01In), - m_ConstInt(IdxN01))) || - !sd_match(N10Elt, m_BinOp(ISD::EXTRACT_VECTOR_ELT, m_Value(N10In), - m_ConstInt(IdxN10))) || - !sd_match(N11Elt, m_BinOp(ISD::EXTRACT_VECTOR_ELT, m_Value(N11In), - m_ConstInt(IdxN11)))) + if (!sd_match(N00Elt, m_ExtractElt(m_Value(N00In), m_ConstInt(IdxN00))) || + !sd_match(N01Elt, m_ExtractElt(m_Value(N01In), m_ConstInt(IdxN01))) || + !sd_match(N10Elt, m_ExtractElt(m_Value(N10In), m_ConstInt(IdxN10))) || + !sd_match(N11Elt, m_ExtractElt(m_Value(N11In), m_ConstInt(IdxN11)))) return SDValue(); // Add is commutative so indices can be reordered. if (IdxN00.getZExtValue() > IdxN10.getZExtValue()) { diff --git a/llvm/lib/Transforms/Instrumentation/MemProfiler.cpp b/llvm/lib/Transforms/Instrumentation/MemProfiler.cpp index ab7d3c700299..c980869a1c0d 100644 --- a/llvm/lib/Transforms/Instrumentation/MemProfiler.cpp +++ b/llvm/lib/Transforms/Instrumentation/MemProfiler.cpp @@ -725,8 +725,7 @@ static uint64_t computeStackId(const memprof::Frame &Frame) { // Helper to generate a single hash id for a given callstack, used for emitting // matching statistics and useful for uniquing such statistics across modules. -static uint64_t -computeFullStackId(const std::vector<memprof::Frame> &CallStack) { +static uint64_t computeFullStackId(ArrayRef<Frame> CallStack) { llvm::HashBuilder<llvm::TruncatedBLAKE3<8>, llvm::endianness::little> HashBuilder; for (auto &F : CallStack) @@ -763,9 +762,8 @@ static AllocationType addCallStack(CallStackTrie &AllocTrie, // non-zero. static bool stackFrameIncludesInlinedCallStack(ArrayRef<Frame> ProfileCallStack, - ArrayRef<uint64_t> InlinedCallStack, - unsigned StartIndex = 0) { - auto StackFrame = ProfileCallStack.begin() + StartIndex; + ArrayRef<uint64_t> InlinedCallStack) { + auto StackFrame = ProfileCallStack.begin(); auto InlCallStackIter = InlinedCallStack.begin(); for (; StackFrame != ProfileCallStack.end() && InlCallStackIter != InlinedCallStack.end(); @@ -969,9 +967,15 @@ readMemprof(Module &M, Function &F, IndexedInstrProfReader *MemProfReader, // Build maps of the location hash to all profile data with that leaf location // (allocation info and the callsites). std::map<uint64_t, std::set<const AllocationInfo *>> LocHashToAllocInfo; - // For the callsites we need to record the index of the associated frame in - // the frame array (see comments below where the map entries are added). - std::map<uint64_t, std::set<std::pair<const std::vector<Frame> *, unsigned>>> + // A hash function for std::unordered_set<ArrayRef<Frame>> to work. + struct CallStackHash { + size_t operator()(ArrayRef<Frame> CS) const { + return computeFullStackId(CS); + } + }; + // For the callsites we need to record slices of the frame array (see comments + // below where the map entries are added). + std::map<uint64_t, std::unordered_set<ArrayRef<Frame>, CallStackHash>> LocHashToCallSites; for (auto &AI : MemProfRec->AllocSites) { NumOfMemProfAllocContextProfiles++; @@ -989,7 +993,7 @@ readMemprof(Module &M, Function &F, IndexedInstrProfReader *MemProfReader, unsigned Idx = 0; for (auto &StackFrame : CS) { uint64_t StackId = computeStackId(StackFrame); - LocHashToCallSites[StackId].insert(std::make_pair(&CS, Idx++)); + LocHashToCallSites[StackId].insert(ArrayRef<Frame>(CS).drop_front(Idx++)); ProfileHasColumns |= StackFrame.Column; // Once we find this function, we can stop recording. if (StackFrame.Function == FuncGUID) @@ -1029,8 +1033,7 @@ readMemprof(Module &M, Function &F, IndexedInstrProfReader *MemProfReader, // and another callsite). std::map<uint64_t, std::set<const AllocationInfo *>>::iterator AllocInfoIter; - std::map<uint64_t, std::set<std::pair<const std::vector<Frame> *, - unsigned>>>::iterator CallSitesIter; + decltype(LocHashToCallSites)::iterator CallSitesIter; for (const DILocation *DIL = I.getDebugLoc(); DIL != nullptr; DIL = DIL->getInlinedAt()) { // Use C++ linkage name if possible. Need to compile with @@ -1121,8 +1124,8 @@ readMemprof(Module &M, Function &F, IndexedInstrProfReader *MemProfReader, for (auto CallStackIdx : CallSitesIter->second) { // If we found and thus matched all frames on the call, create and // attach call stack metadata. - if (stackFrameIncludesInlinedCallStack( - *CallStackIdx.first, InlinedCallStack, CallStackIdx.second)) { + if (stackFrameIncludesInlinedCallStack(CallStackIdx, + InlinedCallStack)) { NumOfMemProfMatchedCallSites++; addCallsiteMetadata(I, InlinedCallStack, Ctx); // Only need to find one with a matching call stack and add a single diff --git a/llvm/lib/Transforms/Scalar/SROA.cpp b/llvm/lib/Transforms/Scalar/SROA.cpp index d80af26451ac..3e46f0d35ee0 100644 --- a/llvm/lib/Transforms/Scalar/SROA.cpp +++ b/llvm/lib/Transforms/Scalar/SROA.cpp @@ -43,6 +43,7 @@ #include "llvm/Analysis/GlobalsModRef.h" #include "llvm/Analysis/Loads.h" #include "llvm/Analysis/PtrUseVisitor.h" +#include "llvm/Analysis/ValueTracking.h" #include "llvm/Config/llvm-config.h" #include "llvm/IR/BasicBlock.h" #include "llvm/IR/Constant.h" @@ -83,6 +84,7 @@ #include "llvm/Transforms/Utils/BasicBlockUtils.h" #include "llvm/Transforms/Utils/Local.h" #include "llvm/Transforms/Utils/PromoteMemToReg.h" +#include "llvm/Transforms/Utils/SSAUpdater.h" #include <algorithm> #include <cassert> #include <cstddef> @@ -246,6 +248,7 @@ private: bool presplitLoadsAndStores(AllocaInst &AI, AllocaSlices &AS); AllocaInst *rewritePartition(AllocaInst &AI, AllocaSlices &AS, Partition &P); bool splitAlloca(AllocaInst &AI, AllocaSlices &AS); + bool propagateStoredValuesToLoads(AllocaInst &AI, AllocaSlices &AS); std::pair<bool /*Changed*/, bool /*CFGChanged*/> runOnAlloca(AllocaInst &AI); void clobberUse(Use &U); bool deleteDeadInstructions(SmallPtrSetImpl<AllocaInst *> &DeletedAllocas); @@ -598,6 +601,7 @@ public: /// If this is true, the slices are never fully built and should be /// ignored. bool isEscaped() const { return PointerEscapingInstr; } + bool isEscapedReadOnly() const { return PointerEscapingInstrReadOnly; } /// Support for iterating over the slices. /// @{ @@ -680,6 +684,7 @@ private: /// store a pointer to that here and abort trying to form slices of the /// alloca. This will be null if the alloca slices are analyzed successfully. Instruction *PointerEscapingInstr; + Instruction *PointerEscapingInstrReadOnly; /// The slices of the alloca. /// @@ -1390,6 +1395,18 @@ private: /// Disable SROA entirely if there are unhandled users of the alloca. void visitInstruction(Instruction &I) { PI.setAborted(&I); } + + void visitCallBase(CallBase &CB) { + // If the call operand is NoCapture ReadOnly, then we mark it as + // EscapedReadOnly. + if (CB.doesNotCapture(U->getOperandNo()) && + CB.onlyReadsMemory(U->getOperandNo())) { + PI.setEscapedReadOnly(&CB); + return; + } + + Base::visitCallBase(CB); + } }; AllocaSlices::AllocaSlices(const DataLayout &DL, AllocaInst &AI) @@ -1397,7 +1414,7 @@ AllocaSlices::AllocaSlices(const DataLayout &DL, AllocaInst &AI) #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) AI(AI), #endif - PointerEscapingInstr(nullptr) { + PointerEscapingInstr(nullptr), PointerEscapingInstrReadOnly(nullptr) { SliceBuilder PB(DL, AI, *this); SliceBuilder::PtrInfo PtrI = PB.visitPtr(AI); if (PtrI.isEscaped() || PtrI.isAborted()) { @@ -1408,6 +1425,7 @@ AllocaSlices::AllocaSlices(const DataLayout &DL, AllocaInst &AI) assert(PointerEscapingInstr && "Did not track a bad instruction"); return; } + PointerEscapingInstrReadOnly = PtrI.getEscapedReadOnlyInst(); llvm::erase_if(Slices, [](const Slice &S) { return S.isDead(); }); @@ -1445,6 +1463,9 @@ void AllocaSlices::print(raw_ostream &OS) const { return; } + if (PointerEscapingInstrReadOnly) + OS << "Escapes into ReadOnly: " << *PointerEscapingInstrReadOnly << "\n"; + OS << "Slices of alloca: " << AI << "\n"; for (const_iterator I = begin(), E = end(); I != E; ++I) print(OS, I); @@ -5454,6 +5475,88 @@ void SROA::clobberUse(Use &U) { } } +/// A basic LoadAndStorePromoter that does not remove store nodes. +class BasicLoadAndStorePromoter : public LoadAndStorePromoter { +public: + BasicLoadAndStorePromoter(ArrayRef<const Instruction *> Insts, SSAUpdater &S, + Type *ZeroType) + : LoadAndStorePromoter(Insts, S), ZeroType(ZeroType) {} + bool shouldDelete(Instruction *I) const override { + return !isa<StoreInst>(I) && !isa<AllocaInst>(I); + } + + Value *getValueToUseForAlloca(Instruction *I) const override { + return UndefValue::get(ZeroType); + } + +private: + Type *ZeroType; +}; + +bool SROA::propagateStoredValuesToLoads(AllocaInst &AI, AllocaSlices &AS) { + // Look through each "partition", looking for slices with the same start/end + // that do not overlap with any before them. The slices are sorted by + // increasing beginOffset. We don't use AS.partitions(), as it will use a more + // sophisticated algorithm that takes splittable slices into account. + auto PartitionBegin = AS.begin(); + auto PartitionEnd = PartitionBegin; + uint64_t BeginOffset = PartitionBegin->beginOffset(); + uint64_t EndOffset = PartitionBegin->endOffset(); + while (PartitionBegin != AS.end()) { + bool AllSameAndValid = true; + SmallVector<Instruction *> Insts; + Type *PartitionType = nullptr; + while (PartitionEnd != AS.end() && + (PartitionEnd->beginOffset() < EndOffset || + PartitionEnd->endOffset() <= EndOffset)) { + if (AllSameAndValid) { + AllSameAndValid &= PartitionEnd->beginOffset() == BeginOffset && + PartitionEnd->endOffset() == EndOffset; + Instruction *User = + cast<Instruction>(PartitionEnd->getUse()->getUser()); + if (auto *LI = dyn_cast<LoadInst>(User)) { + Type *UserTy = LI->getType(); + // LoadAndStorePromoter requires all the types to be the same. + if (!LI->isSimple() || (PartitionType && UserTy != PartitionType)) + AllSameAndValid = false; + PartitionType = UserTy; + Insts.push_back(User); + } else if (auto *SI = dyn_cast<StoreInst>(User)) { + Type *UserTy = SI->getValueOperand()->getType(); + if (!SI->isSimple() || (PartitionType && UserTy != PartitionType)) + AllSameAndValid = false; + PartitionType = UserTy; + Insts.push_back(User); + } else if (!isAssumeLikeIntrinsic(User)) { + AllSameAndValid = false; + } + } + EndOffset = std::max(EndOffset, PartitionEnd->endOffset()); + ++PartitionEnd; + } + + // So long as all the slices start and end offsets matched, update loads to + // the values stored in the partition. + if (AllSameAndValid && !Insts.empty()) { + LLVM_DEBUG(dbgs() << "Propagate values on slice [" << BeginOffset << ", " + << EndOffset << ")\n"); + SmallVector<PHINode *, 4> NewPHIs; + SSAUpdater SSA(&NewPHIs); + Insts.push_back(&AI); + BasicLoadAndStorePromoter Promoter(Insts, SSA, PartitionType); + Promoter.run(Insts); + } + + // Step on to the next partition. + PartitionBegin = PartitionEnd; + if (PartitionBegin == AS.end()) + break; + BeginOffset = PartitionBegin->beginOffset(); + EndOffset = PartitionBegin->endOffset(); + } + return true; +} + /// Analyze an alloca for SROA. /// /// This analyzes the alloca to ensure we can reason about it, builds @@ -5494,6 +5597,11 @@ SROA::runOnAlloca(AllocaInst &AI) { if (AS.isEscaped()) return {Changed, CFGChanged}; + if (AS.isEscapedReadOnly()) { + Changed |= propagateStoredValuesToLoads(AI, AS); + return {Changed, CFGChanged}; + } + // Delete all the dead users of this alloca before splitting and rewriting it. for (Instruction *DeadUser : AS.getDeadUsers()) { // Free up everything used by this instruction. diff --git a/llvm/lib/Transforms/Utils/SSAUpdater.cpp b/llvm/lib/Transforms/Utils/SSAUpdater.cpp index 597d470f18ff..4bf4acd6330f 100644 --- a/llvm/lib/Transforms/Utils/SSAUpdater.cpp +++ b/llvm/lib/Transforms/Utils/SSAUpdater.cpp @@ -412,9 +412,13 @@ void LoadAndStorePromoter::run(const SmallVectorImpl<Instruction *> &Insts) { if (StoreInst *SI = dyn_cast<StoreInst>(User)) { updateDebugInfo(SI); SSA.AddAvailableValue(BB, SI->getOperand(0)); - } else + } else if (auto *AI = dyn_cast<AllocaInst>(User)) { + // We treat AllocaInst as a store of an getValueToUseForAlloca value. + SSA.AddAvailableValue(BB, getValueToUseForAlloca(AI)); + } else { // Otherwise it is a load, queue it to rewrite as a live-in load. LiveInLoads.push_back(cast<LoadInst>(User)); + } BlockUses.clear(); continue; } @@ -422,7 +426,7 @@ void LoadAndStorePromoter::run(const SmallVectorImpl<Instruction *> &Insts) { // Otherwise, check to see if this block is all loads. bool HasStore = false; for (Instruction *I : BlockUses) { - if (isa<StoreInst>(I)) { + if (isa<StoreInst>(I) || isa<AllocaInst>(I)) { HasStore = true; break; } @@ -468,6 +472,12 @@ void LoadAndStorePromoter::run(const SmallVectorImpl<Instruction *> &Insts) { // Remember that this is the active value in the block. StoredValue = SI->getOperand(0); + } else if (auto *AI = dyn_cast<AllocaInst>(&I)) { + // Check if this an alloca, in which case we treat it as a store of + // getValueToUseForAlloca. + if (!isInstInList(AI, Insts)) + continue; + StoredValue = getValueToUseForAlloca(AI); } } diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp index f7b9a676ae80..27b798d94601 100644 --- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp +++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp @@ -1060,6 +1060,9 @@ static void simplifyRecipe(VPRecipeBase &R, VPTypeAnalysis &TypeInfo) { if (match(&R, m_c_Mul(m_VPValue(A), m_SpecificInt(1)))) return R.getVPSingleValue()->replaceAllUsesWith(A); + + if (match(&R, m_Not(m_Not(m_VPValue(A))))) + return R.getVPSingleValue()->replaceAllUsesWith(A); } /// Move loop-invariant recipes out of the vector loop region in \p Plan. diff --git a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp index 09489e249845..9bbd6590d099 100644 --- a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp +++ b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp @@ -179,8 +179,8 @@ bool VectorCombine::vectorizeLoadInsert(Instruction &I) { // Match insert into fixed vector of scalar value. // TODO: Handle non-zero insert index. Value *Scalar; - if (!match(&I, m_InsertElt(m_Undef(), m_Value(Scalar), m_ZeroInt())) || - !Scalar->hasOneUse()) + if (!match(&I, + m_InsertElt(m_Poison(), m_OneUse(m_Value(Scalar)), m_ZeroInt()))) return false; // Optionally match an extract from another vector. diff --git a/llvm/test/CodeGen/AMDGPU/sgpr-regalloc-flags.ll b/llvm/test/CodeGen/AMDGPU/sgpr-regalloc-flags.ll index 33585024d81d..52ad7e535520 100644 --- a/llvm/test/CodeGen/AMDGPU/sgpr-regalloc-flags.ll +++ b/llvm/test/CodeGen/AMDGPU/sgpr-regalloc-flags.ll @@ -9,8 +9,8 @@ ; RUN: llc -verify-machineinstrs=0 -sgpr-regalloc=basic -mtriple=amdgcn-amd-amdhsa -debug-pass=Structure -o /dev/null %s 2>&1 | FileCheck -check-prefix=BASIC-DEFAULT %s ; RUN: llc -verify-machineinstrs=0 -sgpr-regalloc=basic -wwm-regalloc=basic -vgpr-regalloc=basic -mtriple=amdgcn-amd-amdhsa -debug-pass=Structure -o /dev/null %s 2>&1 | FileCheck -check-prefix=BASIC-BASIC %s -; RUN: not llc -verify-machineinstrs=0 -regalloc=basic -mtriple=amdgcn-amd-amdhsa -debug-pass=Structure -o /dev/null %s 2>&1 | FileCheck -check-prefix=REGALLOC %s -; RUN: not llc -verify-machineinstrs=0 -regalloc=fast -O0 -mtriple=amdgcn-amd-amdhsa -debug-pass=Structure -o /dev/null %s 2>&1 | FileCheck -check-prefix=REGALLOC %s +; RUN: not --crash llc -verify-machineinstrs=0 -regalloc=basic -mtriple=amdgcn-amd-amdhsa -debug-pass=Structure -o /dev/null %s 2>&1 | FileCheck -check-prefix=REGALLOC %s +; RUN: not --crash llc -verify-machineinstrs=0 -regalloc=fast -O0 -mtriple=amdgcn-amd-amdhsa -debug-pass=Structure -o /dev/null %s 2>&1 | FileCheck -check-prefix=REGALLOC %s ; REGALLOC: -regalloc not supported with amdgcn. Use -sgpr-regalloc, -wwm-regalloc, and -vgpr-regalloc diff --git a/llvm/test/CodeGen/Mips/2008-07-16-SignExtInReg.ll b/llvm/test/CodeGen/Mips/2008-07-16-SignExtInReg.ll index e4c1eba9a6ca..ae9d739e0219 100644 --- a/llvm/test/CodeGen/Mips/2008-07-16-SignExtInReg.ll +++ b/llvm/test/CodeGen/Mips/2008-07-16-SignExtInReg.ll @@ -1,6 +1,6 @@ ; RUN: llc < %s -mtriple=mips -mcpu=mips32r2 | FileCheck %s ; RUN: llc < %s -mtriple=mips64 -mcpu=mips64r2 | FileCheck %s -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mcpu=mips32r2 -mattr=+mips16 < %s | FileCheck %s +; RUN: llc -mtriple=mipsel-linux-gnu -mcpu=mips32r2 -mattr=+mips16 < %s | FileCheck %s define signext i8 @A(i8 %e.0, i8 signext %sum) nounwind { entry: diff --git a/llvm/test/CodeGen/Mips/beqzc.ll b/llvm/test/CodeGen/Mips/beqzc.ll index 11e009bcc79e..28f3f8c144b6 100644 --- a/llvm/test/CodeGen/Mips/beqzc.ll +++ b/llvm/test/CodeGen/Mips/beqzc.ll @@ -1,4 +1,4 @@ -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 -mattr=+soft-float -mips16-hard-float -relocation-model=pic -mips16-constant-islands < %s | FileCheck %s -check-prefix=cond-b-short +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 -mattr=+soft-float -mips16-hard-float -relocation-model=pic -mips16-constant-islands < %s | FileCheck %s -check-prefix=cond-b-short @i = global i32 0, align 4 @j = common global i32 0, align 4 diff --git a/llvm/test/CodeGen/Mips/beqzc1.ll b/llvm/test/CodeGen/Mips/beqzc1.ll index ad41ae271bb4..915f34e63ff2 100644 --- a/llvm/test/CodeGen/Mips/beqzc1.ll +++ b/llvm/test/CodeGen/Mips/beqzc1.ll @@ -1,4 +1,4 @@ -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 -mattr=+soft-float -mips16-hard-float -relocation-model=pic -mips16-constant-islands < %s | FileCheck %s -check-prefix=cond-b-short +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 -mattr=+soft-float -mips16-hard-float -relocation-model=pic -mips16-constant-islands < %s | FileCheck %s -check-prefix=cond-b-short @i = global i32 0, align 4 @j = common global i32 0, align 4 diff --git a/llvm/test/CodeGen/Mips/blockaddr.ll b/llvm/test/CodeGen/Mips/blockaddr.ll index b1ab9a171eb9..92184e7ed6bd 100644 --- a/llvm/test/CodeGen/Mips/blockaddr.ll +++ b/llvm/test/CodeGen/Mips/blockaddr.ll @@ -10,7 +10,7 @@ ; RUN: -relocation-model=pic < %s | FileCheck %s -check-prefix=PIC-N64 ; RUN: llc -mtriple=mips64el -mcpu=mips64r2 -target-abi n64 \ ; RUN: -relocation-model=static < %s | FileCheck %s -check-prefix=STATIC-N64 -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mcpu=mips32 -mattr=+mips16 \ +; RUN: llc -mtriple=mipsel-linux-gnu -mcpu=mips32 -mattr=+mips16 \ ; RUN: -relocation-model=static < %s | FileCheck %s -check-prefix=STATIC-MIPS16 @reg = common global ptr null, align 4 diff --git a/llvm/test/CodeGen/Mips/brsize3.ll b/llvm/test/CodeGen/Mips/brsize3.ll index a93de3269510..1aea201af96b 100644 --- a/llvm/test/CodeGen/Mips/brsize3.ll +++ b/llvm/test/CodeGen/Mips/brsize3.ll @@ -1,9 +1,9 @@ -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 \ +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 \ ; RUN: -mattr=+soft-float -mips16-hard-float -relocation-model=pic \ ; RUN: -mips16-constant-islands -verify-machineinstrs < %s | \ ; RUN: FileCheck %s -check-prefix=b-no-short -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 \ +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 \ ; RUN: -mattr=+soft-float -mips16-hard-float -relocation-model=pic \ ; RUN: -mips16-constant-islands -verify-machineinstrs < %s | \ ; RUN: FileCheck %s -check-prefix=b-long diff --git a/llvm/test/CodeGen/Mips/brsize3a.ll b/llvm/test/CodeGen/Mips/brsize3a.ll index 87f96203047e..de866f210e7b 100644 --- a/llvm/test/CodeGen/Mips/brsize3a.ll +++ b/llvm/test/CodeGen/Mips/brsize3a.ll @@ -1,4 +1,4 @@ -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 -mattr=+soft-float -mips16-hard-float -relocation-model=pic -mips16-constant-islands < %s | FileCheck %s -check-prefix=b-short +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 -mattr=+soft-float -mips16-hard-float -relocation-model=pic -mips16-constant-islands < %s | FileCheck %s -check-prefix=b-short ; ModuleID = 'brsize3.c' target datalayout = "E-p:32:32:32-i1:8:8-i8:8:32-i16:16:32-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-n32-S64" diff --git a/llvm/test/CodeGen/Mips/ci2.ll b/llvm/test/CodeGen/Mips/ci2.ll index 9546656ebf25..a9497296c8e4 100644 --- a/llvm/test/CodeGen/Mips/ci2.ll +++ b/llvm/test/CodeGen/Mips/ci2.ll @@ -1,4 +1,4 @@ -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 -mattr=+soft-float -mips16-hard-float -relocation-model=static -mips16-constant-islands < %s | FileCheck %s -check-prefix=constisle +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 -mattr=+soft-float -mips16-hard-float -relocation-model=static -mips16-constant-islands < %s | FileCheck %s -check-prefix=constisle @i = common global i32 0, align 4 @b = common global i32 0, align 4 diff --git a/llvm/test/CodeGen/Mips/const1.ll b/llvm/test/CodeGen/Mips/const1.ll index 429107cfdbcd..750912d94f90 100644 --- a/llvm/test/CodeGen/Mips/const1.ll +++ b/llvm/test/CodeGen/Mips/const1.ll @@ -1,4 +1,4 @@ -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 -mattr=+soft-float -mips16-hard-float -relocation-model=static -mips16-constant-islands < %s | FileCheck %s +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 -mattr=+soft-float -mips16-hard-float -relocation-model=static -mips16-constant-islands < %s | FileCheck %s ; ModuleID = 'const1.c' target datalayout = "e-p:32:32:32-i1:8:8-i8:8:32-i16:16:32-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-n32-S64" diff --git a/llvm/test/CodeGen/Mips/const4a.ll b/llvm/test/CodeGen/Mips/const4a.ll index 757629de5da3..245abbfe196c 100644 --- a/llvm/test/CodeGen/Mips/const4a.ll +++ b/llvm/test/CodeGen/Mips/const4a.ll @@ -1,4 +1,4 @@ -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 -mattr=+soft-float -mips16-hard-float -relocation-model=pic -mips16-constant-islands -mips-constant-islands-no-load-relaxation < %s | FileCheck %s -check-prefix=no-load-relax +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 -mattr=+soft-float -mips16-hard-float -relocation-model=pic -mips16-constant-islands -mips-constant-islands-no-load-relaxation < %s | FileCheck %s -check-prefix=no-load-relax ; ModuleID = 'const4.c' target datalayout = "E-p:32:32:32-i1:8:8-i8:8:32-i16:16:32-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-n32-S64" diff --git a/llvm/test/CodeGen/Mips/const6.ll b/llvm/test/CodeGen/Mips/const6.ll index 27e8eace4b16..f40eeef3ccb6 100644 --- a/llvm/test/CodeGen/Mips/const6.ll +++ b/llvm/test/CodeGen/Mips/const6.ll @@ -1,6 +1,6 @@ -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 -mattr=+soft-float -mips16-hard-float -relocation-model=pic -mips16-constant-islands < %s | FileCheck %s -check-prefix=load-relax +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 -mattr=+soft-float -mips16-hard-float -relocation-model=pic -mips16-constant-islands < %s | FileCheck %s -check-prefix=load-relax -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 -mattr=+soft-float -mips16-hard-float -relocation-model=pic -mips16-constant-islands -mips-constant-islands-no-load-relaxation < %s | FileCheck %s -check-prefix=no-load-relax +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 -mattr=+soft-float -mips16-hard-float -relocation-model=pic -mips16-constant-islands -mips-constant-islands-no-load-relaxation < %s | FileCheck %s -check-prefix=no-load-relax ; ModuleID = 'const6.c' target datalayout = "E-p:32:32:32-i1:8:8-i8:8:32-i16:16:32-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-n32-S64" diff --git a/llvm/test/CodeGen/Mips/const6a.ll b/llvm/test/CodeGen/Mips/const6a.ll index 5a3f4a1f951e..720edd3a662b 100644 --- a/llvm/test/CodeGen/Mips/const6a.ll +++ b/llvm/test/CodeGen/Mips/const6a.ll @@ -1,6 +1,6 @@ -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 -mattr=+soft-float -mips16-hard-float -relocation-model=pic -mips16-constant-islands < %s | FileCheck %s -check-prefix=load-relax1 +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 -mattr=+soft-float -mips16-hard-float -relocation-model=pic -mips16-constant-islands < %s | FileCheck %s -check-prefix=load-relax1 -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 -mattr=+soft-float -mips16-hard-float -relocation-model=pic -mips16-constant-islands < %s | FileCheck %s -check-prefix=load-relax +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 -mattr=+soft-float -mips16-hard-float -relocation-model=pic -mips16-constant-islands < %s | FileCheck %s -check-prefix=load-relax ; ModuleID = 'const6a.c' target datalayout = "E-p:32:32:32-i1:8:8-i8:8:32-i16:16:32-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-n32-S64" diff --git a/llvm/test/CodeGen/Mips/ctlz.ll b/llvm/test/CodeGen/Mips/ctlz.ll index efb23f55c2cf..3cc156943f22 100644 --- a/llvm/test/CodeGen/Mips/ctlz.ll +++ b/llvm/test/CodeGen/Mips/ctlz.ll @@ -1,4 +1,4 @@ -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mcpu=mips32 -mattr=+mips16 -relocation-model=static < %s | FileCheck %s -check-prefix=static +; RUN: llc -mtriple=mipsel-linux-gnu -mcpu=mips32 -mattr=+mips16 -relocation-model=static < %s | FileCheck %s -check-prefix=static @x = global i32 28912, align 4 @y = common global i32 0, align 4 diff --git a/llvm/test/CodeGen/Mips/f16abs.ll b/llvm/test/CodeGen/Mips/f16abs.ll index 30ff458f5a46..23bf402bb6dc 100644 --- a/llvm/test/CodeGen/Mips/f16abs.ll +++ b/llvm/test/CodeGen/Mips/f16abs.ll @@ -1,4 +1,4 @@ -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 -relocation-model=static < %s | FileCheck %s -check-prefix=static +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 -relocation-model=static < %s | FileCheck %s -check-prefix=static @y = global double -1.450000e+00, align 8 @x = common global double 0.000000e+00, align 8 diff --git a/llvm/test/CodeGen/Mips/fixdfsf.ll b/llvm/test/CodeGen/Mips/fixdfsf.ll index 07b57f9f9482..e15efe75a60b 100644 --- a/llvm/test/CodeGen/Mips/fixdfsf.ll +++ b/llvm/test/CodeGen/Mips/fixdfsf.ll @@ -1,5 +1,5 @@ -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 -relocation-model=pic < %s | FileCheck %s -check-prefix=pic1 -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 -relocation-model=pic < %s | FileCheck %s -check-prefix=pic2 +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 -relocation-model=pic < %s | FileCheck %s -check-prefix=pic1 +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 -relocation-model=pic < %s | FileCheck %s -check-prefix=pic2 @x = common global double 0.000000e+00, align 8 @y = common global i32 0, align 4 diff --git a/llvm/test/CodeGen/Mips/fp16instrinsmc.ll b/llvm/test/CodeGen/Mips/fp16instrinsmc.ll index 168b042f4d4a..6c29c0872051 100644 --- a/llvm/test/CodeGen/Mips/fp16instrinsmc.ll +++ b/llvm/test/CodeGen/Mips/fp16instrinsmc.ll @@ -1,5 +1,5 @@ -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 -relocation-model=pic < %s | FileCheck %s -check-prefix=pic -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 -relocation-model=static -mips32-function-mask=1010111 -mips-os16 < %s | FileCheck %s -check-prefix=fmask +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 -relocation-model=pic < %s | FileCheck %s -check-prefix=pic +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 -relocation-model=static -mips32-function-mask=1010111 -mips-os16 < %s | FileCheck %s -check-prefix=fmask @x = global float 1.500000e+00, align 4 @xn = global float -1.900000e+01, align 4 diff --git a/llvm/test/CodeGen/Mips/fp16mix.ll b/llvm/test/CodeGen/Mips/fp16mix.ll index d97759422cf9..07fc6a67f11d 100644 --- a/llvm/test/CodeGen/Mips/fp16mix.ll +++ b/llvm/test/CodeGen/Mips/fp16mix.ll @@ -1,8 +1,8 @@ -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 -relocation-model=static -mips32-function-mask=10 -mips-os16 < %s | FileCheck %s -check-prefix=fmask1 +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 -relocation-model=static -mips32-function-mask=10 -mips-os16 < %s | FileCheck %s -check-prefix=fmask1 -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 -relocation-model=static -mips32-function-mask=01 -mips-os16 < %s | FileCheck %s -check-prefix=fmask2 +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 -relocation-model=static -mips32-function-mask=01 -mips-os16 < %s | FileCheck %s -check-prefix=fmask2 -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 -relocation-model=static -mips32-function-mask=10. -mips-os16 < %s | FileCheck %s -check-prefix=fmask1nr +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 -relocation-model=static -mips32-function-mask=10. -mips-os16 < %s | FileCheck %s -check-prefix=fmask1nr ; Function Attrs: nounwind optsize readnone define void @foo1() { diff --git a/llvm/test/CodeGen/Mips/fpnotneeded.ll b/llvm/test/CodeGen/Mips/fpnotneeded.ll index d21bd53e949d..761ef3032fc4 100644 --- a/llvm/test/CodeGen/Mips/fpnotneeded.ll +++ b/llvm/test/CodeGen/Mips/fpnotneeded.ll @@ -1,6 +1,6 @@ -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mcpu=mips32 -relocation-model=static -O3 < %s -mips-os16 | FileCheck %s -check-prefix=32 +; RUN: llc -mtriple=mipsel-linux-gnu -mcpu=mips32 -relocation-model=static -O3 < %s -mips-os16 | FileCheck %s -check-prefix=32 -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mcpu=mips32 -relocation-model=static -O3 -mips16-constant-islands < %s -mips-os16 | FileCheck %s -check-prefix=cisle +; RUN: llc -mtriple=mipsel-linux-gnu -mcpu=mips32 -relocation-model=static -O3 -mips16-constant-islands < %s -mips-os16 | FileCheck %s -check-prefix=cisle @i = global i32 1, align 4 @f = global float 1.000000e+00, align 4 diff --git a/llvm/test/CodeGen/Mips/funnel-shift-rot.ll b/llvm/test/CodeGen/Mips/funnel-shift-rot.ll index ee187678949e..1fc2f5d309b5 100644 --- a/llvm/test/CodeGen/Mips/funnel-shift-rot.ll +++ b/llvm/test/CodeGen/Mips/funnel-shift-rot.ll @@ -1,6 +1,6 @@ ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py -; RUN: llc < %s -mtriple=mips-linux-gnu -march=mips -mcpu=mips32 | FileCheck %s --check-prefixes=CHECK,CHECK-BE -; RUN: llc < %s -mtriple=mipsel-linux-gnu -march=mipsel -mcpu=mips32 | FileCheck %s --check-prefixes=CHECK,CHECK-LE +; RUN: llc < %s -mtriple=mips-linux-gnu -mcpu=mips32 | FileCheck %s --check-prefixes=CHECK,CHECK-BE +; RUN: llc < %s -mtriple=mipsel-linux-gnu -mcpu=mips32 | FileCheck %s --check-prefixes=CHECK,CHECK-LE declare i8 @llvm.fshl.i8(i8, i8, i8) declare i16 @llvm.fshl.i16(i16, i16, i16) diff --git a/llvm/test/CodeGen/Mips/funnel-shift.ll b/llvm/test/CodeGen/Mips/funnel-shift.ll index bda2b477b52f..99e0d47441a0 100644 --- a/llvm/test/CodeGen/Mips/funnel-shift.ll +++ b/llvm/test/CodeGen/Mips/funnel-shift.ll @@ -1,6 +1,6 @@ ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py -; RUN: llc < %s -mtriple=mips-linux-gnu -march=mips -mcpu=mips32 | FileCheck %s --check-prefixes=CHECK,CHECK-BE -; RUN: llc < %s -mtriple=mipsel-linux-gnu -march=mipsel -mcpu=mips32 | FileCheck %s --check-prefixes=CHECK,CHECK-LE +; RUN: llc < %s -mtriple=mips-linux-gnu -mcpu=mips32 | FileCheck %s --check-prefixes=CHECK,CHECK-BE +; RUN: llc < %s -mtriple=mipsel-linux-gnu -mcpu=mips32 | FileCheck %s --check-prefixes=CHECK,CHECK-LE declare i8 @llvm.fshl.i8(i8, i8, i8) declare i16 @llvm.fshl.i16(i16, i16, i16) diff --git a/llvm/test/CodeGen/Mips/helloworld.ll b/llvm/test/CodeGen/Mips/helloworld.ll index 152f8533fc36..ba010aafef1c 100644 --- a/llvm/test/CodeGen/Mips/helloworld.ll +++ b/llvm/test/CodeGen/Mips/helloworld.ll @@ -1,11 +1,11 @@ -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 -relocation-model=pic -O3 < %s | FileCheck %s -check-prefix=C1 -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 -relocation-model=pic -O3 < %s | FileCheck %s -check-prefix=C2 -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 -relocation-model=pic -O3 < %s | FileCheck %s -check-prefix=PE -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 -relocation-model=static -O3 < %s | FileCheck %s -check-prefix=ST1 -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 -relocation-model=static -O3 < %s | FileCheck %s -check-prefix=ST2 +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 -relocation-model=pic -O3 < %s | FileCheck %s -check-prefix=C1 +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 -relocation-model=pic -O3 < %s | FileCheck %s -check-prefix=C2 +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 -relocation-model=pic -O3 < %s | FileCheck %s -check-prefix=PE +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 -relocation-model=static -O3 < %s | FileCheck %s -check-prefix=ST1 +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 -relocation-model=static -O3 < %s | FileCheck %s -check-prefix=ST2 ; -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 -relocation-model=pic -O3 < %s | FileCheck %s -check-prefix=SR -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mcpu=mips32 -relocation-model=pic -O3 < %s | FileCheck %s -check-prefix=SR32 +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 -relocation-model=pic -O3 < %s | FileCheck %s -check-prefix=SR +; RUN: llc -mtriple=mipsel-linux-gnu -mcpu=mips32 -relocation-model=pic -O3 < %s | FileCheck %s -check-prefix=SR32 @.str = private unnamed_addr constant [13 x i8] c"hello world\0A\00", align 1 diff --git a/llvm/test/CodeGen/Mips/hf16call32.ll b/llvm/test/CodeGen/Mips/hf16call32.ll index 881ad12d65a2..e187b76744b8 100644 --- a/llvm/test/CodeGen/Mips/hf16call32.ll +++ b/llvm/test/CodeGen/Mips/hf16call32.ll @@ -1,4 +1,4 @@ -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 -relocation-model=static < %s | FileCheck %s -check-prefix=stel +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 -relocation-model=static < %s | FileCheck %s -check-prefix=stel @x = common global float 0.000000e+00, align 4 @y = common global float 0.000000e+00, align 4 diff --git a/llvm/test/CodeGen/Mips/hf16call32_body.ll b/llvm/test/CodeGen/Mips/hf16call32_body.ll index 88cc02a9f795..ea83f776bd40 100644 --- a/llvm/test/CodeGen/Mips/hf16call32_body.ll +++ b/llvm/test/CodeGen/Mips/hf16call32_body.ll @@ -1,4 +1,4 @@ -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 -relocation-model=static < %s | FileCheck %s -check-prefix=stel +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 -relocation-model=static < %s | FileCheck %s -check-prefix=stel @x = external global float @xd = external global double diff --git a/llvm/test/CodeGen/Mips/hf1_body.ll b/llvm/test/CodeGen/Mips/hf1_body.ll index c3dea6789621..ec452e02757d 100644 --- a/llvm/test/CodeGen/Mips/hf1_body.ll +++ b/llvm/test/CodeGen/Mips/hf1_body.ll @@ -1,9 +1,9 @@ -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 \ +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 \ ; RUN: -relocation-model=pic -no-integrated-as < %s | \ ; RUN: FileCheck %s -check-prefixes=ALL,GAS ; The integrated assembler expands assembly macros before printing. -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 \ +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 \ ; RUN: -relocation-model=pic < %s | \ ; RUN: FileCheck %s -check-prefixes=ALL,IAS diff --git a/llvm/test/CodeGen/Mips/hfptrcall.ll b/llvm/test/CodeGen/Mips/hfptrcall.ll index b4749058ba76..920c6945c25c 100644 --- a/llvm/test/CodeGen/Mips/hfptrcall.ll +++ b/llvm/test/CodeGen/Mips/hfptrcall.ll @@ -1,4 +1,4 @@ -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 -relocation-model=pic < %s | FileCheck %s -check-prefix=picel +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 -relocation-model=pic < %s | FileCheck %s -check-prefix=picel @ptrsv = global ptr @sv, align 4 @ptrdv = global ptr @dv, align 4 diff --git a/llvm/test/CodeGen/Mips/i32k.ll b/llvm/test/CodeGen/Mips/i32k.ll index 130a467433fc..681bdeebc06d 100644 --- a/llvm/test/CodeGen/Mips/i32k.ll +++ b/llvm/test/CodeGen/Mips/i32k.ll @@ -1,4 +1,4 @@ -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 -relocation-model=pic -mips16-constant-islands=false -O3 < %s | FileCheck %s -check-prefix=16 +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 -relocation-model=pic -mips16-constant-islands=false -O3 < %s | FileCheck %s -check-prefix=16 @.str = private unnamed_addr constant [4 x i8] c"%i\0A\00", align 1 diff --git a/llvm/test/CodeGen/Mips/l3mc.ll b/llvm/test/CodeGen/Mips/l3mc.ll index b45208256628..440da3abb53f 100644 --- a/llvm/test/CodeGen/Mips/l3mc.ll +++ b/llvm/test/CodeGen/Mips/l3mc.ll @@ -1,22 +1,22 @@ -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 -mattr=+soft-float -mips16-hard-float -relocation-model=static < %s | FileCheck %s -check-prefix=__call_stub_fp___fixunsdfsi +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 -mattr=+soft-float -mips16-hard-float -relocation-model=static < %s | FileCheck %s -check-prefix=__call_stub_fp___fixunsdfsi -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 -mattr=+soft-float -mips16-hard-float -relocation-model=static < %s | FileCheck %s -check-prefix=__call_stub_fp___floatdidf +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 -mattr=+soft-float -mips16-hard-float -relocation-model=static < %s | FileCheck %s -check-prefix=__call_stub_fp___floatdidf -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 -mattr=+soft-float -mips16-hard-float -relocation-model=static < %s | FileCheck %s -check-prefix=__call_stub_fp___floatdisf +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 -mattr=+soft-float -mips16-hard-float -relocation-model=static < %s | FileCheck %s -check-prefix=__call_stub_fp___floatdisf -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 -mattr=+soft-float -mips16-hard-float -relocation-model=static < %s | FileCheck %s -check-prefix=__call_stub_fp___floatundidf +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 -mattr=+soft-float -mips16-hard-float -relocation-model=static < %s | FileCheck %s -check-prefix=__call_stub_fp___floatundidf -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 -mattr=+soft-float -mips16-hard-float -relocation-model=static < %s | FileCheck %s -check-prefix=__call_stub_fp___fixsfdi +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 -mattr=+soft-float -mips16-hard-float -relocation-model=static < %s | FileCheck %s -check-prefix=__call_stub_fp___fixsfdi -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 -mattr=+soft-float -mips16-hard-float -relocation-model=static < %s | FileCheck %s -check-prefix=__call_stub_fp___fixunsdfdi +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 -mattr=+soft-float -mips16-hard-float -relocation-model=static < %s | FileCheck %s -check-prefix=__call_stub_fp___fixunsdfdi -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 -mattr=+soft-float -mips16-hard-float -relocation-model=static < %s | FileCheck %s -check-prefix=__call_stub_fp___fixdfdi +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 -mattr=+soft-float -mips16-hard-float -relocation-model=static < %s | FileCheck %s -check-prefix=__call_stub_fp___fixdfdi -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 -mattr=+soft-float -mips16-hard-float -relocation-model=static < %s | FileCheck %s -check-prefix=__call_stub_fp___fixunssfsi +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 -mattr=+soft-float -mips16-hard-float -relocation-model=static < %s | FileCheck %s -check-prefix=__call_stub_fp___fixunssfsi -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 -mattr=+soft-float -mips16-hard-float -relocation-model=static < %s | FileCheck %s -check-prefix=__call_stub_fp___fixunssfdi +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 -mattr=+soft-float -mips16-hard-float -relocation-model=static < %s | FileCheck %s -check-prefix=__call_stub_fp___fixunssfdi -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 -mattr=+soft-float -mips16-hard-float -relocation-model=static < %s | FileCheck %s -check-prefix=__call_stub_fp___floatundisf +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 -mattr=+soft-float -mips16-hard-float -relocation-model=static < %s | FileCheck %s -check-prefix=__call_stub_fp___floatundisf @ll1 = global i64 0, align 8 @ll2 = global i64 0, align 8 diff --git a/llvm/test/CodeGen/Mips/lcb2.ll b/llvm/test/CodeGen/Mips/lcb2.ll index 7f9e71d5efec..036de382b621 100644 --- a/llvm/test/CodeGen/Mips/lcb2.ll +++ b/llvm/test/CodeGen/Mips/lcb2.ll @@ -1,6 +1,6 @@ -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 -mattr=+soft-float -mips16-hard-float -relocation-model=static -mips16-constant-islands=true < %s | FileCheck %s -check-prefix=lcb +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 -mattr=+soft-float -mips16-hard-float -relocation-model=static -mips16-constant-islands=true < %s | FileCheck %s -check-prefix=lcb -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 -mattr=+soft-float -mips16-hard-float -relocation-model=static -mips16-constant-islands=true < %s | FileCheck %s -check-prefix=lcbn +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 -mattr=+soft-float -mips16-hard-float -relocation-model=static -mips16-constant-islands=true < %s | FileCheck %s -check-prefix=lcbn @i = global i32 0, align 4 @j = common global i32 0, align 4 diff --git a/llvm/test/CodeGen/Mips/lcb3c.ll b/llvm/test/CodeGen/Mips/lcb3c.ll index 386059f144dd..40912f3701f3 100644 --- a/llvm/test/CodeGen/Mips/lcb3c.ll +++ b/llvm/test/CodeGen/Mips/lcb3c.ll @@ -1,4 +1,4 @@ -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 -mattr=+soft-float -mips16-hard-float -relocation-model=static -O0 < %s | FileCheck %s -check-prefix=lcb +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 -mattr=+soft-float -mips16-hard-float -relocation-model=static -O0 < %s | FileCheck %s -check-prefix=lcb @i = global i32 0, align 4 @j = common global i32 0, align 4 diff --git a/llvm/test/CodeGen/Mips/lcb4a.ll b/llvm/test/CodeGen/Mips/lcb4a.ll index 87089a779558..a0258b15e84a 100644 --- a/llvm/test/CodeGen/Mips/lcb4a.ll +++ b/llvm/test/CodeGen/Mips/lcb4a.ll @@ -1,4 +1,4 @@ -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 -mattr=+soft-float -mips16-hard-float -relocation-model=static < %s | FileCheck %s -check-prefix=ci +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 -mattr=+soft-float -mips16-hard-float -relocation-model=static < %s | FileCheck %s -check-prefix=ci @i = global i32 0, align 4 @j = common global i32 0, align 4 diff --git a/llvm/test/CodeGen/Mips/lcb5.ll b/llvm/test/CodeGen/Mips/lcb5.ll index bb059f1ee845..22baebac3e93 100644 --- a/llvm/test/CodeGen/Mips/lcb5.ll +++ b/llvm/test/CodeGen/Mips/lcb5.ll @@ -1,4 +1,4 @@ -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 -mattr=+soft-float -mips16-hard-float -relocation-model=static < %s | FileCheck %s -check-prefix=ci +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 -mattr=+soft-float -mips16-hard-float -relocation-model=static < %s | FileCheck %s -check-prefix=ci @i = global i32 0, align 4 @j = common global i32 0, align 4 diff --git a/llvm/test/CodeGen/Mips/mbrsize4a.ll b/llvm/test/CodeGen/Mips/mbrsize4a.ll index 7a08d169527d..b8d2e2db8098 100644 --- a/llvm/test/CodeGen/Mips/mbrsize4a.ll +++ b/llvm/test/CodeGen/Mips/mbrsize4a.ll @@ -1,4 +1,4 @@ -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 -mattr=+soft-float -mips16-hard-float -relocation-model=static -mips16-constant-islands < %s | FileCheck %s -check-prefix=jal16 +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 -mattr=+soft-float -mips16-hard-float -relocation-model=static -mips16-constant-islands < %s | FileCheck %s -check-prefix=jal16 @j = global i32 10, align 4 @.str = private unnamed_addr constant [11 x i8] c"at bottom\0A\00", align 1 diff --git a/llvm/test/CodeGen/Mips/mips16-hf-attr-2.ll b/llvm/test/CodeGen/Mips/mips16-hf-attr-2.ll index 46cba348ceb7..80294b5cd958 100644 --- a/llvm/test/CodeGen/Mips/mips16-hf-attr-2.ll +++ b/llvm/test/CodeGen/Mips/mips16-hf-attr-2.ll @@ -1,6 +1,6 @@ ; Check that stubs generation for mips16 hard-float mode does not depend ; on the function 'use-soft-float' attribute's value. -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel \ +; RUN: llc -mtriple=mipsel-linux-gnu \ ; RUN: -mattr=mips16 -relocation-model=pic < %s | FileCheck %s define void @bar_sf() #1 { diff --git a/llvm/test/CodeGen/Mips/mips16-hf-attr.ll b/llvm/test/CodeGen/Mips/mips16-hf-attr.ll index dabe61842d5d..c8af7127b00e 100644 --- a/llvm/test/CodeGen/Mips/mips16-hf-attr.ll +++ b/llvm/test/CodeGen/Mips/mips16-hf-attr.ll @@ -1,6 +1,6 @@ ; Check that stubs generation for mips16 hard-float mode does not depend ; on the function 'use-soft-float' attribute's value. -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel \ +; RUN: llc -mtriple=mipsel-linux-gnu \ ; RUN: -mattr=mips16 -relocation-model=pic < %s | FileCheck %s define void @bar_hf() #0 { diff --git a/llvm/test/CodeGen/Mips/mips16_fpret.ll b/llvm/test/CodeGen/Mips/mips16_fpret.ll index 2f68a8b96039..19f90fdff134 100644 --- a/llvm/test/CodeGen/Mips/mips16_fpret.ll +++ b/llvm/test/CodeGen/Mips/mips16_fpret.ll @@ -1,7 +1,7 @@ -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 -relocation-model=static < %s | FileCheck %s -check-prefix=1 -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 -relocation-model=static < %s | FileCheck %s -check-prefix=2 -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 -relocation-model=static < %s | FileCheck %s -check-prefix=3 -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 -relocation-model=static < %s | FileCheck %s -check-prefix=4 +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 -relocation-model=static < %s | FileCheck %s -check-prefix=1 +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 -relocation-model=static < %s | FileCheck %s -check-prefix=2 +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 -relocation-model=static < %s | FileCheck %s -check-prefix=3 +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 -relocation-model=static < %s | FileCheck %s -check-prefix=4 @x = global float 0x41F487E980000000, align 4 diff --git a/llvm/test/CodeGen/Mips/nomips16.ll b/llvm/test/CodeGen/Mips/nomips16.ll index d05f37e39bf4..62564f9f890d 100644 --- a/llvm/test/CodeGen/Mips/nomips16.ll +++ b/llvm/test/CodeGen/Mips/nomips16.ll @@ -1,4 +1,4 @@ -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 -relocation-model=static < %s | FileCheck %s +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 -relocation-model=static < %s | FileCheck %s @x = global float 0.000000e+00, align 4 @.str = private unnamed_addr constant [20 x i8] c"in main: mips16 %f\0A\00", align 1 diff --git a/llvm/test/CodeGen/Mips/powif64_16.ll b/llvm/test/CodeGen/Mips/powif64_16.ll index 465f71f3d6af..3443b6225a38 100644 --- a/llvm/test/CodeGen/Mips/powif64_16.ll +++ b/llvm/test/CodeGen/Mips/powif64_16.ll @@ -1,4 +1,4 @@ -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 -relocation-model=static < %s | FileCheck %s +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 -relocation-model=static < %s | FileCheck %s declare float @llvm.powi.f32.i32(float %Val, i32 %power) declare double @llvm.powi.f64.i32(double %Val, i32 %power) diff --git a/llvm/test/CodeGen/Mips/rotate.ll b/llvm/test/CodeGen/Mips/rotate.ll index 9063cc163891..6fe6639285ca 100644 --- a/llvm/test/CodeGen/Mips/rotate.ll +++ b/llvm/test/CodeGen/Mips/rotate.ll @@ -1,5 +1,5 @@ ; RUN: llc -mtriple=mips -mcpu=mips32r2 < %s | FileCheck %s -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mcpu=mips32r2 -mattr=+mips16 < %s | FileCheck %s -check-prefix=mips16 +; RUN: llc -mtriple=mipsel-linux-gnu -mcpu=mips32r2 -mattr=+mips16 < %s | FileCheck %s -check-prefix=mips16 ; RUN: llc -mtriple=mips -mcpu=mips32r3 -mattr=+micromips < %s | FileCheck %s \ ; RUN: -check-prefix=MM32 ; RUN: llc -mtriple=mips -mcpu=mips32r6 -mattr=+micromips < %s | FileCheck %s \ diff --git a/llvm/test/CodeGen/Mips/s2rem.ll b/llvm/test/CodeGen/Mips/s2rem.ll index 92bb5ce51f31..fdf06cedc774 100644 --- a/llvm/test/CodeGen/Mips/s2rem.ll +++ b/llvm/test/CodeGen/Mips/s2rem.ll @@ -1,6 +1,6 @@ -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 -relocation-model=pic < %s | FileCheck %s -check-prefix=PIC +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 -relocation-model=pic < %s | FileCheck %s -check-prefix=PIC -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 -relocation-model=static < %s | FileCheck %s -check-prefix=STATIC +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 -relocation-model=static < %s | FileCheck %s -check-prefix=STATIC @xi = common global i32 0, align 4 diff --git a/llvm/test/CodeGen/Mips/sel1c.ll b/llvm/test/CodeGen/Mips/sel1c.ll index b4cba37b78ec..071f988abac3 100644 --- a/llvm/test/CodeGen/Mips/sel1c.ll +++ b/llvm/test/CodeGen/Mips/sel1c.ll @@ -1,4 +1,4 @@ -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 -mattr=+soft-float -mips16-hard-float -relocation-model=pic -mips16-constant-islands < %s | FileCheck %s -check-prefix=cond-b-short +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 -mattr=+soft-float -mips16-hard-float -relocation-model=pic -mips16-constant-islands < %s | FileCheck %s -check-prefix=cond-b-short @i = global i32 1, align 4 @j = global i32 2, align 4 diff --git a/llvm/test/CodeGen/Mips/sel2c.ll b/llvm/test/CodeGen/Mips/sel2c.ll index 9cf8b20eecdd..0c3b9578e69f 100644 --- a/llvm/test/CodeGen/Mips/sel2c.ll +++ b/llvm/test/CodeGen/Mips/sel2c.ll @@ -1,4 +1,4 @@ -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 -mattr=+soft-float -mips16-hard-float -relocation-model=pic -mips16-constant-islands < %s | FileCheck %s -check-prefix=cond-b-short +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 -mattr=+soft-float -mips16-hard-float -relocation-model=pic -mips16-constant-islands < %s | FileCheck %s -check-prefix=cond-b-short @i = global i32 1, align 4 @j = global i32 2, align 4 diff --git a/llvm/test/CodeGen/Mips/simplebr.ll b/llvm/test/CodeGen/Mips/simplebr.ll index ba97bdd89c17..cfe547fe7ca2 100644 --- a/llvm/test/CodeGen/Mips/simplebr.ll +++ b/llvm/test/CodeGen/Mips/simplebr.ll @@ -1,4 +1,4 @@ -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 -mips16-hard-float -mattr=+soft-float -relocation-model=static < %s | FileCheck %s -check-prefix=CHECK-STATIC16 +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 -mips16-hard-float -mattr=+soft-float -relocation-model=static < %s | FileCheck %s -check-prefix=CHECK-STATIC16 ; ModuleID = 'simplebr.c' target datalayout = "E-p:32:32:32-i1:8:8-i8:8:32-i16:16:32-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-n32-S64" diff --git a/llvm/test/CodeGen/Mips/small-section-reserve-gp.ll b/llvm/test/CodeGen/Mips/small-section-reserve-gp.ll index cbe1218c3421..4c1a76a79ae9 100644 --- a/llvm/test/CodeGen/Mips/small-section-reserve-gp.ll +++ b/llvm/test/CodeGen/Mips/small-section-reserve-gp.ll @@ -1,4 +1,4 @@ -; RUN: llc -mtriple=mipsel-sde-elf -march=mipsel -relocation-model=static -mattr=+noabicalls -mgpopt < %s \ +; RUN: llc -mtriple=mipsel-sde-elf -relocation-model=static -mattr=+noabicalls -mgpopt < %s \ ; RUN: | FileCheck %s @i = internal unnamed_addr global i32 0, align 4 diff --git a/llvm/test/CodeGen/Mips/sr1.ll b/llvm/test/CodeGen/Mips/sr1.ll index 47948c488aab..c6fa9fcc4fb0 100644 --- a/llvm/test/CodeGen/Mips/sr1.ll +++ b/llvm/test/CodeGen/Mips/sr1.ll @@ -1,6 +1,6 @@ -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 -relocation-model=static < %s | FileCheck %s +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 -relocation-model=static < %s | FileCheck %s -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 -relocation-model=static < %s | FileCheck %s -check-prefix=NEG +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 -relocation-model=static < %s | FileCheck %s -check-prefix=NEG @f = common global float 0.000000e+00, align 4 diff --git a/llvm/test/CodeGen/Mips/tail16.ll b/llvm/test/CodeGen/Mips/tail16.ll index 831de34f8d89..779ef6b4a11f 100644 --- a/llvm/test/CodeGen/Mips/tail16.ll +++ b/llvm/test/CodeGen/Mips/tail16.ll @@ -1,4 +1,4 @@ -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 -mattr=+soft-float -mips16-hard-float -relocation-model=pic < %s | FileCheck %s +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 -mattr=+soft-float -mips16-hard-float -relocation-model=pic < %s | FileCheck %s ; Function Attrs: nounwind optsize define float @h() { diff --git a/llvm/test/CodeGen/Mips/trap1.ll b/llvm/test/CodeGen/Mips/trap1.ll index 575574a0a3b1..c0c614631509 100644 --- a/llvm/test/CodeGen/Mips/trap1.ll +++ b/llvm/test/CodeGen/Mips/trap1.ll @@ -1,4 +1,4 @@ -; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mattr=mips16 -relocation-model=pic < %s | FileCheck %s -check-prefix=pic +; RUN: llc -mtriple=mipsel-linux-gnu -mattr=mips16 -relocation-model=pic < %s | FileCheck %s -check-prefix=pic declare void @llvm.trap() diff --git a/llvm/test/CodeGen/Thumb2/constant-islands-no-split.mir b/llvm/test/CodeGen/Thumb2/constant-islands-no-split.mir new file mode 100644 index 000000000000..9283ef14ca6c --- /dev/null +++ b/llvm/test/CodeGen/Thumb2/constant-islands-no-split.mir @@ -0,0 +1,165 @@ +# RUN: llc -mtriple=thumbv7-linux-gnueabihf -run-pass=arm-cp-islands -arm-constant-island-max-iteration=1 %s -o - | FileCheck %s +--- | + ; ModuleID = 'constant-islands-new-island.ll' + source_filename = "constant-islands-new-island.ll" + target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64" + target triple = "thumbv7-unknown-linux-gnueabihf" + + define void @test(i1 %tst) { + entry: + %0 = call i32 @llvm.arm.space(i32 2000, i32 undef) + br label %smallbb + + smallbb: ; preds = %entry + br i1 %tst, label %true, label %false + + true: ; preds = %false, %smallbb + %val = phi float [ 1.234500e+04, %smallbb ], [ undef, %false ] + %1 = call i32 @llvm.arm.space(i32 2000, i32 undef) + call void @bar(float %val) + ret void + + false: ; preds = %smallbb + br label %true + } + + declare void @bar(float) + + ; Function Attrs: nounwind + declare i32 @llvm.arm.space(i32 immarg, i32) #0 + + attributes #0 = { nounwind } + +... +--- +name: test +alignment: 2 +exposesReturnsTwice: false +legalized: false +regBankSelected: false +selected: false +failedISel: false +tracksRegLiveness: true +hasWinCFI: false +noPhis: true +isSSA: false +noVRegs: true +hasFakeUses: false +callsEHReturn: false +callsUnwindInit: false +hasEHCatchret: false +hasEHScopes: false +hasEHFunclets: false +isOutlined: false +debugInstrRef: false +failsVerification: false +tracksDebugUserValues: false +registers: [] +liveins: + - { reg: '$r0', virtual-reg: '' } +frameInfo: + isFrameAddressTaken: false + isReturnAddressTaken: false + hasStackMap: false + hasPatchPoint: false + stackSize: 16 + offsetAdjustment: 0 + maxAlignment: 4 + adjustsStack: true + hasCalls: true + stackProtector: '' + functionContext: '' + maxCallFrameSize: 0 + cvBytesOfCalleeSavedRegisters: 0 + hasOpaqueSPAdjustment: false + hasVAStart: false + hasMustTailInVarArgFunc: false + hasTailCall: false + isCalleeSavedInfoValid: true + localFrameSize: 0 + savePoint: '' + restorePoint: '' +fixedStack: [] +stack: + - { id: 0, name: '', type: spill-slot, offset: -12, size: 4, alignment: 4, + stack-id: default, callee-saved-register: '', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 1, name: '', type: spill-slot, offset: -16, size: 4, alignment: 4, + stack-id: default, callee-saved-register: '', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 2, name: '', type: spill-slot, offset: -4, size: 4, alignment: 4, + stack-id: default, callee-saved-register: '$lr', callee-saved-restored: false, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 3, name: '', type: spill-slot, offset: -8, size: 4, alignment: 4, + stack-id: default, callee-saved-register: '$r7', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } +entry_values: [] +callSites: [] +debugValueSubstitutions: [] +constants: + - id: 0 + value: 'float 1.234500e+04' + alignment: 4 + isTargetSpecific: false +machineFunctionInfo: + isLRSpilled: true +body: | + bb.0.entry: + successors: %bb.1(0x80000000) + liveins: $r0, $r7, $lr + + frame-setup tPUSH 14 /* CC::al */, $noreg, killed $r7, killed $lr, implicit-def $sp, implicit $sp + frame-setup CFI_INSTRUCTION def_cfa_offset 8 + frame-setup CFI_INSTRUCTION offset $lr, -4 + frame-setup CFI_INSTRUCTION offset $r7, -8 + $sp = frame-setup tSUBspi $sp, 2, 14 /* CC::al */, $noreg + frame-setup CFI_INSTRUCTION def_cfa_offset 16 + tSTRspi killed $r0, $sp, 1, 14 /* CC::al */, $noreg :: (store (s32) into %stack.0) + renamable $r0 = IMPLICIT_DEF + dead renamable $r0 = SPACE 2000, killed renamable $r0 + t2B %bb.1, 14 /* CC::al */, $noreg + + bb.1.smallbb: + successors: %bb.2(0x40000000), %bb.3(0x40000000) + + $r0 = tLDRspi $sp, 1, 14 /* CC::al */, $noreg :: (load (s32) from %stack.0) + renamable $s0 = VLDRS %const.0, 0, 14 /* CC::al */, $noreg :: (load (s32) from constant-pool) + renamable $r0, dead $cpsr = tLSLri renamable $r0, 31, 14 /* CC::al */, $noreg + tCMPi8 killed renamable $r0, 0, 14 /* CC::al */, $noreg, implicit-def $cpsr + VSTRS killed $s0, $sp, 0, 14 /* CC::al */, $noreg :: (store (s32) into %stack.1) + t2Bcc %bb.3, 0 /* CC::eq */, killed $cpsr + t2B %bb.2, 14 /* CC::al */, $noreg + + bb.2.true: + $s0 = VLDRS $sp, 0, 14 /* CC::al */, $noreg :: (load (s32) from %stack.1) + renamable $r0 = IMPLICIT_DEF + dead renamable $r0 = SPACE 2000, killed renamable $r0 + tBL 14 /* CC::al */, $noreg, @bar, csr_aapcs, implicit-def dead $lr, implicit $sp, implicit killed $s0, implicit-def $sp + $sp = frame-destroy tADDspi $sp, 2, 14 /* CC::al */, $noreg + frame-destroy tPOP_RET 14 /* CC::al */, $noreg, def $r7, def $pc + + bb.3.false: + successors: %bb.2(0x80000000) + + renamable $s0 = IMPLICIT_DEF + t2B %bb.2, 14 /* CC::al */, $noreg + +... +# Check that smallbb is not split by the constant islands pass. Previously, +# smallbb was split due to incorrect calculation of MinNoSplitDisp. +# +# CHECK: bb.1.smallbb: +# CHECK-NEXT: successors: %bb.3(0x40000000), %bb.4(0x40000000) +# CHECK-NEXT: {{^ $}} +# CHECK-NEXT: $r0 = tLDRspi $sp, 1, 14 /* CC::al */, $noreg :: (load (s32) from %stack.0) +# CHECK-NEXT: renamable $s0 = VLDRS %const.1, 0, 14 /* CC::al */, $noreg :: (load (s32) from constant-pool) +# CHECK-NEXT: renamable $r0, dead $cpsr = tLSLri renamable $r0, 31, 14 /* CC::al */, $noreg +# CHECK-NEXT: tCMPi8 killed renamable $r0, 0, 14 /* CC::al */, $noreg, implicit-def $cpsr +# CHECK-NEXT: VSTRS killed $s0, $sp, 0, 14 /* CC::al */, $noreg :: (store (s32) into %stack.1) +# CHECK-NEXT: t2Bcc %bb.4, 0 /* CC::eq */, killed $cpsr +# CHECK-NEXT: tB %bb.3, 14 /* CC::al */, $noreg +# CHECK-NEXT: {{^ $}} +# CHECK-NEXT: bb.2 (align 4): +# CHECK-NEXT: successors: +# CHECK-NEXT: {{^ $}} +# CHECK-NEXT: CONSTPOOL_ENTRY 1, %const.0, 4 diff --git a/llvm/test/MC/ELF/relocation.s b/llvm/test/MC/ELF/relocation.s index 65a9b6f72d0a..618b5c7183c2 100644 --- a/llvm/test/MC/ELF/relocation.s +++ b/llvm/test/MC/ELF/relocation.s @@ -18,30 +18,12 @@ bar: movl bar, %edx # R_X86_64_32S movq bar, %rdx # R_X86_64_32S .long bar # R_X86_64_32 - leaq foo@GOTTPOFF(%rip), %rax # R_X86_64_GOTTPOFF - movq foo@GOTTPOFF(%rip), %r31 # R_X86_64_CODE_4_GOTTPOFF - addq foo@GOTTPOFF(%rip), %r31 # R_X86_64_CODE_4_GOTTPOFF - # NDD - addq %r8, foo@GOTTPOFF(%rip), %r16 # R_X86_64_CODE_6_GOTTPOFF - addq foo@GOTTPOFF(%rip), %rax, %r12 # R_X86_64_CODE_6_GOTTPOFF - # NDD + NF - {nf} addq %r8, foo@GOTTPOFF(%rip), %r16 # R_X86_64_CODE_6_GOTTPOFF - {nf} addq foo@GOTTPOFF(%rip), %rax, %r12 # R_X86_64_CODE_6_GOTTPOFF - # NF - {nf} addq foo@GOTTPOFF(%rip), %r12 # R_X86_64_CODE_6_GOTTPOFF - - leaq foo@TLSGD(%rip), %rax # R_X86_64_TLSGD - leaq foo@TPOFF(%rax), %rax # R_X86_64_TPOFF32 - leaq foo@TLSLD(%rip), %rdi # R_X86_64_TLSLD - leaq foo@dtpoff(%rax), %rcx # R_X86_64_DTPOFF32 - movabs foo@GOT, %rax # R_X86_64_GOT64 - movabs foo@GOTOFF, %rax # R_X86_64_GOTOFF64 + movabs $0, %rax + movabs $0, %rax pushq $bar movq foo(%rip), %rdx leaq foo-bar(%r14),%r14 addq $bar,%rax # R_X86_64_32S - .quad foo@DTPOFF - movabsq $baz@TPOFF, %rax .word foo-bar .byte foo-bar call foo @@ -53,13 +35,6 @@ bar: movl $_GLOBAL_OFFSET_TABLE_, %eax movabs $_GLOBAL_OFFSET_TABLE_, %rax - .quad blah@SIZE # R_X86_64_SIZE64 - .quad blah@SIZE + 32 # R_X86_64_SIZE64 - .quad blah@SIZE - 32 # R_X86_64_SIZE64 - movl blah@SIZE, %eax # R_X86_64_SIZE32 - movl blah@SIZE + 32, %eax # R_X86_64_SIZE32 - movl blah@SIZE - 32, %eax # R_X86_64_SIZE32 - .long foo@gotpcrel .long foo@plt @@ -81,51 +56,29 @@ weak_sym: // CHECK: Section { // CHECK: Name: .rela.text // CHECK: Relocations [ -// CHECK-NEXT: 0x1 R_X86_64_32 .text -// CHECK-NEXT: 0x8 R_X86_64_32S .text -// CHECK-NEXT: 0x13 R_X86_64_32S .text -// CHECK-NEXT: 0x1A R_X86_64_32S .text -// CHECK-NEXT: 0x22 R_X86_64_32S .text -// CHECK-NEXT: 0x26 R_X86_64_32 .text -// CHECK-NEXT: 0x2D R_X86_64_GOTTPOFF foo 0xFFFFFFFFFFFFFFFC -// CHECK-NEXT: 0x35 R_X86_64_CODE_4_GOTTPOFF foo 0xFFFFFFFFFFFFFFFC -// CHECK-NEXT: 0x3D R_X86_64_CODE_4_GOTTPOFF foo 0xFFFFFFFFFFFFFFFC -// CHECK-NEXT: 0x47 R_X86_64_CODE_6_GOTTPOFF foo 0xFFFFFFFFFFFFFFFC -// CHECK-NEXT: 0x51 R_X86_64_CODE_6_GOTTPOFF foo 0xFFFFFFFFFFFFFFFC -// CHECK-NEXT: 0x5B R_X86_64_CODE_6_GOTTPOFF foo 0xFFFFFFFFFFFFFFFC -// CHECK-NEXT: 0x65 R_X86_64_CODE_6_GOTTPOFF foo 0xFFFFFFFFFFFFFFFC -// CHECK-NEXT: 0x6F R_X86_64_CODE_6_GOTTPOFF foo 0xFFFFFFFFFFFFFFFC -// CHECK-NEXT: 0x76 R_X86_64_TLSGD foo 0xFFFFFFFFFFFFFFFC -// CHECK-NEXT: 0x7D R_X86_64_TPOFF32 foo 0x0 -// CHECK-NEXT: 0x84 R_X86_64_TLSLD foo 0xFFFFFFFFFFFFFFFC -// CHECK-NEXT: 0x8B R_X86_64_DTPOFF32 foo 0x0 -// CHECK-NEXT: 0x91 R_X86_64_GOT64 foo 0x0 -// CHECK-NEXT: 0x9B R_X86_64_GOTOFF64 foo 0x0 -// CHECK-NEXT: 0xA4 R_X86_64_32S .text 0x0 -// CHECK-NEXT: 0xAB R_X86_64_PC32 foo 0xFFFFFFFFFFFFFFFC -// CHECK-NEXT: 0xB2 R_X86_64_PC32 foo 0xB2 -// CHECK-NEXT: 0xB9 R_X86_64_32S .text 0x0 -// CHECK-NEXT: 0xBD R_X86_64_DTPOFF64 foo 0x0 -// CHECK-NEXT: 0xC7 R_X86_64_TPOFF64 baz 0x0 -// CHECK-NEXT: 0xCF R_X86_64_PC16 foo 0xCF -// CHECK-NEXT: 0xD1 R_X86_64_PC8 foo 0xD1 -// CHECK-NEXT: 0xD3 R_X86_64_PLT32 foo 0xFFFFFFFFFFFFFFFC -// CHECK-NEXT: 0xDA R_X86_64_PC32 foo 0xFFFFFFFFFFFFFFFB -// CHECK-NEXT: 0xE1 R_X86_64_GOTPC32 _GLOBAL_OFFSET_TABLE_ 0x3 -// CHECK-NEXT: 0xE8 R_X86_64_GOTPC32 _GLOBAL_OFFSET_TABLE_ 0xFFFFFFFFFFFFFFFC -// CHECK-NEXT: 0xED R_X86_64_GOTPC32 _GLOBAL_OFFSET_TABLE_ 0x1 -// CHECK-NEXT: 0xF3 R_X86_64_GOTPC64 _GLOBAL_OFFSET_TABLE_ 0x2 -// CHECK-NEXT: 0xFB R_X86_64_SIZE64 blah 0x0 -// CHECK-NEXT: 0x103 R_X86_64_SIZE64 blah 0x20 -// CHECK-NEXT: 0x10B R_X86_64_SIZE64 blah 0xFFFFFFFFFFFFFFE0 -// CHECK-NEXT: 0x116 R_X86_64_SIZE32 blah 0x0 -// CHECK-NEXT: 0x11D R_X86_64_SIZE32 blah 0x20 -// CHECK-NEXT: 0x124 R_X86_64_SIZE32 blah 0xFFFFFFFFFFFFFFE0 -// CHECK-NEXT: 0x128 R_X86_64_GOTPCREL foo 0x0 -// CHECK-NEXT: 0x12C R_X86_64_PLT32 foo 0x0 -// CHECK-NEXT: 0x140 R_X86_64_32 .text 0x140 -// CHECK-NEXT: 0x145 R_X86_64_PC16 pr23771 0xFFFFFFFFFFFFFFFE -// CHECK-NEXT: 0x147 R_X86_64_PC32 pr23272 0x0 +// CHECK-NEXT: 0x1 R_X86_64_32 .text 0x0 +// CHECK-NEXT: 0x8 R_X86_64_32S .text 0x0 +// CHECK-NEXT: 0x13 R_X86_64_32S .text 0x0 +// CHECK-NEXT: 0x1A R_X86_64_32S .text 0x0 +// CHECK-NEXT: 0x22 R_X86_64_32S .text 0x0 +// CHECK-NEXT: 0x26 R_X86_64_32 .text 0x0 +// CHECK-NEXT: 0x3F R_X86_64_32S .text 0x0 +// CHECK-NEXT: 0x46 R_X86_64_PC32 foo 0xFFFFFFFFFFFFFFFC +// CHECK-NEXT: 0x4D R_X86_64_PC32 foo 0x4D +// CHECK-NEXT: 0x54 R_X86_64_32S .text 0x0 +// CHECK-NEXT: 0x58 R_X86_64_PC16 foo 0x58 +// CHECK-NEXT: 0x5A R_X86_64_PC8 foo 0x5A +// CHECK-NEXT: 0x5C R_X86_64_PLT32 foo 0xFFFFFFFFFFFFFFFC +// CHECK-NEXT: 0x63 R_X86_64_PC32 foo 0xFFFFFFFFFFFFFFFB +// CHECK-NEXT: 0x6A R_X86_64_GOTPC32 _GLOBAL_OFFSET_TABLE_ 0x3 +// CHECK-NEXT: 0x71 R_X86_64_GOTPC32 _GLOBAL_OFFSET_TABLE_ 0xFFFFFFFFFFFFFFFC +// CHECK-NEXT: 0x76 R_X86_64_GOTPC32 _GLOBAL_OFFSET_TABLE_ 0x1 +// CHECK-NEXT: 0x7C R_X86_64_GOTPC64 _GLOBAL_OFFSET_TABLE_ 0x2 +// CHECK-NEXT: 0x84 R_X86_64_GOTPCREL foo 0x0 +// CHECK-NEXT: 0x88 R_X86_64_PLT32 foo 0x0 +// CHECK-NEXT: 0x9C R_X86_64_32 .text 0x9C +// CHECK-NEXT: 0xA1 R_X86_64_PC16 pr23771 0xFFFFFFFFFFFFFFFE +// CHECK-NEXT: 0xA3 R_X86_64_PC32 pr23272 0x0 // CHECK-NEXT: ] // CHECK-NEXT: } diff --git a/llvm/test/MC/X86/elf-reloc-got.s b/llvm/test/MC/X86/elf-reloc-got.s new file mode 100644 index 000000000000..eab24a0ac4a6 --- /dev/null +++ b/llvm/test/MC/X86/elf-reloc-got.s @@ -0,0 +1,13 @@ +# RUN: llvm-mc -filetype=obj -triple=x86_64 %s | llvm-readobj -r - | FileCheck %s + +# CHECK: .rela.GOT64 { +# CHECK-NEXT: 0x2 R_X86_64_GOT64 dat 0x0 +# CHECK-NEXT: 0xC R_X86_64_GOT64 und 0x0 +# CHECK-NEXT: } + +.section .GOT64,"ax" +movabs $dat@GOT, %rax +movabs $und@GOT, %rax + +.data +dat: diff --git a/llvm/test/MC/X86/elf-reloc-size.s b/llvm/test/MC/X86/elf-reloc-size.s new file mode 100644 index 000000000000..d51b2d54f7e7 --- /dev/null +++ b/llvm/test/MC/X86/elf-reloc-size.s @@ -0,0 +1,22 @@ +# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t +# RUN: llvm-readobj -r %t | FileCheck %s + +# CHECK: .rela.text { +# CHECK-NEXT: 0x3 R_X86_64_SIZE32 foo 0x0 +# CHECK-NEXT: 0xA R_X86_64_SIZE32 foo 0x20 +# CHECK-NEXT: 0x11 R_X86_64_SIZE32 foo 0xFFFFFFFFFFFFFFE0 +# CHECK-NEXT: } +# CHECK-NEXT: .rela.data { +# CHECK-NEXT: 0x0 R_X86_64_SIZE64 foo 0x0 +# CHECK-NEXT: 0x8 R_X86_64_SIZE64 foo 0x20 +# CHECK-NEXT: 0x10 R_X86_64_SIZE64 foo 0xFFFFFFFFFFFFFFE0 +# CHECK-NEXT: } + +movl foo@SIZE, %eax +movl foo@SIZE+32, %eax +movl foo@SIZE-32, %eax + +.data +.quad foo@SIZE +.quad foo@SIZE + 32 +.quad foo@SIZE - 32 diff --git a/llvm/test/MC/X86/elf-reloc-tls.s b/llvm/test/MC/X86/elf-reloc-tls.s new file mode 100644 index 000000000000..209043585931 --- /dev/null +++ b/llvm/test/MC/X86/elf-reloc-tls.s @@ -0,0 +1,37 @@ +# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t +# RUN: llvm-readobj -r %t | FileCheck %s + +# CHECK: .rela.GOTTPOFF { +# CHECK-NEXT: 0x3 R_X86_64_GOTTPOFF tls 0xFFFFFFFFFFFFFFFC +# CHECK-NEXT: 0xB R_X86_64_CODE_4_GOTTPOFF foo 0xFFFFFFFFFFFFFFFC +# CHECK-NEXT: 0x13 R_X86_64_CODE_4_GOTTPOFF foo 0xFFFFFFFFFFFFFFFC +# CHECK-NEXT: 0x1D R_X86_64_CODE_6_GOTTPOFF foo 0xFFFFFFFFFFFFFFFC +# CHECK-NEXT: 0x27 R_X86_64_CODE_6_GOTTPOFF foo 0xFFFFFFFFFFFFFFFC +# CHECK-NEXT: 0x31 R_X86_64_CODE_6_GOTTPOFF foo 0xFFFFFFFFFFFFFFFC +# CHECK-NEXT: 0x3B R_X86_64_CODE_6_GOTTPOFF foo 0xFFFFFFFFFFFFFFFC +# CHECK-NEXT: 0x45 R_X86_64_CODE_6_GOTTPOFF foo 0xFFFFFFFFFFFFFFFC +# CHECK-NEXT: } + +.section .TPOFF,"ax" +leaq foo@TPOFF(%rax), %rax # R_X86_64_TPOFF32 +movabsq $baz@TPOFF, %rax + +.section .GOTTPOFF,"ax" +leaq tls@GOTTPOFF(%rip), %rax + +movq foo@GOTTPOFF(%rip), %r31 # R_X86_64_CODE_4_GOTTPOFF +addq foo@GOTTPOFF(%rip), %r31 # R_X86_64_CODE_4_GOTTPOFF +# NDD +addq %r8, foo@GOTTPOFF(%rip), %r16 # R_X86_64_CODE_6_GOTTPOFF +addq foo@GOTTPOFF(%rip), %rax, %r12 # R_X86_64_CODE_6_GOTTPOFF +# NDD + NF +{nf} addq %r8, foo@GOTTPOFF(%rip), %r16 # R_X86_64_CODE_6_GOTTPOFF +{nf} addq foo@GOTTPOFF(%rip), %rax, %r12 # R_X86_64_CODE_6_GOTTPOFF +# NF +{nf} addq foo@GOTTPOFF(%rip), %r12 # R_X86_64_CODE_6_GOTTPOFF + +.section .GD,"ax" +leaq foo@TLSGD(%rip), %rax # R_X86_64_TLSGD +leaq foo@TLSLD(%rip), %rdi # R_X86_64_TLSLD +leaq foo@dtpoff(%rax), %rcx # R_X86_64_DTPOFF32 +.quad foo@DTPOFF diff --git a/llvm/test/Transforms/LoopVectorize/single_early_exit.ll b/llvm/test/Transforms/LoopVectorize/single_early_exit.ll index 08a333fa8651..05f46e8e2770 100644 --- a/llvm/test/Transforms/LoopVectorize/single_early_exit.ll +++ b/llvm/test/Transforms/LoopVectorize/single_early_exit.ll @@ -200,10 +200,8 @@ define i32 @diff_exit_block_needs_scev_check(i32 %end) { ; CHECK-NEXT: [[TMP12:%.*]] = getelementptr inbounds i32, ptr [[TMP11]], i32 0 ; CHECK-NEXT: [[WIDE_LOAD3:%.*]] = load <4 x i32>, ptr [[TMP12]], align 4 ; CHECK-NEXT: [[TMP13:%.*]] = icmp eq <4 x i32> [[WIDE_LOAD]], [[WIDE_LOAD3]] -; CHECK-NEXT: [[TMP14:%.*]] = xor <4 x i1> [[TMP13]], splat (i1 true) ; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 4 -; CHECK-NEXT: [[TMP15:%.*]] = xor <4 x i1> [[TMP14]], splat (i1 true) -; CHECK-NEXT: [[TMP16:%.*]] = call i1 @llvm.vector.reduce.or.v4i1(<4 x i1> [[TMP15]]) +; CHECK-NEXT: [[TMP16:%.*]] = call i1 @llvm.vector.reduce.or.v4i1(<4 x i1> [[TMP13]]) ; CHECK-NEXT: [[TMP17:%.*]] = icmp eq i64 [[INDEX_NEXT]], [[N_VEC]] ; CHECK-NEXT: [[TMP18:%.*]] = or i1 [[TMP16]], [[TMP17]] ; CHECK-NEXT: br i1 [[TMP18]], label [[MIDDLE_SPLIT:%.*]], label [[FOR_BODY]], !llvm.loop [[LOOP6:![0-9]+]] diff --git a/llvm/test/Transforms/LoopVectorize/uncountable-early-exit-vplan.ll b/llvm/test/Transforms/LoopVectorize/uncountable-early-exit-vplan.ll index 730dbfe84070..1a8f29e672f1 100644 --- a/llvm/test/Transforms/LoopVectorize/uncountable-early-exit-vplan.ll +++ b/llvm/test/Transforms/LoopVectorize/uncountable-early-exit-vplan.ll @@ -28,10 +28,8 @@ define i64 @multi_exiting_to_different_exits_live_in_exit_values() { ; CHECK-NEXT: vp<[[VEC_PTR:%.+]]> = vector-pointer ir<%gep.src> ; CHECK-NEXT: WIDEN ir<%l> = load vp<[[VEC_PTR]]> ; CHECK-NEXT: WIDEN ir<%c.1> = icmp eq ir<%l>, ir<10> -; CHECK-NEXT: EMIT vp<[[NOT1:%.+]]> = not ir<%c.1> ; CHECK-NEXT: EMIT vp<%index.next> = add nuw vp<[[CAN_IV]]>, vp<[[VFxUF]]> -; CHECK-NEXT: EMIT vp<[[NOT2:%.+]]> = not vp<[[NOT1]]> -; CHECK-NEXT: EMIT vp<[[EA_TAKEN:%.+]]> = any-of vp<[[NOT2]]> +; CHECK-NEXT: EMIT vp<[[EA_TAKEN:%.+]]> = any-of ir<%c.1> ; CHECK-NEXT: EMIT vp<[[LATCH_CMP:%.+]]> = icmp eq vp<%index.next>, vp<[[VTC]]> ; CHECK-NEXT: EMIT vp<[[EC:%.+]]> = or vp<[[EA_TAKEN]]>, vp<[[LATCH_CMP]]> ; CHECK-NEXT: EMIT branch-on-cond vp<[[EC]]> @@ -112,10 +110,8 @@ define i64 @multi_exiting_to_same_exit_live_in_exit_values() { ; CHECK-NEXT: vp<[[VEC_PTR:%.+]]> = vector-pointer ir<%gep.src> ; CHECK-NEXT: WIDEN ir<%l> = load vp<[[VEC_PTR]]> ; CHECK-NEXT: WIDEN ir<%c.1> = icmp eq ir<%l>, ir<10> -; CHECK-NEXT: EMIT vp<[[NOT1:%.+]]> = not ir<%c.1> ; CHECK-NEXT: EMIT vp<%index.next> = add nuw vp<[[CAN_IV]]>, vp<[[VFxUF]]> -; CHECK-NEXT: EMIT vp<[[NOT2:%.+]]> = not vp<[[NOT1]]> -; CHECK-NEXT: EMIT vp<[[EA_TAKEN:%.+]]> = any-of vp<[[NOT2]]> +; CHECK-NEXT: EMIT vp<[[EA_TAKEN:%.+]]> = any-of ir<%c.1> ; CHECK-NEXT: EMIT vp<[[LATCH_CMP:%.+]]> = icmp eq vp<%index.next>, vp<[[VTC]]> ; CHECK-NEXT: EMIT vp<[[EC:%.+]]> = or vp<[[EA_TAKEN]]>, vp<[[LATCH_CMP]]> ; CHECK-NEXT: EMIT branch-on-cond vp<[[EC]]> @@ -189,10 +185,8 @@ define i64 @multi_exiting_to_same_exit_live_in_exit_values_2() { ; CHECK-NEXT: vp<[[VEC_PTR:%.+]]> = vector-pointer ir<%gep.src> ; CHECK-NEXT: WIDEN ir<%l> = load vp<[[VEC_PTR]]> ; CHECK-NEXT: WIDEN ir<%c.1> = icmp eq ir<%l>, ir<10> -; CHECK-NEXT: EMIT vp<[[NOT1:%.+]]> = not ir<%c.1> ; CHECK-NEXT: EMIT vp<%index.next> = add nuw vp<[[CAN_IV]]>, vp<[[VFxUF]]> -; CHECK-NEXT: EMIT vp<[[NOT2:%.+]]> = not vp<[[NOT1]]> -; CHECK-NEXT: EMIT vp<[[EA_TAKEN:%.+]]> = any-of vp<[[NOT2]]> +; CHECK-NEXT: EMIT vp<[[EA_TAKEN:%.+]]> = any-of ir<%c.1> ; CHECK-NEXT: EMIT vp<[[LATCH_CMP:%.+]]> = icmp eq vp<%index.next>, vp<[[VTC]]> ; CHECK-NEXT: EMIT vp<[[EC:%.+]]> = or vp<[[EA_TAKEN]]>, vp<[[LATCH_CMP]]> ; CHECK-NEXT: EMIT branch-on-cond vp<[[EC]]> diff --git a/llvm/test/Transforms/SROA/non-capturing-call-readonly.ll b/llvm/test/Transforms/SROA/non-capturing-call-readonly.ll index 87862b929a75..cc57abe391aa 100644 --- a/llvm/test/Transforms/SROA/non-capturing-call-readonly.ll +++ b/llvm/test/Transforms/SROA/non-capturing-call-readonly.ll @@ -9,19 +9,18 @@ define i32 @alloca_used_in_call(ptr %data, i64 %n) { ; CHECK-NEXT: store i32 0, ptr [[RETVAL]], align 4 ; CHECK-NEXT: br label [[LOOP:%.*]] ; CHECK: loop: -; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[INDVARS_IV_NEXT:%.*]], [[LOOP]] ] +; CHECK-NEXT: [[RDX:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[RDX_INC:%.*]], [[LOOP]] ] +; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ 0, [[ENTRY]] ], [ [[INDVARS_IV_NEXT:%.*]], [[LOOP]] ] ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, ptr [[DATA:%.*]], i64 [[INDVARS_IV]] ; CHECK-NEXT: [[LD:%.*]] = load i32, ptr [[ARRAYIDX]], align 4 -; CHECK-NEXT: [[RDX:%.*]] = load i32, ptr [[RETVAL]], align 4 -; CHECK-NEXT: [[RDX_INC:%.*]] = add nsw i32 [[RDX]], [[LD]] +; CHECK-NEXT: [[RDX_INC]] = add nsw i32 [[RDX]], [[LD]] ; CHECK-NEXT: store i32 [[RDX_INC]], ptr [[RETVAL]], align 4 ; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nsw i64 [[INDVARS_IV]], 1 ; CHECK-NEXT: [[EXITCOND:%.*]] = icmp ne i64 [[INDVARS_IV_NEXT]], [[N:%.*]] ; CHECK-NEXT: br i1 [[EXITCOND]], label [[LOOP]], label [[EXIT:%.*]] ; CHECK: exit: ; CHECK-NEXT: [[I0:%.*]] = call i32 @user_of_alloca(ptr [[RETVAL]]) -; CHECK-NEXT: [[I1:%.*]] = load i32, ptr [[RETVAL]], align 4 -; CHECK-NEXT: ret i32 [[I1]] +; CHECK-NEXT: ret i32 [[RDX_INC]] ; entry: %retval = alloca i32, align 4 @@ -138,19 +137,18 @@ define i32 @alloca_not_captured_and_readonly_as_per_operand_attr(ptr %data, i64 ; CHECK-NEXT: store i32 0, ptr [[RETVAL]], align 4 ; CHECK-NEXT: br label [[LOOP:%.*]] ; CHECK: loop: -; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[INDVARS_IV_NEXT:%.*]], [[LOOP]] ] +; CHECK-NEXT: [[RDX:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[RDX_INC:%.*]], [[LOOP]] ] +; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ 0, [[ENTRY]] ], [ [[INDVARS_IV_NEXT:%.*]], [[LOOP]] ] ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, ptr [[DATA:%.*]], i64 [[INDVARS_IV]] ; CHECK-NEXT: [[LD:%.*]] = load i32, ptr [[ARRAYIDX]], align 4 -; CHECK-NEXT: [[RDX:%.*]] = load i32, ptr [[RETVAL]], align 4 -; CHECK-NEXT: [[RDX_INC:%.*]] = add nsw i32 [[RDX]], [[LD]] +; CHECK-NEXT: [[RDX_INC]] = add nsw i32 [[RDX]], [[LD]] ; CHECK-NEXT: store i32 [[RDX_INC]], ptr [[RETVAL]], align 4 ; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nsw i64 [[INDVARS_IV]], 1 ; CHECK-NEXT: [[EXITCOND:%.*]] = icmp ne i64 [[INDVARS_IV_NEXT]], [[N:%.*]] ; CHECK-NEXT: br i1 [[EXITCOND]], label [[LOOP]], label [[EXIT:%.*]] ; CHECK: exit: ; CHECK-NEXT: [[I0:%.*]] = call i32 @capture_of_alloca(ptr nocapture readonly [[RETVAL]]) -; CHECK-NEXT: [[I1:%.*]] = load i32, ptr [[RETVAL]], align 4 -; CHECK-NEXT: ret i32 [[I1]] +; CHECK-NEXT: ret i32 [[RDX_INC]] ; entry: %retval = alloca i32, align 4 @@ -267,19 +265,18 @@ define i32 @alloca_with_gep_used_in_call(ptr %data, i64 %n) { ; CHECK-NEXT: store i32 0, ptr [[RETVAL]], align 4 ; CHECK-NEXT: br label [[LOOP:%.*]] ; CHECK: loop: -; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[INDVARS_IV_NEXT:%.*]], [[LOOP]] ] +; CHECK-NEXT: [[RDX:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[RDX_INC:%.*]], [[LOOP]] ] +; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ 0, [[ENTRY]] ], [ [[INDVARS_IV_NEXT:%.*]], [[LOOP]] ] ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, ptr [[DATA:%.*]], i64 [[INDVARS_IV]] ; CHECK-NEXT: [[LD:%.*]] = load i32, ptr [[ARRAYIDX]], align 4 -; CHECK-NEXT: [[RDX:%.*]] = load i32, ptr [[RETVAL]], align 4 -; CHECK-NEXT: [[RDX_INC:%.*]] = add nsw i32 [[RDX]], [[LD]] +; CHECK-NEXT: [[RDX_INC]] = add nsw i32 [[RDX]], [[LD]] ; CHECK-NEXT: store i32 [[RDX_INC]], ptr [[RETVAL]], align 4 ; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nsw i64 [[INDVARS_IV]], 1 ; CHECK-NEXT: [[EXITCOND:%.*]] = icmp ne i64 [[INDVARS_IV_NEXT]], [[N:%.*]] ; CHECK-NEXT: br i1 [[EXITCOND]], label [[LOOP]], label [[EXIT:%.*]] ; CHECK: exit: ; CHECK-NEXT: [[I0:%.*]] = call i32 @user_of_alloca(ptr [[RETVAL]]) -; CHECK-NEXT: [[I1:%.*]] = load i32, ptr [[RETVAL]], align 4 -; CHECK-NEXT: ret i32 [[I1]] +; CHECK-NEXT: ret i32 [[RDX_INC]] ; entry: %retval = alloca i32, align 4 @@ -353,11 +350,11 @@ define i32 @alloca_used_in_maybe_throwing_call(ptr %data, i64 %n) personality pt ; CHECK-NEXT: store i32 0, ptr [[RETVAL]], align 4 ; CHECK-NEXT: br label [[LOOP:%.*]] ; CHECK: loop: -; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[INDVARS_IV_NEXT:%.*]], [[LOOP]] ] +; CHECK-NEXT: [[RDX:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[RDX_INC:%.*]], [[LOOP]] ] +; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ 0, [[ENTRY]] ], [ [[INDVARS_IV_NEXT:%.*]], [[LOOP]] ] ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, ptr [[DATA:%.*]], i64 [[INDVARS_IV]] ; CHECK-NEXT: [[LD:%.*]] = load i32, ptr [[ARRAYIDX]], align 4 -; CHECK-NEXT: [[RDX:%.*]] = load i32, ptr [[RETVAL]], align 4 -; CHECK-NEXT: [[RDX_INC:%.*]] = add nsw i32 [[RDX]], [[LD]] +; CHECK-NEXT: [[RDX_INC]] = add nsw i32 [[RDX]], [[LD]] ; CHECK-NEXT: store i32 [[RDX_INC]], ptr [[RETVAL]], align 4 ; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nsw i64 [[INDVARS_IV]], 1 ; CHECK-NEXT: [[EXITCOND:%.*]] = icmp ne i64 [[INDVARS_IV_NEXT]], [[N:%.*]] @@ -372,8 +369,7 @@ define i32 @alloca_used_in_maybe_throwing_call(ptr %data, i64 %n) personality pt ; CHECK-NEXT: catch ptr null ; CHECK-NEXT: br label [[END]] ; CHECK: end: -; CHECK-NEXT: [[I2:%.*]] = load i32, ptr [[RETVAL]], align 4 -; CHECK-NEXT: ret i32 [[I2]] +; CHECK-NEXT: ret i32 [[RDX_INC]] ; entry: %retval = alloca i32, align 4 @@ -413,11 +409,11 @@ define i32 @alloca_used_in_maybe_throwing_call_with_same_dests(ptr %data, i64 %n ; CHECK-NEXT: store i32 0, ptr [[RETVAL]], align 4 ; CHECK-NEXT: br label [[LOOP:%.*]] ; CHECK: loop: -; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[INDVARS_IV_NEXT:%.*]], [[LOOP]] ] +; CHECK-NEXT: [[RDX:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[RDX_INC:%.*]], [[LOOP]] ] +; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ 0, [[ENTRY]] ], [ [[INDVARS_IV_NEXT:%.*]], [[LOOP]] ] ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, ptr [[DATA:%.*]], i64 [[INDVARS_IV]] ; CHECK-NEXT: [[LD:%.*]] = load i32, ptr [[ARRAYIDX]], align 4 -; CHECK-NEXT: [[RDX:%.*]] = load i32, ptr [[RETVAL]], align 4 -; CHECK-NEXT: [[RDX_INC:%.*]] = add nsw i32 [[RDX]], [[LD]] +; CHECK-NEXT: [[RDX_INC]] = add nsw i32 [[RDX]], [[LD]] ; CHECK-NEXT: store i32 [[RDX_INC]], ptr [[RETVAL]], align 4 ; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nsw i64 [[INDVARS_IV]], 1 ; CHECK-NEXT: [[EXITCOND:%.*]] = icmp ne i64 [[INDVARS_IV_NEXT]], [[N:%.*]] @@ -430,8 +426,7 @@ define i32 @alloca_used_in_maybe_throwing_call_with_same_dests(ptr %data, i64 %n ; CHECK-NEXT: catch ptr null ; CHECK-NEXT: br label [[END]] ; CHECK: end: -; CHECK-NEXT: [[I2:%.*]] = load i32, ptr [[RETVAL]], align 4 -; CHECK-NEXT: ret i32 [[I2]] +; CHECK-NEXT: ret i32 [[RDX_INC]] ; entry: %retval = alloca i32, align 4 @@ -472,11 +467,11 @@ define [2 x i32] @part_of_alloca_used_in_call(ptr %data, i64 %n) { ; CHECK-NEXT: [[RETVAL:%.*]] = getelementptr inbounds [2 x i32], ptr [[RETVAL_FULL]], i64 0, i64 1 ; CHECK-NEXT: br label [[LOOP:%.*]] ; CHECK: loop: -; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[INDVARS_IV_NEXT:%.*]], [[LOOP]] ] +; CHECK-NEXT: [[RDX:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[RDX_INC:%.*]], [[LOOP]] ] +; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ 0, [[ENTRY]] ], [ [[INDVARS_IV_NEXT:%.*]], [[LOOP]] ] ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, ptr [[DATA:%.*]], i64 [[INDVARS_IV]] ; CHECK-NEXT: [[LD:%.*]] = load i32, ptr [[ARRAYIDX]], align 4 -; CHECK-NEXT: [[RDX:%.*]] = load i32, ptr [[RETVAL]], align 4 -; CHECK-NEXT: [[RDX_INC:%.*]] = add nsw i32 [[RDX]], [[LD]] +; CHECK-NEXT: [[RDX_INC]] = add nsw i32 [[RDX]], [[LD]] ; CHECK-NEXT: store i32 [[RDX_INC]], ptr [[RETVAL]], align 4 ; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nsw i64 [[INDVARS_IV]], 1 ; CHECK-NEXT: [[EXITCOND:%.*]] = icmp ne i64 [[INDVARS_IV_NEXT]], [[N:%.*]] @@ -484,11 +479,9 @@ define [2 x i32] @part_of_alloca_used_in_call(ptr %data, i64 %n) { ; CHECK: exit: ; CHECK-NEXT: [[I0:%.*]] = call i32 @user_of_alloca(ptr [[RETVAL]]) ; CHECK-NEXT: [[I1_FCA_0_GEP:%.*]] = getelementptr inbounds [2 x i32], ptr [[RETVAL_FULL]], i32 0, i32 0 -; CHECK-NEXT: [[I1_FCA_0_LOAD:%.*]] = load i32, ptr [[I1_FCA_0_GEP]], align 4 -; CHECK-NEXT: [[I1_FCA_0_INSERT:%.*]] = insertvalue [2 x i32] poison, i32 [[I1_FCA_0_LOAD]], 0 +; CHECK-NEXT: [[I1_FCA_0_INSERT:%.*]] = insertvalue [2 x i32] poison, i32 0, 0 ; CHECK-NEXT: [[I1_FCA_1_GEP:%.*]] = getelementptr inbounds [2 x i32], ptr [[RETVAL_FULL]], i32 0, i32 1 -; CHECK-NEXT: [[I1_FCA_1_LOAD:%.*]] = load i32, ptr [[I1_FCA_1_GEP]], align 4 -; CHECK-NEXT: [[I1_FCA_1_INSERT:%.*]] = insertvalue [2 x i32] [[I1_FCA_0_INSERT]], i32 [[I1_FCA_1_LOAD]], 1 +; CHECK-NEXT: [[I1_FCA_1_INSERT:%.*]] = insertvalue [2 x i32] [[I1_FCA_0_INSERT]], i32 [[RDX_INC]], 1 ; CHECK-NEXT: ret [2 x i32] [[I1_FCA_1_INSERT]] ; entry: @@ -525,11 +518,11 @@ define [2 x i32] @all_parts_of_alloca_used_in_call_with_multiple_args(ptr %data, ; CHECK-NEXT: [[RETVAL:%.*]] = getelementptr inbounds [2 x i32], ptr [[RETVAL_FULL]], i64 0, i64 1 ; CHECK-NEXT: br label [[LOOP:%.*]] ; CHECK: loop: -; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[INDVARS_IV_NEXT:%.*]], [[LOOP]] ] +; CHECK-NEXT: [[RDX:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[RDX_INC:%.*]], [[LOOP]] ] +; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ 0, [[ENTRY]] ], [ [[INDVARS_IV_NEXT:%.*]], [[LOOP]] ] ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, ptr [[DATA:%.*]], i64 [[INDVARS_IV]] ; CHECK-NEXT: [[LD:%.*]] = load i32, ptr [[ARRAYIDX]], align 4 -; CHECK-NEXT: [[RDX:%.*]] = load i32, ptr [[RETVAL]], align 4 -; CHECK-NEXT: [[RDX_INC:%.*]] = add nsw i32 [[RDX]], [[LD]] +; CHECK-NEXT: [[RDX_INC]] = add nsw i32 [[RDX]], [[LD]] ; CHECK-NEXT: store i32 [[RDX_INC]], ptr [[RETVAL]], align 4 ; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nsw i64 [[INDVARS_IV]], 1 ; CHECK-NEXT: [[EXITCOND:%.*]] = icmp ne i64 [[INDVARS_IV_NEXT]], [[N:%.*]] @@ -537,11 +530,9 @@ define [2 x i32] @all_parts_of_alloca_used_in_call_with_multiple_args(ptr %data, ; CHECK: exit: ; CHECK-NEXT: [[I0:%.*]] = call i32 @user_of_alloca_with_multiple_args(ptr [[RETVAL]], ptr [[RETVAL_FULL]]) ; CHECK-NEXT: [[I1_FCA_0_GEP:%.*]] = getelementptr inbounds [2 x i32], ptr [[RETVAL_FULL]], i32 0, i32 0 -; CHECK-NEXT: [[I1_FCA_0_LOAD:%.*]] = load i32, ptr [[I1_FCA_0_GEP]], align 4 -; CHECK-NEXT: [[I1_FCA_0_INSERT:%.*]] = insertvalue [2 x i32] poison, i32 [[I1_FCA_0_LOAD]], 0 +; CHECK-NEXT: [[I1_FCA_0_INSERT:%.*]] = insertvalue [2 x i32] poison, i32 0, 0 ; CHECK-NEXT: [[I1_FCA_1_GEP:%.*]] = getelementptr inbounds [2 x i32], ptr [[RETVAL_FULL]], i32 0, i32 1 -; CHECK-NEXT: [[I1_FCA_1_LOAD:%.*]] = load i32, ptr [[I1_FCA_1_GEP]], align 4 -; CHECK-NEXT: [[I1_FCA_1_INSERT:%.*]] = insertvalue [2 x i32] [[I1_FCA_0_INSERT]], i32 [[I1_FCA_1_LOAD]], 1 +; CHECK-NEXT: [[I1_FCA_1_INSERT:%.*]] = insertvalue [2 x i32] [[I1_FCA_0_INSERT]], i32 [[RDX_INC]], 1 ; CHECK-NEXT: ret [2 x i32] [[I1_FCA_1_INSERT]] ; entry: @@ -688,11 +679,11 @@ define [2 x i32] @part_of_alloca_used_in_call_with_multiple_args(ptr %data, i64 ; CHECK-NEXT: [[RETVAL:%.*]] = getelementptr inbounds [2 x i32], ptr [[RETVAL_FULL]], i64 0, i64 1 ; CHECK-NEXT: br label [[LOOP:%.*]] ; CHECK: loop: -; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[INDVARS_IV_NEXT:%.*]], [[LOOP]] ] +; CHECK-NEXT: [[RDX:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[RDX_INC:%.*]], [[LOOP]] ] +; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ 0, [[ENTRY]] ], [ [[INDVARS_IV_NEXT:%.*]], [[LOOP]] ] ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, ptr [[DATA:%.*]], i64 [[INDVARS_IV]] ; CHECK-NEXT: [[LD:%.*]] = load i32, ptr [[ARRAYIDX]], align 4 -; CHECK-NEXT: [[RDX:%.*]] = load i32, ptr [[RETVAL]], align 4 -; CHECK-NEXT: [[RDX_INC:%.*]] = add nsw i32 [[RDX]], [[LD]] +; CHECK-NEXT: [[RDX_INC]] = add nsw i32 [[RDX]], [[LD]] ; CHECK-NEXT: store i32 [[RDX_INC]], ptr [[RETVAL]], align 4 ; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nsw i64 [[INDVARS_IV]], 1 ; CHECK-NEXT: [[EXITCOND:%.*]] = icmp ne i64 [[INDVARS_IV_NEXT]], [[N:%.*]] @@ -700,11 +691,9 @@ define [2 x i32] @part_of_alloca_used_in_call_with_multiple_args(ptr %data, i64 ; CHECK: exit: ; CHECK-NEXT: [[I0:%.*]] = call i32 @user_of_alloca_with_multiple_args(ptr [[RETVAL]], ptr [[RETVAL]]) ; CHECK-NEXT: [[I1_FCA_0_GEP:%.*]] = getelementptr inbounds [2 x i32], ptr [[RETVAL_FULL]], i32 0, i32 0 -; CHECK-NEXT: [[I1_FCA_0_LOAD:%.*]] = load i32, ptr [[I1_FCA_0_GEP]], align 4 -; CHECK-NEXT: [[I1_FCA_0_INSERT:%.*]] = insertvalue [2 x i32] poison, i32 [[I1_FCA_0_LOAD]], 0 +; CHECK-NEXT: [[I1_FCA_0_INSERT:%.*]] = insertvalue [2 x i32] poison, i32 0, 0 ; CHECK-NEXT: [[I1_FCA_1_GEP:%.*]] = getelementptr inbounds [2 x i32], ptr [[RETVAL_FULL]], i32 0, i32 1 -; CHECK-NEXT: [[I1_FCA_1_LOAD:%.*]] = load i32, ptr [[I1_FCA_1_GEP]], align 4 -; CHECK-NEXT: [[I1_FCA_1_INSERT:%.*]] = insertvalue [2 x i32] [[I1_FCA_0_INSERT]], i32 [[I1_FCA_1_LOAD]], 1 +; CHECK-NEXT: [[I1_FCA_1_INSERT:%.*]] = insertvalue [2 x i32] [[I1_FCA_0_INSERT]], i32 [[RDX_INC]], 1 ; CHECK-NEXT: ret [2 x i32] [[I1_FCA_1_INSERT]] ; entry: @@ -742,11 +731,11 @@ define [2 x i32] @all_parts_of_alloca_used_in_calls_with_multiple_args(ptr %data ; CHECK-NEXT: [[RETVAL:%.*]] = getelementptr inbounds [2 x i32], ptr [[RETVAL_FULL]], i64 0, i64 1 ; CHECK-NEXT: br label [[LOOP:%.*]] ; CHECK: loop: -; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[INDVARS_IV_NEXT:%.*]], [[LOOP]] ] +; CHECK-NEXT: [[RDX:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[RDX_INC:%.*]], [[LOOP]] ] +; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ 0, [[ENTRY]] ], [ [[INDVARS_IV_NEXT:%.*]], [[LOOP]] ] ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, ptr [[DATA:%.*]], i64 [[INDVARS_IV]] ; CHECK-NEXT: [[LD:%.*]] = load i32, ptr [[ARRAYIDX]], align 4 -; CHECK-NEXT: [[RDX:%.*]] = load i32, ptr [[RETVAL]], align 4 -; CHECK-NEXT: [[RDX_INC:%.*]] = add nsw i32 [[RDX]], [[LD]] +; CHECK-NEXT: [[RDX_INC]] = add nsw i32 [[RDX]], [[LD]] ; CHECK-NEXT: store i32 [[RDX_INC]], ptr [[RETVAL]], align 4 ; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nsw i64 [[INDVARS_IV]], 1 ; CHECK-NEXT: [[EXITCOND:%.*]] = icmp ne i64 [[INDVARS_IV_NEXT]], [[N:%.*]] @@ -756,11 +745,9 @@ define [2 x i32] @all_parts_of_alloca_used_in_calls_with_multiple_args(ptr %data ; CHECK-NEXT: [[I1:%.*]] = call i32 @user_of_alloca_with_multiple_args(ptr [[RETVAL_FULL]], ptr [[RETVAL]]) ; CHECK-NEXT: [[I2:%.*]] = call i32 @capture_of_alloca(ptr [[SOME_ANOTHER_ALLOCA_FULL]]) ; CHECK-NEXT: [[I3_FCA_0_GEP:%.*]] = getelementptr inbounds [2 x i32], ptr [[RETVAL_FULL]], i32 0, i32 0 -; CHECK-NEXT: [[I3_FCA_0_LOAD:%.*]] = load i32, ptr [[I3_FCA_0_GEP]], align 4 -; CHECK-NEXT: [[I3_FCA_0_INSERT:%.*]] = insertvalue [2 x i32] poison, i32 [[I3_FCA_0_LOAD]], 0 +; CHECK-NEXT: [[I3_FCA_0_INSERT:%.*]] = insertvalue [2 x i32] poison, i32 0, 0 ; CHECK-NEXT: [[I3_FCA_1_GEP:%.*]] = getelementptr inbounds [2 x i32], ptr [[RETVAL_FULL]], i32 0, i32 1 -; CHECK-NEXT: [[I3_FCA_1_LOAD:%.*]] = load i32, ptr [[I3_FCA_1_GEP]], align 4 -; CHECK-NEXT: [[I3_FCA_1_INSERT:%.*]] = insertvalue [2 x i32] [[I3_FCA_0_INSERT]], i32 [[I3_FCA_1_LOAD]], 1 +; CHECK-NEXT: [[I3_FCA_1_INSERT:%.*]] = insertvalue [2 x i32] [[I3_FCA_0_INSERT]], i32 [[RDX_INC]], 1 ; CHECK-NEXT: ret [2 x i32] [[I3_FCA_1_INSERT]] ; entry: @@ -851,8 +838,7 @@ define i8 @dont_transform_load_only() { ; CHECK-NEXT: entry: ; CHECK-NEXT: [[A:%.*]] = alloca i8, align 1 ; CHECK-NEXT: call void @byte_user_of_alloca(ptr [[A]]) -; CHECK-NEXT: [[R:%.*]] = load i8, ptr [[A]], align 1 -; CHECK-NEXT: ret i8 [[R]] +; CHECK-NEXT: ret i8 undef ; entry: %a = alloca i8 @@ -866,8 +852,7 @@ define i8 @transform_load_and_store() { ; CHECK-NEXT: [[A:%.*]] = alloca i8, align 1 ; CHECK-NEXT: store i8 0, ptr [[A]], align 1 ; CHECK-NEXT: call void @byte_user_of_alloca(ptr [[A]]) -; CHECK-NEXT: [[R:%.*]] = load i8, ptr [[A]], align 1 -; CHECK-NEXT: ret i8 [[R]] +; CHECK-NEXT: ret i8 0 ; entry: %a = alloca i8 diff --git a/llvm/test/Transforms/SROA/readonlynocapture.ll b/llvm/test/Transforms/SROA/readonlynocapture.ll index 2d02996d806e..9c12a4b1a490 100644 --- a/llvm/test/Transforms/SROA/readonlynocapture.ll +++ b/llvm/test/Transforms/SROA/readonlynocapture.ll @@ -8,8 +8,7 @@ define i32 @simple() { ; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4 ; CHECK-NEXT: store i32 0, ptr [[A]], align 4 ; CHECK-NEXT: call void @callee(ptr [[A]]) -; CHECK-NEXT: [[L1:%.*]] = load i32, ptr [[A]], align 4 -; CHECK-NEXT: ret i32 [[L1]] +; CHECK-NEXT: ret i32 0 ; %a = alloca i32 store i32 0, ptr %a @@ -40,9 +39,7 @@ define i32 @twoalloc() { ; CHECK-NEXT: [[B:%.*]] = getelementptr i32, ptr [[A]], i32 1 ; CHECK-NEXT: store i32 1, ptr [[B]], align 4 ; CHECK-NEXT: call void @callee(ptr [[A]]) -; CHECK-NEXT: [[L1:%.*]] = load i32, ptr [[A]], align 4 -; CHECK-NEXT: [[L2:%.*]] = load i32, ptr [[B]], align 4 -; CHECK-NEXT: [[R:%.*]] = add i32 [[L1]], [[L2]] +; CHECK-NEXT: [[R:%.*]] = add i32 0, 1 ; CHECK-NEXT: ret i32 [[R]] ; %a = alloca {i32, i32} @@ -62,8 +59,7 @@ define i32 @twostore() { ; CHECK-NEXT: store i32 1, ptr [[A]], align 4 ; CHECK-NEXT: call void @callee(ptr [[A]]) ; CHECK-NEXT: store i32 2, ptr [[A]], align 4 -; CHECK-NEXT: [[L:%.*]] = load i32, ptr [[A]], align 4 -; CHECK-NEXT: ret i32 [[L]] +; CHECK-NEXT: ret i32 2 ; %a = alloca i32 store i32 1, ptr %a @@ -116,10 +112,8 @@ define i32 @twocalls() { ; CHECK-NEXT: [[B:%.*]] = getelementptr i32, ptr [[A]], i32 1 ; CHECK-NEXT: store i32 1, ptr [[B]], align 4 ; CHECK-NEXT: call void @callee(ptr [[A]]) -; CHECK-NEXT: [[L1:%.*]] = load i32, ptr [[A]], align 4 ; CHECK-NEXT: call void @callee(ptr [[A]]) -; CHECK-NEXT: [[L2:%.*]] = load i32, ptr [[B]], align 4 -; CHECK-NEXT: [[R:%.*]] = add i32 [[L1]], [[L2]] +; CHECK-NEXT: [[R:%.*]] = add i32 0, 1 ; CHECK-NEXT: ret i32 [[R]] ; %a = alloca {i32, i32} @@ -165,8 +159,7 @@ define i32 @atomic() { ; CHECK-NEXT: store i32 1, ptr [[B]], align 4 ; CHECK-NEXT: call void @callee(ptr [[A]]) ; CHECK-NEXT: [[L1:%.*]] = load atomic i32, ptr [[A]] seq_cst, align 4 -; CHECK-NEXT: [[L2:%.*]] = load i32, ptr [[B]], align 4 -; CHECK-NEXT: [[R:%.*]] = add i32 [[L1]], [[L2]] +; CHECK-NEXT: [[R:%.*]] = add i32 [[L1]], 1 ; CHECK-NEXT: ret i32 [[R]] ; %a = alloca {i32, i32} @@ -184,12 +177,10 @@ define i32 @notdominating() { ; CHECK-LABEL: @notdominating( ; CHECK-NEXT: [[A:%.*]] = alloca { i32, i32 }, align 8 ; CHECK-NEXT: [[B:%.*]] = getelementptr i32, ptr [[A]], i32 1 -; CHECK-NEXT: [[L1:%.*]] = load i32, ptr [[A]], align 4 -; CHECK-NEXT: [[L2:%.*]] = load i32, ptr [[B]], align 4 ; CHECK-NEXT: store i32 0, ptr [[A]], align 4 ; CHECK-NEXT: store i32 1, ptr [[B]], align 4 ; CHECK-NEXT: call void @callee(ptr [[A]]) -; CHECK-NEXT: [[R:%.*]] = add i32 [[L1]], [[L2]] +; CHECK-NEXT: [[R:%.*]] = add i32 undef, undef ; CHECK-NEXT: ret i32 [[R]] ; %a = alloca {i32, i32} @@ -235,9 +226,7 @@ define i32 @multiuse() { ; CHECK-NEXT: [[B:%.*]] = getelementptr i32, ptr [[A]], i32 1 ; CHECK-NEXT: store i32 1, ptr [[B]], align 4 ; CHECK-NEXT: call void @callee_multiuse(ptr [[A]], ptr [[A]]) -; CHECK-NEXT: [[L1:%.*]] = load i32, ptr [[A]], align 4 -; CHECK-NEXT: [[L2:%.*]] = load i32, ptr [[B]], align 4 -; CHECK-NEXT: [[R:%.*]] = add i32 [[L1]], [[L2]] +; CHECK-NEXT: [[R:%.*]] = add i32 0, 1 ; CHECK-NEXT: ret i32 [[R]] ; %a = alloca {i32, i32} @@ -296,8 +285,7 @@ define void @incompletestruct(i1 %b, i1 %c) { ; CHECK-NEXT: entry: ; CHECK-NEXT: [[LII:%.*]] = alloca [[STRUCT_LOADIMMEDIATEINFO:%.*]], align 4 ; CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 4, ptr nonnull [[LII]]) -; CHECK-NEXT: [[BF_LOAD:%.*]] = load i32, ptr [[LII]], align 4 -; CHECK-NEXT: [[BF_CLEAR4:%.*]] = and i32 [[BF_LOAD]], -262144 +; CHECK-NEXT: [[BF_CLEAR4:%.*]] = and i32 undef, -262144 ; CHECK-NEXT: [[BF_SET5:%.*]] = select i1 [[B:%.*]], i32 196608, i32 131072 ; CHECK-NEXT: [[BF_SET12:%.*]] = or disjoint i32 [[BF_SET5]], [[BF_CLEAR4]] ; CHECK-NEXT: store i32 [[BF_SET12]], ptr [[LII]], align 4 @@ -325,8 +313,7 @@ define void @incompletestruct_bb(i1 %b, i1 %c) { ; CHECK-NEXT: br i1 [[C:%.*]], label [[IF_THEN:%.*]], label [[IF_END:%.*]] ; CHECK: if.then: ; CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 4, ptr nonnull [[LII]]) -; CHECK-NEXT: [[BF_LOAD:%.*]] = load i32, ptr [[LII]], align 4 -; CHECK-NEXT: [[BF_CLEAR4:%.*]] = and i32 [[BF_LOAD]], -262144 +; CHECK-NEXT: [[BF_CLEAR4:%.*]] = and i32 undef, -262144 ; CHECK-NEXT: [[BF_SET5:%.*]] = select i1 [[B:%.*]], i32 196608, i32 131072 ; CHECK-NEXT: [[BF_SET12:%.*]] = or disjoint i32 [[BF_SET5]], [[BF_CLEAR4]] ; CHECK-NEXT: store i32 [[BF_SET12]], ptr [[LII]], align 4 @@ -355,4 +342,37 @@ if.end: ; preds = %if.then, %entry ret void } +define i32 @sixteenload() { +; CHECK-LABEL: @sixteenload( +; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4 +; CHECK-NEXT: store i32 0, ptr [[A]], align 4 +; CHECK-NEXT: call void @callee(ptr [[A]]) +; CHECK-NEXT: [[A1:%.*]] = add i32 0, 0 +; CHECK-NEXT: [[A2:%.*]] = add i32 [[A1]], 0 +; CHECK-NEXT: ret i32 [[A2]] +; + %a = alloca i32 + store i32 0, ptr %a + call void @callee(ptr %a) + %l1 = load i32, ptr %a + %l2 = load i32, ptr %a + %l3 = load i32, ptr %a + %l4 = load i32, ptr %a + %l5 = load i32, ptr %a + %l6 = load i32, ptr %a + %l7 = load i32, ptr %a + %l8 = load i32, ptr %a + %l9 = load i32, ptr %a + %l10 = load i32, ptr %a + %l11 = load i32, ptr %a + %l12 = load i32, ptr %a + %l13 = load i32, ptr %a + %l14 = load i32, ptr %a + %l15 = load i32, ptr %a + %l16 = load i32, ptr %a + %a1 = add i32 %l1, %l2 + %a2 = add i32 %a1, %l3 + ret i32 %a2 +} + declare void @llvm.memcpy.p0.p0.i64(ptr, ptr, i64, i1) diff --git a/llvm/test/Transforms/VectorCombine/AMDGPU/as-transition.ll b/llvm/test/Transforms/VectorCombine/AMDGPU/as-transition.ll index 94b8c98a80df..83a0490b42a7 100644 --- a/llvm/test/Transforms/VectorCombine/AMDGPU/as-transition.ll +++ b/llvm/test/Transforms/VectorCombine/AMDGPU/as-transition.ll @@ -12,8 +12,8 @@ define protected amdgpu_kernel void @load_from_other_as(ptr nocapture nonnull %r ; CHECK-NEXT: bb: ; CHECK-NEXT: [[A:%.*]] = alloca [[STRUCT_HOGE:%.*]], align 4, addrspace(5) ; CHECK-NEXT: [[TMP0:%.*]] = addrspacecast ptr addrspace(5) [[A]] to ptr -; CHECK-NEXT: [[TMP1:%.*]] = load <1 x float>, ptr [[TMP0]], align 4 -; CHECK-NEXT: [[E:%.*]] = shufflevector <1 x float> [[TMP1]], <1 x float> poison, <4 x i32> <i32 0, i32 poison, i32 poison, i32 poison> +; CHECK-NEXT: [[D:%.*]] = load float, ptr [[TMP0]], align 4 +; CHECK-NEXT: [[E:%.*]] = insertelement <4 x float> undef, float [[D]], i32 0 ; CHECK-NEXT: store <4 x float> [[E]], ptr [[RESULTPTR:%.*]], align 16 ; CHECK-NEXT: ret void ; diff --git a/llvm/test/Transforms/VectorCombine/X86/load.ll b/llvm/test/Transforms/VectorCombine/X86/load.ll index bdd05a1a37c7..b12104c5c673 100644 --- a/llvm/test/Transforms/VectorCombine/X86/load.ll +++ b/llvm/test/Transforms/VectorCombine/X86/load.ll @@ -158,8 +158,8 @@ define double @larger_fp_scalar_256bit_vec(ptr align 32 dereferenceable(32) %p) define <4 x float> @load_f32_insert_v4f32(ptr align 16 dereferenceable(16) %p) nofree nosync { ; CHECK-LABEL: @load_f32_insert_v4f32( -; CHECK-NEXT: [[TMP1:%.*]] = load <4 x float>, ptr [[P:%.*]], align 16 -; CHECK-NEXT: [[R:%.*]] = shufflevector <4 x float> [[TMP1]], <4 x float> poison, <4 x i32> <i32 0, i32 poison, i32 poison, i32 poison> +; CHECK-NEXT: [[S:%.*]] = load float, ptr [[P:%.*]], align 4 +; CHECK-NEXT: [[R:%.*]] = insertelement <4 x float> undef, float [[S]], i32 0 ; CHECK-NEXT: ret <4 x float> [[R]] ; %s = load float, ptr %p, align 4 @@ -169,8 +169,8 @@ define <4 x float> @load_f32_insert_v4f32(ptr align 16 dereferenceable(16) %p) n define <4 x float> @casted_load_f32_insert_v4f32(ptr align 4 dereferenceable(16) %p) nofree nosync { ; CHECK-LABEL: @casted_load_f32_insert_v4f32( -; CHECK-NEXT: [[TMP1:%.*]] = load <4 x float>, ptr [[P:%.*]], align 4 -; CHECK-NEXT: [[R:%.*]] = shufflevector <4 x float> [[TMP1]], <4 x float> poison, <4 x i32> <i32 0, i32 poison, i32 poison, i32 poison> +; CHECK-NEXT: [[S:%.*]] = load float, ptr [[P:%.*]], align 4 +; CHECK-NEXT: [[R:%.*]] = insertelement <4 x float> undef, float [[S]], i32 0 ; CHECK-NEXT: ret <4 x float> [[R]] ; %s = load float, ptr %p, align 4 @@ -182,8 +182,8 @@ define <4 x float> @casted_load_f32_insert_v4f32(ptr align 4 dereferenceable(16) define <4 x i32> @load_i32_insert_v4i32(ptr align 16 dereferenceable(16) %p) nofree nosync { ; CHECK-LABEL: @load_i32_insert_v4i32( -; CHECK-NEXT: [[TMP1:%.*]] = load <4 x i32>, ptr [[P:%.*]], align 16 -; CHECK-NEXT: [[R:%.*]] = shufflevector <4 x i32> [[TMP1]], <4 x i32> poison, <4 x i32> <i32 0, i32 poison, i32 poison, i32 poison> +; CHECK-NEXT: [[S:%.*]] = load i32, ptr [[P:%.*]], align 4 +; CHECK-NEXT: [[R:%.*]] = insertelement <4 x i32> undef, i32 [[S]], i32 0 ; CHECK-NEXT: ret <4 x i32> [[R]] ; %s = load i32, ptr %p, align 4 @@ -195,8 +195,8 @@ define <4 x i32> @load_i32_insert_v4i32(ptr align 16 dereferenceable(16) %p) nof define <4 x i32> @casted_load_i32_insert_v4i32(ptr align 4 dereferenceable(16) %p) nofree nosync { ; CHECK-LABEL: @casted_load_i32_insert_v4i32( -; CHECK-NEXT: [[TMP1:%.*]] = load <4 x i32>, ptr [[P:%.*]], align 4 -; CHECK-NEXT: [[R:%.*]] = shufflevector <4 x i32> [[TMP1]], <4 x i32> poison, <4 x i32> <i32 0, i32 poison, i32 poison, i32 poison> +; CHECK-NEXT: [[S:%.*]] = load i32, ptr [[P:%.*]], align 4 +; CHECK-NEXT: [[R:%.*]] = insertelement <4 x i32> undef, i32 [[S]], i32 0 ; CHECK-NEXT: ret <4 x i32> [[R]] ; %s = load i32, ptr %p, align 4 @@ -208,8 +208,8 @@ define <4 x i32> @casted_load_i32_insert_v4i32(ptr align 4 dereferenceable(16) % define <4 x float> @gep00_load_f32_insert_v4f32(ptr align 16 dereferenceable(16) %p) nofree nosync { ; CHECK-LABEL: @gep00_load_f32_insert_v4f32( -; CHECK-NEXT: [[TMP1:%.*]] = load <4 x float>, ptr [[P:%.*]], align 16 -; CHECK-NEXT: [[R:%.*]] = shufflevector <4 x float> [[TMP1]], <4 x float> poison, <4 x i32> <i32 0, i32 poison, i32 poison, i32 poison> +; CHECK-NEXT: [[S:%.*]] = load float, ptr [[P:%.*]], align 16 +; CHECK-NEXT: [[R:%.*]] = insertelement <4 x float> undef, float [[S]], i64 0 ; CHECK-NEXT: ret <4 x float> [[R]] ; %s = load float, ptr %p, align 16 @@ -221,8 +221,8 @@ define <4 x float> @gep00_load_f32_insert_v4f32(ptr align 16 dereferenceable(16) define <4 x float> @gep00_load_f32_insert_v4f32_addrspace(ptr addrspace(44) align 16 dereferenceable(16) %p) nofree nosync { ; CHECK-LABEL: @gep00_load_f32_insert_v4f32_addrspace( -; CHECK-NEXT: [[TMP1:%.*]] = load <4 x float>, ptr addrspace(44) [[P:%.*]], align 16 -; CHECK-NEXT: [[R:%.*]] = shufflevector <4 x float> [[TMP1]], <4 x float> poison, <4 x i32> <i32 0, i32 poison, i32 poison, i32 poison> +; CHECK-NEXT: [[S:%.*]] = load float, ptr addrspace(44) [[P:%.*]], align 16 +; CHECK-NEXT: [[R:%.*]] = insertelement <4 x float> undef, float [[S]], i64 0 ; CHECK-NEXT: ret <4 x float> [[R]] ; %s = load float, ptr addrspace(44) %p, align 16 @@ -235,8 +235,8 @@ define <4 x float> @gep00_load_f32_insert_v4f32_addrspace(ptr addrspace(44) alig define <8 x i16> @gep01_load_i16_insert_v8i16(ptr align 16 dereferenceable(18) %p) nofree nosync { ; CHECK-LABEL: @gep01_load_i16_insert_v8i16( ; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds <8 x i16>, ptr [[P:%.*]], i64 0, i64 1 -; CHECK-NEXT: [[TMP1:%.*]] = load <8 x i16>, ptr [[GEP]], align 2 -; CHECK-NEXT: [[R:%.*]] = shufflevector <8 x i16> [[TMP1]], <8 x i16> poison, <8 x i32> <i32 0, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison> +; CHECK-NEXT: [[S:%.*]] = load i16, ptr [[GEP]], align 2 +; CHECK-NEXT: [[R:%.*]] = insertelement <8 x i16> undef, i16 [[S]], i64 0 ; CHECK-NEXT: ret <8 x i16> [[R]] ; %gep = getelementptr inbounds <8 x i16>, ptr %p, i64 0, i64 1 @@ -248,16 +248,11 @@ define <8 x i16> @gep01_load_i16_insert_v8i16(ptr align 16 dereferenceable(18) % ; Can't safely load the offset vector, but can load+shuffle if it is profitable. define <8 x i16> @gep01_load_i16_insert_v8i16_deref(ptr align 16 dereferenceable(17) %p) nofree nosync { -; SSE2-LABEL: @gep01_load_i16_insert_v8i16_deref( -; SSE2-NEXT: [[GEP:%.*]] = getelementptr inbounds <8 x i16>, ptr [[P:%.*]], i64 0, i64 1 -; SSE2-NEXT: [[S:%.*]] = load i16, ptr [[GEP]], align 2 -; SSE2-NEXT: [[R:%.*]] = insertelement <8 x i16> undef, i16 [[S]], i64 0 -; SSE2-NEXT: ret <8 x i16> [[R]] -; -; AVX2-LABEL: @gep01_load_i16_insert_v8i16_deref( -; AVX2-NEXT: [[TMP1:%.*]] = load <8 x i16>, ptr [[P:%.*]], align 16 -; AVX2-NEXT: [[R:%.*]] = shufflevector <8 x i16> [[TMP1]], <8 x i16> poison, <8 x i32> <i32 1, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison> -; AVX2-NEXT: ret <8 x i16> [[R]] +; CHECK-LABEL: @gep01_load_i16_insert_v8i16_deref( +; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds <8 x i16>, ptr [[P:%.*]], i64 0, i64 1 +; CHECK-NEXT: [[S:%.*]] = load i16, ptr [[GEP]], align 2 +; CHECK-NEXT: [[R:%.*]] = insertelement <8 x i16> undef, i16 [[S]], i64 0 +; CHECK-NEXT: ret <8 x i16> [[R]] ; %gep = getelementptr inbounds <8 x i16>, ptr %p, i64 0, i64 1 %s = load i16, ptr %gep, align 2 @@ -268,16 +263,11 @@ define <8 x i16> @gep01_load_i16_insert_v8i16_deref(ptr align 16 dereferenceable ; Verify that alignment of the new load is not over-specified. define <8 x i16> @gep01_load_i16_insert_v8i16_deref_minalign(ptr align 2 dereferenceable(16) %p) nofree nosync { -; SSE2-LABEL: @gep01_load_i16_insert_v8i16_deref_minalign( -; SSE2-NEXT: [[GEP:%.*]] = getelementptr inbounds <8 x i16>, ptr [[P:%.*]], i64 0, i64 1 -; SSE2-NEXT: [[S:%.*]] = load i16, ptr [[GEP]], align 8 -; SSE2-NEXT: [[R:%.*]] = insertelement <8 x i16> undef, i16 [[S]], i64 0 -; SSE2-NEXT: ret <8 x i16> [[R]] -; -; AVX2-LABEL: @gep01_load_i16_insert_v8i16_deref_minalign( -; AVX2-NEXT: [[TMP1:%.*]] = load <8 x i16>, ptr [[P:%.*]], align 2 -; AVX2-NEXT: [[R:%.*]] = shufflevector <8 x i16> [[TMP1]], <8 x i16> poison, <8 x i32> <i32 1, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison> -; AVX2-NEXT: ret <8 x i16> [[R]] +; CHECK-LABEL: @gep01_load_i16_insert_v8i16_deref_minalign( +; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds <8 x i16>, ptr [[P:%.*]], i64 0, i64 1 +; CHECK-NEXT: [[S:%.*]] = load i16, ptr [[GEP]], align 8 +; CHECK-NEXT: [[R:%.*]] = insertelement <8 x i16> undef, i16 [[S]], i64 0 +; CHECK-NEXT: ret <8 x i16> [[R]] ; %gep = getelementptr inbounds <8 x i16>, ptr %p, i64 0, i64 1 %s = load i16, ptr %gep, align 8 @@ -304,8 +294,9 @@ define <4 x i32> @gep01_bitcast_load_i32_insert_v4i32(ptr align 1 dereferenceabl define <4 x i32> @gep012_bitcast_load_i32_insert_v4i32(ptr align 1 dereferenceable(20) %p) nofree nosync { ; CHECK-LABEL: @gep012_bitcast_load_i32_insert_v4i32( -; CHECK-NEXT: [[TMP1:%.*]] = load <4 x i32>, ptr [[P:%.*]], align 1 -; CHECK-NEXT: [[R:%.*]] = shufflevector <4 x i32> [[TMP1]], <4 x i32> poison, <4 x i32> <i32 3, i32 poison, i32 poison, i32 poison> +; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds <16 x i8>, ptr [[P:%.*]], i64 0, i64 12 +; CHECK-NEXT: [[S:%.*]] = load i32, ptr [[GEP]], align 1 +; CHECK-NEXT: [[R:%.*]] = insertelement <4 x i32> undef, i32 [[S]], i64 0 ; CHECK-NEXT: ret <4 x i32> [[R]] ; %gep = getelementptr inbounds <16 x i8>, ptr %p, i64 0, i64 12 @@ -336,8 +327,8 @@ define <4 x i32> @gep013_bitcast_load_i32_insert_v4i32(ptr align 1 dereferenceab define <8 x i16> @gep10_load_i16_insert_v8i16(ptr align 16 dereferenceable(32) %p) nofree nosync { ; CHECK-LABEL: @gep10_load_i16_insert_v8i16( ; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds <8 x i16>, ptr [[P:%.*]], i64 1, i64 0 -; CHECK-NEXT: [[TMP1:%.*]] = load <8 x i16>, ptr [[GEP]], align 16 -; CHECK-NEXT: [[R:%.*]] = shufflevector <8 x i16> [[TMP1]], <8 x i16> poison, <8 x i32> <i32 0, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison> +; CHECK-NEXT: [[S:%.*]] = load i16, ptr [[GEP]], align 16 +; CHECK-NEXT: [[R:%.*]] = insertelement <8 x i16> undef, i16 [[S]], i64 0 ; CHECK-NEXT: ret <8 x i16> [[R]] ; %gep = getelementptr inbounds <8 x i16>, ptr %p, i64 1, i64 0 @@ -439,8 +430,8 @@ define <4 x float> @load_f32_insert_v4f32_volatile(ptr align 16 dereferenceable( define <4 x float> @load_f32_insert_v4f32_align(ptr align 1 dereferenceable(16) %p) nofree nosync { ; CHECK-LABEL: @load_f32_insert_v4f32_align( -; CHECK-NEXT: [[TMP1:%.*]] = load <4 x float>, ptr [[P:%.*]], align 4 -; CHECK-NEXT: [[R:%.*]] = shufflevector <4 x float> [[TMP1]], <4 x float> poison, <4 x i32> <i32 0, i32 poison, i32 poison, i32 poison> +; CHECK-NEXT: [[S:%.*]] = load float, ptr [[P:%.*]], align 4 +; CHECK-NEXT: [[R:%.*]] = insertelement <4 x float> undef, float [[S]], i32 0 ; CHECK-NEXT: ret <4 x float> [[R]] ; %s = load float, ptr %p, align 4 @@ -463,8 +454,8 @@ define <4 x float> @load_f32_insert_v4f32_deref(ptr align 4 dereferenceable(15) define <8 x i32> @load_i32_insert_v8i32(ptr align 16 dereferenceable(16) %p) nofree nosync { ; CHECK-LABEL: @load_i32_insert_v8i32( -; CHECK-NEXT: [[TMP1:%.*]] = load <4 x i32>, ptr [[P:%.*]], align 16 -; CHECK-NEXT: [[R:%.*]] = shufflevector <4 x i32> [[TMP1]], <4 x i32> poison, <8 x i32> <i32 0, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison> +; CHECK-NEXT: [[S:%.*]] = load i32, ptr [[P:%.*]], align 4 +; CHECK-NEXT: [[R:%.*]] = insertelement <8 x i32> undef, i32 [[S]], i32 0 ; CHECK-NEXT: ret <8 x i32> [[R]] ; %s = load i32, ptr %p, align 4 @@ -474,8 +465,8 @@ define <8 x i32> @load_i32_insert_v8i32(ptr align 16 dereferenceable(16) %p) nof define <8 x i32> @casted_load_i32_insert_v8i32(ptr align 4 dereferenceable(16) %p) nofree nosync { ; CHECK-LABEL: @casted_load_i32_insert_v8i32( -; CHECK-NEXT: [[TMP1:%.*]] = load <4 x i32>, ptr [[P:%.*]], align 4 -; CHECK-NEXT: [[R:%.*]] = shufflevector <4 x i32> [[TMP1]], <4 x i32> poison, <8 x i32> <i32 0, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison> +; CHECK-NEXT: [[S:%.*]] = load i32, ptr [[P:%.*]], align 4 +; CHECK-NEXT: [[R:%.*]] = insertelement <8 x i32> undef, i32 [[S]], i32 0 ; CHECK-NEXT: ret <8 x i32> [[R]] ; %s = load i32, ptr %p, align 4 @@ -485,8 +476,8 @@ define <8 x i32> @casted_load_i32_insert_v8i32(ptr align 4 dereferenceable(16) % define <16 x float> @load_f32_insert_v16f32(ptr align 16 dereferenceable(16) %p) nofree nosync { ; CHECK-LABEL: @load_f32_insert_v16f32( -; CHECK-NEXT: [[TMP1:%.*]] = load <4 x float>, ptr [[P:%.*]], align 16 -; CHECK-NEXT: [[R:%.*]] = shufflevector <4 x float> [[TMP1]], <4 x float> poison, <16 x i32> <i32 0, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison> +; CHECK-NEXT: [[S:%.*]] = load float, ptr [[P:%.*]], align 4 +; CHECK-NEXT: [[R:%.*]] = insertelement <16 x float> undef, float [[S]], i32 0 ; CHECK-NEXT: ret <16 x float> [[R]] ; %s = load float, ptr %p, align 4 @@ -496,8 +487,8 @@ define <16 x float> @load_f32_insert_v16f32(ptr align 16 dereferenceable(16) %p) define <2 x float> @load_f32_insert_v2f32(ptr align 16 dereferenceable(16) %p) nofree nosync { ; CHECK-LABEL: @load_f32_insert_v2f32( -; CHECK-NEXT: [[TMP1:%.*]] = load <4 x float>, ptr [[P:%.*]], align 16 -; CHECK-NEXT: [[R:%.*]] = shufflevector <4 x float> [[TMP1]], <4 x float> poison, <2 x i32> <i32 0, i32 poison> +; CHECK-NEXT: [[S:%.*]] = load float, ptr [[P:%.*]], align 4 +; CHECK-NEXT: [[R:%.*]] = insertelement <2 x float> undef, float [[S]], i32 0 ; CHECK-NEXT: ret <2 x float> [[R]] ; %s = load float, ptr %p, align 4 @@ -549,8 +540,9 @@ define void @PR47558_multiple_use_load(ptr nocapture nonnull %resultptr, ptr noc define <4 x float> @load_v2f32_extract_insert_v4f32(ptr align 16 dereferenceable(16) %p) nofree nosync { ; CHECK-LABEL: @load_v2f32_extract_insert_v4f32( -; CHECK-NEXT: [[TMP1:%.*]] = load <4 x float>, ptr [[P:%.*]], align 16 -; CHECK-NEXT: [[R:%.*]] = shufflevector <4 x float> [[TMP1]], <4 x float> poison, <4 x i32> <i32 0, i32 poison, i32 poison, i32 poison> +; CHECK-NEXT: [[L:%.*]] = load <2 x float>, ptr [[P:%.*]], align 4 +; CHECK-NEXT: [[S:%.*]] = extractelement <2 x float> [[L]], i32 0 +; CHECK-NEXT: [[R:%.*]] = insertelement <4 x float> undef, float [[S]], i32 0 ; CHECK-NEXT: ret <4 x float> [[R]] ; %l = load <2 x float>, ptr %p, align 4 @@ -560,10 +552,17 @@ define <4 x float> @load_v2f32_extract_insert_v4f32(ptr align 16 dereferenceable } define <4 x float> @load_v8f32_extract_insert_v4f32(ptr align 16 dereferenceable(16) %p) nofree nosync { -; CHECK-LABEL: @load_v8f32_extract_insert_v4f32( -; CHECK-NEXT: [[TMP1:%.*]] = load <4 x float>, ptr [[P:%.*]], align 16 -; CHECK-NEXT: [[R:%.*]] = shufflevector <4 x float> [[TMP1]], <4 x float> poison, <4 x i32> <i32 0, i32 poison, i32 poison, i32 poison> -; CHECK-NEXT: ret <4 x float> [[R]] +; SSE2-LABEL: @load_v8f32_extract_insert_v4f32( +; SSE2-NEXT: [[TMP1:%.*]] = getelementptr inbounds <8 x float>, ptr [[P:%.*]], i32 0, i32 0 +; SSE2-NEXT: [[S:%.*]] = load float, ptr [[TMP1]], align 4 +; SSE2-NEXT: [[R:%.*]] = insertelement <4 x float> undef, float [[S]], i32 0 +; SSE2-NEXT: ret <4 x float> [[R]] +; +; AVX2-LABEL: @load_v8f32_extract_insert_v4f32( +; AVX2-NEXT: [[L:%.*]] = load <8 x float>, ptr [[P:%.*]], align 4 +; AVX2-NEXT: [[S:%.*]] = extractelement <8 x float> [[L]], i32 0 +; AVX2-NEXT: [[R:%.*]] = insertelement <4 x float> undef, float [[S]], i32 0 +; AVX2-NEXT: ret <4 x float> [[R]] ; %l = load <8 x float>, ptr %p, align 4 %s = extractelement <8 x float> %l, i32 0 @@ -589,17 +588,12 @@ define <8 x i32> @load_v1i32_extract_insert_v8i32_extra_use(ptr align 16 derefer ; Can't safely load the offset vector, but can load+shuffle if it is profitable. define <8 x i16> @gep1_load_v2i16_extract_insert_v8i16(ptr align 1 dereferenceable(16) %p) nofree nosync { -; SSE2-LABEL: @gep1_load_v2i16_extract_insert_v8i16( -; SSE2-NEXT: [[GEP:%.*]] = getelementptr inbounds <2 x i16>, ptr [[P:%.*]], i64 1 -; SSE2-NEXT: [[TMP1:%.*]] = getelementptr inbounds <2 x i16>, ptr [[GEP]], i32 0, i32 0 -; SSE2-NEXT: [[S:%.*]] = load i16, ptr [[TMP1]], align 8 -; SSE2-NEXT: [[R:%.*]] = insertelement <8 x i16> undef, i16 [[S]], i64 0 -; SSE2-NEXT: ret <8 x i16> [[R]] -; -; AVX2-LABEL: @gep1_load_v2i16_extract_insert_v8i16( -; AVX2-NEXT: [[TMP1:%.*]] = load <8 x i16>, ptr [[P:%.*]], align 4 -; AVX2-NEXT: [[R:%.*]] = shufflevector <8 x i16> [[TMP1]], <8 x i16> poison, <8 x i32> <i32 2, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison> -; AVX2-NEXT: ret <8 x i16> [[R]] +; CHECK-LABEL: @gep1_load_v2i16_extract_insert_v8i16( +; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds <2 x i16>, ptr [[P:%.*]], i64 1 +; CHECK-NEXT: [[TMP1:%.*]] = getelementptr inbounds <2 x i16>, ptr [[GEP]], i32 0, i32 0 +; CHECK-NEXT: [[S:%.*]] = load i16, ptr [[TMP1]], align 8 +; CHECK-NEXT: [[R:%.*]] = insertelement <8 x i16> undef, i16 [[S]], i64 0 +; CHECK-NEXT: ret <8 x i16> [[R]] ; %gep = getelementptr inbounds <2 x i16>, ptr %p, i64 1 %l = load <2 x i16>, ptr %gep, align 8 diff --git a/llvm/test/tools/llvm-gsymutil/ARM_AArch64/macho-gsym-merged-callsites-dsym.yaml b/llvm/test/tools/llvm-gsymutil/ARM_AArch64/macho-gsym-merged-callsites-dsym.yaml index a98d4db0a791..caf77467bbb9 100644 --- a/llvm/test/tools/llvm-gsymutil/ARM_AArch64/macho-gsym-merged-callsites-dsym.yaml +++ b/llvm/test/tools/llvm-gsymutil/ARM_AArch64/macho-gsym-merged-callsites-dsym.yaml @@ -1,3 +1,7 @@ +# FIXME: Currently disabled as it fails on some Linux hosts +# UNSUPPORTED: true + + ## Test that reconstructs a dSYM file from YAML and generates a gsym from it. The gsym has callsite info and merged functions. # RUN: split-file %s %t diff --git a/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp b/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp index 10f6590e9c7a..31bf9a98943e 100644 --- a/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp +++ b/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp @@ -2463,20 +2463,16 @@ bool TreePatternNode::ApplyTypeConstraints(TreePattern &TP, bool NotRegisters) { // Can only check for types of a known size if (VT == MVT::iPTR) continue; - unsigned Size = MVT(VT).getFixedSizeInBits(); - // Make sure that the value is representable for this type. - if (Size >= 32) - continue; + // Check that the value doesn't use more bits than we have. It must // either be a sign- or zero-extended equivalent of the original. - int64_t SignBitAndAbove = II->getValue() >> (Size - 1); - if (SignBitAndAbove == -1 || SignBitAndAbove == 0 || - SignBitAndAbove == 1) - continue; - - TP.error("Integer value '" + Twine(II->getValue()) + - "' is out of range for type '" + getEnumName(VT) + "'!"); - break; + unsigned Width = MVT(VT).getFixedSizeInBits(); + int64_t Val = II->getValue(); + if (!isIntN(Width, Val) && !isUIntN(Width, Val)) { + TP.error("Integer value '" + Twine(Val) + + "' is out of range for type '" + getEnumName(VT) + "'!"); + break; + } } return MadeChange; } diff --git a/llvm/utils/gn/secondary/libcxx/include/BUILD.gn b/llvm/utils/gn/secondary/libcxx/include/BUILD.gn index 2d5ea2709923..4b07468187a5 100644 --- a/llvm/utils/gn/secondary/libcxx/include/BUILD.gn +++ b/llvm/utils/gn/secondary/libcxx/include/BUILD.gn @@ -653,6 +653,16 @@ if (current_toolchain == default_toolchain) { "__mutex/once_flag.h", "__mutex/tag_types.h", "__mutex/unique_lock.h", + "__new/align_val_t.h", + "__new/allocate.h", + "__new/destroying_delete_t.h", + "__new/exceptions.h", + "__new/global_new_delete.h", + "__new/interference_size.h", + "__new/launder.h", + "__new/new_handler.h", + "__new/nothrow_t.h", + "__new/placement_new_delete.h", "__node_handle", "__numeric/accumulate.h", "__numeric/adjacent_difference.h", diff --git a/llvm/utils/gn/secondary/lldb/source/Plugins/Process/Utility/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Plugins/Process/Utility/BUILD.gn index bd009c966d64..42402565d6fa 100644 --- a/llvm/utils/gn/secondary/lldb/source/Plugins/Process/Utility/BUILD.gn +++ b/llvm/utils/gn/secondary/lldb/source/Plugins/Process/Utility/BUILD.gn @@ -31,6 +31,7 @@ static_library("Utility") { "NativeProcessSoftwareSingleStep.cpp", "NativeRegisterContextDBReg.cpp", "NativeRegisterContextDBReg_arm64.cpp", + "NativeRegisterContextDBReg_loongarch.cpp", "NativeRegisterContextDBReg_x86.cpp", "NativeRegisterContextRegisterInfo.cpp", "NetBSDSignals.cpp", diff --git a/mlir/include/mlir/Analysis/DataFlow/SparseAnalysis.h b/mlir/include/mlir/Analysis/DataFlow/SparseAnalysis.h index dce7ab3bb5ee..507087d5575e 100644 --- a/mlir/include/mlir/Analysis/DataFlow/SparseAnalysis.h +++ b/mlir/include/mlir/Analysis/DataFlow/SparseAnalysis.h @@ -87,7 +87,7 @@ public: using AbstractSparseLattice::AbstractSparseLattice; /// Return the value this lattice is located at. - Value getAnchor() const { return anchor.get<Value>(); } + Value getAnchor() const { return cast<Value>(anchor); } /// Return the value held by this lattice. This requires that the value is /// initialized. diff --git a/mlir/include/mlir/Dialect/SCF/IR/SCFOps.td b/mlir/include/mlir/Dialect/SCF/IR/SCFOps.td index 361f8e0cf79e..23c597a1ca51 100644 --- a/mlir/include/mlir/Dialect/SCF/IR/SCFOps.td +++ b/mlir/include/mlir/Dialect/SCF/IR/SCFOps.td @@ -153,9 +153,10 @@ def ForOp : SCF_Op<"for", operation defines an SSA value for its induction variable. It has one region capturing the loop body. The induction variable is represented as an argument of this region. This SSA value is a signless integer or index. - The step is a value of same type but required to be positive. The lower and - upper bounds specify a half-open range: the range includes the lower bound - but does not include the upper bound. + The step is a value of same type but required to be positive, the lower and + upper bounds can be also negative or zero. The lower and upper bounds specify + a half-open range: the iteration is executed iff the signed comparison of induction + variable value is less than the upper bound and bigger or equal to the lower bound. The body region must contain exactly one block that terminates with `scf.yield`. Calling ForOp::build will create such a region and insert diff --git a/mlir/lib/Analysis/DataFlow/ConstantPropagationAnalysis.cpp b/mlir/lib/Analysis/DataFlow/ConstantPropagationAnalysis.cpp index 56529acd71bb..51fa7739e193 100644 --- a/mlir/lib/Analysis/DataFlow/ConstantPropagationAnalysis.cpp +++ b/mlir/lib/Analysis/DataFlow/ConstantPropagationAnalysis.cpp @@ -103,9 +103,9 @@ LogicalResult SparseConstantPropagation::visitOperation( lattice->join(ConstantValue(attr, op->getDialect()))); } else { LLVM_DEBUG(llvm::dbgs() - << "Folded to value: " << foldResult.get<Value>() << "\n"); + << "Folded to value: " << cast<Value>(foldResult) << "\n"); AbstractSparseForwardDataFlowAnalysis::join( - lattice, *getLatticeElement(foldResult.get<Value>())); + lattice, *getLatticeElement(cast<Value>(foldResult))); } } return success(); diff --git a/mlir/lib/Analysis/DataFlow/IntegerRangeAnalysis.cpp b/mlir/lib/Analysis/DataFlow/IntegerRangeAnalysis.cpp index a97e43708d9a..9e9411e5ede1 100644 --- a/mlir/lib/Analysis/DataFlow/IntegerRangeAnalysis.cpp +++ b/mlir/lib/Analysis/DataFlow/IntegerRangeAnalysis.cpp @@ -43,7 +43,7 @@ void IntegerValueRangeLattice::onUpdate(DataFlowSolver *solver) const { // If the integer range can be narrowed to a constant, update the constant // value of the SSA value. std::optional<APInt> constant = getValue().getValue().getConstantValue(); - auto value = anchor.get<Value>(); + auto value = cast<Value>(anchor); auto *cv = solver->getOrCreateState<Lattice<ConstantValue>>(value); if (!constant) return solver->propagateIfChanged( @@ -155,9 +155,8 @@ void IntegerRangeAnalysis::visitNonControlFlowArguments( Type boundType, bool getUpper) { unsigned int width = ConstantIntRanges::getStorageBitwidth(boundType); if (loopBound.has_value()) { - if (loopBound->is<Attribute>()) { - if (auto bound = - dyn_cast_or_null<IntegerAttr>(loopBound->get<Attribute>())) + if (auto attr = dyn_cast<Attribute>(*loopBound)) { + if (auto bound = dyn_cast_or_null<IntegerAttr>(attr)) return bound.getValue(); } else if (auto value = llvm::dyn_cast_if_present<Value>(*loopBound)) { const IntegerValueRangeLattice *lattice = diff --git a/mlir/lib/Analysis/DataFlow/SparseAnalysis.cpp b/mlir/lib/Analysis/DataFlow/SparseAnalysis.cpp index 67cf8c9c5b81..0b39d1404249 100644 --- a/mlir/lib/Analysis/DataFlow/SparseAnalysis.cpp +++ b/mlir/lib/Analysis/DataFlow/SparseAnalysis.cpp @@ -34,7 +34,7 @@ void AbstractSparseLattice::onUpdate(DataFlowSolver *solver) const { AnalysisState::onUpdate(solver); // Push all users of the value to the queue. - for (Operation *user : anchor.get<Value>().getUsers()) + for (Operation *user : cast<Value>(anchor).getUsers()) for (DataFlowAnalysis *analysis : useDefSubscribers) solver->enqueue({solver->getProgramPointAfter(user), analysis}); } |
