Skip to content

Commit f120b53

Browse files
author
Hugh Delaney
committed
Fixing merge conflict
2 parents 13b1efb + bb0afc2 commit f120b53

File tree

10,286 files changed

+363884
-200532
lines changed

Some content is hidden

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

10,286 files changed

+363884
-200532
lines changed

.github/CODEOWNERS

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
* @bader
1+
* @pvchupin
22

33
# Front-end compiler
44
clang/ @intel/dpcpp-cfe-reviewers
@@ -35,7 +35,7 @@ sycl/doc/extensions/ @intel/dpcpp-specification-reviewers
3535
sycl/plugins/level_zero/ @intel/dpcpp-l0-pi-reviewers
3636

3737
# ESIMD CPU emulator plug-in
38-
sycl/plugins/esimd_cpu/ @intel/dpcpp-esimd-reviewers
38+
sycl/plugins/esimd_emulator/ @intel/dpcpp-esimd-reviewers
3939

4040
# CUDA plugin
4141
sycl/plugins/cuda/ @intel/llvm-reviewers-cuda
@@ -48,7 +48,7 @@ xptifw/ @intel/llvm-reviewers-runtime
4848
llvm/ @intel/dpcpp-tools-reviewers
4949

5050
# Clang offload tools
51-
clang/tools/clang-offload-*/ @sndmitriev @intel/dpcpp-tools-reviewers
51+
clang/tools/clang-offload-*/ @intel/dpcpp-tools-reviewers
5252

5353
# Explicit SIMD
5454
ESIMD/ @intel/dpcpp-esimd-reviewers

bolt/CMakeLists.txt

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -59,28 +59,7 @@ if (BOLT_ENABLE_RUNTIME)
5959
COMPONENT bolt)
6060
endif()
6161

62-
# Get the current git revision for BOLT.
63-
find_program(git_executable NAMES git git.exe git.cmd)
64-
if (git_executable)
65-
execute_process(COMMAND ${git_executable} rev-parse HEAD
66-
WORKING_DIRECTORY ${LLVM_MAIN_SRC_DIR}
67-
TIMEOUT 5
68-
RESULT_VARIABLE git_result
69-
OUTPUT_VARIABLE git_output)
70-
if( git_result EQUAL 0 )
71-
string(STRIP "${git_output}" git_ref_id)
72-
set(BOLT_REVISION "${git_ref_id}")
73-
endif()
74-
endif()
75-
76-
# If we can't find a revision, set it to "<unknown>".
77-
if (NOT BOLT_REVISION)
78-
set(BOLT_REVISION "<unknown>")
79-
endif()
80-
81-
configure_file(
82-
${CMAKE_CURRENT_SOURCE_DIR}/include/bolt/Utils/BoltRevision.inc.in
83-
${CMAKE_CURRENT_BINARY_DIR}/include/bolt/Utils/BoltRevision.inc)
62+
find_program(GNU_LD_EXECUTABLE NAMES ${LLVM_DEFAULT_TARGET_TRIPLE}-ld.bfd ld.bfd DOC "GNU ld")
8463

8564
include_directories(
8665
${CMAKE_CURRENT_SOURCE_DIR}/include

bolt/docs/Heatmaps.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ or if you want to monitor the existing process(es):
2020
$ perf record -e cycles:u -j any,u [-p PID|-a] -- sleep <interval>
2121
```
2222

23-
Note that at the moment running with LBR (`-j any,u` or `-b`) is
24-
a requirement.
23+
Running with LBR (`-j any,u` or `-b`) is recommended. Heatmaps can be generated
24+
from basic events by using the llvm-bolt-heatmap option `-nl` (no LBR) but
25+
such heatmaps do not have the coverage provided by LBR and may only be useful
26+
for finding event hotspots at larger code block granularities.
2527

2628
Once the run is complete, and `perf.data` is generated, run llvm-bolt-heatmap:
2729

bolt/include/bolt/Core/BinaryContext.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,22 @@ class BinaryContext {
774774
return Itr != GlobalSymbols.end() ? Itr->second : nullptr;
775775
}
776776

777+
/// Return registered PLT entry BinaryData with the given \p Name
778+
/// or nullptr if no global PLT symbol with that name exists.
779+
const BinaryData *getPLTBinaryDataByName(StringRef Name) const {
780+
if (const BinaryData *Data = getBinaryDataByName(Name.str() + "@PLT"))
781+
return Data;
782+
783+
// The symbol name might contain versioning information e.g
784+
// memcpy@@GLIBC_2.17. Remove it and try to locate binary data
785+
// without it.
786+
size_t At = Name.find("@");
787+
if (At != std::string::npos)
788+
return getBinaryDataByName(Name.str().substr(0, At) + "@PLT");
789+
790+
return nullptr;
791+
}
792+
777793
/// Return true if \p SymbolName was generated internally and was not present
778794
/// in the input binary.
779795
bool isInternalSymbolName(const StringRef Name) {
@@ -954,6 +970,15 @@ class BinaryContext {
954970
Sections.end()));
955971
}
956972

973+
/// Return base address for the shared object or PIE based on the segment
974+
/// mapping information. \p MMapAddress is an address where one of the
975+
/// segments was mapped. \p FileOffset is the offset in the file of the
976+
/// mapping. Note that \p FileOffset should be page-aligned and could be
977+
/// different from the file offset of the segment which could be unaligned.
978+
/// If no segment is found that matches \p FileOffset, return NoneType().
979+
Optional<uint64_t> getBaseAddressForMapping(uint64_t MMapAddress,
980+
uint64_t FileOffset) const;
981+
957982
/// Check if the address belongs to this binary's static allocation space.
958983
bool containsAddress(uint64_t Address) const {
959984
return Address >= FirstAllocAddress && Address < LayoutStartAddress;

bolt/include/bolt/Core/BinaryFunction.h

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,9 @@ class BinaryFunction {
172172

173173
mutable MCSymbol *FunctionConstantIslandLabel{nullptr};
174174
mutable MCSymbol *FunctionColdConstantIslandLabel{nullptr};
175+
176+
// Returns constant island alignment
177+
uint16_t getAlignment() const { return sizeof(uint64_t); }
175178
};
176179

177180
static constexpr uint64_t COUNT_NO_PROFILE =
@@ -2047,6 +2050,10 @@ class BinaryFunction {
20472050
return *std::prev(CodeIter) <= *DataIter;
20482051
}
20492052

2053+
uint16_t getConstantIslandAlignment() const {
2054+
return Islands ? Islands->getAlignment() : 1;
2055+
}
2056+
20502057
uint64_t
20512058
estimateConstantIslandSize(const BinaryFunction *OnBehalfOf = nullptr) const {
20522059
if (!Islands)
@@ -2074,9 +2081,13 @@ class BinaryFunction {
20742081
Size += NextMarker - *DataIter;
20752082
}
20762083

2077-
if (!OnBehalfOf)
2078-
for (BinaryFunction *ExternalFunc : Islands->Dependency)
2084+
if (!OnBehalfOf) {
2085+
for (BinaryFunction *ExternalFunc : Islands->Dependency) {
2086+
Size = alignTo(Size, ExternalFunc->getConstantIslandAlignment());
20792087
Size += ExternalFunc->estimateConstantIslandSize(this);
2088+
}
2089+
}
2090+
20802091
return Size;
20812092
}
20822093

bolt/include/bolt/Core/MCPlusBuilder.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ class MCPlusBuilder {
353353
}
354354

355355
virtual bool isUnconditionalBranch(const MCInst &Inst) const {
356-
return Analysis->isUnconditionalBranch(Inst);
356+
return Analysis->isUnconditionalBranch(Inst) && !isTailCall(Inst);
357357
}
358358

359359
virtual bool isIndirectBranch(const MCInst &Inst) const {
@@ -511,11 +511,6 @@ class MCPlusBuilder {
511511
return 0;
512512
}
513513

514-
virtual bool isADD64rr(const MCInst &Inst) const {
515-
llvm_unreachable("not implemented");
516-
return false;
517-
}
518-
519514
virtual bool isSUB(const MCInst &Inst) const {
520515
llvm_unreachable("not implemented");
521516
return false;

bolt/include/bolt/Profile/DataAggregator.h

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -168,14 +168,15 @@ class DataAggregator : public DataReader {
168168
/// from the file name in BC.
169169
std::string BuildIDBinaryName;
170170

171-
/// Memory map info for a single file
171+
/// Memory map info for a single file as recorded in perf.data
172172
struct MMapInfo {
173-
uint64_t BaseAddress;
174-
uint64_t Size;
175-
uint64_t Offset;
176-
int32_t PID{-1};
177-
bool Forked{false};
178-
uint64_t Time{0ULL}; // time in micro seconds
173+
uint64_t BaseAddress{0}; /// Base address of the mapped binary.
174+
uint64_t MMapAddress{0}; /// Address of the executable segment.
175+
uint64_t Size{0}; /// Size of the mapping.
176+
uint64_t Offset{0}; /// File offset of the mapped segment.
177+
int32_t PID{-1}; /// Process ID.
178+
bool Forked{false}; /// Was the process forked?
179+
uint64_t Time{0ULL}; /// Time in micro seconds.
179180
};
180181

181182
/// Per-PID map info for the binary
@@ -420,12 +421,8 @@ class DataAggregator : public DataReader {
420421
/// correspond to the binary allocated address space, are adjusted to avoid
421422
/// conflicts.
422423
void adjustAddress(uint64_t &Address, const MMapInfo &MMI) const {
423-
if (Address >= MMI.BaseAddress && Address < MMI.BaseAddress + MMI.Size) {
424-
// NOTE: Assumptions about the binary segment load table (PH for ELF)
425-
// Segment file offset equals virtual address (which is true for .so)
426-
// There aren't multiple executable segments loaded because MMapInfo
427-
// doesn't support them.
428-
Address -= MMI.BaseAddress - MMI.Offset;
424+
if (Address >= MMI.MMapAddress && Address < MMI.MMapAddress + MMI.Size) {
425+
Address -= MMI.BaseAddress;
429426
} else if (Address < MMI.Size) {
430427
// Make sure the address is not treated as belonging to the binary.
431428
Address = (-1ULL);

bolt/include/bolt/Utils/BoltRevision.inc.in

Lines changed: 0 additions & 1 deletion
This file was deleted.

bolt/lib/Core/BinaryContext.cpp

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,17 @@ BinaryContext::createBinaryContext(const ObjectFile *File, bool IsPIC,
155155
Twine("BOLT-ERROR: no register info for target ", TripleName));
156156

157157
// Set up disassembler.
158-
std::unique_ptr<const MCAsmInfo> AsmInfo(
158+
std::unique_ptr<MCAsmInfo> AsmInfo(
159159
TheTarget->createMCAsmInfo(*MRI, TripleName, MCTargetOptions()));
160160
if (!AsmInfo)
161161
return createStringError(
162162
make_error_code(std::errc::not_supported),
163163
Twine("BOLT-ERROR: no assembly info for target ", TripleName));
164+
// BOLT creates "func@PLT" symbols for PLT entries. In function assembly dump
165+
// we want to emit such names as using @PLT without double quotes to convey
166+
// variant kind to the assembler. BOLT doesn't rely on the linker so we can
167+
// override the default AsmInfo behavior to emit names the way we want.
168+
AsmInfo->setAllowAtInName(true);
164169

165170
std::unique_ptr<const MCSubtargetInfo> STI(
166171
TheTarget->createMCSubtargetInfo(TripleName, "", FeaturesStr));
@@ -1529,6 +1534,9 @@ void BinaryContext::preprocessDebugInfo() {
15291534
}
15301535

15311536
bool BinaryContext::shouldEmit(const BinaryFunction &Function) const {
1537+
if (Function.isPseudo())
1538+
return false;
1539+
15321540
if (opts::processAllFunctions())
15331541
return true;
15341542

@@ -1682,6 +1690,22 @@ void BinaryContext::printInstruction(raw_ostream &OS, const MCInst &Instruction,
16821690
}
16831691
}
16841692

1693+
Optional<uint64_t>
1694+
BinaryContext::getBaseAddressForMapping(uint64_t MMapAddress,
1695+
uint64_t FileOffset) const {
1696+
// Find a segment with a matching file offset.
1697+
for (auto &KV : SegmentMapInfo) {
1698+
const SegmentInfo &SegInfo = KV.second;
1699+
if (alignDown(SegInfo.FileOffset, SegInfo.Alignment) == FileOffset) {
1700+
// Use segment's aligned memory offset to calculate the base address.
1701+
const uint64_t MemOffset = alignDown(SegInfo.Address, SegInfo.Alignment);
1702+
return MMapAddress - MemOffset;
1703+
}
1704+
}
1705+
1706+
return NoneType();
1707+
}
1708+
16851709
ErrorOr<BinarySection &> BinaryContext::getSectionForAddress(uint64_t Address) {
16861710
auto SI = AddressToSection.upper_bound(Address);
16871711
if (SI != AddressToSection.begin()) {

bolt/lib/Core/BinaryEmitter.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ void BinaryEmitter::emitFunctions() {
277277
}
278278

279279
bool BinaryEmitter::emitFunction(BinaryFunction &Function, bool EmitColdPart) {
280-
if (Function.size() == 0)
280+
if (Function.size() == 0 && !Function.hasIslandsInfo())
281281
return false;
282282

283283
if (Function.getState() == BinaryFunction::State::Empty)
@@ -500,6 +500,13 @@ void BinaryEmitter::emitConstantIslands(BinaryFunction &BF, bool EmitColdPart,
500500
if (Islands.DataOffsets.empty() && Islands.Dependency.empty())
501501
return;
502502

503+
// AArch64 requires CI to be aligned to 8 bytes due to access instructions
504+
// restrictions. E.g. the ldr with imm, where imm must be aligned to 8 bytes.
505+
const uint16_t Alignment = OnBehalfOf
506+
? OnBehalfOf->getConstantIslandAlignment()
507+
: BF.getConstantIslandAlignment();
508+
Streamer.emitCodeAlignment(Alignment, &*BC.STI);
509+
503510
if (!OnBehalfOf) {
504511
if (!EmitColdPart)
505512
Streamer.emitLabel(BF.getFunctionConstantIslandLabel());

0 commit comments

Comments
 (0)