writeStackPointer emits a LLVM intrinsic call that updates the current stack pointer.
(sp llvm.Value)
| 455 | // writeStackPointer emits a LLVM intrinsic call that updates the current stack |
| 456 | // pointer. |
| 457 | func (b *builder) writeStackPointer(sp llvm.Value) { |
| 458 | name := "llvm.stackrestore.p0" |
| 459 | if llvmutil.Version() < 18 { |
| 460 | name = "llvm.stackrestore" // backwards compatibility with LLVM 17 and below |
| 461 | } |
| 462 | stackrestore := b.mod.NamedFunction(name) |
| 463 | if stackrestore.IsNil() { |
| 464 | fnType := llvm.FunctionType(b.ctx.VoidType(), []llvm.Type{b.dataPtrType}, false) |
| 465 | stackrestore = llvm.AddFunction(b.mod, name, fnType) |
| 466 | } |
| 467 | b.CreateCall(stackrestore.GlobalValueType(), stackrestore, []llvm.Value{sp}, "") |
| 468 | } |
| 469 | |
| 470 | // createZExtOrTrunc lets the input value fit in the output type bits, by zero |
| 471 | // extending or truncating the integer. |
no test coverage detected