summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Bitcode/Writer
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2015-03-30 19:40:05 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2015-03-30 19:40:05 +0000
commitab659fb3d03005114e176cb86449636e0635f16a (patch)
tree8382ab9e3536192f4e3e815e6ff85a6dbb89a687 /llvm/lib/Bitcode/Writer
parent364266663bc16789c0fd07fe6ed5e5e8049573f4 (diff)
downloadbcm5719-llvm-ab659fb3d03005114e176cb86449636e0635f16a.tar.gz
bcm5719-llvm-ab659fb3d03005114e176cb86449636e0635f16a.zip
IR: Use the new DebugLoc API, NFC
Update lib/IR and lib/Bitcode to use the new `DebugLoc` API. Added an explicit conversion to `bool` (avoiding a conversion to `MDLocation`), since a couple of these use cases need to handle broken code. llvm-svn: 233585
Diffstat (limited to 'llvm/lib/Bitcode/Writer')
-rw-r--r--llvm/lib/Bitcode/Writer/BitcodeWriter.cpp21
-rw-r--r--llvm/lib/Bitcode/Writer/ValueEnumerator.cpp10
2 files changed, 11 insertions, 20 deletions
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
index d80d21d01c5..71ba01e6668 100644
--- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -2089,7 +2089,7 @@ static void WriteFunction(const Function &F, ValueEnumerator &VE,
bool NeedsMetadataAttachment = false;
- DebugLoc LastDL;
+ MDLocation *LastDL = nullptr;
// Finally, emit all the instructions, in order.
for (Function::const_iterator BB = F.begin(), E = F.end(); BB != E; ++BB)
@@ -2104,10 +2104,9 @@ static void WriteFunction(const Function &F, ValueEnumerator &VE,
NeedsMetadataAttachment |= I->hasMetadataOtherThanDebugLoc();
// If the instruction has a debug location, emit it.
- DebugLoc DL = I->getDebugLoc();
- if (DL.isUnknown()) {
+ MDLocation *DL = I->getDebugLoc();
+ if (!DL)
continue;
- }
if (DL == LastDL) {
// Just repeat the same debug loc as last time.
@@ -2115,18 +2114,12 @@ static void WriteFunction(const Function &F, ValueEnumerator &VE,
continue;
}
- MDNode *Scope, *IA;
- DL.getScopeAndInlinedAt(Scope, IA, I->getContext());
- assert(Scope && "Expected valid scope");
-
- Vals.push_back(DL.getLine());
- Vals.push_back(DL.getCol());
- Vals.push_back(VE.getMetadataOrNullID(Scope));
- Vals.push_back(VE.getMetadataOrNullID(IA));
+ Vals.push_back(DL->getLine());
+ Vals.push_back(DL->getColumn());
+ Vals.push_back(VE.getMetadataOrNullID(DL->getScope()));
+ Vals.push_back(VE.getMetadataOrNullID(DL->getInlinedAt()));
Stream.EmitRecord(bitc::FUNC_CODE_DEBUG_LOC, Vals);
Vals.clear();
-
- LastDL = DL;
}
// Emit names for all the instructions etc.
diff --git a/llvm/lib/Bitcode/Writer/ValueEnumerator.cpp b/llvm/lib/Bitcode/Writer/ValueEnumerator.cpp
index 549e94fc96a..a450f697f20 100644
--- a/llvm/lib/Bitcode/Writer/ValueEnumerator.cpp
+++ b/llvm/lib/Bitcode/Writer/ValueEnumerator.cpp
@@ -373,12 +373,10 @@ ValueEnumerator::ValueEnumerator(const Module &M)
for (unsigned i = 0, e = MDs.size(); i != e; ++i)
EnumerateMetadata(MDs[i].second);
- if (!I.getDebugLoc().isUnknown()) {
- MDNode *Scope, *IA;
- I.getDebugLoc().getScopeAndInlinedAt(Scope, IA, I.getContext());
- if (Scope) EnumerateMetadata(Scope);
- if (IA) EnumerateMetadata(IA);
- }
+ // Don't enumerate the location directly -- it has a special record
+ // type -- but enumerate its operands.
+ if (MDLocation *L = I.getDebugLoc())
+ EnumerateMDNodeOperands(L);
}
}
OpenPOWER on IntegriCloud