1. [libc] Add [l|ll]abs implementation. (details)
  2. [CSSPGO] Pseudo probe encoding and emission. (details)
  3. [gn build] Port 705a4c149d8 (details)
  4. [WebAssembly][lld] Exclude COMDAT sections (details)
  5. [lld-macho] Don't include absolute address value in expected test output (details)
  6. [lld-macho] Disable some tests that are failing on Windows (details)
  7. Tooling: Migrate some tests to FileEntryRef, NFC (details)
  8. [libomptarget][nfc] Remove data_sharing type aliasing (details)
Commit 1fd32dcb294e16781fcfcf1a468180d00cf1e3ca by chennngwang
[libc] Add [l|ll]abs implementation.

Implement abs, labs and llabs with template.

Reviewed By: sivachandra

Differential Revision:
The file was addedlibc/src/stdlib/abs.cpp
The file was modifiedlibc/spec/
The file was addedlibc/test/src/stdlib/abs_test.cpp
The file was modifiedlibc/config/linux/x86_64/entrypoints.txt
The file was modifiedlibc/src/stdlib/CMakeLists.txt
The file was addedlibc/src/stdlib/llabs.h
The file was addedlibc/src/stdlib/labs.cpp
The file was addedlibc/src/stdlib/abs.h
The file was modifiedlibc/spec/
The file was addedlibc/test/src/stdlib/llabs_test.cpp
The file was addedlibc/test/src/stdlib/labs_test.cpp
The file was addedlibc/src/stdlib/abs_utils.h
The file was addedlibc/src/stdlib/labs.h
The file was addedlibc/src/stdlib/llabs.cpp
The file was modifiedlibc/test/src/stdlib/CMakeLists.txt
The file was modifiedlibc/config/linux/aarch64/entrypoints.txt
Commit 705a4c149d8a3a414c6684a2c01ebbdcb98ccc21 by hoy
[CSSPGO] Pseudo probe encoding and emission.

This change implements pseudo probe encoding and emission for CSSPGO. Please see RFC here for more context:

Pseudo probes are in the form of intrinsic calls on IR/MIR but they do not turn into any machine instructions. Instead they are emitted into the binary as a piece of data in standalone sections.  The probe-specific sections are not needed to be loaded into memory at execution time, thus they do not incur a runtime overhead. 

**ELF object emission**

The binary data to emit are organized as two ELF sections, i.e, the `.pseudo_probe_desc` section and the `.pseudo_probe` section. The `.pseudo_probe_desc` section stores a function descriptor for each function and the `.pseudo_probe` section stores the actual probes, each fo which corresponds to an IR basic block or an IR function callsite. A function descriptor is stored as a module-level metadata during the compilation and is serialized into the object file during object emission.

Both the probe descriptors and pseudo probes can be emitted into a separate ELF section per function to leverage the linker for deduplication.  A `.pseudo_probe` section shares the same COMDAT group with the function code so that when the function is dead, the probes are dead and disposed too. On the contrary, a `.pseudo_probe_desc` section has its own COMDAT group. This is because even if a function is dead, its probes may be inlined into other functions and its descriptor is still needed by the profile generation tool.

The format of `.pseudo_probe_desc` section looks like:

.section   .pseudo_probe_desc,"",@progbits
.quad   6309742469962978389  // Func GUID
.quad   4294967295           // Func Hash
.byte   9                    // Length of func name
.ascii  "_Z5funcAi"          // Func name
.quad   7102633082150537521
.quad   138828622701
.byte   12
.ascii  "_Z8funcLeafi"
.quad   446061515086924981
.quad   4294967295
.byte   9
.ascii  "_Z5funcBi"
.quad   -2016976694713209516
.quad   72617220756
.byte   7
.ascii  "_Z3fibi"

For each `.pseudoprobe` section, the encoded binary data consists of a single function record corresponding to an outlined function (i.e, a function with a code entry in the `.text` section). A function record has the following format :

FUNCTION BODY (one for each outlined function present in the text section)
    GUID (uint64)
        GUID of the function
        Number of probes originating from this function.
        Number of callees inlined into this function, aka number of
        first-level inlinees
        A list of NPROBES entries. Each entry contains:
          INDEX (ULEB128)
          TYPE (uint4)
            0 - block probe, 1 - indirect call, 2 - direct call
          ATTRIBUTE (uint3)
          ADDRESS_TYPE (uint1)
            0 - code address, 1 - address delta
          CODE_ADDRESS (uint64 or ULEB128)
            code address or address delta, depending on ADDRESS_TYPE
        A list of NUM_INLINED_FUNCTIONS entries describing each of the inlined
        callees.  Each record contains:
          INLINE SITE
            GUID of the inlinee (uint64)
            ID of the callsite probe (ULEB128)
            A FUNCTION BODY entry describing the inlined function.

To support building a context-sensitive profile, probes from inlinees are grouped by their inline contexts. An inline context is logically a call path through which a callee function lands in a caller function. The probe emitter builds an inline tree based on the debug metadata for each outlined function in the form of a trie tree. A tree root is the outlined function. Each tree edge stands for a callsite where inlining happens. Pseudo probes originating from an inlinee function are stored in a tree node and the tree path starting from the root all the way down to the tree node is the inline context of the probes. The emission happens on the whole tree top-down recursively. Probes of a tree node will be emitted altogether with their direct parent edge. Since a pseudo probe corresponds to a real code address, for size savings, the address is encoded as a delta from the previous probe except for the first probe. Variant-sized integer encoding, aka LEB128, is used for address delta and probe index.


Pseudo probes can be printed as assembly directives alternatively. This allows for good assembly code readability and also provides a view of how optimizations and pseudo probes affect each other, especially helpful for diff time assembly analysis.

A pseudo probe directive has the following operands in order: function GUID, probe index, probe type, probe attributes and inline context. The directive is generated by the compiler and can be parsed by the assembler to form an encoded `.pseudoprobe` section in the object file.

A example assembly looks like:

foo2: # @foo2
# %bb.0: # %bb0
pushq %rax
testl %edi, %edi
.pseudoprobe 837061429793323041 1 0 0
je .LBB1_1
# %bb.2: # %bb2
.pseudoprobe 837061429793323041 6 2 0
callq foo
.pseudoprobe 837061429793323041 3 0 0
.pseudoprobe 837061429793323041 4 0 0
popq %rax
.LBB1_1: # %bb1
.pseudoprobe 837061429793323041 5 1 0
callq *%rsi
.pseudoprobe 837061429793323041 2 0 0
.pseudoprobe 837061429793323041 4 0 0
popq %rax
# -- End function
.section .pseudo_probe_desc,"",@progbits
.quad 6699318081062747564
.quad 72617220756
.byte 3
.ascii "foo"
.quad 837061429793323041
.quad 281547593931412
.byte 4
.ascii "foo2"

With inlining turned on, the assembly may look different around %bb2 with an inlined probe:

# %bb.2:                                # %bb2
.pseudoprobe    837061429793323041 3 0
.pseudoprobe    6699318081062747564 1 0 @ 837061429793323041:6
.pseudoprobe    837061429793323041 4 0
popq    %rax


We have a disassembling tool (llvm-profgen) that can display disassembly alongside with pseudo probes. So far it only supports ELF executable file.

An example disassembly looks like:

00000000002011a0 <foo2>:
  2011a0: 50                    push   rax
  2011a1: 85 ff                 test   edi,edi
  [Probe]:  FUNC: foo2  Index: 1  Type: Block
  2011a3: 74 02                 je     2011a7 <foo2+0x7>
  [Probe]:  FUNC: foo2  Index: 3  Type: Block
  [Probe]:  FUNC: foo2  Index: 4  Type: Block
  [Probe]:  FUNC: foo   Index: 1  Type: Block  Inlined: @ foo2:6
  2011a5: 58                    pop    rax
  2011a6: c3                    ret
  [Probe]:  FUNC: foo2  Index: 2  Type: Block
  2011a7: bf 01 00 00 00        mov    edi,0x1
  [Probe]:  FUNC: foo2  Index: 5  Type: IndirectCall
  2011ac: ff d6                 call   rsi
  [Probe]:  FUNC: foo2  Index: 4  Type: Block
  2011ae: 58                    pop    rax
  2011af: c3                    ret

Reviewed By: wmi

