https://bugs.llvm.org/show_bug.cgi?id=48095

            Bug ID: 48095
           Summary: Stack memory object managed by a unique_ptr in
                    GCNIterativeScheduler::OverrideLegacyStrategy
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: AMDGPU
          Assignee: unassignedb...@nondot.org
          Reporter: alansnape3...@gmail.com
                CC: llvm-bugs@lists.llvm.org

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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to