Skip to content

Commit e5c1a4c

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 e5c1a4c

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-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: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ class Function;
1717
class CallBase;
1818
class AttributeList;
1919

20+
class SMECallAttrs;
21+
2022
/// SMEAttrs is a utility class to parse the SME ACLE attributes on functions.
2123
/// It helps determine a function's requirements for PSTATE.ZA and PSTATE.SM.
2224
class SMEAttrs {
@@ -50,12 +52,7 @@ class SMEAttrs {
5052

5153
SMEAttrs() = default;
5254
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) {}
55+
SMEAttrs(const Function &F) : SMEAttrs(F.getAttributes()) {}
5956
SMEAttrs(const AttributeList &L);
6057
SMEAttrs(StringRef FuncName) { addKnownFunctionAttrs(FuncName); };
6158

@@ -144,6 +141,8 @@ class SMEAttrs {
144141
return Bitmask == Other.Bitmask;
145142
}
146143

144+
friend SMECallAttrs;
145+
147146
private:
148147
void addKnownFunctionAttrs(StringRef FuncName);
149148
};

0 commit comments

Comments
 (0)