-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[MLIR][LLVM] Add weak_odr to allowed linkage for alias #132840
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[MLIR][LLVM] Add weak_odr to allowed linkage for alias #132840
Conversation
I missed this when originally introduced the feature, this fixes a small bug.
@llvm/pr-subscribers-mlir-llvm Author: Bruno Cardoso Lopes (bcardosolopes) ChangesI missed this when originally introduced the feature (note the verifier message already contains it), this fixes a small bug. Full diff: https://github.com/llvm/llvm-project/pull/132840.diff 3 Files Affected:
diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
index 5370de501a85c..e694f96f5fc63 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
@@ -2595,6 +2595,7 @@ LogicalResult AliasOp::verify() {
case Linkage::Internal:
case Linkage::Private:
case Linkage::Weak:
+ case Linkage::WeakODR:
case Linkage::Linkonce:
case Linkage::LinkonceODR:
case Linkage::AvailableExternally:
diff --git a/mlir/test/Dialect/LLVMIR/alias.mlir b/mlir/test/Dialect/LLVMIR/alias.mlir
index 807843a27e6fa..efba248534862 100644
--- a/mlir/test/Dialect/LLVMIR/alias.mlir
+++ b/mlir/test/Dialect/LLVMIR/alias.mlir
@@ -26,23 +26,23 @@ llvm.mlir.alias external @_ZTV1D : !llvm.struct<(array<3 x ptr>)> {
// -----
-llvm.mlir.global external @zed(42 : i32) : i32
+llvm.mlir.global weak_odr @zed(42 : i32) : i32
-llvm.mlir.alias external @foo : i32 {
+llvm.mlir.alias weak_odr @foo : i32 {
%0 = llvm.mlir.addressof @zed : !llvm.ptr
llvm.return %0 : !llvm.ptr
}
-llvm.mlir.alias external @foo2 : i16 {
+llvm.mlir.alias weak_odr @foo2 : i16 {
%0 = llvm.mlir.addressof @zed : !llvm.ptr
llvm.return %0 : !llvm.ptr
}
-// CHECK: llvm.mlir.alias external @foo : i32 {
+// CHECK: llvm.mlir.alias weak_odr @foo : i32 {
// CHECK: %[[ADDR:.*]] = llvm.mlir.addressof @zed : !llvm.ptr
// CHECK: llvm.return %[[ADDR]] : !llvm.ptr
// CHECK: }
-// CHECK: llvm.mlir.alias external @foo2 : i16 {
+// CHECK: llvm.mlir.alias weak_odr @foo2 : i16 {
// CHECK: %[[ADDR:.*]] = llvm.mlir.addressof @zed : !llvm.ptr
// CHECK: llvm.return %[[ADDR]] : !llvm.ptr
// CHECK: }
diff --git a/mlir/test/Target/LLVMIR/Import/alias.ll b/mlir/test/Target/LLVMIR/Import/alias.ll
index 23eaecb9c9fa7..7015d120a7252 100644
--- a/mlir/test/Target/LLVMIR/Import/alias.ll
+++ b/mlir/test/Target/LLVMIR/Import/alias.ll
@@ -62,6 +62,13 @@ entry:
; // -----
+@glob.private2 = private constant [32 x i32] zeroinitializer
+@glob2 = weak_odr hidden alias [32 x i32], inttoptr (i64 add (i64 ptrtoint (ptr @glob.private2 to i64), i64 1234) to ptr)
+
+; CHECK: llvm.mlir.alias weak_odr hidden @glob2 {dso_local} : !llvm.array<32 x i32> {
+
+; // -----
+
@g1 = private global i32 0
@g2 = internal constant ptr @a1
@g3 = internal constant ptr @a2
|
@llvm/pr-subscribers-mlir Author: Bruno Cardoso Lopes (bcardosolopes) ChangesI missed this when originally introduced the feature (note the verifier message already contains it), this fixes a small bug. Full diff: https://github.com/llvm/llvm-project/pull/132840.diff 3 Files Affected:
diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
index 5370de501a85c..e694f96f5fc63 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
@@ -2595,6 +2595,7 @@ LogicalResult AliasOp::verify() {
case Linkage::Internal:
case Linkage::Private:
case Linkage::Weak:
+ case Linkage::WeakODR:
case Linkage::Linkonce:
case Linkage::LinkonceODR:
case Linkage::AvailableExternally:
diff --git a/mlir/test/Dialect/LLVMIR/alias.mlir b/mlir/test/Dialect/LLVMIR/alias.mlir
index 807843a27e6fa..efba248534862 100644
--- a/mlir/test/Dialect/LLVMIR/alias.mlir
+++ b/mlir/test/Dialect/LLVMIR/alias.mlir
@@ -26,23 +26,23 @@ llvm.mlir.alias external @_ZTV1D : !llvm.struct<(array<3 x ptr>)> {
// -----
-llvm.mlir.global external @zed(42 : i32) : i32
+llvm.mlir.global weak_odr @zed(42 : i32) : i32
-llvm.mlir.alias external @foo : i32 {
+llvm.mlir.alias weak_odr @foo : i32 {
%0 = llvm.mlir.addressof @zed : !llvm.ptr
llvm.return %0 : !llvm.ptr
}
-llvm.mlir.alias external @foo2 : i16 {
+llvm.mlir.alias weak_odr @foo2 : i16 {
%0 = llvm.mlir.addressof @zed : !llvm.ptr
llvm.return %0 : !llvm.ptr
}
-// CHECK: llvm.mlir.alias external @foo : i32 {
+// CHECK: llvm.mlir.alias weak_odr @foo : i32 {
// CHECK: %[[ADDR:.*]] = llvm.mlir.addressof @zed : !llvm.ptr
// CHECK: llvm.return %[[ADDR]] : !llvm.ptr
// CHECK: }
-// CHECK: llvm.mlir.alias external @foo2 : i16 {
+// CHECK: llvm.mlir.alias weak_odr @foo2 : i16 {
// CHECK: %[[ADDR:.*]] = llvm.mlir.addressof @zed : !llvm.ptr
// CHECK: llvm.return %[[ADDR]] : !llvm.ptr
// CHECK: }
diff --git a/mlir/test/Target/LLVMIR/Import/alias.ll b/mlir/test/Target/LLVMIR/Import/alias.ll
index 23eaecb9c9fa7..7015d120a7252 100644
--- a/mlir/test/Target/LLVMIR/Import/alias.ll
+++ b/mlir/test/Target/LLVMIR/Import/alias.ll
@@ -62,6 +62,13 @@ entry:
; // -----
+@glob.private2 = private constant [32 x i32] zeroinitializer
+@glob2 = weak_odr hidden alias [32 x i32], inttoptr (i64 add (i64 ptrtoint (ptr @glob.private2 to i64), i64 1234) to ptr)
+
+; CHECK: llvm.mlir.alias weak_odr hidden @glob2 {dso_local} : !llvm.array<32 x i32> {
+
+; // -----
+
@g1 = private global i32 0
@g2 = internal constant ptr @a1
@g3 = internal constant ptr @a2
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
LGTM |
I missed this when originally introduced the feature (note the verifier message already contains it), this fixes a small bug.
…op linkage fix (#42) * [MLIR][LLVMIR] Add support for the full form of global_{ctor,dtor} (llvm#133176) Currently only ctor/dtor list and their priorities are supported. This PR adds support for the missing data field. Few implementation notes: - The assembly printer has a fixed form because previous `attr_dict` will sort the dict by key name, making global_dtor and global_ctor differ in the order of printed arguments. - LLVM's `ptr null` is being converted to `#llvm.zero` otherwise we'd have to create a region to use the default operation conversion from `ptr null`, which is silly given that the field only support null or a symbol. * [MLIR][LLVM] Add weak_odr to allowed linkage for alias (llvm#132840) I missed this when originally introduced the feature (note the verifier message already contains it), this fixes a small bug. --------- Co-authored-by: Bruno Cardoso Lopes <[email protected]>
I missed this when originally introduced the feature (note the verifier message already contains it), this fixes a small bug.