[OpenMP] Make OpenMPOpt aware of the OpenMP runtime's status
authorJoseph Huber <jhuber6@vols.utk.edu>
Thu, 26 Jan 2023 17:13:56 +0000 (11:13 -0600)
committerJoseph Huber <jhuber6@vols.utk.edu>
Thu, 26 Jan 2023 19:23:44 +0000 (13:23 -0600)
commit0bdde9dfb9b1dbfabee147c196db820e1f5dca1f
tree29a898e9119b8f0d567b2fdbaadefbd87ba99171
parentb4b06d8ff82647824a658356e1e8f7dc9d1ac7d2
[OpenMP] Make OpenMPOpt aware of the OpenMP runtime's status

The `OpenMPOpt` pass contains optimizations that generate new calls into
the OpenMP runtime. This causes problems if we are in a state where the
runtime has already been linked statically. Generating these new calls
will result in them never being resolved. We should indicate if we are
in a "post-link" LTO phase and prevent OpenMPOpt from generating new
runtime calls.

Generally, it's not desireable for passes to maintain state about the
context in which they're called. But this is the only reasonable
solution to static linking when we have a pass that generates new
runtime calls.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D142646
llvm/include/llvm/Transforms/IPO/OpenMPOpt.h
llvm/lib/Passes/PassBuilderPipelines.cpp
llvm/lib/Passes/PassRegistry.def
llvm/lib/Transforms/IPO/OpenMPOpt.cpp
llvm/test/Transforms/OpenMP/custom_state_machines_pre_lto.ll
llvm/test/Transforms/OpenMP/spmdization.ll