From: Chris Lattner Date: Mon, 28 Dec 2009 21:45:40 +0000 (+0000) Subject: move debug info stuff out of line, allowing two #includes X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=43469b6957140898709382082ef95dd4b77ac20a;p=oota-llvm.git move debug info stuff out of line, allowing two #includes to go away from IRBuilder.h git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92230 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/Support/IRBuilder.h b/include/llvm/Support/IRBuilder.h index 92230a81839..a89d5a6ea2c 100644 --- a/include/llvm/Support/IRBuilder.h +++ b/include/llvm/Support/IRBuilder.h @@ -18,12 +18,11 @@ #include "llvm/Constants.h" #include "llvm/Instructions.h" #include "llvm/Function.h" -#include "llvm/Metadata.h" -#include "llvm/LLVMContext.h" #include "llvm/ADT/Twine.h" #include "llvm/Support/ConstantFolder.h" namespace llvm { + class MDNode; /// IRBuilderDefaultInserter - This provides the default implementation of the /// IRBuilder 'InsertHelper' method that is called whenever an instruction is @@ -42,11 +41,11 @@ protected: /// IRBuilderBase - Common base class shared among various IRBuilders. class IRBuilderBase { + unsigned DbgMDKind; + MDNode *CurDbgLocation; protected: BasicBlock *BB; BasicBlock::iterator InsertPt; - unsigned DbgMDKind; - MDNode *CurDbgLocation; LLVMContext &Context; public: @@ -84,27 +83,13 @@ public: /// SetCurrentDebugLocation - Set location information used by debugging /// information. - void SetCurrentDebugLocation(MDNode *L) { - if (DbgMDKind == 0) - DbgMDKind = Context.getMetadata().getMDKindID("dbg"); - CurDbgLocation = L; - } - + void SetCurrentDebugLocation(MDNode *L); MDNode *getCurrentDebugLocation() const { return CurDbgLocation; } - /// SetDebugLocation - Set location information for the given instruction. - void SetDebugLocation(Instruction *I) { - if (CurDbgLocation) - Context.getMetadata().addMD(DbgMDKind, CurDbgLocation, I); - } - - /// SetDebugLocation - Set location information for the given instruction. - void SetDebugLocation(Instruction *I, MDNode *Loc) { - if (DbgMDKind == 0) - DbgMDKind = Context.getMetadata().getMDKindID("dbg"); - Context.getMetadata().addMD(DbgMDKind, Loc, I); - } - + /// SetInstDebugLocation - If this builder has a current debug location, set + /// it on the specified instruction. + void SetInstDebugLocation(Instruction *I) const; + //===--------------------------------------------------------------------===// // Miscellaneous creation methods. //===--------------------------------------------------------------------===// @@ -216,8 +201,8 @@ public: template InstTy *Insert(InstTy *I, const Twine &Name = "") const { this->InsertHelper(I, Name, BB, InsertPt); - if (CurDbgLocation) - Context.getMetadata().addMD(DbgMDKind, CurDbgLocation, I); + if (getCurrentDebugLocation() != 0) + this->SetInstDebugLocation(I); return I; } diff --git a/lib/Target/Target.cpp b/lib/Target/Target.cpp index cc6be9fa7ab..cddf49e5154 100644 --- a/lib/Target/Target.cpp +++ b/lib/Target/Target.cpp @@ -15,6 +15,7 @@ #include "llvm-c/Target.h" #include "llvm/PassManager.h" #include "llvm/Target/TargetData.h" +#include "llvm/LLVMContext.h" #include using namespace llvm; diff --git a/lib/VMCore/IRBuilder.cpp b/lib/VMCore/IRBuilder.cpp index 850812cf66d..99803f134f5 100644 --- a/lib/VMCore/IRBuilder.cpp +++ b/lib/VMCore/IRBuilder.cpp @@ -14,6 +14,8 @@ #include "llvm/Support/IRBuilder.h" #include "llvm/GlobalVariable.h" +#include "llvm/Metadata.h" +#include "llvm/LLVMContext.h" using namespace llvm; /// CreateGlobalString - Make a new global variable with an initializer that @@ -29,3 +31,16 @@ Value *IRBuilderBase::CreateGlobalString(const char *Str, const Twine &Name) { GV->setName(Name); return GV; } + +/// SetCurrentDebugLocation - Set location information used by debugging +/// information. +void IRBuilderBase::SetCurrentDebugLocation(MDNode *L) { + if (DbgMDKind == 0) + DbgMDKind = Context.getMetadata().getMDKindID("dbg"); + CurDbgLocation = L; +} + +void IRBuilderBase::SetInstDebugLocation(Instruction *I) const { + if (CurDbgLocation) + Context.getMetadata().addMD(DbgMDKind, CurDbgLocation, I); +}