llvm.org GIT mirror llvm / 9cf2067
Treat sret arguments as being dereferenceable in getPointerDereferenceableBytes() Reviewers: rnk, hfinkel, efriedma Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D41355 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@321061 91177308-0d34-0410-b5e6-96231b3b80d8 Bjorn Steinbrink 2 years ago
2 changed file(s) with 14 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
626626 CanBeNull = false;
627627 if (const Argument *A = dyn_cast(this)) {
628628 DerefBytes = A->getDereferenceableBytes();
629 if (DerefBytes == 0 && A->hasByValAttr()) {
629 if (DerefBytes == 0 && (A->hasByValAttr() || A->hasStructRetAttr())) {
630630 Type *PT = cast(A->getType())->getElementType();
631 DerefBytes = DL.getTypeStoreSize(PT);
631 if (PT->isSized())
632 DerefBytes = DL.getTypeStoreSize(PT);
632633 }
633634 if (DerefBytes == 0) {
634635 DerefBytes = A->getDereferenceableOrNullBytes();
1919 @globalptr.align16 = external global i8, align 16
2020
2121 ; CHECK-LABEL: 'test'
22 define void @test(i32 addrspace(1)* dereferenceable(8) %dparam,
22 define void @test(%struct.A* sret %result,
23 i32 addrspace(1)* dereferenceable(8) %dparam,
2324 i8 addrspace(1)* dereferenceable(32) align 1 %dparam.align1,
2425 i8 addrspace(1)* dereferenceable(32) align 16 %dparam.align16,
2526 i8* byval %i8_byval,
5152 %big_array_alloca = alloca i8, i64 4
5253 %baa_cast = bitcast i8* %big_array_alloca to i32*
5354 %baa_load = load i32, i32* %baa_cast
55
56 ; Loads from sret arguments
57 ; CHECK: %sret_gep{{.*}}(aligned)
58 %sret_gep = getelementptr inbounds %struct.A, %struct.A* %result, i64 0, i32 1, i64 2
59 load i8, i8* %sret_gep
60
61 ; CHECK-NOT: %sret_gep_outside
62 %sret_gep_outside = getelementptr %struct.A, %struct.A* %result, i64 0, i32 1, i64 7
63 load i8, i8* %sret_gep_outside
5464
5565 ; CHECK: %dparam{{.*}}(aligned)
5666 %load3 = load i32, i32 addrspace(1)* %dparam