[llvm] 89d8449 - [ORC] Fix LLJIT's __cxa_atexit declaration for clang-repl. (#113141)

via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 21 06:12:56 PDT 2024


Author: Jonas Paulsson
Date: 2024-10-21T15:12:53+02:00
New Revision: 89d8449a2900123c2e9bd7a11315381b2b70c155

URL: https://github.com/llvm/llvm-project/commit/89d8449a2900123c2e9bd7a11315381b2b70c155
DIFF: https://github.com/llvm/llvm-project/commit/89d8449a2900123c2e9bd7a11315381b2b70c155.diff

LOG: [ORC] Fix LLJIT's __cxa_atexit declaration for clang-repl. (#113141)

Add sign extension on i32 return value.

Added: 
    

Modified: 
    llvm/lib/ExecutionEngine/Orc/LLJIT.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp b/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
index 401ed525fd5cfe..db39fec12e5fcb 100644
--- a/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp
@@ -477,12 +477,16 @@ class GenericLLVMIRPlatformSupport : public LLJIT::PlatformSupport {
     auto *CxaAtExitCallbackTy = FunctionType::get(VoidTy, {BytePtrTy}, false);
     auto *CxaAtExitCallbackPtrTy = PointerType::getUnqual(CxaAtExitCallbackTy);
 
-    addHelperAndWrapper(
+    auto *CxaAtExit = addHelperAndWrapper(
         *M, "__cxa_atexit",
         FunctionType::get(IntTy, {CxaAtExitCallbackPtrTy, BytePtrTy, BytePtrTy},
                           false),
         GlobalValue::DefaultVisibility, "__lljit.cxa_atexit_helper",
         {PlatformInstanceDecl});
+    Attribute::AttrKind CxaAtExitExtAttr =
+        TargetLibraryInfo::getExtAttrForI32Return(J.getTargetTriple());
+    if (CxaAtExitExtAttr != Attribute::None)
+      CxaAtExit->addRetAttr(CxaAtExitExtAttr);
 
     return ThreadSafeModule(std::move(M), std::move(Ctx));
   }


        


More information about the llvm-commits mailing list