Skip to content

Commit 52ec2d3

Browse files
Add RuntimeLibraryInfo to pass pipeline for LLVM >= 22 (#8892)
llvm/llvm-project#168622 adds a new analysis for determining what libcalls are supported by a target. We need to add it to the Halide pass pipeline, otherwise all libcalls are marked unsupported. This results in some memory libcalls being lowered to loops instead, which can increase runtime. This manifested for us as timeouts for the web assembly tests due to the WABT interpreter taking significantly longer to interpret memset loops versus the libcall.
1 parent 23f76e4 commit 52ec2d3

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/LLVM_Headers.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@
9292
#include <llvm/Transforms/Utils/ModuleUtils.h>
9393
#include <llvm/Transforms/Utils/RelLookupTableConverter.h>
9494
#include <llvm/Transforms/Utils/SymbolRewriter.h>
95+
#if LLVM_VERSION >= 220
96+
#include "llvm/Analysis/RuntimeLibcallInfo.h"
97+
#endif
9598

9699
// IWYU pragma: end_exports
97100

src/LLVM_Output.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,14 @@ void emit_file(const llvm::Module &module_in, Internal::LLVMOStream &out,
390390

391391
const auto &triple = llvm::Triple(module->getTargetTriple());
392392
pass_manager.add(new llvm::TargetLibraryInfoWrapperPass(triple));
393+
#if LLVM_VERSION >= 220
394+
pass_manager.add(new llvm::RuntimeLibraryInfoWrapper(
395+
module->getTargetTriple(), target_machine->Options.ExceptionModel,
396+
target_machine->Options.FloatABIType,
397+
target_machine->Options.EABIVersion,
398+
target_machine->Options.MCOptions.ABIName,
399+
target_machine->Options.VecLib));
400+
#endif
393401

394402
// Make sure things marked as always-inline get inlined
395403
pass_manager.add(llvm::createAlwaysInlinerLegacyPass());

0 commit comments

Comments
 (0)