[PATCH] Teach the inliner how to preserve musttail invariants
Chandler Carruth
chandlerc at gmail.com
Tue May 6 14:04:49 PDT 2014
Ok, this makes more sense now. Thahnks for the clue-bat.
I want to ruminate on the bit about not needing stackrestore. I think I believe you, but I don't fully understand why yet and I would like to. But below are some easy comments to just clean up code.
================
Comment at: lib/Transforms/Utils/InlineFunction.cpp:697
@@ +696,3 @@
+ for (Instruction &I : *BB) {
+ if (CallInst *CI = dyn_cast<CallInst>(&I)) {
+ CallInst::TailCallKind ChildTCK = CI->getTailCallKind();
----------------
nit: invert and use continue to reduce indentation
================
Comment at: lib/Transforms/Utils/InlineFunction.cpp:794
@@ +793,3 @@
+
+ if (NeedBitCast) {
+ // Strip any possible inlined bitcast and grab the musttail call.
----------------
nit: as above, invert and continue to reduce indentation.
================
Comment at: lib/Transforms/Utils/InlineFunction.cpp:795-800
@@ +794,8 @@
+ if (NeedBitCast) {
+ // Strip any possible inlined bitcast and grab the musttail call.
+ Value *RV = RI->getReturnValue();
+ BitCastInst *OldCast = dyn_cast<BitCastInst>(RV);
+ if (OldCast)
+ RV = OldCast->getOperand(0);
+ assert(cast<CallInst>(RV)->isMustTailCall());
+
----------------
Rather than duplicating isPrecededByMustTailCall, make that function getPrecedingMustTailCallInst or some such, and have it return null when there is no call? That should make this loop simplify quite a bit.
http://reviews.llvm.org/D3491
More information about the llvm-commits
mailing list