Target-Triple changes in assembly; Who is wrong?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Target-Triple changes in assembly; Who is wrong?

Hans Wennborg via cfe-dev
Hello Clang-People,

I try to understand the system behind the target triple of clang - but I don't get it. I used clang to compile the same code with two different targets:
--target=x86_64-pc-windows-msvc and --target=x86_64-pc-windows-elf.

I let the dragon compile my code and wished for assembly output. The dragon did fine but the output confused me.

When I looked into the functions I discovered strange difference. For example:
msvc target generated:
movq        %rdx, %rax

but in elf the same line is:
movq        %rcx, %rax

Why is there (and in other places) such difference? The target is still windows, but the elf code is breaking the windows __thiscall calling convention. I expected that both output are compatible to windows.

Is the dragon wrong, or is it me?

Kind regards
Björn

Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789
Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Heiko Lampert, Hiroshi Kawamura, Takashi Nagano, Takeshi Fukushima.


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Target-Triple changes in assembly; Who is wrong?

Hans Wennborg via cfe-dev
Without the context of the code being compiled, it's impossible to say if LLVM is right or not. It's worth mentioning though that there is no __thiscall convention on x64. That's a 32-bit-only thing.

If I had to guess, I'd say this is some struct return ABI detail that's going wrong.

On Mon, Feb 12, 2018 at 10:32 PM, via cfe-dev <[hidden email]> wrote:
Hello Clang-People,

I try to understand the system behind the target triple of clang - but I don't get it. I used clang to compile the same code with two different targets:
--target=x86_64-pc-windows-msvc and --target=x86_64-pc-windows-elf.

I let the dragon compile my code and wished for assembly output. The dragon did fine but the output confused me.

When I looked into the functions I discovered strange difference. For example:
msvc target generated:
movq        %rdx, %rax

but in elf the same line is:
movq        %rcx, %rax

Why is there (and in other places) such difference? The target is still windows, but the elf code is breaking the windows __thiscall calling convention. I expected that both output are compatible to windows.

Is the dragon wrong, or is it me?

Kind regards
Björn

Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789
Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Heiko Lampert, Hiroshi Kawamura, Takashi Nagano, Takeshi Fukushima.


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev



_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Target-Triple changes in assembly; Who is wrong?

Hans Wennborg via cfe-dev
Which kind of context would help you to judge who is wrong?
Do you want the two assembly files? The C++ source code?



From:        Reid Kleckner <[hidden email]>
To:        [hidden email]
Cc:        cfe-dev <[hidden email]>
Date:        13.02.2018 19:37
Subject:        Re: [cfe-dev] Target-Triple changes in assembly; Who is wrong?




Without the context of the code being compiled, it's impossible to say if LLVM is right or not. It's worth mentioning though that there is no __thiscall convention on x64. That's a 32-bit-only thing.

If I had to guess, I'd say this is some struct return ABI detail that's going wrong.

On Mon, Feb 12, 2018 at 10:32 PM, via cfe-dev <[hidden email]> wrote:
Hello Clang-People,

I try to understand the system behind the target triple of clang - but I don't get it. I used clang to compile the same code with two different targets:

--target=x86_64-pc-windows-msvc
and --target=x86_64-pc-windows-elf.


I let the dragon compile my code and wished for assembly output. The dragon did fine but the output confused me.


When I looked into the functions I discovered strange difference. For example:

msvc
target generated:

movq        %rdx, %rax


but in elf the same line is:

movq        %rcx, %rax


Why is there (and in other places) such difference? The target is still windows, but the elf code is breaking the windows __thiscall calling convention. I expected that both output are compatible to windows.


Is the dragon wrong, or is it me?


Kind regards

Björn


Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789
Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Heiko Lampert, Hiroshi Kawamura, Takashi Nagano, Takeshi Fukushima.


_______________________________________________
cfe-dev mailing list

[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev




Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789
Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Heiko Lampert, Hiroshi Kawamura, Takashi Nagano, Takeshi Fukushima.


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Target-Triple changes in assembly; Who is wrong?

Hans Wennborg via cfe-dev
In reply to this post by Hans Wennborg via cfe-dev
(When you receive 2 Mails I'm sorry. There were problems with my mail program)

Which kind of context would help you to judge who is wrong?
Do you want the two assembly files? The C++ source code?


From:        Reid Kleckner <[hidden email]>
To:        [hidden email]
Cc:        cfe-dev <[hidden email]>
Date:        13.02.2018 19:37
Subject:        Re: [cfe-dev] Target-Triple changes in assembly; Who is wrong?




Without the context of the code being compiled, it's impossible to say if LLVM is right or not. It's worth mentioning though that there is no __thiscall convention on x64. That's a 32-bit-only thing.

If I had to guess, I'd say this is some struct return ABI detail that's going wrong.

On Mon, Feb 12, 2018 at 10:32 PM, via cfe-dev <[hidden email]> wrote:
Hello Clang-People,

I try to understand the system behind the target triple of clang - but I don't get it. I used clang to compile the same code with two different targets:

--target=x86_64-pc-windows-msvc
and --target=x86_64-pc-windows-elf.


I let the dragon compile my code and wished for assembly output. The dragon did fine but the output confused me.


When I looked into the functions I discovered strange difference. For example:

msvc
target generated:

movq        %rdx, %rax


but in elf the same line is:

movq        %rcx, %rax


Why is there (and in other places) such difference? The target is still windows, but the elf code is breaking the windows __thiscall calling convention. I expected that both output are compatible to windows.


Is the dragon wrong, or is it me?


Kind regards

Björn


Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789
Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Heiko Lampert, Hiroshi Kawamura, Takashi Nagano, Takeshi Fukushima.


_______________________________________________
cfe-dev mailing list

[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev




Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789
Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Heiko Lampert, Hiroshi Kawamura, Takashi Nagano, Takeshi Fukushima.



Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789
Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Heiko Lampert, Hiroshi Kawamura, Takashi Nagano, Takeshi Fukushima.


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev