(compilationInfo: CompilationInfo, _inputFilepath?: string, args?: string[])
| 49 | } |
| 50 | |
| 51 | override async runTool(compilationInfo: CompilationInfo, _inputFilepath?: string, args?: string[]) { |
| 52 | const isets = new InstructionSets(); |
| 53 | let target = isets.getInstructionSetTarget(compilationInfo.compiler.instructionSet); |
| 54 | const prependArgs: string[] = []; |
| 55 | |
| 56 | // Check if compiler target is overridden with --target=<foo> or -target <foo>. |
| 57 | let argIsTarget = false; |
| 58 | for (const arg of compilationInfo.options) { |
| 59 | if (arg.startsWith('--target=')) target = arg.replace(/^--target=/, ''); |
| 60 | if (argIsTarget) { |
| 61 | target = arg; |
| 62 | argIsTarget = false; |
| 63 | } |
| 64 | if (arg === '-target') argIsTarget = true; |
| 65 | } |
| 66 | |
| 67 | if (target) prependArgs.push('-mtriple=' + target); |
| 68 | |
| 69 | let haveCPU = false; |
| 70 | let haveM32 = false; |
| 71 | for (const arg of compilationInfo.options) { |
| 72 | if (arg.startsWith('-march') && (target?.startsWith('x86_64') || target?.startsWith('i386'))) { |
| 73 | prependArgs.push(arg.replace(/^-march=/, '-mcpu=')); |
| 74 | haveCPU = true; |
| 75 | } |
| 76 | if (arg === '-m32') haveM32 = true; |
| 77 | if (arg.startsWith('-mcpu')) { |
| 78 | prependArgs.push(arg); |
| 79 | haveCPU = true; |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | if (compilationInfo.filters.binary || compilationInfo.filters.binaryObject) { |
| 84 | return this.createErrorResponse('<cannot run analysis on binary>'); |
| 85 | } |
| 86 | |
| 87 | // If no other CPU specified, default to mcpu=generic to |
| 88 | // override llvm-mca's default of -mcpu=native, otherwise MCA's |
| 89 | // CPU analysis varies according to the machine MCA happens to |
| 90 | // run on which can change over time. |
| 91 | if (!haveCPU) { |
| 92 | prependArgs.push('-mcpu=generic'); |
| 93 | } |
| 94 | |
| 95 | if (target?.startsWith('x86_64') && haveM32) { |
| 96 | prependArgs.push('-march=x86'); // (i.e. i686). |
| 97 | } |
| 98 | |
| 99 | // Prepend the detected arguments, so that user specified come |
| 100 | // later (and therefore can be used to override the detected |
| 101 | // ones above). |
| 102 | const newArgs: string[] = prependArgs.concat(args || []); |
| 103 | |
| 104 | if (!compilationInfo.asm) { |
| 105 | return this.createErrorResponse('<no assembly output available>'); |
| 106 | } |
| 107 | |
| 108 | const rewrittenOutputFilename = compilationInfo.outputFilename + '.mca'; |
nothing calls this directly
no test coverage detected