================
@@ -1950,8 +1950,22 @@ ConstantLValueEmitter::tryEmitBase(const
APValue::LValueBase &base) {
if (D->hasAttr<WeakRefAttr>())
return CGM.GetWeakRefReference(D).getPointer();
- if (auto FD = dyn_cast<FunctionDecl>(D))
- return CGM.GetAddrOfFunction(FD);
+ if (auto FD = dyn_cast<FunctionDecl>(D)) {
+ auto *C = CGM.GetAddrOfFunction(FD);
+
+ // we don't normally emit debug info for extern fns referenced via
+ // variable initialisers; BPF needs it since it generates BTF from
+ // debug info and bpftool demands BTF for every symbol linked
+ if (CGM.getTarget().getTriple().isBPF() && FD->getStorageClass() ==
SC_Extern) {
----------------
mejedi wrote:
@efriedma-quic Thank you for insightful comments! As a newbie, I need more
guidance.
It is pretty much clear that `allowDebugInfoForExternalRef` is a preferred way
to check whether we should emit additional debug info. It is currently only
overriden by BPF target and is being used for exact same purpose we have here.
I need help getting up to speed irt. `CompleteExternalDeclaration` proposal.
Having grepped through the code, I can see that BPF faced the same challenge
with `extern` variables. At the moment, there's a vector of `VariableDecl`s
populated in `SemaDecl.cpp` and later used to attach debug info to variables.
A different mechanism is applied to discovering `extern` functions in need for
debug info (prior to my patch, `extern` functions referenced through code were
handled). This is accomplished by code in `CGExpr.cpp`. I am proposing a
similar extension in `CGExprConstant.cpp`.
Would you like to have functions on `ExternalDeclarations` list instead?
What would be a good spot to get ahold of `FunctionDecl` to put it on
`ExternalDeclarations` list?
https://github.com/llvm/llvm-project/pull/91310
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits