Merge llvm, clang, compiler-rt, libc++, lld and lldb release_40 branch

r296002, and update build glue.
This commit is contained in:
Dimitry Andric 2017-02-23 19:25:29 +00:00
12 changed files with 90 additions and 62 deletions

View File

@ -522,22 +522,19 @@ DIE *DwarfCompileUnit::constructVariableDIEImpl(const DbgVariable &DV,
}
// .. else use frame index.
if (DV.getFrameIndex().empty())
if (!DV.hasFrameIndexExprs())
return VariableDie;
auto Expr = DV.getExpression().begin();
DIELoc *Loc = new (DIEValueAllocator) DIELoc;
DIEDwarfExpression DwarfExpr(*Asm, *this, *Loc);
for (auto FI : DV.getFrameIndex()) {
for (auto &Fragment : DV.getFrameIndexExprs()) {
unsigned FrameReg = 0;
const TargetFrameLowering *TFI = Asm->MF->getSubtarget().getFrameLowering();
int Offset = TFI->getFrameIndexReference(*Asm->MF, FI, FrameReg);
assert(Expr != DV.getExpression().end() && "Wrong number of expressions");
DwarfExpr.addFragmentOffset(*Expr);
int Offset = TFI->getFrameIndexReference(*Asm->MF, Fragment.FI, FrameReg);
DwarfExpr.addFragmentOffset(Fragment.Expr);
DwarfExpr.AddMachineRegIndirect(*Asm->MF->getSubtarget().getRegisterInfo(),
FrameReg, Offset);
DwarfExpr.AddExpression(*Expr);
++Expr;
DwarfExpr.AddExpression(Fragment.Expr);
}
addBlock(*VariableDie, dwarf::DW_AT_location, DwarfExpr.finalize());

View File

@ -199,6 +199,15 @@ const DIType *DbgVariable::getType() const {
return Ty;
}
ArrayRef<DbgVariable::FrameIndexExpr> DbgVariable::getFrameIndexExprs() const {
std::sort(FrameIndexExprs.begin(), FrameIndexExprs.end(),
[](const FrameIndexExpr &A, const FrameIndexExpr &B) -> bool {
return A.Expr->getFragmentInfo()->OffsetInBits <
B.Expr->getFragmentInfo()->OffsetInBits;
});
return FrameIndexExprs;
}
static const DwarfAccelTable::Atom TypeAtoms[] = {
DwarfAccelTable::Atom(dwarf::DW_ATOM_die_offset, dwarf::DW_FORM_data4),
DwarfAccelTable::Atom(dwarf::DW_ATOM_die_tag, dwarf::DW_FORM_data2),

View File

@ -54,7 +54,7 @@ class MachineModuleInfo;
///
/// Variables can be created from allocas, in which case they're generated from
/// the MMI table. Such variables can have multiple expressions and frame
/// indices. The \a Expr and \a FrameIndices array must match.
/// indices.
///
/// Variables can be created from \c DBG_VALUE instructions. Those whose
/// location changes over time use \a DebugLocListIndex, while those with a
@ -64,11 +64,16 @@ class MachineModuleInfo;
class DbgVariable {
const DILocalVariable *Var; /// Variable Descriptor.
const DILocation *IA; /// Inlined at location.
SmallVector<const DIExpression *, 1> Expr; /// Complex address.
DIE *TheDIE = nullptr; /// Variable DIE.
unsigned DebugLocListIndex = ~0u; /// Offset in DebugLocs.
const MachineInstr *MInsn = nullptr; /// DBG_VALUE instruction.
SmallVector<int, 1> FrameIndex; /// Frame index.
struct FrameIndexExpr {
int FI;
const DIExpression *Expr;
};
mutable SmallVector<FrameIndexExpr, 1>
FrameIndexExprs; /// Frame index + expression.
public:
/// Construct a DbgVariable.
@ -80,21 +85,18 @@ class DbgVariable {
/// Initialize from the MMI table.
void initializeMMI(const DIExpression *E, int FI) {
assert(Expr.empty() && "Already initialized?");
assert(FrameIndex.empty() && "Already initialized?");
assert(FrameIndexExprs.empty() && "Already initialized?");
assert(!MInsn && "Already initialized?");
assert((!E || E->isValid()) && "Expected valid expression");
assert(~FI && "Expected valid index");
Expr.push_back(E);
FrameIndex.push_back(FI);
FrameIndexExprs.push_back({FI, E});
}
/// Initialize from a DBG_VALUE instruction.
void initializeDbgValue(const MachineInstr *DbgValue) {
assert(Expr.empty() && "Already initialized?");
assert(FrameIndex.empty() && "Already initialized?");
assert(FrameIndexExprs.empty() && "Already initialized?");
assert(!MInsn && "Already initialized?");
assert(Var == DbgValue->getDebugVariable() && "Wrong variable");
@ -103,16 +105,15 @@ class DbgVariable {
MInsn = DbgValue;
if (auto *E = DbgValue->getDebugExpression())
if (E->getNumElements())
Expr.push_back(E);
FrameIndexExprs.push_back({0, E});
}
// Accessors.
const DILocalVariable *getVariable() const { return Var; }
const DILocation *getInlinedAt() const { return IA; }
ArrayRef<const DIExpression *> getExpression() const { return Expr; }
const DIExpression *getSingleExpression() const {
assert(MInsn && Expr.size() <= 1);
return Expr.size() ? Expr[0] : nullptr;
assert(MInsn && FrameIndexExprs.size() <= 1);
return FrameIndexExprs.size() ? FrameIndexExprs[0].Expr : nullptr;
}
void setDIE(DIE &D) { TheDIE = &D; }
DIE *getDIE() const { return TheDIE; }
@ -120,7 +121,9 @@ class DbgVariable {
unsigned getDebugLocListIndex() const { return DebugLocListIndex; }
StringRef getName() const { return Var->getName(); }
const MachineInstr *getMInsn() const { return MInsn; }
ArrayRef<int> getFrameIndex() const { return FrameIndex; }
/// Get the FI entries, sorted by fragment offset.
ArrayRef<FrameIndexExpr> getFrameIndexExprs() const;
bool hasFrameIndexExprs() const { return !FrameIndexExprs.empty(); }
void addMMIEntry(const DbgVariable &V) {
assert(DebugLocListIndex == ~0U && !MInsn && "not an MMI entry");
@ -128,16 +131,15 @@ class DbgVariable {
assert(V.Var == Var && "conflicting variable");
assert(V.IA == IA && "conflicting inlined-at location");
assert(!FrameIndex.empty() && "Expected an MMI entry");
assert(!V.FrameIndex.empty() && "Expected an MMI entry");
assert(Expr.size() == FrameIndex.size() && "Mismatched expressions");
assert(V.Expr.size() == V.FrameIndex.size() && "Mismatched expressions");
assert(!FrameIndexExprs.empty() && "Expected an MMI entry");
assert(!V.FrameIndexExprs.empty() && "Expected an MMI entry");
Expr.append(V.Expr.begin(), V.Expr.end());
FrameIndex.append(V.FrameIndex.begin(), V.FrameIndex.end());
assert(all_of(Expr, [](const DIExpression *E) {
return E && E->isFragment();
}) && "conflicting locations for variable");
FrameIndexExprs.append(V.FrameIndexExprs.begin(), V.FrameIndexExprs.end());
assert(all_of(FrameIndexExprs,
[](FrameIndexExpr &FIE) {
return FIE.Expr && FIE.Expr->isFragment();
}) &&
"conflicting locations for variable");
}
// Translate tag to proper Dwarf tag.
@ -167,11 +169,11 @@ class DbgVariable {
bool hasComplexAddress() const {
assert(MInsn && "Expected DBG_VALUE, not MMI variable");
assert(FrameIndex.empty() && "Expected DBG_VALUE, not MMI variable");
assert(
(Expr.empty() || (Expr.size() == 1 && Expr.back()->getNumElements())) &&
assert((FrameIndexExprs.empty() ||
(FrameIndexExprs.size() == 1 &&
FrameIndexExprs[0].Expr->getNumElements())) &&
"Invalid Expr for DBG_VALUE");
return !Expr.empty();
return !FrameIndexExprs.empty();
}
bool isBlockByrefVariable() const;
const DIType *getType() const;

View File

@ -853,9 +853,11 @@ AArch64LoadStoreOpt::promoteLoadFromStore(MachineBasicBlock::iterator LoadI,
.addImm(Imms);
}
}
StoreI->clearRegisterKills(StRt, TRI);
(void)BitExtMI;
// Clear kill flags between store and load.
for (MachineInstr &MI : make_range(StoreI->getIterator(),
BitExtMI->getIterator()))
MI.clearRegisterKills(StRt, TRI);
DEBUG(dbgs() << "Promoting load by replacing :\n ");
DEBUG(StoreI->print(dbgs()));

View File

@ -1225,16 +1225,36 @@ bool ARMExpandPseudo::ExpandMI(MachineBasicBlock &MBB,
}
case ARM::tTPsoft:
case ARM::TPsoft: {
const bool Thumb = Opcode == ARM::tTPsoft;
MachineInstrBuilder MIB;
if (Opcode == ARM::tTPsoft)
if (STI->genLongCalls()) {
MachineFunction *MF = MBB.getParent();
MachineConstantPool *MCP = MF->getConstantPool();
unsigned PCLabelID = AFI->createPICLabelUId();
MachineConstantPoolValue *CPV =
ARMConstantPoolSymbol::Create(MF->getFunction()->getContext(),
"__aeabi_read_tp", PCLabelID, 0);
unsigned Reg = MI.getOperand(0).getReg();
MIB = BuildMI(MBB, MBBI, MI.getDebugLoc(),
TII->get( ARM::tBL))
.addImm((unsigned)ARMCC::AL).addReg(0)
.addExternalSymbol("__aeabi_read_tp", 0);
else
TII->get(Thumb ? ARM::tLDRpci : ARM::LDRi12), Reg)
.addConstantPoolIndex(MCP->getConstantPoolIndex(CPV, 4));
if (!Thumb)
MIB.addImm(0);
MIB.addImm(static_cast<unsigned>(ARMCC::AL)).addReg(0);
MIB = BuildMI(MBB, MBBI, MI.getDebugLoc(),
TII->get( ARM::BL))
.addExternalSymbol("__aeabi_read_tp", 0);
TII->get(Thumb ? ARM::tBLXr : ARM::BLX));
if (Thumb)
MIB.addImm(static_cast<unsigned>(ARMCC::AL)).addReg(0);
MIB.addReg(Reg, RegState::Kill);
} else {
MIB = BuildMI(MBB, MBBI, MI.getDebugLoc(),
TII->get(Thumb ? ARM::tBL : ARM::BL));
if (Thumb)
MIB.addImm(static_cast<unsigned>(ARMCC::AL)).addReg(0);
MIB.addExternalSymbol("__aeabi_read_tp", 0);
}
MIB->setMemRefs(MI.memoperands_begin(), MI.memoperands_end());
TransferImpOps(MI, MIB, MIB);

View File

@ -3027,17 +3027,20 @@ static SDValue promoteToConstantPool(const GlobalValue *GV, SelectionDAG &DAG,
return DAG.getNode(ARMISD::Wrapper, dl, MVT::i32, CPAddr);
}
static bool isReadOnly(const GlobalValue *GV) {
if (const GlobalAlias *GA = dyn_cast<GlobalAlias>(GV))
GV = GA->getBaseObject();
return (isa<GlobalVariable>(GV) && cast<GlobalVariable>(GV)->isConstant()) ||
isa<Function>(GV);
}
SDValue ARMTargetLowering::LowerGlobalAddressELF(SDValue Op,
SelectionDAG &DAG) const {
EVT PtrVT = getPointerTy(DAG.getDataLayout());
SDLoc dl(Op);
const GlobalValue *GV = cast<GlobalAddressSDNode>(Op)->getGlobal();
const TargetMachine &TM = getTargetMachine();
if (const GlobalAlias *GA = dyn_cast<GlobalAlias>(GV))
GV = GA->getBaseObject();
bool IsRO =
(isa<GlobalVariable>(GV) && cast<GlobalVariable>(GV)->isConstant()) ||
isa<Function>(GV);
bool IsRO = isReadOnly(GV);
// promoteToConstantPool only if not generating XO text section
if (TM.shouldAssumeDSOLocal(*GV->getParent(), GV) && !Subtarget->genExecuteOnly())

View File

@ -1196,10 +1196,7 @@ LoopInvariantCodeMotion::collectAliasInfoForLoop(Loop *L, LoopInfo *LI,
auto mergeLoop = [&](Loop *L) {
// Loop over the body of this loop, looking for calls, invokes, and stores.
// Because subloops have already been incorporated into AST, we skip blocks
// in subloops.
for (BasicBlock *BB : L->blocks())
if (LI->getLoopFor(BB) == L) // Ignore blocks in subloops.
CurAST->add(*BB); // Incorporate the specified basic block
};

View File

@ -4705,7 +4705,6 @@ void CGOpenMPRuntime::emitCancellationPointCall(
auto *Result = CGF.EmitRuntimeCall(
createRuntimeFunction(OMPRTL__kmpc_cancellationpoint), Args);
// if (__kmpc_cancellationpoint()) {
// __kmpc_cancel_barrier();
// exit from construct;
// }
auto *ExitBB = CGF.createBasicBlock(".cancel.exit");
@ -4713,8 +4712,6 @@ void CGOpenMPRuntime::emitCancellationPointCall(
auto *Cmp = CGF.Builder.CreateIsNotNull(Result);
CGF.Builder.CreateCondBr(Cmp, ExitBB, ContBB);
CGF.EmitBlock(ExitBB);
// __kmpc_cancel_barrier();
emitBarrierCall(CGF, Loc, OMPD_unknown, /*EmitChecks=*/false);
// exit from construct;
auto CancelDest =
CGF.getOMPCancelDestination(OMPRegionInfo->getDirectiveKind());
@ -4743,7 +4740,6 @@ void CGOpenMPRuntime::emitCancelCall(CodeGenFunction &CGF, SourceLocation Loc,
auto *Result = CGF.EmitRuntimeCall(
RT.createRuntimeFunction(OMPRTL__kmpc_cancel), Args);
// if (__kmpc_cancel()) {
// __kmpc_cancel_barrier();
// exit from construct;
// }
auto *ExitBB = CGF.createBasicBlock(".cancel.exit");
@ -4751,8 +4747,6 @@ void CGOpenMPRuntime::emitCancelCall(CodeGenFunction &CGF, SourceLocation Loc,
auto *Cmp = CGF.Builder.CreateIsNotNull(Result);
CGF.Builder.CreateCondBr(Cmp, ExitBB, ContBB);
CGF.EmitBlock(ExitBB);
// __kmpc_cancel_barrier();
RT.emitBarrierCall(CGF, Loc, OMPD_unknown, /*EmitChecks=*/false);
// exit from construct;
auto CancelDest =
CGF.getOMPCancelDestination(OMPRegionInfo->getDirectiveKind());

View File

@ -8937,6 +8937,10 @@ void openbsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
if (Args.hasArg(options::OPT_pg))
CmdArgs.push_back(
Args.MakeArgString(getToolChain().GetFilePath("gcrt0.o")));
else if (Args.hasArg(options::OPT_static) &&
!Args.hasArg(options::OPT_nopie))
CmdArgs.push_back(
Args.MakeArgString(getToolChain().GetFilePath("rcrt0.o")));
else
CmdArgs.push_back(
Args.MakeArgString(getToolChain().GetFilePath("crt0.o")));

View File

@ -3154,7 +3154,7 @@ getCCForDeclaratorChunk(Sema &S, Declarator &D,
if (Attr->getKind() == AttributeList::AT_OpenCLKernel) {
llvm::Triple::ArchType arch = S.Context.getTargetInfo().getTriple().getArch();
if (arch == llvm::Triple::spir || arch == llvm::Triple::spir64 ||
arch == llvm::Triple::amdgcn) {
arch == llvm::Triple::amdgcn || arch == llvm::Triple::r600) {
CC = CC_OpenCLKernel;
}
break;

View File

@ -8,4 +8,4 @@
#define CLANG_VENDOR "FreeBSD "
#define SVN_REVISION "295380"
#define SVN_REVISION "296002"

View File

@ -4,5 +4,5 @@
#define LLD_VERSION_STRING "4.0.0"
#define LLD_VERSION_MAJOR 4
#define LLD_VERSION_MINOR 0
#define LLD_REVISION_STRING "295380"
#define LLD_REVISION_STRING "296002"
#define LLD_REPOSITORY_STRING "FreeBSD"