本文整理汇总了C++中LoadInst::dump方法的典型用法代码示例。如果您正苦于以下问题:C++ LoadInst::dump方法的具体用法?C++ LoadInst::dump怎么用?C++ LoadInst::dump使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LoadInst
的用法示例。
在下文中一共展示了LoadInst::dump方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Ranges
//.........这里部分代码省略.........
}
}
// If we have no ranges, then we just had a single store with nothing that
// could be merged in. This is a very common case of course.
if (!Ranges.moreThanOneOp())
return 0;
// Divide the instructions between StartInst and LastLoadOrStore into
// addressing, memops, and uses of memops (uses of loads)
reorderAddressingMemopsUses(StartInst, LastLoadOrStore, DebugThis);
Instruction* insertBefore = StartInst;
IRBuilder<> builder(insertBefore);
// Now that we have full information about ranges, loop over the ranges and
// emit memcpy's for anything big enough to be worthwhile.
for (MemOpRanges::const_iterator I = Ranges.begin(), E = Ranges.end();
I != E; ++I) {
const MemOpRange &Range = *I;
Value* oldBaseI = NULL;
Value* newBaseI = NULL;
if (Range.TheStores.size() == 1) continue; // Don't bother if there's only one thing...
builder.SetInsertPoint(insertBefore);
// Otherwise, we do want to transform this! Create a new memcpy.
// Get the starting pointer of the block.
StartPtr = Range.StartPtr;
if( DebugThis ) {
errs() << "base is:";
StartPtr->dump();
}
// Determine alignment
unsigned Alignment = Range.Alignment;
if (Alignment == 0) {
Type *EltType =
cast<PointerType>(StartPtr->getType())->getElementType();
Alignment = TD->getABITypeAlignment(EltType);
}
Instruction *alloc = NULL;
Value *globalPtr = NULL;
// create temporary alloca space to communicate to/from.
alloc = makeAlloca(int8Ty, "agg.tmp", insertBefore,
Range.End-Range.Start, Alignment);
// Generate the old and new base pointers before we output
// anything else.
{
Type* iPtrTy = TD->getIntPtrType(alloc->getType());
Type* iNewBaseTy = TD->getIntPtrType(alloc->getType());
oldBaseI = builder.CreatePtrToInt(StartPtr, iPtrTy, "agg.tmp.oldb.i");
newBaseI = builder.CreatePtrToInt(alloc, iNewBaseTy, "agg.tmp.newb.i");
}
// If storing, do the stores we had into our alloca'd region.
if( isStore ) {
for (SmallVector<Instruction*, 16>::const_iterator
SI = Range.TheStores.begin(),
SE = Range.TheStores.end(); SI != SE; ++SI) {
StoreInst* oldStore = cast<StoreInst>(*SI);
示例2: PM
Function * futamurize( const Function * orig_func, DenseMap<const Value*, Value*> &argmap, std::set<const unsigned char *> &constant_addresses_set )
{
LLVMContext &context = getGlobalContext();
// Make a copy of the function, removing constant arguments
Function * specialized_func = CloneFunction( orig_func, argmap );
specialized_func->setName( orig_func->getNameStr() + "_1" );
// add it to our module
LLVM_Module->getFunctionList().push_back( specialized_func );
printf("\nspecialized_func = %p <%s>\n", specialized_func, specialized_func->getName().data());
//~ specialized_func->dump();
// Optimize it
FunctionPassManager PM( LLVM_Module );
createStandardFunctionPasses( &PM, 3 );
PM.add(createScalarReplAggregatesPass()); // Break up aggregate allocas
PM.add(createInstructionCombiningPass()); // Cleanup for scalarrepl.
PM.add(createJumpThreadingPass()); // Thread jumps.
PM.add(createCFGSimplificationPass()); // Merge & remove BBs
PM.add(createInstructionCombiningPass()); // Combine silly seq's
PM.add(createTailCallEliminationPass()); // Eliminate tail calls
PM.add(createCFGSimplificationPass()); // Merge & remove BBs
PM.add(createReassociatePass()); // Reassociate expressions
PM.add(createLoopRotatePass()); // Rotate Loop
PM.add(createLICMPass()); // Hoist loop invariants
PM.add(createLoopUnswitchPass( false ));
PM.add(createInstructionCombiningPass());
PM.add(createIndVarSimplifyPass()); // Canonicalize indvars
PM.add(createLoopDeletionPass()); // Delete dead loops
PM.add(createLoopUnroll2Pass()); // Unroll small loops
PM.add(createInstructionCombiningPass()); // Clean up after the unroller
PM.add(createGVNPass()); // Remove redundancies
PM.add(createMemCpyOptPass()); // Remove memcpy / form memset
PM.add(createSCCPPass()); // Constant prop with SCCP
PM.add(createPromoteMemoryToRegisterPass());
PM.add(createConstantPropagationPass());
PM.add(createDeadStoreEliminationPass());
PM.add(createAggressiveDCEPass());
PM.add(new MemoryDependenceAnalysis());
//~ PM.add(createAAEvalPass());
const PassInfo * pinfo = Pass::lookupPassInfo( "print-alias-sets" );
if( !pinfo ) { printf( "print-alias-sets not found\n" ); exit(-1); }
PM.add( pinfo->createPass() );
FunctionPassManager PM_Inline( LLVM_Module );
PM_Inline.add(createSingleFunctionInliningPass());
bool Changed = false;
int iterations = 2;
int inline_iterations = 6;
do
{
Changed = false;
// first do some optimizations
PM.doInitialization();
PM.run( *specialized_func );
PM.doFinalization();
// Load from Constant Memory detection
const TargetData *TD = LLVM_EE->getTargetData();
for (inst_iterator I = inst_begin(specialized_func), E = inst_end(specialized_func); I != E; ++I)
{
Instruction * inst = (Instruction *) &*I;
// get all Load instructions
LoadInst * load = dyn_cast<LoadInst>( inst );
if( !load ) continue;
if( load->isVolatile() ) continue;
if (load->use_empty()) continue; // Don't muck with dead instructions...
// get the address loaded by load instruction
Value *ptr_value = load->getPointerOperand();
// we're only interested in constant addresses
ConstantExpr * ptr_constant_expr = dyn_cast<ConstantExpr>( ptr_value );
if( !ptr_constant_expr ) continue;
ptr_constant_expr->dump();
// compute real address of constant pointer expression
Constant * ptr_constant = ConstantFoldConstantExpression( ptr_constant_expr, TD );
if( !ptr_constant ) continue;
ptr_constant->dump();
// convert to int constant
ConstantInt *int_constant = dyn_cast<ConstantInt>( ConstantExpr::getPtrToInt( ptr_constant, Type::getInt64Ty( context )));
if( !int_constant ) continue;
int_constant->dump();
// get data size
int data_length = TD->getTypeAllocSize( load->getType() );
ptr_value->getType()->dump();
//.........这里部分代码省略.........