[llvm] dce6bc1 - [OpenMP][FIX] remove unused variable and long if-else chain

Johannes Doerfert via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 11 00:40:00 PDT 2020


Author: Johannes Doerfert
Date: 2020-07-11T02:37:57-05:00
New Revision: dce6bc18c4e1d086182f9faa3f984912566a3c20

URL: https://github.com/llvm/llvm-project/commit/dce6bc18c4e1d086182f9faa3f984912566a3c20
DIFF: https://github.com/llvm/llvm-project/commit/dce6bc18c4e1d086182f9faa3f984912566a3c20.diff

LOG: [OpenMP][FIX] remove unused variable and long if-else chain

MSVC throws an error if you use "too many" if-else in a row:
  `Frontend/OpenMP/OMPKinds.def(570): fatal error C1061: compiler limit:
    blocks nested too deeply`
We work around it now...

Added: 
    

Modified: 
    llvm/lib/Transforms/IPO/OpenMPOpt.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
index 7d93e78357b3..f25e95466407 100644
--- a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
+++ b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
@@ -1397,9 +1397,17 @@ void OpenMPInModule::identifyKernels(Module &M) {
 bool llvm::omp::containsOpenMP(Module &M, OpenMPInModule &OMPInModule) {
   if (OMPInModule.isKnown())
     return OMPInModule;
+
+  // MSVC doesn't like long if-else chains for some reason and instead just
+  // issues an error. Work around it..
+  do {
 #define OMP_RTL(_Enum, _Name, ...)                                             \
-  else if (M.getFunction(_Name)) OMPInModule = true;
+  if (M.getFunction(_Name)) {                                                  \
+    OMPInModule = true;                                                        \
+    break;                                                                     \
+  }
 #include "llvm/Frontend/OpenMP/OMPKinds.def"
+  } while (false);
 
   // Identify kernels once. TODO: We should split the OMPInformationCache into a
   // module and an SCC part. The kernel information, among other things, could


        


More information about the llvm-commits mailing list