1 /* { dg-do compile } */
2 /* { dg-additional-options "-Wno-return-type" } */
3 /* { dg-require-visibility "" } */
5 typedef unsigned int size_t;
6 namespace std __attribute__ ((__visibility__ ("default")))
8 template < typename _Iterator > struct iterator_traits
11 template < typename _Tp > struct iterator_traits <_Tp * >
13 typedef _Tp & reference;
17 namespace __gnu_cxx __attribute__ ((__visibility__ ("default")))
19 using std::iterator_traits;
20 template < typename _Iterator, typename _Container > class __normal_iterator
22 public:typedef _Iterator iterator_type;
23 typedef typename iterator_traits < _Iterator >::reference reference;
24 reference operator* () const
27 __normal_iterator operator++ (int)
31 template < typename _IteratorL, typename _IteratorR,
32 typename _Container > inline bool operator!= (const __normal_iterator <
35 const __normal_iterator <
46 __extension__ typedef __SIZE_TYPE__ __intptr_t;
49 namespace __gnu_cxx __attribute__ ((__visibility__ ("default")))
51 template < typename _Tp > class new_allocator
53 public:typedef size_t size_type;
55 template < typename _Tp1 > struct rebind
57 typedef new_allocator < _Tp1 > other;
62 namespace std __attribute__ ((__visibility__ ("default")))
64 template < typename _Tp > class allocator:public __gnu_cxx::new_allocator <
72 typedef __intptr_t intptr_t;
76 template < typename NodeTy > class ilist_half_node
79 template < typename NodeTy > class ilist_node:private ilist_half_node <
83 class MachineBasicBlock;
86 public:enum MachineOperandType
90 unsigned getReg () const
94 class TargetRegisterInfo;
97 namespace std __attribute__ ((__visibility__ ("default")))
99 template < typename _Tp, typename _Alloc > struct _Vector_base
101 typedef typename _Alloc::template rebind < _Tp >::other _Tp_alloc_type;
103 template < typename _Tp, typename _Alloc = std::allocator < _Tp > >class vector:protected _Vector_base < _Tp,
107 typedef _Vector_base < _Tp, _Alloc > _Base;
108 typedef typename _Base::_Tp_alloc_type _Tp_alloc_type;
109 public:typedef _Tp value_type;
110 typedef typename _Tp_alloc_type::pointer pointer;
111 typedef __gnu_cxx::__normal_iterator < pointer, vector > iterator;
123 class MachineFunction;
124 class MachineInstr:public ilist_node < MachineInstr >
126 public:const MachineBasicBlock *getParent () const
129 const MachineOperand & getOperand (unsigned i) const
132 bool registerDefIsDead (unsigned Reg, const TargetRegisterInfo * TRI =
137 class AnalysisResolver;
140 AnalysisResolver *Resolver;
142 public: explicit Pass (intptr_t pid):Resolver (0), PassID (pid)
145 explicit Pass (const void *pid):Resolver (0), PassID ((intptr_t) pid)
148 template < typename AnalysisType > AnalysisType & getAnalysis () const;
150 class FunctionPass:public Pass
152 public:explicit FunctionPass (intptr_t pid):Pass (pid)
155 explicit FunctionPass (const void *pid):Pass (pid)
161 public:typedef Pass *(*NormalCtor_t) ();
162 private:const char *const PassName;
163 const char *const PassArgument;
164 const intptr_t PassID;
165 const bool IsCFGOnlyPass;
166 const bool IsAnalysis;
167 const bool IsAnalysisGroup;
168 NormalCtor_t NormalCtor;
169 public: PassInfo (const char *name, const char *arg, intptr_t pi, NormalCtor_t normal = 0, bool isCFGOnly = false, bool is_analysis = false):PassName (name), PassArgument (arg), PassID (pi),
170 IsCFGOnlyPass (isCFGOnly), IsAnalysis (is_analysis),
171 IsAnalysisGroup (false), NormalCtor (normal)
175 template < typename PassName > Pass * callDefaultCtor ()
177 return new PassName ();
179 template < typename passName > struct RegisterPass:public PassInfo
181 RegisterPass (const char *PassArg, const char *Name, bool CFGOnly = false, bool is_analysis = false):PassInfo (Name, PassArg, intptr_t (&passName::ID),
182 PassInfo::NormalCtor_t (callDefaultCtor < passName >), CFGOnly,
187 template < typename T > class SmallVectorImpl
190 template < typename T,
191 unsigned N > class SmallVector:public SmallVectorImpl < T >
194 class MachineFunctionPass:public FunctionPass
196 protected:explicit MachineFunctionPass (intptr_t ID):FunctionPass (ID)
199 explicit MachineFunctionPass (void *ID):FunctionPass (ID)
202 virtual bool runOnMachineFunction (MachineFunction & MF) = 0;
206 private:unsigned index;
219 public:typedef SmallVector < LiveRange, 4 > Ranges;
220 bool containsOneValue () const
223 LiveRange *getLiveRangeContaining (LiveIndex Idx)
226 void removeRange (LiveIndex Start, LiveIndex End, bool RemoveDeadValNo =
228 void removeRange (LiveRange LR, bool RemoveDeadValNo = false)
230 removeRange (LR.start, LR.end, RemoveDeadValNo);
233 class LiveIntervals:public MachineFunctionPass
235 public:static char ID;
236 LiveIndex getDefIndex (LiveIndex index)
239 LiveInterval & getInterval (unsigned reg)
242 LiveIndex getInstructionIndex (const MachineInstr * instr) const
248 using namespace llvm;
251 struct __attribute__ ((visibility ("hidden"))) StrongPHIElimination:public
255 StrongPHIElimination ():MachineFunctionPass (&ID)
258 bool runOnMachineFunction (MachineFunction & Fn);
262 static RegisterPass < StrongPHIElimination > X ("strong-phi-node-elimination",
263 "Eliminate PHI nodes for register allocation, intelligently");
265 StrongPHIElimination::runOnMachineFunction (MachineFunction & Fn)
267 LiveIntervals & LI = getAnalysis < LiveIntervals > ();
268 std::vector < MachineInstr * >phis;
269 for (std::vector < MachineInstr * >::iterator I = phis.begin (), E =
270 phis.end (); I != E;)
272 MachineInstr *PInstr = *(I++);
273 unsigned DestReg = PInstr->getOperand (0).getReg ();
274 LiveInterval & PI = LI.getInterval (DestReg);
275 if (PInstr->registerDefIsDead (DestReg))
277 if (PI.containsOneValue ())
280 LI.getDefIndex (LI.getInstructionIndex (PInstr));
281 PI.removeRange (*PI.getLiveRangeContaining (idx), true);