[llvm] 39ba027 - [RISCV, test] Test whether MCAssembler uses function target-features

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 7 00:23:46 PST 2023


Author: Fangrui Song
Date: 2023-12-07T00:23:42-08:00
New Revision: 39ba027f4e52175c48da87e2dc2956d23b27e953

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

LOG: [RISCV,test] Test whether MCAssembler uses function target-features

Test https://discourse.llvm.org/t/possible-problem-related-to-subtarget-usage/75283
The test is similar to ARM/relax-per-target-feature.ll in spirit.

Added: 
    llvm/test/CodeGen/RISCV/relax-per-target-feature.ll

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/llvm/test/CodeGen/RISCV/relax-per-target-feature.ll b/llvm/test/CodeGen/RISCV/relax-per-target-feature.ll
new file mode 100644
index 0000000000000..295e8ffc0dfe6
--- /dev/null
+++ b/llvm/test/CodeGen/RISCV/relax-per-target-feature.ll
@@ -0,0 +1,33 @@
+; RUN: llc -filetype=obj -mtriple=riscv64 %s -o %t
+; RUN: llvm-objdump -dr -M no-aliases --mattr=+c %t | FileCheck %s
+
+;; Functions may have more features than the base triple; code generation and
+;; instruction selection may be performed based on this information. This test
+;; makes sure that the MC layer uses the target-features of the function.
+
+declare dso_local i32 @ext(i32)
+
+; CHECK-LABEL: <f>:
+; CHECK-NEXT:    c.li a0, 31
+; CHECK-NEXT:    auipc t1, 0
+; CHECK-NEXT:    R_RISCV_CALL_PLT     ext
+; CHECK-NEXT:    jalr zero, 0(t1)
+define dso_local i32 @f() #0 {
+entry:
+  %r = tail call i32 @ext(i32 31)
+  ret i32 %r
+}
+
+; CHECK-LABEL: <g>:
+; CHECK-NEXT:    addi a0, zero, 31
+; CHECK-NEXT:    auipc t1, 0
+; CHECK-NEXT:    R_RISCV_CALL_PLT     ext
+; CHECK-NEXT:    jalr zero, 0(t1)
+define dso_local i32 @g() #1 {
+entry:
+  %r = tail call i32 @ext(i32 31)
+  ret i32 %r
+}
+
+attributes #0 = { nounwind "target-features"="+c,+relax" }
+attributes #1 = { nounwind "target-features"="-c,-relax" }


        


More information about the llvm-commits mailing list