bool Variables::runOnModule(Module &module) {
  errs() << "Running Variables\n";
  doInitialization(module);

  vector<Change*>::iterator it;

  for(it = changes[GLOBALVAR].begin(); it != changes[GLOBALVAR].end(); it++) {
    changeGlobal(*it, module); // TODO: return value and metadata
  }

  for(it = changes[LOCALVAR].begin(); it != changes[LOCALVAR].end(); it++) {
    AllocaInst* newTarget = changeLocal(*it);
    if (newTarget) {
      errs() << "\tProcessed local variable: " << newTarget->getName() << "\n";
      updateMetadata(module, (*it)->getValue(), newTarget, (*it)->getType()[0]);

#ifdef DEBUG
      verifyModule(module, AbortProcessAction);
      errs() << "**** MODULE VERIFIES after a single change ****\n";
#endif
    }
  }

  return true;
}
int
main (int argc, char *argv[])
{
  __vector __int128 loaded_v;
  __vector unsigned __int128 loaded_uv;

  /* Usage:
   *  <Type> result = vec_ld (int index, __vector <Type> v)
   * is equivalent to:
   *  result = v [index];
   */
  doInitialization ();
  loaded_v = vec_ld (0, pv);
  if (loaded_v[0] != -1)
    abort ();

  loaded_uv = vec_ld (0, puv);
  if (loaded_uv[0] != 0xcafebabe)
    abort ();

  loaded_v = vec_ld (0, pi128);
  if (loaded_v[0] != 0xfabeabe)
    abort ();

  loaded_uv = vec_ld (0, pu128);
  if (loaded_uv[0] != 0xabefabe)
    abort ();

  return 0;
}
int TestMain () {
    scalable_allocation_mode(USE_HUGE_PAGES, 0);
#if !_XBOX && !__TBB_WIN8UI_SUPPORT
    putenv((char*)"TBB_MALLOC_USE_HUGE_PAGES=yes");
#endif
    checkNoHugePages();
    // backreference requires that initialization was done
    if(!isMallocInitialized()) doInitialization();
    checkNoHugePages();
    // to succeed, leak detection must be the 1st memory-intensive test
    TestBackRef();
    TestPools();
    TestBackend();

#if MALLOC_CHECK_RECURSION
    for( int p=MaxThread; p>=MinThread; --p ) {
        TestStartupAlloc::initBarrier( p );
        NativeParallelFor( p, TestStartupAlloc() );
        ASSERT(!firstStartupBlock, "Startup heap memory leak detected");
    }
#endif

    TestLargeObjectCache();
    TestObjectRecognition();
    TestBitMask();
    return Harness::Done;
}
Exemple #4
0
bool Coverage::runOnModule(Module &module)
{
  doInitialization(module);

  // iterate through functions in module
  for (Module::iterator f = module.begin(), fe = module.end(); f != fe; f++)
  {
    runOnFunction(module, *f);
  }

  return true;
}
bool MeasureMetric::runOnModule(Module &M) {
	doInitialization(M);

	for(Module::iterator f = M.begin(), fe = M.end(); f != fe; f++) {
		if (!f->isDeclaration()) {
			runOnFunction(*f);
		}
	}

	doFinalization();

	return false;
}
Exemple #6
0
  bool BytesFlops::runOnModule(Module & module)
  {
      doInitialization(module);
      
      /**
       * for each function in the module, run a function pass on it.
       */
      for ( auto fiter = module.begin(); fiter != module.end(); fiter++ )
      {
          runOnFunction(*fiter);
      }

      doFinalization(module);

      return true;
  }
