[llvm-dev] FW: How to use -forder-file-instrumentation to generate order file for iOS Apps?

Jack Chen via llvm-dev llvm-dev at lists.llvm.org
Fri Sep 24 03:11:34 PDT 2021


Thank you Manman!

I did try the feature with a C file and it worked well. I
called __llvm_profile_set_filename() and __llvm_orderfile_dump() in the C
file, built it with the flags, and ran the binary on Linux. After running,
a profraw.order file was generated with correct contents.

However, I wasn't able to make it work for my iOS app - the profraw.order
file is indeed generated, but it doesn't contain valid contents.

The major differences between them are: (1) the iOS app is written in
objective c and swift, as opposed to C and (2)  The iOS app was run on iOS
simulator, and the profraw.order data was collected on iOS simulator, as
opposed to on linux.

I wonder if you know what could be wrong? Maybe this feature isn't
supported by objective c and swift, or perhaps it doesn't work on the iOS
platform?

Thanks again! Really appreciate your help!

Regards,
Jack


On Fri, Sep 24, 2021 at 5:48 AM Manman Ren <manman.ren at gmail.com> wrote:

> I don't think I wrote a doc on this.
> 'compiler-rt/test/profile/instrprof-order-file.test' shows how to use it,
> build the app with -forder-file-instrumentation and -mllvm
> -orderfile-write-mapping, then run the app, use the mapping file to decode
> the profile.
>
> The profile should be in default.profraw.order. But you can change its
> name via:
>
> - Writes to the file with the last name given to \a *
> - __llvm_profile_set_filename(),
> - or if it hasn't been called, the \c LLVM_PROFILE_FILE environment
> variable,
> - or if that's not set, the last name set to INSTR_PROF_PROFILE_NAME_VAR,
> - or if that's not set,  \c "default.profraw".
>
> Hope this helps!
> Manman
>
> On Thu, Sep 23, 2021 at 2:45 PM Manman Ren <mren at fb.com> wrote:
>
>>
>>
>>
>>
>> *From: *Manman Ren <mren at fb.com>
>> *Date: *Thursday, September 23, 2021 at 2:20 PM
>> *To: *Jack Chen <jacklcc at google.com>, llvm-dev at lists.llvm.org <
>> llvm-dev at lists.llvm.org>
>> *Subject: *Re: How to use -forder-file-instrumentation to generate order
>> file for iOS Apps?
>>
>> I don't think I wrote a doc on this.
>> 'compiler-rt/test/profile/instrprof-order-file.test' shows how to use it,
>> build the app with -forder-file-instrumentation and -mllvm
>> -orderfile-write-mapping, then run the app, use the mapping file to decode
>> the profile.
>>
>> The profile should be in default.profraw.order. But you can change its
>> name via:
>>
>> - Writes to the file with the last name given to \a *
>> - __llvm_profile_set_filename(),
>> - or if it hasn't been called, the \c LLVM_PROFILE_FILE environment
>> variable,
>> - or if that's not set, the last name set to INSTR_PROF_PROFILE_NAME_VAR,
>> - or if that's not set,  \c "default.profraw".
>>
>> Hope this helps!
>> Manman
>>
>>
>>
>>
>>
>> *From: *Jack Chen <jacklcc at google.com>
>> *Date: *Thursday, September 23, 2021 at 1:05 AM
>> *To: *llvm-dev at lists.llvm.org <llvm-dev at lists.llvm.org>
>> *Cc: *Manman Ren <mren at fb.com>
>> *Subject: *How to use -forder-file-instrumentation to generate order
>> file for iOS Apps?
>>
>> Hello llvm developers,
>>
>>
>>
>> I wonder how to use the flag *-forder-file-instrumentation* for iOS Apps
>> written in objective-C and swift?
>>
>>
>>
>> I enabled the flags* -forder-file-instrumentation -mllvm
>> -orderfile-write-mapping* *-fprofile-instr-generate *when building my
>> iOS App, which is written in objective-C and swift.
>>
>> After running the App on the iOS simulator on my macbook, a profraw.order
>> file is generated in the simulator's folder. However, the file doesn't
>> contain the correct contents. It contains too few bytes, also most data
>> blobs are 32 bits (I believe the right format is 64-bits MD5), and many of
>> them are duplicated. FWIW, here are the first few bytes:
>>
>> 00000000: 70aa cb11 0100 0000 f8ac cb11 0100 0000  p...............
>>
>> 00000010: 90ab cb11 0100 0000 58aa cb11 0100 0000  ........X.......
>>
>> 00000020: ffff ffff 0000 0000 0000 0000 0000 0000  ................
>>
>> 00000030: 0000 0000 0000 0000 ffff ffff 0000 0000  ................
>>
>> 00000040: 0000 0000 0000 0000 0000 0000 0000 0000  ................
>>
>> 00000050: 0000 0000 0000 0000 0000 0000 0000 0000  ................
>>
>> 00000060: 0000 0000 0000 0000 0000 0000 0000 0000  ................
>>
>> 00000070: 0000 0000 0000 0000 0000 0000 0000 0000  ................
>>
>> 00000080: 0000 0000 0000 0000 0000 0000 0000 0000  ................
>>
>> I wonder if the feature *-forder-file-instrumentation *is supported for
>> iOS Apps that are written in objective-C and swift?
>>
>> If yes, then I wonder what's the proper steps to use it?
>>
>>
>>
>> Thank you very much for your time.
>>
>>
>>
>> Regards,
>>
>> Jack
>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210924/6cc16187/attachment.html>


More information about the llvm-dev mailing list