<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 - llvm-diff produces non-empty diff in the same code for static variables referencing"
   href="https://bugs.llvm.org/show_bug.cgi?id=48137">48137</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>llvm-diff produces non-empty diff in the same code for static variables referencing
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </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>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>khitrin@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=24143" name="attach_24143" title="full clang-produced IR file">attachment 24143</a> <a href="attachment.cgi?id=24143&action=edit" title="full clang-produced IR file">[details]</a></span>
full clang-produced IR file

Looks like a follow-up for <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED FIXED - llvm-diff finds differences in the same code"
   href="show_bug.cgi?id=33623">bug 33623</a>.

$ cat a.cpp 
struct S {
};

// removing static eliminates the bug
static S s;

void* func() {
    return &s;
}

$ clang a.cpp -S -emit-llvm
$ llvm-diff a.ll a.ll 
in function _Z4funcv:
  in block %0 / %0:
    >   ret i8* getelementptr inbounds (%struct.S.0, %struct.S.0* @_ZL1s, i32
0, i32 0)
    <   ret i8* getelementptr inbounds (%struct.S, %struct.S* @_ZL1s, i32 0,
i32 0)

$ llvm-diff -version
LLVM (<a href="http://llvm.org/">http://llvm.org/</a>):
  LLVM version 11.0.0
  Optimized build.
  Default target: x86_64-apple-darwin18.7.0
  Host CPU: haswell


Reduced testcase with the same llvm-diff output:

$ cat a_reduced.ll 
%struct.S = type { i8 }

@_ZL1s = internal global %struct.S zeroinitializer, align 1

define i8* @_Z4funcv() {
  ret i8* getelementptr inbounds (%struct.S, %struct.S* @_ZL1s, i32 0, i32 0)
}


Also reproducible on llvm-12 development build for Debian</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>