https://github.com/NewSigma created 
https://github.com/llvm/llvm-project/pull/173809

Since opaque pointers have been adopted for years, this bitcast is no longer 
necessary.

>From 925a24760097bdfe090c49ab877bb1c04bd8f38a Mon Sep 17 00:00:00 2001
From: NewSigma <[email protected]>
Date: Sun, 28 Dec 2025 19:45:40 +0800
Subject: [PATCH] [clang][CodeGen] Remove unnecessary bitcast(NFC)

---
 clang/lib/CodeGen/CGCoroutine.cpp         | 5 +----
 clang/test/CodeGenCoroutines/coro-gro.cpp | 4 ++--
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/clang/lib/CodeGen/CGCoroutine.cpp 
b/clang/lib/CodeGen/CGCoroutine.cpp
index f103e4c06f741..f972f6a7e30b9 100644
--- a/clang/lib/CodeGen/CGCoroutine.cpp
+++ b/clang/lib/CodeGen/CGCoroutine.cpp
@@ -975,12 +975,9 @@ void CodeGenFunction::EmitCoroutineBody(const 
CoroutineBodyStmt &S) {
     EmitStmt(S.getPromiseDeclStmt());
 
     Address PromiseAddr = GetAddrOfLocalVar(S.getPromiseDecl());
-    auto *PromiseAddrVoidPtr =
-        new llvm::BitCastInst(PromiseAddr.emitRawPointer(*this), VoidPtrTy, "",
-                              CoroId->getIterator());
     // Update CoroId to refer to the promise. We could not do it earlier 
because
     // promise local variable was not emitted yet.
-    CoroId->setArgOperand(1, PromiseAddrVoidPtr);
+    CoroId->setArgOperand(1, PromiseAddr.emitRawPointer(*this));
 
     // Now we have the promise, initialize the GRO
     GroManager.EmitGroAlloca();
diff --git a/clang/test/CodeGenCoroutines/coro-gro.cpp 
b/clang/test/CodeGenCoroutines/coro-gro.cpp
index fb9d0a6d85377..3ba6f349fdde1 100644
--- a/clang/test/CodeGenCoroutines/coro-gro.cpp
+++ b/clang/test/CodeGenCoroutines/coro-gro.cpp
@@ -56,7 +56,7 @@ int f() {
   // types mismatch (see cwg2563).
 
   // CHECK: pre.gvo.conv:
-  // CHECK-NEXT: %10 = phi i1 [ true, %cleanup8 ], [ false, %final.suspend ], 
[ false, %init.suspend ]
+  // CHECK-NEXT: %[[IsFinalExit:.+]] = phi i1 [ true, %cleanup8 ], [ false, 
%final.suspend ], [ false, %init.suspend ]
   // CHECK-NEXT: %InRamp = call i1 @llvm.coro.is_in_ramp()
   // CHECK-NEXT: br i1 %InRamp, label %[[GroConv:.+]], label 
%[[AfterGroConv:.+]]
 
@@ -66,7 +66,7 @@ int f() {
   // CHECK-NEXT: br label %[[AfterGroConv]]
 
   // CHECK: [[AfterGroConv]]:
-  // CHECK-NEXT: br i1 %10, label %cleanup.cont10, label %[[CoroRet:.+]]
+  // CHECK-NEXT: br i1  %[[IsFinalExit]], label %cleanup.cont10, label 
%[[CoroRet:.+]]
 
   // CHECK: cleanup.cont10:
   // CHECK-NEXT: br label %[[Cleanup:.+]]

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to