Skip to content

r298851 breaks code that tries to initialise TLS on aarch64 #34665

@EdSchouten

Description

@EdSchouten
Bugzilla Link 35317
Resolution FIXED
Resolved on Nov 22, 2017 10:17
Version 5.0
OS All
Blocks #33840
CC @rengolin,@TNorthover,@tstellar
Fixed by commit(s) r318788 r318854

Extended Description

On CloudABI, I've observed crashes of processes on AArch64 when using Clang 5.0, though Clang 4.0 works perfectly fine. This is due to the changes made in SVN r298851.

On CloudABI, crt0 is responsible for allocating TLS and updating TPIDR_EL0 accordingly. Once completed, it will initialise some of the objects stored in TLS for the initial thread.

Setting up TLS:

Initialising TLS objects for the initial thread:

With the changes made in r298851, mrs TPIDR_EL0 is marked as having no side-effects whatsoever. This is too strong, because an msr TPIDR_EL0 can affect the register's value. In other words, it is all right to combine and reorder mrs TPIDR_EL0 instructions, but we shouldn't be doing this across the msr.

I can imagine that the optimisation provided by r298851 would be worth having. If we want to leave it intact, wouldn't it make more sense to revert to the old behaviour, but assume that functions called in other compilation units will not clobber TPIDR_EL0?

If it is hard to fix this on short notice, could we please revert this change for 5.0.1?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions