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,8 +156,9 @@ void DeclarationVisitor::Visit(TorqueMacroDeclaration* decl, ...@@ -156,8 +156,9 @@ void DeclarationVisitor::Visit(TorqueMacroDeclaration* decl,
CurrentCallableActivator activator(global_context_, macro, decl); CurrentCallableActivator activator(global_context_, macro, decl);
DeclareSignature(signature); DeclareSignature(signature);
Variable* return_variable = nullptr;
if (!signature.return_type->IsVoidOrNever()) { if (!signature.return_type->IsVoidOrNever()) {
declarations()->DeclareVariable(kReturnValueVariable, return_variable = declarations()->DeclareVariable(kReturnValueVariable,
signature.return_type); signature.return_type);
} }
...@@ -166,6 +167,7 @@ void DeclarationVisitor::Visit(TorqueMacroDeclaration* decl, ...@@ -166,6 +167,7 @@ void DeclarationVisitor::Visit(TorqueMacroDeclaration* decl,
Visit(body); Visit(body);
} }
auto changed_vars = PopControlSplit(); auto changed_vars = PopControlSplit();
if (return_variable) changed_vars.insert(return_variable);
global_context_.AddControlSplitChangedVariables( global_context_.AddControlSplitChangedVariables(
decl, declarations()->GetCurrentSpecializationTypeNamesVector(), decl, declarations()->GetCurrentSpecializationTypeNamesVector(),
changed_vars); changed_vars);
...@@ -238,11 +240,6 @@ void DeclarationVisitor::Visit(SpecializationDeclaration* decl) { ...@@ -238,11 +240,6 @@ void DeclarationVisitor::Visit(SpecializationDeclaration* decl) {
} }
void DeclarationVisitor::Visit(ReturnStatement* stmt) { 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) { if (stmt->value) {
Visit(*stmt->value); Visit(*stmt->value);
} }
......
...@@ -53,8 +53,6 @@ class FileVisitor { ...@@ -53,8 +53,6 @@ class FileVisitor {
}; };
protected: protected:
static constexpr const char* kTrueLabelName = "_True";
static constexpr const char* kFalseLabelName = "_False";
static constexpr const char* kReturnValueVariable = "_return"; static constexpr const char* kReturnValueVariable = "_return";
static constexpr const char* kDoneLabelName = "_done"; static constexpr const char* kDoneLabelName = "_done";
static constexpr const char* kForIndexValueVariable = "_for_index"; static constexpr const char* kForIndexValueVariable = "_for_index";
......
...@@ -185,21 +185,9 @@ void ImplementationVisitor::Visit(TorqueMacroDeclaration* decl, ...@@ -185,21 +185,9 @@ void ImplementationVisitor::Visit(TorqueMacroDeclaration* decl,
const Variable* result_var = nullptr; const Variable* result_var = nullptr;
if (macro->HasReturnValue()) { 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 = result_var =
GenerateVariableDeclaration(decl, kReturnValueVariable, {}, {}); GenerateVariableDeclaration(decl, kReturnValueVariable, {}, {});
} }
}
Label* macro_end = declarations()->DeclareLabel("macro_end"); Label* macro_end = declarations()->DeclareLabel("macro_end");
GenerateLabelDefinition(macro_end, decl); 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