This is an archive of the discontinued LLVM Phabricator instance.

[PPC64] Bug fix: when enable both sibling-call-opt and shrink-wrapping, the tail call branch instruction might disappear
ClosedPublic

Authored by cycheng on Feb 25 2016, 6:46 AM.

Details

Summary

Note! http://reviews.llvm.org/D16315 is depend on this patch.

Bug case (When enable both SCO and ShrinkWrapping):

# BB#0:                                 # %entry
	cmpldi	 3, 0
	beq-	 0, .LBB0_2
# BB#1:                                 # %exit
	lwz 4, 0(3)
	#TC_RETURNd8 LVComputationKind 0
.LBB0_2:                                # %cond.false
	mflr 0
	std 0, 16(1)
	stdu 1, -96(1)
.Ltmp0:
	.cfi_def_cfa_offset 96
.Ltmp1:
	.cfi_offset lr, 16
	bl __assert_fail
	nop

The branch instruction for tail call return is not generated, because the shrink-wrapping pass choosing a new Restore Point: %cond.false, so %exit block is not sent to emitEpilogue, that's why the branch is not generated.

We handle this case in processFunctionBeforeFrameFinalized.

Diff Detail

Event Timeline

cycheng updated this revision to Diff 49051.Feb 25 2016, 6:46 AM
cycheng retitled this revision from to [PPC64] Bug fix: when enable both sibling-call-opt and shrink-wrapping, the tail call branch instruction might disappear.
cycheng updated this object.
cycheng added reviewers: kbarton, nemanjai, hfinkel, tjablin.
cycheng added a subscriber: llvm-commits.
kbarton edited edge metadata.Mar 30 2016, 9:56 AM

Aside from the minor point about the comment, this LGTM.

lib/Target/PowerPC/PPCFrameLowering.cpp
1325

This comment isn't accurate since you've refactored the code from emitEpilogue into this method.
You could probably remove it altogether, but if you want to keep it I could change it to "Originally from emitEpilogue".

kbarton accepted this revision.Mar 30 2016, 9:57 AM
kbarton edited edge metadata.
This revision is now accepted and ready to land.Mar 30 2016, 9:57 AM
cycheng closed this revision.Mar 31 2016, 11:52 PM
cycheng marked an inline comment as done.

Committed r265112

lib/Target/PowerPC/PPCFrameLowering.cpp
1325

Thanks : )