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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions llvm/test/CodeGen/X86/codegen-no-uselist-constantdata.ll
Original file line number Diff line number Diff line change
@@ -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) }
Original file line number Diff line number Diff line change
@@ -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
}
Loading