Hi, All,
I (think I) posted this to comp.lang.fortran, but it either got lost
or Google Groups is too slow. Sorry for report.
I dont quite get the calling convention of Intel 11.1 for
interoperable
functions. An identity function "id" for a "short structure" (sources
below)
compiles with Gfortran to this (x86_64):
0000000000000000 <id>:
0: 48 89 f8 mov %rdi,%rax
3: c3 retq
But with Intell 11.1 the same source compiles to something that
segfaults.
I assume it is the memory access to (%rdi), location at address stored
in
a register:
0000000000000010 <id>:
10: 48 89 37 mov %rsi,(%rdi)
13: 48 89 f8 mov %rdi,%rax
16: c3 retq
17: 90 nop
18: 90 nop
19: 48 8d bf 00 00 00 00 lea 0x0(%rdi),%rdi
The structure below has just one field, and obviousely it has just one
address,
what are those two "mov"es in the Intel-generated assembly?
Quite recently I had to give op on linking Intel compiled executable
with Gfortran compiled libraries, presumably, because of the calling
conventions with functions that return (double precision) complex
numbers.
Aka. ZDOTC() "bug". I think I need to understand the options/
differences better.
A would appreciate any comments, thanks in advance.
Alexei
module test
use iso_c_binding
implicit none
private
!
! Short structs with size matching that of some integer type may be
! passed/returned in registers. That depends on the platform ABI
! convention. BIND(C) on the type(t) and relevant function
! interfaces requests the Fortran compiler to emulate the behaviour of
! (some) C compiler.
!
! http://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html
!
type, public, bind(c) :: t
private
integer(c_intptr_t) :: ptr
end type t
public :: id
contains
function id(i) result(o) bind(c)
implicit none
type(t), intent(in), value :: i
type(t) :: o
o = i
end function id
end module test
|