OLD | NEW |
1 //=== X86NaClRewritePAss.cpp - Rewrite instructions for NaCl SFI --*- C++ -*-=// | 1 //=== X86NaClRewritePAss.cpp - Rewrite instructions for NaCl SFI --*- C++ -*-=// |
2 // | 2 // |
3 // The LLVM Compiler Infrastructure | 3 // The LLVM Compiler Infrastructure |
4 // | 4 // |
5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
7 // | 7 // |
8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
9 // | 9 // |
10 // This file contains a pass that ensures stores and loads and stack/frame | 10 // This file contains a pass that ensures stores and loads and stack/frame |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 // sandbox base address. | 455 // sandbox base address. |
456 unsigned RegTarget; | 456 unsigned RegTarget; |
457 if (Is64Bit) { | 457 if (Is64Bit) { |
458 RegTarget = (HideSandboxBase ? X86::R11 : X86::RCX); | 458 RegTarget = (HideSandboxBase ? X86::R11 : X86::RCX); |
459 BuildMI(MBB, MBBI, DL, TII->get(X86::POP64r), RegTarget); | 459 BuildMI(MBB, MBBI, DL, TII->get(X86::POP64r), RegTarget); |
460 if (Opc == X86::RETI) { | 460 if (Opc == X86::RETI) { |
461 BuildMI(MBB, MBBI, DL, TII->get(X86::NACL_ASPi32)) | 461 BuildMI(MBB, MBBI, DL, TII->get(X86::NACL_ASPi32)) |
462 .addOperand(MI.getOperand(0)) | 462 .addOperand(MI.getOperand(0)) |
463 .addReg(FlagUseZeroBasedSandbox ? 0 : X86::R15); | 463 .addReg(FlagUseZeroBasedSandbox ? 0 : X86::R15); |
464 } | 464 } |
| 465 |
465 BuildMI(MBB, MBBI, DL, TII->get(X86::NACL_JMP64r)) | 466 BuildMI(MBB, MBBI, DL, TII->get(X86::NACL_JMP64r)) |
466 .addReg(RegTarget) | 467 .addReg(getX86SubSuperRegister(RegTarget, MVT::i32, false)) |
467 .addReg(FlagUseZeroBasedSandbox ? 0 : X86::R15); | 468 .addReg(FlagUseZeroBasedSandbox ? 0 : X86::R15); |
468 } else { | 469 } else { |
469 RegTarget = X86::ECX; | 470 RegTarget = X86::ECX; |
470 BuildMI(MBB, MBBI, DL, TII->get(X86::POP32r), RegTarget); | 471 BuildMI(MBB, MBBI, DL, TII->get(X86::POP32r), RegTarget); |
471 if (Opc == X86::RETI) { | 472 if (Opc == X86::RETI) { |
472 BuildMI(MBB, MBBI, DL, TII->get(X86::ADD32ri), X86::ESP) | 473 BuildMI(MBB, MBBI, DL, TII->get(X86::ADD32ri), X86::ESP) |
473 .addReg(X86::ESP) | 474 .addReg(X86::ESP) |
474 .addOperand(MI.getOperand(0)); | 475 .addOperand(MI.getOperand(0)); |
475 } | 476 } |
476 BuildMI(MBB, MBBI, DL, TII->get(X86::NACL_JMP32r)) | 477 BuildMI(MBB, MBBI, DL, TII->get(X86::NACL_JMP32r)) |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
747 } | 748 } |
748 return Modified; | 749 return Modified; |
749 } | 750 } |
750 | 751 |
751 /// createX86NaClRewritePassPass - returns an instance of the pass. | 752 /// createX86NaClRewritePassPass - returns an instance of the pass. |
752 namespace llvm { | 753 namespace llvm { |
753 FunctionPass* createX86NaClRewritePass() { | 754 FunctionPass* createX86NaClRewritePass() { |
754 return new X86NaClRewritePass(); | 755 return new X86NaClRewritePass(); |
755 } | 756 } |
756 } | 757 } |
OLD | NEW |