From 2c43da5705af0be7096557346080ce540828ec29 Mon Sep 17 00:00:00 2001 From: Andy Ragusa Date: Fri, 2 Feb 2024 11:46:03 -0800 Subject: [PATCH] blah --- clam-format | 4 + .../HelloWorld/HelloWorld.cpp | 26 ++-- .../AnalysisPlugin/AnalysisPlugin.cpp | 121 +++++++++--------- .../ClamBCChangeMallocArgSize.cpp | 1 - .../ClamBCConvertIntrinsicsTo32Bit.cpp | 1 - libclambcc/Common/ClamBCModule.h | 1 - 6 files changed, 77 insertions(+), 77 deletions(-) diff --git a/clam-format b/clam-format index bbee2f76c3..e0cb2e76c0 100755 --- a/clam-format +++ b/clam-format @@ -5,3 +5,7 @@ clang-format-12 -style='{ Language: Cpp, UseTab: Never, IndentWidth: 4, AlignTra clang-format-12 -i -verbose `find libclambcc -name "*.cpp"` clang-format-12 -i -verbose `find libclambcc -name "*.h"` clang-format-12 -i -verbose `find libclambcc -name "*.c"` + +clang-format-12 -i -verbose `find examples -name "*.cpp"` +clang-format-12 -i -verbose `find examples -name "*.h"` +clang-format-12 -i -verbose `find examples -name "*.c"` diff --git a/examples/LegacyPassManager/HelloWorld/HelloWorld.cpp b/examples/LegacyPassManager/HelloWorld/HelloWorld.cpp index f8680f20d6..a8961771e0 100644 --- a/examples/LegacyPassManager/HelloWorld/HelloWorld.cpp +++ b/examples/LegacyPassManager/HelloWorld/HelloWorld.cpp @@ -13,24 +13,24 @@ //#include "Common/clambc.h" using namespace llvm; -namespace { +namespace +{ struct Hello : public FunctionPass { - static char ID; - Hello() : FunctionPass(ID) {} - - bool runOnFunction(Function &F) override { - errs() << "Hello: "; - errs().write_escaped(F.getName()) << '\n'; - return false; - } + static char ID; + Hello() + : FunctionPass(ID) {} + + bool runOnFunction(Function &F) override + { + errs() << "Hello: "; + errs().write_escaped(F.getName()) << '\n'; + return false; + } }; // end of struct Hello -} // end of anonymous namespace +} // end of anonymous namespace char Hello::ID = 0; static RegisterPass X("hello", "Hello World Pass", false /* Only looks at CFG */, false /* Analysis Pass */); - - - diff --git a/examples/PassManager/AnalysisPlugin/AnalysisPlugin.cpp b/examples/PassManager/AnalysisPlugin/AnalysisPlugin.cpp index 450236f98a..2c013a5644 100644 --- a/examples/PassManager/AnalysisPlugin/AnalysisPlugin.cpp +++ b/examples/PassManager/AnalysisPlugin/AnalysisPlugin.cpp @@ -41,89 +41,88 @@ using namespace std; namespace { - class AnalysisResult { - public: - AnalysisResult(){ - llvm::errs() << "<" << __FUNCTION__ << "::" << __LINE__ << ">" << "\n"; - } - - }; - - class ExampleAnalysis : public AnalysisInfoMixin +class AnalysisResult +{ + public: + AnalysisResult() { + llvm::errs() << "<" << __FUNCTION__ << "::" << __LINE__ << ">" + << "\n"; + } +}; - public: +class ExampleAnalysis : public AnalysisInfoMixin +{ - friend AnalysisInfoMixin ; - static AnalysisKey Key; + public: + friend AnalysisInfoMixin; + static AnalysisKey Key; + ExampleAnalysis() + { + } - ExampleAnalysis(){ - } + typedef AnalysisResult Result; - typedef AnalysisResult Result; + AnalysisResult run(llvm::Module &F, llvm::ModuleAnalysisManager &fam) + { - AnalysisResult run(llvm::Module & F, llvm::ModuleAnalysisManager & fam){ - - llvm::errs() << "<" << "Analysis::" << __LINE__ << ">" << "\n"; - return AnalysisResult(); + llvm::errs() << "<" + << "Analysis::" << __LINE__ << ">" + << "\n"; + return AnalysisResult(); + } +}; - } +AnalysisKey ExampleAnalysis::Key; - }; +struct ExamplePass : public PassInfoMixin { + protected: + Module *pMod = nullptr; + bool bChanged = false; - AnalysisKey ExampleAnalysis::Key; + public: + virtual ~ExamplePass() {} - struct ExamplePass : public PassInfoMixin + PreservedAnalyses run(Module &m, ModuleAnalysisManager &MAM) { - protected: - Module *pMod = nullptr; - bool bChanged = false; - - public: + pMod = &m; + llvm::errs() << "<" << __FUNCTION__ << "::" << __LINE__ << ">" + << "Transform Pass" + << "\n"; - virtual ~ExamplePass() {} + MAM.getResult(m); - PreservedAnalyses run(Module & m, ModuleAnalysisManager & MAM) - { - pMod = &m; - llvm::errs() << "<" << __FUNCTION__ << "::" << __LINE__ << ">" << "Transform Pass" << "\n"; + llvm::errs() << "<" << __FUNCTION__ << "::" << __LINE__ << ">" + << "Transform Pass (leaving)" + << "\n"; - MAM.getResult(m); - - llvm::errs() << "<" << __FUNCTION__ << "::" << __LINE__ << ">" << "Transform Pass (leaving)" << "\n"; - - return PreservedAnalyses::all(); - } - }; // end of struct ExamplePass + return PreservedAnalyses::all(); + } +}; // end of struct ExamplePass } // end of anonymous namespace // This part is the new way of registering your pass extern "C" ::llvm::PassPluginLibraryInfo LLVM_ATTRIBUTE_WEAK -llvmGetPassPluginInfo() { +llvmGetPassPluginInfo() +{ return { LLVM_PLUGIN_API_VERSION, "ExamplePass", "v0.1", - [](PassBuilder &PB) { - PB.registerPipelineParsingCallback( - [](StringRef Name, ModulePassManager &FPM, - ArrayRef) { - if(Name == "example-pass-with-analysis"){ + [](PassBuilder &PB) { + PB.registerPipelineParsingCallback( + [](StringRef Name, ModulePassManager &FPM, + ArrayRef) { + if (Name == "example-pass-with-analysis") { FPM.addPass(ExamplePass()); return true; - } - return false; - } - ); - - PB.registerAnalysisRegistrationCallback( - [](ModuleAnalysisManager &mam) { - mam.registerPass([] () { return ExampleAnalysis(); } ); - } - ); - } - }; + } + return false; + }); + + PB.registerAnalysisRegistrationCallback( + [](ModuleAnalysisManager &mam) { + mam.registerPass([]() { return ExampleAnalysis(); }); + }); + }}; } - - - diff --git a/libclambcc/ClamBCChangeMallocArgSize/ClamBCChangeMallocArgSize.cpp b/libclambcc/ClamBCChangeMallocArgSize/ClamBCChangeMallocArgSize.cpp index 93379f2fdb..da1e5b7f37 100644 --- a/libclambcc/ClamBCChangeMallocArgSize/ClamBCChangeMallocArgSize.cpp +++ b/libclambcc/ClamBCChangeMallocArgSize/ClamBCChangeMallocArgSize.cpp @@ -12,7 +12,6 @@ #include #include - using namespace llvm; namespace ChangeMallocArgSize diff --git a/libclambcc/ClamBCConvertIntrinsicsTo32Bit/ClamBCConvertIntrinsicsTo32Bit.cpp b/libclambcc/ClamBCConvertIntrinsicsTo32Bit/ClamBCConvertIntrinsicsTo32Bit.cpp index 0aa0870336..ecb0c0032c 100644 --- a/libclambcc/ClamBCConvertIntrinsicsTo32Bit/ClamBCConvertIntrinsicsTo32Bit.cpp +++ b/libclambcc/ClamBCConvertIntrinsicsTo32Bit/ClamBCConvertIntrinsicsTo32Bit.cpp @@ -15,7 +15,6 @@ #include #include - #include using namespace llvm; diff --git a/libclambcc/Common/ClamBCModule.h b/libclambcc/Common/ClamBCModule.h index ea7b74a7b5..8798da008c 100644 --- a/libclambcc/Common/ClamBCModule.h +++ b/libclambcc/Common/ClamBCModule.h @@ -37,7 +37,6 @@ #include #include - class ClamBCWriter; class ClamBCRegAlloc;