Currently the OMPIRBuilder overwrites the function's existing attributes
when it assigns the ones defined in OMPKinds.def. This changes the
behavior to append the current function's attributes with them instead.
Details
Details
Diff Detail
Diff Detail
- Repository
- rG LLVM Github Monorepo
Unit Tests
Unit Tests
Event Timeline
Comment Actions
LG, two nits.
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp | ||
---|---|---|
49 | no llvm:: above. call getAttributes only once. |
Comment Actions
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. …
Comment Actions
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.
no llvm:: above. call getAttributes only once.