Skip to content

Commit

Permalink
Fix llvm main (#1399)
Browse files Browse the repository at this point in the history
* Fix llvm main

* Fix llvm17

* Remove udiv/sdiv operators

* Fix format
  • Loading branch information
wsmoses authored Sep 2, 2023
1 parent 00d84a7 commit 116e8bb
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 19 deletions.
4 changes: 2 additions & 2 deletions enzyme/Enzyme/ActivityAnalysisPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ bool printActivityAnalysis(llvm::Function &F, TargetLibraryInfo &TLI) {
if (a.getType()->isFPOrFPVectorTy()) {
dt = ConcreteType(a.getType()->getScalarType());
} else if (a.getType()->isPointerTy()) {
#if LLVM_VERSION_MAJOR >= 18
#if LLVM_VERSION_MAJOR >= 17
#else
auto et = a.getType()->getPointerElementType();
if (et->isFPOrFPVectorTy()) {
Expand All @@ -113,7 +113,7 @@ bool printActivityAnalysis(llvm::Function &F, TargetLibraryInfo &TLI) {
if (F.getReturnType()->isFPOrFPVectorTy()) {
dt = ConcreteType(F.getReturnType()->getScalarType());
} else if (F.getReturnType()->isPointerTy()) {
#if LLVM_VERSION_MAJOR >= 18
#if LLVM_VERSION_MAJOR >= 17
#else
auto et = F.getReturnType()->getPointerElementType();
if (et->isFPOrFPVectorTy()) {
Expand Down
8 changes: 4 additions & 4 deletions enzyme/Enzyme/CApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1237,7 +1237,7 @@ void EnzymeFixupJuliaCallingConvention(LLVMValueRef F_C) {

for (auto idx : enzyme_srets) {
llvm::Type *T = nullptr;
#if LLVM_VERSION_MAJOR >= 18
#if LLVM_VERSION_MAJOR >= 17
llvm_unreachable("Unhandled");
// T = F->getParamAttribute(idx, Attribute::AttrKind::ElementType)
// .getValueAsType();
Expand All @@ -1249,7 +1249,7 @@ void EnzymeFixupJuliaCallingConvention(LLVMValueRef F_C) {
for (auto idx : enzyme_srets_v) {
llvm::Type *T = nullptr;
auto AT = cast<ArrayType>(FT->getParamType(idx));
#if LLVM_VERSION_MAJOR >= 18
#if LLVM_VERSION_MAJOR >= 17
llvm_unreachable("Unhandled");
// T = F->getParamAttribute(idx, Attribute::AttrKind::ElementType)
// .getValueAsType();
Expand Down Expand Up @@ -1499,7 +1499,7 @@ void EnzymeFixupJuliaCallingConvention(LLVMValueRef F_C) {
auto arg = delArgMap[i];
assert(arg);
llvm::Type *T = nullptr;
#if LLVM_VERSION_MAJOR >= 18
#if LLVM_VERSION_MAJOR >= 17
llvm_unreachable("Unhandled");
// T = F->getParamAttribute(i, Attribute::AttrKind::ElementType)
// .getValueAsType();
Expand All @@ -1515,7 +1515,7 @@ void EnzymeFixupJuliaCallingConvention(LLVMValueRef F_C) {
assert(arg);
auto AT = cast<ArrayType>(FT->getParamType(i));
llvm::Type *T = nullptr;
#if LLVM_VERSION_MAJOR >= 18
#if LLVM_VERSION_MAJOR >= 17
llvm_unreachable("Unhandled");
// T = F->getParamAttribute(i, Attribute::AttrKind::ElementType)
// .getValueAsType();
Expand Down
26 changes: 18 additions & 8 deletions enzyme/Enzyme/Clang/EnzymeClang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,15 @@ struct EnzymeFunctionLikeAttrInfo : public ParsedAttrInfo {
// GNU-style __attribute__(("example")) and C++/C2x-style [[example]] and
// [[plugin::example]] supported.
static constexpr Spelling S[] = {
{ParsedAttr::AS_GNU, "enzyme_function_like"},
{ParsedAttr::AS_C2x, "enzyme_function_like"},
{ParsedAttr::AS_CXX11, "enzyme_function_like"},
{ParsedAttr::AS_CXX11, "enzyme::function_like"}};
{ParsedAttr::AS_GNU, "enzyme_function_like"},
#if LLVM_VERSION_MAJOR > 17
{ParsedAttr::AS_C23, "enzyme_function_like"},
#else
{ParsedAttr::AS_C2x, "enzyme_function_like"},
#endif
{ParsedAttr::AS_CXX11, "enzyme_function_like"},
{ParsedAttr::AS_CXX11, "enzyme::function_like"}
};
Spellings = S;
}

Expand Down Expand Up @@ -305,10 +310,15 @@ struct EnzymeInactiveAttrInfo : public ParsedAttrInfo {
// GNU-style __attribute__(("example")) and C++/C2x-style [[example]] and
// [[plugin::example]] supported.
static constexpr Spelling S[] = {
{ParsedAttr::AS_GNU, "enzyme_inactive"},
{ParsedAttr::AS_C2x, "enzyme_inactive"},
{ParsedAttr::AS_CXX11, "enzyme_inactive"},
{ParsedAttr::AS_CXX11, "enzyme::inactive"}};
{ParsedAttr::AS_GNU, "enzyme_inactive"},
#if LLVM_VERSION_MAJOR > 17
{ParsedAttr::AS_C23, "enzyme_inactive"},
#else
{ParsedAttr::AS_C2x, "enzyme_inactive"},
#endif
{ParsedAttr::AS_CXX11, "enzyme_inactive"},
{ParsedAttr::AS_CXX11, "enzyme::inactive"}
};
Spellings = S;
}

Expand Down
3 changes: 2 additions & 1 deletion enzyme/Enzyme/TraceUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ TraceUtils::FromClone(ProbProgMode mode,
params.push_back(orig_FTy->getParamType(i));
}

Type *likelihood_acc_type = PointerType::getDoublePtrTy(Context);
Type *likelihood_acc_type =
PointerType::getUnqual(Type::getDoubleTy(Context));
params.push_back(likelihood_acc_type);

if (mode == ProbProgMode::Trace || mode == ProbProgMode::Condition) {
Expand Down
8 changes: 5 additions & 3 deletions enzyme/Enzyme/TypeAnalysis/TypeAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5202,9 +5202,11 @@ bool TypeAnalyzer::mustRemainInteger(Value *val, bool *returned) {
continue;
}
if (isa<BinaryOperator>(u) || isa<IntrinsicInst>(u) || isa<PHINode>(u) ||
isa<UDivOperator>(u) || isa<SDivOperator>(u) || isa<LShrOperator>(u) ||
isa<AShrOperator>(u) || isa<AddOperator>(u) || isa<MulOperator>(u) ||
isa<ShlOperator>(u)) {
#if LLVM_VERSION_MAJOR <= 17
isa<UDivOperator>(u) || isa<SDivOperator>(u) ||
#endif
isa<LShrOperator>(u) || isa<AShrOperator>(u) || isa<AddOperator>(u) ||
isa<MulOperator>(u) || isa<ShlOperator>(u)) {
if (!mustRemainInteger(u, returned)) {
seen[val].first = false;
seen[val].second |= seen[u].second;
Expand Down
2 changes: 1 addition & 1 deletion enzyme/Enzyme/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ static inline DIFFE_TYPE whatType(llvm::Type *arg, DerivativeMode mode,
}

if (arg->isPointerTy()) {
#if LLVM_VERSION_MAJOR >= 18
#if LLVM_VERSION_MAJOR >= 17
return DIFFE_TYPE::DUP_ARG;
#else
#if LLVM_VERSION_MAJOR >= 15
Expand Down

0 comments on commit 116e8bb

Please sign in to comment.