Skip to content

Commit 70410f5

Browse files
committed
Only infer attributes for callees (not definitions)
This matches the old behaviour and allows stubbing the ABI routines in C++.
1 parent c7a5edd commit 70410f5

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,13 @@ bool SMECallAttrs::requiresSMChange() const {
111111
}
112112

113113
SMECallAttrs::SMECallAttrs(const CallBase &CB)
114-
: CallerFn(*CB.getFunction()), CalledFn(CB.getCalledFunction()),
114+
: CallerFn(*CB.getFunction()), CalledFn(SMEAttrs::Normal),
115115
Callsite(CB.getAttributes()), IsIndirect(CB.isIndirectCall()) {
116+
if (auto *CalledFunction = CB.getCalledFunction()) {
117+
CalledFn = SMEAttrs(*CalledFunction);
118+
CalledFn.addKnownFunctionAttrs(CalledFunction->getName());
119+
}
120+
116121
// FIXME: We probably should not allow SME attributes on direct calls but
117122
// clang duplicates streaming mode attributes at each callsite.
118123
assert((IsIndirect ||

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ namespace llvm {
1616
class Function;
1717
class CallBase;
1818
class AttributeList;
19+
class SMECallAttrs;
1920

2021
/// SMEAttrs is a utility class to parse the SME ACLE attributes on functions.
2122
/// It helps determine a function's requirements for PSTATE.ZA and PSTATE.SM.
@@ -50,12 +51,7 @@ class SMEAttrs {
5051

5152
SMEAttrs() = default;
5253
SMEAttrs(unsigned Mask) { set(Mask); }
53-
SMEAttrs(const Function *F)
54-
: SMEAttrs(F ? F->getAttributes() : AttributeList()) {
55-
if (F)
56-
addKnownFunctionAttrs(F->getName());
57-
}
58-
SMEAttrs(const Function &F) : SMEAttrs(&F) {}
54+
SMEAttrs(const Function &F) : SMEAttrs(F.getAttributes()) {}
5955
SMEAttrs(const AttributeList &L);
6056
SMEAttrs(StringRef FuncName) { addKnownFunctionAttrs(FuncName); };
6157

@@ -144,6 +140,8 @@ class SMEAttrs {
144140
return Bitmask == Other.Bitmask;
145141
}
146142

143+
friend SMECallAttrs;
144+
147145
private:
148146
void addKnownFunctionAttrs(StringRef FuncName);
149147
};

0 commit comments

Comments
 (0)