[IRMover] Use signature for exact definition (#177381) It is possible for optimizations to modify attributes on exact definitions. In particular, DeadArgumentElimination may find that a certain argument is dead, and replace arguments in calls with `poison`. This requires dropping the `noundef` attribute on the argument. When ThinLTO import is performed, the destination module already has a declaration for the function, and the definition is not imported (e.g. because it is noinline), we currently simply retain the original declaration. This is incorrect if call with poison arguments were imported, as the calls become immediate UB. There was a previous attempt to address this in https://reviews.llvm.org/D139209. What that patch did was to fix up the attributes of the declaration after the fact, dropping UB implying attributes that are not present on the definition. It was reverted because it made an incorrect assumption that the signature between the declaration and definition must match. In this PR, I propose to fix the issue in a different way: If the source module holds an exact definition (which are the ones that can be, in limited ways, modified by optimizations), then even if we don't import the definition, we should still import a declaration based on it. This ensures that we respect any dropped attributes. (It's probably also useful for optimization purposes, because we also see more inferred attributes.) Fixes https://github.com/llvm/llvm-project/issues/58976. (cherry picked from commit f2deb793af7b9543180bba4b9402dcc7cc7a0c2e)
Welcome to the LLVM project!
This repository contains the source code for LLVM, a toolkit for the construction of highly optimized compilers, optimizers, and run-time environments.
The LLVM project has multiple components. The core of the project is itself called “LLVM”. This contains all of the tools, libraries, and header files needed to process intermediate representations and convert them into object files. Tools include an assembler, disassembler, bitcode analyzer, and bitcode optimizer.
C-like languages use the Clang frontend. This component compiles C, C++, Objective-C, and Objective-C++ code into LLVM bitcode -- and from there into object files, using LLVM.
Other components include: the libc++ C++ standard library, the LLD linker, and more.
Consult the Getting Started with LLVM page for information on building and running LLVM.
For information on how to contribute to the LLVM project, please take a look at the Contributing to LLVM guide.
Join the LLVM Discourse forums, Discord chat, LLVM Office Hours or Regular sync-ups.
The LLVM project has adopted a code of conduct for participants to all modes of communication within the project.