Thanks to visit codestin.com
Credit goes to github.com

Skip to content

@naked attribute does not work on lambdas #2346

@rickyadastra

Description

@rickyadastra

Compiling a lambda with the @naked attribute does not remove prologue and epilogue.

// test.c3
alias IntFn = fn int();

IntFn lambda @export = fn () => 1;
IntFn lambda_naked @export = fn () @naked => 2;

Compile with c3c compile-only test.c3 and look at the generated code with objdump -d, both lambdas are the same:

0000000000000000 <test.$global$lambda2>:
   0:   55                      push   %rbp
   1:   48 89 e5                mov    %rsp,%rbp
   4:   b8 02 00 00 00          mov    $0x2,%eax
   9:   5d                      pop    %rbp
   a:   c3                      ret    
   b:   0f 1f 44 00 00          nopl   0x0(%rax,%rax,1)

0000000000000010 <test.$global$lambda1>:
  10:   55                      push   %rbp
  11:   48 89 e5                mov    %rsp,%rbp
  14:   b8 01 00 00 00          mov    $0x1,%eax
  19:   5d                      pop    %rbp
  1a:   c3                      ret

C3C version is 0.7.3

Metadata

Metadata

Assignees

Labels

BugSomething isn't workingFixed needs testingNeeds verification / testing that it now works

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions