Skip to content

Commit

Permalink
[lumen] Lower gc and gc-leaf-function function attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
bitwalker committed Aug 26, 2020
1 parent 6706c65 commit 3be9a53
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,7 @@ def LLVM_LLVMFuncOp
Arguments<(ins DefaultValuedAttr<Linkage,
"Linkage::External">:$linkage,
OptionalAttr<FlatSymbolRefAttr>:$personality,
OptionalAttr<StrAttr>:$gc,
OptionalAttr<ArrayAttr>:$passthrough)> {
let summary = "LLVM dialect function, has wrapped LLVM IR function type";

Expand Down
9 changes: 9 additions & 0 deletions mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -940,6 +940,15 @@ LogicalResult ModuleTranslation::convertOneFunction(LLVMFuncOp func) {
llvmFunc->setPersonalityFn(pfunc);
}

// Check the gc strategy and set it
auto gcStrategy = func.gc();
if (gcStrategy.hasValue()) {
llvmFunc->setGC(gcStrategy.getValue().str());
}
auto gcLeafAttr = func.getAttrOfType<BoolAttr>("gc-leaf-function");
if (gcLeafAttr && gcLeafAttr.getValue())
llvmFunc->addFnAttr("gc-leaf-function", "1");

// First, create all blocks so we can jump to them; (in topological order
// to ensure defs are converted before uses)
auto blocks = topologicalSort(func);
Expand Down

0 comments on commit 3be9a53

Please sign in to comment.