Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit 5401fdf

Browse files
TimNNarielb1
authored andcommitted
RUST: Merge fastcomp @ 1.37.10
2 parents c8fccc5 + 2db29c7 commit 5401fdf

File tree

209 files changed

+36314
-12
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

209 files changed

+36314
-12
lines changed

CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ set(LLVM_ALL_TARGETS
327327
ARM
328328
BPF
329329
Hexagon
330+
JSBackend # @LOCALMOD
330331
Lanai
331332
Mips
332333
MSP430

emscripten-version.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"1.37.10"

include/llvm/ADT/Triple.h

+9
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ class Triple {
8181
nvptx64, // NVPTX: 64-bit
8282
le32, // le32: generic little-endian 32-bit CPU (PNaCl)
8383
le64, // le64: generic little-endian 64-bit CPU (PNaCl)
84+
asmjs, // asm.js JavaScript subset @LOCALMOD Emscripten
8485
amdil, // AMDIL
8586
amdil64, // AMDIL with 64-bit pointers
8687
hsail, // AMD HSAIL
@@ -161,6 +162,7 @@ class Triple {
161162
Haiku,
162163
Minix,
163164
RTEMS,
165+
Emscripten, // Emscripten JavaScript runtime @LOCALMOD Emscripten
164166
NaCl, // Native Client
165167
CNK, // BG/P Compute-Node Kernel
166168
Bitrig,
@@ -546,6 +548,13 @@ class Triple {
546548
return getOS() == Triple::NaCl;
547549
}
548550

551+
// @LOCALMOD-START Emscripten
552+
/// Tests whether the OS is Emscripten.
553+
bool isOSEmscripten() const {
554+
return getOS() == Triple::Emscripten;
555+
}
556+
// @LOCALMOD-END Emscripten
557+
549558
/// Tests whether the OS is Linux.
550559
bool isOSLinux() const {
551560
return getOS() == Triple::Linux;

include/llvm/Analysis/NaCl.h

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
//===-- NaCl.h - NaCl Analysis ---------------------------*- C++ -*-===//
2+
//
3+
// The LLVM Compiler Infrastructure
4+
//
5+
// This file is distributed under the University of Illinois Open Source
6+
// License. See LICENSE.TXT for details.
7+
//
8+
//===----------------------------------------------------------------------===//
9+
10+
#ifndef LLVM_ANALYSIS_NACL_H
11+
#define LLVM_ANALYSIS_NACL_H
12+
13+
#include "llvm/Support/CommandLine.h"
14+
#include "llvm/Support/ErrorHandling.h"
15+
#include "llvm/Support/raw_ostream.h"
16+
#include <string>
17+
18+
namespace llvm {
19+
20+
class FunctionPass;
21+
class ModulePass;
22+
extern cl::opt<bool> PNaClABIAllowDebugMetadata;
23+
24+
class PNaClABIErrorReporter {
25+
PNaClABIErrorReporter(const PNaClABIErrorReporter&) = delete;
26+
void operator=(const PNaClABIErrorReporter&) = delete;
27+
public:
28+
PNaClABIErrorReporter() : ErrorCount(0), Errors(ErrorString),
29+
UseFatalErrors(true) {}
30+
~PNaClABIErrorReporter() {}
31+
// Return the number of verification errors from the last run.
32+
int getErrorCount() const { return ErrorCount; }
33+
// Print the error messages to O
34+
void printErrors(llvm::raw_ostream &O) {
35+
Errors.flush();
36+
O << ErrorString;
37+
}
38+
// Increments the error count and returns an ostream to which the error
39+
// message can be streamed.
40+
raw_ostream &addError() {
41+
ErrorCount++;
42+
return Errors;
43+
}
44+
// Reset the error count and error messages.
45+
void reset() {
46+
ErrorCount = 0;
47+
Errors.flush();
48+
ErrorString.clear();
49+
}
50+
void setNonFatal() {
51+
UseFatalErrors = false;
52+
}
53+
void checkForFatalErrors() {
54+
if (UseFatalErrors && ErrorCount != 0) {
55+
printErrors(errs());
56+
report_fatal_error("PNaCl ABI verification failed");
57+
}
58+
}
59+
private:
60+
int ErrorCount;
61+
std::string ErrorString;
62+
raw_string_ostream Errors;
63+
bool UseFatalErrors;
64+
};
65+
66+
FunctionPass *createPNaClABIVerifyFunctionsPass(
67+
PNaClABIErrorReporter *Reporter);
68+
ModulePass *createPNaClABIVerifyModulePass(PNaClABIErrorReporter *Reporter,
69+
bool StreamingMode = false);
70+
71+
}
72+
73+
74+
#endif

include/llvm/IR/Intrinsics.td

+45
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,51 @@ def int_convert_from_fp16 : Intrinsic<[llvm_anyfloat_ty], [llvm_i16_ty]>;
688688
def int_clear_cache : Intrinsic<[], [llvm_ptr_ty, llvm_ptr_ty],
689689
[], "llvm.clear_cache">;
690690

691+
// @LOCALMOD-BEGIN
692+
//===----------------------- Native Client Intrinsics ---------------------===//
693+
// NaCl-specific setjmp/longjmp intrinsics.
694+
// See https://code.google.com/p/nativeclient/issues/detail?id=3429
695+
def int_nacl_setjmp : Intrinsic<[llvm_i32_ty], [llvm_ptr_ty]>;
696+
def int_nacl_longjmp : Intrinsic<[], [llvm_ptr_ty, llvm_i32_ty],
697+
[IntrNoReturn]>;
698+
699+
// Fast built-in version of NaCl's tls_get() IRT interface.
700+
def int_nacl_read_tp : Intrinsic<[llvm_ptr_ty], [], [IntrNoMem]>;
701+
702+
// Atomic intrinsics.
703+
//
704+
// Volatiles and atomics are encoded through these intrinsics to make
705+
// them platform-independent, remove some of LLVM's legacy, and isolate
706+
// PNaCl from future changes to IR. The intrinsics allow user code to
707+
// use `__sync_*` builtins as well as C11/C++11 atomics.
708+
//
709+
// These are further documented in docs/PNaClLangRef.rst.
710+
//
711+
// Note that IntrReadWriteArgMem is used in all cases to prevent
712+
// reordering.
713+
def int_nacl_atomic_load : Intrinsic<[llvm_anyint_ty],
714+
[LLVMPointerType<LLVMMatchType<0>>, llvm_i32_ty],
715+
[IntrArgMemOnly]>;
716+
def int_nacl_atomic_store : Intrinsic<[],
717+
[llvm_anyint_ty, LLVMPointerType<LLVMMatchType<0>>, llvm_i32_ty],
718+
[IntrArgMemOnly]>;
719+
def int_nacl_atomic_rmw : Intrinsic<[llvm_anyint_ty],
720+
[llvm_i32_ty, LLVMPointerType<LLVMMatchType<0>>, LLVMMatchType<0>,
721+
llvm_i32_ty],
722+
[IntrArgMemOnly]>;
723+
def int_nacl_atomic_cmpxchg : Intrinsic<[llvm_anyint_ty],
724+
[LLVMPointerType<LLVMMatchType<0>>, LLVMMatchType<0>, LLVMMatchType<0>,
725+
llvm_i32_ty, llvm_i32_ty],
726+
[IntrArgMemOnly]>;
727+
def int_nacl_atomic_fence : Intrinsic<[], [llvm_i32_ty],
728+
[IntrArgMemOnly]>;
729+
def int_nacl_atomic_fence_all : Intrinsic<[], [],
730+
[IntrArgMemOnly]>;
731+
def int_nacl_atomic_is_lock_free : Intrinsic<[llvm_i1_ty],
732+
[llvm_i32_ty, llvm_ptr_ty], [IntrNoMem]>,
733+
GCCBuiltin<"__nacl_atomic_is_lock_free">;
734+
// @LOCALMOD-END
735+
691736
//===-------------------------- Masked Intrinsics -------------------------===//
692737
//
693738
def int_masked_store : Intrinsic<[], [llvm_anyvector_ty,
+110
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
//===-- llvm/IR/NaClAtomicIntrinsics.h - NaCl Atomic Intrinsics -*- C++ -*-===//
2+
//
3+
// The LLVM Compiler Infrastructure
4+
//
5+
// This file is distributed under the University of Illinois Open Source
6+
// License. See LICENSE.TXT for details.
7+
//
8+
//===----------------------------------------------------------------------===//
9+
//
10+
// This file describes atomic intrinsic functions that are specific to NaCl.
11+
//
12+
//===----------------------------------------------------------------------===//
13+
14+
#ifndef LLVM_IR_NACL_ATOMIC_INTRINSICS_H
15+
#define LLVM_IR_NACL_ATOMIC_INTRINSICS_H
16+
17+
#include "llvm/IR/Intrinsics.h"
18+
#include "llvm/Support/Compiler.h"
19+
#include <cstddef>
20+
21+
namespace llvm {
22+
23+
namespace NaCl {
24+
25+
static const size_t NumAtomicIntrinsics = 6;
26+
static const size_t NumAtomicIntrinsicOverloadTypes = 4;
27+
static const size_t MaxAtomicIntrinsicsParameters = 5;
28+
29+
/// Describe all the atomic intrinsics and their type signature. Most
30+
/// can be overloaded on a type.
31+
class AtomicIntrinsics {
32+
public:
33+
enum ParamType {
34+
NoP, /// No parameter.
35+
Int, /// Overloaded.
36+
Ptr, /// Overloaded.
37+
RMW, /// Atomic RMW operation type.
38+
Mem /// Memory order.
39+
};
40+
41+
struct AtomicIntrinsic {
42+
Type *OverloadedType;
43+
Intrinsic::ID ID;
44+
uint8_t Overloaded : 1;
45+
uint8_t NumParams : 7;
46+
uint8_t ParamType[MaxAtomicIntrinsicsParameters];
47+
48+
Function *getDeclaration(Module *M) const {
49+
// The atomic intrinsic can be overloaded on zero or one type,
50+
// which is needed to create the function's declaration.
51+
return Intrinsic::getDeclaration(
52+
M, ID, ArrayRef<Type *>(&OverloadedType, Overloaded ? 1 : 0));
53+
}
54+
};
55+
56+
AtomicIntrinsics(LLVMContext &C);
57+
~AtomicIntrinsics() {}
58+
59+
typedef ArrayRef<AtomicIntrinsic> View;
60+
61+
/// Access all atomic intrinsics, which can then be iterated over.
62+
View allIntrinsicsAndOverloads() const;
63+
/// Access a particular atomic intrinsic.
64+
/// \returns 0 if no intrinsic was found.
65+
const AtomicIntrinsic *find(Intrinsic::ID ID, Type *OverloadedType) const;
66+
67+
private:
68+
AtomicIntrinsic I[NumAtomicIntrinsics][NumAtomicIntrinsicOverloadTypes];
69+
70+
AtomicIntrinsics() = delete;
71+
AtomicIntrinsics(const AtomicIntrinsics &) = delete;
72+
AtomicIntrinsics &operator=(const AtomicIntrinsics &) = delete;
73+
};
74+
75+
/// Operations that can be represented by the @llvm.nacl.atomic.rmw
76+
/// intrinsic.
77+
///
78+
/// Do not reorder these values: their order offers forward
79+
/// compatibility of bitcode targeted to NaCl.
80+
enum AtomicRMWOperation {
81+
AtomicInvalid = 0, // Invalid, keep first.
82+
AtomicAdd,
83+
AtomicSub,
84+
AtomicOr,
85+
AtomicAnd,
86+
AtomicXor,
87+
AtomicExchange,
88+
AtomicNum // Invalid, keep last.
89+
};
90+
91+
/// Memory orderings supported by C11/C++11.
92+
///
93+
/// Do not reorder these values: their order offers forward
94+
/// compatibility of bitcode targeted to NaCl.
95+
enum MemoryOrder {
96+
MemoryOrderInvalid = 0, // Invalid, keep first.
97+
MemoryOrderRelaxed,
98+
MemoryOrderConsume,
99+
MemoryOrderAcquire,
100+
MemoryOrderRelease,
101+
MemoryOrderAcquireRelease,
102+
MemoryOrderSequentiallyConsistent,
103+
MemoryOrderNum // Invalid, keep last.
104+
};
105+
106+
} // End NaCl namespace
107+
108+
} // End llvm namespace
109+
110+
#endif

include/llvm/InitializePasses.h

+63
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,69 @@ void initializeVirtRegMapPass(PassRegistry&);
354354
void initializeVirtRegRewriterPass(PassRegistry&);
355355
void initializeWholeProgramDevirtPass(PassRegistry &);
356356
void initializeWinEHPreparePass(PassRegistry&);
357+
358+
// @LOCALMOD-BEGIN
359+
void initializeAddPNaClExternalDeclsPass(PassRegistry&);
360+
void initializeAllocateDataSegmentPass(PassRegistry&);
361+
void initializeBackendCanonicalizePass(PassRegistry&);
362+
void initializeCanonicalizeMemIntrinsicsPass(PassRegistry&);
363+
void initializeCleanupUsedGlobalsMetadataPass(PassRegistry&);
364+
void initializeConstantInsertExtractElementIndexPass(PassRegistry&);
365+
void initializeExpandAllocasPass(PassRegistry&);
366+
void initializeExpandArithWithOverflowPass(PassRegistry&);
367+
void initializeExpandByValPass(PassRegistry&);
368+
void initializeExpandConstantExprPass(PassRegistry&);
369+
void initializeExpandCtorsPass(PassRegistry&);
370+
void initializeExpandGetElementPtrPass(PassRegistry&);
371+
void initializeExpandIndirectBrPass(PassRegistry&);
372+
void initializeExpandLargeIntegersPass(PassRegistry&);
373+
void initializeExpandShuffleVectorPass(PassRegistry&);
374+
void initializeExpandSmallArgumentsPass(PassRegistry&);
375+
void initializeExpandStructRegsPass(PassRegistry&);
376+
void initializeExpandTlsConstantExprPass(PassRegistry&);
377+
void initializeExpandTlsPass(PassRegistry&);
378+
void initializeExpandVarArgsPass(PassRegistry&);
379+
void initializeFixVectorLoadStoreAlignmentPass(PassRegistry&);
380+
void initializeFlattenGlobalsPass(PassRegistry&);
381+
void initializeGlobalCleanupPass(PassRegistry&);
382+
void initializeGlobalizeConstantVectorsPass(PassRegistry&);
383+
void initializeInsertDivideCheckPass(PassRegistry&);
384+
void initializeInternalizeUsedGlobalsPass(PassRegistry&);
385+
void initializeNaClCcRewritePass(PassRegistry&);
386+
void initializeNormalizeAlignmentPass(PassRegistry&);
387+
void initializePNaClABIVerifyFunctionsPass(PassRegistry&);
388+
void initializePNaClABIVerifyModulePass(PassRegistry&);
389+
void initializePNaClSjLjEHPass(PassRegistry&);
390+
void initializePromoteI1OpsPass(PassRegistry&);
391+
void initializePromoteIntegersPass(PassRegistry&);
392+
void initializeRemoveAsmMemoryPass(PassRegistry&);
393+
void initializeRenameEntryPointPass(PassRegistry&);
394+
void initializeReplacePtrsWithIntsPass(PassRegistry&);
395+
void initializeResolveAliasesPass(PassRegistry&);
396+
void initializeResolvePNaClIntrinsicsPass(PassRegistry&);
397+
void initializeRewriteAtomicsPass(PassRegistry&);
398+
void initializeRewriteLLVMIntrinsicsPass(PassRegistry&);
399+
void initializeRewritePNaClLibraryCallsPass(PassRegistry&);
400+
void initializeSandboxIndirectCallsPass(PassRegistry&);
401+
void initializeSandboxMemoryAccessesPass(PassRegistry&);
402+
void initializeSimplifyAllocasPass(PassRegistry&);
403+
void initializeSimplifyStructRegSignaturesPass(PassRegistry&);
404+
void initializeStripAttributesPass(PassRegistry&);
405+
void initializeStripMetadataPass(PassRegistry&);
406+
void initializeStripModuleFlagsPass(PassRegistry&);
407+
void initializeStripDanglingDISubprogramsPass(PassRegistry&);
408+
void initializeStripTlsPass(PassRegistry&);
409+
void initializeSubstituteUndefsPass(PassRegistry&);
410+
// Emscripten passes:
411+
void initializeExpandI64Pass(PassRegistry&);
412+
void initializeExpandInsertExtractElementPass(PassRegistry&);
413+
void initializeLowerEmAsyncifyPass(PassRegistry&);
414+
void initializeLowerEmExceptionsPass(PassRegistry&);
415+
void initializeLowerEmSetjmpPass(PassRegistry&);
416+
void initializeNoExitRuntimePass(PassRegistry&);
417+
// Emscripten passes end.
418+
// @LOCALMOD-END
419+
357420
void initializeWriteBitcodePassPass(PassRegistry &);
358421
void initializeWriteThinLTOBitcodePass(PassRegistry &);
359422
void initializeXRayInstrumentationPass(PassRegistry &);

0 commit comments

Comments
 (0)