1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
/*========================== begin_copyright_notice ============================
Copyright (C) 2021 Intel Corporation
SPDX-License-Identifier: MIT
============================= end_copyright_notice ===========================*/
#ifndef VC_UTILS_GENERAL_DEBUG_INFO_H
#define VC_UTILS_GENERAL_DEBUG_INFO_H
#include <llvm/IR/DebugInfoMetadata.h>
#include <llvm/ADT/StringRef.h>
namespace llvm {
class GlobalVariable;
class DbgDeclareInst;
class Instruction;
class Function;
class Module;
class Type;
} // namespace llvm
namespace vc {
// Utility class to construct new debug information nodes
// The interface is vaguely similar to llvm::DIBuilder, however it can
// be used on a Module that already contains DICompilation units, allowing
// for an addition or modification of an existing debug information.
class DIBuilder {
llvm::Module &M;
llvm::DIType *translateScalarTypeToDIType(llvm::Type &Ty) const;
void registerNewGlobalVariable(llvm::DIGlobalVariableExpression *NewGV) const;
public:
static bool checkIfModuleHasDebugInfo(const llvm::Module &M);
static bool checkIfFunctionHasDebugInfo(const llvm::Function &F);
static llvm::DbgDeclareInst *
createDbgDeclareForLocalizedGlobal(llvm::Instruction &Address,
const llvm::GlobalVariable &GV,
llvm::Instruction &InsertPt);
DIBuilder(llvm::Module &MIn) : M(MIn) {}
llvm::DIType *translateTypeToDIType(llvm::Type &Ty) const;
llvm::DICompileUnit *getDICompileUnit() const;
llvm::DILocation *createLocationForFunctionScope(llvm::Function &Fn) const;
llvm::DIGlobalVariableExpression *
createGlobalVariableExpression(llvm::StringRef Name,
llvm::StringRef LinkageName,
llvm::DIType *Type) const;
llvm::DbgDeclareInst *createDbgDeclare(llvm::Value &Address,
llvm::DILocalVariable &LocalVar,
llvm::DIExpression &Expr,
llvm::DILocation &Loc,
llvm::Instruction &InsertPt) const;
llvm::DILocalVariable *
createLocalVariable(llvm::DILocalScope *Scope, llvm::StringRef Name,
llvm::DIFile *File, unsigned LineNo, llvm::DIType *Type,
unsigned ArgNo, llvm::DINode::DIFlags Flags,
unsigned AlignInBits) const;
};
} // namespace vc
#endif // VC_UTILS_GENERAL_DEBUG_INFO_H
|