// Using Clang/LLVM 3.6.0 we are observing a case where the optimizations // are clobbering EFLAGS on x86_64. This is inconvenient when the status of // bit 9 (IF), which controls interrupts, changes. // // Here's a simple test program. Assume that the external function foo() // modifies the IF bit in EFLAGS. // // And it's compiled using the following command line: // // $ clang -O2 -c -o clang-eflag.o clang-eflag.c // // Check objdump output using the following command line: // // $ objdump -S clang-eflag.o // // For more details see "[LLVMdev] optimizer clobber EFLAGS" // #include #include void foo(void); int a; int bar(void) { foo(); bool const zero = a -= 1; asm volatile ("" : : : "cc"); foo(); if (zero) { return EXIT_FAILURE; } foo(); return EXIT_SUCCESS; }