https://tinyurl.com/27srmb39
; Enzyme: cast<Constant>() argument of incompatible type
;
; opt castconst-reduced.ll -load-pass-plugin=libEnzyme-23.so -passes=enzyme -S
;
; opt: llvm/Support/Casting.h:572: decltype(auto) llvm::cast(From *)
; [To = llvm::Constant, From = llvm::Value]:
; Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"'
;
; GradientUtils.cpp, the ConstantDataArray case of invertPointerM:
;
; Value *val = invertPointerM(el, BuilderM, subTT);
; Vals.push_back(cast<Constant>(val)); ; <-- fires here
;
; @tab holds two packed doubles as bytes, so its ConstantDataArray elements are
; i8. Element 0 is byte 0x55 ('U') of 1/3 = 0x3FD5555555555555. Its one-byte
; TypeTree window overlaps a float without covering the whole double, so
; inverting that element falls into the generic partially-float path, which
; emits an alloca/store/load and hands back a LoadInst rather than a Constant.
;
; The store makes @tab active, so Enzyme builds a shadow global and inverts its
; initializer; without it the global stays constant and is never inverted.
;
; Reduced with llvm-reduce from repro/castconst-single.rs (a no_std Rust file).
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
@tab = global [16 x i8] c"UUUUUU\D5?\00\00\00\00\00\00\D0?"
@enzyme_const = external global ptr
@enzyme_dup = external global ptr
define void @f(ptr %0, i64 %1, ptr %2, i64 %3, i32 %4) {
store i32 0, ptr @tab, align 4
ret void
}
define {} @entry() {
%1 = tail call {} (...) @__enzyme_autodiff(ptr @f, ptr @enzyme_dup, ptr null, ptr null, ptr @enzyme_const, i64 0, ptr @enzyme_dup, ptr null, ptr null, ptr @enzyme_const, i64 0, ptr @enzyme_const, i32 0)
ret {} %1
}
declare {} @__enzyme_autodiff(...)
@wsmoses
https://tinyurl.com/27srmb39
@wsmoses