Skip to content

Commit 22f29d6

Browse files
authored
[AArch64][SME] Fix incorrect "attributes at callsite do not match" assert (#164991)
Clang always duplicates SME attributes to each callsite, which means removing "ZA_State_Agnostic" from CalledFn before the assert resulted in the assertion failing for IR emitted by clang. I've updated the existing test to match the form emitted by clang (which previously hit the assert).
1 parent 3098435 commit 22f29d6

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

llvm/lib/Target/AArch64/Utils/AArch64SMEAttributes.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,15 +131,15 @@ SMECallAttrs::SMECallAttrs(const CallBase &CB,
131131
if (auto *CalledFunction = CB.getCalledFunction())
132132
CalledFn = SMEAttrs(*CalledFunction, RTLCI);
133133

134-
// An `invoke` of an agnostic ZA function may not return normally (it may
135-
// resume in an exception block). In this case, it acts like a private ZA
136-
// callee and may require a ZA save to be set up before it is called.
137-
if (isa<InvokeInst>(CB))
138-
CalledFn.set(SMEAttrs::ZA_State_Agnostic, /*Enable=*/false);
139-
140134
// FIXME: We probably should not allow SME attributes on direct calls but
141135
// clang duplicates streaming mode attributes at each callsite.
142136
assert((IsIndirect ||
143137
((Callsite.withoutPerCallsiteFlags() | CalledFn) == CalledFn)) &&
144138
"SME attributes at callsite do not match declaration");
139+
140+
// An `invoke` of an agnostic ZA function may not return normally (it may
141+
// resume in an exception block). In this case, it acts like a private ZA
142+
// callee and may require a ZA save to be set up before it is called.
143+
if (isa<InvokeInst>(CB))
144+
CalledFn.set(SMEAttrs::ZA_State_Agnostic, /*Enable=*/false);
145145
}

llvm/test/CodeGen/AArch64/sme-za-exceptions.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,7 @@ define void @try_catch_agnostic_za_invoke() "aarch64_za_state_agnostic" personal
829829
; CHECK-SDAG-NEXT: bl __arm_sme_restore
830830
; CHECK-SDAG-NEXT: b .LBB5_1
831831
entry:
832-
invoke void @agnostic_za_call()
832+
invoke void @agnostic_za_call() "aarch64_za_state_agnostic"
833833
to label %exit unwind label %catch
834834

835835
catch:

0 commit comments

Comments
 (0)