instrprof currently does not set __llvm_prf_vnds's alignment after creating it. The consequence is that the alignment is set to 16 later (https://github.com/llvm/llvm-project/blob/c0f3ac1d0015fd051144a987ff500b888a32be86/llvm/lib/IR/DataLayout.cpp#L1019). This can lead to undefined behaviour when we calculate NumVNodes in lprofGetLoadModuleSignature (https://github.com/llvm/llvm-project/blob/c0f3ac1d0015fd051144a987ff500b888a32be86/compiler-rt/lib/profile/InstrProfilingMerge.c#L32). The reason is that when the __llvm_prf_vnds array is 16 byte aligned, __llvm_profile_end_vnodes() - __llvm_profile_begin_vnodes() may not be a multiple of the size of ValueProfNode (which is 24, 20 on 32 bit targets).
This patch sets __llvm_prf_vnds's alignment to its ABI alignment, which always divides its size. Then __llvm_profile_end_vnodes() - __llvm_profile_begin_vnodes() will be a multiple of sizeof(ValueProfNode).