[PATCH] D71617: [WIP][NFC][Attributor] noalias attribute deduction fixme

pankaj gode via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 12 09:26:24 PST 2020


pgode added a comment.

Thanks for the explanation.  I thought the exact opposite i.e. even though the use is potentially captured in the callee but the callsite of callee is reachable, so we propagate noalias. I apologize as I had basic incorrect understanding.

When I started working on this, I was looking for noalias propagation for the below test. I was looking for the noalias propagation to happen to parameter of 'strtox' function (it gets called from strtold and strtof). For this function the noalias propagation doesn't happen because of the debug messages, '[Attributor][AANoAliasCSArg] check definition: i8* %s :: [P: {arg:s [s at 0]}][noalias][S: fix]  [Attributor][AANoAliasCSArg] i8* %s is assumed NoAlias in the definition'.  These conditions don't solve this problem so I think I will have to look into another way to solve this.

  ; Function Attrs: nounwind optsize
  define dso_local float @strtof(i8* noalias %s, i8** noalias %p) #0 {
  entry:
    %call = tail call fastcc double @strtox(i8* %s, i8** %p, i32 0) #3
    %conv = fptrunc double %call to float
    ret float %conv
  }
  
  ; Function Attrs: nounwind optsize
  define internal fastcc double @strtox(i8* %s, i8** %p, i32 %prec) unnamed_addr #0 {
  entry:
    %f = alloca %struct._IO_FILE, align 8
    %0 = bitcast %struct._IO_FILE* %f to i8*
    call void @llvm.lifetime.start.p0i8(i64 144, i8* nonnull %0) #4
    %call = call i32 bitcast (i32 (...)* @sh_fromstring to i32 (%struct._IO_FILE*, i8*)*)(%struct._IO_FILE* nonnull %f, i8* %s) #5
    call void @__shlim(%struct._IO_FILE* nonnull %f, i64 0) #5
    %call1 = call double @__floatscan(%struct._IO_FILE* nonnull %f, i32 %prec, i32 1) #5
    %shcnt = getelementptr inbounds %struct._IO_FILE, %struct._IO_FILE* %f, i32 0, i32 30
    %1 = load i64, i64* %shcnt, align 8, !tbaa !2
  ...
  }
  ; Function Attrs: nounwind optsize
  define dso_local double @strtold(i8* noalias %s, i8** noalias %p) #0 {
  entry:
    %call = tail call fastcc double @strtox(i8* %s, i8** %p, i32 2) #3
    ret double %call
  }

I had tried these conditions earlier and I do not observe noalias propagation in any of the test case. 
Out of the 3 tests, I was expecting the noalias propagation to happen for noalias.ll, test10_helper_1 but it doesn't. (I am not sure of the other 2 tests.)

  ; TEST 10
  ; Simple CallSite Test
  
  declare void @test10_helper_1(i8* %a)
  define void @test10_helper_2(i8* noalias %a) {
  >>>; CHECK:   tail call void @test10_helper_1(i8* noalias %a)
    tail call void @test10_helper_1(i8* %a)
    ret void
  }
  define void @test10(i8* noalias %a) {
  ; CHECK: define void @test10(i8* noalias %a)
  ; FIXME: missing noalias
  >>>; CHECK-NEXT:   tail call void @test10_helper_1(i8* noalias %a)
    tail call void @test10_helper_1(i8* %a)
  
  ; CHECK-NEXT:   tail call void @test10_helper_2(i8* noalias %a)
    tail call void @test10_helper_2(i8* %a)
    ret void
  }


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71617/new/

https://reviews.llvm.org/D71617





More information about the llvm-commits mailing list