[PATCH] D98740: [OpenMP] Change OMPIRBuilder to append function attributes

Joseph Huber via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 13 09:04:29 PDT 2021


jhuber6 added a comment.

In D98740#2684768 <https://reviews.llvm.org/D98740#2684768>, @sdmitriev wrote:

> With this change OMPIRBuilder may produce invalid IR if existing function attributes conflict with the new attributes it is trying to add. The problem can be reproduced on `llvm/test/Transforms/OpenMP/gpu_state_machine_function_ptr_replacement.ll` test where `__kmpc_global_thread_num` function is declared with the following attributes
>
>   declare i32 @__kmpc_global_thread_num(%struct.ident_t* nocapture readnone)
>
> With ‘optimistic’ attributes OMPIRBuilder will try to add ‘readonly’ to the function argument which would cause a verification error
>
>   $ opt -S -openmpopt -openmp-ir-builder-optimistic-attributes llvm/test/Transforms/OpenMP/gpu_state_machine_function_ptr_replacement.ll
>   Attributes 'readnone and readonly' are incompatible!
>   void (%struct.ident_t*, i32)* @__kmpc_barrier_simple_spmd
>   Attributes 'readnone and readonly' are incompatible!
>   i32 (%struct.ident_t*)* @__kmpc_global_thread_num
>   LLVM ERROR: Broken module found, compilation aborted!
>   PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
>
I believe this is a feature. If the attributes aren't compatible then one of them is wrong. I changed the test here, https://reviews.llvm.org/rGf047cb45bd38.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98740



More information about the llvm-commits mailing list