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

clang inserts stack protector in function with inline assembly "m" constraint #36931

Closed
nickdesaulniers opened this issue May 24, 2018 · 2 comments
Labels
bugzilla Issues migrated from bugzilla clang:as-a-library libclang and C++ API duplicate Resolved as duplicate

Comments

@nickdesaulniers
Copy link
Member

Bugzilla Link 37583
Resolution DUPLICATE
Resolved on Jun 01, 2018 07:33
Version trunk
OS Linux
CC @tstellar

Extended Description

https://godbolt.org/g/TmLd9z

The two examples show that clang will insert a stack guard in a function with inline assembly and the "m" constraint compiled with -fstack-protector-strong. Is there a good reason to do so, or this a bug in clang?

I know the function attribute no_stack_protector was recently added to clang. That seems to help.

It just seems weird the just "=r" generates no stack protector, but "=rm" does.

From discussion:
https://lkml.org/lkml/2018/5/24/1389

@tstellar
Copy link
Collaborator

It's generating a stack protector, because the function takes the address of a local variable.

I think the real question here is why does clang decide pass the input as an address rather than a register.

@llvmbot
Copy link
Collaborator

llvmbot commented Jun 1, 2018

Inline assembly arguments are conservatively chosen to be stored memory if there's a choice to avoid running out of registers later in allocation.

*** This bug has been marked as a duplicate of bug #20571 ***

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla clang:as-a-library libclang and C++ API duplicate Resolved as duplicate
Projects
None yet
Development

No branches or pull requests

3 participants