[llvm-bugs] [Bug 50623] New: Overly optimized simultaneous copy of struct fields corrupts destination struct
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Jun 8 12:47:46 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=50623
Bug ID: 50623
Summary: Overly optimized simultaneous copy of struct fields
corrupts destination struct
Product: clang
Version: 12.0
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: LLVM Codegen
Assignee: unassignedclangbugs at nondot.org
Reporter: samuel.sadok at bluewin.ch
CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
richard-llvm at metafoo.co.uk
Clang 12.0.0 modifies a field of a struct that should not be modified. This is
a regression from clang 11.0.1.
Input File:
```
struct S { char val1; char padding; short val2; };
void func(struct S src, struct S* dest) {
dest->val1 = src.val1;
dest->val2 = src.val2;
}
```
Output from clang 12.0.0 (clang -c test.c -o test.o -O1 && objdump -S test.o -M
intel):
```
0000000000000000 <func>:
0: 89 3e mov DWORD PTR [rsi],edi
2: c3 ret
```
Output from clang 11.0.1:
```
0000000000000000 <func>:
0: 40 88 3e mov BYTE PTR [rsi],dil
3: c1 ef 10 shr edi,0x10
6: 66 89 7e 02 mov WORD PTR [rsi+0x2],di
a: c3 ret
```
The output from clang 12.0.0 is incorrect because it modifies the field
`dest->padding`.
See also here: https://godbolt.org/z/dsr9soqbf
"armv8-a clang (trunk)" exhibits the same problem.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210608/fe731eda/attachment.html>
More information about the llvm-bugs
mailing list