Skip to content

Commit ff544d9

Browse files
author
z1_cciauto
authored
merge main into amd-staging (llvm#3350)
2 parents 086be17 + 775e8fe commit ff544d9

File tree

337 files changed

+14625
-3374
lines changed

Some content is hidden

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

337 files changed

+14625
-3374
lines changed

bolt/lib/Rewrite/RewriteInstance.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -896,6 +896,20 @@ void RewriteInstance::discoverFileObjects() {
896896
continue;
897897

898898
MarkerSymType MarkerType = BC->getMarkerType(SymInfo.Symbol);
899+
900+
// Treat ST_Function as code.
901+
Expected<object::SymbolRef::Type> TypeOrError = SymInfo.Symbol.getType();
902+
consumeError(TypeOrError.takeError());
903+
if (TypeOrError && *TypeOrError == SymbolRef::ST_Function) {
904+
if (IsData) {
905+
Expected<StringRef> NameOrError = SymInfo.Symbol.getName();
906+
consumeError(NameOrError.takeError());
907+
BC->errs() << "BOLT-WARNING: function symbol " << *NameOrError
908+
<< " lacks code marker\n";
909+
}
910+
MarkerType = MarkerSymType::CODE;
911+
}
912+
899913
if (MarkerType != MarkerSymType::NONE) {
900914
SortedMarkerSymbols.push_back(MarkerSym{SymInfo.Address, MarkerType});
901915
LastAddr = SymInfo.Address;
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
## Check that llvm-bolt is able to recover a missing code marker.
2+
3+
# RUN: %clang %cflags %s -o %t.exe -nostdlib -fuse-ld=lld -Wl,-q
4+
# RUN: llvm-bolt %t.exe -o %t.bolt 2>&1 | FileCheck %s
5+
6+
# CHECK: BOLT-WARNING: function symbol foo lacks code marker
7+
8+
.text
9+
.balign 4
10+
11+
.word 0
12+
13+
## Function foo starts immediately after a data object and does not have
14+
## a matching "$x" symbol to indicate the start of code.
15+
.global foo
16+
.type foo, %function
17+
foo:
18+
.word 0xd65f03c0
19+
.size foo, .-foo
20+
21+
.global _start
22+
.type _start, %function
23+
_start:
24+
bl foo
25+
ret
26+
.size _start, .-_start

clang/include/clang/Basic/BuiltinsAMDGPU.def

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,16 @@ TARGET_BUILTIN(__builtin_amdgcn_global_load_monitor_b128, "V4iV4i*1Ii", "nc", "g
656656
TARGET_BUILTIN(__builtin_amdgcn_flat_load_monitor_b32, "ii*0Ii", "nc", "gfx1250-insts")
657657
TARGET_BUILTIN(__builtin_amdgcn_flat_load_monitor_b64, "V2iV2i*0Ii", "nc", "gfx1250-insts")
658658
TARGET_BUILTIN(__builtin_amdgcn_flat_load_monitor_b128, "V4iV4i*0Ii", "nc", "gfx1250-insts")
659+
TARGET_BUILTIN(__builtin_amdgcn_global_load_async_to_lds_b8, "vc*1c*3IiIi", "nc", "gfx1250-insts")
660+
TARGET_BUILTIN(__builtin_amdgcn_global_load_async_to_lds_b32, "vi*1i*3IiIi", "nc", "gfx1250-insts")
661+
TARGET_BUILTIN(__builtin_amdgcn_global_load_async_to_lds_b64, "vV2i*1V2i*3IiIi", "nc", "gfx1250-insts")
662+
TARGET_BUILTIN(__builtin_amdgcn_global_load_async_to_lds_b128, "vV4i*1V4i*3IiIi", "nc", "gfx1250-insts")
663+
TARGET_BUILTIN(__builtin_amdgcn_global_store_async_from_lds_b8, "vc*1c*3IiIi", "nc", "gfx1250-insts")
664+
TARGET_BUILTIN(__builtin_amdgcn_global_store_async_from_lds_b32, "vi*1i*3IiIi", "nc", "gfx1250-insts")
665+
TARGET_BUILTIN(__builtin_amdgcn_global_store_async_from_lds_b64, "vV2i*1V2i*3IiIi", "nc", "gfx1250-insts")
666+
TARGET_BUILTIN(__builtin_amdgcn_global_store_async_from_lds_b128, "vV4i*1V4i*3IiIi", "nc", "gfx1250-insts")
667+
TARGET_BUILTIN(__builtin_amdgcn_ds_atomic_async_barrier_arrive_b64, "vLi*3", "nc", "gfx1250-insts")
668+
TARGET_BUILTIN(__builtin_amdgcn_ds_atomic_barrier_arrive_rtn_b64, "LiLi*3Li", "nc", "gfx1250-insts")
659669

660670
TARGET_BUILTIN(__builtin_amdgcn_tensor_load_to_lds, "vV4iV8iV4iV4iIi", "nc", "gfx1250-insts")
661671
TARGET_BUILTIN(__builtin_amdgcn_tensor_load_to_lds_d2, "vV4iV8iIi", "nc", "gfx1250-insts")
@@ -675,9 +685,6 @@ TARGET_BUILTIN(__builtin_amdgcn_ds_load_tr16_b128_v8i16, "V8sV8s*3", "nc", "gfx1
675685
TARGET_BUILTIN(__builtin_amdgcn_ds_load_tr16_b128_v8f16, "V8hV8h*3", "nc", "gfx1250-insts,wavefrontsize32")
676686
TARGET_BUILTIN(__builtin_amdgcn_ds_load_tr16_b128_v8bf16, "V8yV8y*3", "nc", "gfx1250-insts,wavefrontsize32")
677687

678-
TARGET_BUILTIN(__builtin_amdgcn_ds_atomic_async_barrier_arrive_b64, "vLi*3", "nc", "gfx1250-insts")
679-
TARGET_BUILTIN(__builtin_amdgcn_ds_atomic_barrier_arrive_rtn_b64, "LiLi*3Li", "nc", "gfx1250-insts")
680-
681688
TARGET_BUILTIN(__builtin_amdgcn_s_setprio_inc_wg, "vIs", "n", "setprio-inc-wg-inst")
682689
TARGET_BUILTIN(__builtin_amdgcn_s_monitor_sleep, "vIs", "n", "gfx1250-insts")
683690

clang/include/clang/Basic/DiagnosticASTKinds.td

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,14 @@ def note_odr_number_of_bases : Note<
511511
"class has %0 base %plural{1:class|:classes}0">;
512512
def note_odr_enumerator : Note<"enumerator %0 with value %1 here">;
513513
def note_odr_missing_enumerator : Note<"no corresponding enumerator here">;
514+
def note_odr_incompatible_fixed_underlying_type : Note<
515+
"enumeration %0 declared with incompatible fixed underlying types (%1 vs. "
516+
"%2)">;
517+
def note_odr_fixed_underlying_type : Note<
518+
"enumeration %0 has fixed underlying type here">;
519+
def note_odr_missing_fixed_underlying_type : Note<
520+
"enumeration %0 missing fixed underlying type here">;
521+
514522
def err_odr_field_type_inconsistent : Error<
515523
"field %0 declared with incompatible types in different "
516524
"translation units (%1 vs. %2)">;

clang/include/clang/Basic/FileManager.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -237,11 +237,6 @@ class FileManager : public RefCountedBase<FileManager> {
237237
FileEntryRef getVirtualFileRef(StringRef Filename, off_t Size,
238238
time_t ModificationTime);
239239

240-
LLVM_DEPRECATED("Functions returning FileEntry are deprecated.",
241-
"getVirtualFileRef()")
242-
const FileEntry *getVirtualFile(StringRef Filename, off_t Size,
243-
time_t ModificationTime);
244-
245240
/// Retrieve a FileEntry that bypasses VFE, which is expected to be a virtual
246241
/// file entry, to access the real file. The returned FileEntry will have
247242
/// the same filename as FE but a different identity and its own stat.

clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
7575
return getConstant(loc, cir::IntAttr::get(ty, value));
7676
}
7777

78+
mlir::Value getSignedInt(mlir::Location loc, int64_t val, unsigned numBits) {
79+
auto type = cir::IntType::get(getContext(), numBits, /*isSigned=*/true);
80+
return getConstAPInt(loc, type,
81+
llvm::APInt(numBits, val, /*isSigned=*/true));
82+
}
83+
7884
mlir::Value getUnsignedInt(mlir::Location loc, uint64_t val,
7985
unsigned numBits) {
8086
auto type = cir::IntType::get(getContext(), numBits, /*isSigned=*/false);

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

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -607,8 +607,8 @@ def CIR_ConditionOp : CIR_Op<"condition", [
607607
//===----------------------------------------------------------------------===//
608608

609609
defvar CIR_YieldableScopes = [
610-
"ArrayCtor", "CaseOp", "DoWhileOp", "ForOp", "IfOp", "ScopeOp", "SwitchOp",
611-
"TernaryOp", "WhileOp"
610+
"ArrayCtor", "ArrayDtor", "CaseOp", "DoWhileOp", "ForOp", "IfOp", "ScopeOp",
611+
"SwitchOp", "TernaryOp", "WhileOp"
612612
];
613613

614614
def CIR_YieldOp : CIR_Op<"yield", [
@@ -1946,6 +1946,10 @@ def CIR_FuncOp : CIR_Op<"func", [
19461946
The function linkage information is specified by `linkage`, as defined by
19471947
`GlobalLinkageKind` attribute.
19481948

1949+
The `no_proto` keyword is used to identify functions that were declared
1950+
without a prototype and, consequently, may contain calls with invalid
1951+
arguments and undefined behavior.
1952+
19491953
Example:
19501954

19511955
```mlir
@@ -1964,6 +1968,7 @@ def CIR_FuncOp : CIR_Op<"func", [
19641968
let arguments = (ins SymbolNameAttr:$sym_name,
19651969
CIR_VisibilityAttr:$global_visibility,
19661970
TypeAttrOf<CIR_FuncType>:$function_type,
1971+
UnitAttr:$no_proto,
19671972
UnitAttr:$dso_local,
19681973
DefaultValuedAttr<CIR_GlobalLinkageKind,
19691974
"cir::GlobalLinkageKind::ExternalLinkage">:$linkage,
@@ -2005,13 +2010,6 @@ def CIR_FuncOp : CIR_Op<"func", [
20052010
return getFunctionType().getReturnTypes();
20062011
}
20072012

2008-
// TODO(cir): this should be an operand attribute, but for now we just hard-
2009-
// wire this as a function. Will later add a $no_proto argument to this op.
2010-
bool getNoProto() {
2011-
assert(!cir::MissingFeatures::opFuncNoProto());
2012-
return false;
2013-
}
2014-
20152013
//===------------------------------------------------------------------===//
20162014
// SymbolOpInterface Methods
20172015
//===------------------------------------------------------------------===//
@@ -2229,7 +2227,7 @@ def CIR_TrapOp : CIR_Op<"trap", [Terminator]> {
22292227
}
22302228

22312229
//===----------------------------------------------------------------------===//
2232-
// ArrayCtor
2230+
// ArrayCtor & ArrayDtor
22332231
//===----------------------------------------------------------------------===//
22342232

22352233
class CIR_ArrayInitDestroy<string mnemonic> : CIR_Op<mnemonic> {
@@ -2260,7 +2258,9 @@ def CIR_ArrayCtor : CIR_ArrayInitDestroy<"array.ctor"> {
22602258
let description = [{
22612259
Initialize each array element using the same C++ constructor. This
22622260
operation has one region, with one single block. The block has an
2263-
incoming argument for the current array index to initialize.
2261+
incoming argument for the current array element to initialize.
2262+
2263+
Example:
22642264

22652265
```mlir
22662266
cir.array.ctor(%0 : !cir.ptr<!cir.array<!rec_S x 42>>) {
@@ -2272,6 +2272,25 @@ def CIR_ArrayCtor : CIR_ArrayInitDestroy<"array.ctor"> {
22722272
}];
22732273
}
22742274

2275+
def CIR_ArrayDtor : CIR_ArrayInitDestroy<"array.dtor"> {
2276+
let summary = "Destroy array elements with C++ dtors";
2277+
let description = [{
2278+
Destroy each array element using the same C++ destructor. This
2279+
operation has one region, with one single block. The block has an
2280+
incoming argument for the current array element to destruct.
2281+
2282+
Example:
2283+
2284+
```mlir
2285+
cir.array.dtor(%0 : !cir.ptr<!cir.array<!rec_S x 42>>) {
2286+
^bb0(%arg0: !cir.ptr<!rec_S>):
2287+
cir.call @some_dtor(%arg0) : (!cir.ptr<!rec_S>) -> ()
2288+
cir.yield
2289+
}
2290+
```
2291+
}];
2292+
}
2293+
22752294
//===----------------------------------------------------------------------===//
22762295
// VecCreate
22772296
//===----------------------------------------------------------------------===//

clang/include/clang/CIR/MissingFeatures.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,16 @@ struct MissingFeatures {
7373
// FuncOp handling
7474
static bool opFuncOpenCLKernelMetadata() { return false; }
7575
static bool opFuncAstDeclAttr() { return false; }
76+
static bool opFuncAttributesForDefinition() { return false; }
7677
static bool opFuncCallingConv() { return false; }
77-
static bool opFuncExtraAttrs() { return false; }
78-
static bool opFuncNoProto() { return false; }
7978
static bool opFuncCPUAndFeaturesAttributes() { return false; }
80-
static bool opFuncSection() { return false; }
81-
static bool opFuncMultipleReturnVals() { return false; }
82-
static bool opFuncAttributesForDefinition() { return false; }
79+
static bool opFuncExceptions() { return false; }
80+
static bool opFuncExtraAttrs() { return false; }
8381
static bool opFuncMaybeHandleStaticInExternC() { return false; }
82+
static bool opFuncMultipleReturnVals() { return false; }
83+
static bool opFuncOperandBundles() { return false; }
84+
static bool opFuncParameterAttributes() { return false; }
85+
static bool opFuncSection() { return false; }
8486
static bool setLLVMFunctionFEnvAttributes() { return false; }
8587
static bool setFunctionAttributes() { return false; }
8688

@@ -96,7 +98,6 @@ struct MissingFeatures {
9698
static bool opCallReturn() { return false; }
9799
static bool opCallArgEvaluationOrder() { return false; }
98100
static bool opCallCallConv() { return false; }
99-
static bool opCallNoPrototypeFunc() { return false; }
100101
static bool opCallMustTail() { return false; }
101102
static bool opCallVirtual() { return false; }
102103
static bool opCallInAlloca() { return false; }
@@ -109,6 +110,7 @@ struct MissingFeatures {
109110
static bool opCallCIRGenFuncInfoExtParamInfo() { return false; }
110111
static bool opCallLandingPad() { return false; }
111112
static bool opCallContinueBlock() { return false; }
113+
static bool opCallChain() { return false; }
112114

113115
// CXXNewExpr
114116
static bool exprNewNullCheck() { return false; }
@@ -224,7 +226,6 @@ struct MissingFeatures {
224226
static bool moduleNameHash() { return false; }
225227
static bool msabi() { return false; }
226228
static bool needsGlobalCtorDtor() { return false; }
227-
static bool nonFineGrainedBitfields() { return false; }
228229
static bool objCBlocks() { return false; }
229230
static bool objCGC() { return false; }
230231
static bool objCLifetime() { return false; }

clang/lib/AST/ASTStructuralEquivalence.cpp

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,9 @@ CheckStructurallyEquivalentAttributes(StructuralEquivalenceContext &Context,
456456
const Decl *D1, const Decl *D2,
457457
const Decl *PrimaryDecl = nullptr) {
458458
// If either declaration has an attribute on it, we treat the declarations
459-
// as not being structurally equivalent.
459+
// as not being structurally equivalent unless both declarations are implicit
460+
// (ones generated by the compiler like __NSConstantString_tag).
461+
//
460462
// FIXME: this should be handled on a case-by-case basis via tablegen in
461463
// Attr.td. There are multiple cases to consider: one declaration with the
462464
// attribute, another without it; different attribute syntax|spellings for
@@ -468,7 +470,7 @@ CheckStructurallyEquivalentAttributes(StructuralEquivalenceContext &Context,
468470
D1Attr = *D1->getAttrs().begin();
469471
if (D2->hasAttrs())
470472
D2Attr = *D2->getAttrs().begin();
471-
if (D1Attr || D2Attr) {
473+
if ((D1Attr || D2Attr) && !D1->isImplicit() && !D2->isImplicit()) {
472474
const auto *DiagnoseDecl = cast<TypeDecl>(PrimaryDecl ? PrimaryDecl : D2);
473475
Context.Diag2(DiagnoseDecl->getLocation(),
474476
diag::warn_odr_tag_type_with_attributes)
@@ -884,12 +886,10 @@ static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context,
884886
// class comparison.
885887
if (T1->getTypeClass() == Type::Enum) {
886888
T1 = T1->getAs<EnumType>()->getDecl()->getIntegerType();
887-
if (!T2->isBuiltinType() || T1.isNull()) // Sanity check
888-
return false;
889+
assert(T2->isBuiltinType() && !T1.isNull()); // Sanity check
889890
} else if (T2->getTypeClass() == Type::Enum) {
890891
T2 = T2->getAs<EnumType>()->getDecl()->getIntegerType();
891-
if (!T1->isBuiltinType() || T2.isNull()) // Sanity check
892-
return false;
892+
assert(T1->isBuiltinType() && !T2.isNull()); // Sanity check
893893
}
894894
TC = Type::Builtin;
895895
} else
@@ -2093,6 +2093,48 @@ static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context,
20932093
!CheckStructurallyEquivalentAttributes(Context, D1, D2))
20942094
return false;
20952095

2096+
// In C23, if one enumeration has a fixed underlying type, the other shall
2097+
// have a compatible fixed underlying type (6.2.7).
2098+
if (Context.LangOpts.C23) {
2099+
if (D1->isFixed() != D2->isFixed()) {
2100+
if (Context.Complain) {
2101+
Context.Diag2(D2->getLocation(),
2102+
Context.getApplicableDiagnostic(
2103+
diag::err_odr_tag_type_inconsistent))
2104+
<< Context.ToCtx.getTypeDeclType(D2)
2105+
<< (&Context.FromCtx != &Context.ToCtx);
2106+
Context.Diag1(D1->getLocation(),
2107+
D1->isFixed()
2108+
? diag::note_odr_fixed_underlying_type
2109+
: diag::note_odr_missing_fixed_underlying_type)
2110+
<< D1;
2111+
Context.Diag2(D2->getLocation(),
2112+
D2->isFixed()
2113+
? diag::note_odr_fixed_underlying_type
2114+
: diag::note_odr_missing_fixed_underlying_type)
2115+
<< D2;
2116+
}
2117+
return false;
2118+
}
2119+
if (D1->isFixed()) {
2120+
assert(D2->isFixed() && "enums expected to have fixed underlying types");
2121+
if (!IsStructurallyEquivalent(Context, D1->getIntegerType(),
2122+
D2->getIntegerType())) {
2123+
if (Context.Complain) {
2124+
Context.Diag2(D2->getLocation(),
2125+
Context.getApplicableDiagnostic(
2126+
diag::err_odr_tag_type_inconsistent))
2127+
<< Context.ToCtx.getTypeDeclType(D2)
2128+
<< (&Context.FromCtx != &Context.ToCtx);
2129+
Context.Diag2(D2->getLocation(),
2130+
diag::note_odr_incompatible_fixed_underlying_type)
2131+
<< D2 << D2->getIntegerType() << D1->getIntegerType();
2132+
}
2133+
return false;
2134+
}
2135+
}
2136+
}
2137+
20962138
llvm::SmallVector<const EnumConstantDecl *, 8> D1Enums, D2Enums;
20972139
auto CopyEnumerators =
20982140
[](auto &&Range, llvm::SmallVectorImpl<const EnumConstantDecl *> &Cont) {

0 commit comments

Comments
 (0)