Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(244)

Issue 1506653002: Subzero: Add Non-SFI support for x86-32. (Closed)

Created:
5 years ago by Jim Stichnoth
Modified:
4 years, 11 months ago
Reviewers:
Karl, sehr, John
CC:
native-client-reviews_googlegroups.com
Base URL:
https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Target Ref:
refs/heads/master
Visibility:
Public.

Description

Subzero: Add Non-SFI support for x86-32. The basic model is that each translated function begins with a special "GotVar = getIP" instruction, and each ConstantRelocatable reference is changed to GotVar+ConstantRelocatable@GOTOFF (assuming GotVar is legalized into a physical register). The getIP instruction is late-lowered into: call __Sz_getIP_<reg> add <reg>, $_GLOBAL_OFFSET_TABLE_ mov GotVar, <reg> Note that _GLOBAL_OFFSET_TABLE_ gets a special relocation type. The register allocator takes GotVar uses into account, giving appropriate weight toward register allocation. If there are no uses of GotVar, the getIP instruction gets naturally dead-code eliminated. Special treatment is needed to prevent this elimination when the only GotVar uses are for (floating point) constant pool values from Phi instructions, since the Phi lowering with its GotVar legalization happens after the main round of register allocation. The x86 mem operand now has a IsPIC field to indicate whether it has been PIC-legalized. Mem operands are sometimes legalized more than once, and this IsPIC field keeps GotVar from being added more than once. We have to limit the aggressiveness of address mode inference, to make sure a register slot is left for the GotVar. The Subzero runtime has new asm files to implement all possible __Sz_getIP_<reg> helpers. The szbuild.py script and the spec2k version support Non-SFI builds. Running spec2k depends on a pending change to the spec2k run_all.sh script. Read-only data sections need to be named .data.rel.ro instead of .rodata because of PIC rules. Most cross tests are working, but there is some problem with vector types that seems to be not Subzero related, so most vector tests are disabled for now. Still to do: * Fix "--nonsfi --filetype=iasm". The llvm-mc assembler doesn't properly apply the _GLOBAL_OFFSET_TABLE_ relocation in iasm mode. Maybe I can find a different syntactic trick that works, or use hybrid iasm for this limited case. BUG= https://bugs.chromium.org/p/nativeclient/issues/detail?id=4327 R=jpp@chromium.org Committed: https://gerrit.chromium.org/gerrit/gitweb?p=native_client/pnacl-subzero.git;a=commit;h=8ff4b2819944bc4f02fb29204a1fa5ba7dea5682

Patch Set 1 : Initialize GotVar in prolog. Emit call to runtime helper for filetype=asm. #

Patch Set 2 : Do PIC for mem operand legalization. Unfortunately this is subject to double legalization. #

Patch Set 3 : Add FixupKind/RelocType explicitly to ConstantRelocatables #

Patch Set 4 : Fix GOT legalization for MemOperands. Emit @GOTOFF suffix. #

Patch Set 5 : Works as long as address mode inference isn't too aggressive #

Patch Set 6 : Dial back address mode inference #

Patch Set 7 : Checkpoint before redesigning this #

Patch Set 8 : Take a different approach for relocations #

Patch Set 9 : Basic "hello world" runs with -filetype-asm #

Patch Set 10 : Add --nonsfi to the build script #

Patch Set 11 : Validate X86OperandMem emission. spec2k builds. #

Patch Set 12 : Fix GetIP placement bug. Update spec2k build script. #

Patch Set 13 : Fix szbuild_spec2k.py --run for --sandbox and --nonsfi. #

Patch Set 14 : Works for filetype=obj #

Patch Set 15 : Minor cleanup #

Patch Set 16 : Simplify getIP emission #

Patch Set 17 : Cleanup #

Patch Set 18 : Fill in part of the lit test #

Total comments: 28

Patch Set 19 : Code review changes #

Patch Set 20 : Fix some regressions. Remove crosstest.py --crosstest-bitcode. #

Patch Set 21 : Cross tests #

Patch Set 22 : Clean up some python ternary operator stuff #

Patch Set 23 : Complete lit test. Improve address mode inference. #

Patch Set 24 : Refactor the link commands #

Total comments: 22

Patch Set 25 : Rebase #

Patch Set 26 : Code review changes #

Unified diffs Side-by-side diffs Delta from patch set Stats (+1120 lines, -336 lines) Patch
M Makefile.standalone View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 2 chunks +9 lines, -2 lines 0 comments Download
M crosstest/crosstest.cfg View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 1 chunk +0 lines, -3 lines 0 comments Download
M crosstest/test_arith_main.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 6 chunks +5 lines, -6 lines 0 comments Download
M crosstest/test_global_main.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 1 chunk +5 lines, -0 lines 0 comments Download
M crosstest/test_icmp_main.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 4 chunks +4 lines, -4 lines 0 comments Download
M pydir/build-runtime.py View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 3 chunks +73 lines, -33 lines 0 comments Download
M pydir/crosstest.py View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 8 chunks +106 lines, -41 lines 0 comments Download
M pydir/crosstest_generator.py View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 4 chunks +9 lines, -2 lines 0 comments Download
M pydir/szbuild.py View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 9 chunks +131 lines, -68 lines 0 comments Download
M pydir/szbuild_spec2k.py View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 3 chunks +8 lines, -2 lines 0 comments Download
M pydir/utils.py View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 1 chunk +9 lines, -0 lines 0 comments Download
A runtime/szrt_asm_arm32.s View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 1 chunk +16 lines, -0 lines 0 comments Download
A runtime/szrt_asm_x8632.s View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +51 lines, -0 lines 0 comments Download
A runtime/szrt_asm_x8664.s View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +16 lines, -0 lines 0 comments Download
M src/IceAssemblerARM32.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 2 chunks +2 lines, -2 lines 0 comments Download
M src/IceAssemblerX86Base.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 1 chunk +1 line, -1 line 0 comments Download
M src/IceAssemblerX86BaseImpl.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 4 chunks +6 lines, -4 lines 0 comments Download
M src/IceClFlags.h View 1 2 3 4 5 6 7 8 9 10 11 12 2 chunks +7 lines, -0 lines 0 comments Download
M src/IceClFlags.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 3 chunks +5 lines, -0 lines 0 comments Download
M src/IceELFObjectWriter.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 3 chunks +5 lines, -4 lines 0 comments Download
M src/IceELFObjectWriter.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 5 chunks +11 lines, -8 lines 0 comments Download
M src/IceELFSection.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 1 chunk +5 lines, -3 lines 0 comments Download
M src/IceFixups.h View 1 2 3 4 5 6 7 1 chunk +1 line, -1 line 0 comments Download
M src/IceFixups.cpp View 1 2 3 4 5 6 7 3 chunks +6 lines, -2 lines 0 comments Download
M src/IceGlobalContext.cpp View 1 2 3 4 5 6 7 1 chunk +1 line, -1 line 0 comments Download
M src/IceInst.h View 1 2 3 4 5 6 7 8 9 10 2 chunks +7 lines, -4 lines 0 comments Download
M src/IceInst.cpp View 1 2 3 4 5 6 7 8 9 10 1 chunk +4 lines, -3 lines 0 comments Download
M src/IceInstX8632.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 7 chunks +32 lines, -14 lines 0 comments Download
M src/IceInstX8664.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 3 chunks +7 lines, -5 lines 0 comments Download
M src/IceInstX86Base.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 3 chunks +22 lines, -0 lines 0 comments Download
M src/IceInstX86BaseImpl.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 5 chunks +58 lines, -2 lines 0 comments Download
M src/IceOperand.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 chunk +2 lines, -1 line 0 comments Download
M src/IceOperand.cpp View 1 2 3 4 5 6 7 1 chunk +3 lines, -3 lines 0 comments Download
M src/IceTargetLowering.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 4 chunks +10 lines, -5 lines 0 comments Download
M src/IceTargetLowering.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 8 chunks +13 lines, -15 lines 0 comments Download
M src/IceTargetLoweringARM32.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 3 chunks +4 lines, -6 lines 0 comments Download
M src/IceTargetLoweringARM32.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 6 chunks +18 lines, -5 lines 0 comments Download
M src/IceTargetLoweringMIPS32.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 4 chunks +11 lines, -8 lines 0 comments Download
M src/IceTargetLoweringMIPS32.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 3 chunks +8 lines, -3 lines 0 comments Download
M src/IceTargetLoweringX8632.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 8 chunks +61 lines, -8 lines 0 comments Download
M src/IceTargetLoweringX8632Traits.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 4 chunks +14 lines, -7 lines 0 comments Download
M src/IceTargetLoweringX8664.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 5 chunks +17 lines, -5 lines 0 comments Download
M src/IceTargetLoweringX8664Traits.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 5 chunks +12 lines, -6 lines 0 comments Download
M src/IceTargetLoweringX86Base.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 6 chunks +20 lines, -5 lines 0 comments Download
M src/IceTargetLoweringX86BaseImpl.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 43 chunks +188 lines, -41 lines 0 comments Download
M tests_lit/llvm2ice_tests/adv-switch-opt.ll View 1 2 1 chunk +2 lines, -3 lines 0 comments Download
A tests_lit/llvm2ice_tests/nonsfi.ll View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 1 chunk +115 lines, -0 lines 0 comments Download

Messages

Total messages: 12 (5 generated)
Jim Stichnoth
I need to do a little bit more for the nonsfi.ll test, but otherwise it's ...
5 years ago (2015-12-18 22:22:58 UTC) #3
John
I am not done yet, but here are my initial thoughts. https://codereview.chromium.org/1506653002/diff/330001/pydir/build-runtime.py File pydir/build-runtime.py (right): ...
5 years ago (2015-12-22 15:44:38 UTC) #4
Jim Stichnoth
Also added some plumbing for cross tests, though the actual compilation/linking doesn't work yet. https://codereview.chromium.org/1506653002/diff/330001/pydir/build-runtime.py ...
4 years, 12 months ago (2015-12-28 07:54:07 UTC) #5
Jim Stichnoth
ptal
4 years, 11 months ago (2015-12-30 07:08:49 UTC) #7
John
lgtm https://codereview.chromium.org/1506653002/diff/450001/crosstest/test_arith_main.cpp File crosstest/test_arith_main.cpp (right): https://codereview.chromium.org/1506653002/diff/450001/crosstest/test_arith_main.cpp#newcode378 crosstest/test_arith_main.cpp:378: #endif // ARM32 please update these comments https://codereview.chromium.org/1506653002/diff/450001/crosstest/test_global_main.cpp ...
4 years, 11 months ago (2016-01-04 21:33:52 UTC) #9
Jim Stichnoth
https://codereview.chromium.org/1506653002/diff/450001/crosstest/test_arith_main.cpp File crosstest/test_arith_main.cpp (right): https://codereview.chromium.org/1506653002/diff/450001/crosstest/test_arith_main.cpp#newcode378 crosstest/test_arith_main.cpp:378: #endif // ARM32 On 2016/01/04 21:33:51, John wrote: > ...
4 years, 11 months ago (2016-01-04 23:32:12 UTC) #10
Jim Stichnoth
4 years, 11 months ago (2016-01-04 23:39:10 UTC) #12
Message was sent while issue was closed.
Committed patchset #26 (id:490001) manually as
8ff4b2819944bc4f02fb29204a1fa5ba7dea5682 (presubmit successful).

Powered by Google App Engine
This is Rietveld 408576698