Lines Matching +full:no +full:- +full:temp +full:- +full:support

1 //===- ExtractFunction.cpp - Extract a function from Program --------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
12 //===----------------------------------------------------------------------===//
23 #include "llvm/Support/CommandLine.h"
24 #include "llvm/Support/Debug.h"
25 #include "llvm/Support/FileUtilities.h"
26 #include "llvm/Support/Path.h"
27 #include "llvm/Support/Signals.h"
28 #include "llvm/Support/ToolOutputFile.h"
44 cl::opt<bool> NoDCE("disable-dce",
45 cl::desc("Do not use the -dce pass to reduce testcases"));
47 NoSCFG("disable-simplifycfg", cl::location(DisableSimplifyCFG),
48 cl::desc("Do not use the -simplifycfg pass to reduce testcases"));
51 if (!GV->hasInitializer()) in globalInitUsesExternalBA()
54 Constant *I = GV->getInitializer(); in globalInitUsesExternalBA()
68 Function *F = BA->getFunction(); in globalInitUsesExternalBA()
69 if (F->isDeclaration()) in globalInitUsesExternalBA()
73 for (User::op_iterator i = V->op_begin(), e = V->op_end(); i != e; ++i) { in globalInitUsesExternalBA()
89 const BasicBlock *PBB = I->getParent(); in deleteInstructionFromProgram()
90 const Function *PF = PBB->getParent(); in deleteInstructionFromProgram()
92 Module::iterator RFI = Clone->begin(); // Get iterator to corresponding fn in deleteInstructionFromProgram()
94 RFI, std::distance(PF->getParent()->begin(), Module::const_iterator(PF))); in deleteInstructionFromProgram()
96 Function::iterator RBI = RFI->begin(); // Get iterator to corresponding BB in deleteInstructionFromProgram()
97 std::advance(RBI, std::distance(PF->begin(), Function::const_iterator(PBB))); in deleteInstructionFromProgram()
99 BasicBlock::iterator RI = RBI->begin(); // Get iterator to corresponding inst in deleteInstructionFromProgram()
100 std::advance(RI, std::distance(PBB->begin(), BasicBlock::const_iterator(I))); in deleteInstructionFromProgram()
104 if (!TheInst->getType()->isVoidTy()) in deleteInstructionFromProgram()
105 TheInst->replaceAllUsesWith(Constant::getNullValue(TheInst->getType())); in deleteInstructionFromProgram()
108 TheInst->eraseFromParent(); in deleteInstructionFromProgram()
113 /// Can we get rid of the -disable-* options? in deleteInstructionFromProgram()
132 for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I) in performFinalCleanups()
133 I->setLinkage(GlobalValue::ExternalLinkage); in performFinalCleanups()
152 LoopExtractPasses.push_back("loop-extract-single"); in extractLoop()
162 // Check to see if we created any new functions. If not, no loops were in extractLoop()
166 if (M->size() == NewM->size() || --NumExtracted == 0) { in extractLoop()
169 assert(M->size() < NewM->size() && "Loop extract removed functions?"); in extractLoop()
170 Module::iterator MI = NewM->begin(); in extractLoop()
171 for (unsigned i = 0, e = M->size(); i != e; ++i) in extractLoop()
184 Module *M = GV->getParent(); in eliminateAliases()
185 for (Module::alias_iterator I = M->alias_begin(), E = M->alias_end(); in eliminateAliases()
187 if (I->getAliasee()->stripPointerCasts() == GV) in eliminateAliases()
193 aliases[i]->replaceAllUsesWith(aliases[i]->getAliasee()); in eliminateAliases()
194 aliases[i]->eraseFromParent(); in eliminateAliases()
196 // 3. Repeat until no more aliases found; there might in eliminateAliases()
202 // DeleteGlobalInitializer - "Remove" the global variable by deleting its
208 GV->setInitializer(nullptr); in DeleteGlobalInitializer()
209 GV->setComdat(nullptr); in DeleteGlobalInitializer()
212 // DeleteFunctionBody - "Remove" the function by deleting all of its basic
218 F->setComdat(nullptr); in DeleteFunctionBody()
221 F->deleteBody(); in DeleteFunctionBody()
222 assert(F->isDeclaration() && "This didn't make the function external!"); in DeleteFunctionBody()
225 /// GetTorInit - Given a list of entries for static ctors/dtors, return them
230 Type *Int32Ty = Type::getInt32Ty(TorList[0].first->getContext()); in GetTorInit()
232 StructType *STy = StructType::get(Int32Ty, TorList[0].first->getType()); in GetTorInit()
239 ArrayType::get(ArrayElts[0]->getType(), ArrayElts.size()), ArrayElts); in GetTorInit()
242 /// SplitStaticCtorDtor - A module was recently split into two parts, M1/M2, and
248 GlobalVariable *GV = M1->getNamedGlobal(GlobalName); in SplitStaticCtorDtor()
249 if (!GV || GV->isDeclaration() || GV->hasLocalLinkage() || !GV->use_empty()) in SplitStaticCtorDtor()
253 ConstantArray *InitList = dyn_cast<ConstantArray>(GV->getInitializer()); in SplitStaticCtorDtor()
257 for (unsigned i = 0, e = InitList->getNumOperands(); i != e; ++i) { in SplitStaticCtorDtor()
259 dyn_cast<ConstantStruct>(InitList->getOperand(i))) { in SplitStaticCtorDtor()
260 if (CS->getNumOperands() != 2) in SplitStaticCtorDtor()
261 return; // Not array of 2-element structs. in SplitStaticCtorDtor()
263 if (CS->getOperand(1)->isNullValue()) in SplitStaticCtorDtor()
266 ConstantInt *CI = dyn_cast<ConstantInt>(CS->getOperand(0)); in SplitStaticCtorDtor()
267 int Priority = CI ? CI->getSExtValue() : 0; in SplitStaticCtorDtor()
269 Constant *FP = CS->getOperand(1); in SplitStaticCtorDtor()
271 if (CE->isCast()) in SplitStaticCtorDtor()
272 FP = CE->getOperand(0); in SplitStaticCtorDtor()
274 if (!F->isDeclaration()) in SplitStaticCtorDtor()
285 GV->eraseFromParent(); in SplitStaticCtorDtor()
288 new GlobalVariable(*M1, M1Init->getType(), false, in SplitStaticCtorDtor()
292 GV = M2->getNamedGlobal(GlobalName); in SplitStaticCtorDtor()
294 assert(GV->use_empty() && "llvm.ctors shouldn't have uses!"); in SplitStaticCtorDtor()
296 GV->eraseFromParent(); in SplitStaticCtorDtor()
299 new GlobalVariable(*M2, M2Init->getType(), false, in SplitStaticCtorDtor()
309 for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I) in SplitFunctionsOutOfModule()
310 I->setLinkage(GlobalValue::ExternalLinkage); in SplitFunctionsOutOfModule()
311 for (Module::global_iterator I = M->global_begin(), E = M->global_end(); in SplitFunctionsOutOfModule()
313 if (I->hasName() && I->getName()[0] == '\01') in SplitFunctionsOutOfModule()
314 I->setName(I->getName().substr(1)); in SplitFunctionsOutOfModule()
315 I->setLinkage(GlobalValue::ExternalLinkage); in SplitFunctionsOutOfModule()
326 LLVM_DEBUG(TNOF->printAsOperand(errs(), false)); in SplitFunctionsOutOfModule()
338 for (GlobalVariable &I : M->globals()) { in SplitFunctionsOutOfModule()
344 GV->printAsOperand(errs(), false); in SplitFunctionsOutOfModule()
347 << SafeFn->getName() << "' and from test function '" in SplitFunctionsOutOfModule()
348 << TestFn->getName() << "'.\n"; in SplitFunctionsOutOfModule()
366 //===----------------------------------------------------------------------===//
368 //===----------------------------------------------------------------------===//
373 auto Temp = sys::fs::TempFile::create(OutputPrefix + "-extractblocks%%%%%%%"); in extractMappedBlocksFromModule() local
374 if (!Temp) { in extractMappedBlocksFromModule()
376 errs() << "Error creating temporary file: " << toString(Temp.takeError()) in extractMappedBlocksFromModule()
381 DiscardTemp Discard{*Temp}; in extractMappedBlocksFromModule()
391 raw_fd_ostream OS(Temp->FD, /*shouldClose*/ false); in extractMappedBlocksFromModule()
395 if (!BB->hasName()) in extractMappedBlocksFromModule()
396 BB->setName("tmpbb"); in extractMappedBlocksFromModule()
397 OS << BB->getParent()->getName() << " " << BB->getName() << "\n"; in extractMappedBlocksFromModule()
407 std::string uniqueFN = "--extract-blocks-file="; in extractMappedBlocksFromModule()
408 uniqueFN += Temp->TmpName; in extractMappedBlocksFromModule()
411 PI.push_back("extract-blocks"); in extractMappedBlocksFromModule()