-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove usage of __builtin_constant_p under IBM XL #1907
Remove usage of __builtin_constant_p under IBM XL #1907
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1907 +/- ##
=======================================
Coverage 86.49% 86.49%
=======================================
Files 131 131
Lines 3900 3900
=======================================
Hits 3373 3373
Misses 527 527 |
🤦 It shouldn't evaluate the expression at all, it is just an unevaluated context that allows lambdas (unlike |
Don't touch your face! 🙂 I didn't actually realize how recently this issue was introduced. |
--- Improvements --- * Running tests in random order (`--order rand`) has been reworked significantly (#1908) * Given same seed, all platforms now produce the same order * Given same seed, the relative order of tests does not change if you select only a subset of them * Vector matchers support custom allocators (#1909) * `|` and `&` (bitwise or and bitwise and) are now supported in `CHECK` and `REQUIRE` * The resulting type must be convertible to `bool` --- Fixes --- * Fixed computation of benchmarking column widths in ConsoleReporter (#1885, #1886) * Suppressed clang-tidy's `cppcoreguidelines-pro-type-vararg` in assertions (#1901) * It was a false positive trigered by the new warning support workaround * Fixed bug in test specification parser handling of OR'd patterns using escaping (#1905) --- Miscellaneous --- * Worked around IBM XL's codegen bug (#1907) * It would emit code for _destructors_ of temporaries in an unevaluated context * Improved detection of stdlib's support for `std::uncaught_exceptions` (#1911)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've noted that the clang compiler has a similar problem. You may want to check clang instead (which the XL compiler also defines) just in case you ever use that compiler. I'd also suggest opening a bugzilla report with LLVM.
Oh, I had assumed that this had been tested in clang. I should have checked. |
@cebowler I can't repro this on either Apple's Clang distribution or Clang 9.0. Using this code: #include <iostream>
class Foo {
public:
Foo() {
std::cout << "Foo::Foo" << std::endl;
}
~Foo() {
std::cout << "Foo::~Foo" << std::endl;
}
};
int main(int argc, char *argv[]) {
__builtin_constant_p(Foo());
} If clang exhibited the bug, I would expect to see the following output:
|
Tried it on a Power9 system with clang 7 and clang 8 and couldn't reproduce the issue. Only with an XL compiler. |
Thanks for checking. The similar Clang issues that have been reported have also been fixed: |
Must have been introduced fairly recently - didn't have a clang 10.0 or nightly build lying around to test against. Our IBM XL compiler is fairly recent, so not surprising it would have picked up that issue. |
As far as I can see, the linked issues are about when |
That's not what I see. Please refer to the linked bug report: https://llvm.org/PR45535. |
That said, the implementation in XL does not act exactly the same as in Clang. |
@hubert-reinterpretcast Well, I stand corrected. Anyway, I would welcome a PR for specific version when IBM XL fixes this. As for Clang, it currently seems to work properly, so until bug reports with specific version come in, I am going to keep the |
btw, IBM has fixed this in a recent compiler release, at least to us. At some point this could be re-enabled for certain IBM XL versions if somebody is so inclined. |
Yeah, I am open to a follow-up PR, but I don't intend to get hold of IBM XL to test it myself. |
Description
This change eliminates use of the
__builtin_constant_p
intrinsic for IBM XL compilers that use the clang front end. Under XL, code is generated to call destructors for temporaries in expressions passed to__builtin_constant_p
, but the code to initialize those temporaries is not emitted. For example, IBM XL will generate a call tostd::string::~string
for the following code:This often results in a segfault in the case of
std::string::~string
, asfree
will likely be called on an invalid address.Concretely, this code would result in a segfault:
Previously, this the tests would fail when building with IBM XL 16.1.1.7. Now they all pass.
The bug has been reported to IBM. I will re-enable this for future versions of IBM XL when the problem is fixed.