-
Notifications
You must be signed in to change notification settings - Fork 165
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
Clarification needed for Tag_RISCV_unaligned_access #283
Comments
GNU ld also OR's the flag for all input files https://github.com/bminor/binutils-gdb/blob/a37603c43f8da7983ed53b567ea30ce66066daa2/bfd/elfnn-riscv.c#L3763-L3765 |
Currently, this essentially says "the code has been compiled with It is correct, that the dynamic dispatching case is not covered yet.
This compiles without The reason, why the dynamic dispatching aspect is not fully covered by specifications and tools atm is, Another aspect that I'd like to throw in here is that the upcoming profiles specification defines the |
Phillip pointed me at this one, and while I'm not entirely sure about the LLVM side of things here's some comments:
So IMO the right way to go here is:
|
See <riscv-non-isa#283 (comment)> for more information. Signed-off-by: Palmer Dabbelt <[email protected]>
The intention is tag that when compiler might generating unaligned access, the inline assembly code are not covered, user/programmer should take responsibility for that, that is designed for debugging performance issue or unexpected trap in some scenarios - mainly used for exclude some possibility. What if we got unexpected slow performance or unexpected unaligned access trap? that could cause by different reason, one of the reason is compiler generated unaligned memory access - if so we can quickly diagnosis that by the checking the tag, However profile has mention a new extension name called Zicclsm recently, that extension indicated misaligned loads and stores is supported, so I think that would be better way to describe the info in future, just carry those info by ISA string, but the problem is we don't have too much further info for that yet and no SW has implement yet, but once we start to implement that, that should be a better way to describe the binary (via |
@palmer-dabbelt: I think we should give few more word to clarify |
I think that |
This issue tracks a couple of ambiguities in the wording for this which came up in discussion on https://reviews.llvm.org/D126085.
I'm going to start with a couple of detailed concerns, and then raise a broader justification question at the end.
First, the word "impose" in "Indicates whether to impose unaligned memory accesses in code generation." is unclear to me. Its not clear what meaning this was intended to mean.
Second, giving the existence of inline assembly, it is impossible for the compiler to precisely determine if the object file contains an unaligned load. The author of the inline assembly knows, but the alignment may not be visible to the compiler in any way.
This leaves the compiler two choices: either always set the flag when a possibly unaligned load is present, or don't.
Both are problematic.
If we set it conservatively (which seems to match the "may perform" wording), then essentially every object file will have this set. This means that runtime could can not take any meaning from the tag, as while the code "may" contain unaligned access, there's no guarantee that a) such unaligned access exists, b) if it exists it executes, or thus c) that the hardware actually supports unaligned accesses.
If we only set it when we know an unaligned access exists, then tools have to deal with object files which do contain unaligned accesses, but the compiler failed to notice.
Third, the tag appears to indicate whether an unaligned access exists, not whether it executes. This is problematic for any binary which wishes to do runtime feature detection and dispatch between two versions of code - one with only aligned and one with unaligned access. How should such a binary be tagged?
Note that clarifying/changing any of the above may be a breaking change for existing implementations. We should make sure to survey the impact of any changes on existing deployed code before deciding on a path forward here.
Now, switching to higher level justification.
I do not understand what the intended use case for this feature is, and that makes it hard to figure out what the intended semantics are.
During the LLVM risc-v sync up call today, two possible use cases were mentioned:
Use case 1 becomes nearly useless if we adopt the "may perform" interpretation above as any object file containing inline assembly will be marked as having unaligned accesses.
Use case 2 seems like a misuse of the feature. LLDB should not be generating code based on the characteristics of the binary being run, but based on the characteristics of the remote host. As an illustrative example, say you're debugging a fault due to a misaligned load executed on a remote host which does not support misaligned access. Having the debugger generate code for an expression using an unaligned load just because the ELF binary happened to use this tag seems... unhelpful.
My personal take here is that we'd likely be better removing this feature from the spec entirely. We can reserve the ID space if desired, but if this hasn't actually been implemented in any toolchain yet - which I hope is the actual status - we should defer the specification work until we have a concrete use case in mind.
The text was updated successfully, but these errors were encountered: