From a8b2fed0aef99be3efd11f8eec26df5a7d42fde2 Mon Sep 17 00:00:00 2001 From: Johannes Doerfert Date: Wed, 1 Apr 2020 21:54:46 -0500 Subject: [PATCH] [Utils][FIX] Properly deal with occasionally deleted functions While D68850 allowed functions to be deleted I accidentally saved some version of the function to be used once a suitable prefix was found. This turned out to be problematic when the occasionally deleted function is also occasionally modified. The test case is adjusted to resemble the case in which the problem was found. Reviewed By: lebedev.ri Differential Revision: https://reviews.llvm.org/D76586 --- .../Inputs/sometimes_deleted_function.ll | 10 +++++++--- .../Inputs/sometimes_deleted_function.ll.expected | 18 +++++++++++++----- llvm/utils/UpdateTestChecks/common.py | 13 ++++--------- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/sometimes_deleted_function.ll b/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/sometimes_deleted_function.ll index 6b82c49..adb1ec9 100644 --- a/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/sometimes_deleted_function.ll +++ b/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/sometimes_deleted_function.ll @@ -1,9 +1,13 @@ -; RUN: opt -S < %s | FileCheck %s --check-prefixes=ALL,FIRST -; RUN: opt -S -globalopt < %s | FileCheck %s --check-prefixes=ALL,SECOND +; RUN: opt -S < %s | FileCheck %s --check-prefixes=ALL,ALL_BUT_TWO,ALL_BUT_THREE,ALL_BUT_FOUR,ONE_AND_TWO,ONE_AND_THREE,ONE_AND_FOUR,ONE +; RUN: opt -S -globalopt < %s | FileCheck %s --check-prefixes=ALL,ALL_BUT_ONE,ALL_BUT_THREE,ALL_BUT_FOUR,ONE_AND_TWO,TWO_AND_THREE,TWO_AND_FOUR,TWO +; RUN: opt -S -instsimplify < %s | FileCheck %s --check-prefixes=ALL,ALL_BUT_ONE,ALL_BUT_TWO,ALL_BUT_FOUR,ONE_AND_THREE,TWO_AND_THREE,THREE_AND_FOUR,THREE +; RUN: opt -S < %s | FileCheck %s --check-prefixes=ALL,ALL_BUT_ONE,ALL_BUT_TWO,ALL_BUT_THREE,ONE_AND_FOUR,TWO_AND_FOUR,THREE_AND_FOUR,FOUR ; -; Make sure we use FIRST to check for @sometimes_here as ALL does not work. +; Make sure we don't use anything to check for @sometimes_here that contains "ALL" or "TWO". +; Also verify we use "ONE_AND_FOUR" for the unmodified @sometimes_here version and "THREE" for the version without the add. define internal void @sometimes_here() { + %c = add i32 undef, undef ret void } diff --git a/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/sometimes_deleted_function.ll.expected b/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/sometimes_deleted_function.ll.expected index f937425..c42845f 100644 --- a/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/sometimes_deleted_function.ll.expected +++ b/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/sometimes_deleted_function.ll.expected @@ -1,13 +1,21 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py -; RUN: opt -S < %s | FileCheck %s --check-prefixes=ALL,FIRST -; RUN: opt -S -globalopt < %s | FileCheck %s --check-prefixes=ALL,SECOND +; RUN: opt -S < %s | FileCheck %s --check-prefixes=ALL,ALL_BUT_TWO,ALL_BUT_THREE,ALL_BUT_FOUR,ONE_AND_TWO,ONE_AND_THREE,ONE_AND_FOUR,ONE +; RUN: opt -S -globalopt < %s | FileCheck %s --check-prefixes=ALL,ALL_BUT_ONE,ALL_BUT_THREE,ALL_BUT_FOUR,ONE_AND_TWO,TWO_AND_THREE,TWO_AND_FOUR,TWO +; RUN: opt -S -instsimplify < %s | FileCheck %s --check-prefixes=ALL,ALL_BUT_ONE,ALL_BUT_TWO,ALL_BUT_FOUR,ONE_AND_THREE,TWO_AND_THREE,THREE_AND_FOUR,THREE +; RUN: opt -S < %s | FileCheck %s --check-prefixes=ALL,ALL_BUT_ONE,ALL_BUT_TWO,ALL_BUT_THREE,ONE_AND_FOUR,TWO_AND_FOUR,THREE_AND_FOUR,FOUR ; -; Make sure we use FIRST to check for @sometimes_here as ALL does not work. +; Make sure we don't use anything to check for @sometimes_here that contains "ALL" or "TWO". +; Also verify we use "ONE_AND_FOUR" for the unmodified @sometimes_here version and "THREE" for the version without the add. define internal void @sometimes_here() { -; FIRST-LABEL: @sometimes_here( -; FIRST-NEXT: ret void +; ONE_AND_FOUR-LABEL: @sometimes_here( +; ONE_AND_FOUR-NEXT: [[C:%.*]] = add i32 undef, undef +; ONE_AND_FOUR-NEXT: ret void ; +; THREE-LABEL: @sometimes_here( +; THREE-NEXT: ret void +; + %c = add i32 undef, undef ret void } diff --git a/llvm/utils/UpdateTestChecks/common.py b/llvm/utils/UpdateTestChecks/common.py index 3186628..e35f4b1 100644 --- a/llvm/utils/UpdateTestChecks/common.py +++ b/llvm/utils/UpdateTestChecks/common.py @@ -283,22 +283,17 @@ def add_checks(output_lines, comment_marker, prefix_list, func_dict, func_name, # prefix_blacklist is constructed, we can now emit the output for p in prefix_list: checkprefixes = p[0] - saved_output = None for checkprefix in checkprefixes: if checkprefix in printed_prefixes: break - # prefix is blacklisted. We remember the output as we might need it later but we will not emit anything for the prefix. + # Check if the prefix is blacklisted. if checkprefix in prefix_blacklist: - if not saved_output and func_name in func_dict[checkprefix]: - saved_output = func_dict[checkprefix][func_name] - continue + continue - # If we do not have output for this prefix but there is one saved, we go ahead with this prefix and the saved output. + # If we do not have output for this prefix we skip it. if not func_dict[checkprefix][func_name]: - if not saved_output: - continue - func_dict[checkprefix][func_name] = saved_output + continue # Add some space between different check prefixes, but not after the last # check line (before the test code). -- 2.7.4