Object file questions

Timo Sintonen via D.gnu d.gnu at puremagic.com
Sun Aug 17 08:19:19 PDT 2014


On Sunday, 17 August 2014 at 14:47:57 UTC, Johannes Pfau wrote:
> Am Sun, 17 Aug 2014 14:36:53 +0000
> schrieb "Timo Sintonen" <t.sintonen at luukku.com>:
>
>> On Sunday, 17 August 2014 at 13:59:03 UTC, Artur Skawina via 
>> D.gnu wrote:
>> > On 08/17/14 15:44, Timo Sintonen via D.gnu wrote:
>> >
>> >> I am compiling for arm and I am sorry I misinterpreted the 
>> >> optimized code. Actually the code is correct but it still 
>> >> does not work.
>> >> The problem is that the call to get the tls pointer for 
>> >> volatile_dummy seems to corrupt the register (r3) where the 
>> >> this pointer is. The call is inside the while loop.  After 
>> >> removing tha call by hand in the assembly everything works. 
>> >> R3 is usually pushed into stack when it is used in a 
>> >> function. I have to check what is wrong in this case.
>> >
>> > Does declaring it as:
>> >
>> >    extern __gshared int volatile_dummy;
>> > 
>> > help?
>> >
>> > artur
>> 
>> Yes, now it works.
>> 
>> But the register corruption is still an issue. My tls function 
>> clearly uses r3 and does not save it.
>> 
>> Johannes, do you know the arm calling system? Is it caller or 
>> callee that should save r3?
>> In this case it is my function that has one function inlined 
>> that has another function inlined that contains a compiler 
>> generated function call. Could this be a bug in the compiler 
>> that it does not recognize the innermost call and does not 
>> save registers?
>
> r3 is an argument/scratch register, the callee can't rely on its
> contents after a function call. This could also be caused by 
> the inline
> ASM.

So is this a bug or just undefined behavior?


More information about the D.gnu mailing list