[Mlir-commits] [mlir] a3e48ad - [mlir][LLVM] Export LLVMFuncOp's GC for declarations

Christian Ulmann llvmlistbot at llvm.org
Mon Jul 3 08:24:57 PDT 2023


Author: Christian Ulmann
Date: 2023-07-03T15:16:02Z
New Revision: a3e48ad9b8106d86eee0d9b0566973dd4b5daaad

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

LOG: [mlir][LLVM] Export LLVMFuncOp's GC for declarations

This commit ensures that the garbage collector attribute of LLVMFuncOps
is exported, even when they are declarations.

Added: 
    

Modified: 
    mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
    mlir/test/Target/LLVMIR/llvmir.mlir

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
index 2cfce47aa1373a..9f806957d42f04 100644
--- a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
@@ -901,9 +901,6 @@ LogicalResult ModuleTranslation::convertOneFunction(LLVMFuncOp func) {
       llvmFunc->setPersonalityFn(pfunc);
   }
 
-  if (auto gc = func.getGarbageCollector())
-    llvmFunc->setGC(gc->str());
-
   if (std::optional<StringRef> section = func.getSection())
     llvmFunc->setSection(*section);
 
@@ -1041,6 +1038,9 @@ LogicalResult ModuleTranslation::convertFunctionSignatures() {
           SymbolTable::lookupNearestSymbolFrom(function, *comdat));
       llvmFunc->setComdat(comdatMapping.lookup(selectorOp));
     }
+
+    if (auto gc = function.getGarbageCollector())
+      llvmFunc->setGC(gc->str());
   }
 
   return success();

diff  --git a/mlir/test/Target/LLVMIR/llvmir.mlir b/mlir/test/Target/LLVMIR/llvmir.mlir
index eb8bbacf0085ed..1f9c438a8e1d84 100644
--- a/mlir/test/Target/LLVMIR/llvmir.mlir
+++ b/mlir/test/Target/LLVMIR/llvmir.mlir
@@ -1628,6 +1628,12 @@ llvm.func @hasGCFunction() attributes { garbageCollector = "statepoint-example"
 
 // -----
 
+// CHECK-LABEL: @gc_decl
+// CHECK-SAME: gc "statepoint-example"
+llvm.func @gc_decl() attributes { garbageCollector = "statepoint-example" }
+
+// -----
+
 // CHECK-LABEL: @section_func
 // CHECK-SAME: section ".section.name"
 llvm.func @section_func() attributes { section = ".section.name" } {


        


More information about the Mlir-commits mailing list