[Mesa-dev] [PATCH 1/9] gallivm: Use LLVMPrintValueToString where available.
Roland Scheidegger
sroland at vmware.com
Mon Apr 18 14:18:03 UTC 2016
Series looks great to me. Thanks for the cleanup.
Reviewed-by: Roland Scheidegger <sroland at vmware.com>
Am 18.04.2016 um 11:14 schrieb Jose Fonseca:
> And llvm::raw_string_ostream where not (LLVM 3.3).
>
> Thereby eliminating yet another dependency on unstable LLVM interfaces.
>
> As a bonus this also gets LLVM IR on OutputDebugMessageA on MSVC (which
> was disabled, probably due to C++ issues.)
>
> Tested `lp_test_arit -v -v` on LLVM 3.3, 3.4 and 3.8.
> ---
> src/gallium/auxiliary/gallivm/lp_bld_debug.cpp | 45 ++++++--------------------
> 1 file changed, 10 insertions(+), 35 deletions(-)
>
> diff --git a/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp b/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp
> index 11e9f92..a8c3899 100644
> --- a/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp
> +++ b/src/gallium/auxiliary/gallivm/lp_bld_debug.cpp
> @@ -64,38 +64,6 @@ lp_check_alignment(const void *ptr, unsigned alignment)
> return ((uintptr_t)ptr & (alignment - 1)) == 0;
> }
>
> -#if (defined(PIPE_OS_WINDOWS) && !defined(PIPE_CC_MSVC)) || defined(PIPE_OS_EMBEDDED)
> -
> -class raw_debug_ostream :
> - public llvm::raw_ostream
> -{
> -private:
> - uint64_t pos;
> -
> -public:
> - raw_debug_ostream() : pos(0) { }
> -
> - void write_impl(const char *Ptr, size_t Size);
> -
> - uint64_t current_pos() const { return pos; }
> - size_t preferred_buffer_size() const { return 512; }
> -};
> -
> -
> -void
> -raw_debug_ostream::write_impl(const char *Ptr, size_t Size)
> -{
> - if (Size > 0) {
> - char *lastPtr = (char *)&Ptr[Size];
> - char last = *lastPtr;
> - *lastPtr = 0;
> - _debug_printf("%*s", Size, Ptr);
> - *lastPtr = last;
> - pos += Size;
> - }
> -}
> -
> -#endif
>
> extern "C" const char *
> lp_get_module_id(LLVMModuleRef module)
> @@ -110,10 +78,17 @@ lp_get_module_id(LLVMModuleRef module)
> extern "C" void
> lp_debug_dump_value(LLVMValueRef value)
> {
> -#if (defined(PIPE_OS_WINDOWS) && !defined(PIPE_CC_MSVC)) || defined(PIPE_OS_EMBEDDED)
> - raw_debug_ostream os;
> +#if HAVE_LLVM >= 0x0304
> + char *str = LLVMPrintValueToString(value);
> + if (str) {
> + os_log_message(str);
> + LLVMDisposeMessage(str);
> + }
> +#elif defined(PIPE_OS_WINDOWS) || defined(PIPE_OS_EMBEDDED)
> + std::string str;
> + llvm::raw_string_ostream os(str);
> llvm::unwrap(value)->print(os);
> - os.flush();
> + os_log_message(str.c_str());
> #else
> LLVMDumpValue(value);
> #endif
>
More information about the mesa-dev
mailing list