[llvm] 3959231 - [X86][FastISel] Bail out on large objects when materializing a GlobalValue

Arthur Eubanks via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 12 12:45:40 PST 2023


Author: Arthur Eubanks
Date: 2023-12-12T12:45:20-08:00
New Revision: 3959231695a088e1d8ca0bf8f9d2e5cf9c61a17a

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

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

Added: 
    llvm/test/CodeGen/X86/fast-isel-large-object.ll

Modified: 
    llvm/lib/Target/X86/X86FastISel.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/X86/X86FastISel.cpp b/llvm/lib/Target/X86/X86FastISel.cpp
index 068119a6332a6..bdc9d1d42dd16 100644
--- a/llvm/lib/Target/X86/X86FastISel.cpp
+++ b/llvm/lib/Target/X86/X86FastISel.cpp
@@ -714,6 +714,12 @@ bool X86FastISel::handleConstantAddresses(const Value *V, X86AddressMode &AM) {
     if (TM.getCodeModel() != CodeModel::Small)
       return false;
 
+    // Can't handle large objects yet.
+    if (auto *GO = dyn_cast<GlobalObject>(GV)) {
+      if (TM.isLargeGlobalObject(GO))
+        return false;
+    }
+
     // Can't handle TLS yet.
     if (GV->isThreadLocal())
       return false;

diff  --git a/llvm/test/CodeGen/X86/fast-isel-large-object.ll b/llvm/test/CodeGen/X86/fast-isel-large-object.ll
new file mode 100644
index 0000000000000..6ca2c42407237
--- /dev/null
+++ b/llvm/test/CodeGen/X86/fast-isel-large-object.ll
@@ -0,0 +1,13 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 4
+; RUN: llc -fast-isel -mtriple=x86_64-unknown-unknown -relocation-model=pic < %s | FileCheck %s
+
+ at g = external dso_local global i32, code_model "large"
+
+define ptr @f() {
+; CHECK-LABEL: f:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    leaq _GLOBAL_OFFSET_TABLE_(%rip), %rax
+; CHECK-NEXT:    leaq g at GOTOFF(%rax), %rax
+; CHECK-NEXT:    retq
+  ret ptr @g
+}


        


More information about the llvm-commits mailing list