Skip to content

Commit

Permalink
Merging r332176:
Browse files Browse the repository at this point in the history
------------------------------------------------------------------------
r332176 | dim | 2018-05-12 12:59:54 -0700 (Sat, 12 May 2018) | 20 lines

Clear converters map after X86 Domain Reassignment to avoid crashes

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: 332263
  • Loading branch information
tstellar committed May 14, 2018
1 parent 4030e57 commit d68404a
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 d68404a

Please sign in to comment.