Commit 9bbb0cd2 authored by Tobias Tebbi's avatar Tobias Tebbi Committed by Commit Bot

[torque] remove fake initialization of return variable

It turns out we can just remove kReturnVariable from the normal change
tracking, since it's always set when jumping to the final label anyway.

Bug: v8:7793
Change-Id: I6d0a777016047aa31b0edddd19c661e2631e1078
Reviewed-on: https://chromium-review.googlesource.com/1124471Reviewed-by: 's avatarDaniel Clifford <danno@chromium.org>
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54171}
parent 52a10e50
......@@ -156,9 +156,10 @@ void DeclarationVisitor::Visit(TorqueMacroDeclaration* decl,
CurrentCallableActivator activator(global_context_, macro, decl);
DeclareSignature(signature);
Variable* return_variable = nullptr;
if (!signature.return_type->IsVoidOrNever()) {
declarations()->DeclareVariable(kReturnValueVariable,
signature.return_type);
return_variable = declarations()->DeclareVariable(kReturnValueVariable,
signature.return_type);
}
PushControlSplit();
......@@ -166,6 +167,7 @@ void DeclarationVisitor::Visit(TorqueMacroDeclaration* decl,
Visit(body);
}
auto changed_vars = PopControlSplit();
if (return_variable) changed_vars.insert(return_variable);
global_context_.AddControlSplitChangedVariables(
decl, declarations()->GetCurrentSpecializationTypeNamesVector(),
changed_vars);
......@@ -238,11 +240,6 @@ void DeclarationVisitor::Visit(SpecializationDeclaration* decl) {
}
void DeclarationVisitor::Visit(ReturnStatement* stmt) {
const Callable* callable = global_context_.GetCurrentCallable();
if (callable->IsMacro() && callable->HasReturnValue()) {
MarkVariableModified(
Variable::cast(declarations()->LookupValue(kReturnValueVariable)));
}
if (stmt->value) {
Visit(*stmt->value);
}
......
......@@ -53,8 +53,6 @@ class FileVisitor {
};
protected:
static constexpr const char* kTrueLabelName = "_True";
static constexpr const char* kFalseLabelName = "_False";
static constexpr const char* kReturnValueVariable = "_return";
static constexpr const char* kDoneLabelName = "_done";
static constexpr const char* kForIndexValueVariable = "_for_index";
......
......@@ -185,20 +185,8 @@ void ImplementationVisitor::Visit(TorqueMacroDeclaration* decl,
const Variable* result_var = nullptr;
if (macro->HasReturnValue()) {
const Type* return_type = macro->signature().return_type;
if (!return_type->IsConstexpr()) {
GenerateIndent();
source_out() << "Node* return_default = &*SmiConstant(0);" << std::endl;
VisitResult init = {
return_type,
(std::string("UncheckedCast<") +
return_type->GetGeneratedTNodeTypeName() + ">(return_default)")};
result_var =
GenerateVariableDeclaration(decl, kReturnValueVariable, {}, init);
} else {
result_var =
GenerateVariableDeclaration(decl, kReturnValueVariable, {}, {});
}
result_var =
GenerateVariableDeclaration(decl, kReturnValueVariable, {}, {});
}
Label* macro_end = declarations()->DeclareLabel("macro_end");
GenerateLabelDefinition(macro_end, decl);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment