Skip to content

Add regression tests from ConstantData uselist removal #138960

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

Merged

Conversation

arsenm
Copy link
Contributor

@arsenm arsenm commented May 7, 2025

Add some examples of failures after 87f312a

@llvmbot
Copy link
Member

llvmbot commented May 7, 2025

@llvm/pr-subscribers-llvm-transforms
@llvm/pr-subscribers-backend-x86

@llvm/pr-subscribers-llvm-ir

Author: Matt Arsenault (arsenm)

Changes

Add some examples of failures after 87f312a


Full diff: https://github.com/llvm/llvm-project/pull/138960.diff

2 Files Affected:

  • (added) llvm/test/CodeGen/X86/codegen-no-uselist-constantdata.ll (+52)
  • (added) llvm/test/Transforms/CorrelatedValuePropagation/no-uselist-constantdata-regression.ll (+30)
diff --git a/llvm/test/CodeGen/X86/codegen-no-uselist-constantdata.ll b/llvm/test/CodeGen/X86/codegen-no-uselist-constantdata.ll
new file mode 100644
index 0000000000000..fef2c18b30a82
--- /dev/null
+++ b/llvm/test/CodeGen/X86/codegen-no-uselist-constantdata.ll
@@ -0,0 +1,52 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
+; RUN: llc -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck %s
+
+; Make sure codegen doesn't try to inspect the use list of constants
+
+; Make sure we do not try to make use of the uselist of a constant
+; null when looking for the alignment of the pointer.
+define <2 x i32> @no_uselist_null_isDereferenceableAndAlignedPointer(i1 %arg0, ptr align(4) %arg) {
+; CHECK-LABEL: no_uselist_null_isDereferenceableAndAlignedPointer:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    xorl %eax, %eax
+; CHECK-NEXT:    testb $1, %dil
+; CHECK-NEXT:    cmoveq %rsi, %rax
+; CHECK-NEXT:    movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
+; CHECK-NEXT:    retq
+  %select.ptr = select i1 %arg0, ptr null, ptr %arg
+  %load = load i32, ptr %select.ptr
+  %insert = insertelement <2 x i32> zeroinitializer, i32 %load, i64 0
+  ret <2 x i32> %insert
+}
+
+; Make sure we do not try to inspect the uselist of a constant null
+; when processing a memcpy
+define void @gep_nullptr_no_inspect_uselist(ptr %arg) {
+; CHECK-LABEL: gep_nullptr_no_inspect_uselist:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    movzbl 16, %eax
+; CHECK-NEXT:    movb %al, (%rdi)
+; CHECK-NEXT:    retq
+  %null_gep = getelementptr i8, ptr null, i64 16
+  call void @llvm.memcpy.p0.p0.i64(ptr %arg, ptr %null_gep, i64 1, i1 false)
+  ret void
+}
+
+define <16 x i8> @load_null_offset() {
+; CHECK-LABEL: load_null_offset:
+; CHECK:       # %bb.0:
+; CHECK-NEXT:    movzbl 11, %eax
+; CHECK-NEXT:    movd %eax, %xmm1
+; CHECK-NEXT:    pslld $8, %xmm1
+; CHECK-NEXT:    xorps %xmm0, %xmm0
+; CHECK-NEXT:    movss {{.*#+}} xmm0 = xmm1[0],xmm0[1,2,3]
+; CHECK-NEXT:    retq
+  %gep.null = getelementptr i8, ptr null, i64 11
+  %load = load i8, ptr %gep.null, align 1
+  %insert = insertelement <16 x i8> zeroinitializer, i8 %load, i64 1
+  ret <16 x i8> %insert
+}
+
+declare void @llvm.memcpy.p0.p0.i64(ptr noalias writeonly captures(none), ptr noalias readonly captures(none), i64, i1 immarg) #0
+
+attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
diff --git a/llvm/test/Transforms/CorrelatedValuePropagation/no-uselist-constantdata-regression.ll b/llvm/test/Transforms/CorrelatedValuePropagation/no-uselist-constantdata-regression.ll
new file mode 100644
index 0000000000000..51be78788c454
--- /dev/null
+++ b/llvm/test/Transforms/CorrelatedValuePropagation/no-uselist-constantdata-regression.ll
@@ -0,0 +1,30 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
+; RUN: opt -S -passes=correlated-propagation < %s | FileCheck %s
+
+; Test for regression after 87f312aad6e from trying to use the uselist of constantdata
+
+define ptr @_ZN4mlir6Region15getParentOfTypeINS_19FunctionOpInterfaceEEET_v() {
+; CHECK-LABEL: define ptr @_ZN4mlir6Region15getParentOfTypeINS_19FunctionOpInterfaceEEET_v() {
+; CHECK-NEXT:  [[ENTRY:.*:]]
+; CHECK-NEXT:    [[CALL_FCA_0_EXTRACT:%.*]] = extractvalue [2 x i64] zeroinitializer, 0
+; CHECK-NEXT:    [[I2P:%.*]] = inttoptr i64 [[CALL_FCA_0_EXTRACT]] to ptr
+; CHECK-NEXT:    [[CMP_I:%.*]] = icmp ne ptr [[I2P]], null
+; CHECK-NEXT:    br i1 [[CMP_I]], label %[[CLEANUP:.*]], label %[[DO_COND:.*]]
+; CHECK:       [[DO_COND]]:
+; CHECK-NEXT:    br label %[[CLEANUP]]
+; CHECK:       [[CLEANUP]]:
+; CHECK-NEXT:    ret ptr [[I2P]]
+;
+entry:
+  %call.fca.0.extract = extractvalue [2 x i64] zeroinitializer, 0
+  %i2p = inttoptr i64 %call.fca.0.extract to ptr
+  %cmp.i = icmp ne ptr %i2p, null
+  br i1 %cmp.i, label %cleanup, label %do.cond
+
+do.cond:                                          ; preds = %entry
+  br label %cleanup
+
+cleanup:                                          ; preds = %do.cond, %entry
+  %phi = phi ptr [ %i2p, %entry ], [ null, %do.cond ]
+  ret ptr %phi
+}

Copy link
Contributor Author

arsenm commented May 8, 2025

Merge activity

  • May 8, 1:53 AM EDT: A user started a stack merge that includes this pull request via Graphite.
  • May 8, 1:55 AM EDT: Graphite rebased this pull request as part of a merge.
  • May 8, 1:57 AM EDT: @arsenm merged this pull request with Graphite.

@arsenm arsenm force-pushed the users/arsenm/add-constantdata-uselist-regression-tests branch from 59ae795 to 516db0b Compare May 8, 2025 05:54
@arsenm arsenm merged commit 334c1ab into main May 8, 2025
6 of 10 checks passed
@arsenm arsenm deleted the users/arsenm/add-constantdata-uselist-regression-tests branch May 8, 2025 05:57
petrhosek pushed a commit to petrhosek/llvm-project that referenced this pull request May 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants