@@ -131,7 +131,26 @@ bool fixEntry(Function &main) {
131131 return instToErase.size ();
132132}
133133
134+ // Currently deletes the body of the function. Ideally, this should
135+ // remove users to enable DCE
136+ void handleBlockedFunction (Function &F) { F.deleteBody (); }
137+
134138bool RustFixes::runOnFunction (Function &F) {
139+ // These functions either cause very large BPL files or crash in translation.
140+ // These functions either write to the console, or are in error paths that
141+ // SMACK can otherwise detect.
142+ static const std::vector<StringRef> blocked_fns = {
143+ " _ZN4core3str16slice_error_fail" ,
144+ " _ZN4core3fmt" ,
145+ " __rg_oom" ,
146+ " __rdl_oom" ,
147+ " __alloc_error_handler" ,
148+ " _ZN4core5slice22slice_index_order_fail" ,
149+ " _ZN4core5slice24slice_end_index_len_fail" ,
150+ " _ZN3std2io5Write9write_all" ,
151+ " _ZN3std2io5Write9write_fmt" ,
152+ };
153+
135154 bool result = false ;
136155 if (F.hasName ()) {
137156 StringRef name = F.getName ();
@@ -147,6 +166,12 @@ bool RustFixes::runOnFunction(Function &F) {
147166 if (name == " main" ) {
148167 result |= fixEntry (F);
149168 }
169+ for (auto &blocked : blocked_fns) {
170+ if (name.find (blocked) != StringRef::npos) {
171+ handleBlockedFunction (F);
172+ result = true ;
173+ }
174+ }
150175 result |= replaceSpecialRustFunctions (F);
151176 }
152177
0 commit comments