Skip to content

Commit

Permalink
blah
Browse files Browse the repository at this point in the history
  • Loading branch information
ragusaa committed Apr 24, 2024
1 parent e00300e commit 1355191
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 22 deletions.
6 changes: 5 additions & 1 deletion clambcc/clambc-compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +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-unsupported-icmp-intrinsics'
, 'verify'
, 'clambc-remove-usub'
Expand All @@ -574,6 +576,8 @@ def createInputSourceFile(clangLLVM: ClangLLVM, name: str, args: list, options:
, 'verify'
, 'clambc-rebuild'
, 'verify'
# , 'clambc-remove-pointer-phis'
, 'verify'
, 'clambc-trace'
, 'verify'
, 'clambc-outline-endianness-calls'
Expand Down Expand Up @@ -603,7 +607,7 @@ def createInputSourceFile(clangLLVM: ClangLLVM, name: str, args: list, options:
, f"--load-pass-plugin {SHARED_OBJ_DIR}/libClamBCRemoveUnsupportedICMPIntrinsics.so"
, f"--load-pass-plugin {SHARED_OBJ_DIR}/libClamBCRemoveUSUB.so"
, f"--load-pass-plugin {SHARED_OBJ_DIR}/libClamBCRemoveFSHL.so"
# , f"--load-pass-plugin {SHARED_OBJ_DIR}/libClamBCRemovePointerPHIs.so" #Not needed, since clambc-remove-pointer-phis is not being used.
, f"--load-pass-plugin {SHARED_OBJ_DIR}/libClamBCRemovePointerPHIs.so" #Not needed, since clambc-remove-pointer-phis is not being used.
, f"--load-pass-plugin {SHARED_OBJ_DIR}/libClamBCLoweringNF.so"
, f"--load-pass-plugin {SHARED_OBJ_DIR}/libClamBCRemoveICMPSLE.so"
, f"--load-pass-plugin {SHARED_OBJ_DIR}/libClamBCVerifier.so"
Expand Down
30 changes: 15 additions & 15 deletions libclambcc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -277,21 +277,21 @@ target_link_directories(ClamBCRemoveICMPSLE PRIVATE ${LLVM_LIBRARY_DIRS})
target_link_libraries(ClamBCRemoveICMPSLE PUBLIC ${LLVM_LIBS})
install(TARGETS ClamBCRemoveICMPSLE DESTINATION ${CMAKE_INSTALL_LIBDIR})

# #
# # The ClamBCRemovePointerPHIs shared library.
# #
# add_library(ClamBCRemovePointerPHIs SHARED
# ClamBCRemovePointerPHIs.cpp)
# target_include_directories(ClamBCRemovePointerPHIs PRIVATE
# ${LLVM_INCLUDE_DIRS})
# set_target_properties(ClamBCRemovePointerPHIs PROPERTIES
# COMPILE_FLAGS "${WARNCXXFLAGS}"
# VERSION ${LIBCLAMBC_VERSION}
# SOVERSION ${LIBCLAMBC_SOVERSION})
# #target_compile_definitions(ClamBCRemovePointerPHIs -DLOG_BEFORE_AFTER=1) # For testing
# target_link_directories(ClamBCRemovePointerPHIs PRIVATE ${LLVM_LIBRARY_DIRS})
# target_link_libraries(ClamBCRemovePointerPHIs PUBLIC ${LLVM_LIBS})
# install(TARGETS ClamBCRemovePointerPHIs DESTINATION ${CMAKE_INSTALL_LIBDIR})
#
# The ClamBCRemovePointerPHIs shared library.
#
add_library(ClamBCRemovePointerPHIs SHARED
ClamBCRemovePointerPHIs.cpp)
target_include_directories(ClamBCRemovePointerPHIs PRIVATE
${LLVM_INCLUDE_DIRS})
set_target_properties(ClamBCRemovePointerPHIs PROPERTIES
COMPILE_FLAGS "${WARNCXXFLAGS}"
VERSION ${LIBCLAMBC_VERSION}
SOVERSION ${LIBCLAMBC_SOVERSION})
#target_compile_definitions(ClamBCRemovePointerPHIs -DLOG_BEFORE_AFTER=1) # For testing
target_link_directories(ClamBCRemovePointerPHIs PRIVATE ${LLVM_LIBRARY_DIRS})
target_link_libraries(ClamBCRemovePointerPHIs PUBLIC ${LLVM_LIBS})
install(TARGETS ClamBCRemovePointerPHIs DESTINATION ${CMAKE_INSTALL_LIBDIR})

# #
# # The ClamBCRemoveUndefs shared library.
Expand Down
14 changes: 8 additions & 6 deletions libclambcc/ClamBCRemovePointerPHIs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,11 @@ class ClamBCRemovePointerPHIs : public PassInfoMixin<ClamBCRemovePointerPHIs>
assert(2 == pgepi->getNumOperands() && "Handle the case of more than 2 operands");

Value *incVal = pgepi->getOperand(1);

if (incVal->getType() != pType){
DEBUG_NONPOINTER("SHOULD PROBABLY CHANGE THIS TO CREATE THE INDEX TO BE THE SAME TYPE AS THE incVal");
incVal = CastInst::CreateIntegerCast(incVal, pType, false, "ClamBCRemovePointerPHIs_cast_", pgepi);
}

Instruction *add = BinaryOperator::Create(Instruction::Add, idxNode, incVal, "ClamBCRemovePointerPHIs_add_", pgepi);
BasicBlock *pred = findPredecessor(idxNode->getParent(), pgepi->getParent(), omitNodes);
Expand Down Expand Up @@ -291,17 +296,14 @@ class ClamBCRemovePointerPHIs : public PassInfoMixin<ClamBCRemovePointerPHIs>
public:
ClamBCRemovePointerPHIs() {}

/*This is only necessary for 0.103 on windows.*/
virtual PreservedAnalyses run(Module &m, ModuleAnalysisManager &mam)
{

/*Currently unused. Will remove after the RC phase.*/
DEBUGERR << "TODO: EVALUATE WHETHER OR NOT I NEED THIS"
<< "<END>\n";
return PreservedAnalyses::all();

pMod = &m;
bool ret = false;

llvm::errs() << "<" << __FUNCTION__ << "::" << __LINE__ << ">" << "HAVING ISSUES WITH POINTER PHIS ON 0.103 windows, keep changes isolated to this pass so that we can remove it when we no longer have to support 0.103" << "<END>\n";

for (auto i = pMod->begin(), e = pMod->end(); i != e; i++) {
llvm::Function *pFunc = llvm::dyn_cast<Function>(i);
if (nullptr == pFunc) {
Expand Down
3 changes: 3 additions & 0 deletions libclambcc/ClamBCWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,9 @@ class ClamBCWriter : public PassInfoMixin<ClamBCWriter>, public InstVisitor<Clam
pType = pType->getPointerElementType();

if (not pType->isIntegerTy()) {
DEBUG_VALUE(pGep);
llvm::errs() << "<" << __FUNCTION__ << "::" << __LINE__ << ">" << "EXITING<END>\n";
exit(11);
assert(0 && "ONLY INTEGER TYPES ARE CURRENTLY IMPLEMENTED");
}

Expand Down

0 comments on commit 1355191

Please sign in to comment.