OSDN Git Service

[ARM GlobalISel] Fix selection of pointer constants
authorDiana Picus <diana.picus@linaro.org>
Thu, 4 Jan 2018 10:54:57 +0000 (10:54 +0000)
committerDiana Picus <diana.picus@linaro.org>
Thu, 4 Jan 2018 10:54:57 +0000 (10:54 +0000)
commit79a984ff1cd9d4bb8d86bd6aefec4187d1bc5157
treed34d85eadc99d4bd99e4f2c50421ba4634ed91fb
parentf494e856dbbecfdc2958a07cd4acc3c6a7ed7533
[ARM GlobalISel] Fix selection of pointer constants

We used to handle G_CONSTANT with pointer type by forcing the type of
the result register to s32 and then letting TableGen handle it.
Unfortunately, setting the type only works for generic virtual
registers, that haven't yet been constrained to a register class (e.g.
those used only by a COPY later on). If the result register has already
been constrained as a use of a previously selected instruction, then
setting the type will assert.

It would be nice to be able to teach TableGen to select pointer
constants the same as integer constants, but since it's such an edge
case (at the moment the only pointer constant that we're generally
interested in is 0, and that is mostly used for comparisons and selects,
which are also not supported by TableGen) it's probably not worth the
effort right now. Instead, handle pointer constants with some trivial
handwritten code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@321793 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/ARM/ARMInstructionSelector.cpp
test/CodeGen/ARM/GlobalISel/arm-instruction-select.mir