[cfe-users] Clang Plugin Parallel Compilation Data Output Consolidation

2018-06-27 Thread Seboek, Janos via cfe-users
Dear all,

Not sure if this is the right mailing list for my question but I hope you will 
correct me if it's not.

I am developing a little Clang Plugin that compiles various data about a legacy 
codebase during the compilation process. Unfortunately, compilation of the 
legacy code is slow so it is done using many processes (-j24-144+.)
My problem is as follows: say I want to enumerate all the functions encountered 
in the codebase. Further say clang process 1 is processing a file that includes 
header 1.h and process 2 processes a different file that also includes header 
1.h. The header includes an inline function.

When my plugin writes the function, when visited, into an output file, I end up 
having the same entry twice: once written by process 1 and once by process 2. 
What's the standard way to eliminate this sort of duplication? Is there a clang 
functionality I can use or do I have to mess with shared memory or something 
like that? I can't just have a map of "functions already recorded" because each 
process starts its own Clang plugin instance.

So far, I dealt with this by removing duplicate entries in my output file after 
running the plugin. But the file grows to sizes of multiple Terabytes now and 
this method is no longer sustainable.

If you have any advice or know the best place to ask I would really appreciate 
it.

Thank you so much,
Janos
___
cfe-users mailing list
cfe-users@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users


Re: [cfe-users] question about loop unrolling

2018-06-27 Thread George Burgess IV via cfe-users
It may be that clang added the `optnone` attribute to main when you built
it in (b): https://godbolt.org/g/WhM1UA . optnone, as the name implies,
requests that optimizations are skipped for a given function. If this is
the case, removing the optnone might make (b) do what you want.

For (c), I'd introduce something that may have side-effects, so LLVM can't
easily model+eliminate the entire loop. Examples of this being an external
function call (https://godbolt.org/g/toqR6b) or making your int volatile (
https://godbolt.org/g/4svW7F).

George

On Tue, Jun 26, 2018 at 12:48 PM luck.caile via cfe-users <
cfe-users@lists.llvm.org> wrote:

> test.cpp:
>
> int main() {
>
> int ret = 0;
>
> for (int i = 0; i < 100; i++) {
>
> ret += i;
>
> }
>
> return ret;
>
> }
>
>
>
> Hi,
>
> I’m new to clang/llvm recently and interested in doing some stuff in
> optimization passes.
>
> I tried to play above simple test with clang and see if I could get
> expected llvm IR by enabling llvm loop unrolling of a count 2.
>
> Here are my attempts:
>
>1. adding pragma before loop in test.cpp: #pragma clang loop
>unroll_count(2)
>
> It did not unroll the loop.
>
>1. clang++ -c -emit-llvm -S -std=c++11 test.cpp
>
> opt test.ll -mem2reg -loop-unroll -unroll-count=2 -unroll-allow-partial -S
>
> It did not unroll the loop.
>
> In addition, by enabling -debug, I saw message “Skipping ‘Unroll Loops’
> pass…..”
>
>1. clang++ -c -emit-llvm -S -std=c++11 -O1 test.cpp
>
> It unrolled the loop completely and directly return the final result(4950).
>
>
>
> I assume that my llvm and clang are latest and installed correctly.
>
> Could someone please let me know what I am missing here?
>
>
>
> Thanks,
>
> Kai
> ___
> cfe-users mailing list
> cfe-users@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users
>
___
cfe-users mailing list
cfe-users@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users