[AMDGPU] prevent shrinking udiv/urem if either operand is in (SignedMax,UnsignedMax...
[llvm-project.git] / llvm / lib / ExecutionEngine / Orc / AbsoluteSymbols.cpp
blobd37dad8925e9a6ff4a243c072b7aabd34bda3270
1 //===---------- AbsoluteSymbols.cpp - Absolute symbols utilities ----------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "llvm/ExecutionEngine/Orc/AbsoluteSymbols.h"
10 #include "llvm/ExecutionEngine/Orc/Core.h"
12 #define DEBUG_TYPE "orc"
14 namespace llvm::orc {
16 AbsoluteSymbolsMaterializationUnit::AbsoluteSymbolsMaterializationUnit(
17 SymbolMap Symbols)
18 : MaterializationUnit(extractFlags(Symbols)), Symbols(std::move(Symbols)) {}
20 StringRef AbsoluteSymbolsMaterializationUnit::getName() const {
21 return "<Absolute Symbols>";
24 void AbsoluteSymbolsMaterializationUnit::materialize(
25 std::unique_ptr<MaterializationResponsibility> R) {
26 // Even though these are just absolute symbols we need to check for failure
27 // to resolve/emit: the tracker for these symbols may have been removed while
28 // the materialization was in flight (e.g. due to a failure in some action
29 // triggered by the queries attached to the resolution/emission of these
30 // symbols).
31 if (auto Err = R->notifyResolved(Symbols)) {
32 R->getExecutionSession().reportError(std::move(Err));
33 R->failMaterialization();
34 return;
36 if (auto Err = R->notifyEmitted({})) {
37 R->getExecutionSession().reportError(std::move(Err));
38 R->failMaterialization();
39 return;
43 void AbsoluteSymbolsMaterializationUnit::discard(const JITDylib &JD,
44 const SymbolStringPtr &Name) {
45 assert(Symbols.count(Name) && "Symbol is not part of this MU");
46 Symbols.erase(Name);
49 MaterializationUnit::Interface
50 AbsoluteSymbolsMaterializationUnit::extractFlags(const SymbolMap &Symbols) {
51 SymbolFlagsMap Flags;
52 for (const auto &[Name, Def] : Symbols)
53 Flags[Name] = Def.getFlags();
54 return MaterializationUnit::Interface(std::move(Flags), nullptr);
57 } // namespace llvm::orc