================
@@ -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());
----------------
erichkeane wrote:

Maybe?  But this extra branch above just seems silly IMO.  Its perhaps worth 
the fallout just to simplify this a bit, but also like you said, could very 
well better match OGCG for ordering.

https://github.com/llvm/llvm-project/pull/207260
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to