Skip to content

Commit

Permalink
All new sigs are loaded on windows with 0.103. Testing the rest
Browse files Browse the repository at this point in the history
  • Loading branch information
ragusaa committed Apr 29, 2024
1 parent 95453fd commit 3418d67
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 4 deletions.
8 changes: 4 additions & 4 deletions clambcc/clambc-compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,8 +548,8 @@ def createInputSourceFile(clangLLVM: ClangLLVM, name: str, args: list, options:
, 'globalopt'
, 'clambc-preserve-abis' #remove fake function calls because O3 has already run
, 'verify'
, 'clambc-remove-pointer-phis'
, 'verify'
# , 'clambc-remove-pointer-phis'
# , 'verify'
, 'clambc-remove-unsupported-icmp-intrinsics'
, 'verify'
, 'clambc-remove-usub'
Expand All @@ -576,8 +576,8 @@ def createInputSourceFile(clangLLVM: ClangLLVM, name: str, args: list, options:
, 'verify'
, 'clambc-rebuild'
, 'verify'
# , 'clambc-remove-pointer-phis'
# , 'verify'
, 'clambc-remove-pointer-phis'
, 'verify'
, 'clambc-trace'
, 'verify'
, 'clambc-outline-endianness-calls'
Expand Down
42 changes: 42 additions & 0 deletions libclambcc/ClamBCRemovePointerPHIs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,44 @@ class ClamBCRemovePointerPHIs : public PassInfoMixin<ClamBCRemovePointerPHIs>

}

FunctionType * getSaveFunctionType(){
static FunctionType * pRet = nullptr;

if (nullptr == pRet){

Type * vt = Type::getVoidTy(pMod->getContext());
Type * pt = Type::getInt8Ty(pMod->getContext())->getPointerTo();
pRet = FunctionType::get(vt, {pt->getPointerTo(), pt}, false);

}

return pRet;

}
Function * getSaveFunction(){
static Function * pRet = nullptr;
if (nullptr == pRet){
FunctionType * ft = getSaveFunctionType();
pRet = Function::Create(ft, GlobalValue::PrivateLinkage, "__save_pointer", pMod);
pRet->addFnAttr(Attribute::OptimizeNone);
pRet->addFnAttr(Attribute::NoInline);

BasicBlock * pEntry = BasicBlock::Create(pMod->getContext(), "entry", pRet, nullptr);
new StoreInst(pRet->getArg(1), pRet->getArg(0), pEntry);
ReturnInst::Create(pMod->getContext(), nullptr, pEntry);

DEBUG_VALUE(pRet);

}
return pRet;
}

void savePointer(Value * src, Value * dst, Instruction * insPt){
Function * saveFunction = getSaveFunction();
CallInst::Create(getSaveFunctionType(), saveFunction, {dst, src}, "", insPt);
//CallInst::Create(saveFunction->getType(), saveFunction, {dst, src}, "ClamBCRemovePointerPHIs_", insPt);
}

bool handlePHI2(PHINode *pn)
{
if (not pn->getType()->isPointerTy()) {
Expand Down Expand Up @@ -393,7 +431,11 @@ class ClamBCRemovePointerPHIs : public PassInfoMixin<ClamBCRemovePointerPHIs>
new StoreInst(incoming, pai, insPt);
#else
insPt = pBB->getTerminator();
#if 0
new StoreInst(pn->getIncomingValue(i), pai, insPt);
#else
savePointer(pn->getIncomingValue(i), pai, insPt);
#endif
#endif
}

Expand Down

0 comments on commit 3418d67

Please sign in to comment.