From 381188f1f39ea8980c23aecb3a0695425aaa99cc Mon Sep 17 00:00:00 2001 From: Amara Emerson Date: Wed, 27 Mar 2019 17:47:42 +0000 Subject: [GlobalISel] Fix legalizer artifact combiner from crashing with invalid dead instructions. The artifact combiners push instructions which have been marked for deletion onto an list for the legalizer to deal with on return. However, for trunc(ext) combines the combiner routine recursively calls itself. When it does this the dead instructions list may not be empty, and the other combiners don't expect to be dealing with essentially invalid MIR (multiple vreg defs etc). This change fixes it by ensuring that the dead instructions are processed on entry into tryCombineInstruction. As a result, this fix exposed a few places in tests where G_TRUNC instructions were not being deleted even though they were dead. Differential Revision: https://reviews.llvm.org/D59892 llvm-svn: 357101 --- llvm/lib/CodeGen/GlobalISel/Legalizer.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'llvm/lib/CodeGen/GlobalISel/Legalizer.cpp') diff --git a/llvm/lib/CodeGen/GlobalISel/Legalizer.cpp b/llvm/lib/CodeGen/GlobalISel/Legalizer.cpp index bd486d7dd1f..4db86761cdb 100644 --- a/llvm/lib/CodeGen/GlobalISel/Legalizer.cpp +++ b/llvm/lib/CodeGen/GlobalISel/Legalizer.cpp @@ -225,7 +225,8 @@ bool Legalizer::runOnMachineFunction(MachineFunction &MF) { continue; } SmallVector DeadInstructions; - if (ArtCombiner.tryCombineInstruction(MI, DeadInstructions)) { + if (ArtCombiner.tryCombineInstruction(MI, DeadInstructions, + WrapperObserver)) { for (auto *DeadMI : DeadInstructions) { LLVM_DEBUG(dbgs() << *DeadMI << "Is dead\n"); RemoveDeadInstFromLists(DeadMI); -- cgit v1.2.3