Index: lib/Transforms/Scalar/SCCP.cpp =================================================================== --- lib/Transforms/Scalar/SCCP.cpp +++ lib/Transforms/Scalar/SCCP.cpp @@ -428,6 +428,9 @@ assert(!V->getType()->isStructTy() && "structs should use mergeInValue"); LatticeVal &IV = ValueState[V]; IV.markForcedConstant(C); + // ParamState lattice elements do not have support for forced constants, + // so we have to drop any more precise information. + ParamState.erase(V); LLVM_DEBUG(dbgs() << "markForcedConstant: " << *C << ": " << *V << '\n'); pushToWorkList(IV, V); } Index: test/Transforms/SCCP/ipsccp-paramstate-forcedconst.ll =================================================================== --- /dev/null +++ test/Transforms/SCCP/ipsccp-paramstate-forcedconst.ll @@ -0,0 +1,24 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py +; RUN: opt < %s -S -ipsccp | FileCheck %s + +define void @main() { +; CHECK-LABEL: @main( +; CHECK-NEXT: [[CALL:%.*]] = call i1 @patatino(i1 undef) +; CHECK-NEXT: ret void +; + %call = call i1 @patatino(i1 undef) + ret void +} + +define internal i1 @patatino(i1 %a) { +; CHECK-LABEL: @patatino( +; CHECK-NEXT: br label [[ONFALSE:%.*]] +; CHECK: onfalse: +; CHECK-NEXT: ret i1 undef +; + br i1 %a, label %ontrue, label %onfalse +ontrue: + ret i1 false +onfalse: + ret i1 false +}