[LLVMdev] How to make Polly ignore some non-affine memory accesses

Marcello Maggioni hayarms at gmail.com
Mon Oct 24 14:40:08 PDT 2011


otool is equivalent to objtool on macosx

MacBook-Pro-di-Marcello:llvm-build Kariddi$ otool -tV
../git-prefix/bin/clang|grep RegionInfo
MacBook-Pro-di-Marcello:llvm-build Kariddi$

MacBook-Pro-di-Marcello:llvm-build Kariddi$ otool -tV
../git-prefix/bin/opt|grep RegionInfo
00000001000152d0	callq	__ZN4llvm20createRegionInfoPassEv
00000001002bc65c	callq	__ZN4llvm24initializeRegionInfoPassERNS_12PassRegistryE
__ZN4llvm6RegionC1EPNS_10BasicBlockES2_PNS_10RegionInfoEPNS_13DominatorTreeEPS0_:
000000010039e138	callq	__ZN4llvm6RegionC2EPNS_10BasicBlockES2_PNS_10RegionInfoEPNS_13DominatorTreeEPS0_
__ZN4llvm6RegionC2EPNS_10BasicBlockES2_PNS_10RegionInfoEPNS_13DominatorTreeEPS0_:
000000010039f3b3	callq	__ZNK4llvm10RegionInfo12getRegionForEPNS_10BasicBlockE
__ZNK4llvm10RegionInfo12getRegionForEPNS_10BasicBlockE:
000000010039fc34	callq	__ZN4llvm10RegionInfo12setRegionForEPNS_10BasicBlockEPNS_6RegionE
__ZN4llvm10RegionInfo12setRegionForEPNS_10BasicBlockEPNS_6RegionE:
00000001003a022e	callq	__ZNK4llvm10RegionInfo12getRegionForEPNS_10BasicBlockE
00000001003a02f7	callq	__ZN4llvm6RegionC1EPNS_10BasicBlockES2_PNS_10RegionInfoEPNS_13DominatorTreeEPS0_
00000001003a050e	callq	__ZN4llvm6RegionC1EPNS_10BasicBlockES2_PNS_10RegionInfoEPNS_13DominatorTreeEPS0_
__ZNK4llvm10RegionInfo19isCommonDomFrontierEPNS_10BasicBlockES2_S2_:
__ZNK4llvm10RegionInfo8isRegionEPNS_10BasicBlockES2_:
00000001003a0edf	callq	__ZNK4llvm10RegionInfo19isCommonDomFrontierEPNS_10BasicBlockES2_S2_
__ZNK4llvm10RegionInfo14insertShortCutEPNS_10BasicBlockES2_PNS_8DenseMapIS2_S2_NS_12DenseMapInfoIS2_EES5_EE:
__ZNK4llvm10RegionInfo14getNextPostDomEPNS_15DomTreeNodeBaseINS_10BasicBlockEEEPNS_8DenseMapIPS2_S6_NS_12DenseMapInfoIS6_EES8_EE:
__ZNK4llvm10RegionInfo15isTrivialRegionEPNS_10BasicBlockES2_:
__ZN4llvm10RegionInfo16updateStatisticsEPNS_6RegionE:
__ZN4llvm10RegionInfo12createRegionEPNS_10BasicBlockES2_:
00000001003a1437	callq	__ZNK4llvm10RegionInfo15isTrivialRegionEPNS_10BasicBlockES2_
00000001003a14a5	callq	__ZN4llvm6RegionC1EPNS_10BasicBlockES2_PNS_10RegionInfoEPNS_13DominatorTreeEPS0_
00000001003a1527	callq	__ZN4llvm10RegionInfo16updateStatisticsEPNS_6RegionE
__ZN4llvm10RegionInfo20findRegionsWithEntryEPNS_10BasicBlockEPNS_8DenseMapIS2_S2_NS_12DenseMapInfoIS2_EES5_EE:
00000001003a15e9	callq	__ZNK4llvm10RegionInfo14getNextPostDomEPNS_15DomTreeNodeBaseINS_10BasicBlockEEEPNS_8DenseMapIPS2_S6_NS_12DenseMapInfoIS6_EES8_EE
00000001003a162a	callq	__ZNK4llvm10RegionInfo8isRegionEPNS_10BasicBlockES2_
00000001003a1648	callq	__ZN4llvm10RegionInfo12createRegionEPNS_10BasicBlockES2_
00000001003a16c6	callq	__ZNK4llvm10RegionInfo14insertShortCutEPNS_10BasicBlockES2_PNS_8DenseMapIS2_S2_NS_12DenseMapInfoIS2_EES5_EE
__ZN4llvm10RegionInfo14scanForRegionsERNS_8FunctionEPNS_8DenseMapIPNS_10BasicBlockES5_NS_12DenseMapInfoIS5_EES7_EE:
00000001003a17d8	callq	__ZN4llvm10RegionInfo20findRegionsWithEntryEPNS_10BasicBlockEPNS_8DenseMapIS2_S2_NS_12DenseMapInfoIS2_EES5_EE
__ZN4llvm10RegionInfo16getTopMostParentEPNS_6RegionE:
__ZN4llvm10RegionInfo16buildRegionsTreeEPNS_15DomTreeNodeBaseINS_10BasicBlockEEEPNS_6RegionE:

.... lots of other stuff.

Now I'll try the patch you posted and report, thanks :)

2011/10/23 Tobias Grosser <tobias at grosser.es>:
> On 10/22/2011 08:41 AM, Marcello Maggioni wrote:
>>
>> I was trying the new feature you introduce about printing out the
>> graphs, so I updated my version of llvm/clang/polly synchronizing them
>> to the last version, but I get this error launching clang (also , I
>> recently switched to MacOS X for development):
>>
>> $ clang not_so_simple_loop.c -O3 -Xclang -load -Xclang
>> ${PATH_TO_POLLY_LIB}/LLVMPolly.dylib -mllvm -enable-polly-viewer
>> -mllvm -enable-iv-rewrite
>
> I documented the use of Polly in clang on a new website:
> http://polly.grosser.es/example_load_Polly_into_clang.html
>
>> error: unable to load plugin
>> '/Users/Kariddi/Documents/Sviluppo/Tesi/git-prefix/lib//LLVMPolly.dylib':
>>
>> 'dlopen(/Users/Kariddi/Documents/Sviluppo/Tesi/git-prefix/lib//LLVMPolly.dylib,
>> 9): Symbol not found: __ZN4llvm10RegionInfo2IDE
>>   Referenced from:
>> /Users/Kariddi/Documents/Sviluppo/Tesi/git-prefix/lib//LLVMPolly.dylib
>>   Expected in: flat namespace
>>  in
>> /Users/Kariddi/Documents/Sviluppo/Tesi/git-prefix/lib//LLVMPolly.dylib'
>> clang (LLVM option parsing): Unknown command line argument
>> '-enable-polly-viewer'.  Try: 'clang (LLVM option parsing) -help'
>> clang (LLVM option parsing): Did you mean '-enable-ppc-preinc'?
>>
>> $ clang -v
>> clang version 3.1 (trunk 142724)
>> Target: x86_64-apple-darwin11.2.0
>> Thread model: posix
>>
>> Seems like it tries to load a symbol that it doesn't find ...
>> I have synchronized all clang/llvm/polly to the latest version and I
>> compiled them all together. Loading polly with "opt" works strangely
>> ... :
>>
>> opt -S -load ${PATH_TO_POLLY_LIB}/LLVMPolly.dylib -mem2reg -no-aa
>> -targetlibinfo -tbaa -basicaa -preverify -domtree -verify -mem2reg
>> -instcombine -simplifycfg -tailcallelim -simplifycfg -reassociate
>> -domtree -loops -loop-simplify -lcssa -loop-rotate -instcombine
>> -scalar-evolution -loop-simplify -lcssa -indvars -polly-prepare
>> -postdomtree -domfrontier -regions -polly-region-simplify
>> -scalar-evolution -loop-simplify -lcssa -indvars -postdomtree
>> -domfrontier -regions  -loop-simplify -indvars  -enable-iv-rewrite
>> not_so_simple_loop.s
>>
>> strange ...
>
> Very strange. I have seen such problems previously and they were often
> related to enabling rtti (runtime type info) or exceptions in Polly, but no
> clang or the other way around. I am not sure if this is the case her.
>
> Another possibility is that clang does not use the RegionInfo stuff and
> it gets dead code eliminated.
>
> Can you run the following commands on the clang binary:
>
> ldd /path/to/clang
> objdump -xC /path/to/clang | grep RegionInfo
>
> Can you also run them on the opt tool?
>
> Are you building with cmake or autoconf? Do you use
> --enable-shared/BUILD_SHARED_LIBS. In case you do/don't it would be
> interesting to try to switch. Especially using shared libraries may help as
> it may block some dead code elimination.
>
> Cheers
> Tobi
>




More information about the llvm-dev mailing list