@@ -1034,9 +1034,8 @@ extension IRBuilder {
10341034 /// allocated, otherwise `count` is defaulted to be one. If a constant
10351035 /// alignment is specified, the value result of the allocation is guaranteed
10361036 /// to be aligned to at least that boundary. The alignment may not be
1037- /// greater than `1 << 29`. If not specified, or if zero, the target can
1038- /// choose to align the allocation on any convenient boundary compatible with
1039- /// the type.
1037+ /// greater than `1 << 29`. If not specified, or if zero, the target will
1038+ /// choose a default value that is convenient and compatible with the type.
10401039 ///
10411040 /// The returned value is allocated in the address space specified in the data layout string for the target. If
10421041 /// no such value is specified, the value is allocated in the default address space.
@@ -1057,13 +1056,18 @@ extension IRBuilder {
10571056 } else {
10581057 allocaInst = LLVMBuildAlloca ( llvm, type. asLLVM ( ) , name) !
10591058 }
1060- LLVMSetAlignment ( allocaInst, alignment. rawValue)
1059+ if !alignment. isZero {
1060+ LLVMSetAlignment ( allocaInst, alignment. rawValue)
1061+ }
10611062 return allocaInst
10621063 }
10631064
10641065 /// Build a store instruction that stores the first value into the location
10651066 /// given in the second value.
10661067 ///
1068+ /// If alignment is not specified, or if zero, the target will choose a default
1069+ /// value that is convenient and compatible with the type.
1070+ ///
10671071 /// - parameter val: The source value.
10681072 /// - parameter ptr: The destination pointer to store into.
10691073 /// - parameter ordering: The ordering effect of the fence for this store,
@@ -1077,13 +1081,18 @@ extension IRBuilder {
10771081 let storeInst = LLVMBuildStore ( llvm, val. asLLVM ( ) , ptr. asLLVM ( ) ) !
10781082 LLVMSetOrdering ( storeInst, ordering. llvm)
10791083 LLVMSetVolatile ( storeInst, volatile. llvm)
1080- LLVMSetAlignment ( storeInst, alignment. rawValue)
1084+ if !alignment. isZero {
1085+ LLVMSetAlignment ( storeInst, alignment. rawValue)
1086+ }
10811087 return storeInst
10821088 }
10831089
10841090 /// Build a load instruction that loads a value from the location in the
10851091 /// given value.
10861092 ///
1093+ /// If alignment is not specified, or if zero, the target will choose a default
1094+ /// value that is convenient and compatible with the type.
1095+ ///
10871096 /// - parameter ptr: The pointer value to load from.
10881097 /// - parameter type: The type of value loaded from the given pointer.
10891098 /// - parameter ordering: The ordering effect of the fence for this load,
@@ -1098,7 +1107,9 @@ extension IRBuilder {
10981107 let loadInst = LLVMBuildLoad2 ( llvm, type. asLLVM ( ) , ptr. asLLVM ( ) , name) !
10991108 LLVMSetOrdering ( loadInst, ordering. llvm)
11001109 LLVMSetVolatile ( loadInst, volatile. llvm)
1101- LLVMSetAlignment ( loadInst, alignment. rawValue)
1110+ if !alignment. isZero {
1111+ LLVMSetAlignment ( loadInst, alignment. rawValue)
1112+ }
11021113 return loadInst
11031114 }
11041115
@@ -1927,6 +1938,9 @@ extension IRBuilder {
19271938 /// Build a load instruction that loads a value from the location in the
19281939 /// given value.
19291940 ///
1941+ /// If alignment is not specified, or if zero, the target will choose a default
1942+ /// value that is convenient and compatible with the type.
1943+ ///
19301944 /// - parameter ptr: The pointer value to load from.
19311945 /// - parameter ordering: The ordering effect of the fence for this load,
19321946 /// if any. Defaults to a nonatomic load.
@@ -1941,7 +1955,9 @@ extension IRBuilder {
19411955 let loadInst = LLVMBuildLoad ( llvm, ptr. asLLVM ( ) , name) !
19421956 LLVMSetOrdering ( loadInst, ordering. llvm)
19431957 LLVMSetVolatile ( loadInst, volatile. llvm)
1944- LLVMSetAlignment ( loadInst, alignment. rawValue)
1958+ if !alignment. isZero {
1959+ LLVMSetAlignment ( loadInst, alignment. rawValue)
1960+ }
19451961 return loadInst
19461962 }
19471963
0 commit comments