diff options
Diffstat (limited to 'llvm/lib')
26 files changed, 25 insertions, 258 deletions
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp index 5c007dc..926dc62 100644 --- a/llvm/lib/AsmParser/LLParser.cpp +++ b/llvm/lib/AsmParser/LLParser.cpp @@ -441,8 +441,6 @@ bool LLParser::validateEndOfModule(bool UpgradeDebugInfo) { UpgradeNVVMAnnotations(*M); UpgradeSectionAttributes(*M); - M->setIsNewDbgInfoFormat(true); - if (!Slots) return false; // Initialize the slot mapping. @@ -6906,8 +6904,6 @@ bool LLParser::parseBasicBlock(PerFunctionState &PFS) { if (SeenOldDbgInfoFormat) return error(Lex.getLoc(), "debug record should not appear in a module " "containing debug info intrinsics"); - if (!SeenNewDbgInfoFormat) - M->setNewDbgInfoFormatFlag(true); SeenNewDbgInfoFormat = true; Lex.Lex(); diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index 31129b7..fde934fb 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -4479,10 +4479,6 @@ Error BitcodeReader::parseGlobalIndirectSymbolRecord( Error BitcodeReader::parseModule(uint64_t ResumeBit, bool ShouldLazyLoadMetadata, ParserCallbacks Callbacks) { - // Don't allow modules to use debug-intrinsics: autoupgrading them is now - // mandatory. - TheModule->IsNewDbgInfoFormat = true; - this->ValueTypeCallback = std::move(Callbacks.ValueType); if (ResumeBit) { if (Error JumpFailed = Stream.JumpToBit(ResumeBit)) @@ -6994,10 +6990,6 @@ Error BitcodeReader::materialize(GlobalValue *GV) { if (Error JumpFailed = Stream.JumpToBit(DFII->second)) return JumpFailed; - // Regardless of the debug info format we want to end up in, we need - // IsNewDbgInfoFormat=true to construct any debug records seen in the bitcode. - F->IsNewDbgInfoFormat = true; - if (Error Err = parseFunctionBody(F)) return Err; F->setIsMaterializable(false); diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp index 32348a8..3792b45 100644 --- a/llvm/lib/CodeGen/CodeGenPrepare.cpp +++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp @@ -3335,8 +3335,7 @@ class TypePromotionTransaction { // Record where we would have to re-insert the instruction in the sequence // of DbgRecords, if we ended up reinserting. - if (BB->IsNewDbgInfoFormat) - BeforeDbgRecord = Inst->getDbgReinsertionPosition(); + BeforeDbgRecord = Inst->getDbgReinsertionPosition(); if (HasPrevInstruction) { Point.PrevInst = std::prev(Inst->getIterator()); diff --git a/llvm/lib/IR/BasicBlock.cpp b/llvm/lib/IR/BasicBlock.cpp index 62a7531..8b3e917 100644 --- a/llvm/lib/IR/BasicBlock.cpp +++ b/llvm/lib/IR/BasicBlock.cpp @@ -52,8 +52,6 @@ DbgMarker *BasicBlock::createMarker(InstListType::iterator It) { } void BasicBlock::convertToNewDbgValues() { - IsNewDbgInfoFormat = true; - // Iterate over all instructions in the instruction list, collecting debug // info intrinsics and converting them to DbgRecords. Once we find a "real" // instruction, attach all those DbgRecords to a DbgMarker in that @@ -91,7 +89,6 @@ void BasicBlock::convertToNewDbgValues() { void BasicBlock::convertFromNewDbgValues() { invalidateOrders(); - IsNewDbgInfoFormat = false; // Iterate over the block, finding instructions annotated with DbgMarkers. // Convert any attached DbgRecords to debug intrinsics and insert ahead of the @@ -126,16 +123,6 @@ void BasicBlock::dumpDbgValues() const { } #endif -void BasicBlock::setIsNewDbgInfoFormat(bool NewFlag) { - if (NewFlag && !IsNewDbgInfoFormat) - convertToNewDbgValues(); - else if (!NewFlag && IsNewDbgInfoFormat) - convertFromNewDbgValues(); -} -void BasicBlock::setNewDbgInfoFormatFlag(bool NewFlag) { - IsNewDbgInfoFormat = NewFlag; -} - ValueSymbolTable *BasicBlock::getValueSymbolTable() { if (Function *F = getParent()) return F->getValueSymbolTable(); @@ -157,8 +144,7 @@ template class llvm::SymbolTableListTraits< BasicBlock::BasicBlock(LLVMContext &C, const Twine &Name, Function *NewParent, BasicBlock *InsertBefore) - : Value(Type::getLabelTy(C), Value::BasicBlockVal), - IsNewDbgInfoFormat(true), Parent(nullptr) { + : Value(Type::getLabelTy(C), Value::BasicBlockVal), Parent(nullptr) { if (NewParent) insertInto(NewParent, InsertBefore); @@ -168,8 +154,6 @@ BasicBlock::BasicBlock(LLVMContext &C, const Twine &Name, Function *NewParent, end().getNodePtr()->setParent(this); setName(Name); - if (NewParent) - setIsNewDbgInfoFormat(NewParent->IsNewDbgInfoFormat); } void BasicBlock::insertInto(Function *NewParent, BasicBlock *InsertBefore) { @@ -180,8 +164,6 @@ void BasicBlock::insertInto(Function *NewParent, BasicBlock *InsertBefore) { NewParent->insert(InsertBefore->getIterator(), this); else NewParent->insert(NewParent->end(), this); - - setIsNewDbgInfoFormat(NewParent->IsNewDbgInfoFormat); } BasicBlock::~BasicBlock() { @@ -725,10 +707,6 @@ void BasicBlock::flushTerminatorDbgRecords() { // check whether there's anything trailing at the end and move those // DbgRecords in front of the terminator. - // Do nothing if we're not in new debug-info format. - if (!IsNewDbgInfoFormat) - return; - // If there's no terminator, there's nothing to do. Instruction *Term = getTerminator(); if (!Term) @@ -765,10 +743,6 @@ void BasicBlock::spliceDebugInfoEmptyBlock(BasicBlock::iterator Dest, // in the iterators whether there was the intention to transfer any debug // info. - // If we're not in "new" debug-info format, do nothing. - if (!IsNewDbgInfoFormat) - return; - assert(First == Last); bool InsertAtHead = Dest.getHeadBit(); bool ReadFromHead = First.getHeadBit(); @@ -1029,8 +1003,6 @@ void BasicBlock::spliceDebugInfoImpl(BasicBlock::iterator Dest, BasicBlock *Src, void BasicBlock::splice(iterator Dest, BasicBlock *Src, iterator First, iterator Last) { - assert(Src->IsNewDbgInfoFormat == IsNewDbgInfoFormat); - #ifdef EXPENSIVE_CHECKS // Check that First is before Last. auto FromBBEnd = Src->end(); @@ -1045,9 +1017,7 @@ void BasicBlock::splice(iterator Dest, BasicBlock *Src, iterator First, return; } - // Handle non-instr debug-info specific juggling. - if (IsNewDbgInfoFormat) - spliceDebugInfo(Dest, Src, First, Last); + spliceDebugInfo(Dest, Src, First, Last); // And move the instructions. getInstList().splice(Dest, Src->getInstList(), First, Last); @@ -1056,7 +1026,6 @@ void BasicBlock::splice(iterator Dest, BasicBlock *Src, iterator First, } void BasicBlock::insertDbgRecordAfter(DbgRecord *DR, Instruction *I) { - assert(IsNewDbgInfoFormat); assert(I->getParent() == this); iterator NextIt = std::next(I->getIterator()); diff --git a/llvm/lib/IR/Core.cpp b/llvm/lib/IR/Core.cpp index a7c3a56..9810f04 100644 --- a/llvm/lib/IR/Core.cpp +++ b/llvm/lib/IR/Core.cpp @@ -431,12 +431,12 @@ void LLVMAddModuleFlag(LLVMModuleRef M, LLVMModuleFlagBehavior Behavior, {Key, KeyLen}, unwrap(Val)); } -LLVMBool LLVMIsNewDbgInfoFormat(LLVMModuleRef M) { - return unwrap(M)->IsNewDbgInfoFormat; -} +LLVMBool LLVMIsNewDbgInfoFormat(LLVMModuleRef M) { return true; } void LLVMSetIsNewDbgInfoFormat(LLVMModuleRef M, LLVMBool UseNewFormat) { - unwrap(M)->setIsNewDbgInfoFormat(UseNewFormat); + if (!UseNewFormat) + llvm_unreachable("LLVM no longer supports intrinsic based debug-info"); + (void)M; } /*--.. Printing modules ....................................................--*/ diff --git a/llvm/lib/IR/Function.cpp b/llvm/lib/IR/Function.cpp index 493dec7..28fb810 100644 --- a/llvm/lib/IR/Function.cpp +++ b/llvm/lib/IR/Function.cpp @@ -87,32 +87,17 @@ void Function::validateBlockNumbers() const { } void Function::convertToNewDbgValues() { - IsNewDbgInfoFormat = true; for (auto &BB : *this) { BB.convertToNewDbgValues(); } } void Function::convertFromNewDbgValues() { - IsNewDbgInfoFormat = false; for (auto &BB : *this) { BB.convertFromNewDbgValues(); } } -void Function::setIsNewDbgInfoFormat(bool NewFlag) { - if (NewFlag && !IsNewDbgInfoFormat) - convertToNewDbgValues(); - else if (!NewFlag && IsNewDbgInfoFormat) - convertFromNewDbgValues(); -} -void Function::setNewDbgInfoFormatFlag(bool NewFlag) { - for (auto &BB : *this) { - BB.setNewDbgInfoFormatFlag(NewFlag); - } - IsNewDbgInfoFormat = NewFlag; -} - //===----------------------------------------------------------------------===// // Argument Implementation //===----------------------------------------------------------------------===// @@ -490,7 +475,7 @@ Function::Function(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace, const Twine &name, Module *ParentModule) : GlobalObject(Ty, Value::FunctionVal, AllocMarker, Linkage, name, computeAddrSpace(AddrSpace, ParentModule)), - NumArgs(Ty->getNumParams()), IsNewDbgInfoFormat(true) { + NumArgs(Ty->getNumParams()) { assert(FunctionType::isValidReturnType(getReturnType()) && "invalid return type"); setGlobalObjectSubClassData(0); @@ -505,7 +490,6 @@ Function::Function(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace, if (ParentModule) { ParentModule->getFunctionList().push_back(this); - IsNewDbgInfoFormat = ParentModule->IsNewDbgInfoFormat; } HasLLVMReservedName = getName().starts_with("llvm."); diff --git a/llvm/lib/IR/Instruction.cpp b/llvm/lib/IR/Instruction.cpp index 109d516..1b60caa 100644 --- a/llvm/lib/IR/Instruction.cpp +++ b/llvm/lib/IR/Instruction.cpp @@ -86,7 +86,7 @@ void Instruction::removeFromParent() { } void Instruction::handleMarkerRemoval() { - if (!getParent()->IsNewDbgInfoFormat || !DebugMarker) + if (!DebugMarker) return; DebugMarker->removeMarker(); @@ -136,9 +136,6 @@ void Instruction::insertBefore(BasicBlock &BB, BB.getInstList().insert(InsertPos, this); - if (!BB.IsNewDbgInfoFormat) - return; - // We've inserted "this": if InsertAtHead is set then it comes before any // DbgVariableRecords attached to InsertPos. But if it's not set, then any // DbgRecords should now come before "this". @@ -226,7 +223,7 @@ void Instruction::moveBeforeImpl(BasicBlock &BB, InstListType::iterator I, // If we've been given the "Preserve" flag, then just move the DbgRecords with // the instruction, no more special handling needed. - if (BB.IsNewDbgInfoFormat && DebugMarker && !Preserve) { + if (DebugMarker && !Preserve) { if (I != this->getIterator() || InsertAtHead) { // "this" is definitely moving in the list, or it's moving ahead of its // attached DbgVariableRecords. Detach any existing DbgRecords. @@ -238,7 +235,7 @@ void Instruction::moveBeforeImpl(BasicBlock &BB, InstListType::iterator I, // the block splicer, which will do more debug-info things. BB.getInstList().splice(I, getParent()->getInstList(), getIterator()); - if (BB.IsNewDbgInfoFormat && !Preserve) { + if (!Preserve) { DbgMarker *NextMarker = getParent()->getNextMarker(this); // If we're inserting at point I, and not in front of the DbgRecords @@ -258,10 +255,6 @@ iterator_range<DbgRecord::self_iterator> Instruction::cloneDebugInfoFrom( if (!From->DebugMarker) return DbgMarker::getEmptyDbgRecordRange(); - assert(getParent()->IsNewDbgInfoFormat); - assert(getParent()->IsNewDbgInfoFormat == - From->getParent()->IsNewDbgInfoFormat); - if (!DebugMarker) getParent()->createMarker(this); diff --git a/llvm/lib/IR/Module.cpp b/llvm/lib/IR/Module.cpp index 0a47f98..37f4a72 100644 --- a/llvm/lib/IR/Module.cpp +++ b/llvm/lib/IR/Module.cpp @@ -71,8 +71,7 @@ template class LLVM_EXPORT_TEMPLATE llvm::SymbolTableListTraits<GlobalIFunc>; Module::Module(StringRef MID, LLVMContext &C) : Context(C), ValSymTab(std::make_unique<ValueSymbolTable>(-1)), - ModuleID(std::string(MID)), SourceFileName(std::string(MID)), - IsNewDbgInfoFormat(true) { + ModuleID(std::string(MID)), SourceFileName(std::string(MID)) { Context.addModule(this); } @@ -83,7 +82,6 @@ Module &Module::operator=(Module &&Other) { ModuleID = std::move(Other.ModuleID); SourceFileName = std::move(Other.SourceFileName); - IsNewDbgInfoFormat = std::move(Other.IsNewDbgInfoFormat); GlobalList.clear(); GlobalList.splice(GlobalList.begin(), Other.GlobalList); diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index 9ec94a8..1f1041b 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -2878,11 +2878,6 @@ void Verifier::visitFunction(const Function &F) { Check(verifyAttributeCount(Attrs, FT->getNumParams()), "Attribute after last parameter!", &F); - CheckDI(F.IsNewDbgInfoFormat == F.getParent()->IsNewDbgInfoFormat, - "Function debug format should match parent module", &F, - F.IsNewDbgInfoFormat, F.getParent(), - F.getParent()->IsNewDbgInfoFormat); - bool IsIntrinsic = F.isIntrinsic(); // Check function attributes. @@ -3233,15 +3228,9 @@ void Verifier::visitBasicBlock(BasicBlock &BB) { Check(I.getParent() == &BB, "Instruction has bogus parent pointer!"); } - CheckDI(BB.IsNewDbgInfoFormat == BB.getParent()->IsNewDbgInfoFormat, - "BB debug format should match parent function", &BB, - BB.IsNewDbgInfoFormat, BB.getParent(), - BB.getParent()->IsNewDbgInfoFormat); - // Confirm that no issues arise from the debug program. - if (BB.IsNewDbgInfoFormat) - CheckDI(!BB.getTrailingDbgRecords(), "Basic Block has trailing DbgRecords!", - &BB); + CheckDI(!BB.getTrailingDbgRecords(), "Basic Block has trailing DbgRecords!", + &BB); } void Verifier::visitTerminator(Instruction &I) { diff --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp index df39507..adf995c 100644 --- a/llvm/lib/LTO/LTO.cpp +++ b/llvm/lib/LTO/LTO.cpp @@ -599,9 +599,7 @@ LTO::RegularLTOState::RegularLTOState(unsigned ParallelCodeGenParallelismLevel, const Config &Conf) : ParallelCodeGenParallelismLevel(ParallelCodeGenParallelismLevel), Ctx(Conf), CombinedModule(std::make_unique<Module>("ld-temp.o", Ctx)), - Mover(std::make_unique<IRMover>(*CombinedModule)) { - CombinedModule->IsNewDbgInfoFormat = true; -} + Mover(std::make_unique<IRMover>(*CombinedModule)) {} LTO::ThinLTOState::ThinLTOState(ThinBackend BackendParam) : Backend(std::move(BackendParam)), CombinedIndex(/*HaveGVs*/ false) { diff --git a/llvm/lib/Linker/IRMover.cpp b/llvm/lib/Linker/IRMover.cpp index a449185..2a97090 100644 --- a/llvm/lib/Linker/IRMover.cpp +++ b/llvm/lib/Linker/IRMover.cpp @@ -595,7 +595,6 @@ Function *IRLinker::copyFunctionProto(const Function *SF) { SF->getAddressSpace(), SF->getName(), &DstM); F->copyAttributesFrom(SF); F->setAttributes(mapAttributeTypes(F->getContext(), F->getAttributes())); - F->IsNewDbgInfoFormat = SF->IsNewDbgInfoFormat; return F; } @@ -1030,7 +1029,6 @@ Error IRLinker::linkFunctionBody(Function &Dst, Function &Src) { Dst.setPrologueData(Src.getPrologueData()); if (Src.hasPersonalityFn()) Dst.setPersonalityFn(Src.getPersonalityFn()); - assert(Src.IsNewDbgInfoFormat == Dst.IsNewDbgInfoFormat); // Copy over the metadata attachments without remapping. Dst.copyMetadata(&Src, 0); diff --git a/llvm/lib/Target/AMDGPU/AMDGPULowerBufferFatPointers.cpp b/llvm/lib/Target/AMDGPU/AMDGPULowerBufferFatPointers.cpp index 0f002b0..67db961 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPULowerBufferFatPointers.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPULowerBufferFatPointers.cpp @@ -2364,7 +2364,6 @@ static Function *moveFunctionAdaptingType(Function *OldF, FunctionType *NewTy, bool IsIntrinsic = OldF->isIntrinsic(); Function *NewF = Function::Create(NewTy, OldF->getLinkage(), OldF->getAddressSpace()); - NewF->IsNewDbgInfoFormat = OldF->IsNewDbgInfoFormat; NewF->copyAttributesFrom(OldF); NewF->copyMetadata(OldF, 0); NewF->takeName(OldF); diff --git a/llvm/lib/Target/AMDGPU/AMDGPUPreloadKernelArguments.cpp b/llvm/lib/Target/AMDGPU/AMDGPUPreloadKernelArguments.cpp index 5027705..984c1ee 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPUPreloadKernelArguments.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUPreloadKernelArguments.cpp @@ -134,7 +134,6 @@ private: NF->copyAttributesFrom(&F); NF->copyMetadata(&F, 0); - NF->setIsNewDbgInfoFormat(F.IsNewDbgInfoFormat); F.getParent()->getFunctionList().insert(F.getIterator(), NF); NF->takeName(&F); diff --git a/llvm/lib/Target/AMDGPU/AMDGPURewriteOutArguments.cpp b/llvm/lib/Target/AMDGPU/AMDGPURewriteOutArguments.cpp index e100843..4b1f80c 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPURewriteOutArguments.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPURewriteOutArguments.cpp @@ -325,8 +325,6 @@ bool AMDGPURewriteOutArguments::runOnFunction(Function &F) { NewFunc->removeRetAttrs(RetAttrs); // TODO: How to preserve metadata? - NewFunc->setIsNewDbgInfoFormat(F.IsNewDbgInfoFormat); - // Move the body of the function into the new rewritten function, and replace // this function with a stub. NewFunc->splice(NewFunc->begin(), &F); diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyAddMissingPrototypes.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyAddMissingPrototypes.cpp index f02725e..344a363 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyAddMissingPrototypes.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyAddMissingPrototypes.cpp @@ -135,7 +135,6 @@ bool WebAssemblyAddMissingPrototypes::runOnModule(Module &M) { Function::Create(NewType, F.getLinkage(), F.getName() + ".fixed_sig"); NewF->setAttributes(F.getAttributes()); NewF->removeFnAttr("no-prototype"); - NewF->IsNewDbgInfoFormat = F.IsNewDbgInfoFormat; Replacements.emplace_back(&F, NewF); } diff --git a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp index 0ec5202..262c902 100644 --- a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp +++ b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp @@ -179,7 +179,6 @@ doPromotion(Function *F, FunctionAnalysisManager &FAM, F->getName()); NF->copyAttributesFrom(F); NF->copyMetadata(F, 0); - NF->setIsNewDbgInfoFormat(F->IsNewDbgInfoFormat); // The new function will have the !dbg metadata copied from the original // function. The original function may not be deleted, and dbg metadata need diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp index cbdbf9a..050eed3 100644 --- a/llvm/lib/Transforms/IPO/Attributor.cpp +++ b/llvm/lib/Transforms/IPO/Attributor.cpp @@ -2726,8 +2726,6 @@ void Attributor::createShallowWrapper(Function &F) { Function::Create(FnTy, F.getLinkage(), F.getAddressSpace(), F.getName()); F.setName(""); // set the inside function anonymous M.getFunctionList().insert(F.getIterator(), Wrapper); - // Flag whether the function is using new-debug-info or not. - Wrapper->IsNewDbgInfoFormat = M.IsNewDbgInfoFormat; F.setLinkage(GlobalValue::InternalLinkage); @@ -2808,8 +2806,6 @@ bool Attributor::internalizeFunctions(SmallPtrSetImpl<Function *> &FnSet, VMap[&Arg] = &(*NewFArgIt++); } SmallVector<ReturnInst *, 8> Returns; - // Flag whether the function is using new-debug-info or not. - Copied->IsNewDbgInfoFormat = F->IsNewDbgInfoFormat; // Copy the body of the original function to the new one CloneFunctionInto(Copied, F, VMap, @@ -3027,8 +3023,6 @@ ChangeStatus Attributor::rewriteFunctionSignatures( OldFn->getParent()->getFunctionList().insert(OldFn->getIterator(), NewFn); NewFn->takeName(OldFn); NewFn->copyAttributesFrom(OldFn); - // Flag whether the function is using new-debug-info or not. - NewFn->IsNewDbgInfoFormat = OldFn->IsNewDbgInfoFormat; // Patch the pointer to LLVM function in debug info descriptor. NewFn->setSubprogram(OldFn->getSubprogram()); diff --git a/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp b/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp index 2e2687a..d32b829 100644 --- a/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp +++ b/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp @@ -170,7 +170,6 @@ bool DeadArgumentEliminationPass::deleteDeadVarargs(Function &F) { NF->setComdat(F.getComdat()); F.getParent()->getFunctionList().insert(F.getIterator(), NF); NF->takeName(&F); - NF->IsNewDbgInfoFormat = F.IsNewDbgInfoFormat; // Loop over all the callers of the function, transforming the call sites // to pass in a smaller number of arguments into the new function. @@ -884,7 +883,6 @@ bool DeadArgumentEliminationPass::removeDeadStuffFromFunction(Function *F) { // it again. F->getParent()->getFunctionList().insert(F->getIterator(), NF); NF->takeName(F); - NF->IsNewDbgInfoFormat = F->IsNewDbgInfoFormat; // Loop over all the callers of the function, transforming the call sites to // pass in a smaller number of arguments into the new function. diff --git a/llvm/lib/Transforms/IPO/ExpandVariadics.cpp b/llvm/lib/Transforms/IPO/ExpandVariadics.cpp index e25f231..16ffd50 100644 --- a/llvm/lib/Transforms/IPO/ExpandVariadics.cpp +++ b/llvm/lib/Transforms/IPO/ExpandVariadics.cpp @@ -508,7 +508,6 @@ ExpandVariadics::replaceAllUsesWithNewDeclaration(Module &M, Function *NF = Function::Create(FTy, F.getLinkage(), F.getAddressSpace()); NF->setName(F.getName() + ".varargs"); - NF->IsNewDbgInfoFormat = F.IsNewDbgInfoFormat; F.getParent()->getFunctionList().insert(F.getIterator(), NF); @@ -550,7 +549,6 @@ ExpandVariadics::deriveFixedArityReplacement(Module &M, IRBuilder<> &Builder, NF->setComdat(F.getComdat()); F.getParent()->getFunctionList().insert(F.getIterator(), NF); NF->setName(F.getName() + ".valist"); - NF->IsNewDbgInfoFormat = F.IsNewDbgInfoFormat; AttrBuilder ParamAttrs(Ctx); diff --git a/llvm/lib/Transforms/IPO/MergeFunctions.cpp b/llvm/lib/Transforms/IPO/MergeFunctions.cpp index e5397e9..d4555e9 100644 --- a/llvm/lib/Transforms/IPO/MergeFunctions.cpp +++ b/llvm/lib/Transforms/IPO/MergeFunctions.cpp @@ -751,7 +751,6 @@ void MergeFunctions::writeThunk(Function *F, Function *G) { NewG = Function::Create(G->getFunctionType(), G->getLinkage(), G->getAddressSpace(), "", G->getParent()); NewG->setComdat(G->getComdat()); - NewG->IsNewDbgInfoFormat = G->IsNewDbgInfoFormat; BB = BasicBlock::Create(F->getContext(), "", NewG); } @@ -897,7 +896,6 @@ void MergeFunctions::mergeTwoFunctions(Function *F, Function *G) { NewF->takeName(F); NewF->setComdat(F->getComdat()); F->setComdat(nullptr); - NewF->IsNewDbgInfoFormat = F->IsNewDbgInfoFormat; // Ensure CFI type metadata is propagated to the new function. copyMetadataIfPresent(F, NewF, "type"); copyMetadataIfPresent(F, NewF, "kcfi_type"); diff --git a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp index 6608515..1feed14 100644 --- a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp +++ b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp @@ -437,45 +437,7 @@ DbgVariableRecordsRemoveRedundantDbgInstrsUsingBackwardScan(BasicBlock *BB) { } static bool removeRedundantDbgInstrsUsingBackwardScan(BasicBlock *BB) { - if (BB->IsNewDbgInfoFormat) - return DbgVariableRecordsRemoveRedundantDbgInstrsUsingBackwardScan(BB); - - SmallVector<DbgValueInst *, 8> ToBeRemoved; - SmallDenseSet<DebugVariable> VariableSet; - for (auto &I : reverse(*BB)) { - if (DbgValueInst *DVI = dyn_cast<DbgValueInst>(&I)) { - DebugVariable Key(DVI->getVariable(), - DVI->getExpression(), - DVI->getDebugLoc()->getInlinedAt()); - auto R = VariableSet.insert(Key); - // If the variable fragment hasn't been seen before then we don't want - // to remove this dbg intrinsic. - if (R.second) - continue; - - if (auto *DAI = dyn_cast<DbgAssignIntrinsic>(DVI)) { - // Don't delete dbg.assign intrinsics that are linked to instructions. - if (!at::getAssignmentInsts(DAI).empty()) - continue; - // Unlinked dbg.assign intrinsics can be treated like dbg.values. - } - - // If the same variable fragment is described more than once it is enough - // to keep the last one (i.e. the first found since we for reverse - // iteration). - ToBeRemoved.push_back(DVI); - continue; - } - // Sequence with consecutive dbg.value instrs ended. Clear the map to - // restart identifying redundant instructions if case we find another - // dbg.value sequence. - VariableSet.clear(); - } - - for (auto &Instr : ToBeRemoved) - Instr->eraseFromParent(); - - return !ToBeRemoved.empty(); + return DbgVariableRecordsRemoveRedundantDbgInstrsUsingBackwardScan(BB); } /// Remove redundant dbg.value instructions using a forward scan. This can @@ -578,49 +540,7 @@ DbgVariableRecordsRemoveUndefDbgAssignsFromEntryBlock(BasicBlock *BB) { } static bool removeRedundantDbgInstrsUsingForwardScan(BasicBlock *BB) { - if (BB->IsNewDbgInfoFormat) - return DbgVariableRecordsRemoveRedundantDbgInstrsUsingForwardScan(BB); - - SmallVector<DbgValueInst *, 8> ToBeRemoved; - SmallDenseMap<DebugVariable, - std::pair<SmallVector<Value *, 4>, DIExpression *>, 4> - VariableMap; - for (auto &I : *BB) { - if (DbgValueInst *DVI = dyn_cast<DbgValueInst>(&I)) { - DebugVariable Key(DVI->getVariable(), std::nullopt, - DVI->getDebugLoc()->getInlinedAt()); - auto [VMI, Inserted] = VariableMap.try_emplace(Key); - auto *DAI = dyn_cast<DbgAssignIntrinsic>(DVI); - // A dbg.assign with no linked instructions can be treated like a - // dbg.value (i.e. can be deleted). - bool IsDbgValueKind = (!DAI || at::getAssignmentInsts(DAI).empty()); - - // Update the map if we found a new value/expression describing the - // variable, or if the variable wasn't mapped already. - SmallVector<Value *, 4> Values(DVI->getValues()); - if (Inserted || VMI->second.first != Values || - VMI->second.second != DVI->getExpression()) { - // Use a sentinel value (nullptr) for the DIExpression when we see a - // linked dbg.assign so that the next debug intrinsic will never match - // it (i.e. always treat linked dbg.assigns as if they're unique). - if (IsDbgValueKind) - VMI->second = {Values, DVI->getExpression()}; - else - VMI->second = {Values, nullptr}; - continue; - } - - // Don't delete dbg.assign intrinsics that are linked to instructions. - if (!IsDbgValueKind) - continue; - ToBeRemoved.push_back(DVI); - } - } - - for (auto &Instr : ToBeRemoved) - Instr->eraseFromParent(); - - return !ToBeRemoved.empty(); + return DbgVariableRecordsRemoveRedundantDbgInstrsUsingForwardScan(BB); } /// Remove redundant undef dbg.assign intrinsic from an entry block using a @@ -643,41 +563,7 @@ static bool removeRedundantDbgInstrsUsingForwardScan(BasicBlock *BB) { /// Possible improvements: /// - Keep track of non-overlapping fragments. static bool removeUndefDbgAssignsFromEntryBlock(BasicBlock *BB) { - if (BB->IsNewDbgInfoFormat) - return DbgVariableRecordsRemoveUndefDbgAssignsFromEntryBlock(BB); - - assert(BB->isEntryBlock() && "expected entry block"); - SmallVector<DbgAssignIntrinsic *, 8> ToBeRemoved; - DenseSet<DebugVariable> SeenDefForAggregate; - // Returns the DebugVariable for DVI with no fragment info. - auto GetAggregateVariable = [](DbgValueInst *DVI) { - return DebugVariable(DVI->getVariable(), std::nullopt, - DVI->getDebugLoc()->getInlinedAt()); - }; - - // Remove undef dbg.assign intrinsics that are encountered before - // any non-undef intrinsics from the entry block. - for (auto &I : *BB) { - DbgValueInst *DVI = dyn_cast<DbgValueInst>(&I); - if (!DVI) - continue; - auto *DAI = dyn_cast<DbgAssignIntrinsic>(DVI); - bool IsDbgValueKind = (!DAI || at::getAssignmentInsts(DAI).empty()); - DebugVariable Aggregate = GetAggregateVariable(DVI); - if (!SeenDefForAggregate.contains(Aggregate)) { - bool IsKill = DVI->isKillLocation() && IsDbgValueKind; - if (!IsKill) { - SeenDefForAggregate.insert(Aggregate); - } else if (DAI) { - ToBeRemoved.push_back(DAI); - } - } - } - - for (DbgAssignIntrinsic *DAI : ToBeRemoved) - DAI->eraseFromParent(); - - return !ToBeRemoved.empty(); + return DbgVariableRecordsRemoveUndefDbgAssignsFromEntryBlock(BB); } bool llvm::RemoveRedundantDbgInstrs(BasicBlock *BB) { diff --git a/llvm/lib/Transforms/Utils/CloneFunction.cpp b/llvm/lib/Transforms/Utils/CloneFunction.cpp index 5487dbe..510d9f9 100644 --- a/llvm/lib/Transforms/Utils/CloneFunction.cpp +++ b/llvm/lib/Transforms/Utils/CloneFunction.cpp @@ -114,7 +114,6 @@ BasicBlock *llvm::CloneBasicBlock(const BasicBlock *BB, ValueToValueMapTy &VMap, const Twine &NameSuffix, Function *F, ClonedCodeInfo *CodeInfo, bool MapAtoms) { BasicBlock *NewBB = BasicBlock::Create(BB->getContext(), "", F); - NewBB->IsNewDbgInfoFormat = BB->IsNewDbgInfoFormat; if (BB->hasName()) NewBB->setName(BB->getName() + NameSuffix); @@ -286,7 +285,6 @@ void llvm::CloneFunctionInto(Function *NewFunc, const Function *OldFunc, const char *NameSuffix, ClonedCodeInfo *CodeInfo, ValueMapTypeRemapper *TypeMapper, ValueMaterializer *Materializer) { - NewFunc->setIsNewDbgInfoFormat(OldFunc->IsNewDbgInfoFormat); assert(NameSuffix && "NameSuffix cannot be null!"); #ifndef NDEBUG @@ -391,7 +389,6 @@ Function *llvm::CloneFunction(Function *F, ValueToValueMapTy &VMap, // Create the new function... Function *NewF = Function::Create(FTy, F->getLinkage(), F->getAddressSpace(), F->getName(), F->getParent()); - NewF->setIsNewDbgInfoFormat(F->IsNewDbgInfoFormat); // Loop over the arguments, copying the names of the mapped arguments over... Function::arg_iterator DestI = NewF->arg_begin(); @@ -525,7 +522,6 @@ void PruningFunctionCloner::CloneBlock( BasicBlock *NewBB; Twine NewName(BB->hasName() ? Twine(BB->getName()) + NameSuffix : ""); BBEntry = NewBB = BasicBlock::Create(BB->getContext(), NewName, NewFunc); - NewBB->IsNewDbgInfoFormat = BB->IsNewDbgInfoFormat; // It is only legal to clone a function if a block address within that // function is never referenced outside of the function. Given that, we @@ -549,9 +545,6 @@ void PruningFunctionCloner::CloneBlock( BasicBlock::const_iterator DbgCursor = StartingInst; auto CloneDbgRecordsToHere = [NewBB, &DbgCursor](Instruction *NewInst, BasicBlock::const_iterator II) { - if (!NewBB->IsNewDbgInfoFormat) - return; - // Clone debug-info records onto this instruction. Iterate through any // source-instructions we've cloned and then subsequently optimised // away, so that their debug-info doesn't go missing. diff --git a/llvm/lib/Transforms/Utils/CloneModule.cpp b/llvm/lib/Transforms/Utils/CloneModule.cpp index 88e2bfe..55fb0ac 100644 --- a/llvm/lib/Transforms/Utils/CloneModule.cpp +++ b/llvm/lib/Transforms/Utils/CloneModule.cpp @@ -61,7 +61,6 @@ std::unique_ptr<Module> llvm::CloneModule( New->setDataLayout(M.getDataLayout()); New->setTargetTriple(M.getTargetTriple()); New->setModuleInlineAsm(M.getModuleInlineAsm()); - New->IsNewDbgInfoFormat = M.IsNewDbgInfoFormat; // Loop over all of the global variables, making corresponding globals in the // new module. Here we add them to the VMap and to the new Module. We diff --git a/llvm/lib/Transforms/Utils/CodeExtractor.cpp b/llvm/lib/Transforms/Utils/CodeExtractor.cpp index c4894c9..1210bdf 100644 --- a/llvm/lib/Transforms/Utils/CodeExtractor.cpp +++ b/llvm/lib/Transforms/Utils/CodeExtractor.cpp @@ -792,7 +792,6 @@ void CodeExtractor::severSplitPHINodesOfExits() { NewBB = BasicBlock::Create(ExitBB->getContext(), ExitBB->getName() + ".split", ExitBB->getParent(), ExitBB); - NewBB->IsNewDbgInfoFormat = ExitBB->IsNewDbgInfoFormat; SmallVector<BasicBlock *, 4> Preds(predecessors(ExitBB)); for (BasicBlock *PredBB : Preds) if (Blocks.count(PredBB)) @@ -1548,7 +1547,6 @@ CodeExtractor::extractCodeRegion(const CodeExtractorAnalysisCache &CEAC, Function *newFunction = constructFunctionDeclaration( inputs, outputs, EntryFreq, oldFunction->getName() + "." + SuffixToUse, StructValues, StructTy); - newFunction->IsNewDbgInfoFormat = oldFunction->IsNewDbgInfoFormat; SmallVector<Value *> NewValues; emitFunctionBody(inputs, outputs, StructValues, newFunction, StructTy, header, @@ -1637,7 +1635,6 @@ void CodeExtractor::emitFunctionBody( // head of the region, but the entry node of a function cannot have preds. BasicBlock *newFuncRoot = BasicBlock::Create(Context, "newFuncRoot", newFunction); - newFuncRoot->IsNewDbgInfoFormat = oldFunction->IsNewDbgInfoFormat; // Now sink all instructions which only have non-phi uses inside the region. // Group the allocas at the start of the block, so that any bitcast uses of @@ -1871,10 +1868,8 @@ CallInst *CodeExtractor::emitReplacerCall( // This takes place of the original loop BasicBlock *codeReplacer = BasicBlock::Create(Context, "codeRepl", oldFunction, ReplIP); - codeReplacer->IsNewDbgInfoFormat = oldFunction->IsNewDbgInfoFormat; BasicBlock *AllocaBlock = AllocationBlock ? AllocationBlock : &oldFunction->getEntryBlock(); - AllocaBlock->IsNewDbgInfoFormat = oldFunction->IsNewDbgInfoFormat; // Update the entry count of the function. if (BFI) diff --git a/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp b/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp index 693b1f5..6b42503 100644 --- a/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp +++ b/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp @@ -634,8 +634,7 @@ bool LoopRotate::rotateLoop(Loop *L, bool SimplifiedLatch) { // memory access in coroutines. !Inst->getFunction()->isPresplitCoroutine()) { - if (LoopEntryBranch->getParent()->IsNewDbgInfoFormat && - !NextDbgInsts.empty()) { + if (!NextDbgInsts.empty()) { auto DbgValueRange = LoopEntryBranch->cloneDebugInfoFrom(Inst, NextDbgInsts.begin()); RemapDbgRecordRange(M, DbgValueRange, ValueMap, @@ -664,8 +663,7 @@ bool LoopRotate::rotateLoop(Loop *L, bool SimplifiedLatch) { ++NumInstrsDuplicated; - if (LoopEntryBranch->getParent()->IsNewDbgInfoFormat && - !NextDbgInsts.empty()) { + if (!NextDbgInsts.empty()) { auto Range = C->cloneDebugInfoFrom(Inst, NextDbgInsts.begin()); RemapDbgRecordRange(M, Range, ValueMap, RF_NoModuleLevelChanges | RF_IgnoreMissingLocals); diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index 975ce3b..f67a641 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -4055,13 +4055,11 @@ static bool performBranchToCommonDestFolding(BranchInst *BI, BranchInst *PBI, Module *M = BB->getModule(); - if (PredBlock->IsNewDbgInfoFormat) { - PredBlock->getTerminator()->cloneDebugInfoFrom(BB->getTerminator()); - for (DbgVariableRecord &DVR : - filterDbgVars(PredBlock->getTerminator()->getDbgRecordRange())) { - RemapDbgRecord(M, &DVR, VMap, - RF_NoModuleLevelChanges | RF_IgnoreMissingLocals); - } + PredBlock->getTerminator()->cloneDebugInfoFrom(BB->getTerminator()); + for (DbgVariableRecord &DVR : + filterDbgVars(PredBlock->getTerminator()->getDbgRecordRange())) { + RemapDbgRecord(M, &DVR, VMap, + RF_NoModuleLevelChanges | RF_IgnoreMissingLocals); } // Now that the Cond was cloned into the predecessor basic block, |