With opaque pointers, this is no longer ensured through pointer
type identity.
bool llvm::canConstantFoldCallTo(const CallBase *Call, const Function *F) {
if (Call->isNoBuiltin())
return false;
+ if (Call->getFunctionType() != F->getFunctionType())
+ return false;
switch (F->getIntrinsicID()) {
// Operations that do not operate floating-point numbers and do not depend on
// FP environment can be folded even in strictfp functions.
call void @call_byval(ptr %p, ptr byval(double) %p2)
ret void
}
+
+declare float @fmodf(float, float)
+
+define i32 @const_fold_call_with_func_type_mismatch() {
+; CHECK-LABEL: @const_fold_call_with_func_type_mismatch(
+; CHECK-NEXT: [[V:%.*]] = call float @fmodf(float 0x40091EB860000000, float 2.000000e+00)
+; CHECK-NEXT: ret i32 1066527622
+;
+ %v = call i32 @fmodf(float 0x40091EB860000000, float 2.000000e+00)
+ ret i32 %v
+}