diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -3959,7 +3959,8 @@ if (!IA) return error("Invalid record"); } - LastLoc = DebugLoc::get(Line, Col, Scope, IA, isImplicitCode); + LastLoc = DILocation::get(Scope->getContext(), Line, Col, Scope, IA, + isImplicitCode); I->setDebugLoc(LastLoc); I = nullptr; continue; diff --git a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp --- a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp +++ b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp @@ -2773,8 +2773,8 @@ // We only emit constants into the entry block from here. To prevent jumpy // debug behaviour set the line to 0. if (const DebugLoc &DL = Inst.getDebugLoc()) - EntryBuilder->setDebugLoc( - DebugLoc::get(0, 0, DL.getScope(), DL.getInlinedAt())); + EntryBuilder->setDebugLoc(DILocation::get( + Inst.getContext(), 0, 0, DL.getScope(), DL.getInlinedAt())); else EntryBuilder->setDebugLoc(DebugLoc()); diff --git a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp --- a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp +++ b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp @@ -756,8 +756,9 @@ /// just return the builder for it. MachineInstrBuilder emitLoc(Optional MLoc, const DebugVariable &Var, const DbgValueProperties &Properties) { - DebugLoc DL = - DebugLoc::get(0, 0, Var.getVariable()->getScope(), Var.getInlinedAt()); + DebugLoc DL = DILocation::get(Var.getVariable()->getContext(), 0, 0, + Var.getVariable()->getScope(), + const_cast(Var.getInlinedAt())); auto MIB = BuildMI(MF, DL, TII.get(TargetOpcode::DBG_VALUE)); const DIExpression *Expr = Properties.DIExpr; @@ -1280,8 +1281,9 @@ MachineInstrBuilder emitMOLoc(const MachineOperand &MO, const DebugVariable &Var, const DbgValueProperties &Properties) { - DebugLoc DL = - DebugLoc::get(0, 0, Var.getVariable()->getScope(), Var.getInlinedAt()); + DebugLoc DL = DILocation::get(Var.getVariable()->getContext(), 0, 0, + Var.getVariable()->getScope(), + const_cast(Var.getInlinedAt())); auto MIB = BuildMI(MF, DL, TII->get(TargetOpcode::DBG_VALUE)); MIB.add(MO); if (Properties.Indirect) diff --git a/llvm/lib/CodeGen/SafeStack.cpp b/llvm/lib/CodeGen/SafeStack.cpp --- a/llvm/lib/CodeGen/SafeStack.cpp +++ b/llvm/lib/CodeGen/SafeStack.cpp @@ -789,7 +789,8 @@ // Calls must always have a debug location, or else inlining breaks. So // we explicitly set a artificial debug location here. if (DISubprogram *SP = F.getSubprogram()) - IRB.SetCurrentDebugLocation(DebugLoc::get(SP->getScopeLine(), 0, SP)); + IRB.SetCurrentDebugLocation( + DILocation::get(SP->getContext(), SP->getScopeLine(), 0, SP)); if (SafeStackUsePointerAddress) { FunctionCallee Fn = F.getParent()->getOrInsertFunction( "__safestack_pointer_address", StackPtrTy->getPointerTo(0)); diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp --- a/llvm/lib/IR/DebugInfo.cpp +++ b/llvm/lib/IR/DebugInfo.cpp @@ -652,7 +652,8 @@ MDNode *InlinedAt = DL.getInlinedAt(); Scope = remap(Scope); InlinedAt = remap(InlinedAt); - return DebugLoc::get(DL.getLine(), DL.getCol(), Scope, InlinedAt); + return DILocation::get(M.getContext(), DL.getLine(), DL.getCol(), + Scope, InlinedAt); }; if (I.getDebugLoc() != DebugLoc()) @@ -712,12 +713,12 @@ // Set a line 0 location for calls to preserve scope information in case // inlining occurs. - const DISubprogram *SP = getFunction()->getSubprogram(); + DISubprogram *SP = getFunction()->getSubprogram(); if (SP) // If a function scope is available, set it on the line 0 location. When // hoisting a call to a predecessor block, using the function scope avoids // making it look like the callee was reached earlier than it should be. - setDebugLoc(DebugLoc::get(0, 0, SP)); + setDebugLoc(DILocation::get(getContext(), 0, 0, SP)); else // The parent function has no scope. Go ahead and drop the location. If // the parent function is inlined, and the callee has a subprogram, the diff --git a/llvm/lib/IR/DebugLoc.cpp b/llvm/lib/IR/DebugLoc.cpp --- a/llvm/lib/IR/DebugLoc.cpp +++ b/llvm/lib/IR/DebugLoc.cpp @@ -50,7 +50,7 @@ // FIXME: Add a method on \a DILocation that does this work. const MDNode *Scope = getInlinedAtScope(); if (auto *SP = getDISubprogram(Scope)) - return DebugLoc::get(SP->getScopeLine(), 0, SP); + return DILocation::get(SP->getContext(), SP->getScopeLine(), 0, SP); return DebugLoc(); } diff --git a/llvm/lib/Transforms/IPO/MergeFunctions.cpp b/llvm/lib/Transforms/IPO/MergeFunctions.cpp --- a/llvm/lib/Transforms/IPO/MergeFunctions.cpp +++ b/llvm/lib/Transforms/IPO/MergeFunctions.cpp @@ -725,8 +725,10 @@ if (MergeFunctionsPDI) { DISubprogram *DIS = G->getSubprogram(); if (DIS) { - DebugLoc CIDbgLoc = DebugLoc::get(DIS->getScopeLine(), 0, DIS); - DebugLoc RIDbgLoc = DebugLoc::get(DIS->getScopeLine(), 0, DIS); + DebugLoc CIDbgLoc = + DILocation::get(DIS->getContext(), DIS->getScopeLine(), 0, DIS); + DebugLoc RIDbgLoc = + DILocation::get(DIS->getContext(), DIS->getScopeLine(), 0, DIS); CI->setDebugLoc(CIDbgLoc); RI->setDebugLoc(RIDbgLoc); } else { diff --git a/llvm/lib/Transforms/IPO/SampleProfileProbe.cpp b/llvm/lib/Transforms/IPO/SampleProfileProbe.cpp --- a/llvm/lib/Transforms/IPO/SampleProfileProbe.cpp +++ b/llvm/lib/Transforms/IPO/SampleProfileProbe.cpp @@ -122,7 +122,7 @@ "Expecting pseudo probe or call instructions"); if (!I->getDebugLoc()) { if (auto *SP = F.getSubprogram()) { - auto DIL = DebugLoc::get(0, 0, SP); + auto DIL = DILocation::get(SP->getContext(), 0, 0, SP); I->setDebugLoc(DIL); ArtificialDbgLine++; LLVM_DEBUG({ diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp --- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -3105,7 +3105,8 @@ int StackMallocIdx = -1; DebugLoc EntryDebugLocation; if (auto SP = F.getSubprogram()) - EntryDebugLocation = DebugLoc::get(SP->getScopeLine(), 0, SP); + EntryDebugLocation = + DILocation::get(SP->getContext(), SP->getScopeLine(), 0, SP); Instruction *InsBefore = AllocaVec[0]; IRBuilder<> IRB(InsBefore); diff --git a/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp b/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp --- a/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp +++ b/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp @@ -883,7 +883,7 @@ DebugLoc EntryLoc; if (IsEntryBB) { if (auto SP = F.getSubprogram()) - EntryLoc = DebugLoc::get(SP->getScopeLine(), 0, SP); + EntryLoc = DILocation::get(SP->getContext(), SP->getScopeLine(), 0, SP); // Keep static allocas and llvm.localescape calls in the entry block. Even // if we aren't splitting the block, it's nice for allocas to be before // calls. diff --git a/llvm/lib/Transforms/Utils/CodeExtractor.cpp b/llvm/lib/Transforms/Utils/CodeExtractor.cpp --- a/llvm/lib/Transforms/Utils/CodeExtractor.cpp +++ b/llvm/lib/Transforms/Utils/CodeExtractor.cpp @@ -1547,7 +1547,7 @@ // function. for (Instruction &I : instructions(NewFunc)) { if (const DebugLoc &DL = I.getDebugLoc()) - I.setDebugLoc(DebugLoc::get(DL.getLine(), DL.getCol(), NewSP)); + I.setDebugLoc(DILocation::get(Ctx, DL.getLine(), DL.getCol(), NewSP)); // Loop info metadata may contain line locations. Fix them up. auto updateLoopInfoLoc = [&Ctx, @@ -1558,7 +1558,7 @@ updateLoopMetadataDebugLocations(I, updateLoopInfoLoc); } if (!TheCall.getDebugLoc()) - TheCall.setDebugLoc(DebugLoc::get(0, 0, OldSP)); + TheCall.setDebugLoc(DILocation::get(Ctx, 0, 0, OldSP)); eraseDebugIntrinsicsWithNonLocalRefs(NewFunc); } diff --git a/llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp b/llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp --- a/llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp +++ b/llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp @@ -83,7 +83,7 @@ if (!EntryFunc.empty()) { DebugLoc DL; if (auto SP = F.getSubprogram()) - DL = DebugLoc::get(SP->getScopeLine(), 0, SP); + DL = DILocation::get(SP->getContext(), SP->getScopeLine(), 0, SP); insertCall(F, EntryFunc, &*F.begin()->getFirstInsertionPt(), DL); Changed = true; @@ -104,7 +104,7 @@ if (DebugLoc TerminatorDL = T->getDebugLoc()) DL = TerminatorDL; else if (auto SP = F.getSubprogram()) - DL = DebugLoc::get(0, 0, SP); + DL = DILocation::get(SP->getContext(), 0, 0, SP); insertCall(F, ExitFunc, T, DL); Changed = true; diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp --- a/llvm/lib/Transforms/Utils/InlineFunction.cpp +++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp @@ -1443,8 +1443,8 @@ LLVMContext &Ctx, DenseMap &IANodes) { auto IA = DebugLoc::appendInlinedAt(OrigDL, InlinedAt, Ctx, IANodes); - return DebugLoc::get(OrigDL.getLine(), OrigDL.getCol(), OrigDL.getScope(), - IA); + return DILocation::get(Ctx, OrigDL.getLine(), OrigDL.getCol(), + OrigDL.getScope(), IA); } /// Update inlined instructions' line numbers to diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp --- a/llvm/lib/Transforms/Utils/Local.cpp +++ b/llvm/lib/Transforms/Utils/Local.cpp @@ -1392,7 +1392,7 @@ MDNode *Scope = DeclareLoc.getScope(); DILocation *InlinedAt = DeclareLoc.getInlinedAt(); // Produce an unknown location with the correct scope / inlinedAt fields. - return DebugLoc::get(0, 0, Scope, InlinedAt); + return DILocation::get(DII->getContext(), 0, 0, Scope, InlinedAt); } /// Inserts a llvm.dbg.value intrinsic before a store to an alloca'd value