Skip to content

Commit 300e9c5

Browse files
committed
Manually merged main:bafda89a0944d947fc4b3b5663185e07a397ac30 into amd-gfx:2e4aa61a46dc
Local branch amd-gfx 2e4aa61 Merged main:5434b04234a86273d719f96e9efa6332a53c0eba into amd-gfx:17b97598a1e4 Remote branch main bafda89 [X86] Use generic CPU tuning when tune-cpu is empty (llvm#83631)
2 parents 2e4aa61 + bafda89 commit 300e9c5

File tree

1,428 files changed

+11403
-3980
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,428 files changed

+11403
-3980
lines changed

bolt/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
set(LLVM_SUBPROJECT_TITLE "BOLT")
2+
13
include(ExternalProject)
24

35
set(BOLT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
@@ -121,7 +123,7 @@ option(BOLT_BUILD_TOOLS
121123
"Build the BOLT tools. If OFF, just generate build targets." ON)
122124

123125
add_custom_target(bolt)
124-
set_target_properties(bolt PROPERTIES FOLDER "BOLT")
126+
set_target_properties(bolt PROPERTIES FOLDER "BOLT/Metatargets")
125127
add_llvm_install_targets(install-bolt DEPENDS bolt COMPONENT bolt)
126128

127129
include_directories(

bolt/cmake/modules/AddBOLT.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ include(LLVMDistributionSupport)
33

44
macro(add_bolt_executable name)
55
add_llvm_executable(${name} ${ARGN})
6-
set_target_properties(${name} PROPERTIES FOLDER "BOLT")
76
endmacro()
87

98
macro(add_bolt_tool name)

bolt/docs/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ if (LLVM_ENABLE_DOXYGEN)
7979
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/doxygen.cfg
8080
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
8181
COMMENT "Generating bolt doxygen documentation." VERBATIM)
82+
set_target_properties(doxygen-bolt PROPERTIES FOLDER "BOLT/Docs")
8283

8384
if (LLVM_BUILD_DOCS)
8485
add_dependencies(doxygen doxygen-bolt)

bolt/include/bolt/Core/BinaryContext.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,8 +1224,7 @@ class BinaryContext {
12241224

12251225
/// Return a signed value of \p Size stored at \p Address. The address has
12261226
/// to be a valid statically allocated address for the binary.
1227-
ErrorOr<uint64_t> getSignedValueAtAddress(uint64_t Address,
1228-
size_t Size) const;
1227+
ErrorOr<int64_t> getSignedValueAtAddress(uint64_t Address, size_t Size) const;
12291228

12301229
/// Special case of getUnsignedValueAtAddress() that uses a pointer size.
12311230
ErrorOr<uint64_t> getPointerAtAddress(uint64_t Address) const {

bolt/lib/Core/BinaryContext.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2217,8 +2217,8 @@ ErrorOr<uint64_t> BinaryContext::getUnsignedValueAtAddress(uint64_t Address,
22172217
return DE.getUnsigned(&ValueOffset, Size);
22182218
}
22192219

2220-
ErrorOr<uint64_t> BinaryContext::getSignedValueAtAddress(uint64_t Address,
2221-
size_t Size) const {
2220+
ErrorOr<int64_t> BinaryContext::getSignedValueAtAddress(uint64_t Address,
2221+
size_t Size) const {
22222222
const ErrorOr<const BinarySection &> Section = getSectionForAddress(Address);
22232223
if (!Section)
22242224
return std::make_error_code(std::errc::bad_address);

bolt/lib/Core/BinaryFunction.cpp

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -851,15 +851,19 @@ BinaryFunction::processIndirectBranch(MCInst &Instruction, unsigned Size,
851851
return IndirectBranchType::UNKNOWN;
852852
}
853853

854-
// RIP-relative addressing should be converted to symbol form by now
855-
// in processed instructions (but not in jump).
856-
if (DispExpr) {
854+
auto getExprValue = [&](const MCExpr *Expr) {
857855
const MCSymbol *TargetSym;
858856
uint64_t TargetOffset;
859-
std::tie(TargetSym, TargetOffset) = BC.MIB->getTargetSymbolInfo(DispExpr);
857+
std::tie(TargetSym, TargetOffset) = BC.MIB->getTargetSymbolInfo(Expr);
860858
ErrorOr<uint64_t> SymValueOrError = BC.getSymbolValue(*TargetSym);
861-
assert(SymValueOrError && "global symbol needs a value");
862-
ArrayStart = *SymValueOrError + TargetOffset;
859+
assert(SymValueOrError && "Global symbol needs a value");
860+
return *SymValueOrError + TargetOffset;
861+
};
862+
863+
// RIP-relative addressing should be converted to symbol form by now
864+
// in processed instructions (but not in jump).
865+
if (DispExpr) {
866+
ArrayStart = getExprValue(DispExpr);
863867
BaseRegNum = BC.MIB->getNoRegister();
864868
if (BC.isAArch64()) {
865869
ArrayStart &= ~0xFFFULL;
@@ -3698,6 +3702,13 @@ BinaryFunction::BasicBlockListType BinaryFunction::dfs() const {
36983702

36993703
size_t BinaryFunction::computeHash(bool UseDFS, HashFunction HashFunction,
37003704
OperandHashFuncTy OperandHashFunc) const {
3705+
LLVM_DEBUG({
3706+
dbgs() << "BOLT-DEBUG: computeHash " << getPrintName() << ' '
3707+
<< (UseDFS ? "dfs" : "bin") << " order "
3708+
<< (HashFunction == HashFunction::StdHash ? "std::hash" : "xxh3")
3709+
<< '\n';
3710+
});
3711+
37013712
if (size() == 0)
37023713
return 0;
37033714

bolt/lib/Core/DebugNames.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,6 @@ void DWARF5AcceleratorTable::addUnit(DWARFUnit &Unit,
112112
// Returns true if DW_TAG_variable should be included in .debug-names based on
113113
// section 6.1.1.1 for DWARF5 spec.
114114
static bool shouldIncludeVariable(const DWARFUnit &Unit, const DIE &Die) {
115-
if (Die.findAttribute(dwarf::Attribute::DW_AT_declaration))
116-
return false;
117115
const DIEValue LocAttrInfo =
118116
Die.findAttribute(dwarf::Attribute::DW_AT_location);
119117
if (!LocAttrInfo)
@@ -148,6 +146,8 @@ static bool shouldIncludeVariable(const DWARFUnit &Unit, const DIE &Die) {
148146

149147
bool static canProcess(const DWARFUnit &Unit, const DIE &Die,
150148
std::string &NameToUse, const bool TagsOnly) {
149+
if (Die.findAttribute(dwarf::Attribute::DW_AT_declaration))
150+
return false;
151151
switch (Die.getTag()) {
152152
case dwarf::DW_TAG_base_type:
153153
case dwarf::DW_TAG_class_type:

bolt/lib/Profile/YAMLProfileReader.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,14 @@ bool YAMLProfileReader::parseFunctionProfile(
102102
if (BF.empty())
103103
return true;
104104

105-
if (!opts::IgnoreHash &&
106-
YamlBF.Hash != BF.computeHash(IsDFSOrder, HashFunction)) {
107-
if (opts::Verbosity >= 1)
108-
errs() << "BOLT-WARNING: function hash mismatch\n";
109-
ProfileMatched = false;
105+
if (!opts::IgnoreHash) {
106+
if (!BF.getHash())
107+
BF.computeHash(IsDFSOrder, HashFunction);
108+
if (YamlBF.Hash != BF.getHash()) {
109+
if (opts::Verbosity >= 1)
110+
errs() << "BOLT-WARNING: function hash mismatch\n";
111+
ProfileMatched = false;
112+
}
110113
}
111114

112115
if (YamlBF.NumBasicBlocks != BF.size()) {

bolt/lib/Rewrite/DWARFRewriter.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,7 @@ static void printDie(DWARFUnit &DU, uint64_t DIEOffset) {
7373
DWARFDataExtractor DebugInfoData = DU.getDebugInfoExtractor();
7474
DWARFDebugInfoEntry DIEEntry;
7575
if (DIEEntry.extractFast(DU, &DIEOffset, DebugInfoData, NextCUOffset, 0)) {
76-
if (const DWARFAbbreviationDeclaration *AbbrDecl =
77-
DIEEntry.getAbbreviationDeclarationPtr()) {
76+
if (DIEEntry.getAbbreviationDeclarationPtr()) {
7877
DWARFDie DDie(&DU, &DIEEntry);
7978
printDie(DDie);
8079
} else {

bolt/lib/Rewrite/LinuxKernelRewriter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ void LinuxKernelRewriter::processLKKSymtab(bool IsGPL) {
393393

394394
for (uint64_t I = 0; I < SectionSize; I += 4) {
395395
const uint64_t EntryAddress = SectionAddress + I;
396-
ErrorOr<uint64_t> Offset = BC.getSignedValueAtAddress(EntryAddress, 4);
396+
ErrorOr<int64_t> Offset = BC.getSignedValueAtAddress(EntryAddress, 4);
397397
assert(Offset && "Reading valid PC-relative offset for a ksymtab entry");
398398
const int32_t SignedOffset = *Offset;
399399
const uint64_t RefAddress = EntryAddress + SignedOffset;

bolt/lib/Target/X86/X86MCPlusBuilder.cpp

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1932,6 +1932,19 @@ class X86MCPlusBuilder : public MCPlusBuilder {
19321932
// = R_X86_64_PC32(Ln) + En - JT
19331933
// = R_X86_64_PC32(Ln + offsetof(En))
19341934
//
1935+
auto isRIPRel = [&](X86MemOperand &MO) {
1936+
// NB: DispExpr should be set
1937+
return MO.DispExpr != nullptr &&
1938+
MO.BaseRegNum == RegInfo->getProgramCounter() &&
1939+
MO.IndexRegNum == X86::NoRegister &&
1940+
MO.SegRegNum == X86::NoRegister;
1941+
};
1942+
auto isIndexed = [](X86MemOperand &MO, MCPhysReg R) {
1943+
// NB: IndexRegNum should be set.
1944+
return MO.IndexRegNum != X86::NoRegister && MO.BaseRegNum == R &&
1945+
MO.ScaleImm == 4 && MO.DispImm == 0 &&
1946+
MO.SegRegNum == X86::NoRegister;
1947+
};
19351948
LLVM_DEBUG(dbgs() << "Checking for PIC jump table\n");
19361949
MCInst *MemLocInstr = nullptr;
19371950
const MCInst *MovInstr = nullptr;
@@ -1965,9 +1978,8 @@ class X86MCPlusBuilder : public MCPlusBuilder {
19651978
std::optional<X86MemOperand> MO = evaluateX86MemoryOperand(Instr);
19661979
if (!MO)
19671980
break;
1968-
if (MO->BaseRegNum != R1 || MO->ScaleImm != 4 ||
1969-
MO->IndexRegNum == X86::NoRegister || MO->DispImm != 0 ||
1970-
MO->SegRegNum != X86::NoRegister)
1981+
if (!isIndexed(*MO, R1))
1982+
// POSSIBLE_PIC_JUMP_TABLE
19711983
break;
19721984
MovInstr = &Instr;
19731985
} else {
@@ -1986,9 +1998,7 @@ class X86MCPlusBuilder : public MCPlusBuilder {
19861998
std::optional<X86MemOperand> MO = evaluateX86MemoryOperand(Instr);
19871999
if (!MO)
19882000
break;
1989-
if (MO->BaseRegNum != RegInfo->getProgramCounter() ||
1990-
MO->IndexRegNum != X86::NoRegister ||
1991-
MO->SegRegNum != X86::NoRegister || MO->DispExpr == nullptr)
2001+
if (!isRIPRel(*MO))
19922002
break;
19932003
MemLocInstr = &Instr;
19942004
break;
@@ -2105,13 +2115,15 @@ class X86MCPlusBuilder : public MCPlusBuilder {
21052115
return IndirectBranchType::POSSIBLE_FIXED_BRANCH;
21062116
}
21072117

2108-
if (Type == IndirectBranchType::POSSIBLE_PIC_JUMP_TABLE &&
2109-
(MO->ScaleImm != 1 || MO->BaseRegNum != RIPRegister))
2110-
return IndirectBranchType::UNKNOWN;
2111-
2112-
if (Type != IndirectBranchType::POSSIBLE_PIC_JUMP_TABLE &&
2113-
MO->ScaleImm != PtrSize)
2114-
return IndirectBranchType::UNKNOWN;
2118+
switch (Type) {
2119+
case IndirectBranchType::POSSIBLE_PIC_JUMP_TABLE:
2120+
if (MO->ScaleImm != 1 || MO->BaseRegNum != RIPRegister)
2121+
return IndirectBranchType::UNKNOWN;
2122+
break;
2123+
default:
2124+
if (MO->ScaleImm != PtrSize)
2125+
return IndirectBranchType::UNKNOWN;
2126+
}
21152127

21162128
MemLocInstrOut = MemLocInstr;
21172129

bolt/test/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,14 @@ list(APPEND BOLT_TEST_DEPS
5656
)
5757

5858
add_custom_target(bolt-test-depends DEPENDS ${BOLT_TEST_DEPS})
59-
set_target_properties(bolt-test-depends PROPERTIES FOLDER "BOLT")
59+
set_target_properties(bolt-test-depends PROPERTIES FOLDER "BOLT/Tests")
6060

6161
add_lit_testsuite(check-bolt "Running the BOLT regression tests"
6262
${CMAKE_CURRENT_BINARY_DIR}
6363
PARAMS ${BOLT_TEST_PARAMS}
6464
DEPENDS ${BOLT_TEST_DEPS}
6565
ARGS ${BOLT_TEST_EXTRA_ARGS}
6666
)
67-
set_target_properties(check-bolt PROPERTIES FOLDER "BOLT")
6867

6968
add_lit_testsuites(BOLT ${CMAKE_CURRENT_SOURCE_DIR}
7069
PARAMS ${BOLT_TEST_PARAMS}

0 commit comments

Comments
 (0)