[llvm-dev] Linux/ARM: Segfault issue when we build clang sources including __thread variable using -O2 flag

Tim Northover via llvm-commits llvm-commits at lists.llvm.org
Wed May 11 06:39:29 PDT 2016


On 10 May 2016 at 22:11, Geunsik Lim <leemgs at gmail.com> wrote:
>> we cannot combine the 2 ldr instructions and litpools because they get
>> added to a different pc to form the correct address.
>
> I wonder how we can figure out the reason such as the above statement from
> the libcoreclr.so (or clsload.s).

The key was reusing litpool entries that get added to PC. That's an
extremely odd sequence and almost certainly never what you want to do.
After that it was just stepping through LLVM to work out where things
went wrong.

> Actually, I could not find the same assembly code that you commented to
> r268662  from clsload.s file.

Yes, as I said, I made it up. The real code used .LCPI42_27 or
.LCPI36_27or something (I forget), used different registers and had
dozens of instructions in between. But those details don't matter so I
simplified it.

>> The inliner was needed in this case because most TLS accesses were hidden
>> away in GetThread.
>> You could write C code that would fail at -O1 if you tried.
>
> It's strange. I can normally run C# console applications  with libcoreclr.so
> that is built by -O1 such as -O0

Yes,  libcoreclr.so isn't affected at -O1. You'd have to write C code
specially designed to trigger the bug (or be otherwise unlucky).

Cheers.

Tim.


More information about the llvm-commits mailing list