Skip to content

Commit 5172d01

Browse files
authored
Fix: don't set external linkage when @[NoInline] is specified (#15424)
Unlike `alwaysinline` that is treated by LLVM as a simple hint, the `noinline` function attribute is enough to tell LLVM to always generate the symbol and never inline the calls (even with aggressive optimizations). We don't need to set the linkage to external.
1 parent 34a3f45 commit 5172d01

File tree

1 file changed

+2
-6
lines changed
  • src/compiler/crystal/codegen

1 file changed

+2
-6
lines changed

src/compiler/crystal/codegen/fun.cr

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ class Crystal::CodeGenVisitor
337337
end
338338
end
339339

340-
if @single_module && !target_def.no_inline? && !target_def.is_a?(External)
340+
if @single_module && !target_def.is_a?(External)
341341
context.fun.linkage = LLVM::Linkage::Internal
342342
end
343343

@@ -448,11 +448,7 @@ class Crystal::CodeGenVisitor
448448
context.fun.add_attribute LLVM::Attribute::ReturnsTwice if target_def.returns_twice?
449449
context.fun.add_attribute LLVM::Attribute::Naked if target_def.naked?
450450
context.fun.add_attribute LLVM::Attribute::NoReturn if target_def.no_returns?
451-
452-
if target_def.no_inline?
453-
context.fun.add_attribute LLVM::Attribute::NoInline
454-
context.fun.linkage = LLVM::Linkage::External
455-
end
451+
context.fun.add_attribute LLVM::Attribute::NoInline if target_def.no_inline?
456452
end
457453

458454
def setup_closure_vars(def_vars, closure_vars, context, closure_type, closure_ptr)

0 commit comments

Comments
 (0)