aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp101
1 files changed, 3 insertions, 98 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index d284c98..9c63116 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -100,6 +100,9 @@ static cl::opt<bool> ExpandConstantExprs(
cl::desc(
"Expand constant expressions to instructions for testing purposes"));
+// Declare external flag for whether we're using the new debug-info format.
+extern llvm::cl::opt<bool> UseNewDbgInfoFormat;
+
namespace {
enum {
@@ -4276,10 +4279,6 @@ Error BitcodeReader::parseGlobalIndirectSymbolRecord(
Error BitcodeReader::parseModule(uint64_t ResumeBit,
bool ShouldLazyLoadMetadata,
ParserCallbacks Callbacks) {
- // Force the debug-info mode into the old format for now.
- // FIXME: Remove this once all tools support RemoveDIs.
- TheModule->IsNewDbgInfoFormat = false;
-
this->ValueTypeCallback = std::move(Callbacks.ValueType);
if (ResumeBit) {
if (Error JumpFailed = Stream.JumpToBit(ResumeBit))
@@ -6399,89 +6398,6 @@ Error BitcodeReader::parseFunctionBody(Function *F) {
InstructionList.push_back(I);
break;
}
- case bitc::FUNC_CODE_DEBUG_RECORD_LABEL: {
- // DPLabels are placed after the Instructions that they are attached to.
- Instruction *Inst = getLastInstruction();
- if (!Inst)
- return error("Invalid dbg record: missing instruction");
- DILocation *DIL = cast<DILocation>(getFnMetadataByID(Record[0]));
- DILabel *Label = cast<DILabel>(getFnMetadataByID(Record[1]));
- Inst->getParent()->insertDbgRecordBefore(
- new DPLabel(Label, DebugLoc(DIL)), Inst->getIterator());
- continue; // This isn't an instruction.
- }
- case bitc::FUNC_CODE_DEBUG_RECORD_VALUE_SIMPLE:
- case bitc::FUNC_CODE_DEBUG_RECORD_VALUE:
- case bitc::FUNC_CODE_DEBUG_RECORD_DECLARE:
- case bitc::FUNC_CODE_DEBUG_RECORD_ASSIGN: {
- // DPValues are placed after the Instructions that they are attached to.
- Instruction *Inst = getLastInstruction();
- if (!Inst)
- return error("Invalid dbg record: missing instruction");
-
- // First 3 fields are common to all kinds:
- // DILocation, DILocalVariable, DIExpression
- // dbg_value (FUNC_CODE_DEBUG_RECORD_VALUE)
- // ..., LocationMetadata
- // dbg_value (FUNC_CODE_DEBUG_RECORD_VALUE_SIMPLE - abbrev'd)
- // ..., Value
- // dbg_declare (FUNC_CODE_DEBUG_RECORD_DECLARE)
- // ..., LocationMetadata
- // dbg_assign (FUNC_CODE_DEBUG_RECORD_ASSIGN)
- // ..., LocationMetadata, DIAssignID, DIExpression, LocationMetadata
- unsigned Slot = 0;
- // Common fields (0-2).
- DILocation *DIL = cast<DILocation>(getFnMetadataByID(Record[Slot++]));
- DILocalVariable *Var =
- cast<DILocalVariable>(getFnMetadataByID(Record[Slot++]));
- DIExpression *Expr =
- cast<DIExpression>(getFnMetadataByID(Record[Slot++]));
-
- // Union field (3: LocationMetadata | Value).
- Metadata *RawLocation = nullptr;
- if (BitCode == bitc::FUNC_CODE_DEBUG_RECORD_VALUE_SIMPLE) {
- Value *V = nullptr;
- unsigned TyID = 0;
- // We never expect to see a fwd reference value here because
- // use-before-defs are encoded with the standard non-abbrev record
- // type (they'd require encoding the type too, and they're rare). As a
- // result, getValueTypePair only ever increments Slot by one here (once
- // for the value, never twice for value and type).
- unsigned SlotBefore = Slot;
- if (getValueTypePair(Record, Slot, NextValueNo, V, TyID, CurBB))
- return error("Invalid dbg record: invalid value");
- (void)SlotBefore;
- assert((SlotBefore == Slot - 1) && "unexpected fwd ref");
- RawLocation = ValueAsMetadata::get(V);
- } else {
- RawLocation = getFnMetadataByID(Record[Slot++]);
- }
-
- DPValue *DPV = nullptr;
- switch (BitCode) {
- case bitc::FUNC_CODE_DEBUG_RECORD_VALUE:
- case bitc::FUNC_CODE_DEBUG_RECORD_VALUE_SIMPLE:
- DPV = new DPValue(RawLocation, Var, Expr, DIL,
- DPValue::LocationType::Value);
- break;
- case bitc::FUNC_CODE_DEBUG_RECORD_DECLARE:
- DPV = new DPValue(RawLocation, Var, Expr, DIL,
- DPValue::LocationType::Declare);
- break;
- case bitc::FUNC_CODE_DEBUG_RECORD_ASSIGN: {
- DIAssignID *ID = cast<DIAssignID>(getFnMetadataByID(Record[Slot++]));
- DIExpression *AddrExpr =
- cast<DIExpression>(getFnMetadataByID(Record[Slot++]));
- Metadata *Addr = getFnMetadataByID(Record[Slot++]);
- DPV = new DPValue(RawLocation, Var, Expr, ID, Addr, AddrExpr, DIL);
- break;
- }
- default:
- llvm_unreachable("Unknown DPValue bitcode");
- }
- Inst->getParent()->insertDbgRecordBefore(DPV, Inst->getIterator());
- continue; // This isn't an instruction.
- }
case bitc::FUNC_CODE_INST_CALL: {
// CALL: [paramattrs, cc, fmf, fnty, fnid, arg0, arg1...]
if (Record.size() < 3)
@@ -6761,21 +6677,10 @@ Error BitcodeReader::materialize(GlobalValue *GV) {
// Move the bit stream to the saved position of the deferred function body.
if (Error JumpFailed = Stream.JumpToBit(DFII->second))
return JumpFailed;
-
- // Set the debug info mode to "new", forcing a mismatch between
- // module and function debug modes. This is okay because we'll convert
- // everything back to the old mode after parsing.
- // FIXME: Remove this once all tools support RemoveDIs.
- F->IsNewDbgInfoFormat = true;
-
if (Error Err = parseFunctionBody(F))
return Err;
F->setIsMaterializable(false);
- // Convert new debug info records into intrinsics.
- // FIXME: Remove this once all tools support RemoveDIs.
- F->convertFromNewDbgValues();
-
if (StripDebugInfo)
stripDebugInfo(*F);