Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
wsmoses committed Oct 28, 2024
1 parent 182743c commit 4e4ca89
Showing 1 changed file with 43 additions and 39 deletions.
82 changes: 43 additions & 39 deletions enzyme/Enzyme/TypeAnalysis/TypeAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1033,34 +1033,36 @@ void TypeAnalyzer::updateAnalysis(Value *Val, TypeTree Data, Value *Origin) {
assert(Origin);
if (auto OI = dyn_cast<Instruction>(Origin)) {
if (OI->getParent() != I->getParent()) {
if (!EnzymeStrictAliasing) {
if (!PDT.dominates(OI->getParent(), I->getParent())) {
bool allocationWithAllUsersInBlock = false;
if (auto AI = dyn_cast<AllocaInst>(I)) {
allocationWithAllUsersInBlock = true;
for (auto U : AI->users()) {
auto P = cast<Instruction>(U)->getParent();
if (P == OI->getParent())
continue;
if (PDT.dominates(OI->getParent(), P))
continue;
allocationWithAllUsersInBlock = false;
break;
if (!EnzymeStrictAliasing) {
if (!PDT.dominates(OI->getParent(), I->getParent())) {
bool allocationWithAllUsersInBlock = false;
if (auto AI = dyn_cast<AllocaInst>(I)) {
allocationWithAllUsersInBlock = true;
for (auto U : AI->users()) {
auto P = cast<Instruction>(U)->getParent();
if (P == OI->getParent())
continue;
if (PDT.dominates(OI->getParent(), P))
continue;
allocationWithAllUsersInBlock = false;
break;
}
}
}
if (!allocationWithAllUsersInBlock) {
if (EnzymePrintType) {
llvm::errs() << " skipping update into ";
I->print(llvm::errs(), *MST);
llvm::errs() << " of " << Data.str() << " from ";
OI->print(llvm::errs(), *MST);
llvm::errs() << "\n";
if (!allocationWithAllUsersInBlock) {
if (EnzymePrintType) {
llvm::errs() << " skipping update into ";
I->print(llvm::errs(), *MST);
llvm::errs() << " of " << Data.str() << " from ";
OI->print(llvm::errs(), *MST);
llvm::errs() << "\n";
}
return;
}
return;
}
}
} else {
if (OI->getParent()->hasNPredecessors(1) && hasMetadata(OI->getParent()->getTerminator(), "enzyme_notypeprop")) {
} else {
if (OI->getParent()->hasNPredecessors(1) &&
hasMetadata(OI->getParent()->getTerminator(),
"enzyme_notypeprop")) {
if (EnzymePrintType) {
llvm::errs() << " skipping update into ";
I->print(llvm::errs(), *MST);
Expand All @@ -1072,25 +1074,27 @@ void TypeAnalyzer::updateAnalysis(Value *Val, TypeTree Data, Value *Origin) {
}
}
}
}
}
} else if (auto Arg = dyn_cast<Argument>(Val)) {
assert(fntypeinfo.Function == Arg->getParent());
if (auto OI = dyn_cast<Instruction>(Origin)) {
auto I = &*fntypeinfo.Function->getEntryBlock().begin();
if (OI->getParent() != I->getParent()) {
if (!EnzymeStrictAliasing) {
if (!PDT.dominates(OI->getParent(), I->getParent())) {
if (EnzymePrintType) {
llvm::errs() << " skipping update into ";
Arg->print(llvm::errs(), *MST);
llvm::errs() << " of " << Data.str() << " from ";
OI->print(llvm::errs(), *MST);
llvm::errs() << "\n";
if (!EnzymeStrictAliasing) {
if (!PDT.dominates(OI->getParent(), I->getParent())) {
if (EnzymePrintType) {
llvm::errs() << " skipping update into ";
Arg->print(llvm::errs(), *MST);
llvm::errs() << " of " << Data.str() << " from ";
OI->print(llvm::errs(), *MST);
llvm::errs() << "\n";
}
return;
}
return;
}
} else {
if (OI->getParent()->hasNPredecessors(1) && hasMetadata(OI->getParent()->getTerminator(), "enzyme_notypeprop")) {
} else {
if (OI->getParent()->hasNPredecessors(1) &&
hasMetadata(OI->getParent()->getTerminator(),
"enzyme_notypeprop")) {
if (EnzymePrintType) {
llvm::errs() << " skipping update into ";
I->print(llvm::errs(), *MST);
Expand All @@ -1100,7 +1104,7 @@ void TypeAnalyzer::updateAnalysis(Value *Val, TypeTree Data, Value *Origin) {
}
return;
}
}
}
}
}
}
Expand Down

0 comments on commit 4e4ca89

Please sign in to comment.