mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Get rid of _stdlib_didEnterMain
Process arguments are now fetched per-platform
This commit is contained in:
@@ -64,7 +64,6 @@ FUNC_DECL(BridgeAnyObjectToAny,
|
|||||||
|
|
||||||
FUNC_DECL(ConvertToAnyHashable, "_convertToAnyHashable")
|
FUNC_DECL(ConvertToAnyHashable, "_convertToAnyHashable")
|
||||||
|
|
||||||
FUNC_DECL(DidEnterMain, "_stdlib_didEnterMain")
|
|
||||||
FUNC_DECL(DiagnoseUnexpectedNilOptional, "_diagnoseUnexpectedNilOptional")
|
FUNC_DECL(DiagnoseUnexpectedNilOptional, "_diagnoseUnexpectedNilOptional")
|
||||||
|
|
||||||
FUNC_DECL(GetErrorEmbeddedNSError, "_stdlib_getErrorEmbeddedNSError")
|
FUNC_DECL(GetErrorEmbeddedNSError, "_stdlib_getErrorEmbeddedNSError")
|
||||||
|
|||||||
@@ -34,8 +34,10 @@ namespace swift {
|
|||||||
|
|
||||||
namespace immediate {
|
namespace immediate {
|
||||||
|
|
||||||
// Returns a handle to the runtime suitable for other 'dlsym' or 'dlclose'
|
/// Returns a handle to the runtime suitable for other \c dlsym or \c dlclose
|
||||||
// calls or 'NULL' if an error occurred.
|
/// calls or \c null if an error occurred.
|
||||||
|
///
|
||||||
|
/// \param runtimeLibPath Path to search for compiler-relative stdlib dylibs.
|
||||||
void *loadSwiftRuntime(StringRef runtimeLibPath);
|
void *loadSwiftRuntime(StringRef runtimeLibPath);
|
||||||
bool tryLoadLibraries(ArrayRef<LinkLibrary> LinkLibraries,
|
bool tryLoadLibraries(ArrayRef<LinkLibrary> LinkLibraries,
|
||||||
SearchPathOptions SearchPathOpts,
|
SearchPathOptions SearchPathOpts,
|
||||||
|
|||||||
@@ -1223,29 +1223,6 @@ void SILGenModule::visitTopLevelCodeDecl(TopLevelCodeDecl *td) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void emitTopLevelProlog(SILGenFunction &gen, SILLocation loc) {
|
|
||||||
assert(gen.B.getInsertionBB()->getIterator() == gen.F.begin()
|
|
||||||
&& "not at entry point?!");
|
|
||||||
|
|
||||||
SILBasicBlock *entry = gen.B.getInsertionBB();
|
|
||||||
// Create the argc and argv arguments.
|
|
||||||
auto &C = gen.getASTContext();
|
|
||||||
auto FnTy = gen.F.getLoweredFunctionType();
|
|
||||||
auto *argc = entry->createArgument(FnTy->getParameters()[0].getSILType());
|
|
||||||
auto *argv = entry->createArgument(FnTy->getParameters()[1].getSILType());
|
|
||||||
|
|
||||||
// If the standard library provides a _stdlib_didEnterMain intrinsic, call it
|
|
||||||
// first thing.
|
|
||||||
if (auto didEnterMain = C.getDidEnterMain(nullptr)) {
|
|
||||||
ManagedValue params[] = {
|
|
||||||
ManagedValue::forUnmanaged(argc),
|
|
||||||
ManagedValue::forUnmanaged(argv),
|
|
||||||
};
|
|
||||||
(void) gen.emitApplyOfLibraryIntrinsic(loc, didEnterMain, {}, params,
|
|
||||||
SGFContext());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void SILGenModule::useConformance(ProtocolConformanceRef conformanceRef) {
|
void SILGenModule::useConformance(ProtocolConformanceRef conformanceRef) {
|
||||||
// We don't need to emit dependent conformances.
|
// We don't need to emit dependent conformances.
|
||||||
if (conformanceRef.isAbstract())
|
if (conformanceRef.isAbstract())
|
||||||
@@ -1308,9 +1285,13 @@ public:
|
|||||||
sgm.TopLevelSGF->prepareRethrowEpilog(
|
sgm.TopLevelSGF->prepareRethrowEpilog(
|
||||||
CleanupLocation::getModuleCleanupLocation());
|
CleanupLocation::getModuleCleanupLocation());
|
||||||
|
|
||||||
|
// Create the argc and argv arguments.
|
||||||
auto PrologueLoc = RegularLocation::getModuleLocation();
|
auto PrologueLoc = RegularLocation::getModuleLocation();
|
||||||
PrologueLoc.markAsPrologue();
|
PrologueLoc.markAsPrologue();
|
||||||
emitTopLevelProlog(*sgm.TopLevelSGF, PrologueLoc);
|
auto entry = sgm.TopLevelSGF->B.getInsertionBB();
|
||||||
|
auto FnTy = sgm.TopLevelSGF->F.getLoweredFunctionType();
|
||||||
|
entry->createArgument(FnTy->getParameters()[0].getSILType());
|
||||||
|
entry->createArgument(FnTy->getParameters()[1].getSILType());
|
||||||
|
|
||||||
scope.emplace(sgm.TopLevelSGF->Cleanups,
|
scope.emplace(sgm.TopLevelSGF->Cleanups,
|
||||||
CleanupLocation::getModuleCleanupLocation());
|
CleanupLocation::getModuleCleanupLocation());
|
||||||
@@ -1409,8 +1390,12 @@ public:
|
|||||||
// Assign a debug scope pointing into the void to the top level function.
|
// Assign a debug scope pointing into the void to the top level function.
|
||||||
toplevel->setDebugScope(new (sgm.M) SILDebugScope(TopLevelLoc, toplevel));
|
toplevel->setDebugScope(new (sgm.M) SILDebugScope(TopLevelLoc, toplevel));
|
||||||
|
|
||||||
|
// Create the argc and argv arguments.
|
||||||
SILGenFunction gen(sgm, *toplevel);
|
SILGenFunction gen(sgm, *toplevel);
|
||||||
emitTopLevelProlog(gen, mainClass);
|
auto entry = gen.B.getInsertionBB();
|
||||||
|
auto FnTy = gen.F.getLoweredFunctionType();
|
||||||
|
entry->createArgument(FnTy->getParameters()[0].getSILType());
|
||||||
|
entry->createArgument(FnTy->getParameters()[1].getSILType());
|
||||||
gen.emitArtificialTopLevel(mainClass);
|
gen.emitArtificialTopLevel(mainClass);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,23 +47,3 @@ public enum CommandLine {
|
|||||||
public static var arguments: [String]
|
public static var arguments: [String]
|
||||||
= (0..<Int(argc)).map { String(cString: _unsafeArgv[$0]!) }
|
= (0..<Int(argc)).map { String(cString: _unsafeArgv[$0]!) }
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME(ABI)#25 : Remove this and the entrypoints in SILGen.
|
|
||||||
// rdar://problem/19696522
|
|
||||||
@_transparent
|
|
||||||
public // COMPILER_INTRINSIC
|
|
||||||
func _stdlib_didEnterMain(
|
|
||||||
argc: Int32, argv: UnsafeMutablePointer<UnsafeMutablePointer<Int8>?>
|
|
||||||
) {
|
|
||||||
// Initialize the CommandLine.argc and CommandLine.unsafeArgv variables with the
|
|
||||||
// values that were passed in to main.
|
|
||||||
CommandLine._argc = Int32(argc)
|
|
||||||
CommandLine._unsafeArgv = argv
|
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME: Move this to HashedCollections.swift.gyb
|
|
||||||
internal class _Box<Wrapped> {
|
|
||||||
internal var _value: Wrapped
|
|
||||||
internal init(_ value: Wrapped) { self._value = value }
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,6 @@ markUsed(a+b)
|
|||||||
// CHECK: _main:
|
// CHECK: _main:
|
||||||
// Verify that the top-level function (main) begins at line 0 and then
|
// Verify that the top-level function (main) begins at line 0 and then
|
||||||
// proceeds to line 6.
|
// proceeds to line 6.
|
||||||
// CHECK: .loc {{[0-9]}} 0 {{[0-9]}} prologue_end
|
// CHECK: .loc {{[0-9]}} 0 {{[0-9]}}
|
||||||
// CHECK-NOT: .loc
|
// CHECK-NOT: .loc
|
||||||
// CHECK: .loc {{[0-9]}} 6 {{[0-9]}}
|
// CHECK: .loc {{[0-9]}} 6 {{[0-9]}} prologue_end
|
||||||
|
|||||||
@@ -37,8 +37,8 @@ extension def_enum.TrafficLight : Error {}
|
|||||||
|
|
||||||
extension def_enum.Term : Error {}
|
extension def_enum.Term : Error {}
|
||||||
|
|
||||||
// CHECK-NORMAL-LABEL: define hidden i64 @_TFO12enum_derived7Phantomg8rawValueVs5Int64(i1, %swift.type* nocapture readnone %T) local_unnamed_addr #1
|
// CHECK-NORMAL-LABEL: define hidden i64 @_TFO12enum_derived7Phantomg8rawValueVs5Int64(i1, %swift.type* nocapture readnone %T) local_unnamed_addr #0
|
||||||
// CHECK-TESTABLE-LABEL: define{{( protected)?}} i64 @_TFO12enum_derived7Phantomg8rawValueVs5Int64(i1, %swift.type* nocapture readnone %T) #1
|
// CHECK-TESTABLE-LABEL: define{{( protected)?}} i64 @_TFO12enum_derived7Phantomg8rawValueVs5Int64(i1, %swift.type* nocapture readnone %T) #0
|
||||||
|
|
||||||
enum Phantom<T> : Int64 {
|
enum Phantom<T> : Int64 {
|
||||||
case Up
|
case Up
|
||||||
|
|||||||
Reference in New Issue
Block a user