Skip to content

Commit

Permalink
Chore: Link i128 constants internally if possible (#15217)
Browse files Browse the repository at this point in the history
  • Loading branch information
BlobCodes authored Nov 25, 2024
1 parent fe90f27 commit 558ce7b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/compiler/crystal/codegen/const.cr
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,16 @@ class Crystal::CodeGenVisitor
@main_mod.globals.add(@main_llvm_typer.llvm_type(const.value.type), global_name)

type = const.value.type
# TODO: there's an LLVM bug that prevents us from having internal globals of type i128 or u128:
# TODO: LLVM < 9.0.0 has a bug that prevents us from having internal globals of type i128 or u128:
# https://bugs.llvm.org/show_bug.cgi?id=42932
# so we just use global.
if @single_module && !(type.is_a?(IntegerType) && (type.kind.i128? || type.kind.u128?))
# so we just use global in that case.
{% if compare_versions(Crystal::LLVM_VERSION, "9.0.0") < 0 %}
if @single_module && !(type.is_a?(IntegerType) && (type.kind.i128? || type.kind.u128?))
global.linkage = LLVM::Linkage::Internal
end
{% else %}
global.linkage = LLVM::Linkage::Internal if @single_module
end
{% end %}

global
end
Expand Down

0 comments on commit 558ce7b

Please sign in to comment.