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 16:01:38 +01: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.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "llvm/Analysis/DIBuilder.h"
|
|
|
|
#include "llvm/Analysis/DebugInfo.h"
|
|
|
|
#include "llvm/Constants.h"
|
|
|
|
#include "llvm/IntrinsicInst.h"
|
|
|
|
#include "llvm/Module.h"
|
2010-11-04 19:45:27 +01:00
|
|
|
#include "llvm/ADT/STLExtras.h"
|
2012-04-03 02:43:49 +02: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 16:01:38 +01: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 00:58:00 +01: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 16:01:38 +01:00
|
|
|
DIBuilder::DIBuilder(Module &m)
|
2011-08-26 23:02:40 +02:00
|
|
|
: M(m), VMContext(M.getContext()), TheCU(0), TempEnumTypes(0),
|
|
|
|
TempRetainTypes(0), TempSubprograms(0), TempGVs(0), DeclareFn(0),
|
|
|
|
ValueFn(0)
|
2011-08-17 00:09:43 +02: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 16:01:38 +01:00
|
|
|
|
2011-08-16 01:00:00 +02:00
|
|
|
/// finalize - Construct any deferred debug info descriptors.
|
|
|
|
void DIBuilder::finalize() {
|
2011-08-17 00:09:43 +02: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 01:28:12 +02:00
|
|
|
for (unsigned i = 0, e = SPs.getNumElements(); i != e; ++i) {
|
|
|
|
DISubprogram SP(SPs.getElement(i));
|
2012-04-23 21:00:11 +02:00
|
|
|
SmallVector<Value *, 4> Variables;
|
2011-08-20 01:28:12 +02: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-23 21:00:11 +02:00
|
|
|
if (MDNode *Temp = SP.getVariablesNodes()) {
|
|
|
|
DIArray AV = getOrCreateArray(Variables);
|
|
|
|
DIType(Temp).replaceAllUsesWith(AV);
|
|
|
|
}
|
2011-08-20 01:28:12 +02:00
|
|
|
}
|
2011-08-17 00:09:43 +02:00
|
|
|
|
|
|
|
DIArray GVs = getOrCreateArray(AllGVs);
|
|
|
|
DIType(TempGVs).replaceAllUsesWith(GVs);
|
|
|
|
}
|
|
|
|
|
2011-08-26 23:02:40 +02:00
|
|
|
/// getNonCompileUnitScope - If N is compile unit return NULL otherwise return
|
|
|
|
/// N.
|
2011-08-17 00:09:43 +02:00
|
|
|
static MDNode *getNonCompileUnitScope(MDNode *N) {
|
|
|
|
if (DIDescriptor(N).isCompileUnit())
|
|
|
|
return NULL;
|
|
|
|
return N;
|
2011-08-16 01:00:00 +02:00
|
|
|
}
|
|
|
|
|
2011-02-22 19:56:12 +01: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 16:01:38 +01:00
|
|
|
/// information generated during this instance of compilation.
|
2011-08-26 23:02:40 +02: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 16:01:38 +01:00
|
|
|
unsigned RunTimeVer) {
|
2012-01-10 19:18:52 +01: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 00:09:43 +02:00
|
|
|
Value *TElts[] = { GetTagConstant(VMContext, DW_TAG_base_type) };
|
|
|
|
TempEnumTypes = MDNode::getTemporary(VMContext, TElts);
|
|
|
|
Value *THElts[] = { TempEnumTypes };
|
|
|
|
MDNode *EnumHolder = MDNode::get(VMContext, THElts);
|
|
|
|
|
|
|
|
TempRetainTypes = MDNode::getTemporary(VMContext, TElts);
|
|
|
|
Value *TRElts[] = { TempRetainTypes };
|
|
|
|
MDNode *RetainHolder = MDNode::get(VMContext, TRElts);
|
|
|
|
|
|
|
|
TempSubprograms = MDNode::getTemporary(VMContext, TElts);
|
|
|
|
Value *TSElts[] = { TempSubprograms };
|
|
|
|
MDNode *SPHolder = MDNode::get(VMContext, TSElts);
|
|
|
|
|
|
|
|
TempGVs = MDNode::getTemporary(VMContext, TElts);
|
|
|
|
Value *TVElts[] = { TempGVs };
|
|
|
|
MDNode *GVHolder = MDNode::get(VMContext, TVElts);
|
|
|
|
|
2010-11-04 19:45:27 +01:00
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_compile_unit),
|
|
|
|
llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)),
|
|
|
|
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 00:09:43 +02:00
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), RunTimeVer),
|
|
|
|
EnumHolder,
|
|
|
|
RetainHolder,
|
|
|
|
SPHolder,
|
|
|
|
GVHolder
|
2010-11-04 19:45:27 +01:00
|
|
|
};
|
2011-04-19 01:51:03 +02:00
|
|
|
TheCU = DICompileUnit(MDNode::get(VMContext, Elts));
|
2011-05-03 18:18:28 +02: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 16:01:38 +01:00
|
|
|
}
|
|
|
|
|
2011-02-22 19:56:12 +01: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 16:01:38 +01:00
|
|
|
/// for a file.
|
2011-02-22 19:56:12 +01:00
|
|
|
DIFile DIBuilder::createFile(StringRef Filename, StringRef Directory) {
|
2010-11-04 19:45:27 +01:00
|
|
|
assert(TheCU && "Unable to create DW_TAG_file_type without CompileUnit");
|
2011-09-12 20:26:08 +02:00
|
|
|
assert(!Filename.empty() && "Unable to create file without name");
|
2010-11-04 19:45:27 +01:00
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_file_type),
|
|
|
|
MDString::get(VMContext, Filename),
|
|
|
|
MDString::get(VMContext, Directory),
|
2011-08-17 00:09:43 +02:00
|
|
|
NULL // TheCU
|
2010-11-04 19:45:27 +01:00
|
|
|
};
|
2011-04-19 01:51:03 +02: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 16:01:38 +01:00
|
|
|
}
|
|
|
|
|
2011-02-22 19:56:12 +01:00
|
|
|
/// createEnumerator - Create a single enumerator value.
|
|
|
|
DIEnumerator DIBuilder::createEnumerator(StringRef Name, uint64_t Val) {
|
2011-09-12 20:26:08 +02:00
|
|
|
assert(!Name.empty() && "Unable to create enumerator without name");
|
2010-11-04 19:45:27 +01:00
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_enumerator),
|
|
|
|
MDString::get(VMContext, Name),
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), Val)
|
|
|
|
};
|
2011-04-19 01:51:03 +02: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 16:01:38 +01:00
|
|
|
}
|
|
|
|
|
2011-09-15 01:13:28 +02: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;
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Encoding
|
|
|
|
};
|
|
|
|
return DIType(MDNode::get(VMContext, Elts));
|
|
|
|
}
|
|
|
|
|
2011-08-26 23:02:40 +02: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 16:01:38 +01:00
|
|
|
/// type, e.g 'char'.
|
2011-08-26 23:02:40 +02:00
|
|
|
DIType DIBuilder::createBasicType(StringRef Name, 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 16:01:38 +01:00
|
|
|
uint64_t AlignInBits,
|
|
|
|
unsigned Encoding) {
|
2011-09-12 20:26:08 +02: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 16:01:38 +01:00
|
|
|
// Basic types are encoded in DIBasicType format. Line number, filename,
|
|
|
|
// offset and flags are always empty here.
|
2010-11-04 19:45:27 +01:00
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_base_type),
|
2011-08-17 00:09:43 +02:00
|
|
|
NULL, //TheCU,
|
2010-11-04 19:45:27 +01: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)
|
|
|
|
};
|
2011-04-19 01:51:03 +02: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 16:01:38 +01:00
|
|
|
}
|
|
|
|
|
2011-11-09 23:45:04 +01: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 16:01:38 +01:00
|
|
|
/// type, e.g. 'const int'.
|
2011-02-22 19:56:12 +01:00
|
|
|
DIType DIBuilder::createQualifiedType(unsigned Tag, DIType FromTy) {
|
2010-11-04 19:45:27 +01:00
|
|
|
// Qualified types are encoded in DIDerivedType format.
|
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, Tag),
|
2011-08-17 00:09:43 +02:00
|
|
|
NULL, //TheCU,
|
2010-11-04 19:45:27 +01: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 01:51:03 +02: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 16:01:38 +01:00
|
|
|
}
|
|
|
|
|
2011-02-22 19:56:12 +01: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 16:01:38 +01:00
|
|
|
uint64_t AlignInBits, StringRef Name) {
|
2010-11-04 19:45:27 +01:00
|
|
|
// Pointer types are encoded in DIDerivedType format.
|
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_pointer_type),
|
2011-08-17 00:09:43 +02:00
|
|
|
NULL, //TheCU,
|
2010-11-04 19:45:27 +01: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 01:51:03 +02: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 16:01:38 +01:00
|
|
|
}
|
|
|
|
|
2011-02-22 19:56:12 +01:00
|
|
|
/// createReferenceType - Create debugging information entry for a reference.
|
|
|
|
DIType DIBuilder::createReferenceType(DIType RTy) {
|
2011-09-12 20:26:08 +02:00
|
|
|
assert(RTy.Verify() && "Unable to create reference type");
|
2010-11-04 19:45:27 +01:00
|
|
|
// References are encoded in DIDerivedType format.
|
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_reference_type),
|
2011-08-26 23:02:40 +02:00
|
|
|
NULL, // TheCU,
|
2010-11-04 19:45:27 +01: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 01:51:03 +02: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 16:01:38 +01:00
|
|
|
}
|
|
|
|
|
2011-02-22 19:56:12 +01:00
|
|
|
/// createTypedef - Create debugging information entry for a typedef.
|
|
|
|
DIType DIBuilder::createTypedef(DIType Ty, StringRef Name, DIFile File,
|
2011-06-03 19:04:51 +02:00
|
|
|
unsigned LineNo, DIDescriptor Context) {
|
2010-11-04 19:45:27 +01:00
|
|
|
// typedefs are encoded in DIDerivedType format.
|
|
|
|
assert(Ty.Verify() && "Invalid typedef type!");
|
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_typedef),
|
2011-08-17 00:09:43 +02:00
|
|
|
getNonCompileUnitScope(Context),
|
2010-11-04 19:45:27 +01: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 01:51:03 +02: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 16:01:38 +01:00
|
|
|
}
|
|
|
|
|
2011-02-22 19:56:12 +01:00
|
|
|
/// createFriend - Create debugging information entry for a 'friend'.
|
|
|
|
DIType DIBuilder::createFriend(DIType Ty, DIType FriendTy) {
|
2010-11-04 19:45:27 +01: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 01:51:03 +02: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 16:01:38 +01:00
|
|
|
}
|
|
|
|
|
2011-02-22 19:56:12 +01:00
|
|
|
/// createInheritance - Create debugging information entry to establish
|
2011-09-12 21:58:22 +02:00
|
|
|
/// inheritance relationship between two types.
|
2011-08-26 23:02:40 +02: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 16:01:38 +01:00
|
|
|
uint64_t BaseOffset, unsigned Flags) {
|
2011-09-12 20:26:08 +02:00
|
|
|
assert(Ty.Verify() && "Unable to create inheritance");
|
2010-11-04 19:45:27 +01:00
|
|
|
// TAG_inheritance is encoded in DIDerivedType format.
|
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_inheritance),
|
|
|
|
Ty,
|
|
|
|
NULL, // Name
|
2010-12-08 22:46:37 +01:00
|
|
|
Ty.getFile(),
|
2010-11-04 19:45:27 +01: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 01:51:03 +02: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 16:01:38 +01:00
|
|
|
}
|
|
|
|
|
2011-02-22 19:56:12 +01:00
|
|
|
/// createMemberType - Create debugging information entry for a member.
|
2011-08-26 23:02:40 +02: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 16:01:38 +01:00
|
|
|
uint64_t SizeInBits, uint64_t AlignInBits,
|
2011-08-26 23:02:40 +02: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 16:01:38 +01:00
|
|
|
DIType Ty) {
|
2010-11-04 19:45:27 +01:00
|
|
|
// TAG_member is encoded in DIDerivedType format.
|
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_member),
|
2011-08-17 00:09:43 +02:00
|
|
|
getNonCompileUnitScope(Scope),
|
2010-11-04 19:45:27 +01:00
|
|
|
MDString::get(VMContext, Name),
|
2010-12-08 00:25:47 +01:00
|
|
|
File,
|
2010-11-04 19:45:27 +01: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 01:51:03 +02: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 16:01:38 +01:00
|
|
|
}
|
|
|
|
|
2011-04-16 02:11:51 +02:00
|
|
|
/// createObjCIVar - Create debugging information entry for Objective-C
|
|
|
|
/// instance variable.
|
2011-08-26 23:02:40 +02:00
|
|
|
DIType DIBuilder::createObjCIVar(StringRef Name,
|
|
|
|
DIFile File, unsigned LineNumber,
|
2011-04-16 02:11:51 +02:00
|
|
|
uint64_t SizeInBits, uint64_t AlignInBits,
|
2011-08-26 23:02:40 +02:00
|
|
|
uint64_t OffsetInBits, unsigned Flags,
|
2011-04-16 02:11:51 +02: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 00:09:43 +02:00
|
|
|
getNonCompileUnitScope(File),
|
2011-04-16 02:11:51 +02: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 01:51:03 +02:00
|
|
|
return DIType(MDNode::get(VMContext, Elts));
|
2012-02-06 18:49:43 +01: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 02:11:51 +02:00
|
|
|
}
|
|
|
|
|
2012-02-04 01:59:25 +01:00
|
|
|
/// createObjCProperty - Create debugging information entry for Objective-C
|
|
|
|
/// property.
|
2012-03-29 10:42:56 +02:00
|
|
|
DIObjCProperty DIBuilder::createObjCProperty(StringRef Name,
|
|
|
|
DIFile File, unsigned LineNumber,
|
2012-02-04 01:59:25 +01:00
|
|
|
StringRef GetterName,
|
|
|
|
StringRef SetterName,
|
2012-03-29 10:42:56 +02:00
|
|
|
unsigned PropertyAttributes,
|
|
|
|
DIType Ty) {
|
2012-02-04 01:59:25 +01:00
|
|
|
Value *Elts[] = {
|
2012-03-29 23:35:05 +02:00
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_APPLE_property),
|
2012-02-04 01:59:25 +01:00
|
|
|
MDString::get(VMContext, Name),
|
2012-03-29 10:42:56 +02:00
|
|
|
File,
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber),
|
2012-02-04 01:59:25 +01:00
|
|
|
MDString::get(VMContext, GetterName),
|
|
|
|
MDString::get(VMContext, SetterName),
|
2012-03-29 10:42:56 +02:00
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), PropertyAttributes),
|
|
|
|
Ty
|
2012-02-04 01:59:25 +01:00
|
|
|
};
|
|
|
|
return DIObjCProperty(MDNode::get(VMContext, Elts));
|
|
|
|
}
|
|
|
|
|
2011-02-22 19:56:12 +01:00
|
|
|
/// createClassType - Create debugging information entry for a class.
|
2011-08-26 23:02:40 +02:00
|
|
|
DIType DIBuilder::createClassType(DIDescriptor Context, StringRef Name,
|
|
|
|
DIFile File, unsigned LineNumber,
|
2010-12-08 21:18:20 +01:00
|
|
|
uint64_t SizeInBits, uint64_t AlignInBits,
|
|
|
|
uint64_t OffsetInBits, unsigned Flags,
|
|
|
|
DIType DerivedFrom, DIArray Elements,
|
2012-02-17 08:08:46 +01:00
|
|
|
MDNode *VTableHolder, MDNode *TemplateParams) {
|
2010-12-08 21:18:20 +01:00
|
|
|
// TAG_class_type is encoded in DICompositeType format.
|
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_class_type),
|
2011-08-17 00:09:43 +02:00
|
|
|
getNonCompileUnitScope(Context),
|
2010-12-08 21:18:20 +01: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), OffsetInBits),
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), Flags),
|
|
|
|
DerivedFrom,
|
|
|
|
Elements,
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0),
|
2012-02-17 08:08:46 +01:00
|
|
|
VTableHolder,
|
2011-02-02 22:38:25 +01:00
|
|
|
TemplateParams
|
2010-12-08 21:18:20 +01:00
|
|
|
};
|
2011-04-19 01:51:03 +02:00
|
|
|
return DIType(MDNode::get(VMContext, Elts));
|
2010-12-08 21:18:20 +01:00
|
|
|
}
|
|
|
|
|
2011-02-22 19:56:12 +01:00
|
|
|
/// createTemplateTypeParameter - Create debugging information for template
|
2011-02-02 22:38:25 +01:00
|
|
|
/// type parameter.
|
2011-08-26 23:02:40 +02:00
|
|
|
DITemplateTypeParameter
|
2011-02-22 19:56:12 +01:00
|
|
|
DIBuilder::createTemplateTypeParameter(DIDescriptor Context, StringRef Name,
|
2011-02-02 22:38:25 +01:00
|
|
|
DIType Ty, MDNode *File, unsigned LineNo,
|
|
|
|
unsigned ColumnNo) {
|
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_template_type_parameter),
|
2011-08-17 00:09:43 +02:00
|
|
|
getNonCompileUnitScope(Context),
|
2011-02-02 22:38:25 +01:00
|
|
|
MDString::get(VMContext, Name),
|
|
|
|
Ty,
|
|
|
|
File,
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), LineNo),
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), ColumnNo)
|
|
|
|
};
|
2011-04-19 01:51:03 +02:00
|
|
|
return DITemplateTypeParameter(MDNode::get(VMContext, Elts));
|
2011-02-02 22:38:25 +01:00
|
|
|
}
|
|
|
|
|
2011-02-22 19:56:12 +01:00
|
|
|
/// createTemplateValueParameter - Create debugging information for template
|
2011-02-02 23:35:53 +01:00
|
|
|
/// value parameter.
|
2011-08-26 23:02:40 +02:00
|
|
|
DITemplateValueParameter
|
2011-02-22 19:56:12 +01:00
|
|
|
DIBuilder::createTemplateValueParameter(DIDescriptor Context, StringRef Name,
|
2011-02-02 23:35:53 +01: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 00:09:43 +02:00
|
|
|
getNonCompileUnitScope(Context),
|
2011-02-02 23:35:53 +01: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 01:51:03 +02:00
|
|
|
return DITemplateValueParameter(MDNode::get(VMContext, Elts));
|
2011-02-02 23:35:53 +01:00
|
|
|
}
|
|
|
|
|
2011-02-22 19:56:12 +01:00
|
|
|
/// createStructType - Create debugging information entry for a struct.
|
2011-08-26 23:02:40 +02:00
|
|
|
DIType DIBuilder::createStructType(DIDescriptor Context, StringRef Name,
|
|
|
|
DIFile File, unsigned LineNumber,
|
2010-12-08 02:50:15 +01:00
|
|
|
uint64_t SizeInBits, uint64_t AlignInBits,
|
2011-08-26 23:02:40 +02:00
|
|
|
unsigned Flags, DIArray Elements,
|
2010-12-08 02:50:15 +01:00
|
|
|
unsigned RunTimeLang) {
|
2010-12-08 00:25:47 +01:00
|
|
|
// TAG_structure_type is encoded in DICompositeType format.
|
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_structure_type),
|
2011-08-17 00:09:43 +02:00
|
|
|
getNonCompileUnitScope(Context),
|
2010-12-08 00:25:47 +01:00
|
|
|
MDString::get(VMContext, Name),
|
2010-12-08 02:50:15 +01:00
|
|
|
File,
|
2010-12-08 00:25:47 +01:00
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber),
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), SizeInBits),
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits),
|
2010-12-08 02:50:15 +01:00
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0),
|
2010-12-08 00:25:47 +01:00
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), Flags),
|
2011-12-16 18:51:31 +01:00
|
|
|
NULL,
|
2010-12-08 00:25:47 +01:00
|
|
|
Elements,
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), RunTimeLang),
|
|
|
|
llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)),
|
|
|
|
};
|
2011-04-19 01:51:03 +02:00
|
|
|
return DIType(MDNode::get(VMContext, Elts));
|
2010-12-08 00:25:47 +01:00
|
|
|
}
|
|
|
|
|
2011-02-22 19:56:12 +01:00
|
|
|
/// createUnionType - Create debugging information entry for an union.
|
2011-08-26 23:02:40 +02:00
|
|
|
DIType DIBuilder::createUnionType(DIDescriptor Scope, StringRef Name,
|
2010-12-08 02:50:15 +01: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 00:09:43 +02:00
|
|
|
getNonCompileUnitScope(Scope),
|
2010-12-08 02:50:15 +01: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-16 18:51:31 +01:00
|
|
|
NULL,
|
2010-12-08 02:50:15 +01:00
|
|
|
Elements,
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), RunTimeLang),
|
|
|
|
llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)),
|
|
|
|
};
|
2011-04-19 01:51:03 +02:00
|
|
|
return DIType(MDNode::get(VMContext, Elts));
|
2010-12-08 02:50:15 +01:00
|
|
|
}
|
|
|
|
|
2011-02-22 19:56:12 +01:00
|
|
|
/// createSubroutineType - Create subroutine type.
|
|
|
|
DIType DIBuilder::createSubroutineType(DIFile File, DIArray ParameterTypes) {
|
2010-12-08 02:50:15 +01:00
|
|
|
// TAG_subroutine_type is encoded in DICompositeType format.
|
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_subroutine_type),
|
2011-08-19 01:50:57 +02:00
|
|
|
llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)),
|
2010-12-08 02:50:15 +01:00
|
|
|
MDString::get(VMContext, ""),
|
2011-08-19 01:50:57 +02:00
|
|
|
llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)),
|
2010-12-08 02:50:15 +01:00
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0),
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), 0),
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), 0),
|
2011-12-16 18:51:31 +01:00
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), 0),
|
2010-12-08 02:50:15 +01:00
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0),
|
2011-12-16 18:51:31 +01:00
|
|
|
NULL,
|
2010-12-08 02:50:15 +01:00
|
|
|
ParameterTypes,
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0),
|
|
|
|
llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)),
|
|
|
|
};
|
2011-04-19 01:51:03 +02:00
|
|
|
return DIType(MDNode::get(VMContext, Elts));
|
2010-12-08 02:50:15 +01:00
|
|
|
}
|
|
|
|
|
2011-08-26 23:02:40 +02:00
|
|
|
/// createEnumerationType - Create debugging information entry for an
|
2010-12-08 02:50:15 +01:00
|
|
|
/// enumeration.
|
2011-08-26 23:02:40 +02:00
|
|
|
DIType DIBuilder::createEnumerationType(DIDescriptor Scope, StringRef Name,
|
|
|
|
DIFile File, unsigned LineNumber,
|
|
|
|
uint64_t SizeInBits,
|
|
|
|
uint64_t AlignInBits,
|
2012-02-08 01:17:07 +01:00
|
|
|
DIArray Elements) {
|
2010-12-08 02:50:15 +01:00
|
|
|
// TAG_enumeration_type is encoded in DICompositeType format.
|
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_enumeration_type),
|
2011-08-17 00:09:43 +02:00
|
|
|
getNonCompileUnitScope(Scope),
|
2010-12-08 02:50:15 +01: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),
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0),
|
2011-12-16 18:51:31 +01:00
|
|
|
NULL,
|
2010-12-08 02:50:15 +01:00
|
|
|
Elements,
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0),
|
|
|
|
llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)),
|
|
|
|
};
|
2011-04-19 01:51:03 +02:00
|
|
|
MDNode *Node = MDNode::get(VMContext, Elts);
|
2011-08-17 00:09:43 +02:00
|
|
|
AllEnumTypes.push_back(Node);
|
2010-12-08 02:50:15 +01:00
|
|
|
return DIType(Node);
|
|
|
|
}
|
|
|
|
|
2011-02-22 19:56:12 +01:00
|
|
|
/// createArrayType - Create debugging information entry for an array.
|
2011-08-26 23:02:40 +02:00
|
|
|
DIType DIBuilder::createArrayType(uint64_t Size, uint64_t AlignInBits,
|
2010-12-08 02:50:15 +01: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 00:09:43 +02:00
|
|
|
NULL, //TheCU,
|
2010-12-08 02:50:15 +01:00
|
|
|
MDString::get(VMContext, ""),
|
2011-08-17 00:09:43 +02:00
|
|
|
NULL, //TheCU,
|
2010-12-08 02:50:15 +01: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),
|
|
|
|
llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)),
|
|
|
|
};
|
2011-04-19 01:51:03 +02:00
|
|
|
return DIType(MDNode::get(VMContext, Elts));
|
2010-12-08 02:50:15 +01:00
|
|
|
}
|
|
|
|
|
2011-02-22 19:56:12 +01:00
|
|
|
/// createVectorType - Create debugging information entry for a vector.
|
2011-08-26 23:02:40 +02:00
|
|
|
DIType DIBuilder::createVectorType(uint64_t Size, uint64_t AlignInBits,
|
2010-12-08 02:50:15 +01:00
|
|
|
DIType Ty, DIArray Subscripts) {
|
|
|
|
// TAG_vector_type is encoded in DICompositeType format.
|
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_vector_type),
|
2011-08-17 00:09:43 +02:00
|
|
|
NULL, //TheCU,
|
2010-12-08 02:50:15 +01:00
|
|
|
MDString::get(VMContext, ""),
|
2011-08-17 00:09:43 +02:00
|
|
|
NULL, //TheCU,
|
2010-12-08 02:50:15 +01: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),
|
|
|
|
llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)),
|
|
|
|
};
|
2011-04-19 01:51:03 +02:00
|
|
|
return DIType(MDNode::get(VMContext, Elts));
|
2010-12-08 02:50:15 +01:00
|
|
|
}
|
2010-12-08 00:25:47 +01:00
|
|
|
|
2011-02-22 19:56:12 +01: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 16:01:38 +01: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 01:51:03 +02: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 16:01:38 +01:00
|
|
|
}
|
2010-12-08 00:25:47 +01:00
|
|
|
|
2011-08-26 23:02:40 +02:00
|
|
|
/// retainType - Retain DIType in a module even if it is not referenced
|
2010-12-08 02:50:15 +01:00
|
|
|
/// through debug info anchors.
|
2011-02-22 19:56:12 +01:00
|
|
|
void DIBuilder::retainType(DIType T) {
|
2011-08-17 00:09:43 +02:00
|
|
|
AllRetainTypes.push_back(T);
|
2010-12-08 02:50:15 +01:00
|
|
|
}
|
|
|
|
|
2011-02-22 19:56:12 +01:00
|
|
|
/// createUnspecifiedParameter - Create unspeicified type descriptor
|
2010-12-08 02:50:15 +01:00
|
|
|
/// for the subroutine type.
|
2011-02-22 19:56:12 +01:00
|
|
|
DIDescriptor DIBuilder::createUnspecifiedParameter() {
|
2011-08-26 23:02:40 +02:00
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_unspecified_parameters)
|
2010-12-08 02:50:15 +01:00
|
|
|
};
|
2011-04-19 01:51:03 +02:00
|
|
|
return DIDescriptor(MDNode::get(VMContext, Elts));
|
2010-12-08 02:50:15 +01:00
|
|
|
}
|
|
|
|
|
2011-02-22 19:56:12 +01:00
|
|
|
/// createTemporaryType - Create a temporary forward-declared type.
|
|
|
|
DIType DIBuilder::createTemporaryType() {
|
2010-12-08 00:25:47 +01: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-21 21:59:31 +02:00
|
|
|
MDNode *Node = MDNode::getTemporary(VMContext, Elts);
|
2010-12-08 00:25:47 +01:00
|
|
|
return DIType(Node);
|
|
|
|
}
|
|
|
|
|
2011-02-22 19:56:12 +01:00
|
|
|
/// createTemporaryType - Create a temporary forward-declared type.
|
|
|
|
DIType DIBuilder::createTemporaryType(DIFile F) {
|
2010-12-08 00:25:47 +01: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 00:09:43 +02:00
|
|
|
TheCU,
|
2010-12-08 00:25:47 +01:00
|
|
|
NULL,
|
|
|
|
F
|
|
|
|
};
|
2011-04-21 21:59:31 +02:00
|
|
|
MDNode *Node = MDNode::getTemporary(VMContext, Elts);
|
2010-12-08 00:25:47 +01:00
|
|
|
return DIType(Node);
|
|
|
|
}
|
|
|
|
|
2012-02-08 01:22:26 +01:00
|
|
|
/// createForwardDecl - Create a temporary forward-declared type that
|
|
|
|
/// can be RAUW'd if the full type is seen.
|
2012-04-23 21:00:11 +02:00
|
|
|
DIType DIBuilder::createForwardDecl(unsigned Tag, StringRef Name,
|
|
|
|
DIDescriptor Scope, DIFile F,
|
2012-02-20 19:04:14 +01:00
|
|
|
unsigned Line, unsigned RuntimeLang) {
|
2012-02-08 01:22:26 +01:00
|
|
|
// Create a temporary MDNode.
|
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, Tag),
|
2012-04-23 21:00:11 +02:00
|
|
|
getNonCompileUnitScope(Scope),
|
2012-02-08 01:22:26 +01:00
|
|
|
MDString::get(VMContext, Name),
|
|
|
|
F,
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), Line),
|
|
|
|
// To ease transition include sizes etc of 0.
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0),
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0),
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0),
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext),
|
2012-02-20 19:04:14 +01:00
|
|
|
DIDescriptor::FlagFwdDecl),
|
|
|
|
NULL,
|
|
|
|
DIArray(),
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), RuntimeLang)
|
2012-02-08 01:22:26 +01:00
|
|
|
};
|
|
|
|
MDNode *Node = MDNode::getTemporary(VMContext, Elts);
|
|
|
|
return DIType(Node);
|
|
|
|
}
|
|
|
|
|
2011-02-22 19:56:12 +01:00
|
|
|
/// getOrCreateArray - Get a DIArray, create one if required.
|
2011-04-24 12:11:03 +02:00
|
|
|
DIArray DIBuilder::getOrCreateArray(ArrayRef<Value *> Elements) {
|
|
|
|
if (Elements.empty()) {
|
2010-12-08 00:25:47 +01:00
|
|
|
Value *Null = llvm::Constant::getNullValue(Type::getInt32Ty(VMContext));
|
2011-04-21 21:59:31 +02:00
|
|
|
return DIArray(MDNode::get(VMContext, Null));
|
2010-12-08 00:25:47 +01:00
|
|
|
}
|
2011-04-24 12:11:03 +02:00
|
|
|
return DIArray(MDNode::get(VMContext, Elements));
|
2010-12-08 00:25:47 +01:00
|
|
|
}
|
|
|
|
|
2011-02-22 19:56:12 +01:00
|
|
|
/// getOrCreateSubrange - Create a descriptor for a value range. This
|
2010-12-08 02:50:15 +01:00
|
|
|
/// implicitly uniques the values returned.
|
2011-02-22 19:56:12 +01:00
|
|
|
DISubrange DIBuilder::getOrCreateSubrange(int64_t Lo, int64_t Hi) {
|
2010-12-08 02:50:15 +01:00
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_subrange_type),
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), Lo),
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), Hi)
|
|
|
|
};
|
|
|
|
|
2011-04-19 01:51:03 +02:00
|
|
|
return DISubrange(MDNode::get(VMContext, Elts));
|
2010-12-08 02:50:15 +01:00
|
|
|
}
|
|
|
|
|
2011-02-22 19:56:12 +01:00
|
|
|
/// createGlobalVariable - Create a new descriptor for the specified global.
|
2010-12-08 00:25:47 +01:00
|
|
|
DIGlobalVariable DIBuilder::
|
2011-08-26 23:02:40 +02:00
|
|
|
createGlobalVariable(StringRef Name, DIFile F, unsigned LineNumber,
|
2010-12-08 00:25:47 +01:00
|
|
|
DIType Ty, bool isLocalToUnit, llvm::Value *Val) {
|
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_variable),
|
|
|
|
llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)),
|
2011-08-17 00:09:43 +02:00
|
|
|
NULL, // TheCU,
|
2010-12-08 00:25:47 +01:00
|
|
|
MDString::get(VMContext, Name),
|
|
|
|
MDString::get(VMContext, Name),
|
2010-12-08 01:06:22 +01:00
|
|
|
MDString::get(VMContext, Name),
|
2010-12-08 00:25:47 +01:00
|
|
|
F,
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber),
|
|
|
|
Ty,
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), isLocalToUnit),
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 1), /* isDefinition*/
|
|
|
|
Val
|
|
|
|
};
|
2011-04-19 01:51:03 +02:00
|
|
|
MDNode *Node = MDNode::get(VMContext, Elts);
|
2011-08-17 00:09:43 +02:00
|
|
|
AllGVs.push_back(Node);
|
2010-12-08 00:25:47 +01:00
|
|
|
return DIGlobalVariable(Node);
|
|
|
|
}
|
|
|
|
|
2011-02-22 19:56:12 +01:00
|
|
|
/// createStaticVariable - Create a new descriptor for the specified static
|
2010-12-08 00:25:47 +01:00
|
|
|
/// variable.
|
|
|
|
DIGlobalVariable DIBuilder::
|
2011-08-26 23:02:40 +02:00
|
|
|
createStaticVariable(DIDescriptor Context, StringRef Name,
|
|
|
|
StringRef LinkageName, DIFile F, unsigned LineNumber,
|
2010-12-08 00:25:47 +01:00
|
|
|
DIType Ty, bool isLocalToUnit, llvm::Value *Val) {
|
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_variable),
|
|
|
|
llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)),
|
2011-08-17 00:09:43 +02:00
|
|
|
getNonCompileUnitScope(Context),
|
2010-12-08 00:25:47 +01: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*/
|
|
|
|
Val
|
|
|
|
};
|
2011-04-19 01:51:03 +02:00
|
|
|
MDNode *Node = MDNode::get(VMContext, Elts);
|
2011-08-17 00:09:43 +02:00
|
|
|
AllGVs.push_back(Node);
|
2010-12-08 00:25:47 +01:00
|
|
|
return DIGlobalVariable(Node);
|
|
|
|
}
|
|
|
|
|
2011-02-22 19:56:12 +01:00
|
|
|
/// createVariable - Create a new descriptor for the specified variable.
|
|
|
|
DIVariable DIBuilder::createLocalVariable(unsigned Tag, DIDescriptor Scope,
|
2010-12-08 00:58:00 +01:00
|
|
|
StringRef Name, DIFile File,
|
2011-08-26 23:02:40 +02:00
|
|
|
unsigned LineNo, DIType Ty,
|
2011-03-01 23:58:13 +01:00
|
|
|
bool AlwaysPreserve, unsigned Flags,
|
|
|
|
unsigned ArgNo) {
|
2010-12-08 00:58:00 +01:00
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, Tag),
|
2011-08-17 00:09:43 +02:00
|
|
|
getNonCompileUnitScope(Scope),
|
2010-12-08 00:58:00 +01:00
|
|
|
MDString::get(VMContext, Name),
|
|
|
|
File,
|
2011-03-01 23:58:13 +01:00
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), (LineNo | (ArgNo << 24))),
|
2010-12-08 00:58:00 +01:00
|
|
|
Ty,
|
2011-07-19 21:41:54 +02:00
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), Flags),
|
|
|
|
Constant::getNullValue(Type::getInt32Ty(VMContext)),
|
2010-12-08 00:58:00 +01:00
|
|
|
};
|
2011-04-19 01:51:03 +02:00
|
|
|
MDNode *Node = MDNode::get(VMContext, Elts);
|
2010-12-08 00:58:00 +01: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 01:28:12 +02:00
|
|
|
NamedMDNode *FnLocals = getOrInsertFnSpecificMDNode(M, Fn);
|
2010-12-08 00:58:00 +01:00
|
|
|
FnLocals->addOperand(Node);
|
|
|
|
}
|
|
|
|
return DIVariable(Node);
|
|
|
|
}
|
|
|
|
|
2011-02-22 19:56:12 +01:00
|
|
|
/// createComplexVariable - Create a new descriptor for the specified variable
|
2010-12-08 00:25:47 +01:00
|
|
|
/// which has a complex address expression for its address.
|
2011-02-22 19:56:12 +01:00
|
|
|
DIVariable DIBuilder::createComplexVariable(unsigned Tag, DIDescriptor Scope,
|
2010-12-08 00:25:47 +01:00
|
|
|
StringRef Name, DIFile F,
|
|
|
|
unsigned LineNo,
|
2011-04-24 12:11:03 +02:00
|
|
|
DIType Ty, ArrayRef<Value *> Addr,
|
|
|
|
unsigned ArgNo) {
|
2010-12-08 00:25:47 +01:00
|
|
|
SmallVector<Value *, 15> Elts;
|
|
|
|
Elts.push_back(GetTagConstant(VMContext, Tag));
|
2011-08-17 00:09:43 +02:00
|
|
|
Elts.push_back(getNonCompileUnitScope(Scope)),
|
2010-12-08 00:25:47 +01:00
|
|
|
Elts.push_back(MDString::get(VMContext, Name));
|
|
|
|
Elts.push_back(F);
|
2011-08-26 23:02:40 +02:00
|
|
|
Elts.push_back(ConstantInt::get(Type::getInt32Ty(VMContext),
|
2012-02-08 01:17:07 +01:00
|
|
|
(LineNo | (ArgNo << 24))));
|
2010-12-08 00:25:47 +01:00
|
|
|
Elts.push_back(Ty);
|
2011-04-26 20:24:39 +02:00
|
|
|
Elts.push_back(llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)));
|
2011-07-19 21:41:54 +02:00
|
|
|
Elts.push_back(llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)));
|
2011-04-24 12:11:03 +02:00
|
|
|
Elts.append(Addr.begin(), Addr.end());
|
2010-12-08 00:25:47 +01:00
|
|
|
|
2011-04-19 01:51:03 +02:00
|
|
|
return DIVariable(MDNode::get(VMContext, Elts));
|
2010-12-08 00:25:47 +01:00
|
|
|
}
|
|
|
|
|
2011-02-22 19:56:12 +01:00
|
|
|
/// createFunction - Create a new descriptor for the specified function.
|
|
|
|
DISubprogram DIBuilder::createFunction(DIDescriptor Context,
|
2010-12-08 21:42:44 +01:00
|
|
|
StringRef Name,
|
|
|
|
StringRef LinkageName,
|
|
|
|
DIFile File, unsigned LineNo,
|
|
|
|
DIType Ty,
|
|
|
|
bool isLocalToUnit, bool isDefinition,
|
2012-04-03 02:43:49 +02:00
|
|
|
unsigned ScopeLine,
|
2010-12-08 21:42:44 +01:00
|
|
|
unsigned Flags, bool isOptimized,
|
2011-04-06 00:52:06 +02:00
|
|
|
Function *Fn,
|
2011-04-23 01:10:17 +02:00
|
|
|
MDNode *TParams,
|
|
|
|
MDNode *Decl) {
|
2011-08-20 01:28:12 +02:00
|
|
|
Value *TElts[] = { GetTagConstant(VMContext, DW_TAG_base_type) };
|
|
|
|
MDNode *Temp = MDNode::getTemporary(VMContext, TElts);
|
|
|
|
Value *TVElts[] = { Temp };
|
|
|
|
MDNode *THolder = MDNode::get(VMContext, TVElts);
|
|
|
|
|
2010-12-08 21:42:44 +01:00
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_subprogram),
|
|
|
|
llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)),
|
2011-08-17 00:09:43 +02:00
|
|
|
getNonCompileUnitScope(Context),
|
2010-12-08 21:42:44 +01: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-15 18:55:56 +01:00
|
|
|
NULL,
|
2010-12-08 21:42:44 +01:00
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), Flags),
|
|
|
|
ConstantInt::get(Type::getInt1Ty(VMContext), isOptimized),
|
2011-04-06 00:52:06 +02:00
|
|
|
Fn,
|
2011-04-23 01:10:17 +02:00
|
|
|
TParams,
|
2011-08-20 01:28:12 +02:00
|
|
|
Decl,
|
2012-04-03 02:43:49 +02:00
|
|
|
THolder,
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), ScopeLine)
|
2010-12-08 21:42:44 +01:00
|
|
|
};
|
2011-04-19 01:51:03 +02:00
|
|
|
MDNode *Node = MDNode::get(VMContext, Elts);
|
2010-12-08 21:42:44 +01:00
|
|
|
|
|
|
|
// Create a named metadata so that we do not lose this mdnode.
|
2011-08-17 00:09:43 +02:00
|
|
|
AllSubprograms.push_back(Node);
|
2010-12-08 21:42:44 +01:00
|
|
|
return DISubprogram(Node);
|
|
|
|
}
|
|
|
|
|
2011-02-22 19:56:12 +01:00
|
|
|
/// createMethod - Create a new descriptor for the specified C++ method.
|
|
|
|
DISubprogram DIBuilder::createMethod(DIDescriptor Context,
|
2010-12-08 21:42:44 +01: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 00:52:06 +02:00
|
|
|
Function *Fn,
|
|
|
|
MDNode *TParam) {
|
2011-08-20 01:28:12 +02:00
|
|
|
Value *TElts[] = { GetTagConstant(VMContext, DW_TAG_base_type) };
|
|
|
|
MDNode *Temp = MDNode::getTemporary(VMContext, TElts);
|
|
|
|
Value *TVElts[] = { Temp };
|
|
|
|
MDNode *THolder = MDNode::get(VMContext, TVElts);
|
|
|
|
|
2010-12-08 21:42:44 +01:00
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_subprogram),
|
|
|
|
llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)),
|
2011-08-17 00:09:43 +02:00
|
|
|
getNonCompileUnitScope(Context),
|
2010-12-08 21:42:44 +01: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 00:52:06 +02:00
|
|
|
Fn,
|
|
|
|
TParam,
|
2011-08-20 01:28:12 +02:00
|
|
|
llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)),
|
2012-04-03 02:43:49 +02:00
|
|
|
THolder,
|
|
|
|
// FIXME: Do we want to use a different scope lines?
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), LineNo)
|
2010-12-08 21:42:44 +01:00
|
|
|
};
|
2011-04-19 01:51:03 +02:00
|
|
|
MDNode *Node = MDNode::get(VMContext, Elts);
|
2010-12-08 21:42:44 +01:00
|
|
|
return DISubprogram(Node);
|
|
|
|
}
|
|
|
|
|
2011-02-22 19:56:12 +01:00
|
|
|
/// createNameSpace - This creates new descriptor for a namespace
|
2010-12-08 00:25:47 +01:00
|
|
|
/// with the specified parent scope.
|
2011-02-22 19:56:12 +01:00
|
|
|
DINameSpace DIBuilder::createNameSpace(DIDescriptor Scope, StringRef Name,
|
2010-12-08 00:25:47 +01:00
|
|
|
DIFile File, unsigned LineNo) {
|
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_namespace),
|
2011-08-17 00:09:43 +02:00
|
|
|
getNonCompileUnitScope(Scope),
|
2010-12-08 00:25:47 +01:00
|
|
|
MDString::get(VMContext, Name),
|
|
|
|
File,
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), LineNo)
|
|
|
|
};
|
2011-04-19 01:51:03 +02:00
|
|
|
return DINameSpace(MDNode::get(VMContext, Elts));
|
2010-12-08 00:25:47 +01:00
|
|
|
}
|
|
|
|
|
2011-10-12 00:59:11 +02:00
|
|
|
/// createLexicalBlockFile - This creates a new MDNode that encapsulates
|
|
|
|
/// an existing scope with a new filename.
|
|
|
|
DILexicalBlockFile DIBuilder::createLexicalBlockFile(DIDescriptor Scope,
|
2012-02-08 01:17:07 +01:00
|
|
|
DIFile File) {
|
2011-10-12 00:59:11 +02:00
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_lexical_block),
|
|
|
|
Scope,
|
|
|
|
File
|
|
|
|
};
|
|
|
|
return DILexicalBlockFile(MDNode::get(VMContext, Elts));
|
|
|
|
}
|
|
|
|
|
2011-02-22 19:56:12 +01:00
|
|
|
DILexicalBlock DIBuilder::createLexicalBlock(DIDescriptor Scope, DIFile File,
|
2010-12-08 02:50:15 +01: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 00:09:43 +02:00
|
|
|
getNonCompileUnitScope(Scope),
|
2010-12-08 02:50:15 +01:00
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), Line),
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), Col),
|
|
|
|
File,
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), unique_id++)
|
|
|
|
};
|
2011-04-19 01:51:03 +02:00
|
|
|
return DILexicalBlock(MDNode::get(VMContext, Elts));
|
2010-12-08 02:50:15 +01:00
|
|
|
}
|
|
|
|
|
2011-02-22 19:56:12 +01:00
|
|
|
/// insertDeclare - Insert a new llvm.dbg.declare intrinsic call.
|
|
|
|
Instruction *DIBuilder::insertDeclare(Value *Storage, DIVariable VarInfo,
|
2010-12-08 00:25:47 +01: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-21 21:59:31 +02:00
|
|
|
Value *Args[] = { MDNode::get(Storage->getContext(), Storage), VarInfo };
|
2011-07-15 10:37:34 +02:00
|
|
|
return CallInst::Create(DeclareFn, Args, "", InsertBefore);
|
2010-12-08 00:25:47 +01:00
|
|
|
}
|
|
|
|
|
2011-02-22 19:56:12 +01:00
|
|
|
/// insertDeclare - Insert a new llvm.dbg.declare intrinsic call.
|
|
|
|
Instruction *DIBuilder::insertDeclare(Value *Storage, DIVariable VarInfo,
|
2010-12-08 00:25:47 +01: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-21 21:59:31 +02:00
|
|
|
Value *Args[] = { MDNode::get(Storage->getContext(), Storage), VarInfo };
|
2010-12-08 00:25:47 +01:00
|
|
|
|
|
|
|
// If this block already has a terminator then insert this intrinsic
|
|
|
|
// before the terminator.
|
|
|
|
if (TerminatorInst *T = InsertAtEnd->getTerminator())
|
2011-07-15 10:37:34 +02:00
|
|
|
return CallInst::Create(DeclareFn, Args, "", T);
|
2010-12-08 00:25:47 +01:00
|
|
|
else
|
2011-07-15 10:37:34 +02:00
|
|
|
return CallInst::Create(DeclareFn, Args, "", InsertAtEnd);
|
2010-12-08 00:25:47 +01:00
|
|
|
}
|
|
|
|
|
2011-02-22 19:56:12 +01:00
|
|
|
/// insertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
|
|
|
|
Instruction *DIBuilder::insertDbgValueIntrinsic(Value *V, uint64_t Offset,
|
2010-12-08 00:25:47 +01: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-21 21:59:31 +02:00
|
|
|
Value *Args[] = { MDNode::get(V->getContext(), V),
|
2010-12-08 00:25:47 +01:00
|
|
|
ConstantInt::get(Type::getInt64Ty(V->getContext()), Offset),
|
|
|
|
VarInfo };
|
2011-07-15 10:37:34 +02:00
|
|
|
return CallInst::Create(ValueFn, Args, "", InsertBefore);
|
2010-12-08 00:25:47 +01:00
|
|
|
}
|
|
|
|
|
2011-02-22 19:56:12 +01:00
|
|
|
/// insertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
|
|
|
|
Instruction *DIBuilder::insertDbgValueIntrinsic(Value *V, uint64_t Offset,
|
2010-12-08 00:25:47 +01: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-21 21:59:31 +02:00
|
|
|
Value *Args[] = { MDNode::get(V->getContext(), V),
|
2010-12-08 00:25:47 +01:00
|
|
|
ConstantInt::get(Type::getInt64Ty(V->getContext()), Offset),
|
|
|
|
VarInfo };
|
2011-07-15 10:37:34 +02:00
|
|
|
return CallInst::Create(ValueFn, Args, "", InsertAtEnd);
|
2010-12-08 00:25:47 +01:00
|
|
|
}
|