[llvm] r234778 - DebugInfo: Migrate DISubprogram::describes() to new hierarchy, NFC

David Blaikie dblaikie at gmail.com
Mon Apr 13 12:43:20 PDT 2015


On Mon, Apr 13, 2015 at 12:07 PM, Duncan P. N. Exon Smith <
dexonsmith at apple.com> wrote:

> Author: dexonsmith
> Date: Mon Apr 13 14:07:27 2015
> New Revision: 234778
>
> URL: http://llvm.org/viewvc/llvm-project?rev=234778&view=rev
> Log:
> DebugInfo: Migrate DISubprogram::describes() to new hierarchy, NFC
>
> I don't really like this function at all -- I think it should be as
> simple as `return getFunction() == F` -- but for now this seems like the
> best we can do.
>

Any particular cases where this does anything other than getFunction() ==
F? (maybe this is bitcasts getting in the way again?)


>
> Modified:
>     llvm/trunk/include/llvm/IR/DebugInfo.h
>     llvm/trunk/include/llvm/IR/DebugInfoMetadata.h
>     llvm/trunk/lib/IR/DebugInfo.cpp
>     llvm/trunk/lib/IR/DebugInfoMetadata.cpp
>
> Modified: llvm/trunk/include/llvm/IR/DebugInfo.h
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DebugInfo.h?rev=234778&r1=234777&r2=234778&view=diff
>
> ==============================================================================
> --- llvm/trunk/include/llvm/IR/DebugInfo.h (original)
> +++ llvm/trunk/include/llvm/IR/DebugInfo.h Mon Apr 13 14:07:27 2015
> @@ -520,7 +520,7 @@ public:
>    DITypeRef getContainingType() const { return
> get()->getContainingType(); }
>
>    /// \brief Check if this provides debugging information for the
> function F.
> -  bool describes(const Function *F);
> +  bool describes(const Function *F) const { return get()->describes(F); }
>
>    Function *getFunction() const { return get()->getFunction(); }
>
>
> Modified: llvm/trunk/include/llvm/IR/DebugInfoMetadata.h
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DebugInfoMetadata.h?rev=234778&r1=234777&r2=234778&view=diff
>
> ==============================================================================
> --- llvm/trunk/include/llvm/IR/DebugInfoMetadata.h (original)
> +++ llvm/trunk/include/llvm/IR/DebugInfoMetadata.h Mon Apr 13 14:07:27 2015
> @@ -1386,6 +1386,11 @@ public:
>    void replaceFunction(std::nullptr_t) { replaceOperandWith(7, nullptr); }
>    /// @}
>
> +  /// \brief Check if this subprogram decribes the given function.
> +  ///
> +  /// FIXME: Should this be looking through bitcasts?
> +  bool describes(const Function *F) const;
> +
>    static bool classof(const Metadata *MD) {
>      return MD->getMetadataID() == MDSubprogramKind;
>    }
>
> Modified: llvm/trunk/lib/IR/DebugInfo.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DebugInfo.cpp?rev=234778&r1=234777&r2=234778&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/IR/DebugInfo.cpp (original)
> +++ llvm/trunk/lib/IR/DebugInfo.cpp Mon Apr 13 14:07:27 2015
> @@ -49,18 +49,6 @@ bool DIVariable::isInlinedFnArgument(con
>    return !SP.describes(CurFn);
>  }
>
> -bool DISubprogram::describes(const Function *F) {
> -  assert(F && "Invalid function");
> -  if (F == getFunction())
> -    return true;
> -  StringRef Name = getLinkageName();
> -  if (Name.empty())
> -    Name = getName();
> -  if (F->getName() == Name)
> -    return true;
> -  return false;
> -}
> -
>  GlobalVariable *DIGlobalVariable::getGlobal() const {
>    return dyn_cast_or_null<GlobalVariable>(getConstant());
>  }
>
> Modified: llvm/trunk/lib/IR/DebugInfoMetadata.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DebugInfoMetadata.cpp?rev=234778&r1=234777&r2=234778&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/IR/DebugInfoMetadata.cpp (original)
> +++ llvm/trunk/lib/IR/DebugInfoMetadata.cpp Mon Apr 13 14:07:27 2015
> @@ -348,6 +348,16 @@ Function *MDSubprogram::getFunction() co
>    return dyn_cast_or_null<Function>(getFunctionConstant());
>  }
>
> +bool MDSubprogram::describes(const Function *F) const {
> +  assert(F && "Invalid function");
> +  if (F == getFunction())
> +    return true;
> +  StringRef Name = getLinkageName();
> +  if (Name.empty())
> +    Name = getName();
> +  return F->getName() == Name;
> +}
> +
>  void MDSubprogram::replaceFunction(Function *F) {
>    replaceFunction(F ? ConstantAsMetadata::get(F)
>                      : static_cast<ConstantAsMetadata *>(nullptr));
>
>
> _______________________________________________
> 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/20150413/6e2859e2/attachment.html>


More information about the llvm-commits mailing list