[clang] [CIR] Coerce record returns from memory like CreateCoercedLoad (PR #227482)

Andy Kaylor via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 29 15:52:33 PDT 2026


================
@@ -98,20 +83,20 @@ NonTrivial test_nrvo() {
 //            artifact of us falling through to emitImplicitReturn().
 // CIR:   cir.trap
 
-// LLVM: define {{.*}} void @_Z9test_nrvov(ptr dead_on_unwind noalias writable sret(%struct.NonTrivial) align 1 %[[RESULT:.*]])
-// LLVM:   %[[NRVO_FLAG:.*]] = alloca i8
-// LLVM:   store i8 0, ptr %[[NRVO_FLAG]]
-// LLVM:   call void @_Z10maybeThrowv()
-// LLVM:   store i8 1, ptr %[[NRVO_FLAG]]
-// LLVM:   %[[NRVO_VAL:.*]] = load i8, ptr %[[NRVO_FLAG]]
-// LLVM:   %[[NRVO_VAL_TRUNC:.*]] = trunc i8 %[[NRVO_VAL]] to i1
-// LLVM:   %[[NOT_NRVO_VAL:.*]] = xor i1 %[[NRVO_VAL_TRUNC]], true
-// LLVM:   br i1 %[[NOT_NRVO_VAL]], label %[[NRVO_UNUSED:.*]], label %[[NRVO_USED:.*]]
-// LLVM: [[NRVO_UNUSED]]:
-// LLVM:   call void @_ZN10NonTrivialD1Ev(ptr {{.*}} %[[RESULT]])
-// LLVM:   br label %[[NRVO_USED]]
-// LLVM: [[NRVO_USED]]:
-// LLVM:   ret void
+// LLVMCIR: define {{.*}} void @_Z9test_nrvov(ptr dead_on_unwind noalias writable sret(%struct.NonTrivial) align 1 %[[RESULT:.*]])
----------------
andykaylor wrote:

Can't more of these checks be combined with OGCG?

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


More information about the cfe-commits mailing list