Skip to content

Commit be9f205

Browse files
authored
Merge pull request #6246 from CodaFi/the-farmer-refuted
[Stdlib][ABI] Resolve ABI FIXME #25
2 parents d4131d8 + fe00dc7 commit be9f205

File tree

6 files changed

+18
-52
lines changed

6 files changed

+18
-52
lines changed

Diff for: include/swift/AST/KnownDecls.def

-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ FUNC_DECL(BridgeAnyObjectToAny,
6464

6565
FUNC_DECL(ConvertToAnyHashable, "_convertToAnyHashable")
6666

67-
FUNC_DECL(DidEnterMain, "_stdlib_didEnterMain")
6867
FUNC_DECL(DiagnoseUnexpectedNilOptional, "_diagnoseUnexpectedNilOptional")
6968

7069
FUNC_DECL(GetErrorEmbeddedNSError, "_stdlib_getErrorEmbeddedNSError")

Diff for: lib/Immediate/ImmediateImpl.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ namespace swift {
3434

3535
namespace immediate {
3636

37-
// Returns a handle to the runtime suitable for other 'dlsym' or 'dlclose'
38-
// calls or 'NULL' if an error occurred.
37+
/// Returns a handle to the runtime suitable for other \c dlsym or \c dlclose
38+
/// calls or \c null if an error occurred.
39+
///
40+
/// \param runtimeLibPath Path to search for compiler-relative stdlib dylibs.
3941
void *loadSwiftRuntime(StringRef runtimeLibPath);
4042
bool tryLoadLibraries(ArrayRef<LinkLibrary> LinkLibraries,
4143
SearchPathOptions SearchPathOpts,

Diff for: lib/SILGen/SILGen.cpp

+10-25
Original file line numberDiff line numberDiff line change
@@ -1223,29 +1223,6 @@ void SILGenModule::visitTopLevelCodeDecl(TopLevelCodeDecl *td) {
12231223
}
12241224
}
12251225

1226-
static void emitTopLevelProlog(SILGenFunction &gen, SILLocation loc) {
1227-
assert(gen.B.getInsertionBB()->getIterator() == gen.F.begin()
1228-
&& "not at entry point?!");
1229-
1230-
SILBasicBlock *entry = gen.B.getInsertionBB();
1231-
// Create the argc and argv arguments.
1232-
auto &C = gen.getASTContext();
1233-
auto FnTy = gen.F.getLoweredFunctionType();
1234-
auto *argc = entry->createArgument(FnTy->getParameters()[0].getSILType());
1235-
auto *argv = entry->createArgument(FnTy->getParameters()[1].getSILType());
1236-
1237-
// If the standard library provides a _stdlib_didEnterMain intrinsic, call it
1238-
// first thing.
1239-
if (auto didEnterMain = C.getDidEnterMain(nullptr)) {
1240-
ManagedValue params[] = {
1241-
ManagedValue::forUnmanaged(argc),
1242-
ManagedValue::forUnmanaged(argv),
1243-
};
1244-
(void) gen.emitApplyOfLibraryIntrinsic(loc, didEnterMain, {}, params,
1245-
SGFContext());
1246-
}
1247-
}
1248-
12491226
void SILGenModule::useConformance(ProtocolConformanceRef conformanceRef) {
12501227
// We don't need to emit dependent conformances.
12511228
if (conformanceRef.isAbstract())
@@ -1308,9 +1285,13 @@ class SourceFileScope {
13081285
sgm.TopLevelSGF->prepareRethrowEpilog(
13091286
CleanupLocation::getModuleCleanupLocation());
13101287

1288+
// Create the argc and argv arguments.
13111289
auto PrologueLoc = RegularLocation::getModuleLocation();
13121290
PrologueLoc.markAsPrologue();
1313-
emitTopLevelProlog(*sgm.TopLevelSGF, PrologueLoc);
1291+
auto entry = sgm.TopLevelSGF->B.getInsertionBB();
1292+
auto FnTy = sgm.TopLevelSGF->F.getLoweredFunctionType();
1293+
entry->createArgument(FnTy->getParameters()[0].getSILType());
1294+
entry->createArgument(FnTy->getParameters()[1].getSILType());
13141295

13151296
scope.emplace(sgm.TopLevelSGF->Cleanups,
13161297
CleanupLocation::getModuleCleanupLocation());
@@ -1409,8 +1390,12 @@ class SourceFileScope {
14091390
// Assign a debug scope pointing into the void to the top level function.
14101391
toplevel->setDebugScope(new (sgm.M) SILDebugScope(TopLevelLoc, toplevel));
14111392

1393+
// Create the argc and argv arguments.
14121394
SILGenFunction gen(sgm, *toplevel);
1413-
emitTopLevelProlog(gen, mainClass);
1395+
auto entry = gen.B.getInsertionBB();
1396+
auto FnTy = gen.F.getLoweredFunctionType();
1397+
entry->createArgument(FnTy->getParameters()[0].getSILType());
1398+
entry->createArgument(FnTy->getParameters()[1].getSILType());
14141399
gen.emitArtificialTopLevel(mainClass);
14151400
}
14161401
}

Diff for: stdlib/public/core/CommandLine.swift

-20
Original file line numberDiff line numberDiff line change
@@ -47,23 +47,3 @@ public enum CommandLine {
4747
public static var arguments: [String]
4848
= (0..<Int(argc)).map { String(cString: _unsafeArgv[$0]!) }
4949
}
50-
51-
// FIXME(ABI)#25 : Remove this and the entrypoints in SILGen.
52-
// rdar://problem/19696522
53-
@_transparent
54-
public // COMPILER_INTRINSIC
55-
func _stdlib_didEnterMain(
56-
argc: Int32, argv: UnsafeMutablePointer<UnsafeMutablePointer<Int8>?>
57-
) {
58-
// Initialize the CommandLine.argc and CommandLine.unsafeArgv variables with the
59-
// values that were passed in to main.
60-
CommandLine._argc = Int32(argc)
61-
CommandLine._unsafeArgv = argv
62-
}
63-
64-
// FIXME: Move this to HashedCollections.swift.gyb
65-
internal class _Box<Wrapped> {
66-
internal var _value: Wrapped
67-
internal init(_ value: Wrapped) { self._value = value }
68-
}
69-

Diff for: test/DebugInfo/top_level_code.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ markUsed(a+b)
99
// CHECK: _main:
1010
// Verify that the top-level function (main) begins at line 0 and then
1111
// proceeds to line 6.
12-
// CHECK: .loc {{[0-9]}} 0 {{[0-9]}} prologue_end
12+
// CHECK: .loc {{[0-9]}} 0 {{[0-9]}}
1313
// CHECK-NOT: .loc
14-
// CHECK: .loc {{[0-9]}} 6 {{[0-9]}}
14+
// CHECK: .loc {{[0-9]}} 6 {{[0-9]}} prologue_end

Diff for: test/IRGen/enum_derived.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ extension def_enum.TrafficLight : Error {}
3737

3838
extension def_enum.Term : Error {}
3939

40-
// CHECK-NORMAL-LABEL: define hidden i64 @_TFO12enum_derived7Phantomg8rawValueVs5Int64(i1, %swift.type* nocapture readnone %T) local_unnamed_addr #1
41-
// CHECK-TESTABLE-LABEL: define{{( protected)?}} i64 @_TFO12enum_derived7Phantomg8rawValueVs5Int64(i1, %swift.type* nocapture readnone %T) #1
40+
// CHECK-NORMAL-LABEL: define hidden i64 @_TFO12enum_derived7Phantomg8rawValueVs5Int64(i1, %swift.type* nocapture readnone %T) local_unnamed_addr #0
41+
// CHECK-TESTABLE-LABEL: define{{( protected)?}} i64 @_TFO12enum_derived7Phantomg8rawValueVs5Int64(i1, %swift.type* nocapture readnone %T) #0
4242

4343
enum Phantom<T> : Int64 {
4444
case Up

0 commit comments

Comments
 (0)