[MC] Fix memory leak when allocating MCInst with bump allocator
authorhgreving <hgreving@hendrik-laptop.lan>
Wed, 29 Jul 2020 23:48:03 +0000 (16:48 -0700)
committerhgreving <hgreving@hendrik-laptop.lan>
Mon, 3 Aug 2020 23:08:26 +0000 (16:08 -0700)
commit509f5c4ec2dbae99713ac6292c3a6bd7ba50027c
treea0044422752d700983592d53adef15e5e9409d05
parent045e79e77c252f2c73c640e820e977ef52836d50
[MC] Fix memory leak when allocating MCInst with bump allocator

Adds the function createMCInst() to MCContext that creates a MCInst using
a typed bump alloctor.

MCInst contains a SmallVector<MCOperand, 8>. The SmallVector is POD only
for <= 8 operands. The default untyped bump pointer allocator of MCContext
does not delete the MCInst, so if the SmallVector grows, it's a leak.

This fixes https://bugs.llvm.org/show_bug.cgi?id=46900.
llvm/include/llvm/MC/MCContext.h
llvm/lib/MC/MCContext.cpp
llvm/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp
llvm/lib/Target/Hexagon/Disassembler/HexagonDisassembler.cpp
llvm/lib/Target/Hexagon/HexagonMCInstLower.cpp
llvm/lib/Target/Hexagon/MCTargetDesc/HexagonAsmBackend.cpp
llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCCompound.cpp