Skip to content

Commit 75f3bb5

Browse files
authored
Merge pull request #153 from CodaFi/erasure
Add global erasure
2 parents 22000f1 + d56bbdf commit 75f3bb5

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Sources/LLVM/IRGlobal.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,17 @@ extension IRGlobal {
5757
}
5858
set { LLVMSetSection(asLLVM(), newValue) }
5959
}
60+
61+
/// Removes this global value from the module and deallocates it.
62+
///
63+
/// - note: To ensure correct removal of the global value, you must invalidate
64+
/// any references to it - usually by performing an
65+
/// "Replace All Uses With" (RAUW) operation.
66+
///
67+
/// - warning: The native Swift object wrapping this global becomes a dangling
68+
/// reference once this function has been invoked. It is
69+
/// recommended that all references to it be dropped immediately.
70+
public func eraseFromParent() {
71+
LLVMDeleteGlobal(self.asLLVM())
72+
}
6073
}

0 commit comments

Comments
 (0)