Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Test Check duplicates global check lines. #63746

Closed
jdoerfert opened this issue Jul 7, 2023 · 1 comment
Closed

Update Test Check duplicates global check lines. #63746

jdoerfert opened this issue Jul 7, 2023 · 1 comment
Assignees
Labels
llvm-tools All llvm tools that do not have corresponding tag

Comments

@jdoerfert
Copy link
Member

Since https://reviews.llvm.org/D148216 global check lines are not cleared properly:

cat test.ll
-----------                                                                                                                                                                             
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals --version 2
; RUN: opt -S < %s | FileCheck %s

@G = constant i32 42

;.
; CHECK: @G = constant i32 42
;.
define ptr @foo() {
; CHECK-LABEL: define ptr @foo() {
; CHECK-NEXT:    ret ptr @G
;
  ret ptr @G
}

./llvm/utils/update_test_checks.py --check-globals=all test.ll

cat test.ll
-----------                                                                                                                                                                             
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals --version 2
; RUN: opt -S < %s | FileCheck %s

@G = constant i32 42

; CHECK: @G = constant i32 42
;.
; CHECK: @G = constant i32 42
;.
define ptr @foo() {
; CHECK-LABEL: define ptr @foo() {
; CHECK-NEXT:    ret ptr @G
;
  ret ptr @G
}

./llvm/utils/update_test_checks.py --check-globals=all test.ll

cat test.ll
-----------                                                                                                                                                                             
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals --version 2
; RUN: opt -S < %s | FileCheck %s

@G = constant i32 42

; CHECK: @G = constant i32 42
; CHECK: @G = constant i32 42
;.
; CHECK: @G = constant i32 42
;.
define ptr @foo() {
; CHECK-LABEL: define ptr @foo() {
; CHECK-NEXT:    ret ptr @G
;
  ret ptr @G
}
@EugeneZelenko EugeneZelenko added llvm-tools All llvm tools that do not have corresponding tag and removed new issue labels Jul 7, 2023
@jdoerfert
Copy link
Member Author

This also groups unnamed and named globals, which does not work without -DAG:

; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals
; RUN: opt -S %s | FileCheck %s

@0 = private unnamed_addr constant i32 0
@named1 = weak constant i8 1
@1 = private unnamed_addr constant i32 2
@named2 = weak constant i8 3

declare void @use(ptr)
define void @test() {
  call void @use(ptr @0)
  call void @use(ptr @named1)
  call void @use(ptr @1)
  call void @use(ptr @named2)
  ret void
}

results in

; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals
; RUN: opt -S %s | FileCheck %s

@0 = private unnamed_addr constant i32 0
@named1 = weak constant i8 1
@1 = private unnamed_addr constant i32 2
@named2 = weak constant i8 3

declare void @use(ptr)
;.
; CHECK: @[[GLOB0:[0-9]+]] = private unnamed_addr constant i32 0
; CHECK: @[[GLOB1:[0-9]+]] = private unnamed_addr constant i32 2
;.
; CHECK: @named1 = weak constant i8 1
; CHECK: @named2 = weak constant i8 3
;.
define void @test() {
; CHECK-LABEL: @test(
; CHECK-NEXT:    call void @use(ptr @[[GLOB0]])
; CHECK-NEXT:    call void @use(ptr @named1)
; CHECK-NEXT:    call void @use(ptr @[[GLOB1]])
; CHECK-NEXT:    call void @use(ptr @named2)
; CHECK-NEXT:    ret void
;
  call void @use(ptr @0)
  call void @use(ptr @named1)
  call void @use(ptr @1)
  call void @use(ptr @named2)
  ret void
}

which cannot be verified (due to the order).

jdoerfert added a commit that referenced this issue Jul 14, 2023
This reverts commit 68f5d1b as it is
built on top of https://reviews.llvm.org/D148216 which is broken.

See also #63746
jdoerfert added a commit that referenced this issue Jul 14, 2023
This reverts commit 4488ee2, as it is
built on top of https://reviews.llvm.org/D148216 which is broken.

See also #63746
jdoerfert added a commit that referenced this issue Jul 14, 2023
This reverts commit 6d64faf, as it is
built on top of https://reviews.llvm.org/D148216 which is broken.

See also #63746
jdoerfert added a commit that referenced this issue Jul 14, 2023
Three tests needed manual adjustment after
https://reviews.llvm.org/D148216 got reverted. See
#63746.
hnrklssn added a commit that referenced this issue Nov 13, 2023
Recommits the changes from https://reviews.llvm.org/D148216.
Explicitly named globals are now matched literally, instead of emitting
a capture group for the name. This resolves #70047.
Metadata and annotations, on the other hand, are captured and matched
against by default, since their identifiers are not stable.

The reasons for revert (#63746) have been fixed:
The first issue, that of duplicated checkers, has already been resolved
in #70050.
This PR resolves the second issue listed in #63746, regarding the order
of named and unnamed globals. This is fixed by recording the index of
substrings containing global values, and sorting the checks according to
that index before emitting them. This results in global value checks
being emitted in the order they were seen instead of being grouped
separately.
zahiraam pushed a commit to zahiraam/llvm-project that referenced this issue Nov 20, 2023
Recommits the changes from https://reviews.llvm.org/D148216.
Explicitly named globals are now matched literally, instead of emitting
a capture group for the name. This resolves llvm#70047.
Metadata and annotations, on the other hand, are captured and matched
against by default, since their identifiers are not stable.

The reasons for revert (llvm#63746) have been fixed:
The first issue, that of duplicated checkers, has already been resolved
in llvm#70050.
This PR resolves the second issue listed in llvm#63746, regarding the order
of named and unnamed globals. This is fixed by recording the index of
substrings containing global values, and sorting the checks according to
that index before emitting them. This results in global value checks
being emitted in the order they were seen instead of being grouped
separately.
veselypeta pushed a commit to veselypeta/cherillvm that referenced this issue Sep 6, 2024
veselypeta pushed a commit to veselypeta/cherillvm that referenced this issue Sep 6, 2024
This reverts commit 4488ee2, as it is
built on top of https://reviews.llvm.org/D148216 which is broken.

See also llvm/llvm-project#63746
veselypeta pushed a commit to veselypeta/cherillvm that referenced this issue Sep 6, 2024
This reverts commit 6d64faf, as it is
built on top of https://reviews.llvm.org/D148216 which is broken.

See also llvm/llvm-project#63746
veselypeta pushed a commit to veselypeta/cherillvm that referenced this issue Sep 6, 2024
veselypeta pushed a commit to veselypeta/cherillvm that referenced this issue Sep 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
llvm-tools All llvm tools that do not have corresponding tag
Projects
None yet
Development

No branches or pull requests

3 participants