Exemple #7
0
void TestHeapLimit()
{
    if(!isMallocInitialized()) doInitialization();
    // tiny limit to stop caching
    int res = scalable_allocation_mode(TBBMALLOC_SET_SOFT_HEAP_LIMIT, 1);
    ASSERT(res == TBBMALLOC_OK, NULL);
     // provoke bootstrap heap initialization before recording memory size
    scalable_free(scalable_malloc(8));
    size_t n, sizeBefore = getMemSize();

    // Try to provoke call to OS for memory to check that
    // requests are not fulfilled from caches.
    // Single call is not enough here because of backend fragmentation.
    for (n = minLargeObjectSize; n < 10*1024*1024; n += 16*1024) {
        void *p = scalable_malloc(n);
        bool leave = (sizeBefore != getMemSize());
        scalable_free(p);
        if (leave)
            break;
        ASSERT(sizeBefore == getMemSize(), "No caching expected");
    }
    ASSERT(n < 10*1024*1024, "scalable_malloc doesn't provoke OS request for memory, "
           "is some internal cache still used?");
    // estimate number of objects in single bootstrap block
    int objInBootstrapHeapBlock = (slabSize-2*estimatedCacheLineSize)/sizeof(TLSData);
    // When we have more threads than objects in bootstrap heap block,
    // additional block can be allocated from a region that is different
    // from the original region. Thus even after all caches cleaned,
    // we unable to reach sizeBefore.
    ASSERT_WARNING(MaxThread<=objInBootstrapHeapBlock,
        "The test might fail for larger thread number, "
        "as bootstrap heap is not released till size checking.");
    for( int p=MaxThread; p>=MinThread; --p ) {
        RunTestHeapLimit::initBarrier( p );
        NativeParallelFor( p, RunTestHeapLimit(sizeBefore) );
    }
    // it's try to match limit as well as set limit, so call here
    res = scalable_allocation_mode(TBBMALLOC_SET_SOFT_HEAP_LIMIT, 1);
    ASSERT(res == TBBMALLOC_OK, NULL);
    size_t m = getMemSize();
    ASSERT(sizeBefore == m, NULL);
    // restore default
    res = scalable_allocation_mode(TBBMALLOC_SET_SOFT_HEAP_LIMIT, 0);
    ASSERT(res == TBBMALLOC_OK, NULL);
}
int TestMain () {
    // backreference requires that initialization was done
    if(!isMallocInitialized()) doInitialization();
    // to succeed, leak detection must be the 1st memory-intensive test
    TestBackRef();
    TestPools();
    TestBackend();

#if MALLOC_CHECK_RECURSION
    for( int p=MaxThread; p>=MinThread; --p ) {
        TestStartupAlloc::initBarrier( p );
        NativeParallelFor( p, TestStartupAlloc() );
        ASSERT(!firstStartupBlock, "Startup heap memory leak detected");
    }
#endif

    TestLargeObjectCache();
    TestObjectRecognition();
    TestBitMask();
    return Harness::Done;
}
bool Operators::runOnModule(Module &module) {

	doInitialization(module);

	// iterate through operator set
	
	vector<Change*>::iterator it;
	for (it = changes[OP].begin(); it != changes[OP].end(); it++) {
		Change *change = *it;
		Value *target = change->getValue();
		Type *new_type = change->getType().at(0);

		if (target) {
			if (FCmpInst* old_target = dyn_cast<FCmpInst>(target)) {
				changeFCmpInst(old_target, new_type);
			} else if (BinaryOperator* old_target = dyn_cast<BinaryOperator>(target)) {
				changeBinaryOperator(old_target, new_type);
			}
		}
	}

	return true;
}
int
main (int argc, char *argv[])
{
  vector long long int lv;
  vector unsigned long long int ulv;
  vector int iv;
  vector unsigned int uiv;
  vector short sv;
  vector unsigned short usv;
  vector signed char cv;
  vector unsigned char ucv;
  vector double dv;

  doInitialization ();

  /* Do vector of char.  */
  for (int i = 0; i < 16; i++) {
    /* Focus on ca[16] ... ca[31].  */
    cv = vec_ldl (i+16, ca);	/* compiler: invalid parameter combination */
    if (cv[4] != ca[20])
      abort ();
    /* Focus on uca[32] ... uca[47].  */
    ucv = vec_ldl (i+32, uca);
    if (ucv[7] != uca[39])
      abort ();
    /* Focus on ca[0] ... ca[15].  */
    cv = vec_ldl (i, vcp);
    if (cv[3] != ca[3])
      abort ();
    /* Focus on ca[0] ... ca[15] while i <= 8.
       Focus on ca[16] ... ca[31] while i > 8.  */
    ucv = vec_ldl (i+7, vucp);
    if ((i+7 > 15) && (ucv[13] != uca[29]))
      abort ();
    if ((i + 7 <= 15) && (ucv[13] != uca[13]))
      abort ();
  }

  /* Do vector of short.  */
  for (int i = 0; i < 16; i++) {
    /* Focus on sa[8] ... sa[15].  */
    sv = vec_ldl (i+16, sa);
    if (sv[4] != sa[12])
      abort ();
    /* Focus on usa[24] ... usa[31].  */
    usv = vec_ldl (i+48, usa);
    if (usv[7] != usa[31])
      abort ();
    /* Focus on sa[0] ... sa[7].  */
    sv = vec_ldl (i, vsp);
    if (sv[3] != sa[3])
      abort ();
    /* Focus on usa[0] ... usa[7] while i <= 8.
       Focus on usa[8] ... usa[15] while i > 8.  */
    usv = vec_ldl (i+7, vusp);
    if ((i+7 > 15) && (usv[5] != usa[13]))
      abort ();
    if ((i + 7 <= 15) && (usv[5] != usa[5]))
      abort ();
  }

  /* Do vector of int.  */
  for (int i = 0; i < 16; i++) {
    /* Focus on ia[8] ... ia[11].  */
    iv = vec_ldl (i+32, ia);
    if (iv[3] != ia[11])
      abort ();
    /* Focus on uia[12] ... uia[15].  */
    uiv = vec_ldl (i+48, uia);
    if (uiv[2] != uia[14])
      abort ();
    /* Focus on ia[0] ... ia[3].  */
    iv = vec_ldl (i, vip);
    if (iv[3] != ia[3])
      abort ();
    /* Focus on uia[0] ... uia[3] while i <= 8.
       Focus on uia[4] ... uia[7] while i > 8.  */
    uiv = vec_ldl (i+7, vuip);
    if ((i+7 > 15) && (uiv[1] != uia[5]))
      abort ();
    if ((i + 7 <= 15) && (uiv[1] != uia[1]))
      abort ();
  }

  /* Do vector of long long int.  */
  for (int i = 0; i < 16; i++) {
    /* Focus on la[4] ... la[5].  */
    lv = vec_ldl (i+32, la);
    if (lv[1] != la[5])
      abort ();
    /* Focus on ula[6] ... ula[7].  */
    ulv = vec_ldl (i+48, ula);
    if (ulv[0] != uia[6])
      abort ();
    /* Focus on la[0] ... la[1].  */
    lv = vec_ldl (i, vlp);
    if (iv[1] != la[1])
      abort ();
    /* Focus on ula[0] ... uia[1] while i <= 8.
       Focus on uia[2] ... uia[3] while i > 8.  */
    ulv = vec_ldl (i+7, vulp);
    if ((i+7 > 15) && (ulv[1] != ula[3]))
      abort ();
    if ((i + 7 <= 15) && (ulv[1] != ula[1]))
      abort ();
  }

  /* Do vector of double.  */
  for (int i = 0; i < 16; i++) {
    /* Focus on da[2] ... da[3].  */
    dv = vec_ldl (i+16, da);
    if (dv[1] != da[3])
      abort ();
    /* Focus on da[6] ... da[7].  */
    dv = vec_ldl (i+48, vdp);
    if (dv[0] != da[6])
      abort ();
    /* Focus on da[0] ... da[1].  */
    dv = vec_ldl (i, da);
    if (dv[1] != da[1])
      abort ();
    /* Focus on da[0] ... da[1] while i <= 8.
       Focus on da[2] ... da[3] while i > 8.  */
    dv = vec_ldl (i+7, vdp);
    if ((i+7 <= 15) && (dv[1] != da[1]))
      abort ();
    if ((i + 7 > 15) && (dv[1] != da[3]))
      abort ();
  }
  return 0;
}