Mercurial > projects > ldc
comparison gen/toobj.cpp @ 946:1714836f2c0b
Mostly rewrite debug info generation in terms of llvm/Analysis/DebugInfo.h.
Add getCompilationModule to Dsymbol and fix template compile unit decision code.
Runtime compiles with -g again.
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Sun, 08 Feb 2009 16:50:22 +0100 |
parents | 03d7c4aac654 |
children | e71c61befd6d |
comparison
equal
deleted
inserted
replaced
945:03d7c4aac654 | 946:1714836f2c0b |
---|---|
80 assert(!global.errors); | 80 assert(!global.errors); |
81 | 81 |
82 // start by deleting the old object file | 82 // start by deleting the old object file |
83 deleteObjFile(); | 83 deleteObjFile(); |
84 | 84 |
85 // create a new ir state | |
86 // TODO look at making the instance static and moving most functionality into IrModule where it belongs | |
87 IRState ir; | |
88 gIR = &ir; | |
89 ir.dmodule = this; | |
90 | |
91 // reset all IR data stored in Dsymbols and Types | |
92 IrDsymbol::resetAll(); | |
93 IrType::resetAll(); | |
94 | |
95 // name the module | 85 // name the module |
96 std::string mname(toChars()); | 86 std::string mname(toChars()); |
97 if (md != 0) | 87 if (md != 0) |
98 mname = md->toChars(); | 88 mname = md->toChars(); |
99 ir.module = new llvm::Module(mname); | 89 |
90 // create a new ir state | |
91 // TODO look at making the instance static and moving most functionality into IrModule where it belongs | |
92 IRState ir(new llvm::Module(mname)); | |
93 gIR = &ir; | |
94 ir.dmodule = this; | |
95 | |
96 // reset all IR data stored in Dsymbols and Types | |
97 IrDsymbol::resetAll(); | |
98 IrType::resetAll(); | |
100 | 99 |
101 // module ir state | 100 // module ir state |
102 // might already exist via import, just overwrite since | 101 // might already exist via import, just overwrite since |
103 // the global created for the filename must belong to the right llvm module | 102 // the global created for the filename must belong to the right llvm module |
104 // FIXME: but shouldn't this always get reset between modules? like other IrSymbols | 103 // FIXME: but shouldn't this always get reset between modules? like other IrSymbols |
424 IRBuilder<> builder(bb); | 423 IRBuilder<> builder(bb); |
425 | 424 |
426 // debug info | 425 // debug info |
427 LLGlobalVariable* subprog; | 426 LLGlobalVariable* subprog; |
428 if(global.params.symdebug) { | 427 if(global.params.symdebug) { |
429 subprog = DtoDwarfSubProgramInternal(name.c_str(), name.c_str()); | 428 subprog = DtoDwarfSubProgramInternal(name.c_str(), name.c_str()).getGV(); |
430 builder.CreateCall(gIR->module->getFunction("llvm.dbg.func.start"), DBG_CAST(subprog)); | 429 builder.CreateCall(gIR->module->getFunction("llvm.dbg.func.start"), DBG_CAST(subprog)); |
431 } | 430 } |
432 | 431 |
433 for (size_t i=0; i<n; i++) { | 432 for (size_t i=0; i<n; i++) { |
434 llvm::Function* f = gIR->ctors[i]->ir.irFunc->func; | 433 llvm::Function* f = gIR->ctors[i]->ir.irFunc->func; |
469 IRBuilder<> builder(bb); | 468 IRBuilder<> builder(bb); |
470 | 469 |
471 // debug info | 470 // debug info |
472 LLGlobalVariable* subprog; | 471 LLGlobalVariable* subprog; |
473 if(global.params.symdebug) { | 472 if(global.params.symdebug) { |
474 subprog = DtoDwarfSubProgramInternal(name.c_str(), name.c_str()); | 473 subprog = DtoDwarfSubProgramInternal(name.c_str(), name.c_str()).getGV(); |
475 builder.CreateCall(gIR->module->getFunction("llvm.dbg.func.start"), DBG_CAST(subprog)); | 474 builder.CreateCall(gIR->module->getFunction("llvm.dbg.func.start"), DBG_CAST(subprog)); |
476 } | 475 } |
477 | 476 |
478 for (size_t i=0; i<n; i++) { | 477 for (size_t i=0; i<n; i++) { |
479 llvm::Function* f = gIR->dtors[i]->ir.irFunc->func; | 478 llvm::Function* f = gIR->dtors[i]->ir.irFunc->func; |
514 IRBuilder<> builder(bb); | 513 IRBuilder<> builder(bb); |
515 | 514 |
516 // debug info | 515 // debug info |
517 LLGlobalVariable* subprog; | 516 LLGlobalVariable* subprog; |
518 if(global.params.symdebug) { | 517 if(global.params.symdebug) { |
519 subprog = DtoDwarfSubProgramInternal(name.c_str(), name.c_str()); | 518 subprog = DtoDwarfSubProgramInternal(name.c_str(), name.c_str()).getGV(); |
520 builder.CreateCall(gIR->module->getFunction("llvm.dbg.func.start"), DBG_CAST(subprog)); | 519 builder.CreateCall(gIR->module->getFunction("llvm.dbg.func.start"), DBG_CAST(subprog)); |
521 } | 520 } |
522 | 521 |
523 for (size_t i=0; i<n; i++) { | 522 for (size_t i=0; i<n; i++) { |
524 llvm::Function* f = gIR->unitTests[i]->ir.irFunc->func; | 523 llvm::Function* f = gIR->unitTests[i]->ir.irFunc->func; |
571 IRBuilder<> builder(bb); | 570 IRBuilder<> builder(bb); |
572 | 571 |
573 // debug info | 572 // debug info |
574 LLGlobalVariable* subprog; | 573 LLGlobalVariable* subprog; |
575 if(global.params.symdebug) { | 574 if(global.params.symdebug) { |
576 subprog = DtoDwarfSubProgramInternal(fname.c_str(), fname.c_str()); | 575 subprog = DtoDwarfSubProgramInternal(fname.c_str(), fname.c_str()).getGV(); |
577 builder.CreateCall(gIR->module->getFunction("llvm.dbg.func.start"), DBG_CAST(subprog)); | 576 builder.CreateCall(gIR->module->getFunction("llvm.dbg.func.start"), DBG_CAST(subprog)); |
578 } | 577 } |
579 | 578 |
580 // get current beginning | 579 // get current beginning |
581 LLValue* curbeg = builder.CreateLoad(mref, "current"); | 580 LLValue* curbeg = builder.CreateLoad(mref, "current"); |