[Openmp-dev] r239337 - Remove unused variables '__kmp_build_check_*'

Peyton, Jonathan L jonathan.l.peyton at intel.com
Tue Jun 9 14:17:30 PDT 2015


They produce dummy dead code to detect compile time errors.  A contrived example is something like: 

KMP_BUILD_ASSERT(sizeof(kmp_int32) == sizeof(kmp_int64)); // This should produce a build failure. 

It used to be that they produce one-element, unused character arrays (when the assert is successful), or try to produce a "-1" element character array if the assert condition is false (which prompted a build failure because you can't create arrays with -1 elements).  I thought my change would get rid of these unused-variable warnings because now it creates an unused type.  I thought for sure that there were unused types in kmp.h, and I had not seen any warnings for unused types come up yet.  So, I made the assumption that unused types were ok, but they are unfortunately just a different warning as you have pointed out.

I do think we should use LLVM_ENABLE_ASSERTIONS like you have it, but instead of guarding each KMP_BUILD_ASSERT() statement inside the source files, we should change the definition of KMP_BUILD_ASSERT() based on KMP_USE_ASSERT (see how KMP_ASSERT() and KMP_DEBUG_ASSERT() are defined in kmp_debug.h).

-- Johnny

-----Original Message-----
From: Jack Howarth [mailto:howarth.mailing.lists at gmail.com] 
Sent: Tuesday, June 9, 2015 10:53 AM
To: Peyton, Jonathan L; openmp-dev at dcs-maillist2.engr.illinois.edu
Subject: Re: r239337 - Remove unused variables '__kmp_build_check_*'

Jonathan,
      Are you sure that the __kmp_build_check_* symbols generated from the KMP_BUILD_ASSERT macros aren't dead code in openmp? I find that the following patch eliminates the warnings....

warning: unused typedef '__kmp_build_check_492' [-Wunused-local-typedef]

when the toplevel llvm build is passed-DLLVM_ENABLE_ASSERTIONS=OFF but they still remain for -DLLVM_ENABLE_ASSERTIONS=ON.
                 Jack


On Mon, Jun 8, 2015 at 7:54 PM, Jack Howarth <howarth.mailing.lists at gmail.com> wrote:
> Jonathan,
>      The commit...
>
> http://lists.cs.uiuc.edu/pipermail/openmp-commits/2015-June/000339.htm
> l
>
> only converts the unused-variable warnings for __kmp_build_check_* 
> into unused typedef warnings. My initial inclination was to test 
> adding...
>
> #ifdef KMP_USE_ASSERT
> ...
> #endif
>
> preprocessor wrappers around all of the calls to the KMP_BUILD_ASSERT 
> macro. However this doesn't work since the openmp build passes  -D 
> KMP_USE_ASSERT to the compiler flags in the cmake build of openmp in 
> the llvm tree. This occurs for a cmake build which pass passed 
> -DLLVM_ENABLE_ASSERTIONS=OFF for the top-level cmake options.
> Shouldn't KMP_USE_ASSERT be disabled in that case or are those two 
> usages of asserts unrelated?
>               Jack




More information about the Openmp-dev mailing list