<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW " title="NEW --- - Inliner sometimes produces invalid debug info" href="https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_bugs_show-5Fbug.cgi-3Fid-3D23874&d=AwMBaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=T_dMTdQ7HFf_dt7Qho5OvYuq5axhO_vyvx8M76KKs40&s=NkmmNGW0q_-ACW9j6BIeGP70S-L7PoDQPBCxIP6wKvU&e=">23874</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Inliner sometimes produces invalid debug info
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Transformation Utilities
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>dschuff@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>I have an IR file with an approximate structure as follows. It has an inner and
outer function with debug info and a middle function without debug info.
The inner is inlined into the middle, and then the middle is inlined into the
outer. After inlining when the module verifier visits the DISubprogram for the
middle function, it checks the first instruction in middle (which originally
came from inner), gets the inlinedAtScope, finds that it points to inner, and
fails verification.

; Function Attrs: nounwind uwtable
define void @inner() #0 {
entry:
  <some random instruction> !dbg !13
  ret void, !dbg !14
}

; Function Attrs: nounwind uwtable
define void @middle() #0 {
entry:
  call void @inner()
  ret void
}

; Function Attrs: nounwind uwtable
define void @outer() #0 {
entry:
  call void @middle(), !dbg !21
  ret void, !dbg !18
}

I'm trying to figure out what the cause is; I tried building a simple
reproducer from scratch similar to the above, but I can't reproduce it.
I have attached a reproducer which is reduced by bugpoint; bugpoint did a
pretty good job reducing the code but did nothing to the debug info, which is
still huge, so I'm looking for some suggestions for making that smaller. I
tried removing the !llvm.dbg.cu from the module; this had mostly the effect I
was looking for, in causing most of the metadata to go away, but it also caused
the problem to no longer reproduce.

Any suggestions?




notes on the reproducer:
In the attached file, inner is
_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEaSERKS5_,
middle is
_ZNSt3__115basic_stringbufIcNS_11char_traitsIcEENS_9allocatorIcEEE3strERKNS_12basic_stringIcS2_S4_EE, 
and outer is
_ZN7testing7MessageC2Ev

To reproduce just run opt -inline bugpoint-reduced-simplified.bc
The actual error is
!dbg attachment points at wrong subprogram for function
!22062 = !DISubprogram(name: "str", linkageName:
"_ZNSt3__115basic_stringbufIcNS_11char_traitsIcEENS_9allocatorIcEEE3strERKNS_12basic_stringIcS2_S4_EE",
scope:
!"_ZTSNSt3__115basic_stringbufIcNS_11char_traitsIcEENS_9allocatorIcEEEE", file:
!519, line: 453, type: !15385, isLocal: false, isDefinition: true, scopeLine:
454, flags: DIFlagPrototyped, isOptimized: true, function: void
(%"class.std::__1::basic_stringbuf.130.422.2573.3290.4485.5202.6875.8070.8787.10460.10699.10938.11416.12372.17258"*,
%"class.std::__1::basic_string.5.297.2448.3165.4360.5077.6750.7945.8662.10335.10574.10813.11291.12247.17254"*)*
@_ZNSt3__115basic_stringbufIcNS_11char_traitsIcEENS_9allocatorIcEEE3strERKNS_12basic_stringIcS2_S4_EE,
declaration: !15384, variables: !22063)
void
(%"class.std::__1::basic_stringbuf.130.422.2573.3290.4485.5202.6875.8070.8787.10460.10699.10938.11416.12372.17258"*,
%"class.std::__1::basic_string.5.297.2448.3165.4360.5077.6750.7945.8662.10335.10574.10813.11291.12247.17254"*)*
@_ZNSt3__115basic_stringbufIcNS_11char_traitsIcEENS_9allocatorIcEEE3strERKNS_12basic_stringIcS2_S4_EE
  %cmp.i = icmp eq
%"class.std::__1::basic_string.5.297.2448.3165.4360.5077.6750.7945.8662.10335.10574.10813.11291.12247.17254"*
%__str_, %__s, !dbg !91052
!91057 = !DILocation(line: 2411, column: 14, scope: !91058)
!91058 = distinct !DILexicalBlock(scope: !59819, file: !32233, line: 2411,
column: 9)
!59819 = !DISubprogram(name: "operator=", linkageName:
"_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEaSERKS5_",
scope: !"_ZTSNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE",
file: !32233, line: 2409, type: !53554, isLocal: false, isDefinition: true,
scopeLine: 2410, flags: DIFlagPrototyped, isOptimized: true, function: void
(%"class.std::__1::basic_string.5.297.2448.3165.4360.5077.6750.7945.8662.10335.10574.10813.11291.12247.17254"*,
%"class.std::__1::basic_string.5.297.2448.3165.4360.5077.6750.7945.8662.10335.10574.10813.11291.12247.17254"*)*
@_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEaSERKS5_,
declaration: !58684, variables: !59820)
LLVM ERROR: Broken module found, compilation aborted!</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>