Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ build_llvm()
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=install \
-DBUILD_SHARED_LIBS=ON \
-DLLVM_TARGETS_TO_BUILD="X86"
-DLLVM_TARGETS_TO_BUILD="X86" \
-DLLVM_BINUTILS_INCDIR=/usr/include
fi
make -j `nproc` install install-clang
rm -rf "../$RELEASE_NAME"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -687,8 +687,8 @@ class OrcRemoteTargetClient : public OrcRemoteTargetRPCAPI {

uint32_t getTrampolineSize() const { return RemoteTrampolineSize; }

Expected<std::vector<char>> readMem(char *Dst, JITTargetAddress Src,
uint64_t Size) {
Expected<std::vector<uint8_t>> readMem(char *Dst, JITTargetAddress Src,
uint64_t Size) {
// Check for an 'out-of-band' error, e.g. from an MM destructor.
if (ExistingError)
return std::move(ExistingError);
Expand Down
7 changes: 6 additions & 1 deletion llvm-4.0.0.src/lib/Transforms/Instrumentation/LowFat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,12 @@ static Bounds getPtrBounds(const TargetLibraryInfo *TLI, const DataLayout *DL,
Bounds bounds = Bounds::nonFat();
if (GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(Ptr))
{
bounds = getPtrBounds(TLI, DL, GEP->getPointerOperand(), boundsInfo);
// JumpThreading or other optimizations may produce incorrect IR that
// has not yet been removed; e.g.
// %231 = getelementptr inbounds i8, i8* %231, i64 1
bounds = GEP != GEP->getPointerOperand() ?
getPtrBounds(TLI, DL, GEP->getPointerOperand(), boundsInfo) :
Bounds::nonFat();
if (!bounds.isUnknown() && !bounds.isNonFat())
{
APInt offset(64, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set(LOWFAT_SOURCES

include_directories(..)

set(LOWFAT_CFLAGS -std=gnu99 -m64 -mno-bmi -mno-bmi2 -mno-lzcnt -I. -O2 -mcmodel=large -DLOWFAT_LINUX)
set(LOWFAT_CFLAGS ${SANITIZER_COMMON_CFLAGS} -std=gnu99 -m64 -mno-bmi -mno-bmi2 -mno-lzcnt -I. -O2 -mcmodel=large -DLOWFAT_LINUX)

add_compiler_rt_runtime(clang_rt.lowfat
STATIC
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set(LOWFAT_SOURCES

include_directories(..)

set(LOWFAT_CFLAGS -std=gnu99 -m64 -I. -O2 -mbmi -mbmi2 -mlzcnt -mcmodel=large -DLOWFAT_LINUX)
set(LOWFAT_CFLAGS ${SANITIZER_COMMON_CFLAGS} -std=gnu99 -m64 -I. -O2 -mbmi -mbmi2 -mlzcnt -mcmodel=large -DLOWFAT_LINUX)

add_compiler_rt_runtime(clang_rt.lowfat
STATIC
Expand Down
26 changes: 3 additions & 23 deletions llvm-4.0.0.src/projects/compiler-rt/lib/lowfat/lowfat.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#define LOWFAT_PAGE_SIZE 4096
#define LOWFAT_MAX_ADDRESS 0x1000000000000ull

#define LOWFAT_CONSTRUCTOR __attribute__((__constructor__(10102)))
#define LOWFAT_CONSTRUCTOR __attribute__((__constructor__(0)))
#define LOWFAT_DESTRUCTOR __attribute__((__destructor__(10102)))
#define LOWFAT_NOINLINE __attribute__((__noinline__))
#define LOWFAT_NORETURN __attribute__((__noreturn__))
Expand Down Expand Up @@ -55,9 +55,6 @@ static LOWFAT_NOINLINE void lowfat_warning(const char *format, ...);
static LOWFAT_DATA uint8_t *lowfat_seed = NULL;
static LOWFAT_DATA size_t lowfat_seed_pos = LOWFAT_PAGE_SIZE;
static LOWFAT_DATA bool lowfat_malloc_inited = false;
#ifndef LOWFAT_WINDOWS
static LOWFAT_DATA char **lowfat_envp = NULL;
#endif

#ifdef LOWFAT_WINDOWS
#include "lowfat_windows.c"
Expand Down Expand Up @@ -527,10 +524,7 @@ extern LOWFAT_NOINLINE void *lowfat_stack_pivot_2(void *stack_top)
// that the environment is stored at the base of the stack, which is
// currently true for Linux. It is also necessary to copy the argv/env
// since we patch the stack.
if (lowfat_envp == NULL)
lowfat_error("failed to get the environment pointer");
char **envp = lowfat_envp;
lowfat_envp = NULL;
char **envp = __environ;
uint8_t *stack_bottom = (void *)envp;
while (*envp != NULL)
{
Expand Down Expand Up @@ -579,26 +573,12 @@ __asm__ (
"\t.type lowfat_stack_pivot,@function\n"
"lowfat_stack_pivot:\n"
"\tmovq %rsp, %rdi\n"
"\tsub $8, %rsp\n"
"\tmovabsq $lowfat_stack_pivot_2, %rax\n"
"\tcallq *%rax\n"
"\tmovq %rax, %rsp\n"
"\tretq\n"
);

/*
* This bit of magic ensures lowfat_init() is called very early in process
* startup. Using the "constructor" attribute is not good enough since shared
* object constructors/initializers may be called before lowfat_init(). We
* also save the environment pointer so we can later derive the stack base.
*/
void lowfat_preinit(int argc, char **argv, char **envp)
{
lowfat_envp = envp;
lowfat_init();
}
__attribute__((section(".preinit_array"), used))
void (*__local_effective_preinit)(int argc, char **argv, char **envp) =
lowfat_preinit;

#endif

4 changes: 4 additions & 0 deletions llvm-4.0.0.src/projects/compiler-rt/lib/lowfat/lowfat_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ static void lowfat_random_page(void *buf)
path);
}

#ifdef __GLIBC__
#include <execinfo.h>
static LOWFAT_NOINLINE void lowfat_backtrace(void)
{
Expand All @@ -73,6 +74,9 @@ static LOWFAT_NOINLINE void lowfat_backtrace(void)
if (len == 0 || len == sizeof(trace) / sizeof(void *))
fprintf(stderr, "...\n");
}
#else
static LOWFAT_NOINLINE void lowfat_backtrace(void) { }
#endif /* __GLIBC__ */

/*
* Open a unique+anonymous shared memory object.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ typedef struct user_fpregs elf_fpregset_t;
# include <sys/procfs.h>
#endif
#include <sys/user.h>
#include <sys/ustat.h>
#include <linux/cyclades.h>
#include <linux/if_eql.h>
#include <linux/if_plip.h>
Expand Down Expand Up @@ -253,7 +252,19 @@ namespace __sanitizer {
#endif // SANITIZER_LINUX || SANITIZER_FREEBSD

#if SANITIZER_LINUX && !SANITIZER_ANDROID
unsigned struct_ustat_sz = sizeof(struct ustat);
// Use pre-computed size of struct ustat to avoid <sys/ustat.h> which
// has been removed from glibc 2.28.
#if defined(__aarch64__) || defined(__s390x__) || defined (__mips64) \
|| defined(__powerpc64__) || defined(__arch64__) || defined(__sparcv9) \
|| defined(__x86_64__)
#define SIZEOF_STRUCT_USTAT 32
#elif defined(__arm__) || defined(__i386__) || defined(__mips__) \
|| defined(__powerpc__) || defined(__s390__)
#define SIZEOF_STRUCT_USTAT 20
#else
#error Unknown size of struct ustat
#endif
unsigned struct_ustat_sz = SIZEOF_STRUCT_USTAT;
unsigned struct_rlimit64_sz = sizeof(struct rlimit64);
unsigned struct_statvfs64_sz = sizeof(struct statvfs64);
#endif // SANITIZER_LINUX && !SANITIZER_ANDROID
Expand Down Expand Up @@ -1147,8 +1158,9 @@ CHECK_SIZE_AND_OFFSET(ipc_perm, uid);
CHECK_SIZE_AND_OFFSET(ipc_perm, gid);
CHECK_SIZE_AND_OFFSET(ipc_perm, cuid);
CHECK_SIZE_AND_OFFSET(ipc_perm, cgid);
#if !defined(__aarch64__) || !SANITIZER_LINUX || __GLIBC_PREREQ (2, 21)
/* On aarch64 glibc 2.20 and earlier provided incorrect mode field. */
#if !SANITIZER_LINUX || __GLIBC_PREREQ (2, 31)
/* glibc 2.30 and earlier provided 16-bit mode field instead of 32-bit
on many architectures. */
CHECK_SIZE_AND_OFFSET(ipc_perm, mode);
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,7 @@ namespace __sanitizer {
unsigned long __unused1;
unsigned long __unused2;
#else
unsigned short mode;
unsigned short __pad1;
unsigned int mode;
unsigned short __seq;
unsigned short __pad2;
#if defined(__x86_64__) && !defined(_LP64)
Expand Down
4 changes: 2 additions & 2 deletions llvm-4.0.0.src/tools/clang/lib/AST/CXXInheritance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ bool CXXRecordDecl::isDerivedFrom(const CXXRecordDecl *Base,
const CXXRecordDecl *BaseDecl = Base->getCanonicalDecl();
// FIXME: Capturing 'this' is a workaround for name lookup bugs in GCC 4.7.
return lookupInBases(
[this, BaseDecl](const CXXBaseSpecifier *Specifier, CXXBasePath &Path) {
[BaseDecl](const CXXBaseSpecifier *Specifier, CXXBasePath &Path) {
return FindBaseClass(Specifier, Path, BaseDecl);
},
Paths);
Expand All @@ -109,7 +109,7 @@ bool CXXRecordDecl::isVirtuallyDerivedFrom(const CXXRecordDecl *Base) const {
const CXXRecordDecl *BaseDecl = Base->getCanonicalDecl();
// FIXME: Capturing 'this' is a workaround for name lookup bugs in GCC 4.7.
return lookupInBases(
[this, BaseDecl](const CXXBaseSpecifier *Specifier, CXXBasePath &Path) {
[BaseDecl](const CXXBaseSpecifier *Specifier, CXXBasePath &Path) {
return FindVirtualBaseClass(Specifier, Path, BaseDecl);
},
Paths);
Expand Down
4 changes: 2 additions & 2 deletions llvm-4.0.0.src/tools/clang/lib/AST/MicrosoftMangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2997,14 +2997,14 @@ void MicrosoftMangleContextImpl::mangleStringLiteral(const StringLiteral *SL,
// N.B. The length is in terms of bytes, not characters.
Mangler.mangleNumber(SL->getByteLength() + SL->getCharByteWidth());

auto GetLittleEndianByte = [&Mangler, &SL](unsigned Index) {
auto GetLittleEndianByte = [&SL](unsigned Index) {
unsigned CharByteWidth = SL->getCharByteWidth();
uint32_t CodeUnit = SL->getCodeUnit(Index / CharByteWidth);
unsigned OffsetInCodeUnit = Index % CharByteWidth;
return static_cast<char>((CodeUnit >> (8 * OffsetInCodeUnit)) & 0xff);
};

auto GetBigEndianByte = [&Mangler, &SL](unsigned Index) {
auto GetBigEndianByte = [&SL](unsigned Index) {
unsigned CharByteWidth = SL->getCharByteWidth();
uint32_t CodeUnit = SL->getCodeUnit(Index / CharByteWidth);
unsigned OffsetInCodeUnit = (CharByteWidth - 1) - (Index % CharByteWidth);
Expand Down
21 changes: 10 additions & 11 deletions llvm-4.0.0.src/tools/clang/lib/CodeGen/CGOpenMPRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4006,8 +4006,8 @@ void CGOpenMPRuntime::emitTaskCall(CodeGenFunction &CGF, SourceLocation Loc,
DepTaskArgs[5] = CGF.Builder.getInt32(0);
DepTaskArgs[6] = llvm::ConstantPointerNull::get(CGF.VoidPtrTy);
}
auto &&ThenCodeGen = [this, Loc, &Data, TDBase, KmpTaskTQTyRD,
NumDependencies, &TaskArgs,
auto &&ThenCodeGen = [this, &Data, TDBase, KmpTaskTQTyRD, NumDependencies,
&TaskArgs,
&DepTaskArgs](CodeGenFunction &CGF, PrePostActionTy &) {
if (!Data.Tied) {
auto PartIdFI = std::next(KmpTaskTQTyRD->field_begin(), KmpTaskTPartId);
Expand Down Expand Up @@ -4562,7 +4562,7 @@ void CGOpenMPRuntime::emitReduction(CodeGenFunction &CGF, SourceLocation Loc,
}
if (XExpr) {
auto *VD = cast<VarDecl>(cast<DeclRefExpr>(*ILHS)->getDecl());
auto &&AtomicRedGen = [BO, VD, IPriv,
auto &&AtomicRedGen = [BO, VD,
Loc](CodeGenFunction &CGF, const Expr *XExpr,
const Expr *EExpr, const Expr *UpExpr) {
LValue X = CGF.EmitLValue(XExpr);
Expand All @@ -4572,7 +4572,7 @@ void CGOpenMPRuntime::emitReduction(CodeGenFunction &CGF, SourceLocation Loc,
CGF.EmitOMPAtomicSimpleUpdateExpr(
X, E, BO, /*IsXLHSInRHSPart=*/true,
llvm::AtomicOrdering::Monotonic, Loc,
[&CGF, UpExpr, VD, IPriv, Loc](RValue XRValue) {
[&CGF, UpExpr, VD, Loc](RValue XRValue) {
CodeGenFunction::OMPPrivateScope PrivateScope(CGF);
PrivateScope.addPrivate(
VD, [&CGF, VD, XRValue, Loc]() -> Address {
Expand Down Expand Up @@ -5984,8 +5984,8 @@ void CGOpenMPRuntime::emitTargetCall(CodeGenFunction &CGF,
OffloadError);

// Fill up the pointer arrays and transfer execution to the device.
auto &&ThenGen = [&Ctx, &BasePointers, &Pointers, &Sizes, &MapTypes, Device,
OutlinedFnID, OffloadError, OffloadErrorQType,
auto &&ThenGen = [&BasePointers, &Pointers, &Sizes, &MapTypes, Device,
OutlinedFnID, OffloadError,
&D](CodeGenFunction &CGF, PrePostActionTy &) {
auto &RT = CGF.CGM.getOpenMPRuntime();
// Emit the offloading arrays.
Expand Down Expand Up @@ -6271,8 +6271,8 @@ void CGOpenMPRuntime::emitTargetDataCalls(
// Generate the code for the opening of the data environment. Capture all the
// arguments of the runtime call by reference because they are used in the
// closing of the region.
auto &&BeginThenGen = [&D, &CGF, Device, &Info, &CodeGen, &NoPrivAction](
CodeGenFunction &CGF, PrePostActionTy &) {
auto &&BeginThenGen = [&D, Device, &Info, &CodeGen](CodeGenFunction &CGF,
PrePostActionTy &) {
// Fill up the arrays with all the mapped variables.
MappableExprsHandler::MapBaseValuesArrayTy BasePointers;
MappableExprsHandler::MapValuesArrayTy Pointers;
Expand Down Expand Up @@ -6318,8 +6318,7 @@ void CGOpenMPRuntime::emitTargetDataCalls(
};

// Generate code for the closing of the data region.
auto &&EndThenGen = [&CGF, Device, &Info](CodeGenFunction &CGF,
PrePostActionTy &) {
auto &&EndThenGen = [Device, &Info](CodeGenFunction &CGF, PrePostActionTy &) {
assert(Info.isValid() && "Invalid data environment closing arguments.");

llvm::Value *BasePointersArrayArg = nullptr;
Expand Down Expand Up @@ -6397,7 +6396,7 @@ void CGOpenMPRuntime::emitTargetDataStandAloneCall(
"Expecting either target enter, exit data, or update directives.");

// Generate the code for the opening of the data environment.
auto &&ThenGen = [&D, &CGF, Device](CodeGenFunction &CGF, PrePostActionTy &) {
auto &&ThenGen = [&D, Device](CodeGenFunction &CGF, PrePostActionTy &) {
// Fill up the arrays with all the mapped variables.
MappableExprsHandler::MapBaseValuesArrayTy BasePointers;
MappableExprsHandler::MapValuesArrayTy Pointers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -533,8 +533,7 @@ void CGOpenMPRuntimeNVPTX::emitGenericParallelCall(
ArrayRef<llvm::Value *> CapturedVars, const Expr *IfCond) {
llvm::Function *Fn = cast<llvm::Function>(OutlinedFn);

auto &&L0ParallelGen = [this, Fn, &CapturedVars](CodeGenFunction &CGF,
PrePostActionTy &) {
auto &&L0ParallelGen = [this, Fn](CodeGenFunction &CGF, PrePostActionTy &) {
CGBuilderTy &Bld = CGF.Builder;

// Prepare for parallel region. Indicate the outlined function.
Expand Down Expand Up @@ -565,8 +564,8 @@ void CGOpenMPRuntimeNVPTX::emitGenericParallelCall(

auto &&SeqGen = [this, Fn, &CapturedVars, &Args](CodeGenFunction &CGF,
PrePostActionTy &) {
auto &&CodeGen = [this, Fn, &CapturedVars, &Args](CodeGenFunction &CGF,
PrePostActionTy &Action) {
auto &&CodeGen = [this, Fn, &CapturedVars](CodeGenFunction &CGF,
PrePostActionTy &Action) {
Action.Enter(CGF);

llvm::SmallVector<llvm::Value *, 16> OutlinedFnArgs;
Expand Down
13 changes: 6 additions & 7 deletions llvm-4.0.0.src/tools/clang/lib/CodeGen/CGStmtOpenMP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -986,7 +986,7 @@ void CodeGenFunction::EmitOMPReductionClauseInit(
OriginalBaseLValue);
// Store the address of the original variable associated with the LHS
// implicit variable.
PrivateScope.addPrivate(LHSVD, [this, OASELValueLB]() -> Address {
PrivateScope.addPrivate(LHSVD, [OASELValueLB]() -> Address {
return OASELValueLB.getAddress();
});
// Emit reduction copy.
Expand Down Expand Up @@ -1040,9 +1040,8 @@ void CodeGenFunction::EmitOMPReductionClauseInit(
*this, OrigVD->getType(), ASELValue.getType(), OriginalBaseLValue);
// Store the address of the original variable associated with the LHS
// implicit variable.
PrivateScope.addPrivate(LHSVD, [this, ASELValue]() -> Address {
return ASELValue.getAddress();
});
PrivateScope.addPrivate(
LHSVD, [ASELValue]() -> Address { return ASELValue.getAddress(); });
// Emit reduction copy.
bool IsRegistered = PrivateScope.addPrivate(
OrigVD, [this, OrigVD, PrivateVD, BaseLValue, ASELValue,
Expand Down Expand Up @@ -2633,7 +2632,7 @@ void CodeGenFunction::EmitOMPTaskBasedDirective(const OMPExecutableDirective &S,
for (const auto *C : S.getClausesOfKind<OMPDependClause>())
for (auto *IRef : C->varlists())
Data.Dependences.push_back(std::make_pair(C->getDependencyKind(), IRef));
auto &&CodeGen = [PartId, &S, &Data, CS, &BodyGen, &LastprivateDstsOrigs](
auto &&CodeGen = [&Data, CS, &BodyGen, &LastprivateDstsOrigs](
CodeGenFunction &CGF, PrePostActionTy &Action) {
// Set proper addresses for generated private copies.
OMPPrivateScope Scope(CGF);
Expand Down Expand Up @@ -3250,7 +3249,7 @@ static void EmitOMPAtomicCaptureExpr(CodeGenFunction &CGF, bool IsSeqCst,
NewVValType = XRValExpr->getType();
auto *ERValExpr = IsXLHSInRHSPart ? RHS : LHS;
auto &&Gen = [&CGF, &NewVVal, UE, ExprRValue, XRValExpr, ERValExpr,
IsSeqCst, IsPostfixUpdate](RValue XRValue) -> RValue {
IsPostfixUpdate](RValue XRValue) -> RValue {
CodeGenFunction::OpaqueValueMapping MapExpr(CGF, ERValExpr, ExprRValue);
CodeGenFunction::OpaqueValueMapping MapX(CGF, XRValExpr, XRValue);
RValue Res = CGF.EmitAnyExpr(UE);
Expand All @@ -3277,7 +3276,7 @@ static void EmitOMPAtomicCaptureExpr(CodeGenFunction &CGF, bool IsSeqCst,
NewVValType = X->getType().getNonReferenceType();
ExprRValue = convertToType(CGF, ExprRValue, E->getType(),
X->getType().getNonReferenceType(), Loc);
auto &&Gen = [&CGF, &NewVVal, ExprRValue](RValue XRValue) -> RValue {
auto &&Gen = [&NewVVal, ExprRValue](RValue XRValue) -> RValue {
NewVVal = XRValue;
return ExprRValue;
};
Expand Down