Skip to content

Commit faba476

Browse files
rebase
Created using spr 1.3.6
2 parents 2ea8358 + 7bb7345 commit faba476

File tree

335 files changed

+9111
-2440
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

335 files changed

+9111
-2440
lines changed

.ci/utils.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ function at-exit {
2424
retcode=$?
2525

2626
mkdir -p artifacts
27+
sccache --show-stats
2728
sccache --show-stats >> artifacts/sccache_stats.txt
2829
cp "${BUILD_DIR}"/.ninja_log artifacts/.ninja_log
2930
cp "${MONOREPO_ROOT}"/*.log artifacts/ || :

.github/new-prs-labeler.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,6 @@ LTO:
9090
- llvm/lib/Transforms/*/FunctionImport*
9191
- llvm/tools/gold/**
9292

93-
mc:
94-
- llvm/*/MC/**
95-
9693
clang:driver:
9794
- clang/*/Driver/**
9895

@@ -621,6 +618,12 @@ llvm:adt:
621618
llvm:support:
622619
- llvm/**/Support/**
623620

621+
# Skip llvm/test/MC and llvm/unittests/MC, which includes target-specific directories.
622+
llvm:mc:
623+
- llvm/include/llvm/MC/**
624+
- llvm/lib/MC/**
625+
- llvm/tools/llvm-mc/**
626+
624627
llvm:transforms:
625628
- llvm/lib/Transforms/**
626629
- llvm/include/llvm/Transforms/**

.github/workflows/containers/github-action-ci/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ RUN curl -L 'https://github.com/mozilla/sccache/releases/download/v0.10.0/sccach
8181

8282
ENV LLVM_SYSROOT=$LLVM_SYSROOT
8383
ENV PATH=${LLVM_SYSROOT}/bin:${PATH}
84+
ENV CC=clang
85+
ENV CXX=clang++
8486

8587
# Create a new user to avoid test failures related to a lack of expected
8688
# permissions issues in some tests. Set the user id to 1001 as that is the

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ autoconf/autom4te.cache
5252
# CLion project configuration
5353
/.idea
5454
/cmake-build*
55+
# Coding assistants' stuff
56+
/CLAUDE.md
57+
/.claude/
58+
/GEMINI.md
59+
/.gemini/
5560

5661
#==============================================================================#
5762
# Directories to ignore (do not add trailing '/'s, they skip symlinks).

bolt/include/bolt/Core/MCPlusBuilder.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,10 @@ class MCPlusBuilder {
740740
return false;
741741
}
742742

743+
/// Return true if the hlt instruction under the x86, otherwise, default to
744+
/// false.
745+
virtual bool isX86HLT(const MCInst &Inst) const { return false; }
746+
743747
/// Return the width, in bytes, of the memory access performed by \p Inst, if
744748
/// this is a pop instruction. Return zero otherwise.
745749
virtual int getPopSize(const MCInst &Inst) const {

bolt/lib/Core/MCPlusBuilder.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,10 @@ bool MCPlusBuilder::equals(const MCSpecifierExpr &A, const MCSpecifierExpr &B,
132132
}
133133

134134
bool MCPlusBuilder::isTerminator(const MCInst &Inst) const {
135-
return Analysis->isTerminator(Inst) ||
136-
(opts::TerminalTrap && Info->get(Inst.getOpcode()).isTrap());
135+
return (opts::TerminalTrap && Info->get(Inst.getOpcode()).isTrap()) ||
136+
Analysis->isTerminator(Inst)
137+
? !isX86HLT(Inst)
138+
: false;
137139
}
138140

139141
void MCPlusBuilder::setTailCall(MCInst &Inst) const {

bolt/lib/Target/X86/X86MCPlusBuilder.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,10 @@ class X86MCPlusBuilder : public MCPlusBuilder {
223223
return Inst.getOpcode() == X86::ENDBR32 || Inst.getOpcode() == X86::ENDBR64;
224224
}
225225

226+
bool isX86HLT(const MCInst &Inst) const override {
227+
return Inst.getOpcode() == X86::HLT;
228+
}
229+
226230
int getPopSize(const MCInst &Inst) const override {
227231
switch (Inst.getOpcode()) {
228232
case X86::POP16r:

bolt/test/X86/cfg_build_hlt.s

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
## Check CFG for halt instruction
2+
3+
# RUN: %clang %cflags %s -static -o %t.exe -nostdlib
4+
# RUN: llvm-bolt %t.exe --print-cfg --print-only=main -o %t 2>&1 | FileCheck %s --check-prefix=CHECK-CFG
5+
# RUN: llvm-objdump -d %t --print-imm-hex | FileCheck %s --check-prefix=CHECK-BIN
6+
7+
# CHECK-CFG: BB Count : 1
8+
# CHECK-BIN: <main>:
9+
# CHECK-BIN-NEXT: f4 hlt
10+
# CHECK-BIN-NEXT: c3 retq
11+
12+
.global main
13+
.type main, %function
14+
main:
15+
hlt
16+
retq
17+
.size main, .-main
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// RUN: %check_clang_tidy -std=c++20 %s modernize-type-traits %t
2+
3+
namespace std {
4+
template <class> struct tuple_size {
5+
static const int value = 1;
6+
};
7+
template <int, class> struct tuple_element {
8+
using type = int;
9+
};
10+
}
11+
12+
struct A {};
13+
template <int> int get(const A&);
14+
15+
auto [a] = A();

clang/include/clang/CIR/Dialect/IR/CIROps.td

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1749,6 +1749,39 @@ def CIR_VTableAddrPointOp : CIR_Op<"vtable.address_point", [
17491749
}];
17501750
}
17511751

1752+
//===----------------------------------------------------------------------===//
1753+
// VTableGetVPtr
1754+
//===----------------------------------------------------------------------===//
1755+
1756+
def CIR_VTableGetVPtrOp : CIR_Op<"vtable.get_vptr", [Pure]> {
1757+
let summary = "Get a the address of the vtable pointer for an object";
1758+
let description = [{
1759+
The `vtable.get_vptr` operation retrieves the address of the vptr for a
1760+
C++ object. This operation requires that the object pointer points to
1761+
the start of a complete object. (TODO: Describe how we get that).
1762+
The vptr will always be at offset zero in the object, but this operation
1763+
is more explicit about what is being retrieved than a direct bitcast.
1764+
1765+
The return type is always `!cir.ptr<!cir.vptr>`.
1766+
1767+
Example:
1768+
```mlir
1769+
%2 = cir.load %0 : !cir.ptr<!cir.ptr<!rec_C>>, !cir.ptr<!rec_C>
1770+
%3 = cir.vtable.get_vptr %2 : !cir.ptr<!rec_C> -> !cir.ptr<!cir.vptr>
1771+
```
1772+
}];
1773+
1774+
let arguments = (ins
1775+
Arg<CIR_PointerType, "the vptr address", [MemRead]>:$src
1776+
);
1777+
1778+
let results = (outs CIR_PtrToVPtr:$result);
1779+
1780+
let assemblyFormat = [{
1781+
$src `:` qualified(type($src)) `->` qualified(type($result)) attr-dict
1782+
}];
1783+
}
1784+
17521785
//===----------------------------------------------------------------------===//
17531786
// SetBitfieldOp
17541787
//===----------------------------------------------------------------------===//
@@ -2210,6 +2243,68 @@ def CIR_CallOp : CIR_CallOpBase<"call", [NoRegionArguments]> {
22102243
];
22112244
}
22122245

2246+
//===----------------------------------------------------------------------===//
2247+
// ReturnAddrOp and FrameAddrOp
2248+
//===----------------------------------------------------------------------===//
2249+
2250+
class CIR_FuncAddrBuiltinOp<string mnemonic> : CIR_Op<mnemonic, []> {
2251+
let arguments = (ins CIR_UInt32:$level);
2252+
let results = (outs CIR_VoidPtrType:$result);
2253+
let assemblyFormat = [{
2254+
`(` $level `)` attr-dict
2255+
}];
2256+
}
2257+
2258+
def CIR_ReturnAddrOp : CIR_FuncAddrBuiltinOp<"return_address"> {
2259+
let summary =
2260+
"The return address of the current function, or of one of its callers";
2261+
2262+
let description = [{
2263+
Represents a call to builtin function ` __builtin_return_address` in CIR.
2264+
This builtin function returns the return address of the current function,
2265+
or of one of its callers.
2266+
2267+
The `level` argument is number of frames to scan up the call stack.
2268+
For instance, value of 0 yields the return address of the current function,
2269+
value of 1 yields the return address of the caller of the current function,
2270+
and so forth.
2271+
2272+
Examples:
2273+
2274+
```mlir
2275+
%p = return_address(%level) -> !cir.ptr<!void>
2276+
```
2277+
}];
2278+
}
2279+
2280+
def CIR_FrameAddrOp : CIR_FuncAddrBuiltinOp<"frame_address"> {
2281+
let summary =
2282+
"The frame address of the current function, or of one of its callers";
2283+
2284+
let description = [{
2285+
Represents a call to builtin function ` __builtin_frame_address` in CIR.
2286+
This builtin function returns the frame address of the current function,
2287+
or of one of its callers. The frame is the area on the stack that holds
2288+
local variables and saved registers. The frame address is normally the
2289+
address of the first word pushed on to the stack by the function.
2290+
However, the exact definition depends upon the processor and the calling
2291+
convention. If the processor has a dedicated frame pointer register, and
2292+
the function has a frame, then __builtin_frame_address returns the value of
2293+
the frame pointer register.
2294+
2295+
The `level` argument is number of frames to scan up the call stack.
2296+
For instance, value of 0 yields the frame address of the current function,
2297+
value of 1 yields the frame address of the caller of the current function,
2298+
and so forth.
2299+
2300+
Examples:
2301+
2302+
```mlir
2303+
%p = frame_address(%level) -> !cir.ptr<!void>
2304+
```
2305+
}];
2306+
}
2307+
22132308
//===----------------------------------------------------------------------===//
22142309
// StackSaveOp & StackRestoreOp
22152310
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)