yaxunl added a comment. In D106315#2900882 <https://reviews.llvm.org/D106315#2900882>, @tra wrote:
> In D106315#2899928 <https://reviews.llvm.org/D106315#2899928>, @yaxunl wrote: > >> Yes that's possible. However that would require FE to know these functions >> and declare them, whereas the current approach leave the concern to the >> device library. > > I was thinking of just adding a pointer to an array of pointers to > `@llvm.compiler.used`. > The array itself would come from the bitcode library and would be populated > there. I'm not sure if it's doable without knowing the array size, though. > > e.g > > ; Added by compiler > @llvm.compiler.used = appending global [1 x i8*] [i8* bitcast ([16 x i8*]* > @_ZL5funcs to i8*)], section "llvm.metadata" > > ; comes from the bitcode library, initialized with the pointers to > functions you need to keep. > @_ZL5funcs = internal global [16 x i8*] zeroinitializer, align 4 > > It should be possible to make the pointer to the array opaque with an > intermadiate variable in the library. Yes that is possible. Actually it can be simpler. We can add `__attribute__((used))` to the dummy function in the bitcode lib, and it will be kept when linked by -mlink-builtin-bitcode. However, it has a drawback compared to the current approach. It has no control when to keep the dummy function, whereas the current approach only keep it for -fsanitize=asan. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D106315/new/ https://reviews.llvm.org/D106315 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits