# NOTE: this is a machine readable list of symbols that can legally be used
#       by bitcode without being defined by bitcode because they are
#       * linker-defined
#       * provided by native libraries
#       * known to ALL llc backends
#       Empty lines and lines starting with '#' are ignored
#
# One way to use this list and check a bunch of pexes is:
#
# for i in  scons-out/nacl-x86-64-pnacl/obj/tests/*/*pexe  ; do
# echo $i
# TODO(pnacl-team): Stop hardcoding these paths.
# toolchain/pnacl_linux_x86/host_x86_32/bin/llvm-ld \
#   -o xxx $i   --nacl-abi-check   --nacl-legal-undefs \
#   tools/llvm/non_bitcode_symbols.txt
#
#  done
#
######################################################################

# llvm buitins
# TODO(robertm): there are likely a few more missing
llvm.memcpy.p0i8.p0i8.i32
llvm.memset.p0i8.i32
llvm.memset.p0i8.i64
llvm.memmove.p0i8.p0i8.i32

llvm.memory.barrier
llvm.atomic.cmp.swap.i32.p0i32
llvm.atomic.load.add.i32.p0i32

# used to abstract away exception handling
llvm.eh.exception
llvm.eh.selector
llvm.eh.typeid.for

llvm.flt.rounds

# unwind related
llvm.returnaddress
llvm.eh.dwarf.cfa

# TODO(robertm): ????
llvm.stackrestore
llvm.stacksave

# for example stores to zero addresses get optimized to this
llvm.trap

# TODO(robertm): ???? try to eliminate this
llvm.uadd.with.overflow.i32

# va_list intrinsics
llvm.va_end
llvm.va_start

# linkerdefined symbols
__fini_array_end
__fini_array_start
__init_array_end
__init_array_start
__preinit_array_end
__preinit_array_start
__tls_template_end
__tls_template_start
__tls_template_tdata_end

# currently provided by libgcc_eh and referenced by our startup code
# Could be replaced by dummies when exceptions are not used
__deregister_frame_info
__register_frame_info

# these are most of the remaining functions provided by libgcc_eh
_Unwind_DeleteException
_Unwind_GetDataRelBase
_Unwind_GetIP
_Unwind_GetLanguageSpecificData
_Unwind_GetRegionStart
_Unwind_GetTextRelBase
_Unwind_PNaClSetResult0
_Unwind_PNaClSetResult1
_Unwind_RaiseException
_Unwind_Resume_or_Rethrow
_Unwind_SetIP
_Unwind_Backtrace
_Unwind_GetCFA

# tls related intrinsics
# TODO(sehr): maybe mark them as intrinsics
__nacl_tdb_effective_payload_size
__nacl_tdb_offset_in_tls
__nacl_tls_aligment

# misc
__nacl_return_address_size

# setjmp/longjmp
# TODO(robertm): determine whether these are intrinsics or function calls
longjmp
setjmp

# math
# these may occur even if they not really used because of the
# tools/llvm/llvm-preserve.ll magic
# c.f.: http://code.google.com/p/nativeclient/issues/detail?id=842
cos
cosf
pow
powf
sin
sinf
sqrt
sqrtf
fabs

# these need to be investigated:
memmove
llvm.sqrt.f64
llvm.sqrt.f32

