Skip to content

Commit 5354c83

Browse files
committedJul 25, 2019
[IPSCCP] Add assertion to surface cases where we zap returns with overdefined users.
We should only zap returns in functions, where all live users have a replace-able value (are not overdefined). Unused return values should be undefined. This should make it easier to detect bugs like in PR42738. Alternatively we could bail out of zapping the function returns, but I think it would be better to address those divergences between function and call-site values where they are actually caused. Reviewers: davide, efriedma Reviewed By: davide, efriedma Differential Revision: https://reviews.llvm.org/D65222 llvm-svn: 366998
1 parent 48b16e1 commit 5354c83

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
 

‎llvm/lib/Transforms/Scalar/SCCP.cpp

+15
Original file line numberDiff line numberDiff line change
@@ -1924,6 +1924,21 @@ static void findReturnsToZap(Function &F,
19241924
return;
19251925
}
19261926

1927+
assert(
1928+
all_of(F.users(),
1929+
[&Solver](User *U) {
1930+
if (isa<Instruction>(U) &&
1931+
!Solver.isBlockExecutable(cast<Instruction>(U)->getParent()))
1932+
return false;
1933+
if (U->getType()->isStructTy()) {
1934+
return all_of(
1935+
Solver.getStructLatticeValueFor(U),
1936+
[](const LatticeVal &LV) { return !LV.isOverdefined(); });
1937+
}
1938+
return !Solver.getLatticeValueFor(U).isOverdefined();
1939+
}) &&
1940+
"We can only zap functions where all live users have a concrete value");
1941+
19271942
for (BasicBlock &BB : F) {
19281943
if (CallInst *CI = BB.getTerminatingMustTailCall()) {
19291944
LLVM_DEBUG(dbgs() << "Can't zap return of the block due to present "

0 commit comments

Comments
 (0)
Please sign in to comment.