Skip to content

Commit

Permalink
blah
Browse files Browse the repository at this point in the history
  • Loading branch information
ragusaa committed Feb 2, 2024
1 parent 44ca8d4 commit 2c43da5
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 77 deletions.
4 changes: 4 additions & 0 deletions clam-format
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
26 changes: 13 additions & 13 deletions examples/LegacyPassManager/HelloWorld/HelloWorld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Hello> X("hello", "Hello World Pass",
false /* Only looks at CFG */,
false /* Analysis Pass */);



121 changes: 60 additions & 61 deletions examples/PassManager/AnalysisPlugin/AnalysisPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,89 +41,88 @@ using namespace std;
namespace
{

class AnalysisResult {
public:
AnalysisResult(){
llvm::errs() << "<" << __FUNCTION__ << "::" << __LINE__ << ">" << "<END>\n";
}

};

class ExampleAnalysis : public AnalysisInfoMixin<ExampleAnalysis >
class AnalysisResult
{
public:
AnalysisResult()
{
llvm::errs() << "<" << __FUNCTION__ << "::" << __LINE__ << ">"
<< "<END>\n";
}
};

public:
class ExampleAnalysis : public AnalysisInfoMixin<ExampleAnalysis>
{

friend AnalysisInfoMixin<ExampleAnalysis > ;
static AnalysisKey Key;
public:
friend AnalysisInfoMixin<ExampleAnalysis>;
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__ << ">" << "<END>\n";
return AnalysisResult();
llvm::errs() << "<"
<< "Analysis::" << __LINE__ << ">"
<< "<END>\n";
return AnalysisResult();
}
};

}
AnalysisKey ExampleAnalysis::Key;

};
struct ExamplePass : public PassInfoMixin<ExamplePass> {
protected:
Module *pMod = nullptr;
bool bChanged = false;

AnalysisKey ExampleAnalysis::Key;
public:
virtual ~ExamplePass() {}

struct ExamplePass : public PassInfoMixin<ExamplePass >
PreservedAnalyses run(Module &m, ModuleAnalysisManager &MAM)
{
protected:
Module *pMod = nullptr;
bool bChanged = false;

public:
pMod = &m;
llvm::errs() << "<" << __FUNCTION__ << "::" << __LINE__ << ">"
<< "Transform Pass"
<< "<END>\n";

virtual ~ExamplePass() {}
MAM.getResult<ExampleAnalysis>(m);

PreservedAnalyses run(Module & m, ModuleAnalysisManager & MAM)
{
pMod = &m;
llvm::errs() << "<" << __FUNCTION__ << "::" << __LINE__ << ">" << "Transform Pass" << "<END>\n";
llvm::errs() << "<" << __FUNCTION__ << "::" << __LINE__ << ">"
<< "Transform Pass (leaving)"
<< "<END>\n";

MAM.getResult<ExampleAnalysis>(m);

llvm::errs() << "<" << __FUNCTION__ << "::" << __LINE__ << ">" << "Transform Pass (leaving)" << "<END>\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<PassBuilder::PipelineElement>) {
if(Name == "example-pass-with-analysis"){
[](PassBuilder &PB) {
PB.registerPipelineParsingCallback(
[](StringRef Name, ModulePassManager &FPM,
ArrayRef<PassBuilder::PipelineElement>) {
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(); });
});
}};
}



Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include <llvm/Passes/PassBuilder.h>
#include <llvm/Passes/PassPlugin.h>


using namespace llvm;

namespace ChangeMallocArgSize
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include <llvm/IR/Constants.h>
#include <llvm/Transforms/IPO/PassManagerBuilder.h>


#include <vector>

using namespace llvm;
Expand Down
1 change: 0 additions & 1 deletion libclambcc/Common/ClamBCModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
#include <map>
#include <cstddef>


class ClamBCWriter;
class ClamBCRegAlloc;

Expand Down

0 comments on commit 2c43da5

Please sign in to comment.