[llvm] r220536 - Make getDISubprogram(const Function *F) available in LLVM
David Blaikie
dblaikie at gmail.com
Thu Oct 23 18:10:21 PDT 2014
On Thu, Oct 23, 2014 at 4:46 PM, Timur Iskhodzhanov <timurrrr at google.com>
wrote:
> Author: timurrrr
> Date: Thu Oct 23 18:46:28 2014
> New Revision: 220536
>
> URL: http://llvm.org/viewvc/llvm-project?rev=220536&view=rev
> Log:
> Make getDISubprogram(const Function *F) available in LLVM
>
> Reviewed at http://reviews.llvm.org/D5950
>
> Modified:
> llvm/trunk/include/llvm/IR/DebugInfo.h
> llvm/trunk/lib/IR/DebugInfo.cpp
> llvm/trunk/lib/Transforms/Scalar/SampleProfile.cpp
>
> Modified: llvm/trunk/include/llvm/IR/DebugInfo.h
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DebugInfo.h?rev=220536&r1=220535&r2=220536&view=diff
>
> ==============================================================================
> --- llvm/trunk/include/llvm/IR/DebugInfo.h (original)
> +++ llvm/trunk/include/llvm/IR/DebugInfo.h Thu Oct 23 18:46:28 2014
> @@ -961,6 +961,11 @@ public:
> /// \brief Find subprogram that is enclosing this scope.
> DISubprogram getDISubprogram(const MDNode *Scope);
>
> +/// \brief Find debug info for a given function.
> +/// \returns a valid DISubprogram, if found. Otherwise, it returns an
> empty
> +/// DISubprogram.
> +DISubprogram getDISubprogram(const Function *F);
> +
> /// \brief Find underlying composite type.
> DICompositeType getDICompositeType(DIType T);
>
>
> Modified: llvm/trunk/lib/IR/DebugInfo.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DebugInfo.cpp?rev=220536&r1=220535&r2=220536&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/IR/DebugInfo.cpp (original)
> +++ llvm/trunk/lib/IR/DebugInfo.cpp Thu Oct 23 18:46:28 2014
> @@ -912,6 +912,24 @@ DISubprogram llvm::getDISubprogram(const
> return DISubprogram();
> }
>
> +DISubprogram llvm::getDISubprogram(const Function *F) {
> + // We look for the first instr that has a debug annotation leading back
> to F.
> + const LLVMContext &Ctx = F->getParent()->getContext();
> + for (auto &BB : *F) {
> + for (auto &Inst : BB.getInstList()) {
> + DebugLoc DLoc = Inst.getDebugLoc();
> + if (DLoc.isUnknown())
> + continue;
> + const MDNode *Scope = DLoc.getScopeNode(Ctx);
> + DISubprogram Subprogram = getDISubprogram(Scope);
> + if (Subprogram.describes(F))
> + return Subprogram;
>
You've changed this in the moving - it used to return on the first
Instruction with DebugInfo, now it keeps searching.
(also, we could change this function to take a reference instead of a
pointer - I was going to make that change when I saw this semantic change
that caught me by surprise)
> + }
> + }
> +
> + return DISubprogram();
> +}
> +
> DICompositeType llvm::getDICompositeType(DIType T) {
> if (T.isCompositeType())
> return DICompositeType(T);
>
> Modified: llvm/trunk/lib/Transforms/Scalar/SampleProfile.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SampleProfile.cpp?rev=220536&r1=220535&r2=220536&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Transforms/Scalar/SampleProfile.cpp (original)
> +++ llvm/trunk/lib/Transforms/Scalar/SampleProfile.cpp Thu Oct 23 18:46:28
> 2014
> @@ -627,29 +627,6 @@ void SampleProfileLoader::propagateWeigh
> }
> }
>
> -/// \brief Locate the DISubprogram for F.
> -///
> -/// We look for the first instruction that has a debug annotation
> -/// leading back to \p F.
> -///
> -/// \returns a valid DISubprogram, if found. Otherwise, it returns an
> empty
> -/// DISubprogram.
> -static const DISubprogram getDISubprogram(Function &F, const LLVMContext
> &Ctx) {
> - for (auto &BI : F) {
> - BasicBlock *BB = &BI;
> - for (auto &Inst : BB->getInstList()) {
> - DebugLoc DLoc = Inst.getDebugLoc();
> - if (DLoc.isUnknown())
> - continue;
> - const MDNode *Scope = DLoc.getScopeNode(Ctx);
> - DISubprogram Subprogram = getDISubprogram(Scope);
> - return Subprogram.describes(&F) ? Subprogram : DISubprogram();
> - }
> - }
> -
> - return DISubprogram();
> -}
> -
> /// \brief Get the line number for the function header.
> ///
> /// This looks up function \p F in the current compilation unit and
> @@ -662,7 +639,7 @@ static const DISubprogram getDISubprogra
> /// \returns the line number where \p F is defined. If it returns 0,
> /// it means that there is no debug information available for \p
> F.
> unsigned SampleProfileLoader::getFunctionLoc(Function &F) {
> - const DISubprogram &S = getDISubprogram(F, *Ctx);
> + DISubprogram S = getDISubprogram(&F);
> if (S.isSubprogram())
> return S.getLineNumber();
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141023/93140ed5/attachment.html>
More information about the llvm-commits
mailing list