From: Vedant Kumar Date: Wed, 20 Jun 2018 18:40:14 +0000 (+0000) Subject: [Local] Generalize insertReplacementDbgValues, NFC X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4e93f3dcf890eb443f980fe32c13fdd19988e42e;p=platform%2Fupstream%2Fllvm.git [Local] Generalize insertReplacementDbgValues, NFC This utility should operate on Values, not Instructions. While I'm here, I've also made it possible to skip emitting replacement dbg.values for certain debug users (by having RewriteExpr return nullptr). llvm-svn: 335152 --- diff --git a/llvm/include/llvm/Transforms/Utils/Local.h b/llvm/include/llvm/Transforms/Utils/Local.h index f09ebe5..5290651 100644 --- a/llvm/include/llvm/Transforms/Utils/Local.h +++ b/llvm/include/llvm/Transforms/Utils/Local.h @@ -334,14 +334,16 @@ void replaceDbgValueForAlloca(AllocaInst *AI, Value *NewAllocaAddress, /// DIExpression. void salvageDebugInfo(Instruction &I); -/// Assuming the instruction \p From is going to be deleted, insert replacement +/// Assuming the value \p From is going to be deleted, insert replacement /// dbg.value intrinsics for each debug user of \p From. The newly-inserted /// dbg.values refer to \p To instead of \p From. Each replacement dbg.value /// has the same location and variable as the debug user it replaces, has a /// DIExpression determined by the result of \p RewriteExpr applied to an old -/// debug user of \p From, and is placed before \p InsertBefore. +/// debug user of \p From, and is placed before \p InsertBefore. If +/// \p RewriteExpr returns nullptr, no replacement for the specified debug +/// user is emitted. void insertReplacementDbgValues( - Instruction &From, Instruction &To, Instruction &InsertBefore, + Value &From, Value &To, Instruction &InsertBefore, function_ref RewriteExpr); /// Remove all instructions from a basic block other than it's terminator diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp index 7dd74a1..a718276 100644 --- a/llvm/lib/Transforms/Utils/Local.cpp +++ b/llvm/lib/Transforms/Utils/Local.cpp @@ -1672,7 +1672,7 @@ void llvm::salvageDebugInfo(Instruction &I) { } void llvm::insertReplacementDbgValues( - Instruction &From, Instruction &To, Instruction &InsertBefore, + Value &From, Value &To, Instruction &InsertBefore, function_ref RewriteExpr) { // Collect all debug users of From. SmallVector Users; @@ -1682,11 +1682,11 @@ void llvm::insertReplacementDbgValues( // Insert a replacement debug value for each old debug user. It's assumed // that the old debug users will be erased later. - DIBuilder DIB(*From.getModule()); + DIBuilder DIB(*InsertBefore.getModule()); for (auto *OldDII : Users) - DIB.insertDbgValueIntrinsic(&To, OldDII->getVariable(), - RewriteExpr(*OldDII), - OldDII->getDebugLoc().get(), &InsertBefore); + if (DIExpression *Expr = RewriteExpr(*OldDII)) + DIB.insertDbgValueIntrinsic(&To, OldDII->getVariable(), Expr, + OldDII->getDebugLoc().get(), &InsertBefore); } unsigned llvm::removeAllNonTerminatorAndEHPadInstructions(BasicBlock *BB) {