diff options
author | Sam Clegg <sbc@chromium.org> | 2017-09-15 20:34:47 +0000 |
---|---|---|
committer | Sam Clegg <sbc@chromium.org> | 2017-09-15 20:34:47 +0000 |
commit | 66a99e41cdc8d1ddd67860f7d97d861f654f1dbd (patch) | |
tree | 1a16a1862c0a527303792304cab8c61e1041cf7c /llvm/lib/CodeGen/AsmPrinter | |
parent | 04370d3a820f65ac91faae9eb026ddea33b4f16e (diff) | |
download | bcm5719-llvm-66a99e41cdc8d1ddd67860f7d97d861f654f1dbd.tar.gz bcm5719-llvm-66a99e41cdc8d1ddd67860f7d97d861f654f1dbd.zip |
Change encodeU/SLEB128 to pad to certain number of bytes
Previously the 'Padding' argument was the number of padding
bytes to add. However most callers that use 'Padding' know
how many overall bytes they need to write. With the previous
code this would mean encoding the LEB once to find out how
many bytes it would occupy and then using this to calulate
the 'Padding' value.
See: https://reviews.llvm.org/D36595
Differential Revision: https://reviews.llvm.org/D37494
llvm-svn: 313393
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp | 13 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/EHStreamer.cpp | 15 |
2 files changed, 20 insertions, 8 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp index 0edf9051d34..7b3fe05db76 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp @@ -48,12 +48,19 @@ void AsmPrinter::EmitSLEB128(int64_t Value, const char *Desc) const { } /// EmitULEB128 - emit the specified unsigned leb128 value. -void AsmPrinter::EmitULEB128(uint64_t Value, const char *Desc, - unsigned PadTo) const { +void AsmPrinter::EmitPaddedULEB128(uint64_t Value, unsigned PadTo, + const char *Desc) const { if (isVerbose() && Desc) OutStreamer->AddComment(Desc); - OutStreamer->EmitULEB128IntValue(Value, PadTo); + OutStreamer->EmitPaddedULEB128IntValue(Value, PadTo); +} + +void AsmPrinter::EmitULEB128(uint64_t Value, const char *Desc) const { + if (isVerbose() && Desc) + OutStreamer->AddComment(Desc); + + OutStreamer->EmitULEB128IntValue(Value); } static const char *DecodeDWARFEncoding(unsigned Encoding) { diff --git a/llvm/lib/CodeGen/AsmPrinter/EHStreamer.cpp b/llvm/lib/CodeGen/AsmPrinter/EHStreamer.cpp index e14d5be1177..8767da76ff9 100644 --- a/llvm/lib/CodeGen/AsmPrinter/EHStreamer.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/EHStreamer.cpp @@ -478,13 +478,14 @@ void EHStreamer::emitExceptionTable() { sizeof(int8_t) + // TType format (HaveTTData ? TTypeBaseOffsetSize : 0) + // TType base offset size TTypeBaseOffset; // TType base offset - unsigned SizeAlign = (4 - TotalSize) & 3; + unsigned PadBytes = (4 - TotalSize) & 3; if (HaveTTData) { // Account for any extra padding that will be added to the call site table // length. - Asm->EmitULEB128(TTypeBaseOffset, "@TType base offset", SizeAlign); - SizeAlign = 0; + Asm->EmitPaddedULEB128(TTypeBaseOffset, TTypeBaseOffsetSize + PadBytes, + "@TType base offset"); + PadBytes = 0; } bool VerboseAsm = Asm->OutStreamer->isVerboseAsm(); @@ -494,7 +495,9 @@ void EHStreamer::emitExceptionTable() { Asm->EmitEncodingByte(dwarf::DW_EH_PE_udata4, "Call site"); // Add extra padding if it wasn't added to the TType base offset. - Asm->EmitULEB128(CallSiteTableLength, "Call site table length", SizeAlign); + Asm->EmitPaddedULEB128(CallSiteTableLength, + CallSiteTableLengthSize + PadBytes, + "Call site table length"); // Emit the landing pad site information. unsigned idx = 0; @@ -547,7 +550,9 @@ void EHStreamer::emitExceptionTable() { Asm->EmitEncodingByte(dwarf::DW_EH_PE_udata4, "Call site"); // Add extra padding if it wasn't added to the TType base offset. - Asm->EmitULEB128(CallSiteTableLength, "Call site table length", SizeAlign); + Asm->EmitPaddedULEB128(CallSiteTableLength, + CallSiteTableLengthSize + PadBytes, + "Call site table length"); unsigned Entry = 0; for (SmallVectorImpl<CallSiteEntry>::const_iterator |