Skip to content

Commit 3959231

Browse files
committed
[X86][FastISel] Bail out on large objects when materializing a GlobalValue
To avoid crashes with explicitly large objects. I will clean up fast-isel with large objects/medium code model soon.
1 parent 047399c commit 3959231

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

llvm/lib/Target/X86/X86FastISel.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,12 @@ bool X86FastISel::handleConstantAddresses(const Value *V, X86AddressMode &AM) {
714714
if (TM.getCodeModel() != CodeModel::Small)
715715
return false;
716716

717+
// Can't handle large objects yet.
718+
if (auto *GO = dyn_cast<GlobalObject>(GV)) {
719+
if (TM.isLargeGlobalObject(GO))
720+
return false;
721+
}
722+
717723
// Can't handle TLS yet.
718724
if (GV->isThreadLocal())
719725
return false;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 4
2+
; RUN: llc -fast-isel -mtriple=x86_64-unknown-unknown -relocation-model=pic < %s | FileCheck %s
3+
4+
@g = external dso_local global i32, code_model "large"
5+
6+
define ptr @f() {
7+
; CHECK-LABEL: f:
8+
; CHECK: # %bb.0:
9+
; CHECK-NEXT: leaq _GLOBAL_OFFSET_TABLE_(%rip), %rax
10+
; CHECK-NEXT: leaq g@GOTOFF(%rax), %rax
11+
; CHECK-NEXT: retq
12+
ret ptr @g
13+
}

0 commit comments

Comments
 (0)