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 @@ -2,85 +2,628 @@ ; RUN: llc < %s -mtriple=i386-unknown-linux-gnu | FileCheck %s --check-prefix=I386 ; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu | FileCheck %s --check-prefix=X86-64 -@result = dso_local global i32 0, align 4 +%struct.paravirt_patch_template = type { %struct.pv_cpu_ops, %struct.pv_irq_ops, %struct.pv_mmu_ops, %struct.pv_lock_ops } +%struct.pv_cpu_ops = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr } +%struct.pv_irq_ops = type { %struct.paravirt_callee_save, %struct.paravirt_callee_save, %struct.paravirt_callee_save, ptr, ptr } +%struct.paravirt_callee_save = type { ptr } +%struct.pv_mmu_ops = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, %struct.paravirt_callee_save, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, %struct.paravirt_callee_save, %struct.paravirt_callee_save, %struct.paravirt_callee_save, %struct.paravirt_callee_save, ptr, %struct.paravirt_callee_save, %struct.paravirt_callee_save, %struct.paravirt_callee_save, %struct.paravirt_callee_save, ptr, %struct.pv_lazy_ops, ptr } +%struct.pv_lazy_ops = type { ptr, ptr, ptr } +%struct.pv_lock_ops = type { ptr, %struct.paravirt_callee_save, ptr, ptr, %struct.paravirt_callee_save } +%struct.anon.95 = type <{ i8, i32 }> -define dso_local i32 @skip(i32 returned %x) local_unnamed_addr #0 "zero-call-used-regs"="skip" { +@pv_ops = external dso_local global %struct.paravirt_patch_template, align 8 + +declare dso_local void @g() + +declare dso_local void @h() + +define dso_local i32 @skip(i8 noundef zeroext %arg, ptr noundef writeonly %arg1, i64 noundef %arg2, i32 noundef %arg3) local_unnamed_addr #0 "zero-call-used-regs"="skip" { ; I386-LABEL: skip: -; I386: # %bb.0: # %entry +; I386: # %bb.0: # %bb +; I386-NEXT: movl {{[0-9]+}}(%esp), %ecx ; I386-NEXT: movl {{[0-9]+}}(%esp), %eax +; I386-NEXT: movzbl {{[0-9]+}}(%esp), %edx +; I386-NEXT: movl pv_ops(,%edx,4), %edx +; I386-NEXT: testl %edx, %edx +; I386-NEXT: je .LBB0_1 +; I386-NEXT: # %bb.2: # %bb12 +; I386-NEXT: cmpl $h, %edx +; I386-NEXT: je .LBB0_3 +; I386-NEXT: # %bb.4: # %bb14 +; I386-NEXT: #APP +; I386-NEXT: #NO_APP +; I386-NEXT: #APP +; I386-NEXT: #NO_APP +; I386-NEXT: #APP +; I386-NEXT: #NO_APP +; I386-NEXT: jmp .LBB0_5 +; I386-NEXT: .LBB0_1: # %bb7 +; I386-NEXT: #APP +; I386-NEXT: #NO_APP +; I386-NEXT: #APP +; I386-NEXT: #NO_APP +; I386-NEXT: movl $g, %edx +; I386-NEXT: #APP +; I386-NEXT: #NO_APP +; I386-NEXT: .LBB0_5: # %bb19 +; I386-NEXT: subl %ecx, %edx +; I386-NEXT: movb $-24, (%eax) +; I386-NEXT: addl $-5, %edx +; I386-NEXT: movl %edx, 1(%eax) +; I386-NEXT: movl $5, %eax +; I386-NEXT: retl +; I386-NEXT: .LBB0_3: +; I386-NEXT: xorl %eax, %eax ; I386-NEXT: retl ; ; X86-64-LABEL: skip: -; X86-64: # %bb.0: # %entry +; X86-64: # %bb.0: # %bb ; X86-64-NEXT: movl %edi, %eax +; X86-64-NEXT: movq pv_ops(,%rax,8), %rax +; X86-64-NEXT: testq %rax, %rax +; X86-64-NEXT: je .LBB0_1 +; X86-64-NEXT: # %bb.2: # %bb12 +; X86-64-NEXT: cmpq $h, %rax +; X86-64-NEXT: je .LBB0_3 +; X86-64-NEXT: # %bb.4: # %bb14 +; X86-64-NEXT: #APP +; X86-64-NEXT: #NO_APP +; X86-64-NEXT: #APP +; X86-64-NEXT: #NO_APP +; X86-64-NEXT: #APP +; X86-64-NEXT: #NO_APP +; X86-64-NEXT: jmp .LBB0_5 +; X86-64-NEXT: .LBB0_1: # %bb7 +; X86-64-NEXT: #APP +; X86-64-NEXT: #NO_APP +; X86-64-NEXT: #APP +; X86-64-NEXT: #NO_APP +; X86-64-NEXT: movl $g, %eax +; X86-64-NEXT: #APP +; X86-64-NEXT: #NO_APP +; X86-64-NEXT: .LBB0_5: # %bb19 +; X86-64-NEXT: movb $-24, (%rsi) +; X86-64-NEXT: subl %edx, %eax +; X86-64-NEXT: addl $-5, %eax +; X86-64-NEXT: movl %eax, 1(%rsi) +; X86-64-NEXT: movl $5, %eax +; X86-64-NEXT: retq +; X86-64-NEXT: .LBB0_3: +; X86-64-NEXT: xorl %eax, %eax ; X86-64-NEXT: retq -entry: - ret i32 %x +bb: + %i = zext i8 %arg to i64 + %i4 = getelementptr ptr, ptr @pv_ops, i64 %i + %i5 = load ptr, ptr %i4, align 8 + %i6 = icmp eq ptr %i5, null + br i1 %i6, label %bb7, label %bb12 + +bb7: ; preds = %bb + %i8 = inttoptr i64 %arg2 to ptr + %i9 = tail call ptr asm "", "=r,0,~{dirflag},~{fpsr},~{flags}"(ptr %arg1) #3 + %i10 = tail call ptr asm "", "=r,0,~{dirflag},~{fpsr},~{flags}"(ptr %i8) #3 + %i11 = tail call ptr asm "", "=r,0,~{dirflag},~{fpsr},~{flags}"(ptr nonnull @g) #3 + br label %bb19 + +bb12: ; preds = %bb + %i13 = icmp eq ptr %i5, @h + br i1 %i13, label %bb29, label %bb14 + +bb14: ; preds = %bb12 + %i15 = inttoptr i64 %arg2 to ptr + %i16 = tail call ptr asm "", "=r,0,~{dirflag},~{fpsr},~{flags}"(ptr %arg1) #3 + %i17 = tail call ptr asm "", "=r,0,~{dirflag},~{fpsr},~{flags}"(ptr %i15) #3 + %i18 = tail call ptr asm "", "=r,0,~{dirflag},~{fpsr},~{flags}"(ptr nonnull %i5) #3 + br label %bb19 + +bb19: ; preds = %bb14, %bb7 + %i20 = phi ptr [ %i16, %bb14 ], [ %i9, %bb7 ] + %i21 = phi ptr [ %i18, %bb14 ], [ %i11, %bb7 ] + %i22 = phi ptr [ %i17, %bb14 ], [ %i10, %bb7 ] + store i8 -24, ptr %i20, align 1 + %i23 = ptrtoint ptr %i21 to i64 + %i24 = getelementptr i8, ptr %i22, i64 5 + %i25 = ptrtoint ptr %i24 to i64 + %i26 = sub i64 %i23, %i25 + %i27 = trunc i64 %i26 to i32 + %i28 = getelementptr inbounds %struct.anon.95, ptr %i20, i64 0, i32 1 + store i32 %i27, ptr %i28, align 1 + br label %bb29 + +bb29: ; preds = %bb19, %bb12 + %i30 = phi i32 [ 0, %bb12 ], [ 5, %bb19 ] + ret i32 %i30 } -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(i8 noundef zeroext %arg, ptr noundef writeonly %arg1, i64 noundef %arg2, i32 noundef %arg3) local_unnamed_addr #0 "zero-call-used-regs"="used-gpr-arg" { ; I386-LABEL: used_gpr_arg: -; I386: # %bb.0: # %entry +; I386: # %bb.0: # %bb +; I386-NEXT: movl {{[0-9]+}}(%esp), %ecx ; I386-NEXT: movl {{[0-9]+}}(%esp), %eax +; I386-NEXT: movzbl {{[0-9]+}}(%esp), %edx +; I386-NEXT: movl pv_ops(,%edx,4), %edx +; I386-NEXT: testl %edx, %edx +; I386-NEXT: je .LBB1_1 +; I386-NEXT: # %bb.2: # %bb12 +; I386-NEXT: cmpl $h, %edx +; I386-NEXT: je .LBB1_3 +; I386-NEXT: # %bb.4: # %bb14 +; I386-NEXT: #APP +; I386-NEXT: #NO_APP +; I386-NEXT: #APP +; I386-NEXT: #NO_APP +; I386-NEXT: #APP +; I386-NEXT: #NO_APP +; I386-NEXT: jmp .LBB1_5 +; I386-NEXT: .LBB1_1: # %bb7 +; I386-NEXT: #APP +; I386-NEXT: #NO_APP +; I386-NEXT: #APP +; I386-NEXT: #NO_APP +; I386-NEXT: movl $g, %edx +; I386-NEXT: #APP +; I386-NEXT: #NO_APP +; I386-NEXT: .LBB1_5: # %bb19 +; I386-NEXT: subl %ecx, %edx +; I386-NEXT: movb $-24, (%eax) +; I386-NEXT: addl $-5, %edx +; I386-NEXT: movl %edx, 1(%eax) +; I386-NEXT: movl $5, %eax +; I386-NEXT: retl +; I386-NEXT: .LBB1_3: +; I386-NEXT: xorl %eax, %eax ; I386-NEXT: retl ; ; X86-64-LABEL: used_gpr_arg: -; X86-64: # %bb.0: # %entry +; X86-64: # %bb.0: # %bb ; X86-64-NEXT: movl %edi, %eax -; X86-64-NEXT: xorl %edi, %edi +; X86-64-NEXT: movq pv_ops(,%rax,8), %rax +; X86-64-NEXT: testq %rax, %rax +; X86-64-NEXT: je .LBB1_1 +; X86-64-NEXT: # %bb.2: # %bb12 +; X86-64-NEXT: cmpq $h, %rax +; X86-64-NEXT: je .LBB1_3 +; X86-64-NEXT: # %bb.4: # %bb14 +; X86-64-NEXT: #APP +; X86-64-NEXT: #NO_APP +; X86-64-NEXT: #APP +; X86-64-NEXT: #NO_APP +; X86-64-NEXT: #APP +; X86-64-NEXT: #NO_APP +; X86-64-NEXT: jmp .LBB1_5 +; X86-64-NEXT: .LBB1_1: # %bb7 +; X86-64-NEXT: #APP +; X86-64-NEXT: #NO_APP +; X86-64-NEXT: #APP +; X86-64-NEXT: #NO_APP +; X86-64-NEXT: movl $g, %eax +; X86-64-NEXT: #APP +; X86-64-NEXT: #NO_APP +; X86-64-NEXT: .LBB1_5: # %bb19 +; X86-64-NEXT: movb $-24, (%rsi) +; X86-64-NEXT: subl %edx, %eax +; X86-64-NEXT: addl $-5, %eax +; X86-64-NEXT: movl %eax, 1(%rsi) +; X86-64-NEXT: movl $5, %eax +; X86-64-NEXT: jmp .LBB1_6 +; X86-64-NEXT: .LBB1_3: +; X86-64-NEXT: xorl %eax, %eax +; X86-64-NEXT: .LBB1_6: # %bb29 +; X86-64-NEXT: xorl %edx, %edx +; X86-64-NEXT: xorl %esi, %esi ; X86-64-NEXT: retq +bb: + %i = zext i8 %arg to i64 + %i4 = getelementptr ptr, ptr @pv_ops, i64 %i + %i5 = load ptr, ptr %i4, align 8 + %i6 = icmp eq ptr %i5, null + br i1 %i6, label %bb7, label %bb12 -entry: - ret i32 %x +bb7: ; preds = %bb + %i8 = inttoptr i64 %arg2 to ptr + %i9 = tail call ptr asm "", "=r,0,~{dirflag},~{fpsr},~{flags}"(ptr %arg1) #3 + %i10 = tail call ptr asm "", "=r,0,~{dirflag},~{fpsr},~{flags}"(ptr %i8) #3 + %i11 = tail call ptr asm "", "=r,0,~{dirflag},~{fpsr},~{flags}"(ptr nonnull @g) #3 + br label %bb19 + +bb12: ; preds = %bb + %i13 = icmp eq ptr %i5, @h + br i1 %i13, label %bb29, label %bb14 + +bb14: ; preds = %bb12 + %i15 = inttoptr i64 %arg2 to ptr + %i16 = tail call ptr asm "", "=r,0,~{dirflag},~{fpsr},~{flags}"(ptr %arg1) #3 + %i17 = tail call ptr asm "", "=r,0,~{dirflag},~{fpsr},~{flags}"(ptr %i15) #3 + %i18 = tail call ptr asm "", "=r,0,~{dirflag},~{fpsr},~{flags}"(ptr nonnull %i5) #3 + br label %bb19 + +bb19: ; preds = %bb14, %bb7 + %i20 = phi ptr [ %i16, %bb14 ], [ %i9, %bb7 ] + %i21 = phi ptr [ %i18, %bb14 ], [ %i11, %bb7 ] + %i22 = phi ptr [ %i17, %bb14 ], [ %i10, %bb7 ] + store i8 -24, ptr %i20, align 1 + %i23 = ptrtoint ptr %i21 to i64 + %i24 = getelementptr i8, ptr %i22, i64 5 + %i25 = ptrtoint ptr %i24 to i64 + %i26 = sub i64 %i23, %i25 + %i27 = trunc i64 %i26 to i32 + %i28 = getelementptr inbounds %struct.anon.95, ptr %i20, i64 0, i32 1 + store i32 %i27, ptr %i28, align 1 + br label %bb29 + +bb29: ; preds = %bb19, %bb12 + %i30 = phi i32 [ 0, %bb12 ], [ 5, %bb19 ] + ret i32 %i30 } -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(i8 noundef zeroext %arg, ptr noundef writeonly %arg1, i64 noundef %arg2, i32 noundef %arg3) local_unnamed_addr #0 "zero-call-used-regs"="used-gpr" { ; I386-LABEL: used_gpr: -; I386: # %bb.0: # %entry +; I386: # %bb.0: # %bb +; I386-NEXT: movl {{[0-9]+}}(%esp), %ecx ; I386-NEXT: movl {{[0-9]+}}(%esp), %eax +; I386-NEXT: movzbl {{[0-9]+}}(%esp), %edx +; I386-NEXT: movl pv_ops(,%edx,4), %edx +; I386-NEXT: testl %edx, %edx +; I386-NEXT: je .LBB2_1 +; I386-NEXT: # %bb.2: # %bb12 +; I386-NEXT: cmpl $h, %edx +; I386-NEXT: je .LBB2_3 +; I386-NEXT: # %bb.4: # %bb14 +; I386-NEXT: #APP +; I386-NEXT: #NO_APP +; I386-NEXT: #APP +; I386-NEXT: #NO_APP +; I386-NEXT: #APP +; I386-NEXT: #NO_APP +; I386-NEXT: jmp .LBB2_5 +; I386-NEXT: .LBB2_1: # %bb7 +; I386-NEXT: #APP +; I386-NEXT: #NO_APP +; I386-NEXT: #APP +; I386-NEXT: #NO_APP +; I386-NEXT: movl $g, %edx +; I386-NEXT: #APP +; I386-NEXT: #NO_APP +; I386-NEXT: .LBB2_5: # %bb19 +; I386-NEXT: subl %ecx, %edx +; I386-NEXT: movb $-24, (%eax) +; I386-NEXT: addl $-5, %edx +; I386-NEXT: movl %edx, 1(%eax) +; I386-NEXT: movl $5, %eax +; I386-NEXT: jmp .LBB2_6 +; I386-NEXT: .LBB2_3: +; I386-NEXT: xorl %eax, %eax +; I386-NEXT: .LBB2_6: # %bb29 +; 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: # %bb.0: # %bb ; X86-64-NEXT: movl %edi, %eax -; X86-64-NEXT: xorl %edi, %edi +; X86-64-NEXT: movq pv_ops(,%rax,8), %rax +; X86-64-NEXT: testq %rax, %rax +; X86-64-NEXT: je .LBB2_1 +; X86-64-NEXT: # %bb.2: # %bb12 +; X86-64-NEXT: cmpq $h, %rax +; X86-64-NEXT: je .LBB2_3 +; X86-64-NEXT: # %bb.4: # %bb14 +; X86-64-NEXT: #APP +; X86-64-NEXT: #NO_APP +; X86-64-NEXT: #APP +; X86-64-NEXT: #NO_APP +; X86-64-NEXT: #APP +; X86-64-NEXT: #NO_APP +; X86-64-NEXT: jmp .LBB2_5 +; X86-64-NEXT: .LBB2_1: # %bb7 +; X86-64-NEXT: #APP +; X86-64-NEXT: #NO_APP +; X86-64-NEXT: #APP +; X86-64-NEXT: #NO_APP +; X86-64-NEXT: movl $g, %eax +; X86-64-NEXT: #APP +; X86-64-NEXT: #NO_APP +; X86-64-NEXT: .LBB2_5: # %bb19 +; X86-64-NEXT: movb $-24, (%rsi) +; X86-64-NEXT: subl %edx, %eax +; X86-64-NEXT: addl $-5, %eax +; X86-64-NEXT: movl %eax, 1(%rsi) +; X86-64-NEXT: movl $5, %eax +; X86-64-NEXT: jmp .LBB2_6 +; X86-64-NEXT: .LBB2_3: +; X86-64-NEXT: xorl %eax, %eax +; X86-64-NEXT: .LBB2_6: # %bb29 +; X86-64-NEXT: xorl %edx, %edx +; X86-64-NEXT: xorl %esi, %esi ; X86-64-NEXT: retq +bb: + %i = zext i8 %arg to i64 + %i4 = getelementptr ptr, ptr @pv_ops, i64 %i + %i5 = load ptr, ptr %i4, align 8 + %i6 = icmp eq ptr %i5, null + br i1 %i6, label %bb7, label %bb12 -entry: - ret i32 %x +bb7: ; preds = %bb + %i8 = inttoptr i64 %arg2 to ptr + %i9 = tail call ptr asm "", "=r,0,~{dirflag},~{fpsr},~{flags}"(ptr %arg1) #3 + %i10 = tail call ptr asm "", "=r,0,~{dirflag},~{fpsr},~{flags}"(ptr %i8) #3 + %i11 = tail call ptr asm "", "=r,0,~{dirflag},~{fpsr},~{flags}"(ptr nonnull @g) #3 + br label %bb19 + +bb12: ; preds = %bb + %i13 = icmp eq ptr %i5, @h + br i1 %i13, label %bb29, label %bb14 + +bb14: ; preds = %bb12 + %i15 = inttoptr i64 %arg2 to ptr + %i16 = tail call ptr asm "", "=r,0,~{dirflag},~{fpsr},~{flags}"(ptr %arg1) #3 + %i17 = tail call ptr asm "", "=r,0,~{dirflag},~{fpsr},~{flags}"(ptr %i15) #3 + %i18 = tail call ptr asm "", "=r,0,~{dirflag},~{fpsr},~{flags}"(ptr nonnull %i5) #3 + br label %bb19 + +bb19: ; preds = %bb14, %bb7 + %i20 = phi ptr [ %i16, %bb14 ], [ %i9, %bb7 ] + %i21 = phi ptr [ %i18, %bb14 ], [ %i11, %bb7 ] + %i22 = phi ptr [ %i17, %bb14 ], [ %i10, %bb7 ] + store i8 -24, ptr %i20, align 1 + %i23 = ptrtoint ptr %i21 to i64 + %i24 = getelementptr i8, ptr %i22, i64 5 + %i25 = ptrtoint ptr %i24 to i64 + %i26 = sub i64 %i23, %i25 + %i27 = trunc i64 %i26 to i32 + %i28 = getelementptr inbounds %struct.anon.95, ptr %i20, i64 0, i32 1 + store i32 %i27, ptr %i28, align 1 + br label %bb29 + +bb29: ; preds = %bb19, %bb12 + %i30 = phi i32 [ 0, %bb12 ], [ 5, %bb19 ] + ret i32 %i30 } -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(i8 noundef zeroext %arg, ptr noundef writeonly %arg1, i64 noundef %arg2, i32 noundef %arg3) local_unnamed_addr #0 "zero-call-used-regs"="used-arg" { ; I386-LABEL: used_arg: -; I386: # %bb.0: # %entry +; I386: # %bb.0: # %bb +; I386-NEXT: movl {{[0-9]+}}(%esp), %ecx ; I386-NEXT: movl {{[0-9]+}}(%esp), %eax +; I386-NEXT: movzbl {{[0-9]+}}(%esp), %edx +; I386-NEXT: movl pv_ops(,%edx,4), %edx +; I386-NEXT: testl %edx, %edx +; I386-NEXT: je .LBB3_1 +; I386-NEXT: # %bb.2: # %bb12 +; I386-NEXT: cmpl $h, %edx +; I386-NEXT: je .LBB3_3 +; I386-NEXT: # %bb.4: # %bb14 +; I386-NEXT: #APP +; I386-NEXT: #NO_APP +; I386-NEXT: #APP +; I386-NEXT: #NO_APP +; I386-NEXT: #APP +; I386-NEXT: #NO_APP +; I386-NEXT: jmp .LBB3_5 +; I386-NEXT: .LBB3_1: # %bb7 +; I386-NEXT: #APP +; I386-NEXT: #NO_APP +; I386-NEXT: #APP +; I386-NEXT: #NO_APP +; I386-NEXT: movl $g, %edx +; I386-NEXT: #APP +; I386-NEXT: #NO_APP +; I386-NEXT: .LBB3_5: # %bb19 +; I386-NEXT: subl %ecx, %edx +; I386-NEXT: movb $-24, (%eax) +; I386-NEXT: addl $-5, %edx +; I386-NEXT: movl %edx, 1(%eax) +; I386-NEXT: movl $5, %eax +; I386-NEXT: retl +; I386-NEXT: .LBB3_3: +; I386-NEXT: xorl %eax, %eax ; I386-NEXT: retl ; ; X86-64-LABEL: used_arg: -; X86-64: # %bb.0: # %entry +; X86-64: # %bb.0: # %bb ; X86-64-NEXT: movl %edi, %eax -; X86-64-NEXT: xorl %edi, %edi +; X86-64-NEXT: movq pv_ops(,%rax,8), %rax +; X86-64-NEXT: testq %rax, %rax +; X86-64-NEXT: je .LBB3_1 +; X86-64-NEXT: # %bb.2: # %bb12 +; X86-64-NEXT: cmpq $h, %rax +; X86-64-NEXT: je .LBB3_3 +; X86-64-NEXT: # %bb.4: # %bb14 +; X86-64-NEXT: #APP +; X86-64-NEXT: #NO_APP +; X86-64-NEXT: #APP +; X86-64-NEXT: #NO_APP +; X86-64-NEXT: #APP +; X86-64-NEXT: #NO_APP +; X86-64-NEXT: jmp .LBB3_5 +; X86-64-NEXT: .LBB3_1: # %bb7 +; X86-64-NEXT: #APP +; X86-64-NEXT: #NO_APP +; X86-64-NEXT: #APP +; X86-64-NEXT: #NO_APP +; X86-64-NEXT: movl $g, %eax +; X86-64-NEXT: #APP +; X86-64-NEXT: #NO_APP +; X86-64-NEXT: .LBB3_5: # %bb19 +; X86-64-NEXT: movb $-24, (%rsi) +; X86-64-NEXT: subl %edx, %eax +; X86-64-NEXT: addl $-5, %eax +; X86-64-NEXT: movl %eax, 1(%rsi) +; X86-64-NEXT: movl $5, %eax +; X86-64-NEXT: jmp .LBB3_6 +; X86-64-NEXT: .LBB3_3: +; X86-64-NEXT: xorl %eax, %eax +; X86-64-NEXT: .LBB3_6: # %bb29 +; X86-64-NEXT: xorl %edx, %edx +; X86-64-NEXT: xorl %esi, %esi ; X86-64-NEXT: retq +bb: + %i = zext i8 %arg to i64 + %i4 = getelementptr ptr, ptr @pv_ops, i64 %i + %i5 = load ptr, ptr %i4, align 8 + %i6 = icmp eq ptr %i5, null + br i1 %i6, label %bb7, label %bb12 -entry: - ret i32 %x +bb7: ; preds = %bb + %i8 = inttoptr i64 %arg2 to ptr + %i9 = tail call ptr asm "", "=r,0,~{dirflag},~{fpsr},~{flags}"(ptr %arg1) #3 + %i10 = tail call ptr asm "", "=r,0,~{dirflag},~{fpsr},~{flags}"(ptr %i8) #3 + %i11 = tail call ptr asm "", "=r,0,~{dirflag},~{fpsr},~{flags}"(ptr nonnull @g) #3 + br label %bb19 + +bb12: ; preds = %bb + %i13 = icmp eq ptr %i5, @h + br i1 %i13, label %bb29, label %bb14 + +bb14: ; preds = %bb12 + %i15 = inttoptr i64 %arg2 to ptr + %i16 = tail call ptr asm "", "=r,0,~{dirflag},~{fpsr},~{flags}"(ptr %arg1) #3 + %i17 = tail call ptr asm "", "=r,0,~{dirflag},~{fpsr},~{flags}"(ptr %i15) #3 + %i18 = tail call ptr asm "", "=r,0,~{dirflag},~{fpsr},~{flags}"(ptr nonnull %i5) #3 + br label %bb19 + +bb19: ; preds = %bb14, %bb7 + %i20 = phi ptr [ %i16, %bb14 ], [ %i9, %bb7 ] + %i21 = phi ptr [ %i18, %bb14 ], [ %i11, %bb7 ] + %i22 = phi ptr [ %i17, %bb14 ], [ %i10, %bb7 ] + store i8 -24, ptr %i20, align 1 + %i23 = ptrtoint ptr %i21 to i64 + %i24 = getelementptr i8, ptr %i22, i64 5 + %i25 = ptrtoint ptr %i24 to i64 + %i26 = sub i64 %i23, %i25 + %i27 = trunc i64 %i26 to i32 + %i28 = getelementptr inbounds %struct.anon.95, ptr %i20, i64 0, i32 1 + store i32 %i27, ptr %i28, align 1 + br label %bb29 + +bb29: ; preds = %bb19, %bb12 + %i30 = phi i32 [ 0, %bb12 ], [ 5, %bb19 ] + ret i32 %i30 } -define dso_local i32 @used(i32 returned %x) local_unnamed_addr #0 "zero-call-used-regs"="used" { +define dso_local i32 @used(i8 noundef zeroext %arg, ptr noundef writeonly %arg1, i64 noundef %arg2, i32 noundef %arg3) local_unnamed_addr #0 "zero-call-used-regs"="used" { ; I386-LABEL: used: -; I386: # %bb.0: # %entry +; I386: # %bb.0: # %bb +; I386-NEXT: movl {{[0-9]+}}(%esp), %ecx ; I386-NEXT: movl {{[0-9]+}}(%esp), %eax +; I386-NEXT: movzbl {{[0-9]+}}(%esp), %edx +; I386-NEXT: movl pv_ops(,%edx,4), %edx +; I386-NEXT: testl %edx, %edx +; I386-NEXT: je .LBB4_1 +; I386-NEXT: # %bb.2: # %bb12 +; I386-NEXT: cmpl $h, %edx +; I386-NEXT: je .LBB4_3 +; I386-NEXT: # %bb.4: # %bb14 +; I386-NEXT: #APP +; I386-NEXT: #NO_APP +; I386-NEXT: #APP +; I386-NEXT: #NO_APP +; I386-NEXT: #APP +; I386-NEXT: #NO_APP +; I386-NEXT: jmp .LBB4_5 +; I386-NEXT: .LBB4_1: # %bb7 +; I386-NEXT: #APP +; I386-NEXT: #NO_APP +; I386-NEXT: #APP +; I386-NEXT: #NO_APP +; I386-NEXT: movl $g, %edx +; I386-NEXT: #APP +; I386-NEXT: #NO_APP +; I386-NEXT: .LBB4_5: # %bb19 +; I386-NEXT: subl %ecx, %edx +; I386-NEXT: movb $-24, (%eax) +; I386-NEXT: addl $-5, %edx +; I386-NEXT: movl %edx, 1(%eax) +; I386-NEXT: movl $5, %eax +; I386-NEXT: jmp .LBB4_6 +; I386-NEXT: .LBB4_3: +; I386-NEXT: xorl %eax, %eax +; I386-NEXT: .LBB4_6: # %bb29 +; I386-NEXT: xorl %ecx, %ecx +; I386-NEXT: xorl %edx, %edx ; I386-NEXT: retl ; ; X86-64-LABEL: used: -; X86-64: # %bb.0: # %entry +; X86-64: # %bb.0: # %bb ; X86-64-NEXT: movl %edi, %eax -; X86-64-NEXT: xorl %edi, %edi +; X86-64-NEXT: movq pv_ops(,%rax,8), %rax +; X86-64-NEXT: testq %rax, %rax +; X86-64-NEXT: je .LBB4_1 +; X86-64-NEXT: # %bb.2: # %bb12 +; X86-64-NEXT: cmpq $h, %rax +; X86-64-NEXT: je .LBB4_3 +; X86-64-NEXT: # %bb.4: # %bb14 +; X86-64-NEXT: #APP +; X86-64-NEXT: #NO_APP +; X86-64-NEXT: #APP +; X86-64-NEXT: #NO_APP +; X86-64-NEXT: #APP +; X86-64-NEXT: #NO_APP +; X86-64-NEXT: jmp .LBB4_5 +; X86-64-NEXT: .LBB4_1: # %bb7 +; X86-64-NEXT: #APP +; X86-64-NEXT: #NO_APP +; X86-64-NEXT: #APP +; X86-64-NEXT: #NO_APP +; X86-64-NEXT: movl $g, %eax +; X86-64-NEXT: #APP +; X86-64-NEXT: #NO_APP +; X86-64-NEXT: .LBB4_5: # %bb19 +; X86-64-NEXT: movb $-24, (%rsi) +; X86-64-NEXT: subl %edx, %eax +; X86-64-NEXT: addl $-5, %eax +; X86-64-NEXT: movl %eax, 1(%rsi) +; X86-64-NEXT: movl $5, %eax +; X86-64-NEXT: jmp .LBB4_6 +; X86-64-NEXT: .LBB4_3: +; X86-64-NEXT: xorl %eax, %eax +; X86-64-NEXT: .LBB4_6: # %bb29 +; X86-64-NEXT: xorl %edx, %edx +; X86-64-NEXT: xorl %esi, %esi ; X86-64-NEXT: retq +bb: + %i = zext i8 %arg to i64 + %i4 = getelementptr ptr, ptr @pv_ops, i64 %i + %i5 = load ptr, ptr %i4, align 8 + %i6 = icmp eq ptr %i5, null + br i1 %i6, label %bb7, label %bb12 -entry: - ret i32 %x +bb7: ; preds = %bb + %i8 = inttoptr i64 %arg2 to ptr + %i9 = tail call ptr asm "", "=r,0,~{dirflag},~{fpsr},~{flags}"(ptr %arg1) #3 + %i10 = tail call ptr asm "", "=r,0,~{dirflag},~{fpsr},~{flags}"(ptr %i8) #3 + %i11 = tail call ptr asm "", "=r,0,~{dirflag},~{fpsr},~{flags}"(ptr nonnull @g) #3 + br label %bb19 + +bb12: ; preds = %bb + %i13 = icmp eq ptr %i5, @h + br i1 %i13, label %bb29, label %bb14 + +bb14: ; preds = %bb12 + %i15 = inttoptr i64 %arg2 to ptr + %i16 = tail call ptr asm "", "=r,0,~{dirflag},~{fpsr},~{flags}"(ptr %arg1) #3 + %i17 = tail call ptr asm "", "=r,0,~{dirflag},~{fpsr},~{flags}"(ptr %i15) #3 + %i18 = tail call ptr asm "", "=r,0,~{dirflag},~{fpsr},~{flags}"(ptr nonnull %i5) #3 + br label %bb19 + +bb19: ; preds = %bb14, %bb7 + %i20 = phi ptr [ %i16, %bb14 ], [ %i9, %bb7 ] + %i21 = phi ptr [ %i18, %bb14 ], [ %i11, %bb7 ] + %i22 = phi ptr [ %i17, %bb14 ], [ %i10, %bb7 ] + store i8 -24, ptr %i20, align 1 + %i23 = ptrtoint ptr %i21 to i64 + %i24 = getelementptr i8, ptr %i22, i64 5 + %i25 = ptrtoint ptr %i24 to i64 + %i26 = sub i64 %i23, %i25 + %i27 = trunc i64 %i26 to i32 + %i28 = getelementptr inbounds %struct.anon.95, ptr %i20, i64 0, i32 1 + store i32 %i27, ptr %i28, align 1 + br label %bb29 + +bb29: ; preds = %bb19, %bb12 + %i30 = phi i32 [ 0, %bb12 ], [ 5, %bb19 ] + ret i32 %i30 } define dso_local i32 @all_gpr_arg(i32 returned %x) local_unnamed_addr #0 "zero-call-used-regs"="all-gpr-arg" { @@ -277,5 +820,6 @@ 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" } +attributes #2 = { fn_ret_thunk_extern noredzone nounwind null_pointer_is_valid sspstrong "fentry-call"="true" "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,+retpoline-external-thunk,+retpoline-indirect-branches,+retpoline-indirect-calls,-3dnow,-3dnowa,-aes,-avx,-avx2,-avx512bf16,-avx512bitalg,-avx512bw,-avx512cd,-avx512dq,-avx512er,-avx512f,-avx512fp16,-avx512ifma,-avx512pf,-avx512vbmi,-avx512vbmi2,-avx512vl,-avx512vnni,-avx512vp2intersect,-avx512vpopcntdq,-avxvnni,-f16c,-fma,-fma4,-gfni,-kl,-mmx,-pclmul,-sha,-sse,-sse2,-sse3,-sse4.1,-sse4.2,-sse4a,-ssse3,-vaes,-vpclmulqdq,-widekl,-x87,-xop" "tune-cpu"="generic" "warn-stack-size"="2048" }