Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions maldoca/js/ir/analyses/constant_propagation/tests/and/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

load("//bazel:lit.bzl", "glob_lit_tests")

package(default_applicable_licenses = ["//:license"])

licenses(["notice"])

glob_lit_tests(
name = "all_tests",
data = [
"README.generated.md",
"input.js",
"output.generated.txt",
"//maldoca/js/ir:lit_test_files",
],
test_file_exts = [
"lit",
],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
To run manually:

```shell
blaze run //third_party/maldoca/js/ir:jsir_gen -- \
--input_file $(pwd)/third_party/maldoca/js/ir/analyses/constant_propagation/tests/and/input.js \
--passes "source2ast,ast2hir,hir2lir" \
--jsir_analysis constant_propagation
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
var a = false && true;
var b = true && false;
var c = x && true;
var d = x && false;
console.log(a);
console.log(b);
console.log(c);
console.log(d);

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// RUN: CURRENT_FILE_BASENAME=$(basename %s .lit) && \
// RUN: jsir_gen --input_file "$(dirname %s)"/input.js \
// RUN: --passes "source2ast,ast2hir,hir2lir" \
// RUN: --jsir_analysis constant_propagation \
// RUN: | FileCheck --check-prefix JSLIR "$(dirname %s)"/output.generated.txt
32 changes: 32 additions & 0 deletions maldoca/js/ir/analyses/constant_propagation/tests/and_jshir/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

load("//bazel:lit.bzl", "glob_lit_tests")

package(default_applicable_licenses = ["//:license"])

licenses(["notice"])

glob_lit_tests(
name = "all_tests",
data = [
"README.generated.md",
"input.js",
"output.generated.txt",
"//maldoca/js/ir:lit_test_files",
],
test_file_exts = [
"lit",
],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
To run manually:

```shell
blaze run //third_party/maldoca/js/ir:jsir_gen -- \
--input_file $(pwd)/third_party/maldoca/js/ir/analyses/constant_propagation/tests/and_jshir/input.js \
--passes "source2ast,ast2hir" \
--jsir_analysis constant_propagation
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
var a = false && true;
var b = true && false;
var c = x && true;
var d = x && false;
console.log(a);
console.log(b);
console.log(c);
console.log(d);

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// RUN: CURRENT_FILE_BASENAME=$(basename %s .lit) && \
// RUN: jsir_gen --input_file "$(dirname %s)"/input.js \
// RUN: --passes "source2ast,ast2hir" \
// RUN: --jsir_analysis constant_propagation \
// RUN: | FileCheck --check-prefix JSHIR "$(dirname %s)"/output.generated.txt
32 changes: 32 additions & 0 deletions maldoca/js/ir/analyses/constant_propagation/tests/break/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

load("//bazel:lit.bzl", "glob_lit_tests")

package(default_applicable_licenses = ["//:license"])

licenses(["notice"])

glob_lit_tests(
name = "all_tests",
data = [
"README.generated.md",
"input.js",
"output.generated.txt",
"//maldoca/js/ir:lit_test_files",
],
test_file_exts = [
"lit",
],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
To run manually:

```shell
blaze run //third_party/maldoca/js/ir:jsir_gen -- \
--input_file $(pwd)/third_party/maldoca/js/ir/analyses/constant_propagation/tests/break/input.js \
--passes "source2ast,ast2hir,hir2lir" \
--jsir_analysis constant_propagation
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
var x = 3;
while (true) {
break;
x = 2;
}
console.log(x);
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
// JSLIR: "jsir.file"() <{comments = []}> ({
// JSLIR-NEXT: "jsir.program"() <{source_type = "script"}> ({
// JSLIR-NEXT: "jsir.variable_declaration"() <{kind = "var"}> ({
// JSLIR-NEXT: %11 = "jsir.identifier_ref"() <{name = "x"}> : () -> !jsir.any
// JSLIR-NEXT: %12 = "jsir.numeric_literal"() <{extra = #jsir<numeric_literal_extra "3", 3.000000e+00 : f64>, value = 3.000000e+00 : f64}> : () -> !jsir.any
// JSLIR-NEXT: %13 = "jsir.variable_declarator"(%11, %12) : (!jsir.any, !jsir.any) -> !jsir.any
// JSLIR-NEXT: "jsir.exprs_region_end"(%13) : (!jsir.any) -> ()
// JSLIR-NEXT: }) : () -> ()
// JSLIR-NEXT: %0 = "jslir.control_flow_starter"() <{kind = #jsir<cf_kind WhileStatement>}> : () -> !jsir.any
// JSLIR-NEXT: "cf.br"()[^bb1] : () -> ()
// JSLIR-NEXT: ^bb1: // 2 preds: ^bb0, ^bb3
// JSLIR-NEXT: "jslir.control_flow_marker"(%0) <{kind = #jsir<cf_marker WhileStatementTest>}> : (!jsir.any) -> ()
// JSLIR-NEXT: %1 = "jsir.boolean_literal"() <{value = true}> : () -> !jsir.any
// JSLIR-NEXT: %2 = "builtin.unrealized_conversion_cast"(%1) : (!jsir.any) -> i1
// JSLIR-NEXT: "cf.cond_br"(%2)[^bb2, ^bb4] <{operandSegmentSizes = array<i32: 1, 0, 0>}> : (i1) -> ()
// JSLIR-NEXT: ^bb2: // pred: ^bb1
// JSLIR-NEXT: "jslir.control_flow_marker"(%0) <{kind = #jsir<cf_marker WhileStatementBody>}> : (!jsir.any) -> ()
// JSLIR-NEXT: %3 = "jslir.control_flow_starter"() <{kind = #jsir<cf_kind BlockStatement>}> : () -> !jsir.any
// JSLIR-NEXT: "jslir.control_flow_marker"(%3) <{kind = #jsir<cf_marker BlockStatementDirectives>}> : (!jsir.any) -> ()
// JSLIR-NEXT: "jslir.control_flow_marker"(%3) <{kind = #jsir<cf_marker BlockStatementBody>}> : (!jsir.any) -> ()
// JSLIR-NEXT: "jslir.break_statement"() : () -> ()
// JSLIR-NEXT: "cf.br"()[^bb4] : () -> ()
// JSLIR-NEXT: ^bb3: // no predecessors
// JSLIR-NEXT: %4 = "jsir.identifier_ref"() <{name = "x"}> : () -> !jsir.any
// JSLIR-NEXT: %5 = "jsir.numeric_literal"() <{extra = #jsir<numeric_literal_extra "2", 2.000000e+00 : f64>, value = 2.000000e+00 : f64}> : () -> !jsir.any
// JSLIR-NEXT: %6 = "jsir.assignment_expression"(%4, %5) <{operator_ = "="}> : (!jsir.any, !jsir.any) -> !jsir.any
// JSLIR-NEXT: "jsir.expression_statement"(%6) : (!jsir.any) -> ()
// JSLIR-NEXT: "jslir.control_flow_marker"(%3) <{kind = #jsir<cf_marker BlockStatementEnd>}> : (!jsir.any) -> ()
// JSLIR-NEXT: "cf.br"()[^bb1] : () -> ()
// JSLIR-NEXT: ^bb4: // 2 preds: ^bb1, ^bb2
// JSLIR-NEXT: "jslir.control_flow_marker"(%0) <{kind = #jsir<cf_marker WhileStatementEnd>}> : (!jsir.any) -> ()
// JSLIR-NEXT: %7 = "jsir.identifier"() <{name = "console"}> : () -> !jsir.any
// JSLIR-NEXT: %8 = "jsir.member_expression"(%7) <{literal_property = #jsir<identifier <L 6 C 8>, <L 6 C 11>, "log", 54, 57, 0, "log">}> : (!jsir.any) -> !jsir.any
// JSLIR-NEXT: %9 = "jsir.identifier"() <{name = "x"}> : () -> !jsir.any
// JSLIR-NEXT: %10 = "jsir.call_expression"(%8, %9) : (!jsir.any, !jsir.any) -> !jsir.any
// JSLIR-NEXT: "jsir.expression_statement"(%10) : (!jsir.any) -> ()
// JSLIR-NEXT: }, {
// JSLIR-NEXT: ^bb0:
// JSLIR-NEXT: }) : () -> ()
// JSLIR-NEXT: }) : () -> ()
// JSLIR-NEXT: jsir.file {[]} ({
// JSLIR-NEXT: ^bb0:
// JSLIR-NEXT: // <executable>
// JSLIR-NEXT: // State [default = <unknown>] { }
// JSLIR-NEXT: jsir.program {"script"} ({
// JSLIR-NEXT: ^bb0:
// JSLIR-NEXT: // <executable>
// JSLIR-NEXT: // State [default = <unknown>] { }
// JSLIR-NEXT: jsir.variable_declaration {"var"} ({
// JSLIR-NEXT: ^bb0:
// JSLIR-NEXT: // <executable>
// JSLIR-NEXT: // State [default = <unknown>] { }
// JSLIR-NEXT: %11 = jsir.identifier_ref {"x"}
// JSLIR-NEXT: // %11 = <unknown>
// JSLIR-NEXT: // State [default = <unknown>] { }
// JSLIR-NEXT: %12 = jsir.numeric_literal {#jsir<numeric_literal_extra "3", 3.000000e+00 : f64>, 3.000000e+00 : f64}
// JSLIR-NEXT: // %12 = 3.000000e+00 : f64
// JSLIR-NEXT: // State [default = <unknown>] { }
// JSLIR-NEXT: %13 = jsir.variable_declarator (%11, %12)
// JSLIR-NEXT: // %13 = <uninitialized>
// JSLIR-NEXT: // State [default = <unknown>] { <x#0 : 3.000000e+00 : f64> }
// JSLIR-NEXT: jsir.exprs_region_end (%13)
// JSLIR-NEXT: // State [default = <unknown>] { <x#0 : 3.000000e+00 : f64> }
// JSLIR-NEXT: })
// JSLIR-NEXT: // State [default = <unknown>] { <x#0 : 3.000000e+00 : f64> }
// JSLIR-NEXT: %0 = jslir.control_flow_starter {#jsir<cf_kind WhileStatement>}
// JSLIR-NEXT: // %0 = <unknown>
// JSLIR-NEXT: // State [default = <unknown>] { <x#0 : 3.000000e+00 : f64> }
// JSLIR-NEXT: cf.br
// JSLIR-NEXT: // State [default = <unknown>] { <x#0 : 3.000000e+00 : f64> }
// JSLIR-NEXT: ^bb1:
// JSLIR-NEXT: // <executable>
// JSLIR-NEXT: // State [default = <unknown>] { <x#0 : 3.000000e+00 : f64> }
// JSLIR-NEXT: jslir.control_flow_marker (%0) {#jsir<cf_marker WhileStatementTest>}
// JSLIR-NEXT: // State [default = <unknown>] { <x#0 : 3.000000e+00 : f64> }
// JSLIR-NEXT: %1 = jsir.boolean_literal {true}
// JSLIR-NEXT: // %1 = true
// JSLIR-NEXT: // State [default = <unknown>] { <x#0 : 3.000000e+00 : f64> }
// JSLIR-NEXT: %2 = builtin.unrealized_conversion_cast (%1)
// JSLIR-NEXT: // %2 = true
// JSLIR-NEXT: // State [default = <unknown>] { <x#0 : 3.000000e+00 : f64> }
// JSLIR-NEXT: cf.cond_br (%2) {array<i32: 1, 0, 0>}
// JSLIR-NEXT: // State [default = <unknown>] { <x#0 : 3.000000e+00 : f64> }
// JSLIR-NEXT: ^bb2:
// JSLIR-NEXT: // <executable>
// JSLIR-NEXT: // State [default = <unknown>] { <x#0 : 3.000000e+00 : f64> }
// JSLIR-NEXT: jslir.control_flow_marker (%0) {#jsir<cf_marker WhileStatementBody>}
// JSLIR-NEXT: // State [default = <unknown>] { <x#0 : 3.000000e+00 : f64> }
// JSLIR-NEXT: %3 = jslir.control_flow_starter {#jsir<cf_kind BlockStatement>}
// JSLIR-NEXT: // %3 = <unknown>
// JSLIR-NEXT: // State [default = <unknown>] { <x#0 : 3.000000e+00 : f64> }
// JSLIR-NEXT: jslir.control_flow_marker (%3) {#jsir<cf_marker BlockStatementDirectives>}
// JSLIR-NEXT: // State [default = <unknown>] { <x#0 : 3.000000e+00 : f64> }
// JSLIR-NEXT: jslir.control_flow_marker (%3) {#jsir<cf_marker BlockStatementBody>}
// JSLIR-NEXT: // State [default = <unknown>] { <x#0 : 3.000000e+00 : f64> }
// JSLIR-NEXT: jslir.break_statement
// JSLIR-NEXT: // State [default = <unknown>] { <x#0 : 3.000000e+00 : f64> }
// JSLIR-NEXT: cf.br
// JSLIR-NEXT: // State [default = <unknown>] { <x#0 : 3.000000e+00 : f64> }
// JSLIR-NEXT: ^bb3:
// JSLIR-NEXT: // <not executable>
// JSLIR-NEXT: // State [default = <uninitialized>] { }
// JSLIR-NEXT: %4 = jsir.identifier_ref {"x"}
// JSLIR-NEXT: // %4 = <uninitialized>
// JSLIR-NEXT: // State [default = <uninitialized>] { }
// JSLIR-NEXT: %5 = jsir.numeric_literal {#jsir<numeric_literal_extra "2", 2.000000e+00 : f64>, 2.000000e+00 : f64}
// JSLIR-NEXT: // %5 = <uninitialized>
// JSLIR-NEXT: // State [default = <uninitialized>] { }
// JSLIR-NEXT: %6 = jsir.assignment_expression (%4, %5) {"="}
// JSLIR-NEXT: // %6 = <uninitialized>
// JSLIR-NEXT: // State [default = <uninitialized>] { }
// JSLIR-NEXT: jsir.expression_statement (%6)
// JSLIR-NEXT: // State [default = <uninitialized>] { }
// JSLIR-NEXT: jslir.control_flow_marker (%3) {#jsir<cf_marker BlockStatementEnd>}
// JSLIR-NEXT: // State [default = <uninitialized>] { }
// JSLIR-NEXT: cf.br
// JSLIR-NEXT: // State [default = <uninitialized>] { }
// JSLIR-NEXT: ^bb4:
// JSLIR-NEXT: // <executable>
// JSLIR-NEXT: // State [default = <unknown>] { <x#0 : 3.000000e+00 : f64> }
// JSLIR-NEXT: jslir.control_flow_marker (%0) {#jsir<cf_marker WhileStatementEnd>}
// JSLIR-NEXT: // State [default = <unknown>] { <x#0 : 3.000000e+00 : f64> }
// JSLIR-NEXT: %7 = jsir.identifier {"console"}
// JSLIR-NEXT: // %7 = <unknown>
// JSLIR-NEXT: // State [default = <unknown>] { <x#0 : 3.000000e+00 : f64> }
// JSLIR-NEXT: %8 = jsir.member_expression (%7) {#jsir<identifier <L 6 C 8>, <L 6 C 11>, "log", 54, 57, 0, "log">}
// JSLIR-NEXT: // %8 = <unknown>
// JSLIR-NEXT: // State [default = <unknown>] { <x#0 : 3.000000e+00 : f64> }
// JSLIR-NEXT: %9 = jsir.identifier {"x"}
// JSLIR-NEXT: // %9 = 3.000000e+00 : f64
// JSLIR-NEXT: // State [default = <unknown>] { <x#0 : 3.000000e+00 : f64> }
// JSLIR-NEXT: %10 = jsir.call_expression (%8, %9)
// JSLIR-NEXT: // %10 = <unknown>
// JSLIR-NEXT: // State [default = <unknown>] { <x#0 : 3.000000e+00 : f64> }
// JSLIR-NEXT: jsir.expression_statement (%10)
// JSLIR-NEXT: // State [default = <unknown>] { <x#0 : 3.000000e+00 : f64> }
// JSLIR-NEXT: }, {
// JSLIR-NEXT: ^bb0:
// JSLIR-NEXT: // <executable>
// JSLIR-NEXT: // State [default = <unknown>] { }
// JSLIR-NEXT: })
// JSLIR-NEXT: // State [default = <unknown>] { }
// JSLIR-NEXT: })
// JSLIR-NEXT: // State [default = <uninitialized>] { }
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// RUN: CURRENT_FILE_BASENAME=$(basename %s .lit) && \
// RUN: jsir_gen --input_file "$(dirname %s)"/input.js \
// RUN: --passes "source2ast,ast2hir,hir2lir" \
// RUN: --jsir_analysis constant_propagation \
// RUN: | FileCheck --check-prefix JSLIR "$(dirname %s)"/output.generated.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

load("//bazel:lit.bzl", "glob_lit_tests")

package(default_applicable_licenses = ["//:license"])

licenses(["notice"])

glob_lit_tests(
name = "all_tests",
data = [
"README.generated.md",
"input.js",
"output.generated.txt",
"//maldoca/js/ir:lit_test_files",
],
test_file_exts = [
"lit",
],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
To run manually:

```shell
blaze run //third_party/maldoca/js/ir:jsir_gen -- \
--input_file $(pwd)/third_party/maldoca/js/ir/analyses/constant_propagation/tests/break_jshir/input.js \
--passes "source2ast,ast2hir" \
--jsir_analysis constant_propagation
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
var x = 3;
while (true) {
break;
x = 2;
}
console.log(x);
Loading