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

Chore: Link i128 constants internally if possible #15217

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading