X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FVMCore%2FDebugLoc.cpp;h=9013d28bb67d2d7b8134ce90fdf3f66ede2f6375;hb=2a9d3b79db1f192dba43b8b16755a7822b05f798;hp=35691627f49702441d095ebfb12fb5bab70ae4c2;hpb=4841121580df86b327013d1fab2a9339be487bce;p=oota-llvm.git diff --git a/lib/VMCore/DebugLoc.cpp b/lib/VMCore/DebugLoc.cpp index 35691627f49..9013d28bb67 100644 --- a/lib/VMCore/DebugLoc.cpp +++ b/lib/VMCore/DebugLoc.cpp @@ -104,12 +104,12 @@ MDNode *DebugLoc::getAsMDNode(const LLVMContext &Ctx) const { assert(Scope && "If scope is null, this should be isUnknown()"); LLVMContext &Ctx2 = Scope->getContext(); - const Type *Int32 = Type::getInt32Ty(Ctx2); + Type *Int32 = Type::getInt32Ty(Ctx2); Value *Elts[] = { ConstantInt::get(Int32, getLine()), ConstantInt::get(Int32, getCol()), Scope, IA }; - return MDNode::get(Ctx2, &Elts[0], 4); + return MDNode::get(Ctx2, Elts); } /// getFromDILocation - Translate the DILocation quad into a DebugLoc. @@ -128,6 +128,38 @@ DebugLoc DebugLoc::getFromDILocation(MDNode *N) { return get(LineNo, ColNo, Scope, dyn_cast_or_null(N->getOperand(3))); } +/// getFromDILexicalBlock - Translate the DILexicalBlock into a DebugLoc. +DebugLoc DebugLoc::getFromDILexicalBlock(MDNode *N) { + if (N == 0 || N->getNumOperands() < 3) return DebugLoc(); + + MDNode *Scope = dyn_cast_or_null(N->getOperand(1)); + if (Scope == 0) return DebugLoc(); + + unsigned LineNo = 0, ColNo = 0; + if (ConstantInt *Line = dyn_cast_or_null(N->getOperand(2))) + LineNo = Line->getZExtValue(); + if (ConstantInt *Col = dyn_cast_or_null(N->getOperand(3))) + ColNo = Col->getZExtValue(); + + return get(LineNo, ColNo, Scope, NULL); +} + +void DebugLoc::dump(const LLVMContext &Ctx) const { +#ifndef NDEBUG + if (!isUnknown()) { + dbgs() << getLine(); + if (getCol() != 0) + dbgs() << ',' << getCol(); + DebugLoc InlinedAtDL = DebugLoc::getFromDILocation(getInlinedAt(Ctx)); + if (!InlinedAtDL.isUnknown()) { + dbgs() << " @ "; + InlinedAtDL.dump(Ctx); + } else + dbgs() << "\n"; + } +#endif +} + //===----------------------------------------------------------------------===// // DenseMap specialization //===----------------------------------------------------------------------===// @@ -141,10 +173,7 @@ DebugLoc DenseMapInfo::getTombstoneKey() { } unsigned DenseMapInfo::getHashValue(const DebugLoc &Key) { - FoldingSetNodeID ID; - ID.AddInteger(Key.LineCol); - ID.AddInteger(Key.ScopeIdx); - return ID.ComputeHash(); + return static_cast(hash_combine(Key.LineCol, Key.ScopeIdx)); } bool DenseMapInfo::isEqual(const DebugLoc &LHS, const DebugLoc &RHS) { @@ -208,7 +237,7 @@ int LLVMContextImpl::getOrAddScopeInlinedAtIdxEntry(MDNode *Scope, MDNode *IA, /// deleted - The MDNode this is pointing to got deleted, so this pointer needs /// to drop to null and we need remove our entry from the DenseMap. void DebugRecVH::deleted() { - // If this is a non-canonical reference, just drop the value to null, we know + // If this is a non-canonical reference, just drop the value to null, we know // it doesn't have a map entry. if (Idx == 0) { setValPtr(0);