This is an archive of the discontinued LLVM Phabricator instance.

[libcxx] Improve testing in #ifdef.
AbandonedPublic

Authored by Mordante on Aug 14 2021, 5:23 AM.

Details

Reviewers
Conanap
ldionne
Group Reviewers
Restricted Project
Summary

Fixes midpoint error of PR51430.

Diff Detail

Event Timeline

Mordante requested review of this revision.Aug 14 2021, 5:23 AM
Mordante created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptAug 14 2021, 5:23 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript
Quuxplusone added inline comments.
libcxx/test/std/numerics/numeric.ops/numeric.ops.midpoint/midpoint.float.pass.cpp
95

Who sets the __LONG_DOUBLE_128__ macro — some vendor's compiler?
Are you sure this doesn't need to be

#if defined(__PPC__) && (defined(__LONG_DOUBLE_128__) && __LONG_DOUBLE_128__) && !(defined(__LONG_DOUBLE_IEEE128__) && __LONG_DOUBLE_IEEE128__)

to deal with the (hypothetical but I-don't-know-if-impossible) case of either __LONG_DOUBLE_128__ or __LONG_DOUBLE_IEEE128__ being defined as 0?

Mordante added inline comments.Aug 16 2021, 10:38 AM
libcxx/test/std/numerics/numeric.ops/numeric.ops.midpoint/midpoint.float.pass.cpp
95

Due to the bug report is for the release I strongly suspect the compiler in question is Clang.

Based on Clang's implementation I think the current approach is correct.
clang/lib/Basic/Targets/PPC.cpp:297

if (LongDoubleWidth == 128) {
  Builder.defineMacro("__LONG_DOUBLE_128__");
  Builder.defineMacro("__LONGDOUBLE128");
  if (Opts.PPCIEEELongDouble)
    Builder.defineMacro("__LONG_DOUBLE_IEEE128__");
  else
    Builder.defineMacro("__LONG_DOUBLE_IBM128__");
}

I still would like @Conanap to validate this fixes that build error on PPC.

ldionne accepted this revision.Aug 17 2021, 3:19 PM
ldionne added a subscriber: ldionne.

Can you link to the bug report? LGTM, thanks a lot for handling this.

This revision is now accepted and ready to land.Aug 17 2021, 3:19 PM

Sorry for the late reply! There were some internal discussions before we came to a conclusion.

While this patch works, __LONG_DOUBLE_128__ should be defined (or at least we haven't hit a case where it's undefined), so we would prefer something similar:

#if defined(__PPC__) && __LONG_DOUBLE_128__ && (!defined(__LONG_DOUBLE_IEEE128__) || !__LONG_DOUBLE_IEEE128__)

The compiler in question is indeed Clang.

I have a patch of the preferred implementation here: https://reviews.llvm.org/D108352

Thanks for the help!

@Conanap I'm a bit confused now. Do you want me to fix this patch or do you want to land your patch?

@Conanap I'm a bit confused now. Do you want me to fix this patch or do you want to land your patch?

My patched is preferred here, thanks! I appreciate the work you put in though.

Mordante abandoned this revision.Aug 19 2021, 11:44 AM

@Conanap I'm a bit confused now. Do you want me to fix this patch or do you want to land your patch?

My patched is preferred here, thanks! I appreciate the work you put in though.

No problem, but next time it would be easier to just add review comments to an existing review instead of creating a new review.