[IRMover] Remove UB implying parameter attributes when necessary
authorTim Neumann <timnn@google.com>
Tue, 21 Feb 2023 17:35:30 +0000 (18:35 +0100)
committerBenjamin Kramer <benny.kra@googlemail.com>
Tue, 21 Feb 2023 17:35:31 +0000 (18:35 +0100)
commit451799bb8261bde52bbfef226d019caf1d82aa42
tree21140b26ccba292c92887f38dc9ef40ee1a293d2
parent9ad0ac8eb3d0bc03cac9c8871d0ee771156a67b4
[IRMover] Remove UB implying parameter attributes when necessary

When importing functions from some module X into some module Y, they may reference other functions already present in Y. The signature (especially attributes) of those other functions may have diverged between X and Y (e.g. due to the Dead Argument Elimination optimization). If necessary, modify the attributes to avoid UB.

See the added test and implementation comments for more details.

This was exposed by https://reviews.llvm.org/D133036 before it was reverted. Fixes https://github.com/llvm/llvm-project/issues/58976.

Reviewed By: tejohnson

Differential Revision: https://reviews.llvm.org/D139209
llvm/include/llvm/IR/Attributes.h
llvm/lib/Linker/IRMover.cpp
llvm/test/Transforms/FunctionImport/Inputs/attr_fixup_dae_noundef.ll [new file with mode: 0644]
llvm/test/Transforms/FunctionImport/attr_fixup_dae_noundef.ll [new file with mode: 0644]