[llvm] [LLVM] Add 'ExpandVariadicsPass' to LTO default pipeline (PR #100479)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 25 05:00:48 PDT 2024


================
@@ -0,0 +1,48 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
+; RUN: opt -mtriple=amdgcn-- -S -passes='lto<O2>' < %s | FileCheck %s
+target triple = "amdgcn-amd-amdhsa"
+
+; We use the ExpandVariadics pass to lower variadic functions so they can be
+; inlined.
+
+define i32 @foo() {
+; CHECK-LABEL: define i32 @foo(
+; CHECK-SAME: ) local_unnamed_addr #[[ATTR0:[0-9]+]] {
+; CHECK-NEXT:  [[ENTRY:.*:]]
+; CHECK-NEXT:    ret i32 6
+;
+entry:
+  %call = tail call i32 (i32, ...) @vararg(i32 poison, i32 noundef 1, i32 noundef 2, i32 noundef 3)
+  ret i32 %call
+}
+
+define internal i32 @vararg(i32 %first, ...) {
+entry:
+  %vlist = alloca ptr, align 8, addrspace(5)
+  %vlist.ascast = addrspacecast ptr addrspace(5) %vlist to ptr
+  call void @llvm.lifetime.start.p5(i64 8, ptr addrspace(5) %vlist)
+  call void @llvm.va_start.p0(ptr %vlist.ascast)
+  %vlist.promoted = load ptr, ptr addrspace(5) %vlist, align 8
+  %argp.next = getelementptr inbounds i8, ptr %vlist.promoted, i64 4
+  store ptr %argp.next, ptr addrspace(5) %vlist, align 8
+  %0 = load i32, ptr %vlist.promoted, align 4
----------------
arsenm wrote:

Use named values 

https://github.com/llvm/llvm-project/pull/100479


More information about the llvm-commits mailing list