From b25512fed960c90079692e3252da32b165a21ce8 Mon Sep 17 00:00:00 2001 From: Chris Cummins Date: Tue, 27 Apr 2021 12:54:25 +0100 Subject: [PATCH] [datasets] Fix llvm-stress test. Issue #45. --- tests/llvm/datasets/llvm_stress_test.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/tests/llvm/datasets/llvm_stress_test.py b/tests/llvm/datasets/llvm_stress_test.py index 30c3454cbc..31746d6f52 100644 --- a/tests/llvm/datasets/llvm_stress_test.py +++ b/tests/llvm/datasets/llvm_stress_test.py @@ -9,6 +9,7 @@ import pytest import compiler_gym.envs.llvm # noqa register environments +from compiler_gym.datasets import BenchmarkInitError from compiler_gym.envs.llvm import LlvmEnv from compiler_gym.envs.llvm.datasets import LlvmStressDataset from tests.pytest_plugins.common import skip_on_ci @@ -36,12 +37,25 @@ def test_llvm_stress_size(llvm_stress_dataset: LlvmStressDataset): def test_llvm_stress_random_select( env: LlvmEnv, llvm_stress_dataset: LlvmStressDataset, index: int ): + env.observation_space = "InstCountDict" + uri = next(islice(llvm_stress_dataset.benchmark_uris(), index, None)) benchmark = llvm_stress_dataset.benchmark(uri) - env.observation_space = "InstCountDict" - instcount = env.reset(benchmark=benchmark) - print(env.ir) # For debugging in case of error. - assert instcount["TotalInstsCount"] > 0 + + # As of the current version (LLVM 10.0.0), programs generated with the + # following seeds emit an error when compiled: "Cannot emit physreg copy + # instruction". + FAILING_SEEDS = {173, 239} + + if index in FAILING_SEEDS: + with pytest.raises( + BenchmarkInitError, match="Cannot emit physreg copy instruction" + ): + env.reset(benchmark=benchmark) + else: + instcount = env.reset(benchmark=benchmark) + print(env.ir) # For debugging in case of error. + assert instcount["TotalInstsCount"] > 0 if __name__ == "__main__":