Author: Weibo He
Date: 2025-12-29T11:34:51+08:00
New Revision: 18307bf920074023320ddf33944d572034bc0399

URL: 
https://github.com/llvm/llvm-project/commit/18307bf920074023320ddf33944d572034bc0399
DIFF: 
https://github.com/llvm/llvm-project/commit/18307bf920074023320ddf33944d572034bc0399.diff

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

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

Added: 
    

Modified: 
    clang/lib/CodeGen/CGCoroutine.cpp
    clang/test/CodeGenCoroutines/coro-gro.cpp

Removed: 
    


################################################################################
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