206 lines · plain
1# REQUIRES: riscv2## Test the ZICFISS feature.3## To lift maintenance burden, most tests are conducted only with 64-bit RISC-V4## Naming convention: *-s.s files enable ZICFISS.5# RUN: rm -rf %t && split-file %s %t && cd %t6# RUN: llvm-mc --filetype=obj --triple=riscv32 rv32-f1-s.s -o rv32-f1-s.o7# RUN: llvm-mc --filetype=obj --triple=riscv32 rv32-f2-s.s -o rv32-f2-s.o8# RUN: llvm-mc --filetype=obj --triple=riscv32 rv32-f3-s.s -o rv32-f3-s.o9 10# RUN: llvm-mc --filetype=obj --triple=riscv64 f1-s.s -o f1-s.o11# RUN: llvm-mc --filetype=obj --triple=riscv64 f2.s -o f2.o12# RUN: llvm-mc --filetype=obj --triple=riscv64 f2-s.s -o f2-s.o13# RUN: llvm-mc --filetype=obj --triple=riscv64 f3.s -o f3.o14# RUN: llvm-mc --filetype=obj --triple=riscv64 f3-s.s -o f3-s.o15 16## ZICFISS should be enabled when it's enabled in all inputs or when it's forced on.17# RUN: ld.lld rv32-f1-s.o rv32-f2-s.o rv32-f3-s.o -o out.rv32 --fatal-warnings18# RUN: llvm-readelf -n out.rv32 | FileCheck --check-prefix=ZICFISS %s19# RUN: ld.lld f1-s.o f2-s.o f3-s.o -o out --fatal-warnings20# RUN: llvm-readelf -n out | FileCheck --check-prefix=ZICFISS %s21# RUN: ld.lld f1-s.o f3-s.o --shared -o out.so --fatal-warnings22# RUN: llvm-readelf -n out.so | FileCheck --check-prefix=ZICFISS %s23# RUN: ld.lld f1-s.o f2.o f3-s.o -o out.force -z zicfiss=always --fatal-warnings24# RUN: llvm-readelf -n out.force | FileCheck --check-prefix=ZICFISS %s25# RUN: ld.lld f2-s.o f3.o --shared -o out.force.so -z zicfiss=never -z zicfiss=always --fatal-warnings26# RUN: llvm-readelf -n out.force.so | FileCheck --check-prefix=ZICFISS %s27# ZICFISS: Properties: RISC-V feature: ZICFISS28 29## ZICFISS should not be enabled if it's not enabled in at least one input30# RUN: ld.lld f1-s.o f2.o f3-s.o -o out.no --fatal-warnings31# RUN: llvm-readelf -n out.no | count 032# RUN: ld.lld f2-s.o f3.o --shared -o out.no.so --fatal-warnings33# RUN: llvm-readelf -n out.no.so | count 034 35## ZICFISS should be disabled with zicfiss=never, even if ZICFISS is present in36## all inputs.37# RUN: ld.lld f1-s.o f2-s.o f3-s.o -z zicfiss=always -z zicfiss=never -o out.never --fatal-warnings38# RUN: llvm-readelf -n out.never | count 039 40## zicfiss-report should report any input files that don't have the zicfiss41## property42# RUN: ld.lld f1-s.o f2.o f3-s.o -z zicfiss-report=warning 2>&1 | FileCheck --check-prefix=REPORT-WARN %s43# RUN: ld.lld f1-s.o f2.o f3-s.o -z zicfiss-report=warning -z zicfiss=always 2>&1 | FileCheck --check-prefix=REPORT-WARN %s44# RUN: ld.lld f1-s.o f2.o f3-s.o -z zicfiss-report=warning -z zicfiss=never 2>&1 | FileCheck --check-prefix=REPORT-WARN %s45# RUN: not ld.lld f2-s.o f3.o --shared -z zicfiss-report=error 2>&1 | FileCheck --check-prefix=REPORT-ERROR %s46# RUN: ld.lld f1-s.o f2-s.o f3-s.o -z zicfiss-report=warning -z zicfiss=always 2>&1 | count 047# RUN: ld.lld f1-s.o f2-s.o f3-s.o -z zicfiss-report=error -z zicfiss=always 2>&1 | count 048# REPORT-WARN: warning: f2.o: -z zicfiss-report: file does not have GNU_PROPERTY_RISCV_FEATURE_1_CFI_SS property49# REPORT-ERROR: error: f3.o: -z zicfiss-report: file does not have GNU_PROPERTY_RISCV_FEATURE_1_CFI_SS property50 51## An invalid -z zicfiss-report option should give an error52# RUN: not ld.lld f2-s.o f3-s.o -z zicfiss=x -z zicfiss-report=x 2>&1 | FileCheck --check-prefix=INVALID %s53# INVALID: error: unknown -z zicfiss= value: x54# INVALID: error: unknown -z zicfiss-report= value: x55 56#--- rv32-f1-s.s57.section ".note.gnu.property", "a"58.balign 459.4byte 460.4byte (ndesc_end - ndesc_begin)61.4byte 0x5 // NT_GNU_PROPERTY_TYPE_062.asciz "GNU"63ndesc_begin:64.balign 465.4byte 0xc0000000 // GNU_PROPERTY_RISCV_FEATURE_1_AND66.4byte 467.4byte 2 // GNU_PROPERTY_RISCV_FEATURE_1_CFI_SS68.balign 469ndesc_end:70 71.text72.globl _start73.type f1,%function74f1:75 call f276 ret77 78#--- f1-s.s79.section ".note.gnu.property", "a"80.balign 881.4byte 482.4byte (ndesc_end - ndesc_begin)83.4byte 0x5 // NT_GNU_PROPERTY_TYPE_084.asciz "GNU"85ndesc_begin:86.balign 887.4byte 0xc0000000 // GNU_PROPERTY_RISCV_FEATURE_1_AND88.4byte 489.4byte 2 // GNU_PROPERTY_RISCV_FEATURE_1_CFI_SS90.balign 891ndesc_end:92 93.text94.globl _start95.type f1,%function96f1:97 call f298 ret99 100#--- f2.s101.text102.globl f2103.type f2,@function104f2:105 .globl f3106 .type f3, @function107 call f3108 ret109 110#--- rv32-f2-s.s111.section ".note.gnu.property", "a"112.balign 4113.4byte 4114.4byte (ndesc_end - ndesc_begin)115.4byte 0x5 // NT_GNU_PROPERTY_TYPE_0116.asciz "GNU"117ndesc_begin:118.balign 4119.4byte 0xc0000000 // GNU_PROPERTY_RISCV_FEATURE_1_AND120.4byte 4121.4byte 2 // GNU_PROPERTY_RISCV_FEATURE_1_CFI_SS122.balign 4123ndesc_end:124 125.text126.globl f2127.type f2,@function128f2:129 .globl f3130 .type f3, @function131 call f3132 ret133 134#--- f2-s.s135.section ".note.gnu.property", "a"136.balign 8137.4byte 4138.4byte (ndesc_end - ndesc_begin)139.4byte 0x5 // NT_GNU_PROPERTY_TYPE_0140.asciz "GNU"141ndesc_begin:142.balign 8143.4byte 0xc0000000 // GNU_PROPERTY_RISCV_FEATURE_1_AND144.4byte 4145.4byte 2 // GNU_PROPERTY_RISCV_FEATURE_1_CFI_SS146.balign 8147ndesc_end:148 149.text150.globl f2151.type f2,@function152f2:153 .globl f3154 .type f3, @function155 call f3156 ret157 158#--- f3.s159.text160.globl f3161.type f3,@function162f3:163 ret164 165#--- rv32-f3-s.s166.section ".note.gnu.property", "a"167.balign 4168.4byte 4169.4byte (ndesc_end - ndesc_begin)170.4byte 0x5 // NT_GNU_PROPERTY_TYPE_0171.asciz "GNU"172ndesc_begin:173.balign 4174.4byte 0xc0000000 // GNU_PROPERTY_RISCV_FEATURE_1_AND175.4byte 4176.4byte 2 // GNU_PROPERTY_RISCV_FEATURE_1_CFI_SS177.balign 4178ndesc_end:179 180.text181.globl f3182.type f3,@function183f3:184 ret185 186#--- f3-s.s187.section ".note.gnu.property", "a"188.balign 8189.4byte 4190.4byte (ndesc_end - ndesc_begin)191.4byte 0x5 // NT_GNU_PROPERTY_TYPE_0192.asciz "GNU"193ndesc_begin:194.balign 8195.4byte 0xc0000000 // GNU_PROPERTY_RISCV_FEATURE_1_AND196.4byte 4197.4byte 2 // GNU_PROPERTY_RISCV_FEATURE_1_CFI_SS198.balign 8199ndesc_end:200 201.text202.globl f3203.type f3,@function204f3:205 ret206