Skip to content

Commit 35293f0

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:004c1972b4585fe8051814ceb6c6cdbf3cb62290 into amd-gfx:acd784e3612a
Local branch amd-gfx acd784e Merged main:162fa4dd25d631d0ab7816ec6081bcaff951a23c into amd-gfx:7ab2a1875722 Remote branch main 004c197 [BOLT][DWARF][NFC] Expose DebugStrOffsetsWriter::clear (llvm#82548)
2 parents acd784e + 004c197 commit 35293f0

File tree

412 files changed

+22019
-12742
lines changed

Some content is hidden

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

412 files changed

+22019
-12742
lines changed

bolt/include/bolt/Core/BinarySection.h

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,7 @@ class BinarySection {
139139
Alignment = NewAlignment;
140140
ELFType = NewELFType;
141141
ELFFlags = NewELFFlags;
142-
OutputSize = NewSize;
143-
OutputContents = StringRef(reinterpret_cast<const char *>(NewData),
144-
NewData ? NewSize : 0);
145-
IsFinalized = true;
142+
updateContents(NewData, NewSize);
146143
}
147144

148145
public:
@@ -484,9 +481,18 @@ class BinarySection {
484481
void flushPendingRelocations(raw_pwrite_stream &OS,
485482
SymbolResolverFuncTy Resolver);
486483

487-
/// Change contents of the section.
488-
void updateContents(const uint8_t *Data, size_t NewSize) {
489-
OutputContents = StringRef(reinterpret_cast<const char *>(Data), NewSize);
484+
/// Change contents of the section. Unless the section has a valid SectionID,
485+
/// the memory passed in \p NewData will be managed by the instance of
486+
/// BinarySection.
487+
void updateContents(const uint8_t *NewData, size_t NewSize) {
488+
if (getOutputData() && !hasValidSectionID() &&
489+
(!hasSectionRef() ||
490+
OutputContents.data() != getContentsOrQuit(Section).data())) {
491+
delete[] getOutputData();
492+
}
493+
494+
OutputContents = StringRef(reinterpret_cast<const char *>(NewData),
495+
NewData ? NewSize : 0);
490496
OutputSize = NewSize;
491497
IsFinalized = true;
492498
}

bolt/include/bolt/Core/DIEBuilder.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ class DIEBuilder {
124124
std::vector<std::unique_ptr<DIEAbbrev>> Abbreviations;
125125
BinaryContext &BC;
126126
DWARFContext *DwarfContext{nullptr};
127-
bool IsDWO{false};
127+
DWARFUnit *SkeletonCU{nullptr};
128128
uint64_t UnitSize{0};
129129
llvm::DenseSet<uint64_t> AllProcessed;
130130

@@ -264,8 +264,12 @@ class DIEBuilder {
264264
/// current Section.
265265
DIE *constructDIEFast(DWARFDie &DDie, DWARFUnit &U, uint32_t UnitId);
266266

267+
/// Returns true if this DIEBUilder is for DWO Unit.
268+
bool isDWO() const { return SkeletonCU != nullptr; }
269+
267270
public:
268-
DIEBuilder(BinaryContext &BC, DWARFContext *DwarfContext, bool IsDWO = false);
271+
DIEBuilder(BinaryContext &BC, DWARFContext *DwarfContext,
272+
DWARFUnit *SkeletonCU = nullptr);
269273

270274
/// Returns enum to what we are currently processing.
271275
ProcessingType getCurrentProcessingState() { return getState().Type; }

bolt/include/bolt/Core/DebugData.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,10 +450,16 @@ class DebugStrOffsetsWriter {
450450
return std::move(StrOffsetsBuffer);
451451
}
452452

453-
private:
454453
/// Initializes Buffer and Stream.
455454
void initialize(DWARFUnit &Unit);
456455

456+
/// Clear data.
457+
void clear() {
458+
IndexToAddressMap.clear();
459+
StrOffsets.clear();
460+
}
461+
462+
private:
457463
std::unique_ptr<DebugStrOffsetsBufferVector> StrOffsetsBuffer;
458464
std::unique_ptr<raw_svector_ostream> StrOffsetsStream;
459465
std::map<uint32_t, uint32_t> IndexToAddressMap;

bolt/lib/Core/BinarySection.cpp

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -190,18 +190,7 @@ void BinarySection::flushPendingRelocations(raw_pwrite_stream &OS,
190190
clearList(PendingRelocations);
191191
}
192192

193-
BinarySection::~BinarySection() {
194-
if (isReordered()) {
195-
delete[] getData();
196-
return;
197-
}
198-
199-
if (!isAllocatable() && !hasValidSectionID() &&
200-
(!hasSectionRef() ||
201-
OutputContents.data() != getContentsOrQuit(Section).data())) {
202-
delete[] getOutputData();
203-
}
204-
}
193+
BinarySection::~BinarySection() { updateContents(nullptr, 0); }
205194

206195
void BinarySection::clearRelocations() { clearList(Relocations); }
207196

bolt/lib/Core/DIEBuilder.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,8 @@ void DIEBuilder::constructFromUnit(DWARFUnit &DU) {
179179
}
180180

181181
DIEBuilder::DIEBuilder(BinaryContext &BC, DWARFContext *DwarfContext,
182-
bool IsDWO)
183-
: BC(BC), DwarfContext(DwarfContext), IsDWO(IsDWO) {}
182+
DWARFUnit *SkeletonCU)
183+
: BC(BC), DwarfContext(DwarfContext), SkeletonCU(SkeletonCU) {}
184184

185185
static unsigned int getCUNum(DWARFContext *DwarfContext, bool IsDWO) {
186186
unsigned int CUNum = IsDWO ? DwarfContext->getNumDWOCompileUnits()
@@ -204,11 +204,11 @@ void DIEBuilder::buildTypeUnits(DebugStrOffsetsWriter *StrOffsetWriter,
204204
true);
205205
}
206206
}
207-
const unsigned int CUNum = getCUNum(DwarfContext, IsDWO);
207+
const unsigned int CUNum = getCUNum(DwarfContext, isDWO());
208208
getState().CloneUnitCtxMap.resize(CUNum);
209209
DWARFContext::unit_iterator_range CU4TURanges =
210-
IsDWO ? DwarfContext->dwo_types_section_units()
211-
: DwarfContext->types_section_units();
210+
isDWO() ? DwarfContext->dwo_types_section_units()
211+
: DwarfContext->types_section_units();
212212

213213
getState().Type = ProcessingType::DWARF4TUs;
214214
for (std::unique_ptr<DWARFUnit> &DU : CU4TURanges)
@@ -218,8 +218,8 @@ void DIEBuilder::buildTypeUnits(DebugStrOffsetsWriter *StrOffsetWriter,
218218
constructFromUnit(*DU.get());
219219

220220
DWARFContext::unit_iterator_range CURanges =
221-
IsDWO ? DwarfContext->dwo_info_section_units()
222-
: DwarfContext->info_section_units();
221+
isDWO() ? DwarfContext->dwo_info_section_units()
222+
: DwarfContext->info_section_units();
223223

224224
// This handles DWARF4 CUs and DWARF5 CU/TUs.
225225
// Creating a vector so that for reference handling only DWARF5 CU/TUs are
@@ -242,11 +242,11 @@ void DIEBuilder::buildCompileUnits(const bool Init) {
242242
if (Init)
243243
BuilderState.reset(new State());
244244

245-
unsigned int CUNum = getCUNum(DwarfContext, IsDWO);
245+
unsigned int CUNum = getCUNum(DwarfContext, isDWO());
246246
getState().CloneUnitCtxMap.resize(CUNum);
247247
DWARFContext::unit_iterator_range CURanges =
248-
IsDWO ? DwarfContext->dwo_info_section_units()
249-
: DwarfContext->info_section_units();
248+
isDWO() ? DwarfContext->dwo_info_section_units()
249+
: DwarfContext->info_section_units();
250250

251251
// This handles DWARF4 CUs and DWARF5 CU/TUs.
252252
// Creating a vector so that for reference handling only DWARF5 CU/TUs are

bolt/lib/Core/DebugData.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -909,8 +909,7 @@ void DebugStrOffsetsWriter::finalizeSection(DWARFUnit &Unit,
909909
}
910910

911911
StrOffsetSectionWasModified = false;
912-
IndexToAddressMap.clear();
913-
StrOffsets.clear();
912+
clear();
914913
}
915914

916915
void DebugStrWriter::create() {

bolt/lib/Rewrite/DWARFRewriter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ void DWARFRewriter::updateDebugInfo() {
709709
: LegacyRangesSectionWriter.get();
710710
// Skipping CUs that failed to load.
711711
if (SplitCU) {
712-
DIEBuilder DWODIEBuilder(BC, &(*SplitCU)->getContext(), true);
712+
DIEBuilder DWODIEBuilder(BC, &(*SplitCU)->getContext(), Unit);
713713
DWODIEBuilder.buildDWOUnit(**SplitCU);
714714
std::string DWOName = updateDWONameCompDir(
715715
*Unit, *DIEBlder, *DIEBlder->getUnitDIEbyUnit(*Unit));

bolt/lib/Rewrite/RewriteInstance.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4092,12 +4092,9 @@ void RewriteInstance::rewriteNoteSections() {
40924092
return getNewValueForSymbol(S->getName());
40934093
});
40944094

4095-
// Set/modify section info.
4096-
BinarySection &NewSection = BC->registerOrUpdateNoteSection(
4097-
SectionName, SectionData, Size, Section.sh_addralign,
4098-
!BSec->isWritable(), BSec->getELFType());
4099-
NewSection.setOutputAddress(0);
4100-
NewSection.setOutputFileOffset(NextAvailableOffset);
4095+
// Section contents are no longer needed, but we need to update the size so
4096+
// that it will be reflected in the section header table.
4097+
BSec->updateContents(nullptr, Size);
41014098

41024099
NextAvailableOffset += Size;
41034100
}

bolt/unittests/Core/BinaryContext.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,11 @@ TEST_P(BinaryContextTester, FlushPendingRelocCALL26) {
7777
// 12: bl func2
7878
// 16: func2
7979

80-
char Data[20] = {};
80+
constexpr size_t DataSize = 20;
81+
uint8_t *Data = new uint8_t[DataSize];
8182
BinarySection &BS = BC->registerOrUpdateSection(
82-
".text", ELF::SHT_PROGBITS, ELF::SHF_EXECINSTR | ELF::SHF_ALLOC,
83-
(uint8_t *)Data, sizeof(Data), 4);
83+
".text", ELF::SHT_PROGBITS, ELF::SHF_EXECINSTR | ELF::SHF_ALLOC, Data,
84+
DataSize, 4);
8485
MCSymbol *RelSymbol1 = BC->getOrCreateGlobalSymbol(4, "Func1");
8586
ASSERT_TRUE(RelSymbol1);
8687
BS.addRelocation(8, RelSymbol1, ELF::R_AARCH64_CALL26, 0, 0, true);
@@ -89,7 +90,7 @@ TEST_P(BinaryContextTester, FlushPendingRelocCALL26) {
8990
BS.addRelocation(12, RelSymbol2, ELF::R_AARCH64_CALL26, 0, 0, true);
9091

9192
std::error_code EC;
92-
SmallVector<char> Vect(sizeof(Data));
93+
SmallVector<char> Vect(DataSize);
9394
raw_svector_ostream OS(Vect);
9495

9596
BS.flushPendingRelocations(OS, [&](const MCSymbol *S) {

clang/docs/ReleaseNotes.rst

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -62,21 +62,6 @@ Clang Frontend Potentially Breaking Changes
6262
of ``-Wno-gnu-binary-literal`` will no longer silence this pedantic warning,
6363
which may break existing uses with ``-Werror``.
6464

65-
Target OS macros extension
66-
^^^^^^^^^^^^^^^^^^^^^^^^^^
67-
A new Clang extension (see :ref:`here <target_os_detail>`) is enabled for
68-
Darwin (Apple platform) targets. Clang now defines ``TARGET_OS_*`` macros for
69-
these targets, which could break existing code bases with improper checks for
70-
the ``TARGET_OS_`` macros. For example, existing checks might fail to include
71-
the ``TargetConditionals.h`` header from Apple SDKs and therefore leaving the
72-
macros undefined and guarded code unexercised.
73-
74-
Affected code should be checked to see if it's still intended for the specific
75-
target and fixed accordingly.
76-
77-
The extension can be turned off by the option ``-fno-define-target-os-macros``
78-
as a workaround.
79-
8065
What's New in Clang |release|?
8166
==============================
8267
Some of the major new features and improvements to Clang are listed
@@ -161,17 +146,6 @@ Non-comprehensive list of changes in this release
161146
New Compiler Flags
162147
------------------
163148

164-
.. _target_os_detail:
165-
166-
Target OS macros extension
167-
^^^^^^^^^^^^^^^^^^^^^^^^^^
168-
A pair of new flags ``-fdefine-target-os-macros`` and
169-
``-fno-define-target-os-macros`` has been added to Clang to enable/disable the
170-
extension to provide built-in definitions of a list of ``TARGET_OS_*`` macros
171-
based on the target triple.
172-
173-
The extension is enabled by default for Darwin (Apple platform) targets.
174-
175149
Deprecated Compiler Flags
176150
-------------------------
177151

@@ -297,6 +271,10 @@ Bug Fixes to C++ Support
297271
was only accepted at namespace scope but not at local function scope.
298272
- Clang no longer tries to call consteval constructors at runtime when they appear in a member initializer.
299273
(`#782154 <https://github.com/llvm/llvm-project/issues/82154>`_`)
274+
- Fix crash when using an immediate-escalated function at global scope.
275+
(`#82258 <https://github.com/llvm/llvm-project/issues/82258>`_)
276+
- Correctly immediate-escalate lambda conversion functions.
277+
(`#82258 <https://github.com/llvm/llvm-project/issues/82258>`_)
300278

301279
Bug Fixes to AST Handling
302280
^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -404,6 +382,14 @@ Moved checkers
404382
Sanitizers
405383
----------
406384

385+
- ``-fsanitize=signed-integer-overflow`` now instruments signed arithmetic even
386+
when ``-fwrapv`` is enabled. Previously, only division checks were enabled.
387+
388+
Users with ``-fwrapv`` as well as a sanitizer group like
389+
``-fsanitize=undefined`` or ``-fsanitize=integer`` enabled may want to
390+
manually disable potentially noisy signed integer overflow checks with
391+
``-fno-sanitize=signed-integer-overflow``
392+
407393
Python Binding Changes
408394
----------------------
409395

clang/docs/UndefinedBehaviorSanitizer.rst

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,11 @@ Available checks are:
190190
- ``-fsanitize=signed-integer-overflow``: Signed integer overflow, where the
191191
result of a signed integer computation cannot be represented in its type.
192192
This includes all the checks covered by ``-ftrapv``, as well as checks for
193-
signed division overflow (``INT_MIN/-1``), but not checks for
194-
lossy implicit conversions performed before the computation
195-
(see ``-fsanitize=implicit-conversion``). Both of these two issues are
196-
handled by ``-fsanitize=implicit-conversion`` group of checks.
193+
signed division overflow (``INT_MIN/-1``). Note that checks are still
194+
added even when ``-fwrapv`` is enabled. This sanitizer does not check for
195+
lossy implicit conversions performed before the computation (see
196+
``-fsanitize=implicit-conversion``). Both of these two issues are handled
197+
by ``-fsanitize=implicit-conversion`` group of checks.
197198
- ``-fsanitize=unreachable``: If control flow reaches an unreachable
198199
program point.
199200
- ``-fsanitize=unsigned-integer-overflow``: Unsigned integer overflow, where

clang/include/clang/Basic/DiagnosticDriverKinds.td

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,4 @@ def warn_android_unversioned_fallback : Warning<
804804

805805
def err_drv_triple_version_invalid : Error<
806806
"version '%0' in target triple '%1' is invalid">;
807-
808-
def err_drv_installapi_unsupported : Error<
809-
"InstallAPI is not supported for '%0'">;
810807
}

clang/include/clang/Driver/Action.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ class Action {
5959
PreprocessJobClass,
6060
PrecompileJobClass,
6161
ExtractAPIJobClass,
62-
InstallAPIJobClass,
6362
AnalyzeJobClass,
6463
MigrateJobClass,
6564
CompileJobClass,
@@ -449,17 +448,6 @@ class ExtractAPIJobAction : public JobAction {
449448
void addHeaderInput(Action *Input) { getInputs().push_back(Input); }
450449
};
451450

452-
class InstallAPIJobAction : public JobAction {
453-
void anchor() override;
454-
455-
public:
456-
InstallAPIJobAction(Action *Input, types::ID OutputType);
457-
458-
static bool classof(const Action *A) {
459-
return A->getKind() == InstallAPIJobClass;
460-
}
461-
};
462-
463451
class AnalyzeJobAction : public JobAction {
464452
void anchor() override;
465453

clang/include/clang/Driver/Options.td

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,6 @@ class AnalyzerOpts<string base>
336336
: KeyPathAndMacro<"AnalyzerOpts->", base, "ANALYZER_"> {}
337337
class MigratorOpts<string base>
338338
: KeyPathAndMacro<"MigratorOpts.", base, "MIGRATOR_"> {}
339-
class InstallAPIOpts<string base>
340-
: KeyPathAndMacro<"InstallAPIOpts.", base, "INSTALLAPI_"> {}
341339

342340
// A boolean option which is opt-in in CC1. The positive option exists in CC1 and
343341
// Args.hasArg(OPT_ffoo) can be used to check that the flag is enabled.
@@ -1143,8 +1141,7 @@ def config_user_dir_EQ : Joined<["--"], "config-user-dir=">,
11431141
def coverage : Flag<["-", "--"], "coverage">, Group<Link_Group>,
11441142
Visibility<[ClangOption, CLOption]>;
11451143
def cpp_precomp : Flag<["-"], "cpp-precomp">, Group<clang_ignored_f_Group>;
1146-
def current__version : JoinedOrSeparate<["-"], "current_version">,
1147-
Visibility<[ClangOption, CC1Option]>;
1144+
def current__version : JoinedOrSeparate<["-"], "current_version">;
11481145
def cxx_isystem : JoinedOrSeparate<["-"], "cxx-isystem">, Group<clang_i_Group>,
11491146
HelpText<"Add directory to the C++ SYSTEM include search path">,
11501147
Visibility<[ClangOption, CC1Option]>,
@@ -1559,9 +1556,6 @@ def static_libsan : Flag<["-"], "static-libsan">,
15591556
HelpText<"Statically link the sanitizer runtime (Not supported for ASan, TSan or UBSan on darwin)">;
15601557
def : Flag<["-"], "shared-libasan">, Alias<shared_libsan>;
15611558
def fasm : Flag<["-"], "fasm">, Group<f_Group>;
1562-
def installapi : Flag<["-"], "installapi">,
1563-
Visibility<[ClangOption, CC1Option]>, Group<Action_Group>,
1564-
HelpText<"Create a text-based stub file by scanning header files">;
15651559

15661560
defm assume_unique_vtables : BoolFOption<"assume-unique-vtables",
15671561
CodeGenOpts<"AssumeUniqueVTables">, DefaultTrue,
@@ -4320,9 +4314,7 @@ def verify_pch : Flag<["-"], "verify-pch">, Group<Action_Group>,
43204314
Visibility<[ClangOption, CC1Option]>,
43214315
HelpText<"Load and verify that a pre-compiled header file is not stale">;
43224316
def init : Separate<["-"], "init">;
4323-
def install__name : Separate<["-"], "install_name">,
4324-
Visibility<[ClangOption, CC1Option]>,
4325-
MarshallingInfoString<InstallAPIOpts<"InstallName">>;
4317+
def install__name : Separate<["-"], "install_name">;
43264318
def iprefix : JoinedOrSeparate<["-"], "iprefix">, Group<clang_i_Group>,
43274319
Visibility<[ClangOption, CC1Option]>,
43284320
HelpText<"Set the -iwithprefix/-iwithprefixbefore prefix">, MetaVarName<"<dir>">;

clang/include/clang/Driver/Types.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ TYPE("lto-bc", LTO_BC, INVALID, "o", phases
9494
TYPE("ast", AST, INVALID, "ast", phases::Compile, phases::Backend, phases::Assemble, phases::Link)
9595
TYPE("ifs", IFS, INVALID, "ifs", phases::IfsMerge)
9696
TYPE("ifs-cpp", IFS_CPP, INVALID, "ifs", phases::Compile, phases::IfsMerge)
97-
TYPE("tbd", TextAPI, INVALID, "tbd", phases::Precompile)
9897
TYPE("pcm", ModuleFile, INVALID, "pcm", phases::Compile, phases::Backend, phases::Assemble, phases::Link)
9998
TYPE("header-unit", HeaderUnit, INVALID, "pcm", phases::Compile, phases::Backend, phases::Assemble, phases::Link)
10099
TYPE("plist", Plist, INVALID, "plist", phases::Compile, phases::Backend, phases::Assemble, phases::Link)

clang/include/clang/Frontend/CompilerInstance.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -294,13 +294,6 @@ class CompilerInstance : public ModuleLoader {
294294
return Invocation->getFrontendOpts();
295295
}
296296

297-
InstallAPIOptions &getInstallAPIOpts() {
298-
return Invocation->getInstallAPIOpts();
299-
}
300-
const InstallAPIOptions &getInstallAPIOpts() const {
301-
return Invocation->getInstallAPIOpts();
302-
}
303-
304297
HeaderSearchOptions &getHeaderSearchOpts() {
305298
return Invocation->getHeaderSearchOpts();
306299
}

0 commit comments

Comments
 (0)