Skip to content

Commit

Permalink
merge internal development externally
Browse files Browse the repository at this point in the history
  • Loading branch information
searlmc1 committed May 14, 2024
2 parents c7809cf + 55d3b6d commit 082b063
Show file tree
Hide file tree
Showing 15 changed files with 22 additions and 314 deletions.
81 changes: 0 additions & 81 deletions llvm/docs/TestingGuide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -433,87 +433,6 @@ actually participate in the test besides holding the ``RUN:`` lines.
putting the extra files in an ``Inputs/`` directory. This pattern is
deprecated.

Elaborated tests
----------------

Generally, IR and assembly test files benefit from being cleaned to remove
unnecessary details. However, for tests requiring elaborate IR or assembly
files where cleanup is less practical (e.g., large amount of debug information
output from Clang), you can include generation instructions within
``split-file`` part called ``gen``. Then, run
``llvm/utils/update_test_body.py`` on the test file to generate the needed
content.

.. code-block:: none
; RUN: rm -rf %t && split-file %s %t && cd %t
; RUN: opt -S a.ll ... | FileCheck %s
; CHECK: hello
;--- a.cc
int va;
;--- gen
clang --target=x86_64-linux -S -emit-llvm -g a.cc -o -
;--- a.ll
# content generated by the script 'gen'
.. code-block:: bash
PATH=/path/to/clang_build/bin:$PATH llvm/utils/update_test_body.py path/to/test.ll
The script will prepare extra files with ``split-file``, invoke ``gen``, and
then rewrite the part after ``gen`` with its stdout.

For convenience, if the test needs one single assembly file, you can also wrap
``gen`` and its required files with ``.ifdef`` and ``.endif``. Then you can
skip ``split-file`` in RUN lines.

.. code-block:: none
# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o a.o
# RUN: ... | FileCheck %s
# CHECK: hello
.ifdef GEN
#--- a.cc
int va;
#--- gen
clang --target=x86_64-linux -S -g a.cc -o -
.endif
# content generated by the script 'gen'
.. note::

Consider specifying an explicit target triple to avoid differences when
regeneration is needed on another machine.

``gen`` is invoked with ``PWD`` set to ``/proc/self/cwd``. Clang commands
don't need ``-fdebug-compilation-dir=`` since its default value is ``PWD``.

Check prefixes should be placed before ``.endif`` since the part after
``.endif`` is replaced.

If the test body contains multiple files, you can print ``---`` separators and
utilize ``split-file`` in ``RUN`` lines.

.. code-block:: none
# RUN: rm -rf %t && split-file %s %t && cd %t
...
#--- a.cc
int va;
#--- b.cc
int vb;
#--- gen
clang --target=x86_64-linux -S -O1 -g a.cc -o -
echo '#--- b.s'
clang --target=x86_64-linux -S -O1 -g b.cc -o -
#--- a.s
Fragile tests
-------------

Expand Down
7 changes: 1 addition & 6 deletions llvm/test/tools/UpdateTestChecks/lit.local.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ def add_update_script_substition(
# Specify an explicit default version in UTC tests, so that the --version
# embedded in UTC_ARGS does not change in all test expectations every time
# the default is bumped.
if name != "%update_test_body":
extra_args += " --version=1"
extra_args += " --version=1"
config.substitutions.append(
(name, "'%s' %s %s" % (python_exe, script_path, extra_args))
)
Expand Down Expand Up @@ -48,7 +47,3 @@ if os.path.isfile(llvm_mca_path):
config.available_features.add("llvm-mca-binary")
mca_arg = "--llvm-mca-binary " + shell_quote(llvm_mca_path)
add_update_script_substition("%update_test_checks", extra_args=mca_arg)

split_file_path = os.path.join(config.llvm_tools_dir, "split-file")
if os.path.isfile(split_file_path):
add_update_script_substition("%update_test_body")

This file was deleted.

This file was deleted.

11 changes: 0 additions & 11 deletions llvm/test/tools/UpdateTestChecks/update_test_body/basic-asm.test

This file was deleted.

13 changes: 0 additions & 13 deletions llvm/test/tools/UpdateTestChecks/update_test_body/basic.test

This file was deleted.

This file was deleted.

This file was deleted.

11 changes: 0 additions & 11 deletions llvm/test/tools/UpdateTestChecks/update_test_body/gen-fail.test

This file was deleted.

This file was deleted.

This file was deleted.

26 changes: 12 additions & 14 deletions llvm/test/tools/llvm-dwarfdump/X86/formclass4.s
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
# Source:
# struct e {
# enum {} f[16384];
# short g;
# };
# e foo() {
# auto E = new e;
# return *E;
# }
# Compile with:
# clang -O2 -gdwarf-4 -S a.cpp -o a4.s

# RUN: llvm-mc %s -filetype obj -triple x86_64-apple-darwin -o %t.o
# RUN: llvm-dwarfdump -debug-info -name g %t.o | FileCheck %s

# CHECK: DW_TAG_member
# CHECK: DW_AT_name ("g")
# CHECK: DW_AT_data_member_location (0x4000)

.ifdef GEN
#--- a.cpp
struct e {
enum {} f[16384];
short g;
};
e foo() {
auto E = new e;
return *E;
}
#--- gen
clang --target=x86_64-apple-macosx -O2 -gdwarf-4 -S a.cpp -o -
.endif

.section __TEXT,__text,regular,pure_instructions
.macosx_version_min 10, 14
.globl __Z3foov ## -- Begin function _Z3foov
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# RUN: llvm-mc < %s -filetype obj -triple x86_64 -o - \
# RUN: | llvm-dwarfdump - | FileCheck %s

# Generated from:
#
# struct t1 { };
# t1 v1;
#
# $ clang++ -S -g -fdebug-types-section -gsplit-dwarf -o test.5.split.s -gdwarf-5 -g

# CHECK: DW_TAG_variable
# CHECK: DW_AT_type ({{.*}} "t1")

.ifdef GEN
#--- test.cpp
struct t1 { };
t1 v1;
#--- gen
clang++ --target=x86_64-linux -S -g -fdebug-types-section -gsplit-dwarf -gdwarf-5 test.cpp -o -
.endif
.text
.file "test.cpp"
.section .debug_types.dwo,"e",@progbits
Expand Down
110 changes: 0 additions & 110 deletions llvm/utils/update_test_body.py

This file was deleted.

2 changes: 2 additions & 0 deletions revert_patches.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,5 @@ Reverts: breaks oclConformance
SWDEV-460097
merges: revert : 41466a177a95 [SelectionDAG] Correct the implementation of m_AllOnes. (#90776)

Revert "[utils] Add script to generate elaborated IR and assembly tests (#89026)"
breaks 4 rhel lit tests

0 comments on commit 082b063

Please sign in to comment.