Original file line number Diff line number Diff line change
Expand Up @@ -29,38 +29,38 @@ using namespace lldb_private;
#reg, alt, 8, 0, eEncodingUint, eFormatHexUppercase, \
{dwarf_##reg##_x86_64, dwarf_##reg##_x86_64, generic, \
LLDB_INVALID_REGNUM, lldb_##reg##_x86_64 }, \
nullptr, nullptr, \
nullptr, nullptr, nullptr, \
}

#define DEFINE_GPR_BIN(reg, alt) #reg, alt, 8, 0, eEncodingUint, eFormatBinary
#define DEFINE_FPU_XMM(reg) \
#reg, NULL, 16, 0, eEncodingUint, eFormatVectorOfUInt64, \
{dwarf_##reg##_x86_64, dwarf_##reg##_x86_64, LLDB_INVALID_REGNUM, \
LLDB_INVALID_REGNUM, lldb_##reg##_x86_64}, \
nullptr, nullptr
nullptr, nullptr, nullptr,

#define DEFINE_GPR_PSEUDO_32(reg) \
{ \
#reg, nullptr, 4, 0, eEncodingUint, eFormatHexUppercase, \
{LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \
LLDB_INVALID_REGNUM, lldb_##reg##_x86_64 }, \
nullptr, nullptr \
nullptr, nullptr, nullptr, \
}

#define DEFINE_GPR_PSEUDO_16(reg) \
{ \
#reg, nullptr, 2, 0, eEncodingUint, eFormatHexUppercase, \
{LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \
LLDB_INVALID_REGNUM, lldb_##reg##_x86_64 }, \
nullptr, nullptr \
nullptr, nullptr, nullptr, \
}

#define DEFINE_GPR_PSEUDO_8(reg) \
{ \
#reg, nullptr, 1, 0, eEncodingUint, eFormatHexUppercase, \
{LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, \
LLDB_INVALID_REGNUM, lldb_##reg##_x86_64 }, \
nullptr, nullptr \
nullptr, nullptr, nullptr, \
}

namespace {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,42 @@ def test_scripted_extra_args(self):
self.setup_targets_and_cleanup()
self.do_check_extra_args()

def test_resolver_serialization(self):
"""Test that breakpoint resolvers contain the expected information"""
self.build()
self.setup_targets_and_cleanup()

exe_path = self.getBuildArtifact("a.out")
exe_module = self.orig_target.module[exe_path]
self.assertTrue(
exe_module.IsValid(), "Failed to find the executable module in target"
)
sym_ctx_list = exe_module.FindFunctions("main")
self.assertTrue(sym_ctx_list.GetSize() == 1, "Unable to find function 'main'")
sym_ctx = sym_ctx_list.GetContextAtIndex(0)
self.assertTrue(
sym_ctx.IsValid(), "SBSymbolContext representing function 'main' is invalid"
)
main_func = sym_ctx.GetFunction()
self.assertTrue(
main_func.IsValid(), "SBFunction representing 'main' is invalid"
)
main_addr = main_func.GetStartAddress()

bkpt = self.orig_target.BreakpointCreateBySBAddress(main_addr)
self.assertTrue(
bkpt.IsValid(), "Could not place breakpoint on 'main' by address"
)
stream = lldb.SBStream()
sd = bkpt.SerializeToStructuredData()
sd.GetAsJSON(stream)
serialized_data = json.loads(stream.GetData())

self.assertIn(
exe_path,
serialized_data["Breakpoint"]["BKPTResolver"]["Options"]["ModuleName"],
)

def test_structured_data_serialization(self):
target = self.dbg.GetDummyTarget()
self.assertTrue(target.IsValid(), VALID_TARGET)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,13 @@ def test_OneTargetOneDebugger(self):
# This test tests for the desired behavior as an expected fail.
@skipIfWindows
@expectedFailureAll
@skipIf(oslist=["linux"], archs=["arm", "aarch64"])
def test_TwoTargetsOneDebugger(self):
self.do_test(False, True)

@skipIfWindows
@expectedFailureAll
@skipIf(oslist=["linux"], archs=["arm", "aarch64"])
def test_OneTargetTwoDebuggers(self):
self.do_test(True, False)

Expand Down
4 changes: 0 additions & 4 deletions llvm/docs/CommandGuide/llvm-cxxfilt.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ OPTIONS

Print a summary of command line options.

.. option:: --no-params, -p

Do not demangle function parameters or return types.

.. option:: --no-strip-underscore, -n

Do not strip a leading underscore. This is the default for all platforms
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ set(LLVM_LINK_COMPONENTS
ExecutionEngine
IRReader
JITLink
OrcDebugging
OrcJIT
OrcShared
OrcTargetProcess
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
//
//===----------------------------------------------------------------------===//

#include "llvm/ExecutionEngine/Orc/Debugging/DebuggerSupport.h"
#include "llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h"
#include "llvm/ExecutionEngine/Orc/LLJIT.h"
#include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h"
Expand Down Expand Up @@ -174,32 +175,13 @@ int main(int argc, char *argv[]) {
TSMs.push_back(ExitOnErr(parseExampleModuleFromFile(Path)));
}

std::string TT;
StringRef MainModuleName;
TSMs.front().withModuleDo([&MainModuleName, &TT](Module &M) {
MainModuleName = M.getName();
TT = M.getTargetTriple();
if (TT.empty())
TT = sys::getProcessTriple();
});

// Create a target machine that matches the input triple.
JITTargetMachineBuilder JTMB((Triple(TT)));
JTMB.setCodeModel(CodeModel::Small);
JTMB.setRelocationModel(Reloc::PIC_);

// Create LLJIT and destroy it before disconnecting the target process.
outs() << "Initializing LLJIT for remote executor\n";
auto J = ExitOnErr(LLJITBuilder()
.setExecutorProcessControl(std::move(EPC))
.setJITTargetMachineBuilder(std::move(JTMB))
.setObjectLinkingLayerCreator([&](auto &ES, const auto &TT) {
return std::make_unique<ObjectLinkingLayer>(ES);
})
.create());
auto J = ExitOnErr(
LLJITBuilder().setExecutorProcessControl(std::move(EPC)).create());

// Add plugin for debug support.
ExitOnErr(addDebugSupport(J->getObjLinkingLayer()));
ExitOnErr(enableDebuggerSupport(*J));

// Load required shared libraries on the remote target and add a generator
// for each of it, so the compiler can lookup their symbols.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,6 @@
using namespace llvm;
using namespace llvm::orc;

Error addDebugSupport(ObjectLayer &ObjLayer) {
ExecutionSession &ES = ObjLayer.getExecutionSession();
auto Registrar = createJITLoaderGDBRegistrar(ES);
if (!Registrar)
return Registrar.takeError();

auto *ObjLinkingLayer = cast<ObjectLinkingLayer>(&ObjLayer);
if (!ObjLinkingLayer)
return createStringError(inconvertibleErrorCode(),
"No debug support for given object layer type");

ObjLinkingLayer->addPlugin(std::make_unique<DebugObjectManagerPlugin>(
ES, std::move(*Registrar), true, true));
return Error::success();
}

Expected<std::unique_ptr<DefinitionGenerator>>
loadDylib(ExecutionSession &ES, StringRef RemotePath) {
if (auto Handle = ES.getExecutorProcessControl().loadDylib(RemotePath.data()))
Expand Down Expand Up @@ -111,11 +95,15 @@ launchLocalExecutor(StringRef ExecutablePath) {
close(FromExecutor[ReadEnd]);

// Execute the child process.
std::unique_ptr<char[]> ExecPath, FDSpecifier;
std::unique_ptr<char[]> ExecPath, FDSpecifier, TestOutputFlag;
{
ExecPath = std::make_unique<char[]>(ExecutablePath.size() + 1);
strcpy(ExecPath.get(), ExecutablePath.data());

const char *TestOutputFlagStr = "test-jitloadergdb";
TestOutputFlag = std::make_unique<char[]>(strlen(TestOutputFlagStr) + 1);
strcpy(TestOutputFlag.get(), TestOutputFlagStr);

std::string FDSpecifierStr("filedescs=");
FDSpecifierStr += utostr(ToExecutor[ReadEnd]);
FDSpecifierStr += ',';
Expand All @@ -124,7 +112,8 @@ launchLocalExecutor(StringRef ExecutablePath) {
strcpy(FDSpecifier.get(), FDSpecifierStr.c_str());
}

char *const Args[] = {ExecPath.get(), FDSpecifier.get(), nullptr};
char *const Args[] = {ExecPath.get(), TestOutputFlag.get(),
FDSpecifier.get(), nullptr};
int RC = execvp(ExecPath.get(), Args);
if (RC != 0)
return make_error<StringError>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ launchLocalExecutor(llvm::StringRef ExecutablePath);
llvm::Expected<std::unique_ptr<llvm::orc::SimpleRemoteEPC>>
connectTCPSocket(llvm::StringRef NetworkAddress);

llvm::Error addDebugSupport(llvm::orc::ObjectLayer &ObjLayer);

llvm::Expected<std::unique_ptr<llvm::orc::DefinitionGenerator>>
loadDylib(llvm::orc::ExecutionSession &ES, llvm::StringRef RemotePath);

Expand Down
1 change: 1 addition & 0 deletions llvm/include/llvm/Analysis/AliasSetTracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ class AliasSetsPrinterPass : public PassInfoMixin<AliasSetsPrinterPass> {
public:
explicit AliasSetsPrinterPass(raw_ostream &OS);
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
static bool isRequired() { return true; }
};

} // end namespace llvm
Expand Down
2 changes: 2 additions & 0 deletions llvm/include/llvm/Analysis/AssumptionCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ class AssumptionPrinterPass : public PassInfoMixin<AssumptionPrinterPass> {
explicit AssumptionPrinterPass(raw_ostream &OS) : OS(OS) {}

PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);

static bool isRequired() { return true; }
};

/// An immutable pass that tracks lazily created \c AssumptionCache
Expand Down
2 changes: 2 additions & 0 deletions llvm/include/llvm/Analysis/BlockFrequencyInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ class BlockFrequencyPrinterPass
explicit BlockFrequencyPrinterPass(raw_ostream &OS) : OS(OS) {}

PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);

static bool isRequired() { return true; }
};

/// Legacy analysis pass which computes \c BlockFrequencyInfo.
Expand Down
2 changes: 2 additions & 0 deletions llvm/include/llvm/Analysis/BranchProbabilityInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,8 @@ class BranchProbabilityPrinterPass
explicit BranchProbabilityPrinterPass(raw_ostream &OS) : OS(OS) {}

PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);

static bool isRequired() { return true; }
};

/// Legacy analysis pass which computes \c BranchProbabilityInfo.
Expand Down
1 change: 1 addition & 0 deletions llvm/include/llvm/Analysis/CFGSCCPrinter.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class CFGSCCPrinterPass : public PassInfoMixin<CFGSCCPrinterPass> {
public:
explicit CFGSCCPrinterPass(raw_ostream &OS) : OS(OS) {}
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
static bool isRequired() { return true; }
};
} // namespace llvm

Expand Down
4 changes: 4 additions & 0 deletions llvm/include/llvm/Analysis/CallGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,8 @@ class CallGraphPrinterPass : public PassInfoMixin<CallGraphPrinterPass> {
explicit CallGraphPrinterPass(raw_ostream &OS) : OS(OS) {}

PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);

static bool isRequired() { return true; }
};

/// Printer pass for the summarized \c CallGraphAnalysis results.
Expand All @@ -333,6 +335,8 @@ class CallGraphSCCsPrinterPass
explicit CallGraphSCCsPrinterPass(raw_ostream &OS) : OS(OS) {}

PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);

static bool isRequired() { return true; }
};

/// The \c ModulePass which wraps up a \c CallGraph and the logic to
Expand Down
2 changes: 2 additions & 0 deletions llvm/include/llvm/Analysis/CallPrinter.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ class ModulePass;
class CallGraphDOTPrinterPass : public PassInfoMixin<CallGraphDOTPrinterPass> {
public:
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
static bool isRequired() { return true; }
};

/// Pass for viewing the call graph
class CallGraphViewerPass : public PassInfoMixin<CallGraphViewerPass> {
public:
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
static bool isRequired() { return true; }
};

ModulePass *createCallGraphViewerPass();
Expand Down
2 changes: 2 additions & 0 deletions llvm/include/llvm/Analysis/CostModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class CostModelPrinterPass : public PassInfoMixin<CostModelPrinterPass> {
explicit CostModelPrinterPass(raw_ostream &OS) : OS(OS) {}

PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);

static bool isRequired() { return true; }
};
} // end namespace llvm

Expand Down
2 changes: 2 additions & 0 deletions llvm/include/llvm/Analysis/CycleAnalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ class CycleInfoPrinterPass : public PassInfoMixin<CycleInfoPrinterPass> {
explicit CycleInfoPrinterPass(raw_ostream &OS);

PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);

static bool isRequired() { return true; }
};

} // end namespace llvm
Expand Down
1 change: 1 addition & 0 deletions llvm/include/llvm/Analysis/DDG.h
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ class DDGAnalysisPrinterPass : public PassInfoMixin<DDGAnalysisPrinterPass> {
explicit DDGAnalysisPrinterPass(raw_ostream &OS) : OS(OS) {}
PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM,
LoopStandardAnalysisResults &AR, LPMUpdater &U);
static bool isRequired() { return true; }

private:
raw_ostream &OS;
Expand Down
1 change: 1 addition & 0 deletions llvm/include/llvm/Analysis/DDGPrinter.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class DDGDotPrinterPass : public PassInfoMixin<DDGDotPrinterPass> {
public:
PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM,
LoopStandardAnalysisResults &AR, LPMUpdater &U);
static bool isRequired() { return true; }
};

//===--------------------------------------------------------------------===//
Expand Down
1 change: 1 addition & 0 deletions llvm/include/llvm/Analysis/Delinearization.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ struct DelinearizationPrinterPass
: public PassInfoMixin<DelinearizationPrinterPass> {
explicit DelinearizationPrinterPass(raw_ostream &OS);
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
static bool isRequired() { return true; }

private:
raw_ostream &OS;
Expand Down
2 changes: 2 additions & 0 deletions llvm/include/llvm/Analysis/DemandedBits.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ class DemandedBitsPrinterPass : public PassInfoMixin<DemandedBitsPrinterPass> {
explicit DemandedBitsPrinterPass(raw_ostream &OS) : OS(OS) {}

PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);

static bool isRequired() { return true; }
};

} // end namespace llvm
Expand Down
2 changes: 2 additions & 0 deletions llvm/include/llvm/Analysis/DependenceAnalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -994,6 +994,8 @@ namespace llvm {

PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM);

static bool isRequired() { return true; }

private:
raw_ostream &OS;
bool NormalizeResults;
Expand Down
2 changes: 2 additions & 0 deletions llvm/include/llvm/Analysis/DominanceFrontier.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ class DominanceFrontierPrinterPass
explicit DominanceFrontierPrinterPass(raw_ostream &OS);

PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);

static bool isRequired() { return true; }
};

} // end namespace llvm
Expand Down
2 changes: 2 additions & 0 deletions llvm/include/llvm/Analysis/FunctionPropertiesAnalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ class FunctionPropertiesPrinterPass
explicit FunctionPropertiesPrinterPass(raw_ostream &OS) : OS(OS) {}

PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);

static bool isRequired() { return true; }
};

/// Correctly update FunctionPropertiesInfo post-inlining. A
Expand Down
1 change: 1 addition & 0 deletions llvm/include/llvm/Analysis/IRSimilarityIdentifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -1198,6 +1198,7 @@ class IRSimilarityAnalysisPrinterPass
public:
explicit IRSimilarityAnalysisPrinterPass(raw_ostream &OS) : OS(OS) {}
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
static bool isRequired() { return true; }
};

} // end namespace llvm
Expand Down
3 changes: 2 additions & 1 deletion llvm/include/llvm/Analysis/InlineAdvisor.h
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ class InlineAdvisorAnalysis : public AnalysisInfoMixin<InlineAdvisorAnalysis> {
Result run(Module &M, ModuleAnalysisManager &MAM) { return Result(M, MAM); }
};

/// Printer pass for the FunctionPropertiesAnalysis results.
/// Printer pass for the InlineAdvisorAnalysis results.
class InlineAdvisorAnalysisPrinterPass
: public PassInfoMixin<InlineAdvisorAnalysisPrinterPass> {
raw_ostream &OS;
Expand All @@ -353,6 +353,7 @@ class InlineAdvisorAnalysisPrinterPass

PreservedAnalyses run(LazyCallGraph::SCC &InitialC, CGSCCAnalysisManager &AM,
LazyCallGraph &CG, CGSCCUpdateResult &UR);
static bool isRequired() { return true; }
};

std::unique_ptr<InlineAdvisor>
Expand Down
1 change: 1 addition & 0 deletions llvm/include/llvm/Analysis/InlineCost.h
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ struct InlineCostAnnotationPrinterPass
public:
explicit InlineCostAnnotationPrinterPass(raw_ostream &OS) : OS(OS) {}
PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM);
static bool isRequired() { return true; }
};
} // namespace llvm

Expand Down
2 changes: 2 additions & 0 deletions llvm/include/llvm/Analysis/InlineSizeEstimatorAnalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ class InlineSizeEstimatorAnalysisPrinterPass
explicit InlineSizeEstimatorAnalysisPrinterPass(raw_ostream &OS) : OS(OS) {}

PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);

static bool isRequired() { return true; }
};
} // namespace llvm
#endif // LLVM_ANALYSIS_INLINESIZEESTIMATORANALYSIS_H
4 changes: 4 additions & 0 deletions llvm/include/llvm/Analysis/LazyCallGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -1288,6 +1288,8 @@ class LazyCallGraphPrinterPass
explicit LazyCallGraphPrinterPass(raw_ostream &OS);

PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);

static bool isRequired() { return true; }
};

/// A pass which prints the call graph as a DOT file to a \c raw_ostream.
Expand All @@ -1301,6 +1303,8 @@ class LazyCallGraphDOTPrinterPass
explicit LazyCallGraphDOTPrinterPass(raw_ostream &OS);

PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);

static bool isRequired() { return true; }
};

} // end namespace llvm
Expand Down
2 changes: 2 additions & 0 deletions llvm/include/llvm/Analysis/LazyValueInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ class LazyValueInfoPrinterPass
explicit LazyValueInfoPrinterPass(raw_ostream &OS) : OS(OS) {}

PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);

static bool isRequired() { return true; }
};

/// Wrapper around LazyValueInfo.
Expand Down
2 changes: 2 additions & 0 deletions llvm/include/llvm/Analysis/LoopCacheAnalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,8 @@ class LoopCachePrinterPass : public PassInfoMixin<LoopCachePrinterPass> {

PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM,
LoopStandardAnalysisResults &AR, LPMUpdater &U);

static bool isRequired() { return true; }
};

} // namespace llvm
Expand Down
2 changes: 2 additions & 0 deletions llvm/include/llvm/Analysis/LoopInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -580,11 +580,13 @@ class LoopPrinterPass : public PassInfoMixin<LoopPrinterPass> {
public:
explicit LoopPrinterPass(raw_ostream &OS) : OS(OS) {}
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
static bool isRequired() { return true; }
};

/// Verifier pass for the \c LoopAnalysis results.
struct LoopVerifierPass : public PassInfoMixin<LoopVerifierPass> {
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
static bool isRequired() { return true; }
};

/// The legacy pass manager's analysis pass to compute loop information.
Expand Down
2 changes: 2 additions & 0 deletions llvm/include/llvm/Analysis/LoopNestAnalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ class LoopNestPrinterPass : public PassInfoMixin<LoopNestPrinterPass> {

PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM,
LoopStandardAnalysisResults &AR, LPMUpdater &U);

static bool isRequired() { return true; }
};

} // namespace llvm
Expand Down
1 change: 1 addition & 0 deletions llvm/include/llvm/Analysis/MemDerefPrinter.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class MemDerefPrinterPass : public PassInfoMixin<MemDerefPrinterPass> {
public:
MemDerefPrinterPass(raw_ostream &OS) : OS(OS) {}
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
static bool isRequired() { return true; }
};
} // namespace llvm

Expand Down
5 changes: 5 additions & 0 deletions llvm/include/llvm/Analysis/MemorySSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -953,6 +953,8 @@ class MemorySSAPrinterPass : public PassInfoMixin<MemorySSAPrinterPass> {
: OS(OS), EnsureOptimizedUses(EnsureOptimizedUses) {}

PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);

static bool isRequired() { return true; }
};

/// Printer pass for \c MemorySSA via the walker.
Expand All @@ -964,11 +966,14 @@ class MemorySSAWalkerPrinterPass
explicit MemorySSAWalkerPrinterPass(raw_ostream &OS) : OS(OS) {}

PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);

static bool isRequired() { return true; }
};

/// Verifier pass for \c MemorySSA.
struct MemorySSAVerifierPass : PassInfoMixin<MemorySSAVerifierPass> {
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
static bool isRequired() { return true; }
};

/// Legacy analysis pass which computes \c MemorySSA.
Expand Down
1 change: 1 addition & 0 deletions llvm/include/llvm/Analysis/ModuleDebugInfoPrinter.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class ModuleDebugInfoPrinterPass
public:
explicit ModuleDebugInfoPrinterPass(raw_ostream &OS);
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
static bool isRequired() { return true; }
};
} // end namespace llvm

Expand Down
2 changes: 2 additions & 0 deletions llvm/include/llvm/Analysis/MustExecute.h
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,7 @@ class MustExecutePrinterPass : public PassInfoMixin<MustExecutePrinterPass> {
public:
MustExecutePrinterPass(raw_ostream &OS) : OS(OS) {}
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
static bool isRequired() { return true; }
};

class MustBeExecutedContextPrinterPass
Expand All @@ -556,6 +557,7 @@ class MustBeExecutedContextPrinterPass
public:
MustBeExecutedContextPrinterPass(raw_ostream &OS) : OS(OS) {}
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
static bool isRequired() { return true; }
};

} // namespace llvm
Expand Down
1 change: 1 addition & 0 deletions llvm/include/llvm/Analysis/PhiValues.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ class PhiValuesPrinterPass : public PassInfoMixin<PhiValuesPrinterPass> {
public:
explicit PhiValuesPrinterPass(raw_ostream &OS) : OS(OS) {}
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
static bool isRequired() { return true; }
};

/// Wrapper pass for the legacy pass manager
Expand Down
2 changes: 2 additions & 0 deletions llvm/include/llvm/Analysis/PostDominators.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ class PostDominatorTreePrinterPass
explicit PostDominatorTreePrinterPass(raw_ostream &OS);

PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);

static bool isRequired() { return true; }
};

struct PostDominatorTreeWrapperPass : public FunctionPass {
Expand Down
1 change: 1 addition & 0 deletions llvm/include/llvm/Analysis/ProfileSummaryInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ class ProfileSummaryPrinterPass
public:
explicit ProfileSummaryPrinterPass(raw_ostream &OS) : OS(OS) {}
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
static bool isRequired() { return true; }
};

} // end namespace llvm
Expand Down
3 changes: 3 additions & 0 deletions llvm/include/llvm/Analysis/RegionInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -983,11 +983,14 @@ class RegionInfoPrinterPass : public PassInfoMixin<RegionInfoPrinterPass> {
explicit RegionInfoPrinterPass(raw_ostream &OS);

PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);

static bool isRequired() { return true; }
};

/// Verifier pass for the \c RegionInfo.
struct RegionInfoVerifierPass : PassInfoMixin<RegionInfoVerifierPass> {
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
static bool isRequired() { return true; }
};

template <>
Expand Down
3 changes: 3 additions & 0 deletions llvm/include/llvm/Analysis/ScalarEvolution.h
Original file line number Diff line number Diff line change
Expand Up @@ -2246,6 +2246,7 @@ class ScalarEvolutionVerifierPass
: public PassInfoMixin<ScalarEvolutionVerifierPass> {
public:
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
static bool isRequired() { return true; }
};

/// Printer pass for the \c ScalarEvolutionAnalysis results.
Expand All @@ -2257,6 +2258,8 @@ class ScalarEvolutionPrinterPass
explicit ScalarEvolutionPrinterPass(raw_ostream &OS) : OS(OS) {}

PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);

static bool isRequired() { return true; }
};

class ScalarEvolutionWrapperPass : public FunctionPass {
Expand Down
1 change: 1 addition & 0 deletions llvm/include/llvm/Analysis/StackLifetime.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ class StackLifetimePrinterPass
StackLifetimePrinterPass(raw_ostream &OS, StackLifetime::LivenessType Type)
: Type(Type), OS(OS) {}
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
static bool isRequired() { return true; }
void printPipeline(raw_ostream &OS,
function_ref<StringRef(StringRef)> MapClassName2PassName);
};
Expand Down
2 changes: 2 additions & 0 deletions llvm/include/llvm/Analysis/StackSafetyAnalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ class StackSafetyPrinterPass : public PassInfoMixin<StackSafetyPrinterPass> {
public:
explicit StackSafetyPrinterPass(raw_ostream &OS) : OS(OS) {}
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
static bool isRequired() { return true; }
};

/// StackSafetyInfo wrapper for the legacy pass manager
Expand Down Expand Up @@ -143,6 +144,7 @@ class StackSafetyGlobalPrinterPass
public:
explicit StackSafetyGlobalPrinterPass(raw_ostream &OS) : OS(OS) {}
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
static bool isRequired() { return true; }
};

/// This pass performs the global (interprocedural) stack safety analysis
Expand Down
2 changes: 2 additions & 0 deletions llvm/include/llvm/Analysis/StructuralHash.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class StructuralHashPrinterPass
: OS(OS), EnableDetailedStructuralHash(Detailed) {}

PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM);

static bool isRequired() { return true; }
};

} // namespace llvm
Expand Down
2 changes: 2 additions & 0 deletions llvm/include/llvm/Analysis/UniformityAnalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class UniformityInfoPrinterPass
explicit UniformityInfoPrinterPass(raw_ostream &OS);

PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);

static bool isRequired() { return true; }
};

/// Legacy analysis pass which computes a \ref CycleInfo.
Expand Down
6 changes: 4 additions & 2 deletions llvm/include/llvm/Bitstream/BitstreamWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,8 @@ class BitstreamWriter {

// Emit the bits with VBR encoding, NumBits-1 bits at a time.
while (Val >= Threshold) {
Emit((Val & ((1 << (NumBits-1))-1)) | (1 << (NumBits-1)), NumBits);
Emit((Val & ((1U << (NumBits - 1)) - 1)) | (1U << (NumBits - 1)),
NumBits);
Val >>= NumBits-1;
}

Expand All @@ -255,7 +256,8 @@ class BitstreamWriter {

// Emit the bits with VBR encoding, NumBits-1 bits at a time.
while (Val >= Threshold) {
Emit(((uint32_t)Val & ((1 << (NumBits - 1)) - 1)) | (1 << (NumBits - 1)),
Emit(((uint32_t)Val & ((1U << (NumBits - 1)) - 1)) |
(1U << (NumBits - 1)),
NumBits);
Val >>= NumBits-1;
}
Expand Down
15 changes: 10 additions & 5 deletions llvm/include/llvm/CodeGen/GlobalISel/LegalizerHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,11 +288,14 @@ class LegalizerHelper {

// Implements floating-point environment read/write via library function call.
LegalizeResult createGetStateLibcall(MachineIRBuilder &MIRBuilder,
MachineInstr &MI);
MachineInstr &MI,
LostDebugLocObserver &LocObserver);
LegalizeResult createSetStateLibcall(MachineIRBuilder &MIRBuilder,
MachineInstr &MI);
MachineInstr &MI,
LostDebugLocObserver &LocObserver);
LegalizeResult createResetStateLibcall(MachineIRBuilder &MIRBuilder,
MachineInstr &MI);
MachineInstr &MI,
LostDebugLocObserver &LocObserver);

public:
/// Return the alignment to use for a stack temporary object with the given
Expand Down Expand Up @@ -440,13 +443,15 @@ class LegalizerHelper {
LegalizerHelper::LegalizeResult
createLibcall(MachineIRBuilder &MIRBuilder, const char *Name,
const CallLowering::ArgInfo &Result,
ArrayRef<CallLowering::ArgInfo> Args, CallingConv::ID CC);
ArrayRef<CallLowering::ArgInfo> Args, CallingConv::ID CC,
LostDebugLocObserver &LocObserver, MachineInstr *MI = nullptr);

/// Helper function that creates the given libcall.
LegalizerHelper::LegalizeResult
createLibcall(MachineIRBuilder &MIRBuilder, RTLIB::Libcall Libcall,
const CallLowering::ArgInfo &Result,
ArrayRef<CallLowering::ArgInfo> Args);
ArrayRef<CallLowering::ArgInfo> Args,
LostDebugLocObserver &LocObserver, MachineInstr *MI = nullptr);

/// Create a libcall to memcpy et al.
LegalizerHelper::LegalizeResult
Expand Down
5 changes: 3 additions & 2 deletions llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ extern cl::opt<bool> DisableGISelLegalityCheck;
class MachineFunction;
class raw_ostream;
class LegalizerHelper;
class LostDebugLocObserver;
class MachineInstr;
class MachineRegisterInfo;
class MCInstrInfo;
Expand Down Expand Up @@ -1288,8 +1289,8 @@ class LegalizerInfo {
const MachineRegisterInfo &MRI) const;

/// Called for instructions with the Custom LegalizationAction.
virtual bool legalizeCustom(LegalizerHelper &Helper,
MachineInstr &MI) const {
virtual bool legalizeCustom(LegalizerHelper &Helper, MachineInstr &MI,
LostDebugLocObserver &LocObserver) const {
llvm_unreachable("must implement this if custom action is used");
}

Expand Down
13 changes: 9 additions & 4 deletions llvm/include/llvm/CodeGen/SelectionDAGNodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ struct SDNodeFlags {
bool NoUnsignedWrap : 1;
bool NoSignedWrap : 1;
bool Exact : 1;
bool Disjoint : 1;
bool NonNeg : 1;
bool NoNaNs : 1;
bool NoInfs : 1;
Expand All @@ -402,10 +403,11 @@ struct SDNodeFlags {
public:
/// Default constructor turns off all optimization flags.
SDNodeFlags()
: NoUnsignedWrap(false), NoSignedWrap(false), Exact(false), NonNeg(false),
NoNaNs(false), NoInfs(false), NoSignedZeros(false),
AllowReciprocal(false), AllowContract(false), ApproximateFuncs(false),
AllowReassociation(false), NoFPExcept(false), Unpredictable(false) {}
: NoUnsignedWrap(false), NoSignedWrap(false), Exact(false),
Disjoint(false), NonNeg(false), NoNaNs(false), NoInfs(false),
NoSignedZeros(false), AllowReciprocal(false), AllowContract(false),
ApproximateFuncs(false), AllowReassociation(false), NoFPExcept(false),
Unpredictable(false) {}

/// Propagate the fast-math-flags from an IR FPMathOperator.
void copyFMF(const FPMathOperator &FPMO) {
Expand All @@ -422,6 +424,7 @@ struct SDNodeFlags {
void setNoUnsignedWrap(bool b) { NoUnsignedWrap = b; }
void setNoSignedWrap(bool b) { NoSignedWrap = b; }
void setExact(bool b) { Exact = b; }
void setDisjoint(bool b) { Disjoint = b; }
void setNonNeg(bool b) { NonNeg = b; }
void setNoNaNs(bool b) { NoNaNs = b; }
void setNoInfs(bool b) { NoInfs = b; }
Expand All @@ -437,6 +440,7 @@ struct SDNodeFlags {
bool hasNoUnsignedWrap() const { return NoUnsignedWrap; }
bool hasNoSignedWrap() const { return NoSignedWrap; }
bool hasExact() const { return Exact; }
bool hasDisjoint() const { return Disjoint; }
bool hasNonNeg() const { return NonNeg; }
bool hasNoNaNs() const { return NoNaNs; }
bool hasNoInfs() const { return NoInfs; }
Expand All @@ -454,6 +458,7 @@ struct SDNodeFlags {
NoUnsignedWrap &= Flags.NoUnsignedWrap;
NoSignedWrap &= Flags.NoSignedWrap;
Exact &= Flags.Exact;
Disjoint &= Flags.Disjoint;
NonNeg &= Flags.NonNeg;
NoNaNs &= Flags.NoNaNs;
NoInfs &= Flags.NoInfs;
Expand Down
5 changes: 2 additions & 3 deletions llvm/include/llvm/Demangle/Demangle.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ enum : int {
/// Returns a non-NULL pointer to a NUL-terminated C style string
/// that should be explicitly freed, if successful. Otherwise, may return
/// nullptr if mangled_name is not a valid mangling or is nullptr.
char *itaniumDemangle(std::string_view mangled_name, bool ParseParams = true);
char *itaniumDemangle(std::string_view mangled_name);

enum MSDemangleFlags {
MSDF_None = 0,
Expand Down Expand Up @@ -68,8 +68,7 @@ char *dlangDemangle(std::string_view MangledName);
std::string demangle(std::string_view MangledName);

bool nonMicrosoftDemangle(std::string_view MangledName, std::string &Result,
bool CanHaveLeadingDot = true,
bool ParseParams = true);
bool CanHaveLeadingDot = true);

/// "Partial" demangler. This supports demangling a string into an AST
/// (typically an intermediate stage in itaniumDemangle) and querying certain
Expand Down
22 changes: 6 additions & 16 deletions llvm/include/llvm/Demangle/ItaniumDemangle.h
Original file line number Diff line number Diff line change
Expand Up @@ -2793,7 +2793,7 @@ template <typename Derived, typename Alloc> struct AbstractManglingParser {
Node *parseClassEnumType();
Node *parseQualifiedType();

Node *parseEncoding(bool ParseParams = true);
Node *parseEncoding();
bool parseCallOffset();
Node *parseSpecialName();

Expand Down Expand Up @@ -2910,7 +2910,7 @@ template <typename Derived, typename Alloc> struct AbstractManglingParser {
Node *parseDestructorName();

/// Top-level entry point into the parser.
Node *parse(bool ParseParams = true);
Node *parse();
};

const char* parse_discriminator(const char* first, const char* last);
Expand Down Expand Up @@ -5404,7 +5404,7 @@ Node *AbstractManglingParser<Derived, Alloc>::parseSpecialName() {
// ::= <data name>
// ::= <special-name>
template <typename Derived, typename Alloc>
Node *AbstractManglingParser<Derived, Alloc>::parseEncoding(bool ParseParams) {
Node *AbstractManglingParser<Derived, Alloc>::parseEncoding() {
// The template parameters of an encoding are unrelated to those of the
// enclosing context.
SaveTemplateParams SaveTemplateParamsScope(this);
Expand All @@ -5430,16 +5430,6 @@ Node *AbstractManglingParser<Derived, Alloc>::parseEncoding(bool ParseParams) {
if (IsEndOfEncoding())
return Name;

// ParseParams may be false at the top level only, when called from parse().
// For example in the mangled name _Z3fooILZ3BarEET_f, ParseParams may be
// false when demangling 3fooILZ3BarEET_f but is always true when demangling
// 3Bar.
if (!ParseParams) {
while (consume())
;
return Name;
}

Node *Attrs = nullptr;
if (consumeIf("Ua9enable_ifI")) {
size_t BeforeArgs = Names.size();
Expand Down Expand Up @@ -5904,9 +5894,9 @@ AbstractManglingParser<Derived, Alloc>::parseTemplateArgs(bool TagTemplates) {
// extension ::= ___Z <encoding> _block_invoke<decimal-digit>+
// extension ::= ___Z <encoding> _block_invoke_<decimal-digit>+
template <typename Derived, typename Alloc>
Node *AbstractManglingParser<Derived, Alloc>::parse(bool ParseParams) {
Node *AbstractManglingParser<Derived, Alloc>::parse() {
if (consumeIf("_Z") || consumeIf("__Z")) {
Node *Encoding = getDerived().parseEncoding(ParseParams);
Node *Encoding = getDerived().parseEncoding();
if (Encoding == nullptr)
return nullptr;
if (look() == '.') {
Expand All @@ -5920,7 +5910,7 @@ Node *AbstractManglingParser<Derived, Alloc>::parse(bool ParseParams) {
}

if (consumeIf("___Z") || consumeIf("____Z")) {
Node *Encoding = getDerived().parseEncoding(ParseParams);
Node *Encoding = getDerived().parseEncoding();
if (Encoding == nullptr || !consumeIf("_block_invoke"))
return nullptr;
bool RequireNumber = consumeIf('_');
Expand Down
26 changes: 26 additions & 0 deletions llvm/include/llvm/ExecutionEngine/Orc/TargetProcess/JITLoaderGDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,32 @@
#include "llvm/ExecutionEngine/Orc/Shared/WrapperFunctionUtils.h"
#include <cstdint>

// Keep in sync with gdb/gdb/jit.h
extern "C" {

typedef enum {
JIT_NOACTION = 0,
JIT_REGISTER_FN,
JIT_UNREGISTER_FN
} jit_actions_t;

struct jit_code_entry {
struct jit_code_entry *next_entry;
struct jit_code_entry *prev_entry;
const char *symfile_addr;
uint64_t symfile_size;
};

struct jit_descriptor {
uint32_t version;
// This should be jit_actions_t, but we want to be specific about the
// bit-width.
uint32_t action_flag;
struct jit_code_entry *relevant_entry;
struct jit_code_entry *first_entry;
};
}

extern "C" llvm::orc::shared::CWrapperFunctionResult
llvm_orc_registerJITLoaderGDBWrapper(const char *Data, uint64_t Size);

Expand Down
3 changes: 3 additions & 0 deletions llvm/include/llvm/IR/Dominators.h
Original file line number Diff line number Diff line change
Expand Up @@ -293,11 +293,14 @@ class DominatorTreePrinterPass
explicit DominatorTreePrinterPass(raw_ostream &OS);

PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);

static bool isRequired() { return true; }
};

/// Verifier pass for the \c DominatorTree.
struct DominatorTreeVerifierPass : PassInfoMixin<DominatorTreeVerifierPass> {
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
static bool isRequired() { return true; }
};

/// Enables verification of dominator trees.
Expand Down
2 changes: 2 additions & 0 deletions llvm/include/llvm/IR/SafepointIRVerifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ class SafepointIRVerifierPass : public PassInfoMixin<SafepointIRVerifierPass> {
explicit SafepointIRVerifierPass() = default;

PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);

static bool isRequired() { return true; }
};
}

Expand Down
4 changes: 3 additions & 1 deletion llvm/include/llvm/LTO/LTO.h
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,9 @@ class LTO {
};

// Global mapping from mangled symbol names to resolutions.
StringMap<GlobalResolution> GlobalResolutions;
// Make this an optional to guard against accessing after it has been reset
// (to reduce memory after we're done with it).
std::optional<StringMap<GlobalResolution>> GlobalResolutions;

void addModuleToGlobalRes(ArrayRef<InputFile::Symbol> Syms,
ArrayRef<SymbolResolution> Res, unsigned Partition,
Expand Down
1 change: 1 addition & 0 deletions llvm/include/llvm/Target/GlobalISel/SelectionDAGCompat.td
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ def : GINodeEquiv<G_ATOMICRMW_FMIN, atomic_load_fmin>;
def : GINodeEquiv<G_ATOMICRMW_UINC_WRAP, atomic_load_uinc_wrap>;
def : GINodeEquiv<G_ATOMICRMW_UDEC_WRAP, atomic_load_udec_wrap>;
def : GINodeEquiv<G_FENCE, atomic_fence>;
def : GINodeEquiv<G_PREFETCH, prefetch>;

// Specifies the GlobalISel equivalents for SelectionDAG's ComplexPattern.
// Should be used on defs that subclass GIComplexOperandMatcher<>.
Expand Down
4 changes: 3 additions & 1 deletion llvm/include/llvm/Target/TargetMachine.h
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,9 @@ class TargetMachine {
virtual TargetTransformInfo getTargetTransformInfo(const Function &F) const;

/// Allow the target to modify the pass pipeline.
virtual void registerPassBuilderCallbacks(PassBuilder &) {}
// TODO: Populate all pass names by using <Target>PassRegistry.def.
virtual void registerPassBuilderCallbacks(PassBuilder &,
bool PopulateClassToPassNames) {}

/// Allow the target to register alias analyses with the AAManager for use
/// with the new pass manager. Only affects the "default" AAManager.
Expand Down
1 change: 1 addition & 0 deletions llvm/include/llvm/Transforms/Scalar/IVUsersPrinter.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class IVUsersPrinterPass : public PassInfoMixin<IVUsersPrinterPass> {
explicit IVUsersPrinterPass(raw_ostream &OS) : OS(OS) {}
PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM,
LoopStandardAnalysisResults &AR, LPMUpdater &U);
static bool isRequired() { return true; }
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class LoopAccessInfoPrinterPass
public:
explicit LoopAccessInfoPrinterPass(raw_ostream &OS) : OS(OS) {}
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
static bool isRequired() { return true; }
};

} // End llvm namespace
Expand Down
2 changes: 2 additions & 0 deletions llvm/include/llvm/Transforms/Utils/PredicateInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,13 @@ class PredicateInfoPrinterPass
public:
explicit PredicateInfoPrinterPass(raw_ostream &OS) : OS(OS) {}
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
static bool isRequired() { return true; }
};

/// Verifier pass for \c PredicateInfo.
struct PredicateInfoVerifierPass : PassInfoMixin<PredicateInfoVerifierPass> {
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
static bool isRequired() { return true; }
};

} // end namespace llvm
Expand Down
13 changes: 10 additions & 3 deletions llvm/lib/Analysis/AssumptionCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "llvm/ADT/SmallVector.h"
#include "llvm/Analysis/AssumeBundleQueries.h"
#include "llvm/Analysis/TargetTransformInfo.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/InstrTypes.h"
Expand Down Expand Up @@ -77,9 +78,15 @@ findAffectedValues(CallBase *CI, TargetTransformInfo *TTI,
};

for (unsigned Idx = 0; Idx != CI->getNumOperandBundles(); Idx++) {
if (CI->getOperandBundleAt(Idx).Inputs.size() > ABA_WasOn &&
CI->getOperandBundleAt(Idx).getTagName() != IgnoreBundleTag)
AddAffected(CI->getOperandBundleAt(Idx).Inputs[ABA_WasOn], Idx);
OperandBundleUse Bundle = CI->getOperandBundleAt(Idx);
if (Bundle.getTagName() == "separate_storage") {
assert(Bundle.Inputs.size() == 2 &&
"separate_storage must have two args");
AddAffected(getUnderlyingObject(Bundle.Inputs[0]), Idx);
AddAffected(getUnderlyingObject(Bundle.Inputs[1]), Idx);
} else if (Bundle.Inputs.size() > ABA_WasOn &&
Bundle.getTagName() != IgnoreBundleTag)
AddAffected(Bundle.Inputs[ABA_WasOn], Idx);
}

Value *Cond = CI->getArgOperand(0), *A, *B;
Expand Down
39 changes: 18 additions & 21 deletions llvm/lib/Analysis/BasicAliasAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ static cl::opt<bool> EnableRecPhiAnalysis("basic-aa-recphi", cl::Hidden,
cl::init(true));

static cl::opt<bool> EnableSeparateStorageAnalysis("basic-aa-separate-storage",
cl::Hidden, cl::init(false));
cl::Hidden, cl::init(true));

/// SearchLimitReached / SearchTimes shows how often the limit of
/// to decompose GEPs is reached. It will affect the precision
Expand Down Expand Up @@ -1544,28 +1544,25 @@ AliasResult BasicAAResult::aliasCheck(const Value *V1, LocationSize V1Size,
return AliasResult::NoAlias;

if (CtxI && EnableSeparateStorageAnalysis) {
for (auto &AssumeVH : AC.assumptions()) {
if (!AssumeVH)
for (AssumptionCache::ResultElem &Elem : AC.assumptionsFor(O1)) {
if (!Elem || Elem.Index == AssumptionCache::ExprResultIdx)
continue;

AssumeInst *Assume = cast<AssumeInst>(AssumeVH);

for (unsigned Idx = 0; Idx < Assume->getNumOperandBundles(); Idx++) {
OperandBundleUse OBU = Assume->getOperandBundleAt(Idx);
if (OBU.getTagName() == "separate_storage") {
assert(OBU.Inputs.size() == 2);
const Value *Hint1 = OBU.Inputs[0].get();
const Value *Hint2 = OBU.Inputs[1].get();
// This is often a no-op; instcombine rewrites this for us. No-op
// getUnderlyingObject calls are fast, though.
const Value *HintO1 = getUnderlyingObject(Hint1);
const Value *HintO2 = getUnderlyingObject(Hint2);

if (((O1 == HintO1 && O2 == HintO2) ||
(O1 == HintO2 && O2 == HintO1)) &&
isValidAssumeForContext(Assume, CtxI, DT))
return AliasResult::NoAlias;
}
AssumeInst *Assume = cast<AssumeInst>(Elem);
OperandBundleUse OBU = Assume->getOperandBundleAt(Elem.Index);
if (OBU.getTagName() == "separate_storage") {
assert(OBU.Inputs.size() == 2);
const Value *Hint1 = OBU.Inputs[0].get();
const Value *Hint2 = OBU.Inputs[1].get();
// This is often a no-op; instcombine rewrites this for us. No-op
// getUnderlyingObject calls are fast, though.
const Value *HintO1 = getUnderlyingObject(Hint1);
const Value *HintO2 = getUnderlyingObject(Hint2);

if (((O1 == HintO1 && O2 == HintO2) ||
(O1 == HintO2 && O2 == HintO1)) &&
isValidAssumeForContext(Assume, CtxI, DT))
return AliasResult::NoAlias;
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Analysis/ConstraintSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,14 @@ bool ConstraintSystem::eliminateUsingFM() {
IdxUpper++;
}

if (MulOverflow(UpperV, ((-1) * LowerLast), M1))
if (MulOverflow(UpperV, -1 * LowerLast, M1))
return false;
if (IdxLower < LowerRow.size() && LowerRow[IdxLower].Id == CurrentId) {
LowerV = LowerRow[IdxLower].Coefficient;
IdxLower++;
}

if (MulOverflow(LowerV, (UpperLast), M2))
if (MulOverflow(LowerV, UpperLast, M2))
return false;
if (AddOverflow(M1, M2, N))
return false;
Expand Down
12 changes: 12 additions & 0 deletions llvm/lib/Analysis/InstructionSimplify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2204,6 +2204,13 @@ static Value *simplifyAndInst(Value *Op0, Value *Op1, const SimplifyQuery &Q,
match(Op1, m_c_Xor(m_Specific(Or), m_Specific(Y))))
return Constant::getNullValue(Op0->getType());

const APInt *C1;
Value *A;
// (A ^ C) & (A ^ ~C) -> 0
if (match(Op0, m_Xor(m_Value(A), m_APInt(C1))) &&
match(Op1, m_Xor(m_Specific(A), m_SpecificInt(~*C1))))
return Constant::getNullValue(Op0->getType());

if (Op0->getType()->isIntOrIntVectorTy(1)) {
if (std::optional<bool> Implied = isImpliedCondition(Op0, Op1, Q.DL)) {
// If Op0 is true implies Op1 is true, then Op0 is a subset of Op1.
Expand Down Expand Up @@ -2473,6 +2480,11 @@ static Value *simplifyOrInst(Value *Op0, Value *Op1, const SimplifyQuery &Q,
if (Value *V = threadBinOpOverPHI(Instruction::Or, Op0, Op1, Q, MaxRecurse))
return V;

// (A ^ C) | (A ^ ~C) -> -1, i.e. all bits set to one.
if (match(Op0, m_Xor(m_Value(A), m_APInt(C1))) &&
match(Op1, m_Xor(m_Specific(A), m_SpecificInt(~*C1))))
return Constant::getAllOnesValue(Op0->getType());

if (Op0->getType()->isIntOrIntVectorTy(1)) {
if (std::optional<bool> Implied =
isImpliedCondition(Op0, Op1, Q.DL, false)) {
Expand Down
4 changes: 3 additions & 1 deletion llvm/lib/Analysis/LoopInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,9 @@ LoopInfo LoopAnalysis::run(Function &F, FunctionAnalysisManager &AM) {

PreservedAnalyses LoopPrinterPass::run(Function &F,
FunctionAnalysisManager &AM) {
AM.getResult<LoopAnalysis>(F).print(OS);
auto &LI = AM.getResult<LoopAnalysis>(F);
OS << "Loop info for function '" << F.getName() << "':\n";
LI.print(OS);
return PreservedAnalyses::all();
}

Expand Down
114 changes: 77 additions & 37 deletions llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ LegalizerHelper::legalizeInstrStep(MachineInstr &MI,
return moreElementsVector(MI, Step.TypeIdx, Step.NewType);
case Custom:
LLVM_DEBUG(dbgs() << ".. Custom legalization\n");
return LI.legalizeCustom(*this, MI) ? Legalized : UnableToLegalize;
return LI.legalizeCustom(*this, MI, LocObserver) ? Legalized
: UnableToLegalize;
default:
LLVM_DEBUG(dbgs() << ".. Unable to legalize\n");
return UnableToLegalize;
Expand Down Expand Up @@ -567,7 +568,8 @@ static RTLIB::Libcall getRTLibDesc(unsigned Opcode, unsigned Size) {

/// True if an instruction is in tail position in its caller. Intended for
/// legalizing libcalls as tail calls when possible.
static bool isLibCallInTailPosition(MachineInstr &MI,
static bool isLibCallInTailPosition(const CallLowering::ArgInfo &Result,
MachineInstr &MI,
const TargetInstrInfo &TII,
MachineRegisterInfo &MRI) {
MachineBasicBlock &MBB = *MI.getParent();
Expand Down Expand Up @@ -596,17 +598,12 @@ static bool isLibCallInTailPosition(MachineInstr &MI,
// RET_ReallyLR implicit $x0
auto Next = next_nodbg(MI.getIterator(), MBB.instr_end());
if (Next != MBB.instr_end() && Next->isCopy()) {
switch (MI.getOpcode()) {
default:
llvm_unreachable("unsupported opcode");
case TargetOpcode::G_BZERO:
if (MI.getOpcode() == TargetOpcode::G_BZERO)
return false;
case TargetOpcode::G_MEMCPY:
case TargetOpcode::G_MEMMOVE:
case TargetOpcode::G_MEMSET:
break;
}

// For MEMCPY/MOMMOVE/MEMSET these will be the first use (the dst), as the
// mempy/etc routines return the same parameter. For other it will be the
// returned value.
Register VReg = MI.getOperand(0).getReg();
if (!VReg.isVirtual() || VReg != Next->getOperand(1).getReg())
return false;
Expand All @@ -622,7 +619,7 @@ static bool isLibCallInTailPosition(MachineInstr &MI,
if (Ret->getNumImplicitOperands() != 1)
return false;

if (PReg != Ret->getOperand(0).getReg())
if (!Ret->getOperand(0).isReg() || PReg != Ret->getOperand(0).getReg())
return false;

// Skip over the COPY that we just validated.
Expand All @@ -639,42 +636,73 @@ LegalizerHelper::LegalizeResult
llvm::createLibcall(MachineIRBuilder &MIRBuilder, const char *Name,
const CallLowering::ArgInfo &Result,
ArrayRef<CallLowering::ArgInfo> Args,
const CallingConv::ID CC) {
const CallingConv::ID CC, LostDebugLocObserver &LocObserver,
MachineInstr *MI) {
auto &CLI = *MIRBuilder.getMF().getSubtarget().getCallLowering();

CallLowering::CallLoweringInfo Info;
Info.CallConv = CC;
Info.Callee = MachineOperand::CreateES(Name);
Info.OrigRet = Result;
if (MI)
Info.IsTailCall =
(Result.Ty->isVoidTy() ||
Result.Ty == MIRBuilder.getMF().getFunction().getReturnType()) &&
isLibCallInTailPosition(Result, *MI, MIRBuilder.getTII(),
*MIRBuilder.getMRI());

std::copy(Args.begin(), Args.end(), std::back_inserter(Info.OrigArgs));
if (!CLI.lowerCall(MIRBuilder, Info))
return LegalizerHelper::UnableToLegalize;

if (MI && Info.LoweredTailCall) {
assert(Info.IsTailCall && "Lowered tail call when it wasn't a tail call?");

// Check debug locations before removing the return.
LocObserver.checkpoint(true);

// We must have a return following the call (or debug insts) to get past
// isLibCallInTailPosition.
do {
MachineInstr *Next = MI->getNextNode();
assert(Next &&
(Next->isCopy() || Next->isReturn() || Next->isDebugInstr()) &&
"Expected instr following MI to be return or debug inst?");
// We lowered a tail call, so the call is now the return from the block.
// Delete the old return.
Next->eraseFromParent();
} while (MI->getNextNode());

// We expect to lose the debug location from the return.
LocObserver.checkpoint(false);
}
return LegalizerHelper::Legalized;
}

LegalizerHelper::LegalizeResult
llvm::createLibcall(MachineIRBuilder &MIRBuilder, RTLIB::Libcall Libcall,
const CallLowering::ArgInfo &Result,
ArrayRef<CallLowering::ArgInfo> Args) {
ArrayRef<CallLowering::ArgInfo> Args,
LostDebugLocObserver &LocObserver, MachineInstr *MI) {
auto &TLI = *MIRBuilder.getMF().getSubtarget().getTargetLowering();
const char *Name = TLI.getLibcallName(Libcall);
const CallingConv::ID CC = TLI.getLibcallCallingConv(Libcall);
return createLibcall(MIRBuilder, Name, Result, Args, CC);
return createLibcall(MIRBuilder, Name, Result, Args, CC, LocObserver, MI);
}

// Useful for libcalls where all operands have the same type.
static LegalizerHelper::LegalizeResult
simpleLibcall(MachineInstr &MI, MachineIRBuilder &MIRBuilder, unsigned Size,
Type *OpType) {
Type *OpType, LostDebugLocObserver &LocObserver) {
auto Libcall = getRTLibDesc(MI.getOpcode(), Size);

// FIXME: What does the original arg index mean here?
SmallVector<CallLowering::ArgInfo, 3> Args;
for (const MachineOperand &MO : llvm::drop_begin(MI.operands()))
Args.push_back({MO.getReg(), OpType, 0});
return createLibcall(MIRBuilder, Libcall,
{MI.getOperand(0).getReg(), OpType, 0}, Args);
{MI.getOperand(0).getReg(), OpType, 0}, Args,
LocObserver, &MI);
}

LegalizerHelper::LegalizeResult
Expand Down Expand Up @@ -733,8 +761,9 @@ llvm::createMemLibcall(MachineIRBuilder &MIRBuilder, MachineRegisterInfo &MRI,
Info.CallConv = TLI.getLibcallCallingConv(RTLibcall);
Info.Callee = MachineOperand::CreateES(Name);
Info.OrigRet = CallLowering::ArgInfo({0}, Type::getVoidTy(Ctx), 0);
Info.IsTailCall = MI.getOperand(MI.getNumOperands() - 1).getImm() &&
isLibCallInTailPosition(MI, MIRBuilder.getTII(), MRI);
Info.IsTailCall =
MI.getOperand(MI.getNumOperands() - 1).getImm() &&
isLibCallInTailPosition(Info.OrigRet, MI, MIRBuilder.getTII(), MRI);

std::copy(Args.begin(), Args.end(), std::back_inserter(Info.OrigArgs));
if (!CLI.lowerCall(MIRBuilder, Info))
Expand Down Expand Up @@ -789,11 +818,11 @@ static RTLIB::Libcall getConvRTLibDesc(unsigned Opcode, Type *ToType,

static LegalizerHelper::LegalizeResult
conversionLibcall(MachineInstr &MI, MachineIRBuilder &MIRBuilder, Type *ToType,
Type *FromType) {
Type *FromType, LostDebugLocObserver &LocObserver) {
RTLIB::Libcall Libcall = getConvRTLibDesc(MI.getOpcode(), ToType, FromType);
return createLibcall(MIRBuilder, Libcall,
{MI.getOperand(0).getReg(), ToType, 0},
{{MI.getOperand(1).getReg(), FromType, 0}});
return createLibcall(
MIRBuilder, Libcall, {MI.getOperand(0).getReg(), ToType, 0},
{{MI.getOperand(1).getReg(), FromType, 0}}, LocObserver, &MI);
}

static RTLIB::Libcall
Expand Down Expand Up @@ -829,7 +858,8 @@ getStateLibraryFunctionFor(MachineInstr &MI, const TargetLowering &TLI) {
//
LegalizerHelper::LegalizeResult
LegalizerHelper::createGetStateLibcall(MachineIRBuilder &MIRBuilder,
MachineInstr &MI) {
MachineInstr &MI,
LostDebugLocObserver &LocObserver) {
const DataLayout &DL = MIRBuilder.getDataLayout();
auto &MF = MIRBuilder.getMF();
auto &MRI = *MIRBuilder.getMRI();
Expand All @@ -850,7 +880,8 @@ LegalizerHelper::createGetStateLibcall(MachineIRBuilder &MIRBuilder,
auto Res =
createLibcall(MIRBuilder, RTLibcall,
CallLowering::ArgInfo({0}, Type::getVoidTy(Ctx), 0),
CallLowering::ArgInfo({Temp.getReg(0), StatePtrTy, 0}));
CallLowering::ArgInfo({Temp.getReg(0), StatePtrTy, 0}),
LocObserver, nullptr);
if (Res != LegalizerHelper::Legalized)
return Res;

Expand All @@ -867,7 +898,8 @@ LegalizerHelper::createGetStateLibcall(MachineIRBuilder &MIRBuilder,
// content of memory region.
LegalizerHelper::LegalizeResult
LegalizerHelper::createSetStateLibcall(MachineIRBuilder &MIRBuilder,
MachineInstr &MI) {
MachineInstr &MI,
LostDebugLocObserver &LocObserver) {
const DataLayout &DL = MIRBuilder.getDataLayout();
auto &MF = MIRBuilder.getMF();
auto &MRI = *MIRBuilder.getMRI();
Expand All @@ -892,7 +924,8 @@ LegalizerHelper::createSetStateLibcall(MachineIRBuilder &MIRBuilder,
RTLIB::Libcall RTLibcall = getStateLibraryFunctionFor(MI, TLI);
return createLibcall(MIRBuilder, RTLibcall,
CallLowering::ArgInfo({0}, Type::getVoidTy(Ctx), 0),
CallLowering::ArgInfo({Temp.getReg(0), StatePtrTy, 0}));
CallLowering::ArgInfo({Temp.getReg(0), StatePtrTy, 0}),
LocObserver, nullptr);
}

// The function is used to legalize operations that set default environment
Expand All @@ -902,7 +935,8 @@ LegalizerHelper::createSetStateLibcall(MachineIRBuilder &MIRBuilder,
// it is not true, the target must provide custom lowering.
LegalizerHelper::LegalizeResult
LegalizerHelper::createResetStateLibcall(MachineIRBuilder &MIRBuilder,
MachineInstr &MI) {
MachineInstr &MI,
LostDebugLocObserver &LocObserver) {
const DataLayout &DL = MIRBuilder.getDataLayout();
auto &MF = MIRBuilder.getMF();
auto &Ctx = MF.getFunction().getContext();
Expand All @@ -919,7 +953,8 @@ LegalizerHelper::createResetStateLibcall(MachineIRBuilder &MIRBuilder,
RTLIB::Libcall RTLibcall = getStateLibraryFunctionFor(MI, TLI);
return createLibcall(MIRBuilder, RTLibcall,
CallLowering::ArgInfo({0}, Type::getVoidTy(Ctx), 0),
CallLowering::ArgInfo({ Dest.getReg(), StatePtrTy, 0}));
CallLowering::ArgInfo({Dest.getReg(), StatePtrTy, 0}),
LocObserver, &MI);
}

LegalizerHelper::LegalizeResult
Expand All @@ -938,7 +973,7 @@ LegalizerHelper::libcall(MachineInstr &MI, LostDebugLocObserver &LocObserver) {
LLT LLTy = MRI.getType(MI.getOperand(0).getReg());
unsigned Size = LLTy.getSizeInBits();
Type *HLTy = IntegerType::get(Ctx, Size);
auto Status = simpleLibcall(MI, MIRBuilder, Size, HLTy);
auto Status = simpleLibcall(MI, MIRBuilder, Size, HLTy, LocObserver);
if (Status != Legalized)
return Status;
break;
Expand Down Expand Up @@ -974,7 +1009,7 @@ LegalizerHelper::libcall(MachineInstr &MI, LostDebugLocObserver &LocObserver) {
LLVM_DEBUG(dbgs() << "No libcall available for type " << LLTy << ".\n");
return UnableToLegalize;
}
auto Status = simpleLibcall(MI, MIRBuilder, Size, HLTy);
auto Status = simpleLibcall(MI, MIRBuilder, Size, HLTy, LocObserver);
if (Status != Legalized)
return Status;
break;
Expand All @@ -985,7 +1020,8 @@ LegalizerHelper::libcall(MachineInstr &MI, LostDebugLocObserver &LocObserver) {
Type *ToTy = getFloatTypeForLLT(Ctx, MRI.getType(MI.getOperand(0).getReg()));
if (!FromTy || !ToTy)
return UnableToLegalize;
LegalizeResult Status = conversionLibcall(MI, MIRBuilder, ToTy, FromTy );
LegalizeResult Status =
conversionLibcall(MI, MIRBuilder, ToTy, FromTy, LocObserver);
if (Status != Legalized)
return Status;
break;
Expand All @@ -1000,7 +1036,8 @@ LegalizerHelper::libcall(MachineInstr &MI, LostDebugLocObserver &LocObserver) {
LegalizeResult Status = conversionLibcall(
MI, MIRBuilder,
ToSize == 32 ? Type::getInt32Ty(Ctx) : Type::getInt64Ty(Ctx),
FromSize == 64 ? Type::getDoubleTy(Ctx) : Type::getFloatTy(Ctx));
FromSize == 64 ? Type::getDoubleTy(Ctx) : Type::getFloatTy(Ctx),
LocObserver);
if (Status != Legalized)
return Status;
break;
Expand All @@ -1015,7 +1052,8 @@ LegalizerHelper::libcall(MachineInstr &MI, LostDebugLocObserver &LocObserver) {
LegalizeResult Status = conversionLibcall(
MI, MIRBuilder,
ToSize == 64 ? Type::getDoubleTy(Ctx) : Type::getFloatTy(Ctx),
FromSize == 32 ? Type::getInt32Ty(Ctx) : Type::getInt64Ty(Ctx));
FromSize == 32 ? Type::getInt32Ty(Ctx) : Type::getInt64Ty(Ctx),
LocObserver);
if (Status != Legalized)
return Status;
break;
Expand All @@ -1032,19 +1070,20 @@ LegalizerHelper::libcall(MachineInstr &MI, LostDebugLocObserver &LocObserver) {
return Result;
}
case TargetOpcode::G_GET_FPMODE: {
LegalizeResult Result = createGetStateLibcall(MIRBuilder, MI);
LegalizeResult Result = createGetStateLibcall(MIRBuilder, MI, LocObserver);
if (Result != Legalized)
return Result;
break;
}
case TargetOpcode::G_SET_FPMODE: {
LegalizeResult Result = createSetStateLibcall(MIRBuilder, MI);
LegalizeResult Result = createSetStateLibcall(MIRBuilder, MI, LocObserver);
if (Result != Legalized)
return Result;
break;
}
case TargetOpcode::G_RESET_FPMODE: {
LegalizeResult Result = createResetStateLibcall(MIRBuilder, MI);
LegalizeResult Result =
createResetStateLibcall(MIRBuilder, MI, LocObserver);
if (Result != Legalized)
return Result;
break;
Expand Down Expand Up @@ -2831,6 +2870,7 @@ LegalizerHelper::widenScalar(MachineInstr &MI, unsigned TypeIdx, LLT WideTy) {
return Legalized;
}
case TargetOpcode::G_VECREDUCE_FADD:
case TargetOpcode::G_VECREDUCE_FMUL:
case TargetOpcode::G_VECREDUCE_FMIN:
case TargetOpcode::G_VECREDUCE_FMAX:
case TargetOpcode::G_VECREDUCE_FMINIMUM:
Expand Down
51 changes: 9 additions & 42 deletions llvm/lib/CodeGen/RegisterCoalescer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,11 +305,7 @@ namespace {
/// number if it is not zero. If DstReg is a physical register and the
/// existing subregister number of the def / use being updated is not zero,
/// make sure to set it to the correct physical subregister.
///
/// If \p IsSubregToReg, we are coalescing a DstReg = SUBREG_TO_REG
/// SrcReg. This introduces an implicit-def of DstReg on coalesced users.
void updateRegDefsUses(Register SrcReg, Register DstReg, unsigned SubIdx,
bool IsSubregToReg);
void updateRegDefsUses(Register SrcReg, Register DstReg, unsigned SubIdx);

/// If the given machine operand reads only undefined lanes add an undef
/// flag.
Expand Down Expand Up @@ -1347,7 +1343,8 @@ bool RegisterCoalescer::reMaterializeTrivialDef(const CoalescerPair &CP,
if (DstReg.isPhysical()) {
Register NewDstReg = DstReg;

unsigned NewDstIdx = TRI->composeSubRegIndices(CP.getSrcIdx(), DefSubIdx);
unsigned NewDstIdx = TRI->composeSubRegIndices(CP.getSrcIdx(),
DefMI->getOperand(0).getSubReg());
if (NewDstIdx)
NewDstReg = TRI->getSubReg(DstReg, NewDstIdx);

Expand Down Expand Up @@ -1496,7 +1493,7 @@ bool RegisterCoalescer::reMaterializeTrivialDef(const CoalescerPair &CP,
MRI->setRegClass(DstReg, NewRC);

// Update machine operands and add flags.
updateRegDefsUses(DstReg, DstReg, DstIdx, false);
updateRegDefsUses(DstReg, DstReg, DstIdx);
NewMI.getOperand(0).setSubReg(NewIdx);
// updateRegDefUses can add an "undef" flag to the definition, since
// it will replace DstReg with DstReg.DstIdx. If NewIdx is 0, make
Expand Down Expand Up @@ -1816,7 +1813,7 @@ void RegisterCoalescer::addUndefFlag(const LiveInterval &Int, SlotIndex UseIdx,
}

void RegisterCoalescer::updateRegDefsUses(Register SrcReg, Register DstReg,
unsigned SubIdx, bool IsSubregToReg) {
unsigned SubIdx) {
bool DstIsPhys = DstReg.isPhysical();
LiveInterval *DstInt = DstIsPhys ? nullptr : &LIS->getInterval(DstReg);

Expand Down Expand Up @@ -1856,22 +1853,16 @@ void RegisterCoalescer::updateRegDefsUses(Register SrcReg, Register DstReg,
if (DstInt && !Reads && SubIdx && !UseMI->isDebugInstr())
Reads = DstInt->liveAt(LIS->getInstructionIndex(*UseMI));

bool FullDef = true;

// Replace SrcReg with DstReg in all UseMI operands.
for (unsigned i = 0, e = Ops.size(); i != e; ++i) {
MachineOperand &MO = UseMI->getOperand(Ops[i]);

// Adjust <undef> flags in case of sub-register joins. We don't want to
// turn a full def into a read-modify-write sub-register def and vice
// versa.
if (SubIdx && MO.isDef()) {
if (SubIdx && MO.isDef())
MO.setIsUndef(!Reads);

if (!Reads)
FullDef = false;
}

// A subreg use of a partially undef (super) register may be a complete
// undef use now and then has to be marked that way.
if (MO.isUse() && !DstIsPhys) {
Expand Down Expand Up @@ -1903,25 +1894,6 @@ void RegisterCoalescer::updateRegDefsUses(Register SrcReg, Register DstReg,
MO.substVirtReg(DstReg, SubIdx, *TRI);
}

if (IsSubregToReg && !FullDef) {
// If the coalesed instruction doesn't fully define the register, we need
// to preserve the original super register liveness for SUBREG_TO_REG.
//
// We pretended SUBREG_TO_REG was a regular copy for coalescing purposes,
// but it introduces liveness for other subregisters. Downstream users may
// have been relying on those bits, so we need to ensure their liveness is
// captured with a def of other lanes.

// FIXME: Need to add new subrange if tracking subranges. We could also
// skip adding this if we knew the other lanes are dead, and only for
// other lanes.

assert(!MRI->shouldTrackSubRegLiveness(DstReg) &&
"this should update subranges");
MachineInstrBuilder MIB(*MF, UseMI);
MIB.addReg(DstReg, RegState::ImplicitDefine);
}

LLVM_DEBUG({
dbgs() << "\t\tupdated: ";
if (!UseMI->isDebugInstr())
Expand Down Expand Up @@ -2121,8 +2093,6 @@ bool RegisterCoalescer::joinCopy(MachineInstr *CopyMI, bool &Again) {
});
}

const bool IsSubregToReg = CopyMI->isSubregToReg();

ShrinkMask = LaneBitmask::getNone();
ShrinkMainRange = false;

Expand Down Expand Up @@ -2190,12 +2160,9 @@ bool RegisterCoalescer::joinCopy(MachineInstr *CopyMI, bool &Again) {

// Rewrite all SrcReg operands to DstReg.
// Also update DstReg operands to include DstIdx if it is set.
if (CP.getDstIdx()) {
assert(!IsSubregToReg && "can this happen?");
updateRegDefsUses(CP.getDstReg(), CP.getDstReg(), CP.getDstIdx(), false);
}
updateRegDefsUses(CP.getSrcReg(), CP.getDstReg(), CP.getSrcIdx(),
IsSubregToReg);
if (CP.getDstIdx())
updateRegDefsUses(CP.getDstReg(), CP.getDstReg(), CP.getDstIdx());
updateRegDefsUses(CP.getSrcReg(), CP.getDstReg(), CP.getSrcIdx());

// Shrink subregister ranges if necessary.
if (ShrinkMask.any()) {
Expand Down
8 changes: 6 additions & 2 deletions llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7987,7 +7987,7 @@ SDValue DAGCombiner::visitOR(SDNode *N) {

// If OR can be rewritten into ADD, try combines based on ADD.
if ((!LegalOperations || TLI.isOperationLegal(ISD::ADD, VT)) &&
DAG.haveNoCommonBitsSet(N0, N1))
DAG.isADDLike(SDValue(N, 0)))
if (SDValue Combined = visitADDLike(N))
return Combined;

Expand Down Expand Up @@ -10055,7 +10055,11 @@ SDValue DAGCombiner::visitSHL(SDNode *N) {
DAG.FoldConstantArithmetic(ISD::SHL, SDLoc(N1), VT, {N01, N1})) {
SDValue Shl0 = DAG.getNode(ISD::SHL, SDLoc(N0), VT, N0.getOperand(0), N1);
AddToWorklist(Shl0.getNode());
return DAG.getNode(N0.getOpcode(), SDLoc(N), VT, Shl0, Shl1);
SDNodeFlags Flags;
// Preserve the disjoint flag for Or.
if (N0.getOpcode() == ISD::OR && N0->getFlags().hasDisjoint())
Flags.setDisjoint(true);
return DAG.getNode(N0.getOpcode(), SDLoc(N), VT, Shl0, Shl1, Flags);
}
}

Expand Down
8 changes: 6 additions & 2 deletions llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5022,7 +5022,6 @@ bool SelectionDAG::canCreateUndefOrPoison(SDValue Op, const APInt &DemandedElts,
case ISD::CONCAT_VECTORS:
case ISD::INSERT_SUBVECTOR:
case ISD::AND:
case ISD::OR:
case ISD::XOR:
case ISD::ROTL:
case ISD::ROTR:
Expand Down Expand Up @@ -5062,6 +5061,10 @@ bool SelectionDAG::canCreateUndefOrPoison(SDValue Op, const APInt &DemandedElts,
return ConsiderFlags && (Op->getFlags().hasNoSignedWrap() ||
Op->getFlags().hasNoUnsignedWrap());

// Matches hasPoisonGeneratingFlags().
case ISD::OR:
return ConsiderFlags && Op->getFlags().hasDisjoint();

case ISD::INSERT_VECTOR_ELT:{
// Ensure that the element index is in bounds.
EVT VecVT = Op.getOperand(0).getValueType();
Expand All @@ -5085,7 +5088,8 @@ bool SelectionDAG::canCreateUndefOrPoison(SDValue Op, const APInt &DemandedElts,
bool SelectionDAG::isADDLike(SDValue Op) const {
unsigned Opcode = Op.getOpcode();
if (Opcode == ISD::OR)
return haveNoCommonBitsSet(Op.getOperand(0), Op.getOperand(1));
return Op->getFlags().hasDisjoint() ||
haveNoCommonBitsSet(Op.getOperand(0), Op.getOperand(1));
if (Opcode == ISD::XOR)
return isMinSignedConstant(Op.getOperand(1));
return false;
Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3354,6 +3354,8 @@ void SelectionDAGBuilder::visitBinary(const User &I, unsigned Opcode) {
}
if (auto *ExactOp = dyn_cast<PossiblyExactOperator>(&I))
Flags.setExact(ExactOp->isExact());
if (auto *DisjointOp = dyn_cast<PossiblyDisjointInst>(&I))
Flags.setDisjoint(DisjointOp->isDisjoint());
if (auto *FPOp = dyn_cast<FPMathOperator>(&I))
Flags.copyFMF(*FPOp);

Expand Down
3 changes: 3 additions & 0 deletions llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,9 @@ void SDNode::print_details(raw_ostream &OS, const SelectionDAG *G) const {
if (getFlags().hasExact())
OS << " exact";

if (getFlags().hasDisjoint())
OS << " disjoint";

if (getFlags().hasNonNeg())
OS << " nneg";

Expand Down
23 changes: 16 additions & 7 deletions llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1064,10 +1064,9 @@ static SDValue combineShiftToAVG(SDValue Op, SelectionDAG &DAG,

SDLoc DL(Op);
SDValue ResultAVG =
DAG.getNode(AVGOpc, DL, NVT, DAG.getNode(ISD::TRUNCATE, DL, NVT, ExtOpA),
DAG.getNode(ISD::TRUNCATE, DL, NVT, ExtOpB));
return DAG.getNode(IsSigned ? ISD::SIGN_EXTEND : ISD::ZERO_EXTEND, DL, VT,
ResultAVG);
DAG.getNode(AVGOpc, DL, NVT, DAG.getExtOrTrunc(IsSigned, ExtOpA, DL, NVT),
DAG.getExtOrTrunc(IsSigned, ExtOpB, DL, NVT));
return DAG.getExtOrTrunc(IsSigned, ResultAVG, DL, VT);
}

/// Look at Op. At this point, we know that only the OriginalDemandedBits of the
Expand Down Expand Up @@ -1468,14 +1467,24 @@ bool TargetLowering::SimplifyDemandedBits(
case ISD::OR: {
SDValue Op0 = Op.getOperand(0);
SDValue Op1 = Op.getOperand(1);

SDNodeFlags Flags = Op.getNode()->getFlags();
if (SimplifyDemandedBits(Op1, DemandedBits, DemandedElts, Known, TLO,
Depth + 1))
Depth + 1)) {
if (Flags.hasDisjoint()) {
Flags.setDisjoint(false);
Op->setFlags(Flags);
}
return true;
}
assert(!Known.hasConflict() && "Bits known to be one AND zero?");
if (SimplifyDemandedBits(Op0, ~Known.One & DemandedBits, DemandedElts,
Known2, TLO, Depth + 1))
Known2, TLO, Depth + 1)) {
if (Flags.hasDisjoint()) {
Flags.setDisjoint(false);
Op->setFlags(Flags);
}
return true;
}
assert(!Known2.hasConflict() && "Bits known to be one AND zero?");

// If all of the demanded bits are known zero on one side, return the other.
Expand Down
5 changes: 2 additions & 3 deletions llvm/lib/Demangle/Demangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ static bool isRustEncoding(std::string_view S) { return starts_with(S, "_R"); }
static bool isDLangEncoding(std::string_view S) { return starts_with(S, "_D"); }

bool llvm::nonMicrosoftDemangle(std::string_view MangledName,
std::string &Result, bool CanHaveLeadingDot,
bool ParseParams) {
std::string &Result, bool CanHaveLeadingDot) {
char *Demangled = nullptr;

// Do not consider the dot prefix as part of the demangled symbol name.
Expand All @@ -58,7 +57,7 @@ bool llvm::nonMicrosoftDemangle(std::string_view MangledName,
}

if (isItaniumEncoding(MangledName))
Demangled = itaniumDemangle(MangledName, ParseParams);
Demangled = itaniumDemangle(MangledName);
else if (isRustEncoding(MangledName))
Demangled = rustDemangle(MangledName);
else if (isDLangEncoding(MangledName))
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Demangle/ItaniumDemangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,13 +366,13 @@ class DefaultAllocator {

using Demangler = itanium_demangle::ManglingParser<DefaultAllocator>;

char *llvm::itaniumDemangle(std::string_view MangledName, bool ParseParams) {
char *llvm::itaniumDemangle(std::string_view MangledName) {
if (MangledName.empty())
return nullptr;

Demangler Parser(MangledName.data(),
MangledName.data() + MangledName.length());
Node *AST = Parser.parse(ParseParams);
Node *AST = Parser.parse();
if (!AST)
return nullptr;

Expand Down
23 changes: 0 additions & 23 deletions llvm/lib/ExecutionEngine/Orc/TargetProcess/JITLoaderGDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,31 +21,8 @@
// First version as landed in August 2009
static constexpr uint32_t JitDescriptorVersion = 1;

// Keep in sync with gdb/gdb/jit.h
extern "C" {

typedef enum {
JIT_NOACTION = 0,
JIT_REGISTER_FN,
JIT_UNREGISTER_FN
} jit_actions_t;

struct jit_code_entry {
struct jit_code_entry *next_entry;
struct jit_code_entry *prev_entry;
const char *symfile_addr;
uint64_t symfile_size;
};

struct jit_descriptor {
uint32_t version;
// This should be jit_actions_t, but we want to be specific about the
// bit-width.
uint32_t action_flag;
struct jit_code_entry *relevant_entry;
struct jit_code_entry *first_entry;
};

// We put information about the JITed function in this global, which the
// debugger reads. Make sure to specify the version statically, because the
// debugger checks the version before we can set it during runtime.
Expand Down
4 changes: 4 additions & 0 deletions llvm/lib/IR/DebugInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2115,6 +2115,10 @@ bool AssignmentTrackingPass::runOnFunction(Function &F) {
if (F.hasFnAttribute(Attribute::OptimizeNone))
return /*Changed*/ false;

// FIXME: https://github.com/llvm/llvm-project/issues/76545
if (F.hasFnAttribute(Attribute::SanitizeHWAddress))
return /*Changed*/ false;

bool Changed = false;
auto *DL = &F.getParent()->getDataLayout();
// Collect a map of {backing storage : dbg.declares} (currently "backing
Expand Down
36 changes: 23 additions & 13 deletions llvm/lib/LTO/LTO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,9 @@ LTO::LTO(Config Conf, ThinBackend Backend,
unsigned ParallelCodeGenParallelismLevel, LTOKind LTOMode)
: Conf(std::move(Conf)),
RegularLTO(ParallelCodeGenParallelismLevel, this->Conf),
ThinLTO(std::move(Backend)), LTOMode(LTOMode) {}
ThinLTO(std::move(Backend)),
GlobalResolutions(std::make_optional<StringMap<GlobalResolution>>()),
LTOMode(LTOMode) {}

// Requires a destructor for MapVector<BitcodeModule>.
LTO::~LTO() = default;
Expand All @@ -610,7 +612,7 @@ void LTO::addModuleToGlobalRes(ArrayRef<InputFile::Symbol> Syms,
assert(ResI != ResE);
SymbolResolution Res = *ResI++;

auto &GlobalRes = GlobalResolutions[Sym.getName()];
auto &GlobalRes = (*GlobalResolutions)[Sym.getName()];
GlobalRes.UnnamedAddr &= Sym.isUnnamedAddr();
if (Res.Prevailing) {
assert(!GlobalRes.Prevailing &&
Expand Down Expand Up @@ -1125,7 +1127,7 @@ Error LTO::run(AddStreamFn AddStream, FileCache Cache) {
// Compute "dead" symbols, we don't want to import/export these!
DenseSet<GlobalValue::GUID> GUIDPreservedSymbols;
DenseMap<GlobalValue::GUID, PrevailingType> GUIDPrevailingResolutions;
for (auto &Res : GlobalResolutions) {
for (auto &Res : *GlobalResolutions) {
// Normally resolution have IR name of symbol. We can do nothing here
// otherwise. See comments in GlobalResolution struct for more details.
if (Res.second.IRName.empty())
Expand Down Expand Up @@ -1169,6 +1171,8 @@ Error LTO::run(AddStreamFn AddStream, FileCache Cache) {

Error Result = runRegularLTO(AddStream);
if (!Result)
// This will reset the GlobalResolutions optional once done with it to
// reduce peak memory before importing.
Result = runThinLTO(AddStream, Cache, GUIDPreservedSymbols);

if (StatsFile)
Expand Down Expand Up @@ -1273,8 +1277,8 @@ Error LTO::runRegularLTO(AddStreamFn AddStream) {
// This returns true when the name is local or not defined. Locals are
// expected to be handled separately.
auto IsVisibleToRegularObj = [&](StringRef name) {
auto It = GlobalResolutions.find(name);
return (It == GlobalResolutions.end() || It->second.VisibleOutsideSummary);
auto It = GlobalResolutions->find(name);
return (It == GlobalResolutions->end() || It->second.VisibleOutsideSummary);
};

// If allowed, upgrade public vcall visibility metadata to linkage unit
Expand All @@ -1291,7 +1295,7 @@ Error LTO::runRegularLTO(AddStreamFn AddStream) {
return finalizeOptimizationRemarks(std::move(DiagnosticOutputFile));

if (!Conf.CodeGenOnly) {
for (const auto &R : GlobalResolutions) {
for (const auto &R : *GlobalResolutions) {
GlobalValue *GV =
RegularLTO.CombinedModule->getNamedValue(R.second.IRName);
if (!R.second.isPrevailingIRSymbol())
Expand Down Expand Up @@ -1708,8 +1712,8 @@ Error LTO::runThinLTO(AddStreamFn AddStream, FileCache Cache,
// This returns true when the name is local or not defined. Locals are
// expected to be handled separately.
auto IsVisibleToRegularObj = [&](StringRef name) {
auto It = GlobalResolutions.find(name);
return (It == GlobalResolutions.end() ||
auto It = GlobalResolutions->find(name);
return (It == GlobalResolutions->end() ||
It->second.VisibleOutsideSummary);
};

Expand Down Expand Up @@ -1739,15 +1743,11 @@ Error LTO::runThinLTO(AddStreamFn AddStream, FileCache Cache,
ContextDisambiguation.run(ThinLTO.CombinedIndex, isPrevailing);
}

if (Conf.OptLevel > 0)
ComputeCrossModuleImport(ThinLTO.CombinedIndex, ModuleToDefinedGVSummaries,
isPrevailing, ImportLists, ExportLists);

// Figure out which symbols need to be internalized. This also needs to happen
// at -O0 because summary-based DCE is implemented using internalization, and
// we must apply DCE consistently with the full LTO module in order to avoid
// undefined references during the final link.
for (auto &Res : GlobalResolutions) {
for (auto &Res : *GlobalResolutions) {
// If the symbol does not have external references or it is not prevailing,
// then not need to mark it as exported from a ThinLTO partition.
if (Res.second.Partition != GlobalResolution::External ||
Expand All @@ -1760,6 +1760,16 @@ Error LTO::runThinLTO(AddStreamFn AddStream, FileCache Cache,
ExportedGUIDs.insert(GUID);
}

// Reset the GlobalResolutions to deallocate the associated memory, as there
// are no further accesses. We specifically want to do this before computing
// cross module importing, which adds to peak memory via the computed import
// and export lists.
GlobalResolutions.reset();

if (Conf.OptLevel > 0)
ComputeCrossModuleImport(ThinLTO.CombinedIndex, ModuleToDefinedGVSummaries,
isPrevailing, ImportLists, ExportLists);

// Any functions referenced by the jump table in the regular LTO object must
// be exported.
for (auto &Def : ThinLTO.CombinedIndex.cfiFunctionDefs())
Expand Down
6 changes: 6 additions & 0 deletions llvm/lib/MC/MCExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -704,8 +704,14 @@ static void AttemptToFoldSymbolOffsetDifference(
}

int64_t Num;
unsigned Count;
if (DF) {
Displacement += DF->getContents().size();
} else if (auto *AF = dyn_cast<MCAlignFragment>(FI);
AF && Layout &&
!Asm->getBackend().shouldInsertExtraNopBytesForCodeAlign(
*AF, Count)) {
Displacement += Asm->computeFragmentSize(*Layout, *AF);
} else if (auto *FF = dyn_cast<MCFillFragment>(FI);
FF && FF->getNumValues().evaluateAsAbsolute(Num)) {
Displacement += Num * FF->getValueSize();
Expand Down
5 changes: 3 additions & 2 deletions llvm/lib/Passes/PassBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -452,9 +452,10 @@ PassBuilder::PassBuilder(TargetMachine *TM, PipelineTuningOptions PTO,
std::optional<PGOOptions> PGOOpt,
PassInstrumentationCallbacks *PIC)
: TM(TM), PTO(PTO), PGOOpt(PGOOpt), PIC(PIC) {
bool ShouldPopulateClassToPassNames = PIC && shouldPopulateClassToPassNames();
if (TM)
TM->registerPassBuilderCallbacks(*this);
if (PIC && shouldPopulateClassToPassNames()) {
TM->registerPassBuilderCallbacks(*this, ShouldPopulateClassToPassNames);
if (ShouldPopulateClassToPassNames) {
#define MODULE_PASS(NAME, CREATE_PASS) \
PIC->addClassToPassName(decltype(CREATE_PASS)::name(), NAME);
#define MODULE_PASS_WITH_PARAMS(NAME, CLASS, CREATE_PASS, PARSER, PARAMS) \
Expand Down
9 changes: 0 additions & 9 deletions llvm/lib/Target/AArch64/AArch64FastISel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1231,15 +1231,6 @@ unsigned AArch64FastISel::emitAddSub(bool UseAdd, MVT RetVT, const Value *LHS,
// Only extend the RHS within the instruction if there is a valid extend type.
if (ExtendType != AArch64_AM::InvalidShiftExtend && RHS->hasOneUse() &&
isValueAvailable(RHS)) {
if (const auto *SI = dyn_cast<BinaryOperator>(RHS))
if (const auto *C = dyn_cast<ConstantInt>(SI->getOperand(1)))
if ((SI->getOpcode() == Instruction::Shl) && (C->getZExtValue() < 4)) {
Register RHSReg = getRegForValue(SI->getOperand(0));
if (!RHSReg)
return 0;
return emitAddSub_rx(UseAdd, RetVT, LHSReg, RHSReg, ExtendType,
C->getZExtValue(), SetFlags, WantResult);
}
Register RHSReg = getRegForValue(RHS);
if (!RHSReg)
return 0;
Expand Down
1 change: 1 addition & 0 deletions llvm/lib/Target/AArch64/AArch64InstrFormats.td
Original file line number Diff line number Diff line change
Expand Up @@ -12586,6 +12586,7 @@ def : TokenAlias<".4S", ".4s">;
def : TokenAlias<".2D", ".2d">;
def : TokenAlias<".1Q", ".1q">;
def : TokenAlias<".2H", ".2h">;
def : TokenAlias<".2B", ".2b">;
def : TokenAlias<".B", ".b">;
def : TokenAlias<".H", ".h">;
def : TokenAlias<".S", ".s">;
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/AArch64/AArch64SMEInstrInfo.td
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ defm FMOPA_MPPZZ_H : sme2p1_fmop_tile_fp16<"fmopa", 0b0, 0b0, 0b11, ZPR16>;
defm FMOPS_MPPZZ_H : sme2p1_fmop_tile_fp16<"fmops", 0b0, 0b1, 0b11, ZPR16>;
}

let Predicates = [HasSME2p1, HasB16B16] in {
let Predicates = [HasSME2, HasB16B16] in {
defm BFADD_VG2_M2Z_H : sme2_multivec_accum_add_sub_vg2<"bfadd", 0b1100, MatrixOp16, ZZ_h_mul_r, nxv8bf16, null_frag>;
defm BFADD_VG4_M4Z_H : sme2_multivec_accum_add_sub_vg4<"bfadd", 0b1100, MatrixOp16, ZZZZ_h_mul_r, nxv8bf16, null_frag>;
defm BFSUB_VG2_M2Z_H : sme2_multivec_accum_add_sub_vg2<"bfsub", 0b1101, MatrixOp16, ZZ_h_mul_r, nxv8bf16, null_frag>;
Expand Down
18 changes: 16 additions & 2 deletions llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -989,6 +989,19 @@ AArch64LegalizerInfo::AArch64LegalizerInfo(const AArch64Subtarget &ST)
.clampMaxNumElements(1, s16, 8)
.lower();

// For fmul reductions we need to split up into individual operations. We
// clamp to 128 bit vectors then to 64bit vectors to produce a cascade of
// smaller types, followed by scalarizing what remains.
getActionDefinitionsBuilder(G_VECREDUCE_FMUL)
.minScalarOrElt(0, MinFPScalar)
.clampMaxNumElements(1, s64, 2)
.clampMaxNumElements(1, s32, 4)
.clampMaxNumElements(1, s16, 8)
.clampMaxNumElements(1, s32, 2)
.clampMaxNumElements(1, s16, 4)
.scalarize(1)
.lower();

getActionDefinitionsBuilder(G_VECREDUCE_ADD)
.legalFor({{s8, v16s8},
{s8, v8s8},
Expand Down Expand Up @@ -1137,8 +1150,9 @@ AArch64LegalizerInfo::AArch64LegalizerInfo(const AArch64Subtarget &ST)
verify(*ST.getInstrInfo());
}

bool AArch64LegalizerInfo::legalizeCustom(LegalizerHelper &Helper,
MachineInstr &MI) const {
bool AArch64LegalizerInfo::legalizeCustom(
LegalizerHelper &Helper, MachineInstr &MI,
LostDebugLocObserver &LocObserver) const {
MachineIRBuilder &MIRBuilder = Helper.MIRBuilder;
MachineRegisterInfo &MRI = *MIRBuilder.getMRI();
GISelChangeObserver &Observer = Helper.Observer;
Expand Down
3 changes: 2 additions & 1 deletion llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ class AArch64LegalizerInfo : public LegalizerInfo {
public:
AArch64LegalizerInfo(const AArch64Subtarget &ST);

bool legalizeCustom(LegalizerHelper &Helper, MachineInstr &MI) const override;
bool legalizeCustom(LegalizerHelper &Helper, MachineInstr &MI,
LostDebugLocObserver &LocObserver) const override;

bool legalizeIntrinsic(LegalizerHelper &Helper,
MachineInstr &MI) const override;
Expand Down
12 changes: 12 additions & 0 deletions llvm/lib/Target/AArch64/SVEInstrFormats.td
Original file line number Diff line number Diff line change
Expand Up @@ -10082,6 +10082,12 @@ multiclass sve2p1_vector_to_pred<string mnemonic, SDPatternOperator Op_lane, SDP

def : InstAlias<mnemonic # "\t$Pd, $Zn",
(!cast<Instruction>(NAME # _B) PPR8:$Pd, ZPRAny:$Zn, 0), 1>;
def : InstAlias<mnemonic # "\t$Pd, $Zn",
(!cast<Instruction>(NAME # _H) PPR16:$Pd, ZPRAny:$Zn, 0), 0>;
def : InstAlias<mnemonic # "\t$Pd, $Zn",
(!cast<Instruction>(NAME # _S) PPR32:$Pd, ZPRAny:$Zn, 0), 0>;
def : InstAlias<mnemonic # "\t$Pd, $Zn",
(!cast<Instruction>(NAME # _D) PPR64:$Pd, ZPRAny:$Zn, 0), 0>;

// any_lane
def : Pat<(nxv16i1 (Op_lane (nxv16i8 ZPRAny:$Zn), (i32 timm32_0_0:$Idx))),
Expand Down Expand Up @@ -10143,6 +10149,12 @@ multiclass sve2p1_pred_to_vector<string mnemonic, SDPatternOperator MergeOp,

def : InstAlias<mnemonic # "\t$Zd, $Pn",
(!cast<Instruction>(NAME # _B) ZPRAny:$Zd, 0, PPR8:$Pn), 1>;
def : InstAlias<mnemonic # "\t$Zd, $Pn",
(!cast<Instruction>(NAME # _H) ZPRAny:$Zd, 0, PPR16:$Pn), 0>;
def : InstAlias<mnemonic # "\t$Zd, $Pn",
(!cast<Instruction>(NAME # _S) ZPRAny:$Zd, 0, PPR32:$Pn), 0>;
def : InstAlias<mnemonic # "\t$Zd, $Pn",
(!cast<Instruction>(NAME # _D) ZPRAny:$Zd, 0, PPR64:$Pn), 0>;

// Merge
def : Pat<(nxv8i16 (MergeOp (nxv8i16 ZPRAny:$Zd), (nxv8i1 PPR16:$Pn), (i32 timm32_1_1:$Idx))),
Expand Down
8 changes: 7 additions & 1 deletion llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2764,7 +2764,9 @@ static bool isConstant(const MachineInstr &MI) {
void AMDGPUInstructionSelector::getAddrModeInfo(const MachineInstr &Load,
const MachineRegisterInfo &MRI, SmallVectorImpl<GEPInfo> &AddrInfo) const {

const MachineInstr *PtrMI = MRI.getUniqueVRegDef(Load.getOperand(1).getReg());
unsigned OpNo = Load.getOpcode() == AMDGPU::G_PREFETCH ? 0 : 1;
const MachineInstr *PtrMI =
MRI.getUniqueVRegDef(Load.getOperand(OpNo).getReg());

assert(PtrMI);

Expand Down Expand Up @@ -2817,6 +2819,10 @@ bool AMDGPUInstructionSelector::isInstrUniform(const MachineInstr &MI) const {
if (MMO->getAddrSpace() == AMDGPUAS::CONSTANT_ADDRESS_32BIT)
return true;

if (MI.getOpcode() == AMDGPU::G_PREFETCH)
return RBI.getRegBank(MI.getOperand(0).getReg(), *MRI, TRI)->getID() ==
AMDGPU::SGPRRegBankID;

const Instruction *I = dyn_cast<Instruction>(Ptr);
return I && I->getMetadata("amdgpu.uniform");
}
Expand Down
5 changes: 3 additions & 2 deletions llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1996,8 +1996,9 @@ AMDGPULegalizerInfo::AMDGPULegalizerInfo(const GCNSubtarget &ST_,
verify(*ST.getInstrInfo());
}

bool AMDGPULegalizerInfo::legalizeCustom(LegalizerHelper &Helper,
MachineInstr &MI) const {
bool AMDGPULegalizerInfo::legalizeCustom(
LegalizerHelper &Helper, MachineInstr &MI,
LostDebugLocObserver &LocObserver) const {
MachineIRBuilder &B = Helper.MIRBuilder;
MachineRegisterInfo &MRI = *B.getMRI();

Expand Down
3 changes: 2 additions & 1 deletion llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ class AMDGPULegalizerInfo final : public LegalizerInfo {
AMDGPULegalizerInfo(const GCNSubtarget &ST,
const GCNTargetMachine &TM);

bool legalizeCustom(LegalizerHelper &Helper, MachineInstr &MI) const override;
bool legalizeCustom(LegalizerHelper &Helper, MachineInstr &MI,
LostDebugLocObserver &LocObserver) const override;

Register getSegmentAperture(unsigned AddrSpace,
MachineRegisterInfo &MRI,
Expand Down
16 changes: 9 additions & 7 deletions llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3263,17 +3263,19 @@ void AMDGPURegisterBankInfo::applyMappingImpl(
MI.eraseFromParent();
return;
}
unsigned PtrBank =
getRegBankID(MI.getOperand(0).getReg(), MRI, AMDGPU::SGPRRegBankID);
Register PtrReg = MI.getOperand(0).getReg();
unsigned PtrBank = getRegBankID(PtrReg, MRI, AMDGPU::SGPRRegBankID);
if (PtrBank == AMDGPU::VGPRRegBankID) {
MI.eraseFromParent();
return;
}
// FIXME: There is currently no support for prefetch in global isel.
// There is no node equivalence and what's worse there is no MMO produced
// for a prefetch on global isel path.
// Prefetch does not affect execution so erase it for now.
MI.eraseFromParent();
unsigned AS = MRI.getType(PtrReg).getAddressSpace();
if (!AMDGPU::isFlatGlobalAddrSpace(AS) &&
AS != AMDGPUAS::CONSTANT_ADDRESS_32BIT) {
MI.eraseFromParent();
return;
}
applyDefaultMapping(OpdMapper);
return;
}
default:
Expand Down
3 changes: 2 additions & 1 deletion llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,8 @@ void AMDGPUTargetMachine::registerDefaultAliasAnalyses(AAManager &AAM) {
AAM.registerFunctionAnalysis<AMDGPUAA>();
}

void AMDGPUTargetMachine::registerPassBuilderCallbacks(PassBuilder &PB) {
void AMDGPUTargetMachine::registerPassBuilderCallbacks(
PassBuilder &PB, bool PopulateClassToPassNames) {
PB.registerPipelineParsingCallback(
[this](StringRef PassName, ModulePassManager &PM,
ArrayRef<PassBuilder::PipelineElement>) {
Expand Down
3 changes: 2 additions & 1 deletion llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ class AMDGPUTargetMachine : public LLVMTargetMachine {
return TLOF.get();
}

void registerPassBuilderCallbacks(PassBuilder &PB) override;
void registerPassBuilderCallbacks(PassBuilder &PB,
bool PopulateClassToPassNames) override;
void registerDefaultAliasAnalyses(AAManager &) override;

/// Get the integer value of a null pointer in the given address space.
Expand Down
16 changes: 16 additions & 0 deletions llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ class AMDGPUOperand : public MCParsedAsmOperand {
ImmTyEndpgm,
ImmTyWaitVDST,
ImmTyWaitEXP,
ImmTyWaitVAVDst,
ImmTyWaitVMVSrc,
};

// Immediate operand kind.
Expand Down Expand Up @@ -909,6 +911,8 @@ class AMDGPUOperand : public MCParsedAsmOperand {
bool isEndpgm() const;
bool isWaitVDST() const;
bool isWaitEXP() const;
bool isWaitVAVDst() const;
bool isWaitVMVSrc() const;

auto getPredicate(std::function<bool(const AMDGPUOperand &Op)> P) const {
return std::bind(P, *this);
Expand Down Expand Up @@ -1029,6 +1033,7 @@ class AMDGPUOperand : public MCParsedAsmOperand {
}

static void printImmTy(raw_ostream& OS, ImmTy Type) {
// clang-format off
switch (Type) {
case ImmTyNone: OS << "None"; break;
case ImmTyGDS: OS << "GDS"; break;
Expand Down Expand Up @@ -1086,7 +1091,10 @@ class AMDGPUOperand : public MCParsedAsmOperand {
case ImmTyEndpgm: OS << "Endpgm"; break;
case ImmTyWaitVDST: OS << "WaitVDST"; break;
case ImmTyWaitEXP: OS << "WaitEXP"; break;
case ImmTyWaitVAVDst: OS << "WaitVAVDst"; break;
case ImmTyWaitVMVSrc: OS << "WaitVMVSrc"; break;
}
// clang-format on
}

void print(raw_ostream &OS) const override {
Expand Down Expand Up @@ -9192,6 +9200,14 @@ bool AMDGPUOperand::isWaitVDST() const {
return isImmTy(ImmTyWaitVDST) && isUInt<4>(getImm());
}

bool AMDGPUOperand::isWaitVAVDst() const {
return isImmTy(ImmTyWaitVAVDst) && isUInt<4>(getImm());
}

bool AMDGPUOperand::isWaitVMVSrc() const {
return isImmTy(ImmTyWaitVMVSrc) && isUInt<1>(getImm());
}

//===----------------------------------------------------------------------===//
// VINTERP
//===----------------------------------------------------------------------===//
Expand Down
191 changes: 191 additions & 0 deletions llvm/lib/Target/AMDGPU/DSDIRInstructions.td
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
//===-- DSDIRInstructions.td - LDS/VDS Direct Instruction Definitions -----===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

//===----------------------------------------------------------------------===//
// LDSDIR/VDSDIR encoding (LDSDIR is gfx11, VDSDIR is gfx12+)
//===----------------------------------------------------------------------===//

class LDSDIRe<bits<2> op, bit is_direct> : Enc32 {
// encoding fields
bits<2> attrchan;
bits<6> attr;
bits<4> waitvdst;
bits<8> vdst;

// encoding
let Inst{31-24} = 0xce; // encoding
let Inst{23-22} = 0x0; // reserved
let Inst{21-20} = op;
let Inst{19-16} = waitvdst;
let Inst{15-10} = !if(is_direct, ?, attr);
let Inst{9-8} = !if(is_direct, ?, attrchan);
let Inst{7-0} = vdst;
}

class VDSDIRe<bits<2> op, bit is_direct> : Enc32 {
// encoding fields
bits<2> attrchan;
bits<6> attr;
bits<4> waitvdst;
bits<8> vdst;
bits<1> waitvsrc;

// encoding
let Inst{31-24} = 0xce; // encoding
let Inst{23} = waitvsrc;
let Inst{22} = 0x0; // reserved
let Inst{21-20} = op;
let Inst{19-16} = waitvdst;
let Inst{15-10} = !if(is_direct, ?, attr);
let Inst{9-8} = !if(is_direct, ?, attrchan);
let Inst{7-0} = vdst;
}

//===----------------------------------------------------------------------===//
// LDSDIR/VDSDIR Classes
//===----------------------------------------------------------------------===//

class LDSDIR_getIns<bit direct> {
dag ret = !if(direct,
(ins wait_vdst:$waitvdst),
(ins InterpAttr:$attr, InterpAttrChan:$attrchan, wait_vdst:$waitvdst)
);
}

class VDSDIR_getIns<bit direct> {
dag ret = !if(direct,
(ins wait_va_vdst:$waitvdst, wait_va_vsrc:$waitvsrc),
(ins InterpAttr:$attr, InterpAttrChan:$attrchan, wait_va_vdst:$waitvdst,
wait_va_vsrc:$waitvsrc)
);
}

class DSDIR_Common<string opName, string asm = "", dag ins, bit direct> :
InstSI<(outs VGPR_32:$vdst), ins, asm> {
let LDSDIR = 1;
let EXP_CNT = 1;

let hasSideEffects = 0;
let mayLoad = 1;
let mayStore = 0;

string Mnemonic = opName;
let UseNamedOperandTable = 1;

let Uses = [M0, EXEC];
let DisableWQM = 0;
let SchedRW = [WriteLDS];

bit is_direct;
let is_direct = direct;
}

class DSDIR_Pseudo<string opName, dag ins, bit direct> :
DSDIR_Common<opName, "", ins, direct>,
SIMCInstr<opName, SIEncodingFamily.NONE> {
let isPseudo = 1;
let isCodeGenOnly = 1;
}

class LDSDIR_getAsm<bit direct> {
string ret = !if(direct,
" $vdst$waitvdst",
" $vdst, $attr$attrchan$waitvdst"
);
}

class VDSDIR_getAsm<bit direct> {
string ret = !if(direct,
" $vdst$waitvdst$waitvsrc",
" $vdst, $attr$attrchan$waitvdst$waitvsrc"
);
}

class DSDIR_Real<DSDIR_Pseudo lds, dag ins, string asm, int subtarget> :
DSDIR_Common<lds.Mnemonic,
lds.Mnemonic # asm,
ins,
lds.is_direct>,
SIMCInstr <lds.Mnemonic, subtarget> {
let isPseudo = 0;
let isCodeGenOnly = 0;
}

//===----------------------------------------------------------------------===//
// LDS/VDS Direct Instructions
//===----------------------------------------------------------------------===//

let SubtargetPredicate = isGFX11Only in {

def LDS_DIRECT_LOAD : DSDIR_Pseudo<"lds_direct_load", LDSDIR_getIns<1>.ret, 1>;
def LDS_PARAM_LOAD : DSDIR_Pseudo<"lds_param_load", LDSDIR_getIns<0>.ret, 0>;

def : GCNPat <
(f32 (int_amdgcn_lds_direct_load M0)),
(LDS_DIRECT_LOAD 0)
>;

def : GCNPat <
(f32 (int_amdgcn_lds_param_load timm:$attrchan, timm:$attr, M0)),
(LDS_PARAM_LOAD timm:$attr, timm:$attrchan, 0)
>;

} // End SubtargetPredicate = isGFX11Only

let SubtargetPredicate = isGFX12Plus in {

def DS_DIRECT_LOAD : DSDIR_Pseudo<"ds_direct_load", VDSDIR_getIns<1>.ret, 1>;
def DS_PARAM_LOAD : DSDIR_Pseudo<"ds_param_load", VDSDIR_getIns<0>.ret, 0>;

def : GCNPat <
(f32 (int_amdgcn_lds_direct_load M0)),
(DS_DIRECT_LOAD 0, 1)
>;

def : GCNPat <
(f32 (int_amdgcn_lds_param_load timm:$attrchan, timm:$attr, M0)),
(DS_PARAM_LOAD timm:$attr, timm:$attrchan, 0, 1)
>;

} // End SubtargetPredicate = isGFX12Only

//===----------------------------------------------------------------------===//
// GFX11
//===----------------------------------------------------------------------===//

multiclass DSDIR_Real_gfx11<bits<2> op,
DSDIR_Pseudo lds = !cast<DSDIR_Pseudo>(NAME)> {
def _gfx11 : DSDIR_Real<lds, lds.InOperandList,
LDSDIR_getAsm<lds.is_direct>.ret,
SIEncodingFamily.GFX11>,
LDSDIRe<op, lds.is_direct> {
let AssemblerPredicate = isGFX11Only;
let DecoderNamespace = "GFX11";
}
}

defm LDS_PARAM_LOAD : DSDIR_Real_gfx11<0x0>;
defm LDS_DIRECT_LOAD : DSDIR_Real_gfx11<0x1>;

//===----------------------------------------------------------------------===//
// GFX12+
//===----------------------------------------------------------------------===//

multiclass DSDIR_Real_gfx12<bits<2> op,
DSDIR_Pseudo lds = !cast<DSDIR_Pseudo>(NAME)> {
def _gfx12 : DSDIR_Real<lds, lds.InOperandList,
VDSDIR_getAsm<lds.is_direct>.ret,
SIEncodingFamily.GFX12>,
VDSDIRe<op, lds.is_direct> {
let AssemblerPredicate = isGFX12Plus;
let DecoderNamespace = "GFX12";
}
}

defm DS_PARAM_LOAD : DSDIR_Real_gfx12<0x0>;
defm DS_DIRECT_LOAD : DSDIR_Real_gfx12<0x1>;
116 changes: 0 additions & 116 deletions llvm/lib/Target/AMDGPU/LDSDIRInstructions.td

This file was deleted.

14 changes: 14 additions & 0 deletions llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUInstPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,20 @@ void AMDGPUInstPrinter::printWaitVDST(const MCInst *MI, unsigned OpNo,
printU4ImmDecOperand(MI, OpNo, O);
}

void AMDGPUInstPrinter::printWaitVAVDst(const MCInst *MI, unsigned OpNo,
const MCSubtargetInfo &STI,
raw_ostream &O) {
O << " wait_va_vdst:";
printU4ImmDecOperand(MI, OpNo, O);
}

void AMDGPUInstPrinter::printWaitVMVSrc(const MCInst *MI, unsigned OpNo,
const MCSubtargetInfo &STI,
raw_ostream &O) {
O << " wait_vm_vsrc:";
printU4ImmDecOperand(MI, OpNo, O);
}

void AMDGPUInstPrinter::printWaitEXP(const MCInst *MI, unsigned OpNo,
const MCSubtargetInfo &STI,
raw_ostream &O) {
Expand Down
4 changes: 4 additions & 0 deletions llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUInstPrinter.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ class AMDGPUInstPrinter : public MCInstPrinter {
raw_ostream &O);
void printWaitEXP(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
raw_ostream &O);
void printWaitVAVDst(const MCInst *MI, unsigned OpNo,
const MCSubtargetInfo &STI, raw_ostream &O);
void printWaitVMVSrc(const MCInst *MI, unsigned OpNo,
const MCSubtargetInfo &STI, raw_ostream &O);

void printExpSrcN(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
raw_ostream &O, unsigned N);
Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/Target/AMDGPU/SIInstrInfo.td
Original file line number Diff line number Diff line change
Expand Up @@ -1144,6 +1144,8 @@ def exp_tgt : CustomOperand<i32, 0, "ExpTgt">;

def wait_vdst : NamedIntOperand<i8, "wait_vdst", "WaitVDST">;
def wait_exp : NamedIntOperand<i8, "wait_exp", "WaitEXP">;
def wait_va_vdst : NamedIntOperand<i8, "wait_va_vdst", "WaitVAVDst">;
def wait_va_vsrc : NamedIntOperand<i8, "wait_vm_vsrc", "WaitVMVSrc">;

class KImmFPOperand<ValueType vt> : ImmOperand<vt> {
let OperandNamespace = "AMDGPU";
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/AMDGPU/SIInstructions.td
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ include "SMInstructions.td"
include "FLATInstructions.td"
include "BUFInstructions.td"
include "EXPInstructions.td"
include "LDSDIRInstructions.td"
include "DSDIRInstructions.td"
include "VINTERPInstructions.td"

//===----------------------------------------------------------------------===//
Expand Down
4 changes: 3 additions & 1 deletion llvm/lib/Target/AMDGPU/SIWholeQuadMode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,9 @@ char SIWholeQuadMode::scanInstructions(MachineFunction &MF,
}
continue;
} else if (Opcode == AMDGPU::LDS_PARAM_LOAD ||
Opcode == AMDGPU::LDS_DIRECT_LOAD) {
Opcode == AMDGPU::DS_PARAM_LOAD ||
Opcode == AMDGPU::LDS_DIRECT_LOAD ||
Opcode == AMDGPU::DS_DIRECT_LOAD) {
// Mark these STRICTWQM, but only for the instruction, not its operands.
// This avoid unnecessarily marking M0 as requiring WQM.
InstrInfo &II = Instructions[&MI];
Expand Down
25 changes: 20 additions & 5 deletions llvm/lib/Target/AMDGPU/SMInstructions.td
Original file line number Diff line number Diff line change
Expand Up @@ -977,20 +977,35 @@ def : GCNPat <
}
} // let OtherPredicates = [HasShaderCyclesRegister]

multiclass SMPrefetchPat<string type, int cache_type> {
def i32imm_zero : TImmLeaf <i32, [{
return Imm == 0;
}]>;

def i32imm_one : TImmLeaf <i32, [{
return Imm == 1;
}]>;

multiclass SMPrefetchPat<string type, TImmLeaf cache_type> {
def : GCNPat <
(smrd_prefetch (SMRDImm i64:$sbase, i32:$offset), timm, timm, (i32 cache_type)),
(smrd_prefetch (SMRDImm i64:$sbase, i32:$offset), timm, timm, cache_type),
(!cast<SM_Prefetch_Pseudo>("S_PREFETCH_"#type) $sbase, $offset, (i32 SGPR_NULL), (i8 0))
>;

def : GCNPat <
(smrd_prefetch (i64 SReg_64:$sbase), timm, timm, (i32 cache_type)),
(smrd_prefetch (i64 SReg_64:$sbase), timm, timm, cache_type),
(!cast<SM_Prefetch_Pseudo>("S_PREFETCH_"#type) $sbase, 0, (i32 SGPR_NULL), (i8 0))
>;

def : GCNPat <
(smrd_prefetch (i32 SReg_32:$sbase), timm, timm, cache_type),
(!cast<SM_Prefetch_Pseudo>("S_PREFETCH_"#type)
(i64 (REG_SEQUENCE SReg_64, $sbase, sub0, (i32 (S_MOV_B32 (i32 0))), sub1)),
0, (i32 SGPR_NULL), (i8 0))
>;
}

defm : SMPrefetchPat<"INST", 0>;
defm : SMPrefetchPat<"DATA", 1>;
defm : SMPrefetchPat<"INST", i32imm_zero>;
defm : SMPrefetchPat<"DATA", i32imm_one>;

//===----------------------------------------------------------------------===//
// GFX10.
Expand Down
Loading