SCCP: Don't assert on constantexpr casts of function uses
This includes 2 different, related fixes: 1. Fix asserting on direct assume-like intrinsic uses of a function address 2. Fix asserting on constant expression casts used by assume-like intrinsics. By default hasAddressTaken permits assume-like intrinsic uses, which ignores assume-like calls and pointer casts of the address used by assume-like calls. Fixes #59602, but there are additional issues I encountered when debugging this. For instance, the original failing bitcast expression was really unused. Clang tentatively created it for the function type, but was unnecessary after applyGlobalValReplacements. That did not clean up the now dead ConstantExpr which hung around oun the user list, so this assert only reproduced when running clang from the original testcase, and didn't just running opt -passes=ipsccp. I don't know who is responsible for cleaning up unused ConstantExprs, but I've run into similar issues several times recently. Additionally, I found a few assertions with llvm.ssa.copy with functions and casts of functions as the argument. Another issue theoretically exists if hasAddressTaken chooses to respect nocapture when passed function addresses. The search here would need to do additional work to look at the users of the constant cast to see if any call sites need returned to be stripped.
Loading
Please sign in to comment