[Issue 4486] New: CodeView debug info should contain absolute path names

2010-07-19 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4486

   Summary: CodeView debug info should contain absolute path names
   Product: D
   Version: D1  D2
  Platform: Other
OS/Version: Windows
Status: NEW
  Severity: normal
  Priority: P2
 Component: DMD
AssignedTo: nob...@puremagic.com
ReportedBy: r.sagita...@gmx.de


--- Comment #0 from Rainer Schuetze r.sagita...@gmx.de 2010-07-19 11:22:00 
PDT ---
As of DMD 2.047, the CodeView debug information contains file names as
specified on the command line, i.e. most of the time relative paths.
According to the omf-specification, the full path should be specified in the
THEADR record. This makes it much easier for debuggers to find the correct
source modules and can avoid ambiguities.

Here's a patch (filespec.c only contains an unusable version of making a path
absolute):

Index: cgobj.c
===
--- cgobj.c(revision 576)
+++ cgobj.c(working copy)
@@ -17,6 +17,7 @@
 #includestdlib.h
 #includemalloc.h
 #includectype.h
+#includedirect.h

 #includefilespec.h

@@ -1249,7 +1250,20 @@
 void obj_theadr(const char *modname)
 {   char *theadr;
 int i;
+char absname[260];

+if(modname[0] != '\\'  modname[0] != '/'  !(modname[0]  modname[1]
== ':'))
+{
+if(getcwd(absname, sizeof(absname)))
+{
+int len = strlen(absname);
+if(absname[len - 1] != '\\'  absname[len - 1] != '/')
+absname[len++] = '\\';
+strcpy(absname + len, modname);
+modname = absname;
+}
+}
+
 //printf(obj_theadr(%s)\n, modname);
 theadr = (char *)alloca(ONS_OHD + strlen(modname));
 i = obj_namestring(theadr,modname);

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 4481] Internal compiler error (glue.c, !vthis-csym) or compiles, depending on the import statements order

2010-07-19 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4481



--- Comment #4 from Don clugd...@yahoo.com.au 2010-07-19 12:05:02 PDT ---
(In reply to comment #3)
 (In reply to comment #2)
  This looks similar to bug 2692. It's not a duplicate, but I suspect the root
  cause is the same.
 
 I'm 100% sure you meant bug 2962 that is
 ICE(glue.c) or bad codegen passing variable as template value parameter
 and not bug 2692 which is 
 alignment of double on x86 linux is incorrect and resolved

Correct. In this bug, it's the 'this' parameter which causes the problem, in
bug 2962 it's any other function parameter.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 4488] New: Faster fixed-size array initialization from literal

2010-07-19 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4488

   Summary: Faster fixed-size array initialization from literal
   Product: D
   Version: D2
  Platform: All
OS/Version: All
Status: NEW
  Keywords: performance
  Severity: enhancement
  Priority: P2
 Component: DMD
AssignedTo: nob...@puremagic.com
ReportedBy: bearophile_h...@eml.cc


--- Comment #0 from bearophile_h...@eml.cc 2010-07-19 14:43:10 PDT ---
This D2 program initializes a small fixed-size array allocated on the stack:


import std.c.stdio: printf;
import std.c.stdlib: atof;
void main() {
double x = atof(1.0);
double y = atof(2.0);
double[2] arr = [x, y];
printf(%f\n, arr[1]);
}


The asm generated by dmd in an optimized build shows two calls to initialize
the array (one to build it on the heap and one to copy from heap to stack).
Even LDC leaves the first call.

Inizialization of small stack-allocated arrays like this are often used in
high-performance code, such two calls can reduce performance if they are inside
a function called in an inner loop.

So can such two calls be removed in this simple situation? The compiler can
recognize that there is no need for heap allocations in this case.



DMD v.2.047 asm, optimized build:

__Dmain comdat
sub ESP,04Ch
mov EAX,offset FLAT:_DATA
pushEBX
pushESI
pushEAX
callnear ptr _atof
mov ECX,offset FLAT:_DATA[4]
fstpqword ptr 010h[ESP]
push010h
pushECX
callnear ptr _atof
add ESP,0FFFCh
mov EDX,offset FLAT:_D12TypeInfo_xAd6__initZ
fstpqword ptr [ESP]
pushdword ptr 020h[ESP]
pushdword ptr 020h[ESP]
push2
pushEDX
   callnear ptr __d_arrayliteralT
add ESP,018h
pushEAX
lea EBX,028h[ESP]
pushEBX
   callnear ptr _memcpy
mov ESI,offset FLAT:_DATA[8]
pushdword ptr 038h[ESP]
pushdword ptr 038h[ESP]
pushESI
callnear ptr _printf
add ESP,01Ch
xor EAX,EAX
pop ESI
pop EBX
add ESP,04Ch
ret



LDC asm, optimized build:

_Dmain:
subl$52, %esp
movl$.str, (%esp)
callatof
fstpt   28(%esp)
movl$.str1, (%esp)
callatof
fstpt   16(%esp)
movl$2, 4(%esp)
movl$_D11TypeInfo_Ad6__initZ, (%esp)
   call_d_newarrayvT
fldt28(%esp)
fstpl   (%eax)
fldt16(%esp)
fstpl   40(%esp)
movsd   40(%esp), %xmm0
movsd   %xmm0, 8(%eax)
movsd   %xmm0, 4(%esp)
movl$.str2, (%esp)
callprintf
xorl%eax, %eax
addl$52, %esp
ret $8

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---