On Jul 28, 2020, Qing Zhao via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
>> 2. The main code generation part is moved from i386 backend to middle-end; >> 3. Add 4 target-hooks; >> 4. Implement these 4 target-hooks on i386 backend. >> 5. On a target that does not implement the target hook, issue error I wonder... How important is it that the registers be zeroed, rather than just avoid leaking internal state from the function? It occurred to me that we could implement this in an entirely machine-independent way by just arranging for the option to change the calling conventions for all registers that are not used by return to be regarded as call-saved. Then the prologue logic would save the incoming value of the registers, and the epilogue would restore them, and we're all set. It might even cover propagation of exceptions out of the function. Even if zeroing registers is desirable, it might still be possible to build upon the above to do that in a machine-independent fashion, using the annotations used to output call frame info to identify the slots in which the to-be-zeroed registers were saved, and store zeros there, either by modifying the save insns, or by adding extra stores to the end of the prologue, at least as a default implementation for a target hook, that could be overridden with something that does the job in more efficient but target-specific ways. -- Alexandre Oliva, happy hacker https://FSFLA.org/blogs/lxo/ Free Software Activist GNU Toolchain Engineer