Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All loaded values extension #2219

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions enzyme/Enzyme/ActivityAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2697,8 +2697,8 @@ bool ActivityAnalyzer::isValueInactiveFromUsers(TypeResults const &TR,
}

if (EnzymePrintActivity)
llvm::errs() << " considering use of " << *val << " - " << *a
<< "\n";
llvm::errs() << " considering use(" << to_string(UA) << ") of "
<< *val << " - " << *a << "\n";

// Only ignore stores to the operand, not storing the operand
// somewhere
Expand Down
16 changes: 12 additions & 4 deletions enzyme/Enzyme/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2627,7 +2627,7 @@ bool writesToMemoryReadBy(const TypeResults *TR, llvm::AAResults &AA,

// Find the base pointer of ptr and the offset in bytes from the start of
// the returned base pointer to this value.
AllocaInst *getBaseAndOffset(Value *ptr, size_t &offset) {
Value *getBaseAndOffset(Value *ptr, size_t &offset) {
offset = 0;
while (true) {
if (auto CI = dyn_cast<CastInst>(ptr)) {
Expand Down Expand Up @@ -2663,7 +2663,16 @@ AllocaInst *getBaseAndOffset(Value *ptr, size_t &offset) {
}
return nullptr;
}
return cast<AllocaInst>(ptr);
if (isa<AllocaInst>(ptr))
return ptr;
// Assume all allocainsts are uninitialized data
if (auto *CI = llvm::dyn_cast<llvm::CallBase>(ptr)) {
auto name = getFuncNameFromCall(CI);
if (name == "malloc" || name == "julia.gc_alloc_obj") {
return ptr;
}
}
return nullptr;
}

// Find all user instructions of AI, returning tuples of <instruction, value,
Expand Down Expand Up @@ -2715,8 +2724,7 @@ findAllUsersOf(Value *AI) {
// that pointer when indexed at offset. If it is impossible to guarantee that
// the set contains all such values, set legal to false
SmallVector<std::pair<Value *, size_t>, 1>
getAllLoadedValuesFrom(AllocaInst *ptr0, size_t offset, size_t valSz,
bool &legal) {
getAllLoadedValuesFrom(Value *ptr0, size_t offset, size_t valSz, bool &legal) {
SmallVector<std::pair<Value *, size_t>, 1> options;

auto todo = findAllUsersOf(ptr0);
Expand Down
4 changes: 4 additions & 0 deletions enzyme/Enzyme/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -2121,4 +2121,8 @@ arePointersGuaranteedNoAlias(llvm::TargetLibraryInfo &TLI, llvm::AAResults &AA,
llvm::LoopInfo &LI, llvm::Value *op0,
llvm::Value *op1, bool offsetAllowed = false);

llvm::SmallVector<std::pair<llvm::Value *, size_t>, 1>
getAllLoadedValuesFrom(llvm::Value *ptr0, size_t offset, size_t valSz,
bool &legal);

#endif // ENZYME_UTILS_H
Loading