Skip to content

Commit

Permalink
[utils] change default nameless value to "TMP"
Browse files Browse the repository at this point in the history
This is effectively reverting rGbfdc2552664d to avoid test churn
while we figure out a better way forward.

We at least salvage the warning on name conflict from that patch
though.

If we change the default string again, we may want to mass update
tests at the same time. Alternatively, we could live with the poor
naming if we change -instnamer.

This also adds a test to LLVM as suggested in the post-commit
review. There's a clang test that is also affected. That seems
like a layering violation, but I have not looked at fixing that yet.

Differential Revision: https://reviews.llvm.org/D80584
  • Loading branch information
rotateright committed Jun 1, 2020
1 parent 7bcde99 commit e5b8772
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
// CHECK-NEXT: [[B_ADDR:%.*]] = alloca i32, align 4
// CHECK-NEXT: store i64 [[A:%.*]], i64* [[A_ADDR]], align 8
// CHECK-NEXT: store i32 [[B:%.*]], i32* [[B_ADDR]], align 4
// CHECK-NEXT: [[NAMELESS0:%.*]] = load i64, i64* [[A_ADDR]], align 8
// CHECK-NEXT: [[NAMELESS1:%.*]] = load i32, i32* [[B_ADDR]], align 4
// CHECK-NEXT: [[CONV:%.*]] = sext i32 [[NAMELESS1]] to i64
// CHECK-NEXT: [[ADD:%.*]] = add nsw i64 [[NAMELESS0]], [[CONV]]
// CHECK-NEXT: [[TMP0:%.*]] = load i64, i64* [[A_ADDR]], align 8
// CHECK-NEXT: [[TMP1:%.*]] = load i32, i32* [[B_ADDR]], align 4
// CHECK-NEXT: [[CONV:%.*]] = sext i32 [[TMP1]] to i64
// CHECK-NEXT: [[ADD:%.*]] = add nsw i64 [[TMP0]], [[CONV]]
// CHECK-NEXT: ret i64 [[ADD]]
//
long test(long a, int b) {
Expand All @@ -27,12 +27,12 @@ long test(long a, int b) {
// CHECK-NEXT: store i64 [[A:%.*]], i64* [[A_ADDR]], align 8
// CHECK-NEXT: store i32 [[B:%.*]], i32* [[B_ADDR]], align 4
// CHECK-NEXT: store i32 [[C:%.*]], i32* [[C_ADDR]], align 4
// CHECK-NEXT: [[NAMELESS0:%.*]] = load i64, i64* [[A_ADDR]], align 8
// CHECK-NEXT: [[NAMELESS1:%.*]] = load i32, i32* [[B_ADDR]], align 4
// CHECK-NEXT: [[CONV:%.*]] = sext i32 [[NAMELESS1]] to i64
// CHECK-NEXT: [[ADD:%.*]] = add nsw i64 [[NAMELESS0]], [[CONV]]
// CHECK-NEXT: [[NAMELESS2:%.*]] = load i32, i32* [[C_ADDR]], align 4
// CHECK-NEXT: [[CONV1:%.*]] = sext i32 [[NAMELESS2]] to i64
// CHECK-NEXT: [[TMP0:%.*]] = load i64, i64* [[A_ADDR]], align 8
// CHECK-NEXT: [[TMP1:%.*]] = load i32, i32* [[B_ADDR]], align 4
// CHECK-NEXT: [[CONV:%.*]] = sext i32 [[TMP1]] to i64
// CHECK-NEXT: [[ADD:%.*]] = add nsw i64 [[TMP0]], [[CONV]]
// CHECK-NEXT: [[TMP2:%.*]] = load i32, i32* [[C_ADDR]], align 4
// CHECK-NEXT: [[CONV1:%.*]] = sext i32 [[TMP2]] to i64
// CHECK-NEXT: [[ADD2:%.*]] = add nsw i64 [[ADD]], [[CONV1]]
// CHECK-NEXT: ret i64 [[ADD2]]
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
// CHECK-NEXT: [[B_ADDR:%.*]] = alloca i32, align 4
// CHECK-NEXT: store i64 [[A]], i64* [[A_ADDR]], align 8
// CHECK-NEXT: store i32 [[B]], i32* [[B_ADDR]], align 4
// CHECK-NEXT: [[NAMELESS0:%.*]] = load i64, i64* [[A_ADDR]], align 8
// CHECK-NEXT: [[NAMELESS1:%.*]] = load i32, i32* [[B_ADDR]], align 4
// CHECK-NEXT: [[CONV:%.*]] = sext i32 [[NAMELESS1]] to i64
// CHECK-NEXT: [[ADD:%.*]] = add nsw i64 [[NAMELESS0]], [[CONV]]
// CHECK-NEXT: [[TMP0:%.*]] = load i64, i64* [[A_ADDR]], align 8
// CHECK-NEXT: [[TMP1:%.*]] = load i32, i32* [[B_ADDR]], align 4
// CHECK-NEXT: [[CONV:%.*]] = sext i32 [[TMP1]] to i64
// CHECK-NEXT: [[ADD:%.*]] = add nsw i64 [[TMP0]], [[CONV]]
// CHECK-NEXT: ret i64 [[ADD]]
//
long test(long a, int b) {
Expand All @@ -29,12 +29,12 @@ long test(long a, int b) {
// CHECK-NEXT: store i64 [[A]], i64* [[A_ADDR]], align 8
// CHECK-NEXT: store i32 [[B]], i32* [[B_ADDR]], align 4
// CHECK-NEXT: store i32 [[C]], i32* [[C_ADDR]], align 4
// CHECK-NEXT: [[NAMELESS0:%.*]] = load i64, i64* [[A_ADDR]], align 8
// CHECK-NEXT: [[NAMELESS1:%.*]] = load i32, i32* [[B_ADDR]], align 4
// CHECK-NEXT: [[CONV:%.*]] = sext i32 [[NAMELESS1]] to i64
// CHECK-NEXT: [[ADD:%.*]] = add nsw i64 [[NAMELESS0]], [[CONV]]
// CHECK-NEXT: [[NAMELESS2:%.*]] = load i32, i32* [[C_ADDR]], align 4
// CHECK-NEXT: [[CONV1:%.*]] = sext i32 [[NAMELESS2]] to i64
// CHECK-NEXT: [[TMP0:%.*]] = load i64, i64* [[A_ADDR]], align 8
// CHECK-NEXT: [[TMP1:%.*]] = load i32, i32* [[B_ADDR]], align 4
// CHECK-NEXT: [[CONV:%.*]] = sext i32 [[TMP1]] to i64
// CHECK-NEXT: [[ADD:%.*]] = add nsw i64 [[TMP0]], [[CONV]]
// CHECK-NEXT: [[TMP2:%.*]] = load i32, i32* [[C_ADDR]], align 4
// CHECK-NEXT: [[CONV1:%.*]] = sext i32 [[TMP2]] to i64
// CHECK-NEXT: [[ADD2:%.*]] = add nsw i64 [[ADD]], [[CONV1]]
// CHECK-NEXT: ret i64 [[ADD2]]
//
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
; Example input for update_llc_test_checks (taken from test/Transforms/InstSimplify/add.ll)
; Example input for update_test_checks (taken from test/Transforms/InstSimplify/add.ll)
; RUN: opt < %s -instsimplify -S | FileCheck %s

define i32 @common_sub_operand(i32 %X, i32 %Y) {
Expand Down Expand Up @@ -47,3 +47,12 @@ define <2 x i8> @knownnegation_commute_vec(<2 x i8> %x, <2 x i8> %y) {
%r = add <2 x i8> %yx, %xy
ret <2 x i8> %r
}

define i32 @nameless_value(i32 %X) {
; CHECK-LABEL: @nameless_value(
; CHECK-NEXT: [[TMP1:%.*]] = sub i32 42, [[X:%.*]]
; CHECK-NEXT: ret i32 [[TMP1]]
;
%1 = sub i32 42, %X
ret i32 %1
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; Example input for update_llc_test_checks (taken from test/Transforms/InstSimplify/add.ll)
; Example input for update_test_checks (taken from test/Transforms/InstSimplify/add.ll)
; RUN: opt < %s -instsimplify -S | FileCheck %s

define i32 @common_sub_operand(i32 %X, i32 %Y) {
Expand Down Expand Up @@ -48,3 +48,12 @@ define <2 x i8> @knownnegation_commute_vec(<2 x i8> %x, <2 x i8> %y) {
%r = add <2 x i8> %yx, %xy
ret <2 x i8> %r
}

define i32 @nameless_value(i32 %X) {
; CHECK-LABEL: @nameless_value(
; CHECK-NEXT: [[TMP1:%.*]] = sub i32 42, [[X:%.*]]
; CHECK-NEXT: ret i32 [[TMP1]]
;
%1 = sub i32 42, %X
ret i32 %1
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature
; Example input for update_llc_test_checks (taken from test/Transforms/InstSimplify/add.ll)
; Example input for update_test_checks (taken from test/Transforms/InstSimplify/add.ll)
; RUN: opt < %s -instsimplify -S | FileCheck %s

define i32 @common_sub_operand(i32 %X, i32 %Y) {
Expand Down Expand Up @@ -53,3 +53,13 @@ define <2 x i8> @knownnegation_commute_vec(<2 x i8> %x, <2 x i8> %y) {
%r = add <2 x i8> %yx, %xy
ret <2 x i8> %r
}

define i32 @nameless_value(i32 %X) {
; CHECK-LABEL: define {{[^@]+}}@nameless_value
; CHECK-SAME: (i32 [[X:%.*]])
; CHECK-NEXT: [[TMP1:%.*]] = sub i32 42, [[X]]
; CHECK-NEXT: ret i32 [[TMP1]]
;
%1 = sub i32 42, %X
ret i32 %1
}
2 changes: 1 addition & 1 deletion llvm/utils/UpdateTestChecks/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def build_function_body_dictionary(function_re, scrubber, scrubber_args, raw_too
# spaces, commas, paren, or end of the string
IR_VALUE_RE = re.compile(r'(\s+)%([\w.-]+?)([,\s\(\)]|\Z)')

NAMELESS_PREFIX = "NAMELESS"
NAMELESS_PREFIX = "TMP"

# Create a FileCheck variable name based on an IR name.
def get_value_name(var):
Expand Down

0 comments on commit e5b8772

Please sign in to comment.