Some quick llvm ir fixes

This commit is contained in:
Jeremy
2023-06-15 19:38:59 -04:00
parent 9147d0b0b4
commit ec00e4e6ac
3 changed files with 11 additions and 8 deletions
+5 -3
View File
@@ -36,12 +36,12 @@ import {PrefixTree} from './prefix-tree.js';
export class BaseDemangler extends AsmRegex {
readonly demanglerExe: string;
demanglerArguments: string[];
readonly demanglerArguments: string[];
symbolstore: SymbolStore | null;
othersymbols: SymbolStore;
result: ParsedAsmResult;
input: string[];
includeMetadata: boolean;
readonly includeMetadata: boolean;
readonly compiler: BaseCompiler;
readonly jumpDef = /(j\w+|b|bl|blx)\s+([$_a-z][\w$@]*)/i;
@@ -212,14 +212,16 @@ export class BaseDemangler extends AsmRegex {
if (!this.symbolstore) {
this.symbolstore = new SymbolStore();
this.collectLabels();
}
this.collectLabels();
options.input = this.getInput();
if (options.input === '') {
return this.result;
}
return this.processOutput(await this.execDemangler(options));
}
}
+1 -2
View File
@@ -30,7 +30,6 @@ export class TiC2000Demangler extends CppDemangler {
}
constructor(demanglerExe, compiler) {
super(demanglerExe, compiler);
this.demanglerArguments = ['-q'];
super(demanglerExe, compiler, ['-q']);
}
}
+5 -3
View File
@@ -45,13 +45,12 @@ export class LlvmIrParser {
private metaNodeOptionsRe: RegExp;
private llvmDebugLine: RegExp;
private llvmDebugAnnotation: RegExp;
private otherMetadataAnnotation: RegExp;
private attributeAnnotation: RegExp;
private attributeDirective: RegExp;
private moduleMetadata: RegExp;
private functionAttrs: RegExp;
// TODO(jeremy-rifkin) can awful state things happen because of soring a demangler? Usually they're constructed
// fresh for each compile.
constructor(compilerProps, private readonly irDemangler: LLVMIRDemangler) {
this.maxIrLines = 5000;
if (compilerProps) {
@@ -66,6 +65,7 @@ export class LlvmIrParser {
this.llvmDebugLine = /^\s*call void @llvm\.dbg\..*$/;
this.llvmDebugAnnotation = /,? !dbg !\d+/;
this.otherMetadataAnnotation = /,? !(?!dbg)[\w.]+ (!\d+)/;
this.attributeAnnotation = /,? #\d+(?= )/;
this.attributeDirective = /^attributes #\d+ = { .+ }$/;
this.functionAttrs = /^; Function Attrs: .+$/;
@@ -150,7 +150,8 @@ export class LlvmIrParser {
const result: IRResultLine[] = [];
const irLines = utils.splitLines(ir);
const debugInfo: Record<string, MetaNode> = {};
let prevLineEmpty = false;
// Set to true initially to prevent any leading newlines as a result of filtering
let prevLineEmpty = true;
const filters: RegExp[] = [];
const lineFilters: RegExp[] = [];
@@ -164,6 +165,7 @@ export class LlvmIrParser {
filters.push(this.metaNodeRe);
filters.push(this.otherMetaDirective);
filters.push(this.namedMetaDirective);
lineFilters.push(this.otherMetadataAnnotation);
}
if (options.filterAttributes) {
filters.push(this.attributeDirective);