Skip to content

Commit 2ff6099

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merge upstream LLVM into amd-gfx12
2 parents 0d7b9bd + 5c7c855 commit 2ff6099

File tree

104 files changed

+5366
-622
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+5366
-622
lines changed

clang/lib/CodeGen/CGStmt.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -846,11 +846,13 @@ void CodeGenFunction::EmitGotoStmt(const GotoStmt &S) {
846846
if (HaveInsertPoint())
847847
EmitStopPoint(&S);
848848

849+
ApplyAtomGroup Grp(getDebugInfo());
849850
EmitBranchThroughCleanup(getJumpDestForLabel(S.getLabel()));
850851
}
851852

852853

853854
void CodeGenFunction::EmitIndirectGotoStmt(const IndirectGotoStmt &S) {
855+
ApplyAtomGroup Grp(getDebugInfo());
854856
if (const LabelDecl *Target = S.getConstantTarget()) {
855857
EmitBranchThroughCleanup(getJumpDestForLabel(Target));
856858
return;
@@ -869,6 +871,8 @@ void CodeGenFunction::EmitIndirectGotoStmt(const IndirectGotoStmt &S) {
869871
cast<llvm::PHINode>(IndGotoBB->begin())->addIncoming(V, CurBB);
870872

871873
EmitBranch(IndGotoBB);
874+
if (CurBB && CurBB->getTerminator())
875+
addInstToCurrentSourceAtom(CurBB->getTerminator(), nullptr);
872876
}
873877

874878
void CodeGenFunction::EmitIfStmt(const IfStmt &S) {
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// RUN: %clang_cc1 -triple x86_64-linux-gnu -gkey-instructions -x c++ -std=c++17 %s -debug-info-kind=line-tables-only -emit-llvm -o - -gno-column-info \
2+
// RUN: | FileCheck %s
3+
// RUN: %clang_cc1 -triple x86_64-linux-gnu -gkey-instructions -x c %s -debug-info-kind=line-tables-only -emit-llvm -o - -gno-column-info \
4+
// RUN: | FileCheck %s
5+
6+
// Check the goto branches get Key Instructions metadata.
7+
void ext();
8+
void test_goto(void) {
9+
// CHECK: br label %dst1, !dbg [[G1R1:!.*]]
10+
goto dst1;
11+
dst1:
12+
ext();
13+
14+
void *ptr = &&dst2;
15+
// CHECK: br label %indirectgoto, !dbg [[G3R1:!.*]]
16+
goto *ptr;
17+
dst2:
18+
ext();
19+
20+
// CHECK: br label %dst3, !dbg [[G4R1:!.*]]
21+
goto *&&dst3;
22+
dst3:
23+
ext();
24+
25+
return;
26+
}
27+
28+
// CHECK: [[G1R1]] = !DILocation(line: 10, scope: ![[#]], atomGroup: 1, atomRank: 1)
29+
// CHECK: [[G3R1]] = !DILocation(line: 16, scope: ![[#]], atomGroup: 3, atomRank: 1)
30+
// CHECK: [[G4R1]] = !DILocation(line: 21, scope: ![[#]], atomGroup: 4, atomRank: 1)

lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1545,20 +1545,10 @@ static void LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
15451545
"std::bitset synthetic child", "^std::(__debug::)?bitset<.+>(( )?&)?$",
15461546
stl_deref_flags, true);
15471547

1548-
AddCXXSynthetic(
1549-
cpp_category_sp,
1550-
lldb_private::formatters::LibStdcppOptionalSyntheticFrontEndCreator,
1551-
"std::optional synthetic child", "^std::optional<.+>(( )?&)?$",
1552-
stl_deref_flags, true);
1553-
15541548
AddCXXSummary(cpp_category_sp,
15551549
lldb_private::formatters::StdlibCoroutineHandleSummaryProvider,
15561550
"libstdc++ std::coroutine_handle summary provider",
15571551
libstdcpp_std_coroutine_handle_regex, stl_summary_flags, true);
1558-
AddCXXSummary(cpp_category_sp,
1559-
lldb_private::formatters::GenericOptionalSummaryProvider,
1560-
"libstd++ std::optional summary provider",
1561-
"^std::optional<.+>(( )?&)?$", stl_summary_flags, true);
15621552
}
15631553

15641554
static lldb_private::SyntheticChildrenFrontEnd *
@@ -1648,6 +1638,17 @@ GenericForwardListSyntheticFrontEndCreator(CXXSyntheticChildren *children,
16481638
*valobj_sp);
16491639
}
16501640

