Skip to content

Commit f951148

Browse files
wsmosesUbuntu
and
Ubuntu
authored
Consider invariant loads in cache analysis (rust-lang#559)
* Invariant loads * alloc * Fix for LLVM 9 Co-authored-by: Ubuntu <[email protected]>
1 parent 84d834b commit f951148

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

enzyme/Enzyme/EnzymeLogic.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,14 @@ struct CacheAnalysis {
240240
if (PT->getAddressSpace() == 13)
241241
return false;
242242

243+
#if LLVM_VERSION_MAJOR >= 10
244+
if (li.hasMetadata(LLVMContext::MD_invariant_load))
245+
return false;
246+
#else
247+
if (li.getMetadata(LLVMContext::MD_invariant_load))
248+
return false;
249+
#endif
250+
243251
// Find the underlying object for the pointer operand of the load
244252
// instruction.
245253
auto obj =
@@ -390,7 +398,7 @@ struct CacheAnalysis {
390398
return {};
391399
}
392400

393-
if (isCertainPrintMallocOrFree(Fn)) {
401+
if (isCertainPrintMallocOrFree(Fn) || isAllocationFunction(*Fn, TLI)) {
394402
return {};
395403
}
396404

0 commit comments

Comments
 (0)