[PATCH] D142452: update_test_checks.py: match IR block labels

Nicolai Hähnle via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 24 03:47:47 PST 2023


nhaehnle created this revision.
nhaehnle added reviewers: mtrofin, nikic, lebedev.ri, arichardson, jsilvanus.
Herald added a subscriber: StephenFan.
Herald added a project: All.
nhaehnle requested review of this revision.
Herald added a project: LLVM.

Labels are matched using a regexp of the form '^(pattern):', which
requires the addition of a "suffix" concept to NamelessValue.

Aside from that, the key challenge is that block labels are values, and
we typically capture values including the prefix '%'. However, when
labels appear at the start of a basic block, the prefix '%' is not
included, so we must capture block label values *without* the prefix
'%'.

We don't know ahead of time whether an IR value is a label or not. In
most cases, they are prefixed by the word "label" (their type), but this
isn't the case in phi nodes. We solve this issue by changing the
variable generalization into a two-pass algorithm: the first pass finds
all occurences of a variable and determines whether the '%' prefix can
be included or not. The second pass does the actual substitution.

I did consider the alternative of trying to detect the phi node case
using more regular expression special cases but ultimately decided
against that because it seemed more fragile, and perhaps the approach
of keeping a tentative prefix that may later be discarded could also be
eventually applied to some metadata cases.

This would require more refactoring, though: right now, the two-pass
approach is only used locally to a function, which isn't sufficient for
metadata. Tackling this larger refactoring was a bit too much.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142452

Files:
  llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/check_attrs.ll.funcattrs.expected
  llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/check_attrs.ll.plain.expected
  llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs.ll.generated.expected
  llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs.ll.generated.globals.expected
  llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs.ll.nogenerated.expected
  llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs.ll.nogenerated.globals.expected
  llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs_prefix_reuse.ll.generated.expected
  llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs_prefix_reuse.ll.generated.globals.expected
  llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs_prefix_reuse.ll.nogenerated.expected
  llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs_prefix_reuse.ll.nogenerated.globals.expected
  llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/phi-labels.ll
  llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/phi-labels.ll.expected
  llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/pre-process.ll.expected
  llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.expected
  llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.expected
  llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.globals.expected
  llvm/test/tools/UpdateTestChecks/update_test_checks/basic.test
  llvm/test/tools/UpdateTestChecks/update_test_checks/function-name.test
  llvm/test/tools/UpdateTestChecks/update_test_checks/phi-labels.test
  llvm/utils/UpdateTestChecks/common.py

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142452.491703.patch
Type: text/x-patch
Size: 55152 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230124/1e6b4d3a/attachment-0001.bin>


More information about the llvm-commits mailing list