Skip to content

Commit

Permalink
Clear converters map after X86 Domain Reassignment to avoid crashes
Browse files Browse the repository at this point in the history
Summary:
As reported in PR37264, in some cases the X86 Domain Reassignment
`runOnMachineFunction()` is called twice.  Because it only deletes the
`.second` members of its `InstrConverterBaseMap`, and does not clean up
the map itself, this can lead to double frees and crashes.

Use `DeleteContainerSeconds()` instead, so the `Converters` map can
safely be reinitialized and its members re-deleted for each X86 Domain
Reassignment pass.

Reviewers: guyblank, craig.topper

Reviewed By: craig.topper

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D46425

llvm-svn: 332176
  • Loading branch information
DimitryAndric committed May 12, 2018
1 parent 6a68f38 commit 74f2989
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions llvm/lib/Target/X86/X86DomainReassignment.cpp
Expand Up @@ -750,8 +750,7 @@ bool X86DomainReassignment::runOnMachineFunction(MachineFunction &MF) {
Changed = true;
}

for (auto I : Converters)
delete I.second;
DeleteContainerSeconds(Converters);

DEBUG(dbgs() << "***** Machine Function after Domain Reassignment *****\n");
DEBUG(MF.print(dbgs()));
Expand Down

0 comments on commit 74f2989

Please sign in to comment.