IR: Assembly and bitcode for GenericDebugNode

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228041 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Duncan P. N. Exon Smith
2015-02-03 21:54:14 +00:00
parent 90eef42c8e
commit 6adbfa3815
11 changed files with 178 additions and 13 deletions

View File

@ -792,10 +792,20 @@ static void WriteMDLocation(const MDLocation *N, const ValueEnumerator &VE,
Record.clear();
}
static void WriteGenericDebugNode(const GenericDebugNode *,
const ValueEnumerator &, BitstreamWriter &,
SmallVectorImpl<uint64_t> &, unsigned) {
llvm_unreachable("unimplemented");
static void WriteGenericDebugNode(const GenericDebugNode *N,
const ValueEnumerator &VE,
BitstreamWriter &Stream,
SmallVectorImpl<uint64_t> &Record,
unsigned Abbrev) {
Record.push_back(N->isDistinct());
Record.push_back(N->getTag());
Record.push_back(0); // Per-tag version field; unused for now.
for (auto &I : N->operands())
Record.push_back(VE.getMetadataOrNullID(I));
Stream.EmitRecord(bitc::METADATA_GENERIC_DEBUG, Record, Abbrev);
Record.clear();
}
static void WriteModuleMetadata(const Module *M,
@ -833,6 +843,23 @@ static void WriteModuleMetadata(const Module *M,
MDLocationAbbrev = Stream.EmitAbbrev(Abbv);
}
unsigned GenericDebugNodeAbbrev = 0;
if (VE.hasGenericDebugNode()) {
// Abbrev for METADATA_GENERIC_DEBUG.
//
// Assume the column is usually under 128, and always output the inlined-at
// location (it's never more expensive than building an array size 1).
BitCodeAbbrev *Abbv = new BitCodeAbbrev();
Abbv->Add(BitCodeAbbrevOp(bitc::METADATA_GENERIC_DEBUG));
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
GenericDebugNodeAbbrev = Stream.EmitAbbrev(Abbv);
}
unsigned NameAbbrev = 0;
if (!M->named_metadata_empty()) {
// Abbrev for METADATA_NAME.
@ -844,7 +871,6 @@ static void WriteModuleMetadata(const Module *M,
}
unsigned MDTupleAbbrev = 0;
unsigned GenericDebugNodeAbbrev = 0;
SmallVector<uint64_t, 64> Record;
for (const Metadata *MD : MDs) {
if (const MDNode *N = dyn_cast<MDNode>(MD)) {

View File

@ -284,7 +284,7 @@ static bool isIntOrIntVectorValue(const std::pair<const Value*, unsigned> &V) {
}
ValueEnumerator::ValueEnumerator(const Module &M)
: HasMDString(false), HasMDLocation(false) {
: HasMDString(false), HasMDLocation(false), HasGenericDebugNode(false) {
if (shouldPreserveBitcodeUseListOrder())
UseListOrders = predictUseListOrder(M);
@ -544,6 +544,7 @@ void ValueEnumerator::EnumerateMetadata(const Metadata *MD) {
HasMDString |= isa<MDString>(MD);
HasMDLocation |= isa<MDLocation>(MD);
HasGenericDebugNode |= isa<GenericDebugNode>(MD);
// Replace the dummy ID inserted above with the correct one. MDValueMap may
// have changed by inserting operands, so we need a fresh lookup here.

View File

@ -66,6 +66,7 @@ private:
MetadataMapType MDValueMap;
bool HasMDString;
bool HasMDLocation;
bool HasGenericDebugNode;
typedef DenseMap<AttributeSet, unsigned> AttributeGroupMapType;
AttributeGroupMapType AttributeGroupMap;
@ -120,6 +121,7 @@ public:
bool hasMDString() const { return HasMDString; }
bool hasMDLocation() const { return HasMDLocation; }
bool hasGenericDebugNode() const { return HasGenericDebugNode; }
unsigned getTypeID(Type *T) const {
TypeMapType::const_iterator I = TypeMap.find(T);