Utils

Home


WeChat: cstutorcs
QQ: 749389476
#include “Utils.h”

#include “llvm/IR/CFG.h”

const char *WhiteSpaces = ” \t\n\r”;

std::string toString(Value *I) {
std::string Str;
raw_string_ostream SS(Str);
I->print(SS);
return SS.str();

std::vector getPredecessors(Instruction *I) {
std::vector Ret;
BasicBlock *BB = I->getParent();
for (BasicBlock::reverse_iterator It = BB->rbegin(), E = BB->rend(); It != E;
if (&(*It) == I) {
if (It == E) {
for (pred_iterator Pre = pred_begin(BB), BE = pred_end(BB); Pre != BE;
Ret.push_back(&(*((*Pre)->rbegin())));
Ret.push_back(&(*It));
return Ret;

bool isDef(Instruction *I) {
return !(I->getType()->isVoidTy());