Bug 308660
| Summary: | Regression(302941@main): inline asm in WTF::opaque() needs to be volatile. | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Mark Lam <mark.lam> |
| Component: | New Bugs | Assignee: | Mark Lam <mark.lam> |
| Status: | RESOLVED FIXED | ||
| Severity: | Normal | CC: | webkit-bug-importer |
| Priority: | P2 | Keywords: | InRadar |
| Version: | WebKit Nightly Build | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
Mark Lam
Otherwise, compiler optimizations may elide or relocate the asm statement.
See https://gcc.gnu.org/onlinedocs/gcc-4.7.2/gcc/Extended-Asm.html:
```
If an asm has output operands, GCC assumes for optimization purposes the instruction has no side effects except to change the output operands. This does not mean instructions with a side effect cannot be used, but you must be careful, because the compiler may eliminate them if the output operands aren't used, or move them out of loops, or replace two with one if they constitute a common subexpression. Also, if your instruction does have a side effect on a variable that otherwise appears not to change, the old value of the variable may be reused later if it happens to be found in a register.
You can prevent an asm instruction from being deleted by writing the keyword volatile after the asm. For example:
#define get_and_set_priority(new) \
({ int __old; \
asm volatile ("get_and_set_priority %0, %1" \
: "=g" (__old) : "g" (new)); \
__old; })
```
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Mark Lam
rdar://171189396
Mark Lam
Pull request: https://github.com/WebKit/WebKit/pull/59441
EWS
Committed 308243@main (9f672ca021c2): <https://commits.webkit.org/308243@main>
Reviewed commits have been landed. Closing PR #59441 and removing active labels.