1*4882a593Smuzhiyun /* SPDX-License-Identifier: LGPL-2.1-only OR MIT */ 2*4882a593Smuzhiyun /* 3*4882a593Smuzhiyun * rseq/compiler.h 4*4882a593Smuzhiyun * 5*4882a593Smuzhiyun * Work-around asm goto compiler bugs. 6*4882a593Smuzhiyun * 7*4882a593Smuzhiyun * (C) Copyright 2021 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com> 8*4882a593Smuzhiyun */ 9*4882a593Smuzhiyun 10*4882a593Smuzhiyun #ifndef RSEQ_COMPILER_H 11*4882a593Smuzhiyun #define RSEQ_COMPILER_H 12*4882a593Smuzhiyun 13*4882a593Smuzhiyun /* 14*4882a593Smuzhiyun * gcc prior to 4.8.2 miscompiles asm goto. 15*4882a593Smuzhiyun * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58670 16*4882a593Smuzhiyun * 17*4882a593Smuzhiyun * gcc prior to 8.1.0 miscompiles asm goto at O1. 18*4882a593Smuzhiyun * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103908 19*4882a593Smuzhiyun * 20*4882a593Smuzhiyun * clang prior to version 13.0.1 miscompiles asm goto at O2. 21*4882a593Smuzhiyun * https://github.com/llvm/llvm-project/issues/52735 22*4882a593Smuzhiyun * 23*4882a593Smuzhiyun * Work around these issues by adding a volatile inline asm with 24*4882a593Smuzhiyun * memory clobber in the fallthrough after the asm goto and at each 25*4882a593Smuzhiyun * label target. Emit this for all compilers in case other similar 26*4882a593Smuzhiyun * issues are found in the future. 27*4882a593Smuzhiyun */ 28*4882a593Smuzhiyun #define rseq_after_asm_goto() asm volatile ("" : : : "memory") 29*4882a593Smuzhiyun 30*4882a593Smuzhiyun #endif /* RSEQ_COMPILER_H_ */ 31