Skip to content

Commit

Permalink
Remove unused opt passes
Browse files Browse the repository at this point in the history
Remove ClamBCChangeMallocArgSize and ClamBCRemoveUndefs.

Also removed a commented out call to clambc-remove-pointer-phis.
This pass is performed later on.
  • Loading branch information
micahsnyder committed Aug 3, 2024
1 parent 821c927 commit edf6165
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 524 deletions.
43 changes: 0 additions & 43 deletions clambcc/clambc-compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,16 +549,6 @@ def createInputSourceFile(clangLLVM: ClangLLVM, name: str, args: list, options:
'function(mem2reg)',
'verify',

# Remove 'undef' values.
#
# The optimizer in llvm-8 was replacing unused parameters with 'undef' values in the IR.
# This was causing issues in the writer, not knowing what value to put in the signature.
# The llvm-16 optimizer no longer does this.
#
# TODO: This pass may be removed in a future release.
# 'clambc-remove-undefs',
# 'verify',

# Prevent undefined or poison values from being inserted into the function calls by the 'O3' pass.
# This pass should probably be renamed, since the ABI is not really changed.
# Undefined values cause issues with the ClamBCWriter, and with ClamAV's runtime.
Expand All @@ -578,15 +568,6 @@ def createInputSourceFile(clangLLVM: ClangLLVM, name: str, args: list, options:
'clambc-preserve-abis',
'verify',

# This pass removes pointer phis, and replaces them with an index calculation to get the same offset.
#
# We will call this later, instead of here.
#
# Note: This is only needed for 0.103 on Windows where we're using an older vendored version of LLVM for the runtime.
# This can be removed when 0.103 support is no longer required.
# 'clambc-remove-pointer-phis',
# 'verify',

# Remove calls to smin intrinsics.
# Smin intrinsics are not supported by the ClamAV runtime, so this pass creates it's own smin functions, and replaces
# calls to intrinsics with calls to the newly created functions.
Expand Down Expand Up @@ -700,13 +681,6 @@ def createInputSourceFile(clangLLVM: ClangLLVM, name: str, args: list, options:
'clambc-outline-endianness-calls',
'verify',

# Change malloc argument size.
#
# TODO: This was added because the legacy llvm runtime had issues with 32-bit phi nodes being used in calls to malloc.
# It appears that this is no longer necessary.
# 'clambc-change-malloc-arg-size',
# 'verify',

# Extends all integer phi nodes to use 64-bit values.
#
# TODO: I don't remember what the reason was that I needed to add this. It should be re-evaluated for the next release.
Expand Down Expand Up @@ -742,15 +716,6 @@ def createInputSourceFile(clangLLVM: ClangLLVM, name: str, args: list, options:
OPTIMIZE_LOADS=[
f"--load {SHARED_OBJ_DIR}/libClamBCCommon.so",

# libClamBCRemoveUndefs.so is no longer being run.
#
# This was added because the optimizer in llvm-8 was replacing unused parameters with 'undef' values in the IR.
# This was causing issues in the writer, not knowing what value to put in the signature.
# The llvm-16 optimizer no longer does this.
#
# TODO: This pass may be removed in a future release.
# f"--load-pass-plugin {SHARED_OBJ_DIR}/libClamBCRemoveUndefs.so",

f"--load-pass-plugin {SHARED_OBJ_DIR}/libClamBCPreserveABIs.so",
f"--load-pass-plugin {SHARED_OBJ_DIR}/libClamBCRemoveUnsupportedICMPIntrinsics.so",
f"--load-pass-plugin {SHARED_OBJ_DIR}/libClamBCRemoveUSUB.so",
Expand All @@ -775,14 +740,6 @@ def createInputSourceFile(clangLLVM: ClangLLVM, name: str, args: list, options:
f"--load-pass-plugin {SHARED_OBJ_DIR}/libClamBCRebuild.so",
f"--load-pass-plugin {SHARED_OBJ_DIR}/libClamBCTrace.so",
f"--load-pass-plugin {SHARED_OBJ_DIR}/libClamBCOutlineEndiannessCalls.so",

# libClamBCChangeMallocArgSize.so is no longer being run.
# At one time, the legacy llvm runtime had issues with 32-bit phi nodes being used in calls to malloc.
# It appears as though this change is no longer necessary.
#
# TODO: May be removed in the future.
# f"--load-pass-plugin {SHARED_OBJ_DIR}/libClamBCChangeMallocArgSize.so",

f"--load-pass-plugin {SHARED_OBJ_DIR}/libClamBCExtendPHIsTo64Bit.so",
f"--load-pass-plugin {SHARED_OBJ_DIR}/libClamBCConvertIntrinsicsTo32Bit.so",
f"--load-pass-plugin {SHARED_OBJ_DIR}/libClamBCPrepareGEPsForWriter.so",
Expand Down
32 changes: 0 additions & 32 deletions libclambcc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,6 @@ target_link_directories(ClamBCAnalyzer PRIVATE ${LLVM_LIBRARY_DIRS})
target_link_libraries(ClamBCAnalyzer PUBLIC ${LLVM_LIBS})
install(TARGETS ClamBCAnalyzer DESTINATION ${CMAKE_INSTALL_LIBDIR})

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

#
# The ClamBCConvertIntrinsicsTo32Bit shared library.
#
Expand Down Expand Up @@ -293,22 +277,6 @@ 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.
# #
# add_library(ClamBCRemoveUndefs SHARED
# ClamBCRemoveUndefs.cpp)
# target_include_directories(ClamBCRemoveUndefs PRIVATE
# ${LLVM_INCLUDE_DIRS})
# set_target_properties(ClamBCRemoveUndefs PROPERTIES
# COMPILE_FLAGS "${WARNCXXFLAGS}"
# VERSION ${LIBCLAMBC_VERSION}
# SOVERSION ${LIBCLAMBC_SOVERSION})
# #target_compile_definitions(ClamBCRemoveUndefs -DLOG_BEFORE_AFTER=1) # For testing
# target_link_directories(ClamBCRemoveUndefs PRIVATE ${LLVM_LIBRARY_DIRS})
# target_link_libraries(ClamBCRemoveUndefs PUBLIC ${LLVM_LIBS})
# install(TARGETS ClamBCRemoveUndefs DESTINATION ${CMAKE_INSTALL_LIBDIR})

#
# The ClamBCRemoveUnsupportedICMPIntrinsics shared library.
#
Expand Down
177 changes: 0 additions & 177 deletions libclambcc/ClamBCChangeMallocArgSize.cpp

This file was deleted.

Loading

0 comments on commit edf6165

Please sign in to comment.