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

Only refer to LLVM symbol table in calls to Symbol#to_s #15486

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
11 changes: 10 additions & 1 deletion src/compiler/crystal/codegen/codegen.cr
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,16 @@ module Crystal
end

def define_symbol_table(llvm_mod, llvm_typer)
llvm_mod.globals.add llvm_typer.llvm_type(@program.string).array(@symbol_table_values.size), SYMBOL_TABLE_NAME
llvm_mod.globals[SYMBOL_TABLE_NAME]? || begin
global = llvm_mod.globals.add llvm_typer.llvm_type(@program.string).array(@symbol_table_values.size), SYMBOL_TABLE_NAME
if llvm_mod != @main_mod
global.linkage = LLVM::Linkage::External
elsif @single_module
global.linkage = LLVM::Linkage::Internal
end
global.global_constant = true
global
end
end

def define_slice_constant(info : Program::ConstSliceInfo)
Expand Down
1 change: 0 additions & 1 deletion src/compiler/crystal/codegen/fun.cr
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,6 @@ class Crystal::CodeGenVisitor
llvm_mod = configure_module(llvm_context.new_module(type_name))
llvm_builder = new_builder(llvm_context)

define_symbol_table llvm_mod, llvm_typer
ModuleInfo.new(llvm_mod, llvm_typer, llvm_builder)
end
end
Expand Down
3 changes: 2 additions & 1 deletion src/compiler/crystal/codegen/primitives.cr
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,8 @@ class Crystal::CodeGenVisitor
def codegen_primitive_symbol_to_s(node, target_def, call_args)
string = llvm_type(@program.string)
table_type = string.array(@symbol_table_values.size)
string_ptr = gep table_type, @llvm_mod.globals[SYMBOL_TABLE_NAME], int(0), call_args[0]
table = define_symbol_table(@llvm_mod, @llvm_typer)
string_ptr = gep table_type, table, int(0), call_args[0]
load(string, string_ptr)
end

Expand Down