Skip to content

Commit

Permalink
blah
Browse files Browse the repository at this point in the history
  • Loading branch information
ragusaa committed Dec 15, 2023
1 parent 2408ff7 commit 1316467
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 69 deletions.
36 changes: 1 addition & 35 deletions libclambcc/ClamBCLowering/ClamBCLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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<GetElementPtrInst>(II)) {
Expand Down Expand Up @@ -206,13 +201,7 @@ void ClamBCLowering::simplifyOperands(Function &F)
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(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" << "<END>\n";
llvm::errs() << "<" << __LINE__ << ">" << *CE << "<END>\n";
Ops.push_back(new LoadInst(CE->getType(), CE, "gepex_load", SI));
#endif
Changed = true;
}
} else {
Expand Down Expand Up @@ -349,7 +338,6 @@ static bool replaceIntrinsicCalls(llvm::MemIntrinsic *pMemIntrinsic, std::pair<l
void ClamBCLowering::downsizeIntrinsics(Function &F)
{

//LLVMContext &Context = F.getContext();
std::vector<Instruction *> InstDel;

std::vector<std::pair<llvm::Function *, llvm::Function *>> repPairs;
Expand Down Expand Up @@ -386,7 +374,7 @@ static void gatherAllocasWithBitcasts(llvm::BasicBlock *bb, std::vector<llvm::Al
}
}

/*aragusa
/*
* The following function makes changes similar to the following.
* BEFORE
* %st = alloca [264 x i8] ; <[264 x i8]*> [#uses=2]
Expand Down Expand Up @@ -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<ArrayType>(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<ArrayType>(AI->getAllocatedType());
Type *APTy = PointerType::getUnqual(arTy->getElementType());

Expand All @@ -445,7 +423,6 @@ void ClamBCLowering::fixupBitCasts(Function &F)
AIC->setName("ClamBCLowering_fixupBitCasts");
BasicBlock::iterator IP = AI->getParent()->begin();
while (isa<AllocaInst>(IP)) ++IP;
//Value *Idx[] = {Zero, Zero};
llvm::ArrayRef<llvm::Value *> Idxs = {Zero, Zero};
V = GetElementPtrInst::Create(nullptr, AIC, Idxs, "base_gepz", AI);

Expand Down Expand Up @@ -473,7 +450,6 @@ void ClamBCLowering::fixupGEPs(Function &F)
std::vector<Value *> indexes;
GetElementPtrInst::op_iterator J = GEPI->idx_begin(), JE = GEPI->idx_end();
for (; J != JE; ++J) {
//llvm::Value * v = llvm::cast<llvm::Value>(J);
// push all constants
if (Constant *C = dyn_cast<Constant>(*J)) {
indexes.push_back(C);
Expand All @@ -485,17 +461,13 @@ void ClamBCLowering::fixupGEPs(Function &F)
break;
}
Constant *C = cast<Constant>(GEPI->getOperand(0));
//Constant *GC = ConstantExpr::getInBoundsGetElementPtr(C,
// &indexes[0],
// indexes.size());
Constant *GC = ConstantExpr::getInBoundsGetElementPtr(nullptr, C,
indexes);
if (J != JE) {
indexes.clear();
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<llvm::Instruction>(Entry->begin()));
new StoreInst(GC, AI, GEPI);
Value *L = new LoadInst(AI->getType(), AI, "ClamBCLowering_fixupGEPs", GEPI);
Expand Down Expand Up @@ -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() << "<END>\n";

for (Module::iterator I = pMod->begin(), E = pMod->end();
I != E; ++I) {
if (I->isDeclaration())
Expand Down
5 changes: 3 additions & 2 deletions libclambcc/ClamBCLowering/ClamBCLoweringF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <llvm/Passes/PassPlugin.h>

#include "ClamBCLowering.h"


using namespace llvm;
Expand Down
5 changes: 3 additions & 2 deletions libclambcc/ClamBCLowering/ClamBCLoweringNF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <llvm/Passes/PassPlugin.h>

#include "ClamBCLowering.h"

using namespace llvm;

Expand Down
30 changes: 0 additions & 30 deletions libclambcc/ClamBCModule/ClamBCModule.cpp

This file was deleted.

0 comments on commit 1316467

Please sign in to comment.