www.digitalmars.com         C & C++   DMDScript  

D.gnu - testsuite: optimization dependent test

reply Johannes Pfau <nospam example.com> writes:
In runnable/test42.d test7290 checks if a scope delegate is really
allocated on the stack. To verify this it obtains the EBP pointer and
compares that to the delegates .ptr.

The problem is that as soon as we enable optimization gcc no
longer adjusts the EBP pointer when calling the helper functions and
the test fails...

This test seems to be very fragile in general so what should we do
about this?


BTW: I introduced a small typo in test7290 when porting to GCC asm:
The test in the main test7290 function should check "assert(dg.ptr <=
p);", not "assert(p < dg.ptr);"
Mar 25 2013
next sibling parent Iain Buclaw <ibuclaw ubuntu.com> writes:
--0022158c0dc1f9947d04d8c4c69f
Content-Type: text/plain; charset=ISO-8859-1

On 25 March 2013 18:36, Johannes Pfau <nospam example.com> wrote:

 In runnable/test42.d test7290 checks if a scope delegate is really
 allocated on the stack. To verify this it obtains the EBP pointer and
 compares that to the delegates .ptr.

 The problem is that as soon as we enable optimization gcc no
 longer adjusts the EBP pointer when calling the helper functions and
 the test fails...

 This test seems to be very fragile in general so what should we do
 about this?


 BTW: I introduced a small typo in test7290 when porting to GCC asm:
 The test in the main test7290 function should check "assert(dg.ptr <=
 p);", not "assert(p < dg.ptr);"

1. Revert your typo. 2. Raise with a thread in dmd-internals about it. -O2 in GDC triggers -fomit-frame-pointer. I'm 90% certain that Walter will say that any function with assembly inside requires that a frame pointer must always be present (except in naked function), but that is absolute rubbish. For x86_64 (at least), the ABI encourages the absence of a frame pointer. Regards -- Iain Buclaw *(p < e ? p++ : p) = (c & 0x0f) + '0'; --0022158c0dc1f9947d04d8c4c69f Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On 2= 5 March 2013 18:36, Johannes Pfau <span dir=3D"ltr">&lt;<a href=3D"mailto:n= ospam example.com" target=3D"_blank">nospam example.com</a>&gt;</span> wrot= e:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-l= eft:1px #ccc solid;padding-left:1ex"> In runnable/test42.d test7290 checks if a scope delegate is really<br> allocated on the stack. To verify this it obtains the EBP pointer and<br> compares that to the delegates .ptr.<br> <br> The problem is that as soon as we enable optimization gcc no<br> longer adjusts the EBP pointer when calling the helper functions and<br> the test fails...<br> <br> This test seems to be very fragile in general so what should we do<br> about this?<br> <br> <br> BTW: I introduced a small typo in test7290 when porting to GCC asm:<br> The test in the main test7290 function should check &quot;assert(dg.ptr &lt= ;=3D<br> p);&quot;, not &quot;assert(p &lt; dg.ptr);&quot;<br> </blockquote></div><br><br></div><div class=3D"gmail_extra">1.=A0 Revert yo= ur typo.<br><br></div><div class=3D"gmail_extra">2. Raise with a thread in = dmd-internals about it. -O2 in GDC triggers -fomit-frame-pointer.=A0 I&#39;= m 90% certain that Walter will say that any function with assembly inside r= equires that a frame pointer must always be present (except in naked functi= on), but that is absolute rubbish.=A0 For x86_64 (at least), the ABI encour= ages the absence of a frame pointer.<br clear=3D"all"> </div><div class=3D"gmail_extra"><br><br>Regards<br>-- <br>Iain Buclaw<br><= br>*(p &lt; e ? p++ : p) =3D (c &amp; 0x0f) + &#39;0&#39;; </div></div> --0022158c0dc1f9947d04d8c4c69f--
Mar 25 2013
prev sibling next sibling parent Johannes Pfau <nospam example.com> writes:
Am Mon, 25 Mar 2013 19:26:10 +0000
schrieb Iain Buclaw <ibuclaw ubuntu.com>:

 On 25 March 2013 18:36, Johannes Pfau <nospam example.com> wrote:
 
 In runnable/test42.d test7290 checks if a scope delegate is really
 allocated on the stack. To verify this it obtains the EBP pointer
 and compares that to the delegates .ptr.

 The problem is that as soon as we enable optimization gcc no
 longer adjusts the EBP pointer when calling the helper functions and
 the test fails...

 This test seems to be very fragile in general so what should we do
 about this?


 BTW: I introduced a small typo in test7290 when porting to GCC asm:
 The test in the main test7290 function should check "assert(dg.ptr
 <= p);", not "assert(p < dg.ptr);"

1. Revert your typo. 2. Raise with a thread in dmd-internals about it. -O2 in GDC triggers -fomit-frame-pointer. I'm 90% certain that Walter will say that any function with assembly inside requires that a frame pointer must always be present (except in naked function), but that is absolute rubbish. For x86_64 (at least), the ABI encourages the absence of a frame pointer. Regards

2 doesn't sound very promising though. We could just move that test to another file and make sure it's compiled with -fno-inline and fno-omit-frame-pointer. Even if dmd asm may require the frame pointer that needn't be true for gcc asm. BTW: Do we allow backports of specific frontend fixes into gdc? I'd like to merge the fix for the final methods in interfaces problem.
Mar 26 2013
prev sibling next sibling parent Iain Buclaw <ibuclaw ubuntu.com> writes:
--485b397dcfc936db5e04d8dc29ce
Content-Type: text/plain; charset=ISO-8859-1

On 26 March 2013 18:30, Johannes Pfau <nospam example.com> wrote:

 Am Mon, 25 Mar 2013 19:26:10 +0000
 schrieb Iain Buclaw <ibuclaw ubuntu.com>:

 On 25 March 2013 18:36, Johannes Pfau <nospam example.com> wrote:

 In runnable/test42.d test7290 checks if a scope delegate is really
 allocated on the stack. To verify this it obtains the EBP pointer
 and compares that to the delegates .ptr.

 The problem is that as soon as we enable optimization gcc no
 longer adjusts the EBP pointer when calling the helper functions and
 the test fails...

 This test seems to be very fragile in general so what should we do
 about this?


 BTW: I introduced a small typo in test7290 when porting to GCC asm:
 The test in the main test7290 function should check "assert(dg.ptr
 <= p);", not "assert(p < dg.ptr);"

1. Revert your typo. 2. Raise with a thread in dmd-internals about it. -O2 in GDC triggers -fomit-frame-pointer. I'm 90% certain that Walter will say that any function with assembly inside requires that a frame pointer must always be present (except in naked function), but that is absolute rubbish. For x86_64 (at least), the ABI encourages the absence of a frame pointer. Regards

2 doesn't sound very promising though. We could just move that test to another file and make sure it's compiled with -fno-inline and fno-omit-frame-pointer. Even if dmd asm may require the frame pointer that needn't be true for gcc asm. BTW: Do we allow backports of specific frontend fixes into gdc? I'd like to merge the fix for the final methods in interfaces problem.

Have no objections. Have done that for __vector's before ahead of release. -- Iain Buclaw *(p < e ? p++ : p) = (c & 0x0f) + '0'; --485b397dcfc936db5e04d8dc29ce Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On 2= 6 March 2013 18:30, Johannes Pfau <span dir=3D"ltr">&lt;<a href=3D"mailto:n= ospam example.com" target=3D"_blank">nospam example.com</a>&gt;</span> wrot= e:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-l= eft:1px #ccc solid;padding-left:1ex"> Am Mon, 25 Mar 2013 19:26:10 +0000<br> schrieb Iain Buclaw &lt;<a href=3D"mailto:ibuclaw ubuntu.com">ibuclaw ubunt= u.com</a>&gt;:<br> <div class=3D"im"><br> &gt; On 25 March 2013 18:36, Johannes Pfau &lt;<a href=3D"mailto:nospam exa= mple.com">nospam example.com</a>&gt; wrote:<br> &gt;<br> </div><div><div class=3D"h5">&gt; &gt; In runnable/test42.d test7290 checks= if a scope delegate is really<br> &gt; &gt; allocated on the stack. To verify this it obtains the EBP pointer= <br> &gt; &gt; and compares that to the delegates .ptr.<br> &gt; &gt;<br> &gt; &gt; The problem is that as soon as we enable optimization gcc no<br> &gt; &gt; longer adjusts the EBP pointer when calling the helper functions = and<br> &gt; &gt; the test fails...<br> &gt; &gt;<br> &gt; &gt; This test seems to be very fragile in general so what should we d= o<br> &gt; &gt; about this?<br> &gt; &gt;<br> &gt; &gt;<br> &gt; &gt; BTW: I introduced a small typo in test7290 when porting to GCC as= m:<br> &gt; &gt; The test in the main test7290 function should check &quot;assert(= dg.ptr<br> &gt; &gt; &lt;=3D p);&quot;, not &quot;assert(p &lt; dg.ptr);&quot;<br> &gt; &gt;<br> &gt;<br> &gt;<br> </div></div><div class=3D"im">&gt; 1. =A0Revert your typo.<br> &gt;<br> &gt; 2. Raise with a thread in dmd-internals about it. -O2 in GDC triggers<= br> &gt; -fomit-frame-pointer. =A0I&#39;m 90% certain that Walter will say that= any<br> &gt; function with assembly inside requires that a frame pointer must<br> &gt; always be present (except in naked function), but that is absolute<br> &gt; rubbish. =A0For x86_64 (at least), the ABI encourages the absence of a= <br> &gt; frame pointer.<br> &gt;<br> &gt;<br> &gt; Regards<br> <br> </div>2 doesn&#39;t sound very promising though. We could just move that te= st to<br> another file and make sure it&#39;s compiled with -fno-inline and<br> fno-omit-frame-pointer. Even if dmd asm may require the frame pointer<br> that needn&#39;t be true for gcc asm.<br> <br> BTW: Do we allow backports of specific frontend fixes into gdc? I&#39;d<br> like to merge the fix for the final methods in interfaces problem.<br> </blockquote></div><br></div><div class=3D"gmail_extra">Have no objections.= =A0 Have done that for __vector&#39;s before ahead of release.<br clear=3D"= all"></div><div class=3D"gmail_extra"><br>-- <br>Iain Buclaw<br><br>*(p &lt= ; e ? p++ : p) =3D (c &amp; 0x0f) + &#39;0&#39;; </div></div> --485b397dcfc936db5e04d8dc29ce--
Mar 26 2013
prev sibling next sibling parent "Kagamin" <spam here.lot> writes:
Are you trying to get stack top?

void test(scope void delegate() dg)
{
   int[2] top;
   void* p=top.ptr;
   assert(p < dg.ptr);
   assert(dg.ptr !is null);
   //also check that ptr is not in heap
   assert(gc_addrOf(dg.ptr) is null);
}
Mar 27 2013
prev sibling next sibling parent "Kagamin" <spam here.lot> writes:
core.memory.GC.addrOf(dg.ptr);
Mar 27 2013
prev sibling next sibling parent Iain Buclaw <ibuclaw ubuntu.com> writes:
--20cf3074afa8f7f7cf04d910300c
Content-Type: text/plain; charset=ISO-8859-1

On 28 March 2013 04:47, Kagamin <spam here.lot> wrote:

 core.memory.GC.addrOf(dg.ptr);

Done and already merged in. https://github.com/D-Programming-Language/dmd/pull/1809 Regards -- Iain Buclaw *(p < e ? p++ : p) = (c & 0x0f) + '0'; --20cf3074afa8f7f7cf04d910300c Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On 2= 8 March 2013 04:47, Kagamin <span dir=3D"ltr">&lt;<a href=3D"mailto:spam he= re.lot" target=3D"_blank">spam here.lot</a>&gt;</span> wrote:<br><blockquot= e class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px s= olid rgb(204,204,204);padding-left:1ex"> core.memory.GC.addrOf(dg.ptr);<br> </blockquote></div><br></div><div class=3D"gmail_extra">Done and already me= rged in.<br><br><a href=3D"https://github.com/D-Programming-Language/dmd/pu= ll/1809">https://github.com/D-Programming-Language/dmd/pull/1809</a><br><br= clear=3D"all"> <br></div><div class=3D"gmail_extra">Regards<br></div><div class=3D"gmail_e= xtra">-- <br>Iain Buclaw<br><br>*(p &lt; e ? p++ : p) =3D (c &amp; 0x0f) + = &#39;0&#39;; </div></div> --20cf3074afa8f7f7cf04d910300c--
Mar 29 2013
prev sibling parent "Kagamin" <spam here.lot> writes:
On Friday, 29 March 2013 at 13:24:42 UTC, Iain Buclaw wrote:
 https://github.com/D-Programming-Language/dmd/pull/1809

lol, put imports after test3.
Apr 01 2013