Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple setbounds on the same alloca object even in -Oz #669

Open
Jerryxia32 opened this issue Dec 6, 2022 · 0 comments
Open

Multiple setbounds on the same alloca object even in -Oz #669

Jerryxia32 opened this issue Dec 6, 2022 · 0 comments

Comments

@Jerryxia32
Copy link
Contributor

The function in the code snippet of
https://cheri-compiler-explorer.cl.cam.ac.uk/z/4srf41
creates two allocas which are bounded before being accessed locally or used as arguments to external functions.

However, notice that the two stack arrays have been csetboundsed twice, once before the local zeroing loop and once in the use as arguments, even in -Oz. This has caused a bloat of 20% in code size in certain embedded applications.

When optimising for code size, it would break even with csetbounds on each alloca even if it's used only twice, by storing it (either in a callee-saved register or a stack slot) and loading it back (either a cmove or a clcsp). If the same alloca is used more than twice, then storing and loading definitely wins.

I suspect it has something to do with local and external allocas on different paths, because two external calls on foo() and bar() correctly use callee-saved regs. I would appreciate it if there could be some pointers on a local workaround for this, in case this is non-trivial to fix upstream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants