diff options
author | Chris Lattner <sabre@nondot.org> | 2010-03-31 03:34:40 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-03-31 03:34:40 +0000 |
commit | 870cfcf9a6189b65a8ee805b93a2c737c0183e62 (patch) | |
tree | b9af4814e3f7a7b952fa656e18144b5dbb3457db | |
parent | d363b4ebc7a98483437a5a88aba01dd9facdcd01 (diff) | |
download | external_llvm-870cfcf9a6189b65a8ee805b93a2c737c0183e62.zip external_llvm-870cfcf9a6189b65a8ee805b93a2c737c0183e62.tar.gz external_llvm-870cfcf9a6189b65a8ee805b93a2c737c0183e62.tar.bz2 |
add new apis for getting/setting !dbg metadata on
instructions. In addition to being a convenience,
they are faster than the old apis, particularly when
not going from an MDKindID like people should be
doing.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99982 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/Instruction.h | 10 | ||||
-rw-r--r-- | include/llvm/Support/ValueHandle.h | 3 | ||||
-rw-r--r-- | lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 3 | ||||
-rw-r--r-- | lib/CodeGen/SelectionDAG/FastISel.cpp | 7 | ||||
-rw-r--r-- | lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | 4 | ||||
-rw-r--r-- | lib/VMCore/Metadata.cpp | 4 |
6 files changed, 22 insertions, 9 deletions
diff --git a/include/llvm/Instruction.h b/include/llvm/Instruction.h index 4184112..472ab83 100644 --- a/include/llvm/Instruction.h +++ b/include/llvm/Instruction.h @@ -156,6 +156,16 @@ public: void setMetadata(unsigned KindID, MDNode *Node); void setMetadata(const char *Kind, MDNode *Node); + /// setDbgMetadata - This is just an optimized helper function that is + /// equivalent to setMetadata("dbg", Node); + void setDbgMetadata(MDNode *Node); + + /// getDbgMetadata - This is just an optimized helper function that is + /// equivalent to calling getMetadata("dbg"). + MDNode *getDbgMetadata() const { + return DbgInfo; + } + private: /// hasMetadataHashEntry - Return true if we have an entry in the on-the-side /// metadata hash. diff --git a/include/llvm/Support/ValueHandle.h b/include/llvm/Support/ValueHandle.h index 0e61d09..130a620ab 100644 --- a/include/llvm/Support/ValueHandle.h +++ b/include/llvm/Support/ValueHandle.h @@ -284,8 +284,7 @@ class TrackingVH : public ValueHandleBase { Value *VP = ValueHandleBase::getValPtr(); // Null is always ok. - if (!VP) - return; + if (!VP) return; // Check that this value is valid (i.e., it hasn't been deleted). We // explicitly delay this check until access to avoid requiring clients to be diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 00a98fb..2f1a063 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -2014,7 +2014,8 @@ void DwarfDebug::collectVariableInfo() { // FIXME : Lift this restriction. if (MInsn->getNumOperands() != 3) continue; - DIVariable DV((MDNode*)(MInsn->getOperand(MInsn->getNumOperands() - 1).getMetadata())); + DIVariable DV((MDNode*)(MInsn->getOperand(MInsn->getNumOperands() + - 1).getMetadata())); if (DV.getTag() == dwarf::DW_TAG_arg_variable) { // FIXME Handle inlined subroutine arguments. DbgVariable *ArgVar = new DbgVariable(DV, MInsn, NULL); diff --git a/lib/CodeGen/SelectionDAG/FastISel.cpp b/lib/CodeGen/SelectionDAG/FastISel.cpp index 3fc30ff..e4e9ef4 100644 --- a/lib/CodeGen/SelectionDAG/FastISel.cpp +++ b/lib/CodeGen/SelectionDAG/FastISel.cpp @@ -340,10 +340,9 @@ bool FastISel::SelectCall(User *I) { StaticAllocaMap.find(AI); if (SI == StaticAllocaMap.end()) break; // VLAs. int FI = SI->second; - if (MMI) { - if (MDNode *Dbg = DI->getMetadata("dbg")) - MMI->setVariableDbgInfo(DI->getVariable(), FI, Dbg); - } + if (MDNode *Dbg = DI->getDbgMetadata()) + MMI->setVariableDbgInfo(DI->getVariable(), FI, Dbg); + // Building the map above is target independent. Generating DBG_VALUE // inline is target dependent; do this now. (void)TargetSelectInstruction(cast<Instruction>(I)); diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index 7a0daf6..922c6e8 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -3800,7 +3800,7 @@ SelectionDAGBuilder::visitIntrinsicCall(CallInst &I, unsigned Intrinsic) { int FI = SI->second; if (MachineModuleInfo *MMI = DAG.getMachineModuleInfo()) - if (MDNode *Dbg = DI.getMetadata("dbg")) + if (MDNode *Dbg = DI.getDbgMetadata()) MMI->setVariableDbgInfo(Variable, FI, Dbg); return 0; } @@ -3852,7 +3852,7 @@ SelectionDAGBuilder::visitIntrinsicCall(CallInst &I, unsigned Intrinsic) { return 0; // VLAs. int FI = SI->second; if (MachineModuleInfo *MMI = DAG.getMachineModuleInfo()) - if (MDNode *Dbg = DI.getMetadata("dbg")) + if (MDNode *Dbg = DI.getDbgMetadata()) MMI->setVariableDbgInfo(Variable, FI, Dbg); return 0; } diff --git a/lib/VMCore/Metadata.cpp b/lib/VMCore/Metadata.cpp index 77926f9..6f794da 100644 --- a/lib/VMCore/Metadata.cpp +++ b/lib/VMCore/Metadata.cpp @@ -424,6 +424,10 @@ MDNode *Instruction::getMetadataImpl(const char *Kind) const { return getMetadataImpl(getContext().getMDKindID(Kind)); } +void Instruction::setDbgMetadata(MDNode *Node) { + DbgInfo = Node; +} + /// setMetadata - Set the metadata of of the specified kind to the specified /// node. This updates/replaces metadata if already present, or removes it if /// Node is null. |