================
@@ -33,18 +34,34 @@ struct HoistAllocasPass : public 
impl::HoistAllocasBase<HoistAllocasPass> {
   void runOnOperation() override;
 };
 
+// Find the block that an alloca should be hoisted into. Allocas are normally
+// hoisted to the entry block of the enclosing function. However, an alloca may
+// be nested inside an OpenMP region such as omp.parallel, omp.teams
+// etc. Hoisting it out of these ops breaks the isolated from above requirement
+// for omp.teams and it changes privatization semantics.
+static mlir::Block *getHoistDestBlock(cir::AllocaOp alloca) {
+  mlir::Region *region = alloca->getParentRegion();
+  while (true) {
+    mlir::Operation *parentOp = region->getParentOp();
+    if (mlir::isa<cir::FuncOp>(parentOp) ||
+        mlir::isa<mlir::omp::OutlineableOpenMPOpInterface>(parentOp))
----------------
jsjodin wrote:

@xlauko did you have any more feedback on this?

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

Reply via email to