[OpenMP][JIT] Fixed a couple of issues in the initial implementation of JIT
authorShilei Tian <i@tianshilei.me>
Wed, 28 Dec 2022 19:40:46 +0000 (14:40 -0500)
committerShilei Tian <i@tianshilei.me>
Wed, 28 Dec 2022 19:40:59 +0000 (14:40 -0500)
This patch fixes a couple of issues:
1. Instead of using `llvm_unreachable` for those base virtual functions, unknown
   value will be returned. The previous method could cause runtime error for those
   targets where the image is not compatible but JIT is not implemented.
2. Fixed the type in CMake that causes the `Target` CMake variable is undefined.

Reviewed By: ye-luo

Differential Revision: https://reviews.llvm.org/D140732

openmp/libomptarget/plugins-nextgen/common/PluginInterface/CMakeLists.txt
openmp/libomptarget/plugins-nextgen/common/PluginInterface/JIT.cpp
openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.h

index 9abd430..8c9bbe3 100644 (file)
@@ -18,7 +18,7 @@ add_library(PluginInterface OBJECT
 # Only enable JIT for those targets that LLVM can support.
 string(TOUPPER "${LLVM_TARGETS_TO_BUILD}" TargetsSupported)
 foreach(Target ${TargetsSupported})
-  target_compile_definitions(PluginInterface PRIVATE "LIBOMPTARGET_JIT_${TARGET}")
+  target_compile_definitions(PluginInterface PRIVATE "LIBOMPTARGET_JIT_${Target}")
 endforeach()
 
 # This is required when using LLVM libraries.
index 0d42c6d..7cc1bb8 100644 (file)
@@ -69,7 +69,7 @@ void init(Triple TT) {
   }
 #endif
   if (!JITTargetInitialized) {
-    FAILURE_MESSAGE("unsupported JIT target");
+    FAILURE_MESSAGE("unsupported JIT target: %s\n", TT.str().c_str());
     abort();
   }
 
index 9f25301..836eb81 100644 (file)
@@ -380,7 +380,7 @@ struct GenericDeviceTy : public DeviceAllocatorTy {
 
   /// Get target architecture.
   virtual std::string getArch() const {
-    llvm_unreachable("device doesn't support JIT");
+    return "unknown";
   }
 
   /// Post processing after jit backend. The ownership of \p MB will be taken.
@@ -540,7 +540,7 @@ struct GenericPluginTy {
 
   /// Get the target triple of this plugin.
   virtual Triple::ArchType getTripleArch() const {
-    llvm_unreachable("target doesn't support jit");
+    return Triple::ArchType::UnknownArch;
   }
 
   /// Allocate a structure using the internal allocator.