Skip to content

Commit 432cf6b

Browse files
authored
Merge pull request llvm#568 from AMD-Lightning-Internal/upstream_merge_202502080708
merge main into amd-staging
2 parents f5f9c70 + 44568b1 commit 432cf6b

File tree

81 files changed

+488
-501
lines changed

Some content is hidden

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

81 files changed

+488
-501
lines changed

clang/docs/ClangFormatStyleOptions.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2182,6 +2182,24 @@ the configuration (without a prefix: ``Auto``).
21822182
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);
21832183
}
21842184

2185+
.. _BinPackLongBracedList:
2186+
2187+
**BinPackLongBracedList** (``Boolean``) :versionbadge:`clang-format 21` :ref:`<BinPackLongBracedList>`
2188+
If ``BinPackLongBracedList`` is ``true`` it overrides
2189+
``BinPackArguments`` if there are 20 or more items in a braced
2190+
initializer list.
2191+
2192+
.. code-block:: c++
2193+
2194+
BinPackLongBracedList: false vs. BinPackLongBracedList: true
2195+
vector<int> x{ vector<int> x{1, 2, ...,
2196+
20, 21};
2197+
1,
2198+
2,
2199+
...,
2200+
20,
2201+
21};
2202+
21852203
.. _BinPackParameters:
21862204

21872205
**BinPackParameters** (``BinPackParametersStyle``) :versionbadge:`clang-format 3.7` :ref:`<BinPackParameters>`

clang/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ Bug Fixes to C++ Support
151151
^^^^^^^^^^^^^^^^^^^^^^^^
152152

153153
- Clang is now better at keeping track of friend function template instance contexts. (#GH55509)
154+
- The initialization kind of elements of structured bindings
155+
direct-list-initialized from an array is corrected to direct-initialization.
154156

155157
Bug Fixes to AST Handling
156158
^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -237,6 +239,8 @@ clang-format
237239
------------
238240

239241
- Adds ``BreakBeforeTemplateCloser`` option.
242+
- Adds ``BinPackLongBracedList`` option to override bin packing options in
243+
long (20 item or more) braced list initializer lists.
240244

241245
libclang
242246
--------

clang/include/clang/Format/Format.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,6 +1212,22 @@ struct FormatStyle {
12121212
/// \version 3.7
12131213
bool BinPackArguments;
12141214

1215+
/// If ``BinPackLongBracedList`` is ``true`` it overrides
1216+
/// ``BinPackArguments`` if there are 20 or more items in a braced
1217+
/// initializer list.
1218+
/// \code
1219+
/// BinPackLongBracedList: false vs. BinPackLongBracedList: true
1220+
/// vector<int> x{ vector<int> x{1, 2, ...,
1221+
/// 20, 21};
1222+
/// 1,
1223+
/// 2,
1224+
/// ...,
1225+
/// 20,
1226+
/// 21};
1227+
/// \endcode
1228+
/// \version 21
1229+
bool BinPackLongBracedList;
1230+
12151231
/// Different way to try to fit all parameters on a line.
12161232
enum BinPackParametersStyle : int8_t {
12171233
/// Bin-pack parameters.
@@ -5266,6 +5282,7 @@ struct FormatStyle {
52665282
R.AlwaysBreakBeforeMultilineStrings &&
52675283
AttributeMacros == R.AttributeMacros &&
52685284
BinPackArguments == R.BinPackArguments &&
5285+
BinPackLongBracedList == R.BinPackLongBracedList &&
52695286
BinPackParameters == R.BinPackParameters &&
52705287
BitFieldColonSpacing == R.BitFieldColonSpacing &&
52715288
BracedInitializerIndentWidth == R.BracedInitializerIndentWidth &&

clang/lib/Format/Format.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -995,6 +995,7 @@ template <> struct MappingTraits<FormatStyle> {
995995
Style.AlwaysBreakBeforeMultilineStrings);
996996
IO.mapOptional("AttributeMacros", Style.AttributeMacros);
997997
IO.mapOptional("BinPackArguments", Style.BinPackArguments);
998+
IO.mapOptional("BinPackLongBracedList", Style.BinPackLongBracedList);
998999
IO.mapOptional("BinPackParameters", Style.BinPackParameters);
9991000
IO.mapOptional("BitFieldColonSpacing", Style.BitFieldColonSpacing);
10001001
IO.mapOptional("BracedInitializerIndentWidth",
@@ -1507,6 +1508,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) {
15071508
LLVMStyle.AlwaysBreakBeforeMultilineStrings = false;
15081509
LLVMStyle.AttributeMacros.push_back("__capability");
15091510
LLVMStyle.BinPackArguments = true;
1511+
LLVMStyle.BinPackLongBracedList = true;
15101512
LLVMStyle.BinPackParameters = FormatStyle::BPPS_BinPack;
15111513
LLVMStyle.BitFieldColonSpacing = FormatStyle::BFCS_Both;
15121514
LLVMStyle.BracedInitializerIndentWidth = std::nullopt;

clang/lib/Format/FormatToken.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ void CommaSeparatedList::precomputeFormattingInfos(const FormatToken *Token) {
175175
// have many items (20 or more) or we allow bin-packing of function call
176176
// arguments.
177177
if (Style.Cpp11BracedListStyle && !Style.BinPackArguments &&
178-
Commas.size() < 19) {
178+
(Commas.size() < 19 || !Style.BinPackLongBracedList)) {
179179
return;
180180
}
181181

clang/lib/Sema/SemaInit.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4862,9 +4862,13 @@ static void TryListInitialization(Sema &S,
48624862
assert(
48634863
S.Context.hasSameUnqualifiedType(SubInit[0]->getType(), DestType) &&
48644864
"Deduced to other type?");
4865+
assert(Kind.getKind() == clang::InitializationKind::IK_DirectList &&
4866+
"List-initialize structured bindings but not "
4867+
"direct-list-initialization?");
48654868
TryArrayCopy(S,
4866-
InitializationKind::CreateCopy(Kind.getLocation(),
4867-
InitList->getLBraceLoc()),
4869+
InitializationKind::CreateDirect(Kind.getLocation(),
4870+
InitList->getLBraceLoc(),
4871+
InitList->getRBraceLoc()),
48684872
Entity, SubInit[0], DestType, Sequence,
48694873
TreatUnavailableAsInvalid);
48704874
if (Sequence)

clang/test/SemaCXX/cxx1z-decomposition.cpp

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -200,38 +200,32 @@ namespace lambdas {
200200

201201
namespace by_value_array_copy {
202202
struct explicit_copy {
203-
explicit_copy() = default; // expected-note 2{{candidate constructor not viable: requires 0 arguments, but 1 was provided}}
204-
explicit explicit_copy(const explicit_copy&) = default; // expected-note 2{{explicit constructor is not a candidate}}
203+
explicit_copy() = default; // expected-note {{candidate constructor not viable: requires 0 arguments, but 1 was provided}}
204+
explicit explicit_copy(const explicit_copy&) = default; // expected-note {{explicit constructor is not a candidate}}
205205
};
206206

207-
constexpr int direct_initialization_for_elements() {
208-
explicit_copy ec_arr[2];
209-
auto [a1, b1](ec_arr);
207+
constexpr int simple_array_elements() {
208+
int arr[2]{1, 2};
210209

211-
int arr[3]{1, 2, 3};
212-
auto [a2, b2, c2](arr);
213-
arr[0]--;
214-
return a2 + b2 + c2 + arr[0];
215-
}
216-
static_assert(direct_initialization_for_elements() == 6);
210+
auto [a1, a2] = arr;
211+
auto [b1, b2](arr);
212+
auto [c1, c2]{arr}; // GH31813
217213

218-
constexpr int copy_initialization_for_elements() {
219-
int arr[2]{4, 5};
220-
auto [a1, b1] = arr;
221-
auto [a2, b2]{arr}; // GH31813
222214
arr[0] = 0;
223-
return a1 + b1 + a2 + b2 + arr[0];
215+
return arr[0] + a1 + a2 + b1 + b2 + c1 + c2;
224216
}
225-
static_assert(copy_initialization_for_elements() == 18);
217+
static_assert(simple_array_elements() == 9);
218+
219+
void explicit_copy_ctor_array_elements() {
220+
explicit_copy ec_arr[1];
226221

227-
void copy_initialization_for_elements_with_explicit_copy_ctor() {
228-
explicit_copy ec_arr[2];
229-
auto [a1, b1] = ec_arr; // expected-error {{no matching constructor for initialization of 'explicit_copy[2]'}}
230-
auto [a2, b2]{ec_arr}; // expected-error {{no matching constructor for initialization of 'explicit_copy[2]'}}
222+
auto [a] = ec_arr; // expected-error {{no matching constructor for initialization of 'explicit_copy[1]'}}
223+
auto [b](ec_arr);
224+
auto [c]{ec_arr};
231225

232226
// Test prvalue
233-
using T = explicit_copy[2];
234-
auto [a3, b3] = T{};
235-
auto [a4, b4]{T{}};
227+
using T = explicit_copy[1];
228+
auto [d] = T{};
236229
}
230+
237231
} // namespace by_value_array_copy

clang/unittests/Format/ConfigParseTest.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ TEST(ConfigParseTest, ParsesConfigurationBools) {
168168
CHECK_PARSE_BOOL(AllowShortLoopsOnASingleLine);
169169
CHECK_PARSE_BOOL(AllowShortNamespacesOnASingleLine);
170170
CHECK_PARSE_BOOL(BinPackArguments);
171+
CHECK_PARSE_BOOL(BinPackLongBracedList);
171172
CHECK_PARSE_BOOL(BreakAdjacentStringLiterals);
172173
CHECK_PARSE_BOOL(BreakAfterJavaFieldAnnotations);
173174
CHECK_PARSE_BOOL(BreakBeforeTemplateCloser);

clang/unittests/Format/FormatTest.cpp

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14420,6 +14420,51 @@ TEST_F(FormatTest, LayoutCxx11BraceInitializers) {
1442014420
"};",
1442114421
NoBinPacking);
1442214422

14423+
NoBinPacking.BinPackLongBracedList = false;
14424+
verifyFormat("const Aaaaaa aaaaa = {aaaaa,\n"
14425+
" bbbbb,\n"
14426+
" ccccc,\n"
14427+
" ddddd,\n"
14428+
" eeeee,\n"
14429+
" ffffff,\n"
14430+
" ggggg,\n"
14431+
" hhhhhh,\n"
14432+
" iiiiii,\n"
14433+
" jjjjjj,\n"
14434+
" kkkkkk,\n"
14435+
" aaaaa,\n"
14436+
" bbbbb,\n"
14437+
" ccccc,\n"
14438+
" ddddd,\n"
14439+
" eeeee,\n"
14440+
" ffffff,\n"
14441+
" ggggg,\n"
14442+
" hhhhhh,\n"
14443+
" iiiiii};",
14444+
NoBinPacking);
14445+
verifyFormat("const Aaaaaa aaaaa = {\n"
14446+
" aaaaa,\n"
14447+
" bbbbb,\n"
14448+
" ccccc,\n"
14449+
" ddddd,\n"
14450+
" eeeee,\n"
14451+
" ffffff,\n"
14452+
" ggggg,\n"
14453+
" hhhhhh,\n"
14454+
" iiiiii,\n"
14455+
" jjjjjj,\n"
14456+
" kkkkkk,\n"
14457+
" aaaaa,\n"
14458+
" bbbbb,\n"
14459+
" ccccc,\n"
14460+
" ddddd,\n"
14461+
" eeeee,\n"
14462+
" ffffff,\n"
14463+
" ggggg,\n"
14464+
" hhhhhh,\n"
14465+
"};",
14466+
NoBinPacking);
14467+
1442314468
NoBinPacking.AlignAfterOpenBracket = FormatStyle::BAS_AlwaysBreak;
1442414469
verifyFormat("static uint8 CddDp83848Reg[] = {\n"
1442514470
" CDDDP83848_BMCR_REGISTER,\n"

lldb/include/lldb/ValueObject/ValueObject.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -865,17 +865,18 @@ class ValueObject {
865865

866866
virtual void SetLanguageFlags(uint64_t flags) { m_language_flags = flags; }
867867

868-
/// Returns the size of the local buffer if it's available.
868+
/// Returns the local buffer that this ValueObject points to if it's
869+
/// available.
869870
/// \return
870-
/// The size of the local buffer if this value object's value points to a
871-
/// host address, and if that size can be determined. Otherwise, returns
872-
/// LLDB_INVALID_ADDRESS.
871+
/// The local buffer if this value object's value points to a
872+
/// host address, and if that buffer can be determined. Otherwise, returns
873+
/// an empty ArrayRef.
873874
///
874875
/// TODO: Because a ValueObject's Value can point to any arbitrary memory
875-
/// location, it is possible that the size of the local buffer can't be
876-
/// determined at all. See the comment in Value::m_value for a more thorough
877-
/// explanation of why that is.
878-
uint64_t GetLocalBufferSize();
876+
/// location, it is possible that we can't find what what buffer we're
877+
/// pointing to, and thus also can't know its size. See the comment in
878+
/// Value::m_value for a more thorough explanation of why that is.
879+
llvm::ArrayRef<uint8_t> GetLocalBuffer() const;
879880

880881
protected:
881882
typedef ClusterManager<ValueObject> ValueObjectManager;

lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_loongarch64.cpp

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,23 @@
5050
#define REG_CONTEXT_SIZE \
5151
(GetGPRSize() + GetFPRSize() + sizeof(m_lsx) + sizeof(m_lasx))
5252

53+
// ptrace has a struct type user_watch_state, which was replaced by
54+
// user_watch_state_v2 when more watchpoints were added, so this file
55+
// may be built on systems with one or both in the system headers.
56+
// The type below has the same layout as user_watch_state_v2 but will
57+
// not clash with that name if it exists. We can use the v2 layout even
58+
// on old kernels as we will only see 8 watchpoints and the kernel will
59+
// truncate any extra data we send to it.
60+
struct loongarch_user_watch_state {
61+
uint64_t dbg_info;
62+
struct {
63+
uint64_t addr;
64+
uint64_t mask;
65+
uint32_t ctrl;
66+
uint32_t pad;
67+
} dbg_regs[14];
68+
};
69+
5370
using namespace lldb;
5471
using namespace lldb_private;
5572
using namespace lldb_private::process_linux;
@@ -539,7 +556,7 @@ llvm::Error NativeRegisterContextLinux_loongarch64::ReadHardwareDebugInfo() {
539556

540557
int regset = NT_LOONGARCH_HW_WATCH;
541558
struct iovec ioVec;
542-
struct user_watch_state dreg_state;
559+
struct loongarch_user_watch_state dreg_state;
543560
Status error;
544561

545562
ioVec.iov_base = &dreg_state;
@@ -567,7 +584,7 @@ llvm::Error NativeRegisterContextLinux_loongarch64::ReadHardwareDebugInfo() {
567584
llvm::Error NativeRegisterContextLinux_loongarch64::WriteHardwareDebugRegs(
568585
DREGType hwbType) {
569586
struct iovec ioVec;
570-
struct user_watch_state dreg_state;
587+
struct loongarch_user_watch_state dreg_state;
571588
int regset;
572589

573590
memset(&dreg_state, 0, sizeof(dreg_state));

lldb/source/ValueObject/ValueObject.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -849,20 +849,20 @@ bool ValueObject::SetData(DataExtractor &data, Status &error) {
849849
return true;
850850
}
851851

852-
uint64_t ValueObject::GetLocalBufferSize() {
852+
llvm::ArrayRef<uint8_t> ValueObject::GetLocalBuffer() const {
853853
if (m_value.GetValueType() != Value::ValueType::HostAddress)
854-
return LLDB_INVALID_ADDRESS;
854+
return {};
855855
auto start = m_value.GetScalar().ULongLong(LLDB_INVALID_ADDRESS);
856856
if (start == LLDB_INVALID_ADDRESS)
857-
return LLDB_INVALID_ADDRESS;
857+
return {};
858858
// Does our pointer point to this value object's m_data buffer?
859859
if ((uint64_t)m_data.GetDataStart() == start)
860-
return m_data.GetByteSize();
860+
return m_data.GetData();
861861
// Does our pointer point to the value's buffer?
862862
if ((uint64_t)m_value.GetBuffer().GetBytes() == start)
863-
return m_value.GetBuffer().GetByteSize();
863+
return m_value.GetBuffer().GetData();
864864
// Our pointer points to something else. We can't know what the size is.
865-
return LLDB_INVALID_ADDRESS;
865+
return {};
866866
}
867867

868868
static bool CopyStringDataToBufferSP(const StreamString &source,

lldb/source/ValueObject/ValueObjectDynamicValue.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ bool ValueObjectDynamicValue::UpdateValue() {
241241
SetValueDidChange(true);
242242

243243
// If we found a host address, and the dynamic type fits in the local buffer
244-
// that was found, point to thar buffer. Later on this function will copy
244+
// that was found, point to that buffer. Later on this function will copy
245245
// the buffer over.
246246
if (value_type == Value::ValueType::HostAddress && !local_buffer.empty()) {
247247
auto *exe_scope = exe_ctx.GetBestExecutionContextScope();

lldb/unittests/ValueObject/DynamicValueObjectLocalBuffer.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,8 @@ struct MockLanguageRuntime : public LanguageRuntime {
6666
*ast, "TypeWitInt", ast->GetBasicType(lldb::BasicType::eBasicTypeInt),
6767
"theIntField", LanguageType::eLanguageTypeC_plus_plus);
6868
class_type_or_name.SetCompilerType(int_type);
69-
local_buffer = {(uint8_t *)in_value.GetValue().GetScalar().ULongLong(
70-
LLDB_INVALID_ADDRESS),
71-
static_cast<size_t>(in_value.GetLocalBufferSize())};
69+
local_buffer = in_value.GetLocalBuffer();
7270
value_type = Value::ValueType::HostAddress;
73-
7471
return true;
7572
}
7673

llvm/include/llvm/CodeGen/MachineScheduler.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1385,24 +1385,6 @@ std::unique_ptr<ScheduleDAGMutation>
13851385
createCopyConstrainDAGMutation(const TargetInstrInfo *TII,
13861386
const TargetRegisterInfo *TRI);
13871387

1388-
class MachineSchedulerPass : public PassInfoMixin<MachineSchedulerPass> {
1389-
const TargetMachine *TM;
1390-
1391-
public:
1392-
MachineSchedulerPass(const TargetMachine *TM) : TM(TM) {}
1393-
PreservedAnalyses run(MachineFunction &MF,
1394-
MachineFunctionAnalysisManager &MFAM);
1395-
};
1396-
1397-
class PostMachineSchedulerPass
1398-
: public PassInfoMixin<PostMachineSchedulerPass> {
1399-
const TargetMachine *TM;
1400-
1401-
public:
1402-
PostMachineSchedulerPass(const TargetMachine *TM) : TM(TM) {}
1403-
PreservedAnalyses run(MachineFunction &MF,
1404-
MachineFunctionAnalysisManager &MFAM);
1405-
};
14061388
} // end namespace llvm
14071389

14081390
#endif // LLVM_CODEGEN_MACHINESCHEDULER_H

llvm/include/llvm/InitializePasses.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ void initializeMachinePipelinerPass(PassRegistry &);
210210
void initializeMachinePostDominatorTreeWrapperPassPass(PassRegistry &);
211211
void initializeMachineRegionInfoPassPass(PassRegistry &);
212212
void initializeMachineSanitizerBinaryMetadataPass(PassRegistry &);
213-
void initializeMachineSchedulerLegacyPass(PassRegistry &);
213+
void initializeMachineSchedulerPass(PassRegistry &);
214214
void initializeMachineSinkingPass(PassRegistry &);
215215
void initializeMachineTraceMetricsWrapperPassPass(PassRegistry &);
216216
void initializeMachineUniformityInfoPrinterPassPass(PassRegistry &);
@@ -239,7 +239,7 @@ void initializePostDomPrinterWrapperPassPass(PassRegistry &);
239239
void initializePostDomViewerWrapperPassPass(PassRegistry &);
240240
void initializePostDominatorTreeWrapperPassPass(PassRegistry &);
241241
void initializePostInlineEntryExitInstrumenterPass(PassRegistry &);
242-
void initializePostMachineSchedulerLegacyPass(PassRegistry &);
242+
void initializePostMachineSchedulerPass(PassRegistry &);
243243
void initializePostRAHazardRecognizerPass(PassRegistry &);
244244
void initializePostRAMachineSinkingPass(PassRegistry &);
245245
void initializePostRASchedulerLegacyPass(PassRegistry &);

0 commit comments

Comments
 (0)