1//===- subzero/crosstest/insertelement.h - Helper for PNaCl workaround. ---===// 2// 3// The Subzero Code Generator 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9// 10// Helper function to work around a potential stack overflow issue. 11// 12//===----------------------------------------------------------------------===// 13 14#ifndef INSERTELEMENT_H 15#define INSERTELEMENT_H 16 17// Helper function to perform the insertelement bitcode instruction. The PNaCl 18// ABI simplifications transform insertelement/extractelement instructions with 19// a non-constant index into something involving alloca. This can cause a stack 20// overflow if the alloca is inside a loop. 21template <typename VectorType, typename ElementType> 22void __attribute__((noinline)) 23setElement(VectorType &Value, size_t Index, ElementType Element) { 24 Value[Index] = Element; 25} 26 27#endif // INSERTELEMENT_H 28