File tree 2 files changed +22
-21
lines changed
2 files changed +22
-21
lines changed Original file line number Diff line number Diff line change @@ -209,6 +209,21 @@ pub struct PassManager<T> {
209
209
sub_type : PhantomData < T > ,
210
210
}
211
211
212
+ impl PassManager < FunctionValue > {
213
+ // return true means some pass modified the module, not an error occurred
214
+ pub fn initialize ( & self ) -> bool {
215
+ unsafe {
216
+ LLVMInitializeFunctionPassManager ( self . pass_manager ) == 1
217
+ }
218
+ }
219
+
220
+ pub fn finalize ( & self ) -> bool {
221
+ unsafe {
222
+ LLVMFinalizeFunctionPassManager ( self . pass_manager ) == 1
223
+ }
224
+ }
225
+ }
226
+
212
227
impl < T : PassManagerSubType > PassManager < T > {
213
228
pub ( crate ) fn new ( pass_manager : LLVMPassManagerRef ) -> Self {
214
229
assert ! ( !pass_manager. is_null( ) ) ;
@@ -227,19 +242,6 @@ impl<T: PassManagerSubType> PassManager<T> {
227
242
PassManager :: new ( pass_manager)
228
243
}
229
244
230
- // return true means some pass modified the module, not an error occurred
231
- pub fn initialize ( & self ) -> bool {
232
- unsafe {
233
- LLVMInitializeFunctionPassManager ( self . pass_manager ) == 1
234
- }
235
- }
236
-
237
- pub fn finalize ( & self ) -> bool {
238
- unsafe {
239
- LLVMFinalizeFunctionPassManager ( self . pass_manager ) == 1
240
- }
241
- }
242
-
243
245
/// This method returns true if any of the passes modified the function or module
244
246
/// and false otherwise.
245
247
pub fn run_on ( & self , input : & T ) -> bool {
Original file line number Diff line number Diff line change @@ -82,15 +82,7 @@ fn test_init_all_passes_for_module() {
82
82
pass_manager. add_loop_unroll_and_jam_pass ( ) ;
83
83
}
84
84
85
- assert ! ( !pass_manager. initialize( ) ) ;
86
- assert ! ( !pass_manager. finalize( ) ) ;
87
-
88
85
pass_manager. run_on ( & module) ;
89
-
90
- assert ! ( !pass_manager. initialize( ) ) ;
91
- assert ! ( !pass_manager. finalize( ) ) ;
92
-
93
- // TODO: Test when initialize and finalize are true
94
86
}
95
87
96
88
#[ test]
@@ -120,11 +112,18 @@ fn test_pass_manager_builder() {
120
112
builder. position_at_end ( & entry) ;
121
113
builder. build_return ( None ) ;
122
114
115
+ #[ cfg( not( feature = "llvm3-7" ) ) ]
116
+ assert ! ( !fn_pass_manager. initialize( ) ) ;
117
+ #[ cfg( feature = "llvm3-7" ) ]
118
+ fn_pass_manager. initialize ( ) ;
119
+
123
120
// TODO: Test with actual changes? Would be true in that case
124
121
// REVIEW: Segfaults in 4.0
125
122
#[ cfg( not( feature = "llvm4-0" ) ) ]
126
123
assert ! ( !fn_pass_manager. run_on( & fn_value) ) ;
127
124
125
+ assert ! ( !fn_pass_manager. finalize( ) ) ;
126
+
128
127
let module_pass_manager = PassManager :: create ( ( ) ) ;
129
128
130
129
pass_manager_builder. populate_module_pass_manager ( & module_pass_manager) ;
You can’t perform that action at this time.
0 commit comments