Skip to content
This repository was archived by the owner on Sep 15, 2025. It is now read-only.

Commit 4d6e798

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:3efa4794ecd5 into amd-gfx:b77230b05ebd
Local branch amd-gfx b77230b Revert "Revert "ConstantFolding: Constant fold denormal inputs to canonicalize for IEEE"" Remote branch main 3efa479 [clang][Interp] Support AddOffset with 128bit offsets (llvm#68679)
2 parents b77230b + 3efa479 commit 4d6e798

File tree

1,743 files changed

+120311
-42666
lines changed

Some content is hidden

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

1,743 files changed

+120311
-42666
lines changed

.github/CODEOWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,5 @@
3030
/clang/test/CXX/drs/ @Endilll
3131
/clang/www/cxx_dr_status.html @Endilll
3232
/clang/www/make_cxx_dr_status @Endilll
33+
34+
/lldb/ @JDevlieghere

bolt/include/bolt/Core/BinaryFunction.h

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,6 @@ class BinaryFunction {
192192
static constexpr uint64_t COUNT_NO_PROFILE =
193193
BinaryBasicBlock::COUNT_NO_PROFILE;
194194

195-
/// We have to use at least 2-byte alignment for functions because of C++ ABI.
196-
static constexpr unsigned MinAlign = 2;
197-
198195
static const char TimerGroupName[];
199196
static const char TimerGroupDesc[];
200197

@@ -1720,8 +1717,24 @@ class BinaryFunction {
17201717
return *this;
17211718
}
17221719

1723-
Align getAlign() const { return Align(Alignment); }
1720+
uint16_t getMinAlignment() const {
1721+
// Align data in code BFs minimum to CI alignment
1722+
if (!size() && hasIslandsInfo())
1723+
return getConstantIslandAlignment();
1724+
1725+
// Minimal code alignment on AArch64 and RISCV is 4
1726+
if (BC.isAArch64() || BC.isRISCV())
1727+
return 4;
1728+
1729+
// We have to use at least 2-byte alignment for functions because
1730+
// of C++ ABI.
1731+
return 2;
1732+
}
1733+
1734+
Align getMinAlign() const { return Align(getMinAlignment()); }
1735+
17241736
uint16_t getAlignment() const { return Alignment; }
1737+
Align getAlign() const { return Align(getAlignment()); }
17251738

17261739
BinaryFunction &setMaxAlignmentBytes(uint16_t MaxAlignBytes) {
17271740
MaxAlignmentBytes = MaxAlignBytes;

bolt/include/bolt/Core/MCPlusBuilder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1185,7 +1185,7 @@ class MCPlusBuilder {
11851185

11861186
/// Set the label of \p Inst. This label will be emitted right before \p Inst
11871187
/// is emitted to MCStreamer.
1188-
bool setLabel(MCInst &Inst, MCSymbol *Label);
1188+
bool setLabel(MCInst &Inst, MCSymbol *Label, AllocatorIdTy AllocatorId = 0);
11891189

11901190
/// Return MCSymbol that represents a target of this instruction at a given
11911191
/// operand number \p OpNum. If there's no symbol associated with

bolt/lib/Core/BinaryContext.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1803,6 +1803,10 @@ MarkerSymType BinaryContext::getMarkerType(const SymbolRef &Symbol) const {
18031803
if (*NameOrError == "$x" || NameOrError->startswith("$x."))
18041804
return MarkerSymType::CODE;
18051805

1806+
// $x<ISA>
1807+
if (isRISCV() && NameOrError->startswith("$x"))
1808+
return MarkerSymType::CODE;
1809+
18061810
if (*NameOrError == "$d" || NameOrError->startswith("$d."))
18071811
return MarkerSymType::DATA;
18081812

bolt/lib/Core/BinaryEmitter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ bool BinaryEmitter::emitFunction(BinaryFunction &Function,
309309
// tentative layout.
310310
Section->ensureMinAlignment(Align(opts::AlignFunctions));
311311

312-
Streamer.emitCodeAlignment(Align(BinaryFunction::MinAlign), &*BC.STI);
312+
Streamer.emitCodeAlignment(Function.getMinAlign(), &*BC.STI);
313313
uint16_t MaxAlignBytes = FF.isSplitFragment()
314314
? Function.getMaxColdAlignmentBytes()
315315
: Function.getMaxAlignmentBytes();

bolt/lib/Core/BinaryFunction.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,6 @@ bool shouldPrint(const BinaryFunction &Function) {
164164
namespace llvm {
165165
namespace bolt {
166166

167-
constexpr unsigned BinaryFunction::MinAlign;
168-
169167
template <typename R> static bool emptyRange(const R &Range) {
170168
return Range.begin() == Range.end();
171169
}

bolt/lib/Core/DebugData.cpp

Lines changed: 49 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,14 @@ writeAddressRanges(raw_svector_ostream &Stream,
124124
const DebugAddressRangesVector &AddressRanges,
125125
const bool WriteRelativeRanges = false) {
126126
for (const DebugAddressRange &Range : AddressRanges) {
127-
support::endian::write(Stream, Range.LowPC, support::little);
127+
support::endian::write(Stream, Range.LowPC, llvm::endianness::little);
128128
support::endian::write(
129129
Stream, WriteRelativeRanges ? Range.HighPC - Range.LowPC : Range.HighPC,
130-
support::little);
130+
llvm::endianness::little);
131131
}
132132
// Finish with 0 entries.
133-
support::endian::write(Stream, 0ULL, support::little);
134-
support::endian::write(Stream, 0ULL, support::little);
133+
support::endian::write(Stream, 0ULL, llvm::endianness::little);
134+
support::endian::write(Stream, 0ULL, llvm::endianness::little);
135135
return AddressRanges.size() * 16 + 16;
136136
}
137137

@@ -209,13 +209,15 @@ getDWARF5Header(const LocListsRangelistsHeader &Header) {
209209
getDWARF5RngListLocListHeaderSize() - sizeof(UnitLengthType);
210210

211211
support::endian::write(*HeaderStream, Header.UnitLength + HeaderSize,
212-
support::little);
213-
support::endian::write(*HeaderStream, Header.Version, support::little);
214-
support::endian::write(*HeaderStream, Header.AddressSize, support::little);
212+
llvm::endianness::little);
213+
support::endian::write(*HeaderStream, Header.Version,
214+
llvm::endianness::little);
215+
support::endian::write(*HeaderStream, Header.AddressSize,
216+
llvm::endianness::little);
215217
support::endian::write(*HeaderStream, Header.SegmentSelector,
216-
support::little);
218+
llvm::endianness::little);
217219
support::endian::write(*HeaderStream, Header.OffsetEntryCount,
218-
support::little);
220+
llvm::endianness::little);
219221
return HeaderBuffer;
220222
}
221223

@@ -254,17 +256,18 @@ static bool emitWithBase(raw_ostream &OS, const DebugVector &Entries,
254256
}
255257

256258
support::endian::write(OS, static_cast<uint8_t>(BaseAddressx),
257-
support::little);
259+
llvm::endianness::little);
258260
uint32_t BaseIndex = AddrWriter.getIndexFromAddress(Base, CU);
259261
encodeULEB128(BaseIndex, OS);
260262
for (auto &OffsetEntry : Offsets) {
261263
support::endian::write(OS, static_cast<uint8_t>(OffsetPair),
262-
support::little);
264+
llvm::endianness::little);
263265
encodeULEB128(OffsetEntry.StartOffset, OS);
264266
encodeULEB128(OffsetEntry.EndOffset, OS);
265267
Func(OffsetEntry.Index);
266268
}
267-
support::endian::write(OS, static_cast<uint8_t>(EndOfList), support::little);
269+
support::endian::write(OS, static_cast<uint8_t>(EndOfList),
270+
llvm::endianness::little);
268271
return true;
269272
}
270273

@@ -291,7 +294,7 @@ DebugRangeListsSectionWriter::addRanges(DebugAddressRangesVector &Ranges) {
291294
const DebugAddressRange &Range = Ranges[I];
292295
support::endian::write(*CUBodyStream,
293296
static_cast<uint8_t>(dwarf::DW_RLE_startx_length),
294-
support::little);
297+
llvm::endianness::little);
295298
uint32_t Index = AddrWriter->getIndexFromAddress(Range.LowPC, *CU);
296299
encodeULEB128(Index, *CUBodyStream);
297300
encodeULEB128(Range.HighPC - Range.LowPC, *CUBodyStream);
@@ -301,7 +304,7 @@ DebugRangeListsSectionWriter::addRanges(DebugAddressRangesVector &Ranges) {
301304
if (WrittenStartxLength)
302305
support::endian::write(*CUBodyStream,
303306
static_cast<uint8_t>(dwarf::DW_RLE_end_of_list),
304-
support::little);
307+
llvm::endianness::little);
305308
CurrentOffset = CUBodyBuffer->size();
306309
return RangeEntries.size() - 1;
307310
}
@@ -315,7 +318,7 @@ void DebugRangeListsSectionWriter::finalizeSection() {
315318
const uint32_t SizeOfArraySection = RangeEntries.size() * SizeOfArrayEntry;
316319
for (uint32_t Offset : RangeEntries)
317320
support::endian::write(*CUArrayStream, Offset + SizeOfArraySection,
318-
support::little);
321+
llvm::endianness::little);
319322

320323
std::unique_ptr<DebugBufferVector> Header = getDWARF5Header(
321324
{static_cast<uint32_t>(SizeOfArraySection + CUBodyBuffer.get()->size()),
@@ -359,17 +362,17 @@ void DebugARangesSectionWriter::writeARangesSection(
359362
uint32_t Size = 8 + 4 + 2 * sizeof(uint64_t) * (AddressRanges.size() + 1);
360363

361364
// Header field #1: set size.
362-
support::endian::write(RangesStream, Size, support::little);
365+
support::endian::write(RangesStream, Size, llvm::endianness::little);
363366

364367
// Header field #2: version number, 2 as per the specification.
365368
support::endian::write(RangesStream, static_cast<uint16_t>(2),
366-
support::little);
369+
llvm::endianness::little);
367370

368371
assert(CUMap.count(Offset) && "Original CU offset is not found in CU Map");
369372
// Header field #3: debug info offset of the correspondent compile unit.
370373
support::endian::write(
371374
RangesStream, static_cast<uint32_t>(CUMap.find(Offset)->second.Offset),
372-
support::little);
375+
llvm::endianness::little);
373376

374377
// Header field #4: address size.
375378
// 8 since we only write ELF64 binaries for now.
@@ -380,7 +383,7 @@ void DebugARangesSectionWriter::writeARangesSection(
380383

381384
// Padding before address table - 4 bytes in the 64-bit-pointer case.
382385
support::endian::write(RangesStream, static_cast<uint32_t>(0),
383-
support::little);
386+
llvm::endianness::little);
384387

385388
writeAddressRanges(RangesStream, AddressRanges, true);
386389
}
@@ -473,10 +476,10 @@ void DebugAddrWriter::update(DIEBuilder &DIEBlder, DWARFUnit &CU) {
473476
break;
474477
case 4:
475478
support::endian::write(*AddressStream, static_cast<uint32_t>(Address),
476-
support::little);
479+
llvm::endianness::little);
477480
break;
478481
case 8:
479-
support::endian::write(*AddressStream, Address, support::little);
482+
support::endian::write(*AddressStream, Address, llvm::endianness::little);
480483
break;
481484
}
482485
};
@@ -492,11 +495,12 @@ void DebugAddrWriter::update(DIEBuilder &DIEBlder, DWARFUnit &CU) {
492495
void DebugAddrWriterDwarf5::update(DIEBuilder &DIEBlder, DWARFUnit &CU) {
493496
// Need to layout all sections within .debug_addr
494497
// Within each section sort Address by index.
495-
const endianness Endian =
496-
BC->DwCtx->isLittleEndian() ? support::little : support::big;
498+
const endianness Endian = BC->DwCtx->isLittleEndian()
499+
? llvm::endianness::little
500+
: llvm::endianness::big;
497501
const DWARFSection &AddrSec = BC->DwCtx->getDWARFObj().getAddrSection();
498502
DWARFDataExtractor AddrData(BC->DwCtx->getDWARFObj(), AddrSec,
499-
Endian == support::little, 0);
503+
Endian == llvm::endianness::little, 0);
500504
DWARFDebugAddrTable AddrTable;
501505
DIDumpOptions DumpOpts;
502506
constexpr uint32_t HeaderSize = 8;
@@ -594,11 +598,11 @@ void DebugLocWriter::addList(DIEBuilder &DIEBldr, DIE &Die, DIEValue &AttrInfo,
594598

595599
for (const DebugLocationEntry &Entry : LocList) {
596600
support::endian::write(*LocStream, static_cast<uint64_t>(Entry.LowPC),
597-
support::little);
601+
llvm::endianness::little);
598602
support::endian::write(*LocStream, static_cast<uint64_t>(Entry.HighPC),
599-
support::little);
603+
llvm::endianness::little);
600604
support::endian::write(*LocStream, static_cast<uint16_t>(Entry.Expr.size()),
601-
support::little);
605+
llvm::endianness::little);
602606
*LocStream << StringRef(reinterpret_cast<const char *>(Entry.Expr.data()),
603607
Entry.Expr.size());
604608
LocSectionOffset += 2 * 8 + 2 + Entry.Expr.size();
@@ -618,15 +622,17 @@ std::unique_ptr<DebugBufferVector> DebugLocWriter::getBuffer() {
618622
void DebugLocWriter::finalize(DIEBuilder &DIEBldr, DIE &Die) {}
619623

620624
static void writeEmptyListDwarf5(raw_svector_ostream &Stream) {
621-
support::endian::write(Stream, static_cast<uint32_t>(4), support::little);
625+
support::endian::write(Stream, static_cast<uint32_t>(4),
626+
llvm::endianness::little);
622627
support::endian::write(Stream, static_cast<uint8_t>(dwarf::DW_LLE_start_end),
623-
support::little);
628+
llvm::endianness::little);
624629

625630
const char Zeroes[16] = {0};
626631
Stream << StringRef(Zeroes, 16);
627632
encodeULEB128(0, Stream);
628-
support::endian::write(
629-
Stream, static_cast<uint8_t>(dwarf::DW_LLE_end_of_list), support::little);
633+
support::endian::write(Stream,
634+
static_cast<uint8_t>(dwarf::DW_LLE_end_of_list),
635+
llvm::endianness::little);
630636
}
631637

632638
static void writeLegacyLocList(DIEValue &AttrInfo,
@@ -645,21 +651,21 @@ static void writeLegacyLocList(DIEValue &AttrInfo,
645651
for (const DebugLocationEntry &Entry : LocList) {
646652
support::endian::write(LocStream,
647653
static_cast<uint8_t>(dwarf::DW_LLE_startx_length),
648-
support::little);
654+
llvm::endianness::little);
649655
const uint32_t Index = AddrWriter.getIndexFromAddress(Entry.LowPC, CU);
650656
encodeULEB128(Index, LocStream);
651657

652658
support::endian::write(LocStream,
653659
static_cast<uint32_t>(Entry.HighPC - Entry.LowPC),
654-
support::little);
660+
llvm::endianness::little);
655661
support::endian::write(LocStream, static_cast<uint16_t>(Entry.Expr.size()),
656-
support::little);
662+
llvm::endianness::little);
657663
LocStream << StringRef(reinterpret_cast<const char *>(Entry.Expr.data()),
658664
Entry.Expr.size());
659665
}
660666
support::endian::write(LocStream,
661667
static_cast<uint8_t>(dwarf::DW_LLE_end_of_list),
662-
support::little);
668+
llvm::endianness::little);
663669
replaceLocValbyForm(DIEBldr, Die, AttrInfo, AttrInfo.getForm(), EntryOffset);
664670
}
665671

@@ -701,7 +707,7 @@ static void writeDWARF5LocList(uint32_t &NumberOfEntries, DIEValue &AttrInfo,
701707
const DebugLocationEntry &Entry = LocList[I];
702708
support::endian::write(LocBodyStream,
703709
static_cast<uint8_t>(dwarf::DW_LLE_startx_length),
704-
support::little);
710+
llvm::endianness::little);
705711
const uint32_t Index = AddrWriter.getIndexFromAddress(Entry.LowPC, CU);
706712
encodeULEB128(Index, LocBodyStream);
707713
encodeULEB128(Entry.HighPC - Entry.LowPC, LocBodyStream);
@@ -713,7 +719,7 @@ static void writeDWARF5LocList(uint32_t &NumberOfEntries, DIEValue &AttrInfo,
713719
if (WrittenStartxLength)
714720
support::endian::write(LocBodyStream,
715721
static_cast<uint8_t>(dwarf::DW_LLE_end_of_list),
716-
support::little);
722+
llvm::endianness::little);
717723
}
718724

719725
void DebugLoclistWriter::addList(DIEBuilder &DIEBldr, DIE &Die,
@@ -753,7 +759,7 @@ void DebugLoclistWriter::finalizeDWARF5(DIEBuilder &DIEBldr, DIE &Die) {
753759
support::endian::write(
754760
*LocArrayStream,
755761
static_cast<uint32_t>(SizeOfArraySection + RelativeOffset),
756-
support::little);
762+
llvm::endianness::little);
757763

758764
std::unique_ptr<DebugBufferVector> Header = getDWARF5Header(
759765
{static_cast<uint32_t>(SizeOfArraySection + LocBodyBuffer.get()->size()),
@@ -884,11 +890,11 @@ void DebugStrOffsetsWriter::finalizeSection(DWARFUnit &Unit,
884890
if (RetVal == ProcessedBaseOffsets.end() || StrOffsetSectionWasModified) {
885891
// Writing out the header for each section.
886892
support::endian::write(*StrOffsetsStream, CurrentSectionSize + 4,
887-
support::little);
893+
llvm::endianness::little);
888894
support::endian::write(*StrOffsetsStream, static_cast<uint16_t>(5),
889-
support::little);
895+
llvm::endianness::little);
890896
support::endian::write(*StrOffsetsStream, static_cast<uint16_t>(0),
891-
support::little);
897+
llvm::endianness::little);
892898

893899
uint64_t BaseOffset = StrOffsetsBuffer->size();
894900
ProcessedBaseOffsets[*Val] = BaseOffset;
@@ -897,7 +903,8 @@ void DebugStrOffsetsWriter::finalizeSection(DWARFUnit &Unit,
897903
StrListBaseAttrInfo.getForm(),
898904
DIEInteger(BaseOffset));
899905
for (const auto &Entry : IndexToAddressMap)
900-
support::endian::write(*StrOffsetsStream, Entry.second, support::little);
906+
support::endian::write(*StrOffsetsStream, Entry.second,
907+
llvm::endianness::little);
901908
} else {
902909
DIEBldr.replaceValue(&Die, dwarf::DW_AT_str_offsets_base,
903910
StrListBaseAttrInfo.getForm(),

bolt/lib/Core/MCPlusBuilder.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,10 @@ std::optional<MCSymbol *> MCPlusBuilder::getLabel(const MCInst &Inst) const {
274274
return std::nullopt;
275275
}
276276

277-
bool MCPlusBuilder::setLabel(MCInst &Inst, MCSymbol *Label) {
278-
getOrCreateAnnotationAs<MCSymbol *>(Inst, MCAnnotation::kLabel) = Label;
277+
bool MCPlusBuilder::setLabel(MCInst &Inst, MCSymbol *Label,
278+
AllocatorIdTy AllocatorId) {
279+
getOrCreateAnnotationAs<MCSymbol *>(Inst, MCAnnotation::kLabel, AllocatorId) =
280+
Label;
279281
return true;
280282
}
281283

bolt/lib/Passes/Aligner.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -158,22 +158,6 @@ void AlignerPass::runOnFunctions(BinaryContext &BC) {
158158
BinaryContext::IndependentCodeEmitter Emitter =
159159
BC.createIndependentMCCodeEmitter();
160160

161-
// Align objects that contains constant islands and no code
162-
// to at least 8 bytes.
163-
if (!BF.size() && BF.hasIslandsInfo()) {
164-
uint16_t Alignment = BF.getConstantIslandAlignment();
165-
// Check if we're forcing output alignment and it is greater than minimal
166-
// CI required one
167-
if (!opts::UseCompactAligner && Alignment < opts::AlignFunctions &&
168-
opts::AlignFunctions <= opts::AlignFunctionsMaxBytes)
169-
Alignment = opts::AlignFunctions;
170-
171-
BF.setAlignment(Alignment);
172-
BF.setMaxAlignmentBytes(Alignment);
173-
BF.setMaxColdAlignmentBytes(Alignment);
174-
return;
175-
}
176-
177161
if (opts::UseCompactAligner)
178162
alignCompact(BF, Emitter.MCE.get());
179163
else

bolt/lib/Passes/BinaryPasses.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,8 +619,11 @@ void LowerAnnotations::runOnFunctions(BinaryContext &BC) {
619619
}
620620
for (BinaryFunction *BF : BC.getInjectedBinaryFunctions())
621621
for (BinaryBasicBlock &BB : *BF)
622-
for (MCInst &Instruction : BB)
622+
for (MCInst &Instruction : BB) {
623+
if (auto Label = BC.MIB->getLabel(Instruction))
624+
PreservedLabelAnnotations.emplace_back(&Instruction, *Label);
623625
BC.MIB->stripAnnotations(Instruction);
626+
}
624627

625628
// Release all memory taken by annotations
626629
BC.MIB->freeAnnotations();

0 commit comments

Comments
 (0)