Skip to content

Commit 8e87377

Browse files
authored
Remove function hacky activity (rust-lang#701)
1 parent 47f6b83 commit 8e87377

File tree

2 files changed

+39
-11
lines changed

2 files changed

+39
-11
lines changed

enzyme/Enzyme/ActivityAnalysis.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,17 +1095,6 @@ bool ActivityAnalyzer::isConstantValue(TypeResults const &TR, Value *Val) {
10951095
// infinite loop
10961096
if (auto ce = dyn_cast<ConstantExpr>(Val)) {
10971097
if (ce->isCast()) {
1098-
if (auto PT = dyn_cast<PointerType>(ce->getType())) {
1099-
if (PT->getPointerElementType()->isFunctionTy()) {
1100-
if (EnzymePrintActivity)
1101-
llvm::errs()
1102-
<< " VALUE nonconst as cast to pointer of functiontype " << *Val
1103-
<< "\n";
1104-
ActiveValues.insert(Val);
1105-
return false;
1106-
}
1107-
}
1108-
11091098
if (isConstantValue(TR, ce->getOperand(0))) {
11101099
if (EnzymePrintActivity)
11111100
llvm::errs() << " VALUE const cast from from operand " << *Val
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
; RUN: %opt < %s %loadEnzyme -enzyme -enzyme-preopt=false -mem2reg -instsimplify -simplifycfg -S | FileCheck %s
2+
3+
@g = constant i8* null, align 8
4+
5+
define void @_Z3barv(void ()** %i2) {
6+
store void ()* bitcast (i8** @g to void ()*), void ()** %i2, align 8
7+
ret void
8+
}
9+
10+
define double @_Z3fooRd(double* nocapture readonly %arg) {
11+
%ai2 = alloca void ()*, align 8
12+
call void @_Z3barv(void ()** %ai2)
13+
%a8 = load void ()*, void ()** %ai2, align 8
14+
ret double 0.000000e+00
15+
}
16+
17+
define void @caller(double* %i, double* %i2) {
18+
%i6 = call double (...) @__enzyme_autodiff(i8* bitcast (double (double*)* @_Z3fooRd to i8*), double* %i, double* %i2)
19+
ret void
20+
}
21+
22+
declare double @__enzyme_autodiff(...)
23+
24+
; CHECK: define internal void @diffe_Z3fooRd(double* nocapture readonly %arg, double* nocapture %"arg'", double %differeturn)
25+
; CHECK-NEXT: invert:
26+
; CHECK-NEXT: %"ai2'ipa" = alloca void ()*, align 8
27+
; CHECK-NEXT: store void ()* null, void ()** %"ai2'ipa", align 8
28+
; CHECK-NEXT: %ai2 = alloca void ()*, align 8
29+
; CHECK-NEXT: call void @diffe_Z3barv(void ()** %ai2, void ()** %"ai2'ipa")
30+
; CHECK-NEXT: ret void
31+
; CHECK-NEXT: }
32+
33+
; CHECK: define internal void @diffe_Z3barv(void ()** %i2, void ()** %"i2'")
34+
; CHECK-NEXT: invert:
35+
; CHECK-NEXT: store void ()* bitcast (i8** @g to void ()*), void ()** %"i2'", align 8
36+
; CHECK-NEXT: store void ()* bitcast (i8** @g to void ()*), void ()** %i2, align 8
37+
; CHECK-NEXT: ret void
38+
; CHECK-NEXT: }
39+

0 commit comments

Comments
 (0)