Get rid of _stdlib_didEnterMain

Process arguments are now fetched per-platform
This commit is contained in:
Robert Widmann
2016-07-13 23:52:23 -07:00
parent 0586bc6a3d
commit fe00dc74ea
6 changed files with 18 additions and 52 deletions

View File

@@ -64,7 +64,6 @@ FUNC_DECL(BridgeAnyObjectToAny,
FUNC_DECL(ConvertToAnyHashable, "_convertToAnyHashable")
FUNC_DECL(DidEnterMain, "_stdlib_didEnterMain")
FUNC_DECL(DiagnoseUnexpectedNilOptional, "_diagnoseUnexpectedNilOptional")
FUNC_DECL(GetErrorEmbeddedNSError, "_stdlib_getErrorEmbeddedNSError")

View File

@@ -34,8 +34,10 @@ namespace swift {
namespace immediate {
// Returns a handle to the runtime suitable for other 'dlsym' or 'dlclose'
// calls or 'NULL' if an error occurred.
/// Returns a handle to the runtime suitable for other \c dlsym or \c dlclose
/// calls or \c null if an error occurred.
///
/// \param runtimeLibPath Path to search for compiler-relative stdlib dylibs.
void *loadSwiftRuntime(StringRef runtimeLibPath);
bool tryLoadLibraries(ArrayRef<LinkLibrary> LinkLibraries,
SearchPathOptions SearchPathOpts,

View File

@@ -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) {
// We don't need to emit dependent conformances.
if (conformanceRef.isAbstract())
@@ -1308,9 +1285,13 @@ public:
sgm.TopLevelSGF->prepareRethrowEpilog(
CleanupLocation::getModuleCleanupLocation());
// Create the argc and argv arguments.
auto PrologueLoc = RegularLocation::getModuleLocation();
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,
CleanupLocation::getModuleCleanupLocation());
@@ -1409,8 +1390,12 @@ public:
// Assign a debug scope pointing into the void to the top level function.
toplevel->setDebugScope(new (sgm.M) SILDebugScope(TopLevelLoc, toplevel));
// Create the argc and argv arguments.
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);
}
}

View File

@@ -47,23 +47,3 @@ public enum CommandLine {
public static var arguments: [String]
= (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 }
}

View File

@@ -9,6 +9,6 @@ markUsed(a+b)
// CHECK: _main:
// Verify that the top-level function (main) begins at line 0 and then
// proceeds to line 6.
// CHECK: .loc {{[0-9]}} 0 {{[0-9]}} prologue_end
// CHECK: .loc {{[0-9]}} 0 {{[0-9]}}
// CHECK-NOT: .loc
// CHECK: .loc {{[0-9]}} 6 {{[0-9]}}
// CHECK: .loc {{[0-9]}} 6 {{[0-9]}} prologue_end

View File

@@ -37,8 +37,8 @@ extension def_enum.TrafficLight : 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-TESTABLE-LABEL: define{{( protected)?}} i64 @_TFO12enum_derived7Phantomg8rawValueVs5Int64(i1, %swift.type* nocapture readnone %T) #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) #0
enum Phantom<T> : Int64 {
case Up