[SimplifyCFG][LICM] Preserve nonnull, range and align metadata when speculating
authorNikita Popov <npopov@redhat.com>
Wed, 22 Mar 2023 10:53:01 +0000 (11:53 +0100)
committerNikita Popov <npopov@redhat.com>
Tue, 4 Apr 2023 08:03:45 +0000 (10:03 +0200)
commit78b1fbc63f78660ef10e3ccf0e527c667a563bc8
tree212ec76f43ace94e8713c0741634d288d8bb1d39
parentf7deb69f22b93d7411d08db14b50aae5caf40fcb
[SimplifyCFG][LICM] Preserve nonnull, range and align metadata when speculating

After D141386, violation of nonnull, range and align metadata
results in poison rather than immediate undefined behavior,
which means that these are now safe to retain when speculating.
We only need to remove UB-implying metadata like noundef.

This is done by adding a dropUBImplyingAttrsAndMetadata() helper,
which lists the metadata which is known safe to retain on speculation.

Differential Revision: https://reviews.llvm.org/D146629
llvm/include/llvm/IR/Instruction.h
llvm/lib/IR/Instruction.cpp
llvm/lib/Transforms/Scalar/LICM.cpp
llvm/lib/Transforms/Utils/Local.cpp
llvm/lib/Transforms/Utils/SimplifyCFG.cpp
llvm/test/Transforms/LICM/hoist-metadata.ll
llvm/test/Transforms/SimplifyCFG/hoist-with-metadata.ll