Skip to content

Commit a5825ae

Browse files
committed
Improve docs for noalias and tailcall
1 parent 177deb4 commit a5825ae

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

Sources/LLVM/Call.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ public struct Call: IRInstruction {
2222
set { LLVMSetInstructionCallConv(self.llvm, newValue.llvm.rawValue) }
2323
}
2424

25-
/// Returns whether this function call is a tail call. That is, if the callee
26-
/// may reuse the stack memory of the caller.
25+
/// Returns whether this function call is a tail call.
26+
///
27+
/// A tail call may not reference memory in the stack frame of the calling
28+
/// function. Therefore, the callee may reuse the stack memory of the caller.
2729
///
2830
/// This attribute requires support from the target architecture.
2931
public var isTailCall: Bool {

Sources/LLVM/Function+Attributes.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,14 @@ public enum AttributeKind: String {
163163
/// argument or return value are not also accessed, during the execution of
164164
/// the function, via pointer values not based on the argument or return
165165
/// value.
166+
///
167+
/// The `noalias` attribute may appear in one of two location: on arguments
168+
/// types or on return types. On argument types, `noalias` acts like the
169+
/// `restrict` keyword in C and C++ and implies that no other pointer value
170+
/// points to this object. On return types, `noalias` implies that the
171+
/// returned pointer is not aliased by any other pointer in the program.
172+
///
173+
/// Practically, this allows LLVM to reorder accesses to this memory.
166174
case noalias
167175
/// This indicates that the callee does not make any copies of the pointer
168176
/// that outlive the callee itself.

0 commit comments

Comments
 (0)