Differential Revision:
The file was modifiedllvm/lib/MC/MCStreamer.cpp
The file was addedllvm/lib/CodeGen/AsmPrinter/PseudoProbePrinter.h
The file was modifiedllvm/include/llvm/MC/MCFragment.h
The file was modifiedllvm/include/llvm/Transforms/IPO/SampleProfileProbe.h
The file was modifiedllvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
The file was modifiedllvm/lib/MC/MCParser/AsmParser.cpp
The file was modifiedllvm/include/llvm/IR/MDBuilder.h
The file was modifiedllvm/lib/CodeGen/AsmPrinter/CMakeLists.txt
The file was modifiedllvm/lib/MC/CMakeLists.txt
The file was addedllvm/lib/MC/MCPseudoProbe.cpp
The file was modifiedllvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
The file was modifiedllvm/lib/MC/MCFragment.cpp
The file was modifiedllvm/include/llvm/IR/PseudoProbe.h
The file was modifiedllvm/include/llvm/Passes/PassBuilder.h
The file was modifiedllvm/lib/MC/MCAssembler.cpp
The file was modifiedllvm/test/Transforms/SampleProfile/pseudo-probe-emit.ll
The file was modifiedllvm/include/llvm/MC/MCStreamer.h
The file was addedllvm/include/llvm/MC/MCPseudoProbe.h
The file was modifiedllvm/include/llvm/MC/MCObjectFileInfo.h
The file was modifiedllvm/lib/MC/MCAsmStreamer.cpp
The file was addedllvm/test/Transforms/SampleProfile/pseudo-probe-emit-inline.ll
The file was modifiedllvm/include/llvm/CodeGen/AsmPrinter.h
The file was addedllvm/lib/CodeGen/AsmPrinter/PseudoProbePrinter.cpp
The file was modifiedllvm/lib/IR/MDBuilder.cpp
The file was modifiedllvm/lib/MC/MCObjectStreamer.cpp
The file was modifiedllvm/lib/Transforms/IPO/SampleProfileProbe.cpp
The file was modifiedllvm/include/llvm/MC/MCContext.h
The file was modifiedllvm/lib/MC/MCObjectFileInfo.cpp
The file was modifiedllvm/include/llvm/MC/MCAssembler.h
Commit 6b1bf905d01e6b459d6afde424c8fe76741d865c by llvmgnsyncbot
[gn build] Port 705a4c149d8
The file was modifiedllvm/utils/gn/secondary/llvm/lib/MC/
The file was modifiedllvm/utils/gn/secondary/llvm/lib/CodeGen/AsmPrinter/
Commit dd6412c05c1039e582a970da1aee62cdde75c892 by dschuff
[WebAssembly][lld] Exclude COMDAT sections

Allow exclusion/discarding of custom sections with COMDAT groups.
It piggybacks on the existing COMDAT-handling code, but applies to custom sections as well.

Differential Revision:
The file was modifiedlld/wasm/Writer.cpp
The file was addedlld/test/wasm/Inputs/comdat2.s
The file was addedlld/test/wasm/comdat-sections.s
The file was modifiedlld/wasm/OutputSections.cpp
The file was addedlld/test/wasm/Inputs/comdat1.s
The file was modifiedlld/wasm/InputFiles.cpp
The file was modifiedlld/wasm/InputChunks.h
Commit 553284be2dded5b1d1106b380525e0b1e3b609cd by jezng
[lld-macho] Don't include absolute address value in expected test output

Should fix the mattrs.ll failure introduced by rG29d3b0e47113.
The file was modifiedlld/test/MachO/mattrs.ll
Commit 349d5c9cf79803187a2e1e2a080a8e460d03cf76 by jezng
[lld-macho] Disable some tests that are failing on Windows

lto-object-path.ll, like stabs.s, is disabled on Windows as the path
separators make it difficult to write a test that works across

This diff also disables implicit-dylibs.s on Windows as we seem to emit
LC_LOAD_DYLIBs in a different order on that platform. This seems like a
bug in LLD that needs to be addressed (in a future diff).
The file was modifiedlld/test/MachO/implicit-dylibs.s
The file was modifiedlld/test/MachO/lto-object-path.ll
Commit 494aacd72c6a85a6d586fa58a8481e13b68acf24 by Duncan P. N. Exon Smith
Tooling: Migrate some tests to FileEntryRef, NFC

Migrate to the `FileEntryRef` overload of `SourceManager::createFileID`
(using `FileManager::getOptionalFileRef`) in RefactoringTest.cpp and

No functionality change.

Differential Revision:
The file was modifiedclang/unittests/Tooling/RewriterTestContext.h
The file was modifiedclang/unittests/Tooling/RefactoringTest.cpp
Commit ce93de3bb284c944676c7b81890156d9d80b1db9 by jonathanchesterfield
[libomptarget][nfc] Remove data_sharing type aliasing

[libomptarget][nfc] Remove data_sharing type aliasing

Libomptarget previous used __kmpc_data_sharing_slot to access values of type
__kmpc_data_sharing_{worker,master}_slot_static. This aliasing violation was
benign in practice. The master type has since been removed, so a single type
can be used instead.

This is particularly helpful for the transition to an openmp deviceRTL, as the
c++/openmp compiler for amdgcn currently rejects the flexible array member for
being an incomplete type. Serves the same purpose as abandoned D86324.

Reviewed By: jdoerfert

Differential Revision:
The file was modifiedopenmp/libomptarget/deviceRTLs/common/omptarget.h
The file was modifiedopenmp/libomptarget/deviceRTLs/interface.h