This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP] Add OpenMPOpt as a Module pass
ClosedPublic

Authored by jhuber6 on Mar 23 2021, 11:20 AM.

Details

Summary

This patch registers OpenMPOpt as a Module pass in addition to a CGSCC
pass. This is so certain optimzations that are sensitive to intact
call-sites can happen before inlining. The old openmpopt pass name is
changed to openmp-opt-cgscc and openmp-opt calls the Module pass
which has limited functionality currently.

Diff Detail

Event Timeline

jhuber6 created this revision.Mar 23 2021, 11:20 AM
jhuber6 requested review of this revision.Mar 23 2021, 11:20 AM

This needs PhaseOrdering test

jhuber6 updated this revision to Diff 332743.Mar 23 2021, 11:32 AM

Forgot to format.

jhuber6 updated this revision to Diff 332783.Mar 23 2021, 1:57 PM

Changed the pass registration to happen before the Attributor pass to avoid function specialization. Added a PhaseOrdering test that won't pass without the module pass.

jdoerfert accepted this revision.Mar 23 2021, 5:37 PM

Can you precommit the llvm/test/Transforms/PhaseOrdering/openmp-opt-module.ll test so we can see what changed.

Generally looks good to me otherwise.

llvm/test/Transforms/OpenMP/values_in_offload_arrays.ll
1–2

make two run lines, here and elsewhere if applicable

This revision is now accepted and ready to land.Mar 23 2021, 5:37 PM
jhuber6 updated this revision to Diff 338616.Apr 19 2021, 1:18 PM
jhuber6 edited the summary of this revision. (Show Details)

Changing the OpenMPOpt module pass to only run selected optimizations. Removed the module pass version from most of the tests, more tests will be added once there are additional uses for the module pass.

jhuber6 updated this revision to Diff 338879.Apr 20 2021, 8:24 AM

Fixing tests.

This revision was automatically updated to reflect the committed changes.

The following two tests are causing assertion failures when run with the legacy pass manager (force using -enable-new-pm=0).

  • Transforms/OpenMP/hide_mem_transfer_latency.ll
  • Transforms/OpenMP/values_in_offload_arrays.ll

Waiting on the bugzilla account request to make a ticket but here is the trace.

opt: llvm/lib/Analysis/CallGraphSCCPass.cpp:281: bool (anonymous namespace)::CGPassManager::RefreshCallGraph(const llvm::CallGraphSCC &, llvm::CallGraph &, bool): Assertion `!CheckingMode && "CallGraphSCCPass did not update the CallGraph correctly!"' failed.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
Stack dump:
0.      Program arguments: opt -S -openmp-opt-cgscc -aa-pipeline=basic-aa -openmp-hide-memory-transfer-latency -enable-new-pm=0
1.      Running pass 'CallGraph Pass Manager' on module '<stdin>'.
 #0 0x00000000020bdf43 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (opt+0x20bdf43)
 #1 0x00000000020bbc00 llvm::sys::RunSignalHandlers() (opt+0x20bbc00)
 #2 0x00000000020be3f6 SignalHandler(int) llvm/lib/Support/Signals.cpp:0:0
 #3 0x00007f15159bf330 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x10330)
 #4 0x00007f15143a3c37 raise /build/eglibc-ripdx6/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
 #5 0x00007f15143a7028 abort /build/eglibc-ripdx6/eglibc-2.19/stdlib/abort.c:91:0
 #6 0x00007f151439cbf6 __assert_fail_base /build/eglibc-ripdx6/eglibc-2.19/assert/assert.c:92:0
 #7 0x00007f151439cca2 (/lib/x86_64-linux-gnu/libc.so.6+0x2fca2)
 #8 0x000000000100ab4f (anonymous namespace)::CGPassManager::RefreshCallGraph(llvm::CallGraphSCC const&, llvm::CallGraph&, bool) llvm/lib/Analysis/CallGraphSCCPass.cpp:0:0
 #9 0x00000000010093ac (anonymous namespace)::CGPassManager::runOnModule(llvm::Module&) llvm/lib/Analysis/CallGraphSCCPass.cpp:0:0
#10 0x00000000018c6788 llvm::legacy::PassManagerImpl::run(llvm::Module&) (opt+0x18c6788)
#11 0x00000000007d06e5 main (opt+0x7d06e5)
#12 0x00007f151438ef45 __libc_start_main /build/eglibc-ripdx6/eglibc-2.19/csu/libc-start.c:321:0
#13 0x00000000007ba679 _start (opt+0x7ba679)
[1]    27229 abort      opt -S -openmp-opt-cgscc -aa-pipeline=basic-aa   -enable-new-pm=0

The following two tests are causing assertion failures when run with the legacy pass manager (force using -enable-new-pm=0).

  • Transforms/OpenMP/hide_mem_transfer_latency.ll
  • Transforms/OpenMP/values_in_offload_arrays.ll

Waiting on the bugzilla account request to make a ticket but here is the trace.

opt: llvm/lib/Analysis/CallGraphSCCPass.cpp:281: bool (anonymous namespace)::CGPassManager::RefreshCallGraph(const llvm::CallGraphSCC &, llvm::CallGraph &, bool): Assertion `!CheckingMode && "CallGraphSCCPass did not update the CallGraph correctly!"' failed.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
Stack dump:
0.      Program arguments: opt -S -openmp-opt-cgscc -aa-pipeline=basic-aa -openmp-hide-memory-transfer-latency -enable-new-pm=0
1.      Running pass 'CallGraph Pass Manager' on module '<stdin>'.
 #0 0x00000000020bdf43 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (opt+0x20bdf43)
 #1 0x00000000020bbc00 llvm::sys::RunSignalHandlers() (opt+0x20bbc00)
 #2 0x00000000020be3f6 SignalHandler(int) llvm/lib/Support/Signals.cpp:0:0
 #3 0x00007f15159bf330 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x10330)
 #4 0x00007f15143a3c37 raise /build/eglibc-ripdx6/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
 #5 0x00007f15143a7028 abort /build/eglibc-ripdx6/eglibc-2.19/stdlib/abort.c:91:0
 #6 0x00007f151439cbf6 __assert_fail_base /build/eglibc-ripdx6/eglibc-2.19/assert/assert.c:92:0
 #7 0x00007f151439cca2 (/lib/x86_64-linux-gnu/libc.so.6+0x2fca2)
 #8 0x000000000100ab4f (anonymous namespace)::CGPassManager::RefreshCallGraph(llvm::CallGraphSCC const&, llvm::CallGraph&, bool) llvm/lib/Analysis/CallGraphSCCPass.cpp:0:0
 #9 0x00000000010093ac (anonymous namespace)::CGPassManager::runOnModule(llvm::Module&) llvm/lib/Analysis/CallGraphSCCPass.cpp:0:0
#10 0x00000000018c6788 llvm::legacy::PassManagerImpl::run(llvm::Module&) (opt+0x18c6788)
#11 0x00000000007d06e5 main (opt+0x7d06e5)
#12 0x00007f151438ef45 __libc_start_main /build/eglibc-ripdx6/eglibc-2.19/csu/libc-start.c:321:0
#13 0x00000000007ba679 _start (opt+0x7ba679)
[1]    27229 abort      opt -S -openmp-opt-cgscc -aa-pipeline=basic-aa   -enable-new-pm=0

I'm not sure what the cause of this is, I committed rGb19136e35256c5b21aff93ea5b55b4c142408c40 as a quick work-around. I don't think this patch is the cause, I checked the revision prior to this one landing and it had the same issue. I'm not sure how much of an issue it is overall considering that the new pass manager is the default and hiding the memory transfer latency is an optional feature.

The following two tests are causing assertion failures when run with the legacy pass manager (force using -enable-new-pm=0).

  • Transforms/OpenMP/hide_mem_transfer_latency.ll
  • Transforms/OpenMP/values_in_offload_arrays.ll

Waiting on the bugzilla account request to make a ticket but here is the trace.

opt: llvm/lib/Analysis/CallGraphSCCPass.cpp:281: bool (anonymous namespace)::CGPassManager::RefreshCallGraph(const llvm::CallGraphSCC &, llvm::CallGraph &, bool): Assertion `!CheckingMode && "CallGraphSCCPass did not update the CallGraph correctly!"' failed.
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
Stack dump:
0.      Program arguments: opt -S -openmp-opt-cgscc -aa-pipeline=basic-aa -openmp-hide-memory-transfer-latency -enable-new-pm=0
1.      Running pass 'CallGraph Pass Manager' on module '<stdin>'.
 #0 0x00000000020bdf43 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (opt+0x20bdf43)
 #1 0x00000000020bbc00 llvm::sys::RunSignalHandlers() (opt+0x20bbc00)
 #2 0x00000000020be3f6 SignalHandler(int) llvm/lib/Support/Signals.cpp:0:0
 #3 0x00007f15159bf330 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x10330)
 #4 0x00007f15143a3c37 raise /build/eglibc-ripdx6/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
 #5 0x00007f15143a7028 abort /build/eglibc-ripdx6/eglibc-2.19/stdlib/abort.c:91:0
 #6 0x00007f151439cbf6 __assert_fail_base /build/eglibc-ripdx6/eglibc-2.19/assert/assert.c:92:0
 #7 0x00007f151439cca2 (/lib/x86_64-linux-gnu/libc.so.6+0x2fca2)
 #8 0x000000000100ab4f (anonymous namespace)::CGPassManager::RefreshCallGraph(llvm::CallGraphSCC const&, llvm::CallGraph&, bool) llvm/lib/Analysis/CallGraphSCCPass.cpp:0:0
 #9 0x00000000010093ac (anonymous namespace)::CGPassManager::runOnModule(llvm::Module&) llvm/lib/Analysis/CallGraphSCCPass.cpp:0:0
#10 0x00000000018c6788 llvm::legacy::PassManagerImpl::run(llvm::Module&) (opt+0x18c6788)
#11 0x00000000007d06e5 main (opt+0x7d06e5)
#12 0x00007f151438ef45 __libc_start_main /build/eglibc-ripdx6/eglibc-2.19/csu/libc-start.c:321:0
#13 0x00000000007ba679 _start (opt+0x7ba679)
[1]    27229 abort      opt -S -openmp-opt-cgscc -aa-pipeline=basic-aa   -enable-new-pm=0

Attributor bugs, I thought I fixed them. Do they still happen in ToT?