-
Notifications
You must be signed in to change notification settings - Fork 15.4k
MetaRenamer: replaced command line options with pass parameters #133975
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 3 commits
ca8115a
21e2a36
61327d7
bbfaafc
e1c3ba7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -103,7 +103,6 @@ MODULE_PASS("pgo-force-function-attrs", PGOForceFunctionAttrsPass(PGOOpt ? PGOOp | |
| MODULE_PASS("memprof-context-disambiguation", MemProfContextDisambiguation()) | ||
| MODULE_PASS("memprof-module", ModuleMemProfilerPass()) | ||
| MODULE_PASS("mergefunc", MergeFunctionsPass()) | ||
| MODULE_PASS("metarenamer", MetaRenamerPass()) | ||
| MODULE_PASS("module-inline", ModuleInlinerPass()) | ||
| MODULE_PASS("name-anon-globals", NameAnonGlobalPass()) | ||
| MODULE_PASS("no-op-module", NoOpModulePass()) | ||
|
|
@@ -233,7 +232,12 @@ MODULE_PASS_WITH_PARAMS( | |
| return StructuralHashPrinterPass(errs(), Options); | ||
| }, | ||
| parseStructuralHashPrinterPassOptions, "detailed;call-target-ignored") | ||
|
|
||
| MODULE_PASS_WITH_PARAMS("metarenamer", "MetaRenamerPass", | ||
| [](MetaRenamerOptions Options) { | ||
| return MetaRenamerPass(Options); | ||
| }, | ||
| parseMetaRenamerPassOptions, | ||
| "rename-exclude-alias-prefixes=S;rename-exclude-function-prefixes=S;rename-exclude-global-prefixes=S;rename-exclude-struct-prefixes=S;no-rename-only-inst;rename-only-inst") | ||
|
||
| #undef MODULE_PASS_WITH_PARAMS | ||
|
|
||
| #ifndef CGSCC_ANALYSIS | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| ; RUN: opt -passes=metarenamer -rename-exclude-function-prefixes=my_func -rename-exclude-global-prefixes=my_global -rename-exclude-struct-prefixes=my_struct -rename-exclude-alias-prefixes=my_alias -S %s | FileCheck %s | ||
| ; RUN: opt -passes='metarenamer<rename-exclude-function-prefixes=my_func;rename-exclude-global-prefixes=my_global;rename-exclude-struct-prefixes=my_struct;rename-exclude-alias-prefixes=my_alias>' -S %s | FileCheck %s | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The existing test coverage for all the options is lacking. Can you add a new test to make sure all the options parse? In particular, check the failed to parse case. Bonus points for a test which shows they work Also these are somewhat unique in that the content is also a string, so there may be escape hazards to consider. Not sure there is any precedent for this in the existing options. Can you add some tests where the string value is quoted, and contains a ;?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added invalid-pass-parameter test and semicolon-substr test |
||
| ; RUN: opt -passes='metarenamer<rename-exclude-function-prefixes="my_func";rename-exclude-global-prefixes="my_global";rename-exclude-struct-prefixes="my_struct";rename-exclude-alias-prefixes="my_alias">' -S %s | FileCheck %s | ||
|
|
||
| ; Check that excluded names don't get renamed while all the other ones do | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| ; RUN: not opt -S -passes='metarenamer<invalid>' %s 2>&1 | FileCheck -check-prefix=ERR %s | ||
|
|
||
| ; ERR: invalid metarenamer pass parameter 'invalid' | ||
|
|
||
| define i32 @0(i32, i32) { | ||
| %3 = add i32 %0, %1 | ||
| ret i32 %3 | ||
| } | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| ; RUN: opt -passes='metarenamer<rename-exclude-function-prefixes="my_fu;nc">' -S %s | FileCheck %s | ||
|
|
||
| ; CHECK: define i32 @"my_fu;nc"( | ||
| define i32 @"my_fu;nc"(i32, i32) { | ||
| %3 = add i32 %0, %1 | ||
| ret i32 %3 | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should unify the syntax to handle the case
pass-name<arg=a list>, passinternalizehas the same request but has a different syntax, pending on pass infrastructure maintainers.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed