[llvm-dev] llvm.memcpy for struct copy

Friedman, Eli via llvm-dev llvm-dev at lists.llvm.org
Thu Feb 1 10:39:14 PST 2018

On 2/1/2018 2:03 AM, David Chisnall via llvm-dev wrote:
> In contrast, the padding between fields in non-packed structs 
> disappears as soon as SROA runs. This can lead to violations of C 
> semantics, where padding fields should not change (because C defines 
> bitwise comparisons on structs using memcmp). This can lead to subtly 
> different behaviour in C code depending on the target ABI (we’ve seen 
> cases where trailing padding is copied in one ABI but not in another, 
> depending solely on pointer size). 

The IR type of an alloca isn't supposed to affect the semantics; it's 
just a sizeof(type) block of bytes.  We haven't always gotten this right 
in the past, but it should work correctly on trunk, as far as I know.  
If you have an IR testcase where this still doesn't work correctly, 
please file a bug.


Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project

More information about the llvm-dev mailing list