[CUDA] Use atexit() to call module destructor.
authorArtem Belevich <tra@google.com>
Wed, 27 Jun 2018 18:32:51 +0000 (18:32 +0000)
committerArtem Belevich <tra@google.com>
Wed, 27 Jun 2018 18:32:51 +0000 (18:32 +0000)
commitc66d254ded501057a593260639a2bf80058b544c
tree552f311909b9b3b4c09f09d30081bfe9fc6e51ac
parent520748f01ef5ea4d4bc27cdbf09898ad9bceb9a8
[CUDA] Use atexit() to call module destructor.

This matches the way NVCC does it. Doing module cleanup at global
destructor phase used to work, but is, apparently, too late for
the CUDA runtime in CUDA-9.2, which ends up crashing with double-free.

Differential Revision: https://reviews.llvm.org/D48613

llvm-svn: 335763
clang/lib/CodeGen/CGCUDANV.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/test/CodeGenCUDA/device-stub.cu