diff --git a/llvm/lib/Target/BPF/BPFAbstractMemberAccess.cpp b/llvm/lib/Target/BPF/BPFAbstractMemberAccess.cpp --- a/llvm/lib/Target/BPF/BPFAbstractMemberAccess.cpp +++ b/llvm/lib/Target/BPF/BPFAbstractMemberAccess.cpp @@ -93,8 +93,6 @@ namespace llvm { const std::string BPFCoreSharedInfo::AmaAttr = "btf_ama"; -const std::string BPFCoreSharedInfo::PatchableExtSecName = - ".BPF.patchable_externs"; } // namespace llvm using namespace llvm; diff --git a/llvm/lib/Target/BPF/BPFCORE.h b/llvm/lib/Target/BPF/BPFCORE.h --- a/llvm/lib/Target/BPF/BPFCORE.h +++ b/llvm/lib/Target/BPF/BPFCORE.h @@ -23,10 +23,8 @@ MAX_FIELD_RELOC_KIND, }; - /// The attribute attached to globals representing a member offset + /// The attribute attached to globals representing a field access static const std::string AmaAttr; - /// The section name to identify a patchable external global - static const std::string PatchableExtSecName; }; } // namespace llvm diff --git a/llvm/lib/Target/BPF/BPFMISimplifyPatchable.cpp b/llvm/lib/Target/BPF/BPFMISimplifyPatchable.cpp --- a/llvm/lib/Target/BPF/BPFMISimplifyPatchable.cpp +++ b/llvm/lib/Target/BPF/BPFMISimplifyPatchable.cpp @@ -11,19 +11,15 @@ // ldd r2, r1, 0 // add r3, struct_base_reg, r2 // -// Here @global should either present a AMA (abstruct member access) or -// a patchable extern variable. And these two kinds of accesses -// are subject to bpf load time patching. After this pass, the +// Here @global should represent an AMA (abstruct member access). +// Such an access is subject to bpf load time patching. After this pass, the // code becomes // ld_imm64 r1, @global // add r3, struct_base_reg, r1 // // Eventually, at BTF output stage, a relocation record will be generated // for ld_imm64 which should be replaced later by bpf loader: -// r1 = or -// add r3, struct_base_reg, r1 -// or -// ld_imm64 r1, +// r1 = // add r3, struct_base_reg, r1 // //===----------------------------------------------------------------------===// @@ -120,15 +116,6 @@ if (GVar->hasAttribute(BPFCoreSharedInfo::AmaAttr)) { assert(ImmVal == 0); IsCandidate = true; - } else if (!GVar->hasInitializer() && GVar->hasExternalLinkage() && - GVar->getSection() == - BPFCoreSharedInfo::PatchableExtSecName) { - if (ImmVal == 0) - IsCandidate = true; - else - errs() << "WARNING: unhandled patchable extern " - << GVar->getName() << " with load offset " << ImmVal - << "\n"; } } } diff --git a/llvm/lib/Target/BPF/BTF.h b/llvm/lib/Target/BPF/BTF.h --- a/llvm/lib/Target/BPF/BTF.h +++ b/llvm/lib/Target/BPF/BTF.h @@ -39,13 +39,6 @@ /// struct SecFieldReloc for ELF section #2 /// A number of struct BPFFieldReloc for ELF section #2 /// ... -/// The ExternReloc subsection is defined as below: -/// BPFExternReloc Size -/// struct SecExternReloc for ELF section #1 -/// A number of struct BPFExternReloc for ELF section #1 -/// struct SecExternReloc for ELF section #2 -/// A number of struct BPFExternReloc for ELF section #2 -/// ... /// /// The section formats are also defined at /// https://github.com/torvalds/linux/blob/master/include/uapi/linux/btf.h @@ -63,7 +56,7 @@ /// Sizes in bytes of various things in the BTF format. enum { HeaderSize = 24, - ExtHeaderSize = 40, + ExtHeaderSize = 32, CommonTypeSize = 12, BTFArraySize = 12, BTFEnumSize = 8, @@ -73,11 +66,9 @@ SecFuncInfoSize = 8, SecLineInfoSize = 8, SecFieldRelocSize = 8, - SecExternRelocSize = 8, BPFFuncInfoSize = 8, BPFLineInfoSize = 16, BPFFieldRelocSize = 16, - BPFExternRelocSize = 8, }; /// The .BTF section header definition. @@ -215,8 +206,6 @@ uint32_t LineInfoLen; ///< Length of line info section uint32_t FieldRelocOff; ///< Offset of offset reloc section uint32_t FieldRelocLen; ///< Length of offset reloc section - uint32_t ExternRelocOff; ///< Offset of extern reloc section - uint32_t ExternRelocLen; ///< Length of extern reloc section }; /// Specifying one function info. @@ -260,18 +249,6 @@ uint32_t NumFieldReloc; ///< Number of offset reloc's in this section }; -/// Specifying one offset relocation. -struct BPFExternReloc { - uint32_t InsnOffset; ///< Byte offset in this section - uint32_t ExternNameOff; ///< The string for external variable -}; - -/// Specifying extern relocation's in one section. -struct SecExternReloc { - uint32_t SecNameOff; ///< Section name index in the .BTF string table - uint32_t NumExternReloc; ///< Number of extern reloc's in this section -}; - } // End namespace BTF. } // End namespace llvm. diff --git a/llvm/lib/Target/BPF/BTFDebug.h b/llvm/lib/Target/BPF/BTFDebug.h --- a/llvm/lib/Target/BPF/BTFDebug.h +++ b/llvm/lib/Target/BPF/BTFDebug.h @@ -231,12 +231,6 @@ uint32_t RelocKind; ///< What to patch the instruction }; -/// Represent one extern relocation. -struct BTFExternReloc { - const MCSymbol *Label; ///< MCSymbol identifying insn for the reloc - uint32_t ExternNameOff; ///< The extern variable name -}; - /// Collect and emit BTF information. class BTFDebug : public DebugHandlerBase { MCStreamer &OS; @@ -251,7 +245,6 @@ std::map> FuncInfoTable; std::map> LineInfoTable; std::map> FieldRelocTable; - std::map> ExternRelocTable; StringMap> FileContent; std::map> DataSecEntries; std::vector StructTypes; diff --git a/llvm/lib/Target/BPF/BTFDebug.cpp b/llvm/lib/Target/BPF/BTFDebug.cpp --- a/llvm/lib/Target/BPF/BTFDebug.cpp +++ b/llvm/lib/Target/BPF/BTFDebug.cpp @@ -752,9 +752,10 @@ } void BTFDebug::emitBTFExtSection() { - // Do not emit section if empty FuncInfoTable and LineInfoTable. + // Do not emit section if empty FuncInfoTable and LineInfoTable + // and FieldRelocTable. if (!FuncInfoTable.size() && !LineInfoTable.size() && - !FieldRelocTable.size() && !ExternRelocTable.size()) + !FieldRelocTable.size()) return; MCContext &Ctx = OS.getContext(); @@ -766,8 +767,8 @@ // Account for FuncInfo/LineInfo record size as well. uint32_t FuncLen = 4, LineLen = 4; - // Do not account for optional FieldReloc/ExternReloc. - uint32_t FieldRelocLen = 0, ExternRelocLen = 0; + // Do not account for optional FieldReloc. + uint32_t FieldRelocLen = 0; for (const auto &FuncSec : FuncInfoTable) { FuncLen += BTF::SecFuncInfoSize; FuncLen += FuncSec.second.size() * BTF::BPFFuncInfoSize; @@ -780,15 +781,9 @@ FieldRelocLen += BTF::SecFieldRelocSize; FieldRelocLen += FieldRelocSec.second.size() * BTF::BPFFieldRelocSize; } - for (const auto &ExternRelocSec : ExternRelocTable) { - ExternRelocLen += BTF::SecExternRelocSize; - ExternRelocLen += ExternRelocSec.second.size() * BTF::BPFExternRelocSize; - } if (FieldRelocLen) FieldRelocLen += 4; - if (ExternRelocLen) - ExternRelocLen += 4; OS.EmitIntValue(0, 4); OS.EmitIntValue(FuncLen, 4); @@ -796,8 +791,6 @@ OS.EmitIntValue(LineLen, 4); OS.EmitIntValue(FuncLen + LineLen, 4); OS.EmitIntValue(FieldRelocLen, 4); - OS.EmitIntValue(FuncLen + LineLen + FieldRelocLen, 4); - OS.EmitIntValue(ExternRelocLen, 4); // Emit func_info table. OS.AddComment("FuncInfo"); @@ -848,22 +841,6 @@ } } } - - // Emit extern reloc table. - if (ExternRelocLen) { - OS.AddComment("ExternReloc"); - OS.EmitIntValue(BTF::BPFExternRelocSize, 4); - for (const auto &ExternRelocSec : ExternRelocTable) { - OS.AddComment("Extern reloc section string offset=" + - std::to_string(ExternRelocSec.first)); - OS.EmitIntValue(ExternRelocSec.first, 4); - OS.EmitIntValue(ExternRelocSec.second.size(), 4); - for (const auto &ExternRelocInfo : ExternRelocSec.second) { - Asm->EmitLabelReference(ExternRelocInfo.Label, 4); - OS.EmitIntValue(ExternRelocInfo.ExternNameOff, 4); - } - } - } } void BTFDebug::beginFunctionImpl(const MachineFunction *MF) { @@ -1019,15 +996,6 @@ MDNode *MDN = GVar->getMetadata(LLVMContext::MD_preserve_access_index); DIType *Ty = dyn_cast(MDN); generateFieldReloc(MI, ORSym, Ty, GVar->getName()); - } else if (GVar && !GVar->hasInitializer() && GVar->hasExternalLinkage() && - GVar->getSection() == BPFCoreSharedInfo::PatchableExtSecName) { - MCSymbol *ORSym = OS.getContext().createTempSymbol(); - OS.EmitLabel(ORSym); - - BTFExternReloc ExternReloc; - ExternReloc.Label = ORSym; - ExternReloc.ExternNameOff = addString(GVar->getName()); - ExternRelocTable[SecNameOff].push_back(ExternReloc); } } } @@ -1165,20 +1133,6 @@ OutMI.addOperand(MCOperand::createReg(MI->getOperand(0).getReg())); OutMI.addOperand(MCOperand::createImm(Imm)); return true; - } else if (GVar && !GVar->hasInitializer() && - GVar->hasExternalLinkage() && - GVar->getSection() == BPFCoreSharedInfo::PatchableExtSecName) { - const IntegerType *IntTy = dyn_cast(GVar->getValueType()); - assert(IntTy); - // For patchable externals, emit "LD_imm64, ri, 0" if the external - // variable is 64bit width, emit "mov ri, 0" otherwise. - if (IntTy->getBitWidth() == 64) - OutMI.setOpcode(BPF::LD_imm64); - else - OutMI.setOpcode(BPF::MOV_ri); - OutMI.addOperand(MCOperand::createReg(MI->getOperand(0).getReg())); - OutMI.addOperand(MCOperand::createImm(0)); - return true; } } } diff --git a/llvm/test/CodeGen/BPF/BTF/binary-format.ll b/llvm/test/CodeGen/BPF/BTF/binary-format.ll --- a/llvm/test/CodeGen/BPF/BTF/binary-format.ll +++ b/llvm/test/CodeGen/BPF/BTF/binary-format.ll @@ -28,20 +28,18 @@ ; CHECK: 0x00000060 696e7420 6628696e 74206129 207b2072 ; CHECK: 0x00000070 65747572 6e20613b 207d00 ; CHECK: '.BTF.ext' -; CHECK-EL: 0x00000000 9feb0100 28000000 00000000 14000000 +; CHECK-EL: 0x00000000 9feb0100 20000000 00000000 14000000 ; CHECK-EL: 0x00000010 14000000 2c000000 40000000 00000000 -; CHECK-EL: 0x00000020 40000000 00000000 08000000 09000000 -; CHECK-EL: 0x00000030 01000000 00000000 03000000 10000000 -; CHECK-EL: 0x00000040 09000000 02000000 00000000 0f000000 -; CHECK-EL: 0x00000050 18000000 00040000 08000000 0f000000 -; CHECK-EL: 0x00000060 18000000 10040000 -; CHECK-EB: 0x00000000 eb9f0100 00000028 00000000 00000014 +; CHECK-EL: 0x00000020 08000000 09000000 01000000 00000000 +; CHECK-EL: 0x00000030 03000000 10000000 09000000 02000000 +; CHECK-EL: 0x00000040 00000000 0f000000 18000000 00040000 +; CHECK-EL: 0x00000050 08000000 0f000000 18000000 10040000 +; CHECK-EB: 0x00000000 eb9f0100 00000020 00000000 00000014 ; CHECK-EB: 0x00000010 00000014 0000002c 00000040 00000000 -; CHECK-EB: 0x00000020 00000040 00000000 00000008 00000009 -; CHECK-EB: 0x00000030 00000001 00000000 00000003 00000010 -; CHECK-EB: 0x00000040 00000009 00000002 00000000 0000000f -; CHECK-EB: 0x00000050 00000018 00000400 00000008 0000000f -; CHECK-EB: 0x00000060 00000018 00000410 +; CHECK-EB: 0x00000020 00000008 00000009 00000001 00000000 +; CHECK-EB: 0x00000030 00000003 00000010 00000009 00000002 +; CHECK-EB: 0x00000040 00000000 0000000f 00000018 00000400 +; CHECK-EB: 0x00000050 00000008 0000000f 00000018 00000410 ; Function Attrs: nounwind readnone speculatable declare void @llvm.dbg.value(metadata, metadata, metadata) #1 diff --git a/llvm/test/CodeGen/BPF/BTF/filename.ll b/llvm/test/CodeGen/BPF/BTF/filename.ll --- a/llvm/test/CodeGen/BPF/BTF/filename.ll +++ b/llvm/test/CodeGen/BPF/BTF/filename.ll @@ -43,15 +43,13 @@ ; CHECK-NEXT: .short 60319 # 0xeb9f ; CHECK-NEXT: .byte 1 ; CHECK-NEXT: .byte 0 -; CHECK-NEXT: .long 40 +; CHECK-NEXT: .long 32 ; CHECK-NEXT: .long 0 ; CHECK-NEXT: .long 20 ; CHECK-NEXT: .long 20 ; CHECK-NEXT: .long 28 ; CHECK-NEXT: .long 48 ; CHECK-NEXT: .long 0 -; CHECK-NEXT: .long 48 -; CHECK-NEXT: .long 0 ; CHECK-NEXT: .long 8 # FuncInfo ; CHECK-NEXT: .long 10 # FuncInfo section string offset=10 ; CHECK-NEXT: .long 1 diff --git a/llvm/test/CodeGen/BPF/BTF/func-func-ptr.ll b/llvm/test/CodeGen/BPF/BTF/func-func-ptr.ll --- a/llvm/test/CodeGen/BPF/BTF/func-func-ptr.ll +++ b/llvm/test/CodeGen/BPF/BTF/func-func-ptr.ll @@ -74,15 +74,13 @@ ; CHECK-NEXT: .short 60319 # 0xeb9f ; CHECK-NEXT: .byte 1 ; CHECK-NEXT: .byte 0 -; CHECK-NEXT: .long 40 +; CHECK-NEXT: .long 32 ; CHECK-NEXT: .long 0 ; CHECK-NEXT: .long 20 ; CHECK-NEXT: .long 20 ; CHECK-NEXT: .long 28 ; CHECK-NEXT: .long 48 ; CHECK-NEXT: .long 0 -; CHECK-NEXT: .long 48 -; CHECK-NEXT: .long 0 ; CHECK-NEXT: .long 8 # FuncInfo ; CHECK-NEXT: .long 11 # FuncInfo section string offset=11 ; CHECK-NEXT: .long 1 diff --git a/llvm/test/CodeGen/BPF/BTF/func-non-void.ll b/llvm/test/CodeGen/BPF/BTF/func-non-void.ll --- a/llvm/test/CodeGen/BPF/BTF/func-non-void.ll +++ b/llvm/test/CodeGen/BPF/BTF/func-non-void.ll @@ -48,15 +48,13 @@ ; CHECK-NEXT: .short 60319 # 0xeb9f ; CHECK-NEXT: .byte 1 ; CHECK-NEXT: .byte 0 -; CHECK-NEXT: .long 40 +; CHECK-NEXT: .long 32 ; CHECK-NEXT: .long 0 ; CHECK-NEXT: .long 20 ; CHECK-NEXT: .long 20 ; CHECK-NEXT: .long 44 ; CHECK-NEXT: .long 64 ; CHECK-NEXT: .long 0 -; CHECK-NEXT: .long 64 -; CHECK-NEXT: .long 0 ; CHECK-NEXT: .long 8 # FuncInfo ; CHECK-NEXT: .long 11 # FuncInfo section string offset=11 ; CHECK-NEXT: .long 1 diff --git a/llvm/test/CodeGen/BPF/BTF/func-source.ll b/llvm/test/CodeGen/BPF/BTF/func-source.ll --- a/llvm/test/CodeGen/BPF/BTF/func-source.ll +++ b/llvm/test/CodeGen/BPF/BTF/func-source.ll @@ -43,15 +43,13 @@ ; CHECK-NEXT: .short 60319 # 0xeb9f ; CHECK-NEXT: .byte 1 ; CHECK-NEXT: .byte 0 -; CHECK-NEXT: .long 40 +; CHECK-NEXT: .long 32 ; CHECK-NEXT: .long 0 ; CHECK-NEXT: .long 20 ; CHECK-NEXT: .long 20 ; CHECK-NEXT: .long 28 ; CHECK-NEXT: .long 48 ; CHECK-NEXT: .long 0 -; CHECK-NEXT: .long 48 -; CHECK-NEXT: .long 0 ; CHECK-NEXT: .long 8 # FuncInfo ; CHECK-NEXT: .long 3 # FuncInfo section string offset=3 ; CHECK-NEXT: .long 1 diff --git a/llvm/test/CodeGen/BPF/BTF/func-typedef.ll b/llvm/test/CodeGen/BPF/BTF/func-typedef.ll --- a/llvm/test/CodeGen/BPF/BTF/func-typedef.ll +++ b/llvm/test/CodeGen/BPF/BTF/func-typedef.ll @@ -61,15 +61,13 @@ ; CHECK-NEXT: .short 60319 # 0xeb9f ; CHECK-NEXT: .byte 1 ; CHECK-NEXT: .byte 0 -; CHECK-NEXT: .long 40 +; CHECK-NEXT: .long 32 ; CHECK-NEXT: .long 0 ; CHECK-NEXT: .long 20 ; CHECK-NEXT: .long 20 ; CHECK-NEXT: .long 44 ; CHECK-NEXT: .long 64 ; CHECK-NEXT: .long 0 -; CHECK-NEXT: .long 64 -; CHECK-NEXT: .long 0 ; CHECK-NEXT: .long 8 # FuncInfo ; CHECK-NEXT: .long 20 # FuncInfo section string offset=20 ; CHECK-NEXT: .long 1 diff --git a/llvm/test/CodeGen/BPF/BTF/func-unused-arg.ll b/llvm/test/CodeGen/BPF/BTF/func-unused-arg.ll --- a/llvm/test/CodeGen/BPF/BTF/func-unused-arg.ll +++ b/llvm/test/CodeGen/BPF/BTF/func-unused-arg.ll @@ -48,15 +48,13 @@ ; CHECK-NEXT: .short 60319 # 0xeb9f ; CHECK-NEXT: .byte 1 ; CHECK-NEXT: .byte 0 -; CHECK-NEXT: .long 40 +; CHECK-NEXT: .long 32 ; CHECK-NEXT: .long 0 ; CHECK-NEXT: .long 20 ; CHECK-NEXT: .long 20 ; CHECK-NEXT: .long 28 ; CHECK-NEXT: .long 48 ; CHECK-NEXT: .long 0 -; CHECK-NEXT: .long 48 -; CHECK-NEXT: .long 0 ; CHECK-NEXT: .long 8 # FuncInfo ; CHECK-NEXT: .long 11 # FuncInfo section string offset=11 ; CHECK-NEXT: .long 1 diff --git a/llvm/test/CodeGen/BPF/BTF/func-void.ll b/llvm/test/CodeGen/BPF/BTF/func-void.ll --- a/llvm/test/CodeGen/BPF/BTF/func-void.ll +++ b/llvm/test/CodeGen/BPF/BTF/func-void.ll @@ -37,15 +37,13 @@ ; CHECK-NEXT: .short 60319 # 0xeb9f ; CHECK-NEXT: .byte 1 ; CHECK-NEXT: .byte 0 -; CHECK-NEXT: .long 40 +; CHECK-NEXT: .long 32 ; CHECK-NEXT: .long 0 ; CHECK-NEXT: .long 20 ; CHECK-NEXT: .long 20 ; CHECK-NEXT: .long 28 ; CHECK-NEXT: .long 48 ; CHECK-NEXT: .long 0 -; CHECK-NEXT: .long 48 -; CHECK-NEXT: .long 0 ; CHECK-NEXT: .long 8 # FuncInfo ; CHECK-NEXT: .long 4 # FuncInfo section string offset=4 ; CHECK-NEXT: .long 1 diff --git a/llvm/test/CodeGen/BPF/CORE/offset-reloc-basic.ll b/llvm/test/CodeGen/BPF/CORE/offset-reloc-basic.ll --- a/llvm/test/CodeGen/BPF/CORE/offset-reloc-basic.ll +++ b/llvm/test/CodeGen/BPF/CORE/offset-reloc-basic.ll @@ -103,21 +103,19 @@ ; CHECK-NEXT: .short 60319 # 0xeb9f ; CHECK-NEXT: .byte 1 ; CHECK-NEXT: .byte 0 -; CHECK-NEXT: .long 40 +; CHECK-NEXT: .long 32 ; CHECK-NEXT: .long 0 ; CHECK-NEXT: .long 20 ; CHECK-NEXT: .long 20 ; CHECK-NEXT: .long 124 ; CHECK-NEXT: .long 144 ; CHECK-NEXT: .long 28 -; CHECK-NEXT: .long 172 -; CHECK-NEXT: .long 0 ; CHECK-NEXT: .long 8 # FuncInfo ; CHECK: .long 16 # FieldReloc ; CHECK-NEXT: .long 43 # Field reloc section string offset=43 ; CHECK-NEXT: .long 1 -; CHECK-NEXT: .long .Ltmp2 +; CHECK-NEXT: .long .Ltmp{{[0-9]+}} ; CHECK-NEXT: .long 2 ; CHECK-NEXT: .long 86 ; CHECK-NEXT: .long 0 diff --git a/llvm/test/CodeGen/BPF/CORE/offset-reloc-multilevel.ll b/llvm/test/CodeGen/BPF/CORE/offset-reloc-multilevel.ll --- a/llvm/test/CodeGen/BPF/CORE/offset-reloc-multilevel.ll +++ b/llvm/test/CodeGen/BPF/CORE/offset-reloc-multilevel.ll @@ -111,21 +111,19 @@ ; CHECK-NEXT: .short 60319 # 0xeb9f ; CHECK-NEXT: .byte 1 ; CHECK-NEXT: .byte 0 -; CHECK-NEXT: .long 40 +; CHECK-NEXT: .long 32 ; CHECK-NEXT: .long 0 ; CHECK-NEXT: .long 20 ; CHECK-NEXT: .long 20 ; CHECK-NEXT: .long 76 ; CHECK-NEXT: .long 96 ; CHECK-NEXT: .long 28 -; CHECK-NEXT: .long 124 -; CHECK-NEXT: .long 0 ; CHECK-NEXT: .long 8 # FuncInfo ; CHECK: .long 16 # FieldReloc ; CHECK-NEXT: .long 57 # Field reloc section string offset=57 ; CHECK-NEXT: .long 1 -; CHECK-NEXT: .long .Ltmp2 +; CHECK-NEXT: .long .Ltmp{{[0-9]+}} ; CHECK-NEXT: .long 2 ; CHECK-NEXT: .long 100 ; CHECK-NEXT: .long 0 diff --git a/llvm/test/CodeGen/BPF/CORE/offset-reloc-struct-anonymous.ll b/llvm/test/CodeGen/BPF/CORE/offset-reloc-struct-anonymous.ll --- a/llvm/test/CodeGen/BPF/CORE/offset-reloc-struct-anonymous.ll +++ b/llvm/test/CodeGen/BPF/CORE/offset-reloc-struct-anonymous.ll @@ -121,15 +121,13 @@ ; CHECK-NEXT: .short 60319 # 0xeb9f ; CHECK-NEXT: .byte 1 ; CHECK-NEXT: .byte 0 -; CHECK-NEXT: .long 40 +; CHECK-NEXT: .long 32 ; CHECK-NEXT: .long 0 ; CHECK-NEXT: .long 20 ; CHECK-NEXT: .long 20 ; CHECK-NEXT: .long 76 ; CHECK-NEXT: .long 96 ; CHECK-NEXT: .long 28 -; CHECK-NEXT: .long 124 -; CHECK-NEXT: .long 0 ; CHECK-NEXT: .long 8 # FuncInfo ; CHECK: .long 16 # FieldReloc diff --git a/llvm/test/CodeGen/BPF/CORE/offset-reloc-struct-array.ll b/llvm/test/CodeGen/BPF/CORE/offset-reloc-struct-array.ll --- a/llvm/test/CodeGen/BPF/CORE/offset-reloc-struct-array.ll +++ b/llvm/test/CodeGen/BPF/CORE/offset-reloc-struct-array.ll @@ -124,21 +124,19 @@ ; CHECK-NEXT: .short 60319 # 0xeb9f ; CHECK-NEXT: .byte 1 ; CHECK-NEXT: .byte 0 -; CHECK-NEXT: .long 40 +; CHECK-NEXT: .long 32 ; CHECK-NEXT: .long 0 ; CHECK-NEXT: .long 20 ; CHECK-NEXT: .long 20 ; CHECK-NEXT: .long 76 ; CHECK-NEXT: .long 96 ; CHECK-NEXT: .long 28 -; CHECK-NEXT: .long 124 -; CHECK-NEXT: .long 0 ; CHECK-NEXT: .long 8 # FuncInfo ; CHECK: .long 16 # FieldReloc ; CHECK-NEXT: .long 77 # Field reloc section string offset=77 ; CHECK-NEXT: .long 1 -; CHECK-NEXT: .long .Ltmp2 +; CHECK-NEXT: .long .Ltmp{{[0-9]+}} ; CHECK-NEXT: .long 2 ; CHECK-NEXT: .long 120 ; CHECK-NEXT: .long 0 diff --git a/llvm/test/CodeGen/BPF/CORE/offset-reloc-union.ll b/llvm/test/CodeGen/BPF/CORE/offset-reloc-union.ll --- a/llvm/test/CodeGen/BPF/CORE/offset-reloc-union.ll +++ b/llvm/test/CodeGen/BPF/CORE/offset-reloc-union.ll @@ -127,21 +127,19 @@ ; CHECK-NEXT: .short 60319 # 0xeb9f ; CHECK-NEXT: .byte 1 ; CHECK-NEXT: .byte 0 -; CHECK-NEXT: .long 40 +; CHECK-NEXT: .long 32 ; CHECK-NEXT: .long 0 ; CHECK-NEXT: .long 20 ; CHECK-NEXT: .long 20 ; CHECK-NEXT: .long 76 ; CHECK-NEXT: .long 96 ; CHECK-NEXT: .long 28 -; CHECK-NEXT: .long 124 -; CHECK-NEXT: .long 0 ; CHECK-NEXT: .long 8 # FuncInfo ; CHECK: .long 16 # FieldReloc ; CHECK-NEXT: .long 54 # Field reloc section string offset=54 ; CHECK-NEXT: .long 1 -; CHECK-NEXT: .long .Ltmp2 +; CHECK-NEXT: .long .Ltmp{{[0-9]+}} ; CHECK-NEXT: .long 2 ; CHECK-NEXT: .long 97 ; CHECK-NEXT: .long 0 diff --git a/llvm/test/CodeGen/BPF/CORE/patchable-extern-char.ll b/llvm/test/CodeGen/BPF/CORE/patchable-extern-char.ll deleted file mode 100644 --- a/llvm/test/CodeGen/BPF/CORE/patchable-extern-char.ll +++ /dev/null @@ -1,107 +0,0 @@ -; RUN: llc -march=bpfel -filetype=asm -o - %s | FileCheck -check-prefixes=CHECK %s -; RUN: llc -march=bpfeb -filetype=asm -o - %s | FileCheck -check-prefixes=CHECK %s -; Source code: -; extern __attribute__((section(".BPF.patchable_externs"))) char a; -; int foo() { return a; } -; Compilation flag: -; clang -target bpf -O2 -g -S -emit-llvm test.c - -@a = external dso_local local_unnamed_addr global i8, section ".BPF.patchable_externs", align 1 - -; Function Attrs: norecurse nounwind readonly -define dso_local i32 @foo() local_unnamed_addr #0 !dbg !7 { - %1 = load i8, i8* @a, align 1, !dbg !11, !tbaa !12 - %2 = sext i8 %1 to i32, !dbg !11 -; CHECK: r0 = 0 -; CHECK-NEXT: r0 <<= 56 -; CHECK-NEXT: r0 s>>= 56 - ret i32 %2, !dbg !15 -} - -; CHECK: .section .BTF,"",@progbits -; CHECK-NEXT: .short 60319 # 0xeb9f -; CHECK-NEXT: .byte 1 -; CHECK-NEXT: .byte 0 -; CHECK-NEXT: .long 24 -; CHECK-NEXT: .long 0 -; CHECK-NEXT: .long 40 -; CHECK-NEXT: .long 40 -; CHECK-NEXT: .long 54 -; CHECK-NEXT: .long 0 # BTF_KIND_FUNC_PROTO(id = 1) -; CHECK-NEXT: .long 218103808 # 0xd000000 -; CHECK-NEXT: .long 2 -; CHECK-NEXT: .long 1 # BTF_KIND_INT(id = 2) -; CHECK-NEXT: .long 16777216 # 0x1000000 -; CHECK-NEXT: .long 4 -; CHECK-NEXT: .long 16777248 # 0x1000020 -; CHECK-NEXT: .long 5 # BTF_KIND_FUNC(id = 3) -; CHECK-NEXT: .long 201326592 # 0xc000000 -; CHECK-NEXT: .long 1 -; CHECK-NEXT: .byte 0 # string offset=0 -; CHECK-NEXT: .ascii "int" # string offset=1 -; CHECK-NEXT: .byte 0 -; CHECK-NEXT: .ascii "foo" # string offset=5 -; CHECK-NEXT: .byte 0 -; CHECK-NEXT: .ascii ".text" # string offset=9 -; CHECK-NEXT: .byte 0 -; CHECK-NEXT: .byte 97 # string offset=15 -; CHECK-NEXT: .byte 0 -; CHECK-NEXT: .ascii "/tmp/home/yhs/work/tests/llvm/test.c" # string offset=17 -; CHECK-NEXT: .byte 0 -; CHECK-NEXT: .section .BTF.ext,"",@progbits -; CHECK-NEXT: .short 60319 # 0xeb9f -; CHECK-NEXT: .byte 1 -; CHECK-NEXT: .byte 0 -; CHECK-NEXT: .long 40 -; CHECK-NEXT: .long 0 -; CHECK-NEXT: .long 20 -; CHECK-NEXT: .long 20 -; CHECK-NEXT: .long 44 -; CHECK-NEXT: .long 64 -; CHECK-NEXT: .long 0 -; CHECK-NEXT: .long 64 -; CHECK-NEXT: .long 20 -; CHECK-NEXT: .long 8 # FuncInfo -; CHECK-NEXT: .long 9 # FuncInfo section string offset=9 -; CHECK-NEXT: .long 1 -; CHECK-NEXT: .long .Lfunc_begin0 -; CHECK-NEXT: .long 3 -; CHECK-NEXT: .long 16 # LineInfo -; CHECK-NEXT: .long 9 # LineInfo section string offset=9 -; CHECK-NEXT: .long 2 -; CHECK-NEXT: .long .Ltmp{{[0-9]+}} -; CHECK-NEXT: .long 17 -; CHECK-NEXT: .long 0 -; CHECK-NEXT: .long 2068 # Line 2 Col 20 -; CHECK-NEXT: .long .Ltmp{{[0-9]+}} -; CHECK-NEXT: .long 17 -; CHECK-NEXT: .long 0 -; CHECK-NEXT: .long 2061 # Line 2 Col 13 -; CHECK-NEXT: .long 8 # ExternReloc -; CHECK-NEXT: .long 9 # Extern reloc section string offset=9 -; CHECK-NEXT: .long 1 -; CHECK-NEXT: .long .Ltmp{{[0-9]+}} -; CHECK-NEXT: .long 15 - -attributes #0 = { norecurse nounwind readonly "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } - -!llvm.dbg.cu = !{!0} -!llvm.module.flags = !{!3, !4, !5} -!llvm.ident = !{!6} - -!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 8.0.20181009 ", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None) -!1 = !DIFile(filename: "test.c", directory: "/tmp/home/yhs/work/tests/llvm") -!2 = !{} -!3 = !{i32 2, !"Dwarf Version", i32 4} -!4 = !{i32 2, !"Debug Info Version", i32 3} -!5 = !{i32 1, !"wchar_size", i32 4} -!6 = !{!"clang version 8.0.20181009 "} -!7 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 2, type: !8, isLocal: false, isDefinition: true, scopeLine: 2, isOptimized: true, unit: !0, retainedNodes: !2) -!8 = !DISubroutineType(types: !9) -!9 = !{!10} -!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) -!11 = !DILocation(line: 2, column: 20, scope: !7) -!12 = !{!13, !13, i64 0} -!13 = !{!"omnipotent char", !14, i64 0} -!14 = !{!"Simple C/C++ TBAA"} -!15 = !DILocation(line: 2, column: 13, scope: !7) diff --git a/llvm/test/CodeGen/BPF/CORE/patchable-extern-uint.ll b/llvm/test/CodeGen/BPF/CORE/patchable-extern-uint.ll deleted file mode 100644 --- a/llvm/test/CodeGen/BPF/CORE/patchable-extern-uint.ll +++ /dev/null @@ -1,102 +0,0 @@ -; RUN: llc -march=bpfel -filetype=asm -o - %s | FileCheck -check-prefixes=CHECK %s -; RUN: llc -march=bpfeb -filetype=asm -o - %s | FileCheck -check-prefixes=CHECK %s -; Source code: -; extern __attribute__((section(".BPF.patchable_externs"))) unsigned a; -; int foo() { return a; } -; Compilation flag: -; clang -target bpf -O2 -g -S -emit-llvm test.c - -@a = external dso_local local_unnamed_addr global i32, section ".BPF.patchable_externs", align 4 - -; Function Attrs: norecurse nounwind readonly -define dso_local i32 @foo() local_unnamed_addr #0 !dbg !7 { - %1 = load i32, i32* @a, align 4, !dbg !11, !tbaa !12 -; CHECK: r0 = 0 -; CHECK-NEXT: exit - ret i32 %1, !dbg !16 -} - -; CHECK: .section .BTF,"",@progbits -; CHECK-NEXT: .short 60319 # 0xeb9f -; CHECK-NEXT: .byte 1 -; CHECK-NEXT: .byte 0 -; CHECK-NEXT: .long 24 -; CHECK-NEXT: .long 0 -; CHECK-NEXT: .long 40 -; CHECK-NEXT: .long 40 -; CHECK-NEXT: .long 49 -; CHECK-NEXT: .long 0 # BTF_KIND_FUNC_PROTO(id = 1) -; CHECK-NEXT: .long 218103808 # 0xd000000 -; CHECK-NEXT: .long 2 -; CHECK-NEXT: .long 1 # BTF_KIND_INT(id = 2) -; CHECK-NEXT: .long 16777216 # 0x1000000 -; CHECK-NEXT: .long 4 -; CHECK-NEXT: .long 16777248 # 0x1000020 -; CHECK-NEXT: .long 5 # BTF_KIND_FUNC(id = 3) -; CHECK-NEXT: .long 201326592 # 0xc000000 -; CHECK-NEXT: .long 1 -; CHECK-NEXT: .byte 0 # string offset=0 -; CHECK-NEXT: .ascii "int" # string offset=1 -; CHECK-NEXT: .byte 0 -; CHECK-NEXT: .ascii "foo" # string offset=5 -; CHECK-NEXT: .byte 0 -; CHECK-NEXT: .ascii ".text" # string offset=9 -; CHECK-NEXT: .byte 0 -; CHECK-NEXT: .byte 97 # string offset=15 -; CHECK-NEXT: .byte 0 -; CHECK-NEXT: .ascii "/tmp/yhs/work/tests/llvm/test.c" # string offset=17 -; CHECK-NEXT: .byte 0 -; CHECK-NEXT: .section .BTF.ext,"",@progbits -; CHECK-NEXT: .short 60319 # 0xeb9f -; CHECK-NEXT: .byte 1 -; CHECK-NEXT: .byte 0 -; CHECK-NEXT: .long 40 -; CHECK-NEXT: .long 0 -; CHECK-NEXT: .long 20 -; CHECK-NEXT: .long 20 -; CHECK-NEXT: .long 28 -; CHECK-NEXT: .long 48 -; CHECK-NEXT: .long 0 -; CHECK-NEXT: .long 48 -; CHECK-NEXT: .long 20 -; CHECK-NEXT: .long 8 # FuncInfo -; CHECK-NEXT: .long 9 # FuncInfo section string offset=9 -; CHECK-NEXT: .long 1 -; CHECK-NEXT: .long .Lfunc_begin0 -; CHECK-NEXT: .long 3 -; CHECK-NEXT: .long 16 # LineInfo -; CHECK-NEXT: .long 9 # LineInfo section string offset=9 -; CHECK-NEXT: .long 1 -; CHECK-NEXT: .long .Ltmp{{[0-9]+}} -; CHECK-NEXT: .long 17 -; CHECK-NEXT: .long 0 -; CHECK-NEXT: .long 2061 # Line 2 Col 13 -; CHECK-NEXT: .long 8 # ExternReloc -; CHECK-NEXT: .long 9 # Extern reloc section string offset=9 -; CHECK-NEXT: .long 1 -; CHECK-NEXT: .long .Ltmp{{[0-9]+}} -; CHECK-NEXT: .long 15 - -attributes #0 = { norecurse nounwind readonly "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } - -!llvm.dbg.cu = !{!0} -!llvm.module.flags = !{!3, !4, !5} -!llvm.ident = !{!6} - -!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 8.0.20181009 ", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None) -!1 = !DIFile(filename: "test.c", directory: "/tmp/yhs/work/tests/llvm") -!2 = !{} -!3 = !{i32 2, !"Dwarf Version", i32 4} -!4 = !{i32 2, !"Debug Info Version", i32 3} -!5 = !{i32 1, !"wchar_size", i32 4} -!6 = !{!"clang version 8.0.20181009 "} -!7 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 2, type: !8, isLocal: false, isDefinition: true, scopeLine: 2, isOptimized: true, unit: !0, retainedNodes: !2) -!8 = !DISubroutineType(types: !9) -!9 = !{!10} -!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) -!11 = !DILocation(line: 2, column: 20, scope: !7) -!12 = !{!13, !13, i64 0} -!13 = !{!"int", !14, i64 0} -!14 = !{!"omnipotent char", !15, i64 0} -!15 = !{!"Simple C/C++ TBAA"} -!16 = !DILocation(line: 2, column: 13, scope: !7) diff --git a/llvm/test/CodeGen/BPF/CORE/patchable-extern-ulonglong.ll b/llvm/test/CodeGen/BPF/CORE/patchable-extern-ulonglong.ll deleted file mode 100644 --- a/llvm/test/CodeGen/BPF/CORE/patchable-extern-ulonglong.ll +++ /dev/null @@ -1,103 +0,0 @@ -; RUN: llc -march=bpfel -filetype=asm -o - %s | FileCheck -check-prefixes=CHECK %s -; RUN: llc -march=bpfeb -filetype=asm -o - %s | FileCheck -check-prefixes=CHECK %s -; Source code: -; extern __attribute__((section(".BPF.patchable_externs"))) unsigned long long a; -; int foo() { return a; } -; Compilation flag: -; clang -target bpf -O2 -g -S -emit-llvm test.c - -@a = external dso_local local_unnamed_addr global i64, section ".BPF.patchable_externs", align 8 - -; Function Attrs: norecurse nounwind readonly -define dso_local i32 @foo() local_unnamed_addr #0 !dbg !7 { - %1 = load i64, i64* @a, align 8, !dbg !11, !tbaa !12 - %2 = trunc i64 %1 to i32, !dbg !11 -; CHECK: r0 = 0 ll -; CHECK-NEXT: exit - ret i32 %2, !dbg !16 -} - -; CHECK: .section .BTF,"",@progbits -; CHECK-NEXT: .short 60319 # 0xeb9f -; CHECK-NEXT: .byte 1 -; CHECK-NEXT: .byte 0 -; CHECK-NEXT: .long 24 -; CHECK-NEXT: .long 0 -; CHECK-NEXT: .long 40 -; CHECK-NEXT: .long 40 -; CHECK-NEXT: .long 54 -; CHECK-NEXT: .long 0 # BTF_KIND_FUNC_PROTO(id = 1) -; CHECK-NEXT: .long 218103808 # 0xd000000 -; CHECK-NEXT: .long 2 -; CHECK-NEXT: .long 1 # BTF_KIND_INT(id = 2) -; CHECK-NEXT: .long 16777216 # 0x1000000 -; CHECK-NEXT: .long 4 -; CHECK-NEXT: .long 16777248 # 0x1000020 -; CHECK-NEXT: .long 5 # BTF_KIND_FUNC(id = 3) -; CHECK-NEXT: .long 201326592 # 0xc000000 -; CHECK-NEXT: .long 1 -; CHECK-NEXT: .byte 0 # string offset=0 -; CHECK-NEXT: .ascii "int" # string offset=1 -; CHECK-NEXT: .byte 0 -; CHECK-NEXT: .ascii "foo" # string offset=5 -; CHECK-NEXT: .byte 0 -; CHECK-NEXT: .ascii ".text" # string offset=9 -; CHECK-NEXT: .byte 0 -; CHECK-NEXT: .byte 97 # string offset=15 -; CHECK-NEXT: .byte 0 -; CHECK-NEXT: .ascii "/tmp/home/yhs/work/tests/llvm/test.c" # string offset=17 -; CHECK-NEXT: .byte 0 -; CHECK-NEXT: .section .BTF.ext,"",@progbits -; CHECK-NEXT: .short 60319 # 0xeb9f -; CHECK-NEXT: .byte 1 -; CHECK-NEXT: .byte 0 -; CHECK-NEXT: .long 40 -; CHECK-NEXT: .long 0 -; CHECK-NEXT: .long 20 -; CHECK-NEXT: .long 20 -; CHECK-NEXT: .long 28 -; CHECK-NEXT: .long 48 -; CHECK-NEXT: .long 0 -; CHECK-NEXT: .long 48 -; CHECK-NEXT: .long 20 -; CHECK-NEXT: .long 8 # FuncInfo -; CHECK-NEXT: .long 9 # FuncInfo section string offset=9 -; CHECK-NEXT: .long 1 -; CHECK-NEXT: .long .Lfunc_begin0 -; CHECK-NEXT: .long 3 -; CHECK-NEXT: .long 16 # LineInfo -; CHECK-NEXT: .long 9 # LineInfo section string offset=9 -; CHECK-NEXT: .long 1 -; CHECK-NEXT: .long .Ltmp{{[0-9]+}} -; CHECK-NEXT: .long 17 -; CHECK-NEXT: .long 0 -; CHECK-NEXT: .long 2061 # Line 2 Col 13 -; CHECK-NEXT: .long 8 # ExternReloc -; CHECK-NEXT: .long 9 # Extern reloc section string offset=9 -; CHECK-NEXT: .long 1 -; CHECK-NEXT: .long .Ltmp{{[0-9]+}} -; CHECK-NEXT: .long 15 - -attributes #0 = { norecurse nounwind readonly "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } - -!llvm.dbg.cu = !{!0} -!llvm.module.flags = !{!3, !4, !5} -!llvm.ident = !{!6} - -!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 8.0.20181009 ", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None) -!1 = !DIFile(filename: "test.c", directory: "/tmp/home/yhs/work/tests/llvm") -!2 = !{} -!3 = !{i32 2, !"Dwarf Version", i32 4} -!4 = !{i32 2, !"Debug Info Version", i32 3} -!5 = !{i32 1, !"wchar_size", i32 4} -!6 = !{!"clang version 8.0.20181009 "} -!7 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 2, type: !8, isLocal: false, isDefinition: true, scopeLine: 2, isOptimized: true, unit: !0, retainedNodes: !2) -!8 = !DISubroutineType(types: !9) -!9 = !{!10} -!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) -!11 = !DILocation(line: 2, column: 20, scope: !7) -!12 = !{!13, !13, i64 0} -!13 = !{!"long long", !14, i64 0} -!14 = !{!"omnipotent char", !15, i64 0} -!15 = !{!"Simple C/C++ TBAA"} -!16 = !DILocation(line: 2, column: 13, scope: !7)