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

Side by Side Diff: lib/CodeGen/BranchFolding.cpp

Issue 939073008: Rebased PNaCl localmods in LLVM to 223109 (Closed)
Patch Set: undo localmod Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/CodeGen/AsmPrinter/DwarfDebug.cpp ('k') | lib/CodeGen/LLVMTargetMachine.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===-- BranchFolding.cpp - Fold machine code branch instructions ---------===// 1 //===-- BranchFolding.cpp - Fold machine code branch instructions ---------===//
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 pass forwards branches to unconditional branches to make them branch 10 // This pass forwards branches to unconditional branches to make them branch
11 // directly to the target block. This pass often results in dead MBB's, which 11 // directly to the target block. This pass often results in dead MBB's, which
12 // it then removes. 12 // it then removes.
13 // 13 //
14 // Note that this pass must be run after register allocation, it cannot handle 14 // Note that this pass must be run after register allocation, it cannot handle
15 // SSA form. 15 // SSA form.
16 // 16 //
17 //===----------------------------------------------------------------------===// 17 //===----------------------------------------------------------------------===//
18 18
19 #include "BranchFolding.h" 19 #include "BranchFolding.h"
20 #include "llvm/ADT/STLExtras.h" 20 #include "llvm/ADT/STLExtras.h"
21 #include "llvm/ADT/SmallSet.h" 21 #include "llvm/ADT/SmallSet.h"
22 #include "llvm/ADT/Statistic.h" 22 #include "llvm/ADT/Statistic.h"
23 #include "llvm/CodeGen/MachineBlockFrequencyInfo.h" 23 #include "llvm/CodeGen/MachineBlockFrequencyInfo.h"
24 #include "llvm/CodeGen/MachineBranchProbabilityInfo.h" 24 #include "llvm/CodeGen/MachineBranchProbabilityInfo.h"
25 #include "llvm/CodeGen/MachineConstantPool.h" // @LOCALMOD
25 #include "llvm/CodeGen/MachineFunctionPass.h" 26 #include "llvm/CodeGen/MachineFunctionPass.h"
26 #include "llvm/CodeGen/MachineJumpTableInfo.h" 27 #include "llvm/CodeGen/MachineJumpTableInfo.h"
27 #include "llvm/CodeGen/MachineModuleInfo.h" 28 #include "llvm/CodeGen/MachineModuleInfo.h"
28 #include "llvm/CodeGen/MachineRegisterInfo.h" 29 #include "llvm/CodeGen/MachineRegisterInfo.h"
29 #include "llvm/CodeGen/Passes.h" 30 #include "llvm/CodeGen/Passes.h"
30 #include "llvm/CodeGen/RegisterScavenging.h" 31 #include "llvm/CodeGen/RegisterScavenging.h"
31 #include "llvm/IR/Function.h" 32 #include "llvm/IR/Function.h"
32 #include "llvm/Support/CommandLine.h" 33 #include "llvm/Support/CommandLine.h"
33 #include "llvm/Support/Debug.h" 34 #include "llvm/Support/Debug.h"
34 #include "llvm/Support/ErrorHandling.h" 35 #include "llvm/Support/ErrorHandling.h"
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 I != E; ++I) 241 I != E; ++I)
241 for (unsigned op = 0, e = I->getNumOperands(); op != e; ++op) { 242 for (unsigned op = 0, e = I->getNumOperands(); op != e; ++op) {
242 MachineOperand &Op = I->getOperand(op); 243 MachineOperand &Op = I->getOperand(op);
243 if (!Op.isJTI()) continue; 244 if (!Op.isJTI()) continue;
244 245
245 // Remember that this JT is live. 246 // Remember that this JT is live.
246 JTIsLive.set(Op.getIndex()); 247 JTIsLive.set(Op.getIndex());
247 } 248 }
248 } 249 }
249 250
251 // @LOCALMOD-START
252 // This currently only used on ARM targets where the ConstantPool
253 // subclass is overloading getJumpTableIndex()
254 const std::vector<MachineConstantPoolEntry>& CPs =
255 MF.getConstantPool()->getConstants();
256 for (unsigned i = 0, e = CPs.size(); i != e; ++i) {
257 if (!CPs[i].isMachineConstantPoolEntry()) continue;
258 unsigned *JTIndex = CPs[i].Val.MachineCPVal->getJumpTableIndex();
259 if (!JTIndex) continue;
260 // Remember that this JT is live.
261 JTIsLive.set(*JTIndex);
262 }
263 // @LOCALMOD-END
264
250 // Finally, remove dead jump tables. This happens when the 265 // Finally, remove dead jump tables. This happens when the
251 // indirect jump was unreachable (and thus deleted). 266 // indirect jump was unreachable (and thus deleted).
252 for (unsigned i = 0, e = JTIsLive.size(); i != e; ++i) 267 for (unsigned i = 0, e = JTIsLive.size(); i != e; ++i)
253 if (!JTIsLive.test(i)) { 268 if (!JTIsLive.test(i)) {
254 JTI->RemoveJumpTable(i); 269 JTI->RemoveJumpTable(i);
255 MadeChange = true; 270 MadeChange = true;
256 } 271 }
257 272
258 delete RS; 273 delete RS;
259 return MadeChange; 274 return MadeChange;
(...skipping 1543 matching lines...) Expand 10 before | Expand all | Expand 10 after
1803 unsigned Def = LocalDefs[i]; 1818 unsigned Def = LocalDefs[i];
1804 if (LocalDefsSet.count(Def)) { 1819 if (LocalDefsSet.count(Def)) {
1805 TBB->addLiveIn(Def); 1820 TBB->addLiveIn(Def);
1806 FBB->addLiveIn(Def); 1821 FBB->addLiveIn(Def);
1807 } 1822 }
1808 } 1823 }
1809 1824
1810 ++NumHoist; 1825 ++NumHoist;
1811 return true; 1826 return true;
1812 } 1827 }
OLDNEW
« no previous file with comments | « lib/CodeGen/AsmPrinter/DwarfDebug.cpp ('k') | lib/CodeGen/LLVMTargetMachine.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698