llvm.org GIT mirror llvm / 4b885ee
Remove and forbid raw_svector_ostream::flush() calls. After r244870 flush() will only compare two null pointers and return, doing nothing but wasting run time. The call is not required any more as the stream and its SmallString are always in sync. Thanks to David Blaikie for reviewing. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@244928 91177308-0d34-0410-b5e6-96231b3b80d8 Yaron Keren 4 years ago
16 changed file(s) with 2 addition(s) and 31 deletion(s). Raw diff Collapse all Expand all
3939 if (TM.addPassesToEmitMC(PM, Ctx, ObjStream))
4040 llvm_unreachable("Target does not support MC emission.");
4141 PM.run(M);
42 ObjStream.flush();
4342 std::unique_ptr ObjBuffer(
4443 new ObjectMemoryBuffer(std::move(ObjBufferSV)));
4544 ErrorOr> Obj =
508508 }
509509 ~raw_svector_ostream() override {}
510510
511 void flush() = delete;
512
511513 /// Return a StringRef for the vector contents.
512514 StringRef str() { return StringRef(OS.data(), OS.size()); }
513515 };
158158 // Initialize passes.
159159 PM.run(*M);
160160 // Flush the output buffer to get the generated code into memory
161 ObjStream.flush();
162161
163162 std::unique_ptr CompiledObjBuffer(
164163 new ObjectMemoryBuffer(std::move(ObjBufferSV)));
252252 void MCAsmStreamer::AddComment(const Twine &T) {
253253 if (!IsVerboseAsm) return;
254254
255 // Make sure that CommentStream is flushed.
256 CommentStream.flush();
257
258255 T.toVector(CommentToEmit);
259256 // Each comment goes on its own line.
260257 CommentToEmit.push_back('\n');
266263 return;
267264 }
268265
269 CommentStream.flush();
270266 StringRef Comments = CommentToEmit;
271267
272268 assert(Comments.back() == '\n' &&
12221218 SmallVector Fixups;
12231219 raw_svector_ostream VecOS(Code);
12241220 Emitter->encodeInstruction(Inst, VecOS, Fixups, STI);
1225 VecOS.flush();
12261221
12271222 // If we are showing fixups, create symbolic markers in the encoded
12281223 // representation. We do this by making a per-bit map to the fixup item index,
985985 SmallString<256> Code;
986986 raw_svector_ostream VecOS(Code);
987987 getEmitter().encodeInstruction(Relaxed, VecOS, Fixups, F.getSubtargetInfo());
988 VecOS.flush();
989988
990989 // Update the fragment.
991990 F.setInst(Relaxed);
10081007 encodeSLEB128(Value, OSE);
10091008 else
10101009 encodeULEB128(Value, OSE);
1011 OSE.flush();
10121010 return OldSize != LF.getContents().size();
10131011 }
10141012
10271025 raw_svector_ostream OSE(Data);
10281026 MCDwarfLineAddr::Encode(Context, getDWARFLinetableParams(), LineDelta,
10291027 AddrDelta, OSE);
1030 OSE.flush();
10311028 return OldSize != Data.size();
10321029 }
10331030
10431040 Data.clear();
10441041 raw_svector_ostream OSE(Data);
10451042 MCDwarfFrameEmitter::EncodeAdvanceLoc(Context, AddrDelta, OSE);
1046 OSE.flush();
10471043 return OldSize != Data.size();
10481044 }
10491045
124124 static void emitComments(LLVMDisasmContext *DC,
125125 formatted_raw_ostream &FormattedOS) {
126126 // Flush the stream before taking its content.
127 DC->CommentStream.flush();
128127 StringRef Comments = DC->CommentsToEmit.str();
129128 // Get the default information for printing a comment.
130129 const MCAsmInfo *MAI = DC->getAsmInfo();
259258 return 0;
260259
261260 case MCDisassembler::Success: {
262 Annotations.flush();
263261 StringRef AnnotationsStr = Annotations.str();
264262
265263 SmallVector InsnStr;
271269 emitLatency(DC, Inst);
272270
273271 emitComments(DC, FormattedOS);
274 OS.flush();
275272
276273 assert(OutStringSize != 0 && "Output buffer cannot be zero size");
277274 size_t OutputSize = std::min(OutStringSize-1, InsnStr.size());
6767 EF->setBundlePadding(static_cast(RequiredBundlePadding));
6868
6969 Assembler.writeFragmentPadding(*EF, FSize, OW);
70 VecOS.flush();
7170 delete OW;
7271
7372 DF->getContents().append(Code.begin(), Code.end());
479478 SmallString<256> Code;
480479 raw_svector_ostream VecOS(Code);
481480 Assembler.getEmitter().encodeInstruction(Inst, VecOS, Fixups, STI);
482 VecOS.flush();
483481
484482 for (unsigned i = 0, e = Fixups.size(); i != e; ++i)
485483 fixSymbolsInTLSFixups(Fixups[i].getValue());
442442 SmallString<256> Code;
443443 raw_svector_ostream VecOS(Code);
444444 getAssembler().getEmitter().encodeInstruction(Inst, VecOS, Fixups, STI);
445 VecOS.flush();
446445
447446 // Add the fixups and data.
448447 for (unsigned i = 0, e = Fixups.size(); i != e; ++i) {
275275 raw_svector_ostream VecOS(Code);
276276 getAssembler().getEmitter().encodeInstruction(Inst, VecOS, IF->getFixups(),
277277 STI);
278 VecOS.flush();
279278 IF->getContents().append(Code.begin(), Code.end());
280279 }
281280
4848 SmallString<256> Code;
4949 raw_svector_ostream VecOS(Code);
5050 getAssembler().getEmitter().encodeInstruction(Inst, VecOS, Fixups, STI);
51 VecOS.flush();
5251
5352 // Add the fixups and data.
5453 for (unsigned i = 0, e = Fixups.size(); i != e; ++i) {
227226
228227 OS << " -aligncomm:\"" << Symbol->getName() << "\","
229228 << Log2_32_Ceil(ByteAlignment);
230 OS.flush();
231229
232230 PushSection();
233231 SwitchSection(MFI->getDrectveSection());
135135 MCCodeEmitter &InstEmitter = ObjStreamer.getAssembler().getEmitter();
136136 InstEmitter.encodeInstruction(TmpInst, CodeStream, Fixups,
137137 MF->getSubtarget());
138 CodeStream.flush();
139
140138 HexLines.resize(HexLines.size() + 1);
141139 std::string &HexLine = HexLines.back();
142140 raw_string_ostream HexStream(HexLine);
242242 SmallString<0> CodeString;
243243 raw_svector_ostream OStream(CodeString);
244244 bool Result = LLVMTargetMachineEmit(T, M, OStream, codegen, ErrorMessage);
245 OStream.flush();
246245
247246 StringRef Data = OStream.str();
248247 *OutMemBuf =
9191 SmallVector Fixups;
9292 raw_svector_ostream VecOS(Code);
9393 CodeEmitter->encodeInstruction(Inst, VecOS, Fixups, STI);
94 VecOS.flush();
9594 CurrentShadowSize += Code.size();
9695 if (CurrentShadowSize >= RequiredShadowSize)
9796 InShadow = false; // The shadow is big enough. Stop counting.
58665866 formatted_raw_ostream &FormattedOS,
58675867 const MCAsmInfo &MAI) {
58685868 // Flush the stream before taking its content.
5869 CommentStream.flush();
58705869 StringRef Comments = CommentsToEmit.str();
58715870 // Get the default information for printing a comment.
58725871 const char *CommentBegin = MAI.getCommentString();
62476246 dumpBytes(ArrayRef(Bytes.data() + Index, Size), outs());
62486247 }
62496248 formatted_raw_ostream FormattedOS(outs());
6250 Annotations.flush();
62516249 StringRef AnnotationsStr = Annotations.str();
62526250 if (isThumb)
62536251 ThumbIP->printInst(&Inst, FormattedOS, AnnotationsStr, *ThumbSTI);
726726 ++I;
727727 }
728728 }
729 OS.flush();
730729
731730 // Emit the string.
732731 O.indent(6) << "AsmString = \"" << OutString << "\";\n";
11191119 raw_svector_ostream S(Decoder);
11201120 unsigned I = 4;
11211121 emitDecoder(S, I, Opc, HasCompleteDecoder);
1122 S.flush();
11231122
11241123 // Using the full decoder string as the key value here is a bit
11251124 // heavyweight, but is effective. If the string comparisons become a
12301229 SmallString<16> PBytes;
12311230 raw_svector_ostream S(PBytes);
12321231 encodeULEB128(PIdx, S);
1233 S.flush();
12341232
12351233 TableInfo.Table.push_back(MCD::OPC_CheckPredicate);
12361234 // Predicate index
12961294 if (NeedNegativeMask) {
12971295 MaskBytes.clear();
12981296 encodeULEB128(NegativeMask.getZExtValue(), S);
1299 S.flush();
13001297 for (unsigned i = 0, e = MaskBytes.size(); i != e; ++i)
13011298 TableInfo.Table.push_back(MaskBytes[i]);
13021299 } else
13661363 SmallString<16> Bytes;
13671364 raw_svector_ostream S(Bytes);
13681365 encodeULEB128(DIdx, S);
1369 S.flush();
13701366
13711367 // Decoder index
13721368 for (unsigned i = 0, e = Bytes.size(); i != e; ++i)