Skip to content

Commit e5a78fa

Browse files
committed
Merge from 'main' to 'sycl-web' (335 commits)
CONFLICT (content): Merge conflict in clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp CONFLICT (content): Merge conflict in clang/test/Driver/clang-offload-bundler.c CONFLICT (content): Merge conflict in clang/lib/Driver/ToolChains/Clang.cpp
2 parents 73f0476 + 09a5eae commit e5a78fa

File tree

1,633 files changed

+34487
-16569
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,633 files changed

+34487
-16569
lines changed

bolt/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ if (git_executable)
7373
endif()
7474
endif()
7575

76+
find_program(GNU_LD_EXECUTABLE NAMES ${LLVM_DEFAULT_TARGET_TRIPLE}-ld.bfd ld.bfd DOC "GNU ld")
77+
7678
# If we can't find a revision, set it to "<unknown>".
7779
if (NOT BOLT_REVISION)
7880
set(BOLT_REVISION "<unknown>")

bolt/include/bolt/Core/BinaryContext.h

Lines changed: 16 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) {

bolt/lib/Rewrite/RewriteInstance.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1884,7 +1884,7 @@ bool RewriteInstance::analyzeRelocation(
18841884
IsSectionRelocation = (cantFail(Symbol.getType()) == SymbolRef::ST_Debug);
18851885
// Check for PLT entry registered with symbol name
18861886
if (!SymbolAddress && IsAArch64) {
1887-
BinaryData *BD = BC->getBinaryDataByName(SymbolName + "@PLT");
1887+
const BinaryData *BD = BC->getPLTBinaryDataByName(SymbolName);
18881888
SymbolAddress = BD ? BD->getAddress() : 0;
18891889
}
18901890
}
@@ -2350,7 +2350,7 @@ void RewriteInstance::readRelocations(const SectionRef &Section) {
23502350
continue;
23512351
}
23522352

2353-
if (BC->getDynamicRelocationAt(Rel.getOffset())) {
2353+
if (!IsAArch64 && BC->getDynamicRelocationAt(Rel.getOffset())) {
23542354
LLVM_DEBUG(
23552355
dbgs() << "BOLT-DEBUG: address 0x"
23562356
<< Twine::utohexstr(Rel.getOffset())
@@ -3035,7 +3035,7 @@ class BOLTSymbolResolver : public JITSymbolResolver {
30353035
std::string SymName = Symbol.str();
30363036
LLVM_DEBUG(dbgs() << "BOLT: looking for " << SymName << "\n");
30373037
// Resolve to a PLT entry if possible
3038-
if (BinaryData *I = BC.getBinaryDataByName(SymName + "@PLT")) {
3038+
if (const BinaryData *I = BC.getPLTBinaryDataByName(SymName)) {
30393039
AllResults[Symbol] =
30403040
JITEvaluatedSymbol(I->getAddress(), JITSymbolFlags());
30413041
continue;

bolt/lib/Target/X86/X86MCPlusBuilder.cpp

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,10 @@ class X86MCPlusBuilder : public MCPlusBuilder {
8787
}
8888

8989
unsigned getCondCode(const MCInst &Inst) const override {
90-
switch (Inst.getOpcode()) {
91-
default:
92-
return X86::COND_INVALID;
93-
case X86::JCC_1:
94-
case X86::JCC_2:
95-
case X86::JCC_4:
96-
return Inst.getOperand(Info->get(Inst.getOpcode()).NumOperands - 1)
97-
.getImm();
98-
}
90+
unsigned Opcode = Inst.getOpcode();
91+
if (X86::isJCC(Opcode))
92+
return Inst.getOperand(Info->get(Opcode).NumOperands - 1).getImm();
93+
return X86::COND_INVALID;
9994
}
10095

10196
unsigned getInvertedCondCode(unsigned CC) const override {
@@ -183,13 +178,8 @@ class X86MCPlusBuilder : public MCPlusBuilder {
183178
}
184179

185180
bool isPrefix(const MCInst &Inst) const override {
186-
switch (Inst.getOpcode()) {
187-
case X86::LOCK_PREFIX:
188-
case X86::REPNE_PREFIX:
189-
case X86::REP_PREFIX:
190-
return true;
191-
}
192-
return false;
181+
const MCInstrDesc &Desc = Info->get(Inst.getOpcode());
182+
return X86II::isPrefix(Desc.TSFlags);
193183
}
194184

195185
bool isRep(const MCInst &Inst) const override {
@@ -206,21 +196,9 @@ class X86MCPlusBuilder : public MCPlusBuilder {
206196

207197
// FIXME: For compatibility with old LLVM only!
208198
bool isTerminator(const MCInst &Inst) const override {
209-
if (Info->get(Inst.getOpcode()).isTerminator())
210-
return true;
211-
switch (Inst.getOpcode()) {
212-
default:
213-
return false;
214-
case X86::TRAP:
215-
// Opcodes previously known as X86::UD2B
216-
case X86::UD1Wm:
217-
case X86::UD1Lm:
218-
case X86::UD1Qm:
219-
case X86::UD1Wr:
220-
case X86::UD1Lr:
221-
case X86::UD1Qr:
222-
return true;
223-
}
199+
unsigned Opcode = Inst.getOpcode();
200+
return Info->get(Opcode).isTerminator() || X86::isUD1(Opcode) ||
201+
X86::isUD2(Opcode);
224202
}
225203

226204
bool isIndirectCall(const MCInst &Inst) const override {

0 commit comments

Comments
 (0)