[Mesa-dev] [PATCH] gallivm: print declarations of intrinsics with GALLIVM_DEBUG=ir

Roland Scheidegger sroland at vmware.com
Tue May 10 14:10:30 UTC 2016


Am 10.05.2016 um 06:50 schrieb Jose Fonseca:
> On 09/05/16 18:50, sroland at vmware.com wrote:
>> From: Roland Scheidegger <sroland at vmware.com>
>>
>> Those aren't really interesting, however outputting them is helpful when
>> trying to feed the IR to llvm llc (or opt) for debugging.
>> ---
>>   src/gallium/auxiliary/gallivm/lp_bld_intr.c | 5 +++++
>>   1 file changed, 5 insertions(+)
>>
>> diff --git a/src/gallium/auxiliary/gallivm/lp_bld_intr.c
>> b/src/gallium/auxiliary/gallivm/lp_bld_intr.c
>> index f806503..0a8f996 100644
>> --- a/src/gallium/auxiliary/gallivm/lp_bld_intr.c
>> +++ b/src/gallium/auxiliary/gallivm/lp_bld_intr.c
>> @@ -51,6 +51,7 @@
>>   #include "lp_bld_intr.h"
>>   #include "lp_bld_type.h"
>>   #include "lp_bld_pack.h"
>> +#include "lp_bld_debug.h"
>>
>>
>>   void
>> @@ -146,6 +147,10 @@ lp_build_intrinsic(LLVMBuilderRef builder,
>>
>>         if (attr)
>>             LLVMAddFunctionAttr(function, attr);
>> +
>> +      if (gallivm_debug & GALLIVM_DEBUG_IR) {
>> +         lp_debug_dump_value(function);
>> +      }
>>      }
>>
>>      return LLVMBuildCall(builder, function, args, num_args, "");
>>
> 
> Reviewed-by: Jose Fonseca <jfonseca at vmware.com>
> 
> 
> It's not a bad idea to dump intrinsics and other functions.
> 
> 
> But for the record, the most robust way of getting the whole IR (to pass
> to llc/opt) is to dump it to file:
> 
> diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init.c
> b/src/gallium/auxiliary/gallivm/lp_bld_init.c
> index 687c01f..6ca5bac 100644
> --- a/src/gallium/auxiliary/gallivm/lp_bld_init.c
> +++ b/src/gallium/auxiliary/gallivm/lp_bld_init.c
> @@ -592,7 +592,7 @@ gallivm_compile_module(struct gallivm_state *gallivm)
>     }
> 
>     /* Dump byte code to a file */
> -   if (0) {
> +   if (1) {
>        LLVMWriteBitcodeToFile(gallivm->module, "llvmpipe.bc");
>        debug_printf("llvmpipe.bc written\n");
>        debug_printf("Invoke as \"llc -o - llvmpipe.bc\"\n");
Ahh I missed this. I guess that's because the cases where I just look at
the IR quickly exceed the cases where I actually want to pass it to
opt/llc by at least 20:1 so I forgot about this one ;-).

> 
> 
> But I agree it should be easier to do this (there should be an
> GALLIVM_DEBUG option for this).  Also this code was written when there
> was a single module -- instead of llvmpipe.bc we should use something
> derived from module name so each module go to its own file.
> 
Sounds like a good idea.

Roland




More information about the mesa-dev mailing list