https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85961

--- Comment #4 from bki at hacon dot de ---
(In reply to Alexander Monakov from comment #3)
> You'd need to disable IPA-RA after forcing -O2 with the pragma, i.e.:
> 
> #pragma GCC optimize "O2"
> #pragma GCC optimize "no-ipa-ra"

Yes, this changes the problematic instruction sequence to:
  7e: 48 89 c5              mov    %rax,%rbp                                    
  81: e8 7a ff ff ff        callq  0
<_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6lengthEv.isra.0>
  86: 48 8d 54 05 00        lea    0x0(%rbp,%rax,1),%rdx

Which is better, since rbp is not a scratch register.


> [...]. Do we want to adjust it given that "pragma optimized" is documented as 
> "not suitable for production use"?
I appreciate the explanation which makes sense to me. In the original context,
I did introduce the pragma to reduce compilation times like this:
  #pragma GCC optimize "-fno-var-tracking", "-fno-var-tracking-assignments"

So, with instrumentation but without the optimize pragma, scratch registers
will always be considered changed across a function call?

This would then both fix my issue and more general doubts on the feasibility of
my ABI messing. I also agree that the pragma is clearly documented as not fit
for production use and would remove it accordingly. I think I can manage to
pass these options on the command line somehow.

Reply via email to