コード例 #1
0
ファイル: ContextUtils.cpp プロジェクト: CTSRD-SOAAP/soaap
ContextVector ContextUtils::getAllContexts(SandboxVector& sandboxes) {
    ContextVector Cs;
    Cs.push_back(PRIV_CONTEXT);
    Cs.push_back(NO_CONTEXT);
    Cs.insert(Cs.end(), sandboxes.begin(), sandboxes.end());
    return Cs;
}
コード例 #2
0
bool X86CallFrameOptimization::runOnMachineFunction(MachineFunction &MF) {
  STI = &MF.getSubtarget<X86Subtarget>();
  TII = STI->getInstrInfo();
  TFL = STI->getFrameLowering();
  MRI = &MF.getRegInfo();

  if (!isLegal(MF))
    return false;

  unsigned FrameSetupOpcode = TII->getCallFrameSetupOpcode();

  bool Changed = false;

  ContextVector CallSeqVector;

  for (auto &MBB : MF)
    for (auto &MI : MBB)
      if (MI.getOpcode() == FrameSetupOpcode) {
        CallContext Context;
        collectCallInfo(MF, MBB, MI, Context);
        CallSeqVector.push_back(Context);
      }

  if (!isProfitable(MF, CallSeqVector))
    return false;

  for (auto CC : CallSeqVector)
    if (CC.UsePush)
      Changed |= adjustCallSequence(MF, CC);

  return Changed;
}
コード例 #3
0
bool X86CallFrameOptimization::runOnMachineFunction(MachineFunction &MF) {
  STI = &MF.getSubtarget<X86Subtarget>();
  TII = STI->getInstrInfo();
  TFL = STI->getFrameLowering();
  MRI = &MF.getRegInfo();

  if (!isLegal(MF))
    return false;

  unsigned FrameSetupOpcode = TII->getCallFrameSetupOpcode();

  bool Changed = false;

  ContextVector CallSeqVector;

  for (MachineFunction::iterator BB = MF.begin(), E = MF.end(); BB != E; ++BB)
    for (MachineBasicBlock::iterator I = BB->begin(); I != BB->end(); ++I)
      if (I->getOpcode() == FrameSetupOpcode) {
        CallContext Context;
        collectCallInfo(MF, *BB, I, Context);
        CallSeqVector.push_back(Context);
      }

  if (!isProfitable(MF, CallSeqVector))
    return false;

  for (auto CC : CallSeqVector)
    if (CC.UsePush)
      Changed |= adjustCallSequence(MF, CC);

  return Changed;
}
コード例 #4
0
ファイル: ContextUtils.cpp プロジェクト: CTSRD-SOAAP/soaap
ContextVector ContextUtils::getContextsForMethod(Function* F, bool contextInsensitive, SandboxVector& sandboxes, Module& M) {
    if (contextInsensitive) {
        return ContextVector(1, SINGLE_CONTEXT);
    }
    else {
        ContextVector Cs;
        if (SandboxUtils::isPrivilegedMethod(F, M)) {
            Cs.push_back(PRIV_CONTEXT);
        }
        SandboxVector containers = SandboxUtils::getSandboxesContainingMethod(F, sandboxes);
        Cs.insert(Cs.begin(), containers.begin(), containers.end());
        return Cs;
    }
}
コード例 #5
0
ファイル: ContextUtils.cpp プロジェクト: CTSRD-SOAAP/soaap
ContextVector ContextUtils::getContextsForInstruction(Instruction* I, bool contextInsensitive, SandboxVector& sandboxes, Module& M) {
    SDEBUG("soaap.util.context", 5, dbgs() << "getContextsForInstruction\n");
    if (contextInsensitive) {
        SDEBUG("soaap.util.context", 5, dbgs() << "context insensitive\n");
        return ContextVector(1, SINGLE_CONTEXT);
    }
    else {
        ContextVector Cs;
        if (SandboxUtils::isPrivilegedInstruction(I, sandboxes, M)) {
            Cs.push_back(PRIV_CONTEXT);
        }
        SDEBUG("soaap.util.context", 5, dbgs() << "looking for sandboxes containing instruction\n");
        SandboxVector containers = SandboxUtils::getSandboxesContainingInstruction(I, sandboxes);
        Cs.insert(Cs.begin(), containers.begin(), containers.end());
        return Cs;
    }
}
コード例 #6
0
DataSet DataSet::readTADMDataSet(istream &iss)
{
	string line;
	ContextVector contexts;
	
	while (iss)
	{
		// Would really like to avoid reading the context here,
		// so try to detect EOF.
		if (iss.peek() == EOF)
			break;

		contexts.push_back(readContext(iss));
	}
	
	return DataSet(contexts);
}
コード例 #7
0
bool X86CallFrameOptimization::runOnMachineFunction(MachineFunction &MF) {
  STI = &MF.getSubtarget<X86Subtarget>();
  TII = STI->getInstrInfo();
  TFL = STI->getFrameLowering();
  MRI = &MF.getRegInfo();

  const X86RegisterInfo &RegInfo =
      *static_cast<const X86RegisterInfo *>(STI->getRegisterInfo());
  SlotSize = RegInfo.getSlotSize();
  assert(isPowerOf2_32(SlotSize) && "Expect power of 2 stack slot size");
  Log2SlotSize = Log2_32(SlotSize);

  if (skipFunction(MF.getFunction()) || !isLegal(MF))
    return false;

  unsigned FrameSetupOpcode = TII->getCallFrameSetupOpcode();

  bool Changed = false;

  ContextVector CallSeqVector;

  for (auto &MBB : MF)
    for (auto &MI : MBB)
      if (MI.getOpcode() == FrameSetupOpcode) {
        CallContext Context;
        collectCallInfo(MF, MBB, MI, Context);
        CallSeqVector.push_back(Context);
      }

  if (!isProfitable(MF, CallSeqVector))
    return false;

  for (auto CC : CallSeqVector) {
    if (CC.UsePush) {
      adjustCallSequence(MF, CC);
      Changed = true;
    }
  }

  return Changed;
}