[all-commits] [llvm/llvm-project] 7e4447: [codegen] Store address of indirect arguments on t...
Felipe de Azevedo Piovezan via All-commits
all-commits at lists.llvm.org
Mon Jan 16 06:15:33 PST 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 7e4447a17db4a070f01c8f8a87505a4b2a1b0e3a
https://github.com/llvm/llvm-project/commit/7e4447a17db4a070f01c8f8a87505a4b2a1b0e3a
Author: Felipe de Azevedo Piovezan <fpiovezan at apple.com>
Date: 2023-01-16 (Mon, 16 Jan 2023)
Changed paths:
M clang/docs/ReleaseNotes.rst
M clang/lib/CodeGen/CGDebugInfo.cpp
M clang/lib/CodeGen/CGDebugInfo.h
M clang/lib/CodeGen/CGDecl.cpp
M clang/test/CodeGen/aarch64-ls64.c
M clang/test/CodeGen/atomic-arm64.c
M clang/test/CodeGenCXX/amdgcn-func-arg.cpp
M clang/test/CodeGenCXX/debug-info.cpp
M clang/test/CodeGenCXX/derived-to-base-conv.cpp
M clang/test/CodeGenCoroutines/coro-params-exp-namespace.cpp
M clang/test/CodeGenCoroutines/coro-params.cpp
M clang/test/OpenMP/for_firstprivate_codegen.cpp
M clang/test/OpenMP/parallel_firstprivate_codegen.cpp
M clang/test/OpenMP/sections_firstprivate_codegen.cpp
M clang/test/OpenMP/single_firstprivate_codegen.cpp
M clang/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp
M clang/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp
M clang/test/OpenMP/target_teams_distribute_parallel_for_simd_firstprivate_codegen.cpp
M clang/test/OpenMP/target_teams_distribute_simd_firstprivate_codegen.cpp
M clang/test/OpenMP/teams_distribute_firstprivate_codegen.cpp
M clang/test/OpenMP/teams_distribute_parallel_for_firstprivate_codegen.cpp
M clang/test/OpenMP/teams_distribute_parallel_for_simd_firstprivate_codegen.cpp
M clang/test/OpenMP/teams_distribute_simd_firstprivate_codegen.cpp
M clang/test/OpenMP/teams_firstprivate_codegen.cpp
Log Message:
-----------
[codegen] Store address of indirect arguments on the stack
With codegen prior to this patch, truly indirect arguments -- i.e.
those that are not `byval` -- can have their debug information lost even
at O0. Because indirect arguments are passed by pointer, and this
pointer is likely placed in a register as per the function call ABI,
debug information is lost as soon as the register gets clobbered.
This patch solves the issue by storing the address of the parameter on
the stack, using a similar strategy employed when C++ references are
passed. In other words, this patch changes codegen from:
```
define @foo(ptr %arg) {
call void @llvm.dbg.declare(%arg, [...], metadata !DIExpression())
```
To:
```
define @foo(ptr %arg) {
%ptr_storage = alloca ptr
store ptr %arg, ptr %ptr_storage
call void @llvm.dbg.declare(%ptr_storage, [...], metadata !DIExpression(DW_OP_deref))
```
Some common cases where this may happen with C or C++ function calls:
1. "Big enough" trivial structures passed by value under the ARM ABI.
2. Structures that are non-trivial for the purposes of call (as per
the Itanium ABI) when passed by value.
A few tests were matching the wrong alloca (matching against the new
alloca, instead of the old one), so they were updated to either match
both allocas or include a `,` right after the alloca type, to prevent
matching against a pointer type.
Differential Revision: https://reviews.llvm.org/D141381
More information about the All-commits
mailing list