Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion llvm/include/llvm/MC/CAS/MCCASObjectV1.h
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,8 @@ class InMemoryCASDWARFObject : public DWARFObject {
SmallVector<char, 0> DebugInfoCURefData;
SmallVector<char, 0> DistinctData;
constexpr static std::array FormsToPartition{
llvm::dwarf::Form::DW_FORM_strp, llvm::dwarf::Form::DW_FORM_sec_offset};
llvm::dwarf::Form::DW_FORM_strp, llvm::dwarf::Form::DW_FORM_sec_offset,
llvm::dwarf::Form::DW_FORM_addr};
};

/// Create a DwarfCompileUnit that represents the compile unit at \p CUOffset
Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/MC/MachObjectWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1106,6 +1106,8 @@ void MachObjectWriter::writeSymbolTable(MCAssembler &Asm,
void MachObjectWriter::applyAddends(MCAssembler &Asm,
const MCAsmLayout &Layout) {
for (MCSection &Sec : Asm) {
if (Sec.getName() == "__debug_info")
continue;
for (MCFragment &F : Sec) {
MutableArrayRef<char> Contents;
switch (F.getKind()) {
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ void AArch64AsmBackend::applyFixup(const MCAssembler &Asm, const MCFixup &Fixup,
// Copy the Value at the fixup location and zero-out the fixup if it is
// unresolved, this is done to improve deduplication with MCCAS. The fixup
// will be applied later when the object file is being written out.
if (!IsResolved) {
if (!IsResolved && Fragment->getParent()->getName() != "__debug_info") {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is non-MachO-specific code, we need to do something more generic than check fort the Mach-O section name here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought the CAS was only supported for MachO, we do not want to zero out the addends for a MachO debug info section right?

std::memcpy(&Value, &Data[Offset], NumBytes);
if (Asm.getWriter().addAddend(Fragment, Value, Offset, NumBytes)) {
std::memset(&Data[Offset], 0, NumBytes);
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1077,7 +1077,7 @@ void ARMAsmBackend::applyFixup(const MCAssembler &Asm, const MCFixup &Fixup,
// Copy the Value at the fixup location and zero-out the fixup if it is
// unresolved, this is done to improve deduplication with MCCAS. The fixup
// will be applied later when the object file is being written out.
if (!IsResolved) {
if (!IsResolved && Fragment->getParent()->getName() != "__debug_info") {
std::memcpy(&Value, &Data[Offset], NumBytes);
if (Asm.getWriter().addAddend(Fragment, Value, Offset, NumBytes)) {
std::memset(&Data[Offset], 0, NumBytes);
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ void X86AsmBackend::applyFixup(const MCAssembler &Asm, const MCFixup &Fixup,
// Copy the Value at the fixup location and zero-out the fixup if it is
// unresolved, this is done to improve deduplication with MCCAS. The fixup
// will be applied later when the object file is being written out.
if (!IsResolved) {
if (!IsResolved && Fragment->getParent()->getName() != "__debug_info") {
if (Asm.getWriter().addAddend(Fragment, Value, Fixup.getOffset(), Size)) {
std::memset(&Data[Fixup.getOffset()], 0, Size);
}
Expand Down
18 changes: 9 additions & 9 deletions llvm/test/DebugInfo/CAS/AArch64/test_relocation_zero.ll
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
;RUN: llc -O0 --filetype=obj --cas-backend --cas=%t/cas --mccas-casid %s -o %t/test.id
;RUN: llvm-cas-dump --cas=%t/cas --casid-file %t/test.id --hex-dump --hex-dump-one-line | FileCheck %s

; This file checks to see if relocation addends are zero-ed out correctly in the CAS. The offset's 30, 43, 94, and 107 should all have 8 0x00 bytes.
; This file checks to see if relocation addends are correctly copied into the debug_info_distinct_data CAS Object. The offset 17 in the debug_info_distinct_data should have 2 relocations of 8 0x0 and the offset 53 in the debug_info_distinct_data should have 2 relocations of 0x04 followed by 7 0x00 each.

;CHECK: mc:debug_info_cu llvmcas://{{[0-9a-z]+}}
;CHECK-NEXT: 0x00 0x00 0x00 0x00
;CHECK-SAME: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
;CHECK-SAME: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
;CHECK-NEXT: mc:debug_info_cu llvmcas://{{[0-9a-z]+}}
;CHECK-NEXT: 0x00 0x00 0x00 0x00
;CHECK-SAME: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
;CHECK-SAME: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
; CHECK: mc:debug_info_distinct_data llvmcas://{{[0-9a-z]+}}
; CHECK-NEXT: 0x00 0x00 0x00 0x00 0x6a 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x6e 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x93 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x6a 0x00 0x00 0x00 0x3a 0x00 0x00 0x00 0x6e 0x00 0x00 0x00 0x04 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x04 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x97 0x00 0x00 0x00
; CHECK-NEXT: mc:debug_abbrev_offsets llvmcas://{{[0-9a-z]+}}
; CHECK-NEXT: 0x00 0x2a
; CHECK-NEXT: mc:debug_info_cu llvmcas://{{[0-9a-z]+}}
; CHECK-NEXT: 0x3c 0x00 0x00 0x00 0x04 0x00 0x00 0x00 0x00 0x00 0x08 0x01 0x0c 0x00 0x04 0x00 0x00 0x00 0x02 0x04 0x00 0x00 0x00 0x01 0x6f 0x01 0x01 0x00
; CHECK-NEXT: mc:debug_info_cu llvmcas://{{[0-9a-z]+}}
; CHECK-NEXT: 0x3c 0x00 0x00 0x00 0x04 0x00 0x00 0x00 0x00 0x00 0x08 0x01 0x0c 0x00 0x04 0x00 0x00 0x00 0x02 0x04 0x00 0x00 0x00 0x01 0x6f 0x01 0x04 0x00

target triple = "arm64-apple-macosx12.0.0"

Expand Down
12 changes: 6 additions & 6 deletions llvm/test/tools/llvm-cas-dump/basic_hex_dump_test.ll
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@
; HEXDUMP: mc:debug_info_distinct_data llvmcas://{{[0-9a-z]+}}
; HEXDUMP-NEXT: 0x00 0x00 0x00 0x00 0x05 0x00 0x00 0x00
; HEXDUMP-NEXT: 0x00 0x00 0x00 0x00 0x0c 0x00 0x00 0x00
; HEXDUMP-NEXT: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
; HEXDUMP-NEXT: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
; HEXDUMP-NEXT: 0x15 0x00 0x00 0x00 0x19 0x00 0x00 0x00
; HEXDUMP-NEXT: mc:debug_abbrev_offsets llvmcas://{{[0-9a-z]+}}
; HEXDUMP-NEXT: 0x00
; HEXDUMP-NEXT: mc:debug_info_cu llvmcas://{{[0-9a-z]+}}
; HEXDUMP-NEXT: 0x45 0x00 0x00 0x00 0x04 0x00 0x00 0x00
; HEXDUMP-NEXT: 0x00 0x00 0x08 0x01 0x0c 0x00 0x00 0x00
; HEXDUMP-NEXT: 0x00 0x00 0x00 0x00 0x00 0x00 0x08 0x00
; HEXDUMP-NEXT: 0x00 0x00 0x02 0x00 0x00 0x00 0x00 0x00
; HEXDUMP-NEXT: 0x00 0x00 0x00 0x08 0x00 0x00 0x00 0x01
; HEXDUMP-NEXT: 0x00 0x00 0x08 0x01 0x0c 0x00 0x08 0x00
; HEXDUMP-NEXT: 0x00 0x00 0x02 0x08 0x00 0x00 0x00 0x01
; HEXDUMP-NEXT: 0x6f 0x41 0x00 0x00 0x00 0x03 0x05 0x00
; HEXDUMP-NEXT: 0x00

; RUN: llc -O0 --filetype=obj --cas-backend --cas=%t.casdb --mccas-casid -o %t.casid %s
; RUN: llvm-cas-dump --cas=%t.casdb --casid-file %t.casid --hex-dump --hex-dump-one-line | FileCheck %s --check-prefix=HEXDUMPONELINE

; HEXDUMPONELINE: mc:debug_info_distinct_data llvmcas://{{[0-9a-z]+}}
; HEXDUMPONELINE-NEXT: 0x00 0x00 0x00 0x00 0x05 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x0c 0x00 0x00 0x00 0x15 0x00 0x00 0x00 0x19 0x00 0x00 0x00
; HEXDUMPONELINE-NEXT: 0x00 0x00 0x00 0x00 0x05 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x0c 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x15 0x00 0x00 0x00 0x19 0x00 0x00 0x00
; HEXDUMPONELINE-NEXT: mc:debug_abbrev_offsets llvmcas://{{[0-9a-z]+}}
; HEXDUMPONELINE-NEXT: 0x00
; HEXDUMPONELINE-NEXT: mc:debug_info_cu llvmcas://{{[0-9a-z]+}}
; HEXDUMPONELINE-NEXT: 0x45 0x00 0x00 0x00 0x04 0x00 0x00 0x00 0x00 0x00 0x08 0x01 0x0c 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x08 0x00 0x00 0x00 0x02 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x08 0x00 0x00 0x00 0x01 0x6f 0x41 0x00 0x00 0x00 0x03 0x05 0x00 0x00
; HEXDUMPONELINE-NEXT: 0x45 0x00 0x00 0x00 0x04 0x00 0x00 0x00 0x00 0x00 0x08 0x01 0x0c 0x00 0x08 0x00 0x00 0x00 0x02 0x08 0x00 0x00 0x00 0x01 0x6f 0x41 0x00 0x00 0x00 0x03 0x05 0x00 0x00

; This test is created from a C program like:
; int foo() { return 10; }
Expand Down