-
Notifications
You must be signed in to change notification settings - Fork 13.5k
VC++ truncates X86II::VEX enum constants #8120
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
Comments
That's bad. Not going use #define's for those though. If any other better solution doesn't show up, we should go for putting VEX enums in a new enum, and shift TSFlags before checking. |
Fix VEX enum constant overflow |
That's an option, another option is: "(TSFlags >> 32) & VEX_XXX", considering that VEX_XXX enums would start from 0 again |
Alternative fix for VEX enum constant overflow |
The patch seems fine, but breaks one test/CodeGen/X86 test, can you improve the patch to successfully pass all those? Thanks. |
I would really want to fix that test, but it seems a great lot of tests Can you please point out the specific test that is failing? |
Use C#-style enum type extension http://msdn.microsoft.com/en-us/library/2dzy4k6e(VS.80).aspx |
I'm not really sure of what approach should be done here. I'll wait for more people to see this. |
Dimitry, Check your patch and re-send it and I'll give it a try again. Just make sure all places properly uses TSFlags, this commit initially changed it, may it helps you: Sorry for the delay, |
You actually just missed one TSFlags and I've foreseen! I fixed it myself and commited in r112128! |
This is followup to llvm#8120. Missed a destuctor.
Migrate remaining llvm::Optional to std::optional
This is followup to #8120. Missed a destuctor.
Extended Description
During compilation with VC++ 9 of several llvm files that include
X86InstInfo.h, I am getting the following warnings about it:
lib\target\x86\X86InstrInfo.h(442) : warning C4341: 'VEX' : signed value is out of range for enum constant
lib\target\x86\X86InstrInfo.h(442) : warning C4309: 'initializing' : truncation of constant value
lib\target\x86\X86InstrInfo.h(446) : warning C4341: 'VEX_W' : signed value is out of range for enum constant
lib\target\x86\X86InstrInfo.h(446) : warning C4309: 'initializing' : truncation of constant value
lib\target\x86\X86InstrInfo.h(451) : warning C4341: 'VEX_4V' : signed value is out of range for enum constant
lib\target\x86\X86InstrInfo.h(451) : warning C4309: 'initializing' : truncation of constant value
lib\target\x86\X86InstrInfo.h(456) : warning C4341: 'VEX_I8IMM' : signed value is out of range for enum constant
lib\target\x86\X86InstrInfo.h(456) : warning C4309: 'initializing' : truncation of constant value
lib\target\x86\X86InstrInfo.h(463) : warning C4341: 'VEX_L' : signed value is out of range for enum constant
lib\target\x86\X86InstrInfo.h(463) : warning C4309: 'initializing' : truncation of constant value
This is because of the following enum constants in the X86II namespace:
So unfortunately VC++ truncates these constants, which is probably very
bad if you count on those exact values. The MSDN library says the
following about this warning:
"An enumerated constant exceeds the limit for an int. The value of the
invalid constant is undefined. Constants must resolve to integers
between –4,294,967,295 and +4,294,967,295 (signed)."
http://msdn.microsoft.com/en-us/library/x651y302.aspx
Therefore, these constants should probably be replaced by globals, or
maybe even #defines... (yuck :)
The text was updated successfully, but these errors were encountered: