Skip to content

Commit 69c6f7d

Browse files
committed
workaround for std::aligned_alloc
Signed-off-by: jinge90 <[email protected]>
1 parent 331644e commit 69c6f7d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

llvm/lib/SYCLLowerIR/ComputeModuleRuntimeInfo.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,16 +183,26 @@ PropSetRegTy computeModuleProperties(const Module &M,
183183
continue;
184184

185185
size_t SPVSize = (*SPVMB)->getBufferSize();
186+
// std::aligned_alloc is not available in some pre-ci Windows machine.
187+
#if defined(_WIN32) || defined(_WIN64)
188+
uint8_t *SPVBuffer = reinterpret_cast<uint8_t *>(
189+
_aligned_malloc(alignof(uint32_t), SPVSize + sizeof(uint32_t)));
190+
#else
186191
uint8_t *SPVBuffer = reinterpret_cast<uint8_t *>(
187192
std::aligned_alloc(alignof(uint32_t), SPVSize + sizeof(uint32_t)));
193+
#endif
188194
*(reinterpret_cast<uint32_t *>(SPVBuffer)) = static_cast<uint32_t>(Ext);
189195
std::memcpy(SPVBuffer + sizeof(uint32_t), (*SPVMB)->getBufferStart(),
190196
SPVSize);
191197
llvm::SYCLDeviceLibSPVBinary SPVBinaryObj(SPVBuffer,
192198
SPVSize + sizeof(uint32_t));
193199
PropSet.add(PropSetRegTy::SYCL_DEVICELIB_REQ_BINS, SPVFileName,
194200
SPVBinaryObj);
201+
#if defined(_WIN32) || defined(_WIN64)
202+
_aligned_free(SPVBUffer);
203+
#else
195204
std::free(SPVBuffer);
205+
#endif
196206
}
197207
}
198208

0 commit comments

Comments
 (0)