[clang] b7ac16c - [clang] Default x86-64's medium code model -mlarge-data-threshold to 65535 (#67506)

via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 4 13:06:29 PDT 2023


Author: Arthur Eubanks
Date: 2023-10-04T13:06:23-07:00
New Revision: b7ac16c70faf7274119f393797ce89c054346f48

URL: https://github.com/llvm/llvm-project/commit/b7ac16c70faf7274119f393797ce89c054346f48
DIFF: https://github.com/llvm/llvm-project/commit/b7ac16c70faf7274119f393797ce89c054346f48.diff

LOG: [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.

Added: 
    

Modified: 
    clang/include/clang/Driver/Options.td
    clang/test/CodeGen/large-data-threshold.c

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 7f7024b4ddb50c1..74f255624ce2cd6 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4287,7 +4287,7 @@ def mcmodel_EQ : Joined<["-"], "mcmodel=">, Group<m_Group>,
   MarshallingInfoString<TargetOpts<"CodeModel">, [{"default"}]>;
 def mlarge_data_threshold_EQ : Joined<["-"], "mlarge-data-threshold=">, Group<m_Group>,
   Visibility<[ClangOption, CC1Option]>,
-  MarshallingInfoInt<TargetOpts<"LargeDataThreshold">>;
+  MarshallingInfoInt<TargetOpts<"LargeDataThreshold">, "65535">;
 def mtls_size_EQ : Joined<["-"], "mtls-size=">, Group<m_Group>,
   Flags<[NoXarchOption]>, Visibility<[ClangOption, CC1Option]>,
   HelpText<"Specify bit size of immediate TLS offsets (AArch64 ELF only): "

diff  --git a/clang/test/CodeGen/large-data-threshold.c b/clang/test/CodeGen/large-data-threshold.c
index 650a7fbb0094e66..29ae19e9b718994 100644
--- a/clang/test/CodeGen/large-data-threshold.c
+++ b/clang/test/CodeGen/large-data-threshold.c
@@ -5,7 +5,7 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -S %s -o - -mcmodel=medium -mlarge-data-threshold=200 | FileCheck %s --check-prefix=ASM-SMALL
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -S %s -o - -mcmodel=medium -mlarge-data-threshold=2 | FileCheck %s --check-prefix=ASM-LARGE
 
-// IR-DEFAULT: !{i32 1, !"Large Data Threshold", i64 0}
+// IR-DEFAULT: !{i32 1, !"Large Data Threshold", i64 65535}
 // IR-CUSTOM: !{i32 1, !"Large Data Threshold", i64 200}
 
 // ASM-SMALL-NOT: movabsq


        


More information about the cfe-commits mailing list