Skip to content

Commit 3be9a53

Browse files
committed
[lumen] Lower gc and gc-leaf-function function attributes
1 parent 6706c65 commit 3be9a53

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -787,6 +787,7 @@ def LLVM_LLVMFuncOp
787787
Arguments<(ins DefaultValuedAttr<Linkage,
788788
"Linkage::External">:$linkage,
789789
OptionalAttr<FlatSymbolRefAttr>:$personality,
790+
OptionalAttr<StrAttr>:$gc,
790791
OptionalAttr<ArrayAttr>:$passthrough)> {
791792
let summary = "LLVM dialect function, has wrapped LLVM IR function type";
792793

mlir/lib/Target/LLVMIR/ModuleTranslation.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -940,6 +940,15 @@ LogicalResult ModuleTranslation::convertOneFunction(LLVMFuncOp func) {
940940
llvmFunc->setPersonalityFn(pfunc);
941941
}
942942

943+
// Check the gc strategy and set it
944+
auto gcStrategy = func.gc();
945+
if (gcStrategy.hasValue()) {
946+
llvmFunc->setGC(gcStrategy.getValue().str());
947+
}
948+
auto gcLeafAttr = func.getAttrOfType<BoolAttr>("gc-leaf-function");
949+
if (gcLeafAttr && gcLeafAttr.getValue())
950+
llvmFunc->addFnAttr("gc-leaf-function", "1");
951+
943952
// First, create all blocks so we can jump to them; (in topological order
944953
// to ensure defs are converted before uses)
945954
auto blocks = topologicalSort(func);

0 commit comments

Comments
 (0)