Introduce DIBuilder. It is intended to be a front-end friendly interface to emit debuggging information entries in LLVM IR.
To create debugging information for a pointer, using DIBUilder front-end just needs
DBuilder.CreatePointerType(Ty, Size);
instead of
DebugFactory.CreateDerivedType(llvm::dwarf::DW_TAG_pointer_type,
TheCU, "", getOrCreateMainFile(),
0, Size, 0, 0, 0, OCTy);
llvm-svn: 118248
2010-11-04 23:01:38 +08:00
|
|
|
//===--- DIBuilder.cpp - Debug Information Builder ------------------------===//
|
|
|
|
//
|
|
|
|
// 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 DIBuilder.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2012-06-29 16:32:07 +08:00
|
|
|
#include "llvm/DIBuilder.h"
|
2012-12-04 00:50:05 +08:00
|
|
|
#include "llvm/ADT/STLExtras.h"
|
2012-06-28 08:05:13 +08:00
|
|
|
#include "llvm/DebugInfo.h"
|
2013-01-02 19:36:10 +08:00
|
|
|
#include "llvm/IR/Constants.h"
|
|
|
|
#include "llvm/IR/IntrinsicInst.h"
|
|
|
|
#include "llvm/IR/Module.h"
|
2012-04-03 08:43:49 +08:00
|
|
|
#include "llvm/Support/Debug.h"
|
Introduce DIBuilder. It is intended to be a front-end friendly interface to emit debuggging information entries in LLVM IR.
To create debugging information for a pointer, using DIBUilder front-end just needs
DBuilder.CreatePointerType(Ty, Size);
instead of
DebugFactory.CreateDerivedType(llvm::dwarf::DW_TAG_pointer_type,
TheCU, "", getOrCreateMainFile(),
0, Size, 0, 0, 0, OCTy);
llvm-svn: 118248
2010-11-04 23:01:38 +08:00
|
|
|
#include "llvm/Support/Dwarf.h"
|
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
using namespace llvm::dwarf;
|
|
|
|
|
|
|
|
static Constant *GetTagConstant(LLVMContext &VMContext, unsigned Tag) {
|
|
|
|
assert((Tag & LLVMDebugVersionMask) == 0 &&
|
|
|
|
"Tag too large for debug encoding!");
|
|
|
|
return ConstantInt::get(Type::getInt32Ty(VMContext), Tag | LLVMDebugVersion);
|
|
|
|
}
|
2010-12-08 07:58:00 +08:00
|
|
|
|
Introduce DIBuilder. It is intended to be a front-end friendly interface to emit debuggging information entries in LLVM IR.
To create debugging information for a pointer, using DIBUilder front-end just needs
DBuilder.CreatePointerType(Ty, Size);
instead of
DebugFactory.CreateDerivedType(llvm::dwarf::DW_TAG_pointer_type,
TheCU, "", getOrCreateMainFile(),
0, Size, 0, 0, 0, OCTy);
llvm-svn: 118248
2010-11-04 23:01:38 +08:00
|
|
|
DIBuilder::DIBuilder(Module &m)
|
2011-08-27 05:02:40 +08:00
|
|
|
: M(m), VMContext(M.getContext()), TheCU(0), TempEnumTypes(0),
|
|
|
|
TempRetainTypes(0), TempSubprograms(0), TempGVs(0), DeclareFn(0),
|
|
|
|
ValueFn(0)
|
2011-08-17 06:09:43 +08:00
|
|
|
{}
|
Introduce DIBuilder. It is intended to be a front-end friendly interface to emit debuggging information entries in LLVM IR.
To create debugging information for a pointer, using DIBUilder front-end just needs
DBuilder.CreatePointerType(Ty, Size);
instead of
DebugFactory.CreateDerivedType(llvm::dwarf::DW_TAG_pointer_type,
TheCU, "", getOrCreateMainFile(),
0, Size, 0, 0, 0, OCTy);
llvm-svn: 118248
2010-11-04 23:01:38 +08:00
|
|
|
|
2011-08-16 07:00:00 +08:00
|
|
|
/// finalize - Construct any deferred debug info descriptors.
|
|
|
|
void DIBuilder::finalize() {
|
2011-08-17 06:09:43 +08:00
|
|
|
DIArray Enums = getOrCreateArray(AllEnumTypes);
|
|
|
|
DIType(TempEnumTypes).replaceAllUsesWith(Enums);
|
|
|
|
|
|
|
|
DIArray RetainTypes = getOrCreateArray(AllRetainTypes);
|
|
|
|
DIType(TempRetainTypes).replaceAllUsesWith(RetainTypes);
|
|
|
|
|
|
|
|
DIArray SPs = getOrCreateArray(AllSubprograms);
|
|
|
|
DIType(TempSubprograms).replaceAllUsesWith(SPs);
|
2011-08-20 07:28:12 +08:00
|
|
|
for (unsigned i = 0, e = SPs.getNumElements(); i != e; ++i) {
|
|
|
|
DISubprogram SP(SPs.getElement(i));
|
2012-04-24 03:00:11 +08:00
|
|
|
SmallVector<Value *, 4> Variables;
|
2011-08-20 07:28:12 +08:00
|
|
|
if (NamedMDNode *NMD = getFnSpecificMDNode(M, SP)) {
|
|
|
|
for (unsigned ii = 0, ee = NMD->getNumOperands(); ii != ee; ++ii)
|
|
|
|
Variables.push_back(NMD->getOperand(ii));
|
|
|
|
NMD->eraseFromParent();
|
|
|
|
}
|
2012-04-24 03:00:11 +08:00
|
|
|
if (MDNode *Temp = SP.getVariablesNodes()) {
|
|
|
|
DIArray AV = getOrCreateArray(Variables);
|
|
|
|
DIType(Temp).replaceAllUsesWith(AV);
|
|
|
|
}
|
2011-08-20 07:28:12 +08:00
|
|
|
}
|
2011-08-17 06:09:43 +08:00
|
|
|
|
|
|
|
DIArray GVs = getOrCreateArray(AllGVs);
|
|
|
|
DIType(TempGVs).replaceAllUsesWith(GVs);
|
|
|
|
}
|
|
|
|
|
2011-08-27 05:02:40 +08:00
|
|
|
/// getNonCompileUnitScope - If N is compile unit return NULL otherwise return
|
|
|
|
/// N.
|
2011-08-17 06:09:43 +08:00
|
|
|
static MDNode *getNonCompileUnitScope(MDNode *N) {
|
|
|
|
if (DIDescriptor(N).isCompileUnit())
|
|
|
|
return NULL;
|
|
|
|
return N;
|
2011-08-16 07:00:00 +08:00
|
|
|
}
|
|
|
|
|
2011-02-23 02:56:12 +08:00
|
|
|
/// createCompileUnit - A CompileUnit provides an anchor for all debugging
|
Introduce DIBuilder. It is intended to be a front-end friendly interface to emit debuggging information entries in LLVM IR.
To create debugging information for a pointer, using DIBUilder front-end just needs
DBuilder.CreatePointerType(Ty, Size);
instead of
DebugFactory.CreateDerivedType(llvm::dwarf::DW_TAG_pointer_type,
TheCU, "", getOrCreateMainFile(),
0, Size, 0, 0, 0, OCTy);
llvm-svn: 118248
2010-11-04 23:01:38 +08:00
|
|
|
/// information generated during this instance of compilation.
|
2011-08-27 05:02:40 +08:00
|
|
|
void DIBuilder::createCompileUnit(unsigned Lang, StringRef Filename,
|
|
|
|
StringRef Directory, StringRef Producer,
|
|
|
|
bool isOptimized, StringRef Flags,
|
Introduce DIBuilder. It is intended to be a front-end friendly interface to emit debuggging information entries in LLVM IR.
To create debugging information for a pointer, using DIBUilder front-end just needs
DBuilder.CreatePointerType(Ty, Size);
instead of
DebugFactory.CreateDerivedType(llvm::dwarf::DW_TAG_pointer_type,
TheCU, "", getOrCreateMainFile(),
0, Size, 0, 0, 0, OCTy);
llvm-svn: 118248
2010-11-04 23:01:38 +08:00
|
|
|
unsigned RunTimeVer) {
|
2012-01-11 02:18:52 +08:00
|
|
|
assert(((Lang <= dwarf::DW_LANG_Python && Lang >= dwarf::DW_LANG_C89) ||
|
|
|
|
(Lang <= dwarf::DW_LANG_hi_user && Lang >= dwarf::DW_LANG_lo_user)) &&
|
|
|
|
"Invalid Language tag");
|
|
|
|
assert(!Filename.empty() &&
|
|
|
|
"Unable to create compile unit without filename");
|
2011-08-17 06:09:43 +08:00
|
|
|
Value *TElts[] = { GetTagConstant(VMContext, DW_TAG_base_type) };
|
|
|
|
TempEnumTypes = MDNode::getTemporary(VMContext, TElts);
|
|
|
|
|
|
|
|
TempRetainTypes = MDNode::getTemporary(VMContext, TElts);
|
|
|
|
|
|
|
|
TempSubprograms = MDNode::getTemporary(VMContext, TElts);
|
|
|
|
|
|
|
|
TempGVs = MDNode::getTemporary(VMContext, TElts);
|
|
|
|
|
2010-11-05 02:45:27 +08:00
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_compile_unit),
|
2012-07-07 01:47:36 +08:00
|
|
|
Constant::getNullValue(Type::getInt32Ty(VMContext)),
|
2010-11-05 02:45:27 +08:00
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), Lang),
|
|
|
|
MDString::get(VMContext, Filename),
|
|
|
|
MDString::get(VMContext, Directory),
|
|
|
|
MDString::get(VMContext, Producer),
|
|
|
|
// Deprecate isMain field.
|
|
|
|
ConstantInt::get(Type::getInt1Ty(VMContext), true), // isMain
|
|
|
|
ConstantInt::get(Type::getInt1Ty(VMContext), isOptimized),
|
|
|
|
MDString::get(VMContext, Flags),
|
2011-08-17 06:09:43 +08:00
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), RunTimeVer),
|
2013-02-02 13:56:24 +08:00
|
|
|
TempEnumTypes,
|
|
|
|
TempRetainTypes,
|
|
|
|
TempSubprograms,
|
|
|
|
TempGVs
|
2010-11-05 02:45:27 +08:00
|
|
|
};
|
2011-04-19 07:51:03 +08:00
|
|
|
TheCU = DICompileUnit(MDNode::get(VMContext, Elts));
|
2011-05-04 00:18:28 +08:00
|
|
|
|
|
|
|
// Create a named metadata so that it is easier to find cu in a module.
|
|
|
|
NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.cu");
|
|
|
|
NMD->addOperand(TheCU);
|
Introduce DIBuilder. It is intended to be a front-end friendly interface to emit debuggging information entries in LLVM IR.
To create debugging information for a pointer, using DIBUilder front-end just needs
DBuilder.CreatePointerType(Ty, Size);
instead of
DebugFactory.CreateDerivedType(llvm::dwarf::DW_TAG_pointer_type,
TheCU, "", getOrCreateMainFile(),
0, Size, 0, 0, 0, OCTy);
llvm-svn: 118248
2010-11-04 23:01:38 +08:00
|
|
|
}
|
|
|
|
|
2011-02-23 02:56:12 +08:00
|
|
|
/// createFile - Create a file descriptor to hold debugging information
|
Introduce DIBuilder. It is intended to be a front-end friendly interface to emit debuggging information entries in LLVM IR.
To create debugging information for a pointer, using DIBUilder front-end just needs
DBuilder.CreatePointerType(Ty, Size);
instead of
DebugFactory.CreateDerivedType(llvm::dwarf::DW_TAG_pointer_type,
TheCU, "", getOrCreateMainFile(),
0, Size, 0, 0, 0, OCTy);
llvm-svn: 118248
2010-11-04 23:01:38 +08:00
|
|
|
/// for a file.
|
2011-02-23 02:56:12 +08:00
|
|
|
DIFile DIBuilder::createFile(StringRef Filename, StringRef Directory) {
|
2010-11-05 02:45:27 +08:00
|
|
|
assert(TheCU && "Unable to create DW_TAG_file_type without CompileUnit");
|
2011-09-13 02:26:08 +08:00
|
|
|
assert(!Filename.empty() && "Unable to create file without name");
|
2010-11-05 02:45:27 +08:00
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_file_type),
|
|
|
|
MDString::get(VMContext, Filename),
|
|
|
|
MDString::get(VMContext, Directory),
|
2011-08-17 06:09:43 +08:00
|
|
|
NULL // TheCU
|
2010-11-05 02:45:27 +08:00
|
|
|
};
|
2011-04-19 07:51:03 +08:00
|
|
|
return DIFile(MDNode::get(VMContext, Elts));
|
Introduce DIBuilder. It is intended to be a front-end friendly interface to emit debuggging information entries in LLVM IR.
To create debugging information for a pointer, using DIBUilder front-end just needs
DBuilder.CreatePointerType(Ty, Size);
instead of
DebugFactory.CreateDerivedType(llvm::dwarf::DW_TAG_pointer_type,
TheCU, "", getOrCreateMainFile(),
0, Size, 0, 0, 0, OCTy);
llvm-svn: 118248
2010-11-04 23:01:38 +08:00
|
|
|
}
|
|
|
|
|
2011-02-23 02:56:12 +08:00
|
|
|
/// createEnumerator - Create a single enumerator value.
|
|
|
|
DIEnumerator DIBuilder::createEnumerator(StringRef Name, uint64_t Val) {
|
2011-09-13 02:26:08 +08:00
|
|
|
assert(!Name.empty() && "Unable to create enumerator without name");
|
2010-11-05 02:45:27 +08:00
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_enumerator),
|
|
|
|
MDString::get(VMContext, Name),
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), Val)
|
|
|
|
};
|
2011-04-19 07:51:03 +08:00
|
|
|
return DIEnumerator(MDNode::get(VMContext, Elts));
|
Introduce DIBuilder. It is intended to be a front-end friendly interface to emit debuggging information entries in LLVM IR.
To create debugging information for a pointer, using DIBUilder front-end just needs
DBuilder.CreatePointerType(Ty, Size);
instead of
DebugFactory.CreateDerivedType(llvm::dwarf::DW_TAG_pointer_type,
TheCU, "", getOrCreateMainFile(),
0, Size, 0, 0, 0, OCTy);
llvm-svn: 118248
2010-11-04 23:01:38 +08:00
|
|
|
}
|
|
|
|
|
2011-09-15 07:13:28 +08:00
|
|
|
/// createNullPtrType - Create C++0x nullptr type.
|
|
|
|
DIType DIBuilder::createNullPtrType(StringRef Name) {
|
|
|
|
assert(!Name.empty() && "Unable to create type without name");
|
|
|
|
// nullptr is encoded in DIBasicType format. Line number, filename,
|
|
|
|
// ,size, alignment, offset and flags are always empty here.
|
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_unspecified_type),
|
|
|
|
NULL, //TheCU,
|
|
|
|
MDString::get(VMContext, Name),
|
|
|
|
NULL, // Filename
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Line
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), 0), // Size
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), 0), // Align
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), 0), // Offset
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Flags;
|
2012-07-07 01:49:19 +08:00
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0) // Encoding
|
2011-09-15 07:13:28 +08:00
|
|
|
};
|
|
|
|
return DIType(MDNode::get(VMContext, Elts));
|
|
|
|
}
|
|
|
|
|
2011-08-27 05:02:40 +08:00
|
|
|
/// createBasicType - Create debugging information entry for a basic
|
Introduce DIBuilder. It is intended to be a front-end friendly interface to emit debuggging information entries in LLVM IR.
To create debugging information for a pointer, using DIBUilder front-end just needs
DBuilder.CreatePointerType(Ty, Size);
instead of
DebugFactory.CreateDerivedType(llvm::dwarf::DW_TAG_pointer_type,
TheCU, "", getOrCreateMainFile(),
0, Size, 0, 0, 0, OCTy);
llvm-svn: 118248
2010-11-04 23:01:38 +08:00
|
|
|
/// type, e.g 'char'.
|
2013-02-12 08:40:41 +08:00
|
|
|
DIBasicType
|
|
|
|
DIBuilder::createBasicType(StringRef Name, uint64_t SizeInBits,
|
|
|
|
uint64_t AlignInBits, unsigned Encoding) {
|
2011-09-13 02:26:08 +08:00
|
|
|
assert(!Name.empty() && "Unable to create type without name");
|
Introduce DIBuilder. It is intended to be a front-end friendly interface to emit debuggging information entries in LLVM IR.
To create debugging information for a pointer, using DIBUilder front-end just needs
DBuilder.CreatePointerType(Ty, Size);
instead of
DebugFactory.CreateDerivedType(llvm::dwarf::DW_TAG_pointer_type,
TheCU, "", getOrCreateMainFile(),
0, Size, 0, 0, 0, OCTy);
llvm-svn: 118248
2010-11-04 23:01:38 +08:00
|
|
|
// Basic types are encoded in DIBasicType format. Line number, filename,
|
|
|
|
// offset and flags are always empty here.
|
2010-11-05 02:45:27 +08:00
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_base_type),
|
2011-08-17 06:09:43 +08:00
|
|
|
NULL, //TheCU,
|
2010-11-05 02:45:27 +08:00
|
|
|
MDString::get(VMContext, Name),
|
|
|
|
NULL, // Filename
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Line
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), SizeInBits),
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits),
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), 0), // Offset
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Flags;
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), Encoding)
|
|
|
|
};
|
2013-02-12 08:40:41 +08:00
|
|
|
return DIBasicType(MDNode::get(VMContext, Elts));
|
Introduce DIBuilder. It is intended to be a front-end friendly interface to emit debuggging information entries in LLVM IR.
To create debugging information for a pointer, using DIBUilder front-end just needs
DBuilder.CreatePointerType(Ty, Size);
instead of
DebugFactory.CreateDerivedType(llvm::dwarf::DW_TAG_pointer_type,
TheCU, "", getOrCreateMainFile(),
0, Size, 0, 0, 0, OCTy);
llvm-svn: 118248
2010-11-04 23:01:38 +08:00
|
|
|
}
|
|
|
|
|
2011-11-10 06:45:04 +08:00
|
|
|
/// createQualifiedType - Create debugging information entry for a qualified
|
Introduce DIBuilder. It is intended to be a front-end friendly interface to emit debuggging information entries in LLVM IR.
To create debugging information for a pointer, using DIBUilder front-end just needs
DBuilder.CreatePointerType(Ty, Size);
instead of
DebugFactory.CreateDerivedType(llvm::dwarf::DW_TAG_pointer_type,
TheCU, "", getOrCreateMainFile(),
0, Size, 0, 0, 0, OCTy);
llvm-svn: 118248
2010-11-04 23:01:38 +08:00
|
|
|
/// type, e.g. 'const int'.
|
2011-02-23 02:56:12 +08:00
|
|
|
DIType DIBuilder::createQualifiedType(unsigned Tag, DIType FromTy) {
|
2010-11-05 02:45:27 +08:00
|
|
|
// Qualified types are encoded in DIDerivedType format.
|
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, Tag),
|
2011-08-17 06:09:43 +08:00
|
|
|
NULL, //TheCU,
|
2010-11-05 02:45:27 +08:00
|
|
|
MDString::get(VMContext, StringRef()), // Empty name.
|
|
|
|
NULL, // Filename
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Line
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), 0), // Size
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), 0), // Align
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), 0), // Offset
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Flags
|
|
|
|
FromTy
|
|
|
|
};
|
2011-04-19 07:51:03 +08:00
|
|
|
return DIType(MDNode::get(VMContext, Elts));
|
Introduce DIBuilder. It is intended to be a front-end friendly interface to emit debuggging information entries in LLVM IR.
To create debugging information for a pointer, using DIBUilder front-end just needs
DBuilder.CreatePointerType(Ty, Size);
instead of
DebugFactory.CreateDerivedType(llvm::dwarf::DW_TAG_pointer_type,
TheCU, "", getOrCreateMainFile(),
0, Size, 0, 0, 0, OCTy);
llvm-svn: 118248
2010-11-04 23:01:38 +08:00
|
|
|
}
|
|
|
|
|
2011-02-23 02:56:12 +08:00
|
|
|
/// createPointerType - Create debugging information entry for a pointer.
|
|
|
|
DIType DIBuilder::createPointerType(DIType PointeeTy, uint64_t SizeInBits,
|
Introduce DIBuilder. It is intended to be a front-end friendly interface to emit debuggging information entries in LLVM IR.
To create debugging information for a pointer, using DIBUilder front-end just needs
DBuilder.CreatePointerType(Ty, Size);
instead of
DebugFactory.CreateDerivedType(llvm::dwarf::DW_TAG_pointer_type,
TheCU, "", getOrCreateMainFile(),
0, Size, 0, 0, 0, OCTy);
llvm-svn: 118248
2010-11-04 23:01:38 +08:00
|
|
|
uint64_t AlignInBits, StringRef Name) {
|
2010-11-05 02:45:27 +08:00
|
|
|
// Pointer types are encoded in DIDerivedType format.
|
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_pointer_type),
|
2011-08-17 06:09:43 +08:00
|
|
|
NULL, //TheCU,
|
2010-11-05 02:45:27 +08:00
|
|
|
MDString::get(VMContext, Name),
|
|
|
|
NULL, // Filename
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Line
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), SizeInBits),
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits),
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), 0), // Offset
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Flags
|
|
|
|
PointeeTy
|
|
|
|
};
|
2011-04-19 07:51:03 +08:00
|
|
|
return DIType(MDNode::get(VMContext, Elts));
|
Introduce DIBuilder. It is intended to be a front-end friendly interface to emit debuggging information entries in LLVM IR.
To create debugging information for a pointer, using DIBUilder front-end just needs
DBuilder.CreatePointerType(Ty, Size);
instead of
DebugFactory.CreateDerivedType(llvm::dwarf::DW_TAG_pointer_type,
TheCU, "", getOrCreateMainFile(),
0, Size, 0, 0, 0, OCTy);
llvm-svn: 118248
2010-11-04 23:01:38 +08:00
|
|
|
}
|
|
|
|
|
2013-01-07 13:51:15 +08:00
|
|
|
DIType DIBuilder::createMemberPointerType(DIType PointeeTy, DIType Base) {
|
|
|
|
// Pointer types are encoded in DIDerivedType format.
|
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_ptr_to_member_type),
|
|
|
|
NULL, //TheCU,
|
|
|
|
NULL,
|
|
|
|
NULL, // Filename
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Line
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), 0),
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), 0),
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), 0), // Offset
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Flags
|
|
|
|
PointeeTy,
|
|
|
|
Base
|
|
|
|
};
|
|
|
|
return DIType(MDNode::get(VMContext, Elts));
|
|
|
|
}
|
|
|
|
|
2012-05-19 09:36:37 +08:00
|
|
|
/// createReferenceType - Create debugging information entry for a reference
|
|
|
|
/// type.
|
|
|
|
DIType DIBuilder::createReferenceType(unsigned Tag, DIType RTy) {
|
2011-09-13 02:26:08 +08:00
|
|
|
assert(RTy.Verify() && "Unable to create reference type");
|
2010-11-05 02:45:27 +08:00
|
|
|
// References are encoded in DIDerivedType format.
|
|
|
|
Value *Elts[] = {
|
2012-05-19 09:36:37 +08:00
|
|
|
GetTagConstant(VMContext, Tag),
|
2011-08-27 05:02:40 +08:00
|
|
|
NULL, // TheCU,
|
2010-11-05 02:45:27 +08:00
|
|
|
NULL, // Name
|
|
|
|
NULL, // Filename
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Line
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), 0), // Size
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), 0), // Align
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), 0), // Offset
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Flags
|
|
|
|
RTy
|
|
|
|
};
|
2011-04-19 07:51:03 +08:00
|
|
|
return DIType(MDNode::get(VMContext, Elts));
|
Introduce DIBuilder. It is intended to be a front-end friendly interface to emit debuggging information entries in LLVM IR.
To create debugging information for a pointer, using DIBUilder front-end just needs
DBuilder.CreatePointerType(Ty, Size);
instead of
DebugFactory.CreateDerivedType(llvm::dwarf::DW_TAG_pointer_type,
TheCU, "", getOrCreateMainFile(),
0, Size, 0, 0, 0, OCTy);
llvm-svn: 118248
2010-11-04 23:01:38 +08:00
|
|
|
}
|
|
|
|
|
2011-02-23 02:56:12 +08:00
|
|
|
/// createTypedef - Create debugging information entry for a typedef.
|
|
|
|
DIType DIBuilder::createTypedef(DIType Ty, StringRef Name, DIFile File,
|
2011-06-04 01:04:51 +08:00
|
|
|
unsigned LineNo, DIDescriptor Context) {
|
2010-11-05 02:45:27 +08:00
|
|
|
// typedefs are encoded in DIDerivedType format.
|
|
|
|
assert(Ty.Verify() && "Invalid typedef type!");
|
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_typedef),
|
2011-08-17 06:09:43 +08:00
|
|
|
getNonCompileUnitScope(Context),
|
2010-11-05 02:45:27 +08:00
|
|
|
MDString::get(VMContext, Name),
|
|
|
|
File,
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), LineNo),
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), 0), // Size
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), 0), // Align
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), 0), // Offset
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Flags
|
|
|
|
Ty
|
|
|
|
};
|
2011-04-19 07:51:03 +08:00
|
|
|
return DIType(MDNode::get(VMContext, Elts));
|
Introduce DIBuilder. It is intended to be a front-end friendly interface to emit debuggging information entries in LLVM IR.
To create debugging information for a pointer, using DIBUilder front-end just needs
DBuilder.CreatePointerType(Ty, Size);
instead of
DebugFactory.CreateDerivedType(llvm::dwarf::DW_TAG_pointer_type,
TheCU, "", getOrCreateMainFile(),
0, Size, 0, 0, 0, OCTy);
llvm-svn: 118248
2010-11-04 23:01:38 +08:00
|
|
|
}
|
|
|
|
|
2011-02-23 02:56:12 +08:00
|
|
|
/// createFriend - Create debugging information entry for a 'friend'.
|
|
|
|
DIType DIBuilder::createFriend(DIType Ty, DIType FriendTy) {
|
2010-11-05 02:45:27 +08:00
|
|
|
// typedefs are encoded in DIDerivedType format.
|
|
|
|
assert(Ty.Verify() && "Invalid type!");
|
|
|
|
assert(FriendTy.Verify() && "Invalid friend type!");
|
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_friend),
|
|
|
|
Ty,
|
|
|
|
NULL, // Name
|
|
|
|
Ty.getFile(),
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Line
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), 0), // Size
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), 0), // Align
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), 0), // Offset
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Flags
|
|
|
|
FriendTy
|
|
|
|
};
|
2011-04-19 07:51:03 +08:00
|
|
|
return DIType(MDNode::get(VMContext, Elts));
|
Introduce DIBuilder. It is intended to be a front-end friendly interface to emit debuggging information entries in LLVM IR.
To create debugging information for a pointer, using DIBUilder front-end just needs
DBuilder.CreatePointerType(Ty, Size);
instead of
DebugFactory.CreateDerivedType(llvm::dwarf::DW_TAG_pointer_type,
TheCU, "", getOrCreateMainFile(),
0, Size, 0, 0, 0, OCTy);
llvm-svn: 118248
2010-11-04 23:01:38 +08:00
|
|
|
}
|
|
|
|
|
2011-02-23 02:56:12 +08:00
|
|
|
/// createInheritance - Create debugging information entry to establish
|
2011-09-13 03:58:22 +08:00
|
|
|
/// inheritance relationship between two types.
|
2011-08-27 05:02:40 +08:00
|
|
|
DIType DIBuilder::createInheritance(DIType Ty, DIType BaseTy,
|
Introduce DIBuilder. It is intended to be a front-end friendly interface to emit debuggging information entries in LLVM IR.
To create debugging information for a pointer, using DIBUilder front-end just needs
DBuilder.CreatePointerType(Ty, Size);
instead of
DebugFactory.CreateDerivedType(llvm::dwarf::DW_TAG_pointer_type,
TheCU, "", getOrCreateMainFile(),
0, Size, 0, 0, 0, OCTy);
llvm-svn: 118248
2010-11-04 23:01:38 +08:00
|
|
|
uint64_t BaseOffset, unsigned Flags) {
|
2011-09-13 02:26:08 +08:00
|
|
|
assert(Ty.Verify() && "Unable to create inheritance");
|
2010-11-05 02:45:27 +08:00
|
|
|
// TAG_inheritance is encoded in DIDerivedType format.
|
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_inheritance),
|
|
|
|
Ty,
|
|
|
|
NULL, // Name
|
2010-12-09 05:46:37 +08:00
|
|
|
Ty.getFile(),
|
2010-11-05 02:45:27 +08:00
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Line
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), 0), // Size
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), 0), // Align
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), BaseOffset),
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), Flags),
|
|
|
|
BaseTy
|
|
|
|
};
|
2011-04-19 07:51:03 +08:00
|
|
|
return DIType(MDNode::get(VMContext, Elts));
|
Introduce DIBuilder. It is intended to be a front-end friendly interface to emit debuggging information entries in LLVM IR.
To create debugging information for a pointer, using DIBUilder front-end just needs
DBuilder.CreatePointerType(Ty, Size);
instead of
DebugFactory.CreateDerivedType(llvm::dwarf::DW_TAG_pointer_type,
TheCU, "", getOrCreateMainFile(),
0, Size, 0, 0, 0, OCTy);
llvm-svn: 118248
2010-11-04 23:01:38 +08:00
|
|
|
}
|
|
|
|
|
2011-02-23 02:56:12 +08:00
|
|
|
/// createMemberType - Create debugging information entry for a member.
|
2011-08-27 05:02:40 +08:00
|
|
|
DIType DIBuilder::createMemberType(DIDescriptor Scope, StringRef Name,
|
|
|
|
DIFile File, unsigned LineNumber,
|
Introduce DIBuilder. It is intended to be a front-end friendly interface to emit debuggging information entries in LLVM IR.
To create debugging information for a pointer, using DIBUilder front-end just needs
DBuilder.CreatePointerType(Ty, Size);
instead of
DebugFactory.CreateDerivedType(llvm::dwarf::DW_TAG_pointer_type,
TheCU, "", getOrCreateMainFile(),
0, Size, 0, 0, 0, OCTy);
llvm-svn: 118248
2010-11-04 23:01:38 +08:00
|
|
|
uint64_t SizeInBits, uint64_t AlignInBits,
|
2011-08-27 05:02:40 +08:00
|
|
|
uint64_t OffsetInBits, unsigned Flags,
|
Introduce DIBuilder. It is intended to be a front-end friendly interface to emit debuggging information entries in LLVM IR.
To create debugging information for a pointer, using DIBUilder front-end just needs
DBuilder.CreatePointerType(Ty, Size);
instead of
DebugFactory.CreateDerivedType(llvm::dwarf::DW_TAG_pointer_type,
TheCU, "", getOrCreateMainFile(),
0, Size, 0, 0, 0, OCTy);
llvm-svn: 118248
2010-11-04 23:01:38 +08:00
|
|
|
DIType Ty) {
|
2010-11-05 02:45:27 +08:00
|
|
|
// TAG_member is encoded in DIDerivedType format.
|
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_member),
|
2011-08-17 06:09:43 +08:00
|
|
|
getNonCompileUnitScope(Scope),
|
2010-11-05 02:45:27 +08:00
|
|
|
MDString::get(VMContext, Name),
|
2010-12-08 07:25:47 +08:00
|
|
|
File,
|
2010-11-05 02:45:27 +08:00
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber),
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), SizeInBits),
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits),
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), OffsetInBits),
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), Flags),
|
|
|
|
Ty
|
|
|
|
};
|
2011-04-19 07:51:03 +08:00
|
|
|
return DIType(MDNode::get(VMContext, Elts));
|
Introduce DIBuilder. It is intended to be a front-end friendly interface to emit debuggging information entries in LLVM IR.
To create debugging information for a pointer, using DIBUilder front-end just needs
DBuilder.CreatePointerType(Ty, Size);
instead of
DebugFactory.CreateDerivedType(llvm::dwarf::DW_TAG_pointer_type,
TheCU, "", getOrCreateMainFile(),
0, Size, 0, 0, 0, OCTy);
llvm-svn: 118248
2010-11-04 23:01:38 +08:00
|
|
|
}
|
|
|
|
|
2013-01-16 09:22:23 +08:00
|
|
|
/// createStaticMemberType - Create debugging information entry for a
|
|
|
|
/// C++ static data member.
|
|
|
|
DIType DIBuilder::createStaticMemberType(DIDescriptor Scope, StringRef Name,
|
|
|
|
DIFile File, unsigned LineNumber,
|
|
|
|
DIType Ty, unsigned Flags,
|
|
|
|
llvm::Value *Val) {
|
|
|
|
// TAG_member is encoded in DIDerivedType format.
|
|
|
|
Flags |= DIDescriptor::FlagStaticMember;
|
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_member),
|
|
|
|
getNonCompileUnitScope(Scope),
|
|
|
|
MDString::get(VMContext, Name),
|
|
|
|
File,
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber),
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), 0/*SizeInBits*/),
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), 0/*AlignInBits*/),
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), 0/*OffsetInBits*/),
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), Flags),
|
|
|
|
Ty,
|
|
|
|
Val
|
|
|
|
};
|
|
|
|
return DIType(MDNode::get(VMContext, Elts));
|
|
|
|
}
|
|
|
|
|
2011-04-16 08:11:51 +08:00
|
|
|
/// createObjCIVar - Create debugging information entry for Objective-C
|
|
|
|
/// instance variable.
|
2011-08-27 05:02:40 +08:00
|
|
|
DIType DIBuilder::createObjCIVar(StringRef Name,
|
|
|
|
DIFile File, unsigned LineNumber,
|
2011-04-16 08:11:51 +08:00
|
|
|
uint64_t SizeInBits, uint64_t AlignInBits,
|
2011-08-27 05:02:40 +08:00
|
|
|
uint64_t OffsetInBits, unsigned Flags,
|
2011-04-16 08:11:51 +08:00
|
|
|
DIType Ty, StringRef PropertyName,
|
|
|
|
StringRef GetterName, StringRef SetterName,
|
|
|
|
unsigned PropertyAttributes) {
|
|
|
|
// TAG_member is encoded in DIDerivedType format.
|
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_member),
|
2011-08-17 06:09:43 +08:00
|
|
|
getNonCompileUnitScope(File),
|
2011-04-16 08:11:51 +08:00
|
|
|
MDString::get(VMContext, Name),
|
|
|
|
File,
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber),
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), SizeInBits),
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits),
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), OffsetInBits),
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), Flags),
|
|
|
|
Ty,
|
|
|
|
MDString::get(VMContext, PropertyName),
|
|
|
|
MDString::get(VMContext, GetterName),
|
|
|
|
MDString::get(VMContext, SetterName),
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), PropertyAttributes)
|
|
|
|
};
|
2011-04-19 07:51:03 +08:00
|
|
|
return DIType(MDNode::get(VMContext, Elts));
|
2012-02-07 01:49:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// createObjCIVar - Create debugging information entry for Objective-C
|
|
|
|
/// instance variable.
|
|
|
|
DIType DIBuilder::createObjCIVar(StringRef Name,
|
|
|
|
DIFile File, unsigned LineNumber,
|
|
|
|
uint64_t SizeInBits, uint64_t AlignInBits,
|
|
|
|
uint64_t OffsetInBits, unsigned Flags,
|
|
|
|
DIType Ty, MDNode *PropertyNode) {
|
|
|
|
// TAG_member is encoded in DIDerivedType format.
|
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_member),
|
|
|
|
getNonCompileUnitScope(File),
|
|
|
|
MDString::get(VMContext, Name),
|
|
|
|
File,
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber),
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), SizeInBits),
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits),
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), OffsetInBits),
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), Flags),
|
|
|
|
Ty,
|
|
|
|
PropertyNode
|
|
|
|
};
|
|
|
|
return DIType(MDNode::get(VMContext, Elts));
|
2011-04-16 08:11:51 +08:00
|
|
|
}
|
|
|
|
|
2012-02-04 08:59:25 +08:00
|
|
|
/// createObjCProperty - Create debugging information entry for Objective-C
|
|
|
|
/// property.
|
2012-03-29 16:42:56 +08:00
|
|
|
DIObjCProperty DIBuilder::createObjCProperty(StringRef Name,
|
2012-07-06 10:35:57 +08:00
|
|
|
DIFile File, unsigned LineNumber,
|
2012-02-04 08:59:25 +08:00
|
|
|
StringRef GetterName,
|
|
|
|
StringRef SetterName,
|
2012-03-29 16:42:56 +08:00
|
|
|
unsigned PropertyAttributes,
|
2012-07-06 10:35:57 +08:00
|
|
|
DIType Ty) {
|
2012-02-04 08:59:25 +08:00
|
|
|
Value *Elts[] = {
|
2012-03-30 05:35:05 +08:00
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_APPLE_property),
|
2012-02-04 08:59:25 +08:00
|
|
|
MDString::get(VMContext, Name),
|
2012-03-29 16:42:56 +08:00
|
|
|
File,
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber),
|
2012-02-04 08:59:25 +08:00
|
|
|
MDString::get(VMContext, GetterName),
|
|
|
|
MDString::get(VMContext, SetterName),
|
2012-03-29 16:42:56 +08:00
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), PropertyAttributes),
|
|
|
|
Ty
|
2012-02-04 08:59:25 +08:00
|
|
|
};
|
|
|
|
return DIObjCProperty(MDNode::get(VMContext, Elts));
|
|
|
|
}
|
|
|
|
|
2011-02-23 02:56:12 +08:00
|
|
|
/// createTemplateTypeParameter - Create debugging information for template
|
2011-02-03 05:38:25 +08:00
|
|
|
/// type parameter.
|
2011-08-27 05:02:40 +08:00
|
|
|
DITemplateTypeParameter
|
2011-02-23 02:56:12 +08:00
|
|
|
DIBuilder::createTemplateTypeParameter(DIDescriptor Context, StringRef Name,
|
2011-02-03 05:38:25 +08:00
|
|
|
DIType Ty, MDNode *File, unsigned LineNo,
|
|
|
|
unsigned ColumnNo) {
|
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_template_type_parameter),
|
2011-08-17 06:09:43 +08:00
|
|
|
getNonCompileUnitScope(Context),
|
2011-02-03 05:38:25 +08:00
|
|
|
MDString::get(VMContext, Name),
|
|
|
|
Ty,
|
|
|
|
File,
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), LineNo),
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), ColumnNo)
|
|
|
|
};
|
2011-04-19 07:51:03 +08:00
|
|
|
return DITemplateTypeParameter(MDNode::get(VMContext, Elts));
|
2011-02-03 05:38:25 +08:00
|
|
|
}
|
|
|
|
|
2011-02-23 02:56:12 +08:00
|
|
|
/// createTemplateValueParameter - Create debugging information for template
|
2011-02-03 06:35:53 +08:00
|
|
|
/// value parameter.
|
2011-08-27 05:02:40 +08:00
|
|
|
DITemplateValueParameter
|
2011-02-23 02:56:12 +08:00
|
|
|
DIBuilder::createTemplateValueParameter(DIDescriptor Context, StringRef Name,
|
2011-02-03 06:35:53 +08:00
|
|
|
DIType Ty, uint64_t Val,
|
|
|
|
MDNode *File, unsigned LineNo,
|
|
|
|
unsigned ColumnNo) {
|
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_template_value_parameter),
|
2011-08-17 06:09:43 +08:00
|
|
|
getNonCompileUnitScope(Context),
|
2011-02-03 06:35:53 +08:00
|
|
|
MDString::get(VMContext, Name),
|
|
|
|
Ty,
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), Val),
|
|
|
|
File,
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), LineNo),
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), ColumnNo)
|
|
|
|
};
|
2011-04-19 07:51:03 +08:00
|
|
|
return DITemplateValueParameter(MDNode::get(VMContext, Elts));
|
2011-02-03 06:35:53 +08:00
|
|
|
}
|
|
|
|
|
2012-07-06 10:35:57 +08:00
|
|
|
/// createClassType - Create debugging information entry for a class.
|
|
|
|
DIType DIBuilder::createClassType(DIDescriptor Context, StringRef Name,
|
|
|
|
DIFile File, unsigned LineNumber,
|
|
|
|
uint64_t SizeInBits, uint64_t AlignInBits,
|
|
|
|
uint64_t OffsetInBits, unsigned Flags,
|
|
|
|
DIType DerivedFrom, DIArray Elements,
|
|
|
|
MDNode *VTableHolder,
|
|
|
|
MDNode *TemplateParams) {
|
|
|
|
// TAG_class_type is encoded in DICompositeType format.
|
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_class_type),
|
|
|
|
getNonCompileUnitScope(Context),
|
|
|
|
MDString::get(VMContext, Name),
|
|
|
|
File,
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber),
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), SizeInBits),
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits),
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), OffsetInBits),
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), Flags),
|
|
|
|
DerivedFrom,
|
|
|
|
Elements,
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0),
|
|
|
|
VTableHolder,
|
|
|
|
TemplateParams
|
|
|
|
};
|
|
|
|
return DIType(MDNode::get(VMContext, Elts));
|
|
|
|
}
|
|
|
|
|
2011-02-23 02:56:12 +08:00
|
|
|
/// createStructType - Create debugging information entry for a struct.
|
2011-08-27 05:02:40 +08:00
|
|
|
DIType DIBuilder::createStructType(DIDescriptor Context, StringRef Name,
|
|
|
|
DIFile File, unsigned LineNumber,
|
2010-12-08 09:50:15 +08:00
|
|
|
uint64_t SizeInBits, uint64_t AlignInBits,
|
2011-08-27 05:02:40 +08:00
|
|
|
unsigned Flags, DIArray Elements,
|
2010-12-08 09:50:15 +08:00
|
|
|
unsigned RunTimeLang) {
|
2010-12-08 07:25:47 +08:00
|
|
|
// TAG_structure_type is encoded in DICompositeType format.
|
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_structure_type),
|
2011-08-17 06:09:43 +08:00
|
|
|
getNonCompileUnitScope(Context),
|
2010-12-08 07:25:47 +08:00
|
|
|
MDString::get(VMContext, Name),
|
2010-12-08 09:50:15 +08:00
|
|
|
File,
|
2010-12-08 07:25:47 +08:00
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber),
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), SizeInBits),
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits),
|
2010-12-08 09:50:15 +08:00
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0),
|
2010-12-08 07:25:47 +08:00
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), Flags),
|
2011-12-17 01:51:31 +08:00
|
|
|
NULL,
|
2010-12-08 07:25:47 +08:00
|
|
|
Elements,
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), RunTimeLang),
|
2012-11-03 07:33:23 +08:00
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0),
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0),
|
2010-12-08 07:25:47 +08:00
|
|
|
};
|
2011-04-19 07:51:03 +08:00
|
|
|
return DIType(MDNode::get(VMContext, Elts));
|
2010-12-08 07:25:47 +08:00
|
|
|
}
|
|
|
|
|
2011-02-23 02:56:12 +08:00
|
|
|
/// createUnionType - Create debugging information entry for an union.
|
2011-08-27 05:02:40 +08:00
|
|
|
DIType DIBuilder::createUnionType(DIDescriptor Scope, StringRef Name,
|
2010-12-08 09:50:15 +08:00
|
|
|
DIFile File,
|
|
|
|
unsigned LineNumber, uint64_t SizeInBits,
|
|
|
|
uint64_t AlignInBits, unsigned Flags,
|
|
|
|
DIArray Elements, unsigned RunTimeLang) {
|
|
|
|
// TAG_union_type is encoded in DICompositeType format.
|
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_union_type),
|
2011-08-17 06:09:43 +08:00
|
|
|
getNonCompileUnitScope(Scope),
|
2010-12-08 09:50:15 +08:00
|
|
|
MDString::get(VMContext, Name),
|
|
|
|
File,
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber),
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), SizeInBits),
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits),
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), 0),
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), Flags),
|
2011-12-17 01:51:31 +08:00
|
|
|
NULL,
|
2010-12-08 09:50:15 +08:00
|
|
|
Elements,
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), RunTimeLang),
|
2012-07-07 01:49:19 +08:00
|
|
|
Constant::getNullValue(Type::getInt32Ty(VMContext))
|
2010-12-08 09:50:15 +08:00
|
|
|
};
|
2011-04-19 07:51:03 +08:00
|
|
|
return DIType(MDNode::get(VMContext, Elts));
|
2010-12-08 09:50:15 +08:00
|
|
|
}
|
|
|
|
|
2011-02-23 02:56:12 +08:00
|
|
|
/// createSubroutineType - Create subroutine type.
|
|
|
|
DIType DIBuilder::createSubroutineType(DIFile File, DIArray ParameterTypes) {
|
2010-12-08 09:50:15 +08:00
|
|
|
// TAG_subroutine_type is encoded in DICompositeType format.
|
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_subroutine_type),
|
2012-07-07 01:47:36 +08:00
|
|
|
Constant::getNullValue(Type::getInt32Ty(VMContext)),
|
2010-12-08 09:50:15 +08:00
|
|
|
MDString::get(VMContext, ""),
|
2012-07-07 01:47:36 +08:00
|
|
|
Constant::getNullValue(Type::getInt32Ty(VMContext)),
|
2010-12-08 09:50:15 +08:00
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0),
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), 0),
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), 0),
|
2011-12-17 01:51:31 +08:00
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), 0),
|
2010-12-08 09:50:15 +08:00
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0),
|
2011-12-17 01:51:31 +08:00
|
|
|
NULL,
|
2010-12-08 09:50:15 +08:00
|
|
|
ParameterTypes,
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0),
|
2012-07-07 01:49:19 +08:00
|
|
|
Constant::getNullValue(Type::getInt32Ty(VMContext))
|
2010-12-08 09:50:15 +08:00
|
|
|
};
|
2011-04-19 07:51:03 +08:00
|
|
|
return DIType(MDNode::get(VMContext, Elts));
|
2010-12-08 09:50:15 +08:00
|
|
|
}
|
|
|
|
|
2011-08-27 05:02:40 +08:00
|
|
|
/// createEnumerationType - Create debugging information entry for an
|
2010-12-08 09:50:15 +08:00
|
|
|
/// enumeration.
|
2011-08-27 05:02:40 +08:00
|
|
|
DIType DIBuilder::createEnumerationType(DIDescriptor Scope, StringRef Name,
|
|
|
|
DIFile File, unsigned LineNumber,
|
|
|
|
uint64_t SizeInBits,
|
|
|
|
uint64_t AlignInBits,
|
2012-05-23 08:09:20 +08:00
|
|
|
DIArray Elements,
|
2012-10-05 09:49:14 +08:00
|
|
|
DIType ClassType) {
|
2010-12-08 09:50:15 +08:00
|
|
|
// TAG_enumeration_type is encoded in DICompositeType format.
|
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_enumeration_type),
|
2011-08-17 06:09:43 +08:00
|
|
|
getNonCompileUnitScope(Scope),
|
2010-12-08 09:50:15 +08:00
|
|
|
MDString::get(VMContext, Name),
|
|
|
|
File,
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber),
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), SizeInBits),
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits),
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0),
|
2012-10-05 09:49:14 +08:00
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0),
|
2012-05-23 08:09:20 +08:00
|
|
|
ClassType,
|
2010-12-08 09:50:15 +08:00
|
|
|
Elements,
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0),
|
2012-07-07 01:49:19 +08:00
|
|
|
Constant::getNullValue(Type::getInt32Ty(VMContext))
|
2010-12-08 09:50:15 +08:00
|
|
|
};
|
2011-04-19 07:51:03 +08:00
|
|
|
MDNode *Node = MDNode::get(VMContext, Elts);
|
2011-08-17 06:09:43 +08:00
|
|
|
AllEnumTypes.push_back(Node);
|
2010-12-08 09:50:15 +08:00
|
|
|
return DIType(Node);
|
|
|
|
}
|
|
|
|
|
2011-02-23 02:56:12 +08:00
|
|
|
/// createArrayType - Create debugging information entry for an array.
|
2011-08-27 05:02:40 +08:00
|
|
|
DIType DIBuilder::createArrayType(uint64_t Size, uint64_t AlignInBits,
|
2010-12-08 09:50:15 +08:00
|
|
|
DIType Ty, DIArray Subscripts) {
|
|
|
|
// TAG_array_type is encoded in DICompositeType format.
|
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_array_type),
|
2011-08-17 06:09:43 +08:00
|
|
|
NULL, //TheCU,
|
2010-12-08 09:50:15 +08:00
|
|
|
MDString::get(VMContext, ""),
|
2011-08-17 06:09:43 +08:00
|
|
|
NULL, //TheCU,
|
2010-12-08 09:50:15 +08:00
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0),
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), Size),
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits),
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0),
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0),
|
|
|
|
Ty,
|
|
|
|
Subscripts,
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0),
|
2012-07-07 01:49:19 +08:00
|
|
|
Constant::getNullValue(Type::getInt32Ty(VMContext))
|
2010-12-08 09:50:15 +08:00
|
|
|
};
|
2011-04-19 07:51:03 +08:00
|
|
|
return DIType(MDNode::get(VMContext, Elts));
|
2010-12-08 09:50:15 +08:00
|
|
|
}
|
|
|
|
|
2011-02-23 02:56:12 +08:00
|
|
|
/// createVectorType - Create debugging information entry for a vector.
|
2011-08-27 05:02:40 +08:00
|
|
|
DIType DIBuilder::createVectorType(uint64_t Size, uint64_t AlignInBits,
|
2010-12-08 09:50:15 +08:00
|
|
|
DIType Ty, DIArray Subscripts) {
|
2013-01-08 09:53:52 +08:00
|
|
|
|
|
|
|
// A vector is an array type with the FlagVector flag applied.
|
2010-12-08 09:50:15 +08:00
|
|
|
Value *Elts[] = {
|
2013-01-08 09:53:52 +08:00
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_array_type),
|
2011-08-17 06:09:43 +08:00
|
|
|
NULL, //TheCU,
|
2010-12-08 09:50:15 +08:00
|
|
|
MDString::get(VMContext, ""),
|
2011-08-17 06:09:43 +08:00
|
|
|
NULL, //TheCU,
|
2010-12-08 09:50:15 +08:00
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0),
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), Size),
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits),
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0),
|
2013-01-08 09:53:52 +08:00
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), DIType::FlagVector),
|
2010-12-08 09:50:15 +08:00
|
|
|
Ty,
|
|
|
|
Subscripts,
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0),
|
2012-07-07 01:49:19 +08:00
|
|
|
Constant::getNullValue(Type::getInt32Ty(VMContext))
|
2010-12-08 09:50:15 +08:00
|
|
|
};
|
2011-04-19 07:51:03 +08:00
|
|
|
return DIType(MDNode::get(VMContext, Elts));
|
2010-12-08 09:50:15 +08:00
|
|
|
}
|
2010-12-08 07:25:47 +08:00
|
|
|
|
2011-02-23 02:56:12 +08:00
|
|
|
/// createArtificialType - Create a new DIType with "artificial" flag set.
|
|
|
|
DIType DIBuilder::createArtificialType(DIType Ty) {
|
Introduce DIBuilder. It is intended to be a front-end friendly interface to emit debuggging information entries in LLVM IR.
To create debugging information for a pointer, using DIBUilder front-end just needs
DBuilder.CreatePointerType(Ty, Size);
instead of
DebugFactory.CreateDerivedType(llvm::dwarf::DW_TAG_pointer_type,
TheCU, "", getOrCreateMainFile(),
0, Size, 0, 0, 0, OCTy);
llvm-svn: 118248
2010-11-04 23:01:38 +08:00
|
|
|
if (Ty.isArtificial())
|
|
|
|
return Ty;
|
|
|
|
|
|
|
|
SmallVector<Value *, 9> Elts;
|
|
|
|
MDNode *N = Ty;
|
|
|
|
assert (N && "Unexpected input DIType!");
|
|
|
|
for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) {
|
|
|
|
if (Value *V = N->getOperand(i))
|
|
|
|
Elts.push_back(V);
|
|
|
|
else
|
|
|
|
Elts.push_back(Constant::getNullValue(Type::getInt32Ty(VMContext)));
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned CurFlags = Ty.getFlags();
|
|
|
|
CurFlags = CurFlags | DIType::FlagArtificial;
|
|
|
|
|
|
|
|
// Flags are stored at this slot.
|
|
|
|
Elts[8] = ConstantInt::get(Type::getInt32Ty(VMContext), CurFlags);
|
|
|
|
|
2011-04-19 07:51:03 +08:00
|
|
|
return DIType(MDNode::get(VMContext, Elts));
|
Introduce DIBuilder. It is intended to be a front-end friendly interface to emit debuggging information entries in LLVM IR.
To create debugging information for a pointer, using DIBUilder front-end just needs
DBuilder.CreatePointerType(Ty, Size);
instead of
DebugFactory.CreateDerivedType(llvm::dwarf::DW_TAG_pointer_type,
TheCU, "", getOrCreateMainFile(),
0, Size, 0, 0, 0, OCTy);
llvm-svn: 118248
2010-11-04 23:01:38 +08:00
|
|
|
}
|
2010-12-08 07:25:47 +08:00
|
|
|
|
2013-01-08 09:53:42 +08:00
|
|
|
/// createObjectPointerType - Create a new type with both the object pointer
|
|
|
|
/// and artificial flags set.
|
2012-09-13 07:36:19 +08:00
|
|
|
DIType DIBuilder::createObjectPointerType(DIType Ty) {
|
|
|
|
if (Ty.isObjectPointer())
|
|
|
|
return Ty;
|
|
|
|
|
|
|
|
SmallVector<Value *, 9> Elts;
|
|
|
|
MDNode *N = Ty;
|
|
|
|
assert (N && "Unexpected input DIType!");
|
|
|
|
for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i) {
|
|
|
|
if (Value *V = N->getOperand(i))
|
|
|
|
Elts.push_back(V);
|
|
|
|
else
|
|
|
|
Elts.push_back(Constant::getNullValue(Type::getInt32Ty(VMContext)));
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned CurFlags = Ty.getFlags();
|
|
|
|
CurFlags = CurFlags | (DIType::FlagObjectPointer | DIType::FlagArtificial);
|
|
|
|
|
|
|
|
// Flags are stored at this slot.
|
|
|
|
Elts[8] = ConstantInt::get(Type::getInt32Ty(VMContext), CurFlags);
|
|
|
|
|
|
|
|
return DIType(MDNode::get(VMContext, Elts));
|
|
|
|
}
|
|
|
|
|
2011-08-27 05:02:40 +08:00
|
|
|
/// retainType - Retain DIType in a module even if it is not referenced
|
2010-12-08 09:50:15 +08:00
|
|
|
/// through debug info anchors.
|
2011-02-23 02:56:12 +08:00
|
|
|
void DIBuilder::retainType(DIType T) {
|
2011-08-17 06:09:43 +08:00
|
|
|
AllRetainTypes.push_back(T);
|
2010-12-08 09:50:15 +08:00
|
|
|
}
|
|
|
|
|
2011-02-23 02:56:12 +08:00
|
|
|
/// createUnspecifiedParameter - Create unspeicified type descriptor
|
2010-12-08 09:50:15 +08:00
|
|
|
/// for the subroutine type.
|
2011-02-23 02:56:12 +08:00
|
|
|
DIDescriptor DIBuilder::createUnspecifiedParameter() {
|
2011-08-27 05:02:40 +08:00
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_unspecified_parameters)
|
2010-12-08 09:50:15 +08:00
|
|
|
};
|
2011-04-19 07:51:03 +08:00
|
|
|
return DIDescriptor(MDNode::get(VMContext, Elts));
|
2010-12-08 09:50:15 +08:00
|
|
|
}
|
|
|
|
|
2011-02-23 02:56:12 +08:00
|
|
|
/// createTemporaryType - Create a temporary forward-declared type.
|
|
|
|
DIType DIBuilder::createTemporaryType() {
|
2010-12-08 07:25:47 +08:00
|
|
|
// Give the temporary MDNode a tag. It doesn't matter what tag we
|
|
|
|
// use here as long as DIType accepts it.
|
|
|
|
Value *Elts[] = { GetTagConstant(VMContext, DW_TAG_base_type) };
|
2011-04-22 03:59:31 +08:00
|
|
|
MDNode *Node = MDNode::getTemporary(VMContext, Elts);
|
2010-12-08 07:25:47 +08:00
|
|
|
return DIType(Node);
|
|
|
|
}
|
|
|
|
|
2011-02-23 02:56:12 +08:00
|
|
|
/// createTemporaryType - Create a temporary forward-declared type.
|
|
|
|
DIType DIBuilder::createTemporaryType(DIFile F) {
|
2010-12-08 07:25:47 +08:00
|
|
|
// Give the temporary MDNode a tag. It doesn't matter what tag we
|
|
|
|
// use here as long as DIType accepts it.
|
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, DW_TAG_base_type),
|
2011-08-17 06:09:43 +08:00
|
|
|
TheCU,
|
2010-12-08 07:25:47 +08:00
|
|
|
NULL,
|
|
|
|
F
|
|
|
|
};
|
2011-04-22 03:59:31 +08:00
|
|
|
MDNode *Node = MDNode::getTemporary(VMContext, Elts);
|
2010-12-08 07:25:47 +08:00
|
|
|
return DIType(Node);
|
|
|
|
}
|
|
|
|
|
2012-02-08 08:22:26 +08:00
|
|
|
/// createForwardDecl - Create a temporary forward-declared type that
|
|
|
|
/// can be RAUW'd if the full type is seen.
|
2012-04-24 03:00:11 +08:00
|
|
|
DIType DIBuilder::createForwardDecl(unsigned Tag, StringRef Name,
|
|
|
|
DIDescriptor Scope, DIFile F,
|
2012-10-05 09:49:14 +08:00
|
|
|
unsigned Line, unsigned RuntimeLang,
|
|
|
|
uint64_t SizeInBits,
|
|
|
|
uint64_t AlignInBits) {
|
2012-02-08 08:22:26 +08:00
|
|
|
// Create a temporary MDNode.
|
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, Tag),
|
2012-04-24 03:00:11 +08:00
|
|
|
getNonCompileUnitScope(Scope),
|
2012-02-08 08:22:26 +08:00
|
|
|
MDString::get(VMContext, Name),
|
|
|
|
F,
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), Line),
|
2012-10-05 09:49:14 +08:00
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), SizeInBits),
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits),
|
2012-02-08 08:22:26 +08:00
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0),
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext),
|
2012-02-21 02:04:14 +08:00
|
|
|
DIDescriptor::FlagFwdDecl),
|
|
|
|
NULL,
|
|
|
|
DIArray(),
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), RuntimeLang)
|
2012-02-08 08:22:26 +08:00
|
|
|
};
|
|
|
|
MDNode *Node = MDNode::getTemporary(VMContext, Elts);
|
|
|
|
return DIType(Node);
|
|
|
|
}
|
|
|
|
|
2011-02-23 02:56:12 +08:00
|
|
|
/// getOrCreateArray - Get a DIArray, create one if required.
|
2011-04-24 18:11:03 +08:00
|
|
|
DIArray DIBuilder::getOrCreateArray(ArrayRef<Value *> Elements) {
|
|
|
|
if (Elements.empty()) {
|
2012-07-07 01:47:36 +08:00
|
|
|
Value *Null = Constant::getNullValue(Type::getInt32Ty(VMContext));
|
2011-04-22 03:59:31 +08:00
|
|
|
return DIArray(MDNode::get(VMContext, Null));
|
2010-12-08 07:25:47 +08:00
|
|
|
}
|
2011-04-24 18:11:03 +08:00
|
|
|
return DIArray(MDNode::get(VMContext, Elements));
|
2010-12-08 07:25:47 +08:00
|
|
|
}
|
|
|
|
|
2011-02-23 02:56:12 +08:00
|
|
|
/// getOrCreateSubrange - Create a descriptor for a value range. This
|
2010-12-08 09:50:15 +08:00
|
|
|
/// implicitly uniques the values returned.
|
2012-12-05 05:34:03 +08:00
|
|
|
DISubrange DIBuilder::getOrCreateSubrange(int64_t Lo, int64_t Count) {
|
2010-12-08 09:50:15 +08:00
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_subrange_type),
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), Lo),
|
2012-12-04 14:20:49 +08:00
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), Count)
|
2010-12-08 09:50:15 +08:00
|
|
|
};
|
|
|
|
|
2011-04-19 07:51:03 +08:00
|
|
|
return DISubrange(MDNode::get(VMContext, Elts));
|
2010-12-08 09:50:15 +08:00
|
|
|
}
|
|
|
|
|
2011-02-23 02:56:12 +08:00
|
|
|
/// createGlobalVariable - Create a new descriptor for the specified global.
|
2010-12-08 07:25:47 +08:00
|
|
|
DIGlobalVariable DIBuilder::
|
2011-08-27 05:02:40 +08:00
|
|
|
createGlobalVariable(StringRef Name, DIFile F, unsigned LineNumber,
|
2012-07-07 01:47:36 +08:00
|
|
|
DIType Ty, bool isLocalToUnit, Value *Val) {
|
2010-12-08 07:25:47 +08:00
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_variable),
|
2012-07-07 01:47:36 +08:00
|
|
|
Constant::getNullValue(Type::getInt32Ty(VMContext)),
|
2011-08-17 06:09:43 +08:00
|
|
|
NULL, // TheCU,
|
2010-12-08 07:25:47 +08:00
|
|
|
MDString::get(VMContext, Name),
|
|
|
|
MDString::get(VMContext, Name),
|
2010-12-08 08:06:22 +08:00
|
|
|
MDString::get(VMContext, Name),
|
2010-12-08 07:25:47 +08:00
|
|
|
F,
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber),
|
|
|
|
Ty,
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), isLocalToUnit),
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 1), /* isDefinition*/
|
2013-01-16 09:22:23 +08:00
|
|
|
Val,
|
|
|
|
DIDescriptor()
|
2010-12-08 07:25:47 +08:00
|
|
|
};
|
2011-04-19 07:51:03 +08:00
|
|
|
MDNode *Node = MDNode::get(VMContext, Elts);
|
2011-08-17 06:09:43 +08:00
|
|
|
AllGVs.push_back(Node);
|
2010-12-08 07:25:47 +08:00
|
|
|
return DIGlobalVariable(Node);
|
|
|
|
}
|
|
|
|
|
2011-02-23 02:56:12 +08:00
|
|
|
/// createStaticVariable - Create a new descriptor for the specified static
|
2010-12-08 07:25:47 +08:00
|
|
|
/// variable.
|
|
|
|
DIGlobalVariable DIBuilder::
|
2011-08-27 05:02:40 +08:00
|
|
|
createStaticVariable(DIDescriptor Context, StringRef Name,
|
|
|
|
StringRef LinkageName, DIFile F, unsigned LineNumber,
|
2013-01-16 09:22:23 +08:00
|
|
|
DIType Ty, bool isLocalToUnit, Value *Val, MDNode *Decl) {
|
2010-12-08 07:25:47 +08:00
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_variable),
|
2012-07-07 01:47:36 +08:00
|
|
|
Constant::getNullValue(Type::getInt32Ty(VMContext)),
|
2011-08-17 06:09:43 +08:00
|
|
|
getNonCompileUnitScope(Context),
|
2010-12-08 07:25:47 +08:00
|
|
|
MDString::get(VMContext, Name),
|
|
|
|
MDString::get(VMContext, Name),
|
|
|
|
MDString::get(VMContext, LinkageName),
|
|
|
|
F,
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber),
|
|
|
|
Ty,
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), isLocalToUnit),
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 1), /* isDefinition*/
|
2013-01-16 09:22:23 +08:00
|
|
|
Val,
|
|
|
|
DIDescriptor(Decl)
|
2010-12-08 07:25:47 +08:00
|
|
|
};
|
2011-04-19 07:51:03 +08:00
|
|
|
MDNode *Node = MDNode::get(VMContext, Elts);
|
2011-08-17 06:09:43 +08:00
|
|
|
AllGVs.push_back(Node);
|
2010-12-08 07:25:47 +08:00
|
|
|
return DIGlobalVariable(Node);
|
|
|
|
}
|
|
|
|
|
2011-02-23 02:56:12 +08:00
|
|
|
/// createVariable - Create a new descriptor for the specified variable.
|
|
|
|
DIVariable DIBuilder::createLocalVariable(unsigned Tag, DIDescriptor Scope,
|
2010-12-08 07:58:00 +08:00
|
|
|
StringRef Name, DIFile File,
|
2011-08-27 05:02:40 +08:00
|
|
|
unsigned LineNo, DIType Ty,
|
2011-03-02 06:58:13 +08:00
|
|
|
bool AlwaysPreserve, unsigned Flags,
|
|
|
|
unsigned ArgNo) {
|
2010-12-08 07:58:00 +08:00
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, Tag),
|
2011-08-17 06:09:43 +08:00
|
|
|
getNonCompileUnitScope(Scope),
|
2010-12-08 07:58:00 +08:00
|
|
|
MDString::get(VMContext, Name),
|
|
|
|
File,
|
2011-03-02 06:58:13 +08:00
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), (LineNo | (ArgNo << 24))),
|
2010-12-08 07:58:00 +08:00
|
|
|
Ty,
|
2011-07-20 03:41:54 +08:00
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), Flags),
|
2012-07-07 01:49:19 +08:00
|
|
|
Constant::getNullValue(Type::getInt32Ty(VMContext))
|
2010-12-08 07:58:00 +08:00
|
|
|
};
|
2011-04-19 07:51:03 +08:00
|
|
|
MDNode *Node = MDNode::get(VMContext, Elts);
|
2010-12-08 07:58:00 +08:00
|
|
|
if (AlwaysPreserve) {
|
|
|
|
// The optimizer may remove local variable. If there is an interest
|
|
|
|
// to preserve variable info in such situation then stash it in a
|
|
|
|
// named mdnode.
|
|
|
|
DISubprogram Fn(getDISubprogram(Scope));
|
2011-08-20 07:28:12 +08:00
|
|
|
NamedMDNode *FnLocals = getOrInsertFnSpecificMDNode(M, Fn);
|
2010-12-08 07:58:00 +08:00
|
|
|
FnLocals->addOperand(Node);
|
|
|
|
}
|
|
|
|
return DIVariable(Node);
|
|
|
|
}
|
|
|
|
|
2011-02-23 02:56:12 +08:00
|
|
|
/// createComplexVariable - Create a new descriptor for the specified variable
|
2010-12-08 07:25:47 +08:00
|
|
|
/// which has a complex address expression for its address.
|
2011-02-23 02:56:12 +08:00
|
|
|
DIVariable DIBuilder::createComplexVariable(unsigned Tag, DIDescriptor Scope,
|
2010-12-08 07:25:47 +08:00
|
|
|
StringRef Name, DIFile F,
|
|
|
|
unsigned LineNo,
|
2011-04-24 18:11:03 +08:00
|
|
|
DIType Ty, ArrayRef<Value *> Addr,
|
|
|
|
unsigned ArgNo) {
|
2010-12-08 07:25:47 +08:00
|
|
|
SmallVector<Value *, 15> Elts;
|
|
|
|
Elts.push_back(GetTagConstant(VMContext, Tag));
|
2011-08-17 06:09:43 +08:00
|
|
|
Elts.push_back(getNonCompileUnitScope(Scope)),
|
2010-12-08 07:25:47 +08:00
|
|
|
Elts.push_back(MDString::get(VMContext, Name));
|
|
|
|
Elts.push_back(F);
|
2011-08-27 05:02:40 +08:00
|
|
|
Elts.push_back(ConstantInt::get(Type::getInt32Ty(VMContext),
|
2012-02-08 08:17:07 +08:00
|
|
|
(LineNo | (ArgNo << 24))));
|
2010-12-08 07:25:47 +08:00
|
|
|
Elts.push_back(Ty);
|
2012-07-07 01:47:36 +08:00
|
|
|
Elts.push_back(Constant::getNullValue(Type::getInt32Ty(VMContext)));
|
|
|
|
Elts.push_back(Constant::getNullValue(Type::getInt32Ty(VMContext)));
|
2011-04-24 18:11:03 +08:00
|
|
|
Elts.append(Addr.begin(), Addr.end());
|
2010-12-08 07:25:47 +08:00
|
|
|
|
2011-04-19 07:51:03 +08:00
|
|
|
return DIVariable(MDNode::get(VMContext, Elts));
|
2010-12-08 07:25:47 +08:00
|
|
|
}
|
|
|
|
|
2011-02-23 02:56:12 +08:00
|
|
|
/// createFunction - Create a new descriptor for the specified function.
|
|
|
|
DISubprogram DIBuilder::createFunction(DIDescriptor Context,
|
2010-12-09 04:42:44 +08:00
|
|
|
StringRef Name,
|
|
|
|
StringRef LinkageName,
|
|
|
|
DIFile File, unsigned LineNo,
|
|
|
|
DIType Ty,
|
|
|
|
bool isLocalToUnit, bool isDefinition,
|
2012-04-03 08:43:49 +08:00
|
|
|
unsigned ScopeLine,
|
2010-12-09 04:42:44 +08:00
|
|
|
unsigned Flags, bool isOptimized,
|
2011-04-06 06:52:06 +08:00
|
|
|
Function *Fn,
|
2011-04-23 07:10:17 +08:00
|
|
|
MDNode *TParams,
|
|
|
|
MDNode *Decl) {
|
2011-08-20 07:28:12 +08:00
|
|
|
Value *TElts[] = { GetTagConstant(VMContext, DW_TAG_base_type) };
|
2010-12-09 04:42:44 +08:00
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_subprogram),
|
2012-07-07 01:47:36 +08:00
|
|
|
Constant::getNullValue(Type::getInt32Ty(VMContext)),
|
2011-08-17 06:09:43 +08:00
|
|
|
getNonCompileUnitScope(Context),
|
2010-12-09 04:42:44 +08:00
|
|
|
MDString::get(VMContext, Name),
|
|
|
|
MDString::get(VMContext, Name),
|
|
|
|
MDString::get(VMContext, LinkageName),
|
|
|
|
File,
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), LineNo),
|
|
|
|
Ty,
|
|
|
|
ConstantInt::get(Type::getInt1Ty(VMContext), isLocalToUnit),
|
|
|
|
ConstantInt::get(Type::getInt1Ty(VMContext), isDefinition),
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0),
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0),
|
2011-12-16 01:55:56 +08:00
|
|
|
NULL,
|
2010-12-09 04:42:44 +08:00
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), Flags),
|
|
|
|
ConstantInt::get(Type::getInt1Ty(VMContext), isOptimized),
|
2011-04-06 06:52:06 +08:00
|
|
|
Fn,
|
2011-04-23 07:10:17 +08:00
|
|
|
TParams,
|
2011-08-20 07:28:12 +08:00
|
|
|
Decl,
|
2013-02-04 13:56:36 +08:00
|
|
|
MDNode::getTemporary(VMContext, TElts),
|
2012-04-03 08:43:49 +08:00
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), ScopeLine)
|
2010-12-09 04:42:44 +08:00
|
|
|
};
|
2011-04-19 07:51:03 +08:00
|
|
|
MDNode *Node = MDNode::get(VMContext, Elts);
|
2010-12-09 04:42:44 +08:00
|
|
|
|
|
|
|
// Create a named metadata so that we do not lose this mdnode.
|
2011-08-17 06:09:43 +08:00
|
|
|
AllSubprograms.push_back(Node);
|
2010-12-09 04:42:44 +08:00
|
|
|
return DISubprogram(Node);
|
|
|
|
}
|
|
|
|
|
2011-02-23 02:56:12 +08:00
|
|
|
/// createMethod - Create a new descriptor for the specified C++ method.
|
|
|
|
DISubprogram DIBuilder::createMethod(DIDescriptor Context,
|
2010-12-09 04:42:44 +08:00
|
|
|
StringRef Name,
|
|
|
|
StringRef LinkageName,
|
|
|
|
DIFile F,
|
|
|
|
unsigned LineNo, DIType Ty,
|
|
|
|
bool isLocalToUnit,
|
|
|
|
bool isDefinition,
|
|
|
|
unsigned VK, unsigned VIndex,
|
|
|
|
MDNode *VTableHolder,
|
|
|
|
unsigned Flags,
|
|
|
|
bool isOptimized,
|
2011-04-06 06:52:06 +08:00
|
|
|
Function *Fn,
|
|
|
|
MDNode *TParam) {
|
2011-08-20 07:28:12 +08:00
|
|
|
Value *TElts[] = { GetTagConstant(VMContext, DW_TAG_base_type) };
|
2010-12-09 04:42:44 +08:00
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_subprogram),
|
2012-07-07 01:47:36 +08:00
|
|
|
Constant::getNullValue(Type::getInt32Ty(VMContext)),
|
2011-08-17 06:09:43 +08:00
|
|
|
getNonCompileUnitScope(Context),
|
2010-12-09 04:42:44 +08:00
|
|
|
MDString::get(VMContext, Name),
|
|
|
|
MDString::get(VMContext, Name),
|
|
|
|
MDString::get(VMContext, LinkageName),
|
|
|
|
F,
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), LineNo),
|
|
|
|
Ty,
|
|
|
|
ConstantInt::get(Type::getInt1Ty(VMContext), isLocalToUnit),
|
|
|
|
ConstantInt::get(Type::getInt1Ty(VMContext), isDefinition),
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), (unsigned)VK),
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), VIndex),
|
|
|
|
VTableHolder,
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), Flags),
|
|
|
|
ConstantInt::get(Type::getInt1Ty(VMContext), isOptimized),
|
2011-04-06 06:52:06 +08:00
|
|
|
Fn,
|
|
|
|
TParam,
|
2012-07-07 01:47:36 +08:00
|
|
|
Constant::getNullValue(Type::getInt32Ty(VMContext)),
|
2013-02-04 13:56:36 +08:00
|
|
|
MDNode::getTemporary(VMContext, TElts),
|
2012-05-18 08:16:22 +08:00
|
|
|
// FIXME: Do we want to use different scope/lines?
|
2012-04-03 08:43:49 +08:00
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), LineNo)
|
2010-12-09 04:42:44 +08:00
|
|
|
};
|
2011-04-19 07:51:03 +08:00
|
|
|
MDNode *Node = MDNode::get(VMContext, Elts);
|
2010-12-09 04:42:44 +08:00
|
|
|
return DISubprogram(Node);
|
|
|
|
}
|
|
|
|
|
2011-02-23 02:56:12 +08:00
|
|
|
/// createNameSpace - This creates new descriptor for a namespace
|
2010-12-08 07:25:47 +08:00
|
|
|
/// with the specified parent scope.
|
2011-02-23 02:56:12 +08:00
|
|
|
DINameSpace DIBuilder::createNameSpace(DIDescriptor Scope, StringRef Name,
|
2010-12-08 07:25:47 +08:00
|
|
|
DIFile File, unsigned LineNo) {
|
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_namespace),
|
2011-08-17 06:09:43 +08:00
|
|
|
getNonCompileUnitScope(Scope),
|
2010-12-08 07:25:47 +08:00
|
|
|
MDString::get(VMContext, Name),
|
|
|
|
File,
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), LineNo)
|
|
|
|
};
|
2011-04-19 07:51:03 +08:00
|
|
|
return DINameSpace(MDNode::get(VMContext, Elts));
|
2010-12-08 07:25:47 +08:00
|
|
|
}
|
|
|
|
|
2011-10-12 06:59:11 +08:00
|
|
|
/// createLexicalBlockFile - This creates a new MDNode that encapsulates
|
|
|
|
/// an existing scope with a new filename.
|
|
|
|
DILexicalBlockFile DIBuilder::createLexicalBlockFile(DIDescriptor Scope,
|
2012-02-08 08:17:07 +08:00
|
|
|
DIFile File) {
|
2011-10-12 06:59:11 +08:00
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_lexical_block),
|
|
|
|
Scope,
|
|
|
|
File
|
|
|
|
};
|
|
|
|
return DILexicalBlockFile(MDNode::get(VMContext, Elts));
|
|
|
|
}
|
|
|
|
|
2011-02-23 02:56:12 +08:00
|
|
|
DILexicalBlock DIBuilder::createLexicalBlock(DIDescriptor Scope, DIFile File,
|
2010-12-08 09:50:15 +08:00
|
|
|
unsigned Line, unsigned Col) {
|
|
|
|
// Defeat MDNode uniqing for lexical blocks by using unique id.
|
|
|
|
static unsigned int unique_id = 0;
|
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_lexical_block),
|
2011-08-17 06:09:43 +08:00
|
|
|
getNonCompileUnitScope(Scope),
|
2010-12-08 09:50:15 +08:00
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), Line),
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), Col),
|
|
|
|
File,
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), unique_id++)
|
|
|
|
};
|
2011-04-19 07:51:03 +08:00
|
|
|
return DILexicalBlock(MDNode::get(VMContext, Elts));
|
2010-12-08 09:50:15 +08:00
|
|
|
}
|
|
|
|
|
2011-02-23 02:56:12 +08:00
|
|
|
/// insertDeclare - Insert a new llvm.dbg.declare intrinsic call.
|
|
|
|
Instruction *DIBuilder::insertDeclare(Value *Storage, DIVariable VarInfo,
|
2010-12-08 07:25:47 +08:00
|
|
|
Instruction *InsertBefore) {
|
|
|
|
assert(Storage && "no storage passed to dbg.declare");
|
|
|
|
assert(VarInfo.Verify() && "empty DIVariable passed to dbg.declare");
|
|
|
|
if (!DeclareFn)
|
|
|
|
DeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare);
|
|
|
|
|
2011-04-22 03:59:31 +08:00
|
|
|
Value *Args[] = { MDNode::get(Storage->getContext(), Storage), VarInfo };
|
2011-07-15 16:37:34 +08:00
|
|
|
return CallInst::Create(DeclareFn, Args, "", InsertBefore);
|
2010-12-08 07:25:47 +08:00
|
|
|
}
|
|
|
|
|
2011-02-23 02:56:12 +08:00
|
|
|
/// insertDeclare - Insert a new llvm.dbg.declare intrinsic call.
|
|
|
|
Instruction *DIBuilder::insertDeclare(Value *Storage, DIVariable VarInfo,
|
2010-12-08 07:25:47 +08:00
|
|
|
BasicBlock *InsertAtEnd) {
|
|
|
|
assert(Storage && "no storage passed to dbg.declare");
|
|
|
|
assert(VarInfo.Verify() && "invalid DIVariable passed to dbg.declare");
|
|
|
|
if (!DeclareFn)
|
|
|
|
DeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare);
|
|
|
|
|
2011-04-22 03:59:31 +08:00
|
|
|
Value *Args[] = { MDNode::get(Storage->getContext(), Storage), VarInfo };
|
2010-12-08 07:25:47 +08:00
|
|
|
|
|
|
|
// If this block already has a terminator then insert this intrinsic
|
|
|
|
// before the terminator.
|
|
|
|
if (TerminatorInst *T = InsertAtEnd->getTerminator())
|
2011-07-15 16:37:34 +08:00
|
|
|
return CallInst::Create(DeclareFn, Args, "", T);
|
2010-12-08 07:25:47 +08:00
|
|
|
else
|
2011-07-15 16:37:34 +08:00
|
|
|
return CallInst::Create(DeclareFn, Args, "", InsertAtEnd);
|
2010-12-08 07:25:47 +08:00
|
|
|
}
|
|
|
|
|
2011-02-23 02:56:12 +08:00
|
|
|
/// insertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
|
|
|
|
Instruction *DIBuilder::insertDbgValueIntrinsic(Value *V, uint64_t Offset,
|
2010-12-08 07:25:47 +08:00
|
|
|
DIVariable VarInfo,
|
|
|
|
Instruction *InsertBefore) {
|
|
|
|
assert(V && "no value passed to dbg.value");
|
|
|
|
assert(VarInfo.Verify() && "invalid DIVariable passed to dbg.value");
|
|
|
|
if (!ValueFn)
|
|
|
|
ValueFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_value);
|
|
|
|
|
2011-04-22 03:59:31 +08:00
|
|
|
Value *Args[] = { MDNode::get(V->getContext(), V),
|
2010-12-08 07:25:47 +08:00
|
|
|
ConstantInt::get(Type::getInt64Ty(V->getContext()), Offset),
|
|
|
|
VarInfo };
|
2011-07-15 16:37:34 +08:00
|
|
|
return CallInst::Create(ValueFn, Args, "", InsertBefore);
|
2010-12-08 07:25:47 +08:00
|
|
|
}
|
|
|
|
|
2011-02-23 02:56:12 +08:00
|
|
|
/// insertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
|
|
|
|
Instruction *DIBuilder::insertDbgValueIntrinsic(Value *V, uint64_t Offset,
|
2010-12-08 07:25:47 +08:00
|
|
|
DIVariable VarInfo,
|
|
|
|
BasicBlock *InsertAtEnd) {
|
|
|
|
assert(V && "no value passed to dbg.value");
|
|
|
|
assert(VarInfo.Verify() && "invalid DIVariable passed to dbg.value");
|
|
|
|
if (!ValueFn)
|
|
|
|
ValueFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_value);
|
|
|
|
|
2011-04-22 03:59:31 +08:00
|
|
|
Value *Args[] = { MDNode::get(V->getContext(), V),
|
2010-12-08 07:25:47 +08:00
|
|
|
ConstantInt::get(Type::getInt64Ty(V->getContext()), Offset),
|
|
|
|
VarInfo };
|
2011-07-15 16:37:34 +08:00
|
|
|
return CallInst::Create(ValueFn, Args, "", InsertAtEnd);
|
2010-12-08 07:25:47 +08:00
|
|
|
}
|