Skip to content

Commit

Permalink
Disabled erasing llvm.global_ctors from LLVM module because of issues…
Browse files Browse the repository at this point in the history
… on MacOS Apple Clang.

Left as future work.

Signed-off-by: Steena Monteiro <[email protected]>
  • Loading branch information
steenax86 committed May 3, 2022
1 parent 3bcc8e2 commit f3198b3
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions src/liboslexec/llvm_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1981,6 +1981,7 @@ void
LLVM_Util::prune_and_internalize_module (std::unordered_set<llvm::Function*> external_functions,
Linkage default_linkage, std::string *out_err)
{
// WIP: Investigating stripping global constructors and destructors
// Avoid calling global variable constructors
// as it is generally creates order of execution issues
// and difficult to support on devices.
Expand All @@ -1989,12 +1990,22 @@ LLVM_Util::prune_and_internalize_module (std::unordered_set<llvm::Function*> ext
// NEVER ACTUALLY CALLED!
// Should plumbing to execute the global constructors
// be created, then this should be revisitted
llvm::GlobalVariable *ctorgv = m_llvm_module->getGlobalVariable("llvm.global_ctors");
if(ctorgv==nullptr)
{
OSL_ASSERT("llvm.global_ctors not found");
}
ctorgv->eraseFromParent();
// llvm::GlobalVariable *ctors_gv = m_llvm_module->getGlobalVariable("llvm.global_ctors");
// if(ctors_gv!=nullptr)
// {
// ctors_gv->eraseFromParent();
// } else {
// // TODO: investigate if this symbol exists on Mac OS
// OSL_ASSERT("llvm.global_ctors not found");
// }
// llvm::GlobalVariable *dtors_gv = m_llvm_module->getGlobalVariable("llvm.global_dtors");
// if(dtors_gv!=nullptr)
// {
// dtors_gv->eraseFromParent();
// } else {
// // TODO: investigate if this symbol exists on Mac OS
// OSL_ASSERT("llvm.global_dtors not found");
// }

// Turn tracing for pruning on locally
#if defined(OSL_DEV)
Expand Down

0 comments on commit f3198b3

Please sign in to comment.