brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.1 KiB · 2195e43 Raw
74 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --scrub-attributes2; In PR41658, argpromotion put an inalloca in a position that per the3; calling convention is passed in a register. This test verifies that4; we don't do that anymore. It also verifies that the combination of5; globalopt and argpromotion is able to optimize the call safely.6;7; RUN: opt -S -passes=argpromotion %s | FileCheck %s --check-prefix=ARGPROMOTION8; RUN: opt -S -passes=globalopt,argpromotion %s | FileCheck %s --check-prefix=GLOBALOPT_ARGPROMOTION9 10target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"11target triple = "i386-pc-windows-msvc19.11.0"12 13%struct.a = type { i8 }14 15define internal x86_thiscallcc void @internalfun(ptr %this, ptr inalloca(<{ %struct.a }>)) {16; ARGPROMOTION-LABEL: define {{[^@]+}}@internalfun17; ARGPROMOTION-SAME: (ptr [[THIS:%.*]], ptr inalloca(<{ [[STRUCT_A:%.*]] }>) [[TMP0:%.*]]) {18; ARGPROMOTION-NEXT:  entry:19; ARGPROMOTION-NEXT:    [[A:%.*]] = getelementptr inbounds <{ [[STRUCT_A]] }>, ptr [[TMP0]], i32 0, i32 020; ARGPROMOTION-NEXT:    [[ARGMEM:%.*]] = alloca inalloca <{ [[STRUCT_A]] }>, align 421; ARGPROMOTION-NEXT:    [[TMP1:%.*]] = getelementptr inbounds <{ [[STRUCT_A]] }>, ptr [[ARGMEM]], i32 0, i32 022; ARGPROMOTION-NEXT:    [[CALL:%.*]] = call x86_thiscallcc ptr @copy_ctor(ptr [[TMP1]], ptr dereferenceable(1) [[A]])23; ARGPROMOTION-NEXT:    call void @ext(ptr inalloca(<{ [[STRUCT_A]] }>) [[ARGMEM]])24; ARGPROMOTION-NEXT:    ret void25;26; GLOBALOPT_ARGPROMOTION-LABEL: define {{[^@]+}}@internalfun27; GLOBALOPT_ARGPROMOTION-SAME: (ptr [[TMP0:%.*]]) unnamed_addr {28; GLOBALOPT_ARGPROMOTION-NEXT:  entry:29; GLOBALOPT_ARGPROMOTION-NEXT:    [[A:%.*]] = getelementptr inbounds <{ [[STRUCT_A:%.*]] }>, ptr [[TMP0]], i32 0, i32 030; GLOBALOPT_ARGPROMOTION-NEXT:    [[ARGMEM:%.*]] = alloca inalloca <{ [[STRUCT_A]] }>, align 431; GLOBALOPT_ARGPROMOTION-NEXT:    [[TMP1:%.*]] = getelementptr inbounds <{ [[STRUCT_A]] }>, ptr [[ARGMEM]], i32 0, i32 032; GLOBALOPT_ARGPROMOTION-NEXT:    [[CALL:%.*]] = call x86_thiscallcc ptr @copy_ctor(ptr [[TMP1]], ptr dereferenceable(1) [[A]])33; GLOBALOPT_ARGPROMOTION-NEXT:    call void @ext(ptr inalloca(<{ [[STRUCT_A]] }>) [[ARGMEM]])34; GLOBALOPT_ARGPROMOTION-NEXT:    ret void35;36entry:37  %a = getelementptr inbounds <{ %struct.a }>, ptr %0, i32 0, i32 038  %argmem = alloca inalloca <{ %struct.a }>, align 439  %1 = getelementptr inbounds <{ %struct.a }>, ptr %argmem, i32 0, i32 040  %call = call x86_thiscallcc ptr @copy_ctor(ptr %1, ptr dereferenceable(1) %a)41  call void @ext(ptr inalloca(<{ %struct.a }>) %argmem)42  ret void43}44 45; This is here to ensure @internalfun is live.46define void @exportedfun(ptr %a) {47; ARGPROMOTION-LABEL: define {{[^@]+}}@exportedfun48; ARGPROMOTION-SAME: (ptr [[A:%.*]]) {49; ARGPROMOTION-NEXT:    [[INALLOCA_SAVE:%.*]] = tail call ptr @llvm.stacksave.p0()50; ARGPROMOTION-NEXT:    [[ARGMEM:%.*]] = alloca inalloca <{ [[STRUCT_A:%.*]] }>, align 451; ARGPROMOTION-NEXT:    call x86_thiscallcc void @internalfun(ptr [[A]], ptr inalloca(<{ [[STRUCT_A]] }>) [[ARGMEM]])52; ARGPROMOTION-NEXT:    call void @llvm.stackrestore.p0(ptr [[INALLOCA_SAVE]])53; ARGPROMOTION-NEXT:    ret void54;55; GLOBALOPT_ARGPROMOTION-LABEL: define {{[^@]+}}@exportedfun56; GLOBALOPT_ARGPROMOTION-SAME: (ptr [[A:%.*]]) local_unnamed_addr {57; GLOBALOPT_ARGPROMOTION-NEXT:    [[INALLOCA_SAVE:%.*]] = tail call ptr @llvm.stacksave.p0()58; GLOBALOPT_ARGPROMOTION-NEXT:    [[ARGMEM:%.*]] = alloca inalloca <{ [[STRUCT_A:%.*]] }>, align 459; GLOBALOPT_ARGPROMOTION-NEXT:    call fastcc void @internalfun(ptr [[ARGMEM]])60; GLOBALOPT_ARGPROMOTION-NEXT:    call void @llvm.stackrestore.p0(ptr [[INALLOCA_SAVE]])61; GLOBALOPT_ARGPROMOTION-NEXT:    ret void62;63  %inalloca.save = tail call ptr @llvm.stacksave()64  %argmem = alloca inalloca <{ %struct.a }>, align 465  call x86_thiscallcc void @internalfun(ptr %a, ptr inalloca(<{ %struct.a }>) %argmem)66  call void @llvm.stackrestore(ptr %inalloca.save)67  ret void68}69 70declare x86_thiscallcc ptr @copy_ctor(ptr returned, ptr dereferenceable(1))71declare void @ext(ptr inalloca(<{ %struct.a }>))72declare ptr @llvm.stacksave()73declare void @llvm.stackrestore(ptr)74