================
@@ -639,13 +674,82 @@ cir::FuncOp 
CIRGenModule::getAddrOfFunction(clang::GlobalDecl gd,
     funcType = convertType(fd->getType());
   }
 
-  assert(!cir::MissingFeatures::mangledNames());
-  cir::FuncOp func = getOrCreateCIRFunction(
-      cast<NamedDecl>(gd.getDecl())->getIdentifier()->getName(), funcType, gd,
-      forVTable, dontDefer, /*isThunk=*/false, isForDefinition);
+  StringRef mangledName = getMangledName(gd);
+  cir::FuncOp func =
+      getOrCreateCIRFunction(mangledName, funcType, gd, forVTable, dontDefer,
+                             /*isThunk=*/false, isForDefinition);
   return func;
 }
 
+static std::string getMangledNameImpl(CIRGenModule &cgm, GlobalDecl gd,
+                                      const NamedDecl *nd) {
+  SmallString<256> buffer;
+
+  llvm::raw_svector_ostream out(buffer);
+  MangleContext &mc = cgm.getCXXABI().getMangleContext();
+
+  assert(!cir::MissingFeatures::moduleNameHash());
+
+  if (mc.shouldMangleDeclName(nd)) {
+    mc.mangleName(gd.getWithDecl(nd), out);
+  } else {
+    IdentifierInfo *ii = nd->getIdentifier();
+    assert(ii && "Attempt to mangle unnamed decl.");
+
+    const auto *fd = dyn_cast<FunctionDecl>(nd);
+    if (fd &&
+        fd->getType()->castAs<FunctionType>()->getCallConv() == CC_X86RegCall) 
{
+      cgm.errorNYI(nd->getSourceRange(), "getMangledName: X86RegCall");
+      out << ii->getName();
+    } else if (fd && fd->hasAttr<CUDAGlobalAttr>() &&
+               gd.getKernelReferenceKind() == KernelReferenceKind::Stub) {
+      out << "__device_stub__" << ii->getName();
----------------
erichkeane wrote:

We should either have tests for this, or just leave this errorNYI.

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

Reply via email to