Skip to content

Commit

Permalink
Merged main:08136d822c73 into amd-gfx:5c4b01290188
Browse files Browse the repository at this point in the history
Local branch amd-gfx 5c4b012 Merged main:3ff7d51eb823 into amd-gfx:fb1d7733ee1c
Remote branch main 08136d8 [DWARFLinkerParallel] Add support of accelerator tables to DWARFLinkerParallel.
  • Loading branch information
SC llvm team authored and SC llvm team committed Sep 27, 2023
2 parents 5c4b012 + 08136d8 commit a3e6510
Show file tree
Hide file tree
Showing 102 changed files with 2,669 additions and 2,564 deletions.
10 changes: 5 additions & 5 deletions libcxx/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,22 @@ if (MSVC)
set(dbg_include "")

if (NOT CMAKE_MSVC_RUNTIME_LIBRARY OR CMAKE_MSVC_RUNTIME_LIBRARY MATCHES "DLL$")
set(crt_lib "msvcrt")
set(fms_runtime_lib "dll")
set(cxx_lib "msvcprt")
else()
set(crt_lib "libcmt")
set(fms_runtime_lib "static")
set(cxx_lib "libcpmt")
endif()

if ((NOT CMAKE_MSVC_RUNTIME_LIBRARY AND uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG")
OR (CMAKE_MSVC_RUNTIME_LIBRARY MATCHES "Debug"))
set(dbg_include " -D_DEBUG -include set_windows_crt_report_mode.h")
set(crt_lib "${crt_lib}d")
set(dbg_include " -include set_windows_crt_report_mode.h")
set(fms_runtime_lib "${fms_runtime_lib}_dbg")
set(cxx_lib "${cxx_lib}d")
endif()

serialize_lit_param(dbg_include "\"${dbg_include}\"")
serialize_lit_param(crt_lib "\"${crt_lib}\"")
serialize_lit_param(fms_runtime_lib "\"${fms_runtime_lib}\"")
serialize_lit_param(cxx_lib "\"${cxx_lib}\"")
endif()

Expand Down
4 changes: 2 additions & 2 deletions libcxx/test/configs/llvm-libc++-shared-clangcl.cfg.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg')

config.substitutions.append(('%{flags}', '--driver-mode=g++'))
config.substitutions.append(('%{compile_flags}',
'-nostdinc++ -I %{include} -I %{target-include} -I %{libcxx}/test/support -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_STDIO_ISO_WIDE_SPECIFIERS -DNOMINMAX' + config.dbg_include
'-fms-runtime-lib=' + config.fms_runtime_lib + ' -nostdinc++ -I %{include} -I %{target-include} -I %{libcxx}/test/support -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_STDIO_ISO_WIDE_SPECIFIERS -DNOMINMAX' + config.dbg_include
))
config.substitutions.append(('%{link_flags}',
'-nostdlib -L %%{lib} -lc++ -l%s -l%s -loldnames' % (config.crt_lib, config.cxx_lib)
'-nostdlib -L %{lib} -lc++ -l' + config.cxx_lib
))
config.substitutions.append(('%{exec}',
'%{executor} --execdir %T --prepend_env PATH=%{lib} -- '
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg')

config.substitutions.append(('%{flags}', '--driver-mode=g++'))
config.substitutions.append(('%{compile_flags}',
'-nostdinc++ -I %{include} -I %{target-include} -I %{libcxx}/test/support -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_STDIO_ISO_WIDE_SPECIFIERS -DNOMINMAX -D_HAS_EXCEPTIONS=0' + config.dbg_include
'-fms-runtime-lib=' + config.fms_runtime_lib + ' -nostdinc++ -I %{include} -I %{target-include} -I %{libcxx}/test/support -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_STDIO_ISO_WIDE_SPECIFIERS -DNOMINMAX -D_HAS_EXCEPTIONS=0' + config.dbg_include
))
config.substitutions.append(('%{link_flags}',
'-nostdlib -L %%{lib} -lc++ -l%s -l%s -loldnames' % (config.crt_lib, config.cxx_lib)
'-nostdlib -L %{lib} -lc++ -l' + config.cxx_lib
))
config.substitutions.append(('%{exec}',
'%{executor} --execdir %T --prepend_env PATH=%{lib} -- '
Expand Down
4 changes: 2 additions & 2 deletions libcxx/test/configs/llvm-libc++-static-clangcl.cfg.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg')

config.substitutions.append(('%{flags}', '--driver-mode=g++'))
config.substitutions.append(('%{compile_flags}',
'-nostdinc++ -I %{include} -I %{target-include} -I %{libcxx}/test/support -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_STDIO_ISO_WIDE_SPECIFIERS -DNOMINMAX' + config.dbg_include
'-fms-runtime-lib=' + config.fms_runtime_lib + ' -nostdinc++ -I %{include} -I %{target-include} -I %{libcxx}/test/support -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_STDIO_ISO_WIDE_SPECIFIERS -DNOMINMAX' + config.dbg_include
))
config.substitutions.append(('%{link_flags}',
'-nostdlib -L %%{lib} -llibc++ -l%s -l%s -loldnames' % (config.crt_lib, config.cxx_lib)
'-nostdlib -L %{lib} -llibc++ -l' + config.cxx_lib
))
config.substitutions.append(('%{exec}',
'%{executor} --execdir %T -- '
Expand Down
7 changes: 6 additions & 1 deletion llvm/include/llvm/CodeGen/AccelTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "llvm/Support/DJB.h"
#include "llvm/Support/Debug.h"
#include <cstdint>
#include <variant>
#include <vector>

/// \file
Expand Down Expand Up @@ -310,9 +311,13 @@ void emitDWARF5AccelTable(AsmPrinter *Asm,
const DwarfDebug &DD,
ArrayRef<std::unique_ptr<DwarfCompileUnit>> CUs);

/// Emit a DWARFv5 Accelerator Table consisting of entries in the specified
/// AccelTable. The \p CUs contains either symbols keeping offsets to the
/// start of compilation unit, either offsets to the start of compilation
/// unit themselves.
void emitDWARF5AccelTable(
AsmPrinter *Asm, AccelTable<DWARF5AccelTableStaticData> &Contents,
ArrayRef<MCSymbol *> CUs,
ArrayRef<std::variant<MCSymbol *, uint64_t>> CUs,
llvm::function_ref<unsigned(const DWARF5AccelTableStaticData &)>
getCUIndexForEntry);

Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/Config/llvm-config.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

/* Indicate that this is LLVM compiled from the amd-gfx branch. */
#define LLVM_HAVE_BRANCH_AMD_GFX
#define LLVM_MAIN_REVISION 476071
#define LLVM_MAIN_REVISION 476085

/* Define if LLVM_ENABLE_DUMP is enabled */
#cmakedefine LLVM_ENABLE_DUMP
Expand Down
3 changes: 0 additions & 3 deletions llvm/include/llvm/DWARFLinkerParallel/DWARFLinker.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,6 @@ class ExtraDwarfEmitter {
/// Emit section named SecName with data SecData.
virtual void emitSectionContents(StringRef SecData, StringRef SecName) = 0;

/// Emit temporarily symbol named \p SymName inside section \p SecName.
virtual MCSymbol *emitTempSym(StringRef SecName, StringRef SymName) = 0;

/// Emit the swift_ast section stored in \p Buffer.
virtual void emitSwiftAST(StringRef Buffer) = 0;

Expand Down
52 changes: 38 additions & 14 deletions llvm/include/llvm/Transforms/Utils/UnrollLoop.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,6 @@ LoopUnrollResult UnrollAndJamLoop(Loop *L, unsigned Count, unsigned TripCount,
bool isSafeToUnrollAndJam(Loop *L, ScalarEvolution &SE, DominatorTree &DT,
DependenceInfo &DI, LoopInfo &LI);

bool computeUnrollCount(Loop *L, const TargetTransformInfo &TTI,
DominatorTree &DT, LoopInfo *LI, AssumptionCache *AC,
ScalarEvolution &SE,
const SmallPtrSetImpl<const Value *> &EphValues,
OptimizationRemarkEmitter *ORE, unsigned TripCount,
unsigned MaxTripCount, bool MaxOrZero,
unsigned TripMultiple, unsigned LoopSize,
TargetTransformInfo::UnrollingPreferences &UP,
TargetTransformInfo::PeelingPreferences &PP,
bool &UseUpperBound);

void simplifyLoopAfterUnroll(Loop *L, bool SimplifyIVs, LoopInfo *LI,
ScalarEvolution *SE, DominatorTree *DT,
AssumptionCache *AC,
Expand All @@ -126,9 +115,44 @@ TargetTransformInfo::UnrollingPreferences gatherUnrollingPreferences(
std::optional<bool> UserUpperBound,
std::optional<unsigned> UserFullUnrollMaxCount);

InstructionCost ApproximateLoopSize(const Loop *L, unsigned &NumCalls,
bool &NotDuplicatable, bool &Convergent, const TargetTransformInfo &TTI,
const SmallPtrSetImpl<const Value *> &EphValues, unsigned BEInsns);
/// Produce an estimate of the unrolled cost of the specified loop. This
/// is used to a) produce a cost estimate for partial unrolling and b) to
/// cheaply estimate cost for full unrolling when we don't want to symbolically
/// evaluate all iterations.
class UnrollCostEstimator {
InstructionCost LoopSize;
bool NotDuplicatable;

public:
unsigned NumInlineCandidates;
bool Convergent;

UnrollCostEstimator(const Loop *L, const TargetTransformInfo &TTI,
const SmallPtrSetImpl<const Value *> &EphValues,
unsigned BEInsns);

/// Whether it is legal to unroll this loop.
bool canUnroll() const { return LoopSize.isValid() && !NotDuplicatable; }

uint64_t getRolledLoopSize() const { return *LoopSize.getValue(); }

/// Returns loop size estimation for unrolled loop, given the unrolling
/// configuration specified by UP.
uint64_t
getUnrolledLoopSize(const TargetTransformInfo::UnrollingPreferences &UP,
unsigned CountOverwrite = 0) const;
};

bool computeUnrollCount(Loop *L, const TargetTransformInfo &TTI,
DominatorTree &DT, LoopInfo *LI, AssumptionCache *AC,
ScalarEvolution &SE,
const SmallPtrSetImpl<const Value *> &EphValues,
OptimizationRemarkEmitter *ORE, unsigned TripCount,
unsigned MaxTripCount, bool MaxOrZero,
unsigned TripMultiple, const UnrollCostEstimator &UCE,
TargetTransformInfo::UnrollingPreferences &UP,
TargetTransformInfo::PeelingPreferences &PP,
bool &UseUpperBound);

} // end namespace llvm

Expand Down
15 changes: 9 additions & 6 deletions llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ class Dwarf5AccelTableWriter : public AccelTableWriter {

Header Header;
DenseMap<uint32_t, SmallVector<AttributeEncoding, 2>> Abbreviations;
ArrayRef<MCSymbol *> CompUnits;
ArrayRef<std::variant<MCSymbol *, uint64_t>> CompUnits;
llvm::function_ref<unsigned(const DataT &)> getCUIndexForEntry;
MCSymbol *ContributionEnd = nullptr;
MCSymbol *AbbrevStart = Asm->createTempSymbol("names_abbrev_start");
Expand All @@ -235,7 +235,7 @@ class Dwarf5AccelTableWriter : public AccelTableWriter {
public:
Dwarf5AccelTableWriter(
AsmPrinter *Asm, const AccelTableBase &Contents,
ArrayRef<MCSymbol *> CompUnits,
ArrayRef<std::variant<MCSymbol *, uint64_t>> CompUnits,
llvm::function_ref<unsigned(const DataT &)> GetCUIndexForEntry);

void emit();
Expand Down Expand Up @@ -419,7 +419,10 @@ template <typename DataT>
void Dwarf5AccelTableWriter<DataT>::emitCUList() const {
for (const auto &CU : enumerate(CompUnits)) {
Asm->OutStreamer->AddComment("Compilation unit " + Twine(CU.index()));
Asm->emitDwarfSymbolReference(CU.value());
if (std::holds_alternative<MCSymbol *>(CU.value()))
Asm->emitDwarfSymbolReference(std::get<MCSymbol *>(CU.value()));
else
Asm->emitDwarfLengthOrOffset(std::get<uint64_t>(CU.value()));
}
}

Expand Down Expand Up @@ -508,7 +511,7 @@ template <typename DataT> void Dwarf5AccelTableWriter<DataT>::emitData() const {
template <typename DataT>
Dwarf5AccelTableWriter<DataT>::Dwarf5AccelTableWriter(
AsmPrinter *Asm, const AccelTableBase &Contents,
ArrayRef<MCSymbol *> CompUnits,
ArrayRef<std::variant<MCSymbol *, uint64_t>> CompUnits,
llvm::function_ref<unsigned(const DataT &)> getCUIndexForEntry)
: AccelTableWriter(Asm, Contents, false),
Header(CompUnits.size(), Contents.getBucketCount(),
Expand Down Expand Up @@ -545,7 +548,7 @@ void llvm::emitAppleAccelTableImpl(AsmPrinter *Asm, AccelTableBase &Contents,
void llvm::emitDWARF5AccelTable(
AsmPrinter *Asm, AccelTable<DWARF5AccelTableData> &Contents,
const DwarfDebug &DD, ArrayRef<std::unique_ptr<DwarfCompileUnit>> CUs) {
std::vector<MCSymbol *> CompUnits;
std::vector<std::variant<MCSymbol *, uint64_t>> CompUnits;
SmallVector<unsigned, 1> CUIndex(CUs.size());
int Count = 0;
for (const auto &CU : enumerate(CUs)) {
Expand Down Expand Up @@ -581,7 +584,7 @@ void llvm::emitDWARF5AccelTable(

void llvm::emitDWARF5AccelTable(
AsmPrinter *Asm, AccelTable<DWARF5AccelTableStaticData> &Contents,
ArrayRef<MCSymbol *> CUs,
ArrayRef<std::variant<MCSymbol *, uint64_t>> CUs,
llvm::function_ref<unsigned(const DWARF5AccelTableStaticData &)>
getCUIndexForEntry) {
Contents.finalize(Asm, "names");
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/DWARFLinker/DWARFStreamer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ void DwarfStreamer::emitDebugNames(
return;

// Build up data structures needed to emit this section.
std::vector<MCSymbol *> CompUnits;
std::vector<std::variant<MCSymbol *, uint64_t>> CompUnits;
DenseMap<unsigned, size_t> UniqueIdToCuMap;
unsigned Id = 0;
for (auto &CU : EmittedUnits) {
Expand Down
Loading

0 comments on commit a3e6510

Please sign in to comment.