[Openmp-commits] [PATCH] D80222: Replace Clang's createRuntimeFunction with the definitions in OMPKinds.def

Joseph Huber via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Tue May 26 14:45:17 PDT 2020


jhuber6 marked 3 inline comments as done.
jhuber6 added inline comments.


================
Comment at: llvm/include/llvm/Frontend/OpenMP/OMPKinds.def:250
+__OMP_SIZE_TYPE(SizeTy)
+#undef __OMP_SIZE_TYPE
+
----------------
jdoerfert wrote:
> Why the indirection via `__OMP_SIZE_TYPE`? Wouldn't `OMP_TYPE(SizeTy, M.getDataLayout().getIntPtrType(Ctx))` suffice?
I think I did it just to make it more explicit while it was temporary, but now that we're defining it here there's no point, I'll change it.


================
Comment at: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:124
+    assert(FnTy == Fn->getFunctionType() &&
+           "Found OpenMP runtime function has mismatched types");
   }
----------------
jdoerfert wrote:
> I now think we either put the stuff in `#ifndef NDEBUG` or move the `FnTy =` into the first switch that does the lookup.
Yeah, I was wondering about the cost of the extra lookup. But we could definitely just get the type when we look up the function and just do a comparison in this branch.


================
Comment at: openmp/runtime/test/tasking/kmp_taskloop.c:100
         th_counter[i] = 0;
-    #pragma omp parallel num_threads(N)
+    #pragma omp parallel // num_threads(N)
     {
----------------
jdoerfert wrote:
> jhuber6 wrote:
> > I am not entirely sure why, but commenting this out causes the problem to go away. I tried adding proper names to the forward-declared functions but since clang already knew I had something called ident_t, I couldn't declare a new struct with the same name.
> This is not good. The difference should only be that the `kmpc_fork_call` has a different argument, right? Does the segfault happen at compile or runtime?
> 
> You can just use the ident_t clang created, right? Did you print the function names requested by clang as we discussed?
I added an assertion and debug statements. If I try to declare a struct named "Ident_t" I get the following error message in the seg-fault. I think the seg-fault is compile-time.

Found OpenMP runtime function __kmpc_global_thread_num with type i32 (%struct.ident_t.0*). Expected type is i32 (%struct.ident_t*)
clang: /home/jhuber/Documents/llvm-project/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:124: static llvm::Function* llvm::OpenMPIRBuilder::getOrCreateRuntimeFunction(llvm::Module&, llvm::omp::RuntimeFunction): Assertion `FnTy == Fn->getFunctionType() && "Found OpenMP runtime function has mismatched types"' failed.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80222/new/

https://reviews.llvm.org/D80222





More information about the Openmp-commits mailing list