<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 --- - Compiler generating an unnecessary volatile load" href="https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_bugs_show-5Fbug.cgi-3Fid-3D24325&d=AwMBaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=AE8E1C5m7rc0I6e3GfRJNEDWZEnDjk35sRsMOI23SPM&s=7oF2O1pN8Q6aP6w9Zzi-ZlPAPVQY6avBVIwPOBFJZKk&e=">24325</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Compiler generating an unnecessary volatile load
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </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>LLVM Codegen
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>douglas_yung@playstation.sony.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>This bug was found when trying to modify the clang lit test
CodeGenCXX\volatile.cpp to work when the compiler is in c++11 mode.

The repro is as follows:

volatile int *x;

void test() {
  *x;
}

If you compile the code with trunk (I am using r242449) and give the option "-S
-emit-llvm", you get the following:

@x = global i32* null, align 8

; Function Attrs: nounwind uwtable
define void @_Z4testv() #0 {
entry:
  %0 = load i32*, i32** @x, align 8
  ret void
}

However if you also add the switch "-std=c++11", the code generated is the
following:

@x = global i32* null, align 8

; Function Attrs: nounwind uwtable
define void @_Z4testv() #0 {
entry:
  %0 = load i32*, i32** @x, align 8
  %1 = load volatile i32, i32* %0, align 4
  ret void
}

Note that there is an extra load volatile that is generated in this case.</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>