[llvm-branch-commits] [clang] CodeGen: Fix implementation of __builtin_trivially_relocate. (PR #140312)
Peter Collingbourne via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed May 21 16:21:10 PDT 2025
https://github.com/pcc updated https://github.com/llvm/llvm-project/pull/140312
>From 1399ec4fdf8fe08000b590844f4e24c31a310a01 Mon Sep 17 00:00:00 2001
From: Peter Collingbourne <pcc at google.com>
Date: Wed, 21 May 2025 16:20:57 -0700
Subject: [PATCH] Add test with variable count
Created using spr 1.3.6-beta.1
---
.../CodeGenCXX/cxx2c-trivially-relocatable.cpp | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/clang/test/CodeGenCXX/cxx2c-trivially-relocatable.cpp b/clang/test/CodeGenCXX/cxx2c-trivially-relocatable.cpp
index 63f3ba8e74ed5..465e539d363e8 100644
--- a/clang/test/CodeGenCXX/cxx2c-trivially-relocatable.cpp
+++ b/clang/test/CodeGenCXX/cxx2c-trivially-relocatable.cpp
@@ -1,5 +1,7 @@
// RUN: %clang_cc1 -std=c++26 -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck %s
+typedef __SIZE_TYPE__ size_t;
+
struct S trivially_relocatable_if_eligible {
S(const S&);
~S();
@@ -8,9 +10,13 @@ struct S trivially_relocatable_if_eligible {
};
// CHECK: @_Z4testP1SS0_
-// CHECK: call void @llvm.memmove.p0.p0.i64({{.*}}, i64 8
-// CHECK-NOT: __builtin
-// CHECK: ret
-void test(S* source, S* dest) {
+void test(S* source, S* dest, size_t count) {
+ // CHECK: call void @llvm.memmove.p0.p0.i64({{.*}}, i64 8
+ // CHECK-NOT: __builtin
__builtin_trivially_relocate(dest, source, 1);
+ // CHECK: [[A:%.*]] = load i64, ptr %count.addr
+ // CHECK: [[M:%.*]] = mul i64 [[A]], 8
+ // CHECK: call void @llvm.memmove.p0.p0.i64({{.*}}, i64 [[M]]
+ __builtin_trivially_relocate(dest, source, count);
+ // CHECK: ret
};
More information about the llvm-branch-commits
mailing list