6 changes: 3 additions & 3 deletions bolt/test/X86/frame-opt-lea.s
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This checks that frame optimizer does not try to optimize away caller-saved
# regs when we do not have complete aliasing info (when there is an LEA
# instruction and the function does arithmetic with stack addresses).
## This checks that frame optimizer does not try to optimize away caller-saved
## regs when we do not have complete aliasing info (when there is an LEA
## instruction and the function does arithmetic with stack addresses).


# REQUIRES: system-linux
Expand Down
4 changes: 2 additions & 2 deletions bolt/test/X86/function-order-lite.s
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Check that functions listed in -function-order list take precedence over
# lite mode function filtering.
## Check that functions listed in -function-order list take precedence over
## lite mode function filtering.

# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s -o %t.o
# RUN: link_fdata %s %t.o %t.fdata
Expand Down
18 changes: 9 additions & 9 deletions bolt/test/X86/gdbindex.test
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ RUN: ld.lld --gdb-index %t.o %t2.o -o %tfile.exe
RUN: llvm-bolt %tfile.exe -o %tfile.exe.bolt --update-debug-sections
RUN: llvm-dwarfdump -gdb-index %tfile.exe.bolt | FileCheck %s

; test.cpp:
; int main() { return 0; }
; test2.cpp:
; int main2() { return 0; }
; Compiled with:
; gcc -gsplit-dwarf -c test.cpp test2.cpp
; gold --gdb-index test.o test2.o -o dwarfdump-gdbindex-v7.elf-x86-64
; gcc version 5.3.1 20160413, GNU gold (GNU Binutils for Ubuntu 2.26) 1.11
; Info about gdb-index: https://sourceware.org/gdb/onlinedocs/gdb/Index-Section-Format.html
;; test.cpp:
;; int main() { return 0; }
;; test2.cpp:
;; int main2() { return 0; }
;; Compiled with:
;; gcc -gsplit-dwarf -c test.cpp test2.cpp
;; gold --gdb-index test.o test2.o -o dwarfdump-gdbindex-v7.elf-x86-64
;; gcc version 5.3.1 20160413, GNU gold (GNU Binutils for Ubuntu 2.26) 1.11
;; Info about gdb-index: https://sourceware.org/gdb/onlinedocs/gdb/Index-Section-Format.html

; CHECK-LABEL: .gdb_index contents:
; CHECK: Version = 7
Expand Down
4 changes: 2 additions & 2 deletions bolt/test/X86/high_pc_udata.s
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
# POSTCHECK-NEXT: DW_AT_name [DW_FORM_strp]
# POSTCHECK-SAME: "main.cpp"

# Testing that BOLT transforms DW_AT_high_pc of form DW_FORM_udata correctly into DW_AT_ranges.
# Manually changed so that DW_AT_high_pc is DW_FORM_udata, and that DW_AT_name is after it.
## Testing that BOLT transforms DW_AT_high_pc of form DW_FORM_udata correctly into DW_AT_ranges.
## Manually changed so that DW_AT_high_pc is DW_FORM_udata, and that DW_AT_name is after it.
# int main() {
# return 0;
# }
Expand Down
6 changes: 3 additions & 3 deletions bolt/test/X86/icp-inline.s
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This test verifies the effect of -icp-inline option: that ICP is only
# performed for call targets eligible for inlining.
## This test verifies the effect of -icp-inline option: that ICP is only
## performed for call targets eligible for inlining.

# The assembly was produced from C code compiled with clang-15 -O1 -S:
## The assembly was produced from C code compiled with clang-15 -O1 -S:

# int foo(int x) { return x + 1; }
# int bar(int x) { return x*100 + 42; }
Expand Down
12 changes: 6 additions & 6 deletions bolt/test/X86/ignored-interprocedural-reference.s
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This reproduces a bug with not processing interprocedural references from
# ignored functions.
## This reproduces a bug with not processing interprocedural references from
## ignored functions.

# REQUIRES: system-linux

Expand All @@ -16,7 +16,7 @@
# CHECK-YAML: calls: {{.*}} disc: 1

# PREAGG: B #main# #foo_secondary# 1 1
# main calls foo at valid instruction offset past nops that are to be stripped.
## main calls foo at valid instruction offset past nops that are to be stripped.
.globl main
main:
.cfi_startproc
Expand All @@ -25,16 +25,16 @@ main:
.cfi_endproc
.size main,.-main

# Placeholder cold fragment to force main to be ignored in non-relocation mode.
## Placeholder cold fragment to force main to be ignored in non-relocation mode.
.globl main.cold
main.cold:
.cfi_startproc
ud2
.cfi_endproc
.size main.cold,.-main.cold

# foo is set up to contain a valid instruction at called offset, and trapping
# instructions past that.
## foo is set up to contain a valid instruction at called offset, and trapping
## instructions past that.
.globl foo
foo:
.cfi_startproc
Expand Down
8 changes: 4 additions & 4 deletions bolt/test/X86/indirect-goto-pie.test
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Check that llvm-bolt fails to process PIC binaries with computed goto, as the
# support is not there yet for correctly updating dynamic relocations
# referencing code inside functions.
## Check that llvm-bolt fails to process PIC binaries with computed goto, as the
## support is not there yet for correctly updating dynamic relocations
## referencing code inside functions.

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

# Check that processing works if main() is skipped.
## Check that processing works if main() is skipped.
RUN: llvm-bolt %t -o %t.bolt --relocs=1 --skip-funcs=main

CHECK: jmpq *%rax # UNKNOWN CONTROL FLOW
Expand Down
4 changes: 2 additions & 2 deletions bolt/test/X86/indirect-goto.test
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Check llvm-bolt processes binaries compiled from sources that use indirect goto.
## Check llvm-bolt processes binaries compiled from sources that use indirect goto.
RUN: %clang %cflags -no-pie %S/Inputs/indirect_goto.c -Wl,-q -o %t
RUN: llvm-bolt %t -o %t.null --relocs=1 --print-cfg --print-only=main \
RUN: --strict \
RUN: 2>&1 | FileCheck %s

# Check that all possible destinations are included as successors.
## Check that all possible destinations are included as successors.
CHECK: jmpq *%rax # UNKNOWN CONTROL FLOW
CHECK: Successors: .Ltmp0, .Ltmp1, .Ltmp2
4 changes: 2 additions & 2 deletions bolt/test/X86/inlined-function-mixed.test
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Make sure inlining from a unit with debug info into unit without
# debug info does not cause a crash.
## Make sure inlining from a unit with debug info into unit without
## debug info does not cause a crash.

RUN: %clangxx %cxxflags %S/Inputs/inlined.cpp -c -o %T/inlined.o
RUN: %clangxx %cxxflags %S/Inputs/inlinee.cpp -c -o %T/inlinee.o -g
Expand Down
4 changes: 2 additions & 2 deletions bolt/test/X86/insert-addr-rnglists_base.s
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
# 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

# This test checks we correctly insert DW_AT_addr_base, when converting DW_AT_low_pc into DW_AT_ranges.
# PRECHECK-NOT: DW_AT_addr_base
## This test checks we correctly insert DW_AT_addr_base, when converting DW_AT_low_pc into DW_AT_ranges.
## PRECHECK-NOT: DW_AT_addr_base

# POSTCHECK: DW_AT_ranges [DW_FORM_rnglistx]
# POSTCHECK: DW_AT_rnglists_base [DW_FORM_sec_offset] (0x0000000c)
Expand Down
2 changes: 1 addition & 1 deletion bolt/test/X86/insert-debug-info-entry.test
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
; RUN: llvm-dwarfdump --debug-info foo.exe | FileCheck -check-prefix=PRE-BOLT %s
; RUN: llvm-dwarfdump --debug-info foo.exe.bolt | FileCheck %s

; This tests checks that DW_AT_GNU_ranges_base is added at the end of the CU.
;; This tests checks that DW_AT_GNU_ranges_base is added at the end of the CU.

; PRE-BOLT: DW_AT_GNU_addr_base
; PRE-BOLT-NOT: DW_AT_GNU_ranges_base
Expand Down
2 changes: 1 addition & 1 deletion bolt/test/X86/internal-call-instrument-so.s
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This reproduces a bug with instrumentation crashes on internal call
## This reproduces a bug with instrumentation crashes on internal call

# REQUIRES: system-linux,bolt-runtime,target=x86_64{{.*}}

Expand Down
2 changes: 1 addition & 1 deletion bolt/test/X86/internal-call-instrument.s
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This reproduces a bug with instrumentation crashes on internal call
## This reproduces a bug with instrumentation crashes on internal call

# REQUIRES: x86_64-linux,bolt-runtime,target=x86_64{{.*}}

Expand Down
8 changes: 4 additions & 4 deletions bolt/test/X86/interprocedural-ref-entry-point.s
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This reproduces a bug where not registering cold fragment entry points
# leads to removing blocks and an inconsistent CFG after UCE.
# Test assembly was obtained using C-Reduce from this C++ code:
# (compiled with `g++ -O2 -Wl,-q`)
## This reproduces a bug where not registering cold fragment entry points
## leads to removing blocks and an inconsistent CFG after UCE.
## Test assembly was obtained using C-Reduce from this C++ code:
## (compiled with `g++ -O2 -Wl,-q`)
#
# #include <stdexcept>
# int a;
Expand Down
2 changes: 1 addition & 1 deletion bolt/test/X86/is-strip.s
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This test checks whether a binary is stripped or not.
## This test checks whether a binary is stripped or not.

# RUN: %clang++ %cflags %p/Inputs/linenumber.cpp -o %t -Wl,-q
# RUN: llvm-bolt %t -o %t.out 2>&1 | FileCheck %s -check-prefix=CHECK-NOSTRIP
Expand Down
6 changes: 3 additions & 3 deletions bolt/test/X86/issue20.s
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This reproduces issue 20 from our github repo
# "BOLT crashes when removing unreachable BBs that are a target
# in a JT"
## This reproduces issue 20 from our github repo
## "BOLT crashes when removing unreachable BBs that are a target
## in a JT"

# REQUIRES: system-linux

Expand Down
6 changes: 3 additions & 3 deletions bolt/test/X86/issue20.test
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This reproduces issue 20 from our github repo
# "BOLT crashes when removing unreachable BBs that are a target
# in a JT"
## This reproduces issue 20 from our github repo
## "BOLT crashes when removing unreachable BBs that are a target
## in a JT"

# RUN: yaml2obj %p/Inputs/issue20.yaml &> %t.exe
# RUN: llvm-bolt %t.exe --relocs=0 --jump-tables=move --print-finalized \
Expand Down
6 changes: 3 additions & 3 deletions bolt/test/X86/issue26.s
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This reproduces issue 26 from our github repo
# BOLT fails with the following assertion:
# llvm/tools/llvm-bolt/src/BinaryFunction.cpp:2950: void llvm::bolt::BinaryFunction::postProcessBranches(): Assertion `validateCFG() && "invalid CFG"' failed.
## This reproduces issue 26 from our github repo
## BOLT fails with the following assertion:
## llvm/tools/llvm-bolt/src/BinaryFunction.cpp:2950: void llvm::bolt::BinaryFunction::postProcessBranches(): Assertion `validateCFG() && "invalid CFG"' failed.

# REQUIRES: system-linux

Expand Down
2 changes: 1 addition & 1 deletion bolt/test/X86/issue26.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This reproduces issue 26 from our github repo
## This reproduces issue 26 from our github repo

# RUN: yaml2obj %p/Inputs/issue26.yaml &> %t.exe
# RUN: llvm-bolt %t.exe --relocs --print-cfg -o %t.out 2>&1 \
Expand Down
6 changes: 3 additions & 3 deletions bolt/test/X86/jmp-optimization.test
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Tests the optimization of functions that just do a tail call in the beginning.
## Tests the optimization of functions that just do a tail call in the beginning.

# This test has commands that rely on shell capabilities that won't execute
# correctly on Windows e.g. unsupported parameter expansion
## This test has commands that rely on shell capabilities that won't execute
## correctly on Windows e.g. unsupported parameter expansion
REQUIRES: shell

RUN: %clang %cflags -O2 %S/Inputs/jmp_opt{,2,3}.cpp -o %t
Expand Down
4 changes: 2 additions & 2 deletions bolt/test/X86/jmpjmp.test
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Verifies that llvm-bolt allocates two consecutive jumps in two separate basic
# blocks.
## Verifies that llvm-bolt allocates two consecutive jumps in two separate basic
## blocks.

RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %S/Inputs/jmpjmp.s -o %t.o
RUN: %clang %cflags %t.o -o %t.exe
Expand Down
20 changes: 10 additions & 10 deletions bolt/test/X86/jt-symbol-disambiguation-3.s
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# In this test case, we reproduce the behavior seen in gcc where the
# base address of a jump table is decremented by some number and ends up
# at the exact addess of a jump table from another function. After
# linking, the instruction references another jump table and that
# confuses BOLT.
# We repro here the following issue:
# Before assembler: Instruction operand is: jumptable - 32
# After linking: Instruction operand is: another_jumptable
## In this test case, we reproduce the behavior seen in gcc where the
## base address of a jump table is decremented by some number and ends up
## at the exact addess of a jump table from another function. After
## linking, the instruction references another jump table and that
## confuses BOLT.
## We repro here the following issue:
## Before assembler: Instruction operand is: jumptable - 32
## After linking: Instruction operand is: another_jumptable

# REQUIRES: system-linux, asserts

Expand All @@ -18,8 +18,8 @@
# RUN: llvm-bolt %t.exe -o %t.exe.bolt --relocs=1 --lite=0 \
# RUN: --reorder-blocks=reverse

# Useful when manually testing this. Currently we just check that
# the test does not cause BOLT to assert.
## Useful when manually testing this. Currently we just check that
## the test does not cause BOLT to assert.
# COM: %t.exe.bolt 1 2

.file "jt-symbol-disambiguation-3.s"
Expand Down
4 changes: 2 additions & 2 deletions bolt/test/X86/jump-table-fixed-ref-pic.test
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Verify that BOLT detects fixed destination of indirect jump for PIC
# case.
## Verify that BOLT detects fixed destination of indirect jump for PIC
## case.

XFAIL: *

Expand Down
4 changes: 2 additions & 2 deletions bolt/test/X86/jump-table-footprint-reduction.test
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Checks that jump table footprint reduction optimization is reducing entry
# sizes.
## Checks that jump table footprint reduction optimization is reducing entry
## sizes.

RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown \
RUN: %S/Inputs/jump_table_footprint_reduction.s -o %t.o
Expand Down
4 changes: 2 additions & 2 deletions bolt/test/X86/jump-table-icp.test
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ RUN: link_fdata %p/Inputs/jump_table_icp.s %t.o %t.fdata --nmtool llvm-nm
RUN: llvm-strip --strip-unneeded %t.o
RUN: %clang %cflags -no-pie %t.o -o %t.exe -Wl,-q

# This test has commands that rely on shell capabilities that won't execute
# correctly on Windows e.g. subshell execution
## This test has commands that rely on shell capabilities that won't execute
## correctly on Windows e.g. subshell execution
REQUIRES: shell

RUN: (llvm-bolt %t.exe --data %t.fdata -o %t --relocs \
Expand Down
36 changes: 18 additions & 18 deletions bolt/test/X86/jump-table-pic-conflict.s
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# Check cases when the first PIC jump table entries of one function can be
# interpreted as valid last entries of the previous function.
## Check cases when the first PIC jump table entries of one function can be
## interpreted as valid last entries of the previous function.

# Conditions to trigger the bug: Function A and B have jump tables that
# are adjacent in memory. We run in lite relocation mode. Function B
# is not disassembled because it does not have profile. Function A
# triggers a special conditional that forced BOLT to rewrite its jump
# table in-place (instead of moving it) because it is marked as
# non-simple (in this case, containing unknown control flow). The
# first entry of B's jump table (a PIC offset) happens to be a valid
# address inside A when added to A's jump table base address. In this
# case, BOLT could overwrite B's jump table, corrupting it, thinking
# the first entry of it is actually part of A's jump table.
## Conditions to trigger the bug: Function A and B have jump tables that
## are adjacent in memory. We run in lite relocation mode. Function B
## is not disassembled because it does not have profile. Function A
## triggers a special conditional that forced BOLT to rewrite its jump
## table in-place (instead of moving it) because it is marked as
## non-simple (in this case, containing unknown control flow). The
## first entry of B's jump table (a PIC offset) happens to be a valid
## address inside A when added to A's jump table base address. In this
## case, BOLT could overwrite B's jump table, corrupting it, thinking
## the first entry of it is actually part of A's jump table.

# REQUIRES: system-linux

Expand All @@ -26,8 +26,8 @@
# readelf. This is another way to check this bug:
# COM: %t.out

# BOLT needs to create a new rodata section, indicating that it
# successfully moved the jump table in _start.
## BOLT needs to create a new rodata section, indicating that it
## successfully moved the jump table in _start.
# CHECK: [{{.*}}] .bolt.org.rodata

.globl _start
Expand All @@ -41,8 +41,8 @@ _start:
cmpq $3, %rdi
ja .L5
jmp .L6
# Unreachable code, here to mark this function as non-simple
# (containing unknown control flow) with a stray indirect jmp
## Unreachable code, here to mark this function as non-simple
## (containing unknown control flow) with a stray indirect jmp
jmp *%rax
.L6:
decq %rdi
Expand Down Expand Up @@ -115,8 +115,8 @@ str1: .asciz "Message 1\n"
str2: .asciz "Message 2\n"
str3: .asciz "Message 3\n"
str4: .asciz "Highrange\n"
# Special case where the first .LJT2 entry is a valid offset of
# _start when interpreted with .LJT1 as a base address.
## Special case where the first .LJT2 entry is a valid offset of
## _start when interpreted with .LJT1 as a base address.
.LJT1:
.long .L1-.LJT1
.long .L2-.LJT1
Expand Down
6 changes: 3 additions & 3 deletions bolt/test/X86/jump-table-pic-order.test
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Check that successors of a basic block with jump table are generated
# in the same order as they appear in the input code.
## Check that successors of a basic block with jump table are generated
## in the same order as they appear in the input code.

RUN: %clang %cflags %S/Inputs/jump-table-pic.s -o %t.exe -Wl,-q
RUN: llvm-bolt %t.exe --strict --print-cfg --print-only=main -o %t.null \
RUN: | FileCheck %s

CHECK: BB Layout : {{.*, .*, .*,}} [[BB4to6:.*, .*, .*]]

# Check that successors appear in the order matching the input layout.
## Check that successors appear in the order matching the input layout.
CHECK: jmpq *%rax # JUMPTABLE
CHECK-NEXT: Successors: [[BB4to6]]
2 changes: 1 addition & 1 deletion bolt/test/X86/jump-table-reference.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Verifies that BOLT detects fixed destination of indirect jump
## Verifies that BOLT detects fixed destination of indirect jump

RUN: %clang %cflags -no-pie %S/Inputs/jump_table_reference.s -Wl,-q -o %t
RUN: llvm-bolt %t --relocs -o %t.null 2>&1 | FileCheck %s
Expand Down
10 changes: 5 additions & 5 deletions bolt/test/X86/layout-heuristic.test
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Checks that llvm-bolt is able to read data generated by perf2bolt, update the
# CFG edges accordingly with absolute number of branches and mispredictions,
# infer fallthrough branch info and reorder basic blocks using a greedy
# heuristic, or find the optimal solution if the function is small enough.
# Also checks that llvm-bolt disassembler and CFG builder is working properly.
## Checks that llvm-bolt is able to read data generated by perf2bolt, update the
## CFG edges accordingly with absolute number of branches and mispredictions,
## infer fallthrough branch info and reorder basic blocks using a greedy
## heuristic, or find the optimal solution if the function is small enough.
## Also checks that llvm-bolt disassembler and CFG builder is working properly.

RUN: yaml2obj %p/Inputs/blarge.yaml &> %t.exe
RUN: llvm-bolt %t.exe -o %t.null --data %p/Inputs/blarge.fdata \
Expand Down
12 changes: 6 additions & 6 deletions bolt/test/X86/line-number.test
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Verifies that the extraction of DWARF line number information is correct.
## Verifies that the extraction of DWARF line number information is correct.

RUN: %clangxx %cxxflags %S/Inputs/linenumber.cpp -g -o %t
RUN: llvm-bolt %t -o %t.null --print-reordered --update-debug-sections \
RUN: --print-debug-info --reorder-blocks=reverse --sequential-disassembly \
RUN: 2>&1 | FileCheck %s

# Local variable in f()
## Local variable in f()
CHECK: movl $0xbeef, -0x4(%rbp) # debug line {{.*}}linenumber.cpp:9
# Checks that a branch instruction that is inserted by BOLT does not have
# debug line info associated with it.
## Checks that a branch instruction that is inserted by BOLT does not have
## debug line info associated with it.
CHECK-NOT: jmp .LFT0 # debug line {{.*}}linenumber.cpp:1
# Call to f() in g()
## Call to f() in g()
CHECK: callq _Z1fv{{.*}} # debug line {{.*}}linenumber.cpp:19
# Calls to g() and f() in main
## Calls to g() and f() in main
CHECK: callq _Z1gv{{.*}} # debug line {{.*}}linenumber.cpp:23
CHECK: callq _Z1fv{{.*}} # debug line {{.*}}linenumber.cpp:23
2 changes: 1 addition & 1 deletion bolt/test/X86/lit.local.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
if not "X86" in config.root.targets:
config.unsupported = True

flags = "--target=x86_64-pc-linux -nostdlib"
flags = "--target=x86_64-unknown-linux-gnu -nostdlib"

config.substitutions.insert(0, ("%cflags", f"%cflags {flags}"))
config.substitutions.insert(0, ("%cxxflags", f"%cxxflags {flags}"))
8 changes: 4 additions & 4 deletions bolt/test/X86/log.test
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Tests whether llvm-bolt is able to redirect logs when processing a simple
# input. If this test fails on your changes, please use BinaryContext::outs()
# to print BOLT logging instead of llvm::outs().
## Tests whether llvm-bolt is able to redirect logs when processing a simple
## input. If this test fails on your changes, please use BinaryContext::outs()
## to print BOLT logging instead of llvm::outs().

RUN: yaml2obj %p/Inputs/blarge.yaml &> %t.exe
RUN: llvm-bolt %t.exe -o %t.null --data %p/Inputs/blarge.fdata -v=2 \
Expand All @@ -12,7 +12,7 @@ CHECK-NOT: BOLT-INFO
CHECK-NOT: BOLT-WARNING
CHECK-NOT: BOLT-ERROR

# Check some usual BOLT output lines are being redirected to the log file
## Check some usual BOLT output lines are being redirected to the log file
CHECK-LOG: BOLT-INFO: Target architecture
CHECK-LOG: BOLT-INFO: BOLT version
CHECK-LOG: BOLT-INFO: basic block reordering modified layout
Expand Down
6 changes: 3 additions & 3 deletions bolt/test/X86/loop-inversion-pass.s
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@
# RUN: --print-finalized --loop-inversion-opt -o %t.out3 \
# RUN: | FileCheck --check-prefix="CHECK3" %s

# The case where the loop is used:
## The case where the loop is used:
# FDATA: 1 main 2 1 main #.J1# 0 420
# FDATA: 1 main b 1 main #.Jloop# 0 420
# FDATA: 1 main b 1 main d 0 1
# CHECK: BB Layout : .LBB00, .Ltmp0, .Ltmp1, .LFT0

# The case where the loop is unused:
## The case where the loop is unused:
# FDATA2: 1 main 2 1 main #.J1# 0 420
# FDATA2: 1 main b 1 main #.Jloop# 0 1
# FDATA2: 1 main b 1 main d 0 420
# CHECK2: BB Layout : .LBB00, .Ltmp1, .LFT0, .Ltmp0

# The case where the loop does not require rotation:
## The case where the loop does not require rotation:
# FDATA3: 1 main 2 1 main #.J1# 0 420
# FDATA3: 1 main b 1 main #.Jloop# 0 420
# FDATA3: 1 main b 1 main d 0 1
Expand Down
2 changes: 1 addition & 1 deletion bolt/test/X86/loop-nest.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Verifies that llvm-bolt prints correct loop information.
## Verifies that llvm-bolt prints correct loop information.

RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown \
RUN: %p/Inputs/loop_nest.s -o %t.o
Expand Down
4 changes: 2 additions & 2 deletions bolt/test/X86/merge-fdata-bat-mode.test
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Check merge-fdata tool correctly processes fdata files with header strings
# such as the ones produced by BAT mode (boltedcollection)
## Check merge-fdata tool correctly processes fdata files with header strings
## such as the ones produced by BAT mode (boltedcollection)
RUN: merge-fdata %S/Inputs/bat_profile_1.fdata \
RUN: %S/Inputs/bat_profile_2.fdata \
RUN: | FileCheck %s --check-prefix=CHECK-FDATA
Expand Down
2 changes: 1 addition & 1 deletion bolt/test/X86/merge-fdata-nobat-mode.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Check that merge-fdata tool doesn't spuriously print boltedcollection
## Check that merge-fdata tool doesn't spuriously print boltedcollection

RUN: merge-fdata %S/Inputs/blarge.fdata %S/Inputs/blarge.fdata \
RUN: | FileCheck %s --check-prefix=CHECK-FDATA
Expand Down
4 changes: 2 additions & 2 deletions bolt/test/X86/merge-fdata-output.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Check merge-fdata tool correctly handles `-o` option.
## Check merge-fdata tool correctly handles `-o` option.
RUN: merge-fdata %S/Inputs/bat_profile_1.fdata \
RUN: %S/Inputs/bat_profile_2.fdata \
RUN: | FileCheck %s
Expand All @@ -13,4 +13,4 @@ RUN: %S/Inputs/bat_profile_2.fdata \
RUN: -o %t
RUN: FileCheck %s < %t

CHECK: 1 main 451 1 SolveCubic 0 0 302
CHECK: 1 main 451 1 SolveCubic 0 0 302
4 changes: 2 additions & 2 deletions bolt/test/X86/no-entry-reordering.test
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Verifies that llvm-bolt reordering heuristic does not allocate a BB before the
# entry point even if there is a hot edge from a block to entry point
## Verifies that llvm-bolt reordering heuristic does not allocate a BB before the
## entry point even if there is a hot edge from a block to entry point

RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %S/Inputs/entry.s -o %t.o
RUN: link_fdata %S/Inputs/entry.s %t.o %t.fdata --nmtool llvm-nm
Expand Down
2 changes: 1 addition & 1 deletion bolt/test/X86/no-output.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This script checks that BOLT is able to work in dry run mode (no output)
## This script checks that BOLT is able to work in dry run mode (no output)

# REQUIRES: system-linux

Expand Down
6 changes: 3 additions & 3 deletions bolt/test/X86/nolbr.s
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This reproduces a bug where profile collected from perf without LBRs and
# converted into fdata-no-lbr format is reported to not contain profile for any
# functions.
## This reproduces a bug where profile collected from perf without LBRs and
## converted into fdata-no-lbr format is reported to not contain profile for any
## functions.

# REQUIRES: system-linux

Expand Down
18 changes: 9 additions & 9 deletions bolt/test/X86/patch-entries.test
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Checking crashes against injected binary functions created by patch
# entries pass and debug info turned on. In these cases, we were
# trying to fetch input to output maps on injected functions and
# crashing.
## Checking crashes against injected binary functions created by patch
## entries pass and debug info turned on. In these cases, we were
## trying to fetch input to output maps on injected functions and
## crashing.

REQUIRES: system-linux

Expand All @@ -10,22 +10,22 @@ RUN: -Wl,-q -I%p/../Inputs
RUN: llvm-bolt -relocs %t.exe -o %t.out --update-debug-sections --force-patch \
RUN: --enable-bat

# Check that patched functions can be disassembled (override FDE from the
# original function)
## Check that patched functions can be disassembled (override FDE from the
## original function)
# PREAGG: B X:0 #foo.org.0# 1 0
RUN: link_fdata %s %t.out %t.preagg PREAGG
RUN: perf2bolt %t.out -p %t.preagg --pa -o %t.yaml --profile-format=yaml \
RUN: -print-disasm -print-only=foo.org.0/1 2>&1 | FileCheck %s
CHECK-NOT: BOLT-WARNING: sizes differ for function foo.org.0/1
CHECK: Binary Function "foo.org.0/1(*2)" after disassembly {

# Check the expected eh_frame contents
## Check the expected eh_frame contents
RUN: llvm-nm --print-size %t.out > %t.foo
RUN: llvm-objdump %t.out --dwarf=frames >> %t.foo
RUN: FileCheck %s --input-file %t.foo --check-prefix=CHECK-FOO
CHECK-FOO: 0000000000[[#%x,FOO:]] [[#%x,OPTSIZE:]] t foo
CHECK-FOO: 0000000000[[#%x,ORG:]] [[#%x,ORGSIZE:]] t foo.org.0
# patched FDE comes first
## patched FDE comes first
CHECK-FOO: FDE {{.*}} pc=00[[#%x,ORG]]...00[[#%x,ORG+ORGSIZE]]
# original FDE comes second
## original FDE comes second
CHECK-FOO: FDE {{.*}} pc=00[[#%x,ORG]]...00[[#%x,ORG+OPTSIZE]]
20 changes: 10 additions & 10 deletions bolt/test/X86/pre-aggregated-perf.test
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# This script checks that perf2bolt is reading pre-aggregated perf information
# correctly for a simple example. The perf.data of this example was generated
# with the following command:
#
# $ perf record -j any,u -e branch -o perf.data -- ./blarge
#
# blarge is the binary for "basicmath large inputs" taken from Mibench.
## This script checks that perf2bolt is reading pre-aggregated perf information
## correctly for a simple example. The perf.data of this example was generated
## with the following command:
##
## $ perf record -j any,u -e branch -o perf.data -- ./blarge
##
## blarge is the binary for "basicmath large inputs" taken from Mibench.

# Currently failing in MacOS / generating different hash for usqrt
## Currently failing in MacOS / generating different hash for usqrt
REQUIRES: system-linux

RUN: yaml2obj %p/Inputs/blarge.yaml &> %t.exe
Expand All @@ -22,7 +22,7 @@ CHECK: BOLT-INFO: 4 out of 7 functions in the binary (57.1%) have non-empty exec
RUN: cat %t | sort | FileCheck %s -check-prefix=PERF2BOLT
RUN: cat %t.new | FileCheck %s -check-prefix=NEWFORMAT

# Test --profile-format option with perf2bolt
## Test --profile-format option with perf2bolt
RUN: perf2bolt %t.exe -o %t.fdata --pa -p %p/Inputs/pre-aggregated.txt \
RUN: --profile-format=fdata
RUN: cat %t.fdata | sort | FileCheck %s -check-prefix=PERF2BOLT
Expand All @@ -31,7 +31,7 @@ RUN: perf2bolt %t.exe -o %t.yaml --pa -p %p/Inputs/pre-aggregated.txt \
RUN: --profile-format=yaml --profile-use-dfs
RUN: cat %t.yaml | FileCheck %s -check-prefix=NEWFORMAT

# Test --profile-format option with llvm-bolt --aggregate-only
## Test --profile-format option with llvm-bolt --aggregate-only
RUN: llvm-bolt %t.exe -o %t.bolt.fdata --pa -p %p/Inputs/pre-aggregated.txt \
RUN: --aggregate-only --profile-format=fdata
RUN: cat %t.bolt.fdata | sort | FileCheck %s -check-prefix=PERF2BOLT
Expand Down
4 changes: 2 additions & 2 deletions bolt/test/X86/pt_gnu_relro.s
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# REQUIRES: system-linux

# Check that BOLT recognizes PT_GNU_RELRO segment and marks respective sections
# accordingly.
## Check that BOLT recognizes PT_GNU_RELRO segment and marks respective sections
## accordingly.

# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-linux %s -o %t.o
# RUN: ld.lld %t.o -o %t.exe -q --no-relax
Expand Down
28 changes: 14 additions & 14 deletions bolt/test/X86/reader-stale-yaml-std.test
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# This script checks that YamlProfileReader in llvm-bolt is reading data
# correctly and stale data is corrected by profile inference.
## This script checks that YamlProfileReader in llvm-bolt is reading data
## correctly and stale data is corrected by profile inference.

RUN: yaml2obj %p/Inputs/blarge.yaml &> %t.exe
RUN: llvm-bolt %t.exe -o %t.null -b %p/Inputs/blarge_profile_stale.std-hash.yaml \
RUN: --print-cfg --print-only=usqrt,SolveCubic --infer-stale-profile=1 -v=1 \
RUN: 2>&1 | FileCheck %s

# Verify that yaml reader works as expected.
## Verify that yaml reader works as expected.
CHECK: pre-processing profile using YAML profile reader
CHECK: BOLT-INFO: YAML profile with hash: std::hash

# Function "SolveCubic" has stale profile, since there is one jump in the
# profile (from bid=13 to bid=2) which is not in the CFG in the binary. The test
# verifies that the inference is able to match two blocks (bid=1 and bid=13)
# using "loose" hashes and then correctly propagate the counts.
## Function "SolveCubic" has stale profile, since there is one jump in the
## profile (from bid=13 to bid=2) which is not in the CFG in the binary. The test
## verifies that the inference is able to match two blocks (bid=1 and bid=13)
## using "loose" hashes and then correctly propagate the counts.

CHECK: Binary Function "SolveCubic" after building cfg {
CHECK: State : CFG constructed
Expand All @@ -25,7 +25,7 @@ CHECK: BB Count : 18
CHECK: Exec Count : 151
CHECK: Branch Count: 552
CHECK: }
# Verify block counts.
## Verify block counts.
CHECK: .LBB00 (43 instructions, align : 1)
CHECK: Successors: .Ltmp[[#BB07:]] (mispreds: 0, count: 0), .LFT[[#BB01:]] (mispreds: 0, count: 151)
CHECK: .LFT[[#BB01:]] (5 instructions, align : 1)
Expand All @@ -37,10 +37,10 @@ CHECK: .Ltmp[[#BB013:]] (12 instructions, align : 1)
CHECK: Successors: .Ltmp[[#BB03:]] (mispreds: 0, count: 151)
CHECK: End of Function "SolveCubic"

# Function "usqrt" has stale profile, since the number of blocks in the profile
# (nblocks=6) does not match the size of the CFG in the binary. The entry
# block (bid=0) has an incorrect (missing) count, which should be inferred by
# the algorithm.
## Function "usqrt" has stale profile, since the number of blocks in the profile
## (nblocks=6) does not match the size of the CFG in the binary. The entry
## block (bid=0) has an incorrect (missing) count, which should be inferred by
# #the algorithm.

CHECK: Binary Function "usqrt" after building cfg {
CHECK: State : CFG constructed
Expand All @@ -52,7 +52,7 @@ CHECK: BB Count : 5
CHECK: Exec Count : 20
CHECK: Branch Count: 640
CHECK: }
# Verify block counts.
## Verify block counts.
CHECK: .LBB01 (4 instructions, align : 1)
CHECK: Successors: .Ltmp[[#BB113:]] (mispreds: 0, count: 20)
CHECK: .Ltmp[[#BB113:]] (9 instructions, align : 1)
Expand All @@ -63,6 +63,6 @@ CHECK: .Ltmp[[#BB112:]] (2 instructions, align : 1)
CHECK: Successors: .Ltmp[[#BB113:]] (mispreds: 0, count: 300), .LFT[[#BB11:]] (mispreds: 0, count: 20)
CHECK: .LFT[[#BB11:]] (2 instructions, align : 1)
CHECK: End of Function "usqrt"
# Check the overall inference stats.
## Check the overall inference stats.
CHECK: 2 out of 7 functions in the binary (28.6%) have non-empty execution profile
CHECK: inferred profile for 2 (100.00% of profiled, 100.00% of stale) functions responsible for {{.*}} samples ({{.*}} out of {{.*}})
40 changes: 20 additions & 20 deletions bolt/test/X86/reader-stale-yaml.test
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# This script checks that YamlProfileReader in llvm-bolt is reading data
# correctly and stale data is corrected by profile inference.
## This script checks that YamlProfileReader in llvm-bolt is reading data
## correctly and stale data is corrected by profile inference.

REQUIRES: asserts
RUN: yaml2obj %p/Inputs/blarge.yaml &> %t.exe
RUN: llvm-bolt %t.exe -o %t.null --b %p/Inputs/blarge_profile_stale.yaml \
RUN: --infer-stale-profile=0 --profile-ignore-hash=1 --profile-use-dfs=0 \
RUN: 2>&1 | FileCheck %s -check-prefix=CHECK0
# Testing "usqrt"
## Testing "usqrt"
RUN: llvm-bolt %t.exe -o %t.null --b %p/Inputs/blarge_profile_stale.yaml \
RUN: --print-cfg --print-only=usqrt --infer-stale-profile=1 \
RUN: --profile-ignore-hash=1 --profile-use-dfs=0 --debug-only=bolt-prof 2>&1 | FileCheck %s -check-prefix=CHECK1
# Testing "SolveCubic"
## Testing "SolveCubic"
RUN: llvm-bolt %t.exe -o %t.null --b %p/Inputs/blarge_profile_stale.yaml \
RUN: --print-cfg --print-only=SolveCubic --infer-stale-profile=1 \
RUN: --profile-ignore-hash=1 --profile-use-dfs=0 --debug-only=bolt-prof 2>&1 | FileCheck %s -check-prefix=CHECK2
# Testing skipped function
## Testing skipped function
RUN: llvm-bolt %t.exe -o %t.null --b %p/Inputs/blarge_profile_stale.yaml \
RUN: --print-cfg --print-only=usqrt --infer-stale-profile=1 --skip-funcs=usqrt \
RUN: --profile-ignore-hash=1 --profile-use-dfs=0
Expand All @@ -23,12 +23,12 @@ CHECK0: BOLT-INFO: 2 out of 7 functions in the binary (28.6%) have non-empty exe
CHECK0: BOLT-WARNING: 2 (100.0% of all profiled) functions have invalid (possibly stale) profile
CHECK0: BOLT-WARNING: 1192 out of 1192 samples in the binary (100.0%) belong to functions with invalid (possibly stale) profile

# Function "usqrt" has stale profile, since the number of blocks in the profile
# (nblocks=6) does not match the size of the CFG in the binary. The entry
# block (bid=0) has an incorrect (missing) count, which should be inferred by
# the algorithm.
## Function "usqrt" has stale profile, since the number of blocks in the profile
## (nblocks=6) does not match the size of the CFG in the binary. The entry
## block (bid=0) has an incorrect (missing) count, which should be inferred by
## the algorithm.

# Verify inference details.
## Verify inference details.
CHECK1: pre-processing profile using YAML profile reader
CHECK1: applying profile inference for "usqrt"
CHECK1: Matched yaml block (bid = 0) with hash 1111111111111111 to BB (index = 0) with hash 36007ba1d80c0000
Expand All @@ -38,7 +38,7 @@ CHECK1-NEXT: exact match
CHECK1: Matched yaml block (bid = 3) with hash 5c06705524800039 to BB (index = 3) with hash 5c06705524800039
CHECK1-NEXT: exact match

# Verify that yaml reader works as expected.
## Verify that yaml reader works as expected.
CHECK1: Binary Function "usqrt" after building cfg {
CHECK1: State : CFG constructed
CHECK1: Address : 0x401170
Expand All @@ -50,7 +50,7 @@ CHECK1: Exec Count : 20
CHECK1: Branch Count: 640
CHECK1: }

# Verify block counts.
## Verify block counts.
CHECK1: .LBB01 (4 instructions, align : 1)
CHECK1: Successors: .Ltmp[[#BB13:]] (mispreds: 0, count: 20)
CHECK1: .Ltmp[[#BB13:]] (9 instructions, align : 1)
Expand All @@ -60,19 +60,19 @@ CHECK1: Successors: .Ltmp[[#BB12:]] (mispreds: 0, count: 0)
CHECK1: .Ltmp[[#BB12:]] (2 instructions, align : 1)
CHECK1: Successors: .Ltmp[[#BB13:]] (mispreds: 0, count: 300), .LFT[[#BB1:]] (mispreds: 0, count: 20)
CHECK1: .LFT[[#BB1:]] (2 instructions, align : 1)
# Check the overall inference stats.
## Check the overall inference stats.
CHECK1: 2 out of 7 functions in the binary (28.6%) have non-empty execution profile
CHECK1: BOLT-WARNING: 2 (100.0% of all profiled) functions have invalid (possibly stale) profile
CHECK1: BOLT-WARNING: 1192 out of 1192 samples in the binary (100.0%) belong to functions with invalid (possibly stale) profile
CHECK1: inferred profile for 2 (100.00% of profiled, 100.00% of stale) functions responsible for {{.*}} samples ({{.*}} out of {{.*}})


# Function "SolveCubic" has stale profile, since there is one jump in the
# profile (from bid=13 to bid=2) which is not in the CFG in the binary. The test
# verifies that the inference is able to match two blocks (bid=1 and bid=13)
# using "loose" hashes and then correctly propagate the counts.
## Function "SolveCubic" has stale profile, since there is one jump in the
## profile (from bid=13 to bid=2) which is not in the CFG in the binary. The test
## verifies that the inference is able to match two blocks (bid=1 and bid=13)
## using "loose" hashes and then correctly propagate the counts.

# Verify inference details.
## Verify inference details.
CHECK2: pre-processing profile using YAML profile reader
CHECK2: applying profile inference for "SolveCubic"
CHECK2: Matched yaml block (bid = 0) with hash 4600940a609c0000 to BB (index = 0) with hash 4600940a609c0000
Expand All @@ -86,7 +86,7 @@ CHECK2-NEXT: loose match
CHECK2: Matched yaml block (bid = 5) with hash 6446e1ea500111 to BB (index = 5) with hash 6446e1ea500111
CHECK2-NEXT: exact match

# Verify that yaml reader works as expected.
## Verify that yaml reader works as expected.
CHECK2: Binary Function "SolveCubic" after building cfg {
CHECK2: State : CFG constructed
CHECK2: Address : 0x400e00
Expand All @@ -97,7 +97,7 @@ CHECK2: BB Count : 18
CHECK2: Exec Count : 151
CHECK2: Branch Count: 552

# Verify block counts.
## Verify block counts.
CHECK2: .LBB00 (43 instructions, align : 1)
CHECK2: Successors: .Ltmp[[#BB7:]] (mispreds: 0, count: 0), .LFT[[#BB1:]] (mispreds: 0, count: 151)
CHECK2: .LFT[[#BB1:]] (5 instructions, align : 1)
Expand Down
2 changes: 1 addition & 1 deletion bolt/test/X86/reader.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This script checks that DataReader in llvm-bolt is reading data correctly
## This script checks that DataReader in llvm-bolt is reading data correctly

RUN: yaml2obj %p/Inputs/blarge.yaml &> %t.exe
RUN: llvm-bolt %t.exe -o %t.null --data %p/Inputs/blarge.fdata --dump-data \
Expand Down
16 changes: 14 additions & 2 deletions bolt/test/X86/register-fragments-bolt-symbols.s
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
# Test the heuristics for matching BOLT-added split functions.
## Test the heuristics for matching BOLT-added split functions.

# RUN: llvm-mc --filetype=obj --triple x86_64-unknown-unknown %S/cdsplit-symbol-names.s -o %t.main.o
# RUN: llvm-mc --filetype=obj --triple x86_64-unknown-unknown %s -o %t.chain.o
# RUN: link_fdata %S/cdsplit-symbol-names.s %t.main.o %t.fdata
# RUN: sed -i 's|chain|chain/2|g' %t.fdata
# RUN: llvm-strip --strip-unneeded %t.main.o

## Check warm fragment name matching (produced by cdsplit)
# RUN: %clang %cflags %t.main.o -o %t.warm.exe -Wl,-q
# RUN: llvm-bolt %t.warm.exe -o %t.warm.bolt --split-functions --split-strategy=cdsplit \
# RUN: --call-scale=2 --data=%t.fdata --reorder-blocks=ext-tsp --enable-bat
# RUN: link_fdata %s %t.warm.bolt %t.preagg.warm PREAGGWARM
# PREAGGWARM: B X:0 #chain.warm# 1 0
# RUN: perf2bolt %t.warm.bolt -p %t.preagg.warm --pa -o %t.warm.fdata -w %t.warm.yaml \
# RUN: -v=1 | FileCheck %s --check-prefix=CHECK-BOLT-WARM

# CHECK-BOLT-WARM: marking chain.warm/1(*2) as a fragment of chain

# RUN: sed -i 's|chain|chain/2|g' %t.fdata
# RUN: llvm-objcopy --localize-symbol=chain %t.main.o
# RUN: %clang %cflags %t.chain.o %t.main.o -o %t.exe -Wl,-q
# RUN: llvm-bolt %t.exe -o %t.bolt --split-functions --split-strategy=randomN \
Expand Down
2 changes: 1 addition & 1 deletion bolt/test/X86/relaxed-tailcall.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Check that tail calls can be 2 bytes in the output binary.
## Check that tail calls can be 2 bytes in the output binary.

RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-unknown -o %t.o \
RUN: %S/Inputs/relaxed_tc.s
Expand Down
6 changes: 3 additions & 3 deletions bolt/test/X86/remove-unused.test
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Verifies that llvm-bolt is able to remove dead basic blocks. Also check that
# the BB reordering ignores dead BBs.
## Verifies that llvm-bolt is able to remove dead basic blocks. Also check that
## the BB reordering ignores dead BBs.

RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %S/Inputs/entry.s -o %t.o
RUN: link_fdata %S/Inputs/entry.s %t.o %t.fdata --nmtool llvm-nm
Expand All @@ -9,5 +9,5 @@ RUN: llvm-bolt %t.exe --data %t.fdata -o %t --funcs=_start \
RUN: --eliminate-unreachable --reorder-blocks=none \
RUN: --print-finalized --sequential-disassembly 2>&1 | FileCheck %s

# Optimized
## Optimized
CHECK: BB Layout : .LBB00, .Ltmp0, .Ltmp2, .Ltmp3, .Ltmp4, .Ltmp5, .Ltmp6, .Ltmp7, .Ltmp8, .Ltmp9, .Ltmp10, .Ltmp11
6 changes: 3 additions & 3 deletions bolt/test/X86/rodata-simpl-loads.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Check for the simplification of .rodata loads.
## Check for the simplification of .rodata loads.

RUN: %clang %cflags %p/Inputs/rodata_simpl_loads.s -o %t.exe
RUN: llvm-bolt %t.exe -o %t --simplify-rodata-loads
Expand All @@ -7,8 +7,8 @@ RUN: llvm-objdump -d %t --print-imm-hex --disassemble-symbols=main | FileCheck %

CHECK: Disassembly of section .text:
CHECK: <main>:
# check that the following rip-relative operands have been
# replaced with immediates
## check that the following rip-relative operands have been
## replaced with immediates

ORIGINAL: movzbl s1(%rip), %eax
CHECK: movl $0x41, %eax
Expand Down
2 changes: 1 addition & 1 deletion bolt/test/X86/sctc-bug.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Check that we don't accidentally optimize out a tail call.
## Check that we don't accidentally optimize out a tail call.

RUN: %clang %cflags %S/Inputs/sctc_bug.s -o %t
RUN: llvm-bolt %t -o %t.null --funcs=main --print-after-lowering \
Expand Down
2 changes: 1 addition & 1 deletion bolt/test/X86/sctc-bug2.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Check that conditional tail call is not treated as a regular tail call by SCTC.
## Check that conditional tail call is not treated as a regular tail call by SCTC.

RUN: %clang %cflags %S/Inputs/sctc_bug2.s -o %t
RUN: llvm-bolt %t -o %t.null --funcs=main --print-after-lowering \
Expand Down
6 changes: 3 additions & 3 deletions bolt/test/X86/sctc-bug3.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Check that we don't accidentally optimize out a tail call.
## Check that we don't accidentally optimize out a tail call.

RUN: %clang %cflags %S/Inputs/sctc_bug3.s -o %t
RUN: llvm-bolt %t -o %t.null --funcs=main --print-after-lowering \
Expand All @@ -7,9 +7,9 @@ RUN: --sequential-disassembly 2>&1 | FileCheck %s
CHECK: .LBB00 (1 instructions, align : 1)
CHECK: cmpq %rdi, 0x0

# Check that .Ltmp0 does not have a deleted predecessor.
## Check that .Ltmp0 does not have a deleted predecessor.
CHECK: .Ltmp0 (1 instructions, align : 1)
CHECK: Predecessors: .LBB00

# Tail call.
## Tail call.
CHECK: jmp foo
4 changes: 2 additions & 2 deletions bolt/test/X86/sctc-bug4.test
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Check that fallthrough blocks are handled properly and Offset annotation is
# set for conditional tail calls.
## Check that fallthrough blocks are handled properly and Offset annotation is
## set for conditional tail calls.

RUN: %clang %cflags %S/Inputs/sctc_bug4.s -o %t
RUN: llvm-bolt %t -o %t.null --enable-bat \
Expand Down
2 changes: 1 addition & 1 deletion bolt/test/X86/shared_object_entry.s
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# RUN: -split-functions -reorder-blocks=ext-tsp -split-all-cold \
# RUN: -dyno-stats -icf=1 -use-gnu-stack

# Check that an entry point is a cold symbol
## Check that an entry point is a cold symbol
# RUN: llvm-readelf -h %t.so > %t.log
# RUN: llvm-nm %t.so >> %t.log
# RUN: FileCheck %s --input-file %t.log
Expand Down
4 changes: 2 additions & 2 deletions bolt/test/X86/shorten-mov.test
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Test that 64 bit movq instructions with immediate operands
# that fit in 32 bits are shortened.
## Test that 64 bit movq instructions with immediate operands
## that fit in 32 bits are shortened.

RUN: %clang %cflags %p/Inputs/asm_main.c %p/Inputs/shorten_mov.s -o %t.exe
RUN: llvm-bolt %t.exe -o %t
Expand Down
12 changes: 6 additions & 6 deletions bolt/test/X86/shrinkwrapping-and-rsp.s
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This checks that shrink wrapping does attempt at accessing stack elements
# using RSP when the function is aligning RSP and changing offsets.
## This checks that shrink wrapping does attempt at accessing stack elements
## using RSP when the function is aligning RSP and changing offsets.

# REQUIRES: system-linux

Expand All @@ -12,10 +12,10 @@
# RUN: --frame-opt=all --simplify-conditional-tail-calls=false \
# RUN: --eliminate-unreachable=false | FileCheck %s

# Here we have a function that aligns the stack at prologue. Stack pointer
# analysis can't try to infer offset positions after AND because that depends
# on the runtime value of the stack pointer of callee (whether it is misaligned
# or not).
## Here we have a function that aligns the stack at prologue. Stack pointer
## analysis can't try to infer offset positions after AND because that depends
## on the runtime value of the stack pointer of callee (whether it is misaligned
## or not).
.globl _start
.type _start, %function
_start:
Expand Down
4 changes: 2 additions & 2 deletions bolt/test/X86/shrinkwrapping-critedge.s
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This reproduces a bug with shrink wrapping when trying to split critical
# edges originating at the same basic block.
## This reproduces a bug with shrink wrapping when trying to split critical
## edges originating at the same basic block.

# REQUIRES: system-linux

Expand Down
26 changes: 13 additions & 13 deletions bolt/test/X86/shrinkwrapping-do-not-pessimize.s
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# This checks that shrink wrapping does not pessimize a CFG pattern where two
# blocks can be proved to have the same execution count but, because of profile
# inaccuricies, we could move saves into the second block. We can prove two
# blocks have the same frequency when B post-dominate A and A dominates B and
# are at the same loop nesting level. This would be a pessimization because
# shrink wrapping is unlikely to be able to cleanly move PUSH instructions,
# inserting additional store instructions.
## This checks that shrink wrapping does not pessimize a CFG pattern where two
## blocks can be proved to have the same execution count but, because of profile
## inaccuricies, we could move saves into the second block. We can prove two
## blocks have the same frequency when B post-dominate A and A dominates B and
## are at the same loop nesting level. This would be a pessimization because
## shrink wrapping is unlikely to be able to cleanly move PUSH instructions,
## inserting additional store instructions.

# REQUIRES: system-linux

Expand All @@ -16,15 +16,15 @@
# RUN: llvm-bolt -relocs %t.exe -o %t.out -data %t.fdata \
# RUN: -frame-opt=all -equalize-bb-counts | FileCheck %s

# Here we create a CFG pattern with two blocks A and B belonging to the same
# equivalency class as defined by dominance relations and having in theory
# the same frequency. But we tweak edge counts from profile to make block A
# hotter than block B.
## Here we create a CFG pattern with two blocks A and B belonging to the same
## equivalency class as defined by dominance relations and having in theory
## the same frequency. But we tweak edge counts from profile to make block A
## hotter than block B.
.globl _start
.type _start, %function
_start:
.cfi_startproc
# Hot prologue
## Hot prologue
# FDATA: 0 [unknown] 0 1 _start 0 0 10
push %rbp
mov %rsp, %rbp
Expand All @@ -36,7 +36,7 @@ b: je end_if_1
if_false:
movq rel(%rip), %rdi # Add this to create a relocation and run bolt w/ relocs
c: jmp end_if_1
# Reduce frequency from 9 to 1 to simulate an inaccurate profile
## Reduce frequency from 9 to 1 to simulate an inaccurate profile
# FDATA: 1 _start #c# 1 _start #end_if_1# 0 1
end_if_1:
# first uses of R14 and RBX appear at this point, possible move point for SW
Expand Down
12 changes: 6 additions & 6 deletions bolt/test/X86/shrinkwrapping-insertcfi.s
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This test reproduces the issue with inserting updated CFI in shrink wrapping
# into the first basic block.
## This test reproduces the issue with inserting updated CFI in shrink wrapping
## into the first basic block.

# REQUIRES: system-linux

Expand All @@ -10,10 +10,10 @@
# RUN: llvm-bolt %t.exe -o %t.out --data %t.fdata --frame-opt=all --lite=0 \
# RUN: --print-fop 2>&1 | FileCheck %s

# Check shrink wrapping results:
## Check shrink wrapping results:
# CHECK: BOLT-INFO: Shrink wrapping moved 0 spills inserting load/stores and 1 spills inserting push/pops

# Check that CFI is successfully inserted into the first basic block:
## Check that CFI is successfully inserted into the first basic block:
# CHECK: Binary Function "_start" after frame-optimizer
# CHECK: .LBB00 (2 instructions, align : 1)
# CHECK-NEXT: Entry Point
Expand All @@ -34,8 +34,8 @@ c:
.cfi_offset 3, 4
pop %rbx

# This basic block is treated as having 0 execution count.
# push and pop will be sinked into this block.
## This basic block is treated as having 0 execution count.
## push and pop will be sinked into this block.
a:
ud2
.cfi_endproc
6 changes: 3 additions & 3 deletions bolt/test/X86/shrinkwrapping-lea.s
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This checks that shrink wrapping correctly drops moving push/pops when
# there is an LEA instruction.
## This checks that shrink wrapping correctly drops moving push/pops when
## there is an LEA instruction.


# REQUIRES: system-linux
Expand Down Expand Up @@ -58,7 +58,7 @@ JT:

# CHECK: BOLT-INFO: Shrink wrapping moved 2 spills inserting load/stores and 0 spills inserting push/pops

# Checks that offsets of instructions accessing the stack were not changed
## Checks that offsets of instructions accessing the stack were not changed
# CHECK-OBJDUMP: <_start>:
# CHECK-OBJDUMP: movq %rbx, %rdi
# CHECK-OBJDUMP-NEXT: leaq -0x20(%rbp), %r14
Expand Down
6 changes: 3 additions & 3 deletions bolt/test/X86/shrinkwrapping-mov.s
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This checks that shrink wrapping correctly drops moving push/pops when
# there is a MOV instruction loading the value of the stack pointer in
# order to do pointer arithmetic with a stack address.
## This checks that shrink wrapping correctly drops moving push/pops when
## there is a MOV instruction loading the value of the stack pointer in
## order to do pointer arithmetic with a stack address.


# REQUIRES: system-linux
Expand Down
16 changes: 8 additions & 8 deletions bolt/test/X86/shrinkwrapping-pop-order.s
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This test reproduces a POP reordering issue in shrink wrapping where we would
# incorrectly put a store after a load (instead of before) when having multiple
# insertions at the same point. Check that the order is correct in this test.
## This test reproduces a POP reordering issue in shrink wrapping where we would
## incorrectly put a store after a load (instead of before) when having multiple
## insertions at the same point. Check that the order is correct in this test.

# REQUIRES: system-linux

Expand All @@ -25,23 +25,23 @@ c:
pop %rbp
pop %rbx

# This basic block is treated as having 0 execution count.
# push and pop will be sinked into this block.
## This basic block is treated as having 0 execution count.
## push and pop will be sinked into this block.
a:
ud2
.cfi_endproc


# Check shrink wrapping results:
## Check shrink wrapping results:
# CHECK: BOLT-INFO: Shrink wrapping moved 0 spills inserting load/stores and 2 spills inserting push/pops
# CHECK: BOLT-INFO: Shrink wrapping reduced 6 store executions (28.6% total instructions executed, 100.0% store instructions)
# CHECK: BOLT-INFO: Shrink wrapping failed at reducing 0 store executions (0.0% total instructions executed, 0.0% store instructions)

# Check that order is correct
## Check that order is correct
# CHECK: Binary Function "_start" after frame-optimizer
# Pushes are ordered according to their reg number and come first
# CHECK: pushq %rbp
# CHECK: pushq %rbx
# Pops are ordered according to their dominance relation and come last
## Pops are ordered according to their dominance relation and come last
# CHECK: popq %rbx
# CHECK: popq %rbp
4 changes: 2 additions & 2 deletions bolt/test/X86/shrinkwrapping-popf.s
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This test checks that POPF will not crash our frame analysis pass
## This test checks that POPF will not crash our frame analysis pass

# REQUIRES: system-linux

Expand Down Expand Up @@ -26,7 +26,7 @@ c:
pop %rbx
popf

# This basic block is treated as having 0 execution count.
## This basic block is treated as having 0 execution count.
a:
ud2
.cfi_endproc
12 changes: 6 additions & 6 deletions bolt/test/X86/shrinkwrapping-restore-position.s
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This checks that shrink wrapping uses the red zone defined in the X86 ABI by
# placing restores that access elements already deallocated by the stack.
## This checks that shrink wrapping uses the red zone defined in the X86 ABI by
## placing restores that access elements already deallocated by the stack.

# REQUIRES: system-linux

Expand All @@ -16,10 +16,10 @@
# RUN: FileCheck --check-prefix CHECK-OBJDUMP %s


# Here we create a CFG where the restore position matches the previous (deleted)
# restore position. Shrink wrapping then will put a stack access to an element
# that was deallocated at the previously deleted POP, which falls in the red
# zone and should be safe for X86 Linux ABI.
## Here we create a CFG where the restore position matches the previous (deleted)
## restore position. Shrink wrapping then will put a stack access to an element
## that was deallocated at the previously deleted POP, which falls in the red
## zone and should be safe for X86 Linux ABI.
.globl _start
.type _start, %function
_start:
Expand Down
10 changes: 5 additions & 5 deletions bolt/test/X86/shrinkwrapping.test
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Verifies that llvm-bolt updates CFI correctly after
# shrink-wrapping when optimizing a function without
# frame pointers.
## Verifies that llvm-bolt updates CFI correctly after
## shrink-wrapping when optimizing a function without
## frame pointers.

# This test has commands that rely on shell capabilities that won't execute
# correctly on Windows e.g. subshell execution to capture command output.
## This test has commands that rely on shell capabilities that won't execute
## correctly on Windows e.g. subshell execution to capture command output.
REQUIRES: shell

RUN: %clangxx %cxxflags -no-pie %S/Inputs/exc4sw.S -o %t.exe -Wl,-q
Expand Down
6 changes: 3 additions & 3 deletions bolt/test/X86/split-all-lptrampoline.s
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This test checks that trampolines are inserted in split fragments if
# necessary. There are 4 LSDA ranges with a landing pad to three landing pads.
# After splitting all blocks, there have to be 4 trampolines in the output.
## This test checks that trampolines are inserted in split fragments if
## necessary. There are 4 LSDA ranges with a landing pad to three landing pads.
## After splitting all blocks, there have to be 4 trampolines in the output.

# RUN: llvm-mc --filetype=obj --triple x86_64-unknown-unknown %s -o %t.o
# RUN: %clangxx %cxxflags %t.o -o %t.exe -Wl,-q -pie
Expand Down
2 changes: 1 addition & 1 deletion bolt/test/X86/split-all.s
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Test split all block strategy
## Test split all block strategy

# RUN: llvm-mc --filetype=obj --triple x86_64-unknown-unknown %s -o %t.o
# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q
Expand Down
22 changes: 11 additions & 11 deletions bolt/test/X86/split-func-icf.s
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This reproduces an issue where two cold fragments are folded into one, so the
# fragment has two parents.
# The fragment is only reachable through a jump table, so all functions must be
# ignored.
## This reproduces an issue where two cold fragments are folded into one, so the
## fragment has two parents.
## The fragment is only reachable through a jump table, so all functions must be
## ignored.

# REQUIRES: system-linux

Expand All @@ -27,10 +27,10 @@ main:
LBB0:
andl $0xf, %ecx
cmpb $0x4, %cl
# exit through ret
## exit through ret
ja LBB3

# jump table dispatch, jumping to label indexed by val in %ecx
## jump table dispatch, jumping to label indexed by val in %ecx
LBB1:
leaq JUMP_TABLE1(%rip), %r8
movzbl %cl, %ecx
Expand All @@ -55,7 +55,7 @@ LBB20:
# exit through ret
ja LBB23

# jump table dispatch, jumping to label indexed by val in %ecx
## jump table dispatch, jumping to label indexed by val in %ecx
LBB21:
leaq JUMP_TABLE2(%rip), %r8
movzbl %cl, %ecx
Expand All @@ -70,23 +70,23 @@ LBB23:
ret
.size main2, .-main2

# cold fragment is only reachable through jump table
## cold fragment is only reachable through jump table
.globl main2.cold.1
.type main2.cold.1, %function
main2.cold.1:
.globl main.cold.1
.type main.cold.1, %function
.p2align 2
main.cold.1:
# load bearing nop: pad LBB4 so that it can't be treated
# as __builtin_unreachable by analyzeJumpTable
## load bearing nop: pad LBB4 so that it can't be treated
## as __builtin_unreachable by analyzeJumpTable
nop
LBB4:
callq abort
.size main.cold.1, .-main.cold.1

.rodata
# jmp table, entries must be R_X86_64_PC32 relocs
## jmp table, entries must be R_X86_64_PC32 relocs
.globl JUMP_TABLE1
JUMP_TABLE1:
.long LBB2-JUMP_TABLE1
Expand Down
22 changes: 11 additions & 11 deletions bolt/test/X86/split-func-jump-table-fragment-bidirection.s
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This reproduces an issue where two fragments of same function access same
# jump table, which means at least one fragment visits the other, i.e., one
# of them has split jump table. As a result, all of them will be marked as
# non-simple function.
## This reproduces an issue where two fragments of same function access same
## jump table, which means at least one fragment visits the other, i.e., one
## of them has split jump table. As a result, all of them will be marked as
## non-simple function.

# REQUIRES: system-linux

Expand All @@ -21,10 +21,10 @@ main:
LBB0:
andl $0xf, %ecx
cmpb $0x4, %cl
# exit through ret
## exit through ret
ja LBB3

# jump table dispatch, jumping to label indexed by val in %ecx
## jump table dispatch, jumping to label indexed by val in %ecx
LBB1:
leaq JUMP_TABLE1(%rip), %r8
movzbl %cl, %ecx
Expand All @@ -39,21 +39,21 @@ LBB3:
ret
.size main, .-main

# cold fragment is only reachable
## cold fragment is only reachable
.globl main.cold.1
.type main.cold.1, %function
.p2align 2
main.cold.1:
# load bearing nop: pad LBB8 so that it can't be treated
# as __builtin_unreachable by analyzeJumpTable
## load bearing nop: pad LBB8 so that it can't be treated
## as __builtin_unreachable by analyzeJumpTable
nop
LBB4:
andl $0xb, %ebx
cmpb $0x1, %cl
# exit through ret
ja LBB7

# jump table dispatch, jumping to label indexed by val in %ecx
## jump table dispatch, jumping to label indexed by val in %ecx
LBB5:
leaq JUMP_TABLE1(%rip), %r8
movzbl %cl, %ecx
Expand All @@ -71,7 +71,7 @@ LBB8:
.size main.cold.1, .-main.cold.1

.rodata
# jmp table, entries must be R_X86_64_PC32 relocs
## jmp table, entries must be R_X86_64_PC32 relocs
.globl JUMP_TABLE1
JUMP_TABLE1:
.long LBB2-JUMP_TABLE1
Expand Down
18 changes: 9 additions & 9 deletions bolt/test/X86/split-func-jump-table-fragment-noparent.s
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This reproduces a bug with jump table identification where jump table has
# entries pointing to code in function and its cold fragment.
# The fragment is only reachable through jump table.
## This reproduces a bug with jump table identification where jump table has
## entries pointing to code in function and its cold fragment.
## The fragment is only reachable through jump table.

# REQUIRES: system-linux

Expand All @@ -19,10 +19,10 @@ main:
LBB0:
andl $0xf, %ecx
cmpb $0x4, %cl
# exit through ret
## exit through ret
ja LBB3

# jump table dispatch, jumping to label indexed by val in %ecx
## jump table dispatch, jumping to label indexed by val in %ecx
LBB1:
leaq JUMP_TABLE(%rip), %r8
movzbl %cl, %ecx
Expand All @@ -37,20 +37,20 @@ LBB3:
ret
.size main, .-main

# cold fragment is only reachable through jump table
## cold fragment is only reachable through jump table
.globl main.cold.1
.type main.cold.1, %function
.p2align 2
main.cold.1:
# load bearing nop: pad LBB4 so that it can't be treated
# as __builtin_unreachable by analyzeJumpTable
## load bearing nop: pad LBB4 so that it can't be treated
## as __builtin_unreachable by analyzeJumpTable
nop
LBB4:
callq abort
.size main.cold.1, .-main.cold.1

.rodata
# jmp table, entries must be R_X86_64_PC32 relocs
## jmp table, entries must be R_X86_64_PC32 relocs
.globl JUMP_TABLE
JUMP_TABLE:
.long LBB2-JUMP_TABLE
Expand Down
18 changes: 9 additions & 9 deletions bolt/test/X86/split-func-jump-table-fragment-reverse.s
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This reproduces a bug with jump table identification where jump table has
# entries pointing to code in function and its cold fragment.
# The fragment is only reachable through jump table.
## This reproduces a bug with jump table identification where jump table has
## entries pointing to code in function and its cold fragment.
## The fragment is only reachable through jump table.

# REQUIRES: system-linux

Expand All @@ -26,10 +26,10 @@ main.cold:
LBB0:
andl $0xf, %ecx
cmpb $0x4, %cl
# exit through ret
## exit through ret
ja LBB3

# jump table dispatch, jumping to label indexed by val in %ecx
## jump table dispatch, jumping to label indexed by val in %ecx
LBB1:
leaq JUMP_TABLE(%rip), %r8
movzbl %cl, %ecx
Expand All @@ -44,20 +44,20 @@ LBB3:
ret
.size main.cold, .-main.cold

# main function, referenced from jump table in cold fragment
## main function, referenced from jump table in cold fragment
.globl main
.type main, %function
.p2align 2
main:
# load bearing nop: pad LBB4 so that it can't be treated
# as __builtin_unreachable by analyzeJumpTable
## load bearing nop: pad LBB4 so that it can't be treated
## as __builtin_unreachable by analyzeJumpTable
nop
LBB4:
callq abort
.size main, .-main

.rodata
# jmp table, entries must be R_X86_64_PC32 relocs
## jmp table, entries must be R_X86_64_PC32 relocs
.globl JUMP_TABLE
JUMP_TABLE:
.long LBB2-JUMP_TABLE
Expand Down
10 changes: 5 additions & 5 deletions bolt/test/X86/split-func-jump-table-fragment.s
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ main:
LBB0:
andl $0xf, %ecx
cmpb $0x4, %cl
# exit through abort in main.cold.1, registers cold fragment the regular way
## exit through abort in main.cold.1, registers cold fragment the regular way
ja main.cold.1

# jump table dispatch, jumping to label indexed by val in %ecx
## jump table dispatch, jumping to label indexed by val in %ecx
LBB1:
leaq JUMP_TABLE(%rip), %r8
movzbl %cl, %ecx
Expand All @@ -37,8 +37,8 @@ LBB3:
ret
.size main, .-main

# Insert padding between functions, so that the next instruction cannot be
# treated as __builtin_unreachable destination for the jump table.
## Insert padding between functions, so that the next instruction cannot be
## treated as __builtin_unreachable destination for the jump table.
.quad 0

.globl main.cold.1
Expand All @@ -50,7 +50,7 @@ LBB4:
.size main.cold.1, .-main.cold.1

.rodata
# jmp table, entries must be R_X86_64_PC32 relocs
## jmp table, entries must be R_X86_64_PC32 relocs
.globl JUMP_TABLE
JUMP_TABLE:
.long LBB2-JUMP_TABLE
Expand Down
14 changes: 7 additions & 7 deletions bolt/test/X86/split-func-jump-table-unknown.s
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This reproduces a bug with converting an unknown control flow jump table with
# entries pointing to code in function and its cold fragment.
## This reproduces a bug with converting an unknown control flow jump table with
## entries pointing to code in function and its cold fragment.

# REQUIRES: system-linux

Expand Down Expand Up @@ -27,10 +27,10 @@ LBB0:
leaq JUMP_TABLE(%rip), %r8
andl $0xf, %ecx
cmpb $0x4, %cl
# exit through abort in main.cold.1, registers cold fragment the regular way
## exit through abort in main.cold.1, registers cold fragment the regular way
ja main.cold.1

# jump table dispatch, jumping to label indexed by val in %ecx
## jump table dispatch, jumping to label indexed by val in %ecx
LBB1:
movzbl %cl, %ecx
movslq (%r8,%rcx,4), %rax
Expand All @@ -48,15 +48,15 @@ LBB3:
.type main.cold.1, %function
.p2align 2
main.cold.1:
# load bearing nop: pad LBB4 so that it can't be treated
# as __builtin_unreachable by analyzeJumpTable
## load bearing nop: pad LBB4 so that it can't be treated
## as __builtin_unreachable by analyzeJumpTable
nop
LBB4:
callq abort
.size main.cold.1, .-main.cold.1

.rodata
# jmp table, entries must be R_X86_64_PC32 relocs
## jmp table, entries must be R_X86_64_PC32 relocs
.globl JUMP_TABLE
JUMP_TABLE:
.long LBB2-JUMP_TABLE
Expand Down
44 changes: 22 additions & 22 deletions bolt/test/X86/split-landing-pad.s
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
# This test reproduces the case where C++ exception handling is used and split
# function optimization is enabled. In particular, function foo is splitted
# to two fragments:
# foo: contains 2 try blocks, which invokes bar to throw exception
# foo.cold.1: contains 2 corresponding catch blocks (landing pad)
#
# Similar to split jump table, split landing pad target to different fragment.
# This test is written to ensure BOLT safely handle these targets, e.g., by
# marking them as non-simple.
#
# Steps to write this test:
# - Create a copy of Inputs/src/unreachable.cpp
# - Simplify bar(), focus on throw an exception
# - Create the second switch case in foo() to have multiple landing pads
# - Compile with clang++ to .s
# - Move landing pad code from foo to foo.cold.1
# - Ensure that all landing pads can be reached normally
#
# Additional details:
# .gcc_except_table specify the landing pads for try blocks
# LPStart = 255 (omit), which means LPStart = foo start
# Landing pads .Ltmp2 and .Ltmp5 in call site record are offset to foo start.
## This test reproduces the case where C++ exception handling is used and split
## function optimization is enabled. In particular, function foo is splitted
## to two fragments:
## foo: contains 2 try blocks, which invokes bar to throw exception
## foo.cold.1: contains 2 corresponding catch blocks (landing pad)
##
## Similar to split jump table, split landing pad target to different fragment.
## This test is written to ensure BOLT safely handle these targets, e.g., by
## marking them as non-simple.
##
## Steps to write this test:
## - Create a copy of Inputs/src/unreachable.cpp
## - Simplify bar(), focus on throw an exception
## - Create the second switch case in foo() to have multiple landing pads
## - Compile with clang++ to .s
## - Move landing pad code from foo to foo.cold.1
## - Ensure that all landing pads can be reached normally
##
## Additional details:
## .gcc_except_table specify the landing pads for try blocks
## LPStart = 255 (omit), which means LPStart = foo start
## Landing pads .Ltmp2 and .Ltmp5 in call site record are offset to foo start.


# REQUIRES: system-linux
Expand Down
2 changes: 1 addition & 1 deletion bolt/test/X86/split-random.s
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Test random function splitting option
## Test random function splitting option

# RUN: llvm-mc --filetype=obj --triple x86_64-unknown-unknown %s -o %t.o
# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q
Expand Down
2 changes: 1 addition & 1 deletion bolt/test/X86/static-exe.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Check that llvm-bolt can rewrite static executable
## Check that llvm-bolt can rewrite static executable

RUN: %clang %cflags %S/Inputs/static_exe.s -static -o %t.exe -nostdlib
RUN: llvm-bolt %t.exe -o %t 2>&1 | FileCheck %s
Expand Down
4 changes: 2 additions & 2 deletions bolt/test/X86/symtab-secondary-entries.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Check that secondary entry points are updated correctly in the ELF symtab
## Check that secondary entry points are updated correctly in the ELF symtab

RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown \
RUN: %p/Inputs/user-order.S -o %t.o
Expand All @@ -13,7 +13,7 @@ CHECK: [[#]] FUNC GLOBAL DEFAULT [[#NDX]] main
CHECK: [[#]] FUNC LOCAL DEFAULT [[#NDX]] _a
CHECK: [[#]] FUNC GLOBAL DEFAULT [[#NDX]] _b
CHECK: [[#]] FUNC GLOBAL DEFAULT [[#NDX]] _f
# The following are all secondary entries of _f
## The following are all secondary entries of _f
CHECK: 0 FUNC GLOBAL DEFAULT [[#NDX]] _c
CHECK: 0 FUNC GLOBAL DEFAULT [[#NDX]] _d
CHECK: 0 FUNC GLOBAL DEFAULT [[#NDX]] _e
4 changes: 2 additions & 2 deletions bolt/test/X86/tail-duplication-cache.s
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# RUN: --print-finalized --tail-duplication=cache -o %t.out2 \
# RUN: | FileCheck --check-prefix="CHECK2" %s

# A test where the tail is duplicated to eliminate an unconditional jump
## A test where the tail is duplicated to eliminate an unconditional jump
# FDATA: 1 main #.BB0_br# 1 main #.BB4# 0 100
# FDATA: 1 main #.BB0_br# 1 main #.BB1# 0 100
# FDATA: 1 main #.BB1_br# 1 main #.BB3# 0 50
Expand All @@ -20,7 +20,7 @@
# CHECK: BOLT-INFO: tail duplication modified 1 ({{.*}}%) functions; duplicated 1 blocks (13 bytes) responsible for 50 dynamic executions ({{.*}}% of all block executions)
# CHECK: BB Layout : .LBB00, .Ltmp0, .Ltmp1, .Ltmp2, .Ltmp3, .Ltmp4, .Ltmp5, .Ltail-dup0, .Ltmp6

# A test where the tail is not duplicated due to the cache score
## A test where the tail is not duplicated due to the cache score
# FDATA2: 1 main #.BB0_br# 1 main #.BB4# 0 100
# FDATA2: 1 main #.BB0_br# 1 main #.BB1# 0 2
# FDATA2: 1 main #.BB1_br# 1 main #.BB3# 0 1
Expand Down
4 changes: 2 additions & 2 deletions bolt/test/X86/tail-duplication-cacheline.s
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This reproduces a bug in TailDuplication::isInCacheLine
# with accessing BlockLayout past bounds (unreachable blocks).
## This reproduces a bug in TailDuplication::isInCacheLine
## with accessing BlockLayout past bounds (unreachable blocks).

# REQUIRES: system-linux

Expand Down
12 changes: 6 additions & 6 deletions bolt/test/X86/tail-duplication-complex.s
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
# CHECK: tail duplication modified 1 ({{.*}}%) functions; duplicated 1 blocks ({{.*}} bytes) responsible for {{.*}} dynamic executions ({{.*}} of all block executions)
# CHECK: BB Layout : .LBB00, .Ltmp0, .Ltail-dup0, .Ltmp1, .Ltmp2

# This is the C++ code fed to Clang
# int fib(int term) {
# if (term <= 1)
# return term;
# return fib(term-1) + fib(term-2);
# }
## This is the C++ code fed to Clang
## int fib(int term) {
## if (term <= 1)
## return term;
## return fib(term-1) + fib(term-2);
## }

.text
.globl main
Expand Down
4 changes: 2 additions & 2 deletions bolt/test/X86/tail-duplication-jt.s
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This reproduces a bug in tail duplication when aggressiveCodeToDuplicate
# fails to handle a block with a jump table.
## This reproduces a bug in tail duplication when aggressiveCodeToDuplicate
## fails to handle a block with a jump table.

# REQUIRES: system-linux

Expand Down
2 changes: 1 addition & 1 deletion bolt/test/X86/tail-duplication-pass.s
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# CHECK: BOLT-INFO: tail duplication modified 1 ({{.*}}%) functions; duplicated 1 blocks (1 bytes) responsible for {{.*}} dynamic executions ({{.*}}% of all block executions)
# CHECK: BB Layout : .LBB00, .Ltail-dup0, .Ltmp0, .Ltmp1

# Check that the successor of Ltail-dup0 is .LBB00, not itself.
## Check that the successor of Ltail-dup0 is .LBB00, not itself.
# CHECK-NOLOOP: .Ltail-dup0 (1 instructions, align : 1)
# CHECK-NOLOOP: Predecessors: .LBB00
# CHECK-NOLOOP: retq
Expand Down
2 changes: 1 addition & 1 deletion bolt/test/X86/tail-duplication-prop-bug.s
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This reproduces a bug in aggressive tail duplication/copy propagation.
## This reproduces a bug in aggressive tail duplication/copy propagation.

# REQUIRES: system-linux
# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s -o %t.o
Expand Down
2 changes: 1 addition & 1 deletion bolt/test/X86/tailcall-traps.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Tests the peephole that adds trap instructions following indirect tail calls.
## Tests the peephole that adds trap instructions following indirect tail calls.

RUN: %clang %cflags %p/Inputs/tailcall_traps.s -o %t.exe
RUN: llvm-bolt %t.exe -o %t --peepholes=tailcall-traps \
Expand Down
4 changes: 2 additions & 2 deletions bolt/test/X86/tailcall.test
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Verifies that llvm-bolt recognizes tailcalls and mark them
# in control flow graph.
## Verifies that llvm-bolt recognizes tailcalls and mark them
## in control flow graph.

RUN: %clang %cflags %S/Inputs/tailcall.s -o %t.exe
RUN: llvm-bolt %t.exe -o %t.null --print-cfg 2>&1 | FileCheck %s
Expand Down
4 changes: 2 additions & 2 deletions bolt/test/X86/unclaimed-jt-entries.s
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This test ensures that "unclaimed" jump table entries are accounted later
# in postProcessIndirectBranches and the function is marked as non-simple.
## This test ensures that "unclaimed" jump table entries are accounted later
## in postProcessIndirectBranches and the function is marked as non-simple.

# The test is compiled from the following source using GCC 12.2 -O3:
# https://godbolt.org/z/YcPG131s6
Expand Down
10 changes: 5 additions & 5 deletions bolt/test/X86/unreachable-jmp.s
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This checks that we don't create an invalid CFG when there is an
# unreachable direct jump right after an indirect one.
## This checks that we don't create an invalid CFG when there is an
## unreachable direct jump right after an indirect one.

# REQUIRES: system-linux

Expand All @@ -25,8 +25,8 @@ _start:
b:
jmpq *JUMP_TABLE(,%rcx,8)
# FDATA: 1 _start #b# 1 _start #hotpath# 0 20
# Unreachable direct jump here. Our CFG should still make sense and properly
# place this instruction in a new basic block.
## Unreachable direct jump here. Our CFG should still make sense and properly
## place this instruction in a new basic block.
jmp .lbb2
.lbb1: je .lexit
.lbb2:
Expand Down Expand Up @@ -60,7 +60,7 @@ JUMP_TABLE:
.quad .lbb2
.quad hotpath

# No basic blocks above should have 4 successors! That is a bug.
## No basic blocks above should have 4 successors! That is a bug.
# CHECK-NOT: Successors: {{.*}} (mispreds: 0, count: 20), {{.*}} (mispreds: 0, count: 0), {{.*}} (mispreds: 0, count: 0), {{.*}} (mispreds: 0, count: 0)
# Check successful removal of stray direct jmp
# CHECK: UCE removed 1 block
2 changes: 1 addition & 1 deletion bolt/test/X86/unreachable.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Check unreachable code elimination
## Check unreachable code elimination

RUN: %clang %cflags %p/../Inputs/stub.c -fPIC -pie -shared -o %t.so
RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown \
Expand Down
6 changes: 3 additions & 3 deletions bolt/test/X86/vararg.test
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Check that a function that references a label inside itself,
# as in the case of vararg handling code generated by GCC 4.5
# and earlier, is recognized as multi-entry.
## Check that a function that references a label inside itself,
## as in the case of vararg handling code generated by GCC 4.5
## and earlier, is recognized as multi-entry.

REQUIRES: x86_64-linux

Expand Down
4 changes: 2 additions & 2 deletions bolt/test/X86/yaml-multiple-profiles.test
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This test ensures that a YAML profile with multiple profiles matching the same
# function is handled gracefully.
## This test ensures that a YAML profile with multiple profiles matching the same
## function is handled gracefully.

# REQUIRES: system-linux
# RUN: split-file %s %t
Expand Down
4 changes: 2 additions & 2 deletions bolt/test/X86/zero-sized-object.s
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Check that references to local (unnamed) objects below are not
# treated as references relative to zero-sized A object.
## Check that references to local (unnamed) objects below are not
## treated as references relative to zero-sized A object.

# REQUIRES: system-linux

Expand Down
8 changes: 4 additions & 4 deletions bolt/test/bad-exe.test
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Check that llvm-bolt rejects input that is not a valid ELF executable
# bzip2.debuginfo is the result of running "objcopy --only-keep-debug".
## Check that llvm-bolt rejects input that is not a valid ELF executable
## bzip2.debuginfo is the result of running "objcopy --only-keep-debug".

# This test uses the clang driver without target flags and will only succeed
# on Linux systems where the host triple matches the target.
## This test uses the clang driver without target flags and will only succeed
## on Linux systems where the host triple matches the target.
REQUIRES: system-linux

RUN: %clang %cflags %S/Inputs/icf-jump-tables.c -g -o %t
Expand Down
2 changes: 1 addition & 1 deletion bolt/test/bolt-icf.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Check for the replacement of calls to identical functions.
## Check for the replacement of calls to identical functions.

REQUIRES: system-linux

Expand Down
6 changes: 3 additions & 3 deletions bolt/test/bolt-info.test
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Check that the .bolt_info section is generated properly.
## Check that the .bolt_info section is generated properly.

# This test uses the clang driver without target flags and will only succeed
# on Linux systems where the host triple matches the target.
## This test uses the clang driver without target flags and will only succeed
## on Linux systems where the host triple matches the target.
REQUIRES: system-linux

RUN: %clang %cflags %S/Inputs/icf-jump-tables.c -o %t
Expand Down
2 changes: 1 addition & 1 deletion bolt/test/heatmap.test
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Verifies basic functioning of heatmap mode
## Verifies basic functioning of heatmap mode

REQUIRES: system-linux

Expand Down
6 changes: 3 additions & 3 deletions bolt/test/invalid-profile.test
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Check that llvm-bolt detects bad profile data and aborts
## Check that llvm-bolt detects bad profile data and aborts

# This test uses the clang driver without target flags and will only succeed
# on Linux systems where the host triple matches the target.
## This test uses the clang driver without target flags and will only succeed
## on Linux systems where the host triple matches the target.
REQUIRES: system-linux

RUN: %clang %S/Inputs/icf-jump-tables.c -o %t
Expand Down
4 changes: 2 additions & 2 deletions bolt/test/keep-aranges.test
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Check that BOLT generates .debug_aranges section for an input
# where it was removed when .gdb_index was generated.
## Check that BOLT generates .debug_aranges section for an input
## where it was removed when .gdb_index was generated.

REQUIRES: system-linux

Expand Down
2 changes: 1 addition & 1 deletion bolt/test/lit.local.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
host_linux_triple = config.target_triple.split("-")[0] + "-linux"
host_linux_triple = config.target_triple.split("-")[0] + "-unknown-linux-gnu"
common_linker_flags = "-fuse-ld=lld -Wl,--unresolved-symbols=ignore-all"
flags = f"--target={host_linux_triple} {common_linker_flags}"

Expand Down
6 changes: 3 additions & 3 deletions bolt/test/no-relocs.test
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Verifies that input without relocations is rejected in relocs mode.
## Verifies that input without relocations is rejected in relocs mode.

# This test uses the clang driver without target flags and will only succeed
# on Linux systems where the host triple matches the target.
## This test uses the clang driver without target flags and will only succeed
## on Linux systems where the host triple matches the target.
REQUIRES: system-linux

RUN: %clang %cflags %S/Inputs/icf-jump-tables.c -o %t
Expand Down
8 changes: 4 additions & 4 deletions bolt/test/non-empty-debug-line.test
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Verifies that BOLT emits DWARF line table with the same size if
# no functions with debug info were modified.
## Verifies that BOLT emits DWARF line table with the same size if
## no functions with debug info were modified.

REQUIRES: system-linux

Expand All @@ -9,12 +9,12 @@ RUN: llvm-readobj -S %t > %t2
RUN: llvm-readobj -S %t1 >> %t2
RUN: FileCheck %s --input-file %t2

# Check the input and grab .debug_line size.
## Check the input and grab .debug_line size.
CHECK: File:
CHECK: Name: .debug_line
CHECK: Size: [[SIZE:[0-9]+]]

# Verify .debug_line size is the same after BOLT.
## Verify .debug_line size is the same after BOLT.
CHECK: File:
CHECK: Name: .debug_line
CHECK: Size:
Expand Down
6 changes: 3 additions & 3 deletions bolt/test/pie.test
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Check that we do not reject position-independent executables (PIEs).
## Check that we do not reject position-independent executables (PIEs).

# This test uses the clang driver without target flags and will only succeed
# on Linux systems where the host triple matches the target.
## This test uses the clang driver without target flags and will only succeed
## on Linux systems where the host triple matches the target.
REQUIRES: system-linux

RUN: %clang %cflags -fPIC -pie %p/Inputs/jump_table_icp.cpp -o %t
Expand Down
6 changes: 3 additions & 3 deletions bolt/test/re-optimize.test
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Check that we detect re-optimization attempt.
## Check that we detect re-optimization attempt.

# This test uses the clang driver without target flags and will only succeed
# on Linux systems where the host triple matches the target.
## This test uses the clang driver without target flags and will only succeed
## on Linux systems where the host triple matches the target.
REQUIRES: system-linux

RUN: %clang %cflags %S/Inputs/icf-jump-tables.c -o %t.exe
Expand Down
2 changes: 1 addition & 1 deletion bolt/test/runtime/X86/asm-dump.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Test for asm-dump functionality.
** Test for asm-dump functionality.
*
* REQUIRES: x86_64-linux,bolt-runtime
*
Expand Down
6 changes: 3 additions & 3 deletions bolt/test/shared-object.test
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Test that llvm-bolt processes *.so without a failure
## Test that llvm-bolt processes *.so without a failure

# This test uses the clang driver without target flags and will only succeed
# on Linux systems where the host triple matches the target.
## This test uses the clang driver without target flags and will only succeed
## on Linux systems where the host triple matches the target.
REQUIRES: system-linux

RUN: %clang %cflags %S/Inputs/icf-jump-tables.c -o %t.so -shared -fPIC -Wl,--build-id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ void ContainerSizeEmptyCheck::registerMatchers(MatchFinder *Finder) {

Finder->addMatcher(
cxxMemberCallExpr(
argumentCountIs(0),
on(expr(anyOf(hasType(ValidContainer),
hasType(pointsTo(ValidContainer)),
hasType(references(ValidContainer))))
Expand All @@ -163,7 +164,8 @@ void ContainerSizeEmptyCheck::registerMatchers(MatchFinder *Finder) {
this);

Finder->addMatcher(
callExpr(has(cxxDependentScopeMemberExpr(
callExpr(argumentCountIs(0),
has(cxxDependentScopeMemberExpr(
hasObjectExpression(
expr(anyOf(hasType(ValidContainer),
hasType(pointsTo(ValidContainer)),
Expand Down
5 changes: 3 additions & 2 deletions clang-tools-extra/clangd/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,11 @@ struct Config {
IncludesPolicy UnusedIncludes = IncludesPolicy::Strict;
IncludesPolicy MissingIncludes = IncludesPolicy::None;

/// IncludeCleaner will not diagnose usages of these headers matched by
/// these regexes.
struct {
/// IncludeCleaner will not diagnose usages of these headers matched by
/// these regexes.
std::vector<std::function<bool(llvm::StringRef)>> IgnoreHeader;
bool AnalyzeAngledIncludes = false;
} Includes;
} Diagnostics;

Expand Down
60 changes: 37 additions & 23 deletions clang-tools-extra/clangd/ConfigCompile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -572,32 +572,46 @@ struct FragmentCompiler {
#else
static llvm::Regex::RegexFlags Flags = llvm::Regex::NoFlags;
#endif
auto Filters = std::make_shared<std::vector<llvm::Regex>>();
for (auto &HeaderPattern : F.IgnoreHeader) {
// Anchor on the right.
std::string AnchoredPattern = "(" + *HeaderPattern + ")$";
llvm::Regex CompiledRegex(AnchoredPattern, Flags);
std::string RegexError;
if (!CompiledRegex.isValid(RegexError)) {
diag(Warning,
llvm::formatv("Invalid regular expression '{0}': {1}",
*HeaderPattern, RegexError)
.str(),
HeaderPattern.Range);
continue;
std::shared_ptr<std::vector<llvm::Regex>> Filters;
if (!F.IgnoreHeader.empty()) {
Filters = std::make_shared<std::vector<llvm::Regex>>();
for (auto &HeaderPattern : F.IgnoreHeader) {
// Anchor on the right.
std::string AnchoredPattern = "(" + *HeaderPattern + ")$";
llvm::Regex CompiledRegex(AnchoredPattern, Flags);
std::string RegexError;
if (!CompiledRegex.isValid(RegexError)) {
diag(Warning,
llvm::formatv("Invalid regular expression '{0}': {1}",
*HeaderPattern, RegexError)
.str(),
HeaderPattern.Range);
continue;
}
Filters->push_back(std::move(CompiledRegex));
}
Filters->push_back(std::move(CompiledRegex));
}
if (Filters->empty())
// Optional to override the resulting AnalyzeAngledIncludes
// only if it's explicitly set in the current fragment.
// Otherwise it's inherited from parent fragment.
std::optional<bool> AnalyzeAngledIncludes;
if (F.AnalyzeAngledIncludes.has_value())
AnalyzeAngledIncludes = **F.AnalyzeAngledIncludes;
if (!Filters && !AnalyzeAngledIncludes.has_value())
return;
auto Filter = [Filters](llvm::StringRef Path) {
for (auto &Regex : *Filters)
if (Regex.match(Path))
return true;
return false;
};
Out.Apply.push_back([Filter](const Params &, Config &C) {
C.Diagnostics.Includes.IgnoreHeader.emplace_back(Filter);
Out.Apply.push_back([Filters = std::move(Filters),
AnalyzeAngledIncludes](const Params &, Config &C) {
if (Filters) {
auto Filter = [Filters](llvm::StringRef Path) {
for (auto &Regex : *Filters)
if (Regex.match(Path))
return true;
return false;
};
C.Diagnostics.Includes.IgnoreHeader.emplace_back(std::move(Filter));
}
if (AnalyzeAngledIncludes.has_value())
C.Diagnostics.Includes.AnalyzeAngledIncludes = *AnalyzeAngledIncludes;
});
}

Expand Down
4 changes: 4 additions & 0 deletions clang-tools-extra/clangd/ConfigFragment.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,10 @@ struct Fragment {
/// unused or missing. These can match any suffix of the header file in
/// question.
std::vector<Located<std::string>> IgnoreHeader;

/// If false (default), unused system headers will be ignored.
/// Standard library headers are analyzed regardless of this option.
std::optional<Located<bool>> AnalyzeAngledIncludes;
};
IncludesBlock Includes;

Expand Down
4 changes: 4 additions & 0 deletions clang-tools-extra/clangd/ConfigYAML.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ class Parser {
if (auto Values = scalarValues(N))
F.IgnoreHeader = std::move(*Values);
});
Dict.handle("AnalyzeAngledIncludes", [&](Node &N) {
if (auto Value = boolValue(N, "AnalyzeAngledIncludes"))
F.AnalyzeAngledIncludes = *Value;
});
Dict.parse(N);
}

Expand Down
32 changes: 21 additions & 11 deletions clang-tools-extra/clangd/IncludeCleaner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,24 +68,30 @@ bool isIgnored(llvm::StringRef HeaderPath, HeaderFilter IgnoreHeaders) {
}

bool mayConsiderUnused(const Inclusion &Inc, ParsedAST &AST,
const include_cleaner::PragmaIncludes *PI) {
const include_cleaner::PragmaIncludes *PI,
bool AnalyzeAngledIncludes) {
assert(Inc.HeaderID);
auto HID = static_cast<IncludeStructure::HeaderID>(*Inc.HeaderID);
auto FE = AST.getSourceManager().getFileManager().getFileRef(
AST.getIncludeStructure().getRealPath(HID));
assert(FE);
if (FE->getDir() == AST.getPreprocessor()
.getHeaderSearchInfo()
.getModuleMap()
.getBuiltinDir())
.getHeaderSearchInfo()
.getModuleMap()
.getBuiltinDir())
return false;
if (PI && PI->shouldKeep(*FE))
return false;
// FIXME(kirillbobyrev): We currently do not support the umbrella headers.
// System headers are likely to be standard library headers.
// Until we have good support for umbrella headers, don't warn about them.
if (Inc.Written.front() == '<')
return tooling::stdlib::Header::named(Inc.Written).has_value();
// Until we have good support for umbrella headers, don't warn about them
// (unless analysis is explicitly enabled).
if (Inc.Written.front() == '<') {
if (tooling::stdlib::Header::named(Inc.Written))
return true;
if (!AnalyzeAngledIncludes)
return false;
}
if (PI) {
// Check if main file is the public interface for a private header. If so we
// shouldn't diagnose it as unused.
Expand Down Expand Up @@ -266,7 +272,8 @@ Fix fixAll(const Fix &RemoveAllUnused, const Fix &AddAllMissing) {

std::vector<const Inclusion *>
getUnused(ParsedAST &AST,
const llvm::DenseSet<IncludeStructure::HeaderID> &ReferencedFiles) {
const llvm::DenseSet<IncludeStructure::HeaderID> &ReferencedFiles,
bool AnalyzeAngledIncludes) {
trace::Span Tracer("IncludeCleaner::getUnused");
std::vector<const Inclusion *> Unused;
for (const Inclusion &MFI : AST.getIncludeStructure().MainFileIncludes) {
Expand All @@ -275,7 +282,8 @@ getUnused(ParsedAST &AST,
auto IncludeID = static_cast<IncludeStructure::HeaderID>(*MFI.HeaderID);
if (ReferencedFiles.contains(IncludeID))
continue;
if (!mayConsiderUnused(MFI, AST, &AST.getPragmaIncludes())) {
if (!mayConsiderUnused(MFI, AST, &AST.getPragmaIncludes(),
AnalyzeAngledIncludes)) {
dlog("{0} was not used, but is not eligible to be diagnosed as unused",
MFI.Written);
continue;
Expand Down Expand Up @@ -347,7 +355,8 @@ include_cleaner::Includes convertIncludes(const ParsedAST &AST) {
return ConvertedIncludes;
}

IncludeCleanerFindings computeIncludeCleanerFindings(ParsedAST &AST) {
IncludeCleanerFindings
computeIncludeCleanerFindings(ParsedAST &AST, bool AnalyzeAngledIncludes) {
// Interaction is only polished for C/CPP.
if (AST.getLangOpts().ObjC)
return {};
Expand Down Expand Up @@ -432,7 +441,8 @@ IncludeCleanerFindings computeIncludeCleanerFindings(ParsedAST &AST) {
MapInfo::getHashValue(RHS.Symbol);
});
MissingIncludes.erase(llvm::unique(MissingIncludes), MissingIncludes.end());
std::vector<const Inclusion *> UnusedIncludes = getUnused(AST, Used);
std::vector<const Inclusion *> UnusedIncludes =
getUnused(AST, Used, AnalyzeAngledIncludes);
return {std::move(UnusedIncludes), std::move(MissingIncludes)};
}

Expand Down
4 changes: 3 additions & 1 deletion clang-tools-extra/clangd/IncludeCleaner.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ struct IncludeCleanerFindings {
std::vector<MissingIncludeDiagInfo> MissingIncludes;
};

IncludeCleanerFindings computeIncludeCleanerFindings(ParsedAST &AST);
IncludeCleanerFindings
computeIncludeCleanerFindings(ParsedAST &AST,
bool AnalyzeAngledIncludes = false);

using HeaderFilter = llvm::ArrayRef<std::function<bool(llvm::StringRef)>>;
std::vector<Diag>
Expand Down
3 changes: 2 additions & 1 deletion clang-tools-extra/clangd/ParsedAST.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,8 @@ std::vector<Diag> getIncludeCleanerDiags(ParsedAST &AST, llvm::StringRef Code,
Cfg.Diagnostics.UnusedIncludes == Config::IncludesPolicy::None;
if (SuppressMissing && SuppressUnused)
return {};
auto Findings = computeIncludeCleanerFindings(AST);
auto Findings = computeIncludeCleanerFindings(
AST, Cfg.Diagnostics.Includes.AnalyzeAngledIncludes);
if (SuppressMissing)
Findings.MissingIncludes.clear();
if (SuppressUnused)
Expand Down
6 changes: 6 additions & 0 deletions clang-tools-extra/clangd/unittests/ConfigCompileTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,12 @@ TEST_F(ConfigCompileTests, DiagnosticsIncludeCleaner) {
};
EXPECT_TRUE(HeaderFilter("foo.h"));
EXPECT_FALSE(HeaderFilter("bar.h"));

Frag = {};
EXPECT_FALSE(Conf.Diagnostics.Includes.AnalyzeAngledIncludes);
Frag.Diagnostics.Includes.AnalyzeAngledIncludes = true;
EXPECT_TRUE(compileAndApply());
EXPECT_TRUE(Conf.Diagnostics.Includes.AnalyzeAngledIncludes);
}

TEST_F(ConfigCompileTests, DiagnosticSuppression) {
Expand Down
15 changes: 15 additions & 0 deletions clang-tools-extra/clangd/unittests/ConfigYAMLTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,21 @@ TEST(ParseYAML, IncludesIgnoreHeader) {
ElementsAre(val("foo"), val("bar")));
}

TEST(ParseYAML, IncludesAnalyzeAngledIncludes) {
CapturedDiags Diags;
Annotations YAML(R"yaml(
Diagnostics:
Includes:
AnalyzeAngledIncludes: true
)yaml");
auto Results =
Fragment::parseYAML(YAML.code(), "config.yaml", Diags.callback());
ASSERT_THAT(Diags.Diagnostics, IsEmpty());
ASSERT_EQ(Results.size(), 1u);
EXPECT_THAT(Results[0].Diagnostics.Includes.AnalyzeAngledIncludes,
llvm::ValueIs(val(true)));
}

TEST(ParseYAML, Style) {
CapturedDiags Diags;
Annotations YAML(R"yaml(
Expand Down
44 changes: 44 additions & 0 deletions clang-tools-extra/clangd/unittests/IncludeCleanerTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ TEST(IncludeCleaner, GetUnusedHeaders) {
#include "unguarded.h"
#include "unused.h"
#include <system_header.h>
#include <non_system_angled_header.h>
void foo() {
a();
b();
Expand All @@ -122,6 +123,7 @@ TEST(IncludeCleaner, GetUnusedHeaders) {
TU.AdditionalFiles["dir/c.h"] = guard("void c();");
TU.AdditionalFiles["unused.h"] = guard("void unused();");
TU.AdditionalFiles["dir/unused.h"] = guard("void dirUnused();");
TU.AdditionalFiles["dir/non_system_angled_header.h"] = guard("");
TU.AdditionalFiles["system/system_header.h"] = guard("");
TU.AdditionalFiles["unguarded.h"] = "";
TU.ExtraArgs.push_back("-I" + testPath("dir"));
Expand All @@ -135,6 +137,48 @@ TEST(IncludeCleaner, GetUnusedHeaders) {
Pointee(writtenInclusion("\"dir/unused.h\""))));
}

TEST(IncludeCleaner, IgnoredAngledHeaders) {
// Currently the default behavior is to ignore unused angled includes
auto TU = TestTU::withCode(R"cpp(
#include <system_header.h>
#include <system_unused.h>
#include <non_system_angled_unused.h>
SystemClass x;
)cpp");
TU.AdditionalFiles["system/system_header.h"] = guard("class SystemClass {};");
TU.AdditionalFiles["system/system_unused.h"] = guard("");
TU.AdditionalFiles["dir/non_system_angled_unused.h"] = guard("");
TU.ExtraArgs = {
"-isystem" + testPath("system"),
"-I" + testPath("dir"),
};
auto AST = TU.build();
IncludeCleanerFindings Findings = computeIncludeCleanerFindings(AST);
EXPECT_THAT(Findings.UnusedIncludes, IsEmpty());
}

TEST(IncludeCleaner, UnusedAngledHeaders) {
auto TU = TestTU::withCode(R"cpp(
#include <system_header.h>
#include <system_unused.h>
#include <non_system_angled_unused.h>
SystemClass x;
)cpp");
TU.AdditionalFiles["system/system_header.h"] = guard("class SystemClass {};");
TU.AdditionalFiles["system/system_unused.h"] = guard("");
TU.AdditionalFiles["dir/non_system_angled_unused.h"] = guard("");
TU.ExtraArgs = {
"-isystem" + testPath("system"),
"-I" + testPath("dir"),
};
auto AST = TU.build();
IncludeCleanerFindings Findings = computeIncludeCleanerFindings(AST, true);
EXPECT_THAT(Findings.UnusedIncludes,
UnorderedElementsAre(
Pointee(writtenInclusion("<system_unused.h>")),
Pointee(writtenInclusion("<non_system_angled_unused.h>"))));
}

TEST(IncludeCleaner, ComputeMissingHeaders) {
Annotations MainFile(R"cpp(
#include "a.h"
Expand Down
9 changes: 9 additions & 0 deletions clang-tools-extra/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ Objective-C
Miscellaneous
^^^^^^^^^^^^^

- Added a boolean option `AnalyzeAngledIncludes` to `Includes` config section,
which allows to enable unused includes detection for all angled ("system") headers.
At this moment umbrella headers are not supported, so enabling this option
may result in false-positives.

Improvements to clang-doc
-------------------------

Expand Down Expand Up @@ -363,6 +368,10 @@ Changes in existing checks
<clang-tidy/checks/readability/const-return-type>` check to eliminate false
positives when returning types with const not at the top level.

- Improved :doc:`readability-container-size-empty
<clang-tidy/checks/readability/container-size-empty>` check to prevent false
positives when utilizing ``size`` or ``length`` methods that accept parameter.

- Improved :doc:`readability-duplicate-include
<clang-tidy/checks/readability/duplicate-include>` check by excluding include
directives that form the filename using macro.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -861,3 +861,31 @@ namespace PR72619 {
if (0 >= s.size()) {}
}
}

namespace PR88203 {
struct SS {
bool empty() const;
int size() const;
int length(int) const;
};

struct SU {
bool empty() const;
int size(int) const;
int length() const;
};

void f(const SS& s) {
if (0 == s.length(1)) {}
if (0 == s.size()) {}
// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: the 'empty' method should be used to check for emptiness instead of 'size' [readability-container-size-empty]
// CHECK-FIXES: {{^ }}if (s.empty()) {}{{$}}
}

void f(const SU& s) {
if (0 == s.size(1)) {}
if (0 == s.length()) {}
// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: the 'empty' method should be used to check for emptiness instead of 'length' [readability-container-size-empty]
// CHECK-FIXES: {{^ }}if (s.empty()) {}{{$}}
}
}
2 changes: 1 addition & 1 deletion clang/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ on the Clang forums:
https://discourse.llvm.org/c/clang/

If you find a bug in Clang, please file it in the LLVM bug tracker:
http://llvm.org/bugs/
https://github.com/llvm/llvm-project/issues
17 changes: 17 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ ABI Changes in This Version
AST Dumping Potentially Breaking Changes
----------------------------------------

- The text ast-dumper has improved printing of TemplateArguments.

Clang Frontend Potentially Breaking Changes
-------------------------------------------
- Removed support for constructing on-stack ``TemplateArgumentList``\ s; interfaces should instead
Expand Down Expand Up @@ -249,6 +251,9 @@ Resolutions to C++ Defect Reports
- P0522 implementation is enabled by default in all language versions, and
provisional wording for CWG2398 is implemented.

- Clang now requires a template argument list after a template keyword.
(`CWG96: Syntactic disambiguation using the template keyword <https://cplusplus.github.io/CWG/issues/96.html>`_).

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

Expand Down Expand Up @@ -318,6 +323,9 @@ Non-comprehensive list of changes in this release
- Builtins ``__builtin_shufflevector()`` and ``__builtin_convertvector()`` may
now be used within constant expressions.

- ``#pragma GCC diagnostic warning "-Wfoo"`` can now downgrade ``-Werror=foo``
errors and certain default-to-error ``-W`` diagnostics to warnings.

New Compiler Flags
------------------
- ``-fsanitize=implicit-bitfield-conversion`` checks implicit truncation and
Expand Down Expand Up @@ -810,12 +818,21 @@ Bug Fixes to C++ Support
- Clang now diagnoses unexpanded parameter packs in attributes. (Fixes #GH93269).
- Clang now allows ``@$``` in raw string literals. Fixes (#GH93130).
- Fix an assertion failure when checking invalid ``this`` usage in the wrong context. (Fixes #GH91536).
- Clang no longer models dependent NTTP arguments as ``TemplateParamObjectDecl`` s. Fixes (#GH84052).
- Fix incorrect merging of modules which contain using declarations which shadow
other declarations. This could manifest as ODR checker false positives.
Fixes (`#80252 <https://github.com/llvm/llvm-project/issues/80252>`_)
- Fix a regression introduced in Clang 18 causing incorrect overload resolution in the presence of functions only
differering by their constraints when only one of these function was variadic.
- Fix a crash when a variable is captured by a block nested inside a lambda. (Fixes #GH93625).

Bug Fixes to AST Handling
^^^^^^^^^^^^^^^^^^^^^^^^^
- Clang now properly preserves ``FoundDecls`` within a ``ConceptReference``. (#GH82628)
- The presence of the ``typename`` keyword is now stored in ``TemplateTemplateParmDecl``.
- Fixed malformed AST generated for anonymous union access in templates. (#GH90842)
- Improved preservation of qualifiers and sugar in `TemplateNames`, including
template keyword.

Miscellaneous Bug Fixes
^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
6 changes: 3 additions & 3 deletions clang/docs/UsersManual.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4430,9 +4430,9 @@ To generate SPIR-V binaries, Clang uses the external ``llvm-spirv`` tool from th
Prior to the generation of SPIR-V binary with Clang, ``llvm-spirv``
should be built or installed. Please refer to `the following instructions
<https://github.com/KhronosGroup/SPIRV-LLVM-Translator#build-instructions>`_
for more details. Clang will expect the ``llvm-spirv`` executable to
be present in the ``PATH`` environment variable. Clang uses ``llvm-spirv``
with `the widely adopted assembly syntax package
for more details. Clang will look for ``llvm-spirv-<LLVM-major-version>`` and
``llvm-spirv`` executables, in this order, in the ``PATH`` environment variable.
Clang uses ``llvm-spirv`` with `the widely adopted assembly syntax package
<https://github.com/KhronosGroup/SPIRV-LLVM-Translator/#build-with-spirv-tools>`_.

`The versioning
Expand Down
41 changes: 33 additions & 8 deletions clang/docs/analyzer/checkers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3135,17 +3135,42 @@ alpha.unix
alpha.unix.BlockInCriticalSection (C)
"""""""""""""""""""""""""""""""""""""
Check for calls to blocking functions inside a critical section.
Applies to: ``lock, unlock, sleep, getc, fgets, read, recv, pthread_mutex_lock,``
`` pthread_mutex_unlock, mtx_lock, mtx_timedlock, mtx_trylock, mtx_unlock, lock_guard, unique_lock``
Blocking functions detected by this checker: ``sleep, getc, fgets, read, recv``.
Critical section handling functions modelled by this checker: ``lock, unlock, pthread_mutex_lock, pthread_mutex_trylock, pthread_mutex_unlock, mtx_lock, mtx_timedlock, mtx_trylock, mtx_unlock, lock_guard, unique_lock``.

.. code-block:: c

void test() {
std::mutex m;
m.lock();
sleep(3); // warn: a blocking function sleep is called inside a critical
// section
m.unlock();
void pthread_lock_example(pthread_mutex_t *m) {
pthread_mutex_lock(m); // note: entering critical section here
sleep(10); // warn: Call to blocking function 'sleep' inside of critical section
pthread_mutex_unlock(m);
}

.. code-block:: cpp

void overlapping_critical_sections(mtx_t *m1, std::mutex &m2) {
std::lock_guard lg{m2}; // note: entering critical section here
mtx_lock(m1); // note: entering critical section here
sleep(10); // warn: Call to blocking function 'sleep' inside of critical section
mtx_unlock(m1);
sleep(10); // warn: Call to blocking function 'sleep' inside of critical section
// still inside of the critical section of the std::lock_guard
}

**Limitations**

* The ``trylock`` and ``timedlock`` versions of acquiring locks are currently assumed to always succeed.
This can lead to false positives.

.. code-block:: c

void trylock_example(pthread_mutex_t *m) {
if (pthread_mutex_trylock(m) == 0) { // assume trylock always succeeds
sleep(10); // warn: Call to blocking function 'sleep' inside of critical section
pthread_mutex_unlock(m);
} else {
sleep(10); // false positive: Incorrect warning about blocking function inside critical section.
}
}

.. _alpha-unix-Chroot:
Expand Down
10 changes: 7 additions & 3 deletions clang/include/clang/AST/RecursiveASTVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -855,10 +855,14 @@ bool RecursiveASTVisitor<Derived>::TraverseDeclarationNameInfo(

template <typename Derived>
bool RecursiveASTVisitor<Derived>::TraverseTemplateName(TemplateName Template) {
if (DependentTemplateName *DTN = Template.getAsDependentTemplateName())
if (DependentTemplateName *DTN = Template.getAsDependentTemplateName()) {
TRY_TO(TraverseNestedNameSpecifier(DTN->getQualifier()));
else if (QualifiedTemplateName *QTN = Template.getAsQualifiedTemplateName())
TRY_TO(TraverseNestedNameSpecifier(QTN->getQualifier()));
} else if (QualifiedTemplateName *QTN =
Template.getAsQualifiedTemplateName()) {
if (QTN->getQualifier()) {
TRY_TO(TraverseNestedNameSpecifier(QTN->getQualifier()));
}
}

return true;
}
Expand Down
23 changes: 14 additions & 9 deletions clang/include/clang/AST/TemplateName.h
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ class TemplateName {
/// unexpanded parameter pack (for C++0x variadic templates).
bool containsUnexpandedParameterPack() const;

enum class Qualified { None, AsWritten, Fully };
enum class Qualified { None, AsWritten };
/// Print the template name.
///
/// \param OS the output stream to which the template name will be
Expand Down Expand Up @@ -360,6 +360,10 @@ class TemplateName {
static TemplateName getFromVoidPointer(void *Ptr) {
return TemplateName(Ptr);
}

/// Structural equality.
bool operator==(TemplateName Other) const { return Storage == Other.Storage; }
bool operator!=(TemplateName Other) const { return !operator==(Other); }
};

/// Insertion operator for diagnostics. This allows sending TemplateName's
Expand Down Expand Up @@ -417,17 +421,18 @@ inline TemplateName TemplateName::getUnderlying() const {
return *this;
}

/// Represents a template name that was expressed as a
/// qualified name.
/// Represents a template name as written in source code.
///
/// This kind of template name refers to a template name that was
/// This kind of template name may refer to a template name that was
/// preceded by a nested name specifier, e.g., \c std::vector. Here,
/// the nested name specifier is "std::" and the template name is the
/// declaration for "vector". The QualifiedTemplateName class is only
/// used to provide "sugar" for template names that were expressed
/// with a qualified name, and has no semantic meaning. In this
/// manner, it is to TemplateName what ElaboratedType is to Type,
/// providing extra syntactic sugar for downstream clients.
/// declaration for "vector". It may also have been written with the
/// 'template' keyword. The QualifiedTemplateName class is only
/// used to provide "sugar" for template names, so that they can
/// be differentiated from canonical template names. and has no
/// semantic meaning. In this manner, it is to TemplateName what
/// ElaboratedType is to Type, providing extra syntactic sugar
/// for downstream clients.
class QualifiedTemplateName : public llvm::FoldingSetNode {
friend class ASTContext;

Expand Down
3 changes: 3 additions & 0 deletions clang/include/clang/AST/TextNodeDumper.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@ class TextNodeDumper
void dumpTemplateSpecializationKind(TemplateSpecializationKind TSK);
void dumpNestedNameSpecifier(const NestedNameSpecifier *NNS);
void dumpConceptReference(const ConceptReference *R);
void dumpTemplateArgument(const TemplateArgument &TA);
void dumpBareTemplateName(TemplateName TN);
void dumpTemplateName(TemplateName TN, StringRef Label = {});

void dumpDeclRef(const Decl *D, StringRef Label = {});

Expand Down
Loading