1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 20:51:52 +01:00

[Hexagon] Allocate MCInst in the MCContext to avoid leaking it.

Found by leaksanitizer.

llvm-svn: 252931
This commit is contained in:
Benjamin Kramer 2015-11-12 19:30:40 +00:00
parent 4dd6659eb0
commit 6e646c8655
3 changed files with 11 additions and 8 deletions

View File

@ -871,7 +871,7 @@ bool HexagonAsmParser::MatchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode,
MatchingInlineAsm, MustExtend))
return true;
HexagonMCInstrInfo::extendIfNeeded(
MCII, MCB, *SubInst,
getParser().getContext(), MCII, MCB, *SubInst,
HexagonMCInstrInfo::isExtended(MCII, *SubInst) || MustExtend);
MCB.addOperand(MCOperand::createInst(SubInst));
if (!InBrackets)

View File

@ -28,7 +28,8 @@ void HexagonMCInstrInfo::addConstant(MCInst &MI, uint64_t Value,
MI.addOperand(MCOperand::createExpr(MCConstantExpr::create(Value, Context)));
}
void HexagonMCInstrInfo::addConstExtender(MCInstrInfo const &MCII, MCInst &MCB,
void HexagonMCInstrInfo::addConstExtender(MCContext &Context,
MCInstrInfo const &MCII, MCInst &MCB,
MCInst const &MCI) {
assert(HexagonMCInstrInfo::isBundle(MCB));
MCOperand const &exOp =
@ -36,7 +37,7 @@ void HexagonMCInstrInfo::addConstExtender(MCInstrInfo const &MCII, MCInst &MCB,
// Create the extender.
MCInst *XMCI =
new MCInst(HexagonMCInstrInfo::deriveExtender(MCII, MCI, exOp));
new (Context) MCInst(HexagonMCInstrInfo::deriveExtender(MCII, MCI, exOp));
MCB.addOperand(MCOperand::createInst(XMCI));
}
@ -150,10 +151,11 @@ MCInst const *HexagonMCInstrInfo::extenderForIndex(MCInst const &MCB,
return nullptr;
}
void HexagonMCInstrInfo::extendIfNeeded(MCInstrInfo const &MCII, MCInst &MCB,
void HexagonMCInstrInfo::extendIfNeeded(MCContext &Context,
MCInstrInfo const &MCII, MCInst &MCB,
MCInst const &MCI, bool MustExtend) {
if (isConstExtended(MCII, MCI) || MustExtend)
addConstExtender(MCII, MCB, MCI);
addConstExtender(Context, MCII, MCB, MCI);
}
HexagonII::MemAccessSize

View File

@ -53,7 +53,8 @@ int64_t const memStoreReorderEnabledMask = 1 << memStoreReorderEnabledOffset;
size_t const bundleInstructionsOffset = 1;
void addConstant(MCInst &MI, uint64_t Value, MCContext &Context);
void addConstExtender(MCInstrInfo const &MCII, MCInst &MCB, MCInst const &MCI);
void addConstExtender(MCContext &Context, MCInstrInfo const &MCII, MCInst &MCB,
MCInst const &MCI);
// Returns a iterator range of instructions in this bundle
iterator_range<MCInst::const_iterator> bundleInstructions(MCInst const &MCI);
@ -71,8 +72,8 @@ void clampExtended(MCInstrInfo const &MCII, MCContext &Context, MCInst &MCI);
// Return the extender for instruction at Index or nullptr if none
MCInst const *extenderForIndex(MCInst const &MCB, size_t Index);
void extendIfNeeded(MCInstrInfo const &MCII, MCInst &MCB, MCInst const &MCI,
bool MustExtend);
void extendIfNeeded(MCContext &Context, MCInstrInfo const &MCII, MCInst &MCB,
MCInst const &MCI, bool MustExtend);
// Create a duplex instruction given the two subinsts
MCInst *deriveDuplex(MCContext &Context, unsigned iClass, MCInst const &inst0,