[PATCH] D69428: [GlobalOpt] Remove valgrind specific hacks (revert r160529)

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 13 19:16:11 PDT 2021


MaskRay added a comment.

  // a.cc
  #include <stdio.h>
  #include <stdlib.h>
  #include <string.h>
  
  static void *g;
  
  void set(char *a);
  void foo(void *a) { g = a; } // add a store from a different function to suppress global internalization
  
  int main() {
    char a[10];
    set(a);
    char *b = strdup(a);
    printf("%p %s\n", b, b);
    g = b;
  }
  // b.cc
  #include <string.h>
  
  void set(char *a) {
    strcpy(a, "hello");
  }

`clang++ -O1 a.cc b.cc -fsanitize=leak` had no leak before and reported a leak with this patch. You can also change -O1 to -O2 or -O3. `-fsanitize=leak` can be changed to `-fsanitize=address`.

I think there is value retaining the original test case `cleanup-pointer-root-users.ll`.  We can teach isLeakCheckerRoot that function pointer should not need the pessimization.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69428



More information about the llvm-commits mailing list