This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP][DeviceRTL] Fix the issue that multiple calls to `omp_get_wtime` is optimized out by mistake
ClosedPublic

Authored by tianshilei1992 on Jul 20 2022, 8:04 AM.

Details

Summary

Multiple calls to omp_get_wtime could be optimized out due to the function
is mistakenly marked as readnone. This patch fixes the issue, and also add the
support to run optimization on libomptarget tests.

Diff Detail

Event Timeline

tianshilei1992 created this revision.Jul 20 2022, 8:04 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 20 2022, 8:04 AM
tianshilei1992 requested review of this revision.Jul 20 2022, 8:04 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 20 2022, 8:04 AM
jdoerfert accepted this revision.Jul 20 2022, 3:05 PM

LG, though we might want to make sure we mark it as readonly and inaccessible_mem_only in the openmp-opt pass (see OMPKinds.td)

This revision is now accepted and ready to land.Jul 20 2022, 3:05 PM

update OMPKinds.def

Herald added a project: Restricted Project. · View Herald TranscriptJul 22 2022, 3:33 AM

@tianshilei1992
This broke the build:

FAILED: lib/Frontend/OpenMP/CMakeFiles/LLVMFrontendOpenMP.dir/OMPIRBuilder.cpp.o 
CCACHE_CPP2=yes CCACHE_HASHDIR=yes /usr/bin/ccache /usr/bin/clang++ -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/sergei/llvm-project/cmake-build-release/lib/Frontend/OpenMP -I/home/sergei/llvm-project/llvm/lib/Frontend/OpenMP -I/home/sergei/llvm-project/cmake-build-release/include -I/home/sergei/llvm-project/llvm/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -fdiagnostics-color -ffunction-sections -fdata-sections -O3 -DNDEBUG -fPIC  -fno-exceptions -fno-rtti -UNDEBUG -std=c++14 -MD -MT lib/Frontend/OpenMP/CMakeFiles/LLVMFrontendOpenMP.dir/OMPIRBuilder.cpp.o -MF lib/Frontend/OpenMP/CMakeFiles/LLVMFrontendOpenMP.dir/OMPIRBuilder.cpp.o.d -o lib/Frontend/OpenMP/CMakeFiles/LLVMFrontendOpenMP.dir/OMPIRBuilder.cpp.o -c /home/sergei/llvm-project/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
In file included from /home/sergei/llvm-project/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:354:
/home/sergei/llvm-project/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def:684:1: error: use of undeclared identifier 'OMPRTL_omp_get_wtime'
__OMP_RTL_ATTRS(omp_get_wtime, GetterAttrs, AttributeSet(), ParamAttrs())
^
/home/sergei/llvm-project/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def:610:17: note: expanded from macro '__OMP_RTL_ATTRS'
  OMP_RTL_ATTRS(OMPRTL_##Name, FnAttrSet, RetAttrSet, ArgAttrSets)
                ^
<scratch space>:78:1: note: expanded from here
OMPRTL_omp_get_wtime
^
1 error generated.

@tianshilei1992
This broke the build:

FAILED: lib/Frontend/OpenMP/CMakeFiles/LLVMFrontendOpenMP.dir/OMPIRBuilder.cpp.o 
CCACHE_CPP2=yes CCACHE_HASHDIR=yes /usr/bin/ccache /usr/bin/clang++ -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/sergei/llvm-project/cmake-build-release/lib/Frontend/OpenMP -I/home/sergei/llvm-project/llvm/lib/Frontend/OpenMP -I/home/sergei/llvm-project/cmake-build-release/include -I/home/sergei/llvm-project/llvm/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -fdiagnostics-color -ffunction-sections -fdata-sections -O3 -DNDEBUG -fPIC  -fno-exceptions -fno-rtti -UNDEBUG -std=c++14 -MD -MT lib/Frontend/OpenMP/CMakeFiles/LLVMFrontendOpenMP.dir/OMPIRBuilder.cpp.o -MF lib/Frontend/OpenMP/CMakeFiles/LLVMFrontendOpenMP.dir/OMPIRBuilder.cpp.o.d -o lib/Frontend/OpenMP/CMakeFiles/LLVMFrontendOpenMP.dir/OMPIRBuilder.cpp.o -c /home/sergei/llvm-project/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
In file included from /home/sergei/llvm-project/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:354:
/home/sergei/llvm-project/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def:684:1: error: use of undeclared identifier 'OMPRTL_omp_get_wtime'
__OMP_RTL_ATTRS(omp_get_wtime, GetterAttrs, AttributeSet(), ParamAttrs())
^
/home/sergei/llvm-project/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def:610:17: note: expanded from macro '__OMP_RTL_ATTRS'
  OMP_RTL_ATTRS(OMPRTL_##Name, FnAttrSet, RetAttrSet, ArgAttrSets)
                ^
<scratch space>:78:1: note: expanded from here
OMPRTL_omp_get_wtime
^
1 error generated.

Thanks for the info. I reverted it.

tianshilei1992 reopened this revision.Jul 22 2022, 8:53 AM
This revision is now accepted and ready to land.Jul 22 2022, 8:53 AM

fix build issue

This revision was landed with ongoing or failed builds.Jul 22 2022, 10:46 AM
This revision was automatically updated to reflect the committed changes.