[llvm-dev] multi-entry function (debug info)
Roger Ferrer Ibáñez via llvm-dev
llvm-dev at lists.llvm.org
Tue Oct 23 12:27:10 PDT 2018
Yep, I think wasn't clear enough when I said "an integer parameter to
discriminate". Perhaps an example may help
module moo
contains
function bad_cos(x) result(y)
real, value :: x ! degrees
real :: y
real, parameter :: pi = 3.14159265359
x = x + pi / 2
entry bad_sin(x)
y = ...
end function bad_cos
end module moo
program main
use moo
implicit none
real :: c, s
c = bad_cos(0.6)
s = bad_sin(0.6)
print *, c, s, c**2 + s**2
end program main
the code above might be lowered into something like
float moo_bad_cos__(float x, int discriminator)
{
switch (discriminator) {
case 0: goto moo_bad_cos;
case 1: goto moo_bad_sin;
}
moo_bad_cos:
x = x - pi;
moo_bad_sin:
y = ...;
return y;
}
int main() {
float c = moo_bad_cos__(0.6, 0);
float s = moo_bad_cos__(0.6, 1);
// print etc.
}
I'm afraid I don't know enough about the consequences of describing the
ENTRY as a subprogram of its own in the debug info, so apologies if what
follows is unrelated to that.
In my (definitely biased) view of the Fortran things, I'd probably be OK if
the debugger knows I'm inside (the original) "bad_cos" given that an ENTRY
statement is always going to be found inside a function/procedure (where
the enclosing function/procedure acts as the "principal" entry), so it
would surprise me a bit if the debugger thinks I'm in a function called
"bad_sin" as I don't have any procedure (at least at the "program function"
or "module procedure", in Fortran parlance, level) with that name in the
code. But that's my view.
Perhaps flang/f18 folks want to weigh in here.
Kind regards,
Roger
Missatge de Krzysztof Parzyszek via llvm-dev <llvm-dev at lists.llvm.org> del
dia dt., 23 d’oct. 2018 a les 18:31:
> On 10/23/2018 11:21 AM, via llvm-dev wrote:
> > Interesting. So the FORTRAN subprogram would have an implicit parameter
> > and effectively have a computed GOTO at the beginning to dispatch to the
> > correct ENTRY?
>
> At least in Fortran 77, each ENTRY has its own name, so there is no
> "dynamic dispatch". They are really more like separate functions with a
> common tail.
>
> -Krzysztof
>
> --
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
> hosted by The Linux Foundation
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
--
Roger Ferrer Ibáñez
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20181023/74667f59/attachment.html>
More information about the llvm-dev
mailing list