Skip to content

Commit 9ee2941

Browse files
committed
blah
1 parent 4d60675 commit 9ee2941

File tree

3 files changed

+9
-76
lines changed

3 files changed

+9
-76
lines changed

libclambcc/ClamBCRebuild.cpp

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -305,12 +305,16 @@ class ClamBCRebuild : public PassInfoMixin<ClamBCRebuild>, public InstVisitor<Cl
305305
return NV;
306306
}
307307

308+
/* findDuplicateType looks through all the casts of a value to find if it
309+
* is ultimately being casted to a type that it is already casted from.
310+
* If that is the case, it just returns the original, instead of creating
311+
* another cast.
312+
*
313+
* In addition to being inefficient, the excessive casting was causing
314+
* issues in 0.103 and 0.105.
315+
*/
308316
Value * findDuplicateType(Value * v, Type * t){
309317
if (BitCastInst * bci = llvm::dyn_cast<BitCastInst>(v)){
310-
//DEBUG_VALUE(bci->getOperand(0));
311-
//DEBUG_VALUE(bci->getOperand(0)->getType());
312-
//DEBUG_VALUE(bci->getSrcTy());
313-
//DEBUG_VALUE(t);
314318
if (bci->getSrcTy() == t){
315319
return bci->getOperand(0);
316320
}
@@ -323,18 +327,11 @@ class ClamBCRebuild : public PassInfoMixin<ClamBCRebuild>, public InstVisitor<Cl
323327
Value *makeCast(Value *V, Type *Ty)
324328
{
325329

326-
//looking for concat_var
327-
//DEBUG_VALUE(V);
328-
//DEBUG_VALUE(Ty);
329330
Value * v = findDuplicateType(V, Ty);
330331
if (v){
331-
//DEBUG_VALUE(v);
332332
return v;
333333
}
334334

335-
336-
337-
338335
if (V->getType() == Ty) {
339336
return V;
340337
}

libclambcc/ClamBCVerifier.cpp

Lines changed: 1 addition & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -163,13 +163,6 @@ class ClamBCVerifier : public PassInfoMixin<ClamBCVerifier>,
163163
Function *getCalledFunctionFromCallInst(CallInst *pci)
164164
{
165165

166-
{
167-
/*
168-
* Issue is in 'memstr'.
169-
*
170-
* The 'needle' is not correct in the earlier versions.
171-
*/
172-
llvm::errs() << "<" << __LINE__ << ">" << "TODO: Clean this up!!!" << "<END>\n";
173166
Value * pCalledOperand = pci->getCalledOperand();
174167
Function * ret = llvm::dyn_cast<Function>(pCalledOperand);
175168
if (nullptr == ret){
@@ -179,65 +172,9 @@ class ClamBCVerifier : public PassInfoMixin<ClamBCVerifier>,
179172
}
180173

181174
if (nullptr == ret){
182-
assert (0 && "still got work to do ");
175+
ClamBCStop("Verifier unable to get called function from call instruction", pci);
183176
}
184177

185-
return ret;
186-
}
187-
188-
189-
190-
DEBUG_VALUE(pci);
191-
Function *ret = pci->getCalledFunction();
192-
if (nullptr == ret) {
193-
DEBUG_VALUE(pci);
194-
Value *v = pci->getOperand(0); /*This is the called operand.*/
195-
if (nullptr == v) {
196-
llvm::errs() << "<" << __LINE__ << ">" << *pci << "<END>\n";
197-
llvm::errs() << "<" << __LINE__ << ">" << *(pci->getOperand(0)) << "<END>\n";
198-
assert(0 && "How do I handle function pointers?");
199-
}
200-
201-
for (size_t i = 0; i< pci->getNumOperands(); i++){
202-
DEBUG_VALUE(pci->getOperand(i));
203-
}
204-
llvm::errs() << "\n";
205-
llvm::errs() << "\n";
206-
llvm::errs() << "\n";
207-
208-
209-
DEBUG_VALUE(pci->getCalledOperand());
210-
llvm::errs() << "\n";
211-
llvm::errs() << "\n";
212-
llvm::errs() << "\n";
213-
214-
215-
216-
exit(11);
217-
#if 0
218-
219-
220-
221-
222-
while (1){
223-
224-
if (BitCastOperator *bco = llvm::dyn_cast<BitCastOperator>(v)) {
225-
ret = llvm::dyn_cast<Function>(bco->getOperand(0));
226-
} else if (GEPOperator * pgpe = llvm::dyn_cast<GEPOperator>(v)) {
227-
ret = llvm::dyn_cast<Function>(pgpe->getPointerOperand());
228-
} else {
229-
DEBUG_VALUE(v);
230-
DEBUG_NONPOINTER(llvm::isa<GEPOperator>(v));
231-
assert (0 && "WTF");
232-
}
233-
}
234-
235-
236-
237-
#endif
238-
239-
}
240-
241178
return ret;
242179
}
243180

libclambcc/ClamBCWriter.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1337,7 +1337,6 @@ class ClamBCWriter : public PassInfoMixin<ClamBCWriter>, public InstVisitor<Clam
13371337

13381338
void visitCallInst(CallInst &CI)
13391339
{
1340-
//DEBUG_VALUE(&CI);
13411340
Function *F = CI.getCalledFunction();
13421341
if (!F) {
13431342
stop("Indirect calls are not implemented yet!", &CI);

0 commit comments

Comments
 (0)