llvm.org GIT mirror llvm / 0e0047f
bpf: introduce -mattr=dwarfris to disable DwarfUsesRelocationsAcrossSections Commit e4507fb8c94b ("bpf: disable DwarfUsesRelocationsAcrossSections") disables MCAsmInfo DwarfUsesRelocationsAcrossSections unconditionally so that dwarf will not use cross section (between dwarf and symbol table) relocations. This new debug format enables pahole to dump structures correctly as libdwarves.so does not have BPF backend support yet. This new debug format, however, breaks bcc (https://github.com/iovisor/bcc) source debug output as llvm in-memory Dwarf support has some issues to handle it. More specifically, with DwarfUsesRelocationsAcrossSections disabled, JIT compiler does not generate .debug_abbrev and Dwarf DIE (debug info entry) processing is not happy about this. This patch introduces a new flag -mattr=dwarfris (dwarf relocation in section) to disable DwarfUsesRelocationsAcrossSections. DwarfUsesRelocationsAcrossSections is true by default. Signed-off-by: Yonghong Song <yhs@fb.com> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@326505 91177308-0d34-0410-b5e6-96231b3b80d8 Yonghong Song 2 years ago
5 changed file(s) with 16 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
2828 def ALU32 : SubtargetFeature<"alu32", "HasAlu32", "true",
2929 "Enable ALU32 instructions">;
3030
31 def DwarfRIS: SubtargetFeature<"dwarfris", "UseDwarfRIS", "true",
32 "Disable MCAsmInfo DwarfUsesRelocationsAcrossSections">;
33
3134 def BPFInstPrinter : AsmWriter {
3235 string AsmWriterClassName = "InstPrinter";
3336 bit isMCAsmWriter = 1;
3636 void BPFSubtarget::initializeEnvironment() {
3737 HasJmpExt = false;
3838 HasAlu32 = false;
39 UseDwarfRIS = false;
3940 }
4041
4142 void BPFSubtarget::initSubtargetFeatures(StringRef CPU, StringRef FS) {
4949 // whether the cpu supports alu32 instructions.
5050 bool HasAlu32;
5151
52 // whether we should enable MCAsmInfo DwarfUsesRelocationsAcrossSections
53 bool UseDwarfRIS;
54
5255 public:
5356 // This constructor initializes the data members to match that
5457 // of the specified triple.
6265 void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
6366 bool getHasJmpExt() const { return HasJmpExt; }
6467 bool getHasAlu32() const { return HasAlu32; }
68 bool getUseDwarfRIS() const { return UseDwarfRIS; }
6569
6670 const BPFInstrInfo *getInstrInfo() const override { return &InstrInfo; }
6771 const BPFFrameLowering *getFrameLowering() const override {
1212
1313 #include "BPFTargetMachine.h"
1414 #include "BPF.h"
15 #include "MCTargetDesc/BPFMCAsmInfo.h"
1516 #include "llvm/CodeGen/Passes.h"
1617 #include "llvm/CodeGen/TargetLoweringObjectFileImpl.h"
1718 #include "llvm/CodeGen/TargetPassConfig.h"
6768 TLOF(make_unique()),
6869 Subtarget(TT, CPU, FS, *this) {
6970 initAsmInfo();
71
72 BPFMCAsmInfo *MAI = static_cast(const_cast(AsmInfo));
73 MAI->setDwarfUsesRelocationsAcrossSections(!Subtarget.getUseDwarfRIS());
7074 }
7175 namespace {
7276 // BPF Code Generator Pass Configuration Options.
3636 ExceptionsType = ExceptionHandling::DwarfCFI;
3737 MinInstAlignment = 8;
3838
39 DwarfUsesRelocationsAcrossSections = false;
40
4139 // the default is 4 and it only affects dwarf elf output
4240 // so if not set correctly, the dwarf data will be
4341 // messed up in random places by 4 bytes. .debug_line
4543 // line numbers, etc.
4644 CodePointerSize = 8;
4745 }
46
47 void setDwarfUsesRelocationsAcrossSections(bool enable) {
48 DwarfUsesRelocationsAcrossSections = enable;
49 }
4850 };
4951 }
5052