Skip to content

Commit

Permalink
Add NoFree cmd line fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
wsmoses committed Dec 17, 2023
1 parent fb6a1c6 commit 5b15cf1
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions enzyme/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,8 @@ export(TARGETS LLDEnzyme-${LLVM_VERSION_MAJOR}

export(TARGETS LLDEnzymeFlags
APPEND FILE "${PROJECT_BINARY_DIR}/EnzymeTargets.cmake")
export(TARGETS LLDEnzymeAssumeUnknownNoFree
APPEND FILE "${PROJECT_BINARY_DIR}/EnzymeTargets.cmake")
export(TARGETS LLDEnzymeLooseTypeFlags
APPEND FILE "${PROJECT_BINARY_DIR}/EnzymeTargets.cmake")
export(TARGETS LLDEnzymePrintTypeFlags
Expand Down
3 changes: 3 additions & 0 deletions enzyme/Enzyme/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ if (${LLVM_VERSION_MAJOR} GREATER 14)
target_link_options(LLDEnzymeFlags INTERFACE "SHELL: -Wl,--load-pass-plugin=$<TARGET_FILE:LLDEnzyme-${LLVM_VERSION_MAJOR}>")
endif()

add_library(LLDEnzymeAssumeUnknownNoFree INTERFACE)
target_link_options(LLDEnzymeAssumeUnknownNoFree INTERFACE "SHELL: -Wl,-mllvm -Wl,-enzyme-assume-unknown-nofree=1")

add_library(LLDEnzymeLooseTypeFlags INTERFACE)
target_link_options(LLDEnzymeLooseTypeFlags INTERFACE "SHELL: -Wl,-mllvm -Wl,-enzyme-loose-types=1")

Expand Down
8 changes: 8 additions & 0 deletions enzyme/Enzyme/EnzymeLogic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ cl::opt<bool> EnzymeJuliaAddrLoad(
"enzyme-julia-addr-load", cl::init(false), cl::Hidden,
cl::desc("Mark all loads resulting in an addr(13)* to be legal to redo"));

cl::opt<bool> EnzymeAssumeUnknownNoFree(
"enzyme-assume-unknown-nofree", cl::init(false), cl::Hidden,
cl::desc("Assume unknown instructions are nofree as needed"));

LLVMValueRef (*EnzymeFixupReturn)(LLVMBuilderRef, LLVMValueRef) = nullptr;
}

Expand Down Expand Up @@ -5220,6 +5224,10 @@ llvm::Value *EnzymeLogic::CreateNoFree(RequestContext context,
return todiff;
}

if (EnzymeAssumeUnknownNoFree) {
return todiff;
}

if (context.req) {
EmitFailure("IllegalNoFree", context.req->getDebugLoc(), context.req,
"Cannot create nofree of instruction-created value: ", *todiff);
Expand Down
2 changes: 2 additions & 0 deletions enzyme/cmake/EnzymeConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ set(Enzyme_TABLEGEN_EXE "@Enzyme_CONFIG_TABLEGEN_EXE@")

# Our library dependencies (contains definitions for IMPORTED targets)
if(NOT TARGET ClangEnzymeFlags AND NOT TARGET LLDEnzymeFlags
AND NOT TARGET LLDEnzymeAssumeUnknownNoFree
AND NOT TARGET LLDEnzymeLooseTypeFlags
AND NOT TARGET LLDEnzymePrintTypeFlags
AND NOT TARGET LLDEnzymePrintFlags
Expand All @@ -20,6 +21,7 @@ if(NOT TARGET ClangEnzymeFlags AND NOT TARGET LLDEnzymeFlags
include("${Enzyme_CMAKE_DIR}/EnzymeTargets.cmake")
# These are IMPORTED targets created by EnzymeTargets.cmake
set(Enzyme_LIBRARIES ClangEnzymeFlags LLDEnzymeFlags
LLDEnzymeAssumeUnknownNoFree
LLDEnzymeLooseTypeFlags
LLDEnzymePrintTypeFlags
LLDEnzymePrintFlags
Expand Down

0 comments on commit 5b15cf1

Please sign in to comment.