//===--- DebugInfo.cpp - Debug Information Helper Classes -----------------===////// The LLVM Compiler Infrastructure//// This file is distributed under the University of Illinois Open Source// License. See LICENSE.TXT for details.////===----------------------------------------------------------------------===////// This file implements the helper classes used to build and interpret debug// information in LLVM IR form.////===----------------------------------------------------------------------===//#include"llvm/Analysis/DebugInfo.h"#include"llvm/Constants.h"#include"llvm/DerivedTypes.h"#include"llvm/Intrinsics.h"#include"llvm/IntrinsicInst.h"#include"llvm/Instructions.h"#include"llvm/LLVMContext.h"#include"llvm/Module.h"#include"llvm/Analysis/ValueTracking.h"#include"llvm/Support/Dwarf.h"#include"llvm/Support/DebugLoc.h"#include"llvm/Support/Streams.h"usingnamespacellvm;usingnamespacellvm::dwarf;//===----------------------------------------------------------------------===//// DIDescriptor//===----------------------------------------------------------------------===///// ValidDebugInfo - Return true if V represents valid debug info value.boolDIDescriptor::ValidDebugInfo(Value*V,CodeGenOpt::LevelOptLevel){if(!V)returnfalse;GlobalVariable*GV=dyn_cast<GlobalVariable>(V->stripPointerCasts());if(!GV)returnfalse;if(!GV->hasInternalLinkage()&&!GV->hasLinkOnceLinkage())returnfalse;DIDescriptorDI(GV);// Check current version. Allow Version6 for now.unsignedVersion=DI.getVersion();if(Version!=LLVMDebugVersion&&Version!=LLVMDebugVersion6)returnfalse;unsignedTag=DI.getTag();switch(Tag){caseDW_TAG_variable:assert(DIVariable(GV).Verify()&&"Invalid DebugInfo value");break;caseDW_TAG_compile_unit:assert(DICompileUnit(GV).Verify()&&"Invalid DebugInfo value");break;caseDW_TAG_subprogram:assert(DISubprogram(GV).Verify()&&"Invalid DebugInfo value");break;caseDW_TAG_lexical_block:// FIXME: This interfers with the quality of generated code during// optimization.if(OptLevel!=CodeGenOpt::None)returnfalse;// FALLTHROUGHdefault:break;}returntrue;}DIDescriptor::DIDescriptor(GlobalVariable*GV,unsignedRequiredTag){DbgGV