[clang] [Clang][CodeGen] Emit fake uses before musttail calls (PR #136867)

John McCall via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 25 00:08:45 PDT 2025


================
@@ -0,0 +1,56 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5
+// RUN: %clang_cc1 -emit-llvm -fextend-variable-liveness -o - %s | FileCheck %s
+
+/// Tests that when we have fake uses in a function ending in a musttail call,
+/// we emit the fake uses and their corresponding loads immediately prior to the
+/// tail call.
+
+extern "C" char *bar(int *, const char *, int *, const int *, unsigned long);
+
+// CHECK-LABEL: define dso_local ptr @foo(
+// CHECK-SAME: ptr noundef [[E:%.*]], ptr noundef [[F:%.*]], ptr noundef [[G:%.*]], ptr noundef [[H:%.*]], i64 noundef [[I:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  [[ENTRY:.*:]]
+// CHECK-NEXT:    [[E_ADDR:%.*]] = alloca ptr, align 8
+// CHECK-NEXT:    [[F_ADDR:%.*]] = alloca ptr, align 8
+// CHECK-NEXT:    [[G_ADDR:%.*]] = alloca ptr, align 8
+// CHECK-NEXT:    [[H_ADDR:%.*]] = alloca ptr, align 8
+// CHECK-NEXT:    [[I_ADDR:%.*]] = alloca i64, align 8
+// CHECK-NEXT:    store ptr [[E]], ptr [[E_ADDR]], align 8
+// CHECK-NEXT:    store ptr [[F]], ptr [[F_ADDR]], align 8
+// CHECK-NEXT:    store ptr [[G]], ptr [[G_ADDR]], align 8
+// CHECK-NEXT:    store ptr [[H]], ptr [[H_ADDR]], align 8
+// CHECK-NEXT:    store i64 [[I]], ptr [[I_ADDR]], align 8
+// CHECK-NEXT:    [[TMP0:%.*]] = load ptr, ptr [[E_ADDR]], align 8
+// CHECK-NEXT:    [[TMP1:%.*]] = load ptr, ptr [[F_ADDR]], align 8
+// CHECK-NEXT:    [[TMP2:%.*]] = load ptr, ptr [[G_ADDR]], align 8
+// CHECK-NEXT:    [[TMP3:%.*]] = load ptr, ptr [[H_ADDR]], align 8
+// CHECK-NEXT:    [[TMP4:%.*]] = load i64, ptr [[I_ADDR]], align 8
+// CHECK-NEXT:    [[FAKE_USE:%.*]] = load i64, ptr [[I_ADDR]], align 8
+// CHECK-NEXT:    notail call void (...) @llvm.fake.use(i64 [[FAKE_USE]]) #[[ATTR3:[0-9]+]]
----------------
rjmccall wrote:

If you're not testing the attributes, you can just leave this off; matches don't have to match the entire line.

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


More information about the cfe-commits mailing list