Skip to content

Commit 3204995

Browse files
authored
Merge branch 'main' into fix-omp-typo
2 parents cbf0644 + f0967fc commit 3204995

File tree

143 files changed

+6483
-812
lines changed

Some content is hidden

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

143 files changed

+6483
-812
lines changed

.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

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
//===----------------------------------------------------------------------===//

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,14 @@ def CIR_AnyFloatOrVecOfFloatType
289289
let cppFunctionName = "isFPOrVectorOfFPType";
290290
}
291291

292+
//===----------------------------------------------------------------------===//
293+
// VPtr type predicates
294+
//===----------------------------------------------------------------------===//
295+
296+
def CIR_AnyVPtrType : CIR_TypeBase<"::cir::VPtrType", "vptr type">;
297+
298+
def CIR_PtrToVPtr : CIR_PtrToType<CIR_AnyVPtrType>;
299+
292300
//===----------------------------------------------------------------------===//
293301
// Scalar Type predicates
294302
//===----------------------------------------------------------------------===//

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -296,10 +296,10 @@ def CIR_VPtrType : CIR_Type<"VPtr", "vptr", [
296296
access to the vptr.
297297

298298
This type will be the element type of the 'vptr' member of structures that
299-
require a vtable pointer. A pointer to this type is returned by the
300-
`cir.vtable.address_point` and `cir.vtable.get_vptr` operations, and this
301-
pointer may be passed to the `cir.vtable.get_virtual_fn_addr` operation to
302-
get the address of a virtual function pointer.
299+
require a vtable pointer. The `cir.vtable.address_point` operation returns
300+
this type. The `cir.vtable.get_vptr` operations returns a pointer to this
301+
type. This pointer may be passed to the `cir.vtable.get_virtual_fn_addr`
302+
operation to get the address of a virtual function pointer.
303303

304304
The pointer may also be cast to other pointer types in order to perform
305305
pointer arithmetic based on information encoded in the AST layout to get

0 commit comments

Comments
 (0)