<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 - Missing optimization for member function with const attribute"
   href="https://bugs.llvm.org/show_bug.cgi?id=50735">50735</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Missing optimization for member function with const attribute
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>12.0
          </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>Backend: C
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>zhongyunde@tom.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>refer to <a href="https://developer.arm.com/documentation/dui0491/c/Cacgigch">https://developer.arm.com/documentation/dui0491/c/Cacgigch</a>, if we
defined the following function Function_Attributes_const_0 with __attribute__
((const)),  code Function_Attributes_const_0 might be called once only, with
the result being doubled to obtain the correct return value.

int Function_Attributes_const_0(int b) __attribute__ ((const));

int test (int b)
{
    int aLocal=0;
    aLocal += Function_Attributes_const_0(b);
    aLocal += Function_Attributes_const_0(b);
    return aLocal;
}

while we change the function into member function as following, then code
Function_Attributes_const_0 might be called twice, so it seems missing
optimization for member function.

class foo {
public:
  int Function_Attributes_const_0(int b) const;
};

int test (int b)
{
    int aLocal=1;
    class foo fuc;
    aLocal += fuc.Function_Attributes_const_0(b);
    aLocal += fuc.Function_Attributes_const_0(b);
    return aLocal;
}</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>