================
@@ -3420,8 +3412,15 @@ CIRGenModule::createCIRFunction(mlir::Location loc,
StringRef name,
//
// Be sure to insert a new function before a current one.
CIRGenFunction *cgf = this->curCGF;
- if (cgf)
+ if (cgf) {
builder.setInsertionPoint(cgf->curFn);
+ } else {
+ // No CIRGenFunction is active, but the builder's insertion point may
+ // still be inside another op (e.g. a function materialized on demand
+ // while generating a vtable thunk). Insert at module scope so the new
+ // function is not parented under the ambient insertion point.
+ builder.setInsertionPointToEnd(theModule.getBody());
----------------
andykaylor wrote:
That would probably change a lot of tests, but I wonder if it would help with
the cases where we end up with functions being emitted in a different order
than OGCG.
https://github.com/llvm/llvm-project/pull/207260
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits