Recommit "[SCCP] Remove forcedconstant, go to overdefined instead"
authorFlorian Hahn <flo@fhahn.com>
Wed, 12 Feb 2020 14:22:20 +0000 (14:22 +0000)
committerFlorian Hahn <flo@fhahn.com>
Wed, 12 Feb 2020 18:02:18 +0000 (18:02 +0000)
commitbb310b3f73dde5551bc2a0d564e88f7c831dfdb3
tree022b65293a33cd46d60d415a2d82646a488f7f1d
parent5bb4954008a6354a54ae225ba37f2788109f218a
Recommit "[SCCP] Remove forcedconstant, go to overdefined instead"

This version includes a fix for a set of crashes caused by marking
values depending on a yet unknown & tracked call as overdefined.

In some cases, we would later discover that the call has a constant
result and try to mark a user of it as constant, although it was already
marked as overdefined. Most instruction handlers bail out early if the
instruction is already overdefined. But that is not necessary for
CastInsts for example. By skipping values that depend on skipped
calls, we resolve the crashes and also improve the precision in some
cases (see resolvedundefsin-tracked-fn.ll).

Note that we may not skip PHI nodes that may depend on a skipped call,
but they can be safely marked as overdefined, as we bail out early if
the PHI node is overdefined.

This reverts the revert commit
a74b31a3e9cd844c7ce2087978568e3f5ec8519.
14 files changed:
llvm/lib/Transforms/Scalar/SCCP.cpp
llvm/test/Transforms/IPConstantProp/PR16052.ll
llvm/test/Transforms/IPConstantProp/PR26044.ll
llvm/test/Transforms/SCCP/2006-12-19-UndefBug.ll
llvm/test/Transforms/SCCP/apint-bigint2.ll
llvm/test/Transforms/SCCP/apint-ipsccp3.ll
llvm/test/Transforms/SCCP/apint-select.ll
llvm/test/Transforms/SCCP/ip-constant-ranges.ll
llvm/test/Transforms/SCCP/ipsccp-basic.ll
llvm/test/Transforms/SCCP/logical-nuke.ll
llvm/test/Transforms/SCCP/resolvedundefsin-tracked-fn.ll [new file with mode: 0644]
llvm/test/Transforms/SCCP/switch-multiple-undef.ll
llvm/test/Transforms/SCCP/ub-shift.ll
llvm/test/Transforms/SCCP/undef-resolve.ll