Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Prev Previous commit
Next Next commit
Import LLVM 5.0.
  • Loading branch information
vgvassilev committed Oct 21, 2017
commit 3df6c915df4134a2473e62bc450096becaf52ac2
26 changes: 21 additions & 5 deletions interpreter/llvm/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ if(NOT DEFINED LLVM_VERSION_PATCH)
set(LLVM_VERSION_PATCH 0)
endif()
if(NOT DEFINED LLVM_VERSION_SUFFIX)
set(LLVM_VERSION_SUFFIX svn)
set(LLVM_VERSION_SUFFIX "")
endif()

if (POLICY CMP0048)
Expand All @@ -44,6 +44,13 @@ if (NOT PACKAGE_VERSION)
"${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}${LLVM_VERSION_SUFFIX}")
endif()

if ((CMAKE_GENERATOR MATCHES "Visual Studio") AND (CMAKE_GENERATOR_TOOLSET STREQUAL ""))
message(WARNING "Visual Studio generators use the x86 host compiler by "
"default, even for 64-bit targets. This can result in linker "
"instability and out of memory errors. To use the 64-bit "
"host compiler, pass -Thost=x64 on the CMake command line.")
endif()

project(LLVM
${cmake_3_0_PROJ_VERSION}
${cmake_3_0_LANGUAGES}
Expand Down Expand Up @@ -87,7 +94,7 @@ if(CMAKE_HOST_APPLE AND APPLE)
set(LIBTOOL_NO_WARNING_FLAG "-no_warning_for_no_symbols")
endif()
endif()

foreach(lang ${languages})
set(CMAKE_${lang}_CREATE_STATIC_LIBRARY
"${CMAKE_LIBTOOL} -static ${LIBTOOL_NO_WARNING_FLAG} -o <TARGET> \
Expand Down Expand Up @@ -199,7 +206,7 @@ endif()
include(VersionFromVCS)

option(LLVM_APPEND_VC_REV
"Append the version control system revision id to LLVM version" OFF)
"Embed the version control system revision id in LLVM" ON)

if( LLVM_APPEND_VC_REV )
add_version_info_from_vcs(PACKAGE_VERSION)
Expand Down Expand Up @@ -281,6 +288,10 @@ set(LLVM_LIBDIR_SUFFIX "" CACHE STRING "Define suffix of library directory name
set(LLVM_TOOLS_INSTALL_DIR "bin" CACHE STRING "Path for binary subdirectory (defaults to 'bin')")
mark_as_advanced(LLVM_TOOLS_INSTALL_DIR)

set(LLVM_UTILS_INSTALL_DIR "bin" CACHE STRING
"Path to install LLVM utilities (enabled by LLVM_INSTALL_UTILS=ON) (defaults to LLVM_TOOLS_INSTALL_DIR)")
mark_as_advanced(LLVM_TOOLS_INSTALL_DIR)

# They are used as destination of target generators.
set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin)
set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX})
Expand All @@ -303,6 +314,7 @@ set(LLVM_CMAKE_PATH ${LLVM_MAIN_SRC_DIR}/cmake/modules)
set(LLVM_EXAMPLES_BINARY_DIR ${LLVM_BINARY_DIR}/examples)
set(LLVM_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/include)

# List of all targets to be built by default:
set(LLVM_ALL_TARGETS
AArch64
AMDGPU
Expand All @@ -314,7 +326,6 @@ set(LLVM_ALL_TARGETS
MSP430
NVPTX
PowerPC
RISCV
Sparc
SystemZ
X86
Expand Down Expand Up @@ -563,6 +574,10 @@ if (LLVM_BUILD_STATIC)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
endif()

# Override the default target with an environment variable named by LLVM_TARGET_TRIPLE_ENV.
set(LLVM_TARGET_TRIPLE_ENV CACHE STRING "The name of environment variable to override default target. Disabled by blank.")
mark_as_advanced(LLVM_TARGET_TRIPLE_ENV)

# All options referred to from HandleLLVMOptions have to be specified
# BEFORE this include, otherwise options will not be correctly set on
# first cmake run
Expand Down Expand Up @@ -793,7 +808,8 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "(FreeBSD|DragonFly)")
endif(${CMAKE_SYSTEM_NAME} MATCHES "(FreeBSD|DragonFly)")

if( ${CMAKE_SYSTEM_NAME} MATCHES SunOS )
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -include llvm/Support/Solaris.h")
# special hack for Solaris to handle crazy system sys/regset.h
include_directories("${LLVM_MAIN_INCLUDE_DIR}/llvm/Support/Solaris")
endif( ${CMAKE_SYSTEM_NAME} MATCHES SunOS )

# Make sure we don't get -rdynamic in every binary. For those that need it,
Expand Down
3 changes: 2 additions & 1 deletion interpreter/llvm/src/CODE_OWNERS.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ D: Branch weights and BlockFrequencyInfo

N: Hal Finkel
E: [email protected]
D: BBVectorize, the loop reroller, alias analysis and the PowerPC target
D: The loop reroller, alias analysis and the PowerPC target

N: Dan Gohman
E: [email protected]
Expand Down Expand Up @@ -195,6 +195,7 @@ D: MemorySanitizer (LLVM part)

N: Craig Topper
E: [email protected]
E: [email protected]
D: X86 Backend

N: Ulrich Weigand
Expand Down
11 changes: 6 additions & 5 deletions interpreter/llvm/src/CREDITS.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ W: http://randomhacks.net/
D: llvm-config script

N: Anton Korobeynikov
E: [email protected]
E: anton at korobeynikov dot info
D: Mingw32 fixes, cross-compiling support, stdcall/fastcall calling conv.
D: x86/linux PIC codegen, aliases, regparm/visibility attributes
D: Switch lowering refactoring
Expand Down Expand Up @@ -265,7 +265,7 @@ D: Release manager (1.7+)
N: Sylvestre Ledru
E: [email protected]
W: http://sylvestre.ledru.info/
W: http://llvm.org/apt/
W: http://apt.llvm.org/
D: Debian and Ubuntu packaging
D: Continuous integration with jenkins

Expand Down Expand Up @@ -318,11 +318,12 @@ D: Support for implicit TLS model used with MS VC runtime
D: Dumping of Win64 EH structures

N: Takumi Nakamura
I: chapuni
E: [email protected]
E: [email protected]
D: Cygwin and MinGW support.
D: Win32 tweaks.
S: Yokohama, Japan
D: Maintaining the Git monorepo
W: https://github.com/llvm-project/
S: Ebina, Japan

N: Edward O'Callaghan
E: [email protected]
Expand Down
7 changes: 1 addition & 6 deletions interpreter/llvm/src/RELEASE_TESTERS.TXT
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,9 @@ E: [email protected]
T: x86
O: Windows

N: Renato Golin
E: [email protected]
T: ARM
O: Linux

N: Diana Picus
E: [email protected]
T: AArch64
T: ARM, AArch64
O: Linux

N: Simon Dardis
Expand Down
6 changes: 6 additions & 0 deletions interpreter/llvm/src/bindings/go/llvm/ir.go
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,12 @@ func (t Type) StructElementTypes() []Type {
}

// Operations on array, pointer, and vector types (sequence types)
func (t Type) Subtypes() (ret []Type) {
ret = make([]Type, C.LLVMGetNumContainedTypes(t.C))
C.LLVMGetSubtypes(t.C, llvmTypeRefPtr(&ret[0]))
return
}

func ArrayType(elementType Type, elementCount int) (t Type) {
t.C = C.LLVMArrayType(elementType.C, C.unsigned(elementCount))
return
Expand Down
26 changes: 26 additions & 0 deletions interpreter/llvm/src/bindings/go/llvm/ir_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,29 @@ func TestDebugLoc(t *testing.T) {
t.Errorf("Got metadata %v as scope, though wanted %v", loc.Scope.C, scope.C)
}
}

func TestSubtypes(t *testing.T) {
cont := NewContext()
defer cont.Dispose()

int_pointer := PointerType(cont.Int32Type(), 0)
int_inner := int_pointer.Subtypes()
if len(int_inner) != 1 {
t.Errorf("Got size %d, though wanted 1")
}
if int_inner[0] != cont.Int32Type() {
t.Errorf("Expected int32 type")
}

st_pointer := cont.StructType([]Type{cont.Int32Type(), cont.Int8Type()}, false)
st_inner := st_pointer.Subtypes()
if len(st_inner) != 2 {
t.Errorf("Got size %d, though wanted 2")
}
if st_inner[0] != cont.Int32Type() {
t.Errorf("Expected first struct field to be int32")
}
if st_inner[1] != cont.Int8Type() {
t.Errorf("Expected second struct field to be int8")
}
}
6 changes: 6 additions & 0 deletions interpreter/llvm/src/bindings/ocaml/llvm/llvm.ml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ type llattribute
type llmemorybuffer
type llmdkind

exception FeatureDisabled of string

let () = Callback.register_exception "Llvm.FeatureDisabled" (FeatureDisabled "")

module TypeKind = struct
type t =
| Void
Expand Down Expand Up @@ -459,6 +463,8 @@ external is_packed : lltype -> bool = "llvm_is_packed"
external is_opaque : lltype -> bool = "llvm_is_opaque"

(*--... Operations on pointer, vector, and array types .....................--*)

external subtypes : lltype -> lltype array = "llvm_subtypes"
external array_type : lltype -> int -> lltype = "llvm_array_type"
external pointer_type : lltype -> lltype = "llvm_pointer_type"
external qualified_pointer_type : lltype -> int -> lltype
Expand Down
5 changes: 5 additions & 0 deletions interpreter/llvm/src/bindings/ocaml/llvm/llvm.mli
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,8 @@ type ('a, 'b) llrev_pos =

(** {6 Exceptions} *)

exception FeatureDisabled of string

exception IoError of string


Expand Down Expand Up @@ -658,6 +660,9 @@ val is_opaque : lltype -> bool

(** {7 Operations on pointer, vector, and array types} *)

(** [subtypes ty] returns [ty]'s subtypes *)
val subtypes : lltype -> lltype array

(** [array_type ty n] returns the array type containing [n] elements of type
[ty]. See the method [llvm::ArrayType::get]. *)
val array_type : lltype -> int -> lltype
Expand Down
19 changes: 19 additions & 0 deletions interpreter/llvm/src/bindings/ocaml/llvm/llvm_ocaml.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,12 @@ CAMLprim LLVMContextRef llvm_type_context(LLVMTypeRef Ty) {

/* lltype -> unit */
CAMLprim value llvm_dump_type(LLVMTypeRef Val) {
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVMDumpType(Val);
#else
caml_raise_with_arg(*caml_named_value("Llvm.FeatureDisabled"),
caml_copy_string("dump"));
#endif
return Val_unit;
}

Expand Down Expand Up @@ -506,6 +511,20 @@ CAMLprim value llvm_is_opaque(LLVMTypeRef StructTy) {

/*--... Operations on array, pointer, and vector types .....................--*/

/* lltype -> lltype array */
CAMLprim value llvm_subtypes(LLVMTypeRef Ty) {
CAMLparam0();
CAMLlocal1(Arr);

unsigned Size = LLVMGetNumContainedTypes(Ty);

Arr = caml_alloc(Size, 0);

LLVMGetSubtypes(Ty, (LLVMTypeRef *) Arr);

CAMLreturn(Arr);
}

/* lltype -> int -> lltype */
CAMLprim LLVMTypeRef llvm_array_type(LLVMTypeRef ElementTy, value Count) {
return LLVMArrayType(ElementTy, Int_val(Count));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ CAMLprim value llvm_datalayout_pointer_size(value DL) {

/* Llvm.llcontext -> DataLayout.t -> Llvm.lltype */
CAMLprim LLVMTypeRef llvm_datalayout_intptr_type(LLVMContextRef C, value DL) {
return LLVMIntPtrTypeInContext(C, DataLayout_val(DL));;
return LLVMIntPtrTypeInContext(C, DataLayout_val(DL));
}

/* int -> DataLayout.t -> int */
Expand Down
2 changes: 1 addition & 1 deletion interpreter/llvm/src/cmake/config-ix.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ elseif (LLVM_NATIVE_ARCH MATCHES "msp430")
set(LLVM_NATIVE_ARCH MSP430)
elseif (LLVM_NATIVE_ARCH MATCHES "hexagon")
set(LLVM_NATIVE_ARCH Hexagon)
elseif (LLVM_NATIVE_ARCH MATCHES "s390[x]")
elseif (LLVM_NATIVE_ARCH MATCHES "s390x")
set(LLVM_NATIVE_ARCH SystemZ)
elseif (LLVM_NATIVE_ARCH MATCHES "wasm32")
set(LLVM_NATIVE_ARCH WebAssembly)
Expand Down
39 changes: 31 additions & 8 deletions interpreter/llvm/src/cmake/modules/AddLLVM.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function(add_llvm_symbol_exports target_name export_file)
DEPENDS ${export_file}
VERBATIM
COMMENT "Creating export file for ${target_name}")
if (${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
if (${LLVM_LINKER_IS_SOLARISLD})
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,-M,${CMAKE_CURRENT_BINARY_DIR}/${native_export_file}")
else()
Expand Down Expand Up @@ -148,13 +148,28 @@ function(add_llvm_symbol_exports target_name export_file)
endfunction(add_llvm_symbol_exports)

if(NOT WIN32 AND NOT APPLE)
# Detect what linker we have here
execute_process(
COMMAND ${CMAKE_C_COMPILER} -Wl,--version
OUTPUT_VARIABLE stdout
ERROR_QUIET
ERROR_VARIABLE stderr
)
set(LLVM_LINKER_DETECTED ON)
if("${stdout}" MATCHES "GNU gold")
set(LLVM_LINKER_IS_GOLD ON)
message(STATUS "Linker detection: GNU Gold")
elseif("${stdout}" MATCHES "^LLD")
set(LLVM_LINKER_IS_LLD ON)
message(STATUS "Linker detection: LLD")
elseif("${stdout}" MATCHES "GNU ld")
set(LLVM_LINKER_IS_GNULD ON)
message(STATUS "Linker detection: GNU ld")
elseif("${stderr}" MATCHES "Solaris Link Editors")
set(LLVM_LINKER_IS_SOLARISLD ON)
message(STATUS "Linker detection: Solaris ld")
else()
set(LLVM_LINKER_DETECTED OFF)
message(STATUS "Linker detection: unknown")
endif()
endif()

Expand Down Expand Up @@ -865,7 +880,7 @@ macro(add_llvm_utility name)
set_target_properties(${name} PROPERTIES FOLDER "Utils")
if( LLVM_INSTALL_UTILS AND LLVM_BUILD_UTILS )
install (TARGETS ${name}
RUNTIME DESTINATION bin
RUNTIME DESTINATION ${LLVM_UTILS_INSTALL_DIR}
COMPONENT ${name})
if (NOT CMAKE_CONFIGURATION_TYPES)
add_custom_target(install-${name}
Expand Down Expand Up @@ -1133,6 +1148,19 @@ function(configure_lit_site_cfg input output)

set(LIT_SITE_CFG_IN_HEADER "## Autogenerated from ${input}\n## Do not edit!")

# Override config_target_triple (and the env)
if(LLVM_TARGET_TRIPLE_ENV)
# This is expanded into the heading.
string(CONCAT LIT_SITE_CFG_IN_HEADER "${LIT_SITE_CFG_IN_HEADER}\n\n"
"import os\n"
"target_env = \"${LLVM_TARGET_TRIPLE_ENV}\"\n"
"config.target_triple = config.environment[target_env] = os.environ.get(target_env, \"${TARGET_TRIPLE}\")\n"
)

# This is expanded to; config.target_triple = ""+config.target_triple+""
set(TARGET_TRIPLE "\"+config.target_triple+\"")
endif()

configure_file(${input} ${output} @ONLY)
endfunction()

Expand All @@ -1146,11 +1174,6 @@ function(add_lit_target target comment)
list(APPEND LIT_ARGS --param build_mode=${CMAKE_CFG_INTDIR})
endif ()
if (EXISTS ${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py)
# reset cache after erraneous r283029
# TODO: remove this once all buildbots run
if (LIT_COMMAND STREQUAL "${PYTHON_EXECUTABLE} ${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py")
unset(LIT_COMMAND CACHE)
endif()
set (LIT_COMMAND "${PYTHON_EXECUTABLE};${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py"
CACHE STRING "Command used to spawn llvm-lit")
else()
Expand Down
7 changes: 6 additions & 1 deletion interpreter/llvm/src/cmake/modules/AddOCaml.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ function(add_ocaml_library name)
foreach( include_dir ${LLVM_INCLUDE_DIR} ${LLVM_MAIN_INCLUDE_DIR} )
set(c_flags "${c_flags} -I${include_dir}")
endforeach()
# include -D/-UNDEBUG to match dump function visibility
# regex from HandleLLVMOptions.cmake
string(REGEX MATCH "(^| )[/-][UD] *NDEBUG($| )" flag_matches
"${CMAKE_C_FLAGS_${uppercase_CMAKE_BUILD_TYPE}} ${CMAKE_C_FLAGS}")
set(c_flags "${c_flags} ${flag_matches}")

foreach( ocaml_file ${ARG_OCAML} )
list(APPEND sources "${ocaml_file}.mli" "${ocaml_file}.ml")
Expand Down Expand Up @@ -199,7 +204,7 @@ function(add_ocaml_library name)
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE
DESTINATION "${LLVM_OCAML_INSTALL_PATH}/llvm")
DESTINATION "${LLVM_OCAML_INSTALL_PATH}/stublibs")

foreach( install_file ${install_files} ${install_shlibs} )
get_filename_component(filename "${install_file}" NAME)
Expand Down
Loading