Skip to content
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

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

Merged
merged 1 commit into from
Oct 4, 2023

Conversation

aeubanks
Copy link
Contributor

@aeubanks aeubanks commented Sep 27, 2023

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.

@llvmbot llvmbot added the clang Clang issues not falling into any other category label Sep 27, 2023
@llvmbot
Copy link
Member

llvmbot commented Sep 27, 2023

@llvm/pr-subscribers-clang

Changes

This matches gcc.

See https://discourse.llvm.org/t/rfc-matching-gccs-mlarge-data-threshold-for-x86-64s-medium-code-model/73727.


Full diff: https://github.com/llvm/llvm-project/pull/67506.diff

2 Files Affected:

  • (modified) clang/include/clang/Driver/Options.td (+1-1)
  • (modified) clang/test/CodeGen/large-data-threshold.c (+1-1)
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index f573f5a06ceb501..5030a709f14a1f3 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4250,7 +4250,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

@aeubanks aeubanks requested review from rnk and jyknight September 28, 2023 17:49
@aeubanks aeubanks changed the title [clang] Default x86_64's medium code model -mlarge-data-threshold to 65535 [clang] Default x86-64's medium code model -mlarge-data-threshold to 65535 Sep 28, 2023
Copy link
Collaborator

@rnk rnk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@aeubanks aeubanks merged commit b7ac16c into llvm:main Oct 4, 2023
@aeubanks aeubanks deleted the medium branch October 4, 2023 20:06
@tnv01 tnv01 mentioned this pull request Oct 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants