diff gen/statements.c @ 82:d8dd47ef3973 trunk

[svn r86] Changed the way arguments are given storage. It is now detected if they will need it during semantic passes. Initial support for debug information. Very limited, but MUCH better than nothing :)
author lindquist
date Fri, 02 Nov 2007 01:17:26 +0100
parents 3587401b6eeb
children
line wrap: on
line diff
--- a/gen/statements.c	Thu Nov 01 17:27:18 2007 +0100
+++ b/gen/statements.c	Fri Nov 02 01:17:26 2007 +0100
@@ -22,6 +22,7 @@
 #include "gen/tollvm.h"
 #include "gen/runtime.h"
 #include "gen/arrays.h"
+#include "gen/todebug.h"
 
 //////////////////////////////////////////////////////////////////////////////
 
@@ -63,6 +64,8 @@
             TypeFunction* f = p->topfunctype();
             assert(f->llvmRetInPtr && f->llvmRetArg);
 
+            if (global.params.symdebug) DtoDwarfStopPoint(loc.linnum);
+
             p->exps.push_back(IRExp(NULL,exp,f->llvmRetArg));
             elem* e = exp->toElem(p);
             p->exps.pop_back();
@@ -93,14 +96,17 @@
             assert(0);
 
             IRFunction::FinallyVec& fin = p->func().finallys;
-            if (fin.empty())
+            if (fin.empty()) {
+                if (global.params.symdebug) DtoDwarfFuncEnd(p->func().decl);
                 new llvm::ReturnInst(p->scopebb());
+            }
             else {
                 new llvm::BranchInst(fin.back().retbb, p->scopebb());
             }
             delete e;
         }
         else {
+            if (global.params.symdebug) DtoDwarfStopPoint(loc.linnum);
             elem* e = exp->toElem(p);
             llvm::Value* v = e->getValue();
             delete e;
@@ -108,6 +114,7 @@
 
             IRFunction::FinallyVec& fin = p->func().finallys;
             if (fin.empty()) {
+                if (global.params.symdebug) DtoDwarfFuncEnd(p->func().decl);
                 new llvm::ReturnInst(v, p->scopebb());
             }
             else {
@@ -124,6 +131,7 @@
         if (p->topfunc()->getReturnType() == llvm::Type::VoidTy) {
             IRFunction::FinallyVec& fin = p->func().finallys;
             if (fin.empty()) {
+                if (global.params.symdebug) DtoDwarfFuncEnd(p->func().decl);
                 new llvm::ReturnInst(p->scopebb());
             }
             else {
@@ -145,6 +153,9 @@
     Logger::println("ExpStatement::toIR(%d): %s", esi++, toChars());
     LOG_SCOPE;
 
+    if (global.params.symdebug)
+        DtoDwarfStopPoint(loc.linnum);
+
     if (exp != 0) {
         elem* e = exp->toElem(p);
         delete e;
@@ -473,6 +484,7 @@
     // no outer
     else
     {
+        if (global.params.symdebug) DtoDwarfFuncEnd(p->func().decl);
         llvm::Value* retval = p->func().finallyretval;
         if (retval) {
             retval = p->ir->CreateLoad(retval,"tmp");