@@ -4,6 +4,29 @@ import cllvm
44
55/// An `Alias` represents a global alias in an LLVM module - a new symbol and
66/// corresponding metadata for an existing global value.
7+ ///
8+ /// An `Alias`, unlike a function or global variable declaration, does not
9+ /// create any new data in the resulting object file. It is merely a new name
10+ /// for an existing symbol or constant. The aliased value (the aliasee) must
11+ /// be either another global value like a function, global variable, or even
12+ /// another alias, or it must be a constant expression.
13+ ///
14+ /// Linkers make no guarantees that aliases will be preserved in the final
15+ /// object file. Aliases where the address is known to be relevant should be
16+ /// marked with the appropriate `UnnamedAddressKind` value. If this value is
17+ /// not `none`, the alias is guaranteed to have the same address as the aliasee.
18+ /// Else, the alias is guaranteed to point to the same content as the aliasee,
19+ /// but may reside at a different address.
20+ ///
21+ /// If the aliasee is a constant value, LLVM places additional restrictions on
22+ /// its content in order to maintain compatibility with the expected behavior of
23+ /// most linkers:
24+ ///
25+ /// - The constant expression may not involve aliases with weak linkage. Such
26+ /// weak aliases cannot be guaranteed to be stable in the final object file.
27+ /// - The constant expression may not involve global values requiring a
28+ /// relocation such as a global function or global variable declared but not
29+ /// defined within its module.
730public struct Alias : IRGlobal {
831 internal let llvm : LLVMValueRef
932
@@ -12,7 +35,9 @@ public struct Alias: IRGlobal {
1235 return llvm
1336 }
1437
15- /// Access the target value of this alias.
38+ /// The target value of this alias.
39+ ///
40+ /// The aliasee is required to be another global value or constant
1641 public var aliasee : IRValue {
1742 get { return LLVMAliasGetAliasee ( llvm) }
1843 set { LLVMAliasSetAliasee ( llvm, newValue. asLLVM ( ) ) }
0 commit comments