================
@@ -553,6 +591,35 @@ RValue CIRGenFunction::emitLoadOfLValue(LValue lv, 
SourceLocation loc) {
   return RValue::get(nullptr);
 }
 
+static cir::FuncOp emitFunctionDeclPointer(CIRGenModule &cgm, GlobalDecl gd) {
+  assert(!cir::MissingFeatures::weakRefReference());
+  return cgm.getAddrOfFunction(gd);
+}
+
+static LValue emitFunctionDeclLValue(CIRGenFunction &CGF, const Expr *E,
+                                     GlobalDecl GD) {
+  const FunctionDecl *FD = cast<FunctionDecl>(GD.getDecl());
+  auto funcOp = emitFunctionDeclPointer(CGF.cgm, GD);
+  auto loc = CGF.getLoc(E->getSourceRange());
+  CharUnits align = CGF.getContext().getDeclAlign(FD);
+
+  mlir::Type fnTy = funcOp.getFunctionType();
+  auto ptrTy = cir::PointerType::get(fnTy);
+  mlir::Value addr = CGF.getBuilder().create<cir::GetGlobalOp>(
+      loc, ptrTy, funcOp.getSymName());
+
+  if (funcOp.getFunctionType() != CGF.convertType(FD->getType())) {
+    fnTy = CGF.convertType(FD->getType());
+    ptrTy = cir::PointerType::get(fnTy);
+
+    addr = CGF.getBuilder().create<cir::CastOp>(addr.getLoc(), ptrTy,
----------------
mmha wrote:

```suggestion
    addr = cir::CastOp::create(cgf.getBuilder(), addr.getLoc(), ptrTy,
```

https://github.com/llvm/llvm-project/pull/154060
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to