[PATCH] D59892: [GlobalISel] Fix legalizer artifact combiner from crashing with invalid dead instructions

Amara Emerson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 27 10:21:28 PDT 2019


aemerson created this revision.
aemerson added reviewers: aditya_nandakumar, paquette, qcolombet.
aemerson added a project: LLVM.
Herald added subscribers: Petar.Avramovic, volkan, atanasyan, jrtc27, hiraditya, javed.absar, kristof.beyls, rovka, nhaehnle, jvesely, sdardis.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D59892

Files:
  llvm/include/llvm/CodeGen/GlobalISel/LegalizationArtifactCombiner.h
  llvm/lib/CodeGen/GlobalISel/Legalizer.cpp
  llvm/test/CodeGen/AArch64/GlobalISel/legalize-phi.mir
  llvm/test/CodeGen/AArch64/GlobalISel/legalizer-combiner-zext-trunc-crash.mir
  llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-icmp.mir
  llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-unmerge-values.mir
  llvm/test/CodeGen/Mips/GlobalISel/legalizer/sub.mir

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59892.192470.patch
Type: text/x-patch
Size: 14336 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190327/b891bdb4/attachment.bin>


More information about the llvm-commits mailing list