[clang] [CIR] Upstream support for cir.get_global (PR #135095)

Andy Kaylor via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 10 10:21:52 PDT 2025


================
@@ -200,6 +200,105 @@ void CIRGenModule::emitGlobalFunctionDefinition(clang::GlobalDecl gd,
   }
 }
 
+mlir::Operation *CIRGenModule::getGlobalValue(StringRef name) {
+  mlir::Operation *global = mlir::SymbolTable::lookupSymbolIn(theModule, name);
+  if (!global)
----------------
andykaylor wrote:

Oh, weird. The incubator code had `return {};` here, so it wasn't as obvious. I changed that to `nullptr` since it was actually returning a pointer and not an MLIR value, but I didn't notice the obvious redundancy of this. I'm pretty sure you're right that we can just return from line 204.

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


More information about the cfe-commits mailing list