@@ -217,8 +217,7 @@ void CIRGenVTables::addVTableComponent(ConstantArrayBuilder &builder,
217
217
llvm_unreachable (" NYI" );
218
218
}
219
219
220
- [[maybe_unused]] auto getSpecialVirtualFn =
221
- [&](StringRef name) -> mlir::Attribute {
220
+ auto getSpecialVirtualFn = [&](StringRef name) -> mlir::cir::FuncOp {
222
221
// FIXME(PR43094): When merging comdat groups, lld can select a local
223
222
// symbol as the signature symbol even though it cannot be accessed
224
223
// outside that symbol's TU. The relative vtables ABI would make
@@ -235,45 +234,41 @@ void CIRGenVTables::addVTableComponent(ConstantArrayBuilder &builder,
235
234
CGM.getTriple ().isNVPTX ())
236
235
llvm_unreachable (" NYI" );
237
236
238
- llvm_unreachable (" NYI" );
239
- // llvm::FunctionType *fnTy =
240
- // llvm::FunctionType::get(CGM.VoidTy, /*isVarArg=*/false);
241
- // llvm::Constant *fn = cast<llvm::Constant>(
242
- // CGM.CreateRuntimeFunction(fnTy, name).getCallee());
243
- // if (auto f = dyn_cast<llvm::Function>(fn))
244
- // f->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
245
- // return llvm::ConstantExpr::getBitCast(fn, CGM.Int8PtrTy);
237
+ mlir::cir::FuncType fnTy =
238
+ CGM.getBuilder ().getFuncType ({}, CGM.getBuilder ().getVoidTy ());
239
+ mlir::cir::FuncOp fnPtr = CGM.createRuntimeFunction (fnTy, name);
240
+ // LLVM codegen handles unnamedAddr
241
+ assert (!MissingFeatures::unnamedAddr ());
242
+ return fnPtr;
246
243
};
247
244
248
245
mlir::cir::FuncOp fnPtr;
249
- // Pure virtual member functions.
250
246
if (cast<CXXMethodDecl>(GD.getDecl ())->isPureVirtual ()) {
251
- llvm_unreachable ( " NYI " );
252
- // if (!PureVirtualFn)
253
- // PureVirtualFn =
254
- // getSpecialVirtualFn(CGM.getCXXABI().GetPureVirtualCallName ());
255
- // fnPtr = PureVirtualFn;
247
+ // Pure virtual member functions.
248
+ if (!PureVirtualFn)
249
+ PureVirtualFn =
250
+ getSpecialVirtualFn (CGM.getCXXABI ().getPureVirtualCallName ());
251
+ fnPtr = PureVirtualFn;
256
252
257
- // Deleted virtual member functions.
258
253
} else if (cast<CXXMethodDecl>(GD.getDecl ())->isDeleted ()) {
259
- llvm_unreachable ( " NYI " );
260
- // if (!DeletedVirtualFn)
261
- // DeletedVirtualFn =
262
- // getSpecialVirtualFn(CGM.getCXXABI().GetDeletedVirtualCallName ());
263
- // fnPtr = DeletedVirtualFn;
254
+ // Deleted virtual member functions.
255
+ if (!DeletedVirtualFn)
256
+ DeletedVirtualFn =
257
+ getSpecialVirtualFn (CGM.getCXXABI ().getDeletedVirtualCallName ());
258
+ fnPtr = DeletedVirtualFn;
264
259
265
- // Thunks.
266
260
} else if (nextVTableThunkIndex < layout.vtable_thunks ().size () &&
267
261
layout.vtable_thunks ()[nextVTableThunkIndex].first ==
268
262
componentIndex) {
263
+ // Thunks.
269
264
llvm_unreachable (" NYI" );
270
265
// auto &thunkInfo = layout.vtable_thunks()[nextVTableThunkIndex].second;
271
266
272
267
// nextVTableThunkIndex++;
273
268
// fnPtr = maybeEmitThunk(GD, thunkInfo, /*ForVTable=*/true);
274
269
275
- // Otherwise we can use the method definition directly.
276
270
} else {
271
+ // Otherwise we can use the method definition directly.
277
272
auto fnTy = CGM.getTypes ().GetFunctionTypeForVTable (GD);
278
273
fnPtr = CGM.GetAddrOfFunction (GD, fnTy, /* ForVTable=*/ true );
279
274
}
0 commit comments