-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[clang] Implement gcc_struct attribute on Itanium targets #71148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4861,9 +4861,7 @@ def mmacos_version_min_EQ : Joined<["-"], "mmacos-version-min=">, | |
def : Joined<["-"], "mmacosx-version-min=">, | ||
Group<m_Group>, Alias<mmacos_version_min_EQ>; | ||
def mms_bitfields : Flag<["-"], "mms-bitfields">, Group<m_Group>, | ||
Visibility<[ClangOption, CC1Option]>, | ||
HelpText<"Set the default structure layout to be compatible with the Microsoft compiler standard">, | ||
MarshallingInfoFlag<LangOpts<"MSBitfields">>; | ||
HelpText<"Set the default structure layout to be compatible with the Microsoft compiler standard">; | ||
|
||
def moutline : Flag<["-"], "moutline">, Group<f_clang_Group>, | ||
Visibility<[ClangOption, CC1Option]>, | ||
HelpText<"Enable function outlining (AArch64 only)">; | ||
|
@@ -4872,6 +4870,12 @@ def mno_outline : Flag<["-"], "mno-outline">, Group<f_clang_Group>, | |
HelpText<"Disable function outlining (AArch64 only)">; | ||
def mno_ms_bitfields : Flag<["-"], "mno-ms-bitfields">, Group<m_Group>, | ||
HelpText<"Do not set the default structure layout to be compatible with the Microsoft compiler standard">; | ||
def fms_layout_compatibility_EQ : Joined<["-"], "fms-layout-compatibility=">, | ||
Visibility<[CC1Option]>, | ||
HelpText<"Structure layout compatibility with Microsoft C++ ABI">, | ||
Values<"default,itanium,microsoft">, | ||
NormalizedValues<["Default", "Itanium", "Microsoft"]>, NormalizedValuesScope<"LangOptions::LayoutCompatibilityKind">, | ||
MarshallingInfoEnum<LangOpts<"LayoutCompatibility">, "Default">; | ||
def mskip_rax_setup : Flag<["-"], "mskip-rax-setup">, Group<m_Group>, | ||
Visibility<[ClangOption, CC1Option]>, | ||
HelpText<"Skip setting up RAX register when passing variable arguments (x86 only)">, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6113,9 +6113,13 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, | |
if (KernelOrKext && RawTriple.isOSDarwin()) | ||
CmdArgs.push_back("-fforbid-guard-variables"); | ||
|
||
if (Args.hasFlag(options::OPT_mms_bitfields, options::OPT_mno_ms_bitfields, | ||
Triple.isWindowsGNUEnvironment())) { | ||
CmdArgs.push_back("-mms-bitfields"); | ||
if (Args.hasArg(options::OPT_mms_bitfields) || | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the LangOption default varies across targets, and you want to forward the driver option to clang -cc1,
|
||
Args.hasArg(options::OPT_mno_ms_bitfields)) { | ||
if (Args.hasFlag(options::OPT_mms_bitfields, options::OPT_mno_ms_bitfields, | ||
false)) | ||
CmdArgs.push_back("-fms-layout-compatibility=microsoft"); | ||
else | ||
CmdArgs.push_back("-fms-layout-compatibility=itanium"); | ||
} | ||
|
||
if (Triple.isWindowsGNUEnvironment()) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// RUN: %clang_cc1 -emit-llvm-only -triple x86_64-pc-windows-msvc -verify %s | ||
|
||
// expected-error@+1 {{Itanium-compatible layout for the Microsoft C++ ABI is not yet supported}} | ||
struct { | ||
int a; | ||
} __attribute__((gcc_struct)) t1; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// RUN: %clang_cc1 -emit-llvm-only -triple x86_64-pc-windows-msvc -fms-layout-compatibility=itanium -verify %s | ||
|
||
// expected-error@+1 {{Itanium-compatible layout for the Microsoft C++ ABI is not yet supported}} | ||
struct { | ||
int a; | ||
} t1; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// RUN: %clang_cc1 -emit-llvm-only -triple x86_64-pc-linux-gnu %s | ||
// RUN: %clang_cc1 -emit-llvm-only -triple x86_64-pc-linux-gnu -fms-layout-compatibility=microsoft %s | ||
// RUN: %clang_cc1 -emit-llvm-only -triple x86_64-pc-windows-gnu %s | ||
// RUN: %clang_cc1 -emit-llvm-only -triple x86_64-pc-windows-gnu -fms-layout-compatibility=itanium %s | ||
|
||
struct { | ||
int a : 24; | ||
char b : 8; | ||
} __attribute__((gcc_struct)) t1; | ||
_Static_assert(sizeof(t1) == 4, ""); | ||
|
||
#pragma ms_struct on | ||
struct { | ||
int a : 24; | ||
char b : 8; | ||
} __attribute__((gcc_struct)) t2; | ||
_Static_assert(sizeof(t2) == 4, ""); | ||
#pragma ms_struct off |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,15 @@ | ||
// RUN: %clang -### --target=x86_64-linux-gnu %s 2>&1 | FileCheck %s -check-prefix=NO-MSBITFIELDS | ||
// RUN: %clang -### --target=x86_64-windows-gnu %s 2>&1 | FileCheck %s -check-prefix=MSBITFIELDS | ||
// RUN: %clang -### -mno-ms-bitfields -mms-bitfields %s 2>&1 | FileCheck %s -check-prefix=MSBITFIELDS | ||
// RUN: %clang -### -mms-bitfields -mno-ms-bitfields %s 2>&1 | FileCheck %s -check-prefix=NO-MSBITFIELDS | ||
// RUN: %clang -### --target=x86_64-linux-gnu %s 2>&1 | FileCheck %s -check-prefix=DEFAULT-LAYOUT | ||
// RUN: %clang -### --target=x86_64-windows-gnu %s 2>&1 | FileCheck %s -check-prefix=DEFAULT-LAYOUT | ||
// RUN: %clang -### --target=x86_64-windows-msvc %s 2>&1 | FileCheck %s -check-prefix=DEFAULT-LAYOUT | ||
// RUN: %clang -### -mms-bitfields %s 2>&1 | FileCheck %s -check-prefix=MICROSOFT-LAYOUT | ||
// RUN: %clang -### -mno-ms-bitfields %s 2>&1 | FileCheck %s -check-prefix=ITANIUM-LAYOUT | ||
// RUN: %clang -### -mno-ms-bitfields -mms-bitfields %s 2>&1 | FileCheck %s -check-prefix=MICROSOFT-LAYOUT | ||
// RUN: %clang -### -mms-bitfields -mno-ms-bitfields %s 2>&1 | FileCheck %s -check-prefix=ITANIUM-LAYOUT | ||
|
||
// MSBITFIELDS: -mms-bitfields | ||
// NO-MSBITFIELDS-NOT: -mms-bitfields | ||
// DEFAULT-LAYOUT-NOT: -fms-layout-compatibility=itanium | ||
// DEFAULT-LAYOUT-NOT: -fms-layout-compatibility=microsoft | ||
// MICROSOFT-LAYOUT: -fms-layout-compatibility=microsoft | ||
// MICROSOFT-LAYOUT-NOT: -fms-layout-compatibility=itanium | ||
// ITANIUM-LAYOUT: -fms-layout-compatibility=itanium | ||
// ITANIUM-LAYOUT-NOT: -fms-layout-compatibility=microsoft | ||
|
Uh oh!
There was an error while loading. Please reload this page.