1641+
static SyntheticChildrenFrontEnd *
1642+
GenericOptionalSyntheticFrontEndCreator(CXXSyntheticChildren *children,
1643+
lldb::ValueObjectSP valobj_sp) {
1644+
if (!valobj_sp)
1645+
return nullptr;
1646+
1647+
if (IsMsvcStlOptional(*valobj_sp))
1648+
return MsvcStlOptionalSyntheticFrontEndCreator(children, valobj_sp);
1649+
return LibStdcppOptionalSyntheticFrontEndCreator(children, valobj_sp);
1650+
}
1651+
16511652
/// Load formatters that are formatting types from more than one STL
16521653
static void LoadCommonStlFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
16531654
if (!cpp_category_sp)
@@ -1713,6 +1714,12 @@ static void LoadCommonStlFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
17131714
"std::forward_list synthetic children",
17141715
"^std::forward_list<.+>(( )?&)?$", stl_synth_flags, true);
17151716

1717+
SyntheticChildren::Flags stl_deref_flags = stl_synth_flags;
1718+
stl_deref_flags.SetFrontEndWantsDereference();
1719+
AddCXXSynthetic(cpp_category_sp, GenericOptionalSyntheticFrontEndCreator,
1720+
"std::optional synthetic children",
1721+
"^std::optional<.+>(( )?&)?$", stl_deref_flags, true);
1722+
17161723
AddCXXSummary(cpp_category_sp, GenericSmartPointerSummaryProvider,
17171724
"MSVC STL/libstdc++ std::shared_ptr summary provider",
17181725
"^std::shared_ptr<.+>(( )?&)?$", stl_summary_flags, true);
@@ -1739,6 +1746,9 @@ static void LoadCommonStlFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
17391746
TypeSummaryImplSP(new ScriptSummaryFormat(
17401747
stl_summary_flags,
17411748
"lldb.formatters.cpp.gnu_libstdcpp.ForwardListSummaryProvider")));
1749+
AddCXXSummary(cpp_category_sp, GenericOptionalSummaryProvider,
1750+
"MSVC STL/libstd++ std::optional summary provider",
1751+
"^std::optional<.+>(( )?&)?$", stl_summary_flags, true);
17421752
}
17431753

17441754
static void LoadMsvcStlFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {

lldb/source/Plugins/Language/CPlusPlus/GenericOptional.cpp

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "Generic.h"
1010
#include "LibCxx.h"
1111
#include "LibStdcpp.h"
12+
#include "MsvcStl.h"
1213
#include "Plugins/TypeSystem/Clang/TypeSystemClang.h"
1314
#include "lldb/DataFormatters/FormattersHelpers.h"
1415
#include "lldb/Target/Target.h"
@@ -32,6 +33,7 @@ class GenericOptionalFrontend : public SyntheticChildrenFrontEnd {
3233
enum class StdLib {
3334
LibCxx,
3435
LibStdcpp,
36+
MsvcStl,
3537
};
3638

3739
GenericOptionalFrontend(ValueObject &valobj, StdLib stdlib);
@@ -77,7 +79,8 @@ lldb::ChildCacheState GenericOptionalFrontend::Update() {
7779
else if (m_stdlib == StdLib::LibStdcpp) {
7880
if (ValueObjectSP payload = m_backend.GetChildMemberWithName("_M_payload"))
7981
engaged_sp = payload->GetChildMemberWithName("_M_engaged");
80-
}
82+
} else if (m_stdlib == StdLib::MsvcStl)
83+
engaged_sp = m_backend.GetChildMemberWithName("_Has_value");
8184

8285
if (!engaged_sp)
8386
return lldb::ChildCacheState::eRefetch;
@@ -114,7 +117,12 @@ ValueObjectSP GenericOptionalFrontend::GetChildAtIndex(uint32_t _idx) {
114117
ValueObjectSP candidate = val_sp->GetChildMemberWithName("_M_value");
115118
if (candidate)
116119
val_sp = candidate;
117-
}
120+
} else if (m_stdlib == StdLib::MsvcStl)
121+
// Same issue as with LibCxx
122+
val_sp = m_backend.GetChildMemberWithName("_Has_value")
123+
->GetParent()
124+
->GetChildAtIndex(0)
125+
->GetChildMemberWithName("_Value");
118126

119127
if (!val_sp)
120128
return ValueObjectSP();
@@ -143,3 +151,17 @@ SyntheticChildrenFrontEnd *formatters::LibcxxOptionalSyntheticFrontEndCreator(
143151
GenericOptionalFrontend::StdLib::LibCxx);
144152
return nullptr;
145153
}
154+
155+
bool formatters::IsMsvcStlOptional(ValueObject &valobj) {
156+
if (auto valobj_sp = valobj.GetNonSyntheticValue())
157+
return valobj_sp->GetChildMemberWithName("_Has_value") != nullptr;
158+
return false;
159+
}
160+
161+
SyntheticChildrenFrontEnd *formatters::MsvcStlOptionalSyntheticFrontEndCreator(
162+
CXXSyntheticChildren *, lldb::ValueObjectSP valobj_sp) {
163+
if (valobj_sp)
164+
return new GenericOptionalFrontend(
165+
*valobj_sp, GenericOptionalFrontend::StdLib::MsvcStl);
166+
return nullptr;
167+
}

