Skip to content

Commit

Permalink
[MIR] Fix vreg flag vector memory leak (#112479)
Browse files Browse the repository at this point in the history
A fix-it patch for dbfca24 #110228.

No need for a container. This allows 8 flags for a register.

The virtual register flags vector had a memory leak because the vector's
memory is not freed.
The `BumpPtrAllocator` handles the deallocation and missed calling the
`std::vector<uint8_t> Flags` destructor.
  • Loading branch information
optimisan authored Oct 16, 2024
1 parent 1d40fef commit b5cc222
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion llvm/include/llvm/CodeGen/MIRParser/MIParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ struct VRegInfo {
} D;
Register VReg;
Register PreferredReg;
std::vector<uint8_t> Flags;
uint8_t Flags = 0;
};

using Name2RegClassMap = StringMap<const TargetRegisterClass *>;
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/MIRParser/MIRParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ bool MIRParserImpl::parseRegisterInfo(PerFunctionMIParsingState &PFS,
return error(FlagStringValue.SourceRange.Start,
Twine("use of undefined register flag '") +
FlagStringValue.Value + "'");
Info.Flags.push_back(FlagValue);
Info.Flags |= FlagValue;
}
RegInfo.noteNewVirtualRegister(Info.VReg);
}
Expand Down

0 comments on commit b5cc222

Please sign in to comment.