[PATCH] D88706: [OpenMP][MLIR] WIP : Fix for nested parallel region

Kiran Chandramohan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 2 07:19:16 PDT 2020


kiranchandramohan added a comment.

@fghanim I just saw your following comment in https://reviews.llvm.org/D87247.
"All llvm passes expect Allocas to be in the entry block of the function. In this case, the soon-to-be-outlined region. is builder's current insertion point in the entry block? Also, is it guaranteed to not be empty?"

I belive all allocas in the LLVM dialect will also be in the entry block of the OpenMP operation. But these will added only in the bodygen call-back. So they will be added to omp.par.region (actually omp.par.region1 since a dummy branch is created). But all these are trivial branches (not conditional) and can't they be inlined into the entry block if required? See example below for,

  llvm.func @test_omp_parallel_4() -> () {
    omp.parallel {
      omp.barrier
      omp.terminator
    }
    llvm.return
  }

  define internal void @test_omp_parallel_4..omp_par(i32* noalias %tid.addr, i32* noalias %zero.addr) #0 !dbg !10 {
  omp.par.entry:
    %tid.addr.local = alloca i32, align 4
    %0 = load i32, i32* %tid.addr, align 4
    store i32 %0, i32* %tid.addr.local, align 4
    %tid = load i32, i32* %tid.addr.local, align 4
    br label %omp.par.region
  
  omp.par.outlined.exit.exitStub:                   ; preds = %omp.par.pre_finalize
    ret void
  
  omp.par.region:                                   ; preds = %omp.par.entry
    br label %omp.par.region1
  
  omp.par.region1:                                  ; preds = %omp.par.region
    // ALLOCAS IN the OpenMP parallel region will appear HERE.
    %omp_global_thread_num2 = call i32 @__kmpc_global_thread_num(%struct.ident_t* @4)
    call void @__kmpc_barrier(%struct.ident_t* @3, i32 %omp_global_thread_num2)
    br label %omp.par.pre_finalize, !dbg !11
  
  omp.par.pre_finalize:                             ; preds = %omp.par.region1
    br label %omp.par.outlined.exit.exitStub
  }


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88706/new/

https://reviews.llvm.org/D88706



More information about the llvm-commits mailing list