lldb/source/Plugins/Language/CPlusPlus/MsvcStl.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ SyntheticChildrenFrontEnd *
6565
MsvcStlListSyntheticFrontEndCreator(CXXSyntheticChildren *,
6666
lldb::ValueObjectSP valobj_sp);
6767

68+
// MSVC STL std::optional<>
69+
bool IsMsvcStlOptional(ValueObject &valobj);
70+
SyntheticChildrenFrontEnd *
71+
MsvcStlOptionalSyntheticFrontEndCreator(CXXSyntheticChildren *,
72+
lldb::ValueObjectSP valobj_sp);
73+
6874
} // namespace formatters
6975
} // namespace lldb_private
7076

lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/optional/TestDataFormatterGenericOptional.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,9 @@
33
from lldbsuite.test.lldbtest import *
44
from lldbsuite.test import lldbutil
55

6-
USE_LIBSTDCPP = "USE_LIBSTDCPP"
7-
USE_LIBCPP = "USE_LIBCPP"
8-
96

107
class GenericOptionalDataFormatterTestCase(TestBase):
11-
def do_test_with_run_command(self, stdlib_type):
8+
def do_test_with_run_command(self):
129
"""Test that that file and class static variables display correctly."""
1310

1411
# This is the function to remove the custom formats in order to have a
@@ -21,7 +18,6 @@ def cleanup():
2118

2219
self.addTearDownHook(cleanup)
2320

24-
self.build(dictionary={stdlib_type: "1"})
2521
self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
2622

2723
bkpt = self.target().FindBreakpointByID(
@@ -100,7 +96,8 @@ def cleanup():
10096
## We are skipping gcc version less that 5.1 since this test requires -std=c++17
10197
@skipIf(compiler="gcc", compiler_version=["<", "5.1"])
10298
def test_with_run_command_libcpp(self):
103-
self.do_test_with_run_command(USE_LIBCPP)
99+
self.build(dictionary={"USE_LIBCPP": 1})
100+
self.do_test_with_run_command()
104101

105102
@add_test_categories(["libstdcxx"])
106103
## Clang 7.0 is the oldest Clang that can reliably parse newer libc++ versions
@@ -109,4 +106,11 @@ def test_with_run_command_libcpp(self):
109106
## We are skipping gcc version less that 5.1 since this test requires -std=c++17
110107
@skipIf(compiler="gcc", compiler_version=["<", "5.1"])
111108
def test_with_run_command_libstdcpp(self):
112-
self.do_test_with_run_command(USE_LIBSTDCPP)
109+
self.build(dictionary={"USE_LIBSTDCPP": 1})
110+
self.do_test_with_run_command()
111+
112+
@add_test_categories(["msvcstl"])
113+
def test_with_run_command_msvcstl(self):
114+
# No flags, because the "msvcstl" category checks that the MSVC STL is used by default.
115+
self.build()
116+
self.do_test_with_run_command()

llvm/docs/AMDGPUUsage.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1853,6 +1853,20 @@ The AMDGPU backend supports the following calling conventions:
18531853
..TODO::
18541854
Describe.
18551855

1856+
``amdgpu_gfx_whole_wave`` Used for AMD graphics targets. Functions with this calling convention
1857+
cannot be used as entry points. They must have an i1 as the first argument,
1858+
which will be mapped to the value of EXEC on entry into the function. Other
1859+
arguments will contain poison in their inactive lanes. Similarly, the return
1860+
value for the inactive lanes is poison.
1861+
1862+
The function will run with all lanes enabled, i.e. EXEC will be set to -1 in the
1863+
prologue and restored to its original value in the epilogue. The inactive lanes
1864+
will be preserved for all the registers used by the function. Active lanes only
1865+
will only be preserved for the callee saved registers.
1866+
1867+
In all other respects, functions with this calling convention behave like
1868+
``amdgpu_gfx`` functions.
1869+
18561870
``amdgpu_gs`` Used for Mesa/AMDPAL geometry shaders.
18571871
..TODO::
18581872
Describe.

llvm/docs/CommandGuide/llvm-objdump.rst

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -140,23 +140,29 @@ OPTIONS
140140
debug information for stripped binaries. Multiple instances of this argument
141141
are searched in the order given.
142142

143-
.. option:: --debuginfod, --no-debuginfod
143+
.. option:: --debug-indent=<width>
144144

145-
Whether or not to try debuginfod lookups for debug binaries. Unless specified,
146-
debuginfod is only enabled if libcurl was compiled in (``LLVM_ENABLE_CURL``)
147-
and at least one server URL was provided by the environment variable
148-
``DEBUGINFOD_URLS``.
145+
Distance to indent the source-level variable or inlined function display,
146+
relative to the start of the disassembly. Defaults to 52 characters.
147+
148+
.. option:: --debug-inlined-funcs[=<format>]
149149

150-
.. option:: --debug-vars=<format>
150+
Print the locations of inlined functions alongside disassembly.
151+
``format`` may be ``ascii``, ``limits-only``, or ``unicode``, defaulting to
152+
``unicode`` if omitted.
153+
154+
.. option:: --debug-vars[=<format>]
151155

152156
Print the locations (in registers or memory) of source-level variables
153-
alongside disassembly. ``format`` may be ``unicode`` or ``ascii``, defaulting
157+
alongside disassembly. ``format`` may be ``ascii`` or ``unicode``, defaulting
154158
to ``unicode`` if omitted.
155159

156-
.. option:: --debug-vars-indent=<width>
160+
.. option:: --debuginfod, --no-debuginfod
157161

158-
Distance to indent the source-level variable display, relative to the start
159-
of the disassembly. Defaults to 52 characters.
162+
Whether or not to try debuginfod lookups for debug binaries. Unless specified,
163+
debuginfod is only enabled if libcurl was compiled in (``LLVM_ENABLE_CURL``)
164+
and at least one server URL was provided by the environment variable
165+
``DEBUGINFOD_URLS``.
160166

161167
.. option:: -j, --section=<section1[,section2,...]>
162168

llvm/docs/ReleaseNotes.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,9 @@ Changes to the LLVM tools
282282
([#47468](https://github.com/llvm/llvm-project/issues/47468))
283283
* llvm-addr2line now supports a `+` prefix when specifying an address.
284284
* Support for `SHT_LLVM_BB_ADDR_MAP` versions 0 and 1 has been dropped.
285+
* llvm-objdump now supports the `--debug-inlined-funcs` flag, which prints the
286+
locations of inlined functions alongside disassembly. The
287+
`--debug-vars-indent` flag has also been renamed to `--debug-indent`.
285288

286289
Changes to LLDB
287290
---------------------------------

llvm/include/llvm/AsmParser/LLToken.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ enum Kind {
181181
kw_amdgpu_cs_chain_preserve,
182182
kw_amdgpu_kernel,
183183
kw_amdgpu_gfx,
184+
kw_amdgpu_gfx_whole_wave,
184185
kw_tailcc,
185186
kw_m68k_rtdcc,
186187
kw_graalcc,

0 commit comments

Comments
 (0)