Skip to content

Commit d68837a

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:782f1a0d8956 into amd-gfx:b08b9d7e72fc
Local branch amd-gfx b08b9d7 Merged main:b8b4ee6b4507 into amd-gfx:d15fa08abe6d Remote branch main 782f1a0 [gn build] Port e5f169f
2 parents b08b9d7 + 782f1a0 commit d68837a

File tree

15 files changed

+157
-130
lines changed

15 files changed

+157
-130
lines changed

clang/lib/Interpreter/IncrementalExecutor.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include "clang/Interpreter/PartialTranslationUnit.h"
1818
#include "llvm/ExecutionEngine/ExecutionEngine.h"
1919
#include "llvm/ExecutionEngine/Orc/CompileUtils.h"
20-
#include "llvm/ExecutionEngine/Orc/DebuggerSupport.h"
2120
#include "llvm/ExecutionEngine/Orc/ExecutionUtils.h"
2221
#include "llvm/ExecutionEngine/Orc/IRCompileLayer.h"
2322
#include "llvm/ExecutionEngine/Orc/LLJIT.h"
@@ -47,13 +46,8 @@ IncrementalExecutor::IncrementalExecutor(llvm::orc::ThreadSafeContext &TSC,
4746
JTMB.addFeatures(TI.getTargetOpts().Features);
4847
LLJITBuilder Builder;
4948
Builder.setJITTargetMachineBuilder(JTMB);
50-
Builder.setPrePlatformSetup(
51-
[](LLJIT &J) {
52-
// Try to enable debugging of JIT'd code (only works with JITLink for
53-
// ELF and MachO).
54-
consumeError(enableDebuggerSupport(J));
55-
return llvm::Error::success();
56-
});
49+
// Enable debugging of JIT'd code (only works on JITLink for ELF and MachO).
50+
Builder.setEnableDebuggerSupport(true);
5751

5852
if (auto JitOrErr = Builder.create())
5953
Jit = std::move(*JitOrErr);

clang/tools/clang-repl/ClangRepl.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,9 @@ int main(int argc, const char **argv) {
152152
llvm::InitializeAllAsmPrinters();
153153

154154
if (OptHostSupportsJit) {
155-
auto J = llvm::orc::LLJITBuilder().create();
155+
auto J = llvm::orc::LLJITBuilder()
156+
.setEnableDebuggerSupport(true)
157+
.create();
156158
if (J)
157159
llvm::outs() << "true\n";
158160
else {

clang/unittests/Interpreter/ExceptionTests/InterpreterExceptionTest.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ TEST(InterpreterTest, CatchException) {
5252
llvm::InitializeNativeTargetAsmPrinter();
5353

5454
{
55-
auto J = llvm::orc::LLJITBuilder().create();
55+
auto J = llvm::orc::LLJITBuilder()
56+
.setEnableDebuggerSupport(true)
57+
.create();
5658
if (!J) {
5759
// The platform does not support JITs.
5860
// Using llvm::consumeError will require typeinfo for ErrorInfoBase, we

clang/unittests/Interpreter/InterpreterTest.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,9 @@ static std::string MangleName(NamedDecl *ND) {
191191
}
192192

193193
static bool HostSupportsJit() {
194-
auto J = llvm::orc::LLJITBuilder().create();
194+
auto J = llvm::orc::LLJITBuilder()
195+
.setEnableDebuggerSupport(true)
196+
.create();
195197
if (J)
196198
return true;
197199
LLVMConsumeError(llvm::wrap(J.takeError()));

llvm/include/llvm/Config/llvm-config.h.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
/* Indicate that this is LLVM compiled from the amd-gfx branch. */
1818
#define LLVM_HAVE_BRANCH_AMD_GFX
19-
#define LLVM_MAIN_REVISION 475721
19+
#define LLVM_MAIN_REVISION 475724
2020

2121
/* Define if LLVM_ENABLE_DUMP is enabled */
2222
#cmakedefine LLVM_ENABLE_DUMP

llvm/include/llvm/ExecutionEngine/Orc/DebuggerSupport.h

Lines changed: 0 additions & 28 deletions
This file was deleted.

llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ class LLJITBuilderState {
322322
unique_function<Error(LLJIT &)> PrePlatformSetup;
323323
PlatformSetupFunction SetUpPlatform;
324324
unsigned NumCompileThreads = 0;
325+
bool EnableDebuggerSupport = false;
325326

326327
/// Called prior to JIT class construcion to fix up defaults.
327328
Error prepareForConstruction();
@@ -454,6 +455,12 @@ class LLJITBuilderSetters {
454455
return impl();
455456
}
456457

458+
/// Enable / disable debugger support (off by default).
459+
SetterImpl &setEnableDebuggerSupport(bool EnableDebuggerSupport) {
460+
impl().EnableDebuggerSupport = EnableDebuggerSupport;
461+
return impl();
462+
}
463+
457464
/// Set an ExecutorProcessControl object.
458465
///
459466
/// If the platform uses ObjectLinkingLayer by default and no

llvm/lib/ExecutionEngine/Orc/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ add_llvm_component_library(LLVMOrcJIT
1313
CompileUtils.cpp
1414
Core.cpp
1515
DebugObjectManagerPlugin.cpp
16-
DebuggerSupport.cpp
1716
DebuggerSupportPlugin.cpp
1817
DebugUtils.cpp
1918
EPCDynamicLibrarySearchGenerator.cpp

llvm/lib/ExecutionEngine/Orc/DebuggerSupport.cpp

Lines changed: 0 additions & 61 deletions
This file was deleted.

llvm/lib/ExecutionEngine/Orc/LLJIT.cpp

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#include "llvm/ExecutionEngine/JITLink/EHFrameSupport.h"
1111
#include "llvm/ExecutionEngine/JITLink/JITLinkMemoryManager.h"
1212
#include "llvm/ExecutionEngine/Orc/COFFPlatform.h"
13+
#include "llvm/ExecutionEngine/Orc/DebugObjectManagerPlugin.h"
14+
#include "llvm/ExecutionEngine/Orc/DebuggerSupportPlugin.h"
1315
#include "llvm/ExecutionEngine/Orc/ELFNixPlatform.h"
1416
#include "llvm/ExecutionEngine/Orc/EPCDynamicLibrarySearchGenerator.h"
1517
#include "llvm/ExecutionEngine/Orc/EPCEHFrameRegistrar.h"
@@ -779,8 +781,18 @@ Error LLJITBuilderState::prepareForConstruction() {
779781

780782
// If we need a process JITDylib but no setup function has been given then
781783
// create a default one.
782-
if (!SetupProcessSymbolsJITDylib && LinkProcessSymbolsByDefault) {
783-
LLVM_DEBUG(dbgs() << "Creating default Process JD setup function\n");
784+
if (!SetupProcessSymbolsJITDylib &&
785+
(LinkProcessSymbolsByDefault || EnableDebuggerSupport)) {
786+
787+
LLVM_DEBUG({
788+
dbgs() << "Creating default Process JD setup function (neeeded for";
789+
if (LinkProcessSymbolsByDefault)
790+
dbgs() << " <link-process-syms-by-default>";
791+
if (EnableDebuggerSupport)
792+
dbgs() << " <debugger-support>";
793+
dbgs() << ")\n";
794+
});
795+
784796
SetupProcessSymbolsJITDylib = [this](LLJIT &J) -> Expected<JITDylibSP> {
785797
auto &JD =
786798
J.getExecutionSession().createBareJITDylib("<Process Symbols>");
@@ -1002,6 +1014,46 @@ LLJIT::LLJIT(LLJITBuilderState &S, Error &Err)
10021014
}
10031015
}
10041016

1017+
if (S.EnableDebuggerSupport) {
1018+
if (auto *OLL = dyn_cast<ObjectLinkingLayer>(ObjLinkingLayer.get())) {
1019+
switch (TT.getObjectFormat()) {
1020+
case Triple::ELF: {
1021+
auto Registrar = createJITLoaderGDBRegistrar(*ES);
1022+
if (!Registrar) {
1023+
Err = Registrar.takeError();
1024+
return;
1025+
}
1026+
OLL->addPlugin(std::make_unique<DebugObjectManagerPlugin>(
1027+
*ES, std::move(*Registrar), true, true));
1028+
break;
1029+
}
1030+
case Triple::MachO: {
1031+
assert(ProcessSymbols && "ProcessSymbols JD should be available when "
1032+
"EnableDebuggerSupport is set");
1033+
auto DS =
1034+
GDBJITDebugInfoRegistrationPlugin::Create(*ES, *ProcessSymbols, TT);
1035+
if (!DS) {
1036+
Err = DS.takeError();
1037+
return;
1038+
}
1039+
OLL->addPlugin(std::move(*DS));
1040+
break;
1041+
}
1042+
default:
1043+
LLVM_DEBUG({
1044+
dbgs() << "Cannot enable LLJIT debugger support: "
1045+
<< Triple::getObjectFormatTypeName(TT.getObjectFormat())
1046+
<< " not supported.\n";
1047+
});
1048+
}
1049+
} else {
1050+
LLVM_DEBUG({
1051+
dbgs() << "Cannot enable LLJIT debugger support: "
1052+
" debugger support is only available when using JITLink.\n";
1053+
});
1054+
}
1055+
}
1056+
10051057
if (S.PrePlatformSetup) {
10061058
if (auto Err2 = S.PrePlatformSetup(*this)) {
10071059
Err = std::move(Err2);

llvm/lib/Target/AArch64/AArch64InstrInfo.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2270,6 +2270,7 @@ bool AArch64InstrInfo::hasUnscaledLdStOffset(unsigned Opc) {
22702270
case AArch64::LDRWpre:
22712271
case AArch64::LDURXi:
22722272
case AArch64::LDRXpre:
2273+
case AArch64::LDRSWpre:
22732274
case AArch64::LDURSWi:
22742275
case AArch64::LDURHHi:
22752276
case AArch64::LDURBBi:
@@ -2479,6 +2480,7 @@ bool AArch64InstrInfo::isPairableLdStInst(const MachineInstr &MI) {
24792480
case AArch64::LDURXi:
24802481
case AArch64::LDRXpre:
24812482
case AArch64::LDURSWi:
2483+
case AArch64::LDRSWpre:
24822484
return true;
24832485
}
24842486
}
@@ -2599,7 +2601,8 @@ bool AArch64InstrInfo::isCandidateToMergeOrPair(const MachineInstr &MI) const {
25992601
// Can't merge/pair if the instruction modifies the base register.
26002602
// e.g., ldr x0, [x0]
26012603
// This case will never occur with an FI base.
2602-
// However, if the instruction is an LDR/STR<S,D,Q,W,X>pre, it can be merged.
2604+
// However, if the instruction is an LDR<S,D,Q,W,X,SW>pre or
2605+
// STR<S,D,Q,W,X>pre, it can be merged.
26032606
// For example:
26042607
// ldr q0, [x11, #32]!
26052608
// ldr q1, [x11, #16]
@@ -3176,6 +3179,7 @@ int AArch64InstrInfo::getMemScale(unsigned Opc) {
31763179
case AArch64::LDRSpre:
31773180
case AArch64::LDRSWui:
31783181
case AArch64::LDURSWi:
3182+
case AArch64::LDRSWpre:
31793183
case AArch64::LDRWpre:
31803184
case AArch64::LDRWui:
31813185
case AArch64::LDURWi:
@@ -3231,6 +3235,7 @@ bool AArch64InstrInfo::isPreLd(const MachineInstr &MI) {
32313235
return false;
32323236
case AArch64::LDRWpre:
32333237
case AArch64::LDRXpre:
3238+
case AArch64::LDRSWpre:
32343239
case AArch64::LDRSpre:
32353240
case AArch64::LDRDpre:
32363241
case AArch64::LDRQpre:

llvm/lib/Target/AArch64/AArch64LoadStoreOptimizer.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,8 @@ static unsigned getMatchingNonSExtOpcode(unsigned Opc,
293293
return AArch64::LDRWui;
294294
case AArch64::LDURSWi:
295295
return AArch64::LDURWi;
296+
case AArch64::LDRSWpre:
297+
return AArch64::LDRWpre;
296298
}
297299
}
298300

@@ -372,6 +374,8 @@ static unsigned getMatchingPairOpcode(unsigned Opc) {
372374
case AArch64::LDRSWui:
373375
case AArch64::LDURSWi:
374376
return AArch64::LDPSWi;
377+
case AArch64::LDRSWpre:
378+
return AArch64::LDPSWpre;
375379
}
376380
}
377381

@@ -585,6 +589,8 @@ static bool isPreLdStPairCandidate(MachineInstr &FirstMI, MachineInstr &MI) {
585589
return (OpcB == AArch64::LDRWui) || (OpcB == AArch64::LDURWi);
586590
case AArch64::LDRXpre:
587591
return (OpcB == AArch64::LDRXui) || (OpcB == AArch64::LDURXi);
592+
case AArch64::LDRSWpre:
593+
return (OpcB == AArch64::LDRSWui) || (OpcB == AArch64::LDURSWi);
588594
}
589595
}
590596

@@ -1318,6 +1324,10 @@ static bool areCandidatesToMergeOrPair(MachineInstr &FirstMI, MachineInstr &MI,
13181324
if (OpcA == OpcB)
13191325
return !AArch64InstrInfo::isPreLdSt(FirstMI);
13201326

1327+
// Two pre ld/st of different opcodes cannot be merged either
1328+
if (AArch64InstrInfo::isPreLdSt(FirstMI) && AArch64InstrInfo::isPreLdSt(MI))
1329+
return false;
1330+
13211331
// Try to match a sign-extended load/store with a zero-extended load/store.
13221332
bool IsValidLdStrOpc, PairIsValidLdStrOpc;
13231333
unsigned NonSExtOpc = getMatchingNonSExtOpcode(OpcA, &IsValidLdStrOpc);
@@ -1340,7 +1350,7 @@ static bool areCandidatesToMergeOrPair(MachineInstr &FirstMI, MachineInstr &MI,
13401350
return false;
13411351

13421352
// The STR<S,D,Q,W,X>pre - STR<S,D,Q,W,X>ui and
1343-
// LDR<S,D,Q,W,X>pre-LDR<S,D,Q,W,X>ui
1353+
// LDR<S,D,Q,W,X,SW>pre-LDR<S,D,Q,W,X,SW>ui
13441354
// are candidate pairs that can be merged.
13451355
if (isPreLdStPairCandidate(FirstMI, MI))
13461356
return true;

0 commit comments

Comments
 (0)