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

Side by Side Diff: lib/Transforms/Scalar/CodeGenPrepare.cpp

Issue 183273009: Prep for merging 3.4: Undo changes from 3.3 branch (Closed) Base URL: http://git.chromium.org/native_client/pnacl-llvm.git@master
Patch Set: Retry Created 6 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
OLDNEW
1 //===- CodeGenPrepare.cpp - Prepare a function for code generation --------===// 1 //===- CodeGenPrepare.cpp - Prepare a function for code generation --------===//
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 munges the code in the input function to better prepare it for 10 // This pass munges the code in the input function to better prepare it for
11 // SelectionDAG-based code generation. This works around limitations in it's 11 // SelectionDAG-based code generation. This works around limitations in it's
12 // basic-block-at-a-time approach. It should eventually be removed. 12 // basic-block-at-a-time approach. It should eventually be removed.
13 // 13 //
14 //===----------------------------------------------------------------------===// 14 //===----------------------------------------------------------------------===//
15 15
16 #define DEBUG_TYPE "codegenprepare" 16 #define DEBUG_TYPE "codegenprepare"
17 #include "llvm/Transforms/Scalar.h" 17 #include "llvm/Transforms/Scalar.h"
18 #include "llvm/ADT/DenseMap.h" 18 #include "llvm/ADT/DenseMap.h"
19 #include "llvm/ADT/SmallSet.h" 19 #include "llvm/ADT/SmallSet.h"
20 #include "llvm/ADT/Statistic.h" 20 #include "llvm/ADT/Statistic.h"
21 #include "llvm/ADT/ValueMap.h"
22 #include "llvm/Analysis/DominatorInternals.h" 21 #include "llvm/Analysis/DominatorInternals.h"
23 #include "llvm/Analysis/Dominators.h" 22 #include "llvm/Analysis/Dominators.h"
24 #include "llvm/Analysis/InstructionSimplify.h" 23 #include "llvm/Analysis/InstructionSimplify.h"
25 #include "llvm/Analysis/ProfileInfo.h" 24 #include "llvm/Analysis/ProfileInfo.h"
26 #include "llvm/Assembly/Writer.h" 25 #include "llvm/Assembly/Writer.h"
27 #include "llvm/IR/Constants.h" 26 #include "llvm/IR/Constants.h"
28 #include "llvm/IR/DataLayout.h" 27 #include "llvm/IR/DataLayout.h"
29 #include "llvm/IR/DerivedTypes.h" 28 #include "llvm/IR/DerivedTypes.h"
30 #include "llvm/IR/Function.h" 29 #include "llvm/IR/Function.h"
31 #include "llvm/IR/IRBuilder.h" 30 #include "llvm/IR/IRBuilder.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 ProfileInfo *PFI; 81 ProfileInfo *PFI;
83 82
84 /// CurInstIterator - As we scan instructions optimizing them, this is the 83 /// CurInstIterator - As we scan instructions optimizing them, this is the
85 /// next instruction to optimize. Xforms that can invalidate this should 84 /// next instruction to optimize. Xforms that can invalidate this should
86 /// update it. 85 /// update it.
87 BasicBlock::iterator CurInstIterator; 86 BasicBlock::iterator CurInstIterator;
88 87
89 /// Keeps track of non-local addresses that have been sunk into a block. 88 /// Keeps track of non-local addresses that have been sunk into a block.
90 /// This allows us to avoid inserting duplicate code for blocks with 89 /// This allows us to avoid inserting duplicate code for blocks with
91 /// multiple load/stores of the same address. 90 /// multiple load/stores of the same address.
92 ValueMap<Value*, Value*> SunkAddrs; 91 DenseMap<Value*, Value*> SunkAddrs;
93 92
94 /// ModifiedDT - If CFG is modified in anyway, dominator tree may need to 93 /// ModifiedDT - If CFG is modified in anyway, dominator tree may need to
95 /// be updated. 94 /// be updated.
96 bool ModifiedDT; 95 bool ModifiedDT;
97 96
98 /// OptSize - True if optimizing for size. 97 /// OptSize - True if optimizing for size.
99 bool OptSize; 98 bool OptSize;
100 99
101 public: 100 public:
102 static char ID; // Pass identification, replacement for typeid 101 static char ID; // Pass identification, replacement for typeid
(...skipping 1544 matching lines...) Expand 10 before | Expand all | Expand 10 after
1647 WeakVH IterHandle(CurInstIterator); 1646 WeakVH IterHandle(CurInstIterator);
1648 BasicBlock *BB = CurInstIterator->getParent(); 1647 BasicBlock *BB = CurInstIterator->getParent();
1649 1648
1650 RecursivelyDeleteTriviallyDeadInstructions(Repl, TLInfo); 1649 RecursivelyDeleteTriviallyDeadInstructions(Repl, TLInfo);
1651 1650
1652 if (IterHandle != CurInstIterator) { 1651 if (IterHandle != CurInstIterator) {
1653 // If the iterator instruction was recursively deleted, start over at the 1652 // If the iterator instruction was recursively deleted, start over at the
1654 // start of the block. 1653 // start of the block.
1655 CurInstIterator = BB->begin(); 1654 CurInstIterator = BB->begin();
1656 SunkAddrs.clear(); 1655 SunkAddrs.clear();
1656 } else {
1657 // This address is now available for reassignment, so erase the table
1658 // entry; we don't want to match some completely different instruction.
1659 SunkAddrs[Addr] = 0;
1657 } 1660 }
1658 } 1661 }
1659 ++NumMemoryInsts; 1662 ++NumMemoryInsts;
1660 return true; 1663 return true;
1661 } 1664 }
1662 1665
1663 /// OptimizeInlineAsmInst - If there are any memory operands, use 1666 /// OptimizeInlineAsmInst - If there are any memory operands, use
1664 /// OptimizeMemoryInst to sink their address computing into the block when 1667 /// OptimizeMemoryInst to sink their address computing into the block when
1665 /// possible / profitable. 1668 /// possible / profitable.
1666 bool CodeGenPrepare::OptimizeInlineAsmInst(CallInst *CS) { 1669 bool CodeGenPrepare::OptimizeInlineAsmInst(CallInst *CS) {
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
2000 DVI->insertBefore(VI->getParent()->getFirstInsertionPt()); 2003 DVI->insertBefore(VI->getParent()->getFirstInsertionPt());
2001 else 2004 else
2002 DVI->insertAfter(VI); 2005 DVI->insertAfter(VI);
2003 MadeChange = true; 2006 MadeChange = true;
2004 ++NumDbgValueMoved; 2007 ++NumDbgValueMoved;
2005 } 2008 }
2006 } 2009 }
2007 } 2010 }
2008 return MadeChange; 2011 return MadeChange;
2009 } 2012 }
OLDNEW
« no previous file with comments | « lib/Transforms/InstCombine/InstCombineMulDivRem.cpp ('k') | lib/Transforms/Vectorize/LoopVectorize.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698