-i x8632,native,sse2 \
-i x8632,native,sse4.1,test_vector_ops \
-i x8632,sandbox,sse4.1,Om1 \
- -i x8632,nonsfi,sse2,O2 -e x8632,nonsfi,test_select \
+ -i x8632,nonsfi,sse2,O2 \
-i x8664,native,sse2 \
-i x8664,native,sse4.1,test_vector_ops \
-e x8664,sandbox,sse4.1,Om1 \
--- /dev/null
+//===- subzero/crosstest/insertelement.h - Helper for PNaCl workaround. ---===//
+//
+// The Subzero Code Generator
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// Helper function to work around a potential stack overflow issue.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef INSERTELEMENT_H
+#define INSERTELEMENT_H
+
+// Helper function to perform the insertelement bitcode instruction. The PNaCl
+// ABI simplifications transform insertelement/extractelement instructions with
+// a non-constant index into something involving alloca. This can cause a stack
+// overflow if the alloca is inside a loop.
+template <typename VectorType, typename ElementType>
+void __attribute__((noinline))
+setElement(VectorType &Value, size_t Index, ElementType Element) {
+ Value[Index] = Element;
+}
+
+#endif // INSERTELEMENT_H
// Subzero_ namespace, corresponding to the llc and Subzero translated
// object files, respectively.
#include "test_arith.h"
-#include "xdefs.h"
namespace Subzero_ {
#include "test_arith.h"
}
+#include "insertelement.h"
+#include "xdefs.h"
+
template <class T> bool inputsMayTriggerException(T Value1, T Value2) {
// Avoid HW divide-by-zero exception.
if (Value2 == 0)
template <typename TypeUnsignedLabel, typename TypeSignedLabel>
void testsVecInt(size_t &TotalTests, size_t &Passes, size_t &Failures) {
-#if !defined(ARM32) && !defined(NONSFI)
+#if !defined(ARM32)
// TODO(jpp): remove this once vector support is implemented.
typedef typename Vectors<TypeUnsignedLabel>::Ty TypeUnsigned;
typedef typename Vectors<TypeSignedLabel>::Ty TypeSigned;
continue;
if (Funcs[f].MaskShiftOperations)
Element2 &= CHAR_BIT * sizeof(ElementTypeUnsigned) - 1;
- Value1[j] = Element1;
- Value2[j] = Element2;
+ setElement(Value1, j, Element1);
+ setElement(Value2, j, Element2);
}
// Perform the test.
TypeUnsigned ResultSz, ResultLlc;
}
}
}
-#endif // !ARM32 && !NONSFI
+#endif // !ARM32
}
template <typename Type>
}
void testsVecFp(size_t &TotalTests, size_t &Passes, size_t &Failures) {
-#if !defined(ARM32) && !defined(NONSFI)
+#if !defined(ARM32)
// TODO(jpp): remove this once vector support is implemented.
static const float NegInf = -1.0 / 0.0;
static const float PosInf = 1.0 / 0.0;
// Initialize the test vectors.
v4f32 Value1, Value2;
for (size_t j = 0; j < NumElementsInType; ++j) {
- Value1[j] = Values[Index() % NumValues];
- Value2[j] = Values[Index() % NumValues];
+ setElement(Value1, j, Values[Index() % NumValues]);
+ setElement(Value2, j, Values[Index() % NumValues]);
}
// Perform the test.
v4f32 ResultSz = Funcs[f].FuncSz(Value1, Value2);
}
}
}
-#endif // !ARM32 && !NONSFI
+#endif // !ARM32
}
#ifdef X8664_STACK_HACK
#include "test_icmp.h"
}
+#include "insertelement.h"
#include "xdefs.h"
volatile unsigned Values[] = {
template <typename TypeUnsignedLabel, typename TypeSignedLabel>
void testsVecInt(size_t &TotalTests, size_t &Passes, size_t &Failures) {
-#if !defined(ARM32) && !defined(NONSFI)
+#if !defined(ARM32)
// TODO(jpp): remove this once vector support is implemented.
typedef typename Vectors<TypeUnsignedLabel>::Ty TypeUnsigned;
typedef typename Vectors<TypeSignedLabel>::Ty TypeSigned;
+ typedef typename Vectors<TypeUnsignedLabel>::ElementTy ElementTypeUnsigned;
+ typedef typename Vectors<TypeSignedLabel>::ElementTy ElementTypeSigned;
typedef TypeUnsigned (*FuncTypeUnsigned)(TypeUnsigned, TypeUnsigned);
typedef TypeSigned (*FuncTypeSigned)(TypeSigned, TypeSigned);
static struct {
for (size_t i = 0; i < MaxTestsPerFunc; ++i) {
// Initialize the test vectors.
TypeUnsigned Value1, Value2;
- for (size_t j = 0; j < NumElementsInType;) {
- Value1[j] = Values[Index() % NumValues];
- Value2[j] = Values[Index() % NumValues];
- ++j;
+ for (size_t j = 0; j < NumElementsInType; ++j) {
+ setElement(Value1, j, Values[Index() % NumValues]);
+ setElement(Value2, j, Values[Index() % NumValues]);
}
// Perform the test.
TypeUnsigned ResultSz = Funcs[f].FuncSz(Value1, Value2);
}
}
}
-#endif // !ARM32 && !NONSFI
+#endif // !ARM32
}
// Return true on wraparound
-template <typename T> bool incrementI1Vector(typename Vectors<T>::Ty &Vect) {
+template <typename T>
+bool __attribute__((noinline))
+incrementI1Vector(typename Vectors<T>::Ty &Vect) {
size_t Pos = 0;
const static size_t NumElements = Vectors<T>::NumElements;
for (Pos = 0; Pos < NumElements; ++Pos) {
template <typename T>
void testsVecI1(size_t &TotalTests, size_t &Passes, size_t &Failures) {
-#if !defined(ARM32) && !defined(NONSFI)
+#if !defined(ARM32)
// TODO(jpp): remove this once vector support is implemented.
typedef typename Vectors<T>::Ty Ty;
typedef Ty (*FuncType)(Ty, Ty);
Ty Value1, Value2;
// Initialize the test vectors.
for (size_t j = 0; j < NumElements; ++j) {
- Value1[j] = Index() % 2;
- Value2[j] = Index() % 2;
+ setElement(Value1, j, Index() % 2);
+ setElement(Value2, j, Index() % 2);
}
// Perform the test.
Ty ResultSz = Funcs[f].FuncSz(Value1, Value2);
}
}
}
-#endif // !ARM32 && !NONSFI
+#endif // !ARM32
}
#ifdef X8664_STACK_HACK
#include "test_select.h"
}
+#include "insertelement.h"
+
static const size_t MaxTestsPerFunc = 100000;
template <typename T, typename TI1>
TyI1 Cond;
Ty Value1, Value2;
for (size_t j = 0; j < NumElements; ++j) {
- Cond[j] = Index() % 2;
- Value1[j] = Values[Index() % NumValues];
- Value2[j] = Values[Index() % NumValues];
+ setElement(Cond, j, Index() % 2);
+ setElement(Value1, j, Values[Index() % NumValues]);
+ setElement(Value2, j, Values[Index() % NumValues]);
}
Ty ResultLlc = select(Cond, Value1, Value2);
Ty ResultSz = Subzero_::select(Cond, Value1, Value2);
v4si32 Cond;
v4f32 Value1, Value2;
for (size_t j = 0; j < NumElements; ++j) {
- Cond[j] = Index() % 2;
- Value1[j] = Values[Index() % NumValues];
- Value2[j] = Values[Index() % NumValues];
+ setElement(Cond, j, Index() % 2);
+ setElement(Value1, j, Values[Index() % NumValues]);
+ setElement(Value2, j, Values[Index() % NumValues]);
}
v4f32 ResultLlc = select(Cond, Value1, Value2);
v4f32 ResultSz = Subzero_::select(Cond, Value1, Value2);
Ty Cond;
Ty Value1, Value2;
for (size_t j = 0; j < NumElements; ++j) {
- Cond[j] = Index() % 2;
- Value1[j] = Index() % 2;
- Value2[j] = Index() % 2;
+ setElement(Cond, j, Index() % 2);
+ setElement(Value1, j, Index() % 2);
+ setElement(Value2, j, Index() % 2);
}
Ty ResultLlc = select_i1(Cond, Value1, Value2);
Ty ResultSz = Subzero_::select_i1(Cond, Value1, Value2);
bitcode = os.path.join(args.dir, base + '.' + key + '.pnacl.ll')
shellcmd(['{bin}/pnacl-clang'.format(bin=bindir),
('-O2' if args.clang_opt else '-O0'),
- get_sfi_string(args, '', '-DNONSFI', ''),
('-DARM32' if args.target == 'arm32' else ''), '-c', arg,
'-o', bitcode_nonfinal])
shellcmd(['{bin}/pnacl-opt'.format(bin=bindir),
if args.target == 'arm32':
target_params.append('-DARM32')
target_params.append('-static')
- if args.nonsfi:
- target_params.append('-DNONSFI')
pure_c = os.path.splitext(args.driver)[1] == '.c'
if not args.nonsfi:
cc='clang' if pure_c else 'clang++')
shellcmd([compiler,
args.driver,
- '-DNONSFI' if args.nonsfi else '',
'-O2',
'-o', bitcode_nonfinal,
'-Wl,-r'