Fix a bug that prevents global variables from having a DW_OP_deref.

For local variables the first DW_OP_deref is consumed by turning the
location kind into a memeory location, but that only makes sense for
values that are in a register to begin with, which cannot happen for
global variables that are attached to a symbol.

rdar://problem/39741860

This reapplies r330970 after fixing an uncovered bug in r331086 and
working around the situation caused by it.

llvm-svn: 331090
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h b/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h
index ea5cbc4..7d6d45e 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h
@@ -211,6 +211,8 @@
   /// Emit an unsigned constant.
   void addUnsignedConstant(const APInt &Value);
 
+  bool isMemoryLocation() const { return LocationKind == Memory; }
+
   /// Lock this down to become a memory location description.
   void setMemoryLocationKind() {
     assert(LocationKind == Unknown);