Comments (7)
The main problem with gcc for the testcase is that we assume the in-struct offset is always zero when we have a single float arg. Though now that I look at the issue, I see you already came to the same conclusion and wrote a similar patch.
I think the handling for empty structs should stay the same, as there is no bug there. The text you quoted only applies to an empty struct. It does not apply to an empty struct inside another struct.
If there is an issue, it would be in the text for flattening structures. However, this text already says
Fields containing empty structs or unions are ignored while flattening, even in C++, unless they have nontrivial copy constructors or destructors.
So gcc does seem to be implementing this correctly.
We only flatten an aggregate when it contains at least one float field, and an empty struct plus an integer doesn't qualify, so we don't need any change to the ABI for this case.
Thus all we need to fix is a gcc bug where it is getting the float field offset wrong when we have empty struct plus float. Since this case is already broken, it isn't really an ABI change, it is just a bug fix, and doesn't need any special handling.
from riscv-elf-psabi-doc.
Jim, thanks for the explanation. I admit I hadn't spotted that the flattening only happens when passing floats. I can imagine how that situation has arrived. I'll post a patch for GCC shortly to fix the float offset case.
I wonder if it is worth adding some words to the "Integer Calling Convention" explicitly stating that empty structures are never flattened in the integer only case, and thus when using C++ this will result in empty space being passed around. Though its correct that with no words this should be the assumed default, this makes the integer ABI slightly less efficient than the float ABI, and so isn't (to me anyway) the "obvious" choice.
The Floating Point ABI (see below) describes a strategy for flattening structures in order to more efficiently pass values in floating point registers. Any structure not covered by the Float Point ABI flattening rules is not flattened, and is passed as a standard structure. When considering empty sub-structures in C++, this means that the space associated with the empty structure can be passed in a register.
from riscv-elf-psabi-doc.
I don't see the need to clarify the int docs. The int docs don't do flattening, so we don't need to document that. They also don't use FP regs, and we don't document that either. You usually don't need to document something that doesn't exist.
The int docs say "Aggregates whose total size is no more than XLEN bits are passed in a register, with the fields laid out as though they were passed in memory. " Whether or not one of the fields is an empty structure is irrelevant. It doesn't change how the aggregate is passed.
I don't feel strongly about this though. If other people think this is helpful we can add it into the docs.
from riscv-elf-psabi-doc.
I don't feel particularly strongly about this either. The fact that flattening doesn't happen for the integer ABI seemed clear to me, but once you've spent long enough with the spec it becomes pretty hard to judge what is obvious/non-obvious.
I think something along the lines of the clarification suggested seems ok. I question if it's needed but like Jim don't feel strongly about it.
from riscv-elf-psabi-doc.
I'd suggest erring on the side of parsimony.
from riscv-elf-psabi-doc.
FYI we now coincidentally have a FSF GCC bug report.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89627
Unlike Andrew's testcase, this one looks like real code.
from riscv-elf-psabi-doc.
No one seems in favor of extending the docs here, so I propose closing this.
from riscv-elf-psabi-doc.
Related Issues (20)
- Specify relocation overflow checks HOT 1
- Specify a platform reserved register HOT 20
- Should calling convention also define ptrdiff_t? HOT 1
- Should we use lw/sw in push pop when we used ILP32, whether it's RV32 or RV64 HOT 3
- Operation semantics of __bf16 datatype HOT 2
- representation of GNU C fixed-size vectors HOT 4
- Deprecate R_RISCV_RVC_LUI? HOT 4
- Define GOT-Relative data relocation HOT 8
- Embedding R_RISCV_RELAX to another relocations HOT 7
- Define gp(x3) as global VLENB HOT 4
- Bitfield integer calling convention garbled
- Calling convention uses RV64GQ without definition or reference HOT 3
- Calling convention description of va_list et al. are unclear HOT 2
- Interpretation of floating-point types
- Linux ABI for Pointer Masking HOT 19
- New ABI for stack layout and frame pointer scheme HOT 4
- Change branch from "master" to "main" HOT 1
- Add CREL support HOT 3
- Add RELR support HOT 6
- Question about medlow's single 2 GiB address range HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from riscv-elf-psabi-doc.