Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OpenMP] Avoid type-punning on the parallel_51 call edge #60327

Closed
jdoerfert opened this issue Jan 27, 2023 · 2 comments
Closed

[OpenMP] Avoid type-punning on the parallel_51 call edge #60327

jdoerfert opened this issue Jan 27, 2023 · 2 comments

Comments

@jdoerfert
Copy link
Member

jdoerfert commented Jan 27, 2023

We type pun firstprivate integers (among other things) on the call edge between the sequential and parallel region. This is really bad for device code as it prevents us in pretty much all pipelines to inline the parallel runtime function. If we would not type-pun it works fine. If we run another optimization pipeline, it does work too. Unsure what part of the inliner is affected here but my guess is that it's the "CallBase::getCalledFunction" checking that the callee type matches the call site.

This is a pretty bad regression we should try to fix and backport into 16.

Example: https://godbolt.org/z/9o7qMPcvM

#include <omp.h>
void f(long *A, int N) {
    long i = 0;
#pragma omp target map(A[ : N])
    {
#pragma omp parallel firstprivate(i)
        A[omp_get_thread_num()] = i;
    }
}
@llvmbot
Copy link
Collaborator

llvmbot commented Jan 27, 2023

@llvm/issue-subscribers-openmp

@jdoerfert jdoerfert changed the title [OpenM] Avoid type-punning on the parallel_51 call edge [OpenMP] Avoid type-punning on the parallel_51 call edge Jan 27, 2023
@jdoerfert
Copy link
Member Author

The real problem are the "previous.lb" and "previous.ub" bounds passed as i64 to the outlined function. These need to be casted to pointers first. With the new loop API this should resolve itself.

@jdoerfert jdoerfert self-assigned this Aug 18, 2023
razmser pushed a commit to SuduIDE/llvm-project that referenced this issue Oct 2, 2023
AAIndirectCallInfo will collect information and specialize indirect call
sites. It is similar to our IndirectCallPromotion but runs as part of
the Attributor (so with assumed callee information). It also expands
more calls and let's the rest of the pipeline figure out what is UB, for
now. We use existing call promotion logic to improve the result,
otherwise we rely on the (implicit) function pointer cast.

This effectively "fixes" llvm#60327 as it will undo the type punning early
enough for the inliner to work with the (now specialized, thus direct)
call.

Fixes: llvm#60327
razmser pushed a commit to SuduIDE/llvm-project that referenced this issue Oct 2, 2023
AAIndirectCallInfo will collect information and specialize indirect call
sites. It is similar to our IndirectCallPromotion but runs as part of
the Attributor (so with assumed callee information). It also expands
more calls and let's the rest of the pipeline figure out what is UB, for
now. We use existing call promotion logic to improve the result,
otherwise we rely on the (implicit) function pointer cast.

This effectively "fixes" llvm#60327 as it will undo the type punning early
enough for the inliner to work with the (now specialized, thus direct)
call.

Fixes: llvm#60327
razmser pushed a commit to SuduIDE/llvm-project that referenced this issue Oct 2, 2023
AAIndirectCallInfo will collect information and specialize indirect call
sites. It is similar to our IndirectCallPromotion but runs as part of
the Attributor (so with assumed callee information). It also expands
more calls and let's the rest of the pipeline figure out what is UB, for
now. We use existing call promotion logic to improve the result,
otherwise we rely on the (implicit) function pointer cast.

This effectively "fixes" llvm#60327 as it will undo the type punning early
enough for the inliner to work with the (now specialized, thus direct)
call.

Fixes: llvm#60327
razmser pushed a commit to SuduIDE/llvm-project that referenced this issue Oct 3, 2023
AAIndirectCallInfo will collect information and specialize indirect call
sites. It is similar to our IndirectCallPromotion but runs as part of
the Attributor (so with assumed callee information). It also expands
more calls and let's the rest of the pipeline figure out what is UB, for
now. We use existing call promotion logic to improve the result,
otherwise we rely on the (implicit) function pointer cast.

This effectively "fixes" llvm#60327 as it will undo the type punning early
enough for the inliner to work with the (now specialized, thus direct)
call.

Fixes: llvm#60327
razmser pushed a commit to SuduIDE/llvm-project that referenced this issue Oct 3, 2023
AAIndirectCallInfo will collect information and specialize indirect call
sites. It is similar to our IndirectCallPromotion but runs as part of
the Attributor (so with assumed callee information). It also expands
more calls and let's the rest of the pipeline figure out what is UB, for
now. We use existing call promotion logic to improve the result,
otherwise we rely on the (implicit) function pointer cast.

This effectively "fixes" llvm#60327 as it will undo the type punning early
enough for the inliner to work with the (now specialized, thus direct)
call.

Fixes: llvm#60327
razmser pushed a commit to SuduIDE/llvm-project that referenced this issue Oct 6, 2023
AAIndirectCallInfo will collect information and specialize indirect call
sites. It is similar to our IndirectCallPromotion but runs as part of
the Attributor (so with assumed callee information). It also expands
more calls and let's the rest of the pipeline figure out what is UB, for
now. We use existing call promotion logic to improve the result,
otherwise we rely on the (implicit) function pointer cast.

This effectively "fixes" llvm#60327 as it will undo the type punning early
enough for the inliner to work with the (now specialized, thus direct)
call.

Fixes: llvm#60327
razmser pushed a commit to SuduIDE/llvm-project that referenced this issue Oct 11, 2023
AAIndirectCallInfo will collect information and specialize indirect call
sites. It is similar to our IndirectCallPromotion but runs as part of
the Attributor (so with assumed callee information). It also expands
more calls and let's the rest of the pipeline figure out what is UB, for
now. We use existing call promotion logic to improve the result,
otherwise we rely on the (implicit) function pointer cast.

This effectively "fixes" llvm#60327 as it will undo the type punning early
enough for the inliner to work with the (now specialized, thus direct)
call.

Fixes: llvm#60327
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants