https://github.com/BStott6 created 
https://github.com/llvm/llvm-project/pull/166798

- Fixes https://github.com/llvm/llvm-project/issues/166512
- `ComplexExprEmitter::EmitCompoundAssignLValue` is calling 
`EmitLoadOfScalar(LValue, SourceLocation)` to load the LHS value in the case 
that it's non-complex, however this function requires that the value is a 
simple LValue - issue occurred because the LValue in question was a bitfield 
LValue. I changed it to use this function which seems to handle all of the 
different cases (deferring to the original `EmitLoadOfScalar` if it's a simple 
LValue)

Note that I am new to Clang and I'm not confident this is the right change; it 
makes sense to me, fixes the crash and passes all tests but please check 
carefully!

>From eab7dd02ab238c0029c2f0fc9a7f8f3ce1ab055c Mon Sep 17 00:00:00 2001
From: BStott <[email protected]>
Date: Thu, 6 Nov 2025 16:25:54 +0000
Subject: [PATCH] [Clang][CodeGen] Use EmitLoadOfLValue instead of
 EmitLoadOfScalar to get LHS for complex compound assignment

---
 clang/lib/CodeGen/CGExprComplex.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/CodeGen/CGExprComplex.cpp 
b/clang/lib/CodeGen/CGExprComplex.cpp
index f8a946a76554a..47435758fcde7 100644
--- a/clang/lib/CodeGen/CGExprComplex.cpp
+++ b/clang/lib/CodeGen/CGExprComplex.cpp
@@ -1283,7 +1283,7 @@ EmitCompoundAssignLValue(const CompoundAssignOperator *E,
     else
       OpInfo.LHS = EmitComplexToComplexCast(LHSVal, LHSTy, OpInfo.Ty, Loc);
   } else {
-    llvm::Value *LHSVal = CGF.EmitLoadOfScalar(LHS, Loc);
+    llvm::Value *LHSVal = CGF.EmitLoadOfLValue(LHS, Loc).getScalarVal();
     // For floating point real operands we can directly pass the scalar form
     // to the binary operator emission and potentially get more efficient code.
     if (LHSTy->isRealFloatingType()) {

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

Reply via email to