diff --git a/Sources/FrontEnd/BuiltinFunction.swift b/Sources/FrontEnd/BuiltinFunction.swift index cf5896ecc..7ca0db7f9 100644 --- a/Sources/FrontEnd/BuiltinFunction.swift +++ b/Sources/FrontEnd/BuiltinFunction.swift @@ -14,6 +14,10 @@ public struct BuiltinFunction: Hashable { let p = ParameterType(.let, ^freshVariable()) return .init(inputs: [.init(label: "of", type: ^p)], output: .builtin(.ptr)) + case .markUninitialized: + let p = ParameterType(.let, ^freshVariable()) + return .init(inputs: [.init(label: nil, type: ^p)], output: .void) + case .llvm(let s): return s.type } @@ -37,6 +41,11 @@ extension BuiltinFunction { /// measures may be needed to keep the argument alive during the pointer's use. case addressOf + /// `Builtin.mark_uninitialized(_ v: sink T) -> Void` + /// + /// Marks `v` as being uninitialized. + case markUninitialized + } } @@ -49,6 +58,8 @@ extension BuiltinFunction.Name: CustomStringConvertible { return n.description case .addressOf: return "address(of:)" + case .markUninitialized: + return "mark_uninitialized(_:)" } } @@ -63,6 +74,8 @@ extension BuiltinFunction { switch n { case "address": self.init(name: .addressOf) + case "mark_uninitialized": + self.init(name: .markUninitialized) default: self.init(native: n) } diff --git a/Sources/IR/Emitter.swift b/Sources/IR/Emitter.swift index e50d53ee8..bb67336c1 100644 --- a/Sources/IR/Emitter.swift +++ b/Sources/IR/Emitter.swift @@ -2112,6 +2112,11 @@ struct Emitter { case .addressOf: let source = emitLValue(arguments[0].value) return insert(module.makeAddressToPointer(source, at: site))! + + case .markUninitialized: + let source = emitLValue(arguments[0].value) + insert(module.makeMarkState(source, initialized: false, at: site)) + return .void } }