111
|
1 /* { dg-do compile } */
|
131
|
2 /* { dg-additional-options "-Wno-return-type" } */
|
111
|
3 /* { dg-require-visibility "" } */
|
|
4
|
|
5 typedef unsigned int size_t;
|
|
6 namespace std __attribute__ ((__visibility__ ("default")))
|
|
7 {
|
|
8 template < typename _Iterator > struct iterator_traits
|
|
9 {
|
|
10 };
|
|
11 template < typename _Tp > struct iterator_traits <_Tp * >
|
|
12 {
|
|
13 typedef _Tp & reference;
|
|
14 };
|
|
15 }
|
|
16
|
|
17 namespace __gnu_cxx __attribute__ ((__visibility__ ("default")))
|
|
18 {
|
|
19 using std::iterator_traits;
|
|
20 template < typename _Iterator, typename _Container > class __normal_iterator
|
|
21 {
|
|
22 public:typedef _Iterator iterator_type;
|
|
23 typedef typename iterator_traits < _Iterator >::reference reference;
|
|
24 reference operator* () const
|
|
25 {
|
|
26 }
|
|
27 __normal_iterator operator++ (int)
|
|
28 {
|
|
29 }
|
|
30 };
|
|
31 template < typename _IteratorL, typename _IteratorR,
|
|
32 typename _Container > inline bool operator!= (const __normal_iterator <
|
|
33 _IteratorL,
|
|
34 _Container > &__lhs,
|
|
35 const __normal_iterator <
|
|
36 _IteratorR,
|
|
37 _Container > &__rhs)
|
|
38 {
|
|
39 }
|
|
40 }
|
|
41
|
|
42 extern "C"
|
|
43 {
|
|
44 extern "C"
|
|
45 {
|
|
46 __extension__ typedef __SIZE_TYPE__ __intptr_t;
|
|
47 }
|
|
48 }
|
|
49 namespace __gnu_cxx __attribute__ ((__visibility__ ("default")))
|
|
50 {
|
|
51 template < typename _Tp > class new_allocator
|
|
52 {
|
|
53 public:typedef size_t size_type;
|
|
54 typedef _Tp *pointer;
|
|
55 template < typename _Tp1 > struct rebind
|
|
56 {
|
|
57 typedef new_allocator < _Tp1 > other;
|
|
58 };
|
|
59 };
|
|
60 }
|
|
61
|
|
62 namespace std __attribute__ ((__visibility__ ("default")))
|
|
63 {
|
|
64 template < typename _Tp > class allocator:public __gnu_cxx::new_allocator <
|
|
65 _Tp >
|
|
66 {
|
|
67 };
|
|
68 }
|
|
69
|
|
70 extern "C"
|
|
71 {
|
|
72 typedef __intptr_t intptr_t;
|
|
73 }
|
|
74 namespace llvm
|
|
75 {
|
|
76 template < typename NodeTy > class ilist_half_node
|
|
77 {
|
|
78 };
|
|
79 template < typename NodeTy > class ilist_node:private ilist_half_node <
|
|
80 NodeTy >
|
|
81 {
|
|
82 };
|
|
83 class MachineBasicBlock;
|
|
84 class MachineOperand
|
|
85 {
|
|
86 public:enum MachineOperandType
|
|
87 {
|
|
88 }
|
|
89 Contents;
|
|
90 unsigned getReg () const
|
|
91 {
|
|
92 }
|
|
93 };
|
|
94 class TargetRegisterInfo;
|
|
95 }
|
|
96
|
|
97 namespace std __attribute__ ((__visibility__ ("default")))
|
|
98 {
|
|
99 template < typename _Tp, typename _Alloc > struct _Vector_base
|
|
100 {
|
|
101 typedef typename _Alloc::template rebind < _Tp >::other _Tp_alloc_type;
|
|
102 };
|
|
103 template < typename _Tp, typename _Alloc = std::allocator < _Tp > >class vector:protected _Vector_base < _Tp,
|
|
104 _Alloc
|
|
105 >
|
|
106 {
|
|
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;
|
|
112 iterator begin ()
|
|
113 {
|
|
114 }
|
|
115 iterator end ()
|
|
116 {
|
|
117 }
|
|
118 };
|
|
119 }
|
|
120
|
|
121 namespace llvm
|
|
122 {
|
|
123 class MachineFunction;
|
|
124 class MachineInstr:public ilist_node < MachineInstr >
|
|
125 {
|
|
126 public:const MachineBasicBlock *getParent () const
|
|
127 {
|
|
128 }
|
|
129 const MachineOperand & getOperand (unsigned i) const
|
|
130 {
|
|
131 }
|
|
132 bool registerDefIsDead (unsigned Reg, const TargetRegisterInfo * TRI =
|
|
133 __null) const
|
|
134 {
|
|
135 }
|
|
136 };
|
|
137 class AnalysisResolver;
|
|
138 class Pass
|
|
139 {
|
|
140 AnalysisResolver *Resolver;
|
|
141 intptr_t PassID;
|
|
142 public: explicit Pass (intptr_t pid):Resolver (0), PassID (pid)
|
|
143 {
|
|
144 }
|
|
145 explicit Pass (const void *pid):Resolver (0), PassID ((intptr_t) pid)
|
|
146 {
|
|
147 }
|
|
148 template < typename AnalysisType > AnalysisType & getAnalysis () const;
|
|
149 };
|
|
150 class FunctionPass:public Pass
|
|
151 {
|
|
152 public:explicit FunctionPass (intptr_t pid):Pass (pid)
|
|
153 {
|
|
154 }
|
|
155 explicit FunctionPass (const void *pid):Pass (pid)
|
|
156 {
|
|
157 }
|
|
158 };
|
|
159 class PassInfo
|
|
160 {
|
|
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)
|
|
172 {
|
|
173 }
|
|
174 };
|
|
175 template < typename PassName > Pass * callDefaultCtor ()
|
|
176 {
|
|
177 return new PassName ();
|
|
178 }
|
|
179 template < typename passName > struct RegisterPass:public PassInfo
|
|
180 {
|
|
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,
|
|
183 is_analysis)
|
|
184 {
|
|
185 }
|
|
186 };
|
|
187 template < typename T > class SmallVectorImpl
|
|
188 {
|
|
189 };
|
|
190 template < typename T,
|
|
191 unsigned N > class SmallVector:public SmallVectorImpl < T >
|
|
192 {
|
|
193 };
|
|
194 class MachineFunctionPass:public FunctionPass
|
|
195 {
|
|
196 protected:explicit MachineFunctionPass (intptr_t ID):FunctionPass (ID)
|
|
197 {
|
|
198 }
|
|
199 explicit MachineFunctionPass (void *ID):FunctionPass (ID)
|
|
200 {
|
|
201 }
|
|
202 virtual bool runOnMachineFunction (MachineFunction & MF) = 0;
|
|
203 };
|
|
204 class LiveIndex
|
|
205 {
|
|
206 private:unsigned index;
|
|
207 };
|
|
208 class VNInfo
|
|
209 {
|
|
210 };
|
|
211 struct LiveRange
|
|
212 {
|
|
213 LiveIndex start;
|
|
214 LiveIndex end;
|
|
215 VNInfo *valno;
|
|
216 };
|
|
217 class LiveInterval
|
|
218 {
|
|
219 public:typedef SmallVector < LiveRange, 4 > Ranges;
|
|
220 bool containsOneValue () const
|
|
221 {
|
|
222 }
|
|
223 LiveRange *getLiveRangeContaining (LiveIndex Idx)
|
|
224 {
|
|
225 }
|
|
226 void removeRange (LiveIndex Start, LiveIndex End, bool RemoveDeadValNo =
|
|
227 false);
|
|
228 void removeRange (LiveRange LR, bool RemoveDeadValNo = false)
|
|
229 {
|
|
230 removeRange (LR.start, LR.end, RemoveDeadValNo);
|
|
231 }
|
|
232 };
|
|
233 class LiveIntervals:public MachineFunctionPass
|
|
234 {
|
|
235 public:static char ID;
|
|
236 LiveIndex getDefIndex (LiveIndex index)
|
|
237 {
|
|
238 }
|
|
239 LiveInterval & getInterval (unsigned reg)
|
|
240 {
|
|
241 }
|
|
242 LiveIndex getInstructionIndex (const MachineInstr * instr) const
|
|
243 {
|
|
244 }
|
|
245 };
|
|
246 }
|
|
247
|
|
248 using namespace llvm;
|
|
249 namespace
|
|
250 {
|
|
251 struct __attribute__ ((visibility ("hidden"))) StrongPHIElimination:public
|
|
252 MachineFunctionPass
|
|
253 {
|
|
254 static char ID;
|
|
255 StrongPHIElimination ():MachineFunctionPass (&ID)
|
|
256 {
|
|
257 }
|
|
258 bool runOnMachineFunction (MachineFunction & Fn);
|
|
259 };
|
|
260 }
|
|
261
|
|
262 static RegisterPass < StrongPHIElimination > X ("strong-phi-node-elimination",
|
|
263 "Eliminate PHI nodes for register allocation, intelligently");
|
|
264 bool
|
|
265 StrongPHIElimination::runOnMachineFunction (MachineFunction & Fn)
|
|
266 {
|
|
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;)
|
|
271 {
|
|
272 MachineInstr *PInstr = *(I++);
|
|
273 unsigned DestReg = PInstr->getOperand (0).getReg ();
|
|
274 LiveInterval & PI = LI.getInterval (DestReg);
|
|
275 if (PInstr->registerDefIsDead (DestReg))
|
|
276 {
|
|
277 if (PI.containsOneValue ())
|
|
278 {
|
|
279 LiveIndex idx =
|
|
280 LI.getDefIndex (LI.getInstructionIndex (PInstr));
|
|
281 PI.removeRange (*PI.getLiveRangeContaining (idx), true);
|
|
282 }
|
|
283 }
|
|
284 }
|
|
285 }
|