diff --git a/nautilus/include/nautilus/Engine.hpp b/nautilus/include/nautilus/Engine.hpp index 2388364d..4943d119 100644 --- a/nautilus/include/nautilus/Engine.hpp +++ b/nautilus/include/nautilus/Engine.hpp @@ -32,7 +32,7 @@ std::function createFunctionWrapper(std::index_sequence, std auto traceFunc = [=]() { if constexpr (std::is_void_v) { func(details::createTraceableArgument()...); - tracing::traceReturnOperation(Type::v, tracing::value_ref()); + tracing::traceReturnOperation(Type::v, tracing::TypedValueRef()); } else { auto returnValue = func(details::createTraceableArgument()...); auto type = tracing::to_type(); diff --git a/nautilus/include/nautilus/function.hpp b/nautilus/include/nautilus/function.hpp index d9ab2584..2e37f1bd 100644 --- a/nautilus/include/nautilus/function.hpp +++ b/nautilus/include/nautilus/function.hpp @@ -10,10 +10,10 @@ namespace nautilus { template auto getArgumentReferences(const ValueArguments&... arguments) { - std::vector functionArgumentReferences; + std::vector functionArgumentReferences; if constexpr (sizeof...(ValueArguments) > 0) { functionArgumentReferences.reserve(sizeof...(ValueArguments)); - for (const tracing::value_ref& p : {details::getState(arguments)...}) { + for (const tracing::TypedValueRef& p : {details::getState(arguments)...}) { functionArgumentReferences.emplace_back(p); } } diff --git a/nautilus/include/nautilus/tracing/TracingUtil.hpp b/nautilus/include/nautilus/tracing/TracingUtil.hpp index 7880f4e0..69e875f3 100644 --- a/nautilus/include/nautilus/tracing/TracingUtil.hpp +++ b/nautilus/include/nautilus/tracing/TracingUtil.hpp @@ -15,32 +15,32 @@ namespace nautilus::tracing { bool inTracer(); -value_ref traceBinaryOp(Op operation, Type resultType, const TypedValueRef& leftState, const TypedValueRef& rightState); -value_ref traceUnaryOp(Op operation, Type resultType, const TypedValueRef& inputState); +TypedValueRef traceBinaryOp(Op operation, Type resultType, const TypedValueRef& leftState, const TypedValueRef& rightState); +TypedValueRef traceUnaryOp(Op operation, Type resultType, const TypedValueRef& inputState); bool traceBool(const TypedValueRef& state); -value_ref traceConstant(Type type, const ConstantLiteral& value); +TypedValueRef traceConstant(Type type, const ConstantLiteral& value); template -value_ref traceConstant(T&& value) { +TypedValueRef traceConstant(T&& value) { if (inTracer()) { return traceConstant(to_type(), createConstLiteral(value)); } return {0, to_type()}; } -value_ref traceLoad(const TypedValueRef& src, Type resultType); +TypedValueRef traceLoad(const TypedValueRef& src, Type resultType); void traceStore(const TypedValueRef& target, const TypedValueRef& src, Type valueType); -value_ref traceCast(const value_ref& state, Type resultType); +TypedValueRef traceCast(const TypedValueRef& state, Type resultType); void traceAssignment(const TypedValueRef& target, const TypedValueRef& source, Type resultType); -value_ref traceCopy(const TypedValueRef& state); +TypedValueRef traceCopy(const TypedValueRef& state); -value_ref traceCall(void* fptn, Type resultType, const std::vector& arguments); +TypedValueRef traceCall(void* fptn, Type resultType, const std::vector& arguments); -value_ref registerFunctionArgument(Type type, size_t index); +TypedValueRef registerFunctionArgument(Type type, size_t index); -void traceReturnOperation(Type type, const value_ref& ref); -void traceValueDestruction(value_ref ref); +void traceReturnOperation(Type type, const TypedValueRef& ref); +void traceValueDestruction(TypedValueRef ref); void pushStaticVal(void* ptr); void popStaticVal(); diff --git a/nautilus/include/nautilus/tracing/TypedValueRef.hpp b/nautilus/include/nautilus/tracing/TypedValueRef.hpp index 42f13a90..e8be57d8 100644 --- a/nautilus/include/nautilus/tracing/TypedValueRef.hpp +++ b/nautilus/include/nautilus/tracing/TypedValueRef.hpp @@ -49,5 +49,4 @@ class TypedValueRefHolder { TypedValueRef valueRef; }; -using value_ref = TypedValueRef; } // namespace nautilus::tracing diff --git a/nautilus/include/nautilus/val.hpp b/nautilus/include/nautilus/val.hpp index c2bf5334..13d21e92 100644 --- a/nautilus/include/nautilus/val.hpp +++ b/nautilus/include/nautilus/val.hpp @@ -22,7 +22,7 @@ LHS getRawValue(const val& val); #define DEDUCT_RETURN_TYPE(OP) val template -tracing::value_ref getState(T&& value) { +tracing::TypedValueRef getState(T&& value) { return value.state; } @@ -48,7 +48,7 @@ class val { // move constructor val(const val&& other) noexcept : state(std::move(other.state)), value(other.value) { } - val(tracing::value_ref& tc) : state(tc), value() { + val(tracing::TypedValueRef& tc) : state(tc), value() { } #else val() { @@ -145,7 +145,7 @@ class val { // move constructor val(const val&& other) : state(other.state), value(other.value) { } - val(tracing::value_ref& tc) : state(tc) { + val(tracing::TypedValueRef& tc) : state(tc) { } #else diff --git a/nautilus/include/nautilus/val_ptr.hpp b/nautilus/include/nautilus/val_ptr.hpp index 60179a40..a60411cf 100644 --- a/nautilus/include/nautilus/val_ptr.hpp +++ b/nautilus/include/nautilus/val_ptr.hpp @@ -17,11 +17,11 @@ class val { const tracing::TypedValueRefHolder state; #endif #ifdef ENABLE_TRACING - val(ValueType ref) : state(tracing::value_ref()), ptr(&ref) { + val(ValueType ref) : state(tracing::TypedValueRef()), ptr(&ref) { } - val(ValueType ref, tracing::value_ref value_ref) : state(value_ref), ptr(&ref) { + val(ValueType ref, tracing::TypedValueRef TypedValueRef) : state(TypedValueRef), ptr(&ref) { } - val(val ptr, tracing::value_ref ref) : state(ref), ptr(ptr) { + val(val ptr, tracing::TypedValueRef ref) : state(ref), ptr(ptr) { } #else val(ValueType ref) : ptr(&ref) { @@ -90,12 +90,12 @@ class base_ptr_val { #ifdef ENABLE_TRACING base_ptr_val(ValuePtrType ptr) : state(tracing::traceConstant((void*) ptr)), value(ptr) { } - base_ptr_val(ValuePtrType ptr, tracing::value_ref tc) : state(tc), value(ptr) { + base_ptr_val(ValuePtrType ptr, tracing::TypedValueRef tc) : state(tc), value(ptr) { } base_ptr_val(ValuePtrType ptr, tracing::TypedValueRefHolder tc) : state(std::move(tc)), value(ptr) { } - base_ptr_val(tracing::value_ref ref) : state(ref), value(nullptr) { + base_ptr_val(tracing::TypedValueRef ref) : state(ref), value(nullptr) { } #else base_ptr_val(ValuePtrType ptr) : value(ptr) { @@ -356,11 +356,11 @@ class val { #ifdef ENABLE_TRACING tracing::TypedValueRefHolder state; - val(bool ref) : state(tracing::value_ref()), ptr(&ref) { + val(bool ref) : state(tracing::TypedValueRef()), ptr(&ref) { } - val(bool& ref, tracing::value_ref value_ref) : state(value_ref), ptr(&ref) { + val(bool& ref, tracing::TypedValueRef TypedValueRef) : state(TypedValueRef), ptr(&ref) { } - val(val ptr, tracing::value_ref ref) : state(ref), ptr(ptr) { + val(val ptr, tracing::TypedValueRef ref) : state(ref), ptr(ptr) { } #else val(bool ref) : ptr(&ref) { diff --git a/nautilus/src/nautilus/tracing/ExecutionTrace.cpp b/nautilus/src/nautilus/tracing/ExecutionTrace.cpp index 848a141a..83344166 100644 --- a/nautilus/src/nautilus/tracing/ExecutionTrace.cpp +++ b/nautilus/src/nautilus/tracing/ExecutionTrace.cpp @@ -51,7 +51,7 @@ bool ExecutionTrace::checkTag(Snapshot& snapshot) { return true; } -void ExecutionTrace::addReturn(Snapshot& snapshot, Type resultType, value_ref ref) { +void ExecutionTrace::addReturn(Snapshot& snapshot, Type resultType, TypedValueRef ref) { if (blocks.empty()) { createBlock(); } @@ -68,7 +68,7 @@ void ExecutionTrace::addReturn(Snapshot& snapshot, Type resultType, value_ref re returnRefs.emplace_back(operationIdentifier); } -void ExecutionTrace::addAssignmentOperation(Snapshot& snapshot, nautilus::tracing::value_ref targetRef, nautilus::tracing::value_ref srcRef, Type resultType) { +void ExecutionTrace::addAssignmentOperation(Snapshot& snapshot, nautilus::tracing::TypedValueRef targetRef, nautilus::tracing::TypedValueRef srcRef, Type resultType) { if (blocks.empty()) { createBlock(); } @@ -80,7 +80,7 @@ void ExecutionTrace::addAssignmentOperation(Snapshot& snapshot, nautilus::tracin addTag(snapshot, operationIdentifier); } -void ExecutionTrace::addOperation(Snapshot& snapshot, Op& operation, Type& resultType, nautilus::tracing::value_ref targetRef, nautilus::tracing::value_ref srcRef) { +void ExecutionTrace::addOperation(Snapshot& snapshot, Op& operation, Type& resultType, nautilus::tracing::TypedValueRef targetRef, nautilus::tracing::TypedValueRef srcRef) { if (blocks.empty()) { createBlock(); } @@ -88,20 +88,20 @@ void ExecutionTrace::addOperation(Snapshot& snapshot, Op& operation, Type& resul operations.emplace_back(snapshot, operation, resultType, targetRef, std::vector {srcRef}); } -value_ref ExecutionTrace::addOperationWithResult(Snapshot& snapshot, Op& operation, Type& resultType, std::vector&& inputs) { +TypedValueRef ExecutionTrace::addOperationWithResult(Snapshot& snapshot, Op& operation, Type& resultType, std::vector&& inputs) { if (blocks.empty()) { createBlock(); } auto& operations = blocks[currentBlockIndex].operations; - auto& to = operations.emplace_back(snapshot, operation, resultType, value_ref(getNextValueRef(), resultType), std::forward>(inputs)); + auto& to = operations.emplace_back(snapshot, operation, resultType, TypedValueRef(getNextValueRef(), resultType), std::forward>(inputs)); auto operationIdentifier = getNextOperationIdentifier(); addTag(snapshot, operationIdentifier); return to.resultRef; } -void ExecutionTrace::addCmpOperation(Snapshot& snapshot, value_ref inputs) { +void ExecutionTrace::addCmpOperation(Snapshot& snapshot, TypedValueRef inputs) { if (blocks.empty()) { createBlock(); } @@ -112,7 +112,7 @@ void ExecutionTrace::addCmpOperation(Snapshot& snapshot, value_ref inputs) { auto falseBlock = createBlock(); getBlock(falseBlock).predecessors.emplace_back(getCurrentBlockIndex()); auto& operations = blocks[currentBlockIndex].operations; - operations.emplace_back(snapshot, CMP, Type::v, value_ref(getNextValueRef(), Type::v), std::vector {inputs, BlockRef(trueBlock), BlockRef(falseBlock)}); + operations.emplace_back(snapshot, CMP, Type::v, TypedValueRef(getNextValueRef(), Type::v), std::vector {inputs, BlockRef(trueBlock), BlockRef(falseBlock)}); auto operationIdentifier = getNextOperationIdentifier(); addTag(snapshot, operationIdentifier); } @@ -204,7 +204,7 @@ Block& ExecutionTrace::processControlFlowMerge(operation_identifier oi) { return mergeBlock; } -value_ref ExecutionTrace::setArgument(Type type, size_t index) { +TypedValueRef ExecutionTrace::setArgument(Type type, size_t index) { ++lastValueRef; uint16_t argRef = index + 1; auto& arguments = blocks[0].arguments; @@ -212,7 +212,7 @@ value_ref ExecutionTrace::setArgument(Type type, size_t index) { arguments.resize(argRef); } // arguments[index] = {argRef, type}; - arguments[index] = value_ref(argRef, type); + arguments[index] = TypedValueRef(argRef, type); return arguments[index]; } @@ -346,7 +346,7 @@ auto formatter::format(const nautilus::tracin fmt::format_to(out, "\t{}\t", toString(operation.op)); fmt::format_to(out, "{}\t", operation.resultRef); for (const auto& opInput : operation.input) { - if (auto inputRef = std::get_if(&opInput)) { + if (auto inputRef = std::get_if(&opInput)) { fmt::format_to(out, "{}\t", *inputRef); } else if (auto blockRef = std::get_if(&opInput)) { fmt::format_to(out, "{}\t", *blockRef); diff --git a/nautilus/src/nautilus/tracing/ExecutionTrace.hpp b/nautilus/src/nautilus/tracing/ExecutionTrace.hpp index 74b6caf2..5d24e9cd 100644 --- a/nautilus/src/nautilus/tracing/ExecutionTrace.hpp +++ b/nautilus/src/nautilus/tracing/ExecutionTrace.hpp @@ -18,13 +18,13 @@ class ExecutionTrace { ~ExecutionTrace() = default; - value_ref addOperationWithResult(Snapshot& snapshot, Op& operation, Type& resultType, std::vector&& inputs); + TypedValueRef addOperationWithResult(Snapshot& snapshot, Op& operation, Type& resultType, std::vector&& inputs); - void addCmpOperation(Snapshot& snapshot, value_ref inputs); + void addCmpOperation(Snapshot& snapshot, TypedValueRef inputs); - void addAssignmentOperation(Snapshot&, value_ref targetRef, value_ref srcRef, Type resultType); + void addAssignmentOperation(Snapshot&, TypedValueRef targetRef, TypedValueRef srcRef, Type resultType); - void addReturn(Snapshot&, Type type, value_ref ref); + void addReturn(Snapshot&, Type type, TypedValueRef ref); bool checkTag(Snapshot& snapshot); @@ -36,7 +36,7 @@ class ExecutionTrace { * @brief Adds arguments that are passed to the traced function * @param argument */ - value_ref setArgument(Type type, size_t index); + TypedValueRef setArgument(Type type, size_t index); /** * @brief Returns all arguments of this trace. @@ -69,7 +69,7 @@ class ExecutionTrace { */ uint16_t getCurrentBlockIndex() const; - void addOperation(Snapshot& snapshot, Op& operation, Type& resultType, value_ref targetRef, value_ref srcRef); + void addOperation(Snapshot& snapshot, Op& operation, Type& resultType, TypedValueRef targetRef, TypedValueRef srcRef); /** * @brief Returns the current block diff --git a/nautilus/src/nautilus/tracing/TraceContext.cpp b/nautilus/src/nautilus/tracing/TraceContext.cpp index f85cfe09..0f420f3a 100644 --- a/nautilus/src/nautilus/tracing/TraceContext.cpp +++ b/nautilus/src/nautilus/tracing/TraceContext.cpp @@ -41,15 +41,15 @@ void TraceContext::terminate() { TraceContext::TraceContext(TagRecorder& tagRecorder) : tagRecorder(tagRecorder), executionTrace(std::make_unique()), symbolicExecutionContext(std::make_unique()) { } -value_ref TraceContext::registerFunctionArgument(Type type, size_t index) { +TypedValueRef TraceContext::registerFunctionArgument(Type type, size_t index) { return executionTrace->setArgument(type, index); } -void TraceContext::traceValueDestruction(nautilus::tracing::value_ref) { +void TraceContext::traceValueDestruction(nautilus::tracing::TypedValueRef) { // currently yed not implemented } -value_ref TraceContext::traceLoad(const value_ref& src, Type resultType) { +TypedValueRef TraceContext::traceLoad(const TypedValueRef& src, Type resultType) { if (isFollowing()) { auto& currentOperation = executionTrace->getCurrentOperation(); executionTrace->nextOperation(); @@ -65,7 +65,7 @@ value_ref TraceContext::traceLoad(const value_ref& src, Type resultType) { throw TraceTerminationException(); } -void TraceContext::traceStore(const value_ref& target, const value_ref& src, Type valueType) { +void TraceContext::traceStore(const TypedValueRef& target, const TypedValueRef& src, Type valueType) { if (isFollowing()) { auto& currentOperation = executionTrace->getCurrentOperation(); executionTrace->nextOperation(); @@ -85,7 +85,7 @@ bool TraceContext::isFollowing() { return symbolicExecutionContext->getCurrentMode() == SymbolicExecutionContext::MODE::FOLLOW; } -value_ref TraceContext::traceConstValue(Type type, const ConstantLiteral& constValue) { +TypedValueRef TraceContext::traceConstValue(Type type, const ConstantLiteral& constValue) { log::debug("Trace Constant"); auto op = Op::CONST; if (isFollowing()) { @@ -108,7 +108,7 @@ value_ref TraceContext::traceConstValue(Type type, const ConstantLiteral& constV } } -value_ref TraceContext::traceCopy(const value_ref& ref) { +TypedValueRef TraceContext::traceCopy(const TypedValueRef& ref) { log::debug("Trace Copy"); if (symbolicExecutionContext->getCurrentMode() == SymbolicExecutionContext::MODE::FOLLOW) { auto& currentOperation = executionTrace->getCurrentOperation(); @@ -125,7 +125,7 @@ value_ref TraceContext::traceCopy(const value_ref& ref) { throw TraceTerminationException(); } -value_ref TraceContext::traceCall(const std::string& functionName, const std::string& mangledName, void* fptn, Type resultType, const std::vector& arguments) { +TypedValueRef TraceContext::traceCall(const std::string& functionName, const std::string& mangledName, void* fptn, Type resultType, const std::vector& arguments) { auto op = Op::CALL; if (symbolicExecutionContext->getCurrentMode() == SymbolicExecutionContext::MODE::FOLLOW) { @@ -149,7 +149,7 @@ value_ref TraceContext::traceCall(const std::string& functionName, const std::st throw TraceTerminationException(); } -void TraceContext::traceAssignment(const value_ref& targetRef, const value_ref& sourceRef, Type resultType) { +void TraceContext::traceAssignment(const TypedValueRef& targetRef, const TypedValueRef& sourceRef, Type resultType) { if (symbolicExecutionContext->getCurrentMode() == SymbolicExecutionContext::MODE::FOLLOW) { auto& currentOperation = executionTrace->getCurrentOperation(); executionTrace->nextOperation(); @@ -164,7 +164,7 @@ void TraceContext::traceAssignment(const value_ref& targetRef, const value_ref& throw TraceTerminationException(); } -value_ref TraceContext::traceCast(const value_ref& state, Type resultType) { +TypedValueRef TraceContext::traceCast(const TypedValueRef& state, Type resultType) { if (isFollowing()) { auto& currentOperation = executionTrace->getCurrentOperation(); executionTrace->nextOperation(); @@ -183,7 +183,7 @@ value_ref TraceContext::traceCast(const value_ref& state, Type resultType) { throw TraceTerminationException(); } -void TraceContext::traceReturnOperation(Type type, const value_ref& ref) { +void TraceContext::traceReturnOperation(Type type, const TypedValueRef& ref) { if (symbolicExecutionContext->getCurrentMode() == SymbolicExecutionContext::MODE::FOLLOW) { auto& currentOperation = executionTrace->getCurrentOperation(); executionTrace->nextOperation(); @@ -194,7 +194,7 @@ void TraceContext::traceReturnOperation(Type type, const value_ref& ref) { executionTrace->addReturn(tag, type, ref); } -value_ref TraceContext::traceUnaryOperation(nautilus::tracing::Op op, Type resultType, const value_ref& inputRef) { +TypedValueRef TraceContext::traceUnaryOperation(nautilus::tracing::Op op, Type resultType, const TypedValueRef& inputRef) { if (isFollowing()) { auto& currentOperation = executionTrace->getCurrentOperation(); executionTrace->nextOperation(); @@ -210,7 +210,7 @@ value_ref TraceContext::traceUnaryOperation(nautilus::tracing::Op op, Type resul throw TraceTerminationException(); } -value_ref TraceContext::traceBinaryOperation(Op op, Type resultType, const value_ref& leftRef, const value_ref& rightRef) { +TypedValueRef TraceContext::traceBinaryOperation(Op op, Type resultType, const TypedValueRef& leftRef, const TypedValueRef& rightRef) { if (isFollowing()) { auto& currentOperation = executionTrace->getCurrentOperation(); executionTrace->nextOperation(); @@ -226,7 +226,7 @@ value_ref TraceContext::traceBinaryOperation(Op op, Type resultType, const value throw TraceTerminationException(); } -bool TraceContext::traceCmp(const value_ref& targetRef) { +bool TraceContext::traceCmp(const TypedValueRef& targetRef) { bool result; if (symbolicExecutionContext->getCurrentMode() == SymbolicExecutionContext::MODE::FOLLOW) { // eval execution path one step diff --git a/nautilus/src/nautilus/tracing/TraceContext.hpp b/nautilus/src/nautilus/tracing/TraceContext.hpp index 55e63e35..11ffa998 100644 --- a/nautilus/src/nautilus/tracing/TraceContext.hpp +++ b/nautilus/src/nautilus/tracing/TraceContext.hpp @@ -40,18 +40,18 @@ class TraceContext { static bool shouldTrace(); - value_ref registerFunctionArgument(Type type, size_t index); + TypedValueRef registerFunctionArgument(Type type, size_t index); - void traceValueDestruction(value_ref target); + void traceValueDestruction(TypedValueRef target); /** * @brief Trace a constant operation. * @param valueReference reference to the const value. * @param constValue constant value. */ - value_ref traceConstValue(Type type, const ConstantLiteral& constValue); + TypedValueRef traceConstValue(Type type, const ConstantLiteral& constValue); - value_ref traceCopy(const value_ref& ref); + TypedValueRef traceCopy(const TypedValueRef& ref); Tag* getTag(); @@ -61,7 +61,7 @@ class TraceContext { * @param inputRef reference to the input. * @param resultRef reference to the result. */ - value_ref traceUnaryOperation(Op op, Type resultType, const value_ref& inputRef); + TypedValueRef traceUnaryOperation(Op op, Type resultType, const TypedValueRef& inputRef); /** * @brief Trace a binary operation, e.g., add, sub, div. @@ -70,30 +70,30 @@ class TraceContext { * @param rightRef reference to the right input. * @param resultRef reference to the result. */ - value_ref traceBinaryOperation(Op op, Type resultType, const value_ref& leftRef, const value_ref& rightRef); + TypedValueRef traceBinaryOperation(Op op, Type resultType, const TypedValueRef& leftRef, const TypedValueRef& rightRef); /** * @brief Trace the return function. * @param resultRef referent to the return value. */ - void traceReturnOperation(Type type, const value_ref& ref); + void traceReturnOperation(Type type, const TypedValueRef& ref); /** * @brief Trace a value assignment. * @param targetRef reference to the target value. * @param sourceRef reference to the source value. */ - void traceAssignment(const value_ref& targetRef, const value_ref& sourceRef, Type resultType); + void traceAssignment(const TypedValueRef& targetRef, const TypedValueRef& sourceRef, Type resultType); - value_ref traceCall(const std::string& functionName, const std::string& mangledName, void* fptn, Type resultType, const std::vector& arguments); + TypedValueRef traceCall(const std::string& functionName, const std::string& mangledName, void* fptn, Type resultType, const std::vector& arguments); - bool traceCmp(const value_ref& targetRef); + bool traceCmp(const TypedValueRef& targetRef); - value_ref traceLoad(const value_ref& src, Type resultType); + TypedValueRef traceLoad(const TypedValueRef& src, Type resultType); - value_ref traceCast(const value_ref& state, Type resultType); + TypedValueRef traceCast(const TypedValueRef& state, Type resultType); - void traceStore(const value_ref& target, const value_ref& src, Type valueType); + void traceStore(const TypedValueRef& target, const TypedValueRef& src, Type valueType); ~TraceContext() = default; diff --git a/nautilus/src/nautilus/tracing/TraceOperation.cpp b/nautilus/src/nautilus/tracing/TraceOperation.cpp index ae3e88ab..b25152e9 100644 --- a/nautilus/src/nautilus/tracing/TraceOperation.cpp +++ b/nautilus/src/nautilus/tracing/TraceOperation.cpp @@ -5,7 +5,7 @@ namespace nautilus::tracing { BlockRef::BlockRef(uint16_t block) : block(block) { } -TraceOperation::TraceOperation(Snapshot& tag, Op op, Type resultType, value_ref ref, std::vector&& input) : tag(tag), op(op), resultType(resultType), resultRef(ref), input(input) { +TraceOperation::TraceOperation(Snapshot& tag, Op op, Type resultType, TypedValueRef ref, std::vector&& input) : tag(tag), op(op), resultType(resultType), resultRef(ref), input(input) { } TraceOperation::TraceOperation(Op op, std::vector&& input) : tag(), op(op), resultType(Type::v), resultRef(), input(input) { diff --git a/nautilus/src/nautilus/tracing/TraceOperation.hpp b/nautilus/src/nautilus/tracing/TraceOperation.hpp index 0d321d6d..635cfa01 100644 --- a/nautilus/src/nautilus/tracing/TraceOperation.hpp +++ b/nautilus/src/nautilus/tracing/TraceOperation.hpp @@ -18,7 +18,7 @@ struct FunctionCall { std::string functionName; std::string mangledName; void* ptr; - std::vector arguments; + std::vector arguments; }; struct BlockRef { @@ -27,19 +27,19 @@ struct BlockRef { std::vector arguments; }; -using InputVariant = std::variant; +using InputVariant = std::variant; /** * @brief Represents an individual operation in a trace. */ class TraceOperation { public: - TraceOperation(Snapshot& tag, Op op, Type resultType, value_ref ref, std::vector&& input); + TraceOperation(Snapshot& tag, Op op, Type resultType, TypedValueRef ref, std::vector&& input); TraceOperation(Op op, std::vector&& input); Snapshot tag; Op op; Type resultType; - value_ref resultRef; + TypedValueRef resultRef; std::vector input; }; diff --git a/nautilus/src/nautilus/tracing/TracingUtil.cpp b/nautilus/src/nautilus/tracing/TracingUtil.cpp index afe46d32..244f39e6 100644 --- a/nautilus/src/nautilus/tracing/TracingUtil.cpp +++ b/nautilus/src/nautilus/tracing/TracingUtil.cpp @@ -42,11 +42,11 @@ void traceReturnOperation(Type type, const TypedValueRef& ref) { TraceContext::get()->traceReturnOperation(type, ref); } -value_ref registerFunctionArgument(Type type, size_t index) { +TypedValueRef registerFunctionArgument(Type type, size_t index) { return TraceContext::get()->registerFunctionArgument(type, index); } -value_ref traceLoad(const TypedValueRef& src, Type resultType) { +TypedValueRef traceLoad(const TypedValueRef& src, Type resultType) { return TraceContext::get()->traceLoad(src, resultType); } @@ -54,7 +54,7 @@ void traceStore(const TypedValueRef& target, const TypedValueRef& src, Type valu TraceContext::get()->traceStore(target, src, valueType); } -value_ref traceConstant(Type type, const ConstantLiteral& value) { +TypedValueRef traceConstant(Type type, const ConstantLiteral& value) { return TraceContext::get()->traceConstValue(type, value); } @@ -62,7 +62,7 @@ bool traceBool(const TypedValueRef& state) { return TraceContext::get()->traceCmp(state); } -value_ref traceCast(const TypedValueRef& state, Type resultType) { +TypedValueRef traceCast(const TypedValueRef& state, Type resultType) { return TraceContext::get()->traceCast(state, resultType); } @@ -73,7 +73,7 @@ void freeValRef(ValueRef ref) { TraceContext::get()->freeValRef(ref); } -value_ref traceCopy(const value_ref& state) { +TypedValueRef traceCopy(const TypedValueRef& state) { if (inTracer()) { return TraceContext::get()->traceCopy(state); } @@ -84,17 +84,17 @@ bool inTracer() { return TraceContext::get() != nullptr; } -value_ref traceCall(void* fptn, Type resultType, const std::vector& arguments) { +TypedValueRef traceCall(void* fptn, Type resultType, const std::vector& arguments) { auto mangledName = getMangledName(fptn); auto functionName = getFunctionName(mangledName); return TraceContext::get()->traceCall(functionName, mangledName, fptn, resultType, arguments); } -value_ref traceBinaryOp(Op operation, Type resultType, const TypedValueRef& leftState, const TypedValueRef& rightState) { +TypedValueRef traceBinaryOp(Op operation, Type resultType, const TypedValueRef& leftState, const TypedValueRef& rightState) { return TraceContext::get()->traceBinaryOperation(operation, resultType, leftState, rightState); } -value_ref traceUnaryOp(Op operation, Type resultType, const TypedValueRef& inputState) { +TypedValueRef traceUnaryOp(Op operation, Type resultType, const TypedValueRef& inputState) { return TraceContext::get()->traceUnaryOperation(operation, resultType, inputState); } diff --git a/nautilus/src/nautilus/tracing/phases/SSACreationPhase.cpp b/nautilus/src/nautilus/tracing/phases/SSACreationPhase.cpp index 50e07e81..5dc2b851 100644 --- a/nautilus/src/nautilus/tracing/phases/SSACreationPhase.cpp +++ b/nautilus/src/nautilus/tracing/phases/SSACreationPhase.cpp @@ -36,7 +36,7 @@ Block& SSACreationPhase::SSACreationPhaseContext::getReturnBlock() { returnOpBlock.operations.erase(returnOpBlock.operations.cbegin() + returnOp.operationIndex); } else { auto snap = Snapshot(); - returnOpBlock.operations[returnOp.operationIndex] = TraceOperation(snap, ASSIGN, defaultReturnOp.resultType, std::get(defaultReturnOp.input[0]), {returnValue.input[0]}); + returnOpBlock.operations[returnOp.operationIndex] = TraceOperation(snap, ASSIGN, defaultReturnOp.resultType, std::get(defaultReturnOp.input[0]), {returnValue.input[0]}); } returnOpBlock.addOperation({Op::JMP, std::vector {BlockRef(returnBlock.blockId)}}); returnBlock.predecessors.emplace_back(returnOp.blockIndex); @@ -71,7 +71,7 @@ std::shared_ptr SSACreationPhase::SSACreationPhaseContext::proce return std::move(trace); } -bool SSACreationPhase::SSACreationPhaseContext::isLocalValueRef(Block& block, value_ref& ref, Type, uint32_t operationIndex) { +bool SSACreationPhase::SSACreationPhaseContext::isLocalValueRef(Block& block, TypedValueRef& ref, Type, uint32_t operationIndex) { // A value ref is defined in the local scope, if it is the result of an // operation before the operationIndex for (uint32_t i = 0; i < operationIndex; i++) { @@ -91,7 +91,7 @@ void SSACreationPhase::SSACreationPhaseContext::processBlock(Block& block) { auto& operation = block.operations[i]; // process input for each variable for (auto& input : operation.input) { - if (auto* valueRef = std::get_if(&input)) { + if (auto* valueRef = std::get_if(&input)) { // set op type processValueRef(block, *valueRef, operation.resultType, i); } else if (auto* blockRef = std::get_if(&input)) { @@ -120,7 +120,7 @@ void SSACreationPhase::SSACreationPhaseContext::processBlock(Block& block) { } } -void SSACreationPhase::SSACreationPhaseContext::processValueRef(Block& block, value_ref& ref, Type ref_type, uint32_t operationIndex) { +void SSACreationPhase::SSACreationPhaseContext::processValueRef(Block& block, TypedValueRef& ref, Type ref_type, uint32_t operationIndex) { if (isLocalValueRef(block, ref, ref_type, operationIndex)) { // variable is a local ref -> don't do anything as the value is defined in // the current block @@ -179,12 +179,12 @@ void SSACreationPhase::SSACreationPhaseContext::removeAssignOperations() { } } if (operation.op == Op::ASSIGN) { - auto valueRef = get(operation.input[0]); + auto valueRef = get(operation.input[0]); auto foundAssignment = assignmentMap.find(valueRef.ref); if (foundAssignment != assignmentMap.end()) { assignmentMap[operation.resultRef.ref] = assignmentMap[valueRef.ref]; } else { - assignmentMap[operation.resultRef.ref] = get(operation.input[0]).ref; + assignmentMap[operation.resultRef.ref] = get(operation.input[0]).ref; } } else { if (operation.op == Op::STORE) { @@ -194,7 +194,7 @@ void SSACreationPhase::SSACreationPhaseContext::removeAssignOperations() { } } for (auto& input : operation.input) { - if (auto* valueRef = std::get_if(&input)) { + if (auto* valueRef = std::get_if(&input)) { auto foundAssignment = assignmentMap.find(valueRef->ref); if (foundAssignment != assignmentMap.end()) { // todo check assignment @@ -238,7 +238,7 @@ void SSACreationPhase::SSACreationPhaseContext::makeBlockArgumentsUnique() { for (uint64_t i = 0; i < block.operations.size(); i++) { auto& operation = block.operations[i]; for (auto& input : operation.input) { - if (auto* valueRef = std::get_if(&input)) { + if (auto* valueRef = std::get_if(&input)) { auto foundAssignment = blockArgumentMap.find(valueRef->ref); if (foundAssignment != blockArgumentMap.end()) { // todo check assignment diff --git a/nautilus/src/nautilus/tracing/phases/SSACreationPhase.hpp b/nautilus/src/nautilus/tracing/phases/SSACreationPhase.hpp index c692837d..7df62c44 100644 --- a/nautilus/src/nautilus/tracing/phases/SSACreationPhase.hpp +++ b/nautilus/src/nautilus/tracing/phases/SSACreationPhase.hpp @@ -54,9 +54,9 @@ class SSACreationPhase { * @param operationIndex the operation index, which accesses the ValueRef * @return true if Value Ref is defined locally. */ - static bool isLocalValueRef(Block& block, value_ref& valRef, Type ref_type, uint32_t operationIndex); + static bool isLocalValueRef(Block& block, TypedValueRef& valRef, Type ref_type, uint32_t operationIndex); - void processValueRef(Block& block, value_ref& type, Type ref_type, uint32_t operationIndex); + void processValueRef(Block& block, TypedValueRef& type, Type ref_type, uint32_t operationIndex); void processBlockRef(Block& block, BlockRef& blockRef, uint32_t operationIndex); diff --git a/nautilus/src/nautilus/tracing/phases/TraceToIRConversionPhase.cpp b/nautilus/src/nautilus/tracing/phases/TraceToIRConversionPhase.cpp index f1838beb..b8279226 100644 --- a/nautilus/src/nautilus/tracing/phases/TraceToIRConversionPhase.cpp +++ b/nautilus/src/nautilus/tracing/phases/TraceToIRConversionPhase.cpp @@ -20,12 +20,12 @@ namespace nautilus::tracing { using namespace compiler::ir; -OperationIdentifier createValueIdentifier(value_ref& val) { +OperationIdentifier createValueIdentifier(TypedValueRef& val) { return {val.ref}; } OperationIdentifier createValueIdentifier(InputVariant& val) { - if (auto* valRef = std::get_if(&val)) { + if (auto* valRef = std::get_if(&val)) { return {valRef->ref}; } throw NotImplementedException("wrong input variant"); @@ -220,7 +220,7 @@ void TraceToIRConversionPhase::IRConversionContext::processJMP(ValueFrame& frame } void TraceToIRConversionPhase::IRConversionContext::processCMP(ValueFrame& frame, Block&, BasicBlock* currentIrBlock, TraceOperation& operation) { - auto valueRef = get(operation.input[0]); + auto valueRef = get(operation.input[0]); auto trueCaseBlockRef = get(operation.input[1]); auto falseCaseBlockRef = get(operation.input[2]); diff --git a/nautilus/test/common/TracingUtil.hpp b/nautilus/test/common/TracingUtil.hpp index 4d150107..99e6717f 100644 --- a/nautilus/test/common/TracingUtil.hpp +++ b/nautilus/test/common/TracingUtil.hpp @@ -14,7 +14,7 @@ std::function createFunctionWrapper(std::index_sequence, R ( auto traceFunc = [=]() { if constexpr (std::is_void_v) { fnptr(details::createTraceableArgument()...); - tracing::traceReturnOperation(Type::v, tracing::value_ref()); + tracing::traceReturnOperation(Type::v, tracing::TypedValueRef()); } else { auto returnValue = fnptr(details::createTraceableArgument()...); auto type = tracing::to_type(); @@ -28,4 +28,4 @@ template std::function createFunctionWrapper(R (*fnptr)(FunctionArguments...)) { return createFunctionWrapper(std::make_index_sequence {}, fnptr); } -}} // namespace nautilus::details \ No newline at end of file +}} // namespace nautilus::details diff --git a/nautilus/test/execution-tests/TracingTest.cpp b/nautilus/test/execution-tests/TracingTest.cpp index cc95b102..027bb08a 100644 --- a/nautilus/test/execution-tests/TracingTest.cpp +++ b/nautilus/test/execution-tests/TracingTest.cpp @@ -30,7 +30,7 @@ std::function createFunctionWrapper(std::index_sequence, R ( auto traceFunc = [=]() { if constexpr (std::is_void_v) { fnptr(details::createTraceableArgument()...); - tracing::traceReturnOperation(Type::v, tracing::value_ref()); + tracing::traceReturnOperation(Type::v, tracing::TypedValueRef()); } else { auto returnValue = fnptr(details::createTraceableArgument()...); auto type = tracing::to_type(); diff --git a/third_party/backward-cpp/backward.hpp b/third_party/backward-cpp/backward.hpp index 670aa458..797eab1b 100644 --- a/third_party/backward-cpp/backward.hpp +++ b/third_party/backward-cpp/backward.hpp @@ -2925,7 +2925,7 @@ class TraceResolverLinuxImpl case DW_TAG_restrict_type: context.text.insert(0, "restrict "); break; - case DW_TAG_rvalue_reference_type: + case DW_TAG_rTypedValueReference_type: context.text.insert(0, "&&"); break; case DW_TAG_volatile_type: