<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:10pt;color:#000000;font-family:'Courier New',monospace;" dir="ltr">
<p style="margin-top:0;margin-bottom:0"></p>
<div>Hi Eli,<br>
<br>
> You're correct that any solution that works with LTO must encode the information into the object file.<br>
> But module metadata isn't the best way to do that here.<br>
> The approach I'm suggesting is to use the "target-features" attribute on each function in the file. <br>
> See https://reviews.llvm.org/D46552 / https://reviews.llvm.org/D48581 / https://reviews.llvm.org/D46552 / etc.<br>
<br>
We took your advice and redid our work to use target-features instead of using module-metadata.<br>
With these patches, declaring the register variable in source will not reserve a register,<br>
and to reserve the register rN, -ffixed-rN should be specified in the command line.<br>
Reserving a register rN by -ffixed-rN will prevent them from being callee-saved.<br>
While we initially expected to support the full callee-saved register set (R4-R11),<br>
the source code shows that R4 is being hard-coded to be used as a scratch register under various conditions,<br>
so for now we revised the supported range of registers from R5-R11.<br>
<br>
As you pointed out previously, extra checks have been implemented so that reserved registers will not be spilled for stack alignment purposes.<br>
<br>
Effect on existing behavior<br>
----------------------------<br>
1. -ffixed-r9 and -frwpi<br>
The previous implementation of both -ffixed-r9 and -frwpi reserved the register R9, but did not stop it from being callee-saved.<br>
Specifying either flag new implementation reserves R9 and also stops it from being callee-saved.<br>
<br>
<br>
Errors for conflicting options<br>
------------------------------<br>
The following combination of flags will raise errors.<br>
1. -ffixed-r7 specified without -fomit-frame-pointer or with -fno-omit-frame-pointer<br>
2. -ffixed-r11 specified without -fomit-frame-pointer or with -fno-omit-frame-pointer<br>
3. -ffixed-r9 specified with -frwpi</div>
<p></p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0"></p>
<div>Draft Patches</div>
<div>-------------<br>
Clang: https://reviews.llvm.org/D56003<br>
LLVM: https://reviews.llvm.org/D56005</div>
<br>
<p></p>
<p style="margin-top:0;margin-bottom:0">Thank you</p>
<p style="margin-top:0;margin-bottom:0">Amilendra</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<br>
<br>
<div style="color: rgb(0, 0, 0);">
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" face="Calibri, sans-serif" color="#000000"><b>From:</b> Friedman, Eli <efriedma@codeaurora.org><br>
<b>Sent:</b> Monday, January 7, 2019 10:31 PM<br>
<b>To:</b> Amilendra Kodithuwakku; Carey Williams<br>
<b>Cc:</b> cfe-dev@lists.llvm.org; llvm-dev@lists.llvm.org<br>
<b>Subject:</b> Re: [llvm-dev] [RFC] Allocatable Global Register Variables for ARM</font>
<div> </div>
</div>
<div style="background-color:#FFFFFF">
<div class="x_moz-cite-prefix">On 1/4/2019 1:49 AM, Amilendra Kodithuwakku wrote:<br>
</div>
<blockquote type="cite">
<div id="x_divtagdefaultwrapper" dir="ltr" style="">
<pre class="x__ad_q1">> Why did you decide to use global metadata here? For AArch64, we use a target feature instead, to implement roughly equivalent functionality (the reserve-x18 feature, to implement -ffixed-x18).
> Making a global register declaration have side-effects never made sense, IMO; on the surface, it's using variable declaration syntax, but in reality it's actually changing the ABI rules for the whole file.
> I would prefer to support -ffixed-r4, and never allow global register declarations to modify the ABI. This subset should be compatible with gcc, as far as I know.
>
> (Compiler flags that affect the ABI are easy to misuse, but clang and gcc have a long tradition of flags which change the ABI, so it's not really worse than what we already do.)
>
>
We were looking for a solution which works with LTO.
While we investigated a possible -ffixed-reg flag, our understanding was that it would only work as long as it sets module metadata in the IR.
Adding a -ffixed-reg option in the LLVM backend, and adding that option to the -cc1 command-line, would not work because that would not get passed through to the backend when LTO is used. So our belief was that one could later implement the -ffixed-reg flag upon the module metadata added by this patch.
Is this the target feature mechanism you explained? <a class="x_moz-txt-link-freetext" href="https://llvm.org/docs/WritingAnLLVMBackend.html#subtarget-support">https://llvm.org/docs/WritingAnLLVMBackend.html#subtarget-support</a>
I still have not gone through the specifics of that but do you know if it would work with LTO?
</pre>
</div>
</blockquote>
<p>You're correct that any solution that works with LTO must encode the information into the object file. But module metadata isn't the best way to do that here. The approach I'm suggesting is to use the "target-features" attribute on each function in the
file. See <a class="x_moz-txt-link-freetext" href="https://reviews.llvm.org/D46552">
https://reviews.llvm.org/D46552</a> / <a class="x_moz-txt-link-freetext" href="https://reviews.llvm.org/D48581">
https://reviews.llvm.org/D48581</a> / <a class="x_moz-txt-link-freetext" href="https://reviews.llvm.org/D46552">
https://reviews.llvm.org/D46552</a> / etc.</p>
<p><br>
</p>
<p>-Eli<br>
</p>
<pre class="x_moz-signature" cols="72">--
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project</pre>
</div>
</div>
</div>
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose,
or store or copy the information in any medium. Thank you.
</body>
</html>