Index: include/llvm-c/Core.h =================================================================== --- include/llvm-c/Core.h +++ include/llvm-c/Core.h @@ -1417,7 +1417,9 @@ macro(CallInst) \ macro(IntrinsicInst) \ macro(DbgInfoIntrinsic) \ - macro(DbgDeclareInst) \ + macro(DbgVariableIntrinsic) \ + macro(DbgDeclareInst) \ + macro(DbgLabelInst) \ macro(MemIntrinsic) \ macro(MemCpyInst) \ macro(MemMoveInst) \ Index: include/llvm/IR/InstVisitor.h =================================================================== --- include/llvm/IR/InstVisitor.h +++ include/llvm/IR/InstVisitor.h @@ -211,10 +211,12 @@ RetTy visitCatchPadInst(CatchPadInst &I) { DELEGATE(FuncletPadInst); } // Handle the special instrinsic instruction classes. - RetTy visitDbgDeclareInst(DbgDeclareInst &I) { DELEGATE(DbgInfoIntrinsic);} - RetTy visitDbgValueInst(DbgValueInst &I) { DELEGATE(DbgInfoIntrinsic);} + RetTy visitDbgDeclareInst(DbgDeclareInst &I){ DELEGATE(DbgVariableIntrinsic);} + RetTy visitDbgValueInst(DbgValueInst &I) { DELEGATE(DbgVariableIntrinsic);} + RetTy visitDbgVariableIntrinsic(DbgVariableIntrinsic &I) + { DELEGATE(DbgInfoIntrinsic);} RetTy visitDbgLabelInst(DbgLabelInst &I) { DELEGATE(DbgInfoIntrinsic);} - RetTy visitDbgInfoIntrinsic(DbgInfoIntrinsic &I) { DELEGATE(IntrinsicInst); } + RetTy visitDbgInfoIntrinsic(DbgInfoIntrinsic &I){ DELEGATE(IntrinsicInst); } RetTy visitMemSetInst(MemSetInst &I) { DELEGATE(MemIntrinsic); } RetTy visitMemCpyInst(MemCpyInst &I) { DELEGATE(MemTransferInst); } RetTy visitMemMoveInst(MemMoveInst &I) { DELEGATE(MemTransferInst); } Index: include/llvm/IR/IntrinsicInst.h =================================================================== --- include/llvm/IR/IntrinsicInst.h +++ include/llvm/IR/IntrinsicInst.h @@ -65,6 +65,27 @@ /// This is the common base class for debug info intrinsics. class DbgInfoIntrinsic : public IntrinsicInst { + public: + /// \name Casting methods + /// @{ + static bool classof(const IntrinsicInst *I) { + switch (I->getIntrinsicID()) { + case Intrinsic::dbg_declare: + case Intrinsic::dbg_value: + case Intrinsic::dbg_addr: + case Intrinsic::dbg_label: + return true; + default: return false; + } + } + static bool classof(const Value *V) { + return isa(V) && classof(cast(V)); + } + /// @} + }; + + /// This is the common base class for debug info intrinsics for variables. + class DbgVariableIntrinsic : public DbgInfoIntrinsic { public: /// Get the location corresponding to the variable referenced by the debug /// info intrinsic. Depending on the intrinsic, this could be the @@ -104,7 +125,6 @@ case Intrinsic::dbg_declare: case Intrinsic::dbg_value: case Intrinsic::dbg_addr: - case Intrinsic::dbg_label: return true; default: return false; } @@ -116,7 +136,7 @@ }; /// This represents the llvm.dbg.declare instruction. - class DbgDeclareInst : public DbgInfoIntrinsic { + class DbgDeclareInst : public DbgVariableIntrinsic { public: Value *getAddress() const { return getVariableLocation(); } @@ -132,7 +152,7 @@ }; /// This represents the llvm.dbg.addr instruction. - class DbgAddrIntrinsic : public DbgInfoIntrinsic { + class DbgAddrIntrinsic : public DbgVariableIntrinsic { public: Value *getAddress() const { return getVariableLocation(); } @@ -147,7 +167,7 @@ }; /// This represents the llvm.dbg.value instruction. - class DbgValueInst : public DbgInfoIntrinsic { + class DbgValueInst : public DbgVariableIntrinsic { public: Value *getValue() const { return getVariableLocation(/* AllowNullOp = */ false); @@ -168,17 +188,13 @@ class DbgLabelInst : public DbgInfoIntrinsic { public: DILabel *getLabel() const { - return cast(getRawVariable()); + return cast(getRawLabel()); } - Metadata *getRawVariable() const { + Metadata *getRawLabel() const { return cast(getArgOperand(0))->getMetadata(); } - Metadata *getRawExpression() const { - return nullptr; - } - /// Methods for support type inquiry through isa, cast, and dyn_cast: /// @{ static bool classof(const IntrinsicInst *I) { Index: include/llvm/Transforms/Utils/Local.h =================================================================== --- include/llvm/Transforms/Utils/Local.h +++ include/llvm/Transforms/Utils/Local.h @@ -43,7 +43,7 @@ class BasicBlock; class BranchInst; class CallInst; -class DbgInfoIntrinsic; +class DbgVariableIntrinsic; class DbgValueInst; class DIBuilder; class Function; @@ -270,17 +270,17 @@ /// 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 ConvertDebugDeclareToDebugValue(DbgInfoIntrinsic *DII, +void ConvertDebugDeclareToDebugValue(DbgVariableIntrinsic *DII, StoreInst *SI, DIBuilder &Builder); /// 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 ConvertDebugDeclareToDebugValue(DbgInfoIntrinsic *DII, +void ConvertDebugDeclareToDebugValue(DbgVariableIntrinsic *DII, LoadInst *LI, DIBuilder &Builder); /// Inserts a llvm.dbg.value intrinsic after a phi that has an associated /// llvm.dbg.declare or llvm.dbg.addr intrinsic. -void ConvertDebugDeclareToDebugValue(DbgInfoIntrinsic *DII, +void ConvertDebugDeclareToDebugValue(DbgVariableIntrinsic *DII, PHINode *LI, DIBuilder &Builder); /// Lowers llvm.dbg.declare intrinsics into appropriate set of @@ -294,13 +294,13 @@ /// 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 FindDbgAddrUses(Value *V); +TinyPtrVector FindDbgAddrUses(Value *V); /// Finds the llvm.dbg.value intrinsics describing a value. void findDbgValues(SmallVectorImpl &DbgValues, Value *V); /// Finds the debug info intrinsics describing a value. -void findDbgUsers(SmallVectorImpl &DbgInsts, Value *V); +void findDbgUsers(SmallVectorImpl &DbgInsts, Value *V); /// Replaces llvm.dbg.declare instruction when the address it /// describes is replaced with a new value. If Deref is true, an Index: lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp =================================================================== --- lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -5176,7 +5176,7 @@ } case Intrinsic::dbg_addr: case Intrinsic::dbg_declare: { - const DbgInfoIntrinsic &DI = cast(I); + const DbgVariableIntrinsic &DI = cast(I); DILocalVariable *Variable = DI.getVariable(); DIExpression *Expression = DI.getExpression(); dropDanglingDebugInfo(Variable, Expression); Index: lib/IR/IntrinsicInst.cpp =================================================================== --- lib/IR/IntrinsicInst.cpp +++ lib/IR/IntrinsicInst.cpp @@ -32,10 +32,11 @@ using namespace llvm; //===----------------------------------------------------------------------===// -/// DbgInfoIntrinsic - This is the common base class for debug info intrinsics +/// DbgVariableIntrinsic - This is the common base class for debug info +/// intrinsics for variables. /// -Value *DbgInfoIntrinsic::getVariableLocation(bool AllowNullOp) const { +Value *DbgVariableIntrinsic::getVariableLocation(bool AllowNullOp) const { Value *Op = getArgOperand(0); if (AllowNullOp && !Op) return nullptr; @@ -45,14 +46,11 @@ return V->getValue(); // When the value goes to null, it gets replaced by an empty MDNode. - assert((isa(this) - || !cast(MD)->getNumOperands()) - && "DbgValueInst Expected an empty MDNode"); - + assert(!cast(MD)->getNumOperands() && "Expected an empty MDNode"); return nullptr; } -Optional DbgInfoIntrinsic::getFragmentSizeInBits() const { +Optional DbgVariableIntrinsic::getFragmentSizeInBits() const { if (auto Fragment = getExpression()->getFragmentInfo()) return Fragment->SizeInBits; return getVariable()->getSizeInBits(); Index: lib/IR/Verifier.cpp =================================================================== --- lib/IR/Verifier.cpp +++ lib/IR/Verifier.cpp @@ -467,7 +467,7 @@ void visitUserOp2(Instruction &I) { visitUserOp1(I); } void visitIntrinsicCallSite(Intrinsic::ID ID, CallSite CS); void visitConstrainedFPIntrinsic(ConstrainedFPIntrinsic &FPI); - void visitDbgIntrinsic(StringRef Kind, DbgInfoIntrinsic &DII); + void visitDbgIntrinsic(StringRef Kind, DbgVariableIntrinsic &DII); void visitDbgLabelIntrinsic(StringRef Kind, DbgLabelInst &DLI); void visitAtomicCmpXchgInst(AtomicCmpXchgInst &CXI); void visitAtomicRMWInst(AtomicRMWInst &RMWI); @@ -505,12 +505,12 @@ void verifyFrameRecoverIndices(); void verifySiblingFuncletUnwinds(); - void verifyFragmentExpression(const DbgInfoIntrinsic &I); + void verifyFragmentExpression(const DbgVariableIntrinsic &I); template void verifyFragmentExpression(const DIVariable &V, DIExpression::FragmentInfo Fragment, ValueOrMetadata *Desc); - void verifyFnArgs(const DbgInfoIntrinsic &I); + void verifyFnArgs(const DbgVariableIntrinsic &I); /// Module-level debug info verification... void verifyCompileUnits(); @@ -3984,7 +3984,7 @@ visitMDNode(*N); } - if (auto *DII = dyn_cast(&I)) + if (auto *DII = dyn_cast(&I)) verifyFragmentExpression(*DII); InstsInThisBlock.insert(&I); @@ -4090,13 +4090,13 @@ case Intrinsic::dbg_declare: // llvm.dbg.declare Assert(isa(CS.getArgOperand(0)), "invalid llvm.dbg.declare intrinsic call 1", CS); - visitDbgIntrinsic("declare", cast(*CS.getInstruction())); + visitDbgIntrinsic("declare", cast(*CS.getInstruction())); break; case Intrinsic::dbg_addr: // llvm.dbg.addr - visitDbgIntrinsic("addr", cast(*CS.getInstruction())); + visitDbgIntrinsic("addr", cast(*CS.getInstruction())); break; case Intrinsic::dbg_value: // llvm.dbg.value - visitDbgIntrinsic("value", cast(*CS.getInstruction())); + visitDbgIntrinsic("value", cast(*CS.getInstruction())); break; case Intrinsic::dbg_label: // llvm.dbg.label visitDbgLabelIntrinsic("label", cast(*CS.getInstruction())); @@ -4491,7 +4491,7 @@ "invalid exception behavior argument", &FPI); } -void Verifier::visitDbgIntrinsic(StringRef Kind, DbgInfoIntrinsic &DII) { +void Verifier::visitDbgIntrinsic(StringRef Kind, DbgVariableIntrinsic &DII) { auto *MD = cast(DII.getArgOperand(0))->getMetadata(); AssertDI(isa(MD) || (isa(MD) && !cast(MD)->getNumOperands()), @@ -4531,9 +4531,9 @@ } void Verifier::visitDbgLabelIntrinsic(StringRef Kind, DbgLabelInst &DLI) { - AssertDI(isa(DLI.getRawVariable()), + AssertDI(isa(DLI.getRawLabel()), "invalid llvm.dbg." + Kind + " intrinsic variable", &DLI, - DLI.getRawVariable()); + DLI.getRawLabel()); // Ignore broken !dbg attachments; they're checked elsewhere. if (MDNode *N = DLI.getDebugLoc().getAsMDNode()) @@ -4560,10 +4560,7 @@ Loc->getScope()->getSubprogram()); } -void Verifier::verifyFragmentExpression(const DbgInfoIntrinsic &I) { - if (dyn_cast(&I)) - return; - +void Verifier::verifyFragmentExpression(const DbgVariableIntrinsic &I) { DILocalVariable *V = dyn_cast_or_null(I.getRawVariable()); DIExpression *E = dyn_cast_or_null(I.getRawExpression()); @@ -4605,7 +4602,7 @@ AssertDI(FragSize != *VarSize, "fragment covers entire variable", Desc, &V); } -void Verifier::verifyFnArgs(const DbgInfoIntrinsic &I) { +void Verifier::verifyFnArgs(const DbgVariableIntrinsic &I) { // This function does not take the scope of noninlined function arguments into // account. Don't run it if current function is nodebug, because it may // contain inlined debug intrinsics. Index: lib/Transforms/InstCombine/InstructionCombining.cpp =================================================================== --- lib/Transforms/InstCombine/InstructionCombining.cpp +++ lib/Transforms/InstCombine/InstructionCombining.cpp @@ -2144,7 +2144,7 @@ // If we are removing an alloca with a dbg.declare, insert dbg.value calls // before each store. - TinyPtrVector DIIs; + TinyPtrVector DIIs; std::unique_ptr DIB; if (isa(MI)) { DIIs = FindDbgAddrUses(&MI); @@ -2934,7 +2934,7 @@ // Also sink all related debug uses from the source basic block. Otherwise we // get debug use before the def. - SmallVector DbgUsers; + SmallVector DbgUsers; findDbgUsers(DbgUsers, I); for (auto *DII : DbgUsers) { if (DII->getParent() == SrcBlock) { Index: lib/Transforms/Scalar/ADCE.cpp =================================================================== --- lib/Transforms/Scalar/ADCE.cpp +++ lib/Transforms/Scalar/ADCE.cpp @@ -507,7 +507,7 @@ if (isLive(&I)) continue; - if (auto *DII = dyn_cast(&I)) { + if (auto *DII = dyn_cast(&I)) { // Check if the scope of this variable location is alive. if (AliveScopes.count(DII->getDebugLoc()->getScope())) continue; Index: lib/Transforms/Scalar/Reassociate.cpp =================================================================== --- lib/Transforms/Scalar/Reassociate.cpp +++ lib/Transforms/Scalar/Reassociate.cpp @@ -788,7 +788,7 @@ // 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 DbgUsers; + SmallVector DbgUsers; findDbgUsers(DbgUsers, ExpressionChanged); for (auto *DII : DbgUsers) { Value *Undef = UndefValue::get(ExpressionChanged->getType()); Index: lib/Transforms/Scalar/SROA.cpp =================================================================== --- lib/Transforms/Scalar/SROA.cpp +++ lib/Transforms/Scalar/SROA.cpp @@ -4212,7 +4212,7 @@ // Migrate debug information from the old alloca to the new alloca(s) // and the individual partitions. - TinyPtrVector DbgDeclares = FindDbgAddrUses(&AI); + TinyPtrVector DbgDeclares = FindDbgAddrUses(&AI); if (!DbgDeclares.empty()) { auto *Var = DbgDeclares.front()->getVariable(); auto *Expr = DbgDeclares.front()->getExpression(); @@ -4264,7 +4264,7 @@ } // 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 @@ // not be able to find it. if (AllocaInst *AI = dyn_cast(I)) { DeletedAllocas.insert(AI); - for (DbgInfoIntrinsic *OldDII : FindDbgAddrUses(AI)) + for (DbgVariableIntrinsic *OldDII : FindDbgAddrUses(AI)) OldDII->eraseFromParent(); } Index: lib/Transforms/Utils/Local.cpp =================================================================== --- lib/Transforms/Utils/Local.cpp +++ lib/Transforms/Utils/Local.cpp @@ -1237,7 +1237,7 @@ /// 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()) @@ -1255,7 +1255,7 @@ /// 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(); @@ -1312,7 +1312,7 @@ /// 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(); @@ -1341,7 +1341,7 @@ /// 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(); @@ -1443,7 +1443,7 @@ // Map existing PHI nodes to their dbg.values. ValueToValueMapTy DbgValueMap; for (auto &I : *BB) { - if (auto DbgII = dyn_cast(&I)) { + if (auto DbgII = dyn_cast(&I)) { if (auto *Loc = dyn_cast_or_null(DbgII->getVariableLocation())) DbgValueMap.insert({Loc, DbgII}); } @@ -1464,7 +1464,7 @@ for (auto VI : PHI->operand_values()) { auto V = DbgValueMap.find(VI); if (V != DbgValueMap.end()) { - auto *DbgII = cast(V->second); + auto *DbgII = cast(V->second); Instruction *NewDbgII = DbgII->clone(); NewDbgII->setOperand(0, PhiMAV); auto InsertionPt = Parent->getFirstInsertionPt(); @@ -1478,7 +1478,7 @@ /// 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 llvm::FindDbgAddrUses(Value *V) { +TinyPtrVector llvm::FindDbgAddrUses(Value *V) { // This function is hot. Check whether the value has any metadata to avoid a // DenseMap lookup. if (!V->isUsedByMetadata()) @@ -1490,9 +1490,9 @@ if (!MDV) return {}; - TinyPtrVector Declares; + TinyPtrVector Declares; for (User *U : MDV->users()) { - if (auto *DII = dyn_cast(U)) + if (auto *DII = dyn_cast(U)) if (DII->isAddressOfVariable()) Declares.push_back(DII); } @@ -1512,7 +1512,7 @@ DbgValues.push_back(DVI); } -void llvm::findDbgUsers(SmallVectorImpl &DbgUsers, +void llvm::findDbgUsers(SmallVectorImpl &DbgUsers, Value *V) { // This function is hot. Check whether the value has any metadata to avoid a // DenseMap lookup. @@ -1521,7 +1521,7 @@ if (auto *L = LocalAsMetadata::getIfExists(V)) if (auto *MDV = MetadataAsValue::getIfExists(V->getContext(), L)) for (User *U : MDV->users()) - if (DbgInfoIntrinsic *DII = dyn_cast(U)) + if (DbgVariableIntrinsic *DII = dyn_cast(U)) DbgUsers.push_back(DII); } @@ -1529,7 +1529,7 @@ 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(); @@ -1597,7 +1597,7 @@ } bool llvm::salvageDebugInfo(Instruction &I) { - SmallVector DbgUsers; + SmallVector DbgUsers; findDbgUsers(DbgUsers, &I); if (DbgUsers.empty()) return false; @@ -1607,7 +1607,7 @@ auto &Ctx = I.getContext(); auto wrapMD = [&](Value *V) { return wrapValueInMetadata(Ctx, V); }; - auto doSalvage = [&](DbgInfoIntrinsic *DII, SmallVectorImpl &Ops) { + auto doSalvage = [&](DbgVariableIntrinsic *DII, SmallVectorImpl &Ops) { auto *DIExpr = DII->getExpression(); if (!Ops.empty()) { // Do not add DW_OP_stack_value for DbgDeclare and DbgAddr, because they @@ -1621,13 +1621,13 @@ LLVM_DEBUG(dbgs() << "SALVAGE: " << *DII << '\n'); }; - auto applyOffset = [&](DbgInfoIntrinsic *DII, uint64_t Offset) { + auto applyOffset = [&](DbgVariableIntrinsic *DII, uint64_t Offset) { SmallVector Ops; DIExpression::appendOffset(Ops, Offset); doSalvage(DII, Ops); }; - auto applyOps = [&](DbgInfoIntrinsic *DII, + auto applyOps = [&](DbgVariableIntrinsic *DII, std::initializer_list Opcodes) { SmallVector Ops(Opcodes); doSalvage(DII, Ops); @@ -1726,16 +1726,16 @@ /// changes are made. static bool rewriteDebugUsers( Instruction &From, Value &To, Instruction &DomPoint, DominatorTree &DT, - function_ref RewriteExpr) { + function_ref RewriteExpr) { // Find debug users of From. - SmallVector Users; + SmallVector Users; findDbgUsers(Users, &From); if (Users.empty()) return false; // Prevent use-before-def of To. bool Changed = false; - SmallPtrSet DeleteOrSalvage; + SmallPtrSet DeleteOrSalvage; if (isa(&To)) { bool DomPointAfterFrom = From.getNextNonDebugInstruction() == &DomPoint; @@ -1824,7 +1824,7 @@ Type *FromTy = From.getType(); Type *ToTy = To.getType(); - auto Identity = [&](DbgInfoIntrinsic &DII) -> DbgValReplacement { + auto Identity = [&](DbgVariableIntrinsic &DII) -> DbgValReplacement { return DII.getExpression(); }; @@ -1848,7 +1848,7 @@ // 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. Index: lib/Transforms/Utils/LoopRotationUtils.cpp =================================================================== --- lib/Transforms/Utils/LoopRotationUtils.cpp +++ lib/Transforms/Utils/LoopRotationUtils.cpp @@ -303,13 +303,13 @@ // Record all debug intrinsics preceding LoopEntryBranch to avoid duplication. using DbgIntrinsicHash = std::pair, DIExpression *>; - auto makeHash = [](DbgInfoIntrinsic *D) -> DbgIntrinsicHash { + auto makeHash = [](DbgVariableIntrinsic *D) -> DbgIntrinsicHash { return {{D->getVariableLocation(), D->getVariable()}, D->getExpression()}; }; SmallDenseSet DbgIntrinsics; for (auto I = std::next(OrigPreheader->rbegin()), E = OrigPreheader->rend(); I != E; ++I) { - if (auto *DII = dyn_cast(&*I)) + if (auto *DII = dyn_cast(&*I)) DbgIntrinsics.insert(makeHash(DII)); else break; @@ -339,7 +339,7 @@ RF_NoModuleLevelChanges | RF_IgnoreMissingLocals); // Avoid inserting the same intrinsic twice. - if (auto *DII = dyn_cast(C)) + if (auto *DII = dyn_cast(C)) if (DbgIntrinsics.count(makeHash(DII))) { C->deleteValue(); continue; Index: lib/Transforms/Utils/PromoteMemoryToRegister.cpp =================================================================== --- lib/Transforms/Utils/PromoteMemoryToRegister.cpp +++ lib/Transforms/Utils/PromoteMemoryToRegister.cpp @@ -116,7 +116,7 @@ bool OnlyUsedInOneBlock; Value *AllocaPointerVal; - TinyPtrVector DbgDeclares; + TinyPtrVector DbgDeclares; void clear() { DefiningBlocks.clear(); @@ -263,7 +263,7 @@ /// 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, 8> AllocaDbgDeclares; + SmallVector, 8> AllocaDbgDeclares; /// The set of basic blocks the renamer has already visited. SmallPtrSet Visited; @@ -426,7 +426,7 @@ // 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 @@ while (!AI->use_empty()) { StoreInst *SI = cast(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 @@ 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 @@ // 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 @@ // 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); } Index: unittests/Transforms/Utils/Local.cpp =================================================================== --- unittests/Transforms/Utils/Local.cpp +++ unittests/Transforms/Utils/Local.cpp @@ -533,25 +533,25 @@ // Simulate i32* <-> i64* conversion. EXPECT_TRUE(replaceAllDbgUsesWith(D, C, C, DT)); - SmallVector CDbgVals; + SmallVector CDbgVals; findDbgUsers(CDbgVals, &C); EXPECT_EQ(2U, CDbgVals.size()); - EXPECT_TRUE(any_of(CDbgVals, [](DbgInfoIntrinsic *DII) { + EXPECT_TRUE(any_of(CDbgVals, [](DbgVariableIntrinsic *DII) { return isa(DII); })); - EXPECT_TRUE(any_of(CDbgVals, [](DbgInfoIntrinsic *DII) { + EXPECT_TRUE(any_of(CDbgVals, [](DbgVariableIntrinsic *DII) { return isa(DII); })); EXPECT_TRUE(replaceAllDbgUsesWith(C, D, D, DT)); - SmallVector DDbgVals; + SmallVector DDbgVals; findDbgUsers(DDbgVals, &D); EXPECT_EQ(2U, DDbgVals.size()); - EXPECT_TRUE(any_of(DDbgVals, [](DbgInfoIntrinsic *DII) { + EXPECT_TRUE(any_of(DDbgVals, [](DbgVariableIntrinsic *DII) { return isa(DII); })); - EXPECT_TRUE(any_of(DDbgVals, [](DbgInfoIntrinsic *DII) { + EXPECT_TRUE(any_of(DDbgVals, [](DbgVariableIntrinsic *DII) { return isa(DII); }));