<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </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 - Partial inliner doesn't set up correct debug info which causes LTO to fail"
   href="https://bugs.llvm.org/show_bug.cgi?id=35288">35288</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Partial inliner doesn't set up correct debug info which causes LTO to fail
          </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>All
          </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>Interprocedural Optimizations
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>eastig@yandex.ru
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The partial inliner does not set up debug info for instructions it has inlined.
During LTO a decision is made to inline a function the partial inliner created.
LTO has Verifier enabled. Verifier finds the resulted code does not have
correct debug info. This cause LTO to fail.

Reproducer:

$ cat test.c
int a02(int);

int a01(int v) {
  v = v * 100;
  return a02(v);
}

int a02(int v) {
  if (v > 2000)
    v *= 10;
  v += 200;
  return v;
}

$ clang -c -O3 -mthumb --target=arm-arm-none-eabi -mcpu=cortex-m7 test.c -g  -S
-emit-llvm -mllvm -disable-llvm-optzns

$ opt  -S -o test.pi.ll  -partial-inliner test.ll
-skip-partial-inlining-cost-analysis=true

$ opt  -S -o test.i.ll -inline test.pi.ll
!dbg attachment points at wrong subprogram for function
!8 = distinct !DISubprogram(name: "a01", scope: !1, file: !1, line: 3, type:
!9, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped,
isOptimized: true, unit: !0, variables: !12)
i32 (i32)* @a01
  %4 = load i32, i32* %v.addr.i, align 4, !dbg !32, !tbaa !19
!32 = !DILocation(line: 10, column: 7, scope: !29)
!29 = distinct !DILexicalBlock(scope: !15, file: !1, line: 9, column: 7)
!15 = distinct !DISubprogram(name: "a02", scope: !1, file: !1, line: 8, type:
!9, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped,
isOptimized: true, unit: !0, variables: !16)
LLVM ERROR: Broken module found, compilation aborted!

---------
'test.c', 'test.ll' and 'test.pi.ll' are attached.</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>