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

ARM back-end generating GNU EABI div/mod library calls in EABI mode #18561

Closed
rengolin opened this issue Dec 9, 2013 · 5 comments
Closed

ARM back-end generating GNU EABI div/mod library calls in EABI mode #18561

rengolin opened this issue Dec 9, 2013 · 5 comments
Assignees
Labels
backend:ARM bugzilla Issues migrated from bugzilla invalid Resolved as invalid, i.e. not a bug

Comments

@rengolin
Copy link
Member

rengolin commented Dec 9, 2013

Bugzilla Link 18187
Resolution INVALID
Resolved on Dec 10, 2015 08:33
Version trunk
OS Linux
CC @compnerd,@emaste,@jsonn,@kbeyls,@TNorthover

Extended Description

$ cat mod.c
int f(int a, int b) { return a % b; }
unsigned int g(unsigned int a, unsigned int b) { return a % b; }

$ clang -target arm-elf-eabi -S mod.c -o - | grep mod
.file "mod.c"
bl __modsi3
bl __umodsi3

$ clang -target arm-none-eabi -S mod.c -o - | grep mod
.file "mod.c"
bl __aeabi_idivmod
bl __aeabi_uidivmod

For conformance reasons, both should output the EABI calls.

@rengolin
Copy link
Member Author

rengolin commented Dec 9, 2013

assigned to @rengolin

@rengolin
Copy link
Member Author

rengolin commented Dec 9, 2013

It seems that this only happens when you chose a triple that has both ELF and EABI, since both are considered "environments".

The "arm-elf-eabi" triple is normalized to "armv4t---elf-eabi", since "elf" is a valid environment, it completely ignores the EABI portion.

Since I could have ELF files with any ABI in it, making ELF an environment doesn't make much sense, though I can see it's there, to differentiate between ELF and MachO.

Supposing that people do write triples like "arm-elf-eabi", we should fix the behaviour. If not, we should just forbid such cases, as they will create confusion and we're not making a good default choice on them.

There are two obvious ways to solve this:

  1. Put ELF, MachO, COFF whatever in its own class. That would be a big change and only worthy if there is a big concern, which I don't think there is.

  2. Analyse all tokens, and decide which to use, or use them all. This is a weird implementation and might create corner cases which we don't account for now.

I'm open to ideas.

@compnerd
Copy link
Member

It seems that this only happens when you chose a triple that has both ELF
and EABI, since both are considered "environments".

The "arm-elf-eabi" triple is normalized to "armv4t---elf-eabi", since "elf"
is a valid environment, it completely ignores the EABI portion.

Since I could have ELF files with any ABI in it, making ELF an environment
doesn't make much sense, though I can see it's there, to differentiate
between ELF and MachO.

Supposing that people do write triples like "arm-elf-eabi", we should fix
the behaviour. If not, we should just forbid such cases, as they will create
confusion and we're not making a good default choice on them.

There are two obvious ways to solve this:

  1. Put ELF, MachO, COFF whatever in its own class. That would be a big
    change and only worthy if there is a big concern, which I don't think there
    is.

I did do this a while back. Triple has an ObjectFormat field that indicates what the format is. This is a worthy concern IMO, and is really available. getObjectFormat and getEnvironment should return the necessary information. Am I misunderstanding something and something else is needed in order to support that?

  1. Analyse all tokens, and decide which to use, or use them all. This is a
    weird implementation and might create corner cases which we don't account
    for now.

I'm open to ideas.

@rengolin
Copy link
Member Author

Hi Saleem,

I believe this is only a concern to FreeBSD, which uses elf, rather than Linux, which doesn't.

If you want to have a go at this, using the infrastructure you created, please do. I believe the hardest part will be to make sure all the unknown corner cases are dealt with, since I don't believe we have tests for all of them.

I suggest you create a single patch that does the job, plus tests, and let everyone know in the list, so that if they start seeing weird behaviour in their platforms, they know what broke and it'll be easy to revert.

cheers,
--renato

@rengolin
Copy link
Member Author

This is a non-issue, since triples are not meant to mean anything. If/when we have a real issue with this odd behaviour, we can re-open the bug.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 9, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:ARM bugzilla Issues migrated from bugzilla invalid Resolved as invalid, i.e. not a bug
Projects
None yet
Development

No branches or pull requests

2 participants