DebugLocLists with no entries: any idea how to generate a testcase?

Duncan P. N. Exon Smith dexonsmith at apple.com
Fri May 29 11:15:37 PDT 2015


> On 2015-May-27, at 17:55, David Blaikie <dblaikie at gmail.com> wrote:
> 
> Can't say I know of any particular situations that cause this (I guess it's trickier than just a variable that's optimized away entirely) - I'd just start reducing an existing test case (probably add the assertion and try a non-LTO build, hope that it reproduces there, then just creduce any specific file where it reproduces)
> 
> On Wed, May 27, 2015 at 5:51 PM, Duncan P. N. Exon Smith <dexonsmith at apple.com> wrote:
> I've noticed there are debug loc lists with no entries sometimes
> in my heap profiling workload (a linker dump of `-flto -g`).  It
> seems to happen when *all* the locations correspond to `%noreg`.
> 
> This patch adds an assertion (which fires on my big workload,
> but not in any of our tests), and adds a likely fix that's
> commented out.
> 
> Does anyone know how to generate this kind of thing, or should I
> just start compiling things to see if I can make it happen on my
> own?  (I've tried reducing my workload, but I'm having trouble
> getting very far with it.)
> 
> 

Ran a bootstrap with my assertion:
--
$ git diff HEAD^..
diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index e891ab9..9b6bef4 100644
--- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -916,6 +916,7 @@ void DwarfDebug::collectVariableInfo(DwarfCompileUnit &TheCU,
     // Build the location list for this variable.
     SmallVector<DebugLocEntry, 8> Entries;
     buildLocationList(Entries, Ranges);
+    assert(!Entries.empty() && "Found the testcase");
 
     // If the variable has an DIBasicType, extract it.  Basic types cannot have
     // unique identifiers, so don't bother resolving the type with the
--

And eventually reduced this testcase:
--
$ cat t.cpp
int a, b;
bool test();
bool testp(void *);
void sink(void *);
void run(bool (*&)());
void foo(void *, void *p2, void *p3) {
  sink(p2);
  sink(p3);
  bool (*c)() = test;
  int d = b;
  sink(&a);
  if (d)
    run(c);
}
void loop(void *p1, void *p2, void *p3) {
  while (testp(p1))
    foo(p1, p2, p3);
}
$ clang -cc1 -triple x86_64-apple-macosx -emit-obj -mdisable-fp-elim -gdwarf-2 -O2 -x c++ t.cpp
Assertion failed: (!Entries.empty() && "Found the testcase"), function collectVariableInfo, file /Volumes/Data/llvm/bootstrap/lib/CodeGen/AsmPrinter/DwarfDebug.cpp, line 919.
Illegal instruction: 4
--

This is fairly complicated, so I think as Adrian suggested this
likely depends on register pressure or something.

I'll dig a bit deeper to see if I can deal with the other ways of
getting an empty list (or empty entries in a list) that Adrian
pointed out.



More information about the llvm-commits mailing list