Improve the accuracy of variable ranges .debug_loc location lists.

For the following motivating example
  bool c();
  void f();
  bool start() {
    bool result = c();
    if (!c()) {
      result = false;
      goto exit;
    }
    f();
    result = true;
  exit:
    return result;
  }

we would previously generate a single DW_AT_const_value(1) because
only the DBG_VALUE in the second-to-last basic block survived
codegen. This patch improves the heuristic used to determine when a
DBG_VALUE is available at the beginning of its variable's enclosing
lexical scope:

- Stop giving singular constants blanket permission to take over the
  entire scope. There is still a special case for constants in the
  function prologue that we also miight want to retire later.

- Use the lexical scope information to determine available-at-entry
  instead of proximity to the function prologue.

After this patch we generate a location list with a more accurate
narrower availability for the constant true value. As a pleasant side
effect, we also generate inline locations instead of location lists
where a loacation covers the entire range of the enclosing lexical
scope.

Measured on compiling llc with four targets this doesn't have an
effect on compile time and reduces the size of the debug info for llc
by ~600K.

rdar://problem/30286912

llvm-svn: 305599
diff --git a/llvm/test/DebugInfo/Generic/sugared-constants.ll b/llvm/test/DebugInfo/Generic/sugared-constants.ll
index 2bee2a9..97d4d60 100644
--- a/llvm/test/DebugInfo/Generic/sugared-constants.ll
+++ b/llvm/test/DebugInfo/Generic/sugared-constants.ll
@@ -3,47 +3,23 @@
 ; RUN: %llc_dwarf -O0 -filetype=obj %s -o - | llvm-dwarfdump -debug-dump=info - | FileCheck %s
 ; Use correct signedness when emitting constants of derived (sugared) types.
 
-; Test compiled to IR from clang with -O1 and the following source:
-
-; void func(int);
-; void func(unsigned);
-; void func(char16_t);
-; int main() {
-;   const int i = 42;
-;   func(i);
-;   const unsigned j = 117;
-;   func(j);
-;   char16_t c = 7;
-;   func(c);
-; }
-
 ; CHECK: DW_AT_const_value [DW_FORM_sdata] (42)
 ; CHECK: DW_AT_const_value [DW_FORM_udata] (117)
 ; CHECK: DW_AT_const_value [DW_FORM_udata] (7)
 
 ; Function Attrs: uwtable
-define i32 @main() #0 !dbg !4 {
+define void @main() #0 !dbg !4 {
 entry:
   tail call void @llvm.dbg.value(metadata i32 42, i64 0, metadata !10, metadata !DIExpression()), !dbg !21
-  tail call void @_Z4funci(i32 42), !dbg !22
   tail call void @llvm.dbg.value(metadata i32 117, i64 0, metadata !12, metadata !DIExpression()), !dbg !24
-  tail call void @_Z4funcj(i32 117), !dbg !25
   tail call void @llvm.dbg.value(metadata i16 7, i64 0, metadata !15, metadata !DIExpression()), !dbg !27
-  tail call void @_Z4funcDs(i16 zeroext 7), !dbg !28
-  ret i32 0, !dbg !29
+  ret void, !dbg !29
 }
 
-declare void @_Z4funci(i32) #1
-
-declare void @_Z4funcj(i32) #1
-
-declare void @_Z4funcDs(i16 zeroext) #1
-
 ; Function Attrs: nounwind readnone
 declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #2
 
-attributes #0 = { uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
-attributes #1 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
+attributes #0 = { uwtable }
 attributes #2 = { nounwind readnone }
 
 !llvm.dbg.cu = !{!0}