diff options
author | Hsiangkai Wang <hsiangkai@gmail.com> | 2018-08-06 03:59:47 +0000 |
---|---|---|
committer | Hsiangkai Wang <hsiangkai@gmail.com> | 2018-08-06 03:59:47 +0000 |
commit | ef72e481ea11f5e1954bf3af41e2dc78f15836e3 (patch) | |
tree | cc5ede53ac602f31501a839caf17c0e4a8927b71 /llvm/lib/Transforms | |
parent | 4a73aa112b1ec2ac771c6d749a6843f2b38e5c64 (diff) | |
download | bcm5719-llvm-ef72e481ea11f5e1954bf3af41e2dc78f15836e3.tar.gz bcm5719-llvm-ef72e481ea11f5e1954bf3af41e2dc78f15836e3.zip |
[DebugInfo] Refactor DbgInfoIntrinsic class hierarchy.
In the past, DbgInfoIntrinsic has a strong assumption that these
intrinsics all have variables and expressions attached to them.
However, it is too strong to derive the class for other debug entities.
Now, it has problems for debug labels.
In order to make DbgInfoIntrinsic as a base class for 'debug info', I
create a class for 'variable debug info', DbgVariableIntrinsic.
DbgDeclareInst, DbgAddrIntrinsic, and DbgValueInst will be derived from it.
Differential Revision: https://reviews.llvm.org/D50220
llvm-svn: 338984
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstructionCombining.cpp | 4 | ||||
-rw-r--r-- | llvm/lib/Transforms/Scalar/ADCE.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/Transforms/Scalar/Reassociate.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/Transforms/Scalar/SROA.cpp | 6 | ||||
-rw-r--r-- | llvm/lib/Transforms/Utils/Local.cpp | 42 | ||||
-rw-r--r-- | llvm/lib/Transforms/Utils/LoopRotationUtils.cpp | 6 | ||||
-rw-r--r-- | llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp | 14 |
7 files changed, 38 insertions, 38 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp index cff0d544729..b87d5593f58 100644 --- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp +++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp @@ -2144,7 +2144,7 @@ Instruction *InstCombiner::visitAllocSite(Instruction &MI) { // If we are removing an alloca with a dbg.declare, insert dbg.value calls // before each store. - TinyPtrVector<DbgInfoIntrinsic *> DIIs; + TinyPtrVector<DbgVariableIntrinsic *> DIIs; std::unique_ptr<DIBuilder> DIB; if (isa<AllocaInst>(MI)) { DIIs = FindDbgAddrUses(&MI); @@ -2934,7 +2934,7 @@ static bool TryToSinkInstruction(Instruction *I, BasicBlock *DestBlock) { // Also sink all related debug uses from the source basic block. Otherwise we // get debug use before the def. - SmallVector<DbgInfoIntrinsic *, 1> DbgUsers; + SmallVector<DbgVariableIntrinsic *, 1> DbgUsers; findDbgUsers(DbgUsers, I); for (auto *DII : DbgUsers) { if (DII->getParent() == SrcBlock) { diff --git a/llvm/lib/Transforms/Scalar/ADCE.cpp b/llvm/lib/Transforms/Scalar/ADCE.cpp index d134a158073..61c4be854da 100644 --- a/llvm/lib/Transforms/Scalar/ADCE.cpp +++ b/llvm/lib/Transforms/Scalar/ADCE.cpp @@ -508,7 +508,7 @@ bool AggressiveDeadCodeElimination::removeDeadInstructions() { if (isLive(&I)) continue; - if (auto *DII = dyn_cast<DbgInfoIntrinsic>(&I)) { + if (auto *DII = dyn_cast<DbgVariableIntrinsic>(&I)) { // Check if the scope of this variable location is alive. if (AliveScopes.count(DII->getDebugLoc()->getScope())) continue; diff --git a/llvm/lib/Transforms/Scalar/Reassociate.cpp b/llvm/lib/Transforms/Scalar/Reassociate.cpp index 1df0a9c49fb..03cd7c10150 100644 --- a/llvm/lib/Transforms/Scalar/Reassociate.cpp +++ b/llvm/lib/Transforms/Scalar/Reassociate.cpp @@ -788,7 +788,7 @@ void ReassociatePass::RewriteExprTree(BinaryOperator *I, // Discard any debug info related to the expressions that has changed (we // can leave debug infor related to the root, since the result of the // expression tree should be the same even after reassociation). - SmallVector<DbgInfoIntrinsic *, 1> DbgUsers; + SmallVector<DbgVariableIntrinsic *, 1> DbgUsers; findDbgUsers(DbgUsers, ExpressionChanged); for (auto *DII : DbgUsers) { Value *Undef = UndefValue::get(ExpressionChanged->getType()); diff --git a/llvm/lib/Transforms/Scalar/SROA.cpp b/llvm/lib/Transforms/Scalar/SROA.cpp index de16b608f75..1d8ba73c9a2 100644 --- a/llvm/lib/Transforms/Scalar/SROA.cpp +++ b/llvm/lib/Transforms/Scalar/SROA.cpp @@ -4212,7 +4212,7 @@ bool SROA::splitAlloca(AllocaInst &AI, AllocaSlices &AS) { // Migrate debug information from the old alloca to the new alloca(s) // and the individual partitions. - TinyPtrVector<DbgInfoIntrinsic *> DbgDeclares = FindDbgAddrUses(&AI); + TinyPtrVector<DbgVariableIntrinsic *> DbgDeclares = FindDbgAddrUses(&AI); if (!DbgDeclares.empty()) { auto *Var = DbgDeclares.front()->getVariable(); auto *Expr = DbgDeclares.front()->getExpression(); @@ -4264,7 +4264,7 @@ bool SROA::splitAlloca(AllocaInst &AI, AllocaSlices &AS) { } // Remove any existing intrinsics describing the same alloca. - for (DbgInfoIntrinsic *OldDII : FindDbgAddrUses(Fragment.Alloca)) + for (DbgVariableIntrinsic *OldDII : FindDbgAddrUses(Fragment.Alloca)) OldDII->eraseFromParent(); DIB.insertDeclare(Fragment.Alloca, Var, FragmentExpr, @@ -4379,7 +4379,7 @@ bool SROA::deleteDeadInstructions( // not be able to find it. if (AllocaInst *AI = dyn_cast<AllocaInst>(I)) { DeletedAllocas.insert(AI); - for (DbgInfoIntrinsic *OldDII : FindDbgAddrUses(AI)) + for (DbgVariableIntrinsic *OldDII : FindDbgAddrUses(AI)) OldDII->eraseFromParent(); } diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp index 6bddbb2b1c5..ab4170d1a9d 100644 --- a/llvm/lib/Transforms/Utils/Local.cpp +++ b/llvm/lib/Transforms/Utils/Local.cpp @@ -1244,7 +1244,7 @@ static bool PhiHasDebugValue(DILocalVariable *DIVar, /// alloc size of the value when doing the comparison. E.g. an i1 value will be /// identified as covering an n-bit fragment, if the store size of i1 is at /// least n bits. -static bool valueCoversEntireFragment(Type *ValTy, DbgInfoIntrinsic *DII) { +static bool valueCoversEntireFragment(Type *ValTy, DbgVariableIntrinsic *DII) { const DataLayout &DL = DII->getModule()->getDataLayout(); uint64_t ValueSize = DL.getTypeAllocSizeInBits(ValTy); if (auto FragmentSize = DII->getFragmentSizeInBits()) @@ -1262,7 +1262,7 @@ static bool valueCoversEntireFragment(Type *ValTy, DbgInfoIntrinsic *DII) { /// Inserts a llvm.dbg.value intrinsic before a store to an alloca'd value /// that has an associated llvm.dbg.declare or llvm.dbg.addr intrinsic. -void llvm::ConvertDebugDeclareToDebugValue(DbgInfoIntrinsic *DII, +void llvm::ConvertDebugDeclareToDebugValue(DbgVariableIntrinsic *DII, StoreInst *SI, DIBuilder &Builder) { assert(DII->isAddressOfVariable()); auto *DIVar = DII->getVariable(); @@ -1319,7 +1319,7 @@ void llvm::ConvertDebugDeclareToDebugValue(DbgInfoIntrinsic *DII, /// Inserts a llvm.dbg.value intrinsic before a load of an alloca'd value /// that has an associated llvm.dbg.declare or llvm.dbg.addr intrinsic. -void llvm::ConvertDebugDeclareToDebugValue(DbgInfoIntrinsic *DII, +void llvm::ConvertDebugDeclareToDebugValue(DbgVariableIntrinsic *DII, LoadInst *LI, DIBuilder &Builder) { auto *DIVar = DII->getVariable(); auto *DIExpr = DII->getExpression(); @@ -1348,7 +1348,7 @@ void llvm::ConvertDebugDeclareToDebugValue(DbgInfoIntrinsic *DII, /// Inserts a llvm.dbg.value intrinsic after a phi that has an associated /// llvm.dbg.declare or llvm.dbg.addr intrinsic. -void llvm::ConvertDebugDeclareToDebugValue(DbgInfoIntrinsic *DII, +void llvm::ConvertDebugDeclareToDebugValue(DbgVariableIntrinsic *DII, PHINode *APN, DIBuilder &Builder) { auto *DIVar = DII->getVariable(); auto *DIExpr = DII->getExpression(); @@ -1450,7 +1450,7 @@ void llvm::insertDebugValuesForPHIs(BasicBlock *BB, // Map existing PHI nodes to their dbg.values. ValueToValueMapTy DbgValueMap; for (auto &I : *BB) { - if (auto DbgII = dyn_cast<DbgInfoIntrinsic>(&I)) { + if (auto DbgII = dyn_cast<DbgVariableIntrinsic>(&I)) { if (auto *Loc = dyn_cast_or_null<PHINode>(DbgII->getVariableLocation())) DbgValueMap.insert({Loc, DbgII}); } @@ -1471,7 +1471,7 @@ void llvm::insertDebugValuesForPHIs(BasicBlock *BB, for (auto VI : PHI->operand_values()) { auto V = DbgValueMap.find(VI); if (V != DbgValueMap.end()) { - auto *DbgII = cast<DbgInfoIntrinsic>(V->second); + auto *DbgII = cast<DbgVariableIntrinsic>(V->second); Instruction *NewDbgII = DbgII->clone(); NewDbgII->setOperand(0, PhiMAV); auto InsertionPt = Parent->getFirstInsertionPt(); @@ -1485,7 +1485,7 @@ void llvm::insertDebugValuesForPHIs(BasicBlock *BB, /// Finds all intrinsics declaring local variables as living in the memory that /// 'V' points to. This may include a mix of dbg.declare and /// dbg.addr intrinsics. -TinyPtrVector<DbgInfoIntrinsic *> llvm::FindDbgAddrUses(Value *V) { +TinyPtrVector<DbgVariableIntrinsic *> llvm::FindDbgAddrUses(Value *V) { // This function is hot. Check whether the value has any metadata to avoid a // DenseMap lookup. if (!V->isUsedByMetadata()) @@ -1497,9 +1497,9 @@ TinyPtrVector<DbgInfoIntrinsic *> llvm::FindDbgAddrUses(Value *V) { if (!MDV) return {}; - TinyPtrVector<DbgInfoIntrinsic *> Declares; + TinyPtrVector<DbgVariableIntrinsic *> Declares; for (User *U : MDV->users()) { - if (auto *DII = dyn_cast<DbgInfoIntrinsic>(U)) + if (auto *DII = dyn_cast<DbgVariableIntrinsic>(U)) if (DII->isAddressOfVariable()) Declares.push_back(DII); } @@ -1519,7 +1519,7 @@ void llvm::findDbgValues(SmallVectorImpl<DbgValueInst *> &DbgValues, Value *V) { DbgValues.push_back(DVI); } -void llvm::findDbgUsers(SmallVectorImpl<DbgInfoIntrinsic *> &DbgUsers, +void llvm::findDbgUsers(SmallVectorImpl<DbgVariableIntrinsic *> &DbgUsers, Value *V) { // This function is hot. Check whether the value has any metadata to avoid a // DenseMap lookup. @@ -1528,7 +1528,7 @@ void llvm::findDbgUsers(SmallVectorImpl<DbgInfoIntrinsic *> &DbgUsers, if (auto *L = LocalAsMetadata::getIfExists(V)) if (auto *MDV = MetadataAsValue::getIfExists(V->getContext(), L)) for (User *U : MDV->users()) - if (DbgInfoIntrinsic *DII = dyn_cast<DbgInfoIntrinsic>(U)) + if (DbgVariableIntrinsic *DII = dyn_cast<DbgVariableIntrinsic>(U)) DbgUsers.push_back(DII); } @@ -1536,7 +1536,7 @@ bool llvm::replaceDbgDeclare(Value *Address, Value *NewAddress, Instruction *InsertBefore, DIBuilder &Builder, bool DerefBefore, int Offset, bool DerefAfter) { auto DbgAddrs = FindDbgAddrUses(Address); - for (DbgInfoIntrinsic *DII : DbgAddrs) { + for (DbgVariableIntrinsic *DII : DbgAddrs) { DebugLoc Loc = DII->getDebugLoc(); auto *DIVar = DII->getVariable(); auto *DIExpr = DII->getExpression(); @@ -1604,7 +1604,7 @@ static MetadataAsValue *wrapValueInMetadata(LLVMContext &C, Value *V) { } bool llvm::salvageDebugInfo(Instruction &I) { - SmallVector<DbgInfoIntrinsic *, 1> DbgUsers; + SmallVector<DbgVariableIntrinsic *, 1> DbgUsers; findDbgUsers(DbgUsers, &I); if (DbgUsers.empty()) return false; @@ -1614,7 +1614,7 @@ bool llvm::salvageDebugInfo(Instruction &I) { auto &Ctx = I.getContext(); auto wrapMD = [&](Value *V) { return wrapValueInMetadata(Ctx, V); }; - auto doSalvage = [&](DbgInfoIntrinsic *DII, SmallVectorImpl<uint64_t> &Ops) { + auto doSalvage = [&](DbgVariableIntrinsic *DII, SmallVectorImpl<uint64_t> &Ops) { auto *DIExpr = DII->getExpression(); if (!Ops.empty()) { // Do not add DW_OP_stack_value for DbgDeclare and DbgAddr, because they @@ -1628,13 +1628,13 @@ bool llvm::salvageDebugInfo(Instruction &I) { LLVM_DEBUG(dbgs() << "SALVAGE: " << *DII << '\n'); }; - auto applyOffset = [&](DbgInfoIntrinsic *DII, uint64_t Offset) { + auto applyOffset = [&](DbgVariableIntrinsic *DII, uint64_t Offset) { SmallVector<uint64_t, 8> Ops; DIExpression::appendOffset(Ops, Offset); doSalvage(DII, Ops); }; - auto applyOps = [&](DbgInfoIntrinsic *DII, + auto applyOps = [&](DbgVariableIntrinsic *DII, std::initializer_list<uint64_t> Opcodes) { SmallVector<uint64_t, 8> Ops(Opcodes); doSalvage(DII, Ops); @@ -1733,16 +1733,16 @@ using DbgValReplacement = Optional<DIExpression *>; /// changes are made. static bool rewriteDebugUsers( Instruction &From, Value &To, Instruction &DomPoint, DominatorTree &DT, - function_ref<DbgValReplacement(DbgInfoIntrinsic &DII)> RewriteExpr) { + function_ref<DbgValReplacement(DbgVariableIntrinsic &DII)> RewriteExpr) { // Find debug users of From. - SmallVector<DbgInfoIntrinsic *, 1> Users; + SmallVector<DbgVariableIntrinsic *, 1> Users; findDbgUsers(Users, &From); if (Users.empty()) return false; // Prevent use-before-def of To. bool Changed = false; - SmallPtrSet<DbgInfoIntrinsic *, 1> DeleteOrSalvage; + SmallPtrSet<DbgVariableIntrinsic *, 1> DeleteOrSalvage; if (isa<Instruction>(&To)) { bool DomPointAfterFrom = From.getNextNonDebugInstruction() == &DomPoint; @@ -1831,7 +1831,7 @@ bool llvm::replaceAllDbgUsesWith(Instruction &From, Value &To, Type *FromTy = From.getType(); Type *ToTy = To.getType(); - auto Identity = [&](DbgInfoIntrinsic &DII) -> DbgValReplacement { + auto Identity = [&](DbgVariableIntrinsic &DII) -> DbgValReplacement { return DII.getExpression(); }; @@ -1855,7 +1855,7 @@ bool llvm::replaceAllDbgUsesWith(Instruction &From, Value &To, // The width of the result has shrunk. Use sign/zero extension to describe // the source variable's high bits. - auto SignOrZeroExt = [&](DbgInfoIntrinsic &DII) -> DbgValReplacement { + auto SignOrZeroExt = [&](DbgVariableIntrinsic &DII) -> DbgValReplacement { DILocalVariable *Var = DII.getVariable(); // Without knowing signedness, sign/zero extension isn't possible. diff --git a/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp b/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp index 0f58f18bc87..514c594ddfa 100644 --- a/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp +++ b/llvm/lib/Transforms/Utils/LoopRotationUtils.cpp @@ -304,13 +304,13 @@ bool LoopRotate::rotateLoop(Loop *L, bool SimplifiedLatch) { // Record all debug intrinsics preceding LoopEntryBranch to avoid duplication. using DbgIntrinsicHash = std::pair<std::pair<Value *, DILocalVariable *>, DIExpression *>; - auto makeHash = [](DbgInfoIntrinsic *D) -> DbgIntrinsicHash { + auto makeHash = [](DbgVariableIntrinsic *D) -> DbgIntrinsicHash { return {{D->getVariableLocation(), D->getVariable()}, D->getExpression()}; }; SmallDenseSet<DbgIntrinsicHash, 8> DbgIntrinsics; for (auto I = std::next(OrigPreheader->rbegin()), E = OrigPreheader->rend(); I != E; ++I) { - if (auto *DII = dyn_cast<DbgInfoIntrinsic>(&*I)) + if (auto *DII = dyn_cast<DbgVariableIntrinsic>(&*I)) DbgIntrinsics.insert(makeHash(DII)); else break; @@ -340,7 +340,7 @@ bool LoopRotate::rotateLoop(Loop *L, bool SimplifiedLatch) { RF_NoModuleLevelChanges | RF_IgnoreMissingLocals); // Avoid inserting the same intrinsic twice. - if (auto *DII = dyn_cast<DbgInfoIntrinsic>(C)) + if (auto *DII = dyn_cast<DbgVariableIntrinsic>(C)) if (DbgIntrinsics.count(makeHash(DII))) { C->deleteValue(); continue; diff --git a/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp b/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp index 86e15bbd7f2..afc2a863759 100644 --- a/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp +++ b/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp @@ -116,7 +116,7 @@ struct AllocaInfo { bool OnlyUsedInOneBlock; Value *AllocaPointerVal; - TinyPtrVector<DbgInfoIntrinsic *> DbgDeclares; + TinyPtrVector<DbgVariableIntrinsic *> DbgDeclares; void clear() { DefiningBlocks.clear(); @@ -263,7 +263,7 @@ struct PromoteMem2Reg { /// For each alloca, we keep track of the dbg.declare intrinsic that /// describes it, if any, so that we can convert it to a dbg.value /// intrinsic if the alloca gets promoted. - SmallVector<TinyPtrVector<DbgInfoIntrinsic *>, 8> AllocaDbgDeclares; + SmallVector<TinyPtrVector<DbgVariableIntrinsic *>, 8> AllocaDbgDeclares; /// The set of basic blocks the renamer has already visited. SmallPtrSet<BasicBlock *, 16> Visited; @@ -426,7 +426,7 @@ static bool rewriteSingleStoreAlloca(AllocaInst *AI, AllocaInfo &Info, // Record debuginfo for the store and remove the declaration's // debuginfo. - for (DbgInfoIntrinsic *DII : Info.DbgDeclares) { + for (DbgVariableIntrinsic *DII : Info.DbgDeclares) { DIBuilder DIB(*AI->getModule(), /*AllowUnresolved*/ false); ConvertDebugDeclareToDebugValue(DII, Info.OnlyStore, DIB); DII->eraseFromParent(); @@ -527,7 +527,7 @@ static bool promoteSingleBlockAlloca(AllocaInst *AI, const AllocaInfo &Info, while (!AI->use_empty()) { StoreInst *SI = cast<StoreInst>(AI->user_back()); // Record debuginfo for the store before removing it. - for (DbgInfoIntrinsic *DII : Info.DbgDeclares) { + for (DbgVariableIntrinsic *DII : Info.DbgDeclares) { DIBuilder DIB(*AI->getModule(), /*AllowUnresolved*/ false); ConvertDebugDeclareToDebugValue(DII, SI, DIB); } @@ -539,7 +539,7 @@ static bool promoteSingleBlockAlloca(AllocaInst *AI, const AllocaInfo &Info, LBI.deleteValue(AI); // The alloca's debuginfo can be removed as well. - for (DbgInfoIntrinsic *DII : Info.DbgDeclares) { + for (DbgVariableIntrinsic *DII : Info.DbgDeclares) { DII->eraseFromParent(); LBI.deleteValue(DII); } @@ -932,7 +932,7 @@ NextIteration: // The currently active variable for this block is now the PHI. IncomingVals[AllocaNo] = APN; - for (DbgInfoIntrinsic *DII : AllocaDbgDeclares[AllocaNo]) + for (DbgVariableIntrinsic *DII : AllocaDbgDeclares[AllocaNo]) ConvertDebugDeclareToDebugValue(DII, APN, DIB); // Get the next phi node. @@ -992,7 +992,7 @@ NextIteration: // Record debuginfo for the store before removing it. IncomingLocs[AllocaNo] = SI->getDebugLoc(); - for (DbgInfoIntrinsic *DII : AllocaDbgDeclares[ai->second]) + for (DbgVariableIntrinsic *DII : AllocaDbgDeclares[ai->second]) ConvertDebugDeclareToDebugValue(DII, SI, DIB); BB->getInstList().erase(SI); } |