Created
April 15, 2020 09:26
-
-
Save dannas/bd863593511bf65fd221236344980591 to your computer and use it in GitHub Desktop.
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
// Unfinished example of clobber and doNotOptimize functions. | |
// https://godbolt.org/z/CkZ9Bh | |
void f() { | |
int val; | |
//asm volatile("" : : "r,m"(val) : "memory"); | |
//asm volatile("" : : "rm"(val) : "memory"); | |
asm volatile("" : "+m"(val) : : "memory"); | |
val = 1; | |
asm volatile("" : : : "memory"); | |
val = 2; | |
asm volatile("" : : : "memory"); | |
} | |
extern int ExternInt; | |
extern int ExternInt2; | |
void g() { | |
ExternInt = 1; | |
asm volatile("" : : : "memory"); | |
ExternInt = 2; | |
} | |
void redundant_read() { | |
int x; | |
asm volatile("" : "+m"(x) : : "memory"); | |
x = ExternInt; | |
asm volatile("" : : : "memory"); | |
x = ExternInt2; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment