[llvm] r289661 - New API for merging debug locations. NFC.

Davide Italiano via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 14 14:47:43 PST 2016


On Wed, Dec 14, 2016 at 8:14 AM, Robert Lougher via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
> Author: rlougher
> Date: Wed Dec 14 10:14:17 2016
> New Revision: 289661
>
> URL: http://llvm.org/viewvc/llvm-project?rev=289661&view=rev
> Log:
> New API for merging debug locations. NFC.
>
> Given two debug locations the function getMergedLocation combines the
> locations into a single location (which may be an empty location).
> Please see https://reviews.llvm.org/D26256 for the discussion leading
> up to this API.
>
> Note the function is currently a stub.  This allows optimisations to
> use the API although no location will actually be used.
>
> This is patch 1 out of 8 for D26256.  As suggested by David Blaikie,
> each change in D26256 has been broken out into a separate patch.
>
> Modified:
>     llvm/trunk/include/llvm/IR/DebugInfoMetadata.h
>
> Modified: llvm/trunk/include/llvm/IR/DebugInfoMetadata.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DebugInfoMetadata.h?rev=289661&r1=289660&r2=289661&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/IR/DebugInfoMetadata.h (original)
> +++ llvm/trunk/include/llvm/IR/DebugInfoMetadata.h Wed Dec 14 10:14:17 2016
> @@ -1291,6 +1291,24 @@ public:
>    /// Returns a new DILocation with updated \p Discriminator.
>    inline DILocation *cloneWithDiscriminator(unsigned Discriminator) const;
>
> +  /// When two instructions are combined into a single instruction we also
> +  /// need to combine the original locations into a single location.
> +  ///
> +  /// When the locations are the same we can use either location. When they
> +  /// differ, we need a third location which is distinct from either. If
> +  /// they have the same file/line but have a different discriminator we
> +  /// could create a location with a new discriminator. If they are from
> +  /// different files/lines the location is ambiguous and can't be
> +  /// represented in a single line entry.  In this case, no location
> +  /// should be set.
> +  ///
> +  /// Currently this function is simply a stub, and no location will be
> +  /// used for all cases.
> +  static DILocation *getMergedLocation(const DILocation *LocA,
> +                                       const DILocation *LocB) {
> +    return nullptr;
> +  }
>

Thanks for this API (even if it's only as stub for now).
I think this can be used to fix the problem Adam reported in
https://llvm.org/bugs/show_bug.cgi?id=31310 (see Wolfgang's comment),
but in order to merge DILocation for phi nodes we may need a variant
that takes two or more arguments (and merges the debug loc iff all the
arguments agree). What do you think about it?

-- 
Davide

"There are no solved problems; there are only problems that are more
or less solved" -- Henri Poincare


More information about the llvm-commits mailing list