cave in and initialize variables in gcc

This commit is contained in:
dzaima 2022-12-03 23:58:33 +02:00
parent 6ca5050f4d
commit af978bbc91
5 changed files with 11 additions and 7 deletions

View File

@ -1,6 +1,3 @@
#if defined(__GNUC__) && !defined(__clang__) // have to do this at the very top because diagnostic ignoring works based on the callee location, not caller
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#endif
#include "../core.h"
#include "../utils/each.h"
#include "../utils/file.h"
@ -150,12 +147,13 @@ static B m1c2(B t, B f, B w, B x) { // consumes w,x
#pragma GCC diagnostic push
#ifdef __clang__
#pragma GCC diagnostic ignored "-Wsometimes-uninitialized"
// no gcc case because there's no way to do it specifically for this segment of code; X##_csh is just initialized with an unused null pointer
#endif
#define S_SLICES(X) \
BSS2A X##_slc = TI(X,slice); \
usz X##_csz = 1; \
usz X##_cr = RNK(X)-1; \
ShArr* X##_csh; \
ShArr* X##_csh ONLY_GCC(=0); \
if (X##_cr>1) { \
X##_csh = m_shArr(X##_cr); \
PLAINLOOP for (usz i = 0; i < X##_cr; i++) { \

View File

@ -316,7 +316,7 @@ B rank_c1(Md2D* d, B x) { B f = d->f; B g = d->g;
return r;
}
usz csz = shProd(xsh, k, xr);
ShArr* csh;
ShArr* csh ONLY_GCC(= NULL);
if (cr>1) {
csh = m_shArr(cr);
shcpy(csh->a, xsh+k, cr);

View File

@ -139,7 +139,7 @@ B shape_c2(B t, B w, B x) {
} else {
SGetU(w)
i32 unkPos = -1;
i32 unkInd;
i32 unkInd ONLY_GCC(= 0);
bool bad=false, good=false;
for (i32 i = 0; i < nr; i++) {
B c = GetU(w, i);

View File

@ -268,6 +268,7 @@ static B compress_grouped(u64* wp, B x, usz wia, usz wsum, u8 xt) {
xp = tyany_ptr(x);
rp = m_tyarrv(&r,width,wsum,xt);
} else {
ONLY_GCC(r = m_f64(0);)
xp = (u8*)arr_bptr(x);
usz ria = wsum*csz;
if (xp != NULL) {
@ -709,7 +710,7 @@ B slash_c1(B t, B x) {
B slash_c2(B t, B w, B x) {
i32 wv = -1;
usz wia;
usz wia ONLY_GCC(= 0);
if (isArr(w)) {
if (depth(w)>1) goto base;
ur wr = RNK(w);

View File

@ -152,6 +152,11 @@ typedef double f64;
#define NOVECTORIZE
#endif
#define PLAINLOOP NOUNROLL NOVECTORIZE
#if EXACTLY_GCC
#define ONLY_GCC(X) X
#else
#define ONLY_GCC(X)
#endif
#define JOIN0(A,B) A##B
#define JOIN(A,B) JOIN0(A,B)