svn commit: r278002 - in projects/clang360-import: contrib/llvm/include/llvm/IR contrib/llvm/include/llvm/MC contrib/llvm/include/llvm/Transforms/Utils contrib/llvm/lib/Analysis contrib/llvm/lib/Co...
Dimitry Andric
dim at FreeBSD.org
Sat Jan 31 21:57:46 UTC 2015
Author: dim
Date: Sat Jan 31 21:57:38 2015
New Revision: 278002
URL: https://svnweb.freebsd.org/changeset/base/278002
Log:
Merge llvm 3.6.0rc2 from ^/vendor/llvm/dist, merge clang 3.6.0rc2 from
^/vendor/clang/dist, resolve conflicts, and cleanup patches.
Deleted:
projects/clang360-import/contrib/llvm/patches/patch-06-llvm-r226664-aarch64-x18.diff
projects/clang360-import/contrib/llvm/patches/patch-07-clang-r227062-fixes-x18.diff
Modified:
projects/clang360-import/contrib/llvm/include/llvm/IR/LegacyPassManagers.h
projects/clang360-import/contrib/llvm/include/llvm/MC/MCAsmBackend.h
projects/clang360-import/contrib/llvm/include/llvm/MC/MCAssembler.h
projects/clang360-import/contrib/llvm/include/llvm/MC/MCMachObjectWriter.h
projects/clang360-import/contrib/llvm/include/llvm/MC/MCObjectWriter.h
projects/clang360-import/contrib/llvm/include/llvm/Transforms/Utils/SimplifyLibCalls.h
projects/clang360-import/contrib/llvm/lib/Analysis/ScalarEvolution.cpp
projects/clang360-import/contrib/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
projects/clang360-import/contrib/llvm/lib/CodeGen/MachineFunctionPass.cpp
projects/clang360-import/contrib/llvm/lib/IR/Core.cpp
projects/clang360-import/contrib/llvm/lib/IR/LegacyPassManager.cpp
projects/clang360-import/contrib/llvm/lib/MC/ELFObjectWriter.cpp
projects/clang360-import/contrib/llvm/lib/MC/MCAsmInfoDarwin.cpp
projects/clang360-import/contrib/llvm/lib/MC/MCAssembler.cpp
projects/clang360-import/contrib/llvm/lib/MC/MachObjectWriter.cpp
projects/clang360-import/contrib/llvm/lib/MC/WinCOFFObjectWriter.cpp
projects/clang360-import/contrib/llvm/lib/Support/Triple.cpp
projects/clang360-import/contrib/llvm/lib/Target/AArch64/AArch64CallingConvention.td
projects/clang360-import/contrib/llvm/lib/Target/AArch64/AArch64FastISel.cpp
projects/clang360-import/contrib/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
projects/clang360-import/contrib/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
projects/clang360-import/contrib/llvm/lib/Target/AArch64/AArch64RegisterInfo.cpp
projects/clang360-import/contrib/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp
projects/clang360-import/contrib/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp
projects/clang360-import/contrib/llvm/lib/Target/ARM/ARMLoadStoreOptimizer.cpp
projects/clang360-import/contrib/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
projects/clang360-import/contrib/llvm/lib/Target/ARM/MCTargetDesc/ARMMachObjectWriter.cpp
projects/clang360-import/contrib/llvm/lib/Target/Hexagon/HexagonRemoveSZExtArgs.cpp
projects/clang360-import/contrib/llvm/lib/Target/Mips/Mips16ISelLowering.cpp
projects/clang360-import/contrib/llvm/lib/Target/Mips/Mips32r6InstrInfo.td
projects/clang360-import/contrib/llvm/lib/Target/Mips/MipsISelLowering.cpp
projects/clang360-import/contrib/llvm/lib/Target/Mips/MipsISelLowering.h
projects/clang360-import/contrib/llvm/lib/Target/NVPTX/NVPTXAllocaHoisting.h
projects/clang360-import/contrib/llvm/lib/Target/NVPTX/NVPTXLowerAggrCopies.h
projects/clang360-import/contrib/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMachObjectWriter.cpp
projects/clang360-import/contrib/llvm/lib/Target/R600/AMDGPU.h
projects/clang360-import/contrib/llvm/lib/Target/R600/AMDGPU.td
projects/clang360-import/contrib/llvm/lib/Target/R600/AMDGPUAsmPrinter.cpp
projects/clang360-import/contrib/llvm/lib/Target/R600/AMDGPUISelDAGToDAG.cpp
projects/clang360-import/contrib/llvm/lib/Target/R600/AMDGPUISelLowering.cpp
projects/clang360-import/contrib/llvm/lib/Target/R600/AMDGPUInstrInfo.cpp
projects/clang360-import/contrib/llvm/lib/Target/R600/AMDGPUInstrInfo.h
projects/clang360-import/contrib/llvm/lib/Target/R600/AMDGPUMCInstLower.cpp
projects/clang360-import/contrib/llvm/lib/Target/R600/AMDGPUMCInstLower.h
projects/clang360-import/contrib/llvm/lib/Target/R600/AMDGPUSubtarget.cpp
projects/clang360-import/contrib/llvm/lib/Target/R600/AMDGPUSubtarget.h
projects/clang360-import/contrib/llvm/lib/Target/R600/MCTargetDesc/AMDGPUAsmBackend.cpp
projects/clang360-import/contrib/llvm/lib/Target/R600/SIDefines.h
projects/clang360-import/contrib/llvm/lib/Target/R600/SIISelLowering.cpp
projects/clang360-import/contrib/llvm/lib/Target/R600/SIInstrFormats.td
projects/clang360-import/contrib/llvm/lib/Target/R600/SIInstrInfo.cpp
projects/clang360-import/contrib/llvm/lib/Target/R600/SIInstrInfo.h
projects/clang360-import/contrib/llvm/lib/Target/R600/SIInstrInfo.td
projects/clang360-import/contrib/llvm/lib/Target/R600/SIInstructions.td
projects/clang360-import/contrib/llvm/lib/Target/R600/SIMachineFunctionInfo.h
projects/clang360-import/contrib/llvm/lib/Target/R600/SIPrepareScratchRegs.cpp
projects/clang360-import/contrib/llvm/lib/Target/R600/SIRegisterInfo.cpp
projects/clang360-import/contrib/llvm/lib/Target/R600/SIRegisterInfo.h
projects/clang360-import/contrib/llvm/lib/Target/R600/SIShrinkInstructions.cpp
projects/clang360-import/contrib/llvm/lib/Target/R600/VIInstructions.td
projects/clang360-import/contrib/llvm/lib/Target/Sparc/MCTargetDesc/SparcMCAsmInfo.cpp
projects/clang360-import/contrib/llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
projects/clang360-import/contrib/llvm/lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp
projects/clang360-import/contrib/llvm/lib/Target/X86/MCTargetDesc/X86MachObjectWriter.cpp
projects/clang360-import/contrib/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
projects/clang360-import/contrib/llvm/lib/Transforms/Scalar/GVN.cpp
projects/clang360-import/contrib/llvm/lib/Transforms/Scalar/LoopInstSimplify.cpp
projects/clang360-import/contrib/llvm/lib/Transforms/Utils/LowerSwitch.cpp
projects/clang360-import/contrib/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
projects/clang360-import/contrib/llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
projects/clang360-import/contrib/llvm/lib/Transforms/Utils/SymbolRewriter.cpp
projects/clang360-import/contrib/llvm/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp
projects/clang360-import/contrib/llvm/patches/README.TXT
projects/clang360-import/contrib/llvm/tools/clang/include/clang/Basic/Attr.td
projects/clang360-import/contrib/llvm/tools/clang/include/clang/Basic/AttrDocs.td
projects/clang360-import/contrib/llvm/tools/clang/include/clang/Basic/DiagnosticGroups.td
projects/clang360-import/contrib/llvm/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td
projects/clang360-import/contrib/llvm/tools/clang/include/clang/Sema/AttributeList.h
projects/clang360-import/contrib/llvm/tools/clang/include/clang/Sema/Sema.h
projects/clang360-import/contrib/llvm/tools/clang/include/clang/Sema/SemaInternal.h
projects/clang360-import/contrib/llvm/tools/clang/lib/Basic/Targets.cpp
projects/clang360-import/contrib/llvm/tools/clang/lib/CodeGen/CGDecl.cpp
projects/clang360-import/contrib/llvm/tools/clang/lib/CodeGen/CGDeclCXX.cpp
projects/clang360-import/contrib/llvm/tools/clang/lib/CodeGen/CodeGenModule.cpp
projects/clang360-import/contrib/llvm/tools/clang/lib/CodeGen/ItaniumCXXABI.cpp
projects/clang360-import/contrib/llvm/tools/clang/lib/CodeGen/MicrosoftCXXABI.cpp
projects/clang360-import/contrib/llvm/tools/clang/lib/Driver/Tools.cpp
projects/clang360-import/contrib/llvm/tools/clang/lib/Driver/Tools.h
projects/clang360-import/contrib/llvm/tools/clang/lib/Sema/SemaChecking.cpp
projects/clang360-import/contrib/llvm/tools/clang/lib/Sema/SemaDecl.cpp
projects/clang360-import/contrib/llvm/tools/clang/lib/Sema/SemaDeclAttr.cpp
projects/clang360-import/contrib/llvm/tools/clang/lib/Sema/SemaExpr.cpp
projects/clang360-import/contrib/llvm/tools/clang/lib/Sema/SemaExprCXX.cpp
projects/clang360-import/contrib/llvm/tools/clang/lib/Sema/SemaLookup.cpp
projects/clang360-import/contrib/llvm/tools/clang/lib/Sema/SemaStmt.cpp
projects/clang360-import/contrib/llvm/tools/clang/lib/Sema/SemaStmtAsm.cpp
projects/clang360-import/contrib/llvm/tools/clang/lib/Tooling/ArgumentsAdjusters.cpp
projects/clang360-import/contrib/llvm/tools/clang/utils/TableGen/ClangAttrEmitter.cpp
projects/clang360-import/lib/clang/include/clang/Basic/Version.inc
Directory Properties:
projects/clang360-import/contrib/llvm/ (props changed)
projects/clang360-import/contrib/llvm/tools/clang/ (props changed)
Modified: projects/clang360-import/contrib/llvm/include/llvm/IR/LegacyPassManagers.h
==============================================================================
--- projects/clang360-import/contrib/llvm/include/llvm/IR/LegacyPassManagers.h Sat Jan 31 21:43:46 2015 (r278001)
+++ projects/clang360-import/contrib/llvm/include/llvm/IR/LegacyPassManagers.h Sat Jan 31 21:57:38 2015 (r278002)
@@ -195,6 +195,9 @@ public:
/// then return NULL.
Pass *findAnalysisPass(AnalysisID AID);
+ /// Retrieve the PassInfo for an analysis.
+ const PassInfo *findAnalysisPassInfo(AnalysisID AID) const;
+
/// Find analysis usage information for the pass P.
AnalysisUsage *findAnalysisUsage(Pass *P);
@@ -251,6 +254,12 @@ private:
SmallVector<ImmutablePass *, 16> ImmutablePasses;
DenseMap<Pass *, AnalysisUsage *> AnUsageMap;
+
+ /// Collection of PassInfo objects found via analysis IDs and in this top
+ /// level manager. This is used to memoize queries to the pass registry.
+ /// FIXME: This is an egregious hack because querying the pass registry is
+ /// either slow or racy.
+ mutable DenseMap<AnalysisID, const PassInfo *> AnalysisPassInfos;
};
Modified: projects/clang360-import/contrib/llvm/include/llvm/MC/MCAsmBackend.h
==============================================================================
--- projects/clang360-import/contrib/llvm/include/llvm/MC/MCAsmBackend.h Sat Jan 31 21:43:46 2015 (r278001)
+++ projects/clang360-import/contrib/llvm/include/llvm/MC/MCAsmBackend.h Sat Jan 31 21:57:38 2015 (r278002)
@@ -61,6 +61,12 @@ public:
/// markers. If not, data region directives will be ignored.
bool hasDataInCodeSupport() const { return HasDataInCodeSupport; }
+ /// doesSectionRequireSymbols - Check whether the given section requires that
+ /// all symbols (even temporaries) have symbol table entries.
+ virtual bool doesSectionRequireSymbols(const MCSection &Section) const {
+ return false;
+ }
+
/// @name Target Fixup Interfaces
/// @{
Modified: projects/clang360-import/contrib/llvm/include/llvm/MC/MCAssembler.h
==============================================================================
--- projects/clang360-import/contrib/llvm/include/llvm/MC/MCAssembler.h Sat Jan 31 21:43:46 2015 (r278001)
+++ projects/clang360-import/contrib/llvm/include/llvm/MC/MCAssembler.h Sat Jan 31 21:57:38 2015 (r278002)
@@ -11,7 +11,6 @@
#define LLVM_MC_MCASSEMBLER_H
#include "llvm/ADT/DenseMap.h"
-#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/PointerIntPair.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallString.h"
@@ -882,8 +881,6 @@ private:
iplist<MCSymbolData> Symbols;
- DenseSet<const MCSymbol *> LocalsUsedInReloc;
-
/// The map of sections to their associated assembler backend data.
//
// FIXME: Avoid this indirection?
@@ -983,9 +980,6 @@ private:
MCFragment &F, const MCFixup &Fixup);
public:
- void addLocalUsedInReloc(const MCSymbol &Sym);
- bool isLocalUsedInReloc(const MCSymbol &Sym) const;
-
/// Compute the effective fragment size assuming it is laid out at the given
/// \p SectionAddress and \p FragmentOffset.
uint64_t computeFragmentSize(const MCAsmLayout &Layout,
Modified: projects/clang360-import/contrib/llvm/include/llvm/MC/MCMachObjectWriter.h
==============================================================================
--- projects/clang360-import/contrib/llvm/include/llvm/MC/MCMachObjectWriter.h Sat Jan 31 21:43:46 2015 (r278001)
+++ projects/clang360-import/contrib/llvm/include/llvm/MC/MCMachObjectWriter.h Sat Jan 31 21:57:38 2015 (r278002)
@@ -68,10 +68,12 @@ public:
/// @name API
/// @{
- virtual void RecordRelocation(MachObjectWriter *Writer, MCAssembler &Asm,
+ virtual void RecordRelocation(MachObjectWriter *Writer,
+ const MCAssembler &Asm,
const MCAsmLayout &Layout,
const MCFragment *Fragment,
- const MCFixup &Fixup, MCValue Target,
+ const MCFixup &Fixup,
+ MCValue Target,
uint64_t &FixedValue) = 0;
/// @}
@@ -95,14 +97,8 @@ class MachObjectWriter : public MCObject
/// @name Relocation Data
/// @{
- struct RelAndSymbol {
- const MCSymbolData *Sym;
- MachO::any_relocation_info MRE;
- RelAndSymbol(const MCSymbolData *Sym, const MachO::any_relocation_info &MRE)
- : Sym(Sym), MRE(MRE) {}
- };
-
- llvm::DenseMap<const MCSectionData *, std::vector<RelAndSymbol>> Relocations;
+ llvm::DenseMap<const MCSectionData*,
+ std::vector<MachO::any_relocation_info> > Relocations;
llvm::DenseMap<const MCSectionData*, unsigned> IndirectSymBase;
/// @}
@@ -217,15 +213,9 @@ public:
// - Input errors, where something cannot be correctly encoded. 'as' allows
// these through in many cases.
- // Add a relocation to be output in the object file. At the time this is
- // called, the symbol indexes are not know, so if the relocation refers
- // to a symbol it should be passed as \p RelSymbol so that it can be updated
- // afterwards. If the relocation doesn't refer to a symbol, nullptr should be
- // used.
- void addRelocation(const MCSymbolData *RelSymbol, const MCSectionData *SD,
+ void addRelocation(const MCSectionData *SD,
MachO::any_relocation_info &MRE) {
- RelAndSymbol P(RelSymbol, MRE);
- Relocations[SD].push_back(P);
+ Relocations[SD].push_back(MRE);
}
void RecordScatteredRelocation(const MCAssembler &Asm,
@@ -241,7 +231,7 @@ public:
const MCFixup &Fixup, MCValue Target,
uint64_t &FixedValue);
- void RecordRelocation(MCAssembler &Asm, const MCAsmLayout &Layout,
+ void RecordRelocation(const MCAssembler &Asm, const MCAsmLayout &Layout,
const MCFragment *Fragment, const MCFixup &Fixup,
MCValue Target, bool &IsPCRel,
uint64_t &FixedValue) override;
Modified: projects/clang360-import/contrib/llvm/include/llvm/MC/MCObjectWriter.h
==============================================================================
--- projects/clang360-import/contrib/llvm/include/llvm/MC/MCObjectWriter.h Sat Jan 31 21:43:46 2015 (r278001)
+++ projects/clang360-import/contrib/llvm/include/llvm/MC/MCObjectWriter.h Sat Jan 31 21:57:38 2015 (r278002)
@@ -76,10 +76,12 @@ public:
/// post layout binding. The implementation is responsible for storing
/// information about the relocation so that it can be emitted during
/// WriteObject().
- virtual void RecordRelocation(MCAssembler &Asm, const MCAsmLayout &Layout,
+ virtual void RecordRelocation(const MCAssembler &Asm,
+ const MCAsmLayout &Layout,
const MCFragment *Fragment,
const MCFixup &Fixup, MCValue Target,
- bool &IsPCRel, uint64_t &FixedValue) = 0;
+ bool &IsPCRel,
+ uint64_t &FixedValue) = 0;
/// \brief Check whether the difference (A - B) between two symbol
/// references is fully resolved.
Modified: projects/clang360-import/contrib/llvm/include/llvm/Transforms/Utils/SimplifyLibCalls.h
==============================================================================
--- projects/clang360-import/contrib/llvm/include/llvm/Transforms/Utils/SimplifyLibCalls.h Sat Jan 31 21:43:46 2015 (r278001)
+++ projects/clang360-import/contrib/llvm/include/llvm/Transforms/Utils/SimplifyLibCalls.h Sat Jan 31 21:57:38 2015 (r278002)
@@ -17,6 +17,7 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/IR/IRBuilder.h"
+#include "llvm/Target/TargetLibraryInfo.h"
namespace llvm {
class Value;
@@ -53,8 +54,10 @@ private:
Value *optimizeMemCpyChk(CallInst *CI, IRBuilder<> &B);
Value *optimizeMemMoveChk(CallInst *CI, IRBuilder<> &B);
Value *optimizeMemSetChk(CallInst *CI, IRBuilder<> &B);
- Value *optimizeStrCpyChk(CallInst *CI, IRBuilder<> &B);
- Value *optimizeStrNCpyChk(CallInst *CI, IRBuilder<> &B);
+
+ // Str/Stp cpy are similar enough to be handled in the same functions.
+ Value *optimizeStrpCpyChk(CallInst *CI, IRBuilder<> &B, LibFunc::Func Func);
+ Value *optimizeStrpNCpyChk(CallInst *CI, IRBuilder<> &B, LibFunc::Func Func);
/// \brief Checks whether the call \p CI to a fortified libcall is foldable
/// to the non-fortified version.
Modified: projects/clang360-import/contrib/llvm/lib/Analysis/ScalarEvolution.cpp
==============================================================================
--- projects/clang360-import/contrib/llvm/lib/Analysis/ScalarEvolution.cpp Sat Jan 31 21:43:46 2015 (r278001)
+++ projects/clang360-import/contrib/llvm/lib/Analysis/ScalarEvolution.cpp Sat Jan 31 21:57:38 2015 (r278002)
@@ -3154,8 +3154,9 @@ const SCEV *ScalarEvolution::getMinusSCE
if (LHS == RHS)
return getConstant(LHS->getType(), 0);
- // X - Y --> X + -Y
- return getAddExpr(LHS, getNegativeSCEV(RHS), Flags);
+ // X - Y --> X + -Y.
+ // X -(nsw || nuw) Y --> X + -Y.
+ return getAddExpr(LHS, getNegativeSCEV(RHS));
}
/// getTruncateOrZeroExtend - Return a SCEV corresponding to a conversion of the
@@ -3461,12 +3462,10 @@ const SCEV *ScalarEvolution::createNodeF
if (isKnownPositive(getMinusSCEV(getSCEV(GEP), Ptr)))
Flags = setFlags(Flags, SCEV::FlagNUW);
}
- } else if (const SubOperator *OBO =
- dyn_cast<SubOperator>(BEValueV)) {
- if (OBO->hasNoUnsignedWrap())
- Flags = setFlags(Flags, SCEV::FlagNUW);
- if (OBO->hasNoSignedWrap())
- Flags = setFlags(Flags, SCEV::FlagNSW);
+
+ // We cannot transfer nuw and nsw flags from subtraction
+ // operations -- sub nuw X, Y is not the same as add nuw X, -Y
+ // for instance.
}
const SCEV *StartVal = getSCEV(StartValueV);
Modified: projects/clang360-import/contrib/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
==============================================================================
--- projects/clang360-import/contrib/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp Sat Jan 31 21:43:46 2015 (r278001)
+++ projects/clang360-import/contrib/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp Sat Jan 31 21:57:38 2015 (r278002)
@@ -626,10 +626,7 @@ static uint64_t getBaseTypeSize(DwarfDeb
DIType BaseType = DD->resolve(Ty.getTypeDerivedFrom());
- // If this type is not derived from any type or the type is a declaration then
- // take conservative approach.
- if (!BaseType.isValid() || BaseType.isForwardDecl())
- return Ty.getSizeInBits();
+ assert(BaseType.isValid());
// If this is a derived type, go ahead and get the base type, unless it's a
// reference then it's just the size of the field. Pointer types have no need
@@ -1473,7 +1470,7 @@ void DwarfUnit::constructMemberDIE(DIE &
uint64_t FieldSize = getBaseTypeSize(DD, DT);
uint64_t OffsetInBytes;
- if (Size != FieldSize) {
+ if (FieldSize && Size != FieldSize) {
// Handle bitfield, assume bytes are 8 bits.
addUInt(MemberDie, dwarf::DW_AT_byte_size, None, FieldSize/8);
addUInt(MemberDie, dwarf::DW_AT_bit_size, None, Size);
Modified: projects/clang360-import/contrib/llvm/lib/CodeGen/MachineFunctionPass.cpp
==============================================================================
--- projects/clang360-import/contrib/llvm/lib/CodeGen/MachineFunctionPass.cpp Sat Jan 31 21:43:46 2015 (r278001)
+++ projects/clang360-import/contrib/llvm/lib/CodeGen/MachineFunctionPass.cpp Sat Jan 31 21:57:38 2015 (r278002)
@@ -11,11 +11,19 @@
//
//===----------------------------------------------------------------------===//
-#include "llvm/IR/Function.h"
+#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/Analysis/AliasAnalysis.h"
+#include "llvm/Analysis/DominanceFrontier.h"
+#include "llvm/Analysis/IVUsers.h"
+#include "llvm/Analysis/LoopInfo.h"
+#include "llvm/Analysis/LoopInfo.h"
+#include "llvm/Analysis/MemoryDependenceAnalysis.h"
+#include "llvm/Analysis/ScalarEvolution.h"
#include "llvm/CodeGen/MachineFunctionAnalysis.h"
-#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/Passes.h"
+#include "llvm/CodeGen/StackProtector.h"
+#include "llvm/IR/Dominators.h"
+#include "llvm/IR/Function.h"
using namespace llvm;
Pass *MachineFunctionPass::createPrinterPass(raw_ostream &O,
@@ -43,15 +51,13 @@ void MachineFunctionPass::getAnalysisUsa
// because CodeGen overloads that to mean preserving the MachineBasicBlock
// CFG in addition to the LLVM IR CFG.
AU.addPreserved<AliasAnalysis>();
- AU.addPreserved("scalar-evolution");
- AU.addPreserved("iv-users");
- AU.addPreserved("memdep");
- AU.addPreserved("live-values");
- AU.addPreserved("domtree");
- AU.addPreserved("domfrontier");
- AU.addPreserved("loops");
- AU.addPreserved("lda");
- AU.addPreserved("stack-protector");
+ AU.addPreserved<DominanceFrontier>();
+ AU.addPreserved<DominatorTreeWrapperPass>();
+ AU.addPreserved<IVUsers>();
+ AU.addPreserved<LoopInfo>();
+ AU.addPreserved<MemoryDependenceAnalysis>();
+ AU.addPreserved<ScalarEvolution>();
+ AU.addPreserved<StackProtector>();
FunctionPass::getAnalysisUsage(AU);
}
Modified: projects/clang360-import/contrib/llvm/lib/IR/Core.cpp
==============================================================================
--- projects/clang360-import/contrib/llvm/lib/IR/Core.cpp Sat Jan 31 21:43:46 2015 (r278001)
+++ projects/clang360-import/contrib/llvm/lib/IR/Core.cpp Sat Jan 31 21:57:38 2015 (r278002)
@@ -563,9 +563,23 @@ LLVMValueRef LLVMGetMetadata(LLVMValueRe
return nullptr;
}
-void LLVMSetMetadata(LLVMValueRef Inst, unsigned KindID, LLVMValueRef MD) {
- MDNode *N =
- MD ? cast<MDNode>(unwrap<MetadataAsValue>(MD)->getMetadata()) : nullptr;
+// MetadataAsValue uses a canonical format which strips the actual MDNode for
+// MDNode with just a single constant value, storing just a ConstantAsMetadata
+// This undoes this canonicalization, reconstructing the MDNode.
+static MDNode *extractMDNode(MetadataAsValue *MAV) {
+ Metadata *MD = MAV->getMetadata();
+ assert((isa<MDNode>(MD) || isa<ConstantAsMetadata>(MD)) &&
+ "Expected a metadata node or a canonicalized constant");
+
+ if (MDNode *N = dyn_cast<MDNode>(MD))
+ return N;
+
+ return MDNode::get(MAV->getContext(), MD);
+}
+
+void LLVMSetMetadata(LLVMValueRef Inst, unsigned KindID, LLVMValueRef Val) {
+ MDNode *N = Val ? extractMDNode(unwrap<MetadataAsValue>(Val)) : nullptr;
+
unwrap<Instruction>(Inst)->setMetadata(KindID, N);
}
@@ -795,7 +809,7 @@ void LLVMAddNamedMetadataOperand(LLVMMod
return;
if (!Val)
return;
- N->addOperand(cast<MDNode>(unwrap<MetadataAsValue>(Val)->getMetadata()));
+ N->addOperand(extractMDNode(unwrap<MetadataAsValue>(Val)));
}
/*--.. Operations on scalar constants ......................................--*/
Modified: projects/clang360-import/contrib/llvm/lib/IR/LegacyPassManager.cpp
==============================================================================
--- projects/clang360-import/contrib/llvm/lib/IR/LegacyPassManager.cpp Sat Jan 31 21:43:46 2015 (r278001)
+++ projects/clang360-import/contrib/llvm/lib/IR/LegacyPassManager.cpp Sat Jan 31 21:57:38 2015 (r278002)
@@ -600,8 +600,7 @@ void PMTopLevelManager::schedulePass(Pas
// If P is an analysis pass and it is available then do not
// generate the analysis again. Stale analysis info should not be
// available at this point.
- const PassInfo *PI =
- PassRegistry::getPassRegistry()->getPassInfo(P->getPassID());
+ const PassInfo *PI = findAnalysisPassInfo(P->getPassID());
if (PI && PI->isAnalysis() && findAnalysisPass(P->getPassID())) {
delete P;
return;
@@ -619,7 +618,7 @@ void PMTopLevelManager::schedulePass(Pas
Pass *AnalysisPass = findAnalysisPass(*I);
if (!AnalysisPass) {
- const PassInfo *PI = PassRegistry::getPassRegistry()->getPassInfo(*I);
+ const PassInfo *PI = findAnalysisPassInfo(*I);
if (!PI) {
// Pass P is not in the global PassRegistry
@@ -716,8 +715,7 @@ Pass *PMTopLevelManager::findAnalysisPas
return *I;
// If Pass not found then check the interfaces implemented by Immutable Pass
- const PassInfo *PassInf =
- PassRegistry::getPassRegistry()->getPassInfo(PI);
+ const PassInfo *PassInf = findAnalysisPassInfo(PI);
assert(PassInf && "Expected all immutable passes to be initialized");
const std::vector<const PassInfo*> &ImmPI =
PassInf->getInterfacesImplemented();
@@ -731,6 +729,17 @@ Pass *PMTopLevelManager::findAnalysisPas
return nullptr;
}
+const PassInfo *PMTopLevelManager::findAnalysisPassInfo(AnalysisID AID) const {
+ const PassInfo *&PI = AnalysisPassInfos[AID];
+ if (!PI)
+ PI = PassRegistry::getPassRegistry()->getPassInfo(AID);
+ else
+ assert(PI == PassRegistry::getPassRegistry()->getPassInfo(AID) &&
+ "The pass info pointer changed for an analysis ID!");
+
+ return PI;
+}
+
// Print passes managed by this top level manager.
void PMTopLevelManager::dumpPasses() const {
@@ -759,8 +768,7 @@ void PMTopLevelManager::dumpArguments()
dbgs() << "Pass Arguments: ";
for (SmallVectorImpl<ImmutablePass *>::const_iterator I =
ImmutablePasses.begin(), E = ImmutablePasses.end(); I != E; ++I)
- if (const PassInfo *PI =
- PassRegistry::getPassRegistry()->getPassInfo((*I)->getPassID())) {
+ if (const PassInfo *PI = findAnalysisPassInfo((*I)->getPassID())) {
assert(PI && "Expected all immutable passes to be initialized");
if (!PI->isAnalysisGroup())
dbgs() << " -" << PI->getPassArgument();
@@ -824,7 +832,7 @@ void PMDataManager::recordAvailableAnaly
// This pass is the current implementation of all of the interfaces it
// implements as well.
- const PassInfo *PInf = PassRegistry::getPassRegistry()->getPassInfo(PI);
+ const PassInfo *PInf = TPM->findAnalysisPassInfo(PI);
if (!PInf) return;
const std::vector<const PassInfo*> &II = PInf->getInterfacesImplemented();
for (unsigned i = 0, e = II.size(); i != e; ++i)
@@ -957,7 +965,7 @@ void PMDataManager::freePass(Pass *P, St
}
AnalysisID PI = P->getPassID();
- if (const PassInfo *PInf = PassRegistry::getPassRegistry()->getPassInfo(PI)) {
+ if (const PassInfo *PInf = TPM->findAnalysisPassInfo(PI)) {
// Remove the pass itself (if it is not already removed).
AvailableAnalysis.erase(PI);
@@ -1037,7 +1045,7 @@ void PMDataManager::add(Pass *P, bool Pr
for (SmallVectorImpl<AnalysisID>::iterator
I = ReqAnalysisNotAvailable.begin(),
E = ReqAnalysisNotAvailable.end() ;I != E; ++I) {
- const PassInfo *PI = PassRegistry::getPassRegistry()->getPassInfo(*I);
+ const PassInfo *PI = TPM->findAnalysisPassInfo(*I);
Pass *AnalysisPass = PI->createPass();
this->addLowerLevelRequiredPass(P, AnalysisPass);
}
@@ -1142,7 +1150,7 @@ void PMDataManager::dumpPassArguments()
PMD->dumpPassArguments();
else
if (const PassInfo *PI =
- PassRegistry::getPassRegistry()->getPassInfo((*I)->getPassID()))
+ TPM->findAnalysisPassInfo((*I)->getPassID()))
if (!PI->isAnalysisGroup())
dbgs() << " -" << PI->getPassArgument();
}
@@ -1218,7 +1226,7 @@ void PMDataManager::dumpAnalysisUsage(St
dbgs() << (const void*)P << std::string(getDepth()*2+3, ' ') << Msg << " Analyses:";
for (unsigned i = 0; i != Set.size(); ++i) {
if (i) dbgs() << ',';
- const PassInfo *PInf = PassRegistry::getPassRegistry()->getPassInfo(Set[i]);
+ const PassInfo *PInf = TPM->findAnalysisPassInfo(Set[i]);
if (!PInf) {
// Some preserved passes, such as AliasAnalysis, may not be initialized by
// all drivers.
@@ -1658,8 +1666,8 @@ void MPPassManager::addLowerLevelRequire
OnTheFlyManagers[P] = FPP;
}
- const PassInfo * RequiredPassPI =
- PassRegistry::getPassRegistry()->getPassInfo(RequiredPass->getPassID());
+ const PassInfo *RequiredPassPI =
+ TPM->findAnalysisPassInfo(RequiredPass->getPassID());
Pass *FoundPass = nullptr;
if (RequiredPassPI && RequiredPassPI->isAnalysis()) {
Modified: projects/clang360-import/contrib/llvm/lib/MC/ELFObjectWriter.cpp
==============================================================================
--- projects/clang360-import/contrib/llvm/lib/MC/ELFObjectWriter.cpp Sat Jan 31 21:43:46 2015 (r278001)
+++ projects/clang360-import/contrib/llvm/lib/MC/ELFObjectWriter.cpp Sat Jan 31 21:57:38 2015 (r278002)
@@ -219,7 +219,7 @@ class ELFObjectWriter : public MCObjectW
const MCSymbolData *SD, uint64_t C,
unsigned Type) const;
- void RecordRelocation(MCAssembler &Asm, const MCAsmLayout &Layout,
+ void RecordRelocation(const MCAssembler &Asm, const MCAsmLayout &Layout,
const MCFragment *Fragment, const MCFixup &Fixup,
MCValue Target, bool &IsPCRel,
uint64_t &FixedValue) override;
@@ -789,11 +789,13 @@ static const MCSymbol *getWeakRef(const
return nullptr;
}
-void ELFObjectWriter::RecordRelocation(MCAssembler &Asm,
+void ELFObjectWriter::RecordRelocation(const MCAssembler &Asm,
const MCAsmLayout &Layout,
const MCFragment *Fragment,
- const MCFixup &Fixup, MCValue Target,
- bool &IsPCRel, uint64_t &FixedValue) {
+ const MCFixup &Fixup,
+ MCValue Target,
+ bool &IsPCRel,
+ uint64_t &FixedValue) {
const MCSectionData *FixupSection = Fragment->getParent();
uint64_t C = Target.getConstant();
uint64_t FixupOffset = Layout.getFragmentOffset(Fragment) + Fixup.getOffset();
Modified: projects/clang360-import/contrib/llvm/lib/MC/MCAsmInfoDarwin.cpp
==============================================================================
--- projects/clang360-import/contrib/llvm/lib/MC/MCAsmInfoDarwin.cpp Sat Jan 31 21:43:46 2015 (r278001)
+++ projects/clang360-import/contrib/llvm/lib/MC/MCAsmInfoDarwin.cpp Sat Jan 31 21:57:38 2015 (r278002)
@@ -27,7 +27,22 @@ bool MCAsmInfoDarwin::isSectionAtomizabl
// contain.
// Sections holding 2 byte strings require symbols in order to be atomized.
// There is no dedicated section for 4 byte strings.
- if (SMO.getType() == MachO::S_CSTRING_LITERALS)
+ if (SMO.getKind().isMergeable1ByteCString())
+ return false;
+
+ if (SMO.getSegmentName() == "__TEXT" &&
+ SMO.getSectionName() == "__objc_classname" &&
+ SMO.getType() == MachO::S_CSTRING_LITERALS)
+ return false;
+
+ if (SMO.getSegmentName() == "__TEXT" &&
+ SMO.getSectionName() == "__objc_methname" &&
+ SMO.getType() == MachO::S_CSTRING_LITERALS)
+ return false;
+
+ if (SMO.getSegmentName() == "__TEXT" &&
+ SMO.getSectionName() == "__objc_methtype" &&
+ SMO.getType() == MachO::S_CSTRING_LITERALS)
return false;
if (SMO.getSegmentName() == "__DATA" && SMO.getSectionName() == "__cfstring")
Modified: projects/clang360-import/contrib/llvm/lib/MC/MCAssembler.cpp
==============================================================================
--- projects/clang360-import/contrib/llvm/lib/MC/MCAssembler.cpp Sat Jan 31 21:43:46 2015 (r278001)
+++ projects/clang360-import/contrib/llvm/lib/MC/MCAssembler.cpp Sat Jan 31 21:57:38 2015 (r278002)
@@ -425,16 +425,6 @@ bool MCAssembler::isThumbFunc(const MCSy
return true;
}
-void MCAssembler::addLocalUsedInReloc(const MCSymbol &Sym) {
- assert(Sym.isTemporary());
- LocalsUsedInReloc.insert(&Sym);
-}
-
-bool MCAssembler::isLocalUsedInReloc(const MCSymbol &Sym) const {
- assert(Sym.isTemporary());
- return LocalsUsedInReloc.count(&Sym);
-}
-
bool MCAssembler::isSymbolLinkerVisible(const MCSymbol &Symbol) const {
// Non-temporary labels should always be visible to the linker.
if (!Symbol.isTemporary())
@@ -444,10 +434,8 @@ bool MCAssembler::isSymbolLinkerVisible(
if (!Symbol.isInSection())
return false;
- if (isLocalUsedInReloc(Symbol))
- return true;
-
- return false;
+ // Otherwise, check if the section requires symbols even for temporary labels.
+ return getBackend().doesSectionRequireSymbols(Symbol.getSection());
}
const MCSymbolData *MCAssembler::getAtom(const MCSymbolData *SD) const {
Modified: projects/clang360-import/contrib/llvm/lib/MC/MachObjectWriter.cpp
==============================================================================
--- projects/clang360-import/contrib/llvm/lib/MC/MachObjectWriter.cpp Sat Jan 31 21:43:46 2015 (r278001)
+++ projects/clang360-import/contrib/llvm/lib/MC/MachObjectWriter.cpp Sat Jan 31 21:57:38 2015 (r278002)
@@ -448,11 +448,14 @@ void MachObjectWriter::WriteLinkerOption
assert(OS.tell() - Start == Size);
}
-void MachObjectWriter::RecordRelocation(MCAssembler &Asm,
+
+void MachObjectWriter::RecordRelocation(const MCAssembler &Asm,
const MCAsmLayout &Layout,
const MCFragment *Fragment,
- const MCFixup &Fixup, MCValue Target,
- bool &IsPCRel, uint64_t &FixedValue) {
+ const MCFixup &Fixup,
+ MCValue Target,
+ bool &IsPCRel,
+ uint64_t &FixedValue) {
TargetObjectWriter->RecordRelocation(this, Asm, Layout, Fragment, Fixup,
Target, FixedValue);
}
@@ -613,22 +616,6 @@ void MachObjectWriter::ComputeSymbolTabl
ExternalSymbolData[i].SymbolData->setIndex(Index++);
for (unsigned i = 0, e = UndefinedSymbolData.size(); i != e; ++i)
UndefinedSymbolData[i].SymbolData->setIndex(Index++);
-
- for (const MCSectionData &SD : Asm) {
- std::vector<RelAndSymbol> &Relocs = Relocations[&SD];
- for (RelAndSymbol &Rel : Relocs) {
- if (!Rel.Sym)
- continue;
-
- // Set the Index and the IsExtern bit.
- unsigned Index = Rel.Sym->getIndex();
- assert(isInt<24>(Index));
- if (IsLittleEndian)
- Rel.MRE.r_word1 = (Rel.MRE.r_word1 & (-1 << 24)) | Index | (1 << 27);
- else
- Rel.MRE.r_word1 = (Rel.MRE.r_word1 & 0xff) | Index << 8 | (1 << 4);
- }
- }
}
void MachObjectWriter::computeSectionAddresses(const MCAssembler &Asm,
@@ -675,6 +662,10 @@ void MachObjectWriter::ExecutePostLayout
// Mark symbol difference expressions in variables (from .set or = directives)
// as absolute.
markAbsoluteVariableSymbols(Asm, Layout);
+
+ // Compute symbol table information and bind symbol indices.
+ ComputeSymbolTable(Asm, LocalSymbolData, ExternalSymbolData,
+ UndefinedSymbolData);
}
bool MachObjectWriter::
@@ -758,10 +749,6 @@ IsSymbolRefDifferenceFullyResolvedImpl(c
void MachObjectWriter::WriteObject(MCAssembler &Asm,
const MCAsmLayout &Layout) {
- // Compute symbol table information and bind symbol indices.
- ComputeSymbolTable(Asm, LocalSymbolData, ExternalSymbolData,
- UndefinedSymbolData);
-
unsigned NumSections = Asm.size();
const MCAssembler::VersionMinInfoType &VersionInfo =
Layout.getAssembler().getVersionMinInfo();
@@ -852,7 +839,7 @@ void MachObjectWriter::WriteObject(MCAss
uint64_t RelocTableEnd = SectionDataStart + SectionDataFileSize;
for (MCAssembler::const_iterator it = Asm.begin(),
ie = Asm.end(); it != ie; ++it) {
- std::vector<RelAndSymbol> &Relocs = Relocations[it];
+ std::vector<MachO::any_relocation_info> &Relocs = Relocations[it];
unsigned NumRelocs = Relocs.size();
uint64_t SectionStart = SectionDataStart + getSectionAddress(it);
WriteSection(Asm, Layout, *it, SectionStart, RelocTableEnd, NumRelocs);
@@ -946,10 +933,10 @@ void MachObjectWriter::WriteObject(MCAss
ie = Asm.end(); it != ie; ++it) {
// Write the section relocation entries, in reverse order to match 'as'
// (approximately, the exact algorithm is more complicated than this).
- std::vector<RelAndSymbol> &Relocs = Relocations[it];
+ std::vector<MachO::any_relocation_info> &Relocs = Relocations[it];
for (unsigned i = 0, e = Relocs.size(); i != e; ++i) {
- Write32(Relocs[e - i - 1].MRE.r_word0);
- Write32(Relocs[e - i - 1].MRE.r_word1);
+ Write32(Relocs[e - i - 1].r_word0);
+ Write32(Relocs[e - i - 1].r_word1);
}
}
Modified: projects/clang360-import/contrib/llvm/lib/MC/WinCOFFObjectWriter.cpp
==============================================================================
--- projects/clang360-import/contrib/llvm/lib/MC/WinCOFFObjectWriter.cpp Sat Jan 31 21:43:46 2015 (r278001)
+++ projects/clang360-import/contrib/llvm/lib/MC/WinCOFFObjectWriter.cpp Sat Jan 31 21:57:38 2015 (r278002)
@@ -175,7 +175,7 @@ public:
const MCFragment &FB, bool InSet,
bool IsPCRel) const override;
- void RecordRelocation(MCAssembler &Asm, const MCAsmLayout &Layout,
+ void RecordRelocation(const MCAssembler &Asm, const MCAsmLayout &Layout,
const MCFragment *Fragment, const MCFixup &Fixup,
MCValue Target, bool &IsPCRel,
uint64_t &FixedValue) override;
@@ -661,9 +661,13 @@ bool WinCOFFObjectWriter::IsSymbolRefDif
InSet, IsPCRel);
}
-void WinCOFFObjectWriter::RecordRelocation(
- MCAssembler &Asm, const MCAsmLayout &Layout, const MCFragment *Fragment,
- const MCFixup &Fixup, MCValue Target, bool &IsPCRel, uint64_t &FixedValue) {
+void WinCOFFObjectWriter::RecordRelocation(const MCAssembler &Asm,
+ const MCAsmLayout &Layout,
+ const MCFragment *Fragment,
+ const MCFixup &Fixup,
+ MCValue Target,
+ bool &IsPCRel,
+ uint64_t &FixedValue) {
assert(Target.getSymA() && "Relocation must reference a symbol!");
const MCSymbol &Symbol = Target.getSymA()->getSymbol();
Modified: projects/clang360-import/contrib/llvm/lib/Support/Triple.cpp
==============================================================================
--- projects/clang360-import/contrib/llvm/lib/Support/Triple.cpp Sat Jan 31 21:43:46 2015 (r278001)
+++ projects/clang360-import/contrib/llvm/lib/Support/Triple.cpp Sat Jan 31 21:57:38 2015 (r278002)
@@ -246,13 +246,21 @@ static Triple::ArchType parseARMArch(Str
if (ArchName.startswith("armv")) {
offset = 3;
- arch = Triple::arm;
+ if (ArchName.endswith("eb")) {
+ arch = Triple::armeb;
+ ArchName = ArchName.substr(0, ArchName.size() - 2);
+ } else
+ arch = Triple::arm;
} else if (ArchName.startswith("armebv")) {
offset = 5;
arch = Triple::armeb;
} else if (ArchName.startswith("thumbv")) {
offset = 5;
- arch = Triple::thumb;
+ if (ArchName.endswith("eb")) {
+ arch = Triple::thumbeb;
+ ArchName = ArchName.substr(0, ArchName.size() - 2);
+ } else
+ arch = Triple::thumb;
} else if (ArchName.startswith("thumbebv")) {
offset = 7;
arch = Triple::thumbeb;
@@ -271,6 +279,8 @@ static Triple::ArchType parseARMArch(Str
}
static Triple::ArchType parseArch(StringRef ArchName) {
+ Triple::ArchType ARMArch(parseARMArch(ArchName));
+
return StringSwitch<Triple::ArchType>(ArchName)
.Cases("i386", "i486", "i586", "i686", Triple::x86)
// FIXME: Do we need to support these?
@@ -280,9 +290,10 @@ static Triple::ArchType parseArch(String
.Cases("powerpc64", "ppu", Triple::ppc64)
.Case("powerpc64le", Triple::ppc64le)
.Case("xscale", Triple::arm)
- .StartsWith("arm", parseARMArch(ArchName))
- .StartsWith("thumb", parseARMArch(ArchName))
- .StartsWith("aarch64", parseARMArch(ArchName))
+ .Case("xscaleeb", Triple::armeb)
+ .StartsWith("arm", ARMArch)
+ .StartsWith("thumb", ARMArch)
+ .StartsWith("aarch64", ARMArch)
.Case("msp430", Triple::msp430)
.Cases("mips", "mipseb", "mipsallegrex", Triple::mips)
.Cases("mipsel", "mipsallegrexel", Triple::mipsel)
@@ -379,6 +390,9 @@ static Triple::ObjectFormatType parseFor
}
static Triple::SubArchType parseSubArch(StringRef SubArchName) {
+ if (SubArchName.endswith("eb"))
+ SubArchName = SubArchName.substr(0, SubArchName.size() - 2);
+
return StringSwitch<Triple::SubArchType>(SubArchName)
.EndsWith("v8", Triple::ARMSubArch_v8)
.EndsWith("v8a", Triple::ARMSubArch_v8)
@@ -1022,6 +1036,8 @@ const char *Triple::getARMCPUForArch(Str
offset = 5;
if (offset != StringRef::npos && MArch.substr(offset, 2) == "eb")
offset += 2;
+ if (MArch.endswith("eb"))
+ MArch = MArch.substr(0, MArch.size() - 2);
if (offset != StringRef::npos)
result = llvm::StringSwitch<const char *>(MArch.substr(offset))
.Cases("v2", "v2a", "arm2")
Modified: projects/clang360-import/contrib/llvm/lib/Target/AArch64/AArch64CallingConvention.td
==============================================================================
--- projects/clang360-import/contrib/llvm/lib/Target/AArch64/AArch64CallingConvention.td Sat Jan 31 21:43:46 2015 (r278001)
+++ projects/clang360-import/contrib/llvm/lib/Target/AArch64/AArch64CallingConvention.td Sat Jan 31 21:57:38 2015 (r278002)
@@ -204,6 +204,44 @@ def RetCC_AArch64_WebKit_JS : CallingCon
[Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7]>>
]>;
+//===----------------------------------------------------------------------===//
+// ARM64 Calling Convention for GHC
+//===----------------------------------------------------------------------===//
+
+// This calling convention is specific to the Glasgow Haskell Compiler.
+// The only documentation is the GHC source code, specifically the C header
+// file:
+//
+// https://github.com/ghc/ghc/blob/master/includes/stg/MachRegs.h
+//
+// which defines the registers for the Spineless Tagless G-Machine (STG) that
+// GHC uses to implement lazy evaluation. The generic STG machine has a set of
+// registers which are mapped to appropriate set of architecture specific
+// registers for each CPU architecture.
+//
+// The STG Machine is documented here:
+//
+// https://ghc.haskell.org/trac/ghc/wiki/Commentary/Compiler/GeneratedCode
+//
+// The AArch64 register mapping is under the heading "The ARMv8/AArch64 ABI
+// register mapping".
+
+def CC_AArch64_GHC : CallingConv<[
+ // Handle all vector types as either f64 or v2f64.
+ CCIfType<[v1i64, v2i32, v4i16, v8i8, v2f32], CCBitConvertToType<f64>>,
+ CCIfType<[v2i64, v4i32, v8i16, v16i8, v4f32, f128], CCBitConvertToType<v2f64>>,
+
+ CCIfType<[v2f64], CCAssignToReg<[Q4, Q5]>>,
+ CCIfType<[f32], CCAssignToReg<[S8, S9, S10, S11]>>,
+ CCIfType<[f64], CCAssignToReg<[D12, D13, D14, D15]>>,
+
+ // Promote i8/i16/i32 arguments to i64.
+ CCIfType<[i8, i16, i32], CCPromoteToType<i64>>,
+
+ // Pass in STG registers: Base, Sp, Hp, R1, R2, R3, R4, R5, R6, SpLim
+ CCIfType<[i64], CCAssignToReg<[X19, X20, X21, X22, X23, X24, X25, X26, X27, X28]>>
+]>;
+
// FIXME: LR is only callee-saved in the sense that *we* preserve it and are
// presumably a callee to someone. External functions may not do so, but this
// is currently safe since BL has LR as an implicit-def and what happens after a
@@ -249,3 +287,4 @@ def CSR_AArch64_AllRegs
(sequence "S%u", 0, 31), (sequence "D%u", 0, 31),
(sequence "Q%u", 0, 31))>;
+def CSR_AArch64_NoRegs : CalleeSavedRegs<(add)>;
Modified: projects/clang360-import/contrib/llvm/lib/Target/AArch64/AArch64FastISel.cpp
==============================================================================
--- projects/clang360-import/contrib/llvm/lib/Target/AArch64/AArch64FastISel.cpp Sat Jan 31 21:43:46 2015 (r278001)
+++ projects/clang360-import/contrib/llvm/lib/Target/AArch64/AArch64FastISel.cpp Sat Jan 31 21:57:38 2015 (r278002)
@@ -302,6 +302,8 @@ static unsigned getImplicitScaleFactor(M
CCAssignFn *AArch64FastISel::CCAssignFnForCall(CallingConv::ID CC) const {
if (CC == CallingConv::WebKit_JS)
return CC_AArch64_WebKit_JS;
+ if (CC == CallingConv::GHC)
+ return CC_AArch64_GHC;
return Subtarget->isTargetDarwin() ? CC_AArch64_DarwinPCS : CC_AArch64_AAPCS;
}
Modified: projects/clang360-import/contrib/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
==============================================================================
--- projects/clang360-import/contrib/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp Sat Jan 31 21:43:46 2015 (r278001)
+++ projects/clang360-import/contrib/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp Sat Jan 31 21:57:38 2015 (r278002)
@@ -215,6 +215,11 @@ void AArch64FrameLowering::emitPrologue(
bool HasFP = hasFP(MF);
DebugLoc DL = MBB.findDebugLoc(MBBI);
+ // All calls are tail calls in GHC calling conv, and functions have no
+ // prologue/epilogue.
+ if (MF.getFunction()->getCallingConv() == CallingConv::GHC)
+ return;
+
int NumBytes = (int)MFI->getStackSize();
if (!AFI->hasStackFrame()) {
assert(!HasFP && "unexpected function without stack frame but with FP");
@@ -451,6 +456,11 @@ void AArch64FrameLowering::emitEpilogue(
int NumBytes = MFI->getStackSize();
const AArch64FunctionInfo *AFI = MF.getInfo<AArch64FunctionInfo>();
+ // All calls are tail calls in GHC calling conv, and functions have no
+ // prologue/epilogue.
+ if (MF.getFunction()->getCallingConv() == CallingConv::GHC)
+ return;
+
// Initial and residual are named for consitency with the prologue. Note that
// in the epilogue, the residual adjustment is executed first.
uint64_t ArgumentPopSize = 0;
Modified: projects/clang360-import/contrib/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
==============================================================================
--- projects/clang360-import/contrib/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp Sat Jan 31 21:43:46 2015 (r278001)
+++ projects/clang360-import/contrib/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp Sat Jan 31 21:57:38 2015 (r278002)
@@ -1990,6 +1990,8 @@ CCAssignFn *AArch64TargetLowering::CCAss
llvm_unreachable("Unsupported calling convention.");
case CallingConv::WebKit_JS:
return CC_AArch64_WebKit_JS;
+ case CallingConv::GHC:
+ return CC_AArch64_GHC;
case CallingConv::C:
case CallingConv::Fast:
if (!Subtarget->isTargetDarwin())
Modified: projects/clang360-import/contrib/llvm/lib/Target/AArch64/AArch64RegisterInfo.cpp
==============================================================================
--- projects/clang360-import/contrib/llvm/lib/Target/AArch64/AArch64RegisterInfo.cpp Sat Jan 31 21:43:46 2015 (r278001)
+++ projects/clang360-import/contrib/llvm/lib/Target/AArch64/AArch64RegisterInfo.cpp Sat Jan 31 21:57:38 2015 (r278002)
@@ -44,6 +44,10 @@ AArch64RegisterInfo::AArch64RegisterInfo
const MCPhysReg *
AArch64RegisterInfo::getCalleeSavedRegs(const MachineFunction *MF) const {
assert(MF && "Invalid MachineFunction pointer.");
+ if (MF->getFunction()->getCallingConv() == CallingConv::GHC)
+ // GHC set of callee saved regs is empty as all those regs are
+ // used for passing STG regs around
+ return CSR_AArch64_NoRegs_SaveList;
if (MF->getFunction()->getCallingConv() == CallingConv::AnyReg)
return CSR_AArch64_AllRegs_SaveList;
else
@@ -52,6 +56,9 @@ AArch64RegisterInfo::getCalleeSavedRegs(
const uint32_t *
AArch64RegisterInfo::getCallPreservedMask(CallingConv::ID CC) const {
+ if (CC == CallingConv::GHC)
+ // This is academic becase all GHC calls are (supposed to be) tail calls
+ return CSR_AArch64_NoRegs_RegMask;
if (CC == CallingConv::AnyReg)
return CSR_AArch64_AllRegs_RegMask;
else
@@ -67,7 +74,7 @@ const uint32_t *AArch64RegisterInfo::get
}
const uint32_t *
-AArch64RegisterInfo::getThisReturnPreservedMask(CallingConv::ID) const {
+AArch64RegisterInfo::getThisReturnPreservedMask(CallingConv::ID CC) const {
// This should return a register mask that is the same as that returned by
// getCallPreservedMask but that additionally preserves the register used for
// the first i64 argument (which must also be the register used to return a
@@ -75,6 +82,7 @@ AArch64RegisterInfo::getThisReturnPreser
//
// In case that the calling convention does not use the same register for
// both, the function should return NULL (does not currently apply)
+ assert(CC != CallingConv::GHC && "should not be GHC calling convention.");
return CSR_AArch64_AAPCS_ThisReturn_RegMask;
}
Modified: projects/clang360-import/contrib/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp
==============================================================================
--- projects/clang360-import/contrib/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp Sat Jan 31 21:43:46 2015 (r278001)
+++ projects/clang360-import/contrib/llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp Sat Jan 31 21:57:38 2015 (r278002)
@@ -317,6 +317,42 @@ public:
MachO::CPU_SUBTYPE_ARM64_ALL);
}
+ bool doesSectionRequireSymbols(const MCSection &Section) const override {
+ // Any section for which the linker breaks things into atoms needs to
+ // preserve symbols, including assembler local symbols, to identify
+ // those atoms. These sections are:
+ // Sections of type:
+ //
+ // S_CSTRING_LITERALS (e.g. __cstring)
+ // S_LITERAL_POINTERS (e.g. objc selector pointers)
+ // S_16BYTE_LITERALS, S_8BYTE_LITERALS, S_4BYTE_LITERALS
+ //
+ // Sections named:
+ //
+ // __TEXT,__eh_frame
+ // __TEXT,__ustring
+ // __DATA,__cfstring
+ // __DATA,__objc_classrefs
+ // __DATA,__objc_catlist
+ //
+ // FIXME: It would be better if the compiler used actual linker local
+ // symbols for each of these sections rather than preserving what
+ // are ostensibly assembler local symbols.
+ const MCSectionMachO &SMO = static_cast<const MCSectionMachO &>(Section);
+ return (SMO.getType() == MachO::S_CSTRING_LITERALS ||
+ SMO.getType() == MachO::S_4BYTE_LITERALS ||
+ SMO.getType() == MachO::S_8BYTE_LITERALS ||
+ SMO.getType() == MachO::S_16BYTE_LITERALS ||
+ SMO.getType() == MachO::S_LITERAL_POINTERS ||
+ (SMO.getSegmentName() == "__TEXT" &&
+ (SMO.getSectionName() == "__eh_frame" ||
+ SMO.getSectionName() == "__ustring")) ||
+ (SMO.getSegmentName() == "__DATA" &&
+ (SMO.getSectionName() == "__cfstring" ||
+ SMO.getSectionName() == "__objc_classrefs" ||
+ SMO.getSectionName() == "__objc_catlist")));
+ }
+
/// \brief Generate the compact unwind encoding from the CFI directives.
uint32_t generateCompactUnwindEncoding(
ArrayRef<MCCFIInstruction> Instrs) const override {
Modified: projects/clang360-import/contrib/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp
==============================================================================
--- projects/clang360-import/contrib/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp Sat Jan 31 21:43:46 2015 (r278001)
+++ projects/clang360-import/contrib/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp Sat Jan 31 21:57:38 2015 (r278002)
@@ -10,7 +10,6 @@
#include "MCTargetDesc/AArch64FixupKinds.h"
#include "MCTargetDesc/AArch64MCTargetDesc.h"
#include "llvm/ADT/Twine.h"
-#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCAsmLayout.h"
#include "llvm/MC/MCAssembler.h"
#include "llvm/MC/MCContext.h"
@@ -34,7 +33,7 @@ public:
: MCMachObjectTargetWriter(true /* is64Bit */, CPUType, CPUSubtype,
/*UseAggressiveSymbolFolding=*/true) {}
- void RecordRelocation(MachObjectWriter *Writer, MCAssembler &Asm,
+ void RecordRelocation(MachObjectWriter *Writer, const MCAssembler &Asm,
const MCAsmLayout &Layout, const MCFragment *Fragment,
const MCFixup &Fixup, MCValue Target,
uint64_t &FixedValue) override;
@@ -113,25 +112,8 @@ bool AArch64MachObjectWriter::getAArch64
}
}
-static bool canUseLocalRelocation(const MCSectionMachO &Section,
- const MCSymbol &Symbol, unsigned Log2Size) {
- // Debug info sections can use local relocations.
- if (Section.hasAttribute(MachO::S_ATTR_DEBUG))
- return true;
-
- // Otherwise, only pointer sized relocations are supported.
- if (Log2Size != 3)
- return false;
-
- // But only if they don't point to a cstring.
- if (!Symbol.isInSection())
- return true;
- const MCSectionMachO &RefSec = cast<MCSectionMachO>(Symbol.getSection());
- return RefSec.getType() != MachO::S_CSTRING_LITERALS;
-}
-
void AArch64MachObjectWriter::RecordRelocation(
- MachObjectWriter *Writer, MCAssembler &Asm, const MCAsmLayout &Layout,
+ MachObjectWriter *Writer, const MCAssembler &Asm, const MCAsmLayout &Layout,
const MCFragment *Fragment, const MCFixup &Fixup, MCValue Target,
uint64_t &FixedValue) {
unsigned IsPCRel = Writer->isFixupKindPCRel(Asm, Fixup.getKind());
@@ -141,9 +123,9 @@ void AArch64MachObjectWriter::RecordRelo
unsigned Log2Size = 0;
int64_t Value = 0;
unsigned Index = 0;
+ unsigned IsExtern = 0;
unsigned Type = 0;
unsigned Kind = Fixup.getKind();
- const MCSymbolData *RelSymbol = nullptr;
FixupOffset += Fixup.getOffset();
@@ -189,8 +171,10 @@ void AArch64MachObjectWriter::RecordRelo
// FIXME: Should this always be extern?
// SymbolNum of 0 indicates the absolute section.
Type = MachO::ARM64_RELOC_UNSIGNED;
+ Index = 0;
if (IsPCRel) {
+ IsExtern = 1;
Asm.getContext().FatalError(Fixup.getLoc(),
"PC relative absolute relocation!");
@@ -214,12 +198,15 @@ void AArch64MachObjectWriter::RecordRelo
Layout.getSymbolOffset(&B_SD) ==
Layout.getFragmentOffset(Fragment) + Fixup.getOffset()) {
// SymB is the PC, so use a PC-rel pointer-to-GOT relocation.
+ Index = A_Base->getIndex();
+ IsExtern = 1;
Type = MachO::ARM64_RELOC_POINTER_TO_GOT;
IsPCRel = 1;
MachO::any_relocation_info MRE;
MRE.r_word0 = FixupOffset;
- MRE.r_word1 = (IsPCRel << 24) | (Log2Size << 25) | (Type << 28);
- Writer->addRelocation(A_Base, Fragment->getParent(), MRE);
+ MRE.r_word1 = ((Index << 0) | (IsPCRel << 24) | (Log2Size << 25) |
+ (IsExtern << 27) | (Type << 28));
+ Writer->addRelocation(Fragment->getParent(), MRE);
return;
} else if (Target.getSymA()->getKind() != MCSymbolRefExpr::VK_None ||
Target.getSymB()->getKind() != MCSymbolRefExpr::VK_None)
@@ -265,30 +252,25 @@ void AArch64MachObjectWriter::RecordRelo
? 0
: Writer->getSymbolAddress(B_Base, Layout));
+ Index = A_Base->getIndex();
+ IsExtern = 1;
Type = MachO::ARM64_RELOC_UNSIGNED;
MachO::any_relocation_info MRE;
MRE.r_word0 = FixupOffset;
- MRE.r_word1 = (IsPCRel << 24) | (Log2Size << 25) | (Type << 28);
- Writer->addRelocation(A_Base, Fragment->getParent(), MRE);
+ MRE.r_word1 = ((Index << 0) | (IsPCRel << 24) | (Log2Size << 25) |
+ (IsExtern << 27) | (Type << 28));
+ Writer->addRelocation(Fragment->getParent(), MRE);
- RelSymbol = B_Base;
+ Index = B_Base->getIndex();
+ IsExtern = 1;
Type = MachO::ARM64_RELOC_SUBTRACTOR;
} else { // A + constant
const MCSymbol *Symbol = &Target.getSymA()->getSymbol();
- const MCSectionMachO &Section = static_cast<const MCSectionMachO &>(
- Fragment->getParent()->getSection());
-
- bool CanUseLocalRelocation =
- canUseLocalRelocation(Section, *Symbol, Log2Size);
- if (Symbol->isTemporary() && (Value || !CanUseLocalRelocation)) {
- const MCSection &Sec = Symbol->getSection();
- if (!Asm.getContext().getAsmInfo()->isSectionAtomizableBySymbols(Sec))
- Asm.addLocalUsedInReloc(*Symbol);
- }
-
const MCSymbolData &SD = Asm.getSymbolData(*Symbol);
const MCSymbolData *Base = Asm.getAtom(&SD);
*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
More information about the svn-src-projects
mailing list