diff --git a/llvm/include/llvm/IR/DebugInfoMetadata.h b/llvm/include/llvm/IR/DebugInfoMetadata.h --- a/llvm/include/llvm/IR/DebugInfoMetadata.h +++ b/llvm/include/llvm/IR/DebugInfoMetadata.h @@ -2048,15 +2048,13 @@ /// use the scope of any location. /// /// \p LocA \p LocB: The locations to be merged. - static const DILocation *getMergedLocation(const DILocation *LocA, - const DILocation *LocB); + static DILocation *getMergedLocation(DILocation *LocA, DILocation *LocB); /// Try to combine the vector of locations passed as input in a single one. /// This function applies getMergedLocation() repeatedly left-to-right. /// /// \p Locs: The locations to be merged. - static const DILocation * - getMergedLocations(ArrayRef Locs); + static DILocation *getMergedLocations(ArrayRef Locs); /// Return the masked discriminator value for an input discrimnator value D /// (i.e. zero out the (B+1)-th and above bits for D (B is 0-base). diff --git a/llvm/include/llvm/IR/Instruction.h b/llvm/include/llvm/IR/Instruction.h --- a/llvm/include/llvm/IR/Instruction.h +++ b/llvm/include/llvm/IR/Instruction.h @@ -521,7 +521,7 @@ /// applications, thus the N-way merging should be in code path. /// The DebugLoc attached to this instruction will be overwritten by the /// merged DebugLoc. - void applyMergedLocation(const DILocation *LocA, const DILocation *LocB); + void applyMergedLocation(DILocation *LocA, DILocation *LocB); /// Updates the debug location given that the instruction has been hoisted /// from a block to a predecessor of that block. 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 @@ -868,8 +868,7 @@ return 0; } -void Instruction::applyMergedLocation(const DILocation *LocA, - const DILocation *LocB) { +void Instruction::applyMergedLocation(DILocation *LocA, DILocation *LocB) { setDebugLoc(DILocation::getMergedLocation(LocA, LocB)); } diff --git a/llvm/lib/IR/DebugInfoMetadata.cpp b/llvm/lib/IR/DebugInfoMetadata.cpp --- a/llvm/lib/IR/DebugInfoMetadata.cpp +++ b/llvm/lib/IR/DebugInfoMetadata.cpp @@ -95,14 +95,13 @@ Storage, Context.pImpl->DILocations); } -const DILocation * -DILocation::getMergedLocations(ArrayRef Locs) { +DILocation *DILocation::getMergedLocations(ArrayRef Locs) { if (Locs.empty()) return nullptr; if (Locs.size() == 1) return Locs[0]; auto *Merged = Locs[0]; - for (const DILocation *L : llvm::drop_begin(Locs)) { + for (DILocation *L : llvm::drop_begin(Locs)) { Merged = getMergedLocation(Merged, L); if (Merged == nullptr) break; @@ -110,8 +109,7 @@ return Merged; } -const DILocation *DILocation::getMergedLocation(const DILocation *LocA, - const DILocation *LocB) { +DILocation *DILocation::getMergedLocation(DILocation *LocA, DILocation *LocB) { if (!LocA || !LocB) return nullptr; diff --git a/llvm/lib/Transforms/Scalar/LICM.cpp b/llvm/lib/Transforms/Scalar/LICM.cpp --- a/llvm/lib/Transforms/Scalar/LICM.cpp +++ b/llvm/lib/Transforms/Scalar/LICM.cpp @@ -2214,7 +2214,7 @@ }); // Look at all the loop uses, and try to merge their locations. - std::vector LoopUsesLocs; + std::vector LoopUsesLocs; for (auto *U : LoopUses) LoopUsesLocs.push_back(U->getDebugLoc().get()); auto DL = DebugLoc(DILocation::getMergedLocations(LoopUsesLocs)); diff --git a/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp b/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp --- a/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp +++ b/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp @@ -121,7 +121,7 @@ // Now, go through each block (with the current terminator type) // we've recorded, and rewrite it to branch to the new common block. - const DILocation *CommonDebugLoc = nullptr; + DILocation *CommonDebugLoc = nullptr; for (BasicBlock *BB : BBs) { auto *Term = BB->getTerminator(); assert(Term->getOpcode() == CanonicalTerm->getOpcode() && diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -2562,7 +2562,7 @@ // And finally, replace the original `invoke`s with an unconditional branch // to the block with the merged `invoke`. Also, give that merged `invoke` // the merged debugloc of all the original `invoke`s. - const DILocation *MergedDebugLoc = nullptr; + DILocation *MergedDebugLoc = nullptr; for (InvokeInst *II : Invokes) { // Compute the debug location common to all the original `invoke`s. if (!MergedDebugLoc) diff --git a/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h b/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h --- a/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h +++ b/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h @@ -168,7 +168,7 @@ llvm::Module *getLLVMModule() { return llvmModule.get(); } /// Translates the given location. - const llvm::DILocation *translateLoc(Location loc, llvm::DILocalScope *scope); + llvm::DILocation *translateLoc(Location loc, llvm::DILocalScope *scope); /// Translates the given LLVM debug info metadata. llvm::Metadata *translateDebugInfo(LLVM::DINodeAttr attr); diff --git a/mlir/lib/Target/LLVMIR/DebugTranslation.h b/mlir/lib/Target/LLVMIR/DebugTranslation.h --- a/mlir/lib/Target/LLVMIR/DebugTranslation.h +++ b/mlir/lib/Target/LLVMIR/DebugTranslation.h @@ -35,7 +35,7 @@ void finalize(); /// Translate the given location to an llvm debug location. - const llvm::DILocation *translateLoc(Location loc, llvm::DILocalScope *scope); + llvm::DILocation *translateLoc(Location loc, llvm::DILocalScope *scope); /// Translate the debug information for the given function. void translate(LLVMFuncOp func, llvm::Function &llvmFunc); @@ -54,8 +54,8 @@ private: /// Translate the given location to an llvm debug location with the given /// scope and inlinedAt parameters. - const llvm::DILocation *translateLoc(Location loc, llvm::DILocalScope *scope, - const llvm::DILocation *inlinedAt); + llvm::DILocation *translateLoc(Location loc, llvm::DILocalScope *scope, + llvm::DILocation *inlinedAt); /// Create an llvm debug file for the given file path. llvm::DIFile *translateFile(StringRef fileName); @@ -85,7 +85,7 @@ /// A mapping between mlir location+scope and the corresponding llvm debug /// metadata. DenseMap, - const llvm::DILocation *> + llvm::DILocation *> locationToLoc; /// A mapping between debug attribute and the corresponding llvm debug diff --git a/mlir/lib/Target/LLVMIR/DebugTranslation.cpp b/mlir/lib/Target/LLVMIR/DebugTranslation.cpp --- a/mlir/lib/Target/LLVMIR/DebugTranslation.cpp +++ b/mlir/lib/Target/LLVMIR/DebugTranslation.cpp @@ -261,17 +261,17 @@ //===----------------------------------------------------------------------===// /// Translate the given location to an llvm debug location. -const llvm::DILocation * -DebugTranslation::translateLoc(Location loc, llvm::DILocalScope *scope) { +llvm::DILocation *DebugTranslation::translateLoc(Location loc, + llvm::DILocalScope *scope) { if (!debugEmissionIsEnabled) return nullptr; return translateLoc(loc, scope, /*inlinedAt=*/nullptr); } /// Translate the given location to an llvm DebugLoc. -const llvm::DILocation * -DebugTranslation::translateLoc(Location loc, llvm::DILocalScope *scope, - const llvm::DILocation *inlinedAt) { +llvm::DILocation *DebugTranslation::translateLoc(Location loc, + llvm::DILocalScope *scope, + llvm::DILocation *inlinedAt) { // LLVM doesn't have a representation for unknown. if (!scope || isa(loc)) return nullptr; @@ -281,10 +281,10 @@ if (existingIt != locationToLoc.end()) return existingIt->second; - const llvm::DILocation *llvmLoc = nullptr; + llvm::DILocation *llvmLoc = nullptr; if (auto callLoc = dyn_cast(loc)) { // For callsites, the caller is fed as the inlinedAt for the callee. - const auto *callerLoc = translateLoc(callLoc.getCaller(), scope, inlinedAt); + auto *callerLoc = translateLoc(callLoc.getCaller(), scope, inlinedAt); llvmLoc = translateLoc(callLoc.getCallee(), scope, callerLoc); } else if (auto fileLoc = dyn_cast(loc)) { diff --git a/mlir/lib/Target/LLVMIR/LoopAnnotationTranslation.cpp b/mlir/lib/Target/LLVMIR/LoopAnnotationTranslation.cpp --- a/mlir/lib/Target/LLVMIR/LoopAnnotationTranslation.cpp +++ b/mlir/lib/Target/LLVMIR/LoopAnnotationTranslation.cpp @@ -198,10 +198,10 @@ localScopeAttr)); if (!localScope) return; - const llvm::Metadata *loc = + llvm::Metadata *loc = loopAnnotationTranslation.moduleTranslation.translateLoc(location, localScope); - metadataNodes.push_back(const_cast(loc)); + metadataNodes.push_back(loc); } llvm::MDNode *LoopAnnotationConversion::convert() { diff --git a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp --- a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp +++ b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp @@ -1275,8 +1275,8 @@ return ompBuilder.get(); } -const llvm::DILocation * -ModuleTranslation::translateLoc(Location loc, llvm::DILocalScope *scope) { +llvm::DILocation *ModuleTranslation::translateLoc(Location loc, + llvm::DILocalScope *scope) { return debugTranslation->translateLoc(loc, scope); }