llvm.org GIT mirror llvm / 2cccc62
whitespace git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190973 91177308-0d34-0410-b5e6-96231b3b80d8 Andrew Trick 5 years ago
6 changed file(s) with 33 addition(s) and 33 deletion(s). Raw diff Collapse all Expand all
9696 return wrap(new Module(ModuleID, getGlobalContext()));
9797 }
9898
99 LLVMModuleRef LLVMModuleCreateWithNameInContext(const char *ModuleID,
99 LLVMModuleRef LLVMModuleCreateWithNameInContext(const char *ModuleID,
100100 LLVMContextRef C) {
101101 return wrap(new Module(ModuleID, *unwrap(C)));
102102 }
680680 return wrap(ConstantDataArray::getString(*unwrap(C), StringRef(Str, Length),
681681 DontNullTerminate == 0));
682682 }
683 LLVMValueRef LLVMConstStructInContext(LLVMContextRef C,
683 LLVMValueRef LLVMConstStructInContext(LLVMContextRef C,
684684 LLVMValueRef *ConstantVals,
685685 unsigned Count, LLVMBool Packed) {
686686 Constant **Elements = unwrap(ConstantVals, Count);
15521552 return (LLVMAttribute)A->getParent()->getAttributes().
15531553 Raw(A->getArgNo()+1);
15541554 }
1555
1555
15561556
15571557 void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned align) {
15581558 Argument *A = unwrap(Arg);
17441744 llvm_unreachable("LLVMSetInstructionCallConv applies only to call and invoke!");
17451745 }
17461746
1747 void LLVMAddInstrAttribute(LLVMValueRef Instr, unsigned index,
1747 void LLVMAddInstrAttribute(LLVMValueRef Instr, unsigned index,
17481748 LLVMAttribute PA) {
17491749 CallSite Call = CallSite(unwrap(Instr));
17501750 AttrBuilder B(PA);
17541754 index, B)));
17551755 }
17561756
1757 void LLVMRemoveInstrAttribute(LLVMValueRef Instr, unsigned index,
1757 void LLVMRemoveInstrAttribute(LLVMValueRef Instr, unsigned index,
17581758 LLVMAttribute PA) {
17591759 CallSite Call = CallSite(unwrap(Instr));
17601760 AttrBuilder B(PA);
17641764 index, B)));
17651765 }
17661766
1767 void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index,
1767 void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index,
17681768 unsigned align) {
17691769 CallSite Call = CallSite(unwrap(Instr));
17701770 AttrBuilder B;
21182118 Type* ITy = Type::getInt32Ty(unwrap(B)->GetInsertBlock()->getContext());
21192119 Constant* AllocSize = ConstantExpr::getSizeOf(unwrap(Ty));
21202120 AllocSize = ConstantExpr::getTruncOrBitCast(AllocSize, ITy);
2121 Instruction* Malloc = CallInst::CreateMalloc(unwrap(B)->GetInsertBlock(),
2122 ITy, unwrap(Ty), AllocSize,
2121 Instruction* Malloc = CallInst::CreateMalloc(unwrap(B)->GetInsertBlock(),
2122 ITy, unwrap(Ty), AllocSize,
21232123 0, 0, "");
21242124 return wrap(unwrap(B)->Insert(Malloc, Twine(Name)));
21252125 }
21292129 Type* ITy = Type::getInt32Ty(unwrap(B)->GetInsertBlock()->getContext());
21302130 Constant* AllocSize = ConstantExpr::getSizeOf(unwrap(Ty));
21312131 AllocSize = ConstantExpr::getTruncOrBitCast(AllocSize, ITy);
2132 Instruction* Malloc = CallInst::CreateMalloc(unwrap(B)->GetInsertBlock(),
2133 ITy, unwrap(Ty), AllocSize,
2132 Instruction* Malloc = CallInst::CreateMalloc(unwrap(B)->GetInsertBlock(),
2133 ITy, unwrap(Ty), AllocSize,
21342134 unwrap(Val), 0, "");
21352135 return wrap(unwrap(B)->Insert(Malloc, Twine(Name)));
21362136 }
21562156 return wrap(unwrap(B)->CreateLoad(unwrap(PointerVal), Name));
21572157 }
21582158
2159 LLVMValueRef LLVMBuildStore(LLVMBuilderRef B, LLVMValueRef Val,
2159 LLVMValueRef LLVMBuildStore(LLVMBuilderRef B, LLVMValueRef Val,
21602160 LLVMValueRef PointerVal) {
21612161 return wrap(unwrap(B)->CreateStore(unwrap(Val), unwrap(PointerVal)));
21622162 }
23952395 return wrap(unwrap(B)->CreatePtrDiff(unwrap(LHS), unwrap(RHS), Name));
23962396 }
23972397
2398 LLVMValueRef LLVMBuildAtomicRMW(LLVMBuilderRef B,LLVMAtomicRMWBinOp op,
2399 LLVMValueRef PTR, LLVMValueRef Val,
2400 LLVMAtomicOrdering ordering,
2398 LLVMValueRef LLVMBuildAtomicRMW(LLVMBuilderRef B,LLVMAtomicRMWBinOp op,
2399 LLVMValueRef PTR, LLVMValueRef Val,
2400 LLVMAtomicOrdering ordering,
24012401 LLVMBool singleThread) {
24022402 AtomicRMWInst::BinOp intop;
24032403 switch (op) {
24202420 case LLVMAtomicOrderingMonotonic: intordering = Monotonic; break;
24212421 case LLVMAtomicOrderingAcquire: intordering = Acquire; break;
24222422 case LLVMAtomicOrderingRelease: intordering = Release; break;
2423 case LLVMAtomicOrderingAcquireRelease:
2424 intordering = AcquireRelease;
2423 case LLVMAtomicOrderingAcquireRelease:
2424 intordering = AcquireRelease;
24252425 break;
2426 case LLVMAtomicOrderingSequentiallyConsistent:
2427 intordering = SequentiallyConsistent;
2426 case LLVMAtomicOrderingSequentiallyConsistent:
2427 intordering = SequentiallyConsistent;
24282428 break;
24292429 }
2430 return wrap(unwrap(B)->CreateAtomicRMW(intop, unwrap(PTR), unwrap(Val),
2430 return wrap(unwrap(B)->CreateAtomicRMW(intop, unwrap(PTR), unwrap(Val),
24312431 intordering, singleThread ? SingleThread : CrossThread));
24322432 }
24332433
15561556
15571557 for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index)
15581558 Changed |= getContainedPass(Index)->doInitialization(M);
1559
1559
15601560 return Changed;
15611561 }
15621562
15651565
15661566 for (int Index = getNumContainedPasses() - 1; Index >= 0; --Index)
15671567 Changed |= getContainedPass(Index)->doFinalization(M);
1568
1568
15691569 return Changed;
15701570 }
15711571
16331633 FPP->releaseMemoryOnTheFly();
16341634 Changed |= FPP->doFinalization(M);
16351635 }
1636
1636
16371637 return Changed;
16381638 }
16391639
6969 cl::ParseCommandLineOptions(argc, argv);
7070
7171 LLVMContext Context;
72
72
7373 // Load both modules. Die if that fails.
7474 Module *LModule = ReadModule(Context, LeftFilename);
7575 Module *RModule = ReadModule(Context, RightFilename);
5252 ExtractFuncs("func", cl::desc("Specify function to extract"),
5353 cl::ZeroOrMore, cl::value_desc("function"));
5454
55 // ExtractRegExpFuncs - The functions, matched via regular expression, to
55 // ExtractRegExpFuncs - The functions, matched via regular expression, to
5656 // extract from the module.
5757 static cl::list
5858 ExtractRegExpFuncs("rfunc", cl::desc("Specify function(s) to extract using a "
6969 // Print a stack trace if we signal out.
7070 sys::PrintStackTraceOnErrorSignal();
7171 PrettyStackTraceProgram X(argc, argv);
72
72
7373 LLVMContext &Context = getGlobalContext();
7474 llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
7575 cl::ParseCommandLineOptions(argc, argv, "llvm linker\n");
130130 ProfileInfoLoader &PIL;
131131 public:
132132 static char ID; // Class identification, replacement for typeinfo.
133 explicit ProfileInfoPrinterPass(ProfileInfoLoader &_PIL)
133 explicit ProfileInfoPrinterPass(ProfileInfoLoader &_PIL)
134134 : ModulePass(ID), PIL(_PIL) {}
135135
136136 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
160160 if (FI->isDeclaration()) continue;
161161 double w = ignoreMissing(PI.getExecutionCount(FI));
162162 FunctionCounts.push_back(std::make_pair(FI, w));
163 for (Function::iterator BB = FI->begin(), BBE = FI->end();
163 for (Function::iterator BB = FI->begin(), BBE = FI->end();
164164 BB != BBE; ++BB) {
165165 double w = ignoreMissing(PI.getExecutionCount(BB));
166166 Counts.push_back(std::make_pair(BB, w));
193193 outs() << " ## Frequency\n";
194194 for (unsigned i = 0, e = FunctionCounts.size(); i != e; ++i) {
195195 if (FunctionCounts[i].second == 0) {
196 outs() << "\n NOTE: " << e-i << " function"
196 outs() << "\n NOTE: " << e-i << " function"
197197 << (e-i-1 ? "s were" : " was") << " never executed!\n";
198198 break;
199199 }
209209 TotalExecutions = 0;
210210 for (unsigned i = 0, e = Counts.size(); i != e; ++i)
211211 TotalExecutions += Counts[i].second;
212
212
213213 // Sort by the frequency, backwards.
214214 sort(Counts.begin(), Counts.end(),
215215 PairSecondSortReverse());
216
216
217217 outs() << "\n===" << std::string(73, '-') << "===\n";
218218 outs() << "Top 20 most frequently executed basic blocks:\n\n";
219
219
220220 // Print out the function frequencies...
221221 outs() <<" ## %% \tFrequency\n";
222222 unsigned BlocksToPrint = Counts.size();
236236 if (PrintAnnotatedLLVM || PrintAllCode) {
237237 outs() << "\n===" << std::string(73, '-') << "===\n";
238238 outs() << "Annotated LLVM code for the module:\n\n";
239
239
240240 ProfileAnnotator PA(PI);
241241
242242 if (FunctionsToPrint.empty() || PrintAllCode)
258258
259259 LLVMContext &Context = getGlobalContext();
260260 llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
261
261
262262 cl::ParseCommandLineOptions(argc, argv, "llvm profile dump decoder\n");
263263
264264 // Read in the bitcode file...