Skip to content

Commit 4f799c0

Browse files
committedMay 8, 2018
[X86] Mark all byval parameters as aliased
This is a fix for PR30290: by marking all byval stack slots as being aliased, the instruction scheduler is more conservative about rescheduling memory accesses to such stack slots as an LLVM Value* might alias it. This fixes errors such as in the patched test case, where reads and writes to a data structure are illegally mixed. This could be fixed better in the future with better analysis for the instruction scheduler to know what Values alias what stack slots. Differential Revision: https://reviews.llvm.org/D45022 llvm-svn: 331749
1 parent c47f799 commit 4f799c0

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed
 

‎llvm/lib/Target/X86/X86ISelLowering.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -2839,7 +2839,11 @@ X86TargetLowering::LowerMemArgument(SDValue Chain, CallingConv::ID CallConv,
28392839
if (Flags.isByVal()) {
28402840
unsigned Bytes = Flags.getByValSize();
28412841
if (Bytes == 0) Bytes = 1; // Don't create zero-sized stack objects.
2842-
int FI = MFI.CreateFixedObject(Bytes, VA.getLocMemOffset(), isImmutable);
2842+
2843+
// FIXME: For now, all byval parameter objects are marked as aliasing. This
2844+
// can be improved with deeper analysis.
2845+
int FI = MFI.CreateFixedObject(Bytes, VA.getLocMemOffset(), isImmutable,
2846+
/*isAliased=*/true);
28432847
// Adjust SP offset of interrupt parameter.
28442848
if (CallConv == CallingConv::X86_INTR) {
28452849
MFI.setObjectOffset(FI, Offset);

‎llvm/test/CodeGen/X86/pr30290.ll

+1-5
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55
; When broken, five "1" constants are written into the byval %struct.face,
66
; but the subsequent byval read of that struct (call to bar) gets re-ordered
77
; before those writes, illegally.
8-
;
9-
; FIXME: the output shown below is the broken output of llc, "movl $1" is
10-
; scheduled after the copy between byval arguments starts. This will be fixed
11-
; with the patch in review D45022.
128
source_filename = "test.c"
139
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
1410
target triple = "x86_64-pc-linux-gnu"
@@ -26,8 +22,8 @@ define void @foo(%struct.face* byval nocapture align 8) local_unnamed_addr {
2622
; CHECK-NEXT: .cfi_def_cfa_offset 48
2723
; CHECK-NEXT: vmovaps {{.*#+}} xmm0 = [1,1,1,1]
2824
; CHECK-NEXT: vmovaps %xmm0, {{[0-9]+}}(%rsp)
29-
; CHECK-NEXT: vmovups {{[0-9]+}}(%rsp), %xmm0
3025
; CHECK-NEXT: movl $1, {{[0-9]+}}(%rsp)
26+
; CHECK-NEXT: vmovups {{[0-9]+}}(%rsp), %xmm0
3127
; CHECK-NEXT: vmovups %xmm0, {{[0-9]+}}(%rsp)
3228
; CHECK-NEXT: vmovaps {{[0-9]+}}(%rsp), %xmm0
3329
; CHECK-NEXT: vmovups %xmm0, (%rsp)

0 commit comments

Comments
 (0)
Please sign in to comment.