[llvm] r261384 - [RegAllocFast] Properly track the physical register definitions on calls.

Quentin Colombet via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 19 16:32:30 PST 2016


Author: qcolombet
Date: Fri Feb 19 18:32:29 2016
New Revision: 261384

URL: http://llvm.org/viewvc/llvm-project?rev=261384&view=rev
Log:
[RegAllocFast] Properly track the physical register definitions on calls.

PR26485

Added:
    llvm/trunk/test/CodeGen/X86/i386-tlscall-fastregalloc.ll
Modified:
    llvm/trunk/lib/CodeGen/RegAllocFast.cpp
    llvm/trunk/test/CodeGen/ARM/Windows/alloca.ll

Modified: llvm/trunk/lib/CodeGen/RegAllocFast.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocFast.cpp?rev=261384&r1=261383&r2=261384&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/RegAllocFast.cpp (original)
+++ llvm/trunk/lib/CodeGen/RegAllocFast.cpp Fri Feb 19 18:32:29 2016
@@ -1002,11 +1002,13 @@ void RAFast::AllocateBasicBlock() {
 
     unsigned DefOpEnd = MI->getNumOperands();
     if (MI->isCall()) {
-      // Spill all virtregs before a call. This serves two purposes: 1. If an
+      // Spill all virtregs before a call. This serves one purpose: If an
       // exception is thrown, the landing pad is going to expect to find
-      // registers in their spill slots, and 2. we don't have to wade through
-      // all the <imp-def> operands on the call instruction.
-      DefOpEnd = VirtOpEnd;
+      // registers in their spill slots.
+      // Note: although this is appealing to just consider all definitions
+      // as call-clobbered, this is not correct because some of those
+      // definitions may be used later on and we do not want to reuse
+      // those for virtual registers in between.
       DEBUG(dbgs() << "  Spilling remaining registers before call.\n");
       spillAll(MI);
 

Modified: llvm/trunk/test/CodeGen/ARM/Windows/alloca.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/Windows/alloca.ll?rev=261384&r1=261383&r2=261384&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/ARM/Windows/alloca.ll (original)
+++ llvm/trunk/test/CodeGen/ARM/Windows/alloca.ll Fri Feb 19 18:32:29 2016
@@ -13,7 +13,9 @@ entry:
 }
 
 ; CHECK: bl num_entries
-; CHECK: movs [[R1:r[0-9]+]], #7
+; Any register is actually valid here, but turns out we use lr,
+; because we do not have the kill flag on R0.
+; CHECK: mov.w [[R1:lr]], #7
 ; CHECK: add.w [[R0:r[0-9]+]], [[R1]], [[R0]], lsl #2
 ; CHECK: bic [[R0]], [[R0]], #7
 ; CHECK: lsrs r4, [[R0]], #2

Added: llvm/trunk/test/CodeGen/X86/i386-tlscall-fastregalloc.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/i386-tlscall-fastregalloc.ll?rev=261384&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/i386-tlscall-fastregalloc.ll (added)
+++ llvm/trunk/test/CodeGen/X86/i386-tlscall-fastregalloc.ll Fri Feb 19 18:32:29 2016
@@ -0,0 +1,26 @@
+; RUN: llc %s -o - -O0 -regalloc=fast | FileCheck %s
+target datalayout = "e-m:o-p:32:32-f64:32:64-f80:128-n8:16:32-S128"
+target triple = "i386-apple-macosx10.10"
+
+ at c = external global i8, align 1
+ at p = thread_local global i8* null, align 4
+
+; Check that regalloc fast correctly preserves EAX that is set by the TLS call
+; until the actual use.
+; PR26485.
+;
+; CHECK-LABEL: f:
+; Get p.
+; CHECK: movl _p@{{[0-9a-zA-Z]+}}, [[P_ADDR:%[a-z]+]]
+; CHECK-NEXT: calll *([[P_ADDR]])
+; At this point eax contiains the address of p.
+; Load c address.
+; Make sure we do not clobber eax.
+; CHECK-NEXT: movl L_c{{[^,]*}}, [[C_ADDR:%e[b-z]x+]]
+; Store c address into p.
+; CHECK-NEXT: movl [[C_ADDR]], (%eax)
+define void @f() #0 {
+entry:
+  store i8* @c, i8** @p, align 4
+  ret void
+}




More information about the llvm-commits mailing list