Skip to content

Commit

Permalink
[unittest][codegen] Avoid memory leak in recently added FindDebugLocT…
Browse files Browse the repository at this point in the history
…est unittest

Need to finalize the DIBuilder to avoid leak sanitizer errors
like this:

Direct leak of 48 byte(s) in 1 object(s) allocated from:
    #0 0x55c99ea1761d in operator new(unsigned long)
    #1 0x55c9a518ae49 in operator new
    #2 0x55c9a518ae49 in llvm::MDTuple::getImpl(...)
    #3 0x55c9a4f1b1ec in getTemporary
    llvm#4 0x55c9a4f1b1ec in llvm::DIBuilder::createFunction(...)
  • Loading branch information
bjope committed May 25, 2023
1 parent 1826fad commit 28d418b
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions llvm/unittests/CodeGen/MachineBasicBlockTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ TEST(FindDebugLocTest, DifferentIterators) {
EXPECT_EQ(DL1, MBB.rfindPrevDebugLoc(MI2));
EXPECT_EQ(DL1, MBB.rfindPrevDebugLoc(MI3));
EXPECT_EQ(DL1, MBB.rfindPrevDebugLoc(MBB.instr_rbegin()));

// Finalize DIBuilder to avoid memory leaks.
DIB.finalize();
}

} // end namespace

0 comments on commit 28d418b

Please sign in to comment.