Skip to content

Commit 156c96b

Browse files
committed
fixup: allow streaming compatible callee and check if modes are the same
1 parent 04866d0 commit 156c96b

File tree

5 files changed

+32
-5
lines changed

5 files changed

+32
-5
lines changed

clang/lib/CodeGen/Targets/AArch64.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -827,12 +827,13 @@ void AArch64TargetCodeGenInfo::checkFunctionCallABI(
827827
if (!Callee->hasAttr<AlwaysInlineAttr>())
828828
return;
829829

830-
auto CalleeIsStreaming =
831-
Sema::getArmStreamingFnType(Callee) == Sema::ArmStreaming;
832-
auto CallerIsStreaming =
833-
Sema::getArmStreamingFnType(Caller) == Sema::ArmStreaming;
830+
auto CalleeStreamingMode = Sema::getArmStreamingFnType(Callee);
831+
auto CallerStreamingMode = Sema::getArmStreamingFnType(Caller);
834832

835-
if (CalleeIsStreaming && !CallerIsStreaming)
833+
// The caller can inline the callee if their streaming modes match or the
834+
// callee is streaming compatible
835+
if (CalleeStreamingMode != CallerStreamingMode &&
836+
CalleeStreamingMode != Sema::ArmStreamingCompatible)
836837
CGM.getDiags().Report(CallLoc,
837838
diag::err_function_alwaysinline_attribute_mismatch)
838839
<< Caller->getDeclName() << Callee->getDeclName() << "streaming";
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// RUN: %clang --target=aarch64-none-linux-gnu -march=armv9-a+sme -O3 -S -Xclang -verify %s
2+
3+
// Conflicting attributes when using always_inline
4+
__attribute__((always_inline))
5+
int inlined_fn_streaming(void) __arm_streaming {
6+
return 42;
7+
}
8+
// expected-error@+1 {{always_inline function 'inlined_fn_streaming' and its caller 'inlined_fn_caller' have mismatched streaming attributes}}
9+
int inlined_fn_caller(void) __arm_streaming_compatible { return inlined_fn_streaming(); }
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// RUN: %clang --target=aarch64-none-linux-gnu -march=armv9-a+sme -O3 -S -Xclang -verify %s
2+
3+
// Conflicting attributes when using always_inline
4+
__attribute__((always_inline))
5+
int inlined_fn_streaming_compatible(void) __arm_streaming_compatible {
6+
return 42;
7+
}
8+
__attribute__((always_inline))
9+
int inlined_fn(void) {
10+
return 42;
11+
}
12+
int inlined_fn_caller(void) { return inlined_fn_streaming_compatible(); }
13+
__arm_locally_streaming
14+
int inlined_fn_caller_local(void) { return inlined_fn_streaming_compatible(); }
15+
int inlined_fn_caller_streaming(void) __arm_streaming { return inlined_fn_streaming_compatible(); }
16+
// expected-error@+1 {{always_inline function 'inlined_fn' and its caller 'inlined_fn_caller_compatible' have mismatched streaming attributes}}
17+
int inlined_fn_caller_compatible(void) __arm_streaming_compatible { return inlined_fn(); }

0 commit comments

Comments
 (0)