This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP] Introduce RAII to protect certain RTL calls from DCE
ClosedPublic

Authored by jhuber6 on Jul 23 2021, 1:44 PM.

Details

Summary

This patch introduces a new RAII struct that will temporarily make an OpenMP
RTL function have external linkage. This is done before the attributor is
invoked to prevent it from incorrectly removing some function definitions that
we will use later. For example, if we determine all calls to one function are
dead, because it has internal linkage it can safely be removed. Later when we
try to get an instance to that function to modify the source using
getOrCreateRuntimeFunction we will then get an empty declaration for that
function that won't be defined anywhere. This patch prevents this from
occurring.

Diff Detail

Event Timeline

jhuber6 created this revision.Jul 23 2021, 1:44 PM
jhuber6 requested review of this revision.Jul 23 2021, 1:44 PM
Herald added a reviewer: baziotis. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
jdoerfert accepted this revision.Jul 24 2021, 10:26 PM

LG, two nits.

llvm/lib/Transforms/IPO/OpenMPOpt.cpp
1787

no need to store OMPInfoCache

1818–1821

_tgt_... are not device runtime functions, no need to have them here.

This revision is now accepted and ready to land.Jul 24 2021, 10:26 PM
jdoerfert added inline comments.Jul 25 2021, 10:58 AM
llvm/lib/Transforms/IPO/OpenMPOpt.cpp
1818–1821

You need to create objects with a lifetime that matches the scope. You are creating unnamed objects here that die right away.

jhuber6 updated this revision to Diff 361515.Jul 25 2021, 11:10 AM

Fixing RAII and removing unnecessary functions.

This revision was landed with ongoing or failed builds.Jul 25 2021, 11:16 AM
This revision was automatically updated to reflect the committed changes.