llvm-project/llvm
Ellis Hoag 549773f9e9 [Dwarf] Reference the correct CU when inlining
Sometimes when a function is inlined into a different CU, `llvm-dwarfdump --verify` would find an inlined subroutine with an invalid abstract origin. This is because `DwarfUnit::addDIEEntry()` will incorrectly assume the inlined subroutine and the abstract origin are from the same CU if it can't find the CU for the inlined subroutine.

In the added test, the inlined subroutine for `bar()` is created before the CU for `B.swift` is created, so it tries to point to `goo()` in the wrong CU. Interestingly, if we swap the order of the two functions then we don't see a crash since the module for `goo()` is created first.

The fix is to give a parent DIE to `ScopeDIE` before calling `addDIEEntry()` so that its CU can be found. Luckily, `constructInlinedScopeDIE()` is only called once so we can pass it the DIE of the scope's parent and give it a child just after it's created.

`constructInlinedScopeDIE()` should always return a DIE, so assert that it is not null.

Reviewed By: aprantl

Differential Revision: https://reviews.llvm.org/D135114
2022-10-05 09:19:12 -07:00
..
benchmarks
bindings [llvm-ocaml] Add binding for constructing opaque pointers 2022-10-03 14:38:48 -07:00
cmake [llvm-driver] Support single distributions 2022-10-01 20:20:28 +00:00
docs [LangRef][VP] Change masked-off lanes from undef to poison 2022-10-05 15:24:14 +01:00
examples
include [Attributor] Teach AAPointerInfo to look into aggregates 2022-10-05 06:19:47 -07:00
lib [Dwarf] Reference the correct CU when inlining 2022-10-05 09:19:12 -07:00
projects
resources
runtimes [NFC] Fix typo in comment 2022-09-20 17:22:08 -04:00
test [Dwarf] Reference the correct CU when inlining 2022-10-05 09:19:12 -07:00
tools [AArch64][Windows] Add llvm-readobj support for save_any_reg unwind opcode. 2022-10-04 18:55:01 -07:00
unittests Add APFloat and MLIR type support for fp8 (e5m2). 2022-10-04 17:18:17 -07:00
utils [gn build] Port f0f474dfd0 2022-10-05 09:44:51 +00:00
.clang-format
.clang-tidy
.gitattributes
.gitignore
CMakeLists.txt [llvm] Remove libcxx, libcxxabi and libunwind from supported LLVM_ENABLE_PROJECTS 2022-10-04 09:04:12 -04:00
CODE_OWNERS.TXT
CREDITS.TXT
LICENSE.TXT
README.txt
RELEASE_TESTERS.TXT
configure
llvm.spec.in

README.txt

The LLVM Compiler Infrastructure
================================

This directory and its subdirectories contain source code for LLVM,
a toolkit for the construction of highly optimized compilers,
optimizers, and runtime environments.

LLVM is open source software. You may freely distribute it under the terms of
the license agreement found in LICENSE.txt.

Please see the documentation provided in docs/ for further
assistance with LLVM, and in particular docs/GettingStarted.rst for getting
started with LLVM and docs/README.txt for an overview of LLVM's
documentation setup.

If you are writing a package for LLVM, see docs/Packaging.rst for our
suggestions.