[LinkerWrapper] Fix -fsave-optimization-record default file (#149003) As discussed in PR #145603, the following command seems to fail to produce a YAML remarks file for offload LTO passes and thus for kernel-info: ``` clang -O2 -g -fopenmp --offload-arch=native test.c -foffload-lto \ -Rpass=kernel-info -fsave-optimization-record ``` The problem is that, in clang-linker-wrapper's clang call, clang names the file based on clang's main output file (from `-o`). That is a temporary file, so the YAML file becomes a temporary file, which the user never sees. This patch: - Makes clang honor `-dumpdir` for the default YAML remarks file in the case of LTO. - Extends clang-linker-wrapper to specify that option to clang. To demonstrate the appeal of the generality of `-dumpdir` (as opposed to a one-off `-fsave-optimization-record` solution in clang-linker-wrapper), this patch also fixes `-gsplit-dwarf`. Without this patch, when using `-gsplit-dwarf` and later debugging using rocgdb, the dwo directory for offload is a temporary file, so temporary file cleanup causes rocgdb to lose debug symbols for offload code. WARNING: The clang driver passes `-dumpdir` to various clang frontend calls. For LTO, that was previously being ignored, and now it's not. That changes some auxiliary file names, as revealed by changes in some existing tests' expected output: `clang/test/Driver/opt-record.c` and `clang/test/Driver/lto-dwo.c`. Hopefully this change does not introduce a backward compatibility issue for users.
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.