CodeGen: Assert that inlined-at locations agree

As a follow-up to r234021, assert that a debug info intrinsic variable's
`MDLocalVariable::getInlinedAt()` always matches the
`MDLocation::getInlinedAt()` of its `!dbg` attachment.

The goal here is to get rid of `MDLocalVariable::getInlinedAt()`
entirely (PR22778), but I'll let these assertions bake for a while
first.

If you have an out-of-tree backend that just broke, you're probably
attaching the wrong `DebugLoc` to a `DBG_VALUE` instruction.  The one
you want is the location that was attached to the corresponding
`@llvm.dbg.declare` or `@llvm.dbg.value` call that you started with.

llvm-svn: 234038
diff --git a/llvm/include/llvm/IR/DebugInfoMetadata.h b/llvm/include/llvm/IR/DebugInfoMetadata.h
index f25358c..5875910 100644
--- a/llvm/include/llvm/IR/DebugInfoMetadata.h
+++ b/llvm/include/llvm/IR/DebugInfoMetadata.h
@@ -1587,6 +1587,14 @@
 
   Metadata *getRawInlinedAt() const { return getOperand(4); }
 
+  /// \brief Check that a location is valid for this variable.
+  ///
+  /// Check that \c DL has the same inlined-at location as this variable,
+  /// making them valid for the same \a DbgInfoIntrinsic.
+  bool isValidLocationForIntrinsic(const MDLocation *DL) const {
+    return getInlinedAt() == (DL ? DL->getInlinedAt() : nullptr);
+  }
+
   /// \brief Get an inlined version of this variable.
   ///
   /// Returns a version of this with \a getAlinedAt() set to \c InlinedAt.