aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Quist <partouf@gmail.com>2023-10-31 02:04:04 +0100
committerGitHub <noreply@github.com>2023-10-31 02:04:04 +0100
commitb5fb8086d63394e5114c4ef9c6d1c12b89b30829 (patch)
treee22e444701e801c49d721a6d1f23a2fb86aafe52
parentea78f75233c2f320022d02660ac4e8c25c4952b4 (diff)
parentedeca232c5ce62e8153ee1e902743df020572118 (diff)
downloadcompiler-explorer-gh-9310.tar.gz
compiler-explorer-gh-9310.zip
Merge branch 'main' into exec-with-heaptrackgh-9310
-rw-r--r--etc/config/c++.amazon.properties2
-rw-r--r--etc/config/c.amazon.properties2
-rw-r--r--etc/config/cpp_for_opencl.amazon.properties2
-rw-r--r--etc/config/openclc.amazon.properties2
-rw-r--r--lib/base-compiler.ts11
-rw-r--r--lib/compilers/dotnet.ts36
-rw-r--r--lib/llvm-opt-transformer.ts11
-rw-r--r--static/components.interfaces.ts15
-rw-r--r--static/panes/ir-view.ts8
-rw-r--r--test/llvm-opt-transformer-test.ts20
10 files changed, 72 insertions, 37 deletions
diff --git a/etc/config/c++.amazon.properties b/etc/config/c++.amazon.properties
index ebafcf2e3..27c174e13 100644
--- a/etc/config/c++.amazon.properties
+++ b/etc/config/c++.amazon.properties
@@ -720,7 +720,7 @@ compiler.armv8-clang-trunk.options=-target aarch64-linux-gnu --gcc-toolchain=/op
compiler.armv8-full-clang-trunk.exe=/opt/compiler-explorer/clang-trunk/bin/clang++
compiler.armv8-full-clang-trunk.demangler=/opt/compiler-explorer/gcc-snapshot/bin/c++filt
compiler.armv8-full-clang-trunk.objdumper=/opt/compiler-explorer/arm64/gcc-10.2.0/aarch64-unknown-linux-gnu/aarch64-unknown-linux-gnu/bin/objdump
-compiler.armv8-full-clang-trunk.semver=(trunk, all architectural features)
+compiler.armv8-full-clang-trunk.semver=(all architectural features, trunk)
compiler.armv8-full-clang-trunk.isNightly=true
# Arm v8-a with all supported architectural features
compiler.armv8-full-clang-trunk.options=-target aarch64-linux-gnu --gcc-toolchain=/opt/compiler-explorer/arm64/gcc-12.2.0/aarch64-unknown-linux-gnu --sysroot=/opt/compiler-explorer/arm64/gcc-12.2.0/aarch64-unknown-linux-gnu/aarch64-unknown-linux-gnu/sysroot -march=armv8.8-a+crypto+profile+rng+memtag+sve2+sve2-bitperm+sve2-sm4+sve2-aes+sve2-sha3+tme+brbe+f32mm+f64mm+fp16fml+ls64+sme+sme-f64f64+sme-i16i64+sme2
diff --git a/etc/config/c.amazon.properties b/etc/config/c.amazon.properties
index ee0e9bc31..ecf31a80d 100644
--- a/etc/config/c.amazon.properties
+++ b/etc/config/c.amazon.properties
@@ -545,7 +545,7 @@ compiler.armv8-cclang-trunk.isNightly=true
# Arm v8-a
compiler.armv8-cclang-trunk.options=-target aarch64-linux-gnu --gcc-toolchain=/opt/compiler-explorer/arm64/gcc-12.2.0/aarch64-unknown-linux-gnu --sysroot=/opt/compiler-explorer/arm64/gcc-12.2.0/aarch64-unknown-linux-gnu/aarch64-unknown-linux-gnu/sysroot
-compiler.armv8-full-cclang-trunk.name=armv8-a clang (trunk, all architectural features)
+compiler.armv8-full-cclang-trunk.name=armv8-a clang (all architectural features, trunk)
compiler.armv8-full-cclang-trunk.exe=/opt/compiler-explorer/clang-trunk/bin/clang
compiler.armv8-full-cclang-trunk.demangler=/opt/compiler-explorer/gcc-snapshot/bin/c++filt
compiler.armv8-full-cclang-trunk.objdumper=/opt/compiler-explorer/arm64/gcc-10.2.0/aarch64-unknown-linux-gnu/aarch64-unknown-linux-gnu/bin/objdump
diff --git a/etc/config/cpp_for_opencl.amazon.properties b/etc/config/cpp_for_opencl.amazon.properties
index 3ed355c7c..e2c9984f8 100644
--- a/etc/config/cpp_for_opencl.amazon.properties
+++ b/etc/config/cpp_for_opencl.amazon.properties
@@ -171,7 +171,7 @@ compiler.armv8-cpp4oclclang-trunk-assertions.isNightly=true
# Arm v8-a
compiler.armv8-cpp4oclclang-trunk-assertions.options=-target aarch64-linux-gnu --gcc-toolchain=/opt/compiler-explorer/arm64/gcc-12.2.0/aarch64-unknown-linux-gnu --sysroot=/opt/compiler-explorer/arm64/gcc-12.2.0/aarch64-unknown-linux-gnu/aarch64-unknown-linux-gnu/sysroot
-compiler.armv8-full-cpp4oclclang-trunk.name=armv8-a clang (trunk, all architectural features)
+compiler.armv8-full-cpp4oclclang-trunk.name=armv8-a clang (all architectural features, trunk)
compiler.armv8-full-cpp4oclclang-trunk.exe=/opt/compiler-explorer/clang-trunk/bin/clang
compiler.armv8-full-cpp4oclclang-trunk.demangler=/opt/compiler-explorer/gcc-snapshot/bin/c++filt
compiler.armv8-full-cpp4oclclang-trunk.objdumper=/opt/compiler-explorer/gcc-snapshot/bin/objdump
diff --git a/etc/config/openclc.amazon.properties b/etc/config/openclc.amazon.properties
index cef1badde..3283c0a99 100644
--- a/etc/config/openclc.amazon.properties
+++ b/etc/config/openclc.amazon.properties
@@ -192,7 +192,7 @@ compiler.armv8-oclcclang-trunk-assertions.semver=(assertions trunk)
# Arm v8-a
compiler.armv8-oclcclang-trunk-assertions.options=-target aarch64-linux-gnu --gcc-toolchain=/opt/compiler-explorer/arm64/gcc-12.2.0/aarch64-unknown-linux-gnu --sysroot=/opt/compiler-explorer/arm64/gcc-12.2.0/aarch64-unknown-linux-gnu/aarch64-unknown-linux-gnu/sysroot
-compiler.armv8-full-oclcclang-trunk.name=armv8-a clang (trunk, all architectural features)
+compiler.armv8-full-oclcclang-trunk.name=armv8-a clang (all architectural features, trunk)
compiler.armv8-full-oclcclang-trunk.exe=/opt/compiler-explorer/clang-trunk/bin/clang
compiler.armv8-full-oclcclang-trunk.demangler=/opt/compiler-explorer/gcc-snapshot/bin/c++filt
compiler.armv8-full-oclcclang-trunk.objdumper=/opt/compiler-explorer/gcc-snapshot/bin/objdump
diff --git a/lib/base-compiler.ts b/lib/base-compiler.ts
index cce00b879..b8fce73a8 100644
--- a/lib/base-compiler.ts
+++ b/lib/base-compiler.ts
@@ -112,6 +112,7 @@ import {ParsedAsmResultLine} from '../types/asmresult/asmresult.interfaces.js';
import {unique} from '../shared/common-utils.js';
import {ClientOptionsType, OptionsHandlerLibrary, VersionInfo} from './options-handler.js';
import {HeaptrackWrapper} from './runtime-tools/heaptrack-wrapper.js';
+import stream from 'node:stream';
const compilationTimeHistogram = new PromClient.Histogram({
name: 'ce_base_compiler_compilation_duration_seconds',
@@ -2906,9 +2907,13 @@ export class BaseCompiler implements ICompiler {
async processOptOutput(optPath: string) {
const output: compilerOptInfo.LLVMOptInfo[] = [];
- const optStream = fs
- .createReadStream(optPath, {encoding: 'utf8'})
- .pipe(new compilerOptInfo.LLVMOptTransformer());
+ const optStream = stream.pipeline(
+ fs.createReadStream(optPath, {encoding: 'utf8'}),
+ new compilerOptInfo.LLVMOptTransformer(),
+ err => {
+ if (err) logger.error(`Error handling opt output: ${err}`);
+ },
+ );
for await (const opt of optStream as AsyncIterable<compilerOptInfo.LLVMOptInfo>) {
if (opt.DebugLoc && opt.DebugLoc.File && opt.DebugLoc.File.includes(this.compileFilename)) {
diff --git a/lib/compilers/dotnet.ts b/lib/compilers/dotnet.ts
index a55a9a172..5a1f4c12f 100644
--- a/lib/compilers/dotnet.ts
+++ b/lib/compilers/dotnet.ts
@@ -54,8 +54,6 @@ class DotNetCompiler extends BaseCompiler {
private readonly crossgen2Path: string;
private readonly sdkMajorVersion: number;
- private versionString: string;
-
constructor(compilerInfo: PreliminaryCompilerInfo, env) {
super(compilerInfo, env);
@@ -71,9 +69,8 @@ class DotNetCompiler extends BaseCompiler {
this.langVersion = this.compilerProps<string>(`compiler.${this.compiler.id}.langVersion`);
this.corerunPath = path.join(this.clrBuildDir, 'corerun');
- this.crossgen2Path = path.join(this.clrBuildDir, 'crossgen2', 'crossgen2');
+ this.crossgen2Path = path.join(this.clrBuildDir, 'crossgen2', 'crossgen2.dll');
this.asm = new DotNetAsmParser();
- this.versionString = '';
this.disassemblyLoaderPath = path.join(this.clrBuildDir, 'DisassemblyLoader', 'DisassemblyLoader.dll');
}
@@ -400,6 +397,7 @@ class DotNetCompiler extends BaseCompiler {
if (isCrossgen2) {
const crossgen2Result = await this.runCrossgen2(
+ compiler,
execOptions,
this.clrBuildDir,
programDllPath,
@@ -475,15 +473,13 @@ class DotNetCompiler extends BaseCompiler {
}
}
- async checkRuntimeVersion() {
- if (!this.versionString) {
- const versionFilePath = `${this.clrBuildDir}/version.txt`;
- if (fs.existsSync(versionFilePath)) {
- const versionString = await fs.readFile(versionFilePath);
- this.versionString = versionString.toString();
- } else {
- this.versionString = '<unknown version>';
- }
+ async getRuntimeVersion() {
+ const versionFilePath = `${this.clrBuildDir}/version.txt`;
+ if (fs.existsSync(versionFilePath)) {
+ const versionString = await fs.readFile(versionFilePath);
+ return versionString.toString();
+ } else {
+ return '<unknown version>';
}
}
@@ -495,8 +491,6 @@ class DotNetCompiler extends BaseCompiler {
options: string[],
outputPath: string,
) {
- await this.checkRuntimeVersion();
-
const corerunOptions = ['--clr-path', coreRoot, '--env', envPath].concat([
...options,
this.disassemblyLoaderPath,
@@ -507,13 +501,16 @@ class DotNetCompiler extends BaseCompiler {
await fs.writeFile(
outputPath,
- `// coreclr ${this.versionString}\n\n${result.stdout.map(o => o.text).reduce((a, n) => `${a}\n${n}`, '')}`,
+ `// coreclr ${await this.getRuntimeVersion()}\n\n${result.stdout
+ .map(o => o.text)
+ .reduce((a, n) => `${a}\n${n}`, '')}`,
);
return result;
}
async runCrossgen2(
+ compiler: string,
execOptions: ExecutionOptions,
bclPath: string,
dllPath: string,
@@ -521,22 +518,21 @@ class DotNetCompiler extends BaseCompiler {
toolSwitches: string[],
outputPath: string,
) {
- await this.checkRuntimeVersion();
-
// prettier-ignore
const crossgen2Options = [
+ this.crossgen2Path,
'-r', path.join(bclPath, '/'),
'-r', this.disassemblyLoaderPath,
dllPath,
'-o', `${AssemblyName}.r2r.dll`,
].concat(toolOptions).concat(toolSwitches);
- const compilerExecResult = await this.exec(this.crossgen2Path, crossgen2Options, execOptions);
+ const compilerExecResult = await this.exec(compiler, crossgen2Options, execOptions);
const result = this.transformToCompilationResult(compilerExecResult, dllPath);
await fs.writeFile(
outputPath,
- `// crossgen2 ${this.versionString}\n\n${result.stdout
+ `// crossgen2 ${await this.getRuntimeVersion()}\n\n${result.stdout
.map(o => o.text)
.reduce((a, n) => `${a}\n${n}`, '')}`,
);
diff --git a/lib/llvm-opt-transformer.ts b/lib/llvm-opt-transformer.ts
index 40ac66b63..41f6fbf34 100644
--- a/lib/llvm-opt-transformer.ts
+++ b/lib/llvm-opt-transformer.ts
@@ -86,9 +86,14 @@ export class LLVMOptTransformer extends Transform {
}
override _transform(chunk: any, encoding: string, done: TransformCallback) {
- this._buffer += chunk.toString();
- //buffer until we have a start and end if at any time i care about improving performance stash the offset
- this.processBuffer();
+ // See https://stackoverflow.com/a/40928431/390318 - we have to catch all exceptions here
+ try {
+ this._buffer += chunk.toString();
+ this.processBuffer();
+ } catch (exception) {
+ done(exception as Error);
+ return;
+ }
done();
}
diff --git a/static/components.interfaces.ts b/static/components.interfaces.ts
index dabe0d561..932b3214b 100644
--- a/static/components.interfaces.ts
+++ b/static/components.interfaces.ts
@@ -28,6 +28,7 @@ import {LLVMOptPipelineViewState} from './panes/llvm-opt-pipeline.interfaces.js'
import {GccDumpViewState} from './panes/gccdump-view.interfaces.js';
import {ConfiguredOverrides} from './compilation/compiler-overrides.interfaces.js';
import {ConfiguredRuntimeTools} from './execution/execution.interfaces.js';
+import {IrState} from './panes/ir-view.interfaces.js';
export const COMPILER_COMPONENT_NAME = 'compiler';
export const EXECUTOR_COMPONENT_NAME = 'executor';
export const EDITOR_COMPONENT_NAME = 'codeEditor';
@@ -204,13 +205,13 @@ export type PopulatedConformanceViewState = {
};
export type EmptyIrViewState = EmptyState;
-export type PopulatedIrViewState = StateWithId & {
- editorid: number;
- treeid: number;
- source: string;
- irOutput: unknown;
- compilerName: string;
-};
+export type PopulatedIrViewState = StateWithId &
+ IrState & {
+ editorid: number;
+ treeid: number;
+ source: string;
+ compilerName: string;
+ };
export type EmptyLLVMOptPipelineViewState = EmptyState;
export type PopulatedLLVMOptPipelineViewState = StateWithId &
diff --git a/static/panes/ir-view.ts b/static/panes/ir-view.ts
index 575842fc6..8bb2d02d3 100644
--- a/static/panes/ir-view.ts
+++ b/static/panes/ir-view.ts
@@ -129,6 +129,14 @@ export class Ir extends MonacoPane<monaco.editor.IStandaloneCodeEditor, IrState>
});
}
+ override getCurrentState() {
+ return {
+ ...this.options.get(),
+ ...this.filters.get(),
+ ...super.getCurrentState(),
+ };
+ }
+
override registerEditorActions(): void {
this.editor.addAction({
id: 'viewsource',
diff --git a/test/llvm-opt-transformer-test.ts b/test/llvm-opt-transformer-test.ts
index e9dc771c3..f41d181f5 100644
--- a/test/llvm-opt-transformer-test.ts
+++ b/test/llvm-opt-transformer-test.ts
@@ -19,6 +19,8 @@
import * as stream from 'stream';
+import {YAMLParseError} from 'yaml';
+
import {LLVMOptTransformer} from '../lib/llvm-opt-transformer.js';
describe('LLVM opt transformer', () => {
@@ -94,4 +96,22 @@ Args:
},
]);
});
+ it('should error with unparseable yaml data', async () => {
+ const doc = `--- !Analysis
+broken: not a yaml doc
+broken: duplicate key makes this invalid
+...
+`;
+ const readString = new stream.PassThrough();
+ readString.push(doc);
+ readString.end();
+ return (async () => {
+ const optStream = stream.pipeline(readString, new LLVMOptTransformer(), res => {
+ return res;
+ });
+ for await (const _ of optStream) {
+ // just consume
+ }
+ })().should.be.rejectedWith(YAMLParseError);
+ });
});