Skip to content

Commit

Permalink
Codegen: don't incorrectly share metadata across llvm modules
Browse files Browse the repository at this point in the history
  • Loading branch information
asterite committed Sep 15, 2017
1 parent 3e68043 commit b5484e4
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/compiler/crystal/codegen/debug.cr
Expand Up @@ -38,8 +38,14 @@ module Crystal
di_builder.create_subroutine_type(nil, int1)
end

def debug_type_cache
@debug_types ||= {} of Type => LibLLVMExt::Metadata?
def debug_type_cache(llvm_module = @llvm_mod)
# We must cache debug types per module so metadata of a type
# from one module isn't incorrectly used in another module.
debug_types_per_module =
@debug_types_per_module ||=
{} of LLVM::Module => Hash(Type, LibLLVMExt::Metadata?)

debug_types_per_module[llvm_module] ||= {} of Type => LibLLVMExt::Metadata?
end

def get_debug_type(type)
Expand Down

0 comments on commit b5484e4

Please sign in to comment.