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

Sergey Dmitriev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 12 19:56:51 PDT 2021


sdmitriev added a comment.

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.
  …


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