-
Notifications
You must be signed in to change notification settings - Fork 20
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
-Wmaybe-uninitialized #428
base: dev
Are you sure you want to change the base?
Conversation
const N* n; | ||
if (isXtn2) { | ||
d = sourceValues[0].getAsVector<D>(); | ||
n = sourceValues[1].getAsVector<N>(); | ||
} else { | ||
d = {}; | ||
n = sourceValues[0].getAsVector<N>(); | ||
} | ||
|
||
D out[16 / sizeof(D)] = {0}; | ||
int index = 0; | ||
|
||
for (int i = 0; i < I; i++) { | ||
if (isXtn2 & (i < (I / 2))) { | ||
assert(isXtn2 && "isXtn2 is false so d is not initialised"); | ||
out[i] = d[i]; | ||
} else { | ||
out[i] = static_cast<D>(n[index]); |
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.
@FinnWilkinson this is a temporary solution as I didn't want to fiddle too much with the for loop below. If you have a preferred solution then feel free to push a commit implementing that.
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 think this proposed solution is good.
From our offline discussion aboout line 801 on whether it should be isXtn2 & (i < (I / 2))
or isXtn2 && (i < (I / 2))
, given both arguments are bools the functionality would be the same, but using &&
may be marginally clearer of this fact?
@@ -128,7 +128,7 @@ class RegisterValue { | |||
|
|||
/** The underlying local member value. Aligned to 8 bytes to prevent | |||
* potential alignment issue when casting. */ | |||
alignas(8) char value[MAX_LOCAL_BYTES]; | |||
alignas(8) char localValue[MAX_LOCAL_BYTES] = {}; |
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.
This is slightly inefficient as it initialises localValue to all 0's for every instance which will be overwritten when constructing the instance. We should test if there is any visible performance degradation from this change. Maybe another one for Leo @ABenC377
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.
Alternative solution is to do something like
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wuninitialized"
foo(b); /* no diagnostic for this one */
#pragma GCC diagnostic pop
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.
Given we use Pool's for RegisterValues this may not cause a huge performance hit. Worth checking though
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.
All looks fine to me. Will approve once the main performance comment has been resolved
@@ -128,7 +128,7 @@ class RegisterValue { | |||
|
|||
/** The underlying local member value. Aligned to 8 bytes to prevent | |||
* potential alignment issue when casting. */ | |||
alignas(8) char value[MAX_LOCAL_BYTES]; | |||
alignas(8) char localValue[MAX_LOCAL_BYTES] = {}; |
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.
Given we use Pool's for RegisterValues this may not cause a huge performance hit. Worth checking though
const N* n; | ||
if (isXtn2) { | ||
d = sourceValues[0].getAsVector<D>(); | ||
n = sourceValues[1].getAsVector<N>(); | ||
} else { | ||
d = {}; | ||
n = sourceValues[0].getAsVector<N>(); | ||
} | ||
|
||
D out[16 / sizeof(D)] = {0}; | ||
int index = 0; | ||
|
||
for (int i = 0; i < I; i++) { | ||
if (isXtn2 & (i < (I / 2))) { | ||
assert(isXtn2 && "isXtn2 is false so d is not initialised"); | ||
out[i] = d[i]; | ||
} else { | ||
out[i] = static_cast<D>(n[index]); |
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 think this proposed solution is good.
From our offline discussion aboout line 801 on whether it should be isXtn2 & (i < (I / 2))
or isXtn2 && (i < (I / 2))
, given both arguments are bools the functionality would be the same, but using &&
may be marginally clearer of this fact?
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.
All looks good pending the performance check.
Is it worth including I didn't spot the separate PR, ignore!cstdint
into Register.hh to also fix that issue, or will we leave it for the SME branch? Imo we may as well add it now to get rid of another potential error point.
#rerun tests |
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.
Approval subject to performance review of initialising with 0s
Fixes #426