Skip to content

Commit 14dcf62

Browse files
authored
merge main into amd-staging (llvm#3557)
2 parents e1ad3ca + d634b96 commit 14dcf62

File tree

520 files changed

+20857
-2306
lines changed

Some content is hidden

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

520 files changed

+20857
-2306
lines changed

clang/include/clang/APINotes/Types.h

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ class CommonTypeInfo : public CommonEntityInfo {
141141
/// The NS error domain for this type.
142142
std::optional<std::string> NSErrorDomain;
143143

144+
/// The Swift protocol that this type should be automatically conformed to.
145+
std::optional<std::string> SwiftConformance;
146+
144147
public:
145148
CommonTypeInfo() {}
146149

@@ -165,6 +168,14 @@ class CommonTypeInfo : public CommonEntityInfo {
165168
: std::nullopt;
166169
}
167170

171+
std::optional<std::string> getSwiftConformance() const {
172+
return SwiftConformance;
173+
}
174+
175+
void setSwiftConformance(std::optional<std::string> conformance) {
176+
SwiftConformance = conformance;
177+
}
178+
168179
friend bool operator==(const CommonTypeInfo &, const CommonTypeInfo &);
169180

170181
CommonTypeInfo &operator|=(const CommonTypeInfo &RHS) {
@@ -175,6 +186,8 @@ class CommonTypeInfo : public CommonEntityInfo {
175186
setSwiftBridge(RHS.getSwiftBridge());
176187
if (!NSErrorDomain)
177188
setNSErrorDomain(RHS.getNSErrorDomain());
189+
if (SwiftConformance)
190+
setSwiftConformance(RHS.getSwiftConformance());
178191

179192
return *this;
180193
}
@@ -185,7 +198,8 @@ class CommonTypeInfo : public CommonEntityInfo {
185198
inline bool operator==(const CommonTypeInfo &LHS, const CommonTypeInfo &RHS) {
186199
return static_cast<const CommonEntityInfo &>(LHS) == RHS &&
187200
LHS.SwiftBridge == RHS.SwiftBridge &&
188-
LHS.NSErrorDomain == RHS.NSErrorDomain;
201+
LHS.NSErrorDomain == RHS.NSErrorDomain &&
202+
LHS.SwiftConformance == RHS.SwiftConformance;
189203
}
190204

191205
inline bool operator!=(const CommonTypeInfo &LHS, const CommonTypeInfo &RHS) {
@@ -739,9 +753,6 @@ class TagInfo : public CommonTypeInfo {
739753
std::optional<std::string> SwiftReleaseOp;
740754
std::optional<std::string> SwiftDefaultOwnership;
741755

742-
/// The Swift protocol that this type should be automatically conformed to.
743-
std::optional<std::string> SwiftConformance;
744-
745756
std::optional<EnumExtensibilityKind> EnumExtensibility;
746757

747758
TagInfo()
@@ -790,9 +801,6 @@ class TagInfo : public CommonTypeInfo {
790801
if (!SwiftDefaultOwnership)
791802
SwiftDefaultOwnership = RHS.SwiftDefaultOwnership;
792803

793-
if (!SwiftConformance)
794-
SwiftConformance = RHS.SwiftConformance;
795-
796804
if (!HasFlagEnum)
797805
setFlagEnum(RHS.isFlagEnum());
798806

@@ -819,7 +827,6 @@ inline bool operator==(const TagInfo &LHS, const TagInfo &RHS) {
819827
LHS.SwiftRetainOp == RHS.SwiftRetainOp &&
820828
LHS.SwiftReleaseOp == RHS.SwiftReleaseOp &&
821829
LHS.SwiftDefaultOwnership == RHS.SwiftDefaultOwnership &&
822-
LHS.SwiftConformance == RHS.SwiftConformance &&
823830
LHS.isFlagEnum() == RHS.isFlagEnum() &&
824831
LHS.isSwiftCopyable() == RHS.isSwiftCopyable() &&
825832
LHS.isSwiftEscapable() == RHS.isSwiftEscapable() &&

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,13 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
212212
return create<cir::AllocaOp>(loc, addrType, type, name, alignment);
213213
}
214214

215+
/// Get constant address of a global variable as an MLIR attribute.
216+
cir::GlobalViewAttr getGlobalViewAttr(cir::PointerType type,
217+
cir::GlobalOp globalOp) {
218+
auto symbol = mlir::FlatSymbolRefAttr::get(globalOp.getSymNameAttr());
219+
return cir::GlobalViewAttr::get(type, symbol);
220+
}
221+
215222
mlir::Value createGetGlobal(mlir::Location loc, cir::GlobalOp global) {
216223
assert(!cir::MissingFeatures::addressSpace());
217224
return create<cir::GetGlobalOp>(loc, getPointerTo(global.getSymType()),

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

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,53 @@ def CIR_ConstPtrAttr : CIR_Attr<"ConstPtr", "ptr", [TypedAttrInterface]> {
370370
}];
371371
}
372372

373+
//===----------------------------------------------------------------------===//
374+
// GlobalViewAttr
375+
//===----------------------------------------------------------------------===//
376+
377+
def CIR_GlobalViewAttr : CIR_Attr<"GlobalView", "global_view", [
378+
TypedAttrInterface
379+
]> {
380+
let summary = "Provides constant access to a global address";
381+
let description = [{
382+
Get constant address of global `symbol`. It provides a way to access globals
383+
from other global and always produces a pointer.
384+
385+
The type of the input symbol can be different from `#cir.global_view`
386+
output type, since a given view of the global might require a static
387+
cast for initializing other globals.
388+
389+
The result type of this attribute may be an integer type. In such a case,
390+
the pointer to the referenced global is casted to an integer and this
391+
attribute represents the casted result.
392+
393+
Example:
394+
395+
```
396+
cir.global external @s = @".str2": !cir.ptr<i8>
397+
cir.global external @x = #cir.global_view<@s> : !cir.ptr<i8>
398+
cir.global external @s_addr = #cir.global_view<@s> : !s64i
399+
```
400+
}];
401+
402+
let parameters = (ins AttributeSelfTypeParameter<"">:$type,
403+
"mlir::FlatSymbolRefAttr":$symbol);
404+
405+
let builders = [
406+
AttrBuilderWithInferredContext<(ins "mlir::Type":$type,
407+
"mlir::FlatSymbolRefAttr":$symbol), [{
408+
return $_get(type.getContext(), type, symbol);
409+
}]>
410+
];
411+
412+
// let genVerifyDecl = 1;
413+
let assemblyFormat = [{
414+
`<`
415+
$symbol
416+
`>`
417+
}];
418+
}
419+
373420
//===----------------------------------------------------------------------===//
374421
// ConstComplexAttr
375422
//===----------------------------------------------------------------------===//

clang/include/clang/CIR/MissingFeatures.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ struct MissingFeatures {
192192
static bool constantFoldSwitchStatement() { return false; }
193193
static bool constructABIArgDirectExtend() { return false; }
194194
static bool coverageMapping() { return false; }
195+
static bool createInvariantGroup() { return false; }
195196
static bool createProfileWeightsForLoop() { return false; }
196197
static bool ctorMemcpyizer() { return false; }
197198
static bool cudaSupport() { return false; }
@@ -200,6 +201,8 @@ struct MissingFeatures {
200201
static bool deferredCXXGlobalInit() { return false; }
201202
static bool ehCleanupFlags() { return false; }
202203
static bool ehCleanupScope() { return false; }
204+
static bool ehCleanupScopeRequiresEHCleanup() { return false; }
205+
static bool ehCleanupBranchFixups() { return false; }
203206
static bool ehstackBranches() { return false; }
204207
static bool emitCheckedInBoundsGEP() { return false; }
205208
static bool emitCondLikelihoodViaExpectIntrinsic() { return false; }
@@ -210,9 +213,12 @@ struct MissingFeatures {
210213
static bool fastMathFlags() { return false; }
211214
static bool fpConstraints() { return false; }
212215
static bool generateDebugInfo() { return false; }
216+
static bool globalViewIndices() { return false; }
217+
static bool globalViewIntLowering() { return false; }
213218
static bool hip() { return false; }
214219
static bool implicitConstructorArgs() { return false; }
215220
static bool incrementProfileCounter() { return false; }
221+
static bool innermostEHScope() { return false; }
216222
static bool insertBuiltinUnpredictable() { return false; }
217223
static bool instrumentation() { return false; }
218224
static bool intrinsics() { return false; }
@@ -233,7 +239,6 @@ struct MissingFeatures {
233239
static bool objCGC() { return false; }
234240
static bool objCLifetime() { return false; }
235241
static bool openMP() { return false; }
236-
static bool opGlobalViewAttr() { return false; }
237242
static bool opTBAA() { return false; }
238243
static bool peepholeProtection() { return false; }
239244
static bool pgoUse() { return false; }
@@ -260,6 +265,7 @@ struct MissingFeatures {
260265
static bool appleKext() { return false; }
261266
static bool dtorCleanups() { return false; }
262267
static bool vtableInitialization() { return false; }
268+
static bool vtableRelativeLayout() { return false; }
263269
static bool msvcBuiltins() { return false; }
264270
static bool vlas() { return false; }
265271

clang/include/clang/Interpreter/RemoteJITUtils.h

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@
2626

2727
llvm::Expected<std::unique_ptr<llvm::orc::SimpleRemoteEPC>>
2828
launchExecutor(llvm::StringRef ExecutablePath, bool UseSharedMemory,
29-
llvm::StringRef SlabAllocateSizeString,
30-
std::function<void()> CustomizeFork = nullptr);
29+
llvm::StringRef SlabAllocateSizeString);
3130

3231
/// Create a JITLinkExecutor that connects to the given network address
3332
/// through a TCP socket. A valid NetworkAddress provides hostname and port,
@@ -36,13 +35,4 @@ llvm::Expected<std::unique_ptr<llvm::orc::SimpleRemoteEPC>>
3635
connectTCPSocket(llvm::StringRef NetworkAddress, bool UseSharedMemory,
3736
llvm::StringRef SlabAllocateSizeString);
3837

39-
#ifdef LLVM_ON_UNIX
40-
/// Returns PID of last launched executor.
41-
pid_t getLastLaunchedExecutorPID();
42-
43-
/// Returns PID of nth launched executor.
44-
/// 1-based indexing.
45-
pid_t getNthLaunchedExecutorPID(int n);
46-
#endif
47-
4838
#endif // LLVM_CLANG_INTERPRETER_REMOTEJITUTILS_H

clang/lib/APINotes/APINotesFormat.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const uint16_t VERSION_MAJOR = 0;
2424
/// API notes file minor version number.
2525
///
2626
/// When the format changes IN ANY WAY, this number should be incremented.
27-
const uint16_t VERSION_MINOR = 35; // SwiftDefaultOwnership
27+
const uint16_t VERSION_MINOR = 36; // Typedef SwiftConformsTo
2828

2929
const uint8_t kSwiftConforms = 1;
3030
const uint8_t kSwiftDoesNotConform = 2;

clang/lib/APINotes/APINotesReader.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,13 @@ void ReadCommonTypeInfo(const uint8_t *&Data, CommonTypeInfo &Info) {
134134
reinterpret_cast<const char *>(Data), ErrorDomainLength - 1)));
135135
Data += ErrorDomainLength - 1;
136136
}
137+
138+
if (unsigned ConformanceLength =
139+
endian::readNext<uint16_t, llvm::endianness::little>(Data)) {
140+
Info.setSwiftConformance(std::string(reinterpret_cast<const char *>(Data),
141+
ConformanceLength - 1));
142+
Data += ConformanceLength - 1;
143+
}
137144
}
138145

139146
/// Used to deserialize the on-disk identifier table.
@@ -629,12 +636,6 @@ class TagTableInfo
629636
reinterpret_cast<const char *>(Data), DefaultOwnershipLength - 1);
630637
Data += DefaultOwnershipLength - 1;
631638
}
632-
if (unsigned ConformanceLength =
633-
endian::readNext<uint16_t, llvm::endianness::little>(Data)) {
634-
Info.SwiftConformance = std::string(reinterpret_cast<const char *>(Data),
635-
ConformanceLength - 1);
636-
Data += ConformanceLength - 1;
637-
}
638639

639640
ReadCommonTypeInfo(Data, Info);
640641
return Info;

clang/lib/APINotes/APINotesWriter.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,8 @@ unsigned getCommonEntityInfoSize(const CommonEntityInfo &CEI) {
536536
// in on-disk hash tables.
537537
unsigned getCommonTypeInfoSize(const CommonTypeInfo &CTI) {
538538
return 2 + (CTI.getSwiftBridge() ? CTI.getSwiftBridge()->size() : 0) + 2 +
539-
(CTI.getNSErrorDomain() ? CTI.getNSErrorDomain()->size() : 0) +
539+
(CTI.getNSErrorDomain() ? CTI.getNSErrorDomain()->size() : 0) + 2 +
540+
(CTI.getSwiftConformance() ? CTI.getSwiftConformance()->size() : 0) +
540541
getCommonEntityInfoSize(CTI);
541542
}
542543

@@ -557,6 +558,12 @@ void emitCommonTypeInfo(raw_ostream &OS, const CommonTypeInfo &CTI) {
557558
} else {
558559
writer.write<uint16_t>(0);
559560
}
561+
if (auto conformance = CTI.getSwiftConformance()) {
562+
writer.write<uint16_t>(conformance->size() + 1);
563+
OS.write(conformance->c_str(), conformance->size());
564+
} else {
565+
writer.write<uint16_t>(0);
566+
}
560567
}
561568

562569
/// Used to serialize the on-disk Objective-C property table.
@@ -1274,7 +1281,6 @@ class TagTableInfo : public CommonTypeTableInfo<TagTableInfo, TagInfo> {
12741281
2 + (TI.SwiftRetainOp ? TI.SwiftRetainOp->size() : 0) +
12751282
2 + (TI.SwiftReleaseOp ? TI.SwiftReleaseOp->size() : 0) +
12761283
2 + (TI.SwiftDefaultOwnership ? TI.SwiftDefaultOwnership->size() : 0) +
1277-
2 + (TI.SwiftConformance ? TI.SwiftConformance->size() : 0) +
12781284
3 + getCommonTypeInfoSize(TI);
12791285
// clang-format on
12801286
}
@@ -1328,12 +1334,6 @@ class TagTableInfo : public CommonTypeTableInfo<TagTableInfo, TagInfo> {
13281334
} else {
13291335
writer.write<uint16_t>(0);
13301336
}
1331-
if (auto Conformance = TI.SwiftConformance) {
1332-
writer.write<uint16_t>(Conformance->size() + 1);
1333-
OS.write(Conformance->c_str(), Conformance->size());
1334-
} else {
1335-
writer.write<uint16_t>(0);
1336-
}
13371337

13381338
emitCommonTypeInfo(OS, TI);
13391339
}

clang/lib/APINotes/APINotesYAMLCompiler.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ struct Class {
251251
std::optional<StringRef> NSErrorDomain;
252252
std::optional<bool> SwiftImportAsNonGeneric;
253253
std::optional<bool> SwiftObjCMembers;
254+
std::optional<std::string> SwiftConformance;
254255
MethodsSeq Methods;
255256
PropertiesSeq Properties;
256257
};
@@ -275,6 +276,7 @@ template <> struct MappingTraits<Class> {
275276
IO.mapOptional("NSErrorDomain", C.NSErrorDomain);
276277
IO.mapOptional("SwiftImportAsNonGeneric", C.SwiftImportAsNonGeneric);
277278
IO.mapOptional("SwiftObjCMembers", C.SwiftObjCMembers);
279+
IO.mapOptional("SwiftConformsTo", C.SwiftConformance);
278280
IO.mapOptional("Methods", C.Methods);
279281
IO.mapOptional("Properties", C.Properties);
280282
}
@@ -525,6 +527,7 @@ struct Typedef {
525527
std::optional<StringRef> SwiftBridge;
526528
std::optional<StringRef> NSErrorDomain;
527529
std::optional<SwiftNewTypeKind> SwiftType;
530+
std::optional<std::string> SwiftConformance;
528531
};
529532

530533
typedef std::vector<Typedef> TypedefsSeq;
@@ -553,6 +556,7 @@ template <> struct MappingTraits<Typedef> {
553556
IO.mapOptional("SwiftBridge", T.SwiftBridge);
554557
IO.mapOptional("NSErrorDomain", T.NSErrorDomain);
555558
IO.mapOptional("SwiftWrapper", T.SwiftType);
559+
IO.mapOptional("SwiftConformsTo", T.SwiftConformance);
556560
}
557561
};
558562
} // namespace yaml
@@ -802,6 +806,8 @@ class YAMLConverter {
802806
if (Common.SwiftBridge)
803807
Info.setSwiftBridge(std::string(*Common.SwiftBridge));
804808
Info.setNSErrorDomain(Common.NSErrorDomain);
809+
if (auto conformance = Common.SwiftConformance)
810+
Info.setSwiftConformance(conformance);
805811
}
806812

807813
// Translate from Method into ObjCMethodInfo and write it out.
@@ -990,8 +996,6 @@ class YAMLConverter {
990996
TI.SwiftRetainOp = T.SwiftRetainOp;
991997
if (T.SwiftReleaseOp)
992998
TI.SwiftReleaseOp = T.SwiftReleaseOp;
993-
if (T.SwiftConformance)
994-
TI.SwiftConformance = T.SwiftConformance;
995999
if (T.SwiftDefaultOwnership)
9961000
TI.SwiftDefaultOwnership = T.SwiftDefaultOwnership;
9971001

clang/lib/CIR/CodeGen/CIRGenBuilder.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,17 @@ class CIRGenBuilderTy : public cir::CIRBaseBuilderTy {
244244
}
245245
bool isInt(mlir::Type i) { return mlir::isa<cir::IntType>(i); }
246246

247+
// Fetch the type representing a pointer to unsigned int8 values.
248+
cir::PointerType getUInt8PtrTy() { return typeCache.UInt8PtrTy; }
249+
250+
/// Get a CIR anonymous record type.
251+
cir::RecordType getAnonRecordTy(llvm::ArrayRef<mlir::Type> members,
252+
bool packed = false, bool padded = false) {
253+
assert(!cir::MissingFeatures::astRecordDeclAttr());
254+
auto kind = cir::RecordType::RecordKind::Struct;
255+
return getType<cir::RecordType>(members, packed, padded, kind);
256+
}
257+
247258
//
248259
// Constant creation helpers
249260
// -------------------------

0 commit comments

Comments
 (0)