46 changes: 23 additions & 23 deletions bolt/test/X86/dynrelocs.s
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
# This reproduces a bug when rewriting dynamic relocations in X86 as
# BOLT incorrectly attributes R_X86_64_64 dynamic relocations
# to the wrong section when the -jump-tables=move flag is used. We
# expect the relocations to belong to the .bolt.org.rodata section but
# it is attributed to a new .rodata section that only contains jump
# table entries, created by BOLT. BOLT will only create this new .rodata
# section if both -jump-tables=move is used and a hot function with
# jt is present in the input binary, triggering a scenario where the
# dynamic relocs rewriting gets confused on where to put .rodata relocs.
## This reproduces a bug when rewriting dynamic relocations in X86 as
## BOLT incorrectly attributes R_X86_64_64 dynamic relocations
## to the wrong section when the -jump-tables=move flag is used. We
## expect the relocations to belong to the .bolt.org.rodata section but
## it is attributed to a new .rodata section that only contains jump
## table entries, created by BOLT. BOLT will only create this new .rodata
## section if both -jump-tables=move is used and a hot function with
## jt is present in the input binary, triggering a scenario where the
## dynamic relocs rewriting gets confused on where to put .rodata relocs.

# It is uncommon to end up with dynamic relocations against .rodata,
# but it can happen. In these cases we cannot corrupt the
# output binary by writing out dynamic relocs incorrectly. The linker
# avoids emitting relocs against read-only sections but we override
# this behavior with the -z notext flag. During runtime, these pages
# are mapped with write permission and then changed to read-only after
# the dynamic linker finishes processing the dynamic relocs.
## It is uncommon to end up with dynamic relocations against .rodata,
## but it can happen. In these cases we cannot corrupt the
## output binary by writing out dynamic relocs incorrectly. The linker
## avoids emitting relocs against read-only sections but we override
## this behavior with the -z notext flag. During runtime, these pages
## are mapped with write permission and then changed to read-only after
## the dynamic linker finishes processing the dynamic relocs.

# In this test, we create a reference to a dynamic object that will
# imply in R_X86_64_64 being used for .rodata. Now BOLT, when creating
# a new .rodata to hold jump table entries, needs to remember to emit
# these dynamic relocs against the original .rodata, and not the new
# one it just created.
## In this test, we create a reference to a dynamic object that will
## imply in R_X86_64_64 being used for .rodata. Now BOLT, when creating
## a new .rodata to hold jump table entries, needs to remember to emit
## these dynamic relocs against the original .rodata, and not the new
## one it just created.

# REQUIRES: system-linux

Expand All @@ -36,8 +36,8 @@
# RUN: -jump-tables=move
# RUN: llvm-readobj -rs %t.out | FileCheck --check-prefix=READOBJ %s

# Verify that BOLT outputs the dynamic reloc at the correct address,
# which is the start of the .bolt.org.rodata section.
## Verify that BOLT outputs the dynamic reloc at the correct address,
## which is the start of the .bolt.org.rodata section.
# READOBJ: Relocations [
# READOBJ: Section ([[#]]) .rela.dyn {
# READOBJ-NEXT: 0x[[#%X,ADDR:]] R_X86_64_64 bar 0x10
Expand Down
4 changes: 2 additions & 2 deletions bolt/test/X86/exceptions-args.test
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Check that we handle GNU_args_size correctly.
# It is generated for throwing functions with LP that have parameters on stack.
## Check that we handle GNU_args_size correctly.
## It is generated for throwing functions with LP that have parameters on stack.

RUN: %clang %cflags %p/../Inputs/stub.c -fPIC -pie -shared -o %t.so
RUN: %clangxx %cxxflags -no-pie %p/Inputs/exc_args.s -o %t %t.so -Wl,-z,notext
Expand Down
14 changes: 7 additions & 7 deletions bolt/test/X86/fallthrough-to-noop.test
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Check that profile data for the fall-through jump is not ignored when there is
# a conditional jump followed by a no-op.
## Check that profile data for the fall-through jump is not ignored when there is
## a conditional jump followed by a no-op.

RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown \
RUN: %S/Inputs/ft_to_noop.s -o %t.o
Expand All @@ -13,11 +13,11 @@ CHECK: Binary Function "foo" after building cfg
CHECK: Exec Count : 20
CHECK: Profile Acc : 100.0%

# This block is terminated with a conditional jump to .Ltmp0 followed by a
# no-op. The profile data contains a count for the fall-through (3) which
# is different from what would be inferred (2). However the destination
# offset of this fall-through jump in the profile data points to the no-op
# following the jump and not the start of the fall-through block .LFT0.
## This block is terminated with a conditional jump to .Ltmp0 followed by a
## no-op. The profile data contains a count for the fall-through (3) which
## is different from what would be inferred (2). However the destination
## offset of this fall-through jump in the profile data points to the no-op
## following the jump and not the start of the fall-through block .LFT0.
CHECK: Entry Point
CHECK-NEXT: Exec Count : 20
CHECK: Successors: .Ltmp[[#BB1:]] (mispreds: 0, count: 18), .LFT[[#BB2:]] (mispreds: 0, count: 3)
Expand Down
4 changes: 2 additions & 2 deletions bolt/test/X86/false-jump-table.s
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Check that jump table detection does not fail on a false
# reference to a jump table.
## Check that jump table detection does not fail on a false
## reference to a jump table.

# REQUIRES: system-linux

Expand Down
6 changes: 3 additions & 3 deletions bolt/test/X86/fatal-error.s
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Tests whether llvm-bolt will correctly exit with error code and printing
# fatal error message in case one occurs. Here we test opening a function
# reordering file that does not exist.
## Tests whether llvm-bolt will correctly exit with error code and printing
## fatal error message in case one occurs. Here we test opening a function
## reordering file that does not exist.

# 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/fragment-lite-reverse.s
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Check that BOLT in lite mode processes fragments as expected.
## Check that BOLT in lite mode processes fragments as expected.

# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s -o %t.o
# RUN: link_fdata %s %t.o %t.fdata
Expand Down
2 changes: 1 addition & 1 deletion bolt/test/X86/fragment-lite.s
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Check that BOLT in lite mode processes fragments as expected.
## Check that BOLT in lite mode processes fragments as expected.

# RUN: split-file %s %t
# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %t/main.s -o %t.o
Expand Down
4 changes: 2 additions & 2 deletions bolt/test/X86/fragmented-symbols.s
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Checks that symbols are allocated in correct sections, and that empty
# fragments are not allocated at all.
## Checks that symbols are allocated in correct sections, and that empty
## fragments are not allocated at all.

# REQUIRES: x86_64-linux

Expand Down
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
8 changes: 4 additions & 4 deletions bolt/test/lsda-section-name.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
// disassembled by BOLT.

// RUN: %clang++ %cxxflags -O3 -no-pie -c %s -o %t.o
// RUN: %clang++ %cxxflags -no-pie -fuse-ld=lld %t.o -o %t.exe \
// RUN: -Wl,-q -Wl,--script=%S/Inputs/lsda.ldscript
// RUN: llvm-readelf -SW %t.exe | FileCheck %s
// RUN: llvm-bolt %t.exe -o %t.bolt
// RUN: %clang++ %cxxflags -O3 -no-pie -fuse-ld=lld %t.o -o %t
// RUN: llvm-objcopy --rename-section .gcc_except_table=.gcc_except_table.main %t
// RUN: llvm-readelf -SW %t | FileCheck %s
// RUN: llvm-bolt %t -o %t.bolt

// CHECK: .gcc_except_table.main

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
14 changes: 8 additions & 6 deletions clang-tools-extra/clang-tidy/modernize/UseStdFormatCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,15 @@ void UseStdFormatCheck::registerPPCallbacks(const SourceManager &SM,
}

void UseStdFormatCheck::registerMatchers(MatchFinder *Finder) {
auto CharPointerType =
hasType(pointerType(pointee(matchers::isSimpleChar())));
Finder->addMatcher(
callExpr(argumentCountAtLeast(1),
hasArgument(0, stringLiteral(isOrdinary())),
callee(functionDecl(unless(cxxMethodDecl()),
matchers::matchesAnyListedName(
StrFormatLikeFunctions))
.bind("func_decl")))
callExpr(
argumentCountAtLeast(1), hasArgument(0, stringLiteral(isOrdinary())),
callee(functionDecl(
unless(cxxMethodDecl()), hasParameter(0, CharPointerType),
matchers::matchesAnyListedName(StrFormatLikeFunctions))
.bind("func_decl")))
.bind("strformat"),
this);
}
Expand Down
4 changes: 4 additions & 0 deletions clang-tools-extra/clang-tidy/modernize/UseStdPrintCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,15 @@ unusedReturnValue(clang::ast_matchers::StatementMatcher MatchedCallExpr) {
}

void UseStdPrintCheck::registerMatchers(MatchFinder *Finder) {
auto CharPointerType =
hasType(pointerType(pointee(matchers::isSimpleChar())));
if (!PrintfLikeFunctions.empty())
Finder->addMatcher(
unusedReturnValue(
callExpr(argumentCountAtLeast(1),
hasArgument(0, stringLiteral(isOrdinary())),
callee(functionDecl(unless(cxxMethodDecl()),
hasParameter(0, CharPointerType),
matchers::matchesAnyListedName(
PrintfLikeFunctions))
.bind("func_decl")))
Expand All @@ -113,6 +116,7 @@ void UseStdPrintCheck::registerMatchers(MatchFinder *Finder) {
callExpr(argumentCountAtLeast(2),
hasArgument(1, stringLiteral(isOrdinary())),
callee(functionDecl(unless(cxxMethodDecl()),
hasParameter(1, CharPointerType),
matchers::matchesAnyListedName(
FprintfLikeFunctions))
.bind("func_decl")))
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
8 changes: 5 additions & 3 deletions clang-tools-extra/clang-tidy/utils/FormatStringConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,11 @@ FormatStringConverter::FormatStringConverter(ASTContext *ContextIn,
assert(ArgsOffset <= NumArgs);
FormatExpr = llvm::dyn_cast<StringLiteral>(
Args[FormatArgOffset]->IgnoreImplicitAsWritten());
assert(FormatExpr);
if (!FormatExpr->isOrdinary())
return; // No wide string support yet
if (!FormatExpr || !FormatExpr->isOrdinary()) {
// Function must have a narrow string literal as its first argument.
conversionNotPossible("first argument is not a narrow string literal");
return;
}
PrintfFormatString = FormatExpr->getString();

// Assume that the output will be approximately the same size as the input,
Expand Down
8 changes: 8 additions & 0 deletions clang-tools-extra/clang-tidy/utils/Matchers.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ AST_MATCHER_FUNCTION(ast_matchers::TypeMatcher, isPointerToConst) {
return pointerType(pointee(qualType(isConstQualified())));
}

// Returns QualType matcher for target char type only.
AST_MATCHER(QualType, isSimpleChar) {
const auto ActualType = Node.getTypePtr();
return ActualType &&
(ActualType->isSpecificBuiltinType(BuiltinType::Char_S) ||
ActualType->isSpecificBuiltinType(BuiltinType::Char_U));
}

AST_MATCHER(Expr, hasUnevaluatedContext) {
if (isa<CXXNoexceptExpr>(Node) || isa<RequiresExpr>(Node))
return true;
Expand Down
150 changes: 93 additions & 57 deletions clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,11 @@ deleteTokensWithKind(const syntax::TokenBuffer &TokBuf, tok::TokenKind Kind,
// looked up in the context containing the function/method.
// FIXME: Drop attributes in function signature.
llvm::Expected<std::string>
getFunctionSourceCode(const FunctionDecl *FD, llvm::StringRef TargetNamespace,
getFunctionSourceCode(const FunctionDecl *FD, const DeclContext *TargetContext,
const syntax::TokenBuffer &TokBuf,
const HeuristicResolver *Resolver) {
auto &AST = FD->getASTContext();
auto &SM = AST.getSourceManager();
auto TargetContext = findContextForNS(TargetNamespace, FD->getDeclContext());
if (!TargetContext)
return error("define outline: couldn't find a context for target");

llvm::Error Errors = llvm::Error::success();
tooling::Replacements DeclarationCleanups;
Expand Down Expand Up @@ -216,7 +213,7 @@ getFunctionSourceCode(const FunctionDecl *FD, llvm::StringRef TargetNamespace,
}
const NamedDecl *ND = Ref.Targets.front();
const std::string Qualifier =
getQualification(AST, *TargetContext,
getQualification(AST, TargetContext,
SM.getLocForStartOfFile(SM.getMainFileID()), ND);
if (auto Err = DeclarationCleanups.add(
tooling::Replacement(SM, Ref.NameLoc, 0, Qualifier)))
Expand All @@ -232,7 +229,7 @@ getFunctionSourceCode(const FunctionDecl *FD, llvm::StringRef TargetNamespace,
if (const auto *Destructor = llvm::dyn_cast<CXXDestructorDecl>(FD)) {
if (auto Err = DeclarationCleanups.add(tooling::Replacement(
SM, Destructor->getLocation(), 0,
getQualification(AST, *TargetContext,
getQualification(AST, TargetContext,
SM.getLocForStartOfFile(SM.getMainFileID()),
Destructor))))
Errors = llvm::joinErrors(std::move(Errors), std::move(Err));
Expand Down Expand Up @@ -319,29 +316,9 @@ getFunctionSourceCode(const FunctionDecl *FD, llvm::StringRef TargetNamespace,
}

struct InsertionPoint {
std::string EnclosingNamespace;
const DeclContext *EnclosingNamespace = nullptr;
size_t Offset;
};
// Returns the most natural insertion point for \p QualifiedName in \p Contents.
// This currently cares about only the namespace proximity, but in feature it
// should also try to follow ordering of declarations. For example, if decls
// come in order `foo, bar, baz` then this function should return some point
// between foo and baz for inserting bar.
llvm::Expected<InsertionPoint> getInsertionPoint(llvm::StringRef Contents,
llvm::StringRef QualifiedName,
const LangOptions &LangOpts) {
auto Region = getEligiblePoints(Contents, QualifiedName, LangOpts);

assert(!Region.EligiblePoints.empty());
// FIXME: This selection can be made smarter by looking at the definition
// locations for adjacent decls to Source. Unfortunately pseudo parsing in
// getEligibleRegions only knows about namespace begin/end events so we
// can't match function start/end positions yet.
auto Offset = positionToOffset(Contents, Region.EligiblePoints.back());
if (!Offset)
return Offset.takeError();
return InsertionPoint{Region.EnclosingNamespace, *Offset};
}

// Returns the range that should be deleted from declaration, which always
// contains function body. In addition to that it might contain constructor
Expand Down Expand Up @@ -409,14 +386,9 @@ class DefineOutline : public Tweak {
}

bool prepare(const Selection &Sel) override {
// Bail out if we are not in a header file.
// FIXME: We might want to consider moving method definitions below class
// definition even if we are inside a source file.
if (!isHeaderFile(Sel.AST->getSourceManager().getFilename(Sel.Cursor),
Sel.AST->getLangOpts()))
return false;

SameFile = !isHeaderFile(Sel.AST->tuPath(), Sel.AST->getLangOpts());
Source = getSelectedFunction(Sel.ASTSelection.commonAncestor());

// Bail out if the selection is not a in-line function definition.
if (!Source || !Source->doesThisDeclarationHaveABody() ||
Source->isOutOfLine())
Expand All @@ -429,19 +401,24 @@ class DefineOutline : public Tweak {
if (Source->getTemplateSpecializationInfo())
return false;

if (auto *MD = llvm::dyn_cast<CXXMethodDecl>(Source)) {
// Bail out in templated classes, as it is hard to spell the class name,
// i.e if the template parameter is unnamed.
if (MD->getParent()->isTemplated())
return false;

// The refactoring is meaningless for unnamed classes and definitions
// within unnamed namespaces.
for (const DeclContext *DC = MD->getParent(); DC; DC = DC->getParent()) {
if (auto *ND = llvm::dyn_cast<NamedDecl>(DC)) {
if (ND->getDeclName().isEmpty())
return false;
}
auto *MD = llvm::dyn_cast<CXXMethodDecl>(Source);
if (!MD) {
// Can't outline free-standing functions in the same file.
return !SameFile;
}

// Bail out in templated classes, as it is hard to spell the class name,
// i.e if the template parameter is unnamed.
if (MD->getParent()->isTemplated())
return false;

// The refactoring is meaningless for unnamed classes and namespaces,
// unless we're outlining in the same file
for (const DeclContext *DC = MD->getParent(); DC; DC = DC->getParent()) {
if (auto *ND = llvm::dyn_cast<NamedDecl>(DC)) {
if (ND->getDeclName().isEmpty() &&
(!SameFile || !llvm::dyn_cast<NamespaceDecl>(ND)))
return false;
}
}

Expand All @@ -453,8 +430,8 @@ class DefineOutline : public Tweak {

Expected<Effect> apply(const Selection &Sel) override {
const SourceManager &SM = Sel.AST->getSourceManager();
auto CCFile = getSourceFile(Sel.AST->tuPath(), Sel);

auto CCFile = SameFile ? Sel.AST->tuPath().str()
: getSourceFile(Sel.AST->tuPath(), Sel);
if (!CCFile)
return error("Couldn't find a suitable implementation file.");
assert(Sel.FS && "FS Must be set in apply");
Expand All @@ -464,8 +441,7 @@ class DefineOutline : public Tweak {
if (!Buffer)
return llvm::errorCodeToError(Buffer.getError());
auto Contents = Buffer->get()->getBuffer();
auto InsertionPoint = getInsertionPoint(
Contents, Source->getQualifiedNameAsString(), Sel.AST->getLangOpts());
auto InsertionPoint = getInsertionPoint(Contents, Sel);
if (!InsertionPoint)
return InsertionPoint.takeError();

Expand Down Expand Up @@ -499,17 +475,77 @@ class DefineOutline : public Tweak {
HeaderUpdates = HeaderUpdates.merge(*DelInline);
}

auto HeaderFE = Effect::fileEdit(SM, SM.getMainFileID(), HeaderUpdates);
if (!HeaderFE)
return HeaderFE.takeError();

Effect->ApplyEdits.try_emplace(HeaderFE->first,
std::move(HeaderFE->second));
if (SameFile) {
tooling::Replacements &R = Effect->ApplyEdits[*CCFile].Replacements;
R = R.merge(HeaderUpdates);
} else {
auto HeaderFE = Effect::fileEdit(SM, SM.getMainFileID(), HeaderUpdates);
if (!HeaderFE)
return HeaderFE.takeError();
Effect->ApplyEdits.try_emplace(HeaderFE->first,
std::move(HeaderFE->second));
}
return std::move(*Effect);
}

// Returns the most natural insertion point for \p QualifiedName in \p
// Contents. This currently cares about only the namespace proximity, but in
// feature it should also try to follow ordering of declarations. For example,
// if decls come in order `foo, bar, baz` then this function should return
// some point between foo and baz for inserting bar.
// FIXME: The selection can be made smarter by looking at the definition
// locations for adjacent decls to Source. Unfortunately pseudo parsing in
// getEligibleRegions only knows about namespace begin/end events so we
// can't match function start/end positions yet.
llvm::Expected<InsertionPoint> getInsertionPoint(llvm::StringRef Contents,
const Selection &Sel) {
// If the definition goes to the same file and there is a namespace,
// we should (and, in the case of anonymous namespaces, need to)
// put the definition into the original namespace block.
if (SameFile) {
auto *Klass = Source->getDeclContext()->getOuterLexicalRecordContext();
if (!Klass)
return error("moving to same file not supported for free functions");
const SourceLocation EndLoc = Klass->getBraceRange().getEnd();
const auto &TokBuf = Sel.AST->getTokens();
auto Tokens = TokBuf.expandedTokens();
auto It = llvm::lower_bound(
Tokens, EndLoc, [](const syntax::Token &Tok, SourceLocation EndLoc) {
return Tok.location() < EndLoc;
});
while (It != Tokens.end()) {
if (It->kind() != tok::semi) {
++It;
continue;
}
unsigned Offset = Sel.AST->getSourceManager()
.getDecomposedLoc(It->endLocation())
.second;
return InsertionPoint{Klass->getEnclosingNamespaceContext(), Offset};
}
return error(
"failed to determine insertion location: no end of class found");
}

auto Region = getEligiblePoints(
Contents, Source->getQualifiedNameAsString(), Sel.AST->getLangOpts());

assert(!Region.EligiblePoints.empty());
auto Offset = positionToOffset(Contents, Region.EligiblePoints.back());
if (!Offset)
return Offset.takeError();

auto TargetContext =
findContextForNS(Region.EnclosingNamespace, Source->getDeclContext());
if (!TargetContext)
return error("define outline: couldn't find a context for target");

return InsertionPoint{*TargetContext, *Offset};
}

private:
const FunctionDecl *Source = nullptr;
bool SameFile = false;
};

REGISTER_TWEAK(DefineOutline)
Expand Down
10 changes: 7 additions & 3 deletions clang-tools-extra/clangd/unittests/ReplayPeambleTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include "clang/AST/DeclTemplate.h"
#include "clang/Basic/FileEntry.h"
#include "clang/Basic/LLVM.h"
#include "clang/Basic/Module.h"
#include "clang/Basic/SourceLocation.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/TokenKinds.h"
Expand All @@ -42,7 +41,11 @@
#include <memory>
#include <vector>

namespace clang::clangd {
namespace clang {

class Module;

namespace clangd {
namespace {
struct Inclusion {
Inclusion(const SourceManager &SM, SourceLocation HashLoc,
Expand Down Expand Up @@ -170,4 +173,5 @@ TEST(ReplayPreambleTest, IncludesAndSkippedFiles) {
}
}
} // namespace
} // namespace clang::clangd
} // namespace clangd
} // namespace clang
73 changes: 71 additions & 2 deletions clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,47 @@ TWEAK_TEST(DefineOutline);

TEST_F(DefineOutlineTest, TriggersOnFunctionDecl) {
FileName = "Test.cpp";
// Not available unless in a header file.
// Not available for free function unless in a header file.
EXPECT_UNAVAILABLE(R"cpp(
[[void [[f^o^o]]() [[{
return;
}]]]])cpp");

// Available in soure file.
EXPECT_AVAILABLE(R"cpp(
struct Foo {
void f^oo() {}
};
)cpp");

// Available within named namespace in source file.
EXPECT_AVAILABLE(R"cpp(
namespace N {
struct Foo {
void f^oo() {}
};
} // namespace N
)cpp");

// Available within anonymous namespace in source file.
EXPECT_AVAILABLE(R"cpp(
namespace {
struct Foo {
void f^oo() {}
};
} // namespace
)cpp");

// Not available for out-of-line method.
EXPECT_UNAVAILABLE(R"cpp(
class Bar {
void baz();
};

[[void [[Bar::[[b^a^z]]]]() [[{
return;
}]]]])cpp");

FileName = "Test.hpp";
// Not available unless function name or fully body is selected.
EXPECT_UNAVAILABLE(R"cpp(
Expand Down Expand Up @@ -100,7 +135,7 @@ TEST_F(DefineOutlineTest, TriggersOnFunctionDecl) {
};
)cpp");

// Not available on definitions within unnamed namespaces
// Not available on definitions in header file within unnamed namespaces
EXPECT_UNAVAILABLE(R"cpp(
namespace {
struct Foo {
Expand Down Expand Up @@ -349,6 +384,40 @@ TEST_F(DefineOutlineTest, ApplyTest) {
}
}

TEST_F(DefineOutlineTest, InCppFile) {
FileName = "Test.cpp";

struct {
llvm::StringRef Test;
llvm::StringRef ExpectedSource;
} Cases[] = {
{
R"cpp(
namespace foo {
namespace {
struct Foo { void ba^r() {} };
struct Bar { void foo(); };
void Bar::foo() {}
}
}
)cpp",
R"cpp(
namespace foo {
namespace {
struct Foo { void bar() ; };void Foo::bar() {}
struct Bar { void foo(); };
void Bar::foo() {}
}
}
)cpp"},
};

for (const auto &Case : Cases) {
SCOPED_TRACE(Case.Test);
EXPECT_EQ(apply(Case.Test, nullptr), Case.ExpectedSource);
}
}

TEST_F(DefineOutlineTest, HandleMacros) {
llvm::StringMap<std::string> EditedFiles;
ExtraFiles["Test.cpp"] = "";
Expand Down
Loading