summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorSaleem Abdulrasool <compnerd@compnerd.org>2017-06-09 00:40:19 +0000
committerSaleem Abdulrasool <compnerd@compnerd.org>2017-06-09 00:40:19 +0000
commit1f62f57b37bdd40f877eff3a2b1e80f51c82249c (patch)
tree4031423e057727a02e21a776b5ecf5b34d51e120 /llvm
parentdeb391309c9861dcdc995b2c70c2d64189611c3b (diff)
downloadbcm5719-llvm-1f62f57b37bdd40f877eff3a2b1e80f51c82249c.tar.gz
bcm5719-llvm-1f62f57b37bdd40f877eff3a2b1e80f51c82249c.zip
sink DebugCompressionType into MC for exposing to clang
This is a preparatory change to expose the debug compression style to clang. It requires exposing the enumeration and passing the actual value through to the backend from the frontend in actual value form rather than a boolean that selects the GNU style of debug info compression. Minor tweak to the ELF Object Writer to use a variable for re-used values. Add an assertion that debug information format is one of the two currently known types if debug information is being compressed. llvm-svn: 305038
Diffstat (limited to 'llvm')
-rw-r--r--llvm/include/llvm/MC/MCAsmInfo.h8
-rw-r--r--llvm/include/llvm/MC/MCTargetOptions.h6
-rw-r--r--llvm/include/llvm/Target/TargetOptions.h10
-rw-r--r--llvm/lib/CodeGen/LLVMTargetMachine.cpp3
-rw-r--r--llvm/lib/MC/ELFObjectWriter.cpp16
-rw-r--r--llvm/tools/llvm-mc/llvm-mc.cpp22
6 files changed, 33 insertions, 32 deletions
diff --git a/llvm/include/llvm/MC/MCAsmInfo.h b/llvm/include/llvm/MC/MCAsmInfo.h
index 869706c4548..234762f36dd 100644
--- a/llvm/include/llvm/MC/MCAsmInfo.h
+++ b/llvm/include/llvm/MC/MCAsmInfo.h
@@ -51,12 +51,6 @@ enum LCOMMType { NoAlignment, ByteAlignment, Log2Alignment };
} // end namespace LCOMM
-enum class DebugCompressionType {
- DCT_None, // no compression
- DCT_Zlib, // zlib style complession
- DCT_ZlibGnu // zlib-gnu style compression
-};
-
/// This class is intended to be used as a base class for asm
/// properties and features specific to the target.
class MCAsmInfo {
@@ -366,7 +360,7 @@ protected:
bool PreserveAsmComments;
/// Compress DWARF debug sections. Defaults to no compression.
- DebugCompressionType CompressDebugSections = DebugCompressionType::DCT_None;
+ DebugCompressionType CompressDebugSections = DebugCompressionType::None;
/// True if the integrated assembler should interpret 'a >> b' constant
/// expressions as logical rather than arithmetic.
diff --git a/llvm/include/llvm/MC/MCTargetOptions.h b/llvm/include/llvm/MC/MCTargetOptions.h
index ab027ab27a4..5509bb3bdc7 100644
--- a/llvm/include/llvm/MC/MCTargetOptions.h
+++ b/llvm/include/llvm/MC/MCTargetOptions.h
@@ -23,6 +23,12 @@ enum class ExceptionHandling {
WinEH, /// Windows Exception Handling
};
+enum class DebugCompressionType {
+ None, /// No compression
+ GNU, /// zlib-gnu style compression
+ Z, /// zlib style complession
+};
+
class StringRef;
class MCTargetOptions {
diff --git a/llvm/include/llvm/Target/TargetOptions.h b/llvm/include/llvm/Target/TargetOptions.h
index 7cc33f2fdcc..5c2063880f8 100644
--- a/llvm/include/llvm/Target/TargetOptions.h
+++ b/llvm/include/llvm/Target/TargetOptions.h
@@ -105,10 +105,10 @@ namespace llvm {
HonorSignDependentRoundingFPMathOption(false), NoZerosInBSS(false),
GuaranteedTailCallOpt(false), StackSymbolOrdering(true),
EnableFastISel(false), UseInitArray(false),
- DisableIntegratedAS(false), CompressDebugSections(false),
- RelaxELFRelocations(false), FunctionSections(false),
- DataSections(false), UniqueSectionNames(true), TrapUnreachable(false),
- EmulatedTLS(false), EnableIPRA(false) {}
+ DisableIntegratedAS(false), RelaxELFRelocations(false),
+ FunctionSections(false), DataSections(false),
+ UniqueSectionNames(true), TrapUnreachable(false), EmulatedTLS(false),
+ EnableIPRA(false) {}
/// PrintMachineCode - This flag is enabled when the -print-machineinstrs
/// option is specified on the command line, and should enable debugging
@@ -194,7 +194,7 @@ namespace llvm {
unsigned DisableIntegratedAS : 1;
/// Compress DWARF debug sections.
- unsigned CompressDebugSections : 1;
+ DebugCompressionType CompressDebugSections = DebugCompressionType::None;
unsigned RelaxELFRelocations : 1;
diff --git a/llvm/lib/CodeGen/LLVMTargetMachine.cpp b/llvm/lib/CodeGen/LLVMTargetMachine.cpp
index 3e08828ebb8..f2defb4fd62 100644
--- a/llvm/lib/CodeGen/LLVMTargetMachine.cpp
+++ b/llvm/lib/CodeGen/LLVMTargetMachine.cpp
@@ -60,8 +60,7 @@ void LLVMTargetMachine::initAsmInfo() {
TmpAsmInfo->setPreserveAsmComments(Options.MCOptions.PreserveAsmComments);
- if (Options.CompressDebugSections)
- TmpAsmInfo->setCompressDebugSections(DebugCompressionType::DCT_ZlibGnu);
+ TmpAsmInfo->setCompressDebugSections(Options.CompressDebugSections);
TmpAsmInfo->setRelaxELFRelocations(Options.RelaxELFRelocations);
diff --git a/llvm/lib/MC/ELFObjectWriter.cpp b/llvm/lib/MC/ELFObjectWriter.cpp
index 9954d6f6bd6..4d139132df4 100644
--- a/llvm/lib/MC/ELFObjectWriter.cpp
+++ b/llvm/lib/MC/ELFObjectWriter.cpp
@@ -1020,18 +1020,24 @@ void ELFObjectWriter::writeSectionData(const MCAssembler &Asm, MCSection &Sec,
MCSectionELF &Section = static_cast<MCSectionELF &>(Sec);
StringRef SectionName = Section.getSectionName();
+ auto &MC = Asm.getContext();
+ const auto &MAI = MC.getAsmInfo();
+
// Compressing debug_frame requires handling alignment fragments which is
// more work (possibly generalizing MCAssembler.cpp:writeFragment to allow
// for writing to arbitrary buffers) for little benefit.
bool CompressionEnabled =
- Asm.getContext().getAsmInfo()->compressDebugSections() !=
- DebugCompressionType::DCT_None;
+ MAI->compressDebugSections() != DebugCompressionType::None;
if (!CompressionEnabled || !SectionName.startswith(".debug_") ||
SectionName == ".debug_frame") {
Asm.writeSectionData(&Section, Layout);
return;
}
+ assert((MAI->compressDebugSections() == DebugCompressionType::Z ||
+ MAI->compressDebugSections() == DebugCompressionType::GNU) &&
+ "expected zlib or zlib-gnu style compression");
+
SmallVector<char, 128> UncompressedData;
raw_svector_ostream VecOS(UncompressedData);
raw_pwrite_stream &OldStream = getStream();
@@ -1048,8 +1054,7 @@ void ELFObjectWriter::writeSectionData(const MCAssembler &Asm, MCSection &Sec,
return;
}
- bool ZlibStyle = Asm.getContext().getAsmInfo()->compressDebugSections() ==
- DebugCompressionType::DCT_Zlib;
+ bool ZlibStyle = MAI->compressDebugSections() == DebugCompressionType::Z;
if (!maybeWriteCompression(UncompressedData.size(), CompressedContents,
ZlibStyle, Sec.getAlignment())) {
getStream() << UncompressedData;
@@ -1061,8 +1066,7 @@ void ELFObjectWriter::writeSectionData(const MCAssembler &Asm, MCSection &Sec,
Section.setFlags(Section.getFlags() | ELF::SHF_COMPRESSED);
else
// Add "z" prefix to section name. This is zlib-gnu style.
- Asm.getContext().renameELFSection(&Section,
- (".z" + SectionName.drop_front(1)).str());
+ MC.renameELFSection(&Section, (".z" + SectionName.drop_front(1)).str());
getStream() << CompressedContents;
}
diff --git a/llvm/tools/llvm-mc/llvm-mc.cpp b/llvm/tools/llvm-mc/llvm-mc.cpp
index 87efac2d33c..8782588dfdd 100644
--- a/llvm/tools/llvm-mc/llvm-mc.cpp
+++ b/llvm/tools/llvm-mc/llvm-mc.cpp
@@ -56,17 +56,15 @@ static cl::opt<bool> RelaxELFRel(
"relax-relocations", cl::init(true),
cl::desc("Emit R_X86_64_GOTPCRELX instead of R_X86_64_GOTPCREL"));
-static cl::opt<DebugCompressionType>
-CompressDebugSections("compress-debug-sections", cl::ValueOptional,
- cl::init(DebugCompressionType::DCT_None),
- cl::desc("Choose DWARF debug sections compression:"),
- cl::values(
- clEnumValN(DebugCompressionType::DCT_None, "none",
- "No compression"),
- clEnumValN(DebugCompressionType::DCT_Zlib, "zlib",
- "Use zlib compression"),
- clEnumValN(DebugCompressionType::DCT_ZlibGnu, "zlib-gnu",
- "Use zlib-gnu compression (deprecated)")));
+static cl::opt<DebugCompressionType> CompressDebugSections(
+ "compress-debug-sections", cl::ValueOptional,
+ cl::init(DebugCompressionType::None),
+ cl::desc("Choose DWARF debug sections compression:"),
+ cl::values(clEnumValN(DebugCompressionType::None, "none", "No compression"),
+ clEnumValN(DebugCompressionType::Z, "zlib",
+ "Use zlib compression"),
+ clEnumValN(DebugCompressionType::GNU, "zlib-gnu",
+ "Use zlib-gnu compression (deprecated)")));
static cl::opt<bool>
ShowInst("show-inst", cl::desc("Show internal instruction representation"));
@@ -494,7 +492,7 @@ int main(int argc, char **argv) {
MAI->setRelaxELFRelocations(RelaxELFRel);
- if (CompressDebugSections != DebugCompressionType::DCT_None) {
+ if (CompressDebugSections != DebugCompressionType::None) {
if (!zlib::isAvailable()) {
errs() << ProgName
<< ": build tools with zlib to enable -compress-debug-sections";
OpenPOWER on IntegriCloud