From: "Yannick Duchêne (Hibou57)" <yannick_duchene@yahoo.fr>
Subject: Re: GNAT not generating any code for sub‑program: known bug?
Date: Sun, 28 Apr 2013 01:48:42 +0200
Date: 2013-04-28T01:48:42+02:00 [thread overview]
Message-ID: <op.wv74fgxwule2fv@cardamome> (raw)
In-Reply-To: op.wv70f3m3ule2fv@cardamome
Le Sun, 28 Apr 2013 00:22:41 +0200, Yannick Duchêne (Hibou57)
<yannick_duchene@yahoo.fr> a écrit:
> Le Sat, 27 Apr 2013 23:08:52 +0200, Yannick Duchêne (Hibou57)
> <yannick_duchene@yahoo.fr> a écrit:
>
>> Hi all,
>>
>> I will make a stripped‑down version of the case, later.
>
> Here is:
> http://www.les-ziboux.rasama.org/download/2013-04-28-cla-gnat-bug.zip
>
> The bug disappears when optimization is disabled or else when the
> sub‑program is made inlinable.
Seems there is an issue with sub‑program using Ada's machine‑code
insertion.
If the sub‑program which contains machine‑code insertion is not inlined,
then the machine‑code insertion part gets dropped by compiler
optimization, which so seems to be more a GCC bug than a GNAT bug. The
sub‑programs invoke this sub‑program either directly or indirectly, also
has to all be inlined too.
There is a work‑around: implement the sub‑program using machine‑code
insertion as a generic, say `GP`. Then implement `P` which use an
instantiation of `GP` internally, and it will works. `GP` cannot be
declared inlined, or else you will get a GNAT bug‑box. However, if `P`
declared inlined, then its containing `GP` instantiation will be properly
inlined. `P` will be generated when it's either inlined or not
(effectively workaround the bug), and will be really fully inline if
declared inlined (no efficiency cost).
Template as a summary:
generic
…
procedure/function GP (…);
-- No `Inline` here! either `True` or `False`,
-- or else GNAT says “kaboom”.
procedure/function GP (…) is
begin
-- Machine code insertion here
end;
procedure/function P (…)
[with Inline => True/False];
-- Works with either of the three.
procedure/function P (…) is
procedure/function Implementation is
new GP (…);
begin
[return] Implementation (…);
end;
--
“Syntactic sugar causes cancer of the semi-colons.” [1]
“Structured Programming supports the law of the excluded muddle.” [1]
[1]: Epigrams on Programming — Alan J. — P. Yale University
next prev parent reply other threads:[~2013-04-27 23:48 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-27 21:08 GNAT not generating any code for sub‑program: known bug? Yannick Duchêne (Hibou57)
2013-04-27 22:22 ` Yannick Duchêne (Hibou57)
2013-04-27 23:48 ` Yannick Duchêne (Hibou57) [this message]
2013-04-28 7:14 ` Simon Wright
2013-04-28 17:52 ` Yannick Duchêne (Hibou57)
2013-04-28 19:27 ` Yannick Duchêne (Hibou57)
2013-04-28 20:46 ` Simon Wright
2013-04-28 20:43 ` Simon Wright
2013-04-28 22:35 ` Erroneous code generation from GNAT or GCC? Yannick Duchêne (Hibou57)
2013-04-28 22:49 ` Yannick Duchêne (Hibou57)
2013-04-28 23:52 ` Yannick Duchêne (Hibou57)
2013-04-29 1:35 ` Yannick Duchêne (Hibou57)
2013-04-30 0:48 ` Yannick Duchêne (Hibou57)
2013-04-30 6:40 ` Simon Wright
2013-04-30 17:04 ` Yannick Duchêne (Hibou57)
2013-04-30 19:06 ` Simon Wright
2013-04-30 21:28 ` Yannick Duchêne (Hibou57)
2013-04-30 22:22 ` Simon Wright
2013-05-01 18:19 ` J-P. Rosen
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox