llvm.org GIT mirror llvm / 7ebc06b
Yet another nasty spiller bug. %ecx = op store %cl<kill>, (addr) (addr) = op %al It's not safe to unfold the last operand and eliminate store even though %cl is marked kill. It's a sub-register use which means one of its super-register(s) may be used below. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@50794 91177308-0d34-0410-b5e6-96231b3b80d8 Evan Cheng 11 years ago
2 changed file(s) with 56 addition(s) and 14 deletion(s). Raw diff Collapse all Expand all
14641464 // the value and there isn't an earlier def that has already clobbered
14651465 // the physreg.
14661466 if (PhysReg &&
1467 !TII->isStoreToStackSlot(&MI, SS) && // Not profitable!
1468 DeadStore->killsRegister(PhysReg) &&
1469 TII->unfoldMemoryOperand(MF, &MI, PhysReg, false, true, NewMIs)) {
1470 MBB.insert(MII, NewMIs[0]);
1471 NewStore = NewMIs[1];
1472 MBB.insert(MII, NewStore);
1473 VRM.addSpillSlotUse(SS, NewStore);
1474 VRM.RemoveMachineInstrFromMaps(&MI);
1475 MBB.erase(&MI);
1476 Erased = true;
1477 --NextMII;
1478 --NextMII; // backtrack to the unfolded instruction.
1479 BackTracked = true;
1480 isDead = true;
1467 !TII->isStoreToStackSlot(&MI, SS)) { // Not profitable!
1468 MachineOperand *KillOpnd =
1469 DeadStore->findRegisterUseOperand(PhysReg, true);
1470 // Note, if the store is storing a sub-register, it's possible the
1471 // super-register is needed below.
1472 if (KillOpnd && !KillOpnd->getSubReg() &&
1473 TII->unfoldMemoryOperand(MF, &MI, PhysReg, false, true,NewMIs)){
1474 MBB.insert(MII, NewMIs[0]);
1475 NewStore = NewMIs[1];
1476 MBB.insert(MII, NewStore);
1477 VRM.addSpillSlotUse(SS, NewStore);
1478 VRM.RemoveMachineInstrFromMaps(&MI);
1479 MBB.erase(&MI);
1480 Erased = true;
1481 --NextMII;
1482 --NextMII; // backtrack to the unfolded instruction.
1483 BackTracked = true;
1484 isDead = true;
1485 }
14811486 }
14821487 }
14831488
0 ; RUN: llvm-as < %s | llc -mtriple=i386-apple-darwin -relocation-model=pic -disable-fp-elim | grep addb | grep ebp
1
2 %struct.rc4_state = type { i32, i32, [256 x i32] }
3 @.str1 = internal constant [65 x i8] c"m[%d] = 0x%02x, m[%d] = 0x%02x, 0x%02x, k = %d, key[k] = 0x%02x\0A\00" ; <[65 x i8]*> [#uses=1]
4 @keys = internal constant [7 x [30 x i8]] [ [30 x i8] c"\08\01#Eg\89\AB\CD\EF\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00", [30 x i8] c"\08\01#Eg\89\AB\CD\EF\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00", [30 x i8] c"\08\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00", [30 x i8] c"\04\EF\01#E\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00", [30 x i8] c"\08\01#Eg\89\AB\CD\EF\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00", [30 x i8] c"\04\EF\01#E\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00", [30 x i8] zeroinitializer ] ; <[7 x [30 x i8]]*> [#uses=1]
5
6 declare i32 @printf(i8*, ...) nounwind
7
8 define i32 @main(i32 %argc, i8** %argv) nounwind {
9 entry:
10 br label %bb25
11
12 bb25: ; preds = %bb25, %entry
13 br i1 false, label %bb.i, label %bb25
14
15 bb.i: ; preds = %bb.i, %bb25
16 br i1 false, label %bb21.i, label %bb.i
17
18 bb21.i: ; preds = %bb21.i, %bb.i
19 %k.0.reg2mem.0.i = phi i32 [ %k.1.i, %bb21.i ], [ 0, %bb.i ] ; [#uses=2]
20 %j.0.reg2mem.0.i = phi i8 [ %tmp35.i, %bb21.i ], [ 0, %bb.i ] ; [#uses=1]
21 %tmp25.i = load i32* null, align 4 ; [#uses=4]
22 %tmp2829.i = trunc i32 %tmp25.i to i8 ; [#uses=1]
23 %.sum = add i32 %k.0.reg2mem.0.i, 1 ; [#uses=3]
24 %tmp33.i = getelementptr [7 x [30 x i8]]* @keys, i32 0, i32 0, i32 %.sum ; [#uses=1]
25 %tmp34.i = load i8* %tmp33.i, align 1 ; [#uses=1]
26 %tmp30.i = add i8 %tmp2829.i, %j.0.reg2mem.0.i ; [#uses=1]
27 %tmp35.i = add i8 %tmp30.i, %tmp34.i ; [#uses=2]
28 %tmp3536.i = zext i8 %tmp35.i to i32 ; [#uses=2]
29 %tmp39.i = getelementptr %struct.rc4_state* null, i32 0, i32 2, i32 %tmp3536.i ; [#uses=1]
30 store i32 %tmp25.i, i32* %tmp39.i, align 4
31 %tmp60.i = load i32* null, align 4 ; [#uses=1]
32 %tmp65.i = call i32 (i8*, ...)* @printf( i8* getelementptr ([65 x i8]* @.str1, i32 0, i32 0), i32 0, i32 %tmp60.i, i32 %tmp3536.i, i32 %tmp25.i, i32 %tmp25.i, i32 %k.0.reg2mem.0.i, i32 0 ) nounwind ; [#uses=0]
33 %tmp70.i = icmp slt i32 %.sum, 8 ; [#uses=1]
34 %k.1.i = select i1 %tmp70.i, i32 %.sum, i32 0 ; [#uses=1]
35 br label %bb21.i
36 }