aboutsummaryrefslogtreecommitdiff
path: root/llvm/utils
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/utils')
-rw-r--r--llvm/utils/gn/secondary/libcxx/include/BUILD.gn11
-rw-r--r--llvm/utils/gn/secondary/llvm/lib/CodeGen/BUILD.gn1
-rw-r--r--llvm/utils/gn/secondary/llvm/lib/ExecutionEngine/Orc/TargetProcess/BUILD.gn2
-rw-r--r--llvm/utils/gn/secondary/llvm/unittests/ExecutionEngine/Orc/BUILD.gn1
-rw-r--r--llvm/utils/lldbDataFormatters.py5
-rw-r--r--llvm/utils/mlgo-utils/IR2Vec/generateTriplets.py165
-rw-r--r--llvm/utils/profcheck-xfail.txt5
7 files changed, 145 insertions, 45 deletions
diff --git a/llvm/utils/gn/secondary/libcxx/include/BUILD.gn b/llvm/utils/gn/secondary/libcxx/include/BUILD.gn
index e747006..278c29c 100644
--- a/llvm/utils/gn/secondary/libcxx/include/BUILD.gn
+++ b/llvm/utils/gn/secondary/libcxx/include/BUILD.gn
@@ -911,7 +911,6 @@ if (current_toolchain == default_toolchain) {
"__cxx03/cmath",
"__cxx03/codecvt",
"__cxx03/complex",
- "__cxx03/complex.h",
"__cxx03/condition_variable",
"__cxx03/csetjmp",
"__cxx03/csignal",
@@ -924,25 +923,20 @@ if (current_toolchain == default_toolchain) {
"__cxx03/cstring",
"__cxx03/ctgmath",
"__cxx03/ctime",
- "__cxx03/ctype.h",
"__cxx03/cuchar",
"__cxx03/cwchar",
"__cxx03/cwctype",
"__cxx03/deque",
- "__cxx03/errno.h",
"__cxx03/exception",
"__cxx03/experimental/__config",
"__cxx03/experimental/utility",
"__cxx03/ext/__hash",
"__cxx03/ext/hash_map",
"__cxx03/ext/hash_set",
- "__cxx03/fenv.h",
- "__cxx03/float.h",
"__cxx03/forward_list",
"__cxx03/fstream",
"__cxx03/functional",
"__cxx03/future",
- "__cxx03/inttypes.h",
"__cxx03/iomanip",
"__cxx03/ios",
"__cxx03/iosfwd",
@@ -969,11 +963,8 @@ if (current_toolchain == default_toolchain) {
"__cxx03/sstream",
"__cxx03/stack",
"__cxx03/stdatomic.h",
- "__cxx03/stdbool.h",
- "__cxx03/stddef.h",
"__cxx03/stdexcept",
"__cxx03/stdint.h",
- "__cxx03/stdio.h",
"__cxx03/stdlib.h",
"__cxx03/streambuf",
"__cxx03/string",
@@ -981,7 +972,6 @@ if (current_toolchain == default_toolchain) {
"__cxx03/string_view",
"__cxx03/strstream",
"__cxx03/system_error",
- "__cxx03/tgmath.h",
"__cxx03/thread",
"__cxx03/type_traits",
"__cxx03/typeindex",
@@ -994,7 +984,6 @@ if (current_toolchain == default_toolchain) {
"__cxx03/vector",
"__cxx03/version",
"__cxx03/wchar.h",
- "__cxx03/wctype.h",
"__debug_utils/randomize_range.h",
"__debug_utils/sanitizers.h",
"__debug_utils/strict_weak_ordering_check.h",
diff --git a/llvm/utils/gn/secondary/llvm/lib/CodeGen/BUILD.gn b/llvm/utils/gn/secondary/llvm/lib/CodeGen/BUILD.gn
index 39dacf7..4446702 100644
--- a/llvm/utils/gn/secondary/llvm/lib/CodeGen/BUILD.gn
+++ b/llvm/utils/gn/secondary/llvm/lib/CodeGen/BUILD.gn
@@ -122,6 +122,7 @@ static_library("CodeGen") {
"MLRegAllocPriorityAdvisor.cpp",
"MachineBasicBlock.cpp",
"MachineBlockFrequencyInfo.cpp",
+ "MachineBlockHashInfo.cpp",
"MachineBlockPlacement.cpp",
"MachineBranchProbabilityInfo.cpp",
"MachineCFGPrinter.cpp",
diff --git a/llvm/utils/gn/secondary/llvm/lib/ExecutionEngine/Orc/TargetProcess/BUILD.gn b/llvm/utils/gn/secondary/llvm/lib/ExecutionEngine/Orc/TargetProcess/BUILD.gn
index c4ce990..937e81b 100644
--- a/llvm/utils/gn/secondary/llvm/lib/ExecutionEngine/Orc/TargetProcess/BUILD.gn
+++ b/llvm/utils/gn/secondary/llvm/lib/ExecutionEngine/Orc/TargetProcess/BUILD.gn
@@ -12,6 +12,8 @@ static_library("TargetProcess") {
"JITLoaderGDB.cpp",
"JITLoaderPerf.cpp",
"JITLoaderVTune.cpp",
+ "LibraryResolver.cpp",
+ "LibraryScanner.cpp",
"OrcRTBootstrap.cpp",
"RegisterEHFrames.cpp",
"SimpleExecutorDylibManager.cpp",
diff --git a/llvm/utils/gn/secondary/llvm/unittests/ExecutionEngine/Orc/BUILD.gn b/llvm/utils/gn/secondary/llvm/unittests/ExecutionEngine/Orc/BUILD.gn
index dfe6d6d..111e4c9 100644
--- a/llvm/utils/gn/secondary/llvm/unittests/ExecutionEngine/Orc/BUILD.gn
+++ b/llvm/utils/gn/secondary/llvm/unittests/ExecutionEngine/Orc/BUILD.gn
@@ -24,6 +24,7 @@ unittest("OrcJITTests") {
"JITLinkRedirectionManagerTest.cpp",
"JITTargetMachineBuilderTest.cpp",
"LazyCallThroughAndReexportsTest.cpp",
+ "LibraryResolverTest.cpp",
"LookupAndRecordAddrsTest.cpp",
"MachOPlatformTest.cpp",
"MapperJITLinkMemoryManagerTest.cpp",
diff --git a/llvm/utils/lldbDataFormatters.py b/llvm/utils/lldbDataFormatters.py
index 5e553ca..a3e4ae1 100644
--- a/llvm/utils/lldbDataFormatters.py
+++ b/llvm/utils/lldbDataFormatters.py
@@ -197,6 +197,11 @@ def StringRefSummaryProvider(valobj, internal_dict):
return '""'
data = data_pointer.deref
+ # StringRef may be uninitialized with length exceeding available memory,
+ # potentially causing bad_alloc exceptions. Limit the length to max string summary setting.
+ limit_obj = valobj.target.debugger.GetSetting("target.max-string-summary-length")
+ if limit_obj:
+ length = min(length, limit_obj.GetUnsignedIntegerValue())
# Get a char[N] type, from the underlying char type.
array_type = data.type.GetArrayType(length)
# Cast the char* string data to a char[N] array.
diff --git a/llvm/utils/mlgo-utils/IR2Vec/generateTriplets.py b/llvm/utils/mlgo-utils/IR2Vec/generateTriplets.py
index 80ac4c6..dba9e2c 100644
--- a/llvm/utils/mlgo-utils/IR2Vec/generateTriplets.py
+++ b/llvm/utils/mlgo-utils/IR2Vec/generateTriplets.py
@@ -1,14 +1,19 @@
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-"""IR2Vec Triplet Generator
+"""IR2Vec/MIR2Vec Triplet Generator
-Generates IR2Vec triplets by applying random optimization levels to LLVM IR files
-and extracting triplets using llvm-ir2vec. Automatically generates preprocessed
-files: entity2id.txt, relation2id.txt, and train2id.txt.
+Generates IR2Vec or MIR2Vec triplets by applying random optimization levels to
+LLVM IR files (or processing MIR files) and extracting triplets using llvm-ir2vec.
+Automatically generates preprocessed files (entity2id.txt, relation2id.txt, and
+train2id.txt) necessary for training IR2Vec or MIR2Vec vocabularies.
Usage:
- python generateTriplets.py <llvm_build_dir> <num_optimizations> <ll_file_list> <output_dir>
+ For LLVM IR:
+ python generateTriplets.py <llvm_build_dir> <num_optimizations> <ll_file_list> <output_dir>
+
+ For Machine IR:
+ python generateTriplets.py --mode=mir <llvm_build_dir> <mir_file_list> <output_dir>
"""
import argparse
@@ -41,7 +46,7 @@ class TripletResult:
class IR2VecTripletGenerator:
- """Main class for generating IR2Vec triplets"""
+ """Main class for generating IR2Vec or MIR2Vec triplets"""
def __init__(
self,
@@ -49,11 +54,13 @@ class IR2VecTripletGenerator:
num_optimizations: int,
output_dir: Path,
max_workers: int = DEFAULT_MAX_WORKERS,
+ mode: str = "llvm",
):
self.llvm_build_dir = llvm_build_dir
self.num_optimizations = num_optimizations
self.output_dir = output_dir
self.max_workers = max_workers
+ self.mode = mode # "llvm" or "mir"
# Tool paths
self.opt_binary = os.path.join(llvm_build_dir, "bin", "opt")
@@ -85,7 +92,11 @@ class IR2VecTripletGenerator:
f"llvm-ir2vec binary not found or not executable: {self.ir2vec_binary}"
)
- if not (1 <= self.num_optimizations <= len(OPT_LEVELS)):
+ if self.mode not in ["llvm", "mir"]:
+ raise ValueError(f"Mode must be 'llvm' or 'mir', got: {self.mode}")
+
+ # For LLVM IR mode, validate optimization count
+ if self.mode == "llvm" and not (1 <= self.num_optimizations <= len(OPT_LEVELS)):
raise ValueError(
f"Number of optimizations must be between 1-{len(OPT_LEVELS)}"
)
@@ -95,19 +106,28 @@ class IR2VecTripletGenerator:
return random.sample(OPT_LEVELS, self.num_optimizations)
def _process_single_file(self, input_file: Path) -> TripletResult:
- """Process a single LLVM IR file with multiple optimization levels"""
+ """Process a single LLVM IR or MIR file"""
all_triplets = set()
max_relation = 1
- opt_levels = self._select_optimization_levels()
- for opt_level in opt_levels:
- triplets, file_max_relation = self._run_pipeline(input_file, opt_level)
+ if self.mode == "mir":
+ # For MIR files, process directly without optimization
+ triplets, file_max_relation = self._run_mir_pipeline(input_file)
if triplets:
all_triplets.update(triplets)
max_relation = max(max_relation, file_max_relation)
- logger.debug(
- f"Generated {len(triplets)} triplets for {input_file} with {opt_level}"
- )
+ logger.debug(f"Generated {len(triplets)} triplets for {input_file}")
+ else:
+ # For LLVM IR files, apply multiple optimization levels
+ opt_levels = self._select_optimization_levels()
+ for opt_level in opt_levels:
+ triplets, file_max_relation = self._run_pipeline(input_file, opt_level)
+ if triplets:
+ all_triplets.update(triplets)
+ max_relation = max(max_relation, file_max_relation)
+ logger.debug(
+ f"Generated {len(triplets)} triplets for {input_file} with {opt_level}"
+ )
return TripletResult(all_triplets, max_relation)
@@ -124,7 +144,7 @@ class IR2VecTripletGenerator:
# Run llvm-ir2vec with opt's output as input
ir2vec_proc = subprocess.Popen(
- [self.ir2vec_binary, "triplets", "-", "-o", "-"],
+ [self.ir2vec_binary, "triplets", "--mode=llvm", "-", "-o", "-"],
stdin=opt_proc.stdout,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
@@ -143,6 +163,32 @@ class IR2VecTripletGenerator:
except (subprocess.SubprocessError, OSError):
return set(), 1
+ def _run_mir_pipeline(self, input_file: Path) -> Tuple[Set[str], int]:
+ """Run llvm-ir2vec pipeline for MIR files."""
+ try:
+ # Run llvm-ir2vec directly on MIR file
+ result = subprocess.run(
+ [
+ self.ir2vec_binary,
+ "triplets",
+ "--mode=mir",
+ str(input_file),
+ "-o",
+ "-",
+ ],
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ text=True,
+ check=False,
+ )
+
+ if result.returncode != 0:
+ return set(), 1
+
+ return self._parse_triplet_output(result.stdout)
+ except (subprocess.SubprocessError, OSError):
+ return set(), 1
+
def _parse_triplet_output(self, output: str) -> Tuple[Set[str], int]:
"""Parse triplet output and extract max relation"""
if not output.strip():
@@ -160,12 +206,21 @@ class IR2VecTripletGenerator:
return set(lines), max_relation
def generate_triplets(self, file_list: Path) -> None:
- """Main method to generate triplets from a list of LLVM IR files"""
+ """Main method to generate triplets from a list of LLVM IR or MIR files"""
+ # Store file_list_path for later use in entity generation
+ self.file_list_path = file_list
+
input_files = self._read_file_list(file_list)
- logger.info(
- f"Processing {len(input_files)} files with {self.num_optimizations} "
- f"optimization levels using {self.max_workers} workers"
- )
+
+ if self.mode == "mir":
+ logger.info(
+ f"Processing {len(input_files)} MIR files using {self.max_workers} workers"
+ )
+ else:
+ logger.info(
+ f"Processing {len(input_files)} files with {self.num_optimizations} "
+ f"optimization levels using {self.max_workers} workers"
+ )
all_triplets = set()
global_max_relation = 1
@@ -222,28 +277,60 @@ class IR2VecTripletGenerator:
def _generate_entity2id(self, output_file: Path) -> None:
"""Generate entity2id.txt using llvm-ir2vec"""
- subprocess.run(
- [str(self.ir2vec_binary), "entities", "-o", str(output_file)],
- check=True,
- capture_output=True,
- )
+ if self.mode == "mir":
+ # For MIR mode, we need to provide a sample MIR file to determine target
+ # Use the first file from the processed list
+ input_files = self._read_file_list(self.file_list_path)
+ if not input_files:
+ raise ValueError("No input files available for entity generation")
+
+ subprocess.run(
+ [
+ str(self.ir2vec_binary),
+ "entities",
+ "--mode=mir",
+ str(input_files[0]),
+ "-o",
+ str(output_file),
+ ],
+ check=True,
+ capture_output=True,
+ )
+ else:
+ subprocess.run(
+ [
+ str(self.ir2vec_binary),
+ "entities",
+ "--mode=llvm",
+ "-o",
+ str(output_file),
+ ],
+ check=True,
+ capture_output=True,
+ )
def _generate_relation2id(self, output_file: Path, max_relation: int) -> None:
"""Generate relation2id.txt from max relation"""
- max_relation = max(max_relation, 1) # At least Type and Next relations
+ max_relation = max(max_relation, 1) # At least Next relation
num_relations = max_relation + 1
with open(output_file, "w") as f:
f.write(f"{num_relations}\n")
- f.write("Type\t0\n")
- f.write("Next\t1\n")
- f.writelines(f"Arg{i-2}\t{i}\n" for i in range(2, num_relations))
+ if self.mode == "llvm":
+ # LLVM IR has Type relation at 0
+ f.write("Type\t0\n")
+ f.write("Next\t1\n")
+ f.writelines(f"Arg{i-2}\t{i}\n" for i in range(2, num_relations))
+ else:
+ # MIR doesn't have Type relation, starts with Next at 0
+ f.write("Next\t0\n")
+ f.writelines(f"Arg{i-1}\t{i}\n" for i in range(1, num_relations))
def main():
"""Main entry point"""
parser = argparse.ArgumentParser(
- description="Generate IR2Vec triplets from LLVM IR files",
+ description="Generate IR2Vec or MIR2Vec triplets from LLVM IR or Machine IR files",
formatter_class=argparse.RawDescriptionHelpFormatter,
)
@@ -253,17 +340,26 @@ def main():
parser.add_argument(
"num_optimizations",
type=int,
- help="Number of optimization levels to apply (1-6)",
+ nargs="?",
+ default=1,
+ help="Number of optimization levels to apply (1-6) for LLVM IR mode",
)
parser.add_argument(
- "ll_file_list",
+ "input_file_list",
type=Path,
- help="File containing list of LLVM IR files to process",
+ help="File containing list of LLVM IR or MIR files to process",
)
parser.add_argument(
"output_dir", type=Path, help="Output directory for generated files"
)
parser.add_argument(
+ "--mode",
+ type=str,
+ choices=["llvm", "mir"],
+ default="llvm",
+ help="Operation mode: 'llvm' for LLVM IR (default) or 'mir' for Machine IR",
+ )
+ parser.add_argument(
"-j",
"--max-workers",
type=int,
@@ -296,8 +392,9 @@ def main():
args.num_optimizations,
args.output_dir,
args.max_workers,
+ args.mode,
)
- generator.generate_triplets(args.ll_file_list)
+ generator.generate_triplets(args.input_file_list)
if __name__ == "__main__":
diff --git a/llvm/utils/profcheck-xfail.txt b/llvm/utils/profcheck-xfail.txt
index b570f8d..151b065 100644
--- a/llvm/utils/profcheck-xfail.txt
+++ b/llvm/utils/profcheck-xfail.txt
@@ -71,6 +71,7 @@ CodeGen/Hexagon/autohvx/interleave.ll
CodeGen/Hexagon/loop-idiom/hexagon-memmove1.ll
CodeGen/Hexagon/loop-idiom/hexagon-memmove2.ll
CodeGen/Hexagon/loop-idiom/memmove-rt-check.ll
+CodeGen/Hexagon/masked_gather.ll
CodeGen/NVPTX/lower-ctor-dtor.ll
CodeGen/RISCV/zmmul.ll
CodeGen/WebAssembly/memory-interleave.ll
@@ -331,6 +332,10 @@ Instrumentation/MemorySanitizer/AArch64/arm64-vshift.ll
Instrumentation/MemorySanitizer/AArch64/module-flags-aarch64.ll
Instrumentation/MemorySanitizer/AArch64/neon_vst_float.ll
Instrumentation/MemorySanitizer/AArch64/qshrn.ll
+Instrumentation/MemorySanitizer/AArch64/sme-aarch64-svcount-mini.ll
+Instrumentation/MemorySanitizer/AArch64/sme-aarch64-svcount.ll
+Instrumentation/MemorySanitizer/AArch64/sme2-intrinsics-add-mini.ll
+Instrumentation/MemorySanitizer/AArch64/sme2-intrinsics-add.ll
Instrumentation/MemorySanitizer/AArch64/vararg.ll
Instrumentation/MemorySanitizer/AArch64/vararg_shadow.ll
Instrumentation/MemorySanitizer/abs-vector.ll