-
Notifications
You must be signed in to change notification settings - Fork 13.6k
LowerTypeTests: Set small code model on imported globals. #141324
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
LowerTypeTests: Set small code model on imported globals. #141324
Conversation
Created using spr 1.3.6-beta.1 [skip ci]
Created using spr 1.3.6-beta.1
@llvm/pr-subscribers-llvm-transforms Author: Peter Collingbourne (pcc) ChangesThis is either a vtable (in .data.rel.ro) or a jump table (in .text). Full diff: https://github.com/llvm/llvm-project/pull/141324.diff 2 Files Affected:
diff --git a/llvm/lib/Transforms/IPO/LowerTypeTests.cpp b/llvm/lib/Transforms/IPO/LowerTypeTests.cpp
index 51667038575cc..428c4641a7f56 100644
--- a/llvm/lib/Transforms/IPO/LowerTypeTests.cpp
+++ b/llvm/lib/Transforms/IPO/LowerTypeTests.cpp
@@ -1019,8 +1019,14 @@ LowerTypeTestsModule::importTypeId(StringRef TypeId) {
return C;
};
- if (TIL.TheKind != TypeTestResolution::Unsat)
- TIL.OffsetedGlobal = ImportGlobal("global_addr");
+ if (TIL.TheKind != TypeTestResolution::Unsat) {
+ auto *GV = ImportGlobal("global_addr");
+ // This is either a vtable (in .data.rel.ro) or a jump table (in .text).
+ // Either way it's expected to be in the low 2 GiB, so set the small code
+ // model.
+ GV->setCodeModel(CodeModel::Small);
+ TIL.OffsetedGlobal = GV;
+ }
if (TIL.TheKind == TypeTestResolution::ByteArray ||
TIL.TheKind == TypeTestResolution::Inline ||
diff --git a/llvm/test/Transforms/LowerTypeTests/import.ll b/llvm/test/Transforms/LowerTypeTests/import.ll
index 1eff4bbbbdf97..c6566b84a4361 100644
--- a/llvm/test/Transforms/LowerTypeTests/import.ll
+++ b/llvm/test/Transforms/LowerTypeTests/import.ll
@@ -6,29 +6,29 @@ target datalayout = "e-p:64:64"
declare i1 @llvm.type.test(ptr %ptr, metadata %bitset) nounwind readnone
-; CHECK-DAG: @__typeid_single_global_addr = external hidden global [0 x i8]
-; CHECK-DAG: @__typeid_inline6_global_addr = external hidden global [0 x i8]
+; CHECK-DAG: @__typeid_single_global_addr = external hidden global [0 x i8], code_model "small"
+; CHECK-DAG: @__typeid_inline6_global_addr = external hidden global [0 x i8], code_model "small"
; X86-DAG: @__typeid_inline6_align = external hidden global [0 x i8], !absolute_symbol !0
; X86-DAG: @__typeid_inline6_size_m1 = external hidden global [0 x i8], !absolute_symbol !1
; X86-DAG: @__typeid_inline6_inline_bits = external hidden global [0 x i8], !absolute_symbol !2
-; CHECK-DAG: @__typeid_inline5_global_addr = external hidden global [0 x i8]
+; CHECK-DAG: @__typeid_inline5_global_addr = external hidden global [0 x i8], code_model "small"
; X86-DAG: @__typeid_inline5_align = external hidden global [0 x i8], !absolute_symbol !0
; X86-DAG: @__typeid_inline5_size_m1 = external hidden global [0 x i8], !absolute_symbol !3
; X86-DAG: @__typeid_inline5_inline_bits = external hidden global [0 x i8], !absolute_symbol !4
-; CHECK-DAG: @__typeid_bytearray32_global_addr = external hidden global [0 x i8]
+; CHECK-DAG: @__typeid_bytearray32_global_addr = external hidden global [0 x i8], code_model "small"
; X86-DAG: @__typeid_bytearray32_align = external hidden global [0 x i8], !absolute_symbol !0
; X86-DAG: @__typeid_bytearray32_size_m1 = external hidden global [0 x i8], !absolute_symbol !4
; CHECK-DAG: @__typeid_bytearray32_byte_array = external hidden global [0 x i8]
; X86-DAG: @__typeid_bytearray32_bit_mask = external hidden global [0 x i8], !absolute_symbol !0
-; CHECK-DAG: @__typeid_bytearray7_global_addr = external hidden global [0 x i8]
+; CHECK-DAG: @__typeid_bytearray7_global_addr = external hidden global [0 x i8], code_model "small"
; X86-DAG: @__typeid_bytearray7_align = external hidden global [0 x i8], !absolute_symbol !0
; X86-DAG: @__typeid_bytearray7_size_m1 = external hidden global [0 x i8], !absolute_symbol !5
; CHECK-DAG: @__typeid_bytearray7_byte_array = external hidden global [0 x i8]
; X86-DAG: @__typeid_bytearray7_bit_mask = external hidden global [0 x i8], !absolute_symbol !0
-; CHECK-DAG: @__typeid_allones32_global_addr = external hidden global [0 x i8]
+; CHECK-DAG: @__typeid_allones32_global_addr = external hidden global [0 x i8], code_model "small"
; X86-DAG: @__typeid_allones32_align = external hidden global [0 x i8], !absolute_symbol !0
; X86-DAG: @__typeid_allones32_size_m1 = external hidden global [0 x i8], !absolute_symbol !4
-; CHECK-DAG: @__typeid_allones7_global_addr = external hidden global [0 x i8]
+; CHECK-DAG: @__typeid_allones7_global_addr = external hidden global [0 x i8], code_model "small"
; X86-DAG: @__typeid_allones7_align = external hidden global [0 x i8], !absolute_symbol !0
; X86-DAG: @__typeid_allones7_size_m1 = external hidden global [0 x i8], !absolute_symbol !5
|
if (TIL.TheKind != TypeTestResolution::Unsat) { | ||
auto *GV = ImportGlobal("global_addr"); | ||
// This is either a vtable (in .data.rel.ro) or a jump table (in .text). | ||
// Either way it's expected to be in the low 2 GiB, so set the small code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
preferably there would be some reference why we would expect that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added comment with an explanation.
Created using spr 1.3.6-beta.1 [skip ci]
Created using spr 1.3.6-beta.1
This is either a vtable (in .data.rel.ro) or a jump table (in .text). Either way it's expected to be in the low 2 GiB, so set the small code model. Reviewers: fmayer Reviewed By: fmayer Pull Request: llvm/llvm-project#141324
This is either a vtable (in .data.rel.ro) or a jump table (in .text).
Either way it's expected to be in the low 2 GiB, so set the small
code model.