<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 - Stack memory object managed by a unique_ptr in GCNIterativeScheduler::OverrideLegacyStrategy"
   href="https://bugs.llvm.org/show_bug.cgi?id=48095">48095</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Stack memory object managed by a unique_ptr in GCNIterativeScheduler::OverrideLegacyStrategy
          </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>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>Backend: AMDGPU
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>alansnape3058@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>In function GCNIterativeScheduler::scheduleLegacyMaxOccupancy of file
llvm/lib/Target/AMDGPU/GCNIterativeScheduler.cpp on line 492, a "stack memory
object managed by a unique_ptr" is reported by my clang static analyzer fork.

A local variable of GCNMaxOccupancySchedStrategy is created on line 512, then
its address is managed by a unique_ptr through the call to the constructor of
OverrideLegacyStrategy on line 520 and the call to unique_ptr::reset on line
193. Although the managed local address is released from the unique_ptr on line
202 in the destructor of OverrideLegacyStrategy, it would be better to replace
the local variable with a heap memory object, as smart pointers without
customized deleters are not originally designed for non-heap memory objects.

---

The reported execution path:

In function GCNIterativeScheduler::scheduleLegacyMaxOccupancy

512   GCNMaxOccupancySchedStrategy LStrgy(Context);
--> Local variable 'LStrgy' is defined.

520       OverrideLegacyStrategy Ovr(*R, LStrgy, *this);
--> Local address of variable 'LStrgy' is taken as a reference when calling the
constructor of OverrideLegacyStrategy.

In function
GCNIterativeScheduler::OverrideLegacyStrategy::OverrideLegacyStrategy

193     Sch.SchedImpl.reset(&OverrideStrategy);
--> Assign the address of the local variable 'LStrgy' to a unique_ptr.

---

Suggested fix:

Replace the local variable on line 512 with a unique_ptr or a new-ed memory
object.</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>