[clang] [llvm] [WIP][OpenMP] Remove dependency on `libffi` from offloading runtime (PR #91264)

2024-05-07 Thread Joseph Huber via cfe-commits
jhuber6 wrote: > Hmm, hard to tell, need to debug it. Somehow when I print it in the runtime it shows up as garbage, but the actual region seems to get correct values. There shouldn't be anything in-between the arguments I'm printing and the kernel launch however so I'm stumped.

[clang] [llvm] [WIP][OpenMP] Remove dependency on `libffi` from offloading runtime (PR #91264)

2024-05-07 Thread Alexey Bataev via cfe-commits
alexey-bataev wrote: Hmm, hard to tell, need to debug it. https://github.com/llvm/llvm-project/pull/91264 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [WIP][OpenMP] Remove dependency on `libffi` from offloading runtime (PR #91264)

2024-05-07 Thread Joseph Huber via cfe-commits
jhuber6 wrote: I'm getting the same kind of output on `main`, but the warning is mysteriously absent. https://github.com/llvm/llvm-project/pull/91264 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[clang] [llvm] [WIP][OpenMP] Remove dependency on `libffi` from offloading runtime (PR #91264)

2024-05-07 Thread Joseph Huber via cfe-commits
jhuber6 wrote: > > Maybe. The message is emitted on the host, so there is something wrong with > the host code or runtime library. This might be some issue with the host codegen actually. ```console > clang malloc.c -fopenmp -fopenmp-targets=x86_64-pc-linux-gnu >

[clang] [llvm] [WIP][OpenMP] Remove dependency on `libffi` from offloading runtime (PR #91264)

2024-05-07 Thread Alexey Bataev via cfe-commits
alexey-bataev wrote: > > > > > ```llvm > > > > > struct.anon > > > > > ``` > > > > > > > > > > > > Can you provide full IR dump here? > > > > > > > > > https://godbolt.org/z/48h5s3W6v > > > > > > It does not look like the issue of the target code, I don't see any wrong > > access for

[clang] [llvm] [WIP][OpenMP] Remove dependency on `libffi` from offloading runtime (PR #91264)

2024-05-07 Thread Joseph Huber via cfe-commits
jhuber6 wrote: > > > > ```llvm > > > > struct.anon > > > > ``` > > > > > > > > > Can you provide full IR dump here? > > > > > > https://godbolt.org/z/48h5s3W6v > > It does not look like the issue of the target code, I don't see any wrong > access for __context. Мост probably something

[clang] [llvm] [WIP][OpenMP] Remove dependency on `libffi` from offloading runtime (PR #91264)

2024-05-07 Thread Alexey Bataev via cfe-commits
alexey-bataev wrote: > > > ```llvm > > > struct.anon > > > ``` > > > > > > Can you provide full IR dump here? > > https://godbolt.org/z/48h5s3W6v It does not look like the issue of the target code, I don't see any wrong access for __context. Мост probably something wrong with the host

[clang] [llvm] [WIP][OpenMP] Remove dependency on `libffi` from offloading runtime (PR #91264)

2024-05-07 Thread Joseph Huber via cfe-commits
jhuber6 wrote: > > ```llvm > > struct.anon > > ``` > > Can you provide full IR dump here? https://godbolt.org/z/48h5s3W6v https://github.com/llvm/llvm-project/pull/91264 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[clang] [llvm] [WIP][OpenMP] Remove dependency on `libffi` from offloading runtime (PR #91264)

2024-05-07 Thread Alexey Bataev via cfe-commits
alexey-bataev wrote: > ```llvm > struct.anon > ``` Can you provide full IR dump here? https://github.com/llvm/llvm-project/pull/91264 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [WIP][OpenMP] Remove dependency on `libffi` from offloading runtime (PR #91264)

2024-05-07 Thread Joseph Huber via cfe-commits
jhuber6 wrote: > > ```llvm > > = load i32, ptr %.capture_expr., align 4 > > ``` > > Why do you think it reads beyond __context? %2 = getelementptr inbounds > %struct.anon, ptr %1, i32 0, i32 0 points to the first element in the > __context, if I'm not missing something. If it has the wrong

[clang] [llvm] [WIP][OpenMP] Remove dependency on `libffi` from offloading runtime (PR #91264)

2024-05-07 Thread Alexey Bataev via cfe-commits
@@ -613,6 +613,102 @@ static llvm::Function *emitOutlinedFunctionPrologue( return F; } +static llvm::Function *emitOutlinedFunctionPrologueAggregate( +CodeGenFunction , FunctionArgList , +llvm::MapVector> +, +llvm::DenseMap> +, +llvm::Value

[clang] [llvm] [WIP][OpenMP] Remove dependency on `libffi` from offloading runtime (PR #91264)

2024-05-07 Thread Alexey Bataev via cfe-commits
@@ -5932,12 +5932,16 @@ void CGOpenMPRuntime::emitTargetOutlinedFunctionHelper( CodeGenFunction CGF(CGM, true); llvm::OpenMPIRBuilder::FunctionGenCallback & = - [, , ](StringRef EntryFnName) { + [, , , this](StringRef EntryFnName) { const CapturedStmt

[clang] [llvm] [WIP][OpenMP] Remove dependency on `libffi` from offloading runtime (PR #91264)

2024-05-07 Thread Alexey Bataev via cfe-commits
alexey-bataev wrote: > ```llvm > = load i32, ptr %.capture_expr., align 4 > ``` Why do you think it reads beyond __context? %2 = getelementptr inbounds %struct.anon, ptr %1, i32 0, i32 0 points to the first element in the __context, if I'm not missing something. If it has the wrong value,

[clang] [llvm] [WIP][OpenMP] Remove dependency on `libffi` from offloading runtime (PR #91264)

2024-05-06 Thread Joseph Huber via cfe-commits
jhuber6 wrote: I'm unsure how to resolve the issue of `CGF.EmitScalarExpr(NumTeams)` not returning the correct value now. For the following code ```c #include #include int main() { int Teams = 10; #pragma omp target teams distribute parallel for num_teams(Teams) for (int i = 0; i < 1;

[clang] [llvm] [WIP][OpenMP] Remove dependency on `libffi` from offloading runtime (PR #91264)

2024-05-06 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-clang-codegen Author: Joseph Huber (jhuber6) Changes Summary: This patch attempts to remove the dependency on `libffi` by instead emitting the host / CPU kernels using an aggregate struct made from the captured context. This callows us to have a fixed