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)
|
2013-10-16 07:31:31 +08:00
|
|
|
: M(m), VMContext(M.getContext()), TempEnumTypes(0), TempRetainTypes(0),
|
|
|
|
TempSubprograms(0), TempGVs(0), DeclareFn(0), ValueFn(0) {}
|
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);
|
|
|
|
|
2013-08-30 07:17:54 +08:00
|
|
|
SmallVector<Value *, 16> RetainValues;
|
|
|
|
// Declarations and definitions of the same type may be retained. Some
|
|
|
|
// clients RAUW these pairs, leaving duplicates in the retained types
|
|
|
|
// list. Use a set to remove the duplicates while we transform the
|
|
|
|
// TrackingVHs back into Values.
|
|
|
|
SmallPtrSet<Value *, 16> RetainSet;
|
|
|
|
for (unsigned I = 0, E = AllRetainTypes.size(); I < E; I++)
|
|
|
|
if (RetainSet.insert(AllRetainTypes[I]))
|
|
|
|
RetainValues.push_back(AllRetainTypes[I]);
|
|
|
|
DIArray RetainTypes = getOrCreateArray(RetainValues);
|
2011-08-17 06:09:43 +08:00
|
|
|
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);
|
2013-04-22 14:12:31 +08:00
|
|
|
|
|
|
|
DIArray IMs = getOrCreateArray(AllImportedModules);
|
|
|
|
DIType(TempImportedModules).replaceAllUsesWith(IMs);
|
2011-08-17 06:09:43 +08:00
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2013-03-21 07:58:12 +08:00
|
|
|
static MDNode *createFilePathPair(LLVMContext &VMContext, StringRef Filename,
|
|
|
|
StringRef Directory) {
|
|
|
|
assert(!Filename.empty() && "Unable to create file without name");
|
|
|
|
Value *Pair[] = {
|
|
|
|
MDString::get(VMContext, Filename),
|
2013-10-16 07:31:31 +08:00
|
|
|
MDString::get(VMContext, Directory)
|
2013-03-21 07:58:12 +08:00
|
|
|
};
|
|
|
|
return MDNode::get(VMContext, Pair);
|
|
|
|
}
|
|
|
|
|
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.
|
2013-07-19 08:51:47 +08:00
|
|
|
DICompileUnit DIBuilder::createCompileUnit(unsigned Lang, StringRef Filename,
|
|
|
|
StringRef Directory,
|
|
|
|
StringRef Producer, bool isOptimized,
|
|
|
|
StringRef Flags, unsigned RunTimeVer,
|
|
|
|
StringRef SplitName) {
|
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);
|
|
|
|
|
2013-04-22 14:12:31 +08:00
|
|
|
TempImportedModules = MDNode::getTemporary(VMContext, TElts);
|
|
|
|
|
2010-11-05 02:45:27 +08:00
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_compile_unit),
|
2013-03-21 07:58:12 +08:00
|
|
|
createFilePathPair(VMContext, Filename, Directory),
|
2013-03-21 06:52:54 +08:00
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), Lang),
|
2010-11-05 02:45:27 +08:00
|
|
|
MDString::get(VMContext, Producer),
|
|
|
|
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,
|
2013-02-23 07:50:04 +08:00
|
|
|
TempGVs,
|
2013-04-22 14:12:31 +08:00
|
|
|
TempImportedModules,
|
2013-02-23 07:50:04 +08:00
|
|
|
MDString::get(VMContext, SplitName)
|
2010-11-05 02:45:27 +08:00
|
|
|
};
|
2013-07-19 08:51:47 +08:00
|
|
|
|
|
|
|
MDNode *CUNode = 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");
|
2013-07-19 08:51:47 +08:00
|
|
|
NMD->addOperand(CUNode);
|
|
|
|
|
|
|
|
return DICompileUnit(CUNode);
|
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-05-21 06:50:35 +08:00
|
|
|
static DIImportedEntity
|
|
|
|
createImportedModule(LLVMContext &C, DIScope Context, DIDescriptor NS,
|
|
|
|
unsigned Line, StringRef Name,
|
|
|
|
SmallVectorImpl<Value *> &AllImportedModules) {
|
|
|
|
const MDNode *R;
|
|
|
|
if (Name.empty()) {
|
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(C, dwarf::DW_TAG_imported_module),
|
|
|
|
Context,
|
|
|
|
NS,
|
|
|
|
ConstantInt::get(Type::getInt32Ty(C), Line),
|
|
|
|
};
|
|
|
|
R = MDNode::get(C, Elts);
|
|
|
|
} else {
|
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(C, dwarf::DW_TAG_imported_module),
|
|
|
|
Context,
|
|
|
|
NS,
|
|
|
|
ConstantInt::get(Type::getInt32Ty(C), Line),
|
|
|
|
MDString::get(C, Name)
|
|
|
|
};
|
|
|
|
R = MDNode::get(C, Elts);
|
|
|
|
}
|
|
|
|
DIImportedEntity M(R);
|
2013-05-08 05:35:53 +08:00
|
|
|
assert(M.Verify() && "Imported module should be valid");
|
|
|
|
AllImportedModules.push_back(M);
|
|
|
|
return M;
|
|
|
|
}
|
|
|
|
|
2013-05-21 06:50:35 +08:00
|
|
|
DIImportedEntity DIBuilder::createImportedModule(DIScope Context,
|
|
|
|
DINameSpace NS, unsigned Line,
|
|
|
|
StringRef Name) {
|
|
|
|
return ::createImportedModule(VMContext, Context, NS, Line, Name,
|
|
|
|
AllImportedModules);
|
|
|
|
}
|
|
|
|
|
|
|
|
DIImportedEntity DIBuilder::createImportedModule(DIScope Context,
|
|
|
|
DIImportedEntity NS,
|
|
|
|
unsigned Line,
|
|
|
|
StringRef Name) {
|
|
|
|
return ::createImportedModule(VMContext, Context, NS, Line, Name,
|
|
|
|
AllImportedModules);
|
|
|
|
}
|
|
|
|
|
2013-05-08 05:35:53 +08:00
|
|
|
DIImportedEntity DIBuilder::createImportedDeclaration(DIScope Context,
|
|
|
|
DIDescriptor Decl,
|
|
|
|
unsigned Line) {
|
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_imported_declaration),
|
|
|
|
Context,
|
|
|
|
Decl,
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), Line),
|
|
|
|
};
|
|
|
|
DIImportedEntity M(MDNode::get(VMContext, Elts));
|
2013-04-22 14:12:31 +08:00
|
|
|
assert(M.Verify() && "Imported module should be valid");
|
|
|
|
AllImportedModules.push_back(M);
|
|
|
|
return M;
|
|
|
|
}
|
|
|
|
|
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) {
|
2013-03-18 05:13:55 +08:00
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_file_type),
|
2013-03-28 10:44:59 +08:00
|
|
|
createFilePathPair(VMContext, Filename, Directory)
|
2013-03-18 05:13:55 +08:00
|
|
|
};
|
2013-03-28 10:44:59 +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.
|
2013-06-25 01:34:33 +08:00
|
|
|
DIEnumerator DIBuilder::createEnumerator(StringRef Name, int64_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)
|
|
|
|
};
|
2013-03-28 10:44:59 +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
|
|
|
}
|
|
|
|
|
2013-06-28 06:50:59 +08:00
|
|
|
/// \brief Create a DWARF unspecified type.
|
|
|
|
DIBasicType DIBuilder::createUnspecifiedType(StringRef Name) {
|
2011-09-15 07:13:28 +08:00
|
|
|
assert(!Name.empty() && "Unable to create type without name");
|
2013-06-28 06:50:59 +08:00
|
|
|
// Unspecified types are encoded in DIBasicType format. Line number, filename,
|
|
|
|
// size, alignment, offset and flags are always empty here.
|
2011-09-15 07:13:28 +08:00
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_unspecified_type),
|
2013-03-20 07:25:22 +08:00
|
|
|
NULL, // Filename
|
2013-07-19 08:51:47 +08:00
|
|
|
NULL, // Unused
|
2011-09-15 07:13:28 +08:00
|
|
|
MDString::get(VMContext, Name),
|
|
|
|
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
|
|
|
};
|
2013-06-08 02:35:53 +08:00
|
|
|
return DIBasicType(MDNode::get(VMContext, Elts));
|
2011-09-15 07:13:28 +08:00
|
|
|
}
|
|
|
|
|
2013-06-28 06:50:59 +08:00
|
|
|
/// \brief Create C++11 nullptr type.
|
|
|
|
DIBasicType DIBuilder::createNullPtrType() {
|
|
|
|
return createUnspecifiedType("decltype(nullptr)");
|
|
|
|
}
|
|
|
|
|
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),
|
2013-03-20 07:25:22 +08:00
|
|
|
NULL, // File/directory name
|
2013-07-19 08:51:47 +08:00
|
|
|
NULL, // Unused
|
2010-11-05 02:45:27 +08:00
|
|
|
MDString::get(VMContext, Name),
|
|
|
|
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-03-28 10:44:59 +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'.
|
2013-02-18 14:41:57 +08:00
|
|
|
DIDerivedType 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),
|
2013-03-20 07:25:22 +08:00
|
|
|
NULL, // Filename
|
2013-07-19 08:51:47 +08:00
|
|
|
NULL, // Unused
|
2010-11-05 02:45:27 +08:00
|
|
|
MDString::get(VMContext, StringRef()), // Empty name.
|
|
|
|
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
|
2013-10-09 06:56:31 +08:00
|
|
|
FromTy.getRef()
|
2010-11-05 02:45:27 +08:00
|
|
|
};
|
2013-03-28 10:44:59 +08:00
|
|
|
return DIDerivedType(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.
|
2013-02-18 14:41:57 +08:00
|
|
|
DIDerivedType
|
|
|
|
DIBuilder::createPointerType(DIType PointeeTy, uint64_t SizeInBits,
|
|
|
|
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),
|
2013-03-20 07:25:22 +08:00
|
|
|
NULL, // Filename
|
2013-07-19 08:51:47 +08:00
|
|
|
NULL, // Unused
|
2010-11-05 02:45:27 +08:00
|
|
|
MDString::get(VMContext, Name),
|
|
|
|
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
|
2013-10-05 09:43:03 +08:00
|
|
|
PointeeTy.getRef()
|
2010-11-05 02:45:27 +08:00
|
|
|
};
|
2013-03-28 10:44:59 +08:00
|
|
|
return DIDerivedType(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-04-20 04:37:12 +08:00
|
|
|
DIDerivedType DIBuilder::createMemberPointerType(DIType PointeeTy,
|
|
|
|
DIType Base) {
|
2013-01-07 13:51:15 +08:00
|
|
|
// Pointer types are encoded in DIDerivedType format.
|
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_ptr_to_member_type),
|
2013-03-20 07:25:22 +08:00
|
|
|
NULL, // Filename
|
2013-07-19 08:51:47 +08:00
|
|
|
NULL, // Unused
|
2013-01-07 13:51:15 +08:00
|
|
|
NULL,
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Line
|
2013-10-16 07:31:31 +08:00
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), 0), // Size
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), 0), // Align
|
2013-01-07 13:51:15 +08:00
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), 0), // Offset
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Flags
|
2013-10-09 06:56:31 +08:00
|
|
|
PointeeTy.getRef(),
|
2013-10-01 03:42:10 +08:00
|
|
|
Base.getRef()
|
2013-01-07 13:51:15 +08:00
|
|
|
};
|
2013-03-28 10:44:59 +08:00
|
|
|
return DIDerivedType(MDNode::get(VMContext, Elts));
|
2013-01-07 13:51:15 +08:00
|
|
|
}
|
|
|
|
|
2012-05-19 09:36:37 +08:00
|
|
|
/// createReferenceType - Create debugging information entry for a reference
|
|
|
|
/// type.
|
2013-02-18 14:41:57 +08:00
|
|
|
DIDerivedType DIBuilder::createReferenceType(unsigned Tag, DIType RTy) {
|
2013-07-02 05:02:01 +08:00
|
|
|
assert(RTy.isType() && "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),
|
2013-03-20 07:25:22 +08:00
|
|
|
NULL, // Filename
|
2011-08-27 05:02:40 +08:00
|
|
|
NULL, // TheCU,
|
2010-11-05 02:45:27 +08:00
|
|
|
NULL, // Name
|
|
|
|
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
|
2013-10-09 06:56:31 +08:00
|
|
|
RTy.getRef()
|
2010-11-05 02:45:27 +08:00
|
|
|
};
|
2013-03-28 10:44:59 +08:00
|
|
|
return DIDerivedType(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.
|
2013-02-18 14:41:57 +08:00
|
|
|
DIDerivedType DIBuilder::createTypedef(DIType Ty, StringRef Name, DIFile File,
|
|
|
|
unsigned LineNo, DIDescriptor Context) {
|
2010-11-05 02:45:27 +08:00
|
|
|
// typedefs are encoded in DIDerivedType format.
|
2013-07-02 05:02:01 +08:00
|
|
|
assert(Ty.isType() && "Invalid typedef type!");
|
2010-11-05 02:45:27 +08:00
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_typedef),
|
2013-03-20 08:26:26 +08:00
|
|
|
File.getFileNode(),
|
2013-10-09 07:49:38 +08:00
|
|
|
DIScope(getNonCompileUnitScope(Context)).getRef(),
|
2010-11-05 02:45:27 +08:00
|
|
|
MDString::get(VMContext, Name),
|
|
|
|
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
|
2013-10-09 06:56:31 +08:00
|
|
|
Ty.getRef()
|
2010-11-05 02:45:27 +08:00
|
|
|
};
|
2013-03-28 10:44:59 +08:00
|
|
|
return DIDerivedType(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'.
|
2013-06-08 02:35:53 +08:00
|
|
|
DIDerivedType DIBuilder::createFriend(DIType Ty, DIType FriendTy) {
|
2010-11-05 02:45:27 +08:00
|
|
|
// typedefs are encoded in DIDerivedType format.
|
2013-07-02 05:02:01 +08:00
|
|
|
assert(Ty.isType() && "Invalid type!");
|
|
|
|
assert(FriendTy.isType() && "Invalid friend type!");
|
2010-11-05 02:45:27 +08:00
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_friend),
|
2013-03-20 07:25:22 +08:00
|
|
|
NULL,
|
2013-10-01 03:42:10 +08:00
|
|
|
Ty.getRef(),
|
2010-11-05 02:45:27 +08:00
|
|
|
NULL, // Name
|
|
|
|
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
|
2013-10-09 06:56:31 +08:00
|
|
|
FriendTy.getRef()
|
2010-11-05 02:45:27 +08:00
|
|
|
};
|
2013-06-08 02:35:53 +08:00
|
|
|
return DIDerivedType(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.
|
2013-10-16 07:31:31 +08:00
|
|
|
DIDerivedType DIBuilder::createInheritance(DIType Ty, DIType BaseTy,
|
|
|
|
uint64_t BaseOffset,
|
|
|
|
unsigned Flags) {
|
2013-07-02 05:02:01 +08:00
|
|
|
assert(Ty.isType() && "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),
|
2013-03-20 07:25:22 +08:00
|
|
|
NULL,
|
2013-10-01 03:42:10 +08:00
|
|
|
Ty.getRef(),
|
2010-11-05 02:45:27 +08:00
|
|
|
NULL, // Name
|
|
|
|
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),
|
2013-10-09 06:56:31 +08:00
|
|
|
BaseTy.getRef()
|
2010-11-05 02:45:27 +08:00
|
|
|
};
|
2013-03-28 10:44:59 +08:00
|
|
|
return DIDerivedType(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.
|
2013-10-16 07:31:31 +08:00
|
|
|
DIDerivedType DIBuilder::createMemberType(DIDescriptor Scope, StringRef Name,
|
|
|
|
DIFile File, unsigned LineNumber,
|
|
|
|
uint64_t SizeInBits,
|
|
|
|
uint64_t AlignInBits,
|
|
|
|
uint64_t OffsetInBits, unsigned Flags,
|
|
|
|
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),
|
2013-03-20 08:26:26 +08:00
|
|
|
File.getFileNode(),
|
2013-10-01 03:42:10 +08:00
|
|
|
DIScope(getNonCompileUnitScope(Scope)).getRef(),
|
2010-11-05 02:45:27 +08:00
|
|
|
MDString::get(VMContext, Name),
|
|
|
|
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),
|
2013-10-09 06:56:31 +08:00
|
|
|
Ty.getRef()
|
2010-11-05 02:45:27 +08:00
|
|
|
};
|
2013-03-28 10:44:59 +08:00
|
|
|
return DIDerivedType(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.
|
2013-06-08 02:35:53 +08:00
|
|
|
DIDerivedType
|
|
|
|
DIBuilder::createStaticMemberType(DIDescriptor Scope, StringRef Name,
|
|
|
|
DIFile File, unsigned LineNumber,
|
|
|
|
DIType Ty, unsigned Flags,
|
|
|
|
llvm::Value *Val) {
|
2013-01-16 09:22:23 +08:00
|
|
|
// TAG_member is encoded in DIDerivedType format.
|
|
|
|
Flags |= DIDescriptor::FlagStaticMember;
|
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_member),
|
2013-03-20 08:26:26 +08:00
|
|
|
File.getFileNode(),
|
2013-10-09 07:49:38 +08:00
|
|
|
DIScope(getNonCompileUnitScope(Scope)).getRef(),
|
2013-01-16 09:22:23 +08:00
|
|
|
MDString::get(VMContext, Name),
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber),
|
2013-10-16 07:31:31 +08:00
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), 0), // Size
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), 0), // Align
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), 0), // Offset
|
2013-01-16 09:22:23 +08:00
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), Flags),
|
2013-10-09 06:56:31 +08:00
|
|
|
Ty.getRef(),
|
2013-01-16 09:22:23 +08:00
|
|
|
Val
|
|
|
|
};
|
2013-06-08 02:35:53 +08:00
|
|
|
return DIDerivedType(MDNode::get(VMContext, Elts));
|
2013-01-16 09:22:23 +08:00
|
|
|
}
|
|
|
|
|
2011-04-16 08:11:51 +08:00
|
|
|
/// createObjCIVar - Create debugging information entry for Objective-C
|
|
|
|
/// instance variable.
|
2013-06-08 02:35:53 +08:00
|
|
|
DIDerivedType
|
2013-10-16 07:31:31 +08:00
|
|
|
DIBuilder::createObjCIVar(StringRef Name, DIFile File, unsigned LineNumber,
|
2013-06-08 02:35:53 +08:00
|
|
|
uint64_t SizeInBits, uint64_t AlignInBits,
|
2013-10-16 07:31:31 +08:00
|
|
|
uint64_t OffsetInBits, unsigned Flags, DIType Ty,
|
|
|
|
StringRef PropertyName, StringRef GetterName,
|
|
|
|
StringRef SetterName, unsigned PropertyAttributes) {
|
2011-04-16 08:11:51 +08:00
|
|
|
// TAG_member is encoded in DIDerivedType format.
|
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_member),
|
2013-03-20 08:26:26 +08:00
|
|
|
File.getFileNode(),
|
2011-08-17 06:09:43 +08:00
|
|
|
getNonCompileUnitScope(File),
|
2011-04-16 08:11:51 +08:00
|
|
|
MDString::get(VMContext, Name),
|
|
|
|
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)
|
|
|
|
};
|
2013-06-08 02:35:53 +08:00
|
|
|
return DIDerivedType(MDNode::get(VMContext, Elts));
|
2012-02-07 01:49:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// createObjCIVar - Create debugging information entry for Objective-C
|
|
|
|
/// instance variable.
|
2013-10-16 07:31:31 +08:00
|
|
|
DIDerivedType DIBuilder::createObjCIVar(StringRef Name, DIFile File,
|
|
|
|
unsigned LineNumber,
|
|
|
|
uint64_t SizeInBits,
|
|
|
|
uint64_t AlignInBits,
|
|
|
|
uint64_t OffsetInBits, unsigned Flags,
|
|
|
|
DIType Ty, MDNode *PropertyNode) {
|
2012-02-07 01:49:43 +08:00
|
|
|
// TAG_member is encoded in DIDerivedType format.
|
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_member),
|
2013-03-20 08:26:26 +08:00
|
|
|
File.getFileNode(),
|
2012-02-07 01:49:43 +08:00
|
|
|
getNonCompileUnitScope(File),
|
|
|
|
MDString::get(VMContext, Name),
|
|
|
|
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
|
|
|
|
};
|
2013-06-08 02:35:53 +08:00
|
|
|
return DIDerivedType(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.
|
2013-10-16 07:31:31 +08:00
|
|
|
DIObjCProperty
|
|
|
|
DIBuilder::createObjCProperty(StringRef Name, DIFile File, unsigned LineNumber,
|
|
|
|
StringRef GetterName, StringRef SetterName,
|
|
|
|
unsigned PropertyAttributes, 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
|
|
|
};
|
2013-03-28 10:44:59 +08:00
|
|
|
return DIObjCProperty(MDNode::get(VMContext, Elts));
|
2012-02-04 08:59:25 +08:00
|
|
|
}
|
|
|
|
|
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),
|
2013-10-10 03:46:28 +08:00
|
|
|
DIScope(getNonCompileUnitScope(Context)).getRef(),
|
2011-02-03 05:38:25 +08:00
|
|
|
MDString::get(VMContext, Name),
|
2013-10-10 03:46:28 +08:00
|
|
|
Ty.getRef(),
|
2011-02-03 05:38:25 +08:00
|
|
|
File,
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), LineNo),
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), ColumnNo)
|
|
|
|
};
|
2013-03-28 10:44:59 +08:00
|
|
|
return DITemplateTypeParameter(MDNode::get(VMContext, Elts));
|
2011-02-03 05:38:25 +08:00
|
|
|
}
|
|
|
|
|
2011-08-27 05:02:40 +08:00
|
|
|
DITemplateValueParameter
|
2013-06-23 02:59:11 +08:00
|
|
|
DIBuilder::createTemplateValueParameter(unsigned Tag, DIDescriptor Context,
|
|
|
|
StringRef Name, DIType Ty,
|
|
|
|
Value *Val, MDNode *File,
|
|
|
|
unsigned LineNo,
|
2011-02-03 06:35:53 +08:00
|
|
|
unsigned ColumnNo) {
|
|
|
|
Value *Elts[] = {
|
2013-06-23 02:59:11 +08:00
|
|
|
GetTagConstant(VMContext, Tag),
|
2013-10-10 03:46:28 +08:00
|
|
|
DIScope(getNonCompileUnitScope(Context)).getRef(),
|
2011-02-03 06:35:53 +08:00
|
|
|
MDString::get(VMContext, Name),
|
2013-10-10 03:46:28 +08:00
|
|
|
Ty.getRef(),
|
2013-05-11 05:52:07 +08:00
|
|
|
Val,
|
2011-02-03 06:35:53 +08:00
|
|
|
File,
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), LineNo),
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), ColumnNo)
|
|
|
|
};
|
2013-03-28 10:44:59 +08:00
|
|
|
return DITemplateValueParameter(MDNode::get(VMContext, Elts));
|
2011-02-03 06:35:53 +08:00
|
|
|
}
|
|
|
|
|
2013-06-23 02:59:11 +08:00
|
|
|
/// createTemplateValueParameter - Create debugging information for template
|
|
|
|
/// value parameter.
|
|
|
|
DITemplateValueParameter
|
|
|
|
DIBuilder::createTemplateValueParameter(DIDescriptor Context, StringRef Name,
|
|
|
|
DIType Ty, Value *Val,
|
|
|
|
MDNode *File, unsigned LineNo,
|
|
|
|
unsigned ColumnNo) {
|
|
|
|
return createTemplateValueParameter(dwarf::DW_TAG_template_value_parameter,
|
|
|
|
Context, Name, Ty, Val, File, LineNo,
|
|
|
|
ColumnNo);
|
|
|
|
}
|
|
|
|
|
|
|
|
DITemplateValueParameter
|
|
|
|
DIBuilder::createTemplateTemplateParameter(DIDescriptor Context, StringRef Name,
|
|
|
|
DIType Ty, StringRef Val,
|
|
|
|
MDNode *File, unsigned LineNo,
|
|
|
|
unsigned ColumnNo) {
|
|
|
|
return createTemplateValueParameter(
|
|
|
|
dwarf::DW_TAG_GNU_template_template_param, Context, Name, Ty,
|
|
|
|
MDString::get(VMContext, Val), File, LineNo, ColumnNo);
|
|
|
|
}
|
|
|
|
|
|
|
|
DITemplateValueParameter
|
|
|
|
DIBuilder::createTemplateParameterPack(DIDescriptor Context, StringRef Name,
|
|
|
|
DIType Ty, DIArray Val,
|
|
|
|
MDNode *File, unsigned LineNo,
|
|
|
|
unsigned ColumnNo) {
|
|
|
|
return createTemplateValueParameter(dwarf::DW_TAG_GNU_template_parameter_pack,
|
|
|
|
Context, Name, Ty, Val, File, LineNo,
|
|
|
|
ColumnNo);
|
|
|
|
}
|
|
|
|
|
2012-07-06 10:35:57 +08:00
|
|
|
/// createClassType - Create debugging information entry for a class.
|
2013-03-27 07:46:39 +08:00
|
|
|
DICompositeType 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,
|
2013-09-07 07:54:23 +08:00
|
|
|
DIType VTableHolder,
|
2013-08-28 07:06:40 +08:00
|
|
|
MDNode *TemplateParams,
|
|
|
|
StringRef UniqueIdentifier) {
|
2013-07-02 05:02:01 +08:00
|
|
|
assert((!Context || Context.isScope() || Context.isType()) &&
|
2013-03-12 07:21:19 +08:00
|
|
|
"createClassType should be called with a valid Context");
|
|
|
|
// TAG_class_type is encoded in DICompositeType format.
|
2012-07-06 10:35:57 +08:00
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_class_type),
|
2013-03-20 08:26:26 +08:00
|
|
|
File.getFileNode(),
|
2013-10-09 08:17:04 +08:00
|
|
|
DIScope(getNonCompileUnitScope(Context)).getRef(),
|
2012-07-06 10:35:57 +08:00
|
|
|
MDString::get(VMContext, Name),
|
|
|
|
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),
|
2013-10-09 07:28:51 +08:00
|
|
|
DerivedFrom.getRef(),
|
2012-07-06 10:35:57 +08:00
|
|
|
Elements,
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0),
|
2013-10-01 03:42:10 +08:00
|
|
|
VTableHolder.getRef(),
|
2013-08-27 06:39:55 +08:00
|
|
|
TemplateParams,
|
2013-08-28 07:06:40 +08:00
|
|
|
UniqueIdentifier.empty() ? NULL : MDString::get(VMContext, UniqueIdentifier)
|
2012-07-06 10:35:57 +08:00
|
|
|
};
|
2013-03-27 07:46:39 +08:00
|
|
|
DICompositeType R(MDNode::get(VMContext, Elts));
|
2013-07-02 05:02:01 +08:00
|
|
|
assert(R.isCompositeType() &&
|
|
|
|
"createClassType should return a DICompositeType");
|
2013-08-30 07:17:54 +08:00
|
|
|
if (!UniqueIdentifier.empty())
|
|
|
|
retainType(R);
|
2013-03-12 07:21:19 +08:00
|
|
|
return R;
|
2012-07-06 10:35:57 +08:00
|
|
|
}
|
|
|
|
|
2011-02-23 02:56:12 +08:00
|
|
|
/// createStructType - Create debugging information entry for a struct.
|
2013-02-25 09:07:18 +08:00
|
|
|
DICompositeType DIBuilder::createStructType(DIDescriptor Context,
|
|
|
|
StringRef Name, DIFile File,
|
|
|
|
unsigned LineNumber,
|
|
|
|
uint64_t SizeInBits,
|
|
|
|
uint64_t AlignInBits,
|
|
|
|
unsigned Flags, DIType DerivedFrom,
|
|
|
|
DIArray Elements,
|
|
|
|
unsigned RunTimeLang,
|
2013-09-07 07:54:23 +08:00
|
|
|
DIType VTableHolder,
|
2013-08-28 07:06:40 +08:00
|
|
|
StringRef UniqueIdentifier) {
|
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),
|
2013-03-20 08:26:26 +08:00
|
|
|
File.getFileNode(),
|
2013-10-09 08:17:04 +08:00
|
|
|
DIScope(getNonCompileUnitScope(Context)).getRef(),
|
2010-12-08 07:25:47 +08:00
|
|
|
MDString::get(VMContext, Name),
|
|
|
|
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),
|
2013-10-09 07:28:51 +08:00
|
|
|
DerivedFrom.getRef(),
|
2010-12-08 07:25:47 +08:00
|
|
|
Elements,
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), RunTimeLang),
|
2013-10-01 03:42:10 +08:00
|
|
|
VTableHolder.getRef(),
|
2013-02-18 15:27:30 +08:00
|
|
|
NULL,
|
2013-08-28 07:06:40 +08:00
|
|
|
UniqueIdentifier.empty() ? NULL : MDString::get(VMContext, UniqueIdentifier)
|
2010-12-08 07:25:47 +08:00
|
|
|
};
|
2013-03-12 07:21:19 +08:00
|
|
|
DICompositeType R(MDNode::get(VMContext, Elts));
|
2013-07-02 05:02:01 +08:00
|
|
|
assert(R.isCompositeType() &&
|
|
|
|
"createStructType should return a DICompositeType");
|
2013-08-30 07:17:54 +08:00
|
|
|
if (!UniqueIdentifier.empty())
|
|
|
|
retainType(R);
|
2013-03-12 07:21:19 +08:00
|
|
|
return R;
|
2010-12-08 07:25:47 +08:00
|
|
|
}
|
|
|
|
|
2011-02-23 02:56:12 +08:00
|
|
|
/// createUnionType - Create debugging information entry for an union.
|
2013-04-03 06:55:52 +08:00
|
|
|
DICompositeType DIBuilder::createUnionType(DIDescriptor Scope, StringRef Name,
|
|
|
|
DIFile File, unsigned LineNumber,
|
|
|
|
uint64_t SizeInBits,
|
|
|
|
uint64_t AlignInBits, unsigned Flags,
|
|
|
|
DIArray Elements,
|
2013-08-28 07:06:40 +08:00
|
|
|
unsigned RunTimeLang,
|
|
|
|
StringRef UniqueIdentifier) {
|
2010-12-08 09:50:15 +08:00
|
|
|
// TAG_union_type is encoded in DICompositeType format.
|
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_union_type),
|
2013-03-20 08:26:26 +08:00
|
|
|
File.getFileNode(),
|
2013-10-09 08:17:04 +08:00
|
|
|
DIScope(getNonCompileUnitScope(Scope)).getRef(),
|
2010-12-08 09:50:15 +08:00
|
|
|
MDString::get(VMContext, Name),
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber),
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), SizeInBits),
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits),
|
2013-10-16 07:31:31 +08:00
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), 0), // Offset
|
2010-12-08 09:50:15 +08:00
|
|
|
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),
|
2013-08-27 06:39:55 +08:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2013-08-28 07:06:40 +08:00
|
|
|
UniqueIdentifier.empty() ? NULL : MDString::get(VMContext, UniqueIdentifier)
|
2010-12-08 09:50:15 +08:00
|
|
|
};
|
2013-08-30 07:17:54 +08:00
|
|
|
DICompositeType R(MDNode::get(VMContext, Elts));
|
|
|
|
if (!UniqueIdentifier.empty())
|
|
|
|
retainType(R);
|
|
|
|
return R;
|
2010-12-08 09:50:15 +08:00
|
|
|
}
|
|
|
|
|
2011-02-23 02:56:12 +08:00
|
|
|
/// createSubroutineType - Create subroutine type.
|
2013-10-16 07:31:31 +08:00
|
|
|
DICompositeType 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)),
|
2013-09-08 14:00:42 +08:00
|
|
|
NULL,
|
2013-03-20 07:25:22 +08:00
|
|
|
MDString::get(VMContext, ""),
|
2013-10-16 07:31:31 +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), 0), // Offset
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Flags
|
2011-12-17 01:51:31 +08:00
|
|
|
NULL,
|
2010-12-08 09:50:15 +08:00
|
|
|
ParameterTypes,
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0),
|
2013-08-27 06:39:55 +08:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL // Type Identifer
|
2010-12-08 09:50:15 +08:00
|
|
|
};
|
2013-03-28 10:44:59 +08:00
|
|
|
return DICompositeType(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.
|
2013-02-18 14:41:57 +08:00
|
|
|
DICompositeType DIBuilder::createEnumerationType(
|
|
|
|
DIDescriptor Scope, StringRef Name, DIFile File, unsigned LineNumber,
|
|
|
|
uint64_t SizeInBits, uint64_t AlignInBits, DIArray Elements,
|
2013-08-28 07:06:40 +08:00
|
|
|
DIType UnderlyingType, StringRef UniqueIdentifier) {
|
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),
|
2013-03-20 08:26:26 +08:00
|
|
|
File.getFileNode(),
|
2013-10-09 08:17:04 +08:00
|
|
|
DIScope(getNonCompileUnitScope(Scope)).getRef(),
|
2010-12-08 09:50:15 +08:00
|
|
|
MDString::get(VMContext, Name),
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), LineNumber),
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), SizeInBits),
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits),
|
2013-10-16 07:31:31 +08:00
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Offset
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Flags
|
2013-10-09 07:28:51 +08:00
|
|
|
UnderlyingType.getRef(),
|
2010-12-08 09:50:15 +08:00
|
|
|
Elements,
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0),
|
2013-08-27 06:39:55 +08:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2013-08-28 07:06:40 +08:00
|
|
|
UniqueIdentifier.empty() ? NULL : MDString::get(VMContext, UniqueIdentifier)
|
2010-12-08 09:50:15 +08:00
|
|
|
};
|
2013-11-19 07:33:32 +08:00
|
|
|
DICompositeType CTy(MDNode::get(VMContext, Elts));
|
|
|
|
AllEnumTypes.push_back(CTy);
|
2013-08-30 07:17:54 +08:00
|
|
|
if (!UniqueIdentifier.empty())
|
2013-11-19 07:33:32 +08:00
|
|
|
retainType(CTy);
|
|
|
|
return CTy;
|
2010-12-08 09:50:15 +08:00
|
|
|
}
|
|
|
|
|
2011-02-23 02:56:12 +08:00
|
|
|
/// createArrayType - Create debugging information entry for an array.
|
2013-02-18 14:41:57 +08:00
|
|
|
DICompositeType DIBuilder::createArrayType(uint64_t Size, uint64_t AlignInBits,
|
|
|
|
DIType Ty, DIArray Subscripts) {
|
2010-12-08 09:50:15 +08:00
|
|
|
// TAG_array_type is encoded in DICompositeType format.
|
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_array_type),
|
2013-03-20 07:25:22 +08:00
|
|
|
NULL, // Filename/Directory,
|
2013-07-19 08:51:47 +08:00
|
|
|
NULL, // Unused
|
2010-12-08 09:50:15 +08:00
|
|
|
MDString::get(VMContext, ""),
|
2013-10-16 07:31:31 +08:00
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Line
|
2010-12-08 09:50:15 +08:00
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), Size),
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits),
|
2013-10-16 07:31:31 +08:00
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Offset
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Flags
|
2013-10-09 07:28:51 +08:00
|
|
|
Ty.getRef(),
|
2010-12-08 09:50:15 +08:00
|
|
|
Subscripts,
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0),
|
2013-08-27 06:39:55 +08:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL // Type Identifer
|
2010-12-08 09:50:15 +08:00
|
|
|
};
|
2013-03-28 10:44:59 +08:00
|
|
|
return DICompositeType(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.
|
2013-06-07 11:13:46 +08:00
|
|
|
DICompositeType DIBuilder::createVectorType(uint64_t Size, uint64_t AlignInBits,
|
|
|
|
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),
|
2013-03-20 07:25:22 +08:00
|
|
|
NULL, // Filename/Directory,
|
2013-07-19 08:51:47 +08:00
|
|
|
NULL, // Unused
|
2010-12-08 09:50:15 +08:00
|
|
|
MDString::get(VMContext, ""),
|
2013-10-16 07:31:31 +08:00
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Line
|
2010-12-08 09:50:15 +08:00
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), Size),
|
|
|
|
ConstantInt::get(Type::getInt64Ty(VMContext), AlignInBits),
|
2013-10-16 07:31:31 +08:00
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Offset
|
2013-01-08 09:53:52 +08:00
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), DIType::FlagVector),
|
2013-10-09 07:28:51 +08:00
|
|
|
Ty.getRef(),
|
2010-12-08 09:50:15 +08:00
|
|
|
Subscripts,
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0),
|
2013-08-27 06:39:55 +08:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL // Type Identifer
|
2010-12-08 09:50:15 +08:00
|
|
|
};
|
2013-06-07 11:13:46 +08:00
|
|
|
return DICompositeType(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!");
|
2013-09-08 14:00:42 +08:00
|
|
|
for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i)
|
|
|
|
Elts.push_back(N->getOperand(i));
|
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 CurFlags = Ty.getFlags();
|
|
|
|
CurFlags = CurFlags | DIType::FlagArtificial;
|
|
|
|
|
|
|
|
// Flags are stored at this slot.
|
2013-10-16 07:31:31 +08:00
|
|
|
// FIXME: Add an enum for this magic value.
|
2013-03-28 10:44:59 +08:00
|
|
|
Elts[8] = ConstantInt::get(Type::getInt32Ty(VMContext), CurFlags);
|
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-03-28 10:44:59 +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!");
|
2013-09-08 14:00:42 +08:00
|
|
|
for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i)
|
|
|
|
Elts.push_back(N->getOperand(i));
|
2012-09-13 07:36:19 +08:00
|
|
|
|
|
|
|
unsigned CurFlags = Ty.getFlags();
|
|
|
|
CurFlags = CurFlags | (DIType::FlagObjectPointer | DIType::FlagArtificial);
|
|
|
|
|
|
|
|
// Flags are stored at this slot.
|
2013-10-16 07:31:31 +08:00
|
|
|
// FIXME: Add an enum for this magic value.
|
2013-03-28 10:44:59 +08:00
|
|
|
Elts[8] = ConstantInt::get(Type::getInt32Ty(VMContext), CurFlags);
|
2012-09-13 07:36:19 +08:00
|
|
|
|
2013-03-28 10:44:59 +08:00
|
|
|
return DIType(MDNode::get(VMContext, Elts));
|
2012-09-13 07:36:19 +08:00
|
|
|
}
|
|
|
|
|
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) {
|
2013-08-30 07:17:54 +08:00
|
|
|
AllRetainTypes.push_back(TrackingVH<MDNode>(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
|
|
|
}
|
|
|
|
|
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.
|
2013-10-16 07:31:31 +08:00
|
|
|
DICompositeType
|
|
|
|
DIBuilder::createForwardDecl(unsigned Tag, StringRef Name, DIDescriptor Scope,
|
|
|
|
DIFile F, unsigned Line, unsigned RuntimeLang,
|
|
|
|
uint64_t SizeInBits, uint64_t AlignInBits,
|
|
|
|
StringRef UniqueIdentifier) {
|
2012-02-08 08:22:26 +08:00
|
|
|
// Create a temporary MDNode.
|
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, Tag),
|
2013-03-20 08:26:26 +08:00
|
|
|
F.getFileNode(),
|
2013-10-10 02:10:55 +08:00
|
|
|
DIScope(getNonCompileUnitScope(Scope)).getRef(),
|
2012-02-08 08:22:26 +08:00
|
|
|
MDString::get(VMContext, Name),
|
|
|
|
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),
|
2013-10-16 07:31:31 +08:00
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), 0), // Offset
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), DIDescriptor::FlagFwdDecl),
|
2012-02-21 02:04:14 +08:00
|
|
|
NULL,
|
|
|
|
DIArray(),
|
2013-08-17 04:42:14 +08:00
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), RuntimeLang),
|
2013-08-27 06:39:55 +08:00
|
|
|
NULL,
|
|
|
|
NULL, //TemplateParams
|
2013-08-28 07:06:40 +08:00
|
|
|
UniqueIdentifier.empty() ? NULL : MDString::get(VMContext, UniqueIdentifier)
|
2012-02-08 08:22:26 +08:00
|
|
|
};
|
|
|
|
MDNode *Node = MDNode::getTemporary(VMContext, Elts);
|
2013-08-17 04:42:14 +08:00
|
|
|
DICompositeType RetTy(Node);
|
|
|
|
assert(RetTy.isCompositeType() &&
|
2013-07-02 05:02:01 +08:00
|
|
|
"createForwardDecl result should be a DIType");
|
2013-08-30 07:17:54 +08:00
|
|
|
if (!UniqueIdentifier.empty())
|
|
|
|
retainType(RetTy);
|
2013-07-03 02:37:35 +08:00
|
|
|
return RetTy;
|
2012-02-08 08:22:26 +08:00
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2013-03-21 01:49:48 +08:00
|
|
|
/// \brief Create a new descriptor for the specified global.
|
2013-10-16 07:31:31 +08:00
|
|
|
DIGlobalVariable DIBuilder::createGlobalVariable(StringRef Name,
|
|
|
|
StringRef LinkageName,
|
|
|
|
DIFile F, unsigned LineNumber,
|
|
|
|
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),
|
2013-03-21 01:49:48 +08:00
|
|
|
MDString::get(VMContext, LinkageName),
|
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);
|
|
|
|
}
|
|
|
|
|
2013-03-21 01:49:48 +08:00
|
|
|
/// \brief Create a new descriptor for the specified global.
|
2013-10-16 07:31:31 +08:00
|
|
|
DIGlobalVariable DIBuilder::createGlobalVariable(StringRef Name, DIFile F,
|
|
|
|
unsigned LineNumber, DIType Ty,
|
|
|
|
bool isLocalToUnit,
|
|
|
|
Value *Val) {
|
2013-03-21 01:49:48 +08:00
|
|
|
return createGlobalVariable(Name, Name, F, LineNumber, Ty, isLocalToUnit,
|
|
|
|
Val);
|
|
|
|
}
|
|
|
|
|
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.
|
2013-10-16 07:31:31 +08:00
|
|
|
DIGlobalVariable DIBuilder::createStaticVariable(DIDescriptor Context,
|
|
|
|
StringRef Name,
|
|
|
|
StringRef LinkageName,
|
|
|
|
DIFile F, unsigned LineNumber,
|
|
|
|
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) {
|
2013-03-12 07:21:19 +08:00
|
|
|
DIDescriptor Context(getNonCompileUnitScope(Scope));
|
2013-07-02 05:02:01 +08:00
|
|
|
assert((!Context || Context.isScope()) &&
|
2013-03-12 07:21:19 +08:00
|
|
|
"createLocalVariable should be called with a valid Context");
|
2013-07-02 05:02:01 +08:00
|
|
|
assert(Ty.isType() &&
|
2013-03-12 07:21:19 +08:00
|
|
|
"createLocalVariable should be called with a valid type");
|
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);
|
|
|
|
}
|
2013-07-03 02:37:35 +08:00
|
|
|
DIVariable RetVar(Node);
|
|
|
|
assert(RetVar.isVariable() &&
|
2013-07-02 05:02:01 +08:00
|
|
|
"createLocalVariable should return a valid DIVariable");
|
2013-07-03 02:37:35 +08:00
|
|
|
return RetVar;
|
2010-12-08 07:58:00 +08:00
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2013-10-11 02:40:01 +08:00
|
|
|
/// createFunction - Create a new descriptor for the specified function.
|
|
|
|
/// FIXME: this is added for dragonegg. Once we update dragonegg
|
|
|
|
/// to call resolve function, this will be removed.
|
2013-10-16 07:31:31 +08:00
|
|
|
DISubprogram DIBuilder::createFunction(DIScopeRef Context, StringRef Name,
|
|
|
|
StringRef LinkageName, DIFile File,
|
|
|
|
unsigned LineNo, DICompositeType Ty,
|
2013-10-11 02:40:01 +08:00
|
|
|
bool isLocalToUnit, bool isDefinition,
|
2013-10-16 07:31:31 +08:00
|
|
|
unsigned ScopeLine, unsigned Flags,
|
|
|
|
bool isOptimized, Function *Fn,
|
|
|
|
MDNode *TParams, MDNode *Decl) {
|
2013-10-11 02:40:01 +08:00
|
|
|
// dragonegg does not generate identifier for types, so using an empty map
|
|
|
|
// to resolve the context should be fine.
|
|
|
|
DITypeIdentifierMap EmptyMap;
|
|
|
|
return createFunction(Context.resolve(EmptyMap), Name, LinkageName, File,
|
|
|
|
LineNo, Ty, isLocalToUnit, isDefinition, ScopeLine,
|
|
|
|
Flags, isOptimized, Fn, TParams, Decl);
|
|
|
|
}
|
|
|
|
|
2011-02-23 02:56:12 +08:00
|
|
|
/// createFunction - Create a new descriptor for the specified function.
|
2013-10-16 07:31:31 +08:00
|
|
|
DISubprogram DIBuilder::createFunction(DIDescriptor Context, StringRef Name,
|
|
|
|
StringRef LinkageName, DIFile File,
|
|
|
|
unsigned LineNo, DICompositeType Ty,
|
2010-12-09 04:42:44 +08:00
|
|
|
bool isLocalToUnit, bool isDefinition,
|
2013-10-16 07:31:31 +08:00
|
|
|
unsigned ScopeLine, unsigned Flags,
|
|
|
|
bool isOptimized, Function *Fn,
|
|
|
|
MDNode *TParams, MDNode *Decl) {
|
2013-05-23 07:22:18 +08:00
|
|
|
assert(Ty.getTag() == dwarf::DW_TAG_subroutine_type &&
|
|
|
|
"function types should be subroutines");
|
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),
|
2013-03-22 07:08:34 +08:00
|
|
|
File.getFileNode(),
|
2013-10-11 02:40:01 +08:00
|
|
|
DIScope(getNonCompileUnitScope(Context)).getRef(),
|
2010-12-09 04:42:44 +08:00
|
|
|
MDString::get(VMContext, Name),
|
|
|
|
MDString::get(VMContext, Name),
|
|
|
|
MDString::get(VMContext, LinkageName),
|
|
|
|
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.
|
2013-02-18 15:10:22 +08:00
|
|
|
if (isDefinition)
|
|
|
|
AllSubprograms.push_back(Node);
|
2013-03-22 04:28:52 +08:00
|
|
|
DISubprogram S(Node);
|
2013-07-02 05:02:01 +08:00
|
|
|
assert(S.isSubprogram() && "createFunction should return a valid DISubprogram");
|
2013-03-22 04:28:52 +08:00
|
|
|
return S;
|
2010-12-09 04:42:44 +08:00
|
|
|
}
|
|
|
|
|
2011-02-23 02:56:12 +08:00
|
|
|
/// createMethod - Create a new descriptor for the specified C++ method.
|
2013-10-16 07:31:31 +08:00
|
|
|
DISubprogram DIBuilder::createMethod(DIDescriptor Context, StringRef Name,
|
|
|
|
StringRef LinkageName, DIFile F,
|
2013-05-23 07:22:18 +08:00
|
|
|
unsigned LineNo, DICompositeType Ty,
|
2013-10-16 07:31:31 +08:00
|
|
|
bool isLocalToUnit, bool isDefinition,
|
2010-12-09 04:42:44 +08:00
|
|
|
unsigned VK, unsigned VIndex,
|
2013-10-16 07:31:31 +08:00
|
|
|
DIType VTableHolder, unsigned Flags,
|
|
|
|
bool isOptimized, Function *Fn,
|
2011-04-06 06:52:06 +08:00
|
|
|
MDNode *TParam) {
|
2013-05-23 07:22:18 +08:00
|
|
|
assert(Ty.getTag() == dwarf::DW_TAG_subroutine_type &&
|
|
|
|
"function types should be subroutines");
|
2013-10-16 07:31:36 +08:00
|
|
|
assert(getNonCompileUnitScope(Context) &&
|
|
|
|
"Methods should have both a Context and a context that isn't "
|
|
|
|
"the compile unit.");
|
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),
|
2013-03-22 07:08:34 +08:00
|
|
|
F.getFileNode(),
|
2013-10-16 07:31:36 +08:00
|
|
|
DIScope(Context).getRef(),
|
2010-12-09 04:42:44 +08:00
|
|
|
MDString::get(VMContext, Name),
|
|
|
|
MDString::get(VMContext, Name),
|
|
|
|
MDString::get(VMContext, LinkageName),
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), LineNo),
|
|
|
|
Ty,
|
|
|
|
ConstantInt::get(Type::getInt1Ty(VMContext), isLocalToUnit),
|
|
|
|
ConstantInt::get(Type::getInt1Ty(VMContext), isDefinition),
|
2013-10-16 07:31:31 +08:00
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), VK),
|
2010-12-09 04:42:44 +08:00
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), VIndex),
|
2013-10-01 03:42:10 +08:00
|
|
|
VTableHolder.getRef(),
|
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,
|
|
|
|
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);
|
2013-02-18 15:10:22 +08:00
|
|
|
if (isDefinition)
|
|
|
|
AllSubprograms.push_back(Node);
|
2013-03-22 04:28:52 +08:00
|
|
|
DISubprogram S(Node);
|
2013-07-02 05:02:01 +08:00
|
|
|
assert(S.isSubprogram() && "createMethod should return a valid DISubprogram");
|
2013-03-22 04:28:52 +08:00
|
|
|
return S;
|
2010-12-09 04:42:44 +08:00
|
|
|
}
|
|
|
|
|
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),
|
2013-03-21 03:39:15 +08:00
|
|
|
File.getFileNode(),
|
2011-08-17 06:09:43 +08:00
|
|
|
getNonCompileUnitScope(Scope),
|
2010-12-08 07:25:47 +08:00
|
|
|
MDString::get(VMContext, Name),
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), LineNo)
|
|
|
|
};
|
2013-03-12 07:21:19 +08:00
|
|
|
DINameSpace R(MDNode::get(VMContext, Elts));
|
|
|
|
assert(R.Verify() &&
|
|
|
|
"createNameSpace should return a verifiable DINameSpace");
|
|
|
|
return R;
|
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),
|
2013-03-23 04:18:46 +08:00
|
|
|
File.getFileNode(),
|
2013-03-23 03:13:22 +08:00
|
|
|
Scope
|
2011-10-12 06:59:11 +08:00
|
|
|
};
|
2013-03-12 07:21:19 +08:00
|
|
|
DILexicalBlockFile R(MDNode::get(VMContext, Elts));
|
|
|
|
assert(
|
|
|
|
R.Verify() &&
|
|
|
|
"createLexicalBlockFile should return a verifiable DILexicalBlockFile");
|
|
|
|
return R;
|
2011-10-12 06:59:11 +08:00
|
|
|
}
|
|
|
|
|
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) {
|
2013-06-25 05:19:43 +08:00
|
|
|
// Defeat MDNode uniquing for lexical blocks by using unique id.
|
2010-12-08 09:50:15 +08:00
|
|
|
static unsigned int unique_id = 0;
|
|
|
|
Value *Elts[] = {
|
|
|
|
GetTagConstant(VMContext, dwarf::DW_TAG_lexical_block),
|
2013-03-23 01:33:20 +08:00
|
|
|
File.getFileNode(),
|
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),
|
|
|
|
ConstantInt::get(Type::getInt32Ty(VMContext), unique_id++)
|
|
|
|
};
|
2013-03-12 07:21:19 +08:00
|
|
|
DILexicalBlock R(MDNode::get(VMContext, Elts));
|
|
|
|
assert(R.Verify() &&
|
|
|
|
"createLexicalBlock should return a verifiable DILexicalBlock");
|
|
|
|
return R;
|
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");
|
2013-06-29 13:01:19 +08:00
|
|
|
assert(VarInfo.isVariable() &&
|
|
|
|
"empty or invalid DIVariable passed to dbg.declare");
|
2010-12-08 07:25:47 +08:00
|
|
|
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");
|
2013-06-29 13:01:19 +08:00
|
|
|
assert(VarInfo.isVariable() &&
|
|
|
|
"empty or invalid DIVariable passed to dbg.declare");
|
2010-12-08 07:25:47 +08:00
|
|
|
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");
|
2013-06-29 13:01:19 +08:00
|
|
|
assert(VarInfo.isVariable() &&
|
|
|
|
"empty or invalid DIVariable passed to dbg.value");
|
2010-12-08 07:25:47 +08:00
|
|
|
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");
|
2013-06-29 13:01:19 +08:00
|
|
|
assert(VarInfo.isVariable() &&
|
|
|
|
"empty or invalid DIVariable passed to dbg.value");
|
2010-12-08 07:25:47 +08:00
|
|
|
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
|
|
|
}
|