Skip to content
Merged
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
1 change: 1 addition & 0 deletions core/iwasm/compilation/aot_llvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -2165,6 +2165,7 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option)
aot_set_last_error("create LLVM target data layout failed.");
goto fail;
}
LLVMSetModuleDataLayout(comp_ctx->module, target_data_ref);
comp_ctx->pointer_size = LLVMPointerSize(target_data_ref);
LLVMDisposeTargetData(target_data_ref);

Expand Down
2 changes: 0 additions & 2 deletions core/iwasm/compilation/aot_llvm.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,6 @@ typedef struct AOTFuncContext {
AOTFunc *aot_func;
LLVMValueRef func;
LLVMTypeRef func_type;
/* LLVM module for this function, note that in LAZY JIT mode,
each aot function belongs to an individual module */
LLVMModuleRef module;
AOTBlockStack block_stack;

Expand Down
8 changes: 7 additions & 1 deletion core/iwasm/compilation/aot_llvm_extra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

#include <llvm/Passes/StandardInstrumentations.h>
#include <llvm/Support/Error.h>
#include <llvm/ADT/None.h>
#include <llvm/ADT/Optional.h>
#include <llvm/ADT/SmallVector.h>
#include <llvm/ADT/Twine.h>
#include <llvm/ADT/Triple.h>
Expand Down Expand Up @@ -348,12 +350,16 @@ aot_apply_llvm_new_pass_manager(AOTCompContext *comp_ctx, LLVMModuleRef module)
FPM.addPass(LoadStoreVectorizerPass());

if (comp_ctx->enable_llvm_pgo || comp_ctx->use_prof_file) {
LICMOptions licm_opt;
/* LICM pass: loop invariant code motion, attempting to remove
as much code from the body of a loop as possible. Experiments
show it is good to enable it when pgo is enabled. */
#if LLVM_VERSION_MAJOR >= 15
LICMOptions licm_opt;
FPM.addPass(
createFunctionToLoopPassAdaptor(LICMPass(licm_opt), true));
#else
FPM.addPass(createFunctionToLoopPassAdaptor(LICMPass(), true));
#endif
}

/*
Expand Down
6 changes: 6 additions & 0 deletions core/iwasm/compilation/aot_llvm_extra2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@
*/

#include <llvm-c/TargetMachine.h>
#include <llvm/ADT/None.h>
#include <llvm/ADT/Optional.h>
#if LLVM_VERSION_MAJOR >= 14
#include <llvm/MC/TargetRegistry.h>
#else
#include <llvm/Support/TargetRegistry.h>
#endif
#include <llvm/Target/TargetMachine.h>

#include "bh_assert.h"
Expand Down
2 changes: 2 additions & 0 deletions core/iwasm/compilation/aot_orc_extra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include "llvm-c/OrcEE.h"
#include "llvm-c/TargetMachine.h"

#include "llvm/ADT/None.h"
#include "llvm/ADT/Optional.h"
#include "llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h"
#include "llvm/ExecutionEngine/Orc/LLJIT.h"
#include "llvm/ExecutionEngine/Orc/ObjectTransformLayer.h"
Expand Down
25 changes: 14 additions & 11 deletions core/iwasm/compilation/debug/dwarf_extractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ destroy_dwarf_extractor(dwar_extractor_handle_t handle)
}

LLVMMetadataRef
dwarf_gen_file_info(AOTCompContext *comp_ctx)
dwarf_gen_file_info(const AOTCompContext *comp_ctx)
{
dwar_extractor *extractor;
int units_number;
Expand Down Expand Up @@ -191,7 +191,7 @@ dwarf_gen_mock_vm_info(AOTCompContext *comp_ctx)
#endif

LLVMMetadataRef
dwarf_gen_comp_unit_info(AOTCompContext *comp_ctx)
dwarf_gen_comp_unit_info(const AOTCompContext *comp_ctx)
{
dwar_extractor *extractor;
int units_number;
Expand Down Expand Up @@ -257,7 +257,7 @@ lldb_get_basic_type_encoding(BasicType basic_type)
}

static LLVMMetadataRef
lldb_type_to_type_dbi(AOTCompContext *comp_ctx, SBType &type)
lldb_type_to_type_dbi(const AOTCompContext *comp_ctx, SBType &type)
{
LLVMMetadataRef type_info = NULL;
BasicType basic_type = type.GetBasicType();
Expand All @@ -282,8 +282,9 @@ lldb_type_to_type_dbi(AOTCompContext *comp_ctx, SBType &type)
}

static LLVMMetadataRef
lldb_function_to_function_dbi(AOTCompContext *comp_ctx, SBSymbolContext &sc,
AOTFuncContext *func_ctx)
lldb_function_to_function_dbi(const AOTCompContext *comp_ctx,
SBSymbolContext &sc,
const AOTFuncContext *func_ctx)
{
SBFunction function(sc.GetFunction());
const char *function_name = function.GetName();
Expand Down Expand Up @@ -388,7 +389,8 @@ lldb_function_to_function_dbi(AOTCompContext *comp_ctx, SBSymbolContext &sc,
}

LLVMMetadataRef
dwarf_gen_func_info(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
dwarf_gen_func_info(const AOTCompContext *comp_ctx,
const AOTFuncContext *func_ctx)
{
LLVMMetadataRef func_info = NULL;
dwar_extractor *extractor;
Expand Down Expand Up @@ -417,8 +419,8 @@ dwarf_gen_func_info(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
}

void
dwarf_get_func_name(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
char *name, int len)
dwarf_get_func_name(const AOTCompContext *comp_ctx,
const AOTFuncContext *func_ctx, char *name, int len)
{
LLVMMetadataRef func_info = NULL;
dwar_extractor *extractor;
Expand Down Expand Up @@ -448,8 +450,8 @@ dwarf_get_func_name(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
}

LLVMMetadataRef
dwarf_gen_location(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
uint64_t vm_offset)
dwarf_gen_location(const AOTCompContext *comp_ctx,
const AOTFuncContext *func_ctx, uint64_t vm_offset)
{
LLVMMetadataRef location_info = NULL;
dwar_extractor *extractor;
Expand Down Expand Up @@ -487,7 +489,8 @@ dwarf_gen_location(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
}

LLVMMetadataRef
dwarf_gen_func_ret_location(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx)
dwarf_gen_func_ret_location(const AOTCompContext *comp_ctx,
const AOTFuncContext *func_ctx)
{
LLVMMetadataRef func_info = NULL;
dwar_extractor *extractor;
Expand Down
18 changes: 10 additions & 8 deletions core/iwasm/compilation/debug/dwarf_extractor.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,26 @@ dwar_extractor_handle_t
create_dwarf_extractor(aot_comp_data_t comp_data, char *file_name);

LLVMMetadataRef
dwarf_gen_file_info(AOTCompContext *comp_ctx);
dwarf_gen_file_info(const AOTCompContext *comp_ctx);

LLVMMetadataRef
dwarf_gen_comp_unit_info(AOTCompContext *comp_ctx);
dwarf_gen_comp_unit_info(const AOTCompContext *comp_ctx);

LLVMMetadataRef
dwarf_gen_func_info(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx);
dwarf_gen_func_info(const AOTCompContext *comp_ctx,
const AOTFuncContext *func_ctx);

LLVMMetadataRef
dwarf_gen_location(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
uint64_t vm_offset);
dwarf_gen_location(const AOTCompContext *comp_ctx,
const AOTFuncContext *func_ctx, uint64_t vm_offset);

LLVMMetadataRef
dwarf_gen_func_ret_location(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx);
dwarf_gen_func_ret_location(const AOTCompContext *comp_ctx,
const AOTFuncContext *func_ctx);

void
dwarf_get_func_name(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
char *name, int len);
dwarf_get_func_name(const AOTCompContext *comp_ctx,
const AOTFuncContext *func_ctx, char *name, int len);

#ifdef __cplusplus
}
Expand Down
2 changes: 2 additions & 0 deletions core/iwasm/libraries/libc-wasi/libc_wasi_wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,13 @@ typedef struct WASIContext *wasi_ctx_t;
wasi_ctx_t
wasm_runtime_get_wasi_ctx(wasm_module_inst_t module_inst);

#if WASM_ENABLE_THREAD_MGR != 0
static inline uint64_t
min_uint64(uint64_t a, uint64_t b)
{
return a > b ? b : a;
}
#endif

static inline uint32_t
min_uint32(uint32_t a, uint32_t b)
Expand Down
2 changes: 1 addition & 1 deletion core/iwasm/libraries/wasi-nn/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ project (iwasm)
set (CMAKE_VERBOSE_MAKEFILE OFF)
# Reset default linker flags
set (CMAKE_C_STANDARD 99)
set (CMAKE_CXX_STANDARD 14)
set (CMAKE_CXX_STANDARD 17)
set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
set (CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")

Expand Down
1 change: 1 addition & 0 deletions core/shared/mem-alloc/ems/ems_alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,7 @@ gc_realloc_vo_internal(void *vheap, void *ptr, gc_size_t size, const char *file,
os_mutex_unlock(&heap->lock);
return NULL;
}
hmu_mark_pinuse(hmu_next);
}
os_mutex_unlock(&heap->lock);
return obj_old;
Expand Down
5 changes: 4 additions & 1 deletion core/shared/mem-alloc/ems/ems_gc_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,16 @@ set_hmu_normal_node_next(hmu_normal_node_t *node, hmu_normal_node_t *next)
#if defined(_MSC_VER)
__pragma(pack(push, 1));
#define __attr_packed
#define __attr_aligned(a)
#elif defined(__GNUC__) || defined(__clang__)
#define __attr_packed __attribute__((packed))
#define __attr_aligned(a) __attribute__((aligned(a)))
#else
#error "packed attribute isn't used to define struct hmu_tree_node"
#endif
#else /* else of UINTPTR_MAX == UINT64_MAX */
#define __attr_packed
#define __attr_aligned(a)
#endif

typedef struct hmu_tree_node {
Expand All @@ -229,7 +232,7 @@ typedef struct hmu_tree_node {
struct hmu_tree_node *right;
struct hmu_tree_node *parent;
gc_size_t size;
} __attr_packed hmu_tree_node_t;
} __attr_packed __attr_aligned(4) hmu_tree_node_t;

#if UINTPTR_MAX == UINT64_MAX
#if defined(_MSC_VER)
Expand Down
2 changes: 1 addition & 1 deletion doc/build_wamr.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ cmake -DWAMR_BUILD_PLATFORM=linux -DWAMR_BUILD_TARGET=ARM

#### **Disable boundary check with hardware trap**
- **WAMR_DISABLE_HW_BOUND_CHECK**=1/0, default to enable if not set and supported by platform
> Note: by default only platform linux/darwin/android/windows/vxworks 64-bit will enable the boundary check with hardware trap feature, and the wamrc tool will generate AOT code without boundary check instructions in all 64-bit targets except SGX to improve performance. The boundary check includes linear memory access boundary and native stack access boundary, if `WAMR_DISABLE_STACK_HW_BOUND_CHECK` below isn't set.
> Note: by default only platform [linux/darwin/android/windows/vxworks 64-bit](https://github.com/bytecodealliance/wasm-micro-runtime/blob/5fb5119239220b0803e7045ca49b0a29fe65e70e/core/shared/platform/linux/platform_internal.h#L81) will enable the boundary check with hardware trap feature, for 32-bit platforms it's automatically disabled even when the flag set to 0, and the wamrc tool will generate AOT code without boundary check instructions in all 64-bit targets except SGX to improve performance. The boundary check includes linear memory access boundary and native stack access boundary, if `WAMR_DISABLE_STACK_HW_BOUND_CHECK` below isn't set.

#### **Disable native stack boundary check with hardware trap**
- **WAMR_DISABLE_STACK_HW_BOUND_CHECK**=1/0, default to enable if not set and supported by platform, same as `WAMR_DISABLE_HW_BOUND_CHECK`.
Expand Down
2 changes: 1 addition & 1 deletion product-mini/platforms/darwin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif ()

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 17)

if (NOT DEFINED WAMR_BUILD_INTERP)
# Enable Interpreter by default
Expand Down
2 changes: 1 addition & 1 deletion product-mini/platforms/freebsd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif ()

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 17)

if (NOT DEFINED WAMR_BUILD_INTERP)
# Enable Interpreter by default
Expand Down
2 changes: 1 addition & 1 deletion product-mini/platforms/ios/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif ()

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 17)

if (NOT DEFINED WAMR_BUILD_INTERP)
# Enable Interpreter by default
Expand Down
17 changes: 17 additions & 0 deletions product-mini/platforms/linux-sgx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ if (NOT DEFINED WAMR_BUILD_SGX_IPFS)
set (WAMR_BUILD_SGX_IPFS 0)
endif ()

if (NOT DEFINED WAMR_BUILD_STATIC_PGO)
# Disable static PGO by default
set (WAMR_BUILD_STATIC_PGO 0)
endif ()

set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu11 -ffunction-sections -fdata-sections \
-Wall -Wno-unused-parameter -Wno-pedantic \
Expand All @@ -107,6 +112,18 @@ add_custom_command (

add_custom_target (vmlib_untrusted ALL DEPENDS libvmlib_untrusted.a)

if ((WAMR_BUILD_STATIC_PGO EQUAL 1) AND (WAMR_BUILD_AOT EQUAL 1))
execute_process(
COMMAND bash -c "sed -i -E 's/^WAMR_BUILD_STATIC_PGO = 0/WAMR_BUILD_STATIC_PGO = 1/g' ${CMAKE_CURRENT_SOURCE_DIR}/enclave-sample/Makefile"
OUTPUT_VARIABLE cmdOutput
)
else()
execute_process(
COMMAND bash -c "sed -i -E 's/^WAMR_BUILD_STATIC_PGO = 1/WAMR_BUILD_STATIC_PGO = 0/g' ${CMAKE_CURRENT_SOURCE_DIR}/enclave-sample/Makefile"
OUTPUT_VARIABLE cmdOutput
)
endif()

if (DEFINED WAMR_BUILD_GLOBAL_HEAP_POOL)
execute_process(
COMMAND bash -c "sed -i -E 's/^WAMR_BUILD_GLOBAL_HEAP_POOL = .*/WAMR_BUILD_GLOBAL_HEAP_POOL = ${WAMR_BUILD_GLOBAL_HEAP_POOL}/g' ${CMAKE_CURRENT_SOURCE_DIR}/enclave-sample/Makefile"
Expand Down
Loading