; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 ; RUN: opt < %s -mtriple=aarch64-unknown-linux-gnu -mattr=+sme -S -passes=always-inline | FileCheck %s --check-prefixes=CHECK,ALWAYS ; RUN: opt < %s -mtriple=aarch64-unknown-linux-gnu -mattr=+sme -S -passes=inline | FileCheck %s --check-prefixes=CHECK,INLINE ; Test that flatten attribute respects ABI restrictions for SME. ; Streaming callee cannot be inlined into non-streaming caller. ; new_za callee cannot be inlined at all. define internal i32 @streaming_callee() "aarch64_pstate_sm_enabled" { ; CHECK-LABEL: define internal i32 @streaming_callee( ; CHECK-SAME: ) #[[ATTR0:[0-9]+]] { ; CHECK-NEXT: ret i32 42 ; ret i32 42 } define internal i32 @new_za_callee() "aarch64_new_za" { ; CHECK-LABEL: define internal i32 @new_za_callee( ; CHECK-SAME: ) #[[ATTR1:[0-9]+]] { ; CHECK-NEXT: ret i32 100 ; ret i32 100 } define internal i32 @normal_callee() { ; ALWAYS-LABEL: define internal i32 @normal_callee( ; ALWAYS-SAME: ) #[[ATTR2:[0-9]+]] { ; ALWAYS-NEXT: ret i32 50 ; ret i32 50 } ; Streaming callee -> non-streaming caller: should NOT be inlined (ABI violation). define i32 @test_streaming_not_inlined() flatten { ; ALWAYS-LABEL: define i32 @test_streaming_not_inlined( ; ALWAYS-SAME: ) #[[ATTR3:[0-9]+]] { ; ALWAYS-NEXT: [[R:%.*]] = call i32 @streaming_callee() ; ALWAYS-NEXT: ret i32 [[R]] ; ; INLINE-LABEL: define i32 @test_streaming_not_inlined( ; INLINE-SAME: ) #[[ATTR2:[0-9]+]] { ; INLINE-NEXT: [[R:%.*]] = call i32 @streaming_callee() ; INLINE-NEXT: ret i32 [[R]] ; %r = call i32 @streaming_callee() ret i32 %r } ; new_za callee: should NOT be inlined (ABI violation - callee allocates new ZA). define i32 @test_new_za_not_inlined() flatten { ; ALWAYS-LABEL: define i32 @test_new_za_not_inlined( ; ALWAYS-SAME: ) #[[ATTR3]] { ; ALWAYS-NEXT: [[R:%.*]] = call i32 @new_za_callee() ; ALWAYS-NEXT: ret i32 [[R]] ; ; INLINE-LABEL: define i32 @test_new_za_not_inlined( ; INLINE-SAME: ) #[[ATTR2]] { ; INLINE-NEXT: [[R:%.*]] = call i32 @new_za_callee() ; INLINE-NEXT: ret i32 [[R]] ; %r = call i32 @new_za_callee() ret i32 %r } ; Streaming caller -> streaming callee: should be inlined (compatible). define i32 @test_streaming_to_streaming() flatten "aarch64_pstate_sm_enabled" { ; ALWAYS-LABEL: define i32 @test_streaming_to_streaming( ; ALWAYS-SAME: ) #[[ATTR4:[0-9]+]] { ; ALWAYS-NEXT: ret i32 42 ; ; INLINE-LABEL: define i32 @test_streaming_to_streaming( ; INLINE-SAME: ) #[[ATTR3:[0-9]+]] { ; INLINE-NEXT: ret i32 42 ; %r = call i32 @streaming_callee() ret i32 %r } ; Non-streaming caller -> non-streaming callee: should be inlined. define i32 @test_normal_inlined() flatten { ; ALWAYS-LABEL: define i32 @test_normal_inlined( ; ALWAYS-SAME: ) #[[ATTR3]] { ; ALWAYS-NEXT: ret i32 50 ; ; INLINE-LABEL: define i32 @test_normal_inlined( ; INLINE-SAME: ) #[[ATTR2]] { ; INLINE-NEXT: ret i32 50 ; %r = call i32 @normal_callee() ret i32 %r }