OLD | NEW |
1 //===-- ARMNaClRewritePass.cpp - Native Client Rewrite Pass ------*- C++ -*-=// | 1 //===-- ARMNaClRewritePass.cpp - Native Client Rewrite Pass ------*- 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 // Native Client Rewrite Pass | 10 // Native Client Rewrite Pass |
(...skipping 12 matching lines...) Expand all Loading... |
23 | 23 |
24 #define DEBUG_TYPE "arm-sfi" | 24 #define DEBUG_TYPE "arm-sfi" |
25 #include "ARM.h" | 25 #include "ARM.h" |
26 #include "ARMBaseInstrInfo.h" | 26 #include "ARMBaseInstrInfo.h" |
27 #include "ARMNaClRewritePass.h" | 27 #include "ARMNaClRewritePass.h" |
28 #include "llvm/CodeGen/MachineFunctionPass.h" | 28 #include "llvm/CodeGen/MachineFunctionPass.h" |
29 #include "llvm/CodeGen/MachineInstrBuilder.h" | 29 #include "llvm/CodeGen/MachineInstrBuilder.h" |
30 #include "llvm/IR/Function.h" | 30 #include "llvm/IR/Function.h" |
31 #include "llvm/Support/Debug.h" | 31 #include "llvm/Support/Debug.h" |
32 #include "llvm/Support/raw_ostream.h" | 32 #include "llvm/Support/raw_ostream.h" |
33 #include "llvm/Target/TargetMachine.h" | 33 #include "llvm/Target/TargetSubtargetInfo.h" |
34 #include <set> | 34 #include <set> |
35 #include <stdio.h> | 35 #include <stdio.h> |
36 | 36 |
37 using namespace llvm; | 37 using namespace llvm; |
38 | 38 |
39 namespace { | 39 namespace { |
40 class ARMNaClRewritePass : public MachineFunctionPass { | 40 class ARMNaClRewritePass : public MachineFunctionPass { |
41 public: | 41 public: |
42 static char ID; | 42 static char ID; |
43 ARMNaClRewritePass() : MachineFunctionPass(ID) {} | 43 ARMNaClRewritePass() : MachineFunctionPass(ID) {} |
(...skipping 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1049 SandboxMemory(MBB, MBBI, MI, AddrIdx, false); | 1049 SandboxMemory(MBB, MBBI, MI, AddrIdx, false); |
1050 Modified = true; | 1050 Modified = true; |
1051 } | 1051 } |
1052 } | 1052 } |
1053 return Modified; | 1053 return Modified; |
1054 } | 1054 } |
1055 | 1055 |
1056 /**********************************************************************/ | 1056 /**********************************************************************/ |
1057 | 1057 |
1058 bool ARMNaClRewritePass::runOnMachineFunction(MachineFunction &MF) { | 1058 bool ARMNaClRewritePass::runOnMachineFunction(MachineFunction &MF) { |
1059 TII = static_cast<const ARMBaseInstrInfo*>(MF.getTarget().getInstrInfo()); | 1059 TII = static_cast<const ARMBaseInstrInfo*>(MF.getSubtarget().getInstrInfo()); |
1060 TRI = MF.getTarget().getRegisterInfo(); | 1060 TRI = MF.getSubtarget().getRegisterInfo(); |
1061 | 1061 |
1062 bool Modified = false; | 1062 bool Modified = false; |
1063 for (MachineFunction::iterator MFI = MF.begin(), E = MF.end(); | 1063 for (MachineFunction::iterator MFI = MF.begin(), E = MF.end(); |
1064 MFI != E; | 1064 MFI != E; |
1065 ++MFI) { | 1065 ++MFI) { |
1066 MachineBasicBlock &MBB = *MFI; | 1066 MachineBasicBlock &MBB = *MFI; |
1067 | 1067 |
1068 if (MBB.hasAddressTaken()) { | 1068 if (MBB.hasAddressTaken()) { |
1069 //FIXME: use symbolic constant or get this value from some configuration | 1069 //FIXME: use symbolic constant or get this value from some configuration |
1070 MBB.setAlignment(4); | 1070 MBB.setAlignment(4); |
1071 Modified = true; | 1071 Modified = true; |
1072 } | 1072 } |
1073 | 1073 |
1074 Modified |= SandboxMemoryReferencesInBlock(MBB); | 1074 Modified |= SandboxMemoryReferencesInBlock(MBB); |
1075 Modified |= SandboxBranchesInBlock(MBB); | 1075 Modified |= SandboxBranchesInBlock(MBB); |
1076 Modified |= SandboxStackChangesInBlock(MBB); | 1076 Modified |= SandboxStackChangesInBlock(MBB); |
1077 } | 1077 } |
1078 DEBUG(LightweightVerify(MF)); | 1078 DEBUG(LightweightVerify(MF)); |
1079 return Modified; | 1079 return Modified; |
1080 } | 1080 } |
1081 | 1081 |
1082 /// createARMNaClRewritePass - returns an instance of the NaClRewritePass. | 1082 /// createARMNaClRewritePass - returns an instance of the NaClRewritePass. |
1083 FunctionPass *llvm::createARMNaClRewritePass() { | 1083 FunctionPass *llvm::createARMNaClRewritePass() { |
1084 return new ARMNaClRewritePass(); | 1084 return new ARMNaClRewritePass(); |
1085 } | 1085 } |
OLD | NEW |