aboutsummaryrefslogtreecommitdiffhomepage
path: root/compiler/intrinsics.go
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/intrinsics.go')
-rw-r--r--compiler/intrinsics.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/compiler/intrinsics.go b/compiler/intrinsics.go
index c1d05348b..3c7edd7c9 100644
--- a/compiler/intrinsics.go
+++ b/compiler/intrinsics.go
@@ -23,6 +23,8 @@ func (b *builder) defineIntrinsicFunction() {
b.createMemoryCopyImpl()
case name == "runtime.memzero":
b.createMemoryZeroImpl()
+ case name == "runtime.stacksave":
+ b.createStackSaveImpl()
case name == "runtime.KeepAlive":
b.createKeepAliveImpl()
case strings.HasPrefix(name, "runtime/volatile.Load"):
@@ -77,6 +79,14 @@ func (b *builder) createMemoryZeroImpl() {
b.CreateRetVoid()
}
+// createStackSaveImpl creates a call to llvm.stacksave.p0 to read the current
+// stack pointer.
+func (b *builder) createStackSaveImpl() {
+ b.createFunctionStart(true)
+ sp := b.readStackPointer()
+ b.CreateRet(sp)
+}
+
// Return the llvm.memset.p0.i8 function declaration.
func (c *compilerContext) getMemsetFunc() llvm.Value {
fnName := "llvm.memset.p0.i" + strconv.Itoa(c.uintptrType.IntTypeWidth())