Vendor import of llvm release_38 branch r258968:

https://llvm.org/svn/llvm-project/llvm/branches/release_38@258968
This commit is contained in:
Dimitry Andric 2016-01-27 21:08:51 +00:00
parent dadbdfff07
commit aff3ef6f6c
14 changed files with 157 additions and 51 deletions

View File

@ -412,7 +412,11 @@ namespace llvm {
/*implicit*/ ExitLimit(const SCEV *E) : Exact(E), Max(E) {} /*implicit*/ ExitLimit(const SCEV *E) : Exact(E), Max(E) {}
ExitLimit(const SCEV *E, const SCEV *M) : Exact(E), Max(M) {} ExitLimit(const SCEV *E, const SCEV *M) : Exact(E), Max(M) {
assert((isa<SCEVCouldNotCompute>(Exact) ||
!isa<SCEVCouldNotCompute>(Max)) &&
"Exact is not allowed to be less precise than Max");
}
/// Test whether this ExitLimit contains any computed information, or /// Test whether this ExitLimit contains any computed information, or
/// whether it's all SCEVCouldNotCompute values. /// whether it's all SCEVCouldNotCompute values.

View File

@ -244,7 +244,7 @@ void DemandedBits::determineLiveOperandBits(
break; break;
case Instruction::ICmp: case Instruction::ICmp:
// Count the number of leading zeroes in each operand. // Count the number of leading zeroes in each operand.
ComputeKnownBits(BitWidth, I, UserI->getOperand(1)); ComputeKnownBits(BitWidth, UserI->getOperand(0), UserI->getOperand(1));
auto NumLeadingZeroes = std::min(KnownZero.countLeadingOnes(), auto NumLeadingZeroes = std::min(KnownZero.countLeadingOnes(),
KnownZero2.countLeadingOnes()); KnownZero2.countLeadingOnes());
AB = ~APInt::getHighBitsSet(BitWidth, NumLeadingZeroes); AB = ~APInt::getHighBitsSet(BitWidth, NumLeadingZeroes);

View File

@ -5368,6 +5368,14 @@ ScalarEvolution::computeExitLimitFromCond(const Loop *L,
BECount = EL0.Exact; BECount = EL0.Exact;
} }
// There are cases (e.g. PR26207) where computeExitLimitFromCond is able
// to be more aggressive when computing BECount than when computing
// MaxBECount. In these cases it is possible for EL0.Exact and EL1.Exact
// to match, but for EL0.Max and EL1.Max to not.
if (isa<SCEVCouldNotCompute>(MaxBECount) &&
!isa<SCEVCouldNotCompute>(BECount))
MaxBECount = BECount;
return ExitLimit(BECount, MaxBECount); return ExitLimit(BECount, MaxBECount);
} }
if (BO->getOpcode() == Instruction::Or) { if (BO->getOpcode() == Instruction::Or) {

View File

@ -138,6 +138,11 @@ def FeatureEnableHugeScratchBuffer : SubtargetFeature<"huge-scratch-buffer",
"true", "true",
"Enable scratch buffer sizes greater than 128 GB">; "Enable scratch buffer sizes greater than 128 GB">;
def FeatureEnableSIScheduler : SubtargetFeature<"si-scheduler",
"EnableSIScheduler",
"true",
"Enable SI Machine Scheduler">;
class SubtargetFeatureFetchLimit <string Value> : class SubtargetFeatureFetchLimit <string Value> :
SubtargetFeature <"fetch"#Value, SubtargetFeature <"fetch"#Value,
"TexVTXClauseSize", "TexVTXClauseSize",

View File

@ -78,7 +78,7 @@ AMDGPUSubtarget::AMDGPUSubtarget(const Triple &TT, StringRef GPU, StringRef FS,
EnableVGPRSpilling(false), SGPRInitBug(false), IsGCN(false), EnableVGPRSpilling(false), SGPRInitBug(false), IsGCN(false),
GCN1Encoding(false), GCN3Encoding(false), CIInsts(false), LDSBankCount(0), GCN1Encoding(false), GCN3Encoding(false), CIInsts(false), LDSBankCount(0),
IsaVersion(ISAVersion0_0_0), EnableHugeScratchBuffer(false), IsaVersion(ISAVersion0_0_0), EnableHugeScratchBuffer(false),
FrameLowering(nullptr), EnableSIScheduler(false), FrameLowering(nullptr),
InstrItins(getInstrItineraryForCPU(GPU)), TargetTriple(TT) { InstrItins(getInstrItineraryForCPU(GPU)), TargetTriple(TT) {
initializeSubtargetDependencies(TT, GPU, FS); initializeSubtargetDependencies(TT, GPU, FS);

View File

@ -90,6 +90,7 @@ class AMDGPUSubtarget : public AMDGPUGenSubtargetInfo {
int LDSBankCount; int LDSBankCount;
unsigned IsaVersion; unsigned IsaVersion;
bool EnableHugeScratchBuffer; bool EnableHugeScratchBuffer;
bool EnableSIScheduler;
std::unique_ptr<AMDGPUFrameLowering> FrameLowering; std::unique_ptr<AMDGPUFrameLowering> FrameLowering;
std::unique_ptr<AMDGPUTargetLowering> TLInfo; std::unique_ptr<AMDGPUTargetLowering> TLInfo;
@ -280,6 +281,10 @@ class AMDGPUSubtarget : public AMDGPUGenSubtargetInfo {
return EnableHugeScratchBuffer; return EnableHugeScratchBuffer;
} }
bool enableSIScheduler() const {
return EnableSIScheduler;
}
bool dumpCode() const { bool dumpCode() const {
return DumpCode; return DumpCode;
} }

View File

@ -147,6 +147,8 @@ class AMDGPUPassConfig : public TargetPassConfig {
const AMDGPUSubtarget &ST = *getAMDGPUTargetMachine().getSubtargetImpl(); const AMDGPUSubtarget &ST = *getAMDGPUTargetMachine().getSubtargetImpl();
if (ST.getGeneration() <= AMDGPUSubtarget::NORTHERN_ISLANDS) if (ST.getGeneration() <= AMDGPUSubtarget::NORTHERN_ISLANDS)
return createR600MachineScheduler(C); return createR600MachineScheduler(C);
else if (ST.enableSIScheduler())
return createSIMachineScheduler(C);
return nullptr; return nullptr;
} }

View File

@ -21880,7 +21880,8 @@ X86TargetLowering::EmitLoweredSelect(MachineInstr *MI,
if (LastCMOV == MI && if (LastCMOV == MI &&
NextMIIt != BB->end() && NextMIIt->getOpcode() == MI->getOpcode() && NextMIIt != BB->end() && NextMIIt->getOpcode() == MI->getOpcode() &&
NextMIIt->getOperand(2).getReg() == MI->getOperand(2).getReg() && NextMIIt->getOperand(2).getReg() == MI->getOperand(2).getReg() &&
NextMIIt->getOperand(1).getReg() == MI->getOperand(0).getReg()) { NextMIIt->getOperand(1).getReg() == MI->getOperand(0).getReg() &&
NextMIIt->getOperand(1).isKill()) {
CascadedCMOV = &*NextMIIt; CascadedCMOV = &*NextMIIt;
} }

View File

@ -494,6 +494,11 @@ void GCOVProfiler::emitProfileNotes() {
// LTO, we'll generate the same .gcno files. // LTO, we'll generate the same .gcno files.
auto *CU = cast<DICompileUnit>(CU_Nodes->getOperand(i)); auto *CU = cast<DICompileUnit>(CU_Nodes->getOperand(i));
// Skip module skeleton (and module) CUs.
if (CU->getDWOId())
continue;
std::error_code EC; std::error_code EC;
raw_fd_ostream out(mangleName(CU, "gcno"), EC, sys::fs::F_None); raw_fd_ostream out(mangleName(CU, "gcno"), EC, sys::fs::F_None);
std::string EdgeDestinations; std::string EdgeDestinations;
@ -853,6 +858,11 @@ Function *GCOVProfiler::insertCounterWriteout(
if (CU_Nodes) { if (CU_Nodes) {
for (unsigned i = 0, e = CU_Nodes->getNumOperands(); i != e; ++i) { for (unsigned i = 0, e = CU_Nodes->getNumOperands(); i != e; ++i) {
auto *CU = cast<DICompileUnit>(CU_Nodes->getOperand(i)); auto *CU = cast<DICompileUnit>(CU_Nodes->getOperand(i));
// Skip module skeleton (and module) CUs.
if (CU->getDWOId())
continue;
std::string FilenameGcda = mangleName(CU, "gcda"); std::string FilenameGcda = mangleName(CU, "gcda");
uint32_t CfgChecksum = FileChecksums.empty() ? 0 : FileChecksums[i]; uint32_t CfgChecksum = FileChecksums.empty() ? 0 : FileChecksums[i];
Builder.CreateCall(StartFile, Builder.CreateCall(StartFile,

View File

@ -24,11 +24,20 @@ define i1 @test_icmp1(i32 %a, i32 %b) {
; CHECK-LABEL: 'test_icmp2' ; CHECK-LABEL: 'test_icmp2'
; CHECK-DAG: DemandedBits: 0x1 for %3 = icmp eq i32 %1, %2 ; CHECK-DAG: DemandedBits: 0x1 for %3 = icmp eq i32 %1, %2
; CHECK-DAG: DemandedBits: 0xFF for %1 = and i32 %a, 255 ; CHECK-DAG: DemandedBits: 0xFFF for %1 = and i32 %a, 255
; CHECK-DAG: DemandedBits: 0xF for %2 = ashr i32 %1, 4 ; CHECK-DAG: DemandedBits: 0xFF for %2 = ashr i32 %1, 4
define i1 @test_icmp2(i32 %a, i32 %b) { define i1 @test_icmp2(i32 %a, i32 %b) {
%1 = and i32 %a, 255 %1 = and i32 %a, 255
%2 = ashr i32 %1, 4 %2 = ashr i32 %1, 4
%3 = icmp eq i32 %1, %2 %3 = icmp eq i32 %1, %2
ret i1 %3 ret i1 %3
} }
; CHECK-LABEL: 'test_icmp3'
; CHECK-DAG: DemandedBits: 0xFFFFFFFF for %1 = and i32 %a, 255
; CHECK-DAG: DemandedBits: 0x1 for %2 = icmp eq i32 -1, %1
define i1 @test_icmp3(i32 %a) {
%1 = and i32 %a, 255
%2 = icmp eq i32 -1, %1
ret i1 %2
}

View File

@ -224,3 +224,52 @@ entry:
} }
attributes #0 = { nounwind } attributes #0 = { nounwind }
@g8 = global i8 0
; The following test failed because llvm had a bug where a structure like:
;
; %vreg12<def> = CMOV_GR8 %vreg7, %vreg11 ... (lt)
; %vreg13<def> = CMOV_GR8 %vreg12, %vreg11 ... (gt)
;
; was lowered to:
;
; The first two cmovs got expanded to:
; BB#0:
; JL_1 BB#9
; BB#7:
; JG_1 BB#9
; BB#8:
; BB#9:
; vreg12 = phi(vreg7, BB#8, vreg11, BB#0, vreg12, BB#7)
; vreg13 = COPY vreg12
; Which was invalid as %vreg12 is not the same value as %vreg13
; CHECK-LABEL: no_cascade_opt:
; CMOV-DAG: cmpl %edx, %esi
; CMOV-DAG: movb $20, %al
; CMOV-DAG: movb $20, %dl
; CMOV: jl [[BB0:.LBB[0-9_]+]]
; CMOV: movb %cl, %dl
; CMOV: [[BB0]]:
; CMOV: jg [[BB1:.LBB[0-9_]+]]
; CMOV: movb %dl, %al
; CMOV: [[BB1]]:
; CMOV: testl %edi, %edi
; CMOV: je [[BB2:.LBB[0-9_]+]]
; CMOV: movb %dl, %al
; CMOV: [[BB2]]:
; CMOV: movb %al, g8(%rip)
; CMOV: retq
define void @no_cascade_opt(i32 %v0, i32 %v1, i32 %v2, i32 %v3) {
entry:
%c0 = icmp eq i32 %v0, 0
%c1 = icmp slt i32 %v1, %v2
%c2 = icmp sgt i32 %v1, %v2
%trunc = trunc i32 %v3 to i8
%sel0 = select i1 %c1, i8 20, i8 %trunc
%sel1 = select i1 %c2, i8 20, i8 %sel0
%sel2 = select i1 %c0, i8 %sel1, i8 %sel0
store volatile i8 %sel2, i8* @g8
ret void
}

View File

@ -0,0 +1,12 @@
; RUN: opt -insert-gcov-profiling -o - < %s | llvm-dis | FileCheck -check-prefix=EMIT-ARCS %s
; EMIT-ARCS-NOT: call void @llvm_gcda_start_file
!llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!3, !4}
!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "LLVM", isOptimized: false, runtimeVersion: 2, splitDebugFilename: "my.dwo", emissionKind: 1, enums: !2, retainedTypes: !2, subprograms: !2, globals: !2, imports: !2, dwoId: 43981)
!1 = !DIFile(filename: "<stdin>", directory: "/")
!2 = !{}
!3 = !{i32 2, !"Dwarf Version", i32 4}
!4 = !{i32 2, !"Debug Info Version", i32 3}

View File

@ -0,0 +1,20 @@
; RUN: opt -S -indvars < %s | FileCheck %s
target triple = "x86_64-unknown-linux-gnu"
define void @main(i16 %in) {
; CHECK-LABEL: @main(
br label %bb2
bb2: ; preds = %bb1.i, %bb2, %0
%_tmp44.i = icmp slt i16 %in, 2
br i1 %_tmp44.i, label %bb1.i, label %bb2
bb1.i: ; preds = %bb1.i, %bb2
%_tmp25.i = phi i16 [ %in, %bb2 ], [ %_tmp6.i, %bb1.i ]
%_tmp6.i = add nsw i16 %_tmp25.i, 1
%_tmp10.i = icmp sge i16 %_tmp6.i, 2
%exitcond.i = icmp eq i16 %_tmp6.i, 2
%or.cond = and i1 %_tmp10.i, %exitcond.i
br i1 %or.cond, label %bb2, label %bb1.i
}

View File

@ -267,56 +267,36 @@ function export_sources() {
check_valid_urls check_valid_urls
for proj in $projects ; do for proj in $projects ; do
if [ -d $proj.src ]; then case $proj in
echo "# Reusing $proj $Release-$RC sources" llvm)
projsrc=$proj.src
;;
cfe)
projsrc=llvm.src/tools/clang
;;
clang-tools-extra)
projsrc=llvm.src/tools/clang/tools/extra
;;
compiler-rt|libcxx|libcxxabi|libunwind|openmp|test-suite)
projsrc=llvm.src/projects/$proj
;;
*)
echo "error: unknown project $proj"
exit 1
;;
esac
if [ -d $projsrc ]; then
echo "# Reusing $proj $Release-$RC sources in $projsrc"
continue continue
fi fi
echo "# Exporting $proj $Release-$RC sources" echo "# Exporting $proj $Release-$RC sources to $projsrc"
if ! svn export -q $Base_url/$proj/$ExportBranch $proj.src ; then if ! svn export -q $Base_url/$proj/$ExportBranch $projsrc ; then
echo "error: failed to export $proj project" echo "error: failed to export $proj project"
exit 1 exit 1
fi fi
done done
echo "# Creating symlinks"
cd $BuildDir/llvm.src/tools
if [ ! -h clang ]; then
ln -s ../../cfe.src clang
fi
# The autoconf and CMake builds want different symlinks here:
if [ "$use_autoconf" = "yes" ]; then
cd $BuildDir/llvm.src/tools/clang/tools
if [ ! -h extra ]; then
ln -s ../../../../clang-tools-extra.src extra
fi
else
cd $BuildDir/cfe.src/tools
if [ ! -h extra ]; then
ln -s ../../clang-tools-extra.src extra
fi
fi
cd $BuildDir/llvm.src/projects
if [ -d $BuildDir/test-suite.src ] && [ ! -h test-suite ]; then
ln -s ../../test-suite.src test-suite
fi
if [ -d $BuildDir/compiler-rt.src ] && [ ! -h compiler-rt ]; then
ln -s ../../compiler-rt.src compiler-rt
fi
if [ -d $BuildDir/openmp.src ] && [ ! -h openmp ]; then
ln -s ../../openmp.src openmp
fi
if [ -d $BuildDir/libcxx.src ] && [ ! -h libcxx ]; then
ln -s ../../libcxx.src libcxx
fi
if [ -d $BuildDir/libcxxabi.src ] && [ ! -h libcxxabi ]; then
ln -s ../../libcxxabi.src libcxxabi
fi
if [ -d $BuildDir/libunwind.src ] && [ ! -h libunwind ]; then
ln -s ../../libunwind.src libunwind
fi
cd $BuildDir cd $BuildDir
} }
@ -560,8 +540,9 @@ for Flavor in $Flavors ; do
# Substitute 'Phase2' for 'Phase3' in the Phase 2 object file in # Substitute 'Phase2' for 'Phase3' in the Phase 2 object file in
# case there are build paths in the debug info. On some systems, # case there are build paths in the debug info. On some systems,
# sed adds a newline to the output, so pass $p3 through sed too. # sed adds a newline to the output, so pass $p3 through sed too.
if ! cmp -s <(sed -e 's,Phase2,Phase3,g' $p2) <(sed -e '' $p3) \ if ! cmp -s \
16 16 ; then <(env LC_CTYPE=C sed -e 's,Phase2,Phase3,g' $p2) \
<(env LC_CTYPE=C sed -e '' $p3) 16 16; then
echo "file `basename $p2` differs between phase 2 and phase 3" echo "file `basename $p2` differs between phase 2 and phase 3"
fi fi
done done