Skip to content

Commit 8a723e9

Browse files
authored
merge main into amd-staging (llvm#1311)
2 parents 8fc2840 + 272c110 commit 8a723e9

File tree

151 files changed

+11836
-375
lines changed

Some content is hidden

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

151 files changed

+11836
-375
lines changed

clang/include/clang/Basic/ObjCRuntime.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ class ObjCRuntime {
473473
case GCC: return false;
474474
case GNUstep:
475475
return (getVersion() >= VersionTuple(2, 2));
476-
case ObjFW: return false;
476+
case ObjFW: return true;
477477
}
478478
llvm_unreachable("bad kind");
479479
}

clang/lib/CodeGen/CGObjCGNU.cpp

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2224,6 +2224,96 @@ class CGObjCObjFW: public CGObjCGNU {
22242224
return ClassSymbol;
22252225
}
22262226

2227+
void GenerateDirectMethodPrologue(
2228+
CodeGenFunction &CGF, llvm::Function *Fn, const ObjCMethodDecl *OMD,
2229+
const ObjCContainerDecl *CD) override {
2230+
auto &Builder = CGF.Builder;
2231+
bool ReceiverCanBeNull = true;
2232+
auto selfAddr = CGF.GetAddrOfLocalVar(OMD->getSelfDecl());
2233+
auto selfValue = Builder.CreateLoad(selfAddr);
2234+
2235+
// Generate:
2236+
//
2237+
// /* for class methods only to force class lazy initialization */
2238+
// self = [self self];
2239+
//
2240+
// /* unless the receiver is never NULL */
2241+
// if (self == nil) {
2242+
// return (ReturnType){ };
2243+
// }
2244+
//
2245+
// _cmd = @selector(...)
2246+
// ...
2247+
2248+
if (OMD->isClassMethod()) {
2249+
const ObjCInterfaceDecl *OID = cast<ObjCInterfaceDecl>(CD);
2250+
assert(
2251+
OID &&
2252+
"GenerateDirectMethod() should be called with the Class Interface");
2253+
Selector SelfSel = GetNullarySelector("self", CGM.getContext());
2254+
auto ResultType = CGF.getContext().getObjCIdType();
2255+
RValue result;
2256+
CallArgList Args;
2257+
2258+
// TODO: If this method is inlined, the caller might know that `self` is
2259+
// already initialized; for example, it might be an ordinary Objective-C
2260+
// method which always receives an initialized `self`, or it might have
2261+
// just forced initialization on its own.
2262+
//
2263+
// We should find a way to eliminate this unnecessary initialization in
2264+
// such cases in LLVM.
2265+
result = GeneratePossiblySpecializedMessageSend(
2266+
CGF, ReturnValueSlot(), ResultType, SelfSel, selfValue, Args, OID,
2267+
nullptr, true);
2268+
Builder.CreateStore(result.getScalarVal(), selfAddr);
2269+
2270+
// Nullable `Class` expressions cannot be messaged with a direct method
2271+
// so the only reason why the receive can be null would be because
2272+
// of weak linking.
2273+
ReceiverCanBeNull = isWeakLinkedClass(OID);
2274+
}
2275+
2276+
if (ReceiverCanBeNull) {
2277+
llvm::BasicBlock *SelfIsNilBlock =
2278+
CGF.createBasicBlock("objc_direct_method.self_is_nil");
2279+
llvm::BasicBlock *ContBlock =
2280+
CGF.createBasicBlock("objc_direct_method.cont");
2281+
2282+
// if (self == nil) {
2283+
auto selfTy = cast<llvm::PointerType>(selfValue->getType());
2284+
auto Zero = llvm::ConstantPointerNull::get(selfTy);
2285+
2286+
llvm::MDBuilder MDHelper(CGM.getLLVMContext());
2287+
Builder.CreateCondBr(Builder.CreateICmpEQ(selfValue, Zero),
2288+
SelfIsNilBlock, ContBlock,
2289+
MDHelper.createUnlikelyBranchWeights());
2290+
2291+
CGF.EmitBlock(SelfIsNilBlock);
2292+
2293+
// return (ReturnType){ };
2294+
auto retTy = OMD->getReturnType();
2295+
Builder.SetInsertPoint(SelfIsNilBlock);
2296+
if (!retTy->isVoidType()) {
2297+
CGF.EmitNullInitialization(CGF.ReturnValue, retTy);
2298+
}
2299+
CGF.EmitBranchThroughCleanup(CGF.ReturnBlock);
2300+
// }
2301+
2302+
// rest of the body
2303+
CGF.EmitBlock(ContBlock);
2304+
Builder.SetInsertPoint(ContBlock);
2305+
}
2306+
2307+
// only synthesize _cmd if it's referenced
2308+
if (OMD->getCmdDecl()->isUsed()) {
2309+
// `_cmd` is not a parameter to direct methods, so storage must be
2310+
// explicitly declared for it.
2311+
CGF.EmitVarDecl(*OMD->getCmdDecl());
2312+
Builder.CreateStore(GetSelector(CGF, OMD),
2313+
CGF.GetAddrOfLocalVar(OMD->getCmdDecl()));
2314+
}
2315+
}
2316+
22272317
public:
22282318
CGObjCObjFW(CodeGenModule &Mod): CGObjCGNU(Mod, 9, 3) {
22292319
// IMP objc_msg_lookup(id, SEL);

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2914,6 +2914,17 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
29142914
CmdArgs.push_back("-target-feature");
29152915
CmdArgs.push_back(MipsTargetFeature);
29162916
}
2917+
2918+
// Those OSes default to enabling VIS on 64-bit SPARC.
2919+
// See also the corresponding code for external assemblers in
2920+
// sparc::getSparcAsmModeForCPU().
2921+
bool IsSparcV9ATarget =
2922+
(C.getDefaultToolChain().getArch() == llvm::Triple::sparcv9) &&
2923+
(Triple.isOSLinux() || Triple.isOSFreeBSD() || Triple.isOSOpenBSD());
2924+
if (IsSparcV9ATarget && SparcTargetFeatures.empty()) {
2925+
CmdArgs.push_back("-target-feature");
2926+
CmdArgs.push_back("+vis");
2927+
}
29172928
for (const char *Feature : SparcTargetFeatures) {
29182929
CmdArgs.push_back("-target-feature");
29192930
CmdArgs.push_back(Feature);

clang/test/Driver/sparc-ias-Wa.s

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,12 @@
5858
// V9D: "-target-feature" "+vis"
5959
// V9D: "-target-feature" "+vis2"
6060
// V9D: "-target-feature" "+vis3"
61+
62+
// RUN: %clang --target=sparc64-linux-gnu -### -fintegrated-as -c %s 2>&1 | \
63+
// RUN: FileCheck -check-prefix=VIS-DEFAULT %s
64+
// RUN: %clang --target=sparc64-freebsd -### -fintegrated-as -c %s 2>&1 | \
65+
// RUN: FileCheck -check-prefix=VIS-DEFAULT %s
66+
// RUN: %clang --target=sparc64-openbsd -### -fintegrated-as -c %s 2>&1 | \
67+
// RUN: FileCheck -check-prefix=VIS-DEFAULT %s
68+
// VIS-DEFAULT: -cc1as
69+
// VIS-DEFAULT: "-target-feature" "+vis"

libcxx/docs/ReleaseNotes/21.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Implemented Papers
4343
- P1361R2: Integration of chrono with text formatting (`Github <https://github.com/llvm/llvm-project/issues/100014>`__)
4444
- P2255R2: A type trait to detect reference binding to temporary (implemented the type traits only) (`Github <https://github.com/llvm/llvm-project/issues/105180>`__)
4545
- P2562R1: ``constexpr`` Stable Sorting (`Github <https://github.com/llvm/llvm-project/issues/105360>`__)
46+
- P1222R4: A Standard ``flat_set`` is partially implemented and ``flat_set`` is provided (`Github <https://github.com/llvm/llvm-project/issues/105193>`__)
4647

4748
Improvements and New Features
4849
-----------------------------

libcxx/docs/Status/Cxx23Papers.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"`P0009R18 <https://wg21.link/P0009R18>`__","mdspan: A Non-Owning Multidimensional Array Reference","2022-07 (Virtual)","|Complete|","18",""
5555
"`P0429R9 <https://wg21.link/P0429R9>`__","A Standard ``flat_map``","2022-07 (Virtual)","|Complete|","20",""
5656
"`P1169R4 <https://wg21.link/P1169R4>`__","``static operator()``","2022-07 (Virtual)","|Complete|","16",""
57-
"`P1222R4 <https://wg21.link/P1222R4>`__","A Standard ``flat_set``","2022-07 (Virtual)","","",""
57+
"`P1222R4 <https://wg21.link/P1222R4>`__","A Standard ``flat_set``","2022-07 (Virtual)","|In progress|","",""
5858
"`P1223R5 <https://wg21.link/P1223R5>`__","``ranges::find_last()``, ``ranges::find_last_if()``, and ``ranges::find_last_if_not()``","2022-07 (Virtual)","|Complete|","19",""
5959
"`P1467R9 <https://wg21.link/P1467R9>`__","Extended ``floating-point`` types and standard names","2022-07 (Virtual)","","",""
6060
"`P1642R11 <https://wg21.link/P1642R11>`__","Freestanding ``[utilities]``, ``[ranges]``, and ``[iterators]``","2022-07 (Virtual)","","",""

libcxx/include/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,8 @@ set(files
369369
__flat_map/sorted_equivalent.h
370370
__flat_map/sorted_unique.h
371371
__flat_map/utils.h
372+
__flat_set/flat_set.h
373+
__flat_set/ra_iterator.h
372374
__format/buffer.h
373375
__format/concepts.h
374376
__format/container_adaptor.h
@@ -995,6 +997,7 @@ set(files
995997
fenv.h
996998
filesystem
997999
flat_map
1000+
flat_set
9981001
float.h
9991002
format
10001003
forward_list

0 commit comments

Comments
 (0)