22 changes: 20 additions & 2 deletions bolt/lib/Rewrite/RewriteInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ RewriteInstance::RewriteInstance(ELFObjectFileBase *File, const int Argc,
}
}

Relocation::Arch = TheTriple.getArch();
auto BCOrErr = BinaryContext::createBinaryContext(
TheTriple, File->getFileName(), Features.get(), IsPIC,
DWARFContext::create(*File, DWARFContext::ProcessDebugRelocations::Ignore,
Expand Down Expand Up @@ -2143,6 +2144,14 @@ bool RewriteInstance::analyzeRelocation(
if (!Relocation::isSupported(RType))
return false;

auto IsWeakReference = [](const SymbolRef &Symbol) {
Expected<uint32_t> SymFlagsOrErr = Symbol.getFlags();
if (!SymFlagsOrErr)
return false;
return (*SymFlagsOrErr & SymbolRef::SF_Undefined) &&
(*SymFlagsOrErr & SymbolRef::SF_Weak);
};

const bool IsAArch64 = BC->isAArch64();

const size_t RelSize = Relocation::getSizeForType(RType);
Expand Down Expand Up @@ -2174,7 +2183,8 @@ bool RewriteInstance::analyzeRelocation(
// Section symbols are marked as ST_Debug.
IsSectionRelocation = (cantFail(Symbol.getType()) == SymbolRef::ST_Debug);
// Check for PLT entry registered with symbol name
if (!SymbolAddress && (IsAArch64 || BC->isRISCV())) {
if (!SymbolAddress && !IsWeakReference(Symbol) &&
(IsAArch64 || BC->isRISCV())) {
const BinaryData *BD = BC->getPLTBinaryDataByName(SymbolName);
SymbolAddress = BD ? BD->getAddress() : 0;
}
Expand Down Expand Up @@ -2603,7 +2613,7 @@ void RewriteInstance::handleRelocation(const SectionRef &RelocatedSection,
Expected<StringRef> SectionName = Section->getName();
if (SectionName && !SectionName->empty())
ReferencedSection = BC->getUniqueSectionByName(*SectionName);
} else if (ReferencedSymbol && ContainingBF &&
} else if (BC->isRISCV() && ReferencedSymbol && ContainingBF &&
(cantFail(Symbol.getFlags()) & SymbolRef::SF_Absolute)) {
// This might be a relocation for an ABS symbols like __global_pointer$ on
// RISC-V
Expand Down Expand Up @@ -5509,6 +5519,14 @@ uint64_t RewriteInstance::getNewFunctionOrDataAddress(uint64_t OldAddress) {
if (const BinaryFunction *BF =
BC->getBinaryFunctionContainingAddress(OldAddress)) {
if (BF->isEmitted()) {
// If OldAddress is the another entry point of
// the function, then BOLT could get the new address.
if (BF->isMultiEntry()) {
for (const BinaryBasicBlock &BB : *BF)
if (BB.isEntryPoint() &&
(BF->getAddress() + BB.getOffset()) == OldAddress)
return BF->getOutputAddress() + BB.getOffset();
}
BC->errs() << "BOLT-ERROR: unable to get new address corresponding to "
"input address 0x"
<< Twine::utohexstr(OldAddress) << " in function " << *BF
Expand Down
9 changes: 9 additions & 0 deletions bolt/test/AArch64/Inputs/build_id.ldscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
SECTIONS
{
PROVIDE (__executable_start = SEGMENT_START("text-segment", 0x400000)); . = SEGMENT_START("text-segment", 0x400000) + SIZEOF_HEADERS;
.note.gnu.build-id (0x400400):
{
build_id_note = ABSOLUTE(.);
*(.note.gnu.build-id)
}
}
25 changes: 25 additions & 0 deletions bolt/test/AArch64/build_id.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// This test checks that referencing build_id through GOT table
// would result in GOT access after disassembly, not directly
// to build_id address.

// RUN: %clang %cflags -fuse-ld=lld -Wl,-T,%S/Inputs/build_id.ldscript -Wl,-q \
// RUN: -Wl,--no-relax -Wl,--build-id=sha1 %s -o %t.exe
// RUN: llvm-bolt -print-disasm --print-only=get_build_id %t.exe -o %t.bolt | \
// RUN: FileCheck %s

// CHECK: adrp [[REG:x[0-28]+]], __BOLT_got_zero
// CHECK: ldr x{{.*}}, [[[REG]], :lo12:__BOLT_got_zero{{.*}}]

struct build_id_note {
char pad[16];
char hash[20];
};

extern const struct build_id_note build_id_note;

__attribute__((noinline)) char get_build_id() { return build_id_note.hash[0]; }

int main() {
get_build_id();
return 0;
}
34 changes: 34 additions & 0 deletions bolt/test/AArch64/update-weak-reference-symbol.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// This test checks whether BOLT can correctly handle relocations against weak symbols.

// RUN: %clang %cflags -Wl,-z,notext -shared -Wl,-q %s -o %t.so
// RUN: llvm-bolt %t.so -o %t.so.bolt
// RUN: llvm-nm -n %t.so.bolt > %t.out.txt
// RUN: llvm-objdump -dj .rodata %t.so.bolt >> %t.out.txt
// RUN: FileCheck %s --input-file=%t.out.txt

# CHECK: w func_1
# CHECK: {{0+}}[[#%x,ADDR:]] W func_2

# CHECK: {{.*}} <.rodata>:
# CHECK-NEXT: {{.*}} .word 0x00000000
# CHECK-NEXT: {{.*}} .word 0x00000000
# CHECK-NEXT: {{.*}} .word 0x{{[0]+}}[[#ADDR]]
# CHECK-NEXT: {{.*}} .word 0x00000000

.text
.weak func_2
.weak func_1
.global wow
.type wow, %function
wow:
bl func_1
bl func_2
ret
.type func_2, %function
func_2:
ret
.section .rodata
.LC0:
.xword func_1
.LC1:
.xword func_2
326 changes: 326 additions & 0 deletions bolt/test/X86/Inputs/build_id.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,326 @@
--- !ELF
FileHeader:
Class: ELFCLASS64
Data: ELFDATA2LSB
Type: ET_EXEC
Machine: EM_X86_64
Entry: 0x4010A0
ProgramHeaders:
- Type: PT_PHDR
Flags: [ PF_R ]
VAddr: 0x400040
Align: 0x8
Offset: 0x40
- Type: PT_INTERP
Flags: [ PF_R ]
FirstSec: .interp
LastSec: .interp
VAddr: 0x400444
Offset: 0x444
- Type: PT_LOAD
Flags: [ PF_X, PF_R ]
FirstSec: .init
LastSec: .fini
VAddr: 0x401000
Align: 0x1000
Offset: 0x1000
- Type: PT_LOAD
Flags: [ PF_R ]
FirstSec: .rodata
LastSec: .rodata
VAddr: 0x402000
Align: 0x1000
Offset: 0x2000
- Type: PT_LOAD
Flags: [ PF_W, PF_R ]
FirstSec: .init_array
LastSec: .bss
VAddr: 0x403DD8
Align: 0x1000
Offset: 0x2DD8
- Type: PT_DYNAMIC
Flags: [ PF_W, PF_R ]
FirstSec: .dynamic
LastSec: .dynamic
VAddr: 0x403DE8
Align: 0x8
Offset: 0x2DE8
- Type: PT_NOTE
Flags: [ PF_R ]
FirstSec: .note.gnu.build-id
LastSec: .note.ABI-tag
VAddr: 0x400400
Align: 0x4
Offset: 0x400
Sections:
- Name: .note.gnu.build-id
Type: SHT_NOTE
Flags: [ SHF_ALLOC ]
Address: 0x400400
AddressAlign: 0x4
Offset: 0x400
Notes:
- Name: GNU
Desc: 3C34F7D1612996940C48F98DC272543BC3C9C956
Type: NT_PRPSINFO
- Name: .note.ABI-tag
Type: SHT_NOTE
Flags: [ SHF_ALLOC ]
Address: 0x400424
AddressAlign: 0x4
Notes:
- Name: GNU
Desc: '00000000030000000200000000000000'
Type: NT_VERSION
- Name: .interp
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC ]
Address: 0x400444
AddressAlign: 0x1
Content: 2F6C696236342F6C642D6C696E75782D7838362D36342E736F2E3200
- Name: .gnu.hash
Type: SHT_GNU_HASH
Flags: [ SHF_ALLOC ]
Address: 0x400460
Link: .dynsym
AddressAlign: 0x8
Header:
SymNdx: 0x7
Shift2: 0x6
BloomFilter: [ 0x810000 ]
HashBuckets: [ 0x7, 0x0 ]
HashValues: [ 0x6DCE65D1 ]
- Name: .dynsym
Type: SHT_DYNSYM
Flags: [ SHF_ALLOC ]
Address: 0x400488
Link: .dynstr
AddressAlign: 0x8
- Name: .dynstr
Type: SHT_STRTAB
Flags: [ SHF_ALLOC ]
Address: 0x400548
AddressAlign: 0x1
- Name: .gnu.version
Type: SHT_GNU_versym
Flags: [ SHF_ALLOC ]
Address: 0x4005F2
Link: .dynsym
AddressAlign: 0x2
Entries: [ 0, 2, 3, 1, 1, 4, 1, 2 ]
- Name: .gnu.version_r
Type: SHT_GNU_verneed
Flags: [ SHF_ALLOC ]
Address: 0x400608
Link: .dynstr
AddressAlign: 0x8
Dependencies:
- Version: 1
File: libc.so.6
Entries:
- Name: GLIBC_2.3.4
Hash: 157882740
Flags: 0
Other: 4
- Name: GLIBC_2.34
Hash: 110530996
Flags: 0
Other: 3
- Name: GLIBC_2.2.5
Hash: 157882997
Flags: 0
Other: 2
- Name: .init
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
Address: 0x401000
AddressAlign: 0x4
Offset: 0x1000
Content: F30F1EFA4883EC08488B05D92F00004885C07402FFD04883C408C3
- Name: .plt.sec
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
Address: 0x401060
AddressAlign: 0x10
EntSize: 0x10
Content: F30F1EFAF2FF25AD2F00000F1F440000F30F1EFAF2FF25A52F00000F1F440000
- Name: .text
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
Address: 0x401080
AddressAlign: 0x10
Content: F30F1EFA4883EC0831C0E80101000031C04883C408C3662E0F1F840000000000F30F1EFA31ED4989D15E4889E24883E4F050544531C031C9488D3DC1FFFFFFFF15132F0000F4662E0F1F840000000000488D3D612F0000488D055A2F00004839F87415488B05F62E00004885C07409FFE00F1F8000000000C30F1F8000000000488D3D312F0000488D352A2F00004829FE4889F048C1EE3F48C1F8034801C648D1FE7414488B05C52E00004885C07408FFE0660F1F440000C30F1F8000000000F30F1EFA803DED2E000000752B5548833DA22E0000004889E5740C488B3DCE2E0000E8E9FEFFFFE864FFFFFFC605C52E0000015DC30F1F00C30F1F8000000000F30F1EFAE977FFFFFF0F1F8000000000F30F1EFA415455488D2D660E000053488D1D6AF2FFFF4C8D6314660F1F4400000FB6134889EEBF0100000031C04883C301E8AAFEFFFF4C39E375E55BBF0A0000005D415CE987FEFFFF
- Name: .fini
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
Address: 0x4011DC
AddressAlign: 0x4
Content: F30F1EFA4883EC084883C408C3
- Name: .rodata
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC ]
Address: 0x402000
AddressAlign: 0x4
Offset: 0x2000
Content: '0100020025303268687800'
- Name: .init_array
Type: SHT_INIT_ARRAY
Flags: [ SHF_WRITE, SHF_ALLOC ]
Address: 0x403DD8
AddressAlign: 0x8
EntSize: 0x8
Offset: 0x2DD8
Content: '8011400000000000'
- Name: .fini_array
Type: SHT_FINI_ARRAY
Flags: [ SHF_WRITE, SHF_ALLOC ]
Address: 0x403DE0
AddressAlign: 0x8
EntSize: 0x8
Content: '4011400000000000'
- Name: .dynamic
Type: SHT_DYNAMIC
Flags: [ SHF_WRITE, SHF_ALLOC ]
Address: 0x403DE8
Link: .dynstr
AddressAlign: 0x8
Entries:
- Tag: DT_NEEDED
Value: 0x37
- Tag: DT_INIT
Value: 0x401000
- Tag: DT_FINI
Value: 0x4011DC
- Tag: DT_INIT_ARRAY
Value: 0x403DD8
- Tag: DT_INIT_ARRAYSZ
Value: 0x8
- Tag: DT_FINI_ARRAY
Value: 0x403DE0
- Tag: DT_FINI_ARRAYSZ
Value: 0x8
- Tag: DT_GNU_HASH
Value: 0x400460
- Tag: DT_STRTAB
Value: 0x400548
- Tag: DT_SYMTAB
Value: 0x400488
- Tag: DT_STRSZ
Value: 0xA9
- Tag: DT_SYMENT
Value: 0x18
- Tag: DT_DEBUG
Value: 0x0
- Tag: DT_PLTGOT
Value: 0x404000
- Tag: DT_PLTRELSZ
Value: 0x30
- Tag: DT_PLTREL
Value: 0x7
- Tag: DT_FLAGS
Value: 0x8
- Tag: DT_FLAGS_1
Value: 0x8000001
- Tag: DT_VERNEED
Value: 0x400608
- Tag: DT_VERNEEDNUM
Value: 0x1
- Tag: DT_VERSYM
Value: 0x4005F2
- Tag: DT_RELACOUNT
Value: 0x3
- Tag: DT_NULL
Value: 0x0
- Name: .data
Type: SHT_PROGBITS
Flags: [ SHF_WRITE, SHF_ALLOC ]
Address: 0x404028
AddressAlign: 0x8
Content: '00000000000000003040400000000000'
- Name: .tm_clone_table
Type: SHT_PROGBITS
Flags: [ SHF_WRITE, SHF_ALLOC ]
Address: 0x404038
AddressAlign: 0x8
- Name: .bss
Type: SHT_NOBITS
Flags: [ SHF_WRITE, SHF_ALLOC ]
Address: 0x404038
AddressAlign: 0x1
Size: 0x8
- Name: .rela.text
Type: SHT_RELA
Flags: [ SHF_INFO_LINK ]
Link: .symtab
AddressAlign: 0x8
Info: .text
Relocations:
- Offset: 0x40108B
Symbol: print_build_id
Type: R_X86_64_PLT32
Addend: -4
- Offset: 0x4010BB
Symbol: main
Type: R_X86_64_PC32
Addend: -4
- Offset: 0x4011A2
Symbol: build_id_note
Type: R_X86_64_PC32
Addend: 12
- Type: SectionHeaderTable
Sections:
- Name: .note.gnu.build-id
- Name: .note.ABI-tag
- Name: .interp
- Name: .gnu.hash
- Name: .dynsym
- Name: .dynstr
- Name: .gnu.version
- Name: .gnu.version_r
- Name: .init
- Name: .plt.sec
- Name: .text
- Name: .rela.text
- Name: .fini
- Name: .rodata
- Name: .init_array
- Name: .fini_array
- Name: .dynamic
- Name: .data
- Name: .tm_clone_table
- Name: .bss
- Name: .symtab
- Name: .strtab
- Name: .shstrtab
Symbols:
- Name: print_build_id
Type: STT_FUNC
Section: .text
Binding: STB_GLOBAL
Value: 0x401190
Size: 0x49
- Name: _end
Section: .bss
Binding: STB_GLOBAL
Value: 0x404040
- Name: _start
Type: STT_FUNC
Section: .text
Binding: STB_GLOBAL
Value: 0x4010A0
Size: 0x26
- Name: __bss_start
Section: .bss
Binding: STB_GLOBAL
Value: 0x404038
- Name: main
Type: STT_FUNC
Section: .text
Binding: STB_GLOBAL
Value: 0x401080
Size: 0x16
- Name: build_id_note
Index: SHN_ABS
Binding: STB_GLOBAL
Value: 0x400400
...
8 changes: 8 additions & 0 deletions bolt/test/X86/build_id.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// This test checks that relocation addend used to address build_id fields
// is properly disassembled by BOLT.

RUN: yaml2obj %p/Inputs/build_id.yaml &> %t.exe
RUN: llvm-bolt -print-disasm --print-only=print_build_id %t.exe -o %t.bolt | \
RUN: FileCheck %s

CHECK: leaq build_id_note+16(%rip), %rbx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# RUN: llvm-mc -dwarf-version=4 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf4-cross-reference-different-abbrev-dst.s -o %t.o
# RUN: llvm-mc -dwarf-version=4 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf4-cross-reference-different-abbrev-src.s -o %t1.o
# RUN: %clang %cflags -gdwarf-4 %t.o %t1.o -o %t.exe
# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections
# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections --debug-thread-count=4 --cu-processing-batch-size=4
# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.exe | FileCheck --check-prefix=PRECHECK %s
# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.bolt | FileCheck --check-prefix=POSTCHECK %s

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# RUN: llvm-mc -dwarf-version=4 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf4-cross-reference-different-abbrev-dst.s -o %t.o
# RUN: llvm-mc -dwarf-version=4 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf4-cross-reference-different-abbrev-src.s -o %t1.o
# RUN: %clang %cflags -gdwarf-4 %t1.o %t.o -o %t.exe
# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections
# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections --debug-thread-count=4 --cu-processing-batch-size=4
# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.exe | FileCheck --check-prefix=PRECHECK %s
# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.bolt | FileCheck --check-prefix=POSTCHECK %s

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-loclist.s -o %t1.o
# RUN: llvm-mc -dwarf-version=4 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf4-two-entries-loclist.s -o %t2.o
# RUN: %clang %cflags %t1.o %t2.o %t.o -o %t.exe
# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections
# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections --debug-thread-count=4 --cu-processing-batch-size=4
# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.exe | FileCheck --check-prefix=PRECHECK %s
# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.bolt | FileCheck --check-prefix=POSTCHECK %s

Expand Down
2 changes: 1 addition & 1 deletion bolt/test/X86/dwarf4-df-dualcu-loclist.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
; RUN: llvm-mc -dwarf-version=4 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf4-df-dualcu-loclist-helper.s \
; RUN: -split-dwarf-file=helper.dwo -o helper.o
; RUN: %clang %cflags -gdwarf-5 -O2 -gsplit-dwarf=split main.o helper.o -o main.exe
; RUN: llvm-bolt main.exe -o main.exe.bolt --update-debug-sections
; RUN: llvm-bolt main.exe -o main.exe.bolt --update-debug-sections --debug-thread-count=4 --cu-processing-batch-size=4
; RUN: llvm-dwarfdump --show-form --verbose --debug-info main.dwo | FileCheck -check-prefix=PRE-BOLT-DWO-MAIN %s
; RUN: llvm-dwarfdump --show-form --verbose --debug-info main.dwo.dwo | FileCheck -check-prefix=BOLT-DWO-MAIN %s
; RUN: llvm-dwarfdump --show-form --verbose --debug-info helper.dwo | FileCheck -check-prefix=PRE-BOLT-DWO-HELPER %s
Expand Down
2 changes: 1 addition & 1 deletion bolt/test/X86/dwarf4-split-dwarf-no-address.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
; RUN: llvm-mc --split-dwarf-file=helper.dwo --triple=x86_64-unknown-linux-gnu \
; RUN: --filetype=obj %p/Inputs/dwarf4-split-dwarf-no-address-helper.s -o=helper.o
; RUN: %clang %cflags -gdwarf-4 -gsplit-dwarf=split main.o helper.o -o main.exe -fno-pic -no-pie
; RUN: llvm-bolt main.exe -o main.exe.bolt --update-debug-sections
; RUN: llvm-bolt main.exe -o main.exe.bolt --update-debug-sections --debug-thread-count=4 --cu-processing-batch-size=4
; RUN: llvm-dwarfdump --show-form --verbose --debug-info main.exe.bolt | FileCheck -check-prefix=BOLT %s

;; Testing that there are no asserts/crashes when one of the DWARF4 CUs does not modify .debug_addr
Expand Down
2 changes: 1 addition & 1 deletion bolt/test/X86/dwarf4-subprogram-multiple-ranges-cus.test
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# RUN: llvm-mc -dwarf-version=4 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf4-subprogram-multiple-ranges-main.s -o %t1.o
# RUN: llvm-mc -dwarf-version=4 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf4-subprogram-multiple-ranges-other.s -o %t2.o
# RUN: %clang %cflags %t1.o %t2.o -o %t.exe -Wl,-q
# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections
# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections --debug-thread-count=4 --cu-processing-batch-size=4
# RUN: llvm-objdump %t.bolt --disassemble > %t1.txt
# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.bolt >> %t1.txt
# RUN: cat %t1.txt | FileCheck --check-prefix=POSTCHECK %s
Expand Down
2 changes: 1 addition & 1 deletion bolt/test/X86/dwarf4-types-dwarf5-types.test
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# RUN: llvm-mc -dwarf-version=4 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf4-types-dwarf5-types-main.s -o %tmain.o
# RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf4-types-dwarf5-types-helper.s -o %thelper.o
# RUN: %clang %cflags %tmain.o %thelper.o -o %t.exe -Wl,-q
# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections
# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections --debug-thread-count=4 --cu-processing-batch-size=4
# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.bolt | FileCheck --check-prefix=POSTCHECK %s
# RUN: llvm-dwarfdump --show-form --verbose --debug-types %t.bolt | FileCheck --check-prefix=POSTCHECKTU %s

Expand Down
2 changes: 1 addition & 1 deletion bolt/test/X86/dwarf4-types-dwarf5.test
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# RUN: llvm-mc -dwarf-version=4 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf4-types-dwarf5-main.s -o %tmain.o
# RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf4-types-dwarf5-helper.s -o %thelper.o
# RUN: %clang %cflags %tmain.o %thelper.o -o %t.exe -Wl,-q
# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections
# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections --debug-thread-count=4 --cu-processing-batch-size=4
# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.bolt | FileCheck --check-prefix=POSTCHECK %s
# RUN: llvm-dwarfdump --show-form --verbose --debug-types %t.bolt | FileCheck --check-prefix=POSTCHECKTU %s

Expand Down
2 changes: 1 addition & 1 deletion bolt/test/X86/dwarf5-addr-section-reuse.s
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-helper2-addr-section-reuse.s -o %thelper2.o
# RUN: %clang %cflags -dwarf-5 %thelper1.o %tmain.o %thelper2.o -o %t.exe -Wl,-q
# RUN: llvm-dwarfdump --debug-info %t.exe | FileCheck --check-prefix=PRECHECK %s
# RUN: llvm-bolt %t.exe -o %t.exe.bolt --update-debug-sections
# RUN: llvm-bolt %t.exe -o %t.exe.bolt --update-debug-sections --debug-thread-count=4 --cu-processing-batch-size=4
# RUN: llvm-dwarfdump --debug-info %t.exe.bolt | FileCheck --check-prefix=POSTCHECK %s

## This test checks that when a binary is bolted if CU is not modified and has DW_AT_addr_base that is shared
Expand Down
2 changes: 1 addition & 1 deletion bolt/test/X86/dwarf5-call-pc-function-null-check.test
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-call-pc-function-null-check-main.s -o %tmain.o
# RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-call-pc-function-null-check-helper.s -o %thelper.o
# RUN: %clang %cflags -dwarf-5 %tmain.o %thelper.o -o %t.exe -Wl,-q
# RUN: llvm-bolt %t.exe -o %t.exe.bolt --update-debug-sections
# RUN: llvm-bolt %t.exe -o %t.exe.bolt --update-debug-sections --debug-thread-count=4 --cu-processing-batch-size=4
# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.exe > %t.txt
# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.exe.bolt >> %t.txt
# RUN: cat %t.txt | FileCheck --check-prefix=CHECK %s
Expand Down
2 changes: 1 addition & 1 deletion bolt/test/X86/dwarf5-call-pc.test
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-call-pc-main.s -o %tmain.o
# RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-call-pc-helper.s -o %thelper.o
# RUN: %clang %cflags -dwarf-5 %tmain.o %thelper.o -o %t.exe -Wl,-q
# RUN: llvm-bolt %t.exe -o %t.exe.bolt --update-debug-sections -reorder-blocks=reverse
# RUN: llvm-bolt %t.exe -o %t.exe.bolt --update-debug-sections -reorder-blocks=reverse --debug-thread-count=4 --cu-processing-batch-size=4
# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.exe > %tmain.txt
# RUN: llvm-objdump %t.exe --disassemble >> %tmain.txt
# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.exe.bolt > %tmainbolt.txt
Expand Down
2 changes: 1 addition & 1 deletion bolt/test/X86/dwarf5-cu-no-debug-addr.test
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-cu-no-debug-addr-main.s -o %t1main.o
# RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-cu-no-debug-addr-helper.s -o %t1helper.o
# RUN: %clang %cflags -dwarf-5 %t1main.o %t1helper.o -o %t.exe -Wl,-q
# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections
# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections --debug-thread-count=4 --cu-processing-batch-size=4
# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.exe | FileCheck --check-prefix=PRECHECK %s
# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.bolt | FileCheck --check-prefix=POSTCHECK %s

Expand Down
2 changes: 1 addition & 1 deletion bolt/test/X86/dwarf5-df-input-lowpc-ranges-cus.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
; RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-df-input-lowpc-ranges-other.s \
; RUN: -split-dwarf-file=mainOther.dwo -o other.o
; RUN: %clang %cflags main.o other.o -o main.exe
; RUN: llvm-bolt main.exe -o main.exe.bolt --update-debug-sections
; RUN: llvm-bolt main.exe -o main.exe.bolt --update-debug-sections --debug-thread-count=4 --cu-processing-batch-size=4
; RUN: llvm-dwarfdump --show-form --verbose --debug-rnglists main.exe.bolt &> %t/foo.txt
; RUN: llvm-dwarfdump --show-form --verbose --debug-addr main.exe.bolt >> %t/foo.txt
; RUN: llvm-dwarfdump --show-form --verbose --debug-info main.exe.bolt >> %t/foo.txt
Expand Down
2 changes: 1 addition & 1 deletion bolt/test/X86/dwarf5-df-mono-dualcu.test
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
; RUN: -split-dwarf-file=main.dwo -o main.o
; RUN: llvm-mc -filetype=obj -triple x86_64-unknown-linux-gnu %p/Inputs/dwarf5-df-mono-helper.s -o=helper.o
; RUN: %clang %cflags -gdwarf-5 main.o helper.o -o main.exe -fno-pic -no-pie
; RUN: llvm-bolt main.exe -o main.exe.bolt --update-debug-sections --always-convert-to-ranges
; RUN: llvm-bolt main.exe -o main.exe.bolt --update-debug-sections --always-convert-to-ranges --debug-thread-count=4 --cu-processing-batch-size=4
; RUN: llvm-dwarfdump --show-form --verbose --debug-info main.exe | FileCheck -check-prefix=PRE-BOLT %s
; RUN: llvm-dwarfdump --show-form --verbose --debug-addr main.exe.bolt &> %t/foo.txt
; RUN: llvm-dwarfdump --show-form --verbose --debug-info main.exe.bolt >> %t/foo.txt
Expand Down
2 changes: 1 addition & 1 deletion bolt/test/X86/dwarf5-df-output-dir-same-name.test
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
; RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-df-output-dir-same-name-helper.s \
; RUN: -split-dwarf-file=objects/o2/split.dwo -o helper.o
; RUN: %clang %cflags -gdwarf-5 -gsplit-dwarf=split main.o helper.o -o main.exe
; RUN: llvm-bolt main.exe -o main.exe.bolt --update-debug-sections --dwarf-output-path=%t/dwo
; RUN: llvm-bolt main.exe -o main.exe.bolt --update-debug-sections --dwarf-output-path=%t/dwo --debug-thread-count=4 --cu-processing-batch-size=4
; RUN: ls -l %t/dwo > log
; RUN: llvm-dwarfdump --debug-info main.exe.bolt >> log
; RUN: cat log | FileCheck -check-prefix=BOLT %s
Expand Down
2 changes: 1 addition & 1 deletion bolt/test/X86/dwarf5-df-types-debug-names.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
; RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-df-types-debug-names-helper.s \
; RUN: -split-dwarf-file=helper.dwo -o helper.o
; RUN: %clang %cflags -gdwarf-5 -gsplit-dwarf=split main.o helper.o -o main.exe
; RUN: llvm-bolt main.exe -o main.exe.bolt --update-debug-sections
; RUN: llvm-bolt main.exe -o main.exe.bolt --update-debug-sections --debug-thread-count=4 --cu-processing-batch-size=4
; RUN: llvm-dwarfdump --debug-info -r 0 main.dwo.dwo > log.txt
; RUN: llvm-dwarfdump --debug-info -r 0 helper.dwo.dwo >> log.txt
; RUN: llvm-dwarfdump --debug-info --debug-names main.exe.bolt >> log.txt
Expand Down
2 changes: 1 addition & 1 deletion bolt/test/X86/dwarf5-df-types-modify-dwo-name-mixed.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
; RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-df-types-dup-helper.s \
; RUN: -split-dwarf-file=helper.dwo -o helper.o
; RUN: %clang %cflags -gdwarf-5 -gsplit-dwarf=split main.o helper.o -o main.exe
; RUN: llvm-bolt main.exe -o main.exe.bolt --update-debug-sections
; RUN: llvm-bolt main.exe -o main.exe.bolt --update-debug-sections --debug-thread-count=4 --cu-processing-batch-size=4
; RUN: llvm-dwarfdump --debug-info -r 0 main.exe.bolt > log.txt
; RUN: llvm-dwarfdump --debug-info -r 0 main.dwo.dwo >> log.txt
; RUN: llvm-dwarfdump --debug-info -r 0 helper.dwo.dwo >> log.txt
Expand Down
2 changes: 1 addition & 1 deletion bolt/test/X86/dwarf5-df-types-modify-dwo-name.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
; RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-df-types-debug-names-helper.s \
; RUN: -split-dwarf-file=helper.dwo -o helper.o
; RUN: %clang %cflags -gdwarf-5 -gsplit-dwarf=split main.o helper.o -o main.exe
; RUN: llvm-bolt main.exe -o main.exe.bolt --update-debug-sections
; RUN: llvm-bolt main.exe -o main.exe.bolt --update-debug-sections --debug-thread-count=4 --cu-processing-batch-size=4
; RUN: llvm-dwarfdump --debug-info -r 0 main.exe.bolt > log.txt
; RUN: llvm-dwarfdump --debug-info -r 0 main.dwo.dwo >> log.txt
; RUN: llvm-dwarfdump --debug-info -r 0 helper.dwo.dwo >> log.txt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# RUN: llvm-mc -dwarf-version=4 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf4-gdb-index-types-helper.s -o %thelpergdb.o
# RUN: %clang %cflags %tmaingdb.o %thelpergdb.o -o %tgdb.exe -Wl,-q
# RUN: llvm-objcopy %tgdb.exe --add-section=.gdb_index=%p/Inputs/dwarf5-dwarf4-gdb-index-types-v8.generted-gdb11.gdb-index
# RUN: llvm-bolt %tgdb.exe -o %tgdb.bolt --update-debug-sections
# RUN: llvm-bolt %tgdb.exe -o %tgdb.bolt --update-debug-sections --debug-thread-count=4 --cu-processing-batch-size=4
# RUN: llvm-dwarfdump --gdb-index %tgdb.bolt | FileCheck --check-prefix=POSTCHECK %s

## Tests that BOLT correctly handles gdb-index generated by GDB.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# RUN: llvm-mc -dwarf-version=4 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf4-gdb-index-types-helper.s -o %thelpergdb.o
# RUN: %clang %cflags %tmaingdb.o %thelpergdb.o -o %tgdb.exe -Wl,-q
# RUN: llvm-objcopy %tgdb.exe --add-section=.gdb_index=%p/Inputs/dwarf5-dwarf4-gdb-index-types-v8.generted-gdb9.gdb-index
# RUN: llvm-bolt %tgdb.exe -o %tgdb.bolt --update-debug-sections
# RUN: llvm-bolt %tgdb.exe -o %tgdb.bolt --update-debug-sections --debug-thread-count=4 --cu-processing-batch-size=4
# RUN: llvm-dwarfdump --gdb-index %tgdb.bolt | FileCheck --check-prefix=POSTCHECK %s

## Tests that BOLT correctly handles gdb-index generated by GDB.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-gdb-index-types-main.s -o %tmain.o
# RUN: llvm-mc -dwarf-version=4 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf4-gdb-index-types-helper.s -o %thelper.o
# RUN: %clang %cflags %tmain.o %thelper.o -o %t.exe -Wl,-q -Wl,--gdb-index
# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections
# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections --debug-thread-count=4 --cu-processing-batch-size=4
# RUN: llvm-dwarfdump --gdb-index %t.bolt | FileCheck --check-prefix=POSTCHECK %s

## Tests that BOLT correctly handles gdb-index generated by LLD.
Expand Down
2 changes: 1 addition & 1 deletion bolt/test/X86/dwarf5-dwarf4-monolithic.test
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-dwarf4-monolithic-helper1.s -o %t1.o
# RUN: llvm-mc -dwarf-version=4 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-dwarf4-monolithic-helper2.s -o %t2.o
# RUN: %clang %cflags -dwarf-5 %tmain.o %t0.o %t1.o %t2.o -o %t.exe -Wl,-q
# RUN: llvm-bolt --always-convert-to-ranges %t.exe -o %t.bolt --update-debug-sections
# RUN: llvm-bolt --always-convert-to-ranges %t.exe -o %t.bolt --update-debug-sections --debug-thread-count=4 --cu-processing-batch-size=4
# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.exe | FileCheck --check-prefix=PRECHECK %s
# RUN: llvm-dwarfdump --show-form --verbose --debug-line %t.exe > %t_line.txt
# RUN: llvm-dwarfdump --show-form --verbose --debug-addr %t.bolt > %t.txt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-dwarf4-types-backward-forward-cross-reference-main.s -o %tmain.o
# RUN: llvm-mc -dwarf-version=4 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-dwarf4-types-backward-forward-cross-reference-helper.s -o %thelper.o
# RUN: %clang %cflags %tmain.o %thelper.o -o %t.exe
# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections
# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections --debug-thread-count=4 --cu-processing-batch-size=4
# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.bolt | FileCheck --check-prefix=POSTCHECK %s
# RUN: llvm-dwarfdump --show-form --verbose --debug-addr %t.bolt | FileCheck --check-prefix=POSTCHECKADDR %s
# RUN: llvm-dwarfdump --show-form --verbose --debug-types %t.bolt | FileCheck --check-prefix=POSTCHECKTU %s
Expand Down
2 changes: 1 addition & 1 deletion bolt/test/X86/dwarf5-empty-arange.test
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-empty-arange-main.s -o %tmain.o
# RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-empty-arange-helper.s -o %thelper.o
# RUN: %clang %cflags -dwarf-5 %tmain.o %thelper.o -o %t.exe -Wl,--entry=main -Wl,-q -Wl,-gc-sections
# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections
# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections --debug-thread-count=4 --cu-processing-batch-size=4
# RUN: llvm-dwarfdump --debug-aranges %t.bolt > %t.txt
# RUN: llvm-dwarfdump --debug-info -r 0 %t.bolt >> %t.txt
# RUN: cat %t.txt | FileCheck --check-prefix=POSTCHECK %s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-gdb-index-types-helper.s -o %thelpergdb.o
# RUN: %clang %cflags %tmaingdb.o %thelpergdb.o -o %tgdb.exe -Wl,-q
# RUN: llvm-objcopy %tgdb.exe --add-section=.gdb_index=%p/Inputs/dwarf5-gdb-index-types-v8.generted-gdb11.gdb-index
# RUN: llvm-bolt %tgdb.exe -o %tgdb.bolt --update-debug-sections
# RUN: llvm-bolt %tgdb.exe -o %tgdb.bolt --update-debug-sections --debug-thread-count=4 --cu-processing-batch-size=4
# RUN: llvm-dwarfdump --gdb-index %tgdb.bolt | FileCheck --check-prefix=POSTCHECK %s

## Tests that BOLT correctly handles gdb-index generated by GDB.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-gdb-index-types-helper.s -o %thelpergdb.o
# RUN: %clang %cflags %tmaingdb.o %thelpergdb.o -o %tgdb.exe -Wl,-q
# RUN: llvm-objcopy %tgdb.exe --add-section=.gdb_index=%p/Inputs/dwarf5-gdb-index-types-v8.generted-gdb9.gdb-index
# RUN: llvm-bolt %tgdb.exe -o %tgdb.bolt --update-debug-sections
# RUN: llvm-bolt %tgdb.exe -o %tgdb.bolt --update-debug-sections --debug-thread-count=4 --cu-processing-batch-size=4
# RUN: llvm-dwarfdump --gdb-index %tgdb.bolt | FileCheck --check-prefix=POSTCHECK %s

## Tests that BOLT correctly handles gdb-index generated by GDB.
Expand Down
2 changes: 1 addition & 1 deletion bolt/test/X86/dwarf5-gdb-index-types-lld-generated.test
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-gdb-index-types-main.s -o %tmain.o
# RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-gdb-index-types-helper.s -o %thelper.o
# RUN: %clang %cflags %tmain.o %thelper.o -o %t.exe -Wl,-q -Wl,--gdb-index
# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections
# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections --debug-thread-count=4 --cu-processing-batch-size=4
# RUN: llvm-dwarfdump --gdb-index %t.bolt | FileCheck --check-prefix=POSTCHECK %s

## Tests that BOLT correctly handles gdb-index generated by LLD.
Expand Down
2 changes: 1 addition & 1 deletion bolt/test/X86/dwarf5-locexpr-referrence.test
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-locexpr-referrence-main.s -o %tmain.o
# RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-locexpr-referrence-helper.s -o %thelper.o
# RUN: %clang %cflags -dwarf-5 %tmain.o %thelper.o -o %t.exe -Wl,-q
# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections
# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections --debug-thread-count=4 --cu-processing-batch-size=4
# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.bolt | FileCheck --check-prefix=CHECK %s
# RUN: llvm-dwarfdump --show-form --verbose --debug-addr %t.bolt | FileCheck --check-prefix=CHECKADDR %s

Expand Down
2 changes: 1 addition & 1 deletion bolt/test/X86/dwarf5-loclist-offset-form.test
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-loclist-offset-form-main.s -o %tmain.o
# RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-loclist-offset-form-helper.s -o %thelper.o
# RUN: %clang %cflags -dwarf-5 %tmain.o %thelper.o -o %t.exe -Wl,-q
# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections
# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections --debug-thread-count=4 --cu-processing-batch-size=4
# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.exe | FileCheck --check-prefix=PRECHECK %s
# RUN: llvm-dwarfdump --show-form --verbose --debug-addr %t.bolt > %t.txt
# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.bolt >> %t.txt
Expand Down
2 changes: 1 addition & 1 deletion bolt/test/X86/dwarf5-one-loclists-two-bases.test
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5_main.s -o %tmain.o
# RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-loc-base-no-loc-accesshelper.s -o %thelper.o
# RUN: %clang %cflags -dwarf-5 %tmain.o %thelper.o -o %t.exe -Wl,-q
# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections
# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections --debug-thread-count=4 --cu-processing-batch-size=4
# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.exe | FileCheck --check-prefix=PRECHECK %s
# RUN: llvm-dwarfdump --show-form --verbose --debug-addr %t.bolt > %t.txt
# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.bolt >> %t.txt
Expand Down
2 changes: 1 addition & 1 deletion bolt/test/X86/dwarf5-return-pc-form-addr.test
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-return-pc-form-addr-main.s -o %tmain.o
# RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-return-pc-helper.s -o %thelper.o
# RUN: %clang %cflags -dwarf-5 %tmain.o %thelper.o -o %t.exe -Wl,-q
# RUN: llvm-bolt %t.exe -o %t.exe.bolt --update-debug-sections -reorder-blocks=reverse
# RUN: llvm-bolt %t.exe -o %t.exe.bolt --update-debug-sections -reorder-blocks=reverse --debug-thread-count=4 --cu-processing-batch-size=4
# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.exe > %tmain.txt
# RUN: llvm-objdump %t.exe --disassemble >> %tmain.txt
# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.exe.bolt > %tmainbolt.txt
Expand Down
2 changes: 1 addition & 1 deletion bolt/test/X86/dwarf5-return-pc.test
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-return-pc-main.s -o %tmain.o
# RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-return-pc-helper.s -o %thelper.o
# RUN: %clang %cflags -dwarf-5 %tmain.o %thelper.o -o %t.exe -Wl,-q
# RUN: llvm-bolt %t.exe -o %t.exe.bolt --update-debug-sections -reorder-blocks=reverse
# RUN: llvm-bolt %t.exe -o %t.exe.bolt --update-debug-sections -reorder-blocks=reverse --debug-thread-count=4 --cu-processing-batch-size=4
# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.exe > %tmain.txt
# RUN: llvm-objdump %t.exe --disassemble >> %tmain.txt
# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.exe.bolt > %tmainbolt.txt
Expand Down
2 changes: 1 addition & 1 deletion bolt/test/X86/dwarf5-shared-str-offset-base.s
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# RUN: llvm-mc --filetype=obj --triple x86_64 %s -o %tmain.o --defsym MAIN=0
# RUN: llvm-mc --filetype=obj --triple x86_64 %s -o %thelper.o
# RUN: %clang %cflags %tmain.o %thelper.o -o %tmain.exe
# RUN: llvm-bolt %tmain.exe -o %tmain.exe.bolt --update-debug-sections
# RUN: llvm-bolt %tmain.exe -o %tmain.exe.bolt --update-debug-sections --debug-thread-count=4 --cu-processing-batch-size=4
# RUN: llvm-dwarfdump --debug-info %tmain.exe.bolt > %tout.text
# RUN: llvm-dwarfdump --show-section-sizes %tmain.exe >> %tout.text
# RUN: llvm-dwarfdump --show-section-sizes %tmain.exe.bolt >> %tout.text
Expand Down
2 changes: 1 addition & 1 deletion bolt/test/X86/dwarf5-split-dwarf4-monolithic.test
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux -split-dwarf-file=helper1.dwo %p/Inputs/dwarf5-split-dwarf4-monolithic-helper1.s -o helper1.o
# RUN: llvm-mc -dwarf-version=4 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-dwarf4-monolithic-helper2.s -o helper2.o
# RUN: %clang %cflags -dwarf-5 main.o helper0.o helper1.o helper2.o -o main.exe -Wl,-q
# RUN: llvm-bolt --always-convert-to-ranges main.exe -o main.bolt --update-debug-sections
# RUN: llvm-bolt --always-convert-to-ranges main.exe -o main.bolt --update-debug-sections --debug-thread-count=4 --cu-processing-batch-size=4
# RUN: llvm-dwarfdump --show-form --verbose --debug-info main.exe | FileCheck --check-prefix=PRECHECK %s
# RUN: llvm-dwarfdump --show-form --verbose --debug-line main.exe | FileCheck --check-prefix=PRECHECK-LINE %s
# RUN: llvm-dwarfdump --show-form --verbose --debug-addr main.bolt > boltout.txt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# RUN: llvm-mc --split-dwarf-file=helper.dwo -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-split-gdb-index-types-helper.s -o helpergdb.o
# RUN: %clang %cflags maingdb.o helpergdb.o -o maingdb.exe -Wl,-q
# RUN: llvm-objcopy maingdb.exe --add-section=.gdb_index=%p/Inputs/dwarf5-split-gdb-index-types-v8.gdb-index
# RUN: llvm-bolt maingdb.exe -o maingdb.exe.bolt --update-debug-sections
# RUN: llvm-bolt maingdb.exe -o maingdb.exe.bolt --update-debug-sections --debug-thread-count=4 --cu-processing-batch-size=4
# RUN: llvm-dwarfdump --gdb-index maingdb.exe.bolt | FileCheck --check-prefix=POSTCHECK %s

## Tests that BOLT correctly handles gdb-index generated by GDB with split-dwarf DWARF4.
Expand Down
2 changes: 1 addition & 1 deletion bolt/test/X86/dwarf5-subprogram-multiple-ranges-cus.test
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-subprogram-multiple-ranges-main.s -o %t1.o
# RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-subprogram-multiple-ranges-other.s -o %t2.o
# RUN: %clang %cflags %t1.o %t2.o -o %t.exe -Wl,-q
# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections
# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections --debug-thread-count=4 --cu-processing-batch-size=4
# RUN: llvm-objdump %t.bolt --disassemble > %t1.txt
# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.bolt >> %t1.txt
# RUN: cat %t1.txt | FileCheck --check-prefix=POSTCHECK %s
Expand Down
2 changes: 1 addition & 1 deletion bolt/test/X86/dwarf5-two-cu-str-offset-table.test
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5_main.s -o %tmain.o
# RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5_helper.s -o %thelper.o
# RUN: %clang %cflags -dwarf-5 %tmain.o %thelper.o -o %t.exe -Wl,-q
# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections
# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections --debug-thread-count=4 --cu-processing-batch-size=4
# RUN: llvm-dwarfdump --show-form --verbose --debug-str-offsets %t.exe > %t.txt
# RUN: llvm-dwarfdump --show-form --verbose --debug-str-offsets %t.bolt >> %t.txt
# RUN: cat %t.txt | FileCheck --check-prefix=CHECK %s
Expand Down
2 changes: 1 addition & 1 deletion bolt/test/X86/dwarf5-two-loclists.test
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5_main.s -o %tmain.o
# RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5_helper.s -o %thelper.o
# RUN: %clang %cflags -dwarf-5 %tmain.o %thelper.o -o %t.exe -Wl,-q
# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections
# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections --debug-thread-count=4 --cu-processing-batch-size=4
# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.exe | FileCheck --check-prefix=PRECHECK %s
# RUN: llvm-dwarfdump --show-form --verbose --debug-addr %t.bolt > %t.txt
# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.bolt >> %t.txt
Expand Down
2 changes: 1 addition & 1 deletion bolt/test/X86/dwarf5-two-rnglists.test
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5_main.s -o %tmain.o
# RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5_helper.s -o %thelper.o
# RUN: %clang %cflags -dwarf-5 %tmain.o %thelper.o -o %t.exe -Wl,-q
# RUN: llvm-bolt --always-convert-to-ranges %t.exe -o %t.bolt --update-debug-sections
# RUN: llvm-bolt --always-convert-to-ranges %t.exe -o %t.bolt --update-debug-sections --debug-thread-count=4 --cu-processing-batch-size=4
# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.exe | FileCheck --check-prefix=PRECHECK %s
# RUN: llvm-dwarfdump --show-form --verbose --debug-addr %t.bolt > %t.txt
# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.bolt >> %t.txt
Expand Down
2 changes: 1 addition & 1 deletion bolt/test/X86/dwarf5-type-unit-no-cu-str-offset-table.test
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-basic-cu.s -o %tmain.o
# RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-types-no-cu.s -o %thelper.o
# RUN: %clang %cflags %tmain.o %thelper.o -o %t.exe -Wl,-q
# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections
# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections --debug-thread-count=4 --cu-processing-batch-size=4
# RUN: llvm-dwarfdump --show-form --verbose --debug-str-offsets %t.exe | FileCheck -check-prefix=PRE-BOLT %s
# RUN: llvm-dwarfdump --show-form --verbose --debug-str-offsets %t.bolt | FileCheck -check-prefix=POST-BOLT %s

Expand Down
2 changes: 1 addition & 1 deletion bolt/test/X86/dwarf5-types-backward-cross-reference.s
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %s -o %t.o
# RUN: %clang %cflags -gdwarf-5 %t.o -o %t.exe
# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections
# RUN: llvm-bolt %t.exe -o %t.bolt --update-debug-sections --debug-thread-count=4 --cu-processing-batch-size=4
# RUN: llvm-dwarfdump --show-form --verbose --debug-info %t.bolt | FileCheck --check-prefix=POSTCHECK %s

## This test checks that BOLT handles backward cross CU references for dwarf5
Expand Down
2 changes: 1 addition & 1 deletion bolt/test/X86/dwarf5-types-debug-names.test
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
; RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-types-debug-names-main.s -o %tmain.o
; RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-types-debug-names-helper.s -o %thelper.o
; RUN: %clang %cflags -gdwarf-5 %tmain.o %thelper.o -o %tmain.exe
; RUN: llvm-bolt %tmain.exe -o %tmain.exe.bolt --update-debug-sections
; RUN: llvm-bolt %tmain.exe -o %tmain.exe.bolt --update-debug-sections --debug-thread-count=4 --cu-processing-batch-size=4
; RUN: llvm-dwarfdump --debug-info --debug-names %tmain.exe.bolt > %tlog.txt
; RUN: cat %tlog.txt | FileCheck -check-prefix=BOLT %s

Expand Down
32 changes: 32 additions & 0 deletions bolt/test/X86/dynamic-relocs-on-entry.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// This test examines whether BOLT can correctly process when
// dynamic relocation points to other entry points of the
// function.

# RUN: %clang %cflags -fPIC -pie %s -o %t.exe -nostdlib -Wl,-q
# RUN: llvm-bolt %t.exe -o %t.bolt > %t.out.txt
# RUN: readelf -r %t.bolt >> %t.out.txt
# RUN: llvm-objdump --disassemble-symbols=chain %t.bolt >> %t.out.txt
# RUN: FileCheck %s --input-file=%t.out.txt

## Check if the new address in `chain` is correctly updated by BOLT
# CHECK: Relocation section '.rela.dyn' at offset 0x{{.*}} contains 1 entry:
# CHECK: {{.*}} R_X86_64_RELATIVE [[#%x,ADDR:]]
# CHECK: [[#ADDR]]: c3 retq
.text
.type chain, @function
chain:
movq $1, %rax
Label:
ret
.size chain, .-chain

.type _start, @function
.global _start
_start:
jmpq *.Lfoo(%rip)
ret
.size _start, .-_start

.data
.Lfoo:
.quad Label
2 changes: 1 addition & 1 deletion bolt/test/X86/encoding-validation.s
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-linux %s -o %t.o
# RUN: ld.lld %t.o -o %t.exe -q
# RUN: llvm-bolt %t.exe --relocs -o %t.out --check-encoding |& FileCheck %s
# RUN: llvm-bolt %t.exe --relocs -o %t.out --check-encoding 2>&1 | FileCheck %s

.text
.globl _start
Expand Down
6 changes: 3 additions & 3 deletions bolt/test/X86/gotpcrelx.s
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
# RUN: ld.lld %t.o -o %t.pie.exe -q -pie
# RUN: ld.lld %t.o -o %t.no-relax.exe -q --no-relax
# RUN: llvm-bolt %t.exe --relocs -o %t.out --print-cfg --print-only=_start \
# RUN: |& FileCheck --check-prefix=BOLT %s
# RUN: 2>&1 | FileCheck --check-prefix=BOLT %s
# RUN: llvm-bolt %t.pie.exe -o %t.null --print-cfg --print-only=_start \
# RUN: |& FileCheck --check-prefix=PIE-BOLT %s
# RUN: 2>&1 | FileCheck --check-prefix=PIE-BOLT %s
# RUN: llvm-bolt %t.no-relax.exe -o %t.null --print-cfg --print-only=_start \
# RUN: |& FileCheck --check-prefix=NO-RELAX-BOLT %s
# RUN: 2>&1 | FileCheck --check-prefix=NO-RELAX-BOLT %s
# RUN: llvm-objdump -d --no-show-raw-insn --print-imm-hex \
# RUN: %t.out | FileCheck --check-prefix=DISASM %s

Expand Down
2 changes: 1 addition & 1 deletion bolt/test/X86/icf-jump-tables.test
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# REQUIRES: system-linux

# RUN: %clang %cflags -O1 -g %p/../Inputs/icf-jump-tables.c -o %t.exe -Wl,-q
# RUN: llvm-bolt %t.exe --icf -o %t.bolt |& FileCheck %s
# RUN: llvm-bolt %t.exe --icf -o %t.bolt 2>&1 | FileCheck %s

## Check that BOLT successfully folded a function with jump table:
# CHECK: ICF folded {{.*}}. {{[^0]}} functions had jump tables.
Expand Down
2 changes: 1 addition & 1 deletion bolt/test/X86/indirect-goto-pie.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ REQUIRES: x86_64-linux

RUN: %clang %S/Inputs/indirect_goto.c -o %t -fpic -pie -Wl,-q
RUN: not llvm-bolt %t -o %t.bolt --relocs=1 --print-cfg --print-only=main \
RUN: |& FileCheck %s
RUN: 2>&1 | FileCheck %s

## Check that processing works if main() is skipped.
RUN: llvm-bolt %t -o %t.bolt --relocs=1 --skip-funcs=main
Expand Down
2 changes: 1 addition & 1 deletion bolt/test/X86/jump-table-func-entry.s
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# RUN: %clang %cflags %t.o -o %t.exe -no-pie -Wl,-q

# RUN: llvm-bolt %t.exe --print-normalized --print-only=foo -o %t.out \
# RUN: |& FileCheck %s
# RUN: 2>&1 | FileCheck %s



Expand Down
2 changes: 1 addition & 1 deletion bolt/test/X86/keep-nops.s
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-linux %s -o %t.o
# RUN: ld.lld %t.o -o %t.exe -q
# RUN: llvm-bolt %t.exe -o %t.bolt.exe --keep-nops --relocs --print-finalized \
# RUN: |& FileCheck --check-prefix=CHECK-BOLT %s
# RUN: 2>&1 | FileCheck --check-prefix=CHECK-BOLT %s
# RUN: llvm-objdump -d %t.bolt.exe | FileCheck %s

.text
Expand Down
2 changes: 1 addition & 1 deletion bolt/test/X86/linux-bug-table.s
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
## Verify bug entry bindings again after unreachable code elimination.

# RUN: llvm-bolt %t.out -o %t.out.1 --print-only=_start --print-normalized \
# RUN: |& FileCheck --check-prefix=CHECK-REOPT %s
# RUN: 2>&1 | FileCheck --check-prefix=CHECK-REOPT %s

# CHECK: BOLT-INFO: Linux kernel binary detected
# CHECK: BOLT-INFO: parsed 2 bug table entries
Expand Down
8 changes: 4 additions & 4 deletions bolt/test/X86/linux-orc.s
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

## Verify reading contents of ORC sections.

# RUN: llvm-bolt %t.exe --dump-orc -o /dev/null |& FileCheck %s \
# RUN: llvm-bolt %t.exe --dump-orc -o /dev/null 2>&1 | FileCheck %s \
# RUN: --check-prefix=CHECK-ORC

# CHECK-ORC: BOLT-INFO: ORC unwind information:
Expand All @@ -27,19 +27,19 @@
## Verify ORC bindings to instructions.

# RUN: llvm-bolt %t.exe --print-normalized --dump-orc --print-orc -o %t.out \
# RUN: --keep-nops=0 --bolt-info=0 |& FileCheck %s
# RUN: --keep-nops=0 --bolt-info=0 2>&1 | FileCheck %s


## Verify ORC bindings after rewrite.

# RUN: llvm-bolt %t.out -o %t.out.1 --print-normalized --print-orc \
# RUN: |& FileCheck %s
# RUN: 2>&1 | FileCheck %s

## Verify ORC binding after rewrite when some of the functions are skipped.

# RUN: llvm-bolt %t.exe -o %t.out --skip-funcs=bar --bolt-info=0 --keep-nops=0
# RUN: llvm-bolt %t.out -o %t.out.1 --print-normalized --print-orc \
# RUN: |& FileCheck %s
# RUN: 2>&1 | FileCheck %s

# CHECK: BOLT-INFO: Linux kernel binary detected
# CHECK: BOLT-INFO: parsed 9 ORC entries
Expand Down
2 changes: 1 addition & 1 deletion bolt/test/X86/linux-pci-fixup.s
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s -o %t.o
# RUN: %clang %cflags -nostdlib %t.o -o %t.exe \
# RUN: -Wl,--image-base=0xffffffff80000000,--no-dynamic-linker,--no-eh-frame-hdr,--no-pie
# RUN: llvm-bolt %t.exe --print-normalized -o %t.out |& FileCheck %s
# RUN: llvm-bolt %t.exe --print-normalized -o %t.out 2>&1 | FileCheck %s

## Check that BOLT correctly parses the Linux kernel .pci_fixup section and
## verify that PCI fixup hook in the middle of a function is detected.
Expand Down
4 changes: 2 additions & 2 deletions bolt/test/X86/linux-smp-locks.s
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
# RUN: %clang %cflags -nostdlib %t.o -o %t.exe \
# RUN: -Wl,--image-base=0xffffffff80000000,--no-dynamic-linker,--no-eh-frame-hdr,--no-pie
# RUN: llvm-bolt %t.exe --print-normalized --keep-nops=0 --bolt-info=0 -o %t.out \
# RUN: |& FileCheck %s
# RUN: 2>&1 | FileCheck %s

## Check the output of BOLT with NOPs removed.

# RUN: llvm-bolt %t.out -o %t.out.1 --print-normalized |& FileCheck %s
# RUN: llvm-bolt %t.out -o %t.out.1 --print-normalized 2>&1 | FileCheck %s

# CHECK: BOLT-INFO: Linux kernel binary detected
# CHECK: BOLT-INFO: parsed 2 SMP lock entries
Expand Down
4 changes: 2 additions & 2 deletions bolt/test/X86/linux-static-calls.s
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
## Verify static calls bindings to instructions.

# RUN: llvm-bolt %t.exe --print-normalized -o %t.out --keep-nops=0 \
# RUN: --bolt-info=0 |& FileCheck %s
# RUN: --bolt-info=0 2>&1 | FileCheck %s

## Verify the bindings again on the rewritten binary with nops removed.

# RUN: llvm-bolt %t.out -o %t.out.1 --print-normalized |& FileCheck %s
# RUN: llvm-bolt %t.out -o %t.out.1 --print-normalized 2>&1 | FileCheck %s

# CHECK: BOLT-INFO: Linux kernel binary detected
# CHECK: BOLT-INFO: parsed 2 static call entries
Expand Down
8 changes: 4 additions & 4 deletions bolt/test/X86/linux-static-keys.s
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
## Verify static keys jump bindings to instructions.

# RUN: llvm-bolt %t.exe --print-normalized -o %t.out --keep-nops=0 \
# RUN: --bolt-info=0 |& FileCheck %s
# RUN: --bolt-info=0 2>&1 | FileCheck %s

## Verify that profile is matched correctly.

# RUN: llvm-bolt %t.exe --print-normalized -o %t.out --keep-nops=0 \
# RUN: --bolt-info=0 --data %t.fdata |& \
# RUN: FileCheck --check-prefix=CHECK-FDATA %s
# RUN: --bolt-info=0 --data %t.fdata 2>&1 \
# RUN: | FileCheck --check-prefix=CHECK-FDATA %s

## Verify the bindings again on the rewritten binary with nops removed.

# RUN: llvm-bolt %t.out -o %t.out.1 --print-normalized |& FileCheck %s
# RUN: llvm-bolt %t.out -o %t.out.1 --print-normalized 2>&1 | FileCheck %s

# CHECK: BOLT-INFO: Linux kernel binary detected
# CHECK: BOLT-INFO: parsed 2 static keys jump entries
Expand Down
2 changes: 1 addition & 1 deletion bolt/test/X86/pt_gnu_relro.s
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
# READELF: 04 .got

# RUN: llvm-bolt %t.exe --relocs -o %t.null -v=1 \
# RUN: |& FileCheck --check-prefix=BOLT %s
# RUN: 2>&1 | FileCheck --check-prefix=BOLT %s
# BOLT: BOLT-INFO: marking .got as GNU_RELRO

.globl _start
Expand Down
2 changes: 1 addition & 1 deletion bolt/test/X86/unclaimed-jt-entries.s
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s -o %t.o
# RUN: %clang %cflags -no-pie %t.o -o %t.exe -Wl,-q
# RUN: llvm-bolt %t.exe -v=1 -o %t.out |& FileCheck %s
# RUN: llvm-bolt %t.exe -v=1 -o %t.out 2>&1 | FileCheck %s

# CHECK: BOLT-WARNING: unclaimed data to code reference (possibly an unrecognized jump table entry) to .Ltmp[[#]] in main
# CHECK: BOLT-WARNING: unclaimed data to code reference (possibly an unrecognized jump table entry) to .Ltmp[[#]] in main
Expand Down
2 changes: 1 addition & 1 deletion bolt/test/X86/vararg.test
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
REQUIRES: x86_64-linux

RUN: %clangxx %cxxflags -no-pie %p/../Inputs/vararg.s -o %t -Wl,-q
RUN: llvm-bolt %t -o %t.null --print-cfg --print-only=.*printf.* |& FileCheck %s
RUN: llvm-bolt %t -o %t.null --print-cfg --print-only=.*printf.* 2>&1 | FileCheck %s

CHECK: IsSimple : 0
CHECK: Entry Point
Expand Down
2 changes: 1 addition & 1 deletion bolt/test/permission.test
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# This test performs a logical AND operation on the results of the `stat -c %a
# %t.bolt` and `umask` commands (both results are displayed in octal), and
# checks whether the result is equal to 0.
REQUIRES: system-linux
REQUIRES: shell, system-linux

RUN: %clang %cflags %p/Inputs/hello.c -o %t -Wl,-q
RUN: llvm-bolt %t -o %t.bolt
Expand Down
2 changes: 1 addition & 1 deletion bolt/test/runtime/X86/unclaimed-jt-entries.s
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s -o %t.o
# RUN: %clang %cflags %S/Inputs/unclaimed-jt-entries.c -no-pie %t.o -o %t.exe -Wl,-q
# RUN: llvm-bolt %t.exe -v=1 -o %t.out --sequential-disassembly |& FileCheck %s
# RUN: llvm-bolt %t.exe -v=1 -o %t.out --sequential-disassembly 2>&1 | FileCheck %s

# CHECK: BOLT-WARNING: unclaimed data to code reference (possibly an unrecognized jump table entry) to .Ltmp[[#]] in func
# CHECK: BOLT-WARNING: unclaimed data to code reference (possibly an unrecognized jump table entry) to .Ltmp[[#]] in func
Expand Down
1 change: 1 addition & 0 deletions bolt/unittests/Core/BinaryContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ struct BinaryContextTester : public testing::TestWithParam<Triple::ArchType> {
}

void initializeBOLT() {
Relocation::Arch = ObjFile->makeTriple().getArch();
BC = cantFail(BinaryContext::createBinaryContext(
ObjFile->makeTriple(), ObjFile->getFileName(), nullptr, true,
DWARFContext::create(*ObjFile.get()), {llvm::outs(), llvm::errs()}));
Expand Down
1 change: 1 addition & 0 deletions bolt/unittests/Core/MCPlusBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ struct MCPlusBuilderTester : public testing::TestWithParam<Triple::ArchType> {
}

void initializeBolt() {
Relocation::Arch = ObjFile->makeTriple().getArch();
BC = cantFail(BinaryContext::createBinaryContext(
ObjFile->makeTriple(), ObjFile->getFileName(), nullptr, true,
DWARFContext::create(*ObjFile.get()), {llvm::outs(), llvm::errs()}));
Expand Down
11 changes: 8 additions & 3 deletions clang-tools-extra/clang-doc/HTMLGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ genHTML(const EnumInfo &I, const ClangDocContext &CDCtx);
static std::vector<std::unique_ptr<TagNode>>
genHTML(const FunctionInfo &I, const ClangDocContext &CDCtx,
StringRef ParentInfoDir);
static std::unique_ptr<TagNode> genHTML(const std::vector<CommentInfo> &C);

static std::vector<std::unique_ptr<TagNode>>
genEnumsBlock(const std::vector<EnumInfo> &Enums,
Expand Down Expand Up @@ -418,9 +419,13 @@ genRecordMembersBlock(const llvm::SmallVector<MemberTypeInfo, 4> &Members,
if (Access != "")
Access = Access + " ";
auto LIBody = std::make_unique<TagNode>(HTMLTag::TAG_LI);
LIBody->Children.emplace_back(std::make_unique<TextNode>(Access));
LIBody->Children.emplace_back(genReference(M.Type, ParentInfoDir));
LIBody->Children.emplace_back(std::make_unique<TextNode>(" " + M.Name));
auto MemberDecl = std::make_unique<TagNode>(HTMLTag::TAG_DIV);
MemberDecl->Children.emplace_back(std::make_unique<TextNode>(Access));
MemberDecl->Children.emplace_back(genReference(M.Type, ParentInfoDir));
MemberDecl->Children.emplace_back(std::make_unique<TextNode>(" " + M.Name));
if (!M.Description.empty())
LIBody->Children.emplace_back(genHTML(M.Description));
LIBody->Children.emplace_back(std::move(MemberDecl));
ULBody->Children.emplace_back(std::move(LIBody));
}
return Out;
Expand Down
7 changes: 7 additions & 0 deletions clang-tools-extra/clang-doc/Representation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -384,5 +384,12 @@ ClangDocContext::ClangDocContext(tooling::ExecutionContext *ECtx,
}
}

void ScopeChildren::sort() {
llvm::sort(Namespaces.begin(), Namespaces.end());
llvm::sort(Records.begin(), Records.end());
llvm::sort(Functions.begin(), Functions.end());
llvm::sort(Enums.begin(), Enums.end());
llvm::sort(Typedefs.begin(), Typedefs.end());
}
} // namespace doc
} // namespace clang
28 changes: 26 additions & 2 deletions clang-tools-extra/clang-doc/Representation.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ struct Reference {

bool mergeable(const Reference &Other);
void merge(Reference &&I);
bool operator<(const Reference &Other) const { return Name < Other.Name; }

/// Returns the path for this Reference relative to CurrentPath.
llvm::SmallString<64> getRelativeFilePath(const StringRef &CurrentPath) const;
Expand Down Expand Up @@ -145,6 +146,8 @@ struct ScopeChildren {
std::vector<FunctionInfo> Functions;
std::vector<EnumInfo> Enums;
std::vector<TypedefInfo> Typedefs;

void sort();
};

// A base struct for TypeInfos
Expand Down Expand Up @@ -245,6 +248,11 @@ struct Location {
std::tie(Other.LineNumber, Other.Filename);
}

bool operator!=(const Location &Other) const {
return std::tie(LineNumber, Filename) !=
std::tie(Other.LineNumber, Other.Filename);
}

// This operator is used to sort a vector of Locations.
// No specific order (attributes more important than others) is required. Any
// sort is enough, the order is only needed to call std::unique after sorting
Expand All @@ -270,10 +278,12 @@ struct Info {

virtual ~Info() = default;

Info &operator=(Info &&Other) = default;

SymbolID USR =
SymbolID(); // Unique identifier for the decl described by this Info.
const InfoType IT = InfoType::IT_default; // InfoType of this particular Info.
SmallString<16> Name; // Unqualified name of the decl.
InfoType IT = InfoType::IT_default; // InfoType of this particular Info.
SmallString<16> Name; // Unqualified name of the decl.
llvm::SmallVector<Reference, 4>
Namespace; // List of parent namespaces for this decl.
std::vector<CommentInfo> Description; // Comment description of this decl.
Expand Down Expand Up @@ -312,6 +322,20 @@ struct SymbolInfo : public Info {

std::optional<Location> DefLoc; // Location where this decl is defined.
llvm::SmallVector<Location, 2> Loc; // Locations where this decl is declared.

bool operator<(const SymbolInfo &Other) const {
// Sort by declaration location since we want the doc to be
// generated in the order of the source code.
// If the declaration location is the same, or not present
// we sort by defined location otherwise fallback to the extracted name
if (Loc.size() > 0 && Other.Loc.size() > 0 && Loc[0] != Other.Loc[0])
return Loc[0] < Other.Loc[0];

if (DefLoc && Other.DefLoc && *DefLoc != *Other.DefLoc)
return *DefLoc < *Other.DefLoc;

return extractName() < Other.extractName();
}
};

// TODO: Expand to allow for documenting templating and default args.
Expand Down
18 changes: 18 additions & 0 deletions clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,22 @@ llvm::Error getHtmlAssetFiles(const char *Argv0,
return getDefaultAssetFiles(Argv0, CDCtx);
}

/// Make the output of clang-doc deterministic by sorting the children of
/// namespaces and records.
void sortUsrToInfo(llvm::StringMap<std::unique_ptr<doc::Info>> &USRToInfo) {
for (auto &I : USRToInfo) {
auto &Info = I.second;
if (Info->IT == doc::InfoType::IT_namespace) {
auto *Namespace = static_cast<clang::doc::NamespaceInfo *>(Info.get());
Namespace->Children.sort();
}
if (Info->IT == doc::InfoType::IT_record) {
auto *Record = static_cast<clang::doc::RecordInfo *>(Info.get());
Record->Children.sort();
}
}
}

int main(int argc, const char **argv) {
llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
std::error_code OK;
Expand Down Expand Up @@ -341,6 +357,8 @@ Example usage for a project using a compile commands database:
if (Error)
return 1;

sortUsrToInfo(USRToInfo);

// Ensure the root output directory exists.
if (std::error_code Err = llvm::sys::fs::create_directories(OutDirectory);
Err != std::error_code()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ void RedundantSmartptrGetCheck::check(const MatchFinder::MatchResult &Result) {
StringRef SmartptrText = Lexer::getSourceText(
CharSourceRange::getTokenRange(Smartptr->getSourceRange()),
*Result.SourceManager, getLangOpts());
// Check if the last two characters are "->" and remove them
if (SmartptrText.ends_with("->")) {
SmartptrText = SmartptrText.drop_back(2);
}
// Replace foo->get() with *foo, and foo.get() with foo.
std::string Replacement = Twine(IsPtrToPtr ? "*" : "", SmartptrText).str();
diag(GetCall->getBeginLoc(), "redundant get() call on smart pointer")
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clangd/unittests/HoverTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1325,7 +1325,7 @@ class Foo final {})cpp";
HI.LocalScope = "";
HI.Kind = index::SymbolKind::TypeAlias;
HI.Definition = "template <typename T> using AA = A<T>";
HI.Type = {"A<T>", "type-parameter-0-0"}; // FIXME: should be 'T'
HI.Type = {"A<T>", "T"};
HI.TemplateParameters = {
{{"typename"}, std::string("T"), std::nullopt}};
}},
Expand Down
4 changes: 4 additions & 0 deletions clang-tools-extra/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ New check aliases
Changes in existing checks
^^^^^^^^^^^^^^^^^^^^^^^^^^

- Improved :doc:`readability-redundant-smartptr-get
<clang-tidy/checks/readability/redundant-smartptr-get>` check to
remove `->`, when reduntant `get()` is removed.

Removed checks
^^^^^^^^^^^^^^

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ struct Header {
}
StringRef verbatim() const { return std::get<Verbatim>(Storage); }

/// Absolute path for the header when it's a physical file. Otherwise just
/// the spelling without surrounding quotes/brackets.
/// For phiscal files, either absolute path or path relative to the execution
/// root. Otherwise just the spelling without surrounding quotes/brackets.
llvm::StringRef resolvedPath() const;

private:
Expand Down
41 changes: 21 additions & 20 deletions clang-tools-extra/include-cleaner/lib/Analysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ analyze(llvm::ArrayRef<Decl *> ASTRoots,
const PragmaIncludes *PI, const Preprocessor &PP,
llvm::function_ref<bool(llvm::StringRef)> HeaderFilter) {
auto &SM = PP.getSourceManager();
const FileEntry *MainFile = SM.getFileEntryForID(SM.getMainFileID());
const auto MainFile = *SM.getFileEntryRefForID(SM.getMainFileID());
llvm::DenseSet<const Include *> Used;
llvm::StringSet<> Missing;
if (!HeaderFilter)
Expand All @@ -95,37 +95,38 @@ analyze(llvm::ArrayRef<Decl *> ASTRoots,
for (const Header &H : Providers) {
if (H.kind() == Header::Physical &&
(H.physical() == MainFile ||
(ResourceDir && H.physical().getDir() == *ResourceDir))) {
H.physical().getDir() == ResourceDir)) {
Satisfied = true;
}
for (const Include *I : Inc.match(H)) {
Used.insert(I);
Satisfied = true;
}
}
if (!Satisfied && !Providers.empty() &&
Ref.RT == RefType::Explicit &&
!HeaderFilter(Providers.front().resolvedPath())) {
// Check if we have any headers with the same spelling, in edge
// cases like `#include_next "foo.h"`, the user can't ever
// include the physical foo.h, but can have a spelling that
// refers to it.
auto Spelling = spellHeader(
{Providers.front(), PP.getHeaderSearchInfo(), MainFile});
for (const Include *I : Inc.match(Header{Spelling})) {
Used.insert(I);
Satisfied = true;
}
if (!Satisfied)
Missing.insert(std::move(Spelling));
// Bail out if we can't (or need not) insert an include.
if (Satisfied || Providers.empty() || Ref.RT != RefType::Explicit)
return;
if (HeaderFilter(Providers.front().resolvedPath()))
return;
// Check if we have any headers with the same spelling, in edge
// cases like `#include_next "foo.h"`, the user can't ever
// include the physical foo.h, but can have a spelling that
// refers to it.
auto Spelling = spellHeader(
{Providers.front(), PP.getHeaderSearchInfo(), MainFile});
for (const Include *I : Inc.match(Header{Spelling})) {
Used.insert(I);
Satisfied = true;
}
if (!Satisfied)
Missing.insert(std::move(Spelling));
});

AnalysisResults Results;
for (const Include &I : Inc.all()) {
if (Used.contains(&I) || !I.Resolved ||
HeaderFilter(I.Resolved->getFileEntry().tryGetRealPathName()) ||
(ResourceDir && I.Resolved->getFileEntry().getDir() == *ResourceDir))
HeaderFilter(I.Resolved->getName()) ||
I.Resolved->getDir() == ResourceDir)
continue;
if (PI) {
if (PI->shouldKeep(*I.Resolved))
Expand All @@ -137,7 +138,7 @@ analyze(llvm::ArrayRef<Decl *> ASTRoots,
// Since most private -> public mappings happen in a verbatim way, we
// check textually here. This might go wrong in presence of symlinks or
// header mappings. But that's not different than rest of the places.
if (MainFile->tryGetRealPathName().ends_with(PHeader))
if (MainFile.getName().ends_with(PHeader))
continue;
}
}
Expand Down
19 changes: 2 additions & 17 deletions clang-tools-extra/include-cleaner/lib/HTMLReport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
//===----------------------------------------------------------------------===//

#include "AnalysisInternal.h"
#include "clang-include-cleaner/IncludeSpeller.h"
#include "clang-include-cleaner/Types.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/PrettyPrinter.h"
Expand Down Expand Up @@ -167,22 +168,6 @@ class Reporter {
return "semiused";
}

std::string spellHeader(const Header &H) {
switch (H.kind()) {
case Header::Physical: {
bool IsAngled = false;
std::string Path = HS.suggestPathToFileForDiagnostics(
H.physical(), MainFE->tryGetRealPathName(), &IsAngled);
return IsAngled ? "<" + Path + ">" : "\"" + Path + "\"";
}
case Header::Standard:
return H.standard().name().str();
case Header::Verbatim:
return H.verbatim().str();
}
llvm_unreachable("Unknown Header kind");
}

void fillTarget(Ref &R) {
// Duplicates logic from walkUsed(), which doesn't expose SymbolLocations.
for (auto &Loc : locateSymbol(R.Sym))
Expand All @@ -204,7 +189,7 @@ class Reporter {
R.Includes.end());

if (!R.Headers.empty())
R.Insert = spellHeader(R.Headers.front());
R.Insert = spellHeader({R.Headers.front(), HS, MainFE});
}

public:
Expand Down
3 changes: 1 addition & 2 deletions clang-tools-extra/include-cleaner/lib/Types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include "TypesInternal.h"
#include "clang/AST/Decl.h"
#include "clang/Basic/FileEntry.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
Expand Down Expand Up @@ -48,7 +47,7 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Symbol &S) {
llvm::StringRef Header::resolvedPath() const {
switch (kind()) {
case include_cleaner::Header::Physical:
return physical().getFileEntry().tryGetRealPathName();
return physical().getName();
case include_cleaner::Header::Standard:
return standard().name().trim("<>\"");
case include_cleaner::Header::Verbatim:
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ class Action : public clang::ASTFrontendAction {
writeHTML();

llvm::StringRef Path =
SM.getFileEntryForID(SM.getMainFileID())->tryGetRealPathName();
SM.getFileEntryRefForID(SM.getMainFileID())->getName();
assert(!Path.empty() && "Main file path not known?");
llvm::StringRef Code = SM.getBufferData(SM.getMainFileID());

Expand Down
75 changes: 73 additions & 2 deletions clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@
#include "clang/Testing/TestAST.h"
#include "clang/Tooling/Inclusions/StandardLibrary.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/IntrusiveRefCntPtr.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/ScopedPrinter.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "llvm/Testing/Annotations/Annotations.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
Expand Down Expand Up @@ -204,21 +207,37 @@ class AnalyzeTest : public testing::Test {
TestInputs Inputs;
PragmaIncludes PI;
RecordedPP PP;
llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> ExtraFS = nullptr;

AnalyzeTest() {
Inputs.MakeAction = [this] {
struct Hook : public SyntaxOnlyAction {
public:
Hook(RecordedPP &PP, PragmaIncludes &PI) : PP(PP), PI(PI) {}
Hook(RecordedPP &PP, PragmaIncludes &PI,
llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> ExtraFS)
: PP(PP), PI(PI), ExtraFS(std::move(ExtraFS)) {}
bool BeginSourceFileAction(clang::CompilerInstance &CI) override {
CI.getPreprocessor().addPPCallbacks(PP.record(CI.getPreprocessor()));
PI.record(CI);
return true;
}

bool BeginInvocation(CompilerInstance &CI) override {
if (!ExtraFS)
return true;
auto OverlayFS =
llvm::makeIntrusiveRefCnt<llvm::vfs::OverlayFileSystem>(
CI.getFileManager().getVirtualFileSystemPtr());
OverlayFS->pushOverlay(ExtraFS);
CI.getFileManager().setVirtualFileSystem(std::move(OverlayFS));
return true;
}

RecordedPP &PP;
PragmaIncludes &PI;
llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> ExtraFS;
};
return std::make_unique<Hook>(PP, PI);
return std::make_unique<Hook>(PP, PI, ExtraFS);
};
}
};
Expand Down Expand Up @@ -322,6 +341,58 @@ TEST_F(AnalyzeTest, DifferentHeaderSameSpelling) {
EXPECT_THAT(Results.Missing, testing::IsEmpty());
}

TEST_F(AnalyzeTest, SpellingIncludesWithSymlinks) {
llvm::Annotations Code(R"cpp(
#include "header.h"
void $bar^bar() {
$foo^foo();
}
)cpp");
Inputs.Code = Code.code();
ExtraFS = llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
ExtraFS->addFile("content_for/0", /*ModificationTime=*/{},
llvm::MemoryBuffer::getMemBufferCopy(guard(R"cpp(
#include "inner.h"
)cpp")));
ExtraFS->addSymbolicLink("header.h", "content_for/0",
/*ModificationTime=*/{});
ExtraFS->addFile("content_for/1", /*ModificationTime=*/{},
llvm::MemoryBuffer::getMemBufferCopy(guard(R"cpp(
void foo();
)cpp")));
ExtraFS->addSymbolicLink("inner.h", "content_for/1",
/*ModificationTime=*/{});

TestAST AST(Inputs);
std::vector<Decl *> DeclsInTU;
for (auto *D : AST.context().getTranslationUnitDecl()->decls())
DeclsInTU.push_back(D);
auto Results = analyze(DeclsInTU, {}, PP.Includes, &PI, AST.preprocessor());
// Check that we're spelling header using the symlink, and not underlying
// path.
EXPECT_THAT(Results.Missing, testing::ElementsAre("\"inner.h\""));
// header.h should be unused.
EXPECT_THAT(Results.Unused, Not(testing::IsEmpty()));

{
// Make sure filtering is also applied to symlink, not underlying file.
auto HeaderFilter = [](llvm::StringRef Path) { return Path == "inner.h"; };
Results = analyze(DeclsInTU, {}, PP.Includes, &PI, AST.preprocessor(),
HeaderFilter);
EXPECT_THAT(Results.Missing, testing::ElementsAre("\"inner.h\""));
// header.h should be unused.
EXPECT_THAT(Results.Unused, Not(testing::IsEmpty()));
}
{
auto HeaderFilter = [](llvm::StringRef Path) { return Path == "header.h"; };
Results = analyze(DeclsInTU, {}, PP.Includes, &PI, AST.preprocessor(),
HeaderFilter);
// header.h should be ignored now.
EXPECT_THAT(Results.Unused, Not(testing::IsEmpty()));
EXPECT_THAT(Results.Missing, testing::ElementsAre("\"inner.h\""));
}
}

TEST(FixIncludes, Basic) {
llvm::StringRef Code = R"cpp(#include "d.h"
#include "a.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ class DummyIncludeSpeller : public IncludeSpeller {
return "<bits/stdc++.h>";
if (Input.H.kind() != Header::Physical)
return "";
llvm::StringRef AbsolutePath =
Input.H.physical().getFileEntry().tryGetRealPathName();
llvm::StringRef AbsolutePath = Input.H.resolvedPath();
std::string RootWithSeparator{testRoot()};
RootWithSeparator += llvm::sys::path::get_separator();
if (!AbsolutePath.consume_front(llvm::StringRef{RootWithSeparator}))
Expand Down
48 changes: 35 additions & 13 deletions clang-tools-extra/include-cleaner/unittests/RecordTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "clang-include-cleaner/Types.h"
#include "clang/AST/Decl.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/FileEntry.h"
#include "clang/Basic/LLVM.h"
#include "clang/Basic/SourceLocation.h"
#include "clang/Frontend/CompilerInvocation.h"
Expand All @@ -24,6 +25,7 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Testing/Annotations/Annotations.h"
Expand Down Expand Up @@ -53,9 +55,11 @@ MATCHER_P(named, N, "") {
}

MATCHER_P(FileNamed, N, "") {
if (arg.getFileEntry().tryGetRealPathName() == N)
llvm::StringRef ActualName =
llvm::sys::path::remove_leading_dotslash(arg.getName());
if (ActualName == N)
return true;
*result_listener << arg.getFileEntry().tryGetRealPathName().str();
*result_listener << ActualName.str();
return false;
}

Expand Down Expand Up @@ -317,7 +321,8 @@ class PragmaIncludeTest : public ::testing::Test {
}

TestAST build(bool ResetPragmaIncludes = true) {
if (ResetPragmaIncludes) PI = PragmaIncludes();
if (ResetPragmaIncludes)
PI = PragmaIncludes();
return TestAST(Inputs);
}

Expand Down Expand Up @@ -535,16 +540,33 @@ TEST_F(PragmaIncludeTest, IWYUExportBlock) {
TestAST Processed = build();
auto &FM = Processed.fileManager();

EXPECT_THAT(PI.getExporters(FM.getFile("private1.h").get(), FM),
testing::UnorderedElementsAre(FileNamed("export1.h"),
FileNamed("normal.h")));
EXPECT_THAT(PI.getExporters(FM.getFile("private2.h").get(), FM),
testing::UnorderedElementsAre(FileNamed("export1.h")));
EXPECT_THAT(PI.getExporters(FM.getFile("private3.h").get(), FM),
testing::UnorderedElementsAre(FileNamed("export1.h")));

EXPECT_TRUE(PI.getExporters(FM.getFile("foo.h").get(), FM).empty());
EXPECT_TRUE(PI.getExporters(FM.getFile("bar.h").get(), FM).empty());
auto GetNames = [](llvm::ArrayRef<FileEntryRef> FEs) {
std::string Result;
llvm::raw_string_ostream OS(Result);
for (auto &FE : FEs) {
OS << FE.getName() << " ";
}
OS.flush();
return Result;
};
auto Exporters = PI.getExporters(FM.getFile("private1.h").get(), FM);
EXPECT_THAT(Exporters, testing::UnorderedElementsAre(FileNamed("export1.h"),
FileNamed("normal.h")))
<< GetNames(Exporters);

Exporters = PI.getExporters(FM.getFile("private2.h").get(), FM);
EXPECT_THAT(Exporters, testing::UnorderedElementsAre(FileNamed("export1.h")))
<< GetNames(Exporters);

Exporters = PI.getExporters(FM.getFile("private3.h").get(), FM);
EXPECT_THAT(Exporters, testing::UnorderedElementsAre(FileNamed("export1.h")))
<< GetNames(Exporters);

Exporters = PI.getExporters(FM.getFile("foo.h").get(), FM);
EXPECT_TRUE(Exporters.empty()) << GetNames(Exporters);

Exporters = PI.getExporters(FM.getFile("bar.h").get(), FM);
EXPECT_TRUE(Exporters.empty()) << GetNames(Exporters);
}

TEST_F(PragmaIncludeTest, SelfContained) {
Expand Down
18 changes: 9 additions & 9 deletions clang-tools-extra/test/clang-doc/basic-project.test
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// See https://github.com/llvm/llvm-project/issues/97507.
// UNSUPPORTED: target={{.*}}

// RUN: rm -rf %t && mkdir -p %t/docs %t/build
// RUN: sed 's|$test_dir|%/S|g' %S/Inputs/basic-project/database_template.json > %t/build/compile_commands.json
// RUN: clang-doc --format=html --output=%t/docs --executor=all-TUs %t/build/compile_commands.json
Expand Down Expand Up @@ -61,13 +58,13 @@
// HTML-SHAPE: <p>Defined at line 8 of file {{.*}}Shape.h</p>
// HTML-SHAPE: <p> Provides a common interface for different types of shapes.</p>
// HTML-SHAPE: <h2 id="Functions">Functions</h2>
// HTML-SHAPE: <h3 id="{{([0-9A-F]{40})}}">~Shape</h3>
// HTML-SHAPE: <p>public void ~Shape()</p>
// HTML-SHAPE: <p>Defined at line 13 of file {{.*}}Shape.h</p>
// HTML-SHAPE: <h3 id="{{([0-9A-F]{40})}}">area</h3>
// HTML-SHAPE: <p>public double area()</p>
// HTML-SHAPE: <h3 id="{{([0-9A-F]{40})}}">perimeter</h3>
// HTML-SHAPE: <p>public double perimeter()</p>
// HTML-SHAPE: <h3 id="{{([0-9A-F]{40})}}">~Shape</h3>
// HTML-SHAPE: <p>public void ~Shape()</p>
// HTML-SHAPE: <p>Defined at line 13 of file {{.*}}Shape.h</p>

// HTML-CALC: <h1>class Calculator</h1>
// HTML-CALC: <p>Defined at line 8 of file {{.*}}Calculator.h</p>
Expand All @@ -94,8 +91,10 @@
// HTML-RECTANGLE: <a href="Shape.html">Shape</a>
// HTML-RECTANGLE: </p>
// HTML-RECTANGLE: <h2 id="Members">Members</h2>
// HTML-RECTANGLE: <li>private double width_</li>
// HTML-RECTANGLE: <li>private double height_</li>
// HTML-RECTANGLE: <p> Width of the rectangle.</p>
// HTML-RECTANGLE: <div>private double width_</div>
// HTML-RECTANGLE: <p> Height of the rectangle.</p>
// HTML-RECTANGLE: <div>private double height_</div>
// HTML-RECTANGLE: <h2 id="Functions">Functions</h2>
// HTML-RECTANGLE: <h3 id="{{([0-9A-F]{40})}}">Rectangle</h3>
// HTML-RECTANGLE: <p>public void Rectangle(double width, double height)</p>
Expand All @@ -115,7 +114,8 @@
// HTML-CIRCLE: <a href="Shape.html">Shape</a>
// HTML-CIRCLE: </p>
// HTML-CIRCLE: <h2 id="Members">Members</h2>
// HTML-CIRCLE: <li>private double radius_</li>
// HTML-CIRCLE: <p> Radius of the circle.</p>
// HTML-CIRCLE: <div>private double radius_</div>
// HTML-CIRCLE: <h2 id="Functions">Functions</h2>
// HTML-CIRCLE: <h3 id="{{([0-9A-F]{40})}}">Circle</h3>
// HTML-CIRCLE: <p>public void Circle(double radius)</p>
Expand Down
6 changes: 4 additions & 2 deletions clang-tools-extra/test/clang-doc/namespace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,14 +272,16 @@ namespace AnotherNamespace {
// HTML-GLOBAL-INDEX: <h1>Global Namespace</h1>
// HTML-GLOBAL-INDEX: <h2 id="Namespaces">Namespaces</h2>
// HTML-GLOBAL-INDEX: <li>@nonymous_namespace</li>
// HTML-GLOBAL-INDEX: <li>PrimaryNamespace</li>
// HTML-GLOBAL-INDEX: <li>AnotherNamespace</li>
// HTML-GLOBAL-INDEX: <li>PrimaryNamespace</li>


// MD-GLOBAL-INDEX: # Global Namespace
// MD-GLOBAL-INDEX: ## Namespaces
// MD-GLOBAL-INDEX: * [@nonymous_namespace](..{{[\/]}}@nonymous_namespace{{[\/]}}index.md)
// MD-GLOBAL-INDEX: * [PrimaryNamespace](..{{[\/]}}PrimaryNamespace{{[\/]}}index.md)
// MD-GLOBAL-INDEX: * [AnotherNamespace](..{{[\/]}}AnotherNamespace{{[\/]}}index.md)
// MD-GLOBAL-INDEX: * [PrimaryNamespace](..{{[\/]}}PrimaryNamespace{{[\/]}}index.md)


// MD-ALL-FILES: # All Files
// MD-ALL-FILES: ## [@nonymous_namespace](@nonymous_namespace{{[\/]}}index.md)
Expand Down
34 changes: 17 additions & 17 deletions clang-tools-extra/test/clang-doc/templates.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,23 @@ void ParamPackFunction(T... args);
// CHECK: ---
// CHECK-NEXT: USR: '{{([0-9A-F]{40})}}'
// CHECK-NEXT: ChildFunctions:
// CHECK-NEXT: - USR: '{{([0-9A-F]{40})}}'
// CHECK-NEXT: Name: 'ParamPackFunction'
// CHECK-NEXT: Location:
// CHECK-NEXT: - LineNumber: 16
// CHECK-NEXT: Filename: '{{.*}}'
// CHECK-NEXT: Params:
// CHECK-NEXT: - Type:
// CHECK-NEXT: Name: 'T...'
// CHECK-NEXT: QualName: 'T...'
// CHECK-NEXT: Name: 'args'
// CHECK-NEXT: ReturnType:
// CHECK-NEXT: Type:
// CHECK-NEXT: Name: 'void'
// CHECK-NEXT: QualName: 'void'
// CHECK-NEXT: Template:
// CHECK-NEXT: Params:
// CHECK-NEXT: - Contents: 'class... T'
// CHECK-NEXT: - USR: '{{([0-9A-F]{40})}}'
// CHECK-NEXT: Name: 'function'
// CHECK-NEXT: DefLocation:
Expand Down Expand Up @@ -56,21 +73,4 @@ void ParamPackFunction(T... args);
// CHECK-NEXT: Params:
// CHECK-NEXT: - Contents: 'bool'
// CHECK-NEXT: - Contents: '0'
// CHECK-NEXT: - USR: '{{([0-9A-F]{40})}}'
// CHECK-NEXT: Name: 'ParamPackFunction'
// CHECK-NEXT: Location:
// CHECK-NEXT: - LineNumber: 16
// CHECK-NEXT: Filename: '{{.*}}'
// CHECK-NEXT: Params:
// CHECK-NEXT: - Type:
// CHECK-NEXT: Name: 'T...'
// CHECK-NEXT: QualName: 'T...'
// CHECK-NEXT: Name: 'args'
// CHECK-NEXT: ReturnType:
// CHECK-NEXT: Type:
// CHECK-NEXT: Name: 'void'
// CHECK-NEXT: QualName: 'void'
// CHECK-NEXT: Template:
// CHECK-NEXT: Params:
// CHECK-NEXT: - Contents: 'class... T'
// CHECK-NEXT: ...
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ T qux(T Generic) {
async::Future<T> TemplateType;
// CHECK-MESSAGES: :[[@LINE-1]]:22: warning: unused local variable 'TemplateType' of type 'async::Future<T>' [bugprone-unused-local-non-trivial-variable]
a::Future<T> AliasTemplateType;
// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: unused local variable 'AliasTemplateType' of type 'a::Future<T>' (aka 'Future<type-parameter-0-0>') [bugprone-unused-local-non-trivial-variable]
// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: unused local variable 'AliasTemplateType' of type 'a::Future<T>' (aka 'Future<T>') [bugprone-unused-local-non-trivial-variable]
[[maybe_unused]] async::Future<Units> MaybeUnused;
return Generic;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@

namespace absl
{
// Use const char * for the format since the real type is hard to mock up.
template <typename... Args>
std::string StrFormat(const char *format, const Args&... args);
template <typename S, typename... Args>
std::string StrFormat(const S &format, const Args&... args);
} // namespace absl

template <typename T>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,23 @@ struct shared_ptr {
explicit operator bool() const noexcept;
};

template <typename T>
struct vector {
vector();
bool operator==(const vector<T>& other) const;
bool operator!=(const vector<T>& other) const;
unsigned long size() const;
bool empty() const;

using iterator = T*;

iterator begin();
iterator end();

T* data;
unsigned long sz;
};

} // namespace std

struct Bar {
Expand Down Expand Up @@ -235,3 +252,34 @@ void Negative() {
if (MACRO(x) == nullptr)
;
}

void test_redundant_get() {
std::vector<std::shared_ptr<int>> v;
auto f = [](int) {};
for (auto i = v.begin(); i != v.end(); ++i) {
f(*i->get());
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: redundant get() call
// CHECK-FIXES: f(**i);
}
}

struct Inner {
int a;
int *getValue() { return &a; }
};

struct Example {
Inner inner;
Inner* get() { return &inner; }
int *getValue() { return inner.getValue(); }
};

void test_redundant_get_with_member() {
std::vector<std::shared_ptr<Example>> v;
auto f = [](int) {};
for (auto i = v.begin(); i != v.end(); ++i) {
f(*(*i).get()->get()->getValue());
// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: redundant get() call
// CHECK-FIXES: f(**i->get()->getValue());
}
}
4 changes: 3 additions & 1 deletion clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,9 @@ TEST(HTMLGeneratorTest, emitRecordHTML) {
</p>
<h2 id="Members">Members</h2>
<ul>
<li>private int X</li>
<li>
<div>private int X</div>
</li>
</ul>
<h2 id="Records">Records</h2>
<ul>
Expand Down
4 changes: 1 addition & 3 deletions clang/cmake/caches/Fuchsia-stage2.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ foreach(target armv6m-none-eabi;armv7m-none-eabi;armv8m.main-none-eabi)
# TODO: The preprocessor defines workaround various issues in libc and libc++ integration.
# These should be addressed and removed over time.
set(RUNTIMES_${target}_CMAKE_${lang}_local_flags "--target=${target} -mthumb -Wno-atomic-alignment \"-Dvfprintf(stream, format, vlist)=vprintf(format, vlist)\" \"-Dfprintf(stream, format, ...)=printf(format)\" \"-Dtimeval=struct timeval{int tv_sec; int tv_usec;}\" \"-Dgettimeofday(tv, tz)\" -D_LIBCPP_PRINT=1")
if(${target} STREQUAL "armv8m.main-unknown-eabi")
if(${target} STREQUAL "armv8m.main-none-eabi")
set(RUNTIMES_${target}_CMAKE_${lang}_local_flags "${RUNTIMES_${target}_CMAKE_${lang}_local_flags} -mfloat-abi=softfp -march=armv8m.main+fp+dsp -mcpu=cortex-m33" CACHE STRING "")
endif()
set(RUNTIMES_${target}_CMAKE_${lang}_FLAGS "${RUNTIMES_${target}_CMAKE_${lang}_local_flags}" CACHE STRING "")
Expand All @@ -343,7 +343,6 @@ foreach(target armv6m-none-eabi;armv7m-none-eabi;armv8m.main-none-eabi)
set(RUNTIMES_${target}_LIBCXX_CXX_ABI none CACHE STRING "")
set(RUNTIMES_${target}_LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
set(RUNTIMES_${target}_LIBCXX_ENABLE_STATIC ON CACHE BOOL "")
set(RUNTIMES_${target}_LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS ON CACHE BOOL "")
set(RUNTIMES_${target}_LIBCXX_LIBC "llvm-libc" CACHE STRING "")
set(RUNTIMES_${target}_LIBCXX_ENABLE_FILESYSTEM OFF CACHE BOOL "")
set(RUNTIMES_${target}_LIBCXX_ENABLE_RANDOM_DEVICE OFF CACHE BOOL "")
Expand Down Expand Up @@ -395,7 +394,6 @@ foreach(target riscv32-unknown-elf)
set(RUNTIMES_${target}_LIBCXX_CXX_ABI none CACHE STRING "")
set(RUNTIMES_${target}_LIBCXX_ENABLE_SHARED OFF CACHE BOOL "")
set(RUNTIMES_${target}_LIBCXX_ENABLE_STATIC ON CACHE BOOL "")
set(RUNTIMES_${target}_LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS ON CACHE BOOL "")
set(RUNTIMES_${target}_LIBCXX_LIBC "llvm-libc" CACHE STRING "")
set(RUNTIMES_${target}_LIBCXX_ENABLE_FILESYSTEM OFF CACHE BOOL "")
set(RUNTIMES_${target}_LIBCXX_ENABLE_RANDOM_DEVICE OFF CACHE BOOL "")
Expand Down
12 changes: 12 additions & 0 deletions clang/docs/APINotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,18 @@ declaration kind), all of which are optional:
- Name: tzdb
SwiftCopyable: false

:SwiftConformsTo:

Allows annotating a C++ class as conforming to a Swift protocol. Equivalent
to ``SWIFT_CONFORMS_TO_PROTOCOL``. The value is a module-qualified name of a
Swift protocol.

::

Tags:
- Name: vector
SwiftConformsTo: Cxx.CxxSequence

:Availability, AvailabilityMsg:

A value of "nonswift" is equivalent to ``NS_SWIFT_UNAVAILABLE``. A value of
Expand Down
42 changes: 41 additions & 1 deletion clang/docs/ClangFormatStyleOptions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1484,7 +1484,7 @@ the configuration (without a prefix: ``Auto``).
* ``OAS_AlignAfterOperator`` (in configuration: ``AlignAfterOperator``)
Horizontally align operands of binary and ternary expressions.

This is similar to ``AO_Align``, except when
This is similar to ``OAS_Align``, except when
``BreakBeforeBinaryOperators`` is set, the operator is un-indented so
that the wrapped operand is aligned with the operand on the first line.

Expand Down Expand Up @@ -3300,6 +3300,46 @@ the configuration (without a prefix: ``Auto``).
firstValue :
SecondValueVeryVeryVeryVeryLong;

.. _BreakBinaryOperations:

**BreakBinaryOperations** (``BreakBinaryOperationsStyle``) :versionbadge:`clang-format 20` :ref:`¶ <BreakBinaryOperations>`
The break constructor initializers style to use.

Possible values:

* ``BBO_Never`` (in configuration: ``Never``)
Don't break binary operations

.. code-block:: c++

aaa + bbbb * ccccc - ddddd +
eeeeeeeeeeeeeeee;

* ``BBO_OnePerLine`` (in configuration: ``OnePerLine``)
Binary operations will either be all on the same line, or each operation
will have one line each.

.. code-block:: c++

aaa +
bbbb *
ccccc -
ddddd +
eeeeeeeeeeeeeeee;

* ``BBO_RespectPrecedence`` (in configuration: ``RespectPrecedence``)
Binary operations of a particular precedence that exceed the column
limit will have one line each.

.. code-block:: c++

aaa +
bbbb * ccccc -
ddddd +
eeeeeeeeeeeeeeee;



.. _BreakConstructorInitializers:

**BreakConstructorInitializers** (``BreakConstructorInitializersStyle``) :versionbadge:`clang-format 5` :ref:`¶ <BreakConstructorInitializers>`
Expand Down
4 changes: 4 additions & 0 deletions clang/docs/CommandGuide/clang.rst
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,10 @@ Preprocessor Options

Do not search clang's builtin directory for include files.

.. option:: -nostdinc++

Do not search the system C++ standard library directory for include files.

.. option:: -fkeep-system-includes

Usable only with :option:`-E`. Do not copy the preprocessed content of
Expand Down
1 change: 1 addition & 0 deletions clang/docs/LanguageExtensions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1503,6 +1503,7 @@ Conditional ``explicit`` __cpp_conditional_explicit C+
``static operator()`` __cpp_static_call_operator C++23 C++03
Attributes on Lambda-Expressions C++23 C++11
Attributes on Structured Bindings __cpp_structured_bindings C++26 C++03
Pack Indexing __cpp_pack_indexing C++26 C++03
``= delete ("should have a reason");`` __cpp_deleted_function C++26 C++03
-------------------------------------------- -------------------------------- ------------- -------------
Designated initializers (N494) C99 C89
Expand Down
5 changes: 4 additions & 1 deletion clang/docs/OpenMPSupport.rst
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ implementation.
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
| misc | assumes directives | :part:`worked on` | |
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
| misc | assume directive | :part:`worked on` | |
| misc | assume directive | :good:`done` | |
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
| misc | nothing directive | :good:`done` | D123286 |
+------------------------------+--------------------------------------------------------------+--------------------------+-----------------------------------------------------------------------+
Expand Down Expand Up @@ -363,5 +363,8 @@ considered for standardization. Please post on the
| device extension | `'ompx_bare' clause on 'target teams' construct | :good:`prototyped` | #66844, #70612 |
| | <https://www.osti.gov/servlets/purl/2205717>`_ | | |
+------------------------------+-----------------------------------------------------------------------------------+--------------------------+--------------------------------------------------------+
| device extension | Multi-dim 'num_teams' and 'thread_limit' clause on 'target teams ompx_bare' | :good:`partial` | #99732, #101407, #102715 |
| | construct | | |
+------------------------------+-----------------------------------------------------------------------------------+--------------------------+--------------------------------------------------------+

.. _Discourse forums (Runtimes - OpenMP category): https://discourse.llvm.org/c/runtimes/openmp/35
60 changes: 57 additions & 3 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ These changes are ones which we think may surprise users when upgrading to
Clang |release| because of the opportunity they pose for disruption to existing
code bases.

- The ``le32`` and ``le64`` targets have been removed.

C/C++ Language Potentially Breaking Changes
-------------------------------------------

Expand All @@ -59,9 +61,9 @@ Clang Frontend Potentially Breaking Changes
Clang Python Bindings Potentially Breaking Changes
--------------------------------------------------
- Parts of the interface returning string results will now return
the empty string `""` when no result is available, instead of `None`.
- Calling a property on the `CompletionChunk` or `CompletionString` class
statically now leads to an error, instead of returning a `CachedProperty` object
the empty string ``""`` when no result is available, instead of ``None``.
- Calling a property on the ``CompletionChunk`` or ``CompletionString`` class
statically now leads to an error, instead of returning a ``CachedProperty`` object
that is used internally. Properties are only available on instances.

What's New in Clang |release|?
Expand All @@ -73,6 +75,9 @@ sections with improvements to Clang's support for those languages.

C++ Language Changes
--------------------
- Allow single element access of GCC vector/ext_vector_type object to be
constant expression. Supports the `V.xyzw` syntax and other tidbits
as seen in OpenCL. Selecting multiple elements is left as a future work.

C++17 Feature Support
^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -96,6 +101,21 @@ C++2c Feature Support
Resolutions to C++ Defect Reports
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

- Allow calling initializer list constructors from initializer lists with
a single element of the same type instead of always copying.
(`CWG2137: List-initialization from object of same type <https://cplusplus.github.io/CWG/issues/2137.html>`)

- Speculative resolution for CWG2311 implemented so that the implementation of CWG2137 doesn't remove
previous cases where guaranteed copy elision was done. Given a prvalue ``e`` of class type
``T``, ``T{e}`` will try to resolve an initializer list constructor and will use it if successful.
Otherwise, if there is no initializer list constructor, the copy will be elided as if it was ``T(e)``.
(`CWG2311: Missed case for guaranteed copy elision <https://cplusplus.github.io/CWG/issues/2311.html>`)

- Casts from a bit-field to an integral type is now not considered narrowing if the
width of the bit-field means that all potential values are in the range
of the target type, even if the type of the bit-field is larger.
(`CWG2627: Bit-fields and narrowing conversions <https://cplusplus.github.io/CWG/issues/2627.html>`_)

C Language Changes
------------------

Expand All @@ -105,6 +125,9 @@ C2y Feature Support
C23 Feature Support
^^^^^^^^^^^^^^^^^^^

Non-comprehensive list of changes in this release
-------------------------------------------------

New Compiler Flags
------------------

Expand Down Expand Up @@ -148,6 +171,10 @@ Improvements to Clang's diagnostics
- Clang now diagnoses undefined behavior in constant expressions more consistently. This includes invalid shifts, and signed overflow in arithmetic.

- -Wdangling-assignment-gsl is enabled by default.
- Clang now always preserves the template arguments as written used
to specialize template type aliases.

- Clang now diagnoses the use of ``main`` in an ``extern`` context as invalid according to [basic.start.main] p3. Fixes #GH101512.

Improvements to Clang's time-trace
----------------------------------
Expand All @@ -161,6 +188,9 @@ Bug Fixes in This Version
- Fixed the definition of ``ATOMIC_FLAG_INIT`` in ``<stdatomic.h>`` so it can
be used in C++.
- Fixed a failed assertion when checking required literal types in C context. (#GH101304).
- Fixed a crash when trying to transform a dependent address space type. Fixes #GH101685.
- Fixed a crash when diagnosing format strings and encountering an empty
delimited escape sequence (e.g., ``"\o{}"``). #GH102218

Bug Fixes to Compiler Builtins
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -172,13 +202,23 @@ Bug Fixes to C++ Support
^^^^^^^^^^^^^^^^^^^^^^^^

- Fixed a crash when an expression with a dependent ``__typeof__`` type is used as the operand of a unary operator. (#GH97646)
- Fixed incorrect pack expansion of init-capture references in requires expresssions.
- Fixed a failed assertion when checking invalid delete operator declaration. (#GH96191)
- Fix a crash when checking destructor reference with an invalid initializer. (#GH97230)
- Clang now correctly parses potentially declarative nested-name-specifiers in pointer-to-member declarators.
- Fix a crash when checking the initialzier of an object that was initialized
with a string literal. (#GH82167)
- Fix a crash when matching template template parameters with templates which have
parameters of different class type. (#GH101394)
- Clang now correctly recognizes the correct context for parameter
substitutions in concepts, so it doesn't incorrectly complain of missing
module imports in those situations. (#GH60336)
- Fix init-capture packs having a size of one before being instantiated. (#GH63677)
- Clang now preserves the unexpanded flag in a lambda transform used for pack expansion. (#GH56852), (#GH85667),
(#GH99877).
- Fixed a bug when diagnosing ambiguous explicit specializations of constrained member functions.
- Fixed an assertion failure when selecting a function from an overload set that includes a
specialization of a conversion function template.

Bug Fixes to AST Handling
^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down Expand Up @@ -224,6 +264,8 @@ X86 Support
found in the file ``clang/www/builtins.py``.

- Support ISA of ``AVX10.2``.
* Supported MINMAX intrinsics of ``*_(mask(z)))_minmax(ne)_p[s|d|h|bh]`` and
``*_(mask(z)))_minmax_s[s|d|h]``.

Arm and AArch64 Support
^^^^^^^^^^^^^^^^^^^^^^^
Expand Down Expand Up @@ -276,6 +318,8 @@ AST Matchers
clang-format
------------

- Adds ``BreakBinaryOperations`` option.

libclang
--------

Expand Down Expand Up @@ -303,6 +347,11 @@ Improvements
Moved checkers
^^^^^^^^^^^^^^

- The checker ``alpha.security.MallocOverflow`` was deleted because it was
badly implemented and its agressive logic produced too many false positives.
To detect too large arguments passed to malloc, consider using the checker
``alpha.taint.TaintedAlloc``.

.. _release-notes-sanitizers:

Sanitizers
Expand All @@ -314,11 +363,16 @@ Python Binding Changes

OpenMP Support
--------------
- Added support for 'omp assume' directive.

Improvements
^^^^^^^^^^^^
- Improve the handling of mapping array-section for struct containing nested structs with user defined mappers

- `num_teams` and `thead_limit` now accept multiple expressions when it is used
along in ``target teams ompx_bare`` construct. This allows the target region
to be launched with multi-dim grid on GPUs.

Additional Information
======================

Expand Down
Loading