Skip to content

Commit

Permalink
support more names from MS
Browse files Browse the repository at this point in the history
  • Loading branch information
tthsqe12 committed Jul 18, 2023
1 parent 0f586ac commit a094d89
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
1 change: 1 addition & 0 deletions enzyme/Enzyme/ActivityAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1489,6 +1489,7 @@ bool ActivityAnalyzer::isConstantValue(TypeResults const &TR, Value *Val) {
if (directions & DOWN &&
(funcName == "malloc" || funcName == "calloc" ||
funcName == "_Znwm" || funcName == "julia.gc_alloc_obj" ||
funcName == "??2@YAPAXI@Z" || funcName == "??2@YAPEAX_K@Z" ||
funcName == "jl_gc_alloc_typed" ||
funcName == "ijl_gc_alloc_typed")) {
std::shared_ptr<ActivityAnalyzer> Hypothesis =
Expand Down
3 changes: 2 additions & 1 deletion enzyme/Enzyme/AdjointGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -8992,7 +8992,8 @@ class AdjointGenerator
Attribute::NonNull);
#endif

if (funcName == "malloc" || funcName == "_Znwm") {
if (funcName == "malloc" || funcName == "_Znwm" ||
funcName == "??2@YAPAXI@Z" || funcName == "??2@YAPEAX_K@Z") {
if (auto ci = dyn_cast<ConstantInt>(args[0])) {
unsigned derefBytes = ci->getLimitedValue();
CallInst *cal =
Expand Down
2 changes: 1 addition & 1 deletion enzyme/Enzyme/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ if (${Clang_FOUND})
DEPENDS
intrinsics_gen
PLUGIN_TOOL
opt
clang
)
target_compile_definitions(ClangEnzyme-${LLVM_VERSION_MAJOR} PUBLIC ENZYME_RUNPASS)
endif()
Expand Down
20 changes: 14 additions & 6 deletions enzyme/Enzyme/GradientUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4468,10 +4468,13 @@ Constant *GradientUtils::GetOrCreateShadowConstant(
NewOps.push_back(i == 0 ? C : arg->getOperand(i));
return arg->getWithOperands(NewOps);
}
} else if (auto arg = dyn_cast<GlobalAlias>(oval)) {
return GetOrCreateShadowConstant(Logic, TLI, TA, arg->getAliasee(), mode, width, AtomicAdd);
} else if (auto arg = dyn_cast<GlobalVariable>(oval)) {
if (arg->getName() == "_ZTVN10__cxxabiv120__si_class_type_infoE" ||
arg->getName() == "_ZTVN10__cxxabiv117__class_type_infoE" ||
arg->getName() == "_ZTVN10__cxxabiv121__vmi_class_type_infoE")
arg->getName() == "_ZTVN10__cxxabiv121__vmi_class_type_infoE" ||
arg->getName().startswith("??_R")) // any of the MS RTTI manglings
return arg;

if (hasMetadata(arg, "enzyme_shadow")) {
Expand Down Expand Up @@ -9182,15 +9185,20 @@ llvm::CallInst *freeKnownAllocation(llvm::IRBuilder<> &builder,
freefunc = LibFunc_ZdaPv;
break;

case LibFunc_msvc_new_int: // new(unsigned int);
case LibFunc_msvc_new_int_nothrow: // new(unsigned int, nothrow);
case LibFunc_msvc_new_longlong: // new(unsigned long long);
case LibFunc_msvc_new_longlong_nothrow: // new(unsigned long long, nothrow);
freefunc = LibFunc_msvc_delete_ptr64_longlong;
break;

case LibFunc_msvc_new_array_longlong: // new[](unsigned long long);
case LibFunc_msvc_new_array_longlong_nothrow: // new[](unsigned long long, nothrow);
freefunc = LibFunc_msvc_delete_array_ptr64_longlong;
break;

case LibFunc_msvc_new_array_int: // new[](unsigned int);
case LibFunc_msvc_new_array_int_nothrow: // new[](unsigned int, nothrow);
case LibFunc_msvc_new_array_longlong: // new[](unsigned long long);
case LibFunc_msvc_new_array_longlong_nothrow: // new[](unsigned long long,
// nothrow);
case LibFunc_msvc_new_int: // new(unsigned int);
case LibFunc_msvc_new_int_nothrow: // new(unsigned int, nothrow);
llvm_unreachable("msvc deletion not handled");

default:
Expand Down

0 comments on commit a094d89

Please sign in to comment.