
X86 Serializing Instructions
This article contains a categorical list of compiler options. For an alphabetical list, see Compiler options listed alphabetically.
Optimization
Option | Purpose |
---|---|
/O1 | Creates small code. |
/O2 | Creates fast code. |
/Ob | Controls inline expansion. |
/Od | Disables optimization. |
/Og | Deprecated. Uses global optimizations. |
/Oi | Generates intrinsic functions. |
/Os | Favors small code. |
/Ot | Favors fast code. |
/Ox | A subset of /O2 that doesn't include /GF or /Gy. |
/Oy | Omits frame pointer. (x86 only) |
/favor | Produces code that is optimized for a specified architecture, or for a range of architectures. |
Code generation
Serializing instructions The following exception entry instructions are serializing:SVC SMC BKPT instructions that take the prefetch abort handler. Instructions that take the Undefined instruction exception handler, The following instructions that modify mode or program control are serializing: MSR. The source operand is a byte memory location. If the line selected is already present in the lowest level cache and is already in an exclusively owned state, no data movement occurs. Prefetches from non-writeback memory are ignored. The PREFETCHW instruction is merely a hint and does not affect program behavior.
Option | Purpose |
---|---|
/arch | Use SSE or SSE2 instructions in code generation. (x86 only) |
/clr | Produces an output file to run on the common language runtime. |
/EH | Specifies the model of exception handling. |
/fp | Specifies floating-point behavior. |
/GA | Optimizes for Windows applications. |
/Gd | Uses the __cdecl calling convention. (x86 only) |
/Ge | Deprecated. Activates stack probes. |
/GF | Enables string pooling. |
/Gh | Calls hook function _penter . |
/GH | Calls hook function _pexit . |
/GL | Enables whole program optimization. |
/Gm | Deprecated. Enables minimal rebuild. |
/GR | Enables run-time type information (RTTI). |
/Gr | Uses the __fastcall calling convention. (x86 only) |
/GS | Checks buffer security. |
/Gs | Controls stack probes. |
/GT | Supports fiber safety for data allocated by using static thread-local storage. |
/guard:cf | Adds control flow guard security checks. |
/Gv | Uses the __vectorcall calling convention. (x86 and x64 only) |
/Gw | Enables whole-program global data optimization. |
/GX | Deprecated. Enables synchronous exception handling. Use /EH instead. |
/Gy | Enables function-level linking. |
/GZ | Deprecated. Enables fast checks. (Same as /RTC1) |
/Gz | Uses the __stdcall calling convention. (x86 only) |
/homeparams | Forces parameters passed in registers to be written to their locations on the stack upon function entry. This compiler option is only for the x64 compilers (native and cross compile). |
/hotpatch | Creates a hotpatchable image. |
/Qfast_transcendentals | Generates fast transcendentals. |
/QIfist | Deprecated. Suppresses the call of the helper function _ftol when a conversion from a floating-point type to an integral type is required. (x86 only) |
/Qimprecise_fwaits | Removes fwait commands inside try blocks. |
/QIntel-jcc-erratum | Mitigates the performance impact of the Intel JCC erratum microcode update. |
/Qpar | Enables automatic parallelization of loops. |
/Qpar-report | Enables reporting levels for automatic parallelization. |
/Qsafe_fp_loads | Uses integer move instructions for floating-point values and disables certain floating point load optimizations. |
/Qspectre | Enable mitigations for CVE 2017-5753, for a class of Spectre attacks. |
/Qspectre-load | Generate serializing instructions for every load instruction. |
/Qspectre-load-cf | Generate serializing instructions for every control flow instruction that loads memory. |
/Qvec-report | Enables reporting levels for automatic vectorization. |
/RTC | Enables run-time error checking. |
/volatile | Selects how the volatile keyword is interpreted. |
Output files
Option | Purpose |
---|---|
/doc | Processes documentation comments to an XML file. |
/FA | Configures an assembly listing file. |
/Fa | Creates an assembly listing file. |
/Fd | Renames program database file. |
/Fe | Renames the executable file. |
/Fi | Specifies the preprocessed output file name. |
/Fm | Creates a mapfile. |
/Fo | Creates an object file. |
/Fp | Specifies a precompiled header file name. |
/FR, /Fr | Name generated .sbr browser files. |
Preprocessor
Option | Purpose |
---|---|
/AI | Specifies a directory to search to resolve file references passed to the #using directive. |
/C | Preserves comments during preprocessing. |
/D | Defines constants and macros. |
/E | Copies preprocessor output to standard output. |
/EP | Copies preprocessor output to standard output. |
/FI | Preprocesses the specified include file. |
/FU | Forces the use of a file name, as if it had been passed to the #using directive. |
/Fx | Merges injected code with the source file. |
/I | Searches a directory for include files. |
/P | Writes preprocessor output to a file. |
/U | Removes a predefined macro. |
/u | Removes all predefined macros. |
/X | Ignores the standard include directory. |
Language
Option | Purpose |
---|---|
/constexpr | Control constexpr evaluation at compile time. |
/openmp | Enables #pragma omp in source code. |
/vd | Suppresses or enables hidden vtordisp class members. |
/vmb | Uses best base for pointers to members. |
/vmg | Uses full generality for pointers to members. |
/vmm | Declares multiple inheritance. |
/vms | Declares single inheritance. |
/vmv | Declares virtual inheritance. |
/Z7 | Generates C 7.0-compatible debugging information. |
/Za | Disables C89 language extensions. |
/Zc | Specifies standard behavior under /Ze. |
/Ze | Deprecated. Enables C89 language extensions. |
/Zf | Improves PDB generation time in parallel builds. |
/ZH | Specifies MD5, SHA-1, or SHA-256 for checksums in debug info. |
/ZI | Includes debug information in a program database compatible with Edit and Continue. (x86 only) |
/Zi | Generates complete debugging information. |
/Zl | Removes the default library name from the .obj file. |
/Zpn | Packs structure members. |
/Zs | Checks syntax only. |
/ZW | Produces an output file to run on the Windows Runtime. |
Linking
Option | Purpose |
---|---|
/F | Sets stack size. |
/LD | Creates a dynamic-link library. |
/LDd | Creates a debug dynamic-link library. |
/link | Passes the specified option to LINK. |
/LN | Creates an MSIL module. |
/MD | Compiles to create a multithreaded DLL, by using MSVCRT.lib. |
/MDd | Compiles to create a debug multithreaded DLL, by using MSVCRTD.lib. |
/MT | Compiles to create a multithreaded executable file, by using LIBCMT.lib. |
/MTd | Compiles to create a debug multithreaded executable file, by using LIBCMTD.lib. |
Miscellaneous
Option | Purpose |
---|---|
/? | Lists the compiler options. |
@ | Specifies a response file. |
/analyze | Enables code analysis. |
/bigobj | Increases the number of addressable sections in an .obj file. |
/c | Compiles without linking. |
/cgthreads | Specifies number of cl.exe threads to use for optimization and code generation. |
/errorReport | Deprecated. Error reporting is controlled by Windows Error Reporting (WER) settings. |
/FC | Displays the full path of source code files passed to cl.exe in diagnostic text. |
/FS | Forces writes to the PDB file to be serialized through MSPDBSRV.EXE. |
/H | Deprecated. Restricts the length of external (public) names. |
/HELP | Lists the compiler options. |
/J | Changes the default char type. |
/JMC | Supports native C++ Just My Code debugging. |
/kernel | The compiler and linker will create a binary that can be executed in the Windows kernel. |
/MP | Builds multiple source files concurrently. |
/nologo | Suppresses display of sign-on banner. |
/sdl | Enables additional security features and warnings. |
/showIncludes | Displays a list of all include files during compilation. |
/Tc | Specifies a C source file. |
/TC | Specifies all source files are C. |
/Tp | Specifies a C++ source file. |
/TP | Specifies all source files are C++. |
/V | Deprecated. Sets the version string. |
/w | Disables all warnings. |
/W0, /W1, /W2, /W3, /W4 | Sets output warning level. |
/w1, /w2, /w3, /w4 | Sets warning level for the specified warning. |
/Wall | Enables all warnings, including warnings that are disabled by default. |
/wd | Disables the specified warning. |
/we | Treats the specified warning as an error. |
/WL | Enables one-line diagnostics for error and warning messages when compiling C++ source code from the command line. |
/wo | Displays the specified warning only once. |
/Wv | Disables warnings introduced by later versions of the compiler. |
/WX | Treats warnings as errors. |
/Yc | Create .PCH file. |
/Yd | Deprecated. Places complete debugging information in all object files. Use /Zi instead. |
/Yl | Injects a PCH reference when creating a debug library. |
/Yu | Uses a precompiled header file during build. |
/Y- | Ignores all other precompiled-header compiler options in the current build. |
/Zm | Specifies the precompiled header memory allocation limit. |
/await | Enable coroutines (resumable functions) extensions. |
/source-charset | Set source character set. |
/execution-charset | Set execution character set. |
/utf-8 | Set source and execution character sets to UTF-8. |
/validate-charset | Validate UTF-8 files for only compatible characters. |
/diagnostics | Controls the format of diagnostic messages. |
/permissive- | Set standard-conformance mode. |
/std | C++ standard version compatibility selector. |
Experimental options
Experimental options may only be supported by certain versions of the compiler. They may also behave differently in different compiler versions. Often the best, or only, documentation for experimental options is in the Microsoft C++ Team Blog.
Option | Purpose |
---|---|
/experimental:module | Enables experimental module support. |
/experimental:preprocessor | Enables experimental conforming preprocessor support. |
Deprecated and removed compiler options
Option | Purpose |
---|---|
/clr:noAssembly | Deprecated. Use /LN (Create MSIL Module) instead. |
/errorReport | Deprecated. Error reporting is controlled by Windows Error Reporting (WER) settings. |
/Fr | Deprecated. Creates a browse information file without local variables. |
/Ge | Deprecated. Activates stack probes. On by default. |
/Gm | Deprecated. Enables minimal rebuild. |
/GX | Deprecated. Enables synchronous exception handling. Use /EH instead. |
/GZ | Deprecated. Enables fast checks. Use /RTC1 instead. |
/H | Deprecated. Restricts the length of external (public) names. |
/Og | Deprecated. Uses global optimizations. |
/QIfist | Deprecated. Once used to specify how to convert from a floating-point type to an integral type. |
/V | Deprecated. Sets the .obj file version string. |
/Wp64 | Obsolete. Detects 64-bit portability problems. |
/Yd | Deprecated. Places complete debugging information in all object files. Use /Zi instead. |
/Zc:forScope- | Deprecated. Disables conformance in for loop scope. |
/Ze | Deprecated. Enables language extensions. |
/Zg | Removed in Visual Studio 2015. Generates function prototypes. |
See also
C/C++ building reference
MSVC compiler options
MSVC compiler command-line syntax
The Time Stamp Counter (TSC) is a 64-bit register present on all x86 processors since the Pentium. It counts the number of cycles since reset. The instruction RDTSC
returns the TSC in EDX:EAX. In x86-64 mode, RDTSC
also clears the higher 32 bits of RAX and RDX. Its opcode is 0F 31
.[1]Pentium competitors such as the Cyrix6x86 did not always have a TSC and may consider RDTSC
an illegal instruction. Cyrix included a Time Stamp Counter in their MII.
Use[edit]
The Time Stamp Counter was once an excellent high-resolution, low-overhead way for a program to get CPU timing information. With the advent of multi-core/hyper-threaded CPUs, systems with multiple CPUs, and hibernatingoperating systems, the TSC cannot be relied upon to provide accurate results — unless great care is taken to correct the possible flaws: rate of tick and whether all cores (processors) have identical values in their time-keeping registers. There is no promise that the timestamp counters of multiple CPUs on a single motherboard will be synchronized. Therefore, a program can get reliable results only by limiting itself to run on one specific CPU. Even then, the CPU speed may change because of power-saving measures taken by the OS or BIOS, or the system may be hibernated and later resumed, resetting the TSC. In those latter cases, to stay relevant, the program must re-calibrate the counter periodically.
Relying on the TSC also reduces portability, as other processors may not have a similar feature. Recent Intel processors include a constant rate TSC (identified by the kern.timecounter.invariant_tsc sysctl on FreeBSD or by the 'constant_tsc
' flag in Linux's /proc/cpuinfo
). With these processors, the TSC ticks at the processor's nominal frequency, regardless of the actual CPU clock frequency due to turbo or power saving states. Hence TSC ticks are counting the passage of time, not the number of CPU clock cycles elapsed.
On Windows platforms, Microsoft strongly discourages using the TSC for high-resolution timing for exactly these reasons, providing instead the Windows APIsQueryPerformanceCounter
and QueryPerformanceFrequency
.[2] On POSIX systems, a program can get similar function by reading the value of CLOCK_MONOTONIC
clock using the clock_gettime
function.[3]
Starting with the Pentium Pro, Intel processors have practiced out-of-order execution, where instructions are not necessarily performed in the order they appear in the program. This can cause the processor to execute RDTSC
earlier than a simple program expects, producing a misleading cycle count.[4] The programmer can solve this problem by inserting a serializing instruction, such as CPUID, to force every preceding instruction to complete before allowing the program to continue, or by using the RDTSCP
instruction, which is a serializing variant of the RDTSC
Best price for nvidia quadro 4000 for mac pro. instruction.
Implementation in various processors[edit]

Intel processor families increment the time-stamp counter differently:[5]
- For Pentium M processors (family [06H], models [09H, 0DH]); for Pentium 4 processors, Intel Xeon processors (family [0FH], models [00H, 01H, or 02H]); and for P6 family processors: the time-stamp counter increments with every internal processor clock cycle. The internal processor clock cycle is determined by the current core-clock to busclock ratio. Intel SpeedStep technology transitions may also impact the processor clock.
- For Pentium 4 processors, Intel Xeon processors (family [0FH], models [03H and higher]); for Intel Core Solo and Intel Core Duo processors (family [06H], model [0EH]); for the Intel Xeon processor 5100 series and Intel Core 2 Duo processors (family [06H], model [0FH]); for Intel Core 2 and Intel Xeon processors (family [06H], display_model [17H]); for Intel Atom processors (family [06H], display_model [1CH]): the time-stamp counter increments at a constant rate. That rate may be set by the maximum core-clock to bus-clock ratio of the processor or may be set by the maximum resolved frequency at which the processor is booted. The maximum resolved frequency may differ from the maximum qualified frequency of the processor.
The specific processor configuration determines the behavior. Constant TSC behavior ensures that the duration of each clock tick is uniform and makes it possible to use of the TSC as a wall clock timer even if the processor core changes frequency. This is the architectural behavior for all later Intel processors.
AMD processors up to the K8 core always incremented the time-stamp counter every clock cycle.[6] Thus, power management features were able to change the number of increments per second, and the values could get out of sync between different cores or processors in the same system. For Windows, AMD provides a utility[7] to periodically synchronize the counters on multiple core CPUs.Since the family 10h (Barcelona/Phenom), AMD chips feature a constant TSC, which can be driven either by the HyperTransport speed or the highest P state. A CPUID bit (Fn8000_0007:EDX_8
) advertises this; Intel-CPUs also report their invariant TSC on that bit.
Operating system use[edit]
An operating system may provide methods that both use and don't use the RDTSC
Sidify music converter for spotify crack mac. instruction for time keeping, under administrator control. For example, on some versions of the Linux kernel, seccomp sandboxing mode disables RDTSC
.[8] It can also be disabled using the PR_SET_TSC
argument to the prctl()
system call.[9]
Use in exploiting cache side-channel attacks[edit]
The time stamp counter can be used to time instructions accurately which can be exploited in the Meltdown and Spectre security vulnerabilities[10][11]. However if this is not available other counters or timers can be used, as is the case with the ARM processors vulnerable to this type of attack.
Other architectures[edit]
Other processors also have registers which count CPU clock cycles, but with different names. For instance, on the AVR32, it is called the Performance Clock Counter (PCCNT) register. SPARC V9 provides theTICK
register.ARMv7[12] andARMv8[13] architectures provide a genericcounter which counts at a constant frequency. PowerPC provides the 64-bit TBR
register.
See also[edit]
- High Precision Event Timer (HPET)
References[edit]
- ^Intel 64 and IA-32 Architectures Software Developer's Manual Volume 2B: Instruction Set Reference, M-Z(PDF). p. 460.
- ^Game Timing and Multicore Processors. pp. 251–252.
- ^'clock_getres, clock_gettime, clock_settime - clock and timer functions'.
- ^'Using the RDTSC Instruction for Performance Monitoring'(PDF).
- ^'Volume 3A, Chapter 16'. Intel 64 and IA-32 Architectures Software Developer's Manual.
- ^'Volume 3'. AMD64 Architecture Programmer's Manual.
- ^'AMD Dual-Core Optimizer'.
- ^'cr0 blog: Time-stamp counter disabling oddities in the Linux kernel'. May 2009.
- ^
prctl(2)
– Linux Programmer's Manual – System Calls - ^'meltdown.c'.
- ^'spectre.c'.
- ^'ARMv7 reference manual'.
- ^'ARMv8 reference manual'.
External links[edit]
- cycle.h - C code to read the high-resolution timer on many CPUs and compilers.
- [1] - Very simple C code to read the timer on an x86 machine. This reads the 64-bit value into two 32-bit integers and combines them - using just one 64-bit integer is another option.[clarification needed]