[llvm] [MIR] Serialize MachineFrameInfo::isCalleeSavedInfoValid() (PR #90561)

Francis Visoiu Mistrih via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 30 17:02:04 PDT 2024


================
@@ -0,0 +1,158 @@
+
+# RUN: llc -run-pass=none -o - %s | FileCheck %s
+
+--- |
+
+  ; No stack, no callee-saved info -> no callee-saved info
+  define i32 @no_stack_no_calleesavedinfo(i32 noundef %0) #0 {
+    %2 = tail call i32 @f4(i32 noundef %0)
+    ret i32 %2
+  }
+  
+  ; No stack but callee-saved info -> still callee-saved info
+  define i32 @no_stack_calleesavedinfo(i32 noundef %0) #0 {
+    %2 = tail call i32 @f4(i32 noundef %0)
+    ret i32 %2
+  }
+  
+  ; Stack but no callee-saved info -> still callee-saved info
+  define i32 @stack_no_calleesavedinfo(i32 noundef %0) #0 {
+    %2 = call i32 @f4(i32 noundef %0)
+    %3 = add i32 %0, %2
+    ret i32 %3
+  }
+  
+  ; Stack and callee-saved info -> still callee-saved info
+  define i32 @stack_calleesavedinfo(i32 noundef %0) #0 {
+    %2 = call i32 @f4(i32 noundef %0)
+    %3 = add i32 %0, %2
+    ret i32 %3
+  }
+  
+  declare i32 @f4(i32 noundef)
+  
+  attributes #0 = { nounwind }
+
+...
+---
+# CHECK-LABEL:  name:                   no_stack_no_calleesavedinfo
+# CHECK:        isCalleeSavedInfoValid: false
+name:            no_stack_no_calleesavedinfo
+alignment:       4
+tracksRegLiveness: true
+tracksDebugUserValues: true
+liveins:
+  - { reg: '$w0' }
+frameInfo:
+  maxAlignment:    1
+  maxCallFrameSize: 0
+  hasTailCall:     true
+  isCalleeSavedInfoValid: false
+stack: []
+machineFunctionInfo:
+  hasRedZone:      false
+body:             |
+  bb.0 (%ir-block.1):
+    liveins: $w0
+  
+    TCRETURNdi @f4, 0, csr_darwin_aarch64_aapcs, implicit $sp, implicit $w0
----------------
francisvm wrote:

You don't really need this. I think even the body is optional? (see llvm/test/CodeGen/MIR/Generic/llvmIRMissing.mir) If you really need something in the body you can use `$x0 = IMPLICIT_DEF`. I think the same applies to most of the other fields, and the entire LLVM IR.

https://github.com/llvm/llvm-project/pull/90561


More information about the llvm-commits mailing list