[Bug inline-asm/78487] asm cpuid code and -fgcse crashes
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78487 Stephan Beyer changed: What|Removed |Added Status|UNCONFIRMED |RESOLVED Resolution|--- |INVALID --- Comment #6 from Stephan Beyer --- Ok, the problem is solved using __get_cpuid(). Sorry for bothering you and thank you for the quick help.
[Bug inline-asm/78487] asm cpuid code and -fgcse crashes
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78487 --- Comment #5 from Stephan Beyer --- It crashes on run-time. I have absolutely no experience using extended asm syntax but I guess g++ relies on the constraints for its optimization, so I guess the constraints are wrong. I will port the code to use the macro from cpuid.h and close the issue if there are no more crashes. Thank you.
[Bug inline-asm/78487] asm cpuid code and -fgcse crashes
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78487 --- Comment #4 from Andrew Pinski --- Also I doubt this code is correct.
[Bug inline-asm/78487] asm cpuid code and -fgcse crashes
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78487 --- Comment #3 from Andrew Pinski --- Crashes at runtime or crashes inside GCC?
[Bug inline-asm/78487] asm cpuid code and -fgcse crashes
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78487 --- Comment #2 from Stephan Beyer --- The following problem is only reproducible on one machine. I cannot reproduce it on any other machine. When compiling the attached C++ source file with g++ -O1 -fgcse, it crashes at the third cpuid call (ie, there are three output lines). When just using g++ -O1 (without -fgcse), it works well. Changing the code in main() slightly or making cpuid() inline makes it work well also with -fgcse. uname -a and g++ --version of that machine says: Linux ipc675 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt4-3 (2015-02-03) x86_64 GNU/Linux g++ (Debian 6.2.0-13) 6.2.0 20161109 If useful, I can also attach assembly output of the crashing code (with -fgcse), of the code without -fgcse and of the code with "inline" (there using -fgcse makes no difference). The code is not written by me, so I don't know if its "correct" or if the input/output asm constraints are just used wrong. (It's just the minimal example I got from code where a crash occurred.) PS: excuse the first empty bug report, it seems I am too stupid for bugzilla.
[Bug inline-asm/78487] asm cpuid code and -fgcse crashes
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78487 --- Comment #1 from Andrew Pinski --- What is the error message which you are getting? Here is how GCC's cpuid.h header look like for cpuid: #define __cpuid(level, a, b, c, d) \ __asm__ ("cpuid\n\t" \ : "=a" (a), "=b" (b), "=c" (c), "=d" (d) \ : "0" (level)) #define __cpuid_count(level, count, a, b, c, d) \ __asm__ ("cpuid\n\t" \ : "=a" (a), "=b" (b), "=c" (c), "=d" (d) \ : "0" (level), "2" (count)) It does not use r but rather b directly.