diff gen/toir.cpp @ 217:0806379a5eca trunk

[svn r233] Added: -oq command line option for writing fully qualified object names. Added: started support for x86 80bit floating point. Changed: aggregates passed by value now use the llvm 'byval' parameter attribute, also lays ground work for using other attributes. Changed: eliminated a lot more std::vectorS, these showed up pretty much at the top when profiling! Changed: performed other misc. cleanups. Changed: halt expression now call the new llvm trap intrinsic instead of an assert(0). Changed: dstress suite now passes -O0 by default, this only eliminates unreferenced globals, which speeds up linking quite a bit.
author lindquist
date Thu, 05 Jun 2008 06:38:36 +0200
parents a58d8f4b84df
children df641a27e9fd
line wrap: on
line diff
--- a/gen/toir.cpp	Tue Jun 03 22:32:59 2008 +0200
+++ b/gen/toir.cpp	Thu Jun 05 06:38:36 2008 +0200
@@ -618,7 +618,7 @@
             llvm::ConstantInt* cofs = llvm::cast<llvm::ConstantInt>(r->isConst()->c);
 
             TypeStruct* ts = (TypeStruct*)e1next;
-            std::vector<unsigned> offsets;
+            DStructIndexVector offsets;
             LLValue* v = DtoIndexStruct(l->getRVal(), ts->sym, t->next, cofs->getZExtValue(), offsets);
             return new DFieldValue(type, v, true);
         }
@@ -1018,7 +1018,11 @@
 
     bool isInPlace = false;
 
+    // attrs
+    llvm::PAListPtr palist;
+
     // hidden struct return arguments
+    // TODO: use sret param attr
     if (retinptr) {
         if (topexp && topexp->e2 == this) {
             assert(topexp->v);
@@ -1167,6 +1171,10 @@
             Argument* fnarg = Argument::getNth(tf->parameters, i);
             DValue* argval = DtoArgument(fnarg, (Expression*)arguments->data[i]);
             llargs[j] = argval->getRVal();
+        #if USE_BYVAL
+            if (fnarg->llvmByVal)
+                palist = palist.addAttr(j, llvm::ParamAttr::ByVal);
+        #endif
             j++;
         }
 
@@ -1187,6 +1195,11 @@
                 llargs[j] = DtoBitCast(llargs[j], llfnty->getParamType(j));
             }
 
+        #if USE_BYVAL
+            if (fnarg && fnarg->llvmByVal)
+                palist = palist.addAttr(j+1, llvm::ParamAttr::ByVal);
+        #endif
+
             // this hack is necessary :/
             if (dfn && dfn->func && dfn->func->runTimeHack) {
                 if (llfnty->getParamType(j) != NULL) {
@@ -1245,6 +1258,9 @@
         call->setCallingConv(DtoCallingConv(dlink));
     }
 
+    // param attrs
+    call->setParamAttrs(palist);
+
     return new DImValue(type, retllval, isInPlace);
 }
 
@@ -1311,7 +1327,7 @@
                 varmem = p->ir->CreateBitCast(llvalue, llt, "tmp");
             }
             else {
-                std::vector<unsigned> dst;
+                DStructIndexVector dst;
                 varmem = DtoIndexStruct(llvalue,vdt->sym, tnext, offset, dst);
             }
         }
@@ -1429,7 +1445,7 @@
 
             LLValue* src = l->getRVal();
 
-            std::vector<unsigned> vdoffsets;
+            DStructIndexVector vdoffsets;
             arrptr = DtoIndexStruct(src, ts->sym, vd->type, vd->offset, vdoffsets);
         }
         else if (e1type->ty == Tclass) {
@@ -1438,7 +1454,7 @@
 
             LLValue* src = l->getRVal();
 
-            std::vector<unsigned> vdoffsets;
+            DStructIndexVector vdoffsets;
             arrptr = DtoIndexClass(src, tc->sym, vd->type, vd->offset, vdoffsets);
 
             /*std::vector<unsigned> vdoffsets(1,0);
@@ -2255,7 +2271,8 @@
     Logger::print("HaltExp::toElem: %s | %s\n", toChars(), type->toChars());
     LOG_SCOPE;
 
-    DtoAssert(&loc, NULL);
+    // call the new (?) trap intrinsic
+    p->ir->CreateCall(GET_INTRINSIC_DECL(trap),"");
 
     new llvm::UnreachableInst(p->scopebb());
     return 0;