comparison gen/todebug.cpp @ 1517:a7a9e461512a

Make debug info work with newer LLVM.
author Christian Kamm <kamm incasoftware de>
date Fri, 26 Jun 2009 21:00:12 +0200
parents 855f188aab7a
children ad7f2f1862d6
comparison
equal deleted inserted replaced
1516:0f08b145b878 1517:a7a9e461512a
39 ? DEBUGINFO_LINKONCE_LINKAGE_TYPE 39 ? DEBUGINFO_LINKONCE_LINKAGE_TYPE
40 : LLGlobalValue::InternalLinkage; 40 : LLGlobalValue::InternalLinkage;
41 LLGlobalVariable* gv = new LLGlobalVariable(type, true, linkage, NULL, name, gIR->module); 41 LLGlobalVariable* gv = new LLGlobalVariable(type, true, linkage, NULL, name, gIR->module);
42 gv->setSection("llvm.metadata"); 42 gv->setSection("llvm.metadata");
43 return gv; 43 return gv;
44 }
45
46 //////////////////////////////////////////////////////////////////////////////////////////////////
47
48 static llvm::DIAnchor getDwarfAnchor(dwarf_constants c)
49 {
50 switch (c)
51 {
52 case DW_TAG_compile_unit:
53 return gIR->difactory.GetOrCreateCompileUnitAnchor();
54 case DW_TAG_variable:
55 return gIR->difactory.GetOrCreateGlobalVariableAnchor();
56 case DW_TAG_subprogram:
57 return gIR->difactory.GetOrCreateSubprogramAnchor();
58 default:
59 assert(0);
60 }
61 } 44 }
62 45
63 ////////////////////////////////////////////////////////////////////////////////////////////////// 46 //////////////////////////////////////////////////////////////////////////////////////////////////
64 47
65 static const llvm::StructType* getDwarfCompileUnitType() { 48 static const llvm::StructType* getDwarfCompileUnitType() {
309 return ir->diCompositeType; 292 return ir->diCompositeType;
310 293
311 // set to handle recursive types properly 294 // set to handle recursive types properly
312 gv = emitDwarfGlobalDecl(getDwarfCompositeTypeType(), "llvm.dbg.compositetype"); 295 gv = emitDwarfGlobalDecl(getDwarfCompositeTypeType(), "llvm.dbg.compositetype");
313 // set bogus initializer to satisfy asserts in DICompositeType constructor 296 // set bogus initializer to satisfy asserts in DICompositeType constructor
314 gv->setInitializer(LLConstant::getNullValue(getDwarfCompositeTypeType())); 297 std::vector<LLConstant*> initvals(11);
298 initvals[0] = DBG_TAG(DW_TAG_structure_type);
299 for (int i = 1; i < initvals.size(); ++i)
300 initvals[i] = LLConstant::getNullValue(getDwarfCompositeTypeType()->getContainedType(i));
301 gv->setInitializer(LLConstantStruct::get(getDwarfCompositeTypeType(), initvals));
315 ir->diCompositeType = llvm::DICompositeType(gv); 302 ir->diCompositeType = llvm::DICompositeType(gv);
316 303
317 tag = DW_TAG_structure_type; 304 tag = DW_TAG_structure_type;
318 305
319 name = DtoConstStringPtr(sd->toChars(), "llvm.metadata"); 306 name = DtoConstStringPtr(sd->toChars(), "llvm.metadata");