Skip to content

Commit

Permalink
Fix: don't set external linkage when @[NoInline] is specified (#15424)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ysbaddaden authored Feb 7, 2025
1 parent 34a3f45 commit 5172d01
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/compiler/crystal/codegen/fun.cr
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ class Crystal::CodeGenVisitor
end
end

if @single_module && !target_def.no_inline? && !target_def.is_a?(External)
if @single_module && !target_def.is_a?(External)
context.fun.linkage = LLVM::Linkage::Internal
end

Expand Down Expand Up @@ -448,11 +448,7 @@ class Crystal::CodeGenVisitor
context.fun.add_attribute LLVM::Attribute::ReturnsTwice if target_def.returns_twice?
context.fun.add_attribute LLVM::Attribute::Naked if target_def.naked?
context.fun.add_attribute LLVM::Attribute::NoReturn if target_def.no_returns?

if target_def.no_inline?
context.fun.add_attribute LLVM::Attribute::NoInline
context.fun.linkage = LLVM::Linkage::External
end
context.fun.add_attribute LLVM::Attribute::NoInline if target_def.no_inline?
end

def setup_closure_vars(def_vars, closure_vars, context, closure_type, closure_ptr)
Expand Down

0 comments on commit 5172d01

Please sign in to comment.