[PATCH] D97971: [IPSCCP] don't propagate constant in section when caller/callee sections mismatch

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 6 10:35:11 PST 2021


fhahn added inline comments.


================
Comment at: llvm/lib/Transforms/Scalar/SCCP.cpp:1274
+      if (SectionMismatch)
+        if (auto *C = dyn_cast<Constant>(*CAI))
+          if (isGVSection(C)) {
----------------
Shouldn't we check against the current state we have for `CAI` (using `getValueState`/ `getStructValueState`)? Otherwise we might still propagate the global into the caller, e.g. due to conditions or loads. Seeh ttps://godbolt.org/z/qMaMWE

Also, IIUC the real problem is the actual replacement in the function, right? If that's the case, can we just skip replacing uses in invalid functions (e.g. in `tryToReplaceWithConstant`)? That way, we would still be able to simplify conditions (see `test3` in the godbolt) and also propagate the constant through functions without the right section to their callees if they have the right section.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97971/new/

https://reviews.llvm.org/D97971



More information about the llvm-commits mailing list