Open
Description
After commit 56af0e9, there is a build error in the Linux kernel because a call to a function declared with __attribute__((__error__(...)))
(the basis of the kernel's compile time assertion macro BUILD_BUG_ON()
, which is optimization sensitive) is no longer eliminated when -fprofile-instr-generate
(the kernel's CONFIG_GCOV
option) is enabled for the kernel's User Mode Linux target, which was originally reported here, which shows some of the kernel's code, which can be further explored here.
cvise
spits out:
long const_test_bit_addr, __attribute__test_bitmap_const_eval_initvar;
static long exp2[] = {};
_Bool __attribute__test_bitmap_const_eval___trans_tmp_1;
void generic___change_bit() {}
void ___set_bit(long *);
void ___change_bit();
void bitmap_complement(long *dst, long *src) { *dst = ~*src; }
void bitmap_set(int nbits) {
int start = nbits && 1;
if (nbits && nbits && start)
;
}
void bitmap_clear(long *map) {
int nbits = 0, start = 0;
if (__builtin_constant_p(0) && start == 0 && __builtin_constant_p(nbits) &&
nbits == 0)
;
}
void bitmap_replace(long *new) {}
void __attribute__test_bitmap_const_eval() {
long bitmap[1];
long bitopvar = 0, var = 0, p = const_test_bit_addr, mask = 0, val = p;
bitmap_clear(bitmap);
__attribute__test_bitmap_const_eval___trans_tmp_1 = val & mask;
if (!(7 && (long)bitmap != 0 && (long)bitmap && *bitmap
? __attribute__test_bitmap_const_eval___trans_tmp_1
: 0))
bitmap_set(2);
1 && (long)&bitopvar != 0 && (long)&bitopvar &&__builtin_constant_p(bitopvar)
? generic___change_bit()
: ___change_bit;
if (var)
var = __attribute__test_bitmap_const_eval_initvar;
if (__attribute__test_bitmap_const_eval_initvar)
;
__attribute__((__noreturn__)) void __compiletime_assert_154()
__attribute__((__error__("BUILD_BUG_ON failed: "
"!__builtin_constant_p(~var)")));
if (!__builtin_constant_p(~var))
__compiletime_assert_154();
bitmap_complement(&var, &var);
__builtin_constant_p(var) ?: ___set_bit(&var);
bitmap_replace(&exp2[0]);
}
@ 5534d1d:
$ clang --target=x86_64-linux-gnu -O2 -c -o /dev/null test_bitmap.i
$ clang --target=x86_64-linux-gnu -O2 -c -o /dev/null test_bitmap.i -fprofile-instr-generate
@ 56af0e9:
$ clang --target=x86_64-linux-gnu -O2 -c -o /dev/null test_bitmap.i
$ clang --target=x86_64-linux-gnu -O2 -c -o /dev/null test_bitmap.i -fprofile-instr-generate
test_bitmap.i:40:5: error: call to '__compiletime_assert_154' declared with 'error' attribute: BUILD_BUG_ON failed: !__builtin_constant_p(~var)
__compiletime_assert_154();
^
1 error generated.
Bisect log:
# bad: [4706251a3186c34da0ee8fd894f7e6b095da8fdc] Clear release notes for 18.x
# good: [603c286334b07f568d39f6706c848f576914f323] Bump the trunk major version to 17
git bisect start 'llvmorg-18-init' 'llvmorg-17-init'
# bad: [37cf4fc6cef9f2f50e15622a1bdecc89ea6ddd23] [RISCV] Consolidate legality checking for strided load/store [nfc]
git bisect bad 37cf4fc6cef9f2f50e15622a1bdecc89ea6ddd23
# good: [a031f72187ce495b9faa4ccf99b1e901a3872f4b] [libc] Correctly pass the compile options to the internal GPU compilation
git bisect good a031f72187ce495b9faa4ccf99b1e901a3872f4b
# good: [3c8ead2662ac4a223467007c340c9f9a4b2b38af] [clang][dataflow] Eliminate code duplication in Environment::createValueUnlessSelfReferential().
git bisect good 3c8ead2662ac4a223467007c340c9f9a4b2b38af
# good: [8bddb13c2470b95651955c61913627b31e9c99d6] [lldb] Change parameter type of StructuredData::ParseJSON
git bisect good 8bddb13c2470b95651955c61913627b31e9c99d6
# good: [d42ba4c2a65ad782b870a26ca86c45c30ed30fa5] [bazel] update for ba38640b9901d239e32e12c6569f7364d00af922
git bisect good d42ba4c2a65ad782b870a26ca86c45c30ed30fa5
# good: [9d53db21d7bd67ac5e13495df12a048d3062691b] ValueTracking: Add new tests for computeKnownFPClass copysign handling
git bisect good 9d53db21d7bd67ac5e13495df12a048d3062691b
# good: [25462d14b17beb0be10deeea9f9c6c2739051135] [bazel][mlir] update build for mem2reg f88f8fd0bca34dc8e5571cb828b1a159a50fd504
git bisect good 25462d14b17beb0be10deeea9f9c6c2739051135
# good: [bf199576f93191976da2aa6299fe490e14360f82] [libc++][PSTL][NFC] Rename to `pstl/` to `__pstl/`
git bisect good bf199576f93191976da2aa6299fe490e14360f82
# good: [9391177cbcb0e5fb051f7a867683d7a0817f1648] [Assignment Tracking] Check getTypeSizeInBits result for scalable vector types
git bisect good 9391177cbcb0e5fb051f7a867683d7a0817f1648
# good: [047a41446d2bc8d2950ee8cf8e5b6446ebefc9b1] [polly] Drop redundant use of -instnamer in polly MemAccess lit tests
git bisect good 047a41446d2bc8d2950ee8cf8e5b6446ebefc9b1
# good: [5ff493df29cc1eee162ec8308b3a5b4706d300bf] [ARM] Update and regenerate pred-selectop test. NFC
git bisect good 5ff493df29cc1eee162ec8308b3a5b4706d300bf
# good: [5534d1d834c25ec6a3755a44b46e2489b7d0ccf9] [CSE] Precommit an AMDGPU test case for D149348
git bisect good 5534d1d834c25ec6a3755a44b46e2489b7d0ccf9
# bad: [d321f3aa64b4eaedd790dafe974cfdc0517cb22b] [ARM] Enable shouldFoldSelectWithIdentityConstant for MVE
git bisect bad d321f3aa64b4eaedd790dafe974cfdc0517cb22b
# bad: [56af0e913ce7ec29690cc7295d75fc5573153bbf] [EarlyCSE] Do not CSE convergent calls in different basic blocks
git bisect bad 56af0e913ce7ec29690cc7295d75fc5573153bbf
# first bad commit: [56af0e913ce7ec29690cc7295d75fc5573153bbf] [EarlyCSE] Do not CSE convergent calls in different basic blocks
cc @jayfoad