Commit 6a6ffa9
Add function existence validation to TypeAnalysisPrinter and ActivityAnalysisPrinter (#2616)
* Initial plan
* Add function existence checks to TypeAnalysisPrinter and ActivityAnalysisPrinter
Co-authored-by: wsmoses <[email protected]>
* Fix compilation errors and add tests for function existence checks
Co-authored-by: wsmoses <[email protected]>
* Use std::once_flag for thread-safe validation in ActivityAnalysisPrinter NewPM
Co-authored-by: wsmoses <[email protected]>
* Improve code style with early returns and flatten nested conditionals
Co-authored-by: wsmoses <[email protected]>
* Final validation and testing complete
Co-authored-by: wsmoses <[email protected]>
* Remove CodeQL artifact
* Replace report_fatal_error with EmitFailure to avoid crashing
Use EmitFailure instead of report_fatal_error when function is not found.
This provides a better error message and avoids crashing the compiler.
Updated tests to match the new error message format.
Co-authored-by: wsmoses <[email protected]>
* Add function existence validation to TypeAnalysisPrinter and ActivityAnalysisPrinter
Co-authored-by: wsmoses <[email protected]>
* Refactor ActivityAnalysisPrinter to module pass and simplify function lookup
- Changed ActivityAnalysisPrinterNewPM from function pass to module pass
- Replaced std::call_once with M.getFunction for simpler function lookup
- Changed "specified in" to "specified by" in error messages
- Updated pass registration in Enzyme.cpp to use ModulePassManager
- Removed unnecessary <mutex> include
Co-authored-by: wsmoses <[email protected]>
* Optimize FAM retrieval in ActivityAnalysisPrinter
Move FunctionAnalysisManager retrieval outside the loop to avoid repeated calls
Co-authored-by: wsmoses <[email protected]>
* Remove legacy FunctionPass implementations and add empty function name validation
- Deleted legacy ActivityAnalysisPrinter FunctionPass (no longer needed with module pass)
- Deleted legacy TypeAnalysisPrinter FunctionPass (no longer needed with module pass)
- Added validation for empty function names in both passes
- Changed ActivityAnalysisPrinter to only run on target function instead of all functions
- Both passes now emit diagnostic errors for empty function names
Co-authored-by: wsmoses <[email protected]>
* Optimize TypeAnalysisPrinter to only run on target function
Changed TypeAnalysisPrinter to only run analysis on the target function instead of iterating through all functions, consistent with ActivityAnalysisPrinter
Co-authored-by: wsmoses <[email protected]>
* Restore legacy passes as ModulePasses
- Added back ActivityAnalysisPrinter as a legacy ModulePass (converted from FunctionPass)
- Added back TypeAnalysisPrinter as a legacy ModulePass (converted from FunctionPass)
- Both legacy passes now have the same validation logic as NewPM passes
- Legacy passes check for empty function names and non-existent functions
- Keeps RegisterPass registration for backward compatibility
Co-authored-by: wsmoses <[email protected]>
* Extract getFirstFunctionDefinition helper function to reduce code duplication
- Added getFirstFunctionDefinition() helper function in Utils.h/Utils.cpp
- Returns the first non-declaration function in a module, or nullptr if none exists
- Updated ActivityAnalysisPrinter to use the helper function (4 occurrences replaced)
- Updated TypeAnalysisPrinter to use the helper function (4 occurrences replaced)
- Eliminates code duplication and improves maintainability
Co-authored-by: wsmoses <[email protected]>
* Add EmitFailure overload for Module and simplify error handling
- Added EmitFailure template overload that takes llvm::Module& instead of Function*
- New overload automatically finds first function definition for diagnostic context
- Simplified all error handling code in ActivityAnalysisPrinter and TypeAnalysisPrinter
- Removed repetitive getFirstFunctionDefinition calls and if/else blocks
- Added forward declaration of getFirstFunctionDefinition for template usage
- Reduced code duplication and improved maintainability
Co-authored-by: wsmoses <[email protected]>
* Fix test expectations to match "specified by" error messages
Updated test files to expect "specified by" instead of "specified in" to match the actual error messages produced by the code.
Co-authored-by: wsmoses <[email protected]>
* Apply clang-format to fix formatting issues
- Fixed line wrapping for long comments
- Removed trailing whitespace
- Standardized indentation in arrays and function calls
- Applied clang-format to all modified C++ files
Co-authored-by: wsmoses <[email protected]>
* Fix formatting with clang-format-16 and llvm style
Applied clang-format-16 with llvm style (as required by CI) instead of clang-format-18. This changes indentation from 4 spaces to 2 spaces in array initializers to match the project's formatting requirements.
Co-authored-by: wsmoses <[email protected]>
---------
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: wsmoses <[email protected]>1 parent 2d4c57c commit 6a6ffa9
File tree
8 files changed
+141
-25
lines changed- enzyme
- Enzyme
- TypeAnalysis
- test
- ActivityAnalysis
- TypeAnalysis
8 files changed
+141
-25
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
50 | 51 | | |
51 | 52 | | |
52 | 53 | | |
| |||
182 | 183 | | |
183 | 184 | | |
184 | 185 | | |
185 | | - | |
| 186 | + | |
186 | 187 | | |
187 | 188 | | |
188 | | - | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
189 | 198 | | |
190 | | - | |
191 | | - | |
192 | | - | |
| 199 | + | |
| 200 | + | |
193 | 201 | | |
194 | | - | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
195 | 207 | | |
196 | | - | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
197 | 212 | | |
198 | | - | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
199 | 216 | | |
200 | 217 | | |
201 | 218 | | |
| |||
207 | 224 | | |
208 | 225 | | |
209 | 226 | | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
214 | 249 | | |
215 | 250 | | |
216 | 251 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
| 49 | + | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3799 | 3799 | | |
3800 | 3800 | | |
3801 | 3801 | | |
| 3802 | + | |
| 3803 | + | |
| 3804 | + | |
| 3805 | + | |
3802 | 3806 | | |
3803 | 3807 | | |
3804 | 3808 | | |
3805 | 3809 | | |
3806 | 3810 | | |
3807 | | - | |
3808 | | - | |
3809 | | - | |
3810 | | - | |
3811 | 3811 | | |
3812 | 3812 | | |
3813 | 3813 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| 55 | + | |
55 | 56 | | |
56 | 57 | | |
57 | 58 | | |
| |||
165 | 166 | | |
166 | 167 | | |
167 | 168 | | |
168 | | - | |
| 169 | + | |
| 170 | + | |
169 | 171 | | |
170 | 172 | | |
171 | | - | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
172 | 182 | | |
173 | | - | |
174 | | - | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
175 | 194 | | |
176 | 195 | | |
177 | | - | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
178 | 199 | | |
179 | 200 | | |
180 | 201 | | |
| |||
187 | 208 | | |
188 | 209 | | |
189 | 210 | | |
190 | | - | |
191 | | - | |
192 | | - | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
193 | 229 | | |
194 | 230 | | |
195 | 231 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3168 | 3168 | | |
3169 | 3169 | | |
3170 | 3170 | | |
| 3171 | + | |
| 3172 | + | |
| 3173 | + | |
| 3174 | + | |
| 3175 | + | |
| 3176 | + | |
| 3177 | + | |
| 3178 | + | |
| 3179 | + | |
3171 | 3180 | | |
3172 | 3181 | | |
3173 | 3182 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
195 | 195 | | |
196 | 196 | | |
197 | 197 | | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
198 | 201 | | |
199 | 202 | | |
200 | 203 | | |
| |||
217 | 220 | | |
218 | 221 | | |
219 | 222 | | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
220 | 238 | | |
221 | 239 | | |
222 | 240 | | |
| |||
1395 | 1413 | | |
1396 | 1414 | | |
1397 | 1415 | | |
| 1416 | + | |
| 1417 | + | |
1398 | 1418 | | |
1399 | 1419 | | |
1400 | 1420 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
0 commit comments