<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - -ftrivial-auto-var-init creates big redundant structs in .rodata"
href="https://bugs.llvm.org/show_bug.cgi?id=40605">40605</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>-ftrivial-auto-var-init creates big redundant structs in .rodata
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Scalar Optimizations
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>glider@google.com
</td>
</tr>
<tr>
<th>CC</th>
<td>dvyukov@google.com, kcc@google.com, llvm-bugs@lists.llvm.org, llvm-bugzilla@jfbastien.com
</td>
</tr></table>
<p>
<div>
<pre>When wiping uninitialized C structures with a 0xAA pattern in the
-ftrivial-auto-var-init=pattern mode Clang generates big constant structures
that end up in .rodata.
E.g. for the following case:
struct S {
void *p1, *p2, *p3, *p4;
};
extern void bar(struct S *s);
void foo() {
struct S local;
bar(&local);
}
we generate the following IR:
=====================
@__const.foo.local = private unnamed_addr constant %struct.S { i8* inttoptr
(i64 -6148914691236517206 to i8*), i8* inttoptr (i64 -6148914691236517206 to
i8*), i8* inttoptr (i64 -6148914691236517206 to i8*), i8* inttoptr (i64
-6148914691236517206 to i8*) }, align 8
...
define dso_local void @foo() local_unnamed_addr #0 {
%1 = alloca %struct.S, align 8
%2 = bitcast %struct.S* %1 to i8*
call void @llvm.lifetime.start.p0i8(i64 32, i8* nonnull %2) #3
call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 8 %2, i8* align 8
bitcast (%struct.S* @__const.foo.local to i8*), i64 32, i1 false)
call void @bar(%struct.S* nonnull %1) #3
call void @llvm.lifetime.end.p0i8(i64 32, i8* nonnull %2) #3
ret void
}
=====================
, which ends up translated into the following assembly code:
=====================
foo: # @foo
.cfi_startproc
# %bb.0:
subq $40, %rsp
.cfi_def_cfa_offset 48
movups .L__const.foo.local+16(%rip), %xmm0
movaps %xmm0, 16(%rsp)
movups .L__const.foo.local(%rip), %xmm0
movaps %xmm0, (%rsp)
movq %rsp, %rdi
callq bar
addq $40, %rsp
.cfi_def_cfa_offset 8
retq
.Lfunc_end0:
.size foo, .Lfunc_end0-foo
.cfi_endproc
=====================
So the instrumentation produces big volumes of 0xAA constants in .rodata
instead of at most one 16-byte 0xAA constant that's used all over the place.
Most certainly Clang is also unable to split copying of those big structs,
which results in missed dead store elimination opportunities.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>