#include "llvm/Support/CommandLine.h"
#include <algorithm>
#include <deque>
+#include <optional>
cl::opt<std::string> TFIR2NativeModelPath(
"ml-inliner-ir2native-model", cl::Hidden,
InlineSizeEstimatorAnalysis::run(const Function &F,
FunctionAnalysisManager &FAM) {
if (!Evaluator)
- return None;
+ return std::nullopt;
auto Features = IRToNativeSizeLearning::getFunctionFeatures(
const_cast<Function &>(F), FAM);
int32_t *V = Evaluator->getInput<int32_t>(0);
Features.fillTensor(V);
auto ER = Evaluator->evaluate();
if (!ER)
- return None;
+ return std::nullopt;
float Ret = *ER->getTensorValue<float>(0);
if (Ret < 0.0)
Ret = 0.0;
#include "llvm/Analysis/ModelUnderTrainingRunner.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Path.h"
+#include <optional>
using namespace llvm;
namespace {
if (!BufferOrError) {
Ctx.emitError("Error opening output specs file: " + FileName + " : " +
BufferOrError.getError().message());
- return None;
+ return std::nullopt;
}
auto ParsedJSONValues = json::parse(BufferOrError.get()->getBuffer());
if (!ParsedJSONValues) {
Ctx.emitError("Could not parse specs file: " + FileName);
- return None;
+ return std::nullopt;
}
auto ValuesArray = ParsedJSONValues->getAsArray();
if (!ValuesArray) {
Ctx.emitError("Expected an array of {tensor_spec:<TensorSpec>, "
"logging_name:<name>} dictionaries");
- return None;
+ return std::nullopt;
}
std::vector<LoggedFeatureSpec> Ret;
for (const auto &Value : *ValuesArray)
"Only int64, int32, and float tensors are supported. "
"Found unsupported type for tensor named " +
TensorSpec->name());
- return None;
+ return std::nullopt;
}
Ret.push_back({*TensorSpec, LoggingName->str()});
}
"with a json object describing a TensorSpec; and a 'logging_name' key, "
"which is a string to use as name when logging this tensor in the "
"training log.");
- return None;
+ return std::nullopt;
}
if (Ret.empty() || *Ret[0].LoggingName != ExpectedDecisionName) {
Ctx.emitError("The first output spec must describe the decision tensor, "
"and must have the logging_name " +
StringRef(ExpectedDecisionName));
- return None;
+ return std::nullopt;
}
return Ret;
}
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include <assert.h>
#include <cstdint>
+#include <optional>
#include <sstream>
#include <unordered_map>
// UniqueVectors IDs are one-based (which means the VarLocInfo VarID values
// are one-based) so reserve an extra and insert a dummy.
Variables.reserve(Builder.Variables.size() + 1);
- Variables.push_back(DebugVariable(nullptr, None, nullptr));
+ Variables.push_back(DebugVariable(nullptr, std::nullopt, nullptr));
Variables.append(Builder.Variables.begin(), Builder.Variables.end());
}
else if (Elements[2] == dwarf::DW_OP_minus)
Offset = -Elements[1];
else
- return None;
+ return std::nullopt;
}
// If that's all there is it means there's no deref.
if (NextElement >= NumElements)
- return None;
+ return std::nullopt;
// Check the next element is DW_OP_deref - otherwise this is too complex or
// isn't a deref expression.
if (Elements[NextElement] != dwarf::DW_OP_deref)
- return None;
+ return std::nullopt;
// Check the final operation is either the DW_OP_deref or is a fragment.
if (NumElements == NextElement + 1)
return Offset; // Ends with deref + fragment.
// Don't bother trying to interpret anything more complex.
- return None;
+ return std::nullopt;
}
/// A whole (unfragmented) source variable.
auto &Ctx = Fn.getContext();
for (auto FragMemLoc : FragMemLocs) {
- DIExpression *Expr = DIExpression::get(Ctx, None);
+ DIExpression *Expr = DIExpression::get(Ctx, std::nullopt);
Expr = *DIExpression::createFragmentExpression(
Expr, FragMemLoc.OffsetInBits, FragMemLoc.SizeInBits);
Expr = DIExpression::prepend(Expr, DIExpression::DerefAfter,
//
// DIExpression: Add fragment and offset.
DebugVariable V = FnVarLocs->getVariable(Var);
- DIExpression *DIE = DIExpression::get(I.getContext(), None);
+ DIExpression *DIE = DIExpression::get(I.getContext(), std::nullopt);
if (auto Frag = V.getFragment()) {
auto R = DIExpression::createFragmentExpression(DIE, Frag->OffsetInBits,
Frag->SizeInBits);
// built appropriately rather than always using an empty DIExpression.
// The assert below is a reminder.
assert(Simple);
- VarLoc.Expr = DIExpression::get(Fn.getContext(), None);
+ VarLoc.Expr = DIExpression::get(Fn.getContext(), std::nullopt);
DebugVariable Var = FnVarLocs->getVariable(VarLoc.VariableID);
FnVarLocs->addSingleLocVar(Var, VarLoc.Expr, VarLoc.DL, VarLoc.V);
InsertedAnyIntrinsics = true;