[clang] [llvm] [CodeGen] Add support for multiple constraints (PR #195592)

Bill Wendling via cfe-commits cfe-commits at lists.llvm.org
Mon May 4 08:46:28 PDT 2026


================
@@ -2883,13 +2883,23 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) {
     if (!Constraints.empty())
       Constraints += ',';
 
-    // If this is a register output, then make the inline asm return it
-    // by-value.  If this is a memory result, return the value by-reference.
+    // - If this is a register output, then make the inline asm return it
+    //   by-value.
+    // - If this is a memory output, return the value by reference.
+    // - If this is a register and memory output, treat it like a register
+    //   output at -O[1-3]. This allows the optimizing register allocators to
+    //   choose a register, while the fast register allocator defaults to
+    //   memory.
     QualType QTy = OutExpr->getType();
     const bool IsScalarOrAggregate = hasScalarEvaluationKind(QTy) ||
                                      hasAggregateEvaluationKind(QTy);
-    if (!Info.allowsMemory() && IsScalarOrAggregate) {
+    const bool RegisterMemoryConstraints =
+        CGM.getCodeGenOpts().OptimizationLevel != 0 &&
----------------
bwendling wrote:

Here's a discussion of this: https://github.com/llvm/llvm-project/pull/181973/changes#r3046712485

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


More information about the cfe-commits mailing list