<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 - "Deduce function attributes" calculates different attributes if dbg.value is present. -g affects generated code"
   href="https://bugs.llvm.org/show_bug.cgi?id=34696">34696</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>"Deduce function attributes" calculates different attributes if dbg.value is present. -g affects generated code
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </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>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>new bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>mikael.holmen@ericsson.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=19183" name="attach_19183" title="reproducer">attachment 19183</a> <a href="attachment.cgi?id=19183&action=edit" title="reproducer">[details]</a></span>
reproducer

opt -disable-basicaa -S -globals-aa -functionattrs -o - attrs.ll

gives

; Function Attrs: nounwind
define void @f1() #0 {

and

; Function Attrs: nounwind readnone
define void @f0() #1 {

with

attributes #0 = { nounwind }
attributes #1 = { nounwind readnone }

However, if we remove the call to dbg.value in f0 we instead get

; Function Attrs: norecurse nounwind readnone
define void @f1() #0 {

and

; Function Attrs: norecurse nounwind readnone
define void @f0() #0 {

with

attributes #0 = { norecurse nounwind readnone }

so the call to dbg.value in f0 makes -functionattrs deduce different attributes 
on both f1 and f2.

If we then run e.g. -early-cse on the output, we will get different code
because
the call to f0 in f1 will or will not be removed depending on the function
attributes, so code generation is different depending on if we have compiled
with -g or not which is quite unfortunate.</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>