[clang] [compiler-rt] [llvm] [Profile] Refactor profile correlation. (PR #70856)

2023-11-08 Thread Zequan Wu via cfe-commits

ZequanWu wrote:

> If you omit the data and names sections from the object files, then 
> __llvm_profile_end_data() - __llvm_profile_begin_data() and 
> __llvm_profile_end_names() - __llvm_profile_begin_names() are both 0 and 
> there's no need for [special casing this in the 
> runtime](https://github.com/llvm/llvm-project/blob/24b11ba24da3e65f718391ccc85d4d22a081e893/compiler-rt/lib/profile/InstrProfilingBuffer.c#L59).

>From my experiments, I found that for debug info correlation 
>`__llvm_profile_end_data()` - `__llvm_profile_begin_data()` and 
>`__llvm_profile_end_names()` - `__llvm_profile_begin_names()` are both 0 at 
>runtime because `{__start_/__stop_}{__llvm_prf_names/data}` symbols are null 
>if there is no `__llvm_prf_names/data`. 

But for binary correlation, even though `__llvm_prf_names/data` don't have 
`SHF_ALLOC` flag so they are not loaded into memory, 
`__llvm_profile_end_data()` - `__llvm_profile_begin_data()` and 
`__llvm_profile_end_names()` - `__llvm_profile_begin_names()` still produces 
the size of name and data sections, that's why we need a bit in the global 
profile version variable to indicate they are empty at runtime. I feel like 
this is a bug in lld as __start_/__stop_ symbols for non allocated sections 
should be null. Even if we have a way to fix that, we still need the mode bit 
at llvm-profile merging step to indicate if the raw profile need debug 
info/binary to correlate. However, we can get ride of the runtime checking 
`__llvm_profile_has_correlation` to allow code compiled w/wo debug-info linked 
together works well.

https://github.com/llvm/llvm-project/pull/70856
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [llvm] [Profile] Refactor profile correlation. (PR #70856)

2023-11-02 Thread David Tellenbach via cfe-commits

dtellenbach wrote:

@ZequanWu this seems to cause issues on macOS: 
https://green.lab.llvm.org/green/job/clang-stage1-RA/36184/console
```
Profile-x86_64 :: Darwin/instrprof-debug-info-correlate.c
Profile-x86_64 :: instrprof-darwin-
Profile-x86_64h :: Darwin/instrprof-debug-info-correlate.c
Profile-x86_64h :: instrprof-darwin-exports.c
```
are failing, could you please take a look or revert?


https://github.com/llvm/llvm-project/pull/70856
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [llvm] [Profile] Refactor profile correlation. (PR #70856)

2023-11-01 Thread Zequan Wu via cfe-commits

ZequanWu wrote:

> Sounds fine to me, but I guess I don't understand why `-profile-correlate=` 
> doesn't work. Do you still plan to add the flag later?

I haven't found a way to share information (whether of not binary correlation 
is enabled) between CodeGen(TargetLoweringObjectFileImpl.cpp) and 
Instrumentation(InstrProfiling.cpp) components. The explanation is 
here: 
https://discourse.llvm.org/t/rfc-add-binary-profile-correlation-to-not-load-profile-metadata-sections-into-memory-at-runtime/74565#use-temporary-section-names-6.

https://github.com/llvm/llvm-project/pull/70856
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits