Why did GCC generate mov %eax,%eax and what does it mean?

In x86-64, 32-bit instructions implicitly zero-extend: bits 32-63 are cleared (to avoid false dependencies). So sometimes that’s why you’ll see odd-looking instructions. (Is mov %esi, %esi a no-op or not on x86-64?) However, in this case the previous mov-load is also 32-bit so the high half of %rax is already cleared. The mov %eax, %eax … Read more

How to tell Clang to stop pretending to be other compilers?

__GNUC__ doesn’t mean GCC specifically. All compilers that support GNU C extensions define it, including clang and ICC. The normal way to detect specifically GCC is by excluding other “compatible” compilers #if defined(__GNUC__) && !defined(__llvm__) && !defined(__INTEL_COMPILER) #define REAL_GCC __GNUC__ // probably #endif The Clang front-end defines __clang__, but other front-ends that use the LLVM … Read more

Intel x86 0x2E/0x3E Prefix Branch Prediction actually used?

These instruction prefixes have no effect on modern processors (anything newer than Pentium 4). They just cost one byte of code space, and thus, not generating them is the right thing. For details, see Agner Fog’s optimization manuals, in particular 3. Microarchitecture: http://www.agner.org/optimize/ The “IntelĀ® 64 and IA-32 Architectures Optimization Reference Manual” no longer mentions … Read more

GCC 4.8: Does -Og imply -g?

A look in the GCC 4.9.2 source code (gcc/opts.c) showed that -Og is the the same as -O1, but with some flags disabled that could result in a worse debugging experience: /* in function default_options_optimization: */ case OPT_Og: /* -Og selects optimization level 1. */ opts->x_optimize_size = 0; opts->x_optimize = 1; opts->x_optimize_fast = 0; opts->x_optimize_debug … Read more

What are the gcc predefined macros for the compiler’s version number?

From the gnu cpp manual… __GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__ These macros are defined by all GNU compilers that use the C preprocessor: C, C++, Objective-C and Fortran. Their values are the major version, minor version, and patch level of the compiler, as integer constants. For example, GCC 3.2.1 will define __GNUC__ to 3, __GNUC_MINOR__ to 2, … Read more

What is the use of “push %ebp; movl %esp, %ebp” generated by GCC for x86?

unwind’s explanation is the literal truth (one minor directional error notwithstanding), but doesn’t explain why. %ebp is the “base pointer” for your stack frame. It’s the pointer used by the C runtime to access local variables and parameters on the stack. Here’s some typical function prologue code generated by GCC (g++ to be precise) First … Read more

What is the environment variable for GCC/G++ to look for .h files during compilation: LIBRARY_PATH, C_PATH, C_INCLUDE_PATH or CPLUS_PATH?

From: http://gcc.gnu.org/onlinedocs/cpp/Environment-Variables.html CPATH C_INCLUDE_PATH CPLUS_INCLUDE_PATH OBJC_INCLUDE_PATH Each variable’s value is a list of directories separated by a special character, much like PATH, in which to look for header files. The special character, PATH_SEPARATOR, is target-dependent and determined at GCC build time. For Microsoft Windows-based targets it is a semicolon, and for almost all other targets … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)