Created
October 6, 2015 12:23
-
-
Save daniel-j-h/0a1c1414a68d4a67d4b4 to your computer and use it in GitHub Desktop.
Defeating the Optimizer --- Chandler Carruth' CppCon2015 Tricks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void escape(void* p) { | |
asm volatile("" : : "g"(p) : "memory"); | |
} | |
static void clobber() { | |
asm volatile("" : : : "memory"); | |
} |
VC can do something like:
#pragma optimize( "", off )
template<typename T>
static void escape(T&& v) {
T local = v;
}
#pragma optimize( "", on )
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Does anyone know the equivalent trick for the Visual C++ compiler?