diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2009-05-03 08:50:41 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2009-05-03 08:50:41 +0000 |
commit | 77eaa6880b8209acc05de733ebaba5d146c321a0 (patch) | |
tree | 6662090a5db0ec4ac30642a80a6f9521752cb332 /lib/Analysis/DebugInfo.cpp | |
parent | f9a77b77c2324b2ca5c644909ebda387daf82fe3 (diff) |
-Move the DwarfWriter::ValidDebugInfo check to a static DIDescriptor::ValidDebugInfo
-Create DebugLocs without the need to have a DwarfWriter around
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70682 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/DebugInfo.cpp')
-rw-r--r-- | lib/Analysis/DebugInfo.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/lib/Analysis/DebugInfo.cpp b/lib/Analysis/DebugInfo.cpp index 7db9b2f3bc..61e8a1086b 100644 --- a/lib/Analysis/DebugInfo.cpp +++ b/lib/Analysis/DebugInfo.cpp @@ -20,13 +20,57 @@ #include "llvm/Instructions.h" #include "llvm/Module.h" #include "llvm/Analysis/ValueTracking.h" +#include "llvm/Support/Dwarf.h" #include "llvm/Support/Streams.h" using namespace llvm; +using namespace llvm::dwarf; //===----------------------------------------------------------------------===// // DIDescriptor //===----------------------------------------------------------------------===// +/// ValidDebugInfo - Return true if V represents valid debug info value. +bool DIDescriptor::ValidDebugInfo(Value *V, CodeGenOpt::Level OptLevel) { + if (!V) + return false; + + GlobalVariable *GV = dyn_cast<GlobalVariable>(V->stripPointerCasts()); + if (!GV) + return false; + + if (!GV->hasInternalLinkage () && !GV->hasLinkOnceLinkage()) + return false; + + DIDescriptor DI(GV); + + // Check current version. Allow Version6 for now. + unsigned Version = DI.getVersion(); + if (Version != LLVMDebugVersion && Version != LLVMDebugVersion6) + return false; + + unsigned Tag = DI.getTag(); + switch (Tag) { + case DW_TAG_variable: + assert(DIVariable(GV).Verify() && "Invalid DebugInfo value"); + break; + case DW_TAG_compile_unit: + assert(DICompileUnit(GV).Verify() && "Invalid DebugInfo value"); + break; + case DW_TAG_subprogram: + assert(DISubprogram(GV).Verify() && "Invalid DebugInfo value"); + break; + case DW_TAG_lexical_block: + /// FIXME. This interfers with the quality of generated code when + /// during optimization. + if (OptLevel != CodeGenOpt::None) + return false; + default: + break; + } + + return true; +} + DIDescriptor::DIDescriptor(GlobalVariable *gv, unsigned RequiredTag) { GV = gv; |