Skip to content

Commit e9e87d4

Browse files
committed
add LLVM_DSOLocalEquivalentAttr, change folder, add one more test
1 parent 9abbf31 commit e9e87d4

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

mlir/include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,6 +1213,17 @@ def LLVM_UndefAttr : LLVM_Attr<"Undef", "undef">;
12131213
/// Folded into from LLVM::PoisonOp.
12141214
def LLVM_PoisonAttr : LLVM_Attr<"Poison", "poison">;
12151215

1216+
//===----------------------------------------------------------------------===//
1217+
// DSOLocalEquivalentAttr
1218+
//===----------------------------------------------------------------------===//
1219+
1220+
/// Folded into from LLVM::DSOLocalEquivalentOp.
1221+
def LLVM_DSOLocalEquivalentAttr : LLVM_Attr<"DSOLocalEquivalent",
1222+
"dso_local_equivalent"> {
1223+
let parameters = (ins "StringAttr":$name);
1224+
let assemblyFormat = "$name";
1225+
}
1226+
12161227
//===----------------------------------------------------------------------===//
12171228
// VecTypeHintAttr
12181229
//===----------------------------------------------------------------------===//

mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2167,9 +2167,11 @@ DSOLocalEquivalentOp::verifySymbolUses(SymbolTableCollection &symbolTable) {
21672167
return success();
21682168
}
21692169

2170-
// DSOLocalEquivalentOp constant-folds to the global symbol name.
2170+
/// Fold a dso_local_equivalent operation to a dedicated dso_local_equivalent
2171+
/// attribute.
21712172
OpFoldResult DSOLocalEquivalentOp::fold(FoldAdaptor) {
2172-
return getFunctionNameAttr();
2173+
return DSOLocalEquivalentAttr::get(getContext(),
2174+
getFunctionNameAttr().getAttr());
21732175
}
21742176

21752177
//===----------------------------------------------------------------------===//

mlir/test/Dialect/LLVMIR/constant-folding.mlir

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,3 +182,17 @@ func.func @insert_op(%arg0: index, %arg1: memref<13x13xi64>, %arg2: index) {
182182
vector.print %101 : vector<1xi64>
183183
return
184184
}
185+
186+
// -----
187+
188+
// CHECK-LABEL: llvm.func @dso_local_equivalent_select
189+
llvm.func @dso_local_equivalent_select(%arg: i1) -> !llvm.ptr {
190+
// CHECK-NEXT: %[[DSOLOCALEQ:.+]] = llvm.dso_local_equivalent @yay
191+
%0 = llvm.dso_local_equivalent @yay : !llvm.ptr
192+
%1 = llvm.dso_local_equivalent @yay : !llvm.ptr
193+
%2 = arith.select %arg, %0, %1 : !llvm.ptr
194+
// CHECK-NEXT: llvm.return %[[DSOLOCALEQ]]
195+
llvm.return %2 : !llvm.ptr
196+
}
197+
198+
llvm.func @yay()

0 commit comments

Comments
 (0)