vzakhari added inline comments.

================
Comment at: clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp:226
+    // Add this function to global destructors.
+    appendToGlobalDtors(M, Func, 0);
+  }
----------------
ABataev wrote:
> sdmitriev wrote:
> > vzakhari wrote:
> > > FYI, llvm.global_dtors does not work on Windows.  The symbol will be 
> > > placed into .CRT$XC[A-Z] portion of .CRT in 
> > > TargetLoweringObjectFileImpl.cpp, so, basically, __tgt_unregister_lib 
> > > will be called right after __tgt_register_lib.  We can either use a trick 
> > > from ASAN, i.e. put llvm.global_dtors into .CRT$XT[A-Z] (I am not sure 
> > > how solid this solution is) or call atexit() inside __tgt_register_lib to 
> > > register __tgt_unregister_lib terminator.
> > It works as expected on Linux, so I guess this is just a bug in lowering 
> > code for Windows that need to be fixed.
> Still, better to call atexit(), this is common solution to call a global 
> destructor/deinitializer
I agree.  One other thing: if `__tgt_register_lib` is never called do we want 
to call `__tgt_unregister_lib`?  It is possible with global_ctors/global_dtors, 
but not possible with atexit/cxa_atexit.


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

https://reviews.llvm.org/D64943



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to