<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 - Fragment variable size verification fails during LTO in presence of ODR violations"
   href="https://bugs.llvm.org/show_bug.cgi?id=38608">38608</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Fragment variable size verification fails during LTO in presence of ODR violations
          </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>Windows NT
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>DebugInfo
          </td>
        </tr>

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

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

        <tr>
          <th>CC</th>
          <td>bjorn.a.pettersson@ericsson.com, llvm-bugs@lists.llvm.org, llvm@inglorion.net, peter@pcc.me.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Our Chromium ThinLTO bot has been red longer than we have history for it, and I
think it was caused by r334830 from June.

During LTO, our bot is now producing this error:
fragment is larger than or outside of variable
  call void @llvm.dbg.value(metadata i8 %9, metadata !2265359, metadata
!DIExpression(DW_OP_LLVM_fragment, 96, 8)), !dbg !2265363
!2265359 = !DILocalVariable(name: "p", scope: !2265356, f

Here is a reduction of the problem:

// a.cpp
struct ViolateODR {
  int x;
};
int use_small_struct(ViolateODR o) {
  return o.x;
}
int do_sroa(int x, int y);
int main() {
  ViolateODR o = {0};
  return use_small_struct(o) + do_sroa(1, 2);
}

// b.cpp
struct ViolateODR {
  int x;
};
int use_small_struct(ViolateODR o) {
  return o.x;
}
int do_sroa(int x, int y);
int main() {
  ViolateODR o = {0};
  return use_small_struct(o) + do_sroa(1, 2);
}

// script
$ clang-cl -Z7 -flto=thin -c a.cpp b.cpp -O2 && lld-link a.obj b.obj -out:t.exe
fragment covers entire variable
  call void @llvm.dbg.value(metadata i32 %3, metadata !17, metadata
!DIExpression(DW_OP_LLVM_fragment, 0, 32)), !dbg !24
!17 = !DILocalVariable(name: "o", scope: !10, file: !1, line: 6, type: !18)

OK, so maybe I got a.cpp and b.cpp swapped, but you see the point. I don't
think verifier errors during LTO are a reasonable failure mode for ODR
violations.

I would prefer it if instead dbg.value problems could be reported as warnings
and we could locally discard the problematic dbg.value instructions.</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>