[Mlir-commits] [mlir] [MLIR][LLVM] Refactor globals insertion point in import (NFC) (PR #127490)

Henrich Lauko llvmlistbot at llvm.org
Mon Feb 17 09:57:33 PST 2025


================
@@ -996,11 +1001,7 @@ LogicalResult ModuleImport::convertAlias(llvm::GlobalAlias *alias) {
 
 LogicalResult ModuleImport::convertGlobal(llvm::GlobalVariable *globalVar) {
   // Insert the global after the last one or at the start of the module.
-  OpBuilder::InsertionGuard guard(builder);
-  if (!globalInsertionOp)
-    builder.setInsertionPointToStart(mlirModule.getBody());
-  else
-    builder.setInsertionPointAfter(globalInsertionOp);
+  OpBuilder::InsertionGuard guard = setGlobalInsertionPoint(globalInsertionOp);
----------------
xlauko wrote:

It is not. That was my question whether `aliasInsertionOp` is actually needed? I don't see a reason, but it was duplicated with aliases. I think `globalInsertionOp` might be enough. This will result to emit aliases after globals, which I guess desired anyway. Same applies for IFunc I wanted to add.

If this is true, I would inline that as well.

Though there is similar functionality with `constantInsertionOp`, which would require `insertionBlock` as argument as well.
 

https://github.com/llvm/llvm-project/pull/127490


More information about the Mlir-commits mailing list