diff --git a/llvm/lib/CodeGen/PrologEpilogInserter.cpp b/llvm/lib/CodeGen/PrologEpilogInserter.cpp --- a/llvm/lib/CodeGen/PrologEpilogInserter.cpp +++ b/llvm/lib/CodeGen/PrologEpilogInserter.cpp @@ -1193,7 +1193,8 @@ // Mark all used registers. BitVector UsedRegs(TRI.getNumRegs()); - if (OnlyUsed) + if (OnlyUsed) { + const MachineRegisterInfo &MRI = MF.getRegInfo(); for (const MachineBasicBlock &MBB : MF) for (const MachineInstr &MI : MBB) for (const MachineOperand &MO : MI.operands()) { @@ -1202,9 +1203,10 @@ MCRegister Reg = MO.getReg(); if (AllocatableSet[Reg] && !MO.isImplicit() && - (MO.isDef() || MO.isUse())) + MRI.isPhysRegModified(Reg)) UsedRegs.set(Reg); } + } // Get a list of registers that are used. BitVector LiveIns(TRI.getNumRegs()); diff --git a/llvm/test/CodeGen/AArch64/zero-call-used-regs.ll b/llvm/test/CodeGen/AArch64/zero-call-used-regs.ll --- a/llvm/test/CodeGen/AArch64/zero-call-used-regs.ll +++ b/llvm/test/CodeGen/AArch64/zero-call-used-regs.ll @@ -22,8 +22,6 @@ ; CHECK: // %bb.0: // %entry ; CHECK-NEXT: mul w8, w1, w0 ; CHECK-NEXT: orr w0, w8, w2 -; CHECK-NEXT: mov x1, #0 -; CHECK-NEXT: mov x2, #0 ; CHECK-NEXT: ret entry: @@ -37,8 +35,6 @@ ; CHECK: // %bb.0: // %entry ; CHECK-NEXT: mul w8, w1, w0 ; CHECK-NEXT: orr w0, w8, w2 -; CHECK-NEXT: mov x1, #0 -; CHECK-NEXT: mov x2, #0 ; CHECK-NEXT: mov x8, #0 ; CHECK-NEXT: ret @@ -53,8 +49,6 @@ ; CHECK: // %bb.0: // %entry ; CHECK-NEXT: mul w8, w1, w0 ; CHECK-NEXT: orr w0, w8, w2 -; CHECK-NEXT: mov x1, #0 -; CHECK-NEXT: mov x2, #0 ; CHECK-NEXT: ret entry: @@ -68,8 +62,6 @@ ; CHECK: // %bb.0: // %entry ; CHECK-NEXT: mul w8, w1, w0 ; CHECK-NEXT: orr w0, w8, w2 -; CHECK-NEXT: mov x1, #0 -; CHECK-NEXT: mov x2, #0 ; CHECK-NEXT: mov x8, #0 ; CHECK-NEXT: ret diff --git a/llvm/test/CodeGen/X86/zero-call-used-regs.ll b/llvm/test/CodeGen/X86/zero-call-used-regs.ll --- a/llvm/test/CodeGen/X86/zero-call-used-regs.ll +++ b/llvm/test/CodeGen/X86/zero-call-used-regs.ll @@ -4,83 +4,682 @@ @result = dso_local global i32 0, align 4 -define dso_local i32 @skip(i32 returned %x) local_unnamed_addr #0 "zero-call-used-regs"="skip" { +declare dso_local i64 @g(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr + +define dso_local i32 @skip(ptr noundef %arg, i64 noundef %arg1) local_unnamed_addr #0 "zero-call-used-regs"="skip" { ; I386-LABEL: skip: -; I386: # %bb.0: # %entry -; I386-NEXT: movl {{[0-9]+}}(%esp), %eax +; I386: # %bb.0: # %bb +; I386-NEXT: pushl %ebp +; I386-NEXT: pushl %ebx +; I386-NEXT: pushl %edi +; I386-NEXT: pushl %esi +; I386-NEXT: subl $12, %esp +; I386-NEXT: movl {{[0-9]+}}(%esp), %esi +; I386-NEXT: movl {{[0-9]+}}(%esp), %edi +; I386-NEXT: movb $0, {{[0-9]+}}(%esp) +; I386-NEXT: movl %edi, %eax +; I386-NEXT: orl %esi, %eax +; I386-NEXT: je .LBB0_1 +; I386-NEXT: # %bb.2: # %bb3.preheader +; I386-NEXT: movl {{[0-9]+}}(%esp), %ebp +; I386-NEXT: xorl %ebx, %ebx +; I386-NEXT: .p2align 4, 0x90 +; I386-NEXT: .LBB0_3: # %bb3 +; I386-NEXT: # =>This Inner Loop Header: Depth=1 +; I386-NEXT: pushl $0 +; I386-NEXT: pushl $1 +; I386-NEXT: pushl %ebp +; I386-NEXT: leal {{[0-9]+}}(%esp), %eax +; I386-NEXT: pushl %eax +; I386-NEXT: calll g +; I386-NEXT: addl $16, %esp +; I386-NEXT: orl %eax, %edx +; I386-NEXT: sete %al +; I386-NEXT: jne .LBB0_5 +; I386-NEXT: # %bb.4: # %bb9 +; I386-NEXT: # in Loop: Header=BB0_3 Depth=1 +; I386-NEXT: incl %ebp +; I386-NEXT: addb {{[0-9]+}}(%esp), %bl +; I386-NEXT: addl $-1, %edi +; I386-NEXT: adcl $-1, %esi +; I386-NEXT: movl %edi, %ecx +; I386-NEXT: orl %esi, %ecx +; I386-NEXT: jne .LBB0_3 +; I386-NEXT: jmp .LBB0_5 +; I386-NEXT: .LBB0_1: +; I386-NEXT: movb $1, %al +; I386-NEXT: xorl %ebx, %ebx +; I386-NEXT: .LBB0_5: # %bb15 +; I386-NEXT: testb %bl, %bl +; I386-NEXT: sete %cl +; I386-NEXT: andb %al, %cl +; I386-NEXT: movzbl %cl, %eax +; I386-NEXT: addl $12, %esp +; I386-NEXT: popl %esi +; I386-NEXT: popl %edi +; I386-NEXT: popl %ebx +; I386-NEXT: popl %ebp ; I386-NEXT: retl ; ; X86-64-LABEL: skip: -; X86-64: # %bb.0: # %entry -; X86-64-NEXT: movl %edi, %eax +; X86-64: # %bb.0: # %bb +; X86-64-NEXT: pushq %rbp +; X86-64-NEXT: pushq %r15 +; X86-64-NEXT: pushq %r14 +; X86-64-NEXT: pushq %rbx +; X86-64-NEXT: pushq %rax +; X86-64-NEXT: movb $0, {{[0-9]+}}(%rsp) +; X86-64-NEXT: testq %rsi, %rsi +; X86-64-NEXT: je .LBB0_1 +; X86-64-NEXT: # %bb.2: # %bb3.preheader +; X86-64-NEXT: movq %rsi, %r14 +; X86-64-NEXT: movq %rdi, %rbx +; X86-64-NEXT: xorl %ebp, %ebp +; X86-64-NEXT: leaq {{[0-9]+}}(%rsp), %r15 +; X86-64-NEXT: .p2align 4, 0x90 +; X86-64-NEXT: .LBB0_3: # %bb3 +; X86-64-NEXT: # =>This Inner Loop Header: Depth=1 +; X86-64-NEXT: movl $1, %edx +; X86-64-NEXT: movq %r15, %rdi +; X86-64-NEXT: movq %rbx, %rsi +; X86-64-NEXT: callq g +; X86-64-NEXT: testq %rax, %rax +; X86-64-NEXT: sete %al +; X86-64-NEXT: jne .LBB0_5 +; X86-64-NEXT: # %bb.4: # %bb9 +; X86-64-NEXT: # in Loop: Header=BB0_3 Depth=1 +; X86-64-NEXT: incq %rbx +; X86-64-NEXT: addb {{[0-9]+}}(%rsp), %bpl +; X86-64-NEXT: decq %r14 +; X86-64-NEXT: jne .LBB0_3 +; X86-64-NEXT: jmp .LBB0_5 +; X86-64-NEXT: .LBB0_1: +; X86-64-NEXT: movb $1, %al +; X86-64-NEXT: xorl %ebp, %ebp +; X86-64-NEXT: .LBB0_5: # %bb15 +; X86-64-NEXT: testb %bpl, %bpl +; X86-64-NEXT: sete %cl +; X86-64-NEXT: andb %al, %cl +; X86-64-NEXT: movzbl %cl, %eax +; X86-64-NEXT: addq $8, %rsp +; X86-64-NEXT: popq %rbx +; X86-64-NEXT: popq %r14 +; X86-64-NEXT: popq %r15 +; X86-64-NEXT: popq %rbp ; X86-64-NEXT: retq +bb: + %i = alloca i8, align 1 + store i8 0, ptr %i, align 1 + %i2 = icmp eq i64 %arg1, 0 + br i1 %i2, label %bb15, label %bb3 -entry: - ret i32 %x +bb3: ; preds = %bb9, %bb + %i4 = phi ptr [ %i10, %bb9 ], [ %arg, %bb ] + %i5 = phi i64 [ %i13, %bb9 ], [ %arg1, %bb ] + %i6 = phi i8 [ %i12, %bb9 ], [ 0, %bb ] + %i7 = call i64 @g(ptr noundef nonnull %i, ptr noundef %i4, i64 noundef 1) + %i8 = icmp eq i64 %i7, 0 + br i1 %i8, label %bb9, label %bb15 + +bb9: ; preds = %bb3 + %i10 = getelementptr i8, ptr %i4, i64 1 + %i11 = load i8, ptr %i, align 1 + %i12 = add i8 %i11, %i6 + %i13 = add i64 %i5, -1 + %i14 = icmp eq i64 %i13, 0 + br i1 %i14, label %bb15, label %bb3 + +bb15: ; preds = %bb9, %bb3, %bb + %i16 = phi i8 [ 0, %bb ], [ %i12, %bb9 ], [ %i6, %bb3 ] + %i17 = phi i1 [ true, %bb ], [ %i8, %bb9 ], [ %i8, %bb3 ] + %i18 = icmp eq i8 %i16, 0 + %i19 = select i1 %i17, i1 %i18, i1 false + %i20 = zext i1 %i19 to i32 + ret i32 %i20 } -define dso_local i32 @used_gpr_arg(i32 returned %x) local_unnamed_addr #0 "zero-call-used-regs"="used-gpr-arg" { +define dso_local i32 @used_gpr_arg(ptr noundef %arg, i64 noundef %arg1) local_unnamed_addr #0 "zero-call-used-regs"="used-gpr-arg" { ; I386-LABEL: used_gpr_arg: -; I386: # %bb.0: # %entry -; I386-NEXT: movl {{[0-9]+}}(%esp), %eax +; I386: # %bb.0: # %bb +; I386-NEXT: pushl %ebp +; I386-NEXT: pushl %ebx +; I386-NEXT: pushl %edi +; I386-NEXT: pushl %esi +; I386-NEXT: subl $12, %esp +; I386-NEXT: movl {{[0-9]+}}(%esp), %esi +; I386-NEXT: movl {{[0-9]+}}(%esp), %edi +; I386-NEXT: movb $0, {{[0-9]+}}(%esp) +; I386-NEXT: movl %edi, %eax +; I386-NEXT: orl %esi, %eax +; I386-NEXT: je .LBB1_1 +; I386-NEXT: # %bb.2: # %bb3.preheader +; I386-NEXT: movl {{[0-9]+}}(%esp), %ebp +; I386-NEXT: xorl %ebx, %ebx +; I386-NEXT: .p2align 4, 0x90 +; I386-NEXT: .LBB1_3: # %bb3 +; I386-NEXT: # =>This Inner Loop Header: Depth=1 +; I386-NEXT: pushl $0 +; I386-NEXT: pushl $1 +; I386-NEXT: pushl %ebp +; I386-NEXT: leal {{[0-9]+}}(%esp), %eax +; I386-NEXT: pushl %eax +; I386-NEXT: calll g +; I386-NEXT: addl $16, %esp +; I386-NEXT: orl %eax, %edx +; I386-NEXT: sete %al +; I386-NEXT: jne .LBB1_5 +; I386-NEXT: # %bb.4: # %bb9 +; I386-NEXT: # in Loop: Header=BB1_3 Depth=1 +; I386-NEXT: incl %ebp +; I386-NEXT: addb {{[0-9]+}}(%esp), %bl +; I386-NEXT: addl $-1, %edi +; I386-NEXT: adcl $-1, %esi +; I386-NEXT: movl %edi, %ecx +; I386-NEXT: orl %esi, %ecx +; I386-NEXT: jne .LBB1_3 +; I386-NEXT: jmp .LBB1_5 +; I386-NEXT: .LBB1_1: +; I386-NEXT: movb $1, %al +; I386-NEXT: xorl %ebx, %ebx +; I386-NEXT: .LBB1_5: # %bb15 +; I386-NEXT: testb %bl, %bl +; I386-NEXT: sete %cl +; I386-NEXT: andb %al, %cl +; I386-NEXT: movzbl %cl, %eax +; I386-NEXT: addl $12, %esp +; I386-NEXT: popl %esi +; I386-NEXT: popl %edi +; I386-NEXT: popl %ebx +; I386-NEXT: popl %ebp ; I386-NEXT: retl ; ; X86-64-LABEL: used_gpr_arg: -; X86-64: # %bb.0: # %entry -; X86-64-NEXT: movl %edi, %eax +; X86-64: # %bb.0: # %bb +; X86-64-NEXT: pushq %rbp +; X86-64-NEXT: pushq %r15 +; X86-64-NEXT: pushq %r14 +; X86-64-NEXT: pushq %rbx +; X86-64-NEXT: pushq %rax +; X86-64-NEXT: movb $0, {{[0-9]+}}(%rsp) +; X86-64-NEXT: testq %rsi, %rsi +; X86-64-NEXT: je .LBB1_1 +; X86-64-NEXT: # %bb.2: # %bb3.preheader +; X86-64-NEXT: movq %rsi, %r14 +; X86-64-NEXT: movq %rdi, %rbx +; X86-64-NEXT: xorl %ebp, %ebp +; X86-64-NEXT: leaq {{[0-9]+}}(%rsp), %r15 +; X86-64-NEXT: .p2align 4, 0x90 +; X86-64-NEXT: .LBB1_3: # %bb3 +; X86-64-NEXT: # =>This Inner Loop Header: Depth=1 +; X86-64-NEXT: movl $1, %edx +; X86-64-NEXT: movq %r15, %rdi +; X86-64-NEXT: movq %rbx, %rsi +; X86-64-NEXT: callq g +; X86-64-NEXT: testq %rax, %rax +; X86-64-NEXT: sete %al +; X86-64-NEXT: jne .LBB1_5 +; X86-64-NEXT: # %bb.4: # %bb9 +; X86-64-NEXT: # in Loop: Header=BB1_3 Depth=1 +; X86-64-NEXT: incq %rbx +; X86-64-NEXT: addb {{[0-9]+}}(%rsp), %bpl +; X86-64-NEXT: decq %r14 +; X86-64-NEXT: jne .LBB1_3 +; X86-64-NEXT: jmp .LBB1_5 +; X86-64-NEXT: .LBB1_1: +; X86-64-NEXT: movb $1, %al +; X86-64-NEXT: xorl %ebp, %ebp +; X86-64-NEXT: .LBB1_5: # %bb15 +; X86-64-NEXT: testb %bpl, %bpl +; X86-64-NEXT: sete %cl +; X86-64-NEXT: andb %al, %cl +; X86-64-NEXT: movzbl %cl, %eax +; X86-64-NEXT: addq $8, %rsp +; X86-64-NEXT: popq %rbx +; X86-64-NEXT: popq %r14 +; X86-64-NEXT: popq %r15 +; X86-64-NEXT: popq %rbp ; X86-64-NEXT: xorl %edi, %edi +; X86-64-NEXT: xorl %esi, %esi ; X86-64-NEXT: retq +bb: + %i = alloca i8, align 1 + store i8 0, ptr %i, align 1 + %i2 = icmp eq i64 %arg1, 0 + br i1 %i2, label %bb15, label %bb3 -entry: - ret i32 %x +bb3: ; preds = %bb9, %bb + %i4 = phi ptr [ %i10, %bb9 ], [ %arg, %bb ] + %i5 = phi i64 [ %i13, %bb9 ], [ %arg1, %bb ] + %i6 = phi i8 [ %i12, %bb9 ], [ 0, %bb ] + %i7 = call i64 @g(ptr noundef nonnull %i, ptr noundef %i4, i64 noundef 1) + %i8 = icmp eq i64 %i7, 0 + br i1 %i8, label %bb9, label %bb15 + +bb9: ; preds = %bb3 + %i10 = getelementptr i8, ptr %i4, i64 1 + %i11 = load i8, ptr %i, align 1 + %i12 = add i8 %i11, %i6 + %i13 = add i64 %i5, -1 + %i14 = icmp eq i64 %i13, 0 + br i1 %i14, label %bb15, label %bb3 + +bb15: ; preds = %bb9, %bb3, %bb + %i16 = phi i8 [ 0, %bb ], [ %i12, %bb9 ], [ %i6, %bb3 ] + %i17 = phi i1 [ true, %bb ], [ %i8, %bb9 ], [ %i8, %bb3 ] + %i18 = icmp eq i8 %i16, 0 + %i19 = select i1 %i17, i1 %i18, i1 false + %i20 = zext i1 %i19 to i32 + ret i32 %i20 } -define dso_local i32 @used_gpr(i32 returned %x) local_unnamed_addr #0 "zero-call-used-regs"="used-gpr" { +define dso_local i32 @used_gpr(ptr noundef %arg, i64 noundef %arg1) local_unnamed_addr #0 "zero-call-used-regs"="used-gpr" { ; I386-LABEL: used_gpr: -; I386: # %bb.0: # %entry -; I386-NEXT: movl {{[0-9]+}}(%esp), %eax +; I386: # %bb.0: # %bb +; I386-NEXT: pushl %ebp +; I386-NEXT: pushl %ebx +; I386-NEXT: pushl %edi +; I386-NEXT: pushl %esi +; I386-NEXT: subl $12, %esp +; I386-NEXT: movl {{[0-9]+}}(%esp), %esi +; I386-NEXT: movl {{[0-9]+}}(%esp), %edi +; I386-NEXT: movb $0, {{[0-9]+}}(%esp) +; I386-NEXT: movl %edi, %eax +; I386-NEXT: orl %esi, %eax +; I386-NEXT: je .LBB2_1 +; I386-NEXT: # %bb.2: # %bb3.preheader +; I386-NEXT: movl {{[0-9]+}}(%esp), %ebp +; I386-NEXT: xorl %ebx, %ebx +; I386-NEXT: .p2align 4, 0x90 +; I386-NEXT: .LBB2_3: # %bb3 +; I386-NEXT: # =>This Inner Loop Header: Depth=1 +; I386-NEXT: pushl $0 +; I386-NEXT: pushl $1 +; I386-NEXT: pushl %ebp +; I386-NEXT: leal {{[0-9]+}}(%esp), %eax +; I386-NEXT: pushl %eax +; I386-NEXT: calll g +; I386-NEXT: addl $16, %esp +; I386-NEXT: orl %eax, %edx +; I386-NEXT: sete %al +; I386-NEXT: jne .LBB2_5 +; I386-NEXT: # %bb.4: # %bb9 +; I386-NEXT: # in Loop: Header=BB2_3 Depth=1 +; I386-NEXT: incl %ebp +; I386-NEXT: addb {{[0-9]+}}(%esp), %bl +; I386-NEXT: addl $-1, %edi +; I386-NEXT: adcl $-1, %esi +; I386-NEXT: movl %edi, %ecx +; I386-NEXT: orl %esi, %ecx +; I386-NEXT: jne .LBB2_3 +; I386-NEXT: jmp .LBB2_5 +; I386-NEXT: .LBB2_1: +; I386-NEXT: movb $1, %al +; I386-NEXT: xorl %ebx, %ebx +; I386-NEXT: .LBB2_5: # %bb15 +; I386-NEXT: testb %bl, %bl +; I386-NEXT: sete %cl +; I386-NEXT: andb %al, %cl +; I386-NEXT: movzbl %cl, %eax +; I386-NEXT: addl $12, %esp +; I386-NEXT: popl %esi +; I386-NEXT: popl %edi +; I386-NEXT: popl %ebx +; I386-NEXT: popl %ebp +; I386-NEXT: xorl %ecx, %ecx +; I386-NEXT: xorl %edx, %edx ; I386-NEXT: retl ; ; X86-64-LABEL: used_gpr: -; X86-64: # %bb.0: # %entry -; X86-64-NEXT: movl %edi, %eax +; X86-64: # %bb.0: # %bb +; X86-64-NEXT: pushq %rbp +; X86-64-NEXT: pushq %r15 +; X86-64-NEXT: pushq %r14 +; X86-64-NEXT: pushq %rbx +; X86-64-NEXT: pushq %rax +; X86-64-NEXT: movb $0, {{[0-9]+}}(%rsp) +; X86-64-NEXT: testq %rsi, %rsi +; X86-64-NEXT: je .LBB2_1 +; X86-64-NEXT: # %bb.2: # %bb3.preheader +; X86-64-NEXT: movq %rsi, %r14 +; X86-64-NEXT: movq %rdi, %rbx +; X86-64-NEXT: xorl %ebp, %ebp +; X86-64-NEXT: leaq {{[0-9]+}}(%rsp), %r15 +; X86-64-NEXT: .p2align 4, 0x90 +; X86-64-NEXT: .LBB2_3: # %bb3 +; X86-64-NEXT: # =>This Inner Loop Header: Depth=1 +; X86-64-NEXT: movl $1, %edx +; X86-64-NEXT: movq %r15, %rdi +; X86-64-NEXT: movq %rbx, %rsi +; X86-64-NEXT: callq g +; X86-64-NEXT: testq %rax, %rax +; X86-64-NEXT: sete %al +; X86-64-NEXT: jne .LBB2_5 +; X86-64-NEXT: # %bb.4: # %bb9 +; X86-64-NEXT: # in Loop: Header=BB2_3 Depth=1 +; X86-64-NEXT: incq %rbx +; X86-64-NEXT: addb {{[0-9]+}}(%rsp), %bpl +; X86-64-NEXT: decq %r14 +; X86-64-NEXT: jne .LBB2_3 +; X86-64-NEXT: jmp .LBB2_5 +; X86-64-NEXT: .LBB2_1: +; X86-64-NEXT: movb $1, %al +; X86-64-NEXT: xorl %ebp, %ebp +; X86-64-NEXT: .LBB2_5: # %bb15 +; X86-64-NEXT: testb %bpl, %bpl +; X86-64-NEXT: sete %cl +; X86-64-NEXT: andb %al, %cl +; X86-64-NEXT: movzbl %cl, %eax +; X86-64-NEXT: addq $8, %rsp +; X86-64-NEXT: popq %rbx +; X86-64-NEXT: popq %r14 +; X86-64-NEXT: popq %r15 +; X86-64-NEXT: popq %rbp +; X86-64-NEXT: xorl %ecx, %ecx ; X86-64-NEXT: xorl %edi, %edi +; X86-64-NEXT: xorl %edx, %edx +; X86-64-NEXT: xorl %esi, %esi ; X86-64-NEXT: retq +bb: + %i = alloca i8, align 1 + store i8 0, ptr %i, align 1 + %i2 = icmp eq i64 %arg1, 0 + br i1 %i2, label %bb15, label %bb3 -entry: - ret i32 %x +bb3: ; preds = %bb9, %bb + %i4 = phi ptr [ %i10, %bb9 ], [ %arg, %bb ] + %i5 = phi i64 [ %i13, %bb9 ], [ %arg1, %bb ] + %i6 = phi i8 [ %i12, %bb9 ], [ 0, %bb ] + %i7 = call i64 @g(ptr noundef nonnull %i, ptr noundef %i4, i64 noundef 1) + %i8 = icmp eq i64 %i7, 0 + br i1 %i8, label %bb9, label %bb15 + +bb9: ; preds = %bb3 + %i10 = getelementptr i8, ptr %i4, i64 1 + %i11 = load i8, ptr %i, align 1 + %i12 = add i8 %i11, %i6 + %i13 = add i64 %i5, -1 + %i14 = icmp eq i64 %i13, 0 + br i1 %i14, label %bb15, label %bb3 + +bb15: ; preds = %bb9, %bb3, %bb + %i16 = phi i8 [ 0, %bb ], [ %i12, %bb9 ], [ %i6, %bb3 ] + %i17 = phi i1 [ true, %bb ], [ %i8, %bb9 ], [ %i8, %bb3 ] + %i18 = icmp eq i8 %i16, 0 + %i19 = select i1 %i17, i1 %i18, i1 false + %i20 = zext i1 %i19 to i32 + ret i32 %i20 } -define dso_local i32 @used_arg(i32 returned %x) local_unnamed_addr #0 "zero-call-used-regs"="used-arg" { +define dso_local i32 @used_arg(ptr noundef %arg, i64 noundef %arg1) local_unnamed_addr #0 "zero-call-used-regs"="used-arg" { ; I386-LABEL: used_arg: -; I386: # %bb.0: # %entry -; I386-NEXT: movl {{[0-9]+}}(%esp), %eax +; I386: # %bb.0: # %bb +; I386-NEXT: pushl %ebp +; I386-NEXT: pushl %ebx +; I386-NEXT: pushl %edi +; I386-NEXT: pushl %esi +; I386-NEXT: subl $12, %esp +; I386-NEXT: movl {{[0-9]+}}(%esp), %esi +; I386-NEXT: movl {{[0-9]+}}(%esp), %edi +; I386-NEXT: movb $0, {{[0-9]+}}(%esp) +; I386-NEXT: movl %edi, %eax +; I386-NEXT: orl %esi, %eax +; I386-NEXT: je .LBB3_1 +; I386-NEXT: # %bb.2: # %bb3.preheader +; I386-NEXT: movl {{[0-9]+}}(%esp), %ebp +; I386-NEXT: xorl %ebx, %ebx +; I386-NEXT: .p2align 4, 0x90 +; I386-NEXT: .LBB3_3: # %bb3 +; I386-NEXT: # =>This Inner Loop Header: Depth=1 +; I386-NEXT: pushl $0 +; I386-NEXT: pushl $1 +; I386-NEXT: pushl %ebp +; I386-NEXT: leal {{[0-9]+}}(%esp), %eax +; I386-NEXT: pushl %eax +; I386-NEXT: calll g +; I386-NEXT: addl $16, %esp +; I386-NEXT: orl %eax, %edx +; I386-NEXT: sete %al +; I386-NEXT: jne .LBB3_5 +; I386-NEXT: # %bb.4: # %bb9 +; I386-NEXT: # in Loop: Header=BB3_3 Depth=1 +; I386-NEXT: incl %ebp +; I386-NEXT: addb {{[0-9]+}}(%esp), %bl +; I386-NEXT: addl $-1, %edi +; I386-NEXT: adcl $-1, %esi +; I386-NEXT: movl %edi, %ecx +; I386-NEXT: orl %esi, %ecx +; I386-NEXT: jne .LBB3_3 +; I386-NEXT: jmp .LBB3_5 +; I386-NEXT: .LBB3_1: +; I386-NEXT: movb $1, %al +; I386-NEXT: xorl %ebx, %ebx +; I386-NEXT: .LBB3_5: # %bb15 +; I386-NEXT: testb %bl, %bl +; I386-NEXT: sete %cl +; I386-NEXT: andb %al, %cl +; I386-NEXT: movzbl %cl, %eax +; I386-NEXT: addl $12, %esp +; I386-NEXT: popl %esi +; I386-NEXT: popl %edi +; I386-NEXT: popl %ebx +; I386-NEXT: popl %ebp ; I386-NEXT: retl ; ; X86-64-LABEL: used_arg: -; X86-64: # %bb.0: # %entry -; X86-64-NEXT: movl %edi, %eax +; X86-64: # %bb.0: # %bb +; X86-64-NEXT: pushq %rbp +; X86-64-NEXT: pushq %r15 +; X86-64-NEXT: pushq %r14 +; X86-64-NEXT: pushq %rbx +; X86-64-NEXT: pushq %rax +; X86-64-NEXT: movb $0, {{[0-9]+}}(%rsp) +; X86-64-NEXT: testq %rsi, %rsi +; X86-64-NEXT: je .LBB3_1 +; X86-64-NEXT: # %bb.2: # %bb3.preheader +; X86-64-NEXT: movq %rsi, %r14 +; X86-64-NEXT: movq %rdi, %rbx +; X86-64-NEXT: xorl %ebp, %ebp +; X86-64-NEXT: leaq {{[0-9]+}}(%rsp), %r15 +; X86-64-NEXT: .p2align 4, 0x90 +; X86-64-NEXT: .LBB3_3: # %bb3 +; X86-64-NEXT: # =>This Inner Loop Header: Depth=1 +; X86-64-NEXT: movl $1, %edx +; X86-64-NEXT: movq %r15, %rdi +; X86-64-NEXT: movq %rbx, %rsi +; X86-64-NEXT: callq g +; X86-64-NEXT: testq %rax, %rax +; X86-64-NEXT: sete %al +; X86-64-NEXT: jne .LBB3_5 +; X86-64-NEXT: # %bb.4: # %bb9 +; X86-64-NEXT: # in Loop: Header=BB3_3 Depth=1 +; X86-64-NEXT: incq %rbx +; X86-64-NEXT: addb {{[0-9]+}}(%rsp), %bpl +; X86-64-NEXT: decq %r14 +; X86-64-NEXT: jne .LBB3_3 +; X86-64-NEXT: jmp .LBB3_5 +; X86-64-NEXT: .LBB3_1: +; X86-64-NEXT: movb $1, %al +; X86-64-NEXT: xorl %ebp, %ebp +; X86-64-NEXT: .LBB3_5: # %bb15 +; X86-64-NEXT: testb %bpl, %bpl +; X86-64-NEXT: sete %cl +; X86-64-NEXT: andb %al, %cl +; X86-64-NEXT: movzbl %cl, %eax +; X86-64-NEXT: addq $8, %rsp +; X86-64-NEXT: popq %rbx +; X86-64-NEXT: popq %r14 +; X86-64-NEXT: popq %r15 +; X86-64-NEXT: popq %rbp ; X86-64-NEXT: xorl %edi, %edi +; X86-64-NEXT: xorl %esi, %esi ; X86-64-NEXT: retq +bb: + %i = alloca i8, align 1 + store i8 0, ptr %i, align 1 + %i2 = icmp eq i64 %arg1, 0 + br i1 %i2, label %bb15, label %bb3 -entry: - ret i32 %x +bb3: ; preds = %bb9, %bb + %i4 = phi ptr [ %i10, %bb9 ], [ %arg, %bb ] + %i5 = phi i64 [ %i13, %bb9 ], [ %arg1, %bb ] + %i6 = phi i8 [ %i12, %bb9 ], [ 0, %bb ] + %i7 = call i64 @g(ptr noundef nonnull %i, ptr noundef %i4, i64 noundef 1) + %i8 = icmp eq i64 %i7, 0 + br i1 %i8, label %bb9, label %bb15 + +bb9: ; preds = %bb3 + %i10 = getelementptr i8, ptr %i4, i64 1 + %i11 = load i8, ptr %i, align 1 + %i12 = add i8 %i11, %i6 + %i13 = add i64 %i5, -1 + %i14 = icmp eq i64 %i13, 0 + br i1 %i14, label %bb15, label %bb3 + +bb15: ; preds = %bb9, %bb3, %bb + %i16 = phi i8 [ 0, %bb ], [ %i12, %bb9 ], [ %i6, %bb3 ] + %i17 = phi i1 [ true, %bb ], [ %i8, %bb9 ], [ %i8, %bb3 ] + %i18 = icmp eq i8 %i16, 0 + %i19 = select i1 %i17, i1 %i18, i1 false + %i20 = zext i1 %i19 to i32 + ret i32 %i20 } -define dso_local i32 @used(i32 returned %x) local_unnamed_addr #0 "zero-call-used-regs"="used" { +define dso_local i32 @used(ptr noundef %arg, i64 noundef %arg1) local_unnamed_addr #0 "zero-call-used-regs"="used" { ; I386-LABEL: used: -; I386: # %bb.0: # %entry -; I386-NEXT: movl {{[0-9]+}}(%esp), %eax +; I386: # %bb.0: # %bb +; I386-NEXT: pushl %ebp +; I386-NEXT: pushl %ebx +; I386-NEXT: pushl %edi +; I386-NEXT: pushl %esi +; I386-NEXT: subl $12, %esp +; I386-NEXT: movl {{[0-9]+}}(%esp), %esi +; I386-NEXT: movl {{[0-9]+}}(%esp), %edi +; I386-NEXT: movb $0, {{[0-9]+}}(%esp) +; I386-NEXT: movl %edi, %eax +; I386-NEXT: orl %esi, %eax +; I386-NEXT: je .LBB4_1 +; I386-NEXT: # %bb.2: # %bb3.preheader +; I386-NEXT: movl {{[0-9]+}}(%esp), %ebp +; I386-NEXT: xorl %ebx, %ebx +; I386-NEXT: .p2align 4, 0x90 +; I386-NEXT: .LBB4_3: # %bb3 +; I386-NEXT: # =>This Inner Loop Header: Depth=1 +; I386-NEXT: pushl $0 +; I386-NEXT: pushl $1 +; I386-NEXT: pushl %ebp +; I386-NEXT: leal {{[0-9]+}}(%esp), %eax +; I386-NEXT: pushl %eax +; I386-NEXT: calll g +; I386-NEXT: addl $16, %esp +; I386-NEXT: orl %eax, %edx +; I386-NEXT: sete %al +; I386-NEXT: jne .LBB4_5 +; I386-NEXT: # %bb.4: # %bb9 +; I386-NEXT: # in Loop: Header=BB4_3 Depth=1 +; I386-NEXT: incl %ebp +; I386-NEXT: addb {{[0-9]+}}(%esp), %bl +; I386-NEXT: addl $-1, %edi +; I386-NEXT: adcl $-1, %esi +; I386-NEXT: movl %edi, %ecx +; I386-NEXT: orl %esi, %ecx +; I386-NEXT: jne .LBB4_3 +; I386-NEXT: jmp .LBB4_5 +; I386-NEXT: .LBB4_1: +; I386-NEXT: movb $1, %al +; I386-NEXT: xorl %ebx, %ebx +; I386-NEXT: .LBB4_5: # %bb15 +; I386-NEXT: testb %bl, %bl +; I386-NEXT: sete %cl +; I386-NEXT: andb %al, %cl +; I386-NEXT: movzbl %cl, %eax +; I386-NEXT: addl $12, %esp +; I386-NEXT: popl %esi +; I386-NEXT: popl %edi +; I386-NEXT: popl %ebx +; I386-NEXT: popl %ebp +; I386-NEXT: xorl %ecx, %ecx +; I386-NEXT: xorl %edx, %edx ; I386-NEXT: retl ; ; X86-64-LABEL: used: -; X86-64: # %bb.0: # %entry -; X86-64-NEXT: movl %edi, %eax +; X86-64: # %bb.0: # %bb +; X86-64-NEXT: pushq %rbp +; X86-64-NEXT: pushq %r15 +; X86-64-NEXT: pushq %r14 +; X86-64-NEXT: pushq %rbx +; X86-64-NEXT: pushq %rax +; X86-64-NEXT: movb $0, {{[0-9]+}}(%rsp) +; X86-64-NEXT: testq %rsi, %rsi +; X86-64-NEXT: je .LBB4_1 +; X86-64-NEXT: # %bb.2: # %bb3.preheader +; X86-64-NEXT: movq %rsi, %r14 +; X86-64-NEXT: movq %rdi, %rbx +; X86-64-NEXT: xorl %ebp, %ebp +; X86-64-NEXT: leaq {{[0-9]+}}(%rsp), %r15 +; X86-64-NEXT: .p2align 4, 0x90 +; X86-64-NEXT: .LBB4_3: # %bb3 +; X86-64-NEXT: # =>This Inner Loop Header: Depth=1 +; X86-64-NEXT: movl $1, %edx +; X86-64-NEXT: movq %r15, %rdi +; X86-64-NEXT: movq %rbx, %rsi +; X86-64-NEXT: callq g +; X86-64-NEXT: testq %rax, %rax +; X86-64-NEXT: sete %al +; X86-64-NEXT: jne .LBB4_5 +; X86-64-NEXT: # %bb.4: # %bb9 +; X86-64-NEXT: # in Loop: Header=BB4_3 Depth=1 +; X86-64-NEXT: incq %rbx +; X86-64-NEXT: addb {{[0-9]+}}(%rsp), %bpl +; X86-64-NEXT: decq %r14 +; X86-64-NEXT: jne .LBB4_3 +; X86-64-NEXT: jmp .LBB4_5 +; X86-64-NEXT: .LBB4_1: +; X86-64-NEXT: movb $1, %al +; X86-64-NEXT: xorl %ebp, %ebp +; X86-64-NEXT: .LBB4_5: # %bb15 +; X86-64-NEXT: testb %bpl, %bpl +; X86-64-NEXT: sete %cl +; X86-64-NEXT: andb %al, %cl +; X86-64-NEXT: movzbl %cl, %eax +; X86-64-NEXT: addq $8, %rsp +; X86-64-NEXT: popq %rbx +; X86-64-NEXT: popq %r14 +; X86-64-NEXT: popq %r15 +; X86-64-NEXT: popq %rbp +; X86-64-NEXT: xorl %ecx, %ecx ; X86-64-NEXT: xorl %edi, %edi +; X86-64-NEXT: xorl %edx, %edx +; X86-64-NEXT: xorl %esi, %esi ; X86-64-NEXT: retq +bb: + %i = alloca i8, align 1 + store i8 0, ptr %i, align 1 + %i2 = icmp eq i64 %arg1, 0 + br i1 %i2, label %bb15, label %bb3 -entry: - ret i32 %x +bb3: ; preds = %bb9, %bb + %i4 = phi ptr [ %i10, %bb9 ], [ %arg, %bb ] + %i5 = phi i64 [ %i13, %bb9 ], [ %arg1, %bb ] + %i6 = phi i8 [ %i12, %bb9 ], [ 0, %bb ] + %i7 = call i64 @g(ptr noundef nonnull %i, ptr noundef %i4, i64 noundef 1) + %i8 = icmp eq i64 %i7, 0 + br i1 %i8, label %bb9, label %bb15 + +bb9: ; preds = %bb3 + %i10 = getelementptr i8, ptr %i4, i64 1 + %i11 = load i8, ptr %i, align 1 + %i12 = add i8 %i11, %i6 + %i13 = add i64 %i5, -1 + %i14 = icmp eq i64 %i13, 0 + br i1 %i14, label %bb15, label %bb3 + +bb15: ; preds = %bb9, %bb3, %bb + %i16 = phi i8 [ 0, %bb ], [ %i12, %bb9 ], [ %i6, %bb3 ] + %i17 = phi i1 [ true, %bb ], [ %i8, %bb9 ], [ %i8, %bb3 ] + %i18 = icmp eq i8 %i16, 0 + %i19 = select i1 %i17, i1 %i18, i1 false + %i20 = zext i1 %i19 to i32 + ret i32 %i20 } define dso_local i32 @all_gpr_arg(i32 returned %x) local_unnamed_addr #0 "zero-call-used-regs"="all-gpr-arg" { @@ -277,5 +876,5 @@ ret i32 0 } -attributes #0 = { mustprogress nofree norecurse nosync nounwind readnone uwtable willreturn "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } -attributes #1 = { nofree norecurse nounwind uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #0 = { mustprogress nofree norecurse nosync nounwind readnone willreturn "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } +attributes #1 = { nofree norecurse nounwind "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }