mirror of
https://github.com/Gericom/teak-llvm.git
synced 2025-06-23 13:35:42 -04:00

dead code. This is important for C++ templates that essentially compute the valid input in a way that is constant and will cause all the invalid cases to be dead code that is deleted. Code in the wild actually does this and GCC also accepts these kinds of patterns so it is important to support it. To make this work, we provide a non-error path to diagnose these issues, and use a default-error warning instead. This keeps the relatively strict handling but prevents nastiness like SFINAE on these errors. It also allows us to safely use the system to diagnose this only when it occurs at runtime (in emitted code). Entertainingly, this required fixing the syntax in various other ways for the x86 test because we never bothered to diagnose that the returns were invalid. Since debugging these compile failures was super confusing, I've also improved the diagnostic to actually say what the value was. Most of the checks I've made ignore this to simplify maintenance, but I've checked it in a few places to make sure the diagnsotic is working. Depends on D48462. Without that, we might actually crash some part of the compiler after bypassing the error here. Thanks to Richard, Ben Kramer, and especially Craig Topper for all the help here. Differential Revision: https://reviews.llvm.org/D48464 llvm-svn: 335309
52 lines
2.9 KiB
C
52 lines
2.9 KiB
C
// REQUIRES: powerpc-registered-target
|
|
// RUN: %clang_cc1 -target-feature +altivec -target-feature +htm \
|
|
// RUN: -triple powerpc64-unknown-unknown -DTEST_HTM -fsyntax-only \
|
|
// RUN: -verify %s
|
|
|
|
// RUN: %clang_cc1 -target-feature +altivec -target-feature +crypto \
|
|
// RUN: -triple powerpc64le-unknown-unknown -DTEST_CRYPTO -fsyntax-only \
|
|
// RUN: -verify %s
|
|
|
|
#ifdef TEST_HTM
|
|
void test_htm() {
|
|
__builtin_tbegin(4); // expected-error-re {{argument value {{.*}} is outside the valid range}}
|
|
__builtin_tend(-1); // expected-error-re {{argument value {{.*}} is outside the valid range}}
|
|
__builtin_tsr(55); // expected-error-re {{argument value {{.*}} is outside the valid range}}
|
|
__builtin_tabortwc(-5, 2, 3); // expected-error-re {{argument value {{.*}} is outside the valid range}}
|
|
__builtin_tabortdc(55, 2, 3); // expected-error-re {{argument value {{.*}} is outside the valid range}}
|
|
__builtin_tabortwci(-5, 2, 5); // expected-error-re {{argument value {{.*}} is outside the valid range}}
|
|
__builtin_tabortwci(5, 2, 55); // expected-error-re {{argument value {{.*}} is outside the valid range}}
|
|
__builtin_tabortdci(-5, 2, 5); // expected-error-re {{argument value {{.*}} is outside the valid range}}
|
|
__builtin_tabortdci(5, 2, 55); // expected-error-re {{argument value {{.*}} is outside the valid range}}
|
|
}
|
|
#endif
|
|
|
|
|
|
#ifdef TEST_CRYPTO
|
|
#include <altivec.h>
|
|
|
|
#define W_INIT { 0x01020304, 0x05060708, 0x090A0B0C, 0x0D0E0F10 };
|
|
#define D_INIT { 0x0102030405060708, 0x090A0B0C0D0E0F10 };
|
|
vector unsigned int test_vshasigmaw_or(void)
|
|
{
|
|
vector unsigned int a = W_INIT
|
|
vector unsigned int b = __builtin_crypto_vshasigmaw(a, 2, 15); // expected-error-re {{argument value {{.*}} is outside the valid range}}
|
|
vector unsigned int c = __builtin_crypto_vshasigmaw(a, -1, 15); // expected-error-re {{argument value {{.*}} is outside the valid range}}
|
|
vector unsigned int d = __builtin_crypto_vshasigmaw(a, 0, 85); // expected-error-re {{argument value {{.*}} is outside the valid range}}
|
|
vector unsigned int e = __builtin_crypto_vshasigmaw(a, 1, -15); // expected-error-re {{argument value {{.*}} is outside the valid range}}
|
|
return __builtin_crypto_vshasigmaw(a, 1, 15);
|
|
}
|
|
|
|
vector unsigned long long test_vshasigmad_or(void)
|
|
{
|
|
vector unsigned long long a = D_INIT
|
|
vector unsigned long long b = __builtin_crypto_vshasigmad(a, 2, 15); // expected-error-re {{argument value {{.*}} is outside the valid range}}
|
|
vector unsigned long long c = __builtin_crypto_vshasigmad(a, -1, 15); // expected-error-re {{argument value {{.*}} is outside the valid range}}
|
|
vector unsigned long long d = __builtin_crypto_vshasigmad(a, 0, 85); // expected-error-re {{argument value {{.*}} is outside the valid range}}
|
|
vector unsigned long long e = __builtin_crypto_vshasigmad(a, 1, -15); // expected-error-re {{argument value {{.*}} is outside the valid range}}
|
|
return __builtin_crypto_vshasigmad(a, 0, 15);
|
|
}
|
|
|
|
#endif
|
|
|