Skip to content

Commit

Permalink
merge main into amd-staging
Browse files Browse the repository at this point in the history
Change-Id: I8afd2fe4ff9b265d9f77005d9093ad0987768d0c
  • Loading branch information
ronlieb committed Feb 22, 2024
2 parents dbb7ac6 + bc1c86b commit 1af3232
Show file tree
Hide file tree
Showing 557 changed files with 38,533 additions and 22,633 deletions.
20 changes: 13 additions & 7 deletions bolt/include/bolt/Core/BinarySection.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,7 @@ class BinarySection {
Alignment = NewAlignment;
ELFType = NewELFType;
ELFFlags = NewELFFlags;
OutputSize = NewSize;
OutputContents = StringRef(reinterpret_cast<const char *>(NewData),
NewData ? NewSize : 0);
IsFinalized = true;
updateContents(NewData, NewSize);
}

public:
Expand Down Expand Up @@ -484,9 +481,18 @@ class BinarySection {
void flushPendingRelocations(raw_pwrite_stream &OS,
SymbolResolverFuncTy Resolver);

/// Change contents of the section.
void updateContents(const uint8_t *Data, size_t NewSize) {
OutputContents = StringRef(reinterpret_cast<const char *>(Data), NewSize);
/// Change contents of the section. Unless the section has a valid SectionID,
/// the memory passed in \p NewData will be managed by the instance of
/// BinarySection.
void updateContents(const uint8_t *NewData, size_t NewSize) {
if (getOutputData() && !hasValidSectionID() &&
(!hasSectionRef() ||
OutputContents.data() != getContentsOrQuit(Section).data())) {
delete[] getOutputData();
}

OutputContents = StringRef(reinterpret_cast<const char *>(NewData),
NewData ? NewSize : 0);
OutputSize = NewSize;
IsFinalized = true;
}
Expand Down
8 changes: 6 additions & 2 deletions bolt/include/bolt/Core/DIEBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class DIEBuilder {
std::vector<std::unique_ptr<DIEAbbrev>> Abbreviations;
BinaryContext &BC;
DWARFContext *DwarfContext{nullptr};
bool IsDWO{false};
DWARFUnit *SkeletonCU{nullptr};
uint64_t UnitSize{0};
llvm::DenseSet<uint64_t> AllProcessed;

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

/// Returns true if this DIEBUilder is for DWO Unit.
bool isDWO() const { return SkeletonCU != nullptr; }

public:
DIEBuilder(BinaryContext &BC, DWARFContext *DwarfContext, bool IsDWO = false);
DIEBuilder(BinaryContext &BC, DWARFContext *DwarfContext,
DWARFUnit *SkeletonCU = nullptr);

/// Returns enum to what we are currently processing.
ProcessingType getCurrentProcessingState() { return getState().Type; }
Expand Down
8 changes: 7 additions & 1 deletion bolt/include/bolt/Core/DebugData.h
Original file line number Diff line number Diff line change
Expand Up @@ -450,10 +450,16 @@ class DebugStrOffsetsWriter {
return std::move(StrOffsetsBuffer);
}

private:
/// Initializes Buffer and Stream.
void initialize(DWARFUnit &Unit);

/// Clear data.
void clear() {
IndexToAddressMap.clear();
StrOffsets.clear();
}

private:
std::unique_ptr<DebugStrOffsetsBufferVector> StrOffsetsBuffer;
std::unique_ptr<raw_svector_ostream> StrOffsetsStream;
std::map<uint32_t, uint32_t> IndexToAddressMap;
Expand Down
13 changes: 1 addition & 12 deletions bolt/lib/Core/BinarySection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,18 +190,7 @@ void BinarySection::flushPendingRelocations(raw_pwrite_stream &OS,
clearList(PendingRelocations);
}

BinarySection::~BinarySection() {
if (isReordered()) {
delete[] getData();
return;
}

if (!isAllocatable() && !hasValidSectionID() &&
(!hasSectionRef() ||
OutputContents.data() != getContentsOrQuit(Section).data())) {
delete[] getOutputData();
}
}
BinarySection::~BinarySection() { updateContents(nullptr, 0); }

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

Expand Down
20 changes: 10 additions & 10 deletions bolt/lib/Core/DIEBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ void DIEBuilder::constructFromUnit(DWARFUnit &DU) {
}

DIEBuilder::DIEBuilder(BinaryContext &BC, DWARFContext *DwarfContext,
bool IsDWO)
: BC(BC), DwarfContext(DwarfContext), IsDWO(IsDWO) {}
DWARFUnit *SkeletonCU)
: BC(BC), DwarfContext(DwarfContext), SkeletonCU(SkeletonCU) {}

static unsigned int getCUNum(DWARFContext *DwarfContext, bool IsDWO) {
unsigned int CUNum = IsDWO ? DwarfContext->getNumDWOCompileUnits()
Expand All @@ -204,11 +204,11 @@ void DIEBuilder::buildTypeUnits(DebugStrOffsetsWriter *StrOffsetWriter,
true);
}
}
const unsigned int CUNum = getCUNum(DwarfContext, IsDWO);
const unsigned int CUNum = getCUNum(DwarfContext, isDWO());
getState().CloneUnitCtxMap.resize(CUNum);
DWARFContext::unit_iterator_range CU4TURanges =
IsDWO ? DwarfContext->dwo_types_section_units()
: DwarfContext->types_section_units();
isDWO() ? DwarfContext->dwo_types_section_units()
: DwarfContext->types_section_units();

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

DWARFContext::unit_iterator_range CURanges =
IsDWO ? DwarfContext->dwo_info_section_units()
: DwarfContext->info_section_units();
isDWO() ? DwarfContext->dwo_info_section_units()
: DwarfContext->info_section_units();

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

unsigned int CUNum = getCUNum(DwarfContext, IsDWO);
unsigned int CUNum = getCUNum(DwarfContext, isDWO());
getState().CloneUnitCtxMap.resize(CUNum);
DWARFContext::unit_iterator_range CURanges =
IsDWO ? DwarfContext->dwo_info_section_units()
: DwarfContext->info_section_units();
isDWO() ? DwarfContext->dwo_info_section_units()
: DwarfContext->info_section_units();

// This handles DWARF4 CUs and DWARF5 CU/TUs.
// Creating a vector so that for reference handling only DWARF5 CU/TUs are
Expand Down
3 changes: 1 addition & 2 deletions bolt/lib/Core/DebugData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -909,8 +909,7 @@ void DebugStrOffsetsWriter::finalizeSection(DWARFUnit &Unit,
}

StrOffsetSectionWasModified = false;
IndexToAddressMap.clear();
StrOffsets.clear();
clear();
}

