@@ -43,42 +43,40 @@ class SILLinker : public SILModuleTransform {
43
43
// In embedded Swift, the stdlib contains all the runtime functions needed
44
44
// (swift_retain, etc.). Link them in so they can be referenced in IRGen.
45
45
if (M.getOptions ().EmbeddedSwift && LinkEmbeddedRuntime) {
46
- linkEmbeddedRuntimeFromStdlib (!M. getOptions (). NoAllocations );
46
+ linkEmbeddedRuntimeFromStdlib ();
47
47
}
48
48
}
49
49
50
- void linkEmbeddedRuntimeFromStdlib (bool includeAllocatingFunctions) {
51
- #define FUNCTION (ID, NAME, CC, AVAILABILITY, RETURNS, ARGS, ATTRS, EFFECT, \
52
- MEMORY_EFFECTS) \
53
- { \
54
- using namespace RuntimeConstants ; \
55
- ArrayRef<RuntimeEffect> effects = {EFFECT}; \
56
- bool allocating = false ; \
57
- for (RuntimeEffect rt : effects) { \
58
- if (rt == RuntimeEffect::Allocating || \
59
- rt == RuntimeEffect::Deallocating) \
60
- allocating = true ; \
61
- } \
62
- bool include = true ; \
63
- if (allocating) include = includeAllocatingFunctions; \
64
- if (include) linkEmbeddedRuntimeFunctionByName (#NAME); \
65
- }
50
+ void linkEmbeddedRuntimeFromStdlib () {
51
+ using namespace RuntimeConstants ;
52
+ #define FUNCTION (ID, NAME, CC, AVAILABILITY, RETURNS, ARGS, ATTRS, EFFECT, \
53
+ MEMORY_EFFECTS) \
54
+ linkEmbeddedRuntimeFunctionByName (#NAME, EFFECT);
66
55
67
56
#define RETURNS (...)
68
57
#define ARGS (...)
69
58
#define NO_ARGS
70
59
#define ATTRS (...)
71
60
#define NO_ATTRS
72
- #define EFFECT (...) __VA_ARGS__
61
+ #define EFFECT (...) { __VA_ARGS__ }
73
62
#define MEMORY_EFFECTS (...)
74
63
#define UNKNOWN_MEMEFFECTS
75
64
76
65
#include " swift/Runtime/RuntimeFunctions.def"
77
66
}
78
67
79
- void linkEmbeddedRuntimeFunctionByName (StringRef name) {
68
+ void linkEmbeddedRuntimeFunctionByName (StringRef name,
69
+ ArrayRef<RuntimeEffect> effects) {
80
70
SILModule &M = *getModule ();
81
71
72
+ bool allocating = false ;
73
+ for (RuntimeEffect rt : effects)
74
+ if (rt == RuntimeEffect::Allocating || rt == RuntimeEffect::Deallocating)
75
+ allocating = true ;
76
+
77
+ // Don't link allocating runtime functions in -no-allocations mode.
78
+ if (M.getOptions ().NoAllocations && allocating) return ;
79
+
82
80
// Bail if runtime function is already loaded.
83
81
if (M.lookUpFunction (name)) return ;
84
82
0 commit comments