llvm.org GIT mirror llvm / 6025e4b
Merge from mainline. Change CALLSEQ_BEGIN and CALLSEQ_END to take TargetConstant's as parameters instead of raw Constants. This prevents the constants from being selected by the isel pass, fixing PR2735. git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_24@57700 91177308-0d34-0410-b5e6-96231b3b80d8 Tanya Lattner 10 years ago
19 changed file(s) with 74 addition(s) and 70 deletion(s). Raw diff Collapse all Expand all
16771677
16781678 // Chain the dynamic stack allocation so that it doesn't modify the stack
16791679 // pointer when other instructions are using the stack.
1680 Chain = DAG.getCALLSEQ_START(Chain,
1681 DAG.getConstant(0, TLI.getPointerTy()));
1680 Chain = DAG.getCALLSEQ_START(Chain, DAG.getIntPtrConstant(0, true));
16821681
16831682 SDValue Size = Tmp2.getOperand(1);
16841683 SDValue SP = DAG.getCopyFromReg(Chain, SPReg, VT);
16921691 Tmp1 = DAG.getNode(ISD::SUB, VT, SP, Size); // Value
16931692 Chain = DAG.getCopyToReg(Chain, SPReg, Tmp1); // Output chain
16941693
1695 Tmp2 =
1696 DAG.getCALLSEQ_END(Chain,
1697 DAG.getConstant(0, TLI.getPointerTy()),
1698 DAG.getConstant(0, TLI.getPointerTy()),
1699 SDValue());
1694 Tmp2 = DAG.getCALLSEQ_END(Chain, DAG.getIntPtrConstant(0, true),
1695 DAG.getIntPtrConstant(0, true), SDValue());
17001696
17011697 Tmp1 = LegalizeOp(Tmp1);
17021698 Tmp2 = LegalizeOp(Tmp2);
429429
430430 // Adjust the stack pointer for the new arguments...
431431 // These operations are automatically eliminated by the prolog/epilog pass
432 Chain = DAG.getCALLSEQ_START(Chain,
433 DAG.getConstant(NumBytes, MVT::i32));
432 Chain = DAG.getCALLSEQ_START(Chain, DAG.getIntPtrConstant(NumBytes, true));
434433
435434 SDValue StackPtr = DAG.getRegister(ARM::SP, MVT::i32);
436435
602601 &Ops[0], Ops.size());
603602 InFlag = Chain.getValue(1);
604603
605 Chain = DAG.getCALLSEQ_END(Chain,
606 DAG.getConstant(NumBytes, MVT::i32),
607 DAG.getConstant(0, MVT::i32),
608 InFlag);
604 Chain = DAG.getCALLSEQ_END(Chain, DAG.getIntPtrConstant(NumBytes, true),
605 DAG.getIntPtrConstant(0, true), InFlag);
609606 if (RetVT != MVT::Other)
610607 InFlag = Chain.getValue(1);
611608
451451 def ADJCALLSTACKUP :
452452 PseudoInst<(outs), (ins i32imm:$amt1, i32imm:$amt2, pred:$p),
453453 "@ ADJCALLSTACKUP $amt1",
454 [(ARMcallseq_end imm:$amt1, imm:$amt2)]>;
454 [(ARMcallseq_end timm:$amt1, timm:$amt2)]>;
455455
456456 def ADJCALLSTACKDOWN :
457457 PseudoInst<(outs), (ins i32imm:$amt, pred:$p),
458458 "@ ADJCALLSTACKDOWN $amt",
459 [(ARMcallseq_start imm:$amt)]>;
459 [(ARMcallseq_start timm:$amt)]>;
460460 }
461461
462462 def DWARF_LOC :
357357 if (Args.size() > 6)
358358 NumBytes = (Args.size() - 6) * 8;
359359
360 Chain = DAG.getCALLSEQ_START(Chain,
361 DAG.getConstant(NumBytes, getPointerTy()));
360 Chain = DAG.getCALLSEQ_START(Chain, DAG.getIntPtrConstant(NumBytes, true));
362361 std::vector args_to_use;
363362 for (unsigned i = 0, e = Args.size(); i != e; ++i)
364363 {
401400 Ops.insert(Ops.end(), args_to_use.begin(), args_to_use.end());
402401 SDValue TheCall = DAG.getNode(AlphaISD::CALL, RetVals, &Ops[0], Ops.size());
403402 Chain = TheCall.getValue(RetTyVT != MVT::isVoid);
404 Chain = DAG.getCALLSEQ_END(Chain,
405 DAG.getConstant(NumBytes, getPointerTy()),
406 DAG.getConstant(0, getPointerTy()),
407 SDValue());
403 Chain = DAG.getCALLSEQ_END(Chain, DAG.getIntPtrConstant(NumBytes, true),
404 DAG.getIntPtrConstant(0, true), SDValue());
408405 SDValue RetVal = TheCall;
409406
410407 if (RetTyVT != ActualRetTyVT) {
150150 let hasCtrlDep = 1, Defs = [R30], Uses = [R30] in {
151151 def ADJUSTSTACKUP : PseudoInstAlpha<(outs), (ins s64imm:$amt),
152152 "; ADJUP $amt",
153 [(callseq_start imm:$amt)], s_pseudo>;
153 [(callseq_start timm:$amt)], s_pseudo>;
154154 def ADJUSTSTACKDOWN : PseudoInstAlpha<(outs), (ins s64imm:$amt1, s64imm:$amt2),
155155 "; ADJDOWN $amt1",
156 [(callseq_end imm:$amt1, imm:$amt2)], s_pseudo>;
156 [(callseq_end timm:$amt1, timm:$amt2)], s_pseudo>;
157157 }
158158
159159 def ALTENT : PseudoInstAlpha<(outs), (ins s64imm:$TARGET), "$$$TARGET..ng:\n", [], s_pseudo>;
11701170
11711171 // Update number of stack bytes actually used, insert a call sequence start
11721172 NumStackBytes = (ArgOffset - SPUFrameInfo::minStackSize());
1173 Chain = DAG.getCALLSEQ_START(Chain, DAG.getConstant(NumStackBytes, PtrVT));
1173 Chain = DAG.getCALLSEQ_START(Chain, DAG.getIntPtrConstant(NumStackBytes,
1174 true));
11741175
11751176 if (!MemOpChains.empty()) {
11761177 // Adjust the stack pointer for the stack arguments.
12421243 &Ops[0], Ops.size());
12431244 InFlag = Chain.getValue(1);
12441245
1245 Chain = DAG.getCALLSEQ_END(Chain,
1246 DAG.getConstant(NumStackBytes, PtrVT),
1247 DAG.getConstant(0, PtrVT),
1248 InFlag);
1246 Chain = DAG.getCALLSEQ_END(Chain, DAG.getIntPtrConstant(NumStackBytes, true),
1247 DAG.getIntPtrConstant(0, true), InFlag);
12491248 if (TheCall->getValueType(0) != MVT::Other)
12501249 InFlag = Chain.getValue(1);
12511250
2323 let hasCtrlDep = 1, Defs = [R1], Uses = [R1] in {
2424 def ADJCALLSTACKDOWN : Pseudo<(outs), (ins u16imm_i32:$amt),
2525 "${:comment} ADJCALLSTACKDOWN",
26 [(callseq_start imm:$amt)]>;
26 [(callseq_start timm:$amt)]>;
2727 def ADJCALLSTACKUP : Pseudo<(outs), (ins u16imm_i32:$amt),
2828 "${:comment} ADJCALLSTACKUP",
29 [(callseq_end imm:$amt)]>;
29 [(callseq_end timm:$amt)]>;
3030 }
3131
3232 //===----------------------------------------------------------------------===//
332332 // "stack frame not 16-byte aligned!");
333333 NumBytes = (NumBytes+15) & ~15;
334334
335 Chain = DAG.getCALLSEQ_START(Chain,DAG.getConstant(NumBytes, getPointerTy()));
335 Chain = DAG.getCALLSEQ_START(Chain, DAG.getIntPtrConstant(NumBytes, true));
336336
337337 SDValue StackPtr;
338338 std::vector Stores;
542542 }
543543 }
544544
545 Chain = DAG.getCALLSEQ_END(Chain,
546 DAG.getConstant(NumBytes, getPointerTy()),
547 DAG.getConstant(0, getPointerTy()),
548 SDValue());
545 Chain = DAG.getCALLSEQ_END(Chain, DAG.getIntPtrConstant(NumBytes, true),
546 DAG.getIntPtrConstant(0, true), SDValue());
549547 return std::make_pair(RetVal, Chain);
550548 }
551549
607607
608608 // Get a count of how many bytes are to be pushed on the stack.
609609 unsigned NumBytes = CCInfo.getNextStackOffset();
610 Chain = DAG.getCALLSEQ_START(Chain,DAG.getConstant(NumBytes,
611 getPointerTy()));
610 Chain = DAG.getCALLSEQ_START(Chain, DAG.getIntPtrConstant(NumBytes, true));
612611
613612 // With EABI is it possible to have 16 args on registers.
614613 SmallVector, 16> RegsToPass;
714713 InFlag = Chain.getValue(1);
715714
716715 // Create the CALLSEQ_END node.
717 Chain = DAG.getCALLSEQ_END(Chain,
718 DAG.getConstant(NumBytes, getPointerTy()),
719 DAG.getConstant(0, getPointerTy()),
720 InFlag);
716 Chain = DAG.getCALLSEQ_END(Chain, DAG.getIntPtrConstant(NumBytes, true),
717 DAG.getIntPtrConstant(0, true), InFlag);
721718 InFlag = Chain.getValue(1);
722719
723720 // Create a stack location to hold GP when PIC is used. This stack
392392 let Defs = [SP], Uses = [SP] in {
393393 def ADJCALLSTACKDOWN : MipsPseudo<(outs), (ins uimm16:$amt),
394394 "!ADJCALLSTACKDOWN $amt",
395 [(callseq_start imm:$amt)]>;
395 [(callseq_start timm:$amt)]>;
396396 def ADJCALLSTACKUP : MipsPseudo<(outs), (ins uimm16:$amt1, uimm16:$amt2),
397397 "!ADJCALLSTACKUP $amt1",
398 [(callseq_end imm:$amt1, imm:$amt2)]>;
398 [(callseq_end timm:$amt1, timm:$amt2)]>;
399399 }
400400
401401 // Some assembly macros need to avoid pseudoinstructions and assembler
21412141
21422142 // Adjust the stack pointer for the new arguments...
21432143 // These operations are automatically eliminated by the prolog/epilog pass
2144 Chain = DAG.getCALLSEQ_START(Chain,
2145 DAG.getConstant(NumBytes, PtrVT));
2144 Chain = DAG.getCALLSEQ_START(Chain, DAG.getIntPtrConstant(NumBytes, true));
21462145 SDValue CallSeqStart = Chain;
21472146
21482147 // Load the return address and frame pointer so it can be move somewhere else
24752474 SmallVector CallSeqOps;
24762475 SDVTList CallSeqNodeTys = DAG.getVTList(MVT::Other, MVT::Flag);
24772476 CallSeqOps.push_back(Chain);
2478 CallSeqOps.push_back(DAG.getIntPtrConstant(NumBytes));
2479 CallSeqOps.push_back(DAG.getIntPtrConstant(0));
2477 CallSeqOps.push_back(DAG.getIntPtrConstant(NumBytes, true));
2478 CallSeqOps.push_back(DAG.getIntPtrConstant(0, true));
24802479 if (InFlag.getNode())
24812480 CallSeqOps.push_back(InFlag);
24822481 Chain = DAG.getNode(ISD::CALLSEQ_END, CallSeqNodeTys, &CallSeqOps[0],
25632562 Chain = DAG.getNode(CallOpc, NodeTys, &Ops[0], Ops.size());
25642563 InFlag = Chain.getValue(1);
25652564
2566 Chain = DAG.getCALLSEQ_END(Chain,
2567 DAG.getConstant(NumBytes, PtrVT),
2568 DAG.getConstant(BytesCalleePops, PtrVT),
2565 Chain = DAG.getCALLSEQ_END(Chain, DAG.getIntPtrConstant(NumBytes, true),
2566 DAG.getIntPtrConstant(BytesCalleePops, true),
25692567 InFlag);
25702568 if (TheCall->getValueType(0) != MVT::Other)
25712569 InFlag = Chain.getValue(1);
341341 let Defs = [R1], Uses = [R1] in {
342342 def ADJCALLSTACKDOWN : Pseudo<(outs), (ins u16imm:$amt),
343343 "${:comment} ADJCALLSTACKDOWN",
344 [(callseq_start imm:$amt)]>;
344 [(callseq_start timm:$amt)]>;
345345 def ADJCALLSTACKUP : Pseudo<(outs), (ins u16imm:$amt1, u16imm:$amt2),
346346 "${:comment} ADJCALLSTACKUP",
347 [(callseq_end imm:$amt1, imm:$amt2)]>;
347 [(callseq_end timm:$amt1, timm:$amt2)]>;
348348 }
349349
350350 def UPDATE_VRSAVE : Pseudo<(outs GPRC:$rD), (ins GPRC:$rS),
268268 // Keep stack frames 8-byte aligned.
269269 ArgsSize = (ArgsSize+7) & ~7;
270270
271 Chain = DAG.getCALLSEQ_START(Chain, DAG.getIntPtrConstant(ArgsSize));
271 Chain = DAG.getCALLSEQ_START(Chain, DAG.getIntPtrConstant(ArgsSize, true));
272272
273273 SmallVector, 8> RegsToPass;
274274 SmallVector MemOpChains;
419419 Chain = DAG.getNode(SPISD::CALL, NodeTys, Ops, InFlag.getNode() ? 3 : 2);
420420 InFlag = Chain.getValue(1);
421421
422 Chain = DAG.getCALLSEQ_END(Chain,
423 DAG.getConstant(ArgsSize, MVT::i32),
424 DAG.getConstant(0, MVT::i32), InFlag);
422 Chain = DAG.getCALLSEQ_END(Chain, DAG.getIntPtrConstant(ArgsSize, true),
423 DAG.getIntPtrConstant(0, true), InFlag);
425424 InFlag = Chain.getValue(1);
426425
427426 // Assign locations to each value returned by this call.
209209 let Defs = [O6], Uses = [O6] in {
210210 def ADJCALLSTACKDOWN : Pseudo<(outs), (ins i32imm:$amt),
211211 "!ADJCALLSTACKDOWN $amt",
212 [(callseq_start imm:$amt)]>;
212 [(callseq_start timm:$amt)]>;
213213 def ADJCALLSTACKUP : Pseudo<(outs), (ins i32imm:$amt1, i32imm:$amt2),
214214 "!ADJCALLSTACKUP $amt1",
215 [(callseq_end imm:$amt1, imm:$amt2)]>;
215 [(callseq_end timm:$amt1, timm:$amt2)]>;
216216 }
217217
218218 // FpMOVD/FpNEGD/FpABSD - These are lowered to single-precision ops by the
239239 def srcvalue;
240240
241241 def imm : SDNode<"ISD::Constant" , SDTIntLeaf , [], "ConstantSDNode">;
242 def timm : SDNode<"ISD::TargetConstant", SDTIntLeaf , [], "ConstantSDNode">;
242243 def fpimm : SDNode<"ISD::ConstantFP", SDTFPLeaf , [], "ConstantFPSDNode">;
243244 def vt : SDNode<"ISD::VALUETYPE" , SDTOther , [], "VTSDNode">;
244245 def bb : SDNode<"ISD::BasicBlock", SDTOther , [], "BasicBlockSDNode">;
14971497 MF.getInfo()->setTCReturnAddrDelta(FPDiff);
14981498 }
14991499
1500 Chain = DAG.getCALLSEQ_START(Chain, DAG.getIntPtrConstant(NumBytes));
1500 Chain = DAG.getCALLSEQ_START(Chain, DAG.getIntPtrConstant(NumBytes, true));
15011501
15021502 SDValue RetAddrFrIdx;
15031503 // Load return adress for tail calls.
17131713
17141714 if (IsTailCall) {
17151715 Ops.push_back(Chain);
1716 Ops.push_back(DAG.getIntPtrConstant(NumBytes));
1717 Ops.push_back(DAG.getIntPtrConstant(0));
1716 Ops.push_back(DAG.getIntPtrConstant(NumBytes, true));
1717 Ops.push_back(DAG.getIntPtrConstant(0, true));
17181718 if (InFlag.getNode())
17191719 Ops.push_back(InFlag);
17201720 Chain = DAG.getNode(ISD::CALLSEQ_END, NodeTys, &Ops[0], Ops.size());
17761776
17771777 // Returns a flag for retval copy to use.
17781778 Chain = DAG.getCALLSEQ_END(Chain,
1779 DAG.getIntPtrConstant(NumBytes),
1780 DAG.getIntPtrConstant(NumBytesForCalleeToPush),
1779 DAG.getIntPtrConstant(NumBytes, true),
1780 DAG.getIntPtrConstant(NumBytesForCalleeToPush,
1781 true),
17811782 InFlag);
17821783 InFlag = Chain.getValue(1);
17831784
51115112 MVT IntPtr = getPointerTy();
51125113 MVT SPTy = Subtarget->is64Bit() ? MVT::i64 : MVT::i32;
51135114
5114 Chain = DAG.getCALLSEQ_START(Chain, DAG.getIntPtrConstant(0));
5115 Chain = DAG.getCALLSEQ_START(Chain, DAG.getIntPtrConstant(0, true));
51155116
51165117 Chain = DAG.getCopyToReg(Chain, X86::EAX, Size, Flag);
51175118 Flag = Chain.getValue(1);
51265127 Flag = Chain.getValue(1);
51275128
51285129 Chain = DAG.getCALLSEQ_END(Chain,
5129 DAG.getIntPtrConstant(0),
5130 DAG.getIntPtrConstant(0),
5130 DAG.getIntPtrConstant(0, true),
5131 DAG.getIntPtrConstant(0, true),
51315132 Flag);
51325133
51335134 Chain = DAG.getCopyFromReg(Chain, X86StackPtr, SPTy).getValue(1);
9393 let Defs = [RSP, EFLAGS], Uses = [RSP] in {
9494 def ADJCALLSTACKDOWN64 : I<0, Pseudo, (outs), (ins i32imm:$amt),
9595 "#ADJCALLSTACKDOWN",
96 [(X86callseq_start imm:$amt)]>,
96 [(X86callseq_start timm:$amt)]>,
9797 Requires<[In64BitMode]>;
9898 def ADJCALLSTACKUP64 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
9999 "#ADJCALLSTACKUP",
100 [(X86callseq_end imm:$amt1, imm:$amt2)]>,
100 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
101101 Requires<[In64BitMode]>;
102102 }
103103
344344 let Defs = [ESP, EFLAGS], Uses = [ESP] in {
345345 def ADJCALLSTACKDOWN32 : I<0, Pseudo, (outs), (ins i32imm:$amt),
346346 "#ADJCALLSTACKDOWN",
347 [(X86callseq_start imm:$amt)]>,
347 [(X86callseq_start timm:$amt)]>,
348348 Requires<[In32BitMode]>;
349349 def ADJCALLSTACKUP32 : I<0, Pseudo, (outs), (ins i32imm:$amt1, i32imm:$amt2),
350350 "#ADJCALLSTACKUP",
351 [(X86callseq_end imm:$amt1, imm:$amt2)]>,
351 [(X86callseq_end timm:$amt1, timm:$amt2)]>,
352352 Requires<[In32BitMode]>;
353353 }
354354
0 ; RUN: llvm-as < %s | llc
1 ; PR2735
2 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
3 target triple = "i386-apple-darwin7"
4 @g_385 = external global i32 ; [#uses=1]
5
6 define i32 @func_45(i64 %p_46, i32 %p_48) nounwind {
7 entry:
8 %0 = tail call i32 (...)* @lshift_s_u(i64 %p_46, i64 0) nounwind ; [#uses=0]
9 %1 = load i32* @g_385, align 4 ; [#uses=1]
10 %2 = shl i32 %1, 1 ; [#uses=1]
11 %3 = and i32 %2, 32 ; [#uses=1]
12 %4 = tail call i32 (...)* @func_87(i32 undef, i32 %p_48, i32 1) nounwind ; [#uses=1]
13 %5 = add i32 %3, %4 ; [#uses=1]
14 %6 = tail call i32 (...)* @div_rhs(i32 %5) nounwind ; [#uses=0]
15 ret i32 undef
16 }
17
18 declare i32 @lshift_s_u(...)
19 declare i32 @func_87(...)
20 declare i32 @div_rhs(...)