[PATCH] D66079: [SimplifyLibCalls] Add dereferenceable bytes from known callsites

Dávid Bolvanský via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 14 15:13:48 PDT 2019


xbolva00 added a comment.

Hello @jdoerfert.

I found another opportunity

char *d;

char * xmain(unsigned long n) {

  char *s = malloc(32);
  __builtin_memcpy(s, d, n);
  return s;

}

define dso_local noalias i8* @xmain(i64 %n) local_unnamed_addr #0 {
entry:

  %call = tail call i8* @malloc(i64 32)
  %0 = load i8*, i8** @d, align 8, !tbaa !2
  tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %call, i8* align 1 %0, i64 %n, i1 false)
  ret i8* %call

}

from malloc-like functions we can infer e.g. tail call void @llvm.memcpy.p0i8.p0i8.i64(i8*dereferenceable_or_null(32) align 1 %call, i8* align 1 %0, i64 %n, i1 false)

@spatel not sure what is best approach here.. in SLC's optimizeMalloc walk thru all malloc's users and annotate them?


Repository:
  rL LLVM

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

https://reviews.llvm.org/D66079





More information about the llvm-commits mailing list