Skip to content

Commit b7ac16c

Browse files
authored
[clang] Default x86-64's medium code model -mlarge-data-threshold to 65535 (#67506)
This matches gcc. This means that by default, under x86-64's medium code model we treat globals < 2^16 bytes as "small data" and globals >= 2^16 bytes as "large data". The previous clang behavior of treating all data as "large data" can be set with `-mlarge-data-threshold=0`. See https://discourse.llvm.org/t/rfc-matching-gccs-mlarge-data-threshold-for-x86-64s-medium-code-model/73727.
1 parent 9d6ec28 commit b7ac16c

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

clang/include/clang/Driver/Options.td

+1-1
Original file line numberDiff line numberDiff line change
@@ -4287,7 +4287,7 @@ def mcmodel_EQ : Joined<["-"], "mcmodel=">, Group<m_Group>,
42874287
MarshallingInfoString<TargetOpts<"CodeModel">, [{"default"}]>;
42884288
def mlarge_data_threshold_EQ : Joined<["-"], "mlarge-data-threshold=">, Group<m_Group>,
42894289
Visibility<[ClangOption, CC1Option]>,
4290-
MarshallingInfoInt<TargetOpts<"LargeDataThreshold">>;
4290+
MarshallingInfoInt<TargetOpts<"LargeDataThreshold">, "65535">;
42914291
def mtls_size_EQ : Joined<["-"], "mtls-size=">, Group<m_Group>,
42924292
Flags<[NoXarchOption]>, Visibility<[ClangOption, CC1Option]>,
42934293
HelpText<"Specify bit size of immediate TLS offsets (AArch64 ELF only): "

clang/test/CodeGen/large-data-threshold.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -S %s -o - -mcmodel=medium -mlarge-data-threshold=200 | FileCheck %s --check-prefix=ASM-SMALL
66
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -S %s -o - -mcmodel=medium -mlarge-data-threshold=2 | FileCheck %s --check-prefix=ASM-LARGE
77

8-
// IR-DEFAULT: !{i32 1, !"Large Data Threshold", i64 0}
8+
// IR-DEFAULT: !{i32 1, !"Large Data Threshold", i64 65535}
99
// IR-CUSTOM: !{i32 1, !"Large Data Threshold", i64 200}
1010

1111
// ASM-SMALL-NOT: movabsq

0 commit comments

Comments
 (0)