ATS workaround for Clang 3.5

The ATS community is having trouble with clang. They had been using
an older version of clang and upgraded because newer versions give
higher quality warning messages. Unfortunately, with 3.5, moving from
-O1 to -O2 triggers a crash on startup in the clang-generated
executable. I had suggested building with -fsanitize=undefined and
-fsanitize=address to weed out any dependencies undefined behavior.
All their generated C code came out clean. Here is the workaround
Hongwei Xi came up with:

https://github.com/githwxi/ATS-Postiats/commit/5e17db4badf58b404598e8b3ae4a666b8b0e889c

Looks like a bug on the LLVM side. He says it worked with clang 3.3,
but breaks on 3.4 and 3.5. Would someone be interested in
investigating this further? It's fallen down to an area I don't think
I can debug quickly and if we can squeeze a fix into 3.6, that'd be
great. ATS is such an interesting language, I hope we can help.

Thanks,
Greg

Is there a bug filed with the affected C code, or better, a standalone reproducer? I don’t know ATS, so it’s hard to diagnose from an ATS diff.

Is there a bug filed with the affected C code

I just added: http://llvm.org/bugs/show_bug.cgi?id=22360

or better, a standalone reproducer?

I added code sent by Hongwei Xi to the bug report, but it is not
minimal or standalone. :-/

A job for bugpoint?

I don't know ATS, so it's hard to diagnose from an ATS diff.

The diff just aims to demonstrate that that the bug is likely in Clang
and not the ATS-generated C code. He added a level of indirection to
prevent the optimizer for kicking in.

-Greg