[llvm-commits] [llvm] r166929 - in /llvm/trunk: lib/CodeGen/ScheduleDAGInstrs.cpp test/CodeGen/X86/inlineasm-sched-bug.ll

Preston Gurd preston.gurd at intel.com
Mon Oct 29 08:01:23 PDT 2012


Author: pgurd
Date: Mon Oct 29 10:01:23 2012
New Revision: 166929

URL: http://llvm.org/viewvc/llvm-project?rev=166929&view=rev
Log:
This patch addresses a problem with the Post RA scheduler generating an
incorrect instruction sequence due to it not being aware that an
inline assembly instruction may reference memory.

This patch fixes the problem by causing the scheduler to always assume that any
inline assembly code instruction could access memory. This is necessary because
the internal representation of the inline instruction does not include
any information about memory accesses.
 
This should fix PR13504.



Added:
    llvm/trunk/test/CodeGen/X86/inlineasm-sched-bug.ll
Modified:
    llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp

Modified: llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp?rev=166929&r1=166928&r2=166929&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp (original)
+++ llvm/trunk/lib/CodeGen/ScheduleDAGInstrs.cpp Mon Oct 29 10:01:23 2012
@@ -420,6 +420,11 @@
 /// Return true if MI is an instruction we are unable to reason about
 /// (like a call or something with unmodeled side effects).
 static inline bool isGlobalMemoryObject(AliasAnalysis *AA, MachineInstr *MI) {
+  if (MI->isInlineAsm()) {
+    // Until we can tell if an inline assembly instruction accesses
+    // memory, we must assume all such instructions do so.
+    return true;
+  }
   if (MI->isCall() || MI->hasUnmodeledSideEffects() ||
       (MI->hasOrderedMemoryRef() &&
        (!MI->mayLoad() || !MI->isInvariantLoad(AA))))

Added: llvm/trunk/test/CodeGen/X86/inlineasm-sched-bug.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/inlineasm-sched-bug.ll?rev=166929&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/inlineasm-sched-bug.ll (added)
+++ llvm/trunk/test/CodeGen/X86/inlineasm-sched-bug.ll Mon Oct 29 10:01:23 2012
@@ -0,0 +1,13 @@
+; PR13504
+; RUN: llc -march=x86 -mcpu=atom <%s | FileCheck %s
+; CHECK: bsfl
+; CHECK-NOT: movl
+
+define i32 @foo(i32 %treemap) nounwind uwtable {
+entry:
+  %sub = sub i32 0, %treemap
+  %and = and i32 %treemap, %sub
+  %0 = tail call i32 asm "bsfl $1,$0\0A\09", "=r,rm,~{dirflag},~{fpsr},~{flags}"(i32 %and) nounwind
+  ret i32 %0
+}
+





More information about the llvm-commits mailing list