llvm.org GIT mirror llvm / 5150270
GlobalOpt: fix an issue where CXAAtExitFn points to a deleted function. CXAAtExitFn was set outside a loop and before optimizations where functions can be deleted. This patch will set CXAAtExitFn inside the loop and after optimizations. Seg fault when running LTO because of accesses to a deleted function. rdar://problem/13838828 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181838 91177308-0d34-0410-b5e6-96231b3b80d8 Manman Ren 7 years ago
2 changed file(s) with 9 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
33223322 // Try to find the llvm.globalctors list.
33233323 GlobalVariable *GlobalCtors = FindGlobalCtors(M);
33243324
3325 Function *CXAAtExitFn = FindCXAAtExit(M, TLI);
3326
33273325 bool LocalChange = true;
33283326 while (LocalChange) {
33293327 LocalChange = false;
33413339 // Resolve aliases, when possible.
33423340 LocalChange |= OptimizeGlobalAliases(M);
33433341
3344 // Try to remove trivial global destructors.
3342 // Try to remove trivial global destructors if they are not removed
3343 // already.
3344 Function *CXAAtExitFn = FindCXAAtExit(M, TLI);
33453345 if (CXAAtExitFn)
33463346 LocalChange |= OptimizeEmptyGlobalCXXDtors(CXAAtExitFn);
33473347
0 ; RUN: opt < %s -globalopt -S | FileCheck %s
1
2 ; CHECK: ModuleID
3 define internal hidden i32 @__cxa_atexit(void (i8*)* nocapture %func, i8* nocapture %arg, i8* nocapture %dso_handle) nounwind readnone optsize noimplicitfloat {
4 unreachable
5 }