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);
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118248 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-04 15:01:38 +00: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.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2014-03-06 00:22:06 +00:00
|
|
|
#include "llvm/IR/DIBuilder.h"
|
2012-12-03 16:50:05 +00:00
|
|
|
#include "llvm/ADT/STLExtras.h"
|
2013-01-02 11:36:10 +00:00
|
|
|
#include "llvm/IR/Constants.h"
|
2014-03-06 00:46:21 +00:00
|
|
|
#include "llvm/IR/DebugInfo.h"
|
2013-01-02 11:36:10 +00:00
|
|
|
#include "llvm/IR/IntrinsicInst.h"
|
|
|
|
#include "llvm/IR/Module.h"
|
2012-04-03 00:43:49 +00: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);
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118248 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-04 15:01:38 +00:00
|
|
|
#include "llvm/Support/Dwarf.h"
|
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
using namespace llvm::dwarf;
|
|
|
|
|
2014-10-03 20:01:09 +00:00
|
|
|
namespace {
|
|
|
|
class HeaderBuilder {
|
|
|
|
SmallVector<char, 256> Chars;
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit HeaderBuilder(Twine T) { T.toVector(Chars); }
|
|
|
|
HeaderBuilder(const HeaderBuilder &X) : Chars(X.Chars) {}
|
|
|
|
HeaderBuilder(HeaderBuilder &&X) : Chars(std::move(X.Chars)) {}
|
|
|
|
|
|
|
|
template <class Twineable> HeaderBuilder &concat(Twineable &&X) {
|
|
|
|
Chars.push_back(0);
|
|
|
|
Twine(X).toVector(Chars);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
MDString *get(LLVMContext &Context) const {
|
|
|
|
return MDString::get(Context, StringRef(Chars.begin(), Chars.size()));
|
|
|
|
}
|
|
|
|
|
|
|
|
static HeaderBuilder get(unsigned Tag) {
|
|
|
|
return HeaderBuilder("0x" + Twine::utohexstr(Tag));
|
|
|
|
}
|
|
|
|
};
|
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);
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118248 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-04 15:01:38 +00:00
|
|
|
}
|
2010-12-07 23:58:00 +00: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);
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118248 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-04 15:01:38 +00:00
|
|
|
DIBuilder::DIBuilder(Module &m)
|
2014-04-09 06:08:46 +00:00
|
|
|
: M(m), VMContext(M.getContext()), TempEnumTypes(nullptr),
|
|
|
|
TempRetainTypes(nullptr), TempSubprograms(nullptr), TempGVs(nullptr),
|
|
|
|
DeclareFn(nullptr), ValueFn(nullptr) {}
|
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);
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118248 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-04 15:01:38 +00:00
|
|
|
|
2011-08-15 23:00:00 +00:00
|
|
|
void DIBuilder::finalize() {
|
2011-08-16 22:09:43 +00:00
|
|
|
DIArray Enums = getOrCreateArray(AllEnumTypes);
|
|
|
|
DIType(TempEnumTypes).replaceAllUsesWith(Enums);
|
|
|
|
|
2013-08-29 23:17:54 +00: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-16 22:09:43 +00:00
|
|
|
DIType(TempRetainTypes).replaceAllUsesWith(RetainTypes);
|
|
|
|
|
|
|
|
DIArray SPs = getOrCreateArray(AllSubprograms);
|
|
|
|
DIType(TempSubprograms).replaceAllUsesWith(SPs);
|
2011-08-19 23:28:12 +00:00
|
|
|
for (unsigned i = 0, e = SPs.getNumElements(); i != e; ++i) {
|
|
|
|
DISubprogram SP(SPs.getElement(i));
|
2012-04-23 19:00:11 +00:00
|
|
|
if (MDNode *Temp = SP.getVariablesNodes()) {
|
2014-10-15 16:11:41 +00:00
|
|
|
SmallVector<Value *, 4> Variables;
|
|
|
|
for (Value *V : PreservedVariables.lookup(SP))
|
|
|
|
Variables.push_back(V);
|
2012-04-23 19:00:11 +00:00
|
|
|
DIArray AV = getOrCreateArray(Variables);
|
|
|
|
DIType(Temp).replaceAllUsesWith(AV);
|
|
|
|
}
|
2011-08-19 23:28:12 +00:00
|
|
|
}
|
2011-08-16 22:09:43 +00:00
|
|
|
|
|
|
|
DIArray GVs = getOrCreateArray(AllGVs);
|
|
|
|
DIType(TempGVs).replaceAllUsesWith(GVs);
|
2013-04-22 06:12:31 +00:00
|
|
|
|
2014-02-28 21:27:57 +00:00
|
|
|
SmallVector<Value *, 16> RetainValuesI;
|
|
|
|
for (unsigned I = 0, E = AllImportedModules.size(); I < E; I++)
|
|
|
|
RetainValuesI.push_back(AllImportedModules[I]);
|
|
|
|
DIArray IMs = getOrCreateArray(RetainValuesI);
|
2013-04-22 06:12:31 +00:00
|
|
|
DIType(TempImportedModules).replaceAllUsesWith(IMs);
|
2011-08-16 22:09:43 +00:00
|
|
|
}
|
|
|
|
|
2014-10-01 21:32:15 +00:00
|
|
|
/// If N is compile unit return NULL otherwise return N.
|
2011-08-16 22:09:43 +00:00
|
|
|
static MDNode *getNonCompileUnitScope(MDNode *N) {
|
|
|
|
if (DIDescriptor(N).isCompileUnit())
|
2014-04-09 06:08:46 +00:00
|
|
|
return nullptr;
|
2011-08-16 22:09:43 +00:00
|
|
|
return N;
|
2011-08-15 23:00:00 +00:00
|
|
|
}
|
|
|
|
|
2013-03-20 23:58:12 +00: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-15 23:31:31 +00:00
|
|
|
MDString::get(VMContext, Directory)
|
2013-03-20 23:58:12 +00:00
|
|
|
};
|
|
|
|
return MDNode::get(VMContext, Pair);
|
|
|
|
}
|
|
|
|
|
2013-07-19 00:51:47 +00:00
|
|
|
DICompileUnit DIBuilder::createCompileUnit(unsigned Lang, StringRef Filename,
|
|
|
|
StringRef Directory,
|
|
|
|
StringRef Producer, bool isOptimized,
|
|
|
|
StringRef Flags, unsigned RunTimeVer,
|
2014-02-27 01:24:56 +00:00
|
|
|
StringRef SplitName,
|
2014-06-24 17:02:03 +00:00
|
|
|
DebugEmissionKind Kind,
|
|
|
|
bool EmitDebugInfo) {
|
2014-02-27 01:24:56 +00:00
|
|
|
|
2014-04-28 18:11:01 +00:00
|
|
|
assert(((Lang <= dwarf::DW_LANG_OCaml && Lang >= dwarf::DW_LANG_C89) ||
|
2012-01-10 18:18:52 +00:00
|
|
|
(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");
|
2014-10-03 20:01:09 +00:00
|
|
|
Value *TElts[] = {HeaderBuilder::get(DW_TAG_base_type).get(VMContext)};
|
2011-08-16 22:09:43 +00:00
|
|
|
TempEnumTypes = MDNode::getTemporary(VMContext, TElts);
|
|
|
|
|
|
|
|
TempRetainTypes = MDNode::getTemporary(VMContext, TElts);
|
|
|
|
|
|
|
|
TempSubprograms = MDNode::getTemporary(VMContext, TElts);
|
|
|
|
|
|
|
|
TempGVs = MDNode::getTemporary(VMContext, TElts);
|
|
|
|
|
2013-04-22 06:12:31 +00:00
|
|
|
TempImportedModules = MDNode::getTemporary(VMContext, TElts);
|
|
|
|
|
2014-10-03 20:01:09 +00:00
|
|
|
Value *Elts[] = {HeaderBuilder::get(dwarf::DW_TAG_compile_unit)
|
|
|
|
.concat(Lang)
|
|
|
|
.concat(Producer)
|
|
|
|
.concat(isOptimized)
|
|
|
|
.concat(Flags)
|
|
|
|
.concat(RunTimeVer)
|
|
|
|
.concat(SplitName)
|
|
|
|
.concat(Kind)
|
|
|
|
.get(VMContext),
|
|
|
|
createFilePathPair(VMContext, Filename, Directory),
|
|
|
|
TempEnumTypes, TempRetainTypes, TempSubprograms, TempGVs,
|
|
|
|
TempImportedModules};
|
2013-07-19 00:51:47 +00:00
|
|
|
|
|
|
|
MDNode *CUNode = MDNode::get(VMContext, Elts);
|
2011-05-03 16:18:28 +00:00
|
|
|
|
|
|
|
// Create a named metadata so that it is easier to find cu in a module.
|
2014-06-24 17:02:03 +00:00
|
|
|
// Note that we only generate this when the caller wants to actually
|
|
|
|
// emit debug information. When we are only interested in tracking
|
|
|
|
// source line locations throughout the backend, we prevent codegen from
|
|
|
|
// emitting debug info in the final output by not generating llvm.dbg.cu.
|
|
|
|
if (EmitDebugInfo) {
|
|
|
|
NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.cu");
|
|
|
|
NMD->addOperand(CUNode);
|
|
|
|
}
|
2013-07-19 00:51:47 +00:00
|
|
|
|
|
|
|
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);
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118248 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-04 15:01:38 +00:00
|
|
|
}
|
|
|
|
|
2013-05-20 22:50:35 +00:00
|
|
|
static DIImportedEntity
|
2014-04-06 06:29:01 +00:00
|
|
|
createImportedModule(LLVMContext &C, dwarf::Tag Tag, DIScope Context,
|
|
|
|
Value *NS, unsigned Line, StringRef Name,
|
|
|
|
SmallVectorImpl<TrackingVH<MDNode>> &AllImportedModules) {
|
2013-05-20 22:50:35 +00:00
|
|
|
const MDNode *R;
|
2014-10-03 20:01:09 +00:00
|
|
|
Value *Elts[] = {HeaderBuilder::get(Tag).concat(Line).concat(Name).get(C),
|
|
|
|
Context, NS};
|
|
|
|
R = MDNode::get(C, Elts);
|
2013-05-20 22:50:35 +00:00
|
|
|
DIImportedEntity M(R);
|
2013-05-07 21:35:53 +00:00
|
|
|
assert(M.Verify() && "Imported module should be valid");
|
2014-02-28 21:27:57 +00:00
|
|
|
AllImportedModules.push_back(TrackingVH<MDNode>(M));
|
2013-05-07 21:35:53 +00:00
|
|
|
return M;
|
|
|
|
}
|
|
|
|
|
2013-05-20 22:50:35 +00:00
|
|
|
DIImportedEntity DIBuilder::createImportedModule(DIScope Context,
|
2014-04-06 06:29:01 +00:00
|
|
|
DINameSpace NS,
|
|
|
|
unsigned Line) {
|
|
|
|
return ::createImportedModule(VMContext, dwarf::DW_TAG_imported_module,
|
|
|
|
Context, NS, Line, StringRef(), AllImportedModules);
|
2013-05-20 22:50:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DIImportedEntity DIBuilder::createImportedModule(DIScope Context,
|
|
|
|
DIImportedEntity NS,
|
2014-04-06 06:29:01 +00:00
|
|
|
unsigned Line) {
|
|
|
|
return ::createImportedModule(VMContext, dwarf::DW_TAG_imported_module,
|
|
|
|
Context, NS, Line, StringRef(), AllImportedModules);
|
2013-05-20 22:50:35 +00:00
|
|
|
}
|
|
|
|
|
2013-05-07 21:35:53 +00:00
|
|
|
DIImportedEntity DIBuilder::createImportedDeclaration(DIScope Context,
|
2014-04-01 03:41:04 +00:00
|
|
|
DIScope Decl,
|
2014-04-06 06:29:01 +00:00
|
|
|
unsigned Line, StringRef Name) {
|
|
|
|
return ::createImportedModule(VMContext, dwarf::DW_TAG_imported_declaration,
|
|
|
|
Context, Decl.getRef(), Line, Name,
|
|
|
|
AllImportedModules);
|
|
|
|
}
|
|
|
|
|
|
|
|
DIImportedEntity DIBuilder::createImportedDeclaration(DIScope Context,
|
|
|
|
DIImportedEntity Imp,
|
|
|
|
unsigned Line, StringRef Name) {
|
|
|
|
return ::createImportedModule(VMContext, dwarf::DW_TAG_imported_declaration,
|
|
|
|
Context, Imp, Line, Name, AllImportedModules);
|
2013-04-22 06:12:31 +00:00
|
|
|
}
|
|
|
|
|
2011-02-22 18:56:12 +00:00
|
|
|
DIFile DIBuilder::createFile(StringRef Filename, StringRef Directory) {
|
2014-10-03 20:01:09 +00:00
|
|
|
Value *Elts[] = {HeaderBuilder::get(dwarf::DW_TAG_file_type).get(VMContext),
|
|
|
|
createFilePathPair(VMContext, Filename, Directory)};
|
2013-03-28 02:44:59 +00: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);
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118248 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-04 15:01:38 +00:00
|
|
|
}
|
|
|
|
|
2013-06-24 17:34:33 +00:00
|
|
|
DIEnumerator DIBuilder::createEnumerator(StringRef Name, int64_t Val) {
|
2011-09-12 18:26:08 +00:00
|
|
|
assert(!Name.empty() && "Unable to create enumerator without name");
|
2010-11-04 18:45:27 +00:00
|
|
|
Value *Elts[] = {
|
2014-10-03 20:01:09 +00:00
|
|
|
HeaderBuilder::get(dwarf::DW_TAG_enumerator).concat(Name).concat(Val).get(
|
|
|
|
VMContext)};
|
2013-03-28 02:44:59 +00: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);
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118248 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-04 15:01:38 +00:00
|
|
|
}
|
|
|
|
|
2013-06-27 22:50:59 +00:00
|
|
|
DIBasicType DIBuilder::createUnspecifiedType(StringRef Name) {
|
2011-09-14 23:13:28 +00:00
|
|
|
assert(!Name.empty() && "Unable to create type without name");
|
2013-06-27 22:50:59 +00:00
|
|
|
// Unspecified types are encoded in DIBasicType format. Line number, filename,
|
|
|
|
// size, alignment, offset and flags are always empty here.
|
2011-09-14 23:13:28 +00:00
|
|
|
Value *Elts[] = {
|
2014-10-03 20:01:09 +00:00
|
|
|
HeaderBuilder::get(dwarf::DW_TAG_unspecified_type)
|
|
|
|
.concat(Name)
|
|
|
|
.concat(0)
|
|
|
|
.concat(0)
|
|
|
|
.concat(0)
|
|
|
|
.concat(0)
|
|
|
|
.concat(0)
|
|
|
|
.concat(0)
|
|
|
|
.get(VMContext),
|
|
|
|
nullptr, // Filename
|
|
|
|
nullptr // Unused
|
2011-09-14 23:13:28 +00:00
|
|
|
};
|
2013-06-07 18:35:53 +00:00
|
|
|
return DIBasicType(MDNode::get(VMContext, Elts));
|
2011-09-14 23:13:28 +00:00
|
|
|
}
|
|
|
|
|
2013-06-27 22:50:59 +00:00
|
|
|
DIBasicType DIBuilder::createNullPtrType() {
|
|
|
|
return createUnspecifiedType("decltype(nullptr)");
|
|
|
|
}
|
|
|
|
|
2013-02-12 00:40:41 +00:00
|
|
|
DIBasicType
|
|
|
|
DIBuilder::createBasicType(StringRef Name, uint64_t SizeInBits,
|
|
|
|
uint64_t AlignInBits, unsigned Encoding) {
|
2011-09-12 18:26:08 +00: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);
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118248 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-04 15:01:38 +00:00
|
|
|
// Basic types are encoded in DIBasicType format. Line number, filename,
|
|
|
|
// offset and flags are always empty here.
|
2010-11-04 18:45:27 +00:00
|
|
|
Value *Elts[] = {
|
2014-10-03 20:01:09 +00:00
|
|
|
HeaderBuilder::get(dwarf::DW_TAG_base_type)
|
|
|
|
.concat(Name)
|
|
|
|
.concat(0) // Line
|
|
|
|
.concat(SizeInBits)
|
|
|
|
.concat(AlignInBits)
|
|
|
|
.concat(0) // Offset
|
|
|
|
.concat(0) // Flags
|
|
|
|
.concat(Encoding)
|
|
|
|
.get(VMContext),
|
|
|
|
nullptr, // Filename
|
|
|
|
nullptr // Unused
|
2010-11-04 18:45:27 +00:00
|
|
|
};
|
2013-03-28 02:44:59 +00: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);
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118248 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-04 15:01:38 +00:00
|
|
|
}
|
|
|
|
|
2013-02-18 06:41:57 +00:00
|
|
|
DIDerivedType DIBuilder::createQualifiedType(unsigned Tag, DIType FromTy) {
|
2010-11-04 18:45:27 +00:00
|
|
|
// Qualified types are encoded in DIDerivedType format.
|
2014-10-03 20:01:09 +00:00
|
|
|
Value *Elts[] = {HeaderBuilder::get(Tag)
|
|
|
|
.concat(StringRef()) // Name
|
|
|
|
.concat(0) // Line
|
|
|
|
.concat(0) // Size
|
|
|
|
.concat(0) // Align
|
|
|
|
.concat(0) // Offset
|
|
|
|
.concat(0) // Flags
|
|
|
|
.get(VMContext),
|
|
|
|
nullptr, // Filename
|
|
|
|
nullptr, // Unused
|
|
|
|
FromTy.getRef()};
|
2013-03-28 02:44:59 +00: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);
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118248 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-04 15:01:38 +00:00
|
|
|
}
|
|
|
|
|
2013-02-18 06:41:57 +00:00
|
|
|
DIDerivedType
|
|
|
|
DIBuilder::createPointerType(DIType PointeeTy, uint64_t SizeInBits,
|
|
|
|
uint64_t AlignInBits, StringRef Name) {
|
2010-11-04 18:45:27 +00:00
|
|
|
// Pointer types are encoded in DIDerivedType format.
|
2014-10-03 20:01:09 +00:00
|
|
|
Value *Elts[] = {HeaderBuilder::get(dwarf::DW_TAG_pointer_type)
|
|
|
|
.concat(Name)
|
|
|
|
.concat(0) // Line
|
|
|
|
.concat(SizeInBits)
|
|
|
|
.concat(AlignInBits)
|
|
|
|
.concat(0) // Offset
|
|
|
|
.concat(0) // Flags
|
|
|
|
.get(VMContext),
|
|
|
|
nullptr, // Filename
|
|
|
|
nullptr, // Unused
|
|
|
|
PointeeTy.getRef()};
|
2013-03-28 02:44:59 +00: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);
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118248 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-04 15:01:38 +00:00
|
|
|
}
|
|
|
|
|
2013-04-19 20:37:12 +00:00
|
|
|
DIDerivedType DIBuilder::createMemberPointerType(DIType PointeeTy,
|
|
|
|
DIType Base) {
|
2013-01-07 05:51:15 +00:00
|
|
|
// Pointer types are encoded in DIDerivedType format.
|
2014-10-03 20:01:09 +00:00
|
|
|
Value *Elts[] = {HeaderBuilder::get(dwarf::DW_TAG_ptr_to_member_type)
|
|
|
|
.concat(StringRef())
|
|
|
|
.concat(0) // Line
|
|
|
|
.concat(0) // Size
|
|
|
|
.concat(0) // Align
|
|
|
|
.concat(0) // Offset
|
|
|
|
.concat(0) // Flags
|
|
|
|
.get(VMContext),
|
|
|
|
nullptr, // Filename
|
|
|
|
nullptr, // Unused
|
|
|
|
PointeeTy.getRef(), Base.getRef()};
|
2013-03-28 02:44:59 +00:00
|
|
|
return DIDerivedType(MDNode::get(VMContext, Elts));
|
2013-01-07 05:51:15 +00:00
|
|
|
}
|
|
|
|
|
2013-02-18 06:41:57 +00:00
|
|
|
DIDerivedType DIBuilder::createReferenceType(unsigned Tag, DIType RTy) {
|
2013-07-01 21:02:01 +00:00
|
|
|
assert(RTy.isType() && "Unable to create reference type");
|
2010-11-04 18:45:27 +00:00
|
|
|
// References are encoded in DIDerivedType format.
|
2014-10-03 20:01:09 +00:00
|
|
|
Value *Elts[] = {HeaderBuilder::get(Tag)
|
|
|
|
.concat(StringRef()) // Name
|
|
|
|
.concat(0) // Line
|
|
|
|
.concat(0) // Size
|
|
|
|
.concat(0) // Align
|
|
|
|
.concat(0) // Offset
|
|
|
|
.concat(0) // Flags
|
|
|
|
.get(VMContext),
|
|
|
|
nullptr, // Filename
|
|
|
|
nullptr, // TheCU,
|
|
|
|
RTy.getRef()};
|
2013-03-28 02:44:59 +00: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);
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118248 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-04 15:01:38 +00:00
|
|
|
}
|
|
|
|
|
2013-02-18 06:41:57 +00:00
|
|
|
DIDerivedType DIBuilder::createTypedef(DIType Ty, StringRef Name, DIFile File,
|
|
|
|
unsigned LineNo, DIDescriptor Context) {
|
2010-11-04 18:45:27 +00:00
|
|
|
// typedefs are encoded in DIDerivedType format.
|
2014-10-03 20:01:09 +00:00
|
|
|
Value *Elts[] = {HeaderBuilder::get(dwarf::DW_TAG_typedef)
|
|
|
|
.concat(Name)
|
|
|
|
.concat(LineNo)
|
|
|
|
.concat(0) // Size
|
|
|
|
.concat(0) // Align
|
|
|
|
.concat(0) // Offset
|
|
|
|
.concat(0) // Flags
|
|
|
|
.get(VMContext),
|
|
|
|
File.getFileNode(),
|
|
|
|
DIScope(getNonCompileUnitScope(Context)).getRef(),
|
|
|
|
Ty.getRef()};
|
2013-03-28 02:44:59 +00: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);
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118248 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-04 15:01:38 +00:00
|
|
|
}
|
|
|
|
|
2013-06-07 18:35:53 +00:00
|
|
|
DIDerivedType DIBuilder::createFriend(DIType Ty, DIType FriendTy) {
|
2010-11-04 18:45:27 +00:00
|
|
|
// typedefs are encoded in DIDerivedType format.
|
2013-07-01 21:02:01 +00:00
|
|
|
assert(Ty.isType() && "Invalid type!");
|
|
|
|
assert(FriendTy.isType() && "Invalid friend type!");
|
2014-10-03 20:01:09 +00:00
|
|
|
Value *Elts[] = {HeaderBuilder::get(dwarf::DW_TAG_friend)
|
|
|
|
.concat(StringRef()) // Name
|
|
|
|
.concat(0) // Line
|
|
|
|
.concat(0) // Size
|
|
|
|
.concat(0) // Align
|
|
|
|
.concat(0) // Offset
|
|
|
|
.concat(0) // Flags
|
|
|
|
.get(VMContext),
|
|
|
|
nullptr, Ty.getRef(), FriendTy.getRef()};
|
2013-06-07 18:35:53 +00: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);
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118248 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-04 15:01:38 +00:00
|
|
|
}
|
|
|
|
|
2013-10-15 23:31:31 +00:00
|
|
|
DIDerivedType DIBuilder::createInheritance(DIType Ty, DIType BaseTy,
|
|
|
|
uint64_t BaseOffset,
|
|
|
|
unsigned Flags) {
|
2013-07-01 21:02:01 +00:00
|
|
|
assert(Ty.isType() && "Unable to create inheritance");
|
2010-11-04 18:45:27 +00:00
|
|
|
// TAG_inheritance is encoded in DIDerivedType format.
|
2014-10-03 20:01:09 +00:00
|
|
|
Value *Elts[] = {HeaderBuilder::get(dwarf::DW_TAG_inheritance)
|
|
|
|
.concat(StringRef()) // Name
|
|
|
|
.concat(0) // Line
|
|
|
|
.concat(0) // Size
|
|
|
|
.concat(0) // Align
|
|
|
|
.concat(BaseOffset)
|
|
|
|
.concat(Flags)
|
|
|
|
.get(VMContext),
|
|
|
|
nullptr, Ty.getRef(), BaseTy.getRef()};
|
2013-03-28 02:44:59 +00: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);
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118248 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-04 15:01:38 +00:00
|
|
|
}
|
|
|
|
|
2013-10-15 23:31:31 +00: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-04 18:45:27 +00:00
|
|
|
// TAG_member is encoded in DIDerivedType format.
|
2014-10-03 20:01:09 +00:00
|
|
|
Value *Elts[] = {HeaderBuilder::get(dwarf::DW_TAG_member)
|
|
|
|
.concat(Name)
|
|
|
|
.concat(LineNumber)
|
|
|
|
.concat(SizeInBits)
|
|
|
|
.concat(AlignInBits)
|
|
|
|
.concat(OffsetInBits)
|
|
|
|
.concat(Flags)
|
|
|
|
.get(VMContext),
|
|
|
|
File.getFileNode(),
|
|
|
|
DIScope(getNonCompileUnitScope(Scope)).getRef(),
|
|
|
|
Ty.getRef()};
|
2013-03-28 02:44:59 +00: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);
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118248 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-04 15:01:38 +00:00
|
|
|
}
|
|
|
|
|
2013-06-07 18:35:53 +00:00
|
|
|
DIDerivedType
|
|
|
|
DIBuilder::createStaticMemberType(DIDescriptor Scope, StringRef Name,
|
|
|
|
DIFile File, unsigned LineNumber,
|
|
|
|
DIType Ty, unsigned Flags,
|
|
|
|
llvm::Value *Val) {
|
2013-01-16 01:22:23 +00:00
|
|
|
// TAG_member is encoded in DIDerivedType format.
|
|
|
|
Flags |= DIDescriptor::FlagStaticMember;
|
2014-10-03 20:01:09 +00:00
|
|
|
Value *Elts[] = {HeaderBuilder::get(dwarf::DW_TAG_member)
|
|
|
|
.concat(Name)
|
|
|
|
.concat(LineNumber)
|
|
|
|
.concat(0) // Size
|
|
|
|
.concat(0) // Align
|
|
|
|
.concat(0) // Offset
|
|
|
|
.concat(Flags)
|
|
|
|
.get(VMContext),
|
|
|
|
File.getFileNode(),
|
|
|
|
DIScope(getNonCompileUnitScope(Scope)).getRef(), Ty.getRef(),
|
|
|
|
Val};
|
2013-06-07 18:35:53 +00:00
|
|
|
return DIDerivedType(MDNode::get(VMContext, Elts));
|
2013-01-16 01:22:23 +00:00
|
|
|
}
|
|
|
|
|
2013-10-15 23:31:31 +00: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-06 17:49:43 +00:00
|
|
|
// TAG_member is encoded in DIDerivedType format.
|
2014-10-03 20:01:09 +00:00
|
|
|
Value *Elts[] = {HeaderBuilder::get(dwarf::DW_TAG_member)
|
|
|
|
.concat(Name)
|
|
|
|
.concat(LineNumber)
|
|
|
|
.concat(SizeInBits)
|
|
|
|
.concat(AlignInBits)
|
|
|
|
.concat(OffsetInBits)
|
|
|
|
.concat(Flags)
|
|
|
|
.get(VMContext),
|
|
|
|
File.getFileNode(), getNonCompileUnitScope(File), Ty,
|
|
|
|
PropertyNode};
|
2013-06-07 18:35:53 +00:00
|
|
|
return DIDerivedType(MDNode::get(VMContext, Elts));
|
2011-04-16 00:11:51 +00:00
|
|
|
}
|
|
|
|
|
2013-10-15 23:31:31 +00:00
|
|
|
DIObjCProperty
|
|
|
|
DIBuilder::createObjCProperty(StringRef Name, DIFile File, unsigned LineNumber,
|
|
|
|
StringRef GetterName, StringRef SetterName,
|
|
|
|
unsigned PropertyAttributes, DIType Ty) {
|
2014-10-03 20:01:09 +00:00
|
|
|
Value *Elts[] = {HeaderBuilder::get(dwarf::DW_TAG_APPLE_property)
|
|
|
|
.concat(Name)
|
|
|
|
.concat(LineNumber)
|
|
|
|
.concat(GetterName)
|
|
|
|
.concat(SetterName)
|
|
|
|
.concat(PropertyAttributes)
|
|
|
|
.get(VMContext),
|
|
|
|
File, Ty};
|
2013-03-28 02:44:59 +00:00
|
|
|
return DIObjCProperty(MDNode::get(VMContext, Elts));
|
2012-02-04 00:59:25 +00:00
|
|
|
}
|
|
|
|
|
2011-08-26 21:02:40 +00:00
|
|
|
DITemplateTypeParameter
|
2011-02-22 18:56:12 +00:00
|
|
|
DIBuilder::createTemplateTypeParameter(DIDescriptor Context, StringRef Name,
|
2011-02-02 21:38:25 +00:00
|
|
|
DIType Ty, MDNode *File, unsigned LineNo,
|
|
|
|
unsigned ColumnNo) {
|
2014-10-03 20:01:09 +00:00
|
|
|
Value *Elts[] = {HeaderBuilder::get(dwarf::DW_TAG_template_type_parameter)
|
|
|
|
.concat(Name)
|
|
|
|
.concat(LineNo)
|
|
|
|
.concat(ColumnNo)
|
|
|
|
.get(VMContext),
|
|
|
|
DIScope(getNonCompileUnitScope(Context)).getRef(),
|
|
|
|
Ty.getRef(), File};
|
2013-03-28 02:44:59 +00:00
|
|
|
return DITemplateTypeParameter(MDNode::get(VMContext, Elts));
|
2011-02-02 21:38:25 +00:00
|
|
|
}
|
|
|
|
|
2011-08-26 21:02:40 +00:00
|
|
|
DITemplateValueParameter
|
2013-06-22 18:59:11 +00:00
|
|
|
DIBuilder::createTemplateValueParameter(unsigned Tag, DIDescriptor Context,
|
|
|
|
StringRef Name, DIType Ty,
|
|
|
|
Value *Val, MDNode *File,
|
|
|
|
unsigned LineNo,
|
2011-02-02 22:35:53 +00:00
|
|
|
unsigned ColumnNo) {
|
|
|
|
Value *Elts[] = {
|
2014-10-03 20:01:09 +00:00
|
|
|
HeaderBuilder::get(Tag).concat(Name).concat(LineNo).concat(ColumnNo).get(
|
|
|
|
VMContext),
|
|
|
|
DIScope(getNonCompileUnitScope(Context)).getRef(), Ty.getRef(), Val,
|
|
|
|
File};
|
2013-03-28 02:44:59 +00:00
|
|
|
return DITemplateValueParameter(MDNode::get(VMContext, Elts));
|
2011-02-02 22:35:53 +00:00
|
|
|
}
|
|
|
|
|
2013-06-22 18:59:11 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2013-03-26 23:46:39 +00: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-06 23:54:23 +00:00
|
|
|
DIType VTableHolder,
|
2013-08-27 23:06:40 +00:00
|
|
|
MDNode *TemplateParams,
|
|
|
|
StringRef UniqueIdentifier) {
|
2013-07-01 21:02:01 +00:00
|
|
|
assert((!Context || Context.isScope() || Context.isType()) &&
|
2013-03-11 23:21:19 +00:00
|
|
|
"createClassType should be called with a valid Context");
|
|
|
|
// TAG_class_type is encoded in DICompositeType format.
|
2012-07-06 02:35:57 +00:00
|
|
|
Value *Elts[] = {
|
2014-10-03 20:01:09 +00:00
|
|
|
HeaderBuilder::get(dwarf::DW_TAG_class_type)
|
|
|
|
.concat(Name)
|
|
|
|
.concat(LineNumber)
|
|
|
|
.concat(SizeInBits)
|
|
|
|
.concat(AlignInBits)
|
|
|
|
.concat(OffsetInBits)
|
|
|
|
.concat(Flags)
|
|
|
|
.concat(0)
|
|
|
|
.get(VMContext),
|
|
|
|
File.getFileNode(), DIScope(getNonCompileUnitScope(Context)).getRef(),
|
|
|
|
DerivedFrom.getRef(), Elements, VTableHolder.getRef(), TemplateParams,
|
|
|
|
UniqueIdentifier.empty() ? nullptr
|
|
|
|
: MDString::get(VMContext, UniqueIdentifier)};
|
2013-03-26 23:46:39 +00:00
|
|
|
DICompositeType R(MDNode::get(VMContext, Elts));
|
2013-07-01 21:02:01 +00:00
|
|
|
assert(R.isCompositeType() &&
|
|
|
|
"createClassType should return a DICompositeType");
|
2013-08-29 23:17:54 +00:00
|
|
|
if (!UniqueIdentifier.empty())
|
|
|
|
retainType(R);
|
2013-03-11 23:21:19 +00:00
|
|
|
return R;
|
2012-07-06 02:35:57 +00:00
|
|
|
}
|
|
|
|
|
2013-02-25 01:07:18 +00: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-06 23:54:23 +00:00
|
|
|
DIType VTableHolder,
|
2013-08-27 23:06:40 +00:00
|
|
|
StringRef UniqueIdentifier) {
|
2010-12-07 23:25:47 +00:00
|
|
|
// TAG_structure_type is encoded in DICompositeType format.
|
|
|
|
Value *Elts[] = {
|
2014-10-03 20:01:09 +00:00
|
|
|
HeaderBuilder::get(dwarf::DW_TAG_structure_type)
|
|
|
|
.concat(Name)
|
|
|
|
.concat(LineNumber)
|
|
|
|
.concat(SizeInBits)
|
|
|
|
.concat(AlignInBits)
|
|
|
|
.concat(0)
|
|
|
|
.concat(Flags)
|
|
|
|
.concat(RunTimeLang)
|
|
|
|
.get(VMContext),
|
|
|
|
File.getFileNode(), DIScope(getNonCompileUnitScope(Context)).getRef(),
|
|
|
|
DerivedFrom.getRef(), Elements, VTableHolder.getRef(), nullptr,
|
|
|
|
UniqueIdentifier.empty() ? nullptr
|
|
|
|
: MDString::get(VMContext, UniqueIdentifier)};
|
2013-03-11 23:21:19 +00:00
|
|
|
DICompositeType R(MDNode::get(VMContext, Elts));
|
2013-07-01 21:02:01 +00:00
|
|
|
assert(R.isCompositeType() &&
|
|
|
|
"createStructType should return a DICompositeType");
|
2013-08-29 23:17:54 +00:00
|
|
|
if (!UniqueIdentifier.empty())
|
|
|
|
retainType(R);
|
2013-03-11 23:21:19 +00:00
|
|
|
return R;
|
2010-12-07 23:25:47 +00:00
|
|
|
}
|
|
|
|
|
2013-04-02 22:55:52 +00:00
|
|
|
DICompositeType DIBuilder::createUnionType(DIDescriptor Scope, StringRef Name,
|
|
|
|
DIFile File, unsigned LineNumber,
|
|
|
|
uint64_t SizeInBits,
|
|
|
|
uint64_t AlignInBits, unsigned Flags,
|
|
|
|
DIArray Elements,
|
2013-08-27 23:06:40 +00:00
|
|
|
unsigned RunTimeLang,
|
|
|
|
StringRef UniqueIdentifier) {
|
2010-12-08 01:50:15 +00:00
|
|
|
// TAG_union_type is encoded in DICompositeType format.
|
|
|
|
Value *Elts[] = {
|
2014-10-03 20:01:09 +00:00
|
|
|
HeaderBuilder::get(dwarf::DW_TAG_union_type)
|
|
|
|
.concat(Name)
|
|
|
|
.concat(LineNumber)
|
|
|
|
.concat(SizeInBits)
|
|
|
|
.concat(AlignInBits)
|
|
|
|
.concat(0) // Offset
|
|
|
|
.concat(Flags)
|
|
|
|
.concat(RunTimeLang)
|
|
|
|
.get(VMContext),
|
|
|
|
File.getFileNode(), DIScope(getNonCompileUnitScope(Scope)).getRef(),
|
|
|
|
nullptr, Elements, nullptr, nullptr,
|
|
|
|
UniqueIdentifier.empty() ? nullptr
|
|
|
|
: MDString::get(VMContext, UniqueIdentifier)};
|
2013-08-29 23:17:54 +00:00
|
|
|
DICompositeType R(MDNode::get(VMContext, Elts));
|
|
|
|
if (!UniqueIdentifier.empty())
|
|
|
|
retainType(R);
|
|
|
|
return R;
|
2010-12-08 01:50:15 +00:00
|
|
|
}
|
|
|
|
|
2014-07-28 22:24:06 +00:00
|
|
|
DISubroutineType DIBuilder::createSubroutineType(DIFile File,
|
|
|
|
DITypeArray ParameterTypes,
|
|
|
|
unsigned Flags) {
|
2010-12-08 01:50:15 +00:00
|
|
|
// TAG_subroutine_type is encoded in DICompositeType format.
|
|
|
|
Value *Elts[] = {
|
2014-10-03 20:01:09 +00:00
|
|
|
HeaderBuilder::get(dwarf::DW_TAG_subroutine_type)
|
|
|
|
.concat(StringRef())
|
|
|
|
.concat(0) // Line
|
|
|
|
.concat(0) // Size
|
|
|
|
.concat(0) // Align
|
|
|
|
.concat(0) // Offset
|
|
|
|
.concat(Flags) // Flags
|
|
|
|
.concat(0)
|
|
|
|
.get(VMContext),
|
|
|
|
nullptr, nullptr, nullptr, ParameterTypes, nullptr, nullptr,
|
|
|
|
nullptr // Type Identifer
|
2010-12-08 01:50:15 +00:00
|
|
|
};
|
2014-07-28 22:24:06 +00:00
|
|
|
return DISubroutineType(MDNode::get(VMContext, Elts));
|
2010-12-08 01:50:15 +00:00
|
|
|
}
|
|
|
|
|
2013-02-18 06:41:57 +00:00
|
|
|
DICompositeType DIBuilder::createEnumerationType(
|
|
|
|
DIDescriptor Scope, StringRef Name, DIFile File, unsigned LineNumber,
|
|
|
|
uint64_t SizeInBits, uint64_t AlignInBits, DIArray Elements,
|
2013-08-27 23:06:40 +00:00
|
|
|
DIType UnderlyingType, StringRef UniqueIdentifier) {
|
2010-12-08 01:50:15 +00:00
|
|
|
// TAG_enumeration_type is encoded in DICompositeType format.
|
|
|
|
Value *Elts[] = {
|
2014-10-03 20:01:09 +00:00
|
|
|
HeaderBuilder::get(dwarf::DW_TAG_enumeration_type)
|
|
|
|
.concat(Name)
|
|
|
|
.concat(LineNumber)
|
|
|
|
.concat(SizeInBits)
|
|
|
|
.concat(AlignInBits)
|
|
|
|
.concat(0) // Offset
|
|
|
|
.concat(0) // Flags
|
|
|
|
.concat(0)
|
|
|
|
.get(VMContext),
|
|
|
|
File.getFileNode(), DIScope(getNonCompileUnitScope(Scope)).getRef(),
|
|
|
|
UnderlyingType.getRef(), Elements, nullptr, nullptr,
|
|
|
|
UniqueIdentifier.empty() ? nullptr
|
|
|
|
: MDString::get(VMContext, UniqueIdentifier)};
|
2013-11-18 23:33:32 +00:00
|
|
|
DICompositeType CTy(MDNode::get(VMContext, Elts));
|
|
|
|
AllEnumTypes.push_back(CTy);
|
2013-08-29 23:17:54 +00:00
|
|
|
if (!UniqueIdentifier.empty())
|
2013-11-18 23:33:32 +00:00
|
|
|
retainType(CTy);
|
|
|
|
return CTy;
|
2010-12-08 01:50:15 +00:00
|
|
|
}
|
|
|
|
|
2013-02-18 06:41:57 +00:00
|
|
|
DICompositeType DIBuilder::createArrayType(uint64_t Size, uint64_t AlignInBits,
|
|
|
|
DIType Ty, DIArray Subscripts) {
|
2010-12-08 01:50:15 +00:00
|
|
|
// TAG_array_type is encoded in DICompositeType format.
|
|
|
|
Value *Elts[] = {
|
2014-10-03 20:01:09 +00:00
|
|
|
HeaderBuilder::get(dwarf::DW_TAG_array_type)
|
|
|
|
.concat(StringRef())
|
|
|
|
.concat(0) // Line
|
|
|
|
.concat(Size)
|
|
|
|
.concat(AlignInBits)
|
|
|
|
.concat(0) // Offset
|
|
|
|
.concat(0) // Flags
|
|
|
|
.concat(0)
|
|
|
|
.get(VMContext),
|
|
|
|
nullptr, // Filename/Directory,
|
|
|
|
nullptr, // Unused
|
|
|
|
Ty.getRef(), Subscripts, nullptr, nullptr,
|
|
|
|
nullptr // Type Identifer
|
2010-12-08 01:50:15 +00:00
|
|
|
};
|
2013-03-28 02:44:59 +00:00
|
|
|
return DICompositeType(MDNode::get(VMContext, Elts));
|
2010-12-08 01:50:15 +00:00
|
|
|
}
|
|
|
|
|
2013-06-07 03:13:46 +00:00
|
|
|
DICompositeType DIBuilder::createVectorType(uint64_t Size, uint64_t AlignInBits,
|
|
|
|
DIType Ty, DIArray Subscripts) {
|
2013-01-08 01:53:52 +00:00
|
|
|
// A vector is an array type with the FlagVector flag applied.
|
2010-12-08 01:50:15 +00:00
|
|
|
Value *Elts[] = {
|
2014-10-03 20:01:09 +00:00
|
|
|
HeaderBuilder::get(dwarf::DW_TAG_array_type)
|
|
|
|
.concat("")
|
|
|
|
.concat(0) // Line
|
|
|
|
.concat(Size)
|
|
|
|
.concat(AlignInBits)
|
|
|
|
.concat(0) // Offset
|
|
|
|
.concat(DIType::FlagVector)
|
|
|
|
.concat(0)
|
|
|
|
.get(VMContext),
|
|
|
|
nullptr, // Filename/Directory,
|
|
|
|
nullptr, // Unused
|
|
|
|
Ty.getRef(), Subscripts, nullptr, nullptr,
|
|
|
|
nullptr // Type Identifer
|
2010-12-08 01:50:15 +00:00
|
|
|
};
|
2013-06-07 03:13:46 +00:00
|
|
|
return DICompositeType(MDNode::get(VMContext, Elts));
|
2010-12-08 01:50:15 +00:00
|
|
|
}
|
2010-12-07 23:25:47 +00:00
|
|
|
|
2014-10-03 20:01:09 +00:00
|
|
|
static HeaderBuilder setTypeFlagsInHeader(StringRef Header,
|
|
|
|
unsigned FlagsToSet) {
|
|
|
|
DIHeaderFieldIterator I(Header);
|
|
|
|
std::advance(I, 6);
|
2014-10-02 21:56:57 +00:00
|
|
|
|
2014-10-03 20:01:09 +00:00
|
|
|
unsigned Flags;
|
|
|
|
if (I->getAsInteger(0, Flags))
|
|
|
|
Flags = 0;
|
|
|
|
Flags |= FlagsToSet;
|
|
|
|
|
|
|
|
return HeaderBuilder(Twine(I.getPrefix())).concat(Flags).concat(
|
|
|
|
I.getSuffix());
|
|
|
|
}
|
|
|
|
|
|
|
|
static DIType createTypeWithFlags(LLVMContext &Context, DIType Ty,
|
|
|
|
unsigned FlagsToSet) {
|
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);
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118248 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-04 15:01:38 +00:00
|
|
|
SmallVector<Value *, 9> Elts;
|
|
|
|
MDNode *N = Ty;
|
2014-10-03 20:01:09 +00:00
|
|
|
assert(N && "Unexpected input DIType!");
|
|
|
|
// Update header field.
|
|
|
|
Elts.push_back(setTypeFlagsInHeader(Ty.getHeader(), FlagsToSet).get(Context));
|
|
|
|
for (unsigned I = 1, 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);
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118248 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-04 15:01:38 +00:00
|
|
|
|
2014-10-03 20:01:09 +00:00
|
|
|
return DIType(MDNode::get(Context, Elts));
|
|
|
|
}
|
2014-10-02 22:15:31 +00:00
|
|
|
|
2014-10-03 20:01:09 +00:00
|
|
|
DIType DIBuilder::createArtificialType(DIType Ty) {
|
|
|
|
if (Ty.isArtificial())
|
|
|
|
return Ty;
|
|
|
|
return createTypeWithFlags(VMContext, Ty, DIType::FlagArtificial);
|
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);
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118248 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-04 15:01:38 +00:00
|
|
|
}
|
2010-12-07 23:25:47 +00:00
|
|
|
|
2012-09-12 23:36:19 +00:00
|
|
|
DIType DIBuilder::createObjectPointerType(DIType Ty) {
|
|
|
|
if (Ty.isObjectPointer())
|
|
|
|
return Ty;
|
2014-10-03 20:01:09 +00:00
|
|
|
unsigned Flags = DIType::FlagObjectPointer | DIType::FlagArtificial;
|
|
|
|
return createTypeWithFlags(VMContext, Ty, Flags);
|
2012-09-12 23:36:19 +00:00
|
|
|
}
|
|
|
|
|
2011-02-22 18:56:12 +00:00
|
|
|
void DIBuilder::retainType(DIType T) {
|
2013-08-29 23:17:54 +00:00
|
|
|
AllRetainTypes.push_back(TrackingVH<MDNode>(T));
|
2010-12-08 01:50:15 +00:00
|
|
|
}
|
|
|
|
|
2014-07-29 18:20:39 +00:00
|
|
|
DIBasicType DIBuilder::createUnspecifiedParameter() {
|
2014-07-29 22:58:13 +00:00
|
|
|
return DIBasicType();
|
2010-12-08 01:50:15 +00:00
|
|
|
}
|
|
|
|
|
2013-10-15 23:31:31 +00: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 00:22:26 +00:00
|
|
|
// Create a temporary MDNode.
|
|
|
|
Value *Elts[] = {
|
2014-10-03 20:01:09 +00:00
|
|
|
HeaderBuilder::get(Tag)
|
|
|
|
.concat(Name)
|
|
|
|
.concat(Line)
|
|
|
|
.concat(SizeInBits)
|
|
|
|
.concat(AlignInBits)
|
|
|
|
.concat(0) // Offset
|
|
|
|
.concat(DIDescriptor::FlagFwdDecl)
|
|
|
|
.concat(RuntimeLang)
|
|
|
|
.get(VMContext),
|
|
|
|
F.getFileNode(), DIScope(getNonCompileUnitScope(Scope)).getRef(), nullptr,
|
|
|
|
DIArray(), nullptr,
|
|
|
|
nullptr, // TemplateParams
|
|
|
|
UniqueIdentifier.empty() ? nullptr
|
|
|
|
: MDString::get(VMContext, UniqueIdentifier)};
|
2014-05-06 03:41:57 +00:00
|
|
|
MDNode *Node = MDNode::get(VMContext, Elts);
|
|
|
|
DICompositeType RetTy(Node);
|
|
|
|
assert(RetTy.isCompositeType() &&
|
|
|
|
"createForwardDecl result should be a DIType");
|
|
|
|
if (!UniqueIdentifier.empty())
|
|
|
|
retainType(RetTy);
|
|
|
|
return RetTy;
|
|
|
|
}
|
|
|
|
|
|
|
|
DICompositeType DIBuilder::createReplaceableForwardDecl(
|
|
|
|
unsigned Tag, StringRef Name, DIDescriptor Scope, DIFile F, unsigned Line,
|
|
|
|
unsigned RuntimeLang, uint64_t SizeInBits, uint64_t AlignInBits,
|
|
|
|
StringRef UniqueIdentifier) {
|
|
|
|
// Create a temporary MDNode.
|
|
|
|
Value *Elts[] = {
|
2014-10-03 20:01:09 +00:00
|
|
|
HeaderBuilder::get(Tag)
|
|
|
|
.concat(Name)
|
|
|
|
.concat(Line)
|
|
|
|
.concat(SizeInBits)
|
|
|
|
.concat(AlignInBits)
|
|
|
|
.concat(0) // Offset
|
|
|
|
.concat(DIDescriptor::FlagFwdDecl)
|
|
|
|
.concat(RuntimeLang)
|
|
|
|
.get(VMContext),
|
|
|
|
F.getFileNode(), DIScope(getNonCompileUnitScope(Scope)).getRef(), nullptr,
|
|
|
|
DIArray(), nullptr,
|
|
|
|
nullptr, // TemplateParams
|
|
|
|
UniqueIdentifier.empty() ? nullptr
|
|
|
|
: MDString::get(VMContext, UniqueIdentifier)};
|
2012-02-08 00:22:26 +00:00
|
|
|
MDNode *Node = MDNode::getTemporary(VMContext, Elts);
|
2013-08-16 20:42:14 +00:00
|
|
|
DICompositeType RetTy(Node);
|
|
|
|
assert(RetTy.isCompositeType() &&
|
2014-09-10 16:03:14 +00:00
|
|
|
"createReplaceableForwardDecl result should be a DIType");
|
2013-08-29 23:17:54 +00:00
|
|
|
if (!UniqueIdentifier.empty())
|
|
|
|
retainType(RetTy);
|
2013-07-02 18:37:35 +00:00
|
|
|
return RetTy;
|
2012-02-08 00:22:26 +00:00
|
|
|
}
|
|
|
|
|
2011-04-24 10:11:03 +00:00
|
|
|
DIArray DIBuilder::getOrCreateArray(ArrayRef<Value *> Elements) {
|
|
|
|
return DIArray(MDNode::get(VMContext, Elements));
|
2010-12-07 23:25:47 +00:00
|
|
|
}
|
|
|
|
|
2014-07-28 19:33:20 +00:00
|
|
|
DITypeArray DIBuilder::getOrCreateTypeArray(ArrayRef<Value *> Elements) {
|
|
|
|
SmallVector<llvm::Value *, 16> Elts;
|
|
|
|
for (unsigned i = 0, e = Elements.size(); i != e; ++i) {
|
|
|
|
if (Elements[i] && isa<MDNode>(Elements[i]))
|
|
|
|
Elts.push_back(DIType(cast<MDNode>(Elements[i])).getRef());
|
|
|
|
else
|
|
|
|
Elts.push_back(Elements[i]);
|
|
|
|
}
|
|
|
|
return DITypeArray(MDNode::get(VMContext, Elts));
|
|
|
|
}
|
|
|
|
|
2012-12-04 21:34:03 +00:00
|
|
|
DISubrange DIBuilder::getOrCreateSubrange(int64_t Lo, int64_t Count) {
|
2014-10-03 20:01:09 +00:00
|
|
|
Value *Elts[] = {HeaderBuilder::get(dwarf::DW_TAG_subrange_type)
|
|
|
|
.concat(Lo)
|
|
|
|
.concat(Count)
|
|
|
|
.get(VMContext)};
|
2010-12-08 01:50:15 +00:00
|
|
|
|
2011-04-18 23:51:03 +00:00
|
|
|
return DISubrange(MDNode::get(VMContext, Elts));
|
2010-12-08 01:50:15 +00:00
|
|
|
}
|
|
|
|
|
2014-09-17 09:28:34 +00:00
|
|
|
static DIGlobalVariable
|
2014-09-29 06:32:54 +00:00
|
|
|
createGlobalVariableHelper(LLVMContext &VMContext, DIDescriptor Context,
|
2014-09-17 09:28:34 +00:00
|
|
|
StringRef Name, StringRef LinkageName, DIFile F,
|
|
|
|
unsigned LineNumber, DITypeRef Ty, bool isLocalToUnit,
|
|
|
|
Value *Val, MDNode *Decl, bool isDefinition,
|
|
|
|
std::function<MDNode *(ArrayRef<Value *>)> CreateFunc) {
|
2014-10-03 20:01:09 +00:00
|
|
|
Value *Elts[] = {HeaderBuilder::get(dwarf::DW_TAG_variable)
|
|
|
|
.concat(Name)
|
|
|
|
.concat(Name)
|
|
|
|
.concat(LinkageName)
|
|
|
|
.concat(LineNumber)
|
|
|
|
.concat(isLocalToUnit)
|
|
|
|
.concat(isDefinition)
|
|
|
|
.get(VMContext),
|
|
|
|
getNonCompileUnitScope(Context), F, Ty, Val,
|
|
|
|
DIDescriptor(Decl)};
|
2014-09-17 09:28:34 +00:00
|
|
|
|
|
|
|
return DIGlobalVariable(CreateFunc(Elts));
|
|
|
|
}
|
|
|
|
|
2014-09-29 06:32:54 +00:00
|
|
|
DIGlobalVariable DIBuilder::createGlobalVariable(DIDescriptor Context,
|
2014-09-17 09:28:34 +00:00
|
|
|
StringRef Name,
|
|
|
|
StringRef LinkageName,
|
|
|
|
DIFile F, unsigned LineNumber,
|
|
|
|
DITypeRef Ty,
|
|
|
|
bool isLocalToUnit,
|
|
|
|
Value *Val, MDNode *Decl) {
|
2014-09-29 06:32:54 +00:00
|
|
|
return createGlobalVariableHelper(VMContext, Context, Name, LinkageName, F,
|
2014-09-17 09:28:34 +00:00
|
|
|
LineNumber, Ty, isLocalToUnit, Val, Decl, true,
|
|
|
|
[&] (ArrayRef<Value *> Elts) -> MDNode * {
|
|
|
|
MDNode *Node = MDNode::get(VMContext, Elts);
|
|
|
|
AllGVs.push_back(Node);
|
|
|
|
return Node;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
DIGlobalVariable
|
2014-09-29 06:32:54 +00:00
|
|
|
DIBuilder::createTempGlobalVariableFwdDecl(DIDescriptor Context,
|
2014-09-17 09:28:34 +00:00
|
|
|
StringRef Name,
|
|
|
|
StringRef LinkageName,
|
|
|
|
DIFile F, unsigned LineNumber,
|
|
|
|
DITypeRef Ty,
|
|
|
|
bool isLocalToUnit,
|
|
|
|
Value *Val, MDNode *Decl) {
|
2014-09-29 06:32:54 +00:00
|
|
|
return createGlobalVariableHelper(VMContext, Context, Name, LinkageName, F,
|
2014-09-17 09:28:34 +00:00
|
|
|
LineNumber, Ty, isLocalToUnit, Val, Decl, false,
|
|
|
|
[&] (ArrayRef<Value *> Elts) {
|
|
|
|
return MDNode::getTemporary(VMContext, Elts);
|
|
|
|
});
|
2010-12-07 23:25:47 +00:00
|
|
|
}
|
|
|
|
|
2011-02-22 18:56:12 +00:00
|
|
|
DIVariable DIBuilder::createLocalVariable(unsigned Tag, DIDescriptor Scope,
|
2010-12-07 23:58:00 +00:00
|
|
|
StringRef Name, DIFile File,
|
2014-03-18 02:34:58 +00:00
|
|
|
unsigned LineNo, DITypeRef Ty,
|
2011-03-01 22:58:13 +00:00
|
|
|
bool AlwaysPreserve, unsigned Flags,
|
|
|
|
unsigned ArgNo) {
|
2013-03-11 23:21:19 +00:00
|
|
|
DIDescriptor Context(getNonCompileUnitScope(Scope));
|
2013-07-01 21:02:01 +00:00
|
|
|
assert((!Context || Context.isScope()) &&
|
2013-03-11 23:21:19 +00:00
|
|
|
"createLocalVariable should be called with a valid Context");
|
2014-10-03 20:01:09 +00:00
|
|
|
Value *Elts[] = {HeaderBuilder::get(Tag)
|
|
|
|
.concat(Name)
|
|
|
|
.concat(LineNo | (ArgNo << 24))
|
|
|
|
.concat(Flags)
|
|
|
|
.get(VMContext),
|
|
|
|
getNonCompileUnitScope(Scope), File, Ty};
|
2011-04-18 23:51:03 +00:00
|
|
|
MDNode *Node = MDNode::get(VMContext, Elts);
|
2010-12-07 23:58:00 +00: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));
|
2014-10-15 16:11:41 +00:00
|
|
|
assert(Fn && "Missing subprogram for local variable");
|
|
|
|
PreservedVariables[Fn].push_back(Node);
|
2010-12-07 23:58:00 +00:00
|
|
|
}
|
2013-07-02 18:37:35 +00:00
|
|
|
DIVariable RetVar(Node);
|
|
|
|
assert(RetVar.isVariable() &&
|
2013-07-01 21:02:01 +00:00
|
|
|
"createLocalVariable should return a valid DIVariable");
|
2013-07-02 18:37:35 +00:00
|
|
|
return RetVar;
|
2010-12-07 23:58:00 +00:00
|
|
|
}
|
|
|
|
|
2014-10-01 20:26:08 +00:00
|
|
|
DIExpression DIBuilder::createExpression(ArrayRef<int64_t> Addr) {
|
2014-10-03 20:01:09 +00:00
|
|
|
auto Header = HeaderBuilder::get(DW_TAG_expression);
|
2014-10-01 20:26:08 +00:00
|
|
|
for (int64_t I : Addr)
|
2014-10-03 20:01:09 +00:00
|
|
|
Header.concat(I);
|
|
|
|
Value *Elts[] = {Header.get(VMContext)};
|
Move the complex address expression out of DIVariable and into an extra
argument of the llvm.dbg.declare/llvm.dbg.value intrinsics.
Previously, DIVariable was a variable-length field that has an optional
reference to a Metadata array consisting of a variable number of
complex address expressions. In the case of OpPiece expressions this is
wasting a lot of storage in IR, because when an aggregate type is, e.g.,
SROA'd into all of its n individual members, the IR will contain n copies
of the DIVariable, all alike, only differing in the complex address
reference at the end.
By making the complex address into an extra argument of the
dbg.value/dbg.declare intrinsics, all of the pieces can reference the
same variable and the complex address expressions can be uniqued across
the CU, too.
Down the road, this will allow us to move other flags, such as
"indirection" out of the DIVariable, too.
The new intrinsics look like this:
declare void @llvm.dbg.declare(metadata %storage, metadata %var, metadata %expr)
declare void @llvm.dbg.value(metadata %storage, i64 %offset, metadata %var, metadata %expr)
This patch adds a new LLVM-local tag to DIExpressions, so we can detect
and pretty-print DIExpression metadata nodes.
What this patch doesn't do:
This patch does not touch the "Indirect" field in DIVariable; but moving
that into the expression would be a natural next step.
http://reviews.llvm.org/D4919
rdar://problem/17994491
Thanks to dblaikie and dexonsmith for reviewing this patch!
Note: I accidentally committed a bogus older version of this patch previously.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218787 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-01 18:55:02 +00:00
|
|
|
return DIExpression(MDNode::get(VMContext, Elts));
|
2010-12-07 23:25:47 +00:00
|
|
|
}
|
|
|
|
|
2014-10-01 21:32:12 +00:00
|
|
|
DIExpression DIBuilder::createPieceExpression(unsigned OffsetInBytes,
|
|
|
|
unsigned SizeInBytes) {
|
|
|
|
int64_t Addr[] = {dwarf::DW_OP_piece, OffsetInBytes, SizeInBytes};
|
|
|
|
return createExpression(Addr);
|
|
|
|
}
|
|
|
|
|
2013-10-15 23:31:31 +00:00
|
|
|
DISubprogram DIBuilder::createFunction(DIScopeRef Context, StringRef Name,
|
|
|
|
StringRef LinkageName, DIFile File,
|
|
|
|
unsigned LineNo, DICompositeType Ty,
|
2013-10-10 18:40:01 +00:00
|
|
|
bool isLocalToUnit, bool isDefinition,
|
2013-10-15 23:31:31 +00:00
|
|
|
unsigned ScopeLine, unsigned Flags,
|
|
|
|
bool isOptimized, Function *Fn,
|
|
|
|
MDNode *TParams, MDNode *Decl) {
|
2013-10-10 18:40:01 +00: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);
|
|
|
|
}
|
|
|
|
|
2014-09-17 09:28:34 +00:00
|
|
|
static DISubprogram
|
|
|
|
createFunctionHelper(LLVMContext &VMContext, DIDescriptor Context, StringRef Name,
|
|
|
|
StringRef LinkageName, DIFile File, unsigned LineNo,
|
|
|
|
DICompositeType Ty, bool isLocalToUnit, bool isDefinition,
|
|
|
|
unsigned ScopeLine, unsigned Flags, bool isOptimized,
|
|
|
|
Function *Fn, MDNode *TParams, MDNode *Decl,
|
|
|
|
std::function<MDNode *(ArrayRef<Value *>)> CreateFunc) {
|
2013-05-22 23:22:18 +00:00
|
|
|
assert(Ty.getTag() == dwarf::DW_TAG_subroutine_type &&
|
|
|
|
"function types should be subroutines");
|
2014-10-03 20:01:09 +00:00
|
|
|
Value *TElts[] = {HeaderBuilder::get(DW_TAG_base_type).get(VMContext)};
|
2010-12-08 20:42:44 +00:00
|
|
|
Value *Elts[] = {
|
2014-10-03 20:01:09 +00:00
|
|
|
HeaderBuilder::get(dwarf::DW_TAG_subprogram)
|
|
|
|
.concat(Name)
|
|
|
|
.concat(Name)
|
|
|
|
.concat(LinkageName)
|
|
|
|
.concat(LineNo)
|
|
|
|
.concat(isLocalToUnit)
|
|
|
|
.concat(isDefinition)
|
|
|
|
.concat(0)
|
|
|
|
.concat(0)
|
|
|
|
.concat(Flags)
|
|
|
|
.concat(isOptimized)
|
|
|
|
.concat(ScopeLine)
|
|
|
|
.get(VMContext),
|
|
|
|
File.getFileNode(), DIScope(getNonCompileUnitScope(Context)).getRef(), Ty,
|
|
|
|
nullptr, Fn, TParams, Decl, MDNode::getTemporary(VMContext, TElts)};
|
2010-12-08 20:42:44 +00:00
|
|
|
|
2014-09-17 09:28:34 +00:00
|
|
|
DISubprogram S(CreateFunc(Elts));
|
2014-02-28 21:27:59 +00:00
|
|
|
assert(S.isSubprogram() &&
|
|
|
|
"createFunction should return a valid DISubprogram");
|
2013-03-21 20:28:52 +00:00
|
|
|
return S;
|
2010-12-08 20:42:44 +00:00
|
|
|
}
|
|
|
|
|
2014-09-17 09:28:34 +00:00
|
|
|
|
|
|
|
DISubprogram DIBuilder::createFunction(DIDescriptor Context, StringRef Name,
|
|
|
|
StringRef LinkageName, DIFile File,
|
|
|
|
unsigned LineNo, DICompositeType Ty,
|
|
|
|
bool isLocalToUnit, bool isDefinition,
|
|
|
|
unsigned ScopeLine, unsigned Flags,
|
|
|
|
bool isOptimized, Function *Fn,
|
|
|
|
MDNode *TParams, MDNode *Decl) {
|
|
|
|
return createFunctionHelper(VMContext, Context, Name, LinkageName, File,
|
|
|
|
LineNo, Ty, isLocalToUnit, isDefinition, ScopeLine,
|
|
|
|
Flags, isOptimized, Fn, TParams, Decl,
|
|
|
|
[&] (ArrayRef<Value *> Elts) -> MDNode *{
|
|
|
|
MDNode *Node = MDNode::get(VMContext, Elts);
|
|
|
|
// Create a named metadata so that we
|
|
|
|
// do not lose this mdnode.
|
|
|
|
if (isDefinition)
|
|
|
|
AllSubprograms.push_back(Node);
|
|
|
|
return Node;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
DISubprogram
|
|
|
|
DIBuilder::createTempFunctionFwdDecl(DIDescriptor Context, StringRef Name,
|
|
|
|
StringRef LinkageName, DIFile File,
|
|
|
|
unsigned LineNo, DICompositeType Ty,
|
|
|
|
bool isLocalToUnit, bool isDefinition,
|
|
|
|
unsigned ScopeLine, unsigned Flags,
|
|
|
|
bool isOptimized, Function *Fn,
|
|
|
|
MDNode *TParams, MDNode *Decl) {
|
|
|
|
return createFunctionHelper(VMContext, Context, Name, LinkageName, File,
|
|
|
|
LineNo, Ty, isLocalToUnit, isDefinition, ScopeLine,
|
|
|
|
Flags, isOptimized, Fn, TParams, Decl,
|
|
|
|
[&] (ArrayRef<Value *> Elts) {
|
|
|
|
return MDNode::getTemporary(VMContext, Elts);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2013-10-15 23:31:31 +00:00
|
|
|
DISubprogram DIBuilder::createMethod(DIDescriptor Context, StringRef Name,
|
|
|
|
StringRef LinkageName, DIFile F,
|
2013-05-22 23:22:18 +00:00
|
|
|
unsigned LineNo, DICompositeType Ty,
|
2013-10-15 23:31:31 +00:00
|
|
|
bool isLocalToUnit, bool isDefinition,
|
2010-12-08 20:42:44 +00:00
|
|
|
unsigned VK, unsigned VIndex,
|
2013-10-15 23:31:31 +00:00
|
|
|
DIType VTableHolder, unsigned Flags,
|
|
|
|
bool isOptimized, Function *Fn,
|
2011-04-05 22:52:06 +00:00
|
|
|
MDNode *TParam) {
|
2013-05-22 23:22:18 +00:00
|
|
|
assert(Ty.getTag() == dwarf::DW_TAG_subroutine_type &&
|
|
|
|
"function types should be subroutines");
|
2013-10-15 23:31:36 +00:00
|
|
|
assert(getNonCompileUnitScope(Context) &&
|
|
|
|
"Methods should have both a Context and a context that isn't "
|
|
|
|
"the compile unit.");
|
2014-10-03 20:01:09 +00:00
|
|
|
Value *Elts[] = {HeaderBuilder::get(dwarf::DW_TAG_subprogram)
|
|
|
|
.concat(Name)
|
|
|
|
.concat(Name)
|
|
|
|
.concat(LinkageName)
|
|
|
|
.concat(LineNo)
|
|
|
|
.concat(isLocalToUnit)
|
|
|
|
.concat(isDefinition)
|
|
|
|
.concat(VK)
|
|
|
|
.concat(VIndex)
|
|
|
|
.concat(Flags)
|
|
|
|
.concat(isOptimized)
|
|
|
|
.concat(LineNo)
|
|
|
|
// FIXME: Do we want to use different scope/lines?
|
|
|
|
.get(VMContext),
|
|
|
|
F.getFileNode(), DIScope(Context).getRef(), Ty,
|
|
|
|
VTableHolder.getRef(), Fn, TParam, nullptr, nullptr};
|
2011-04-18 23:51:03 +00:00
|
|
|
MDNode *Node = MDNode::get(VMContext, Elts);
|
2013-02-18 07:10:22 +00:00
|
|
|
if (isDefinition)
|
|
|
|
AllSubprograms.push_back(Node);
|
2013-03-21 20:28:52 +00:00
|
|
|
DISubprogram S(Node);
|
2013-07-01 21:02:01 +00:00
|
|
|
assert(S.isSubprogram() && "createMethod should return a valid DISubprogram");
|
2013-03-21 20:28:52 +00:00
|
|
|
return S;
|
2010-12-08 20:42:44 +00:00
|
|
|
}
|
|
|
|
|
2011-02-22 18:56:12 +00:00
|
|
|
DINameSpace DIBuilder::createNameSpace(DIDescriptor Scope, StringRef Name,
|
2010-12-07 23:25:47 +00:00
|
|
|
DIFile File, unsigned LineNo) {
|
2014-10-03 20:01:09 +00:00
|
|
|
Value *Elts[] = {HeaderBuilder::get(dwarf::DW_TAG_namespace)
|
|
|
|
.concat(Name)
|
|
|
|
.concat(LineNo)
|
|
|
|
.get(VMContext),
|
|
|
|
File.getFileNode(), getNonCompileUnitScope(Scope)};
|
2013-03-11 23:21:19 +00:00
|
|
|
DINameSpace R(MDNode::get(VMContext, Elts));
|
|
|
|
assert(R.Verify() &&
|
|
|
|
"createNameSpace should return a verifiable DINameSpace");
|
|
|
|
return R;
|
2010-12-07 23:25:47 +00:00
|
|
|
}
|
|
|
|
|
2011-10-11 22:59:11 +00:00
|
|
|
DILexicalBlockFile DIBuilder::createLexicalBlockFile(DIDescriptor Scope,
|
2014-08-21 22:45:21 +00:00
|
|
|
DIFile File,
|
|
|
|
unsigned Discriminator) {
|
2014-10-03 20:01:09 +00:00
|
|
|
Value *Elts[] = {HeaderBuilder::get(dwarf::DW_TAG_lexical_block)
|
|
|
|
.concat(Discriminator)
|
|
|
|
.get(VMContext),
|
|
|
|
File.getFileNode(), Scope};
|
2013-03-11 23:21:19 +00:00
|
|
|
DILexicalBlockFile R(MDNode::get(VMContext, Elts));
|
|
|
|
assert(
|
|
|
|
R.Verify() &&
|
|
|
|
"createLexicalBlockFile should return a verifiable DILexicalBlockFile");
|
|
|
|
return R;
|
2011-10-11 22:59:11 +00:00
|
|
|
}
|
|
|
|
|
2011-02-22 18:56:12 +00:00
|
|
|
DILexicalBlock DIBuilder::createLexicalBlock(DIDescriptor Scope, DIFile File,
|
2014-08-21 22:45:21 +00:00
|
|
|
unsigned Line, unsigned Col) {
|
2014-05-15 20:09:55 +00:00
|
|
|
// FIXME: This isn't thread safe nor the right way to defeat MDNode uniquing.
|
|
|
|
// I believe the right way is to have a self-referential element in the node.
|
|
|
|
// Also: why do we bother with line/column - they're not used and the
|
|
|
|
// documentation (SourceLevelDebugging.rst) claims the line/col are necessary
|
|
|
|
// for uniquing, yet then we have this other solution (because line/col were
|
|
|
|
// inadequate) anyway. Remove all 3 and replace them with a self-reference.
|
|
|
|
|
2013-06-24 21:19:43 +00:00
|
|
|
// Defeat MDNode uniquing for lexical blocks by using unique id.
|
2010-12-08 01:50:15 +00:00
|
|
|
static unsigned int unique_id = 0;
|
2014-10-03 20:01:09 +00:00
|
|
|
Value *Elts[] = {HeaderBuilder::get(dwarf::DW_TAG_lexical_block)
|
|
|
|
.concat(Line)
|
|
|
|
.concat(Col)
|
|
|
|
.concat(unique_id++)
|
|
|
|
.get(VMContext),
|
|
|
|
File.getFileNode(), getNonCompileUnitScope(Scope)};
|
2013-03-11 23:21:19 +00:00
|
|
|
DILexicalBlock R(MDNode::get(VMContext, Elts));
|
|
|
|
assert(R.Verify() &&
|
|
|
|
"createLexicalBlock should return a verifiable DILexicalBlock");
|
|
|
|
return R;
|
2010-12-08 01:50:15 +00:00
|
|
|
}
|
|
|
|
|
2011-02-22 18:56:12 +00:00
|
|
|
Instruction *DIBuilder::insertDeclare(Value *Storage, DIVariable VarInfo,
|
Move the complex address expression out of DIVariable and into an extra
argument of the llvm.dbg.declare/llvm.dbg.value intrinsics.
Previously, DIVariable was a variable-length field that has an optional
reference to a Metadata array consisting of a variable number of
complex address expressions. In the case of OpPiece expressions this is
wasting a lot of storage in IR, because when an aggregate type is, e.g.,
SROA'd into all of its n individual members, the IR will contain n copies
of the DIVariable, all alike, only differing in the complex address
reference at the end.
By making the complex address into an extra argument of the
dbg.value/dbg.declare intrinsics, all of the pieces can reference the
same variable and the complex address expressions can be uniqued across
the CU, too.
Down the road, this will allow us to move other flags, such as
"indirection" out of the DIVariable, too.
The new intrinsics look like this:
declare void @llvm.dbg.declare(metadata %storage, metadata %var, metadata %expr)
declare void @llvm.dbg.value(metadata %storage, i64 %offset, metadata %var, metadata %expr)
This patch adds a new LLVM-local tag to DIExpressions, so we can detect
and pretty-print DIExpression metadata nodes.
What this patch doesn't do:
This patch does not touch the "Indirect" field in DIVariable; but moving
that into the expression would be a natural next step.
http://reviews.llvm.org/D4919
rdar://problem/17994491
Thanks to dblaikie and dexonsmith for reviewing this patch!
Note: I accidentally committed a bogus older version of this patch previously.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218787 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-01 18:55:02 +00:00
|
|
|
DIExpression Expr,
|
2010-12-07 23:25:47 +00:00
|
|
|
Instruction *InsertBefore) {
|
|
|
|
assert(Storage && "no storage passed to dbg.declare");
|
2013-06-29 05:01:19 +00:00
|
|
|
assert(VarInfo.isVariable() &&
|
|
|
|
"empty or invalid DIVariable passed to dbg.declare");
|
2010-12-07 23:25:47 +00:00
|
|
|
if (!DeclareFn)
|
|
|
|
DeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare);
|
|
|
|
|
Move the complex address expression out of DIVariable and into an extra
argument of the llvm.dbg.declare/llvm.dbg.value intrinsics.
Previously, DIVariable was a variable-length field that has an optional
reference to a Metadata array consisting of a variable number of
complex address expressions. In the case of OpPiece expressions this is
wasting a lot of storage in IR, because when an aggregate type is, e.g.,
SROA'd into all of its n individual members, the IR will contain n copies
of the DIVariable, all alike, only differing in the complex address
reference at the end.
By making the complex address into an extra argument of the
dbg.value/dbg.declare intrinsics, all of the pieces can reference the
same variable and the complex address expressions can be uniqued across
the CU, too.
Down the road, this will allow us to move other flags, such as
"indirection" out of the DIVariable, too.
The new intrinsics look like this:
declare void @llvm.dbg.declare(metadata %storage, metadata %var, metadata %expr)
declare void @llvm.dbg.value(metadata %storage, i64 %offset, metadata %var, metadata %expr)
This patch adds a new LLVM-local tag to DIExpressions, so we can detect
and pretty-print DIExpression metadata nodes.
What this patch doesn't do:
This patch does not touch the "Indirect" field in DIVariable; but moving
that into the expression would be a natural next step.
http://reviews.llvm.org/D4919
rdar://problem/17994491
Thanks to dblaikie and dexonsmith for reviewing this patch!
Note: I accidentally committed a bogus older version of this patch previously.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218787 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-01 18:55:02 +00:00
|
|
|
Value *Args[] = {MDNode::get(Storage->getContext(), Storage), VarInfo, Expr};
|
2011-07-15 08:37:34 +00:00
|
|
|
return CallInst::Create(DeclareFn, Args, "", InsertBefore);
|
2010-12-07 23:25:47 +00:00
|
|
|
}
|
|
|
|
|
2011-02-22 18:56:12 +00:00
|
|
|
Instruction *DIBuilder::insertDeclare(Value *Storage, DIVariable VarInfo,
|
Move the complex address expression out of DIVariable and into an extra
argument of the llvm.dbg.declare/llvm.dbg.value intrinsics.
Previously, DIVariable was a variable-length field that has an optional
reference to a Metadata array consisting of a variable number of
complex address expressions. In the case of OpPiece expressions this is
wasting a lot of storage in IR, because when an aggregate type is, e.g.,
SROA'd into all of its n individual members, the IR will contain n copies
of the DIVariable, all alike, only differing in the complex address
reference at the end.
By making the complex address into an extra argument of the
dbg.value/dbg.declare intrinsics, all of the pieces can reference the
same variable and the complex address expressions can be uniqued across
the CU, too.
Down the road, this will allow us to move other flags, such as
"indirection" out of the DIVariable, too.
The new intrinsics look like this:
declare void @llvm.dbg.declare(metadata %storage, metadata %var, metadata %expr)
declare void @llvm.dbg.value(metadata %storage, i64 %offset, metadata %var, metadata %expr)
This patch adds a new LLVM-local tag to DIExpressions, so we can detect
and pretty-print DIExpression metadata nodes.
What this patch doesn't do:
This patch does not touch the "Indirect" field in DIVariable; but moving
that into the expression would be a natural next step.
http://reviews.llvm.org/D4919
rdar://problem/17994491
Thanks to dblaikie and dexonsmith for reviewing this patch!
Note: I accidentally committed a bogus older version of this patch previously.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218787 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-01 18:55:02 +00:00
|
|
|
DIExpression Expr,
|
2010-12-07 23:25:47 +00:00
|
|
|
BasicBlock *InsertAtEnd) {
|
|
|
|
assert(Storage && "no storage passed to dbg.declare");
|
2013-06-29 05:01:19 +00:00
|
|
|
assert(VarInfo.isVariable() &&
|
|
|
|
"empty or invalid DIVariable passed to dbg.declare");
|
2010-12-07 23:25:47 +00:00
|
|
|
if (!DeclareFn)
|
|
|
|
DeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare);
|
|
|
|
|
Move the complex address expression out of DIVariable and into an extra
argument of the llvm.dbg.declare/llvm.dbg.value intrinsics.
Previously, DIVariable was a variable-length field that has an optional
reference to a Metadata array consisting of a variable number of
complex address expressions. In the case of OpPiece expressions this is
wasting a lot of storage in IR, because when an aggregate type is, e.g.,
SROA'd into all of its n individual members, the IR will contain n copies
of the DIVariable, all alike, only differing in the complex address
reference at the end.
By making the complex address into an extra argument of the
dbg.value/dbg.declare intrinsics, all of the pieces can reference the
same variable and the complex address expressions can be uniqued across
the CU, too.
Down the road, this will allow us to move other flags, such as
"indirection" out of the DIVariable, too.
The new intrinsics look like this:
declare void @llvm.dbg.declare(metadata %storage, metadata %var, metadata %expr)
declare void @llvm.dbg.value(metadata %storage, i64 %offset, metadata %var, metadata %expr)
This patch adds a new LLVM-local tag to DIExpressions, so we can detect
and pretty-print DIExpression metadata nodes.
What this patch doesn't do:
This patch does not touch the "Indirect" field in DIVariable; but moving
that into the expression would be a natural next step.
http://reviews.llvm.org/D4919
rdar://problem/17994491
Thanks to dblaikie and dexonsmith for reviewing this patch!
Note: I accidentally committed a bogus older version of this patch previously.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218787 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-01 18:55:02 +00:00
|
|
|
Value *Args[] = {MDNode::get(Storage->getContext(), Storage), VarInfo, Expr};
|
2010-12-07 23:25:47 +00:00
|
|
|
|
|
|
|
// If this block already has a terminator then insert this intrinsic
|
|
|
|
// before the terminator.
|
|
|
|
if (TerminatorInst *T = InsertAtEnd->getTerminator())
|
2011-07-15 08:37:34 +00:00
|
|
|
return CallInst::Create(DeclareFn, Args, "", T);
|
2010-12-07 23:25:47 +00:00
|
|
|
else
|
2011-07-15 08:37:34 +00:00
|
|
|
return CallInst::Create(DeclareFn, Args, "", InsertAtEnd);
|
2010-12-07 23:25:47 +00:00
|
|
|
}
|
|
|
|
|
2011-02-22 18:56:12 +00:00
|
|
|
Instruction *DIBuilder::insertDbgValueIntrinsic(Value *V, uint64_t Offset,
|
2010-12-07 23:25:47 +00:00
|
|
|
DIVariable VarInfo,
|
Move the complex address expression out of DIVariable and into an extra
argument of the llvm.dbg.declare/llvm.dbg.value intrinsics.
Previously, DIVariable was a variable-length field that has an optional
reference to a Metadata array consisting of a variable number of
complex address expressions. In the case of OpPiece expressions this is
wasting a lot of storage in IR, because when an aggregate type is, e.g.,
SROA'd into all of its n individual members, the IR will contain n copies
of the DIVariable, all alike, only differing in the complex address
reference at the end.
By making the complex address into an extra argument of the
dbg.value/dbg.declare intrinsics, all of the pieces can reference the
same variable and the complex address expressions can be uniqued across
the CU, too.
Down the road, this will allow us to move other flags, such as
"indirection" out of the DIVariable, too.
The new intrinsics look like this:
declare void @llvm.dbg.declare(metadata %storage, metadata %var, metadata %expr)
declare void @llvm.dbg.value(metadata %storage, i64 %offset, metadata %var, metadata %expr)
This patch adds a new LLVM-local tag to DIExpressions, so we can detect
and pretty-print DIExpression metadata nodes.
What this patch doesn't do:
This patch does not touch the "Indirect" field in DIVariable; but moving
that into the expression would be a natural next step.
http://reviews.llvm.org/D4919
rdar://problem/17994491
Thanks to dblaikie and dexonsmith for reviewing this patch!
Note: I accidentally committed a bogus older version of this patch previously.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218787 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-01 18:55:02 +00:00
|
|
|
DIExpression Expr,
|
2010-12-07 23:25:47 +00:00
|
|
|
Instruction *InsertBefore) {
|
|
|
|
assert(V && "no value passed to dbg.value");
|
2013-06-29 05:01:19 +00:00
|
|
|
assert(VarInfo.isVariable() &&
|
|
|
|
"empty or invalid DIVariable passed to dbg.value");
|
2010-12-07 23:25:47 +00:00
|
|
|
if (!ValueFn)
|
|
|
|
ValueFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_value);
|
|
|
|
|
Move the complex address expression out of DIVariable and into an extra
argument of the llvm.dbg.declare/llvm.dbg.value intrinsics.
Previously, DIVariable was a variable-length field that has an optional
reference to a Metadata array consisting of a variable number of
complex address expressions. In the case of OpPiece expressions this is
wasting a lot of storage in IR, because when an aggregate type is, e.g.,
SROA'd into all of its n individual members, the IR will contain n copies
of the DIVariable, all alike, only differing in the complex address
reference at the end.
By making the complex address into an extra argument of the
dbg.value/dbg.declare intrinsics, all of the pieces can reference the
same variable and the complex address expressions can be uniqued across
the CU, too.
Down the road, this will allow us to move other flags, such as
"indirection" out of the DIVariable, too.
The new intrinsics look like this:
declare void @llvm.dbg.declare(metadata %storage, metadata %var, metadata %expr)
declare void @llvm.dbg.value(metadata %storage, i64 %offset, metadata %var, metadata %expr)
This patch adds a new LLVM-local tag to DIExpressions, so we can detect
and pretty-print DIExpression metadata nodes.
What this patch doesn't do:
This patch does not touch the "Indirect" field in DIVariable; but moving
that into the expression would be a natural next step.
http://reviews.llvm.org/D4919
rdar://problem/17994491
Thanks to dblaikie and dexonsmith for reviewing this patch!
Note: I accidentally committed a bogus older version of this patch previously.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218787 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-01 18:55:02 +00:00
|
|
|
Value *Args[] = {MDNode::get(V->getContext(), V),
|
|
|
|
ConstantInt::get(Type::getInt64Ty(V->getContext()), Offset),
|
|
|
|
VarInfo, Expr};
|
2011-07-15 08:37:34 +00:00
|
|
|
return CallInst::Create(ValueFn, Args, "", InsertBefore);
|
2010-12-07 23:25:47 +00:00
|
|
|
}
|
|
|
|
|
2011-02-22 18:56:12 +00:00
|
|
|
Instruction *DIBuilder::insertDbgValueIntrinsic(Value *V, uint64_t Offset,
|
2010-12-07 23:25:47 +00:00
|
|
|
DIVariable VarInfo,
|
Move the complex address expression out of DIVariable and into an extra
argument of the llvm.dbg.declare/llvm.dbg.value intrinsics.
Previously, DIVariable was a variable-length field that has an optional
reference to a Metadata array consisting of a variable number of
complex address expressions. In the case of OpPiece expressions this is
wasting a lot of storage in IR, because when an aggregate type is, e.g.,
SROA'd into all of its n individual members, the IR will contain n copies
of the DIVariable, all alike, only differing in the complex address
reference at the end.
By making the complex address into an extra argument of the
dbg.value/dbg.declare intrinsics, all of the pieces can reference the
same variable and the complex address expressions can be uniqued across
the CU, too.
Down the road, this will allow us to move other flags, such as
"indirection" out of the DIVariable, too.
The new intrinsics look like this:
declare void @llvm.dbg.declare(metadata %storage, metadata %var, metadata %expr)
declare void @llvm.dbg.value(metadata %storage, i64 %offset, metadata %var, metadata %expr)
This patch adds a new LLVM-local tag to DIExpressions, so we can detect
and pretty-print DIExpression metadata nodes.
What this patch doesn't do:
This patch does not touch the "Indirect" field in DIVariable; but moving
that into the expression would be a natural next step.
http://reviews.llvm.org/D4919
rdar://problem/17994491
Thanks to dblaikie and dexonsmith for reviewing this patch!
Note: I accidentally committed a bogus older version of this patch previously.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218787 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-01 18:55:02 +00:00
|
|
|
DIExpression Expr,
|
2010-12-07 23:25:47 +00:00
|
|
|
BasicBlock *InsertAtEnd) {
|
|
|
|
assert(V && "no value passed to dbg.value");
|
2013-06-29 05:01:19 +00:00
|
|
|
assert(VarInfo.isVariable() &&
|
|
|
|
"empty or invalid DIVariable passed to dbg.value");
|
2010-12-07 23:25:47 +00:00
|
|
|
if (!ValueFn)
|
|
|
|
ValueFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_value);
|
|
|
|
|
Move the complex address expression out of DIVariable and into an extra
argument of the llvm.dbg.declare/llvm.dbg.value intrinsics.
Previously, DIVariable was a variable-length field that has an optional
reference to a Metadata array consisting of a variable number of
complex address expressions. In the case of OpPiece expressions this is
wasting a lot of storage in IR, because when an aggregate type is, e.g.,
SROA'd into all of its n individual members, the IR will contain n copies
of the DIVariable, all alike, only differing in the complex address
reference at the end.
By making the complex address into an extra argument of the
dbg.value/dbg.declare intrinsics, all of the pieces can reference the
same variable and the complex address expressions can be uniqued across
the CU, too.
Down the road, this will allow us to move other flags, such as
"indirection" out of the DIVariable, too.
The new intrinsics look like this:
declare void @llvm.dbg.declare(metadata %storage, metadata %var, metadata %expr)
declare void @llvm.dbg.value(metadata %storage, i64 %offset, metadata %var, metadata %expr)
This patch adds a new LLVM-local tag to DIExpressions, so we can detect
and pretty-print DIExpression metadata nodes.
What this patch doesn't do:
This patch does not touch the "Indirect" field in DIVariable; but moving
that into the expression would be a natural next step.
http://reviews.llvm.org/D4919
rdar://problem/17994491
Thanks to dblaikie and dexonsmith for reviewing this patch!
Note: I accidentally committed a bogus older version of this patch previously.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218787 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-01 18:55:02 +00:00
|
|
|
Value *Args[] = {MDNode::get(V->getContext(), V),
|
|
|
|
ConstantInt::get(Type::getInt64Ty(V->getContext()), Offset),
|
|
|
|
VarInfo, Expr};
|
2011-07-15 08:37:34 +00:00
|
|
|
return CallInst::Create(ValueFn, Args, "", InsertAtEnd);
|
2010-12-07 23:25:47 +00:00
|
|
|
}
|