[Mlir-commits] [mlir] [MLIR][LLVM] Fix nameless global import to support use before def case (PR #111797)

Tobias Gysi llvmlistbot at llvm.org
Thu Oct 10 00:29:54 PDT 2024


================
@@ -874,6 +874,24 @@ Attribute ModuleImport::getConstantAsAttr(llvm::Constant *constant) {
   return {};
 }
 
+FlatSymbolRefAttr
+ModuleImport::getOrCreateFakeSymbolName(llvm::GlobalVariable *globalVar) {
+  assert(globalVar->getName().empty() &&
+         "expected to work with a nameless global");
+  auto it = namelessGlobals.find(globalVar);
----------------
gysit wrote:

ultra nit: can you use try_emplace here. That function returns an iterator and if the value has been inserted and hence it avoids the second hashmap lookup blow.

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


More information about the Mlir-commits mailing list