]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - contrib/llvm/patches/patch-r263312-llvm-r196986-allow-realign-alloca.diff
- Copy stable/10@285827 to releng/10.2 in preparation for 10.2-RC1
[FreeBSD/releng/10.2.git] / contrib / llvm / patches / patch-r263312-llvm-r196986-allow-realign-alloca.diff
1 Pull in r196986 from upstream llvm trunk (by Reid Kleckner):
2
3   Revert the backend fatal error from r196939
4
5   The combination of inline asm, stack realignment, and dynamic allocas
6   turns out to be too common to reject out of hand.
7
8   ASan inserts empy inline asm fragments and uses aligned allocas.
9   Compiling any trivial function containing a dynamic alloca with ASan is
10   enough to trigger the check.
11
12   XFAIL the test cases that would be miscompiled and add one that uses the
13   relevant functionality.
14
15 Introduced here: http://svnweb.freebsd.org/changeset/base/263312
16
17 Index: lib/Target/X86/X86RegisterInfo.cpp
18 ===================================================================
19 --- lib/Target/X86/X86RegisterInfo.cpp
20 +++ lib/Target/X86/X86RegisterInfo.cpp
21 @@ -347,12 +347,6 @@ BitVector X86RegisterInfo::getReservedRegs(const M
22          "Stack realignment in presence of dynamic allocas is not supported with"
23          "this calling convention.");
24  
25 -    // FIXME: Do a proper analysis of the inline asm to see if it actually
26 -    // conflicts with the base register we chose.
27 -    if (MF.hasInlineAsm())
28 -      report_fatal_error("Stack realignment in presence of dynamic stack "
29 -                         "adjustments is not supported with inline assembly.");
30 -
31      for (MCSubRegIterator I(getBaseRegister(), this, /*IncludeSelf=*/true);
32           I.isValid(); ++I)
33        Reserved.set(*I);
34 Index: test/CodeGen/X86/inline-asm-stack-realign3.ll
35 ===================================================================
36 --- test/CodeGen/X86/inline-asm-stack-realign3.ll
37 +++ test/CodeGen/X86/inline-asm-stack-realign3.ll
38 @@ -0,0 +1,29 @@
39 +; RUN: llc -march=x86 < %s | FileCheck %s
40 +
41 +declare void @bar(i32* %junk)
42 +
43 +define i32 @foo(i1 %cond) {
44 +entry:
45 +  %r = alloca i32, align 128
46 +  store i32 -1, i32* %r, align 128
47 +  br i1 %cond, label %doit, label %skip
48 +
49 +doit:
50 +  call void asm sideeffect "xor %ecx, %ecx\0A\09mov %ecx, $0", "=*m,~{ecx},~{flags}"(i32* %r)
51 +  %junk = alloca i32
52 +  call void @bar(i32* %junk)
53 +  br label %skip
54 +
55 +skip:
56 +  %0 = load i32* %r, align 128
57 +  ret i32 %0
58 +}
59 +
60 +; CHECK-LABEL: foo:
61 +; CHECK: pushl %ebp
62 +; CHECK: andl $-128, %esp
63 +; CHECK: xor %ecx, %ecx
64 +; CHECK-NEXT: mov %ecx, (%esi)
65 +; CHECK: movl (%esi), %eax
66 +; CHECK: popl %ebp
67 +; CHECK: ret
68 Index: test/CodeGen/X86/inline-asm-stack-realign.ll
69 ===================================================================
70 --- test/CodeGen/X86/inline-asm-stack-realign.ll
71 +++ test/CodeGen/X86/inline-asm-stack-realign.ll
72 @@ -1,8 +1,8 @@
73  ; RUN: not llc -mtriple=i686-pc-win32 < %s 2>&1 | FileCheck %s
74  
75 -; We don't currently support realigning the stack and adjusting the stack
76 -; pointer in inline asm.  This commonly happens in MS inline assembly using
77 -; push and pop.
78 +; FIXME: This is miscompiled due to our unconditional use of ESI as the base
79 +; pointer.
80 +; XFAIL:
81  
82  ; CHECK: Stack realignment in presence of dynamic stack adjustments is not supported with inline assembly
83  
84 Index: test/CodeGen/X86/inline-asm-stack-realign2.ll
85 ===================================================================
86 --- test/CodeGen/X86/inline-asm-stack-realign2.ll
87 +++ test/CodeGen/X86/inline-asm-stack-realign2.ll
88 @@ -1,7 +1,8 @@
89  ; RUN: not llc -mtriple=i686-pc-win32 < %s 2>&1 | FileCheck %s
90  
91 -; We don't currently support realigning the stack and adjusting the stack
92 -; pointer in inline asm.  This can even happen in GNU asm.
93 +; FIXME: This is miscompiled due to our unconditional use of ESI as the base
94 +; pointer.
95 +; XFAIL:
96  
97  ; CHECK: Stack realignment in presence of dynamic stack adjustments is not supported with inline assembly
98