[GC] Remove buggy untested optimization from statepoint lowering
authorPhilip Reames <listmail@philipreames.com>
Wed, 11 Mar 2020 17:01:11 +0000 (10:01 -0700)
committerPhilip Reames <listmail@philipreames.com>
Wed, 11 Mar 2020 17:03:24 +0000 (10:03 -0700)
commite6716418442bf178774ea2ec1d34d3d6a5e06b88
treeb27a4b733008a1397fd0812fa66b41390d709dd2
parent0396aa4c05a4b97101da14b5e813c8ab3a34e9d0
[GC] Remove buggy untested optimization from statepoint lowering

A downstream test case (see included reduced test) revealed that we have a bug in how we handle duplicate relocations. If we have the same SDValue relocated twice, and that value happens to be a constant (such as null), we only export one of the two llvm::Values. Exporting on a per llvm::Value basis is required to allow lowering of gc.relocates in following basic blocks (e.g. invokes). Without it, we end up with a use of an undefined vreg and bad things happen.

Rather than fixing the optimization - which appears to be hard - I propose we simply remove it. There are no tests in tree that change with this code removed. If we find out later that this did matter for something, we can reimplement a variation of this in CodeGenPrepare to catch the easy cases without complicating the lowering code.

Thanks to Denis and Serguei who did all the hard work of figuring out what went wrong here. The patch is by far the easy part. :)

Differential Revision: https://reviews.llvm.org/D75964
llvm/include/llvm/CodeGen/FunctionLoweringInfo.h
llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
llvm/test/CodeGen/X86/statepoint-duplicates-export.ll [new file with mode: 0644]