comparison gen/statements.cpp @ 683:b411c41a9716

Only allocate the module file name once. Fixes #90.
author Christian Kamm <kamm incasoftware de>
date Sun, 12 Oct 2008 10:35:16 +0200
parents c8fcde3337b0
children 0a682c7805d2
comparison
equal deleted inserted replaced
682:518b8cc84369 683:b411c41a9716
14 #include "total.h" 14 #include "total.h"
15 #include "init.h" 15 #include "init.h"
16 #include "mtype.h" 16 #include "mtype.h"
17 #include "hdrgen.h" 17 #include "hdrgen.h"
18 #include "port.h" 18 #include "port.h"
19 #include "module.h"
19 20
20 #include "gen/irstate.h" 21 #include "gen/irstate.h"
21 #include "gen/logger.h" 22 #include "gen/logger.h"
22 #include "gen/tollvm.h" 23 #include "gen/tollvm.h"
23 #include "gen/llvmhelpers.h" 24 #include "gen/llvmhelpers.h"
25 #include "gen/arrays.h" 26 #include "gen/arrays.h"
26 #include "gen/todebug.h" 27 #include "gen/todebug.h"
27 #include "gen/dvalue.h" 28 #include "gen/dvalue.h"
28 29
29 #include "ir/irfunction.h" 30 #include "ir/irfunction.h"
31 #include "ir/irmodule.h"
30 #include "ir/irlandingpad.h" 32 #include "ir/irlandingpad.h"
31 33
32 ////////////////////////////////////////////////////////////////////////////// 34 //////////////////////////////////////////////////////////////////////////////
33 35
34 void CompoundStatement::toIR(IRState* p) 36 void CompoundStatement::toIR(IRState* p)
1268 // param attrs 1270 // param attrs
1269 llvm::AttrListPtr palist; 1271 llvm::AttrListPtr palist;
1270 int idx = 1; 1272 int idx = 1;
1271 1273
1272 std::vector<LLValue*> args; 1274 std::vector<LLValue*> args;
1273 LLConstant* c;
1274 1275
1275 // file param 1276 // file param
1276 // FIXME: every use creates a global for the filename !!! 1277 args.push_back(gIR->dmodule->ir.irModule->fileName);
1277 c = DtoConstString(loc.filename);
1278 llvm::AllocaInst* alloc = gIR->func()->srcfileArg;
1279 if (!alloc)
1280 {
1281 alloc = DtoAlloca(c->getType(), ".srcfile");
1282 gIR->func()->srcfileArg = alloc;
1283 }
1284 LLValue* ptr = DtoGEPi(alloc, 0,0, "tmp");
1285 DtoStore(c->getOperand(0), ptr);
1286 ptr = DtoGEPi(alloc, 0,1, "tmp");
1287 DtoStore(c->getOperand(1), ptr);
1288
1289 args.push_back(alloc);
1290 palist = palist.addAttr(idx++, llvm::Attribute::ByVal); 1278 palist = palist.addAttr(idx++, llvm::Attribute::ByVal);
1291 1279
1292 // line param 1280 // line param
1293 c = DtoConstUint(loc.linnum); 1281 LLConstant* c = DtoConstUint(loc.linnum);
1294 args.push_back(c); 1282 args.push_back(c);
1295 1283
1296 // call 1284 // call
1297 CallOrInvoke* call = gIR->CreateCallOrInvoke(fn, args.begin(), args.end()); 1285 CallOrInvoke* call = gIR->CreateCallOrInvoke(fn, args.begin(), args.end());
1298 call->setAttributes(palist); 1286 call->setAttributes(palist);