MCPcopy Create free account
hub / github.com/compiler-explorer/compiler-explorer / processRawOptRemarks

Method processRawOptRemarks

lib/compilers/gcc.ts:40–96  ·  view source on GitHub ↗
(buffer: string, compileFileName = '')

Source from the content-addressed store, hash-verified

38 }
39
40 override processRawOptRemarks(buffer: string, compileFileName = ''): OptRemark[] {
41 const remarks: OptRemark[] = [];
42
43 // example stderr lines:
44 // <source>:3:20: optimized: loop vectorized using 8 byte vectors
45 // <source>: 2: 6: note: vectorized 1 loops in function.
46 // <source>:11:13: missed: statement clobbers memory: somefunc (&i);
47 // BB 3 is always executed in loop 1
48
49 const remarkRegex = /^(.*?):\s*(\d+):\s*(\d+): (.*?): (.*)$/;
50
51 const mapOptType = (type: string): 'Missed' | 'Passed' | 'Analysis' => {
52 if (type === 'missed') return 'Missed';
53 if (type === 'optimized') return 'Passed';
54 return 'Analysis'; // for type 'note' or empty
55 };
56
57 utils.eachLine(buffer, line => {
58 const match = line.match(remarkRegex);
59 if (match) {
60 const [_, file, lineNum, colNum, type, message] = match;
61 // Filter out opt-remarks for included header files
62 if (file.includes(compileFileName) || file.includes('<source>')) {
63 // opt-remark with line/col info
64 // convert to llvm-emitted OptRemark format, just because it was here first
65 remarks.push({
66 DebugLoc: {
67 File: file,
68 // Could use line.tag for these too:
69 Line: Number.parseInt(lineNum, 10),
70 Column: Number.parseInt(colNum, 10),
71 },
72 optType: mapOptType(type),
73 displayString: message,
74 // TODO: make these optional?
75 Function: '',
76 Pass: '',
77 Name: '',
78 Args: [],
79 });
80 }
81 } else {
82 // opt-remark without line/col info
83 remarks.push({
84 DebugLoc: {File: '', Line: -1, Column: -1},
85 optType: 'Analysis',
86 displayString: line,
87 Function: '',
88 Pass: '',
89 Name: '',
90 Args: [],
91 });
92 }
93 });
94
95 return remarks;
96 }
97}

Callers 1

clang-tests.tsFile · 0.45

Calls 2

matchMethod · 0.80
pushMethod · 0.80

Tested by

no test coverage detected