[all-commits] [llvm/llvm-project] 7d101e: [ORC][LLJIT] Define atexit symbol in GenericLLVMIR...

Sunho Kim via All-commits all-commits at lists.llvm.org
Sat Jun 25 11:50:47 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 7d101e43cd8afe7368c2180ce33b70b71572e846
      https://github.com/llvm/llvm-project/commit/7d101e43cd8afe7368c2180ce33b70b71572e846
  Author: Sunho Kim <ksunhokim123 at gmail.com>
  Date:   2022-06-26 (Sun, 26 Jun 2022)

  Changed paths:
    M llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
    M llvm/test/ExecutionEngine/OrcLazy/global-ctors-and-dtors.ll

  Log Message:
  -----------
  [ORC][LLJIT] Define atexit symbol in GenericLLVMIRPlatformSupport.

Define atexit symbol in GenericLLVMIRPlatformSupport so that it doesn't need to be defined by user.

On windows, llvm codegen emits atexit runtime calls to support global deinitializers as there is no lower function like cxa_atexit as in Itanium C++ ABI. ORC JIT user had to define custom atexit symbol manually. This was a hassle as it has to deal with dso_handle and cxa_atexit internals of LLJIT. If client didn't provide atexit definition, the default behaviour is just linking with host atexit function which is destined to fail as it calls dtors when the host program exits. This is after jit instances and buffers are freed, so users would see weird access violation exception from the uknown location. (in console application, the debugger thinks exception happened in scrt_common_main_seh)

This is a hack that has some caveats. (e.g. memory address is not identical) But, it's better than the situation described in the above. Ultimately, we will move on to ORC runtime that is able to solve the memory address issue properly.

Reviewed By: sgraenitz

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




More information about the All-commits mailing list