[PATCH] D106707: [OpenMP] Introduce RAII to protect certain RTL calls from DCE
Joseph Huber via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Jul 25 11:16:10 PDT 2021
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG58725c12bb27: [OpenMP] Introduce RAII to protect certain RTL calls from DCE (authored by jhuber6).
Changed prior to commit:
https://reviews.llvm.org/D106707?vs=361515&id=361516#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D106707/new/
https://reviews.llvm.org/D106707
Files:
llvm/lib/Transforms/IPO/OpenMPOpt.cpp
Index: llvm/lib/Transforms/IPO/OpenMPOpt.cpp
===================================================================
--- llvm/lib/Transforms/IPO/OpenMPOpt.cpp
+++ llvm/lib/Transforms/IPO/OpenMPOpt.cpp
@@ -1760,6 +1760,32 @@
[&]() { return RemarkCB(RemarkKind(DEBUG_TYPE, RemarkName, F)); });
}
+ /// RAII struct to temporarily change an RTL function's linkage to external.
+ /// This prevents it from being mistakenly removed by other optimizations.
+ struct ExternalizationRAII {
+ ExternalizationRAII(OMPInformationCache &OMPInfoCache,
+ RuntimeFunction RFKind)
+ : OMPInfoCache(OMPInfoCache),
+ Declaration(OMPInfoCache.RFIs[RFKind].Declaration) {
+ if (!Declaration)
+ return;
+
+ LinkageType = Declaration->getLinkage();
+ Declaration->setLinkage(GlobalValue::ExternalLinkage);
+ }
+
+ ~ExternalizationRAII() {
+ if (!Declaration)
+ return;
+
+ Declaration->setLinkage(LinkageType);
+ }
+
+ OMPInformationCache &OMPInfoCache;
+ Function *Declaration;
+ GlobalValue::LinkageTypes LinkageType;
+ };
+
/// The underlying module.
Module &M;
@@ -1784,6 +1810,14 @@
if (SCC.empty())
return false;
+ // Temporarily make these function have external linkage so the Attributor
+ // doesn't remove them when we try to look them up later.
+ ExternalizationRAII Parallel(OMPInfoCache, OMPRTL___kmpc_kernel_parallel);
+ ExternalizationRAII EndParallel(OMPInfoCache,
+ OMPRTL___kmpc_kernel_end_parallel);
+ ExternalizationRAII BarrierSPMD(OMPInfoCache,
+ OMPRTL___kmpc_barrier_simple_spmd);
+
registerAAs(IsModulePass);
ChangeStatus Changed = A.run();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106707.361516.patch
Type: text/x-patch
Size: 1777 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210725/1b1840dc/attachment.bin>
More information about the llvm-commits
mailing list