Index: llvm-toolchain-snapshot_10~+20191020075550+5b8546023f3/openmp/runtime/src/kmp.h
===================================================================
--- llvm-toolchain-snapshot_10~+20191020075550+5b8546023f3.orig/openmp/runtime/src/kmp.h
+++ llvm-toolchain-snapshot_10~+20191020075550+5b8546023f3/openmp/runtime/src/kmp.h
@@ -1142,6 +1142,10 @@ extern kmp_uint64 __kmp_now_nsec();
 /* TODO: tune for KMP_OS_OPENBSD */
 #define KMP_INIT_WAIT 1024U /* initial number of spin-tests   */
 #define KMP_NEXT_WAIT 512U /* susequent number of spin-tests */
+#elif KMP_OS_KFREEBSD
+/* TODO: tune for KMP_OS_KFREEBSD */
+#define KMP_INIT_WAIT 1024U /* initial number of spin-tests   */
+#define KMP_NEXT_WAIT 512U /* susequent number of spin-tests */
 #endif
 
 #if KMP_ARCH_X86 || KMP_ARCH_X86_64
Index: llvm-toolchain-snapshot_10~+20191020075550+5b8546023f3/openmp/runtime/src/kmp_ftn_entry.h
===================================================================
--- llvm-toolchain-snapshot_10~+20191020075550+5b8546023f3.orig/openmp/runtime/src/kmp_ftn_entry.h
+++ llvm-toolchain-snapshot_10~+20191020075550+5b8546023f3/openmp/runtime/src/kmp_ftn_entry.h
@@ -531,7 +531,7 @@ int FTN_STDCALL KMP_EXPAND_NAME(FTN_GET_
   int gtid;
 
 #if KMP_OS_DARWIN || KMP_OS_DRAGONFLY || KMP_OS_FREEBSD || KMP_OS_NETBSD ||    \
-        KMP_OS_HURD
+        KMP_OS_HURD || KMP_OS_KFREEBSD
   gtid = __kmp_entry_gtid();
 #elif KMP_OS_WINDOWS
   if (!__kmp_init_parallel ||
Index: llvm-toolchain-snapshot_10~+20191020075550+5b8546023f3/openmp/runtime/src/kmp_platform.h
===================================================================
--- llvm-toolchain-snapshot_10~+20191020075550+5b8546023f3.orig/openmp/runtime/src/kmp_platform.h
+++ llvm-toolchain-snapshot_10~+20191020075550+5b8546023f3/openmp/runtime/src/kmp_platform.h
@@ -18,6 +18,7 @@
 #define KMP_OS_LINUX 0
 #define KMP_OS_DRAGONFLY 0
 #define KMP_OS_FREEBSD 0
+#define KMP_OS_KFREEBSD 0
 #define KMP_OS_NETBSD 0
 #define KMP_OS_OPENBSD 0
 #define KMP_OS_DARWIN 0
@@ -56,6 +57,11 @@
 #define KMP_OS_FREEBSD 1
 #endif
 
+#if (defined __FreeBSD_kernel__)
+#undef KMP_OS_KFREEBSD
+#define KMP_OS_KFREEBSD 1
+#endif
+
 #if (defined __NetBSD__)
 #undef KMP_OS_NETBSD
 #define KMP_OS_NETBSD 1
@@ -78,12 +84,12 @@
 
 #if (1 !=                                                                      \
      KMP_OS_LINUX + KMP_OS_DRAGONFLY + KMP_OS_FREEBSD + KMP_OS_NETBSD +        \
-         KMP_OS_OPENBSD + KMP_OS_DARWIN + KMP_OS_WINDOWS + KMP_OS_HURD)
+         KMP_OS_OPENBSD + KMP_OS_DARWIN + KMP_OS_WINDOWS + KMP_OS_HURD + KMP_OS_KFREEBSD)
 #error Unknown OS
 #endif
 
 #if KMP_OS_LINUX || KMP_OS_DRAGONFLY || KMP_OS_FREEBSD || KMP_OS_NETBSD ||     \
-        KMP_OS_OPENBSD || KMP_OS_DARWIN || KMP_OS_HURD
+        KMP_OS_OPENBSD || KMP_OS_DARWIN || KMP_OS_HURD || KMP_OS_KFREEBSD
 #undef KMP_OS_UNIX
 #define KMP_OS_UNIX 1
 #endif
Index: llvm-toolchain-snapshot_10~+20191020075550+5b8546023f3/openmp/runtime/src/kmp_runtime.cpp
===================================================================
--- llvm-toolchain-snapshot_10~+20191020075550+5b8546023f3.orig/openmp/runtime/src/kmp_runtime.cpp
+++ llvm-toolchain-snapshot_10~+20191020075550+5b8546023f3/openmp/runtime/src/kmp_runtime.cpp
@@ -8114,7 +8114,7 @@ __kmp_determine_reduction_method(
     KMP_ARCH_MIPS64 || KMP_ARCH_RISCV64
 
 #if KMP_OS_LINUX || KMP_OS_DRAGONFLY || KMP_OS_FREEBSD || KMP_OS_NETBSD ||     \
-    KMP_OS_OPENBSD || KMP_OS_WINDOWS || KMP_OS_DARWIN || KMP_OS_HURD
+    KMP_OS_OPENBSD || KMP_OS_WINDOWS || KMP_OS_DARWIN || KMP_OS_HURD || KMP_OS_KFREEBSD
 
     int teamsize_cutoff = 4;
 
@@ -8142,7 +8142,7 @@ __kmp_determine_reduction_method(
 
 #elif KMP_ARCH_X86 || KMP_ARCH_ARM || KMP_ARCH_AARCH || KMP_ARCH_MIPS
 
-#if KMP_OS_LINUX || KMP_OS_FREEBSD || KMP_OS_WINDOWS || KMP_OS_HURD
+#if KMP_OS_LINUX || KMP_OS_FREEBSD || KMP_OS_WINDOWS || KMP_OS_HURD || KMP_OS_KFREEBSD
 
     // basic tuning
 
Index: llvm-toolchain-snapshot_10~+20191020075550+5b8546023f3/openmp/runtime/src/z_Linux_util.cpp
===================================================================
--- llvm-toolchain-snapshot_10~+20191020075550+5b8546023f3.orig/openmp/runtime/src/z_Linux_util.cpp
+++ llvm-toolchain-snapshot_10~+20191020075550+5b8546023f3/openmp/runtime/src/z_Linux_util.cpp
@@ -472,7 +472,7 @@ void __kmp_terminate_thread(int gtid) {
 static kmp_int32 __kmp_set_stack_info(int gtid, kmp_info_t *th) {
   int stack_data;
 #if KMP_OS_LINUX || KMP_OS_DRAGONFLY || KMP_OS_FREEBSD || KMP_OS_NETBSD ||     \
-        KMP_OS_HURD
+        KMP_OS_HURD || KMP_OS_KFREEBSD
   pthread_attr_t attr;
   int status;
   size_t size = 0;
@@ -526,7 +526,7 @@ static void *__kmp_launch_worker(void *t
 #endif /* KMP_BLOCK_SIGNALS */
   void *exit_val;
 #if KMP_OS_LINUX || KMP_OS_DRAGONFLY || KMP_OS_FREEBSD || KMP_OS_NETBSD ||     \
-        KMP_OS_OPENBSD || KMP_OS_HURD
+        KMP_OS_OPENBSD || KMP_OS_HURD || KMP_OS_KFREEBSD
   void *volatile padding = 0;
 #endif
   int gtid;
@@ -1798,7 +1798,7 @@ static int __kmp_get_xproc(void) {
   int r = 0;
 
 #if KMP_OS_LINUX || KMP_OS_DRAGONFLY || KMP_OS_FREEBSD || KMP_OS_NETBSD ||     \
-        KMP_OS_OPENBSD || KMP_OS_HURD
+        KMP_OS_OPENBSD || KMP_OS_HURD || KMP_OS_KFREEBSD
 
   r = sysconf(_SC_NPROCESSORS_ONLN);
 
@@ -2042,7 +2042,7 @@ int __kmp_is_address_mapped(void *addr)
   // Free resources.
   fclose(file);
   KMP_INTERNAL_FREE(name);
-#elif KMP_OS_FREEBSD
+#elif KMP_OS_FREEBSD || KMP_OS_KFREEBSD
   char *buf;
   size_t lstsz;
   int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_VMMAP, getpid()};
