From 3a4fbb897f788a05024342dded7cd53b21f5c713 Mon Sep 17 00:00:00 2001 From: Daniel Hoekwater Date: Thu, 14 Nov 2024 14:43:20 -0800 Subject: [PATCH] Add testdata for a function with a simple loop PiperOrigin-RevId: 696656413 --- propeller/testdata/BUILD | 2 + .../simple_conditionals_join.protobuf | 93 ++++++++++++++++++ propeller/testdata/simple_loop.protobuf | 94 +++++++++++++++++++ 3 files changed, 189 insertions(+) create mode 100644 propeller/testdata/simple_conditionals_join.protobuf create mode 100644 propeller/testdata/simple_loop.protobuf diff --git a/propeller/testdata/BUILD b/propeller/testdata/BUILD index 3c4377419ad..1f188831b5c 100644 --- a/propeller/testdata/BUILD +++ b/propeller/testdata/BUILD @@ -46,6 +46,8 @@ exports_files([ "sample.bin", "sample.c", "sample_section.bin", + "simple_conditionals_join.protobuf", + "simple_loop.protobuf", "test_comdat.h", "test_comdat_1.cc", "test_comdat_2.cc", diff --git a/propeller/testdata/simple_conditionals_join.protobuf b/propeller/testdata/simple_conditionals_join.protobuf new file mode 100644 index 00000000000..350018c55c1 --- /dev/null +++ b/propeller/testdata/simple_conditionals_join.protobuf @@ -0,0 +1,93 @@ +## CFG consisting of a function with two conditionals which eventually join on +## a single return basic block. In addition, size of foo.2 is zero. +## +## foo +## | \ +## | \110 +## | \ +## | v +## 150| foo.1 +## | / \ +## | /100 \10 +## | / \ +## v v v +## foo.2 foo.3 +## \ / +## \ / +## 250 \ /10 +## \ / +## v v +## foo.4 + +cfg { + name: "foo" + function_index: 10 + node { + bb_id: 0 + size: 10 + out_edges { + sink { + function_index: 10 + bb_index: 1 + } + weight: 110 + kind: BRANCH_OR_FALLTHROUGH + } + out_edges { + sink { + function_index: 10 + bb_index: 2 + } + weight: 150 + kind: BRANCH_OR_FALLTHROUGH + } + } + node { + bb_id: 1 + size: 4 + out_edges { + sink { + function_index: 10 + bb_index: 2 + } + weight: 100 + kind: BRANCH_OR_FALLTHROUGH + } + out_edges { + sink { + function_index: 10 + bb_index: 3 + } + weight: 10 + kind: BRANCH_OR_FALLTHROUGH + } + } + node { + bb_id: 2 + size: 0 + out_edges { + sink { + function_index: 10 + bb_index: 4 + } + weight: 250 + kind: BRANCH_OR_FALLTHROUGH + } + } + node { + bb_id: 3 + size: 2 + out_edges { + sink { + function_index: 10 + bb_index: 4 + } + weight: 10 + kind: BRANCH_OR_FALLTHROUGH + } + } + node { + bb_id: 4 + size: 2 + } +} diff --git a/propeller/testdata/simple_loop.protobuf b/propeller/testdata/simple_loop.protobuf new file mode 100644 index 00000000000..a1b4edc447d --- /dev/null +++ b/propeller/testdata/simple_loop.protobuf @@ -0,0 +1,94 @@ +## CFG Proto for a function consisting of a conditional and a loop on one side +## of the conditional. +## +## foo +## | +## |5 +## V +## a.BB.foo <--+ +## / \ | +## 0/ \95 |90 +## / \ | +## v \ | +## aa.BB.foo v | +## \ aaa.BB.foo +## \ / +## \ / +## 0\ /10 +## \ / +## v v +## raaa.BB.foo + +cfg { + name: "foo" + name: "foo.alias" + function_index: 0 + node { + bb_id: 0 + size: 10 + out_edges { + sink: { + function_index: 0 + bb_index: 1 + } + weight: 5 + kind: BRANCH_OR_FALLTHROUGH + } + } + node { + bb_id: 1 + size: 6 + out_edges { + sink: { + function_index: 0 + bb_index: 2 + } + weight: 0 + kind: BRANCH_OR_FALLTHROUGH + } + out_edges { + sink: { + function_index: 0 + bb_index: 3 + } + weight: 95 + kind: BRANCH_OR_FALLTHROUGH + } + } + node { + bb_id: 2 + size: 4 + out_edges { + sink: { + function_index: 0 + bb_index: 4 + } + weight: 0 + kind: BRANCH_OR_FALLTHROUGH + } + } + node { + bb_id: 3 + size: 4 + out_edges { + sink: { + function_index: 0 + bb_index: 1 + } + weight: 90 + kind: BRANCH_OR_FALLTHROUGH + } + out_edges { + sink: { + function_index: 0 + bb_index: 4 + } + weight: 10 + kind: BRANCH_OR_FALLTHROUGH + } + } + node { + bb_id: 4 + size: 6 + } +}