[all-commits] [llvm/llvm-project] 7de6f6: [SPIR-V] Memory leak fix in SPIRVEmitIntrinsics (#...

bwlodarcz via All-commits all-commits at lists.llvm.org
Tue Mar 5 12:57:23 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 7de6f61a9da3b73a729413a41477d400d9f08b84
      https://github.com/llvm/llvm-project/commit/7de6f61a9da3b73a729413a41477d400d9f08b84
  Author: bwlodarcz <bertrand.wlodarczyk at intel.com>
  Date:   2024-03-05 (Tue, 05 Mar 2024)

  Changed paths:
    M llvm/lib/Target/SPIRV/SPIRVEmitIntrinsics.cpp

  Log Message:
  -----------
  [SPIR-V] Memory leak fix in SPIRVEmitIntrinsics (#83015)

The architecture of SPIRVEmitIntrinsics is build in such way that every
private method is called by one main function runOnFunction which then
calls private methods. Private member IRB is allocated in runOnFunction
method but it's not freed. Due to that every time when IR function
contains intrinsics to emit, runOnFunction is entered and memory is
leaked on exit. It's especially true when there are two or more IR
functions to emit. IRB is set to nullptr during construction of object
and it's left without pointing resource until runOnFunction is entered.
This also create possibility of simple mistake when private method is
called but there is no resource pointed. Change requires passing
IRBuilder by reference to private methods. The visit* functions create
it's own IRBuilder thus IRB is eliminated from class scope. In addition
there is a small performance improvement because IRBuilder is not
allocated by heap.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list