Skip to content

Commit f1dae59

Browse files
authored
Merge branch 'main' into disable-interpreter-tests
2 parents 1f22da0 + 76d993b commit f1dae59

File tree

114 files changed

+5859
-911
lines changed

Some content is hidden

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

114 files changed

+5859
-911
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/**

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

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

clang/include/clang/Driver/Options.td

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6987,7 +6987,6 @@ def static_libgfortran : Flag<["-"], "static-libgfortran">, Group<gfortran_Group
69876987
// "f" options with values for gfortran.
69886988
def fblas_matmul_limit_EQ : Joined<["-"], "fblas-matmul-limit=">, Group<gfortran_Group>;
69896989
def fcheck_EQ : Joined<["-"], "fcheck=">, Group<gfortran_Group>;
6990-
def fcoarray_EQ : Joined<["-"], "fcoarray=">, Group<gfortran_Group>;
69916990
def ffpe_trap_EQ : Joined<["-"], "ffpe-trap=">, Group<gfortran_Group>;
69926991
def ffree_line_length_VALUE : Joined<["-"], "ffree-line-length-">, Group<gfortran_Group>;
69936992
def finit_character_EQ : Joined<["-"], "finit-character=">, Group<gfortran_Group>;
@@ -8695,6 +8694,15 @@ def fopenmp_host_ir_file_path : Separate<["-"], "fopenmp-host-ir-file-path">,
86958694

86968695
} // let Visibility = [CC1Option, FC1Option]
86978696

8697+
//===----------------------------------------------------------------------===//
8698+
// Coarray Options
8699+
//===----------------------------------------------------------------------===//
8700+
8701+
def fcoarray : Flag<["-"], "fcoarray">,
8702+
Group<f_Group>,
8703+
Visibility<[FlangOption, FC1Option]>,
8704+
HelpText<"Enable Coarray features">;
8705+
86988706
//===----------------------------------------------------------------------===//
86998707
// SYCL Options
87008708
//===----------------------------------------------------------------------===//

clang/lib/CIR/CodeGen/CIRGenBuilder.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy {
8484
llvm_unreachable("Unsupported format for long double");
8585
}
8686

87+
mlir::Type getPtrToVPtrType() {
88+
return getPointerTo(cir::VPtrType::get(getContext()));
89+
}
90+
8791
/// Get a CIR record kind from a AST declaration tag.
8892
cir::RecordType::RecordKind getRecordKind(const clang::TagTypeKind kind) {
8993
switch (kind) {
@@ -263,6 +267,9 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy {
263267
cir::ConstantOp getSInt32(int32_t c, mlir::Location loc) {
264268
return getConstantInt(loc, getSInt32Ty(), c);
265269
}
270+
cir::ConstantOp getUInt32(uint32_t c, mlir::Location loc) {
271+
return getConstantInt(loc, getUInt32Ty(), c);
272+
}
266273

267274
// Creates constant nullptr for pointer type ty.
268275
cir::ConstantOp getNullPtr(mlir::Type ty, mlir::Location loc) {

0 commit comments

Comments
 (0)