aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2018-11-04 14:41:47 +0000
committerDimitry Andric <dim@FreeBSD.org>2018-11-04 14:41:47 +0000
commit86392292ee722abb03af4befe2d2c8baaeadaf22 (patch)
treeb33cb35c56c65b9d9ad8db8bc49159a4246f138a
parent36272db3cad448211389168cced4baac39a1a0d1 (diff)
downloadsrc-86392292ee722abb03af4befe2d2c8baaeadaf22.tar.gz
src-86392292ee722abb03af4befe2d2c8baaeadaf22.zip
Vendor import of llvm release_70 branch r346007:vendor/llvm/llvm-release_70-r346007
Notes
Notes: svn path=/vendor/llvm/dist-release_70/; revision=340116 svn path=/vendor/llvm/llvm-release_70-r346007/; revision=340117; tag=vendor/llvm/llvm-release_70-r346007
-rw-r--r--CMakeLists.txt2
-rw-r--r--include/llvm/Transforms/Utils/BuildLibCalls.h1
-rw-r--r--lib/Analysis/ModuleSummaryAnalysis.cpp19
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfDebug.cpp2
-rw-r--r--lib/Target/X86/X86DomainReassignment.cpp21
-rw-r--r--lib/Target/X86/X86ISelLowering.cpp7
-rw-r--r--lib/Target/X86/X86InstrInfo.cpp2
-rw-r--r--lib/Transforms/IPO/FunctionImport.cpp3
-rw-r--r--lib/Transforms/Scalar/LoopIdiomRecognize.cpp5
-rw-r--r--lib/Transforms/Utils/BuildLibCalls.cpp119
-rw-r--r--test/CodeGen/X86/known-signbits-vector.ll29
-rw-r--r--test/CodeGen/X86/pr38803.ll48
-rw-r--r--test/ThinLTO/X86/Inputs/globals-import-blockaddr.ll12
-rw-r--r--test/ThinLTO/X86/globals-import-blockaddr.ll18
-rw-r--r--test/Transforms/InstCombine/pr39177.ll44
-rw-r--r--tools/llvm-xray/xray-account.cpp7
-rw-r--r--utils/lit/lit/__init__.py2
-rw-r--r--utils/lit/lit/builtin_commands/__init__.py0
18 files changed, 264 insertions, 77 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 31df64089eb4..63122c4b6a77 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -29,7 +29,7 @@ if(NOT DEFINED LLVM_VERSION_MINOR)
set(LLVM_VERSION_MINOR 0)
endif()
if(NOT DEFINED LLVM_VERSION_PATCH)
- set(LLVM_VERSION_PATCH 0)
+ set(LLVM_VERSION_PATCH 1)
endif()
if(NOT DEFINED LLVM_VERSION_SUFFIX)
set(LLVM_VERSION_SUFFIX "")
diff --git a/include/llvm/Transforms/Utils/BuildLibCalls.h b/include/llvm/Transforms/Utils/BuildLibCalls.h
index bdcdf6f361f2..eafe07f49284 100644
--- a/include/llvm/Transforms/Utils/BuildLibCalls.h
+++ b/include/llvm/Transforms/Utils/BuildLibCalls.h
@@ -29,6 +29,7 @@ namespace llvm {
///
/// Returns true if any attributes were set and false otherwise.
bool inferLibFuncAttributes(Function &F, const TargetLibraryInfo &TLI);
+ bool inferLibFuncAttributes(Module *M, StringRef Name, const TargetLibraryInfo &TLI);
/// Check whether the overloaded unary floating point function
/// corresponding to \a Ty is available.
diff --git a/lib/Analysis/ModuleSummaryAnalysis.cpp b/lib/Analysis/ModuleSummaryAnalysis.cpp
index 17dae20ce3a1..ce099ed2f391 100644
--- a/lib/Analysis/ModuleSummaryAnalysis.cpp
+++ b/lib/Analysis/ModuleSummaryAnalysis.cpp
@@ -74,9 +74,17 @@ cl::opt<FunctionSummary::ForceSummaryHotnessType, true> FSEC(
// Walk through the operands of a given User via worklist iteration and populate
// the set of GlobalValue references encountered. Invoked either on an
// Instruction or a GlobalVariable (which walks its initializer).
-static void findRefEdges(ModuleSummaryIndex &Index, const User *CurUser,
+// Return true if any of the operands contains blockaddress. This is important
+// to know when computing summary for global var, because if global variable
+// references basic block address we can't import it separately from function
+// containing that basic block. For simplicity we currently don't import such
+// global vars at all. When importing function we aren't interested if any
+// instruction in it takes an address of any basic block, because instruction
+// can only take an address of basic block located in the same function.
+static bool findRefEdges(ModuleSummaryIndex &Index, const User *CurUser,
SetVector<ValueInfo> &RefEdges,
SmallPtrSet<const User *, 8> &Visited) {
+ bool HasBlockAddress = false;
SmallVector<const User *, 32> Worklist;
Worklist.push_back(CurUser);
@@ -92,8 +100,10 @@ static void findRefEdges(ModuleSummaryIndex &Index, const User *CurUser,
const User *Operand = dyn_cast<User>(OI);
if (!Operand)
continue;
- if (isa<BlockAddress>(Operand))
+ if (isa<BlockAddress>(Operand)) {
+ HasBlockAddress = true;
continue;
+ }
if (auto *GV = dyn_cast<GlobalValue>(Operand)) {
// We have a reference to a global value. This should be added to
// the reference set unless it is a callee. Callees are handled
@@ -105,6 +115,7 @@ static void findRefEdges(ModuleSummaryIndex &Index, const User *CurUser,
Worklist.push_back(Operand);
}
}
+ return HasBlockAddress;
}
static CalleeInfo::HotnessType getHotness(uint64_t ProfileCount,
@@ -369,7 +380,7 @@ computeVariableSummary(ModuleSummaryIndex &Index, const GlobalVariable &V,
DenseSet<GlobalValue::GUID> &CantBePromoted) {
SetVector<ValueInfo> RefEdges;
SmallPtrSet<const User *, 8> Visited;
- findRefEdges(Index, &V, RefEdges, Visited);
+ bool HasBlockAddress = findRefEdges(Index, &V, RefEdges, Visited);
bool NonRenamableLocal = isNonRenamableLocal(V);
GlobalValueSummary::GVFlags Flags(V.getLinkage(), NonRenamableLocal,
/* Live = */ false, V.isDSOLocal());
@@ -377,6 +388,8 @@ computeVariableSummary(ModuleSummaryIndex &Index, const GlobalVariable &V,
llvm::make_unique<GlobalVarSummary>(Flags, RefEdges.takeVector());
if (NonRenamableLocal)
CantBePromoted.insert(V.getGUID());
+ if (HasBlockAddress)
+ GVarSummary->setNotEligibleToImport();
Index.addGlobalValueSummary(V, std::move(GVarSummary));
}
diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 500e7a00196f..19b3afef34b5 100644
--- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -2127,7 +2127,7 @@ void DwarfDebug::emitDebugRanges() {
auto NoRangesPresent = [this]() {
return llvm::all_of(
- CUMap, [](const decltype(CUMap)::const_iterator::value_type &Pair) {
+ CUMap, [](const decltype(CUMap)::value_type &Pair) {
return Pair.second->getRangeLists().empty();
});
};
diff --git a/lib/Target/X86/X86DomainReassignment.cpp b/lib/Target/X86/X86DomainReassignment.cpp
index 5196446b39e9..62588e9509d3 100644
--- a/lib/Target/X86/X86DomainReassignment.cpp
+++ b/lib/Target/X86/X86DomainReassignment.cpp
@@ -217,6 +217,27 @@ public:
InstrCOPYReplacer(unsigned SrcOpcode, RegDomain DstDomain, unsigned DstOpcode)
: InstrReplacer(SrcOpcode, DstOpcode), DstDomain(DstDomain) {}
+ bool isLegal(const MachineInstr *MI,
+ const TargetInstrInfo *TII) const override {
+ if (!InstrConverterBase::isLegal(MI, TII))
+ return false;
+
+ // Don't allow copies to/flow GR8/GR16 physical registers.
+ // FIXME: Is there some better way to support this?
+ unsigned DstReg = MI->getOperand(0).getReg();
+ if (TargetRegisterInfo::isPhysicalRegister(DstReg) &&
+ (X86::GR8RegClass.contains(DstReg) ||
+ X86::GR16RegClass.contains(DstReg)))
+ return false;
+ unsigned SrcReg = MI->getOperand(1).getReg();
+ if (TargetRegisterInfo::isPhysicalRegister(SrcReg) &&
+ (X86::GR8RegClass.contains(SrcReg) ||
+ X86::GR16RegClass.contains(SrcReg)))
+ return false;
+
+ return true;
+ }
+
double getExtraCost(const MachineInstr *MI,
MachineRegisterInfo *MRI) const override {
assert(MI->getOpcode() == TargetOpcode::COPY && "Expected a COPY");
diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp
index 2820004cfc6d..67a127fe0a2b 100644
--- a/lib/Target/X86/X86ISelLowering.cpp
+++ b/lib/Target/X86/X86ISelLowering.cpp
@@ -23312,15 +23312,14 @@ static SDValue LowerScalarVariableShift(SDValue Op, SelectionDAG &DAG,
}
// Check cases (mainly 32-bit) where i64 is expanded into high and low parts.
- if (VT == MVT::v2i64 && Amt.getOpcode() == ISD::BITCAST &&
+ if (VT == MVT::v2i64 && Amt.getOpcode() == ISD::BITCAST &&
Amt.getOperand(0).getOpcode() == ISD::BUILD_VECTOR) {
Amt = Amt.getOperand(0);
- unsigned Ratio = Amt.getSimpleValueType().getVectorNumElements() /
- VT.getVectorNumElements();
+ unsigned Ratio = 64 / Amt.getScalarValueSizeInBits();
std::vector<SDValue> Vals(Ratio);
for (unsigned i = 0; i != Ratio; ++i)
Vals[i] = Amt.getOperand(i);
- for (unsigned i = Ratio; i != Amt.getNumOperands(); i += Ratio) {
+ for (unsigned i = Ratio, e = Amt.getNumOperands(); i != e; i += Ratio) {
for (unsigned j = 0; j != Ratio; ++j)
if (Vals[j] != Amt.getOperand(i + j))
return SDValue();
diff --git a/lib/Target/X86/X86InstrInfo.cpp b/lib/Target/X86/X86InstrInfo.cpp
index 96db8b4e7585..e56452362168 100644
--- a/lib/Target/X86/X86InstrInfo.cpp
+++ b/lib/Target/X86/X86InstrInfo.cpp
@@ -3109,7 +3109,7 @@ void X86InstrInfo::copyPhysReg(MachineBasicBlock &MBB,
LLVM_DEBUG(dbgs() << "Cannot copy " << RI.getName(SrcReg) << " to "
<< RI.getName(DestReg) << '\n');
- llvm_unreachable("Cannot emit physreg copy instruction");
+ report_fatal_error("Cannot emit physreg copy instruction");
}
bool X86InstrInfo::isCopyInstr(const MachineInstr &MI,
diff --git a/lib/Transforms/IPO/FunctionImport.cpp b/lib/Transforms/IPO/FunctionImport.cpp
index 15808a073894..ed97d342f348 100644
--- a/lib/Transforms/IPO/FunctionImport.cpp
+++ b/lib/Transforms/IPO/FunctionImport.cpp
@@ -258,8 +258,7 @@ static void computeImportForReferencedGlobals(
for (auto &RefSummary : VI.getSummaryList())
if (RefSummary->getSummaryKind() == GlobalValueSummary::GlobalVarKind &&
- // Don't try to import regular LTO summaries added to dummy module.
- !RefSummary->modulePath().empty() &&
+ !RefSummary->notEligibleToImport() &&
!GlobalValue::isInterposableLinkage(RefSummary->linkage()) &&
RefSummary->refs().empty()) {
ImportList[RefSummary->modulePath()].insert(VI.getGUID());
diff --git a/lib/Transforms/Scalar/LoopIdiomRecognize.cpp b/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
index 653948717fb9..eb3188711858 100644
--- a/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
+++ b/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
@@ -921,10 +921,11 @@ bool LoopIdiomRecognize::processLoopStridedStore(
Type *Int8PtrTy = DestInt8PtrTy;
Module *M = TheStore->getModule();
+ StringRef FuncName = "memset_pattern16";
Value *MSP =
- M->getOrInsertFunction("memset_pattern16", Builder.getVoidTy(),
+ M->getOrInsertFunction(FuncName, Builder.getVoidTy(),
Int8PtrTy, Int8PtrTy, IntPtr);
- inferLibFuncAttributes(*M->getFunction("memset_pattern16"), *TLI);
+ inferLibFuncAttributes(M, FuncName, *TLI);
// Otherwise we should form a memset_pattern16. PatternValue is known to be
// an constant array of 16-bytes. Plop the value into a mergable global.
diff --git a/lib/Transforms/Utils/BuildLibCalls.cpp b/lib/Transforms/Utils/BuildLibCalls.cpp
index d0396e6ce47d..245200362018 100644
--- a/lib/Transforms/Utils/BuildLibCalls.cpp
+++ b/lib/Transforms/Utils/BuildLibCalls.cpp
@@ -112,6 +112,14 @@ static bool setNonLazyBind(Function &F) {
return true;
}
+bool llvm::inferLibFuncAttributes(Module *M, StringRef Name,
+ const TargetLibraryInfo &TLI) {
+ Function *F = M->getFunction(Name);
+ if (!F)
+ return false;
+ return inferLibFuncAttributes(*F, TLI);
+}
+
bool llvm::inferLibFuncAttributes(Function &F, const TargetLibraryInfo &TLI) {
LibFunc TheLibFunc;
if (!(TLI.getLibFunc(F, TheLibFunc) && TLI.has(TheLibFunc)))
@@ -755,11 +763,12 @@ Value *llvm::emitStrLen(Value *Ptr, IRBuilder<> &B, const DataLayout &DL,
return nullptr;
Module *M = B.GetInsertBlock()->getModule();
+ StringRef StrlenName = TLI->getName(LibFunc_strlen);
LLVMContext &Context = B.GetInsertBlock()->getContext();
- Constant *StrLen = M->getOrInsertFunction("strlen", DL.getIntPtrType(Context),
+ Constant *StrLen = M->getOrInsertFunction(StrlenName, DL.getIntPtrType(Context),
B.getInt8PtrTy());
- inferLibFuncAttributes(*M->getFunction("strlen"), *TLI);
- CallInst *CI = B.CreateCall(StrLen, castToCStr(Ptr, B), "strlen");
+ inferLibFuncAttributes(M, StrlenName, *TLI);
+ CallInst *CI = B.CreateCall(StrLen, castToCStr(Ptr, B), StrlenName);
if (const Function *F = dyn_cast<Function>(StrLen->stripPointerCasts()))
CI->setCallingConv(F->getCallingConv());
@@ -772,13 +781,14 @@ Value *llvm::emitStrChr(Value *Ptr, char C, IRBuilder<> &B,
return nullptr;
Module *M = B.GetInsertBlock()->getModule();
+ StringRef StrChrName = TLI->getName(LibFunc_strchr);
Type *I8Ptr = B.getInt8PtrTy();
Type *I32Ty = B.getInt32Ty();
Constant *StrChr =
- M->getOrInsertFunction("strchr", I8Ptr, I8Ptr, I32Ty);
- inferLibFuncAttributes(*M->getFunction("strchr"), *TLI);
+ M->getOrInsertFunction(StrChrName, I8Ptr, I8Ptr, I32Ty);
+ inferLibFuncAttributes(M, StrChrName, *TLI);
CallInst *CI = B.CreateCall(
- StrChr, {castToCStr(Ptr, B), ConstantInt::get(I32Ty, C)}, "strchr");
+ StrChr, {castToCStr(Ptr, B), ConstantInt::get(I32Ty, C)}, StrChrName);
if (const Function *F = dyn_cast<Function>(StrChr->stripPointerCasts()))
CI->setCallingConv(F->getCallingConv());
return CI;
@@ -790,13 +800,14 @@ Value *llvm::emitStrNCmp(Value *Ptr1, Value *Ptr2, Value *Len, IRBuilder<> &B,
return nullptr;
Module *M = B.GetInsertBlock()->getModule();
+ StringRef StrNCmpName = TLI->getName(LibFunc_strncmp);
LLVMContext &Context = B.GetInsertBlock()->getContext();
- Value *StrNCmp = M->getOrInsertFunction("strncmp", B.getInt32Ty(),
+ Value *StrNCmp = M->getOrInsertFunction(StrNCmpName, B.getInt32Ty(),
B.getInt8PtrTy(), B.getInt8PtrTy(),
DL.getIntPtrType(Context));
- inferLibFuncAttributes(*M->getFunction("strncmp"), *TLI);
+ inferLibFuncAttributes(M, StrNCmpName, *TLI);
CallInst *CI = B.CreateCall(
- StrNCmp, {castToCStr(Ptr1, B), castToCStr(Ptr2, B), Len}, "strncmp");
+ StrNCmp, {castToCStr(Ptr1, B), castToCStr(Ptr2, B), Len}, StrNCmpName);
if (const Function *F = dyn_cast<Function>(StrNCmp->stripPointerCasts()))
CI->setCallingConv(F->getCallingConv());
@@ -812,7 +823,7 @@ Value *llvm::emitStrCpy(Value *Dst, Value *Src, IRBuilder<> &B,
Module *M = B.GetInsertBlock()->getModule();
Type *I8Ptr = B.getInt8PtrTy();
Value *StrCpy = M->getOrInsertFunction(Name, I8Ptr, I8Ptr, I8Ptr);
- inferLibFuncAttributes(*M->getFunction(Name), *TLI);
+ inferLibFuncAttributes(M, Name, *TLI);
CallInst *CI =
B.CreateCall(StrCpy, {castToCStr(Dst, B), castToCStr(Src, B)}, Name);
if (const Function *F = dyn_cast<Function>(StrCpy->stripPointerCasts()))
@@ -829,9 +840,9 @@ Value *llvm::emitStrNCpy(Value *Dst, Value *Src, Value *Len, IRBuilder<> &B,
Type *I8Ptr = B.getInt8PtrTy();
Value *StrNCpy = M->getOrInsertFunction(Name, I8Ptr, I8Ptr, I8Ptr,
Len->getType());
- inferLibFuncAttributes(*M->getFunction(Name), *TLI);
+ inferLibFuncAttributes(M, Name, *TLI);
CallInst *CI = B.CreateCall(
- StrNCpy, {castToCStr(Dst, B), castToCStr(Src, B), Len}, "strncpy");
+ StrNCpy, {castToCStr(Dst, B), castToCStr(Src, B), Len}, Name);
if (const Function *F = dyn_cast<Function>(StrNCpy->stripPointerCasts()))
CI->setCallingConv(F->getCallingConv());
return CI;
@@ -866,12 +877,13 @@ Value *llvm::emitMemChr(Value *Ptr, Value *Val, Value *Len, IRBuilder<> &B,
return nullptr;
Module *M = B.GetInsertBlock()->getModule();
+ StringRef MemChrName = TLI->getName(LibFunc_memchr);
LLVMContext &Context = B.GetInsertBlock()->getContext();
- Value *MemChr = M->getOrInsertFunction("memchr", B.getInt8PtrTy(),
+ Value *MemChr = M->getOrInsertFunction(MemChrName, B.getInt8PtrTy(),
B.getInt8PtrTy(), B.getInt32Ty(),
DL.getIntPtrType(Context));
- inferLibFuncAttributes(*M->getFunction("memchr"), *TLI);
- CallInst *CI = B.CreateCall(MemChr, {castToCStr(Ptr, B), Val, Len}, "memchr");
+ inferLibFuncAttributes(M, MemChrName, *TLI);
+ CallInst *CI = B.CreateCall(MemChr, {castToCStr(Ptr, B), Val, Len}, MemChrName);
if (const Function *F = dyn_cast<Function>(MemChr->stripPointerCasts()))
CI->setCallingConv(F->getCallingConv());
@@ -885,13 +897,14 @@ Value *llvm::emitMemCmp(Value *Ptr1, Value *Ptr2, Value *Len, IRBuilder<> &B,
return nullptr;
Module *M = B.GetInsertBlock()->getModule();
+ StringRef MemCmpName = TLI->getName(LibFunc_memcmp);
LLVMContext &Context = B.GetInsertBlock()->getContext();
- Value *MemCmp = M->getOrInsertFunction("memcmp", B.getInt32Ty(),
+ Value *MemCmp = M->getOrInsertFunction(MemCmpName, B.getInt32Ty(),
B.getInt8PtrTy(), B.getInt8PtrTy(),
DL.getIntPtrType(Context));
- inferLibFuncAttributes(*M->getFunction("memcmp"), *TLI);
+ inferLibFuncAttributes(M, MemCmpName, *TLI);
CallInst *CI = B.CreateCall(
- MemCmp, {castToCStr(Ptr1, B), castToCStr(Ptr2, B), Len}, "memcmp");
+ MemCmp, {castToCStr(Ptr1, B), castToCStr(Ptr2, B), Len}, MemCmpName);
if (const Function *F = dyn_cast<Function>(MemCmp->stripPointerCasts()))
CI->setCallingConv(F->getCallingConv());
@@ -958,14 +971,15 @@ Value *llvm::emitPutChar(Value *Char, IRBuilder<> &B,
return nullptr;
Module *M = B.GetInsertBlock()->getModule();
- Value *PutChar = M->getOrInsertFunction("putchar", B.getInt32Ty(), B.getInt32Ty());
- inferLibFuncAttributes(*M->getFunction("putchar"), *TLI);
+ StringRef PutCharName = TLI->getName(LibFunc_putchar);
+ Value *PutChar = M->getOrInsertFunction(PutCharName, B.getInt32Ty(), B.getInt32Ty());
+ inferLibFuncAttributes(M, PutCharName, *TLI);
CallInst *CI = B.CreateCall(PutChar,
B.CreateIntCast(Char,
B.getInt32Ty(),
/*isSigned*/true,
"chari"),
- "putchar");
+ PutCharName);
if (const Function *F = dyn_cast<Function>(PutChar->stripPointerCasts()))
CI->setCallingConv(F->getCallingConv());
@@ -978,10 +992,11 @@ Value *llvm::emitPutS(Value *Str, IRBuilder<> &B,
return nullptr;
Module *M = B.GetInsertBlock()->getModule();
+ StringRef PutsName = TLI->getName(LibFunc_puts);
Value *PutS =
- M->getOrInsertFunction("puts", B.getInt32Ty(), B.getInt8PtrTy());
- inferLibFuncAttributes(*M->getFunction("puts"), *TLI);
- CallInst *CI = B.CreateCall(PutS, castToCStr(Str, B), "puts");
+ M->getOrInsertFunction(PutsName, B.getInt32Ty(), B.getInt8PtrTy());
+ inferLibFuncAttributes(M, PutsName, *TLI);
+ CallInst *CI = B.CreateCall(PutS, castToCStr(Str, B), PutsName);
if (const Function *F = dyn_cast<Function>(PutS->stripPointerCasts()))
CI->setCallingConv(F->getCallingConv());
return CI;
@@ -993,13 +1008,14 @@ Value *llvm::emitFPutC(Value *Char, Value *File, IRBuilder<> &B,
return nullptr;
Module *M = B.GetInsertBlock()->getModule();
- Constant *F = M->getOrInsertFunction("fputc", B.getInt32Ty(), B.getInt32Ty(),
+ StringRef FPutcName = TLI->getName(LibFunc_fputc);
+ Constant *F = M->getOrInsertFunction(FPutcName, B.getInt32Ty(), B.getInt32Ty(),
File->getType());
if (File->getType()->isPointerTy())
- inferLibFuncAttributes(*M->getFunction("fputc"), *TLI);
+ inferLibFuncAttributes(M, FPutcName, *TLI);
Char = B.CreateIntCast(Char, B.getInt32Ty(), /*isSigned*/true,
"chari");
- CallInst *CI = B.CreateCall(F, {Char, File}, "fputc");
+ CallInst *CI = B.CreateCall(F, {Char, File}, FPutcName);
if (const Function *Fn = dyn_cast<Function>(F->stripPointerCasts()))
CI->setCallingConv(Fn->getCallingConv());
@@ -1012,12 +1028,13 @@ Value *llvm::emitFPutCUnlocked(Value *Char, Value *File, IRBuilder<> &B,
return nullptr;
Module *M = B.GetInsertBlock()->getModule();
- Constant *F = M->getOrInsertFunction("fputc_unlocked", B.getInt32Ty(),
+ StringRef FPutcUnlockedName = TLI->getName(LibFunc_fputc_unlocked);
+ Constant *F = M->getOrInsertFunction(FPutcUnlockedName, B.getInt32Ty(),
B.getInt32Ty(), File->getType());
if (File->getType()->isPointerTy())
- inferLibFuncAttributes(*M->getFunction("fputc_unlocked"), *TLI);
+ inferLibFuncAttributes(M, FPutcUnlockedName, *TLI);
Char = B.CreateIntCast(Char, B.getInt32Ty(), /*isSigned*/ true, "chari");
- CallInst *CI = B.CreateCall(F, {Char, File}, "fputc_unlocked");
+ CallInst *CI = B.CreateCall(F, {Char, File}, FPutcUnlockedName);
if (const Function *Fn = dyn_cast<Function>(F->stripPointerCasts()))
CI->setCallingConv(Fn->getCallingConv());
@@ -1034,8 +1051,8 @@ Value *llvm::emitFPutS(Value *Str, Value *File, IRBuilder<> &B,
Constant *F = M->getOrInsertFunction(
FPutsName, B.getInt32Ty(), B.getInt8PtrTy(), File->getType());
if (File->getType()->isPointerTy())
- inferLibFuncAttributes(*M->getFunction(FPutsName), *TLI);
- CallInst *CI = B.CreateCall(F, {castToCStr(Str, B), File}, "fputs");
+ inferLibFuncAttributes(M, FPutsName, *TLI);
+ CallInst *CI = B.CreateCall(F, {castToCStr(Str, B), File}, FPutsName);
if (const Function *Fn = dyn_cast<Function>(F->stripPointerCasts()))
CI->setCallingConv(Fn->getCallingConv());
@@ -1052,8 +1069,8 @@ Value *llvm::emitFPutSUnlocked(Value *Str, Value *File, IRBuilder<> &B,
Constant *F = M->getOrInsertFunction(FPutsUnlockedName, B.getInt32Ty(),
B.getInt8PtrTy(), File->getType());
if (File->getType()->isPointerTy())
- inferLibFuncAttributes(*M->getFunction(FPutsUnlockedName), *TLI);
- CallInst *CI = B.CreateCall(F, {castToCStr(Str, B), File}, "fputs_unlocked");
+ inferLibFuncAttributes(M, FPutsUnlockedName, *TLI);
+ CallInst *CI = B.CreateCall(F, {castToCStr(Str, B), File}, FPutsUnlockedName);
if (const Function *Fn = dyn_cast<Function>(F->stripPointerCasts()))
CI->setCallingConv(Fn->getCallingConv());
@@ -1073,7 +1090,7 @@ Value *llvm::emitFWrite(Value *Ptr, Value *Size, Value *File, IRBuilder<> &B,
DL.getIntPtrType(Context), DL.getIntPtrType(Context), File->getType());
if (File->getType()->isPointerTy())
- inferLibFuncAttributes(*M->getFunction(FWriteName), *TLI);
+ inferLibFuncAttributes(M, FWriteName, *TLI);
CallInst *CI =
B.CreateCall(F, {castToCStr(Ptr, B), Size,
ConstantInt::get(DL.getIntPtrType(Context), 1), File});
@@ -1089,11 +1106,12 @@ Value *llvm::emitMalloc(Value *Num, IRBuilder<> &B, const DataLayout &DL,
return nullptr;
Module *M = B.GetInsertBlock()->getModule();
+ StringRef MallocName = TLI->getName(LibFunc_malloc);
LLVMContext &Context = B.GetInsertBlock()->getContext();
- Value *Malloc = M->getOrInsertFunction("malloc", B.getInt8PtrTy(),
+ Value *Malloc = M->getOrInsertFunction(MallocName, B.getInt8PtrTy(),
DL.getIntPtrType(Context));
- inferLibFuncAttributes(*M->getFunction("malloc"), *TLI);
- CallInst *CI = B.CreateCall(Malloc, Num, "malloc");
+ inferLibFuncAttributes(M, MallocName, *TLI);
+ CallInst *CI = B.CreateCall(Malloc, Num, MallocName);
if (const Function *F = dyn_cast<Function>(Malloc->stripPointerCasts()))
CI->setCallingConv(F->getCallingConv());
@@ -1107,12 +1125,13 @@ Value *llvm::emitCalloc(Value *Num, Value *Size, const AttributeList &Attrs,
return nullptr;
Module *M = B.GetInsertBlock()->getModule();
+ StringRef CallocName = TLI.getName(LibFunc_calloc);
const DataLayout &DL = M->getDataLayout();
IntegerType *PtrType = DL.getIntPtrType((B.GetInsertBlock()->getContext()));
- Value *Calloc = M->getOrInsertFunction("calloc", Attrs, B.getInt8PtrTy(),
+ Value *Calloc = M->getOrInsertFunction(CallocName, Attrs, B.getInt8PtrTy(),
PtrType, PtrType);
- inferLibFuncAttributes(*M->getFunction("calloc"), TLI);
- CallInst *CI = B.CreateCall(Calloc, {Num, Size}, "calloc");
+ inferLibFuncAttributes(M, CallocName, TLI);
+ CallInst *CI = B.CreateCall(Calloc, {Num, Size}, CallocName);
if (const auto *F = dyn_cast<Function>(Calloc->stripPointerCasts()))
CI->setCallingConv(F->getCallingConv());
@@ -1134,7 +1153,7 @@ Value *llvm::emitFWriteUnlocked(Value *Ptr, Value *Size, Value *N, Value *File,
DL.getIntPtrType(Context), DL.getIntPtrType(Context), File->getType());
if (File->getType()->isPointerTy())
- inferLibFuncAttributes(*M->getFunction(FWriteUnlockedName), *TLI);
+ inferLibFuncAttributes(M, FWriteUnlockedName, *TLI);
CallInst *CI = B.CreateCall(F, {castToCStr(Ptr, B), Size, N, File});
if (const Function *Fn = dyn_cast<Function>(F->stripPointerCasts()))
@@ -1148,11 +1167,12 @@ Value *llvm::emitFGetCUnlocked(Value *File, IRBuilder<> &B,
return nullptr;
Module *M = B.GetInsertBlock()->getModule();
+ StringRef FGetCUnlockedName = TLI->getName(LibFunc_fgetc_unlocked);
Constant *F =
- M->getOrInsertFunction("fgetc_unlocked", B.getInt32Ty(), File->getType());
+ M->getOrInsertFunction(FGetCUnlockedName, B.getInt32Ty(), File->getType());
if (File->getType()->isPointerTy())
- inferLibFuncAttributes(*M->getFunction("fgetc_unlocked"), *TLI);
- CallInst *CI = B.CreateCall(F, File, "fgetc_unlocked");
+ inferLibFuncAttributes(M, FGetCUnlockedName, *TLI);
+ CallInst *CI = B.CreateCall(F, File, FGetCUnlockedName);
if (const Function *Fn = dyn_cast<Function>(F->stripPointerCasts()))
CI->setCallingConv(Fn->getCallingConv());
@@ -1165,12 +1185,13 @@ Value *llvm::emitFGetSUnlocked(Value *Str, Value *Size, Value *File,
return nullptr;
Module *M = B.GetInsertBlock()->getModule();
+ StringRef FGetSUnlockedName = TLI->getName(LibFunc_fgets_unlocked);
Constant *F =
- M->getOrInsertFunction("fgets_unlocked", B.getInt8PtrTy(),
+ M->getOrInsertFunction(FGetSUnlockedName, B.getInt8PtrTy(),
B.getInt8PtrTy(), B.getInt32Ty(), File->getType());
- inferLibFuncAttributes(*M->getFunction("fgets_unlocked"), *TLI);
+ inferLibFuncAttributes(M, FGetSUnlockedName, *TLI);
CallInst *CI =
- B.CreateCall(F, {castToCStr(Str, B), Size, File}, "fgets_unlocked");
+ B.CreateCall(F, {castToCStr(Str, B), Size, File}, FGetSUnlockedName);
if (const Function *Fn = dyn_cast<Function>(F->stripPointerCasts()))
CI->setCallingConv(Fn->getCallingConv());
@@ -1191,7 +1212,7 @@ Value *llvm::emitFReadUnlocked(Value *Ptr, Value *Size, Value *N, Value *File,
DL.getIntPtrType(Context), DL.getIntPtrType(Context), File->getType());
if (File->getType()->isPointerTy())
- inferLibFuncAttributes(*M->getFunction(FReadUnlockedName), *TLI);
+ inferLibFuncAttributes(M, FReadUnlockedName, *TLI);
CallInst *CI = B.CreateCall(F, {castToCStr(Ptr, B), Size, N, File});
if (const Function *Fn = dyn_cast<Function>(F->stripPointerCasts()))
diff --git a/test/CodeGen/X86/known-signbits-vector.ll b/test/CodeGen/X86/known-signbits-vector.ll
index d243616fc452..1e48f8683c3f 100644
--- a/test/CodeGen/X86/known-signbits-vector.ll
+++ b/test/CodeGen/X86/known-signbits-vector.ll
@@ -381,19 +381,26 @@ define <4 x float> @signbits_ashr_sext_select_shuffle_sitofp(<4 x i64> %a0, <4 x
; X32-NEXT: movl %esp, %ebp
; X32-NEXT: andl $-16, %esp
; X32-NEXT: subl $16, %esp
+; X32-NEXT: vmovdqa {{.*#+}} xmm3 = [33,0,63,0]
+; X32-NEXT: vmovdqa {{.*#+}} xmm4 = [0,2147483648,0,2147483648]
+; X32-NEXT: vpsrlq %xmm3, %xmm4, %xmm5
+; X32-NEXT: vpshufd {{.*#+}} xmm6 = xmm3[2,3,0,1]
+; X32-NEXT: vpsrlq %xmm6, %xmm4, %xmm4
+; X32-NEXT: vpblendw {{.*#+}} xmm4 = xmm5[0,1,2,3],xmm4[4,5,6,7]
+; X32-NEXT: vextractf128 $1, %ymm2, %xmm5
+; X32-NEXT: vpsrlq %xmm6, %xmm5, %xmm7
+; X32-NEXT: vpsrlq %xmm3, %xmm5, %xmm5
+; X32-NEXT: vpblendw {{.*#+}} xmm5 = xmm5[0,1,2,3],xmm7[4,5,6,7]
+; X32-NEXT: vpsrlq %xmm6, %xmm2, %xmm6
+; X32-NEXT: vpsrlq %xmm3, %xmm2, %xmm2
+; X32-NEXT: vpblendw {{.*#+}} xmm2 = xmm2[0,1,2,3],xmm6[4,5,6,7]
; X32-NEXT: vpmovsxdq 16(%ebp), %xmm3
+; X32-NEXT: vpxor %xmm4, %xmm5, %xmm5
+; X32-NEXT: vpsubq %xmm4, %xmm5, %xmm5
+; X32-NEXT: vpxor %xmm4, %xmm2, %xmm2
+; X32-NEXT: vpsubq %xmm4, %xmm2, %xmm2
; X32-NEXT: vpmovsxdq 8(%ebp), %xmm4
-; X32-NEXT: vmovdqa {{.*#+}} xmm5 = [33,0,63,0]
-; X32-NEXT: vmovdqa {{.*#+}} xmm6 = [0,2147483648,0,2147483648]
-; X32-NEXT: vpsrlq %xmm5, %xmm6, %xmm6
-; X32-NEXT: vextractf128 $1, %ymm2, %xmm7
-; X32-NEXT: vpsrlq %xmm5, %xmm7, %xmm7
-; X32-NEXT: vpxor %xmm6, %xmm7, %xmm7
-; X32-NEXT: vpsubq %xmm6, %xmm7, %xmm7
-; X32-NEXT: vpsrlq %xmm5, %xmm2, %xmm2
-; X32-NEXT: vpxor %xmm6, %xmm2, %xmm2
-; X32-NEXT: vpsubq %xmm6, %xmm2, %xmm2
-; X32-NEXT: vinsertf128 $1, %xmm7, %ymm2, %ymm2
+; X32-NEXT: vinsertf128 $1, %xmm5, %ymm2, %ymm2
; X32-NEXT: vinsertf128 $1, %xmm3, %ymm4, %ymm3
; X32-NEXT: vextractf128 $1, %ymm1, %xmm4
; X32-NEXT: vextractf128 $1, %ymm0, %xmm5
diff --git a/test/CodeGen/X86/pr38803.ll b/test/CodeGen/X86/pr38803.ll
new file mode 100644
index 000000000000..a1ca27d89b03
--- /dev/null
+++ b/test/CodeGen/X86/pr38803.ll
@@ -0,0 +1,48 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mcpu=skylake-avx512 -mtriple=x86_64-unknown-unknown | FileCheck %s
+
+@b = local_unnamed_addr global i32 0, align 4
+@c = local_unnamed_addr global i32 0, align 4
+@d = local_unnamed_addr global float 0.000000e+00, align 4
+
+define float @_Z3fn2v() {
+; CHECK-LABEL: _Z3fn2v:
+; CHECK: # %bb.0: # %entry
+; CHECK-NEXT: pushq %rax
+; CHECK-NEXT: .cfi_def_cfa_offset 16
+; CHECK-NEXT: callq _Z1av
+; CHECK-NEXT: # kill: def $al killed $al def $eax
+; CHECK-NEXT: kmovd %eax, %k1
+; CHECK-NEXT: vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero
+; CHECK-NEXT: vmovss %xmm0, %xmm0, %xmm0 {%k1} {z}
+; CHECK-NEXT: cmpl $0, {{.*}}(%rip)
+; CHECK-NEXT: je .LBB0_2
+; CHECK-NEXT: # %bb.1: # %if.then
+; CHECK-NEXT: vcvtsi2ssl {{.*}}(%rip), %xmm1, %xmm1
+; CHECK-NEXT: kmovd %eax, %k1
+; CHECK-NEXT: vxorps %xmm2, %xmm2, %xmm2
+; CHECK-NEXT: vmovss %xmm2, %xmm0, %xmm1 {%k1}
+; CHECK-NEXT: vmovss %xmm1, {{.*}}(%rip)
+; CHECK-NEXT: .LBB0_2: # %if.end
+; CHECK-NEXT: popq %rax
+; CHECK-NEXT: .cfi_def_cfa_offset 8
+; CHECK-NEXT: retq
+entry:
+ %call = tail call zeroext i1 @_Z1av()
+ %cond = select i1 %call, float 7.500000e-01, float 0.000000e+00
+ %0 = load i32, i32* @c, align 4
+ %tobool2 = icmp eq i32 %0, 0
+ br i1 %tobool2, label %if.end, label %if.then
+
+if.then: ; preds = %entry
+ %1 = load i32, i32* @b, align 4
+ %2 = sitofp i32 %1 to float
+ %conv5 = select i1 %call, float 0.000000e+00, float %2
+ store float %conv5, float* @d, align 4
+ br label %if.end
+
+if.end: ; preds = %entry, %if.then
+ ret float %cond
+}
+
+declare zeroext i1 @_Z1av()
diff --git a/test/ThinLTO/X86/Inputs/globals-import-blockaddr.ll b/test/ThinLTO/X86/Inputs/globals-import-blockaddr.ll
new file mode 100644
index 000000000000..fe1fa70ee831
--- /dev/null
+++ b/test/ThinLTO/X86/Inputs/globals-import-blockaddr.ll
@@ -0,0 +1,12 @@
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+@label_addr = internal constant [1 x i8*] [i8* blockaddress(@foo, %lb)], align 8
+
+; Function Attrs: noinline norecurse nounwind optnone uwtable
+define dso_local [1 x i8*]* @foo() {
+ br label %lb
+
+lb:
+ ret [1 x i8*]* @label_addr
+}
diff --git a/test/ThinLTO/X86/globals-import-blockaddr.ll b/test/ThinLTO/X86/globals-import-blockaddr.ll
new file mode 100644
index 000000000000..d4ed674030a7
--- /dev/null
+++ b/test/ThinLTO/X86/globals-import-blockaddr.ll
@@ -0,0 +1,18 @@
+; RUN: opt -module-summary %s -o %t1.bc
+; RUN: opt -module-summary %p/Inputs/globals-import-blockaddr.ll -o %t2.bc
+; RUN: llvm-lto2 run -save-temps %t1.bc -r=%t1.bc,foo,l -r=%t1.bc,main,pl %t2.bc -r=%t2.bc,foo,pl -o %t3
+; RUN: llvm-dis %t3.1.3.import.bc -o - | FileCheck %s
+
+; Verify that we haven't imported GV containing blockaddress
+; CHECK: @label_addr.llvm.0 = external hidden constant
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+declare dso_local [1 x i8*]* @foo();
+
+define dso_local i32 @main() {
+ %p = call [1 x i8*]* @foo()
+ %v = ptrtoint [1 x i8*]* %p to i32
+ ret i32 %v
+}
diff --git a/test/Transforms/InstCombine/pr39177.ll b/test/Transforms/InstCombine/pr39177.ll
new file mode 100644
index 000000000000..35c5ce0d3f62
--- /dev/null
+++ b/test/Transforms/InstCombine/pr39177.ll
@@ -0,0 +1,44 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -instcombine -S | FileCheck %s
+
+%struct._IO_FILE = type { i32, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, %struct._IO_marker*, %struct._IO_FILE*, i32, i32, i64, i16, i8, [1 x i8], i8*, i64, i8*, i8*, i8*, i8*, i64, i32, [20 x i8] }
+%struct._IO_marker = type { %struct._IO_marker*, %struct._IO_FILE*, i32 }
+
+@stderr = external global %struct._IO_FILE*, align 8
+@.str = private constant [8 x i8] c"crash!\0A\00", align 1
+
+@fwrite = alias i64 (i8*, i64, i64, %struct._IO_FILE*), i64 (i8*, i64, i64, %struct._IO_FILE*)* @__fwrite_alias
+
+define i64 @__fwrite_alias(i8* %ptr, i64 %size, i64 %n, %struct._IO_FILE* %s) {
+; CHECK-LABEL: @__fwrite_alias(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: ret i64 0
+;
+entry:
+ %ptr.addr = alloca i8*, align 8
+ %size.addr = alloca i64, align 8
+ %n.addr = alloca i64, align 8
+ %s.addr = alloca %struct._IO_FILE*, align 8
+ store i8* %ptr, i8** %ptr.addr, align 8
+ store i64 %size, i64* %size.addr, align 8
+ store i64 %n, i64* %n.addr, align 8
+ store %struct._IO_FILE* %s, %struct._IO_FILE** %s.addr, align 8
+ ret i64 0
+}
+
+define void @foo() {
+; CHECK-LABEL: @foo(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[TMP0:%.*]] = load %struct._IO_FILE*, %struct._IO_FILE** @stderr, align 8
+; CHECK-NEXT: [[TMP1:%.*]] = call i64 @__fwrite_alias(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i64 7, i64 1, %struct._IO_FILE* [[TMP0]])
+; CHECK-NEXT: ret void
+;
+entry:
+ %retval = alloca i32, align 4
+ store i32 0, i32* %retval, align 4
+ %0 = load %struct._IO_FILE*, %struct._IO_FILE** @stderr, align 8
+ %call = call i32 (%struct._IO_FILE*, i8*, ...) @fprintf(%struct._IO_FILE* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i32 0, i32 0))
+ ret void
+}
+
+declare i32 @fprintf(%struct._IO_FILE*, i8*, ...)
diff --git a/tools/llvm-xray/xray-account.cpp b/tools/llvm-xray/xray-account.cpp
index 2776a8888481..77de1de496f6 100644
--- a/tools/llvm-xray/xray-account.cpp
+++ b/tools/llvm-xray/xray-account.cpp
@@ -358,8 +358,11 @@ void LatencyAccountant::exportStats(const XRayFileHeader &Header, F Fn) const {
break;
}
- if (AccountTop > 0)
- Results.erase(Results.begin() + AccountTop.getValue(), Results.end());
+ if (AccountTop > 0) {
+ auto MaxTop =
+ std::min(AccountTop.getValue(), static_cast<int>(Results.size()));
+ Results.erase(Results.begin() + MaxTop, Results.end());
+ }
for (const auto &R : Results)
Fn(std::get<0>(R), std::get<1>(R), std::get<2>(R));
diff --git a/utils/lit/lit/__init__.py b/utils/lit/lit/__init__.py
index cc166b2a3e3b..73ef855d2674 100644
--- a/utils/lit/lit/__init__.py
+++ b/utils/lit/lit/__init__.py
@@ -2,7 +2,7 @@
__author__ = 'Daniel Dunbar'
__email__ = 'daniel@minormatter.com'
-__versioninfo__ = (0, 7, 0)
+__versioninfo__ = (0, 7, 1)
__version__ = '.'.join(str(v) for v in __versioninfo__) + 'dev'
__all__ = []
diff --git a/utils/lit/lit/builtin_commands/__init__.py b/utils/lit/lit/builtin_commands/__init__.py
new file mode 100644
index 000000000000..e69de29bb2d1
--- /dev/null
+++ b/utils/lit/lit/builtin_commands/__init__.py