diff options
-rw-r--r-- | etc/config/c++.amazon.properties | 14 | ||||
-rw-r--r-- | etc/config/c.amazon.properties | 15 | ||||
-rw-r--r-- | lib/base-compiler.ts | 11 | ||||
-rw-r--r-- | lib/compilers/clang.ts | 97 | ||||
-rw-r--r-- | lib/llvm-ir.js | 1 | ||||
-rw-r--r-- | static/panes/device-view.js | 16 | ||||
-rw-r--r-- | types/asmresult/asmresult.interfaces.ts | 1 |
7 files changed, 109 insertions, 46 deletions
diff --git a/etc/config/c++.amazon.properties b/etc/config/c++.amazon.properties index 0e65a816b..4464a5f53 100644 --- a/etc/config/c++.amazon.properties +++ b/etc/config/c++.amazon.properties @@ -10,6 +10,8 @@ buildenvsetup.host=https://conan.compiler-explorer.com externalparser=CEAsmParser externalparser.exe=/usr/local/bin/asm-parser +llvmDisassembler=/opt/compiler-explorer/clang-14.0.0/bin/llvm-dis + ############################### # GCC for x86 group.gcc86.compilers=g412:g447:g453:g464:g471:g472:g473:g474:g481:g482:g483:g484:g485:g490:g491:g492:g493:g494:g510:g520:g530:g540:g550:g6:g62:g63:g64:g71:g72:g73:g74:g75:g81:g82:g83:g84:g85:g91:g92:g93:g94:g95:g101:g102:g103:g104:g111:g112:g113:g121:g122:gsnapshot:gcontracts-trunk:gcontract-labels-trunk:gcxx-modules-trunk:gcxx-coroutines-trunk:gcc-embed-trunk:gcc-static-analysis-trunk @@ -659,37 +661,37 @@ group.icx.isSemVer=true group.icx.compilerType=clang-intel compiler.icx202112.exe=/opt/compiler-explorer/intel-cpp-2021.1.2.63/compiler/latest/linux/bin/icpx -compiler.icx202112.ldPath=/opt/compiler-explorer/intel-cpp-2021.1.2.63/compiler/latest/linux/compiler/lib/intel64_lin +compiler.icx202112.ldPath=/opt/compiler-explorer/intel-cpp-2021.1.2.63/compiler/latest/linux/compiler/lib/intel64_lin:/opt/compiler-explorer/intel-cpp-2021.1.2.63/compiler/latest/linux/lib compiler.icx202112.libPath=/opt/compiler-explorer/intel-cpp-2021.1.2.63/compiler/latest/linux/compiler/lib/intel64_lin:/opt/compiler-explorer/intel-cpp-2021.1.2.63/compiler/latest/linux/compiler/lib/ia32_lin compiler.icx202112.semver=2021.1.2 compiler.icx202112.options=--gcc-toolchain=/opt/compiler-explorer/gcc-10.1.0 compiler.icx202120.exe=/opt/compiler-explorer/intel-cpp-2021.2.0.118/compiler/latest/linux/bin/icpx -compiler.icx202120.ldPath=/opt/compiler-explorer/intel-cpp-2021.2.0.118/compiler/latest/linux/compiler/lib/intel64_lin +compiler.icx202120.ldPath=/opt/compiler-explorer/intel-cpp-2021.2.0.118/compiler/latest/linux/compiler/lib/intel64_lin:/opt/compiler-explorer/intel-cpp-2021.2.0.118/compiler/latest/linux/lib compiler.icx202120.libPath=/opt/compiler-explorer/intel-cpp-2021.2.0.118/compiler/latest/linux/compiler/lib/intel64_lin:/opt/compiler-explorer/intel-cpp-2021.2.0.118/compiler/latest/linux/compiler/lib/ia32_lin compiler.icx202120.semver=2021.2.0 compiler.icx202120.options=--gcc-toolchain=/opt/compiler-explorer/gcc-10.1.0 compiler.icx202130.exe=/opt/compiler-explorer/intel-cpp-2021.3.0.3168/compiler/latest/linux/bin/icpx -compiler.icx202130.ldPath=/opt/compiler-explorer/intel-cpp-2021.3.0.3168/compiler/latest/linux/compiler/lib/intel64_lin +compiler.icx202130.ldPath=/opt/compiler-explorer/intel-cpp-2021.3.0.3168/compiler/latest/linux/compiler/lib/intel64_lin:/opt/compiler-explorer/intel-cpp-2021.3.0.3168/compiler/latest/linux/lib compiler.icx202130.libPath=/opt/compiler-explorer/intel-cpp-2021.3.0.3168/compiler/latest/linux/compiler/lib/intel64_lin:/opt/compiler-explorer/intel-cpp-2021.3.0.3168/compiler/latest/linux/compiler/lib/ia32_lin compiler.icx202130.semver=2021.3.0 compiler.icx202130.options=--gcc-toolchain=/opt/compiler-explorer/gcc-10.1.0 compiler.icx202140.exe=/opt/compiler-explorer/intel-cpp-2021.4.0.3201/compiler/latest/linux/bin/icpx -compiler.icx202140.ldPath=/opt/compiler-explorer/intel-cpp-2021.4.0.3201/compiler/latest/linux/compiler/lib/intel64_lin +compiler.icx202140.ldPath=/opt/compiler-explorer/intel-cpp-2021.4.0.3201/compiler/latest/linux/compiler/lib/intel64_lin:/opt/compiler-explorer/intel-cpp-2021.4.0.3201/compiler/latest/linux/lib compiler.icx202140.libPath=/opt/compiler-explorer/intel-cpp-2021.4.0.3201/compiler/latest/linux/compiler/lib/intel64_lin:/opt/compiler-explorer/intel-cpp-2021.4.0.3201/compiler/latest/linux/compiler/lib/ia32_lin compiler.icx202140.semver=2021.4.0 compiler.icx202140.options=--gcc-toolchain=/opt/compiler-explorer/gcc-10.1.0 compiler.icx202200.exe=/opt/compiler-explorer/intel-cpp-2022.0.1.71/compiler/latest/linux/bin/icpx -compiler.icx202200.ldPath=/opt/compiler-explorer/intel-cpp-2022.0.1.71/compiler/latest/linux/compiler/lib/intel64_lin +compiler.icx202200.ldPath=/opt/compiler-explorer/intel-cpp-2022.0.1.71/compiler/latest/linux/compiler/lib/intel64_lin:/opt/compiler-explorer/intel-cpp-2022.0.1.71/compiler/latest/linux/lib compiler.icx202200.libPath=/opt/compiler-explorer/intel-cpp-2022.0.1.71/compiler/latest/linux/compiler/lib/intel64_lin:/opt/compiler-explorer/intel-cpp-2022.0.1.71/compiler/latest/linux/compiler/lib/ia32_lin compiler.icx202200.semver=2022.0.0 compiler.icx202200.options=--gcc-toolchain=/opt/compiler-explorer/gcc-10.1.0 compiler.icx202210.exe=/opt/compiler-explorer/intel-cpp-2022.1.0.137/compiler/latest/linux/bin/icpx -compiler.icx202210.ldPath=/opt/compiler-explorer/intel-cpp-2022.1.0.137/compiler/latest/linux/compiler/lib/intel64_lin +compiler.icx202210.ldPath=/opt/compiler-explorer/intel-cpp-2022.1.0.137/compiler/latest/linux/compiler/lib/intel64_lin:/opt/compiler-explorer/intel-cpp-2022.1.0.137/compiler/latest/linux/lib compiler.icx202210.libPath=/opt/compiler-explorer/intel-cpp-2022.1.0.137/compiler/latest/linux/compiler/lib/intel64_lin:/opt/compiler-explorer/intel-cpp-2022.1.0.137/compiler/latest/linux/compiler/lib/ia32_lin:/opt/compiler-explorer/intel-cpp-2022.1.0.137/compiler/latest/linux/lib:/opt/compiler-explorer/intel-cpp-2022.1.0.137/tbb/2021.6.0/lib/intel64/gcc4.8 compiler.icx202210.semver=2022.1.0 compiler.icx202210.options=--gcc-toolchain=/opt/compiler-explorer/gcc-10.1.0 diff --git a/etc/config/c.amazon.properties b/etc/config/c.amazon.properties index 6307431bb..3791ea437 100644 --- a/etc/config/c.amazon.properties +++ b/etc/config/c.amazon.properties @@ -10,6 +10,8 @@ buildenvsetup.host=https://conan.compiler-explorer.com externalparser=CEAsmParser externalparser.exe=/usr/local/bin/asm-parser +llvmDisassembler=/opt/compiler-explorer/clang-14.0.0/bin/llvm-dis + ############################### # GCC for x86 group.cgcc86.compilers=cg412:cg447:cg453:cg464:cg471:cg472:cg473:cg474:cg481:cg482:cg483:cg484:cg485:cg490:cg491:cg492:cg493:cg494:cg510:cg520:cg530:cg540:cg6:cg62:cg63:cg71:cg72:cg73:cg74:cg81:cg82:cg83:cg84:cg85:cg91:cg92:cg93:cg94:cg95:cg101:cg102:cg103:cg104:cg111:cg112:cg113:cg121:cg122:cgsnapshot:cgstatic-analysis @@ -575,39 +577,40 @@ group.cicx.options= group.cicx.groupName=ICX x86-64 group.cicx.baseName=x86-64 icx group.cicx.isSemVer=true +group.cicx.compilerType=clang-intel compiler.cicx202112.exe=/opt/compiler-explorer/intel-cpp-2021.1.2.63/compiler/latest/linux/bin/icx -compiler.cicx202112.ldPath=/opt/compiler-explorer/intel-cpp-2021.1.2.63/compiler/latest/linux/compiler/lib/intel64_lin +compiler.cicx202112.ldPath=/opt/compiler-explorer/intel-cpp-2021.1.2.63/compiler/latest/linux/compiler/lib/intel64_lin:/opt/compiler-explorer/intel-cpp-2021.1.2.63/compiler/latest/linux/lib compiler.cicx202112.libPath=/opt/compiler-explorer/intel-cpp-2021.1.2.63/compiler/latest/linux/compiler/lib/intel64_lin:/opt/compiler-explorer/intel-cpp-2021.1.2.63/compiler/latest/linux/compiler/lib/ia32_lin compiler.cicx202112.semver=2021.1.2 compiler.cicx202112.options=--gcc-toolchain=/opt/compiler-explorer/gcc-10.1.0 compiler.cicx202120.exe=/opt/compiler-explorer/intel-cpp-2021.2.0.118/compiler/latest/linux/bin/icx -compiler.cicx202120.ldPath=/opt/compiler-explorer/intel-cpp-2021.2.0.118/compiler/latest/linux/compiler/lib/intel64_lin +compiler.cicx202120.ldPath=/opt/compiler-explorer/intel-cpp-2021.2.0.118/compiler/latest/linux/compiler/lib/intel64_lin:/opt/compiler-explorer/intel-cpp-2021.2.0.118/compiler/latest/linux/lib compiler.cicx202120.libPath=/opt/compiler-explorer/intel-cpp-2021.2.0.118/compiler/latest/linux/compiler/lib/intel64_lin:/opt/compiler-explorer/intel-cpp-2021.2.0.118/compiler/latest/linux/compiler/lib/ia32_lin compiler.cicx202120.semver=2021.2.0 compiler.cicx202120.options=--gcc-toolchain=/opt/compiler-explorer/gcc-10.1.0 compiler.cicx202130.exe=/opt/compiler-explorer/intel-cpp-2021.3.0.3168/compiler/latest/linux/bin/icx -compiler.cicx202130.ldPath=/opt/compiler-explorer/intel-cpp-2021.3.0.3168/compiler/latest/linux/compiler/lib/intel64_lin +compiler.cicx202130.ldPath=/opt/compiler-explorer/intel-cpp-2021.3.0.3168/compiler/latest/linux/compiler/lib/intel64_lin:/opt/compiler-explorer/intel-cpp-2021.3.0.3168/compiler/latest/linux/lib compiler.cicx202130.libPath=/opt/compiler-explorer/intel-cpp-2021.3.0.3168/compiler/latest/linux/compiler/lib/intel64_lin:/opt/compiler-explorer/intel-cpp-2021.3.0.3168/compiler/latest/linux/compiler/lib/ia32_lin compiler.cicx202130.semver=2021.3.0 compiler.cicx202130.options=--gcc-toolchain=/opt/compiler-explorer/gcc-10.1.0 compiler.cicx202140.exe=/opt/compiler-explorer/intel-cpp-2021.4.0.3201/compiler/latest/linux/bin/icx -compiler.cicx202140.ldPath=/opt/compiler-explorer/intel-cpp-2021.4.0.3201/compiler/latest/linux/compiler/lib/intel64_lin +compiler.cicx202140.ldPath=/opt/compiler-explorer/intel-cpp-2021.4.0.3201/compiler/latest/linux/compiler/lib/intel64_lin:/opt/compiler-explorer/intel-cpp-2021.4.0.3201/compiler/latest/linux/lib compiler.cicx202140.libPath=/opt/compiler-explorer/intel-cpp-2021.4.0.3201/compiler/latest/linux/compiler/lib/intel64_lin:/opt/compiler-explorer/intel-cpp-2021.4.0.3201/compiler/latest/linux/compiler/lib/ia32_lin compiler.cicx202140.semver=2021.4.0 compiler.cicx202140.options=--gcc-toolchain=/opt/compiler-explorer/gcc-10.1.0 compiler.cicx202200.exe=/opt/compiler-explorer/intel-cpp-2022.0.1.71/compiler/latest/linux/bin/icx -compiler.cicx202200.ldPath=/opt/compiler-explorer/intel-cpp-2022.0.1.71/compiler/latest/linux/compiler/lib/intel64_lin +compiler.cicx202200.ldPath=/opt/compiler-explorer/intel-cpp-2022.0.1.71/compiler/latest/linux/compiler/lib/intel64_lin:/opt/compiler-explorer/intel-cpp-2022.0.1.71/compiler/latest/linux/lib compiler.cicx202200.libPath=/opt/compiler-explorer/intel-cpp-2022.0.1.71/compiler/latest/linux/compiler/lib/intel64_lin:/opt/compiler-explorer/intel-cpp-2022.0.1.71/compiler/latest/linux/compiler/lib/ia32_lin compiler.cicx202200.semver=2022.0.0 compiler.cicx202200.options=--gcc-toolchain=/opt/compiler-explorer/gcc-10.1.0 compiler.cicx202210.exe=/opt/compiler-explorer/intel-cpp-2022.1.0.137/compiler/latest/linux/bin/icx -compiler.cicx202210.ldPath=/opt/compiler-explorer/intel-cpp-2022.1.0.137/compiler/latest/linux/compiler/lib/intel64_lin +compiler.cicx202210.ldPath=/opt/compiler-explorer/intel-cpp-2022.1.0.137/compiler/latest/linux/compiler/lib/intel64_lin:/opt/compiler-explorer/intel-cpp-2022.1.0.137/compiler/latest/linux/lib compiler.cicx202210.libPath=/opt/compiler-explorer/intel-cpp-2022.1.0.137/compiler/latest/linux/compiler/lib/intel64_lin:/opt/compiler-explorer/intel-cpp-2022.1.0.137/compiler/latest/linux/compiler/lib/ia32_lin compiler.cicx202210.semver=2022.1.0 compiler.cicx202210.options=--gcc-toolchain=/opt/compiler-explorer/gcc-10.1.0 diff --git a/lib/base-compiler.ts b/lib/base-compiler.ts index cf173f56a..885ca6cd3 100644 --- a/lib/base-compiler.ts +++ b/lib/base-compiler.ts @@ -2146,14 +2146,15 @@ export class BaseCompiler { delete result.optPath; result.optOutput = optOutput; } + + const compilationInfo = this.getCompilationInfo(key, result, customBuildPath); + result.tools = _.union( result.tools, - await Promise.all( - this.runToolsOfType(tools, 'postcompilation', this.getCompilationInfo(key, result, customBuildPath)), - ), + await Promise.all(this.runToolsOfType(tools, 'postcompilation', compilationInfo)), ); - result = this.extractDeviceCode(result, filters); + result = await this.extractDeviceCode(result, filters, compilationInfo); this.doTempfolderCleanup(result); if (result.buildResult) { @@ -2376,7 +2377,7 @@ but nothing was dumped. Possible causes are: } // eslint-disable-next-line no-unused-vars - extractDeviceCode(result, filters) { + async extractDeviceCode(result, filters, compilationInfo) { return result; } diff --git a/lib/compilers/clang.ts b/lib/compilers/clang.ts index eda3cef71..14dd13514 100644 --- a/lib/compilers/clang.ts +++ b/lib/compilers/clang.ts @@ -28,6 +28,7 @@ import path from 'path'; import _ from 'underscore'; import {ExecutionOptions} from '../../types/compilation/compilation.interfaces'; +import {UnprocessedExecResult} from '../../types/execution/execution.interfaces'; import {BaseCompiler} from '../base-compiler'; import {AmdgpuAsmParser} from '../parsers/asm-parser-amdgpu'; import {SassAsmParser} from '../parsers/asm-parser-sass'; @@ -36,6 +37,8 @@ const offloadRegexp = /^#\s+__CLANG_OFFLOAD_BUNDLE__(__START__|__END__)\s+(.*)$/ export class ClangCompiler extends BaseCompiler { protected asanSymbolizerPath?: string; + protected offloadBundlerPath?: string; + protected llvmDisassemblerPath?: string; static get key() { return 'clang'; @@ -44,10 +47,23 @@ export class ClangCompiler extends BaseCompiler { constructor(info, env) { super(info, env); this.compiler.supportsDeviceAsmView = true; - const asanSymbolizerPath = path.dirname(this.compiler.exe) + '/llvm-symbolizer'; + + const asanSymbolizerPath = path.join(path.dirname(this.compiler.exe), 'llvm-symbolizer'); if (fs.existsSync(asanSymbolizerPath)) { this.asanSymbolizerPath = asanSymbolizerPath; } + + const offloadBundlerPath = path.join(path.dirname(this.compiler.exe), 'clang-offload-bundler'); + if (fs.existsSync(offloadBundlerPath)) { + this.offloadBundlerPath = offloadBundlerPath; + } + + const llvmDisassemblerPath = path.join(path.dirname(this.compiler.exe), 'llvm-dis'); + if (fs.existsSync(llvmDisassemblerPath)) { + this.llvmDisassemblerPath = llvmDisassemblerPath; + } else { + this.llvmDisassemblerPath = this.compilerProps('llvmDisassembler'); + } } override runExecutable(executable, executeParameters, homeDir) { @@ -86,7 +102,7 @@ export class ClangCompiler extends BaseCompiler { return super.runCompiler(compiler, options, inputFilename, execOptions); } - splitDeviceCode(assembly) { + async splitDeviceCode(assembly) { // Check to see if there is any offload code in the assembly file. if (!offloadRegexp.test(assembly)) return null; @@ -105,36 +121,56 @@ export class ClangCompiler extends BaseCompiler { return devices; } - override extractDeviceCode(result, filters) { - const split = this.splitDeviceCode(result.asm); + override async extractDeviceCode(result, filters, compilationInfo) { + const split = await this.splitDeviceCode(result.asm); if (!split) return result; const devices = (result.devices = {}); for (const key of Object.keys(split)) { if (key.indexOf('host-') === 0) result.asm = split[key]; - else devices[key] = this.processDeviceAssembly(key, split[key], filters); + else devices[key] = await this.processDeviceAssembly(key, split[key], filters, compilationInfo); } return result; - // //result.asm = ... - // - // const extractor = this.compiler.deviceExtractor; - // const extractor_result = await this.exec(extractor, - // [outputFilename, result.dirPath + '/devices'], {}); - // if (extractor_result.code !== 0) { - // result.devices = extractor_result.stderr; - // return result; - // } - // const extractor_info = JSON.parse(extractor_result.stdout); - // result.asm = await fs.readFile(extractor_info.host, 'utf-8'); - // const devices = result.devices = {}; - // for (const device in extractor_info.devices) { - // const file = extractor_info.devices[device]; - // devices[device] = await this.processDeviceAssembly(device, file, filters); - // } - // return result; - } - - processDeviceAssembly(deviceName, deviceAsm, filters) { + } + + async extractBitcodeFromBundle(bundlefile, devicename): Promise<string> { + const bcfile = path.join(path.dirname(bundlefile), devicename + '.bc'); + + const env = this.getDefaultExecOptions(); + env.customCwd = path.dirname(bundlefile); + + if (this.offloadBundlerPath) { + const unbundleResult: UnprocessedExecResult = await this.exec( + this.offloadBundlerPath, + ['-unbundle', '--type', 's', '--inputs', bundlefile, '--outputs', bcfile, '--targets', devicename], + env, + ); + if (unbundleResult.code !== 0) { + return unbundleResult.stderr; + } + } else { + return '<error: no offload bundler found to unbundle device code>'; + } + + if (this.llvmDisassemblerPath) { + const llvmirFile = path.join(path.dirname(bundlefile), devicename + '.ll'); + + const disassembleResult: UnprocessedExecResult = await this.exec(this.llvmDisassemblerPath, [bcfile], env); + if (disassembleResult.code !== 0) { + return disassembleResult.stderr; + } + + return fs.readFileSync(llvmirFile, 'utf-8'); + } else { + return '<error: no llvm-dis found to disassemble bitcode>'; + } + } + + async processDeviceAssembly(deviceName, deviceAsm, filters, compilationInfo) { + if (deviceAsm.startsWith('BC')) { + deviceAsm = await this.extractBitcodeFromBundle(compilationInfo.outputFilename, deviceName); + } + return this.llvmIr.isLlvmIr(deviceAsm) ? this.llvmIr.process(deviceAsm, filters) : this.asm.process(deviceAsm, filters); @@ -193,6 +229,17 @@ export class ClangIntelCompiler extends ClangCompiler { return 'clang-intel'; } + constructor(info, env) { + super(info, env); + + if (!this.offloadBundlerPath) { + const offloadBundlerPath = path.join(path.dirname(this.compiler.exe), '../bin-llvm/clang-offload-bundler'); + if (fs.existsSync(offloadBundlerPath)) { + this.offloadBundlerPath = path.resolve(offloadBundlerPath); + } + } + } + override getDefaultExecOptions(): ExecutionOptions { const opts = super.getDefaultExecOptions(); opts.env.PATH = process.env.PATH + path.delimiter + path.dirname(this.compiler.exe); diff --git a/lib/llvm-ir.js b/lib/llvm-ir.js index adb209f9a..b2e3cbd09 100644 --- a/lib/llvm-ir.js +++ b/lib/llvm-ir.js @@ -180,6 +180,7 @@ export class LlvmIrParser { return { asm: result, labelDefinitions: {}, + languageId: 'llvm-ir', }; } diff --git a/static/panes/device-view.js b/static/panes/device-view.js index cdd226e64..270ff96a5 100644 --- a/static/panes/device-view.js +++ b/static/panes/device-view.js @@ -231,9 +231,10 @@ DeviceAsm.prototype.onDeviceSelect = function () { }; DeviceAsm.prototype.updateDeviceAsm = function () { - if (this.selectedDevice && this.devices[this.selectedDevice]) - this.showDeviceAsmResults(this.devices[this.selectedDevice].asm); - else this.showDeviceAsmResults([{text: '<Device ' + this.selectedDevice + ' not found>'}]); + if (this.selectedDevice && this.devices[this.selectedDevice]) { + var languageId = this.devices[this.selectedDevice].languageId; + this.showDeviceAsmResults(this.devices[this.selectedDevice].asm, languageId); + } else this.showDeviceAsmResults([{text: '<Device ' + this.selectedDevice + ' not found>'}]); }; DeviceAsm.prototype.getPaneTag = function () { @@ -256,9 +257,16 @@ DeviceAsm.prototype.updateTitle = function () { this.container.setTitle(_.escape(this.getPaneName())); }; -DeviceAsm.prototype.showDeviceAsmResults = function (deviceCode) { +DeviceAsm.prototype.showDeviceAsmResults = function (deviceCode, languageId) { if (!this.deviceEditor) return; this.deviceCode = deviceCode; + + if (!languageId) { + languageId = 'asm'; + } + + monaco.editor.setModelLanguage(this.deviceEditor.getModel(), languageId); + this.deviceEditor .getModel() .setValue(deviceCode.length ? _.pluck(deviceCode, 'text').join('\n') : '<No device code>'); diff --git a/types/asmresult/asmresult.interfaces.ts b/types/asmresult/asmresult.interfaces.ts index 6c8d00382..a54d61e4b 100644 --- a/types/asmresult/asmresult.interfaces.ts +++ b/types/asmresult/asmresult.interfaces.ts @@ -8,4 +8,5 @@ export type ParsedAsmResult = { externalParserUsed?: boolean; objdumpTime?: number; execTime?: string; + languageId?: string; }; |