void DebugStrWriter::create() {
Expand Down
2 changes: 1 addition & 1 deletion bolt/lib/Rewrite/DWARFRewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ void DWARFRewriter::updateDebugInfo() {
: LegacyRangesSectionWriter.get();
// Skipping CUs that failed to load.
if (SplitCU) {
DIEBuilder DWODIEBuilder(BC, &(*SplitCU)->getContext(), true);
DIEBuilder DWODIEBuilder(BC, &(*SplitCU)->getContext(), Unit);
DWODIEBuilder.buildDWOUnit(**SplitCU);
std::string DWOName = updateDWONameCompDir(
*Unit, *DIEBlder, *DIEBlder->getUnitDIEbyUnit(*Unit));
Expand Down
9 changes: 3 additions & 6 deletions bolt/lib/Rewrite/RewriteInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4092,12 +4092,9 @@ void RewriteInstance::rewriteNoteSections() {
return getNewValueForSymbol(S->getName());
});

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

NextAvailableOffset += Size;
}
Expand Down
9 changes: 5 additions & 4 deletions bolt/unittests/Core/BinaryContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,11 @@ TEST_P(BinaryContextTester, FlushPendingRelocCALL26) {
// 12: bl func2
// 16: func2

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

std::error_code EC;
SmallVector<char> Vect(sizeof(Data));
SmallVector<char> Vect(DataSize);
raw_svector_ostream OS(Vect);

BS.flushPendingRelocations(OS, [&](const MCSymbol *S) {
Expand Down
49 changes: 20 additions & 29 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,6 @@ Clang Frontend Potentially Breaking Changes
of ``-Wno-gnu-binary-literal`` will no longer silence this pedantic warning,
which may break existing uses with ``-Werror``.

Target OS macros extension
^^^^^^^^^^^^^^^^^^^^^^^^^^
A new Clang extension (see :ref:`here <target_os_detail>`) is enabled for
Darwin (Apple platform) targets. Clang now defines ``TARGET_OS_*`` macros for
these targets, which could break existing code bases with improper checks for
the ``TARGET_OS_`` macros. For example, existing checks might fail to include
the ``TargetConditionals.h`` header from Apple SDKs and therefore leaving the
macros undefined and guarded code unexercised.

Affected code should be checked to see if it's still intended for the specific
target and fixed accordingly.

The extension can be turned off by the option ``-fno-define-target-os-macros``
as a workaround.

What's New in Clang |release|?
==============================
Some of the major new features and improvements to Clang are listed
Expand All @@ -98,9 +83,8 @@ C++20 Feature Support

- Implemented the `__is_layout_compatible` intrinsic to support
`P0466R5: Layout-compatibility and Pointer-interconvertibility Traits <https://wg21.link/P0466R5>`_.
Note: `CWG1719: Layout compatibility and cv-qualification revisited <https://cplusplus.github.io/CWG/issues/1719.html>`_
and `CWG2759: [[no_unique_address] and common initial sequence <https://cplusplus.github.io/CWG/issues/2759.html>`_
are not yet implemented.
Note: `CWG2759: [[no_unique_address] and common initial sequence <https://cplusplus.github.io/CWG/issues/2759.html>`_
is not yet implemented.

C++23 Feature Support
^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -125,6 +109,10 @@ Resolutions to C++ Defect Reports
in the template parameters, but is deduced from a previous argument.
(`#78449: <https://github.com/llvm/llvm-project/issues/78449>`_).

- Type qualifications are now ignored when evaluating layout compatibility
of two types.
(`CWG1719: Layout compatibility and cv-qualification revisited <https://cplusplus.github.io/CWG/issues/1719.html>`_).

C Language Changes
------------------

Expand Down Expand Up @@ -163,17 +151,6 @@ Non-comprehensive list of changes in this release
New Compiler Flags
------------------

.. _target_os_detail:

Target OS macros extension
^^^^^^^^^^^^^^^^^^^^^^^^^^
A pair of new flags ``-fdefine-target-os-macros`` and
``-fno-define-target-os-macros`` has been added to Clang to enable/disable the
extension to provide built-in definitions of a list of ``TARGET_OS_*`` macros
based on the target triple.

The extension is enabled by default for Darwin (Apple platform) targets.

Deprecated Compiler Flags
-------------------------

Expand Down Expand Up @@ -284,6 +261,8 @@ Bug Fixes to C++ Support
Fixes (`#68490 <https://github.com/llvm/llvm-project/issues/68490>`_)
- Fix a crash when trying to call a varargs function that also has an explicit object parameter.
Fixes (`#80971 ICE when explicit object parameter be a function parameter pack`)
- Reject explicit object parameters on `new` and `delete` operators.
Fixes (`#82249 <https://github.com/llvm/llvm-project/issues/82249>` _)
- Fixed a bug where abbreviated function templates would append their invented template parameters to
an empty template parameter lists.
- Clang now classifies aggregate initialization in C++17 and newer as constant
Expand All @@ -297,6 +276,10 @@ Bug Fixes to C++ Support
was only accepted at namespace scope but not at local function scope.
- Clang no longer tries to call consteval constructors at runtime when they appear in a member initializer.
(`#782154 <https://github.com/llvm/llvm-project/issues/82154>`_`)
- Fix crash when using an immediate-escalated function at global scope.
(`#82258 <https://github.com/llvm/llvm-project/issues/82258>`_)
- Correctly immediate-escalate lambda conversion functions.
(`#82258 <https://github.com/llvm/llvm-project/issues/82258>`_)

Bug Fixes to AST Handling
^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down Expand Up @@ -409,6 +392,14 @@ Moved checkers
Sanitizers
----------

- ``-fsanitize=signed-integer-overflow`` now instruments signed arithmetic even
when ``-fwrapv`` is enabled. Previously, only division checks were enabled.

Users with ``-fwrapv`` as well as a sanitizer group like
``-fsanitize=undefined`` or ``-fsanitize=integer`` enabled may want to
manually disable potentially noisy signed integer overflow checks with
``-fno-sanitize=signed-integer-overflow``

Python Binding Changes
----------------------

Expand Down
9 changes: 5 additions & 4 deletions clang/docs/UndefinedBehaviorSanitizer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,11 @@ Available checks are:
- ``-fsanitize=signed-integer-overflow``: Signed integer overflow, where the
result of a signed integer computation cannot be represented in its type.
This includes all the checks covered by ``-ftrapv``, as well as checks for
signed division overflow (``INT_MIN/-1``), but not checks for
lossy implicit conversions performed before the computation
(see ``-fsanitize=implicit-conversion``). Both of these two issues are
handled by ``-fsanitize=implicit-conversion`` group of checks.
signed division overflow (``INT_MIN/-1``). Note that checks are still
added even when ``-fwrapv`` is enabled. This sanitizer does not check for
lossy implicit conversions performed before the computation (see
``-fsanitize=implicit-conversion``). Both of these two issues are handled
by ``-fsanitize=implicit-conversion`` group of checks.
- ``-fsanitize=unreachable``: If control flow reaches an unreachable
program point.
- ``-fsanitize=unsigned-integer-overflow``: Unsigned integer overflow, where
Expand Down
3 changes: 0 additions & 3 deletions clang/include/clang/Basic/DiagnosticDriverKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,4 @@ def warn_android_unversioned_fallback : Warning<

def err_drv_triple_version_invalid : Error<
"version '%0' in target triple '%1' is invalid">;

def err_drv_installapi_unsupported : Error<
"InstallAPI is not supported for '%0'">;
}
12 changes: 0 additions & 12 deletions clang/include/clang/Driver/Action.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ class Action {
PreprocessJobClass,
PrecompileJobClass,
ExtractAPIJobClass,
InstallAPIJobClass,
AnalyzeJobClass,
MigrateJobClass,
CompileJobClass,
Expand Down Expand Up @@ -451,17 +450,6 @@ class ExtractAPIJobAction : public JobAction {
void addHeaderInput(Action *Input) { getInputs().push_back(Input); }
};

class InstallAPIJobAction : public JobAction {
void anchor() override;

public:
InstallAPIJobAction(Action *Input, types::ID OutputType);

static bool classof(const Action *A) {
return A->getKind() == InstallAPIJobClass;
}
};

class AnalyzeJobAction : public JobAction {
void anchor() override;

Expand Down
12 changes: 2 additions & 10 deletions clang/include/clang/Driver/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,6 @@ class AnalyzerOpts<string base>
: KeyPathAndMacro<"AnalyzerOpts->", base, "ANALYZER_"> {}
class MigratorOpts<string base>
: KeyPathAndMacro<"MigratorOpts.", base, "MIGRATOR_"> {}
class InstallAPIOpts<string base>
: KeyPathAndMacro<"InstallAPIOpts.", base, "INSTALLAPI_"> {}

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

defm assume_unique_vtables : BoolFOption<"assume-unique-vtables",
CodeGenOpts<"AssumeUniqueVTables">, DefaultTrue,
Expand Down Expand Up @@ -4403,9 +4397,7 @@ def verify_pch : Flag<["-"], "verify-pch">, Group<Action_Group>,
Visibility<[ClangOption, CC1Option]>,
HelpText<"Load and verify that a pre-compiled header file is not stale">;
def init : Separate<["-"], "init">;
def install__name : Separate<["-"], "install_name">,
Visibility<[ClangOption, CC1Option]>,
MarshallingInfoString<InstallAPIOpts<"InstallName">>;
def install__name : Separate<["-"], "install_name">;
def iprefix : JoinedOrSeparate<["-"], "iprefix">, Group<clang_i_Group>,
Visibility<[ClangOption, CC1Option]>,
HelpText<"Set the -iwithprefix/-iwithprefixbefore prefix">, MetaVarName<"<dir>">;
Expand Down
Loading

0 comments on commit 1af3232

Please sign in to comment.