Skip to content

Commit 89d8449

Browse files
authored
[ORC] Fix LLJIT's __cxa_atexit declaration for clang-repl. (#113141)
Add sign extension on i32 return value.
1 parent e26d907 commit 89d8449

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

llvm/lib/ExecutionEngine/Orc/LLJIT.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,12 +477,16 @@ class GenericLLVMIRPlatformSupport : public LLJIT::PlatformSupport {
477477
auto *CxaAtExitCallbackTy = FunctionType::get(VoidTy, {BytePtrTy}, false);
478478
auto *CxaAtExitCallbackPtrTy = PointerType::getUnqual(CxaAtExitCallbackTy);
479479

480-
addHelperAndWrapper(
480+
auto *CxaAtExit = addHelperAndWrapper(
481481
*M, "__cxa_atexit",
482482
FunctionType::get(IntTy, {CxaAtExitCallbackPtrTy, BytePtrTy, BytePtrTy},
483483
false),
484484
GlobalValue::DefaultVisibility, "__lljit.cxa_atexit_helper",
485485
{PlatformInstanceDecl});
486+
Attribute::AttrKind CxaAtExitExtAttr =
487+
TargetLibraryInfo::getExtAttrForI32Return(J.getTargetTriple());
488+
if (CxaAtExitExtAttr != Attribute::None)
489+
CxaAtExit->addRetAttr(CxaAtExitExtAttr);
486490

487491
return ThreadSafeModule(std::move(M), std::move(Ctx));
488492
}

0 commit comments

Comments
 (0)