-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
This commit is contained in:
Argyrios Kyrtzidis
2009-05-03 08:50:41 +00:00
parent f9a77b77c2
commit 77eaa6880b
6 changed files with 162 additions and 191 deletions

View File

@ -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;