Skip to content

llvm: Set warn-stack-size=0 on naked functions.#21207

Closed
alexrp wants to merge 1 commit intoziglang:masterfrom
alexrp:llvm-naked-fn-stack-size
Closed

llvm: Set warn-stack-size=0 on naked functions.#21207
alexrp wants to merge 1 commit intoziglang:masterfrom
alexrp:llvm-naked-fn-stack-size

Conversation

@alexrp
Copy link
Copy Markdown
Member

@alexrp alexrp commented Aug 26, 2024

This makes LLVM produce a warning if any stack allocations happen.

As suggested by @zeroZshadow after discussion about #21193:

zig4 build-obj naked.zig -target powerpc-freestanding-eabi
warning: naked.zig:1:0: stack frame size (4) exceeds limit (0) in function 'someFunc'

It's not the most ideal way to surface this information, but it's a lot better than silently wrong codegen.

This makes LLVM produce a warning if *any* stack allocations happen.
@alexrp
Copy link
Copy Markdown
Member Author

alexrp commented Aug 26, 2024

Just to be clear, this is for stack allocations that LLVM introduces, not us, so #21082 does not help with this. When compiling in debug mode, LLVM's register allocator seems to use a fast but low-quality block-local allocation strategy that results in spills for any branch, which is what happened in #21193.

@andrewrk
Copy link
Copy Markdown
Member

I don't find this to be acceptable. Writing some crap to stderr when the requirements cannot be met is the wrong road to go down. Take it up with the LLVM devs, this is not a good enough API for us.

@andrewrk andrewrk closed this Aug 30, 2024
@alexrp alexrp deleted the llvm-naked-fn-stack-size branch August 31, 2024 01:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants