aboutsummaryrefslogtreecommitdiff
path: root/lib/compilers/ldc.js
diff options
context:
space:
mode:
authorJohan Engelen <jbc.engelen@gmail.com>2019-03-24 01:57:18 +0100
committerJohan Engelen <jbc.engelen@gmail.com>2019-03-24 01:57:51 +0100
commitf2652cfcdd5063943fed2301a9fad56e44bf91e3 (patch)
treecafbd0da62550b0e521150267511c64f42c0c5e8 /lib/compilers/ldc.js
parent68eef3d12671d007fd1627491706da46df5cf14a (diff)
downloadcompiler-explorer-f2652cfcdd5063943fed2301a9fad56e44bf91e3.tar.gz
compiler-explorer-f2652cfcdd5063943fed2301a9fad56e44bf91e3.zip
Add LLVM IR view for LDC.
Diffstat (limited to 'lib/compilers/ldc.js')
-rw-r--r--lib/compilers/ldc.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/compilers/ldc.js b/lib/compilers/ldc.js
index d8b30417d..ced24df3a 100644
--- a/lib/compilers/ldc.js
+++ b/lib/compilers/ldc.js
@@ -26,12 +26,15 @@ const BaseCompiler = require('../base-compiler'),
argumentParsers = require("./argument-parsers"),
fs = require('fs-extra'),
logger = require('./../logger').logger,
+ path = require('path'),
semverParser = require('semver');
class LDCCompiler extends BaseCompiler {
constructor(info, env) {
super(info, env);
this.compiler.supportsIntel = true;
+ this.compiler.supportsIrView = true;
+ this.compiler.irArg = ['-output-ll'];
}
optionsForFilter(filters, outputFilename) {
@@ -80,6 +83,17 @@ class LDCCompiler extends BaseCompiler {
}
return fs.readFileSync(astFilename, 'utf-8');
}
+
+ // Override the IR processing method for LDC because the output file is different from clang.
+ processIrOutput(output, filters) {
+ const irPath = this.getOutputFilename(path.dirname(output.inputFilename), this.outputFilebase).replace('.s', '.ll');
+ if (fs.existsSync(irPath)) {
+ const output = fs.readFileSync(irPath, 'utf-8');
+ // uses same filters as main compiler
+ return this.llvmIr.process(output, filters);
+ }
+ return output.stderr;
+ }
}
module.exports = LDCCompiler;