Debug information causing assertion

We have a test case where we are hitting an assertion in the X86 code generator. The assertion is: “Assertion failed: TheCU && “Unable to find compile unit!”, file …\lib\CodeGen\AsmPrinter\DwarfDebug.cpp, line 1411”

The bitcode is attached.

What I am trying to figure out is what is malformed about our debug that is causing this error? This is reproducible with ‘llc -march=x86 bugpoint-reduced-simplified.bc’.

As far as I can tell, the variable ‘TheCU’ should map to the metadata node !24.

Is this a bug?

Thanks,

Micah

bugpoint-reduced-simplified.bc (1.9 KB)

Somewhere yes. I debugged it for a couple of minutes and you're getting the same scope node with two different addresses:

Addr: 0x102a07cf0
!{i32 786478, i32 0, metadata <badref>, metadata !"__OpenCL_CopyBuffer_kernel", metadata !"__OpenCL_CopyBuffer_kernel", metadata !"__OpenCL_CopyBuffer_kernel", metadata <badref>, i32 5, metadata <badref>, i1 false, i1 true, i32 0, i32 0, null, i32 0, i1 false, null, null, null, metadata <badref>, i32 0} ; [ DW_TAG_subprogram ] [line 5] [def] [scope 0] [__OpenCL_CopyBuffer_kernel]

Addr: 0x102a09f20
!{i32 786478, i32 0, metadata <badref>, metadata !"access_foo", metadata !"access_foo", metadata !"access_foo", metadata <badref>, i32 2, metadata <badref>, i1 false, i1 true, i32 0, i32 0, null, i32 0, i1 false, null, null, null, metadata <badref>, i32 0} ; [ DW_TAG_subprogram ] [line 2] [def] [scope 0] [access_foo]

The Lookup:
!{i32 786478, i32 0, metadata <badref>, metadata !"access_foo", metadata !"access_foo", metadata !"access_foo", metadata <badref>, i32 2, metadata <badref>, i1 false, i1 true, i32 0, i32 0, null, i32 0, i1 false, null, null, null, metadata <badref>, i32 0} ; [ DW_TAG_subprogram ] [line 2] [def] [scope 0] [access_foo]

(lldb) expr FnScope->getScopeNode()
(const llvm::MDNode *) $38 = 0x0000000102a0b430

I couldn't spot anything gratuitously wrong off the top of my head. I know that merging debug info from two modules has some problems but nothing in particular at this point is jumping out.

-eric