[clang] [clang][CodeGen] Emit improved memory effects and return status for AsmStmt (PR #110510)

Bruno De Fraine via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 25 18:54:46 PDT 2024


brunodf-snps wrote:

> Do we want nocapture markings on memory operands?

I had a chance to discuss this with @nikic and he brought up the LEA instruction. The following would capture the address the `b` field:

```
asm("lea %0, %1" : "=r" (r) : "m" (p[i].b));
```

I could not find back if you are allowed to use an inline assembly memory operand for such an instruction (*), but it certainly seems a real risk that users are doing this.

(*) I think an alternative could be:

```
asm("lea %0, %a1": "=r" (r) : "p" (&p[i].b));
```

But clang does not accept it: https://godbolt.org/z/33Mxe9nvd

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


More information about the cfe-commits mailing list