From 5a119335f700251983d9c7da31bdfe17532334b2 Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Wed, 10 Dec 2014 10:05:21 -0800 Subject: Reset to master. Various automerger/conflict resolution shenanigans have made this branch no longer match AOSP. Bring them back into sync. Change-Id: I4117ea6a323068945f237edc0ce0f51e171d4bae --- host/include/llvm/Config/config.h | 6 ++++-- lib/CodeGen/CriticalAntiDepBreaker.cpp | 19 ++++++++++++++++-- test/CodeGen/X86/critical-anti-dep-breaker.ll | 28 +++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 4 deletions(-) create mode 100644 test/CodeGen/X86/critical-anti-dep-breaker.ll diff --git a/host/include/llvm/Config/config.h b/host/include/llvm/Config/config.h index 052adab..cb3d4a3 100644 --- a/host/include/llvm/Config/config.h +++ b/host/include/llvm/Config/config.h @@ -144,11 +144,13 @@ /* Define to 1 if you have the `fmodf' function. */ #define HAVE_FMODF 1 +#ifdef __APPLE__ /* Define to 1 if you have the `futimes' function. */ #define HAVE_FUTIMES 1 - +#else /* Define to 1 if you have the `futimens' function. */ -/* #undef HAVE_FUTIMENS */ +#define HAVE_FUTIMENS 1 +#endif // __APPLE__ /* Define to 1 if you have the `getcwd' function. */ #define HAVE_GETCWD 1 diff --git a/lib/CodeGen/CriticalAntiDepBreaker.cpp b/lib/CodeGen/CriticalAntiDepBreaker.cpp index d083c8e..3d62d48 100644 --- a/lib/CodeGen/CriticalAntiDepBreaker.cpp +++ b/lib/CodeGen/CriticalAntiDepBreaker.cpp @@ -90,7 +90,14 @@ void CriticalAntiDepBreaker::FinishBlock() { void CriticalAntiDepBreaker::Observe(MachineInstr *MI, unsigned Count, unsigned InsertPosIndex) { - if (MI->isDebugValue()) + // Kill instructions can define registers but are really nops, and there might + // be a real definition earlier that needs to be paired with uses dominated by + // this kill. + + // FIXME: It may be possible to remove the isKill() restriction once PR18663 + // has been properly fixed. There can be value in processing kills as seen in + // the AggressiveAntiDepBreaker class. + if (MI->isDebugValue() || MI->isKill()) return; assert(Count < InsertPosIndex && "Instruction index out of expected range!"); @@ -233,6 +240,7 @@ void CriticalAntiDepBreaker::ScanInstruction(MachineInstr *MI, // Update liveness. // Proceeding upwards, registers that are defed but not used in this // instruction are now dead. + assert(!MI->isKill() && "Attempting to scan a kill instruction"); if (!TII->isPredicated(MI)) { // Predicated defs are modeled as read + write, i.e. similar to two @@ -504,7 +512,14 @@ BreakAntiDependencies(const std::vector& SUnits, unsigned Count = InsertPosIndex - 1; for (MachineBasicBlock::iterator I = End, E = Begin; I != E; --Count) { MachineInstr *MI = --I; - if (MI->isDebugValue()) + // Kill instructions can define registers but are really nops, and there + // might be a real definition earlier that needs to be paired with uses + // dominated by this kill. + + // FIXME: It may be possible to remove the isKill() restriction once PR18663 + // has been properly fixed. There can be value in processing kills as seen + // in the AggressiveAntiDepBreaker class. + if (MI->isDebugValue() || MI->isKill()) continue; // Check if this instruction has a dependence on the critical path that diff --git a/test/CodeGen/X86/critical-anti-dep-breaker.ll b/test/CodeGen/X86/critical-anti-dep-breaker.ll new file mode 100644 index 0000000..32d3f49 --- /dev/null +++ b/test/CodeGen/X86/critical-anti-dep-breaker.ll @@ -0,0 +1,28 @@ +; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -relocation-model=pic -post-RA-scheduler=1 -break-anti-dependencies=critical | FileCheck %s + +; PR20308 ( http://llvm.org/bugs/show_bug.cgi?id=20308 ) +; The critical-anti-dependency-breaker must not use register def information from a kill inst. +; This test case expects such an instruction to appear as a comment with def info for RDI. +; There is an anti-dependency (WAR) hazard using RAX using default reg allocation and scheduling. +; The post-RA-scheduler and critical-anti-dependency breaker can eliminate that hazard using R10. +; That is the first free register that isn't used as a param in the call to "@Image". + +@PartClass = external global i32 +@NullToken = external global i64 + +; CHECK-LABEL: Part_Create: +; CHECK-DAG: # kill: RDI +; CHECK-DAG: movq PartClass@GOTPCREL(%rip), %r10 +define i32 @Part_Create(i64* %Anchor, i32 %TypeNum, i32 %F, i32 %Z, i32* %Status, i64* %PartTkn) { + %PartObj = alloca i64*, align 8 + %Vchunk = alloca i64, align 8 + %1 = load i64* @NullToken, align 4 + store i64 %1, i64* %Vchunk, align 8 + %2 = load i32* @PartClass, align 4 + call i32 @Image(i64* %Anchor, i32 %2, i32 0, i32 0, i32* %Status, i64* %PartTkn, i64** %PartObj) + call i32 @Create(i64* %Anchor) + ret i32 %2 +} + +declare i32 @Image(i64*, i32, i32, i32, i32*, i64*, i64**) +declare i32 @Create(i64*) -- cgit v1.1