English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. C/C++

 
 
Thread Tools
Old 17 December 2015, 07:50   #1
Asman
68k
 
Asman's Avatar
 
Join Date: Sep 2005
Location: Somewhere
Posts: 828
VBCC 09d - bug in code generator ?

Hi

I have problem with vbcc 0.9d (cross - I compiled my own 64 bit version for windows). For following function (simplified a bit to show problem)
Code:
void WindowSignals(void)
{
	while (TRUE)
	{
		struct IntuiMessage* pMsg;
		pMsg = (struct IntuiMessage*)GetMsg(g_pWin->UserPort);

		if (pMsg == NULL)
		{
			break;
		}

		ULONG msg_class = pMsg->Class;

		ReplyMsg((struct Message*)pMsg);

		if (IDCMP_CLOSEWINDOW == msg_class)
		{
			return;
		}
	}
}
I have following assembly code

Code:
_WindowSignals
	movem.l	l32,-(a7)
l30
	move.l	_g_pWin(a4),a1
	move.l	(86,a1),a1
	move.l	_SysBase(a4),a6
	move.l	a1,a0
	jsr	-372(a6)
	move.l	d0,a3
	beq	l31
	move.l	(20,a3),a2
	move.l	_SysBase(a4),a6
	move.l	a3,a1
	jsr	-378(a6)
	cmp.l	#512,a2
	bne	l30
l31
l32	reg	a2/a3/a6
	movem.l	(a7)+,a2/a3/a6
l34	equ	12
	rts
And of course this code hangs because beq l31 never happens.
For vbcc 0.9b code generated is differ then above
Code:
	move.l	d0,a3
	move.l a3,d0
	beq	l31
and works fine.

Anyone noticed this bug too ?
Asman is offline  
Old 17 December 2015, 18:04   #2
Leffmann
 
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
Yeah I see it here too, you can fix it by compiling without optimizations.
Leffmann is offline  
Old 17 December 2015, 19:25   #3
Asman
68k
 
Asman's Avatar
 
Join Date: Sep 2005
Location: Somewhere
Posts: 828
@Leffmann
Thanks a lot. I tried with -o0 and works fine and code looks

Code:
	subq.w	#8,a7
	movem.l	l22,-(a7)
l17
	move.l	_g_pWin(a4),a0
	move.l	(86,a0),a0
	move.l	_SysBase(a4),a6
	jsr	-372(a6)
	move.l	d0,(0+l24,a7)
	bne	l21
l20
	bra	l19

l21
	move.l	(0+l24,a7),a0
	move.w	(24,a0),(4+l24,a7)
	move.l	(0+l24,a7),a1
	move.l	_SysBase(a4),a6
	jsr	-378(a6)

        ;rest code
Of course now move.l dn,(an) set zero flag if dn is 0, so its ok.

Thank you.
Asman is offline  
Old 03 January 2016, 15:51   #4
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,510
Could be a known bug. I think it was fixed some time ago. In the list for the next vbcc version I have this:
Code:
- m68k: Fixed asm-peephole optimization of move.l dx,ay; move.l ay,dx when
  cc of ay is used.
Please tell me about bugs (by email!). So they may be fixed and you will get an update immediately!

When you have a small source text for reproduction I could confirm that the bug is fixed. The source fragment above is not compilable.
phx is offline  
Old 03 January 2016, 16:55   #5
Leffmann
 
Join Date: Jul 2008
Location: Sweden
Posts: 2,269
It's probably the same bug. It may happen if you use anything other than -O0. Simple way to reproduce it:
Code:
void* x();

int func() {
  void* p = x();

  if (p)  return 1;
  else    return 2;
}
Leffmann is offline  
Old 03 January 2016, 20:12   #6
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,510
Confirmed. Then it's fixed.
phx is offline  
Old 04 January 2016, 10:43   #7
Asman
68k
 
Asman's Avatar
 
Join Date: Sep 2005
Location: Somewhere
Posts: 828
@phx
Great news. When should I expect a new version of vbcc ?
Asman is offline  
Old 04 January 2016, 13:46   #8
phx
Natteravn
 
phx's Avatar
 
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,510
Quote:
Originally Posted by Asman View Post
When should I expect a new version of vbcc ?
This might take a while. Don't know if we release a new version this year. Maybe I should make another patch for 0.9d, regarding the severity of that bug.

Otherwise just write me a mail and you can get the current development version.
phx is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
vbcc code generation and dbf Asman Coders. C/C++ 15 12 March 2016 01:51
Debugging vbcc code tolkien Coders. C/C++ 5 14 February 2015 06:45
VBCC code generation Asman Coders. C/C++ 9 17 August 2014 09:33
Mixed 68k / PPC code on VBCC. Cowcat Coders. General 10 01 August 2013 16:01

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 11:18.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.08476 seconds with 15 queries