Skip to content

Commit 389679d

Browse files
Reland: "[Clang] Demote always_inline error to warning for mismatching SME attrs" (#100991) (#100996)
Test `aarch64-sme-inline-streaming-attrs.c` caused some buildbot failures, because the test was missing a `REQUIRES: aarch64-registered target`. This was because we've demoted the error to a warning, which then resulted in a different error message, because Clang can't actually CodeGen the IR.
1 parent fdfeea5 commit 389679d

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

clang/include/clang/Basic/DiagnosticFrontendKinds.td

+3
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,9 @@ def err_function_needs_feature : Error<
288288
let CategoryName = "Codegen ABI Check" in {
289289
def err_function_always_inline_attribute_mismatch : Error<
290290
"always_inline function %1 and its caller %0 have mismatching %2 attributes">;
291+
def warn_function_always_inline_attribute_mismatch : Warning<
292+
"always_inline function %1 and its caller %0 have mismatching %2 attributes, "
293+
"inlining may change runtime behaviour">, InGroup<AArch64SMEAttributes>;
291294
def err_function_always_inline_new_za : Error<
292295
"always_inline function %0 has new za state">;
293296

clang/lib/CodeGen/Targets/AArch64.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -883,8 +883,10 @@ void AArch64TargetCodeGenInfo::checkFunctionCallABIStreaming(
883883

884884
if (!CalleeIsStreamingCompatible &&
885885
(CallerIsStreaming != CalleeIsStreaming || CallerIsStreamingCompatible))
886-
CGM.getDiags().Report(CallLoc,
887-
diag::err_function_always_inline_attribute_mismatch)
886+
CGM.getDiags().Report(
887+
CallLoc, CalleeIsStreaming
888+
? diag::err_function_always_inline_attribute_mismatch
889+
: diag::warn_function_always_inline_attribute_mismatch)
888890
<< Caller->getDeclName() << Callee->getDeclName() << "streaming";
889891
if (auto *NewAttr = Callee->getAttr<ArmNewAttr>())
890892
if (NewAttr->isNewZA())

clang/test/CodeGen/aarch64-sme-inline-streaming-attrs.c

+5-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -S -o /dev/null -target-feature +sme -verify -DTEST_STREAMING %s
44
// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -S -o /dev/null -target-feature +sme -verify -DTEST_LOCALLY %s
55

6+
// REQUIRES: aarch64-registered-target
7+
68
#define __ai __attribute__((always_inline))
79
__ai void inlined_fn(void) {}
810
__ai void inlined_fn_streaming_compatible(void) __arm_streaming_compatible {}
@@ -20,7 +22,7 @@ void caller(void) {
2022

2123
#ifdef TEST_COMPATIBLE
2224
void caller_compatible(void) __arm_streaming_compatible {
23-
inlined_fn(); // expected-error {{always_inline function 'inlined_fn' and its caller 'caller_compatible' have mismatching streaming attributes}}
25+
inlined_fn(); // expected-warning {{always_inline function 'inlined_fn' and its caller 'caller_compatible' have mismatching streaming attributes, inlining may change runtime behaviour}}
2426
inlined_fn_streaming_compatible();
2527
inlined_fn_streaming(); // expected-error {{always_inline function 'inlined_fn_streaming' and its caller 'caller_compatible' have mismatching streaming attributes}}
2628
inlined_fn_local(); // expected-error {{always_inline function 'inlined_fn_local' and its caller 'caller_compatible' have mismatching streaming attributes}}
@@ -29,7 +31,7 @@ void caller_compatible(void) __arm_streaming_compatible {
2931

3032
#ifdef TEST_STREAMING
3133
void caller_streaming(void) __arm_streaming {
32-
inlined_fn(); // expected-error {{always_inline function 'inlined_fn' and its caller 'caller_streaming' have mismatching streaming attributes}}
34+
inlined_fn(); // expected-warning {{always_inline function 'inlined_fn' and its caller 'caller_streaming' have mismatching streaming attributes, inlining may change runtime behaviour}}
3335
inlined_fn_streaming_compatible();
3436
inlined_fn_streaming();
3537
inlined_fn_local();
@@ -39,7 +41,7 @@ void caller_streaming(void) __arm_streaming {
3941
#ifdef TEST_LOCALLY
4042
__arm_locally_streaming
4143
void caller_local(void) {
42-
inlined_fn(); // expected-error {{always_inline function 'inlined_fn' and its caller 'caller_local' have mismatching streaming attributes}}
44+
inlined_fn(); // expected-warning {{always_inline function 'inlined_fn' and its caller 'caller_local' have mismatching streaming attributes, inlining may change runtime behaviour}}
4345
inlined_fn_streaming_compatible();
4446
inlined_fn_streaming();
4547
inlined_fn_local();

0 commit comments

Comments
 (0)