From 131646757dedaa14737c1aaab5d176b4dd813d3d Mon Sep 17 00:00:00 2001 From: Andy Ragusa Date: Fri, 15 Dec 2023 11:54:09 -0800 Subject: [PATCH] blah --- libclambcc/ClamBCLowering/ClamBCLowering.cpp | 36 +------------------ libclambcc/ClamBCLowering/ClamBCLoweringF.cpp | 5 +-- .../ClamBCLowering/ClamBCLoweringNF.cpp | 5 +-- libclambcc/ClamBCModule/ClamBCModule.cpp | 30 ---------------- 4 files changed, 7 insertions(+), 69 deletions(-) delete mode 100644 libclambcc/ClamBCModule/ClamBCModule.cpp diff --git a/libclambcc/ClamBCLowering/ClamBCLowering.cpp b/libclambcc/ClamBCLowering/ClamBCLowering.cpp index 0a79978ee4..c4b1c76e5b 100644 --- a/libclambcc/ClamBCLowering/ClamBCLowering.cpp +++ b/libclambcc/ClamBCLowering/ClamBCLowering.cpp @@ -19,7 +19,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. */ -//#define DEBUG_TYPE "bclowering" #include "ClamBCLowering.h" #include "Common/clambc.h" @@ -74,11 +73,7 @@ void ClamBCLowering::lowerIntrinsics(IntrinsicLowering *IL, Function &F) Builder.SetInsertPoint(BO); Value *V = Builder.CreatePointerCast(PII->getOperand(0), PointerType::getUnqual(Type::getInt8Ty(F.getContext()))); -#if 0 - V = Builder.CreateGEP(V, Idx); -#else V = Builder.CreateGEP(V->getType(), V, Idx); -#endif V = Builder.CreatePtrToInt(V, BO->getType()); BO->replaceAllUsesWith(V); } else if (GetElementPtrInst *GEPI = dyn_cast(II)) { @@ -206,13 +201,7 @@ void ClamBCLowering::simplifyOperands(Function &F) if (ConstantExpr *CE = dyn_cast(II->getOperand(i))) { if (CE->getOpcode() == Instruction::GetElementPtr) { // rip out GEP expr and load it -#if 0 - Ops.push_back(new LoadInst(CE, "gepex_load", SI)); -#else - llvm::errs() << "<" << __LINE__ << ">" << "I am expecting this to throw an assert, so check here" << "\n"; - llvm::errs() << "<" << __LINE__ << ">" << *CE << "\n"; Ops.push_back(new LoadInst(CE->getType(), CE, "gepex_load", SI)); -#endif Changed = true; } } else { @@ -349,7 +338,6 @@ static bool replaceIntrinsicCalls(llvm::MemIntrinsic *pMemIntrinsic, std::pair InstDel; std::vector> repPairs; @@ -386,7 +374,7 @@ static void gatherAllocasWithBitcasts(llvm::BasicBlock *bb, std::vector [#uses=2] @@ -424,19 +412,9 @@ void ClamBCLowering::fixupBitCasts(Function &F) continue; } - /*aragusa - * I am getting an assertion failure trying to cast a value that is not an ArrayType - * to an ArrayType. I don't fully understand the reason for doing what we are doing here. - * I am just going to check if AI->getAllocatedType is an array type. I may need to revisit this later. - */ if (not llvm::isa(AI->getAllocatedType())) { continue; } - /*Intentionally leaving this debug message in, because I don't think this code is executed very often, and - * I don't believe it is necessary. Once I get the bugs ironed out of the header files, I am going to - * see if this ever prints and does not have an assertion failure. The iterators were previously not working - * correctly and in fixing them, I believe I turned on code that wasn't previously working.*/ - const ArrayType *arTy = cast(AI->getAllocatedType()); Type *APTy = PointerType::getUnqual(arTy->getElementType()); @@ -445,7 +423,6 @@ void ClamBCLowering::fixupBitCasts(Function &F) AIC->setName("ClamBCLowering_fixupBitCasts"); BasicBlock::iterator IP = AI->getParent()->begin(); while (isa(IP)) ++IP; - //Value *Idx[] = {Zero, Zero}; llvm::ArrayRef Idxs = {Zero, Zero}; V = GetElementPtrInst::Create(nullptr, AIC, Idxs, "base_gepz", AI); @@ -473,7 +450,6 @@ void ClamBCLowering::fixupGEPs(Function &F) std::vector indexes; GetElementPtrInst::op_iterator J = GEPI->idx_begin(), JE = GEPI->idx_end(); for (; J != JE; ++J) { - //llvm::Value * v = llvm::cast(J); // push all constants if (Constant *C = dyn_cast(*J)) { indexes.push_back(C); @@ -485,9 +461,6 @@ void ClamBCLowering::fixupGEPs(Function &F) break; } Constant *C = cast(GEPI->getOperand(0)); - //Constant *GC = ConstantExpr::getInBoundsGetElementPtr(C, - // &indexes[0], - // indexes.size()); Constant *GC = ConstantExpr::getInBoundsGetElementPtr(nullptr, C, indexes); if (J != JE) { @@ -495,7 +468,6 @@ void ClamBCLowering::fixupGEPs(Function &F) for (; J != JE; ++J) { indexes.push_back(*J); } - //AllocaInst *AI = new AllocaInst(GC->getType(), "", Entry->begin()); AllocaInst *AI = new AllocaInst(GC->getType(), 0, "ClamBCLowering_fixupGEPs", llvm::cast(Entry->begin())); new StoreInst(GC, AI, GEPI); Value *L = new LoadInst(AI->getType(), AI, "ClamBCLowering_fixupGEPs", GEPI); @@ -573,18 +545,12 @@ void ClamBCLowering::splitGEPZArray(Function &F) } } -#if 0 -bool ClamBCLowering::runOnModule(Module &M) -#else PreservedAnalyses ClamBCLowering::run(Module & m, ModuleAnalysisManager & MAM) -#endif { pMod = &m; pContext = &(pMod->getContext()); - //llvm::errs() << "<" << __FUNCTION__ << "::" << __LINE__ << ">" << "isFinal = " << isFinal() << "\n"; - for (Module::iterator I = pMod->begin(), E = pMod->end(); I != E; ++I) { if (I->isDeclaration()) diff --git a/libclambcc/ClamBCLowering/ClamBCLoweringF.cpp b/libclambcc/ClamBCLowering/ClamBCLoweringF.cpp index 7cc6d23893..ecc52b5cdf 100644 --- a/libclambcc/ClamBCLowering/ClamBCLoweringF.cpp +++ b/libclambcc/ClamBCLowering/ClamBCLoweringF.cpp @@ -19,12 +19,13 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. */ -//#define DEBUG_TYPE "bcloweringf" + +#include "ClamBCLowering.h" + #include "Common/clambc.h" #include -#include "ClamBCLowering.h" using namespace llvm; diff --git a/libclambcc/ClamBCLowering/ClamBCLoweringNF.cpp b/libclambcc/ClamBCLowering/ClamBCLoweringNF.cpp index f97566ea62..dca1b7d9c9 100644 --- a/libclambcc/ClamBCLowering/ClamBCLoweringNF.cpp +++ b/libclambcc/ClamBCLowering/ClamBCLoweringNF.cpp @@ -19,12 +19,13 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. */ -//#define DEBUG_TYPE "bcloweringnf" + +#include "ClamBCLowering.h" + #include "Common/clambc.h" #include -#include "ClamBCLowering.h" using namespace llvm; diff --git a/libclambcc/ClamBCModule/ClamBCModule.cpp b/libclambcc/ClamBCModule/ClamBCModule.cpp deleted file mode 100644 index 33de28eb59..0000000000 --- a/libclambcc/ClamBCModule/ClamBCModule.cpp +++ /dev/null @@ -1,30 +0,0 @@ - -#include -#include "llvm/IR/Function.h" -#include "llvm/Support/raw_ostream.h" - -#include "llvm/IR/LegacyPassManager.h" -#include "llvm/Transforms/IPO/PassManagerBuilder.h" - -#include "clambc.h" - -using namespace llvm; - -namespace -{ -struct ClamBCModule : public FunctionPass { - static char ID; - ClamBCModule() - : FunctionPass(ID) {} - - bool runOnFunction(Function &F) override - { - return false; - } -}; // end of struct ClamBCModule -} // end of anonymous namespace - -char ClamBCModule::ID = 0; -static RegisterPass X("clambc-module", "ClamBCModule Pass", - false /* Only looks at CFG */, - false /* Analysis Pass */);