aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
diff options
context:
space:
mode:
authorFangrui Song <i@maskray.me>2024-10-11 08:47:07 -0700
committerGitHub <noreply@github.com>2024-10-11 08:47:07 -0700
commit1c6688ae3449da9c8fee1e1c12c892223496fb4c (patch)
tree6fe74c1d89454734f93c63a60a130676bd45dcd6 /llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
parent2d5f3b0a61fb171617012a2c3ba05fd31fb3bb1d (diff)
downloadllvm-1c6688ae3449da9c8fee1e1c12c892223496fb4c.zip
llvm-1c6688ae3449da9c8fee1e1c12c892223496fb4c.tar.gz
llvm-1c6688ae3449da9c8fee1e1c12c892223496fb4c.tar.bz2
[ELF] Make shouldAddProvideSym return values consistent when demoted to Undefined
Case: `PROVIDE(f1 = bar);` when both `f1` and `bar` are in separate sections that would be discarded by GC. Due to `demoteDefined`, `shouldAddProvideSym(f1)` may initially return false (when Defined) and then return true (been demoted to Undefined). ``` addScriptReferencedSymbolsToSymTable shouldAddProvideSym(f1): false // the RHS (bar) is not added to `referencedSymbols` and may be GCed declareSymbols shouldAddProvideSym(f1): false markLive demoteSymbolsAndComputeIsPreemptible // demoted f1 to Undefined processSymbolAssignments addSymbol shouldAddProvideSym(f1): true ``` The inconsistency can cause `cmd->expression()` in `addSymbol` to be evaluated, leading to `symbol not found: bar` errors (since `bar` in the RHS is not in `referencedSymbols` and is GCed) (#111478). Fix this by adding a `sym->isUsedInRegularObj` condition, making `shouldAddProvideSym(f1)` values consistent. In addition, we need a `sym->exportDynamic` condition to keep provide-shared.s working. Fixes: ebb326a51fec37b5a47e5702e8ea157cd4f835cd Pull Request: https://github.com/llvm/llvm-project/pull/111945
Diffstat (limited to 'llvm/lib/Analysis/ModuleSummaryAnalysis.cpp')
0 files changed, 0 insertions, 0 deletions