Skip to content

Commit 665877e

Browse files
committed
Assume this will be backported to llvm-19
1 parent e396582 commit 665877e

File tree

5 files changed

+17
-26
lines changed

5 files changed

+17
-26
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1147,7 +1147,7 @@ Arm and AArch64 Support
11471147
- The AArch64 calling convention for empty structs in C++ mode was changed to
11481148
pass them as if they have a size of 1 byte, matching the AAPCS64
11491149
specification and GCC's implementation. The previous behaviour of ignoring
1150-
the argument can be restored using the -fclang-abi-compat=20 (or earlier)
1150+
the argument can be restored using the -fclang-abi-compat=19 (or earlier)
11511151
option.
11521152

11531153
Android Support

clang/include/clang/Basic/LangOptions.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -245,13 +245,9 @@ class LangOptionsBase {
245245
/// construction vtable because it hasn't added 'type' as a substitution.
246246
/// - Skip mangling enclosing class templates of member-like friend
247247
/// function templates.
248-
Ver19,
249-
250-
/// Attempt to be ABI-compatible with code generated by Clang 20.x.
251-
/// This causes clang to:
252-
/// - Ignore empty struct arguments in C++ mode for AArch64, instead of
248+
/// - Ignore empty struct arguments in C++ mode for AArch64, instead of
253249
/// passing them as if they had a size of 1 byte.
254-
Ver20,
250+
Ver19,
255251

256252
/// Conform to the underlying platform's C and C++ ABIs as closely
257253
/// as we can.

clang/lib/CodeGen/Targets/ARM.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,9 +345,9 @@ bool ARMABIInfo::shouldIgnoreEmptyArg(QualType Ty) const {
345345
if (Size == 0)
346346
return true;
347347

348-
// Clang 20.0 and earlier always ignored empty struct arguments in C++ mode.
348+
// Clang 19.0 and earlier always ignored empty struct arguments in C++ mode.
349349
if (getContext().getLangOpts().getClangABICompat() <=
350-
LangOptions::ClangABI::Ver20)
350+
LangOptions::ClangABI::Ver19)
351351
return true;
352352

353353
// Otherwise, they are passed as if they have a size of 1 byte.

clang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3893,9 +3893,6 @@ void CompilerInvocationBase::GenerateLangArgs(const LangOptions &Opts,
38933893
case LangOptions::ClangABI::Ver19:
38943894
GenerateArg(Consumer, OPT_fclang_abi_compat_EQ, "19.0");
38953895
break;
3896-
case LangOptions::ClangABI::Ver20:
3897-
GenerateArg(Consumer, OPT_fclang_abi_compat_EQ, "20.0");
3898-
break;
38993896
case LangOptions::ClangABI::Latest:
39003897
break;
39013898
}
@@ -4442,8 +4439,6 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
44424439
Opts.setClangABICompat(LangOptions::ClangABI::Ver18);
44434440
else if (Major <= 19)
44444441
Opts.setClangABICompat(LangOptions::ClangABI::Ver19);
4445-
else if (Major <= 20)
4446-
Opts.setClangABICompat(LangOptions::ClangABI::Ver20);
44474442
} else if (Ver != "latest") {
44484443
Diags.Report(diag::err_drv_invalid_value)
44494444
<< A->getAsString(Args) << A->getValue();

clang/test/CodeGen/arm-empty-args.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// RUN: %clang_cc1 -triple armv7a-linux-gnueabi -emit-llvm -o - -x c %s | FileCheck %s --check-prefixes=CHECK,C
22
// RUN: %clang_cc1 -triple armv7a-linux-gnueabi -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,CXX
3-
// RUN: %clang_cc1 -triple armv7a-linux-gnueabi -emit-llvm -o - %s -fclang-abi-compat=20 | FileCheck %s --check-prefixes=CHECK,CXXCLANG20
3+
// RUN: %clang_cc1 -triple armv7a-linux-gnueabi -emit-llvm -o - %s -fclang-abi-compat=19 | FileCheck %s --check-prefixes=CHECK,CXXCLANG19
44
// RUN: %clang_cc1 -triple thumbv7k-apple-watchos2.0 -target-abi aapcs16 -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,WATCHOS
55

66
// Empty structs are ignored for PCS purposes on WatchOS and in C mode
@@ -18,15 +18,15 @@ struct Empty {};
1818

1919
// C: define{{.*}} i32 @empty_arg(i32 noundef %a)
2020
// CXX: define{{.*}} i32 @empty_arg(i8 %e.coerce, i32 noundef %a)
21-
// CXXCLANG20: define{{.*}} i32 @empty_arg(i32 noundef %a)
21+
// CXXCLANG19: define{{.*}} i32 @empty_arg(i32 noundef %a)
2222
// WATCHOS: define{{.*}} i32 @empty_arg(i32 noundef %a)
2323
EXTERNC int empty_arg(struct Empty e, int a) {
2424
return a;
2525
}
2626

2727
// C: define{{.*}} void @empty_ret()
2828
// CXX: define{{.*}} void @empty_ret()
29-
// CXXCLANG20: define{{.*}} void @empty_ret()
29+
// CXXCLANG19: define{{.*}} void @empty_ret()
3030
// WATCHOS: define{{.*}} void @empty_ret()
3131
EXTERNC struct Empty empty_ret(void) {
3232
struct Empty e;
@@ -43,7 +43,7 @@ struct SuperEmpty {
4343

4444
// C: define{{.*}} i32 @super_empty_arg(i32 noundef %a)
4545
// CXX: define{{.*}} i32 @super_empty_arg(i32 noundef %a)
46-
// CXXCLANG20: define{{.*}} i32 @super_empty_arg(i32 noundef %a)
46+
// CXXCLANG19: define{{.*}} i32 @super_empty_arg(i32 noundef %a)
4747
// WATCHOS: define{{.*}} i32 @super_empty_arg(i32 noundef %a)
4848
EXTERNC int super_empty_arg(struct SuperEmpty e, int a) {
4949
return a;
@@ -55,15 +55,15 @@ struct SortOfEmpty {
5555

5656
// C: define{{.*}} i32 @sort_of_empty_arg(i32 noundef %a)
5757
// CXX: define{{.*}} i32 @sort_of_empty_arg(i8 %e.coerce, i32 noundef %a)
58-
// CXXCLANG20: define{{.*}} i32 @sort_of_empty_arg(i32 noundef %a)
58+
// CXXCLANG19: define{{.*}} i32 @sort_of_empty_arg(i32 noundef %a)
5959
// WATCHOS: define{{.*}} i32 @sort_of_empty_arg(i32 noundef %a)
6060
EXTERNC int sort_of_empty_arg(struct Empty e, int a) {
6161
return a;
6262
}
6363

6464
// C: define{{.*}} void @sort_of_empty_ret()
6565
// CXX: define{{.*}} void @sort_of_empty_ret()
66-
// CXXCLANG20: define{{.*}} void @sort_of_empty_ret()
66+
// CXXCLANG19: define{{.*}} void @sort_of_empty_ret()
6767
// WATCHOS: define{{.*}} void @sort_of_empty_ret()
6868
EXTERNC struct SortOfEmpty sort_of_empty_ret(void) {
6969
struct SortOfEmpty e;
@@ -82,8 +82,8 @@ EXTERNC int empty_arg_variadic(int a, ...) {
8282
// C-NOT: {{ getelementptr }}
8383
// CXX: %argp.next = getelementptr inbounds i8, ptr %argp.cur, i32 4
8484
// CXX: %argp.next2 = getelementptr inbounds i8, ptr %argp.cur1, i32 4
85-
// CXXCLANG20: %argp.next = getelementptr inbounds i8, ptr %argp.cur, i32 4
86-
// CXXCLANG20-NOT: {{ getelementptr }}
85+
// CXXCLANG19: %argp.next = getelementptr inbounds i8, ptr %argp.cur, i32 4
86+
// CXXCLANG19-NOT: {{ getelementptr }}
8787
// WATCHOS: %argp.next = getelementptr inbounds i8, ptr %argp.cur, i32 4
8888
// WATCHOS-NOT: {{ getelementptr }}
8989
va_list vl;
@@ -100,8 +100,8 @@ EXTERNC int super_empty_arg_variadic(int a, ...) {
100100
// C-NOT: {{ getelementptr }}
101101
// CXX: %argp.next = getelementptr inbounds i8, ptr %argp.cur, i32 4
102102
// CXX-NOT: {{ getelementptr }}
103-
// CXXCLANG20: %argp.next = getelementptr inbounds i8, ptr %argp.cur, i32 4
104-
// CXXCLANG20-NOT: {{ getelementptr }}
103+
// CXXCLANG19: %argp.next = getelementptr inbounds i8, ptr %argp.cur, i32 4
104+
// CXXCLANG19-NOT: {{ getelementptr }}
105105
// WATCHOS: %argp.next = getelementptr inbounds i8, ptr %argp.cur, i32 4
106106
// WATCHOS-NOT: {{ getelementptr }}
107107
va_list vl;
@@ -118,8 +118,8 @@ EXTERNC int sort_of_empty_arg_variadic(int a, ...) {
118118
// C-NOT: {{ getelementptr }}
119119
// CXX: %argp.next = getelementptr inbounds i8, ptr %argp.cur, i32 4
120120
// CXX-NOT: {{ getelementptr }}
121-
// CXXCLANG20: %argp.next = getelementptr inbounds i8, ptr %argp.cur, i32 4
122-
// CXXCLANG20-NOT: {{ getelementptr }}
121+
// CXXCLANG19: %argp.next = getelementptr inbounds i8, ptr %argp.cur, i32 4
122+
// CXXCLANG19-NOT: {{ getelementptr }}
123123
// WATCHOS: %argp.next = getelementptr inbounds i8, ptr %argp.cur, i32 4
124124
// WATCHOS-NOT: {{ getelementptr }}
125125
va_list vl;

0 commit comments

Comments
 (0)