llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang-codegen Author: Nikita Popov (nikic) <details> <summary>Changes</summary> To `-msmall-int-abi-compat=clang-23`, based on feedback in #<!-- -->236450. This is to make it clearer that this refers to the ABI used by an older Clang version. --- Full diff: https://github.com/llvm/llvm-project/pull/243881.diff 11 Files Affected: - (modified) clang/docs/ReleaseNotes.md (+1-1) - (modified) clang/include/clang/Basic/CodeGenOptions.h (+1-1) - (modified) clang/include/clang/Options/Options.td (+5-5) - (modified) clang/lib/CIR/Lowering/CIRPasses.cpp (+1-1) - (modified) clang/lib/CodeGen/CodeGenModule.cpp (+3-3) - (modified) clang/lib/CodeGen/Targets/X86.cpp (+3-3) - (modified) clang/test/CodeGen/X86/bool_argument_passing.c (+2-2) - (modified) clang/test/CodeGen/X86/integer_argument_passing.c (+4-4) - (modified) llvm/include/llvm/ABI/TargetInfo.h (+1-1) - (modified) llvm/lib/ABI/Targets/X86.cpp (+1-1) - (modified) llvm/unittests/ABI/X86TargetInfoTest.cpp (+9-6) ``````````diff diff --git a/clang/docs/ReleaseNotes.md b/clang/docs/ReleaseNotes.md index cc736c04055ba6..5b10693339e750 100644 --- a/clang/docs/ReleaseNotes.md +++ b/clang/docs/ReleaseNotes.md @@ -184,7 +184,7 @@ features cannot lower the translation-unit ABI level; * `-msmall-int-abi-compat=platform`: Compatible with platform ABI (and thus other compilers such as GCC), but not with old Clang-built objects. Does not extend in the caller and does not assume extension in the callee. - * `-msmall-int-abi-compat=clang`: Compatible with old Clang objects, but + * `-msmall-int-abi-compat=clang-23`: Compatible with old Clang objects, but potentially not the platform ABI. Extends in the caller and assumes extension in the callee. * `-msmall-int-abi-compat=both` (default): Compatible with both the platform diff --git a/clang/include/clang/Basic/CodeGenOptions.h b/clang/include/clang/Basic/CodeGenOptions.h index 85e5a30af02fe5..4f1875d8c0bd47 100644 --- a/clang/include/clang/Basic/CodeGenOptions.h +++ b/clang/include/clang/Basic/CodeGenOptions.h @@ -285,7 +285,7 @@ class CodeGenOptions : public CodeGenOptionsBase { enum class SmallIntABICompatKind { Platform, // Compat with platform ABI (high bits unspecified). - Clang, // Compat with old Clang ABI (high bits zero/sign-extended). + Clang23, // Compat with old Clang ABI (high bits zero/sign-extended). Both, // Compat with both. Extend in caller, don't assume in callee. }; diff --git a/clang/include/clang/Options/Options.td b/clang/include/clang/Options/Options.td index 9156640ff67c79..c2f4ff0f365342 100644 --- a/clang/include/clang/Options/Options.td +++ b/clang/include/clang/Options/Options.td @@ -5823,19 +5823,19 @@ def msmall_int_abi_compat_EQ : Joined<["-"], "msmall-int-abi-compat=">, Group<m_Group>, Visibility<[ClangOption, CC1Option]>, HelpText<"ABI compatibility for small integer arguments on X86: " "'platform' (High bits unspecified) | " - "'clang' (High bits zero/sign-extended) | " + "'clang-23' (High bits zero/sign-extended) | " "'both' (High bits extended in caller, " "extension not assumed in callee)">, - Values<"platform,clang,both">, + Values<"platform,clang-23,both">, NormalizedValuesScope<"CodeGenOptions::SmallIntABICompatKind">, - NormalizedValues<["Platform", "Clang", "Both"]>, + NormalizedValues<["Platform", "Clang23", "Both"]>, MarshallingInfoEnum<CodeGenOpts<"SmallIntABICompat">, "Both">, DocBrief<[{ Specifies how small integer arguments are passed on the following platforms: * 32-bit x86 for operating systems other than Darwin and Playstation. * 64-bit x86 for operating systems other than Windows, Darwin and PlayStation. -The value must be 'platform', 'clang', or 'both'. The default behavior is +The value must be 'platform', 'clang-23', or 'both'. The default behavior is 'both'. In the past, Clang passed promotable integer arguments (non-variadic arguments @@ -5850,7 +5850,7 @@ If 'platform' is used, promotable integer arguments will not be extended by the caller. This is conformant with the platform psABI (such as the System V ABI), but may break compatibility with old Clang-built objects. -If 'clang' is used, promotable integer arguments are extended by the caller, +If 'clang-23' is used, promotable integer arguments are extended by the caller, and the callee assumes this extension has happend. This restores the previous (before version 24) behavior of Clang, but may be incompatible with other compilers like GCC following the platform ABI. diff --git a/clang/lib/CIR/Lowering/CIRPasses.cpp b/clang/lib/CIR/Lowering/CIRPasses.cpp index 9b5004fd5e61a5..5566e32f1361cc 100644 --- a/clang/lib/CIR/Lowering/CIRPasses.cpp +++ b/clang/lib/CIR/Lowering/CIRPasses.cpp @@ -73,7 +73,7 @@ getX86ABICompatInfo(const llvm::Triple &triple, // Match the classic CodeGen default of -msmall-int-abi-compat. assert(!cir::MissingFeatures::smallIntABICompatOption()); abiCompat.SmallIntABICompat = triple.isOSDarwin() || triple.isPS() - ? llvm::abi::SmallIntABICompatKind::Clang + ? llvm::abi::SmallIntABICompatKind::Clang23 : llvm::abi::SmallIntABICompatKind::Both; return abiCompat; } diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 9226f110728dfe..27485e9fd02fce 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -415,14 +415,14 @@ static void initializeX86ABICompatInfo(llvm::abi::X86ABICompatInfo &CompatInfo, CompatInfo.ClassifyUnnamedBitFields = Compat > LangOptions::ClangABI::Ver23 && !T.isPS(); if (T.isOSDarwin() || T.isPS()) { - CompatInfo.SmallIntABICompat = llvm::abi::SmallIntABICompatKind::Clang; + CompatInfo.SmallIntABICompat = llvm::abi::SmallIntABICompatKind::Clang23; } else { switch (CGOpts.getSmallIntABICompat()) { case CodeGenOptions::SmallIntABICompatKind::Platform: CompatInfo.SmallIntABICompat = llvm::abi::SmallIntABICompatKind::Platform; break; - case CodeGenOptions::SmallIntABICompatKind::Clang: - CompatInfo.SmallIntABICompat = llvm::abi::SmallIntABICompatKind::Clang; + case CodeGenOptions::SmallIntABICompatKind::Clang23: + CompatInfo.SmallIntABICompat = llvm::abi::SmallIntABICompatKind::Clang23; break; case CodeGenOptions::SmallIntABICompatKind::Both: CompatInfo.SmallIntABICompat = llvm::abi::SmallIntABICompatKind::Both; diff --git a/clang/lib/CodeGen/Targets/X86.cpp b/clang/lib/CodeGen/Targets/X86.cpp index caf1769ea52bad..01788d55eb29d4 100644 --- a/clang/lib/CodeGen/Targets/X86.cpp +++ b/clang/lib/CodeGen/Targets/X86.cpp @@ -475,7 +475,7 @@ static CodeGenOptions::SmallIntABICompatKind getEffectiveSmallIntABICompat(const CodeGenOptions &Opts, const llvm::Triple &T) { if (T.isOSDarwin() || T.isPS()) - return CodeGenOptions::SmallIntABICompatKind::Clang; + return CodeGenOptions::SmallIntABICompatKind::Clang23; return Opts.getSmallIntABICompat(); } @@ -1013,7 +1013,7 @@ ABIArgInfo X86_32ABIInfo::classifyArgumentType(QualType Ty, CCState &State, : ABIArgInfo::getConservativeExtend(Ty, CGT.ConvertType(Ty)); } break; - case CodeGenOptions::SmallIntABICompatKind::Clang: + case CodeGenOptions::SmallIntABICompatKind::Clang23: return InReg ? ABIArgInfo::getExtendInReg(Ty, CGT.ConvertType(Ty)) : ABIArgInfo::getExtend(Ty, CGT.ConvertType(Ty)); case CodeGenOptions::SmallIntABICompatKind::Both: @@ -3032,7 +3032,7 @@ X86_64ABIInfo::classifyArgumentType(QualType Ty, unsigned freeIntRegs, return ABIArgInfo::getConservativeExtend(Ty, CGT.ConvertType(Ty)); } break; - case CodeGenOptions::SmallIntABICompatKind::Clang: + case CodeGenOptions::SmallIntABICompatKind::Clang23: return ABIArgInfo::getExtend(Ty, CGT.ConvertType(Ty)); case CodeGenOptions::SmallIntABICompatKind::Both: return ABIArgInfo::getConservativeExtend(Ty, CGT.ConvertType(Ty)); diff --git a/clang/test/CodeGen/X86/bool_argument_passing.c b/clang/test/CodeGen/X86/bool_argument_passing.c index 2ee4e122486781..8aee9c4b156500 100644 --- a/clang/test/CodeGen/X86/bool_argument_passing.c +++ b/clang/test/CodeGen/X86/bool_argument_passing.c @@ -1,10 +1,10 @@ // RUN: %clang_cc1 -triple x86_64-linux-gnu %s -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK-BOTH // RUN: %clang_cc1 -triple x86_64-linux-gnu -msmall-int-abi-compat=both %s -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK-BOTH -// RUN: %clang_cc1 -triple x86_64-linux-gnu -msmall-int-abi-compat=clang %s -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK-CLANG +// RUN: %clang_cc1 -triple x86_64-linux-gnu -msmall-int-abi-compat=clang-23 %s -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK-CLANG // RUN: %clang_cc1 -triple x86_64-linux-gnu -msmall-int-abi-compat=platform %s -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK-PLATFORM // RUN: %clang_cc1 -triple x86_64-linux-gnu -fexperimental-abi-lowering %s -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK-BOTH // RUN: %clang_cc1 -triple x86_64-linux-gnu -msmall-int-abi-compat=both -fexperimental-abi-lowering %s -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK-BOTH -// RUN: %clang_cc1 -triple x86_64-linux-gnu -msmall-int-abi-compat=clang -fexperimental-abi-lowering %s -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK-CLANG +// RUN: %clang_cc1 -triple x86_64-linux-gnu -msmall-int-abi-compat=clang-23 -fexperimental-abi-lowering %s -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK-CLANG // RUN: %clang_cc1 -triple x86_64-linux-gnu -msmall-int-abi-compat=platform -fexperimental-abi-lowering %s -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK-PLATFORM // -msmall-int-abi-compat=platform only needs to extend to 8-bits in the caller diff --git a/clang/test/CodeGen/X86/integer_argument_passing.c b/clang/test/CodeGen/X86/integer_argument_passing.c index fac47918455ed8..a44e25a9a58736 100644 --- a/clang/test/CodeGen/X86/integer_argument_passing.c +++ b/clang/test/CodeGen/X86/integer_argument_passing.c @@ -19,18 +19,18 @@ // Test -msmall-int-abi-compat flag // RUN: %clang_cc1 -triple x86_64-linux-gnu -msmall-int-abi-compat=both %s -emit-llvm -o - | FileCheck %s --check-prefixes=CALLER-EXTEND,CALLEE-NO-ASSUME-EXTENDED // RUN: %clang_cc1 -triple x86_64-linux-gnu -msmall-int-abi-compat=platform %s -emit-llvm -o - | FileCheck %s --check-prefixes=CALLER-NO-EXTEND,CALLEE-NO-ASSUME-EXTENDED -// RUN: %clang_cc1 -triple x86_64-linux-gnu -msmall-int-abi-compat=clang %s -emit-llvm -o - | FileCheck %s --check-prefixes=CALLER-EXTEND,CALLEE-ASSUME-EXTENDED +// RUN: %clang_cc1 -triple x86_64-linux-gnu -msmall-int-abi-compat=clang-23 %s -emit-llvm -o - | FileCheck %s --check-prefixes=CALLER-EXTEND,CALLEE-ASSUME-EXTENDED // RUN: %clang_cc1 -triple x86_64-linux-gnu -msmall-int-abi-compat=both -fexperimental-abi-lowering %s -emit-llvm -o - | FileCheck %s --check-prefixes=CALLER-EXTEND,CALLEE-NO-ASSUME-EXTENDED // RUN: %clang_cc1 -triple x86_64-linux-gnu -msmall-int-abi-compat=platform -fexperimental-abi-lowering %s -emit-llvm -o - | FileCheck %s --check-prefixes=CALLER-NO-EXTEND,CALLEE-NO-ASSUME-EXTENDED -// RUN: %clang_cc1 -triple x86_64-linux-gnu -msmall-int-abi-compat=clang -fexperimental-abi-lowering %s -emit-llvm -o - | FileCheck %s --check-prefixes=CALLER-EXTEND,CALLEE-ASSUME-EXTENDED +// RUN: %clang_cc1 -triple x86_64-linux-gnu -msmall-int-abi-compat=clang-23 -fexperimental-abi-lowering %s -emit-llvm -o - | FileCheck %s --check-prefixes=CALLER-EXTEND,CALLEE-ASSUME-EXTENDED // // Check that the flag has no effect on targets with different platform ABI. // RUN: %clang_cc1 -triple x86_64-apple-darwin -msmall-int-abi-compat=both %s -emit-llvm -o - | FileCheck %s --check-prefixes=CALLER-EXTEND,CALLEE-ASSUME-EXTENDED // RUN: %clang_cc1 -triple x86_64-apple-darwin -msmall-int-abi-compat=platform %s -emit-llvm -o - | FileCheck %s --check-prefixes=CALLER-EXTEND,CALLEE-ASSUME-EXTENDED -// RUN: %clang_cc1 -triple x86_64-apple-darwin -msmall-int-abi-compat=clang %s -emit-llvm -o - | FileCheck %s --check-prefixes=CALLER-EXTEND,CALLEE-ASSUME-EXTENDED +// RUN: %clang_cc1 -triple x86_64-apple-darwin -msmall-int-abi-compat=clang-23 %s -emit-llvm -o - | FileCheck %s --check-prefixes=CALLER-EXTEND,CALLEE-ASSUME-EXTENDED // RUN: %clang_cc1 -triple x86_64-apple-darwin -msmall-int-abi-compat=both -fexperimental-abi-lowering %s -emit-llvm -o - | FileCheck %s --check-prefixes=CALLER-EXTEND,CALLEE-ASSUME-EXTENDED // RUN: %clang_cc1 -triple x86_64-apple-darwin -msmall-int-abi-compat=platform -fexperimental-abi-lowering %s -emit-llvm -o - | FileCheck %s --check-prefixes=CALLER-EXTEND,CALLEE-ASSUME-EXTENDED -// RUN: %clang_cc1 -triple x86_64-apple-darwin -msmall-int-abi-compat=clang -fexperimental-abi-lowering %s -emit-llvm -o - | FileCheck %s --check-prefixes=CALLER-EXTEND,CALLEE-ASSUME-EXTENDED +// RUN: %clang_cc1 -triple x86_64-apple-darwin -msmall-int-abi-compat=clang-23 -fexperimental-abi-lowering %s -emit-llvm -o - | FileCheck %s --check-prefixes=CALLER-EXTEND,CALLEE-ASSUME-EXTENDED // CALLEE-ASSUME-EXTENDED: define{{.*}} i32 @ZeroExtend(i8 noundef zeroext %a, i16 noundef zeroext %b) // CALLEE-NO-ASSUME-EXTENDED: define{{.*}} i32 @ZeroExtend(i8 noundef %a, i16 noundef %b) diff --git a/llvm/include/llvm/ABI/TargetInfo.h b/llvm/include/llvm/ABI/TargetInfo.h index cd88f2ce0492eb..e61912588a301e 100644 --- a/llvm/include/llvm/ABI/TargetInfo.h +++ b/llvm/include/llvm/ABI/TargetInfo.h @@ -53,7 +53,7 @@ enum class SmallIntABICompatKind { /// Compat with platform ABI (high bits unspecified). Platform, /// Compat with old Clang ABI (high bits zero/sign-extended). - Clang, + Clang23, /// Compat with both. Extend in caller, don't assume in callee. Both, }; diff --git a/llvm/lib/ABI/Targets/X86.cpp b/llvm/lib/ABI/Targets/X86.cpp index 97d1549c1538d4..8f886f175d31c6 100644 --- a/llvm/lib/ABI/Targets/X86.cpp +++ b/llvm/lib/ABI/Targets/X86.cpp @@ -659,7 +659,7 @@ X86_64TargetInfo::classifyArgumentType(const Type *Ty, unsigned FreeIntRegs, return ArgInfo::getConservativeExtend(Ty); } break; - case SmallIntABICompatKind::Clang: + case SmallIntABICompatKind::Clang23: return ArgInfo::getExtend(Ty); case SmallIntABICompatKind::Both: return ArgInfo::getConservativeExtend(Ty); diff --git a/llvm/unittests/ABI/X86TargetInfoTest.cpp b/llvm/unittests/ABI/X86TargetInfoTest.cpp index 0edcd3dd6c277e..81dc2fbfe3433f 100644 --- a/llvm/unittests/ABI/X86TargetInfoTest.cpp +++ b/llvm/unittests/ABI/X86TargetInfoTest.cpp @@ -1001,12 +1001,14 @@ TEST_F(X86TargetInfoTest, IntArgExtension) { std::unique_ptr<FunctionInfo> FI; std::unique_ptr<TargetInfo> TI; - // Clang: extend in the caller and assume the extension in the callee. - expectExtendInteger(ClassifyArg(I8, SmallIntABICompatKind::Clang, FI, TI), I8, + // Clang23: extend in the caller and assume the extension in the callee. + expectExtendInteger(ClassifyArg(I8, SmallIntABICompatKind::Clang23, FI, TI), + I8, /*IsSigned=*/true); - expectExtendInteger(ClassifyArg(U8, SmallIntABICompatKind::Clang, FI, TI), U8, + expectExtendInteger(ClassifyArg(U8, SmallIntABICompatKind::Clang23, FI, TI), + U8, /*IsSigned=*/false); - expectExtendInteger(ClassifyArg(Bool, SmallIntABICompatKind::Clang, FI, TI), + expectExtendInteger(ClassifyArg(Bool, SmallIntABICompatKind::Clang23, FI, TI), Bool, /*IsSigned=*/false); // Both: extend in the caller, but do not assume it in the callee. @@ -1032,8 +1034,9 @@ TEST_F(X86TargetInfoTest, IntArgExtension) { /*IsSigned=*/false); // int is never extended. - for (auto Kind : {SmallIntABICompatKind::Platform, - SmallIntABICompatKind::Clang, SmallIntABICompatKind::Both}) + for (auto Kind : + {SmallIntABICompatKind::Platform, SmallIntABICompatKind::Clang23, + SmallIntABICompatKind::Both}) expectDirectInteger(ClassifyArg(I32, Kind, FI, TI), 32); } `````````` </details> https://github.com/llvm/llvm-project/pull/243881 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
