Adhemerval Zanella via llvm-dev
2015-Sep-14  21:37 UTC
[llvm-dev] Regression with fno-exceptions handling
While investigating why aarch64 bot is showing a failure for tsan
'malloc_hook.cc'
I noted that clang now is showing an unexpected result with -fno-expection flag:
--
$ cat test.cc
typedef unsigned long int uptr;
#ifdef __cplusplus
extern "C" {
#endif
__attribute__((visibility("default"))) __attribute__((weak))
                   void __sanitizer_malloc_hook(void *ptr, uptr size);
#ifdef __cplusplus
}  // extern "C"
#endif
extern "C" void __attribute__((weak)) __sanitizer_malloc_hook(void
*ptr, uptr size) {
  (void)ptr;
  (void)size;
}
void invoke_malloc_hook(void *ptr, uptr size) {
  //ThreadState *thr = cur_thread();
  //if (ctx == 0 || !ctx->initialized || thr->ignore_interceptors)
  //  return;
  __sanitizer_malloc_hook(ptr, size);
}
$ ./bin/clang test.cc -O3 -S -emit-llvm -S -o - | grep -i 'call' | grep
__sanitizer_malloc_hook
  tail call void @__sanitizer_malloc_hook(i8* %ptr, i64 %size)
$ ./bin/clang test.cc -fno-exceptions -O3 -S -emit-llvm -S -o - | grep -i
'call' | grep __sanitizer_malloc_hook
$ 
The weak symbol is not being called with -fno-exceptions and thus any user
supplied
hook won't work.  Does it ring a bell to someone? I am bissecting to find
out which
commit change it, but if someone could point out it may save me a lot of time =)