@@ -114,16 +114,19 @@ class EncodingReader {
114
114
if (!llvm::isPowerOf2_32 (alignment))
115
115
return emitError (" expected alignment to be a power-of-two" );
116
116
117
+ auto isUnaligned = [&](const uint8_t *ptr) {
118
+ return ((uintptr_t )ptr & (alignment - 1 )) != 0 ;
119
+ };
120
+
117
121
// Ensure the data buffer was sufficiently aligned in the first place.
118
- if (LLVM_UNLIKELY (
119
- !llvm::isAddrAligned (llvm::Align (alignment), buffer.begin ()))) {
122
+ if (LLVM_UNLIKELY (isUnaligned (buffer.begin ()))) {
120
123
return emitError (" expected bytecode buffer to be aligned to " , alignment,
121
124
" , but got pointer: '0x" +
122
125
llvm::utohexstr ((uintptr_t )buffer.begin ()) + " '" );
123
126
}
124
127
125
128
// Shift the reader position to the next alignment boundary.
126
- while (uintptr_t (dataIt) & ( uintptr_t (alignment) - 1 )) {
129
+ while (isUnaligned (dataIt)) {
127
130
uint8_t padding;
128
131
if (failed (parseByte (padding)))
129
132
return failure ();
@@ -135,7 +138,7 @@ class EncodingReader {
135
138
136
139
// Ensure the data iterator is now aligned. This case is unlikely because we
137
140
// *just* went through the effort to align the data iterator.
138
- if (LLVM_UNLIKELY (! llvm::isAddrAligned ( llvm::Align (alignment), dataIt))) {
141
+ if (LLVM_UNLIKELY (isUnaligned ( dataIt))) {
139
142
return emitError (" expected data iterator aligned to " , alignment,
140
143
" , but got pointer: '0x" +
141
144
llvm::utohexstr ((uintptr_t )dataIt) + " '" );
0 commit comments