Skip to content

Commit 4245c00

Browse files
committed
[ORC] Fix LLJIT's atexit declaration for clang-repl on SystemZ.
The atexit needs a signext attribute on its return type. See #109658.
1 parent d8fadad commit 4245c00

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

llvm/lib/ExecutionEngine/Orc/LLJIT.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "llvm/ExecutionEngine/Orc/LLJIT.h"
10+
11+
#include "llvm/Analysis/TargetLibraryInfo.h"
1012
#include "llvm/Config/llvm-config.h" // for LLVM_ENABLE_THREADS
1113
#include "llvm/ExecutionEngine/JITLink/EHFrameSupport.h"
1214
#include "llvm/ExecutionEngine/JITLink/JITLinkMemoryManager.h"
@@ -195,10 +197,14 @@ class GenericLLVMIRPlatformSupport : public LLJIT::PlatformSupport {
195197
auto *IntTy = Type::getIntNTy(*Ctx, sizeof(int) * CHAR_BIT);
196198
auto *AtExitCallbackTy = FunctionType::get(VoidTy, {}, false);
197199
auto *AtExitCallbackPtrTy = PointerType::getUnqual(AtExitCallbackTy);
198-
addHelperAndWrapper(*M, "atexit",
199-
FunctionType::get(IntTy, {AtExitCallbackPtrTy}, false),
200-
GlobalValue::HiddenVisibility, "__lljit.atexit_helper",
201-
{PlatformInstanceDecl, DSOHandle});
200+
auto *AtExit = addHelperAndWrapper(
201+
*M, "atexit", FunctionType::get(IntTy, {AtExitCallbackPtrTy}, false),
202+
GlobalValue::HiddenVisibility, "__lljit.atexit_helper",
203+
{PlatformInstanceDecl, DSOHandle});
204+
Attribute::AttrKind AtExitExtAttr =
205+
TargetLibraryInfo::getExtAttrForI32Return(J.getTargetTriple());
206+
if (AtExitExtAttr != Attribute::None)
207+
AtExit->addRetAttr(AtExitExtAttr);
202208

203209
return J.addIRModule(JD, ThreadSafeModule(std::move(M), std::move(Ctx)));
204210
}

0 commit comments

Comments
 (0)