[llvm-commits] [llvm] r148240 - in /llvm/trunk: lib/Target/X86/X86InstrCompiler.td test/CodeGen/X86/2012-01-16-mfence-nosse-flags.ll

Eli Friedman eli.friedman at gmail.com
Mon Jan 16 08:42:21 PST 2012


Author: efriedma
Date: Mon Jan 16 10:42:21 2012
New Revision: 148240

URL: http://llvm.org/viewvc/llvm-project?rev=148240&view=rev
Log:
Make sure the non-SSE lowering for fences correctly clobbers EFLAGS.  PR11768.


Added:
    llvm/trunk/test/CodeGen/X86/2012-01-16-mfence-nosse-flags.ll
Modified:
    llvm/trunk/lib/Target/X86/X86InstrCompiler.td

Modified: llvm/trunk/lib/Target/X86/X86InstrCompiler.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrCompiler.td?rev=148240&r1=148239&r2=148240&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86InstrCompiler.td (original)
+++ llvm/trunk/lib/Target/X86/X86InstrCompiler.td Mon Jan 16 10:42:21 2012
@@ -551,7 +551,7 @@
 // Memory barriers
 
 // TODO: Get this to fold the constant into the instruction.
-let isCodeGenOnly = 1 in
+let isCodeGenOnly = 1, Defs = [EFLAGS] in
 def OR32mrLocked  : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$zero),
                       "lock\n\t"
                       "or{l}\t{$zero, $dst|$dst, $zero}",

Added: llvm/trunk/test/CodeGen/X86/2012-01-16-mfence-nosse-flags.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2012-01-16-mfence-nosse-flags.ll?rev=148240&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/2012-01-16-mfence-nosse-flags.ll (added)
+++ llvm/trunk/test/CodeGen/X86/2012-01-16-mfence-nosse-flags.ll Mon Jan 16 10:42:21 2012
@@ -0,0 +1,34 @@
+; RUN: llc < %s -mtriple=i686-linux -mattr=-sse | FileCheck %s
+; PR11768
+
+ at ptr = external global i8*
+
+define void @baz() nounwind ssp {
+entry:
+  %0 = load i8** @ptr, align 4
+  %cmp = icmp eq i8* %0, null
+  fence seq_cst
+  br i1 %cmp, label %if.then, label %if.else
+
+; Make sure the fence comes before the comparison, since it
+; clobbers EFLAGS.
+
+; CHECK: lock
+; CHECK-NEXT: orl {{.*}}, (%esp)
+; CHECK-NEXT: cmpl $0
+
+if.then:                                          ; preds = %entry
+  tail call void bitcast (void (...)* @foo to void ()*)() nounwind
+  br label %if.end
+
+if.else:                                          ; preds = %entry
+  tail call void bitcast (void (...)* @bar to void ()*)() nounwind
+  br label %if.end
+
+if.end:                                           ; preds = %if.else, %if.then
+  ret void
+}
+
+declare void @foo(...)
+
+declare void @bar(...)





More information about the llvm-commits mailing list