|
11 | 11 | import lit.util
|
12 | 12 | import lit.formats
|
13 | 13 | from lit.llvm import llvm_config
|
| 14 | +from lit.llvm import ToolFilter |
14 | 15 |
|
15 | 16 | # name: The name of this test suite.
|
16 | 17 | config.name = 'LLVM'
|
@@ -134,108 +135,39 @@ def get_asan_rtlib():
|
134 | 135 | # The regex is a pre-assertion to avoid matching a preceding
|
135 | 136 | # dot, hyphen, carat, or slash (.foo, -foo, etc.). Some patterns
|
136 | 137 | # also have a post-assertion to not match a trailing hyphen (foo-).
|
137 |
| -NOJUNK = r"(?<!\.|-|\^|/|<)" |
138 |
| - |
139 |
| - |
140 |
| -def find_tool_substitution(pattern): |
141 |
| - # Extract the tool name from the pattern. This relies on the tool |
142 |
| - # name being surrounded by \b word match operators. If the |
143 |
| - # pattern starts with "| ", include it in the string to be |
144 |
| - # substituted. |
145 |
| - tool_match = re.match(r"^(\\)?((\| )?)\W+b([0-9A-Za-z-_]+)\\b\W*$", |
146 |
| - pattern) |
147 |
| - tool_pipe = tool_match.group(2) |
148 |
| - tool_name = tool_match.group(4) |
149 |
| - # Did the user specify the tool path + arguments? This allows things like |
150 |
| - # llvm-lit "-Dllc=llc -enable-misched -verify-machineinstrs" |
151 |
| - tool_path = lit_config.params.get(tool_name) |
152 |
| - if tool_path is None: |
153 |
| - tool_path = lit.util.which(tool_name, config.llvm_tools_dir) |
154 |
| - if tool_path is None: |
155 |
| - return tool_name, tool_path, tool_pipe |
156 |
| - if (tool_name == "llc" and |
157 |
| - 'LLVM_ENABLE_MACHINE_VERIFIER' in os.environ and |
158 |
| - os.environ['LLVM_ENABLE_MACHINE_VERIFIER'] == "1"): |
159 |
| - tool_path += " -verify-machineinstrs" |
160 |
| - if (tool_name == "llvm-go"): |
161 |
| - tool_path += " go=" + config.go_executable |
162 |
| - return tool_name, tool_path, tool_pipe |
163 |
| - |
164 |
| - |
165 |
| -for pattern in [r"\bbugpoint\b(?!-)", |
166 |
| - NOJUNK + r"\bllc\b", |
167 |
| - r"\blli\b", |
168 |
| - r"\bllvm-ar\b", |
169 |
| - r"\bllvm-as\b", |
170 |
| - r"\bllvm-bcanalyzer\b", |
171 |
| - r"\bllvm-config\b", |
172 |
| - r"\bllvm-cov\b", |
173 |
| - r"\bllvm-cxxdump\b", |
174 |
| - r"\bllvm-cvtres\b", |
175 |
| - r"\bllvm-diff\b", |
176 |
| - r"\bllvm-dis\b", |
177 |
| - r"\bllvm-dsymutil\b", |
178 |
| - r"\bllvm-dwarfdump\b", |
179 |
| - r"\bllvm-extract\b", |
180 |
| - r"\bllvm-isel-fuzzer\b", |
181 |
| - r"\bllvm-lib\b", |
182 |
| - r"\bllvm-link\b", |
183 |
| - r"\bllvm-lto\b", |
184 |
| - r"\bllvm-lto2\b", |
185 |
| - r"\bllvm-mc\b", |
186 |
| - r"\bllvm-mcmarkup\b", |
187 |
| - r"\bllvm-modextract\b", |
188 |
| - r"\bllvm-nm\b", |
189 |
| - r"\bllvm-objcopy\b", |
190 |
| - r"\bllvm-objdump\b", |
191 |
| - r"\bllvm-pdbutil\b", |
192 |
| - r"\bllvm-profdata\b", |
193 |
| - r"\bllvm-ranlib\b", |
194 |
| - r"\bllvm-readobj\b", |
195 |
| - r"\bllvm-rtdyld\b", |
196 |
| - r"\bllvm-size\b", |
197 |
| - r"\bllvm-split\b", |
198 |
| - r"\bllvm-strings\b", |
199 |
| - r"\bllvm-tblgen\b", |
200 |
| - r"\bllvm-c-test\b", |
201 |
| - r"\bllvm-cxxfilt\b", |
202 |
| - r"\bllvm-xray\b", |
203 |
| - NOJUNK + r"\bllvm-symbolizer\b", |
204 |
| - NOJUNK + r"\bopt\b", |
205 |
| - r"\bFileCheck\b", |
206 |
| - r"\bobj2yaml\b", |
207 |
| - NOJUNK + r"\bsancov\b", |
208 |
| - NOJUNK + r"\bsanstats\b", |
209 |
| - r"\byaml2obj\b", |
210 |
| - r"\byaml-bench\b", |
211 |
| - r"\bverify-uselistorder\b", |
212 |
| - # Handle these specially as they are strings searched |
213 |
| - # for during testing. |
214 |
| - r"\| \bcount\b", |
215 |
| - r"\| \bnot\b"]: |
216 |
| - tool_name, tool_path, tool_pipe = find_tool_substitution(pattern) |
217 |
| - if not tool_path: |
218 |
| - # Warn, but still provide a substitution. |
219 |
| - lit_config.note('Did not find ' + tool_name + ' in ' + config.llvm_tools_dir) |
220 |
| - tool_path = config.llvm_tools_dir + '/' + tool_name |
221 |
| - config.substitutions.append((pattern, tool_pipe + tool_path)) |
| 138 | +JUNKCHARS = r".-^/<" |
| 139 | + |
| 140 | +required_tools = [ |
| 141 | + 'lli', 'llvm-ar', 'llvm-as', 'llvm-bcanalyzer', 'llvm-config', 'llvm-cov', |
| 142 | + 'llvm-cxxdump', 'llvm-cvtres', 'llvm-diff', 'llvm-dis', 'llvm-dsymutil', |
| 143 | + 'llvm-dwarfdump', 'llvm-extract', 'llvm-isel-fuzzer', 'llvm-lib', |
| 144 | + 'llvm-link', 'llvm-lto', 'llvm-lto2', 'llvm-mc', 'llvm-mcmarkup', |
| 145 | + 'llvm-modextract', 'llvm-nm', 'llvm-objcopy', 'llvm-objdump', |
| 146 | + 'llvm-pdbutil', 'llvm-profdata', 'llvm-ranlib', 'llvm-readobj', |
| 147 | + 'llvm-rtdyld', 'llvm-size', 'llvm-split', 'llvm-strings', 'llvm-tblgen', |
| 148 | + 'llvm-c-test', 'llvm-cxxfilt', 'llvm-xray', 'yaml2obj', 'obj2yaml', |
| 149 | + 'FileCheck', 'yaml-bench', 'verify-uselistorder', |
| 150 | + ToolFilter('bugpoint', post='-'), |
| 151 | + ToolFilter('llc', pre=JUNKCHARS), |
| 152 | + ToolFilter('llvm-symbolizer', pre=JUNKCHARS), |
| 153 | + ToolFilter('opt', JUNKCHARS), |
| 154 | + ToolFilter('sancov', pre=JUNKCHARS), |
| 155 | + ToolFilter('sanstats', pre=JUNKCHARS), |
| 156 | + # Handle these specially as they are strings searched for during testing. |
| 157 | + ToolFilter(r'\| \bcount\b', verbatim=True), |
| 158 | + ToolFilter(r'\| \bnot\b', verbatim=True)] |
| 159 | + |
| 160 | +llvm_config.add_tool_substitutions(required_tools, config.llvm_tools_dir) |
222 | 161 |
|
223 | 162 | # For tools that are optional depending on the config, we won't warn
|
224 | 163 | # if they're missing.
|
225 |
| -for pattern in [r"\bllvm-go\b", |
226 |
| - r"\bllvm-mt\b", |
227 |
| - r"\bKaleidoscope-Ch3\b", |
228 |
| - r"\bKaleidoscope-Ch4\b", |
229 |
| - r"\bKaleidoscope-Ch5\b", |
230 |
| - r"\bKaleidoscope-Ch6\b", |
231 |
| - r"\bKaleidoscope-Ch7\b", |
232 |
| - r"\bKaleidoscope-Ch8\b"]: |
233 |
| - tool_name, tool_path, tool_pipe = find_tool_substitution(pattern) |
234 |
| - if not tool_path: |
235 |
| - # Provide a substitution anyway, for the sake of consistent errors. |
236 |
| - tool_path = config.llvm_tools_dir + '/' + tool_name |
237 |
| - config.substitutions.append((pattern, tool_pipe + tool_path)) |
238 | 164 |
|
| 165 | +optional_tools = [ |
| 166 | + 'llvm-go', 'llvm-mt', 'Kaleidoscope-Ch3', 'Kaleidoscope-Ch4', |
| 167 | + 'Kaleidoscope-Ch5', 'Kaleidoscope-Ch6', 'Kaleidoscope-Ch7', |
| 168 | + 'Kaleidoscope-Ch8'] |
| 169 | +llvm_config.add_tool_substitutions(optional_tools, config.llvm_tools_dir, |
| 170 | + warn_missing=False) |
239 | 171 |
|
240 | 172 | ### Targets
|
241 | 173 |
|
|
0 commit comments