[llvm-commits] [PATCH] [MIPS] Avoid use of __builtin_unreachable() when compiling LLVM for MIPS.

Benjamin Kramer benny.kra at googlemail.com
Thu Mar 22 16:56:57 PDT 2012


On 23.03.2012, at 00:20, Petar Jovanovic <petar.jovanovic at rt-rk.com> wrote:

> There is a GCC bug which can be triggered inside of LLVM library. The -O2 opt
> does not work well with __builtin_unreachable(), so we are avoiding it inside
> of LLVM. The issue seems to be caused by 'freorder-blocks' optimization.

Patches working around compiler bugs are generally okay, but please

- Add a comment on why you're blacklisting MIPS here.
- Make the blacklist as narrow as possible, i.e. check for the
specific version of GCC that has this bug.

- Ben
>
> Signed-off-by: Petar Jovanovic <petarj at mips.com>
> ---
> include/llvm/Support/Compiler.h |    2 ++
> 1 files changed, 2 insertions(+), 0 deletions(-)
>
> diff --git a/include/llvm/Support/Compiler.h b/include/llvm/Support/Compiler.h
> index 9c5e7ec..b5a086a 100644
> --- a/include/llvm/Support/Compiler.h
> +++ b/include/llvm/Support/Compiler.h
> @@ -144,9 +144,11 @@
> // LLVM_BUILTIN_UNREACHABLE - On compilers which support it, expands
> // to an expression which states that it is undefined behavior for the
> // compiler to reach this point.  Otherwise is not defined.
> +#if !defined(__mips__)
> #if defined(__clang__) || (__GNUC__ > 4) \
>  || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
> # define LLVM_BUILTIN_UNREACHABLE __builtin_unreachable()
> #endif
> +#endif
>
> #endif
> --
> 1.7.5.4
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits



More information about the llvm-commits mailing list