[clang] [clang][CodeGen] Remove redundant bitcast(NFC) (PR #173809)

via cfe-commits cfe-commits at lists.llvm.org
Sun Dec 28 18:02:03 PST 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang-codegen

Author: Weibo He (NewSigma)

<details>
<summary>Changes</summary>

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

---
Full diff: https://github.com/llvm/llvm-project/pull/173809.diff


2 Files Affected:

- (modified) clang/lib/CodeGen/CGCoroutine.cpp (+1-4) 
- (modified) clang/test/CodeGenCoroutines/coro-gro.cpp (+2-2) 


``````````diff
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:.+]]

``````````

</details>


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


More information about the cfe-commits mailing list