[llvm] 3c4fa5a - [MergeFunc] Add tests showing incorrect handling of metadata call args.

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 26 05:47:47 PST 2025


Author: Florian Hahn
Date: 2025-02-26T13:47:24Z
New Revision: 3c4fa5a20aff390959385bf959a8c0b87e81d36c

URL: https://github.com/llvm/llvm-project/commit/3c4fa5a20aff390959385bf959a8c0b87e81d36c
DIFF: https://github.com/llvm/llvm-project/commit/3c4fa5a20aff390959385bf959a8c0b87e81d36c.diff

LOG: [MergeFunc] Add tests showing incorrect handling of metadata call args.

Added: 
    llvm/test/Transforms/MergeFunc/metadata-call-arguments.ll

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/MergeFunc/metadata-call-arguments.ll b/llvm/test/Transforms/MergeFunc/metadata-call-arguments.ll
new file mode 100644
index 0000000000000..28263741f2cde
--- /dev/null
+++ b/llvm/test/Transforms/MergeFunc/metadata-call-arguments.ll
@@ -0,0 +1,102 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --include-generated-funcs --version 5
+; RUN: opt -p mergefunc -S %s | FileCheck %s
+
+; FIXME: Should not be merged with @call_mdtuple_arg_not_equal_2.
+define i64 @call_mdtuple_arg_not_equal_1() {
+  %r = call i64 @llvm.read_volatile_register.i64(metadata !0)
+  ret i64 %r
+}
+
+define i64 @call_mdtuple_arg_not_equal_2() {
+  %r = call i64 @llvm.read_volatile_register.i64(metadata !1)
+  ret i64 %r
+}
+
+define i64 @call_mdtuple_arg_with_cycle_equal_1() {
+  %r = call i64 @llvm.read_volatile_register.i64(metadata !2)
+  ret i64 %r
+}
+
+define i64 @call_mdtuple_arg_with_cycle_equal_2() {
+  %r = call i64 @llvm.read_volatile_register.i64(metadata !3)
+  ret i64 %r
+}
+
+; FIXME: Should not be merged with @call_mdtuple_arg_with_cycle_not_equal_2.
+define i64 @call_mdtuple_arg_with_cycle_not_equal_1() {
+  %r = call i64 @llvm.read_volatile_register.i64(metadata !3)
+  ret i64 %r
+}
+
+define i64 @call_mdtuple_arg_with_cycle_not_equal_2() {
+  %r = call i64 @llvm.read_volatile_register.i64(metadata !4)
+  ret i64 %r
+}
+
+define i64 @call_mdtuple_arg_equal_1() {
+  %r = call i64 @llvm.read_volatile_register.i64(metadata !5)
+  ret i64 %r
+}
+
+define i64 @call_mdtuple_arg_equal_2() {
+  %r = call i64 @llvm.read_volatile_register.i64(metadata !6)
+  ret i64 %r
+}
+
+declare i64 @llvm.read_volatile_register.i64(metadata)
+
+!0 = !{!"foo"}
+!1 = !{!"bar"}
+
+!2 = distinct !{!2, !"foo"}
+!3 = distinct !{!3, !"foo"}
+
+!4 = distinct !{!4, !"bar"}
+
+!5 = !{!"foo", i64 10}
+!6 = !{!"foo", i64 10}
+; CHECK-LABEL: define i64 @call_mdtuple_arg_with_cycle_equal_1() {
+; CHECK-NEXT:    [[R:%.*]] = call i64 @llvm.read_volatile_register.i64(metadata [[META0:![0-9]+]])
+; CHECK-NEXT:    ret i64 [[R]]
+;
+;
+; CHECK-LABEL: define i64 @call_mdtuple_arg_with_cycle_equal_2() {
+; CHECK-NEXT:    [[R:%.*]] = call i64 @llvm.read_volatile_register.i64(metadata [[META1:![0-9]+]])
+; CHECK-NEXT:    ret i64 [[R]]
+;
+;
+; CHECK-LABEL: define i64 @call_mdtuple_arg_with_cycle_not_equal_1() {
+; CHECK-NEXT:    [[R:%.*]] = call i64 @llvm.read_volatile_register.i64(metadata [[META1]])
+; CHECK-NEXT:    ret i64 [[R]]
+;
+;
+; CHECK-LABEL: define i64 @call_mdtuple_arg_with_cycle_not_equal_2() {
+; CHECK-NEXT:    [[R:%.*]] = call i64 @llvm.read_volatile_register.i64(metadata [[META2:![0-9]+]])
+; CHECK-NEXT:    ret i64 [[R]]
+;
+;
+; CHECK-LABEL: define i64 @call_mdtuple_arg_equal_1() {
+; CHECK-NEXT:    [[R:%.*]] = call i64 @llvm.read_volatile_register.i64(metadata [[META3:![0-9]+]])
+; CHECK-NEXT:    ret i64 [[R]]
+;
+;
+; CHECK-LABEL: define i64 @call_mdtuple_arg_not_equal_2() {
+; CHECK-NEXT:    [[TMP1:%.*]] = tail call i64 @call_mdtuple_arg_equal_1()
+; CHECK-NEXT:    ret i64 [[TMP1]]
+;
+;
+; CHECK-LABEL: define i64 @call_mdtuple_arg_not_equal_1() {
+; CHECK-NEXT:    [[TMP1:%.*]] = tail call i64 @call_mdtuple_arg_equal_1()
+; CHECK-NEXT:    ret i64 [[TMP1]]
+;
+;
+; CHECK-LABEL: define i64 @call_mdtuple_arg_equal_2() {
+; CHECK-NEXT:    [[TMP1:%.*]] = tail call i64 @call_mdtuple_arg_equal_1()
+; CHECK-NEXT:    ret i64 [[TMP1]]
+;
+;.
+; CHECK: [[META0]] = distinct !{[[META0]], !"foo"}
+; CHECK: [[META1]] = distinct !{[[META1]], !"foo"}
+; CHECK: [[META2]] = distinct !{[[META2]], !"bar"}
+; CHECK: [[META3]] = !{!"foo", i64 10}
+;.


        


More information about the llvm-commits mailing list