This is an archive of the discontinued LLVM Phabricator instance.

AArch64: Set shift bit of TLSLE HI12 add instruction
ClosedPublic

Authored by lliu0 on Sep 17 2016, 6:25 PM.

Details

Summary

AArch64 LLVM assembler emits add instruction without shift bit to calculate the higher 12-bit address of TLS variables in local exec model. This generates wrong code sequence to access TLS variables with thread offset larger than 0x1000.

Diff Detail

Event Timeline

lliu0 updated this revision to Diff 71740.Sep 17 2016, 6:25 PM
lliu0 retitled this revision from to AArch64: Set shift bit of TLSLE HI12 add instruction.
lliu0 updated this object.
lliu0 added a reviewer: t.p.northover.
lliu0 added a subscriber: llvm-commits.
rovka edited edge metadata.Sep 19 2016, 2:15 AM

Could you please add a testcase for this? You can use llvm-objdump -r -d to make sure you got the right encoding and relocation.
The fix itself seems ok. Maybe we should consider doing the same thing for DTPREL? (I'm not sure gcc supports DTPREL atm, but we do, so we should be consistent).

lliu0 updated this revision to Diff 71898.Sep 19 2016, 7:41 PM
lliu0 edited edge metadata.

Set shift bit for R_AARCH64_TLSLD_ADD_DTPREL_HI12 as well.
Added test case.

rovka accepted this revision.Sep 20 2016, 2:06 AM
rovka edited edge metadata.

LGTM, thanks.

This revision is now accepted and ready to land.Sep 20 2016, 2:06 AM
lliu0 closed this revision.Sep 21 2016, 12:50 AM
lliu0 updated this revision to Diff 72029.Sep 21 2016, 5:23 AM
lliu0 edited edge metadata.

Fix AArch64 test breakage.

FAIL: LLVM::frameindices.ll
FAIL: LLVM::arm64-tls-modifiers-darwin.s
FAIL: LLVM::darwin-reloc-addsubimm.s

Hi Lei,

Did you run "make check-all" with this patch? It seem to have broken on multiple buildbots, ARM, AArch64, PPC, etc.

cheers,
--renato

lliu0 added a comment.Sep 21 2016, 5:33 PM

Hi Renato,

I have run "make check-all" with my latest change (Diff 72029).

Scanning dependencies of target check-all
[100%] Running all regression tests
Testing Time: 215.37s

Expected Passes    : 17686
Expected Failures  : 124
Unsupported Tests  : 222

[100%] Built target check-all

I think it's good now.

rovka added inline comments.Sep 22 2016, 6:59 AM
lib/Target/AArch64/MCTargetDesc/AArch64MCCodeEmitter.cpp
268

I think the intent would be clearer if you folded this check and the cast below into a dyn_cast (http://llvm.org/docs/ProgrammersManual.html#isa).

lliu0 updated this revision to Diff 72227.Sep 22 2016, 5:32 PM
rovka added a comment.Sep 23 2016, 2:52 AM

Nit: you can move the declaration of A64E in if's condition.
I think this is ok to commit now if it passes check-all.

lliu0 updated this revision to Diff 72390.Sep 24 2016, 4:37 AM

Make check-all passed with the change.

Nit: you can move the declaration of A64E in if's condition.
I think this is ok to commit now if it passes check-all.