Please use GitHub pull requests for new patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
llvm/trunk/lib/IR/DebugInfoMetadata.cpp
Show All 17 Lines | |||||
#include "llvm/ADT/StringSwitch.h" | #include "llvm/ADT/StringSwitch.h" | ||||
#include "llvm/IR/DIBuilder.h" | #include "llvm/IR/DIBuilder.h" | ||||
#include "llvm/IR/Function.h" | #include "llvm/IR/Function.h" | ||||
#include "llvm/IR/Instructions.h" | #include "llvm/IR/Instructions.h" | ||||
using namespace llvm; | using namespace llvm; | ||||
DILocation::DILocation(LLVMContext &C, StorageType Storage, unsigned Line, | DILocation::DILocation(LLVMContext &C, StorageType Storage, unsigned Line, | ||||
unsigned Column, ArrayRef<Metadata *> MDs) | unsigned Column, ArrayRef<Metadata *> MDs, | ||||
bool ImplicitCode) | |||||
: MDNode(C, DILocationKind, Storage, MDs) { | : MDNode(C, DILocationKind, Storage, MDs) { | ||||
assert((MDs.size() == 1 || MDs.size() == 2) && | assert((MDs.size() == 1 || MDs.size() == 2) && | ||||
"Expected a scope and optional inlined-at"); | "Expected a scope and optional inlined-at"); | ||||
// Set line and column. | // Set line and column. | ||||
assert(Column < (1u << 16) && "Expected 16-bit column"); | assert(Column < (1u << 16) && "Expected 16-bit column"); | ||||
SubclassData32 = Line; | SubclassData32 = Line; | ||||
SubclassData16 = Column; | SubclassData16 = Column; | ||||
setImplicitCode(ImplicitCode); | |||||
} | } | ||||
static void adjustColumn(unsigned &Column) { | static void adjustColumn(unsigned &Column) { | ||||
// Set to unknown on overflow. We only have 16 bits to play with here. | // Set to unknown on overflow. We only have 16 bits to play with here. | ||||
if (Column >= (1u << 16)) | if (Column >= (1u << 16)) | ||||
Column = 0; | Column = 0; | ||||
} | } | ||||
DILocation *DILocation::getImpl(LLVMContext &Context, unsigned Line, | DILocation *DILocation::getImpl(LLVMContext &Context, unsigned Line, | ||||
unsigned Column, Metadata *Scope, | unsigned Column, Metadata *Scope, | ||||
Metadata *InlinedAt, StorageType Storage, | Metadata *InlinedAt, bool ImplicitCode, | ||||
bool ShouldCreate) { | StorageType Storage, bool ShouldCreate) { | ||||
// Fixup column. | // Fixup column. | ||||
adjustColumn(Column); | adjustColumn(Column); | ||||
if (Storage == Uniqued) { | if (Storage == Uniqued) { | ||||
if (auto *N = | if (auto *N = getUniqued(Context.pImpl->DILocations, | ||||
getUniqued(Context.pImpl->DILocations, | DILocationInfo::KeyTy(Line, Column, Scope, | ||||
DILocationInfo::KeyTy(Line, Column, Scope, InlinedAt))) | InlinedAt, ImplicitCode))) | ||||
return N; | return N; | ||||
if (!ShouldCreate) | if (!ShouldCreate) | ||||
return nullptr; | return nullptr; | ||||
} else { | } else { | ||||
assert(ShouldCreate && "Expected non-uniqued nodes to always be created"); | assert(ShouldCreate && "Expected non-uniqued nodes to always be created"); | ||||
} | } | ||||
SmallVector<Metadata *, 2> Ops; | SmallVector<Metadata *, 2> Ops; | ||||
Ops.push_back(Scope); | Ops.push_back(Scope); | ||||
if (InlinedAt) | if (InlinedAt) | ||||
Ops.push_back(InlinedAt); | Ops.push_back(InlinedAt); | ||||
return storeImpl(new (Ops.size()) | return storeImpl(new (Ops.size()) DILocation(Context, Storage, Line, Column, | ||||
DILocation(Context, Storage, Line, Column, Ops), | Ops, ImplicitCode), | ||||
Storage, Context.pImpl->DILocations); | Storage, Context.pImpl->DILocations); | ||||
} | } | ||||
const DILocation *DILocation::getMergedLocation(const DILocation *LocA, | const DILocation *DILocation::getMergedLocation(const DILocation *LocA, | ||||
const DILocation *LocB) { | const DILocation *LocB) { | ||||
if (!LocA || !LocB) | if (!LocA || !LocB) | ||||
return nullptr; | return nullptr; | ||||
▲ Show 20 Lines • Show All 964 Lines • Show Last 20 Lines |