llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: KUSHAL R U (KushalRU11) <details> <summary>Changes</summary> This PR introduces a new Clang-based tool: FunctionScopeIdentifier. The tool identifies C/C++ functions that span specific line ranges in a source file. It extends Clang’s tooling interface by supporting a custom command-line option: -identify-scope-range=<comma-separated line ranges> Example usage: ./bin/FunctionScopeIdentifier -identify-scope-range=5-10,12-15 test.cpp -- -std=c++17 The tool reports all functions that overlap with the specified line ranges, including the function name and its start/end lines. This can assist with code analysis, refactoring, and tooling automation. Key Features Accepts multiple line ranges via -identify-scope-range (e.g. 5-10,12-18) Uses Clang AST matchers to identify function declarations with bodies Outputs function names and their source line spans that intersect the given ranges Supports standard Clang compilation arguments (e.g. -I, -D) Files Added clang/tools/FunctionScopeIdentifier/FunctionScopeIdentifier.cpp clang/tools/FunctionScopeIdentifier/CMakeLists.txt test-files/test.cpp test-files/test1.cpp test-files/test.ll (IR generated for validation) --- Patch is 58.09 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/145074.diff 8 Files Affected: - (modified) clang/CMakeLists.txt (+4) - (modified) clang/tools/CMakeLists.txt (+2) - (added) clang/tools/FunctionScopeIdentifier/CMakeLists.txt (+10) - (added) clang/tools/FunctionScopeIdentifier/FunctionScopeIdentifier.cpp (+117) - (added) test-files/test.cpp (+11) - (added) test-files/test.ll (+1005) - (added) test-files/test1.cpp (+9) - (added) test-files/test1.ll (+54) ``````````diff diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt index ab2ac9bc6b9ad..9471553f02286 100644 --- a/clang/CMakeLists.txt +++ b/clang/CMakeLists.txt @@ -879,6 +879,8 @@ if (LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION) endif() add_subdirectory(utils/hmaptool) + + if(CLANG_BUILT_STANDALONE) llvm_distribution_add_targets() process_llvm_pass_plugins() @@ -889,3 +891,5 @@ set(CLANG_INSTALL_LIBDIR_BASENAME "lib${CLANG_LIBDIR_SUFFIX}") configure_file( ${CLANG_SOURCE_DIR}/include/clang/Config/config.h.cmake ${CLANG_BINARY_DIR}/include/clang/Config/config.h) + + diff --git a/clang/tools/CMakeLists.txt b/clang/tools/CMakeLists.txt index 50e3d694236ac..bed19848c250e 100644 --- a/clang/tools/CMakeLists.txt +++ b/clang/tools/CMakeLists.txt @@ -52,3 +52,5 @@ add_llvm_external_project(clang-tools-extra extra) add_clang_subdirectory(libclang) add_clang_subdirectory(offload-arch) + +add_clang_subdirectory(FunctionScopeIdentifier) diff --git a/clang/tools/FunctionScopeIdentifier/CMakeLists.txt b/clang/tools/FunctionScopeIdentifier/CMakeLists.txt new file mode 100644 index 0000000000000..d8e3ff9967b43 --- /dev/null +++ b/clang/tools/FunctionScopeIdentifier/CMakeLists.txt @@ -0,0 +1,10 @@ +add_clang_executable(FunctionScopeIdentifier + FunctionScopeIdentifier.cpp +) + +target_link_libraries(FunctionScopeIdentifier + PRIVATE + clangTooling + clangBasic + clangASTMatchers +) diff --git a/clang/tools/FunctionScopeIdentifier/FunctionScopeIdentifier.cpp b/clang/tools/FunctionScopeIdentifier/FunctionScopeIdentifier.cpp new file mode 100644 index 0000000000000..56046b4be5ec2 --- /dev/null +++ b/clang/tools/FunctionScopeIdentifier/FunctionScopeIdentifier.cpp @@ -0,0 +1,117 @@ +#include "clang/Tooling/CommonOptionsParser.h" +#include "clang/Tooling/Tooling.h" +#include "clang/Frontend/FrontendActions.h" +#include "clang/Frontend/CompilerInstance.h" +#include "clang/AST/RecursiveASTVisitor.h" +#include "clang/ASTMatchers/ASTMatchers.h" +#include "clang/ASTMatchers/ASTMatchFinder.h" +#include "llvm/Support/CommandLine.h" +#include <map> +#include <set> +#include <sstream> + +using namespace clang; +using namespace clang::tooling; +using namespace llvm; +using namespace clang::ast_matchers; + +// Create an option category for the tool +static cl::OptionCategory MyToolCategory("function-scope-identifier options"); + +// Command-line option for line ranges +static cl::opt<std::string> IdentifyRange( + "identify-scope-range", + cl::desc("Comma-separated list of line ranges (e.g., 5-10,15-20)"), + cl::value_desc("line-ranges"), + cl::Required, + cl::cat(MyToolCategory)); + +// Parse line range string like "5-10,15-20" into vector of pairs +std::vector<std::pair<unsigned, unsigned>> parseRanges(const std::string &rangeStr) { + std::vector<std::pair<unsigned, unsigned>> ranges; + std::stringstream ss(rangeStr); + std::string part; + while (std::getline(ss, part, ',')) { + auto dash = part.find('-'); + if (dash != std::string::npos) { + unsigned start = std::stoi(part.substr(0, dash)); + unsigned end = std::stoi(part.substr(dash + 1)); + ranges.emplace_back(start, end); + } + } + return ranges; +} + +// AST matcher callback +class FunctionVisitor : public MatchFinder::MatchCallback { + SourceManager *SM; + std::vector<std::pair<unsigned, unsigned>> TargetRanges; + +public: + FunctionVisitor(SourceManager *SM, std::vector<std::pair<unsigned, unsigned>> Ranges) + : SM(SM), TargetRanges(Ranges) {} + + void run(const MatchFinder::MatchResult &Result) override { + const FunctionDecl *FD = Result.Nodes.getNodeAs<FunctionDecl>("func"); + if (!FD || !FD->hasBody()) return; + + SourceLocation startLoc = FD->getBeginLoc(); + SourceLocation endLoc = FD->getEndLoc(); + + unsigned startLine = SM->getSpellingLineNumber(startLoc); + unsigned endLine = SM->getSpellingLineNumber(endLoc); + + for (auto &[rangeStart, rangeEnd] : TargetRanges) { + if (rangeEnd < startLine || rangeStart > endLine) continue; + + llvm::outs() << "Range " << rangeStart << "-" << rangeEnd << ":\n"; + llvm::outs() << "Function: " << FD->getNameInfo().getName().getAsString() << "\n"; + llvm::outs() << "Start Line: " << startLine << "\n"; + llvm::outs() << "End Line: " << endLine << "\n\n"; + } + } +}; + +// FrontendAction to wrap matchers +class ScopeFrontendAction : public ASTFrontendAction { +public: + std::vector<std::pair<unsigned, unsigned>> Ranges; + + ScopeFrontendAction(std::vector<std::pair<unsigned, unsigned>> R) : Ranges(R) {} + + std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI, + StringRef InFile) override { + auto *Finder = new MatchFinder(); + auto *Callback = new FunctionVisitor(&CI.getSourceManager(), Ranges); + + Finder->addMatcher(functionDecl(isExpansionInMainFile()).bind("func"), Callback); + return Finder->newASTConsumer(); + } +}; + +// Factory to create ScopeFrontendAction with arguments +class ScopeActionFactory : public FrontendActionFactory { + std::vector<std::pair<unsigned, unsigned>> Ranges; + +public: + ScopeActionFactory(std::vector<std::pair<unsigned, unsigned>> R) : Ranges(R) {} + + std::unique_ptr<FrontendAction> create() override { + return std::make_unique<ScopeFrontendAction>(Ranges); + } +}; + +int main(int argc, const char **argv) { + auto ExpectedParser = CommonOptionsParser::create(argc, argv, MyToolCategory); + if (!ExpectedParser) { + llvm::errs() << ExpectedParser.takeError(); + return 1; + } + + CommonOptionsParser &OptionsParser = ExpectedParser.get(); + ClangTool Tool(OptionsParser.getCompilations(), OptionsParser.getSourcePathList()); + + std::vector<std::pair<unsigned, unsigned>> ranges = parseRanges(IdentifyRange); + return Tool.run(new ScopeActionFactory(ranges)); +} + \ No newline at end of file diff --git a/test-files/test.cpp b/test-files/test.cpp new file mode 100644 index 0000000000000..929f892137e15 --- /dev/null +++ b/test-files/test.cpp @@ -0,0 +1,11 @@ +#include <iostream> + +void foo() { std::cout << "foo\n"; } + +void bar() { std::cout << "bar\n"; } + +int main() { + foo(); + bar(); + return 0; +} diff --git a/test-files/test.ll b/test-files/test.ll new file mode 100644 index 0000000000000..7790025d3049b --- /dev/null +++ b/test-files/test.ll @@ -0,0 +1,1005 @@ +; ModuleID = 'test.cpp' +source_filename = "test.cpp" +target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128-Fn32" +target triple = "arm64-apple-macosx15.0.0" + +%"class.std::__1::basic_ostream" = type { ptr, %"class.std::__1::basic_ios.base" } +%"class.std::__1::basic_ios.base" = type <{ %"class.std::__1::ios_base", ptr, %"struct.std::__1::_SentinelValueFill" }> +%"class.std::__1::ios_base" = type { ptr, i32, i64, i64, i32, i32, ptr, ptr, ptr, ptr, i64, i64, ptr, i64, i64, ptr, i64, i64 } +%"struct.std::__1::_SentinelValueFill" = type { i32 } +%"class.std::__1::locale::id" = type <{ %"struct.std::__1::once_flag", i32, [4 x i8] }> +%"struct.std::__1::once_flag" = type { i64 } +%"class.std::__1::basic_ostream<char>::sentry" = type { i8, ptr } +%"class.std::__1::ostreambuf_iterator" = type { ptr } +%"class.std::__1::basic_string" = type { %"class.std::__1::__compressed_pair" } +%"class.std::__1::__compressed_pair" = type { %"struct.std::__1::__compressed_pair_elem" } +%"struct.std::__1::__compressed_pair_elem" = type { %"union.std::__1::basic_string<char>::__rep" } +%"union.std::__1::basic_string<char>::__rep" = type { %"struct.std::__1::basic_string<char>::__long" } +%"struct.std::__1::basic_string<char>::__long" = type { ptr, i64, i64 } +%"class.std::__1::basic_ios" = type <{ %"class.std::__1::ios_base", ptr, %"struct.std::__1::_SentinelValueFill", [4 x i8] }> +%"struct.std::__1::__default_init_tag" = type { i8 } +%"struct.std::__1::basic_string<char>::__short" = type { [23 x i8], [0 x i8], i8 } +%"class.std::__1::locale" = type { ptr } + +@_ZNSt3__14coutE = external global %"class.std::__1::basic_ostream", align 8 +@.str = private unnamed_addr constant [5 x i8] c"foo\0A\00", align 1 +@.str.1 = private unnamed_addr constant [5 x i8] c"bar\0A\00", align 1 +@_ZNSt3__15ctypeIcE2idE = external global %"class.std::__1::locale::id", align 8 + +; Function Attrs: mustprogress noinline optnone ssp uwtable(sync) +define void @_Z3foov() #0 { + %1 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt3__1lsB8ne190102INS_11char_traitsIcEEEERNS_13basic_ostreamIcT_EES6_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZNSt3__14coutE, ptr noundef @.str) + ret void +} + +; Function Attrs: mustprogress noinline optnone ssp uwtable(sync) +define linkonce_odr hidden noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt3__1lsB8ne190102INS_11char_traitsIcEEEERNS_13basic_ostreamIcT_EES6_PKc(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef %1) #0 { + %3 = alloca ptr, align 8 + %4 = alloca ptr, align 8 + store ptr %0, ptr %3, align 8 + store ptr %1, ptr %4, align 8 + %5 = load ptr, ptr %3, align 8 + %6 = load ptr, ptr %4, align 8 + %7 = load ptr, ptr %4, align 8 + %8 = call i64 @_ZNSt3__111char_traitsIcE6lengthB8ne190102EPKc(ptr noundef %7) #7 + %9 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt3__124__put_character_sequenceB8ne190102IcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m(ptr noundef nonnull align 8 dereferenceable(8) %5, ptr noundef %6, i64 noundef %8) + ret ptr %9 +} + +; Function Attrs: mustprogress noinline optnone ssp uwtable(sync) +define void @_Z3barv() #0 { + %1 = call noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt3__1lsB8ne190102INS_11char_traitsIcEEEERNS_13basic_ostreamIcT_EES6_PKc(ptr noundef nonnull align 8 dereferenceable(8) @_ZNSt3__14coutE, ptr noundef @.str.1) + ret void +} + +; Function Attrs: mustprogress noinline norecurse optnone ssp uwtable(sync) +define i32 @main() #1 { + %1 = alloca i32, align 4 + store i32 0, ptr %1, align 4 + call void @_Z3foov() + call void @_Z3barv() + ret i32 0 +} + +; Function Attrs: mustprogress noinline optnone ssp uwtable(sync) +define linkonce_odr hidden noundef nonnull align 8 dereferenceable(8) ptr @_ZNSt3__124__put_character_sequenceB8ne190102IcNS_11char_traitsIcEEEERNS_13basic_ostreamIT_T0_EES7_PKS4_m(ptr noundef nonnull align 8 dereferenceable(8) %0, ptr noundef %1, i64 noundef %2) #0 personality ptr @__gxx_personality_v0 { + %4 = alloca ptr, align 8 + %5 = alloca ptr, align 8 + %6 = alloca i64, align 8 + %7 = alloca %"class.std::__1::basic_ostream<char>::sentry", align 8 + %8 = alloca ptr, align 8 + %9 = alloca i32, align 4 + %10 = alloca %"class.std::__1::ostreambuf_iterator", align 8 + %11 = alloca %"class.std::__1::ostreambuf_iterator", align 8 + store ptr %0, ptr %4, align 8 + store ptr %1, ptr %5, align 8 + store i64 %2, ptr %6, align 8 + %12 = load ptr, ptr %4, align 8 + %13 = invoke ptr @_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE6sentryC1ERS3_(ptr noundef %7, ptr noundef nonnull align 8 dereferenceable(8) %12) + to label %14 unwind label %68 + +14: ; preds = %3 + %15 = invoke zeroext i1 @_ZNKSt3__113basic_ostreamIcNS_11char_traitsIcEEE6sentrycvbB8ne190102Ev(ptr noundef %7) + to label %16 unwind label %72 + +16: ; preds = %14 + br i1 %15, label %17, label %89 + +17: ; preds = %16 + %18 = load ptr, ptr %4, align 8 + %19 = call ptr @_ZNSt3__119ostreambuf_iteratorIcNS_11char_traitsIcEEEC1B8ne190102ERNS_13basic_ostreamIcS2_EE(ptr noundef %11, ptr noundef nonnull align 8 dereferenceable(8) %18) #7 + %20 = load ptr, ptr %5, align 8 + %21 = load ptr, ptr %4, align 8 + %22 = load ptr, ptr %21, align 8 + %23 = getelementptr i8, ptr %22, i64 -24 + %24 = load i64, ptr %23, align 8 + %25 = getelementptr inbounds i8, ptr %21, i64 %24 + %26 = invoke i32 @_ZNKSt3__18ios_base5flagsB8ne190102Ev(ptr noundef %25) + to label %27 unwind label %72 + +27: ; preds = %17 + %28 = and i32 %26, 176 + %29 = icmp eq i32 %28, 32 + br i1 %29, label %30, label %34 + +30: ; preds = %27 + %31 = load ptr, ptr %5, align 8 + %32 = load i64, ptr %6, align 8 + %33 = getelementptr inbounds i8, ptr %31, i64 %32 + br label %36 + +34: ; preds = %27 + %35 = load ptr, ptr %5, align 8 + br label %36 + +36: ; preds = %34, %30 + %37 = phi ptr [ %33, %30 ], [ %35, %34 ] + %38 = load ptr, ptr %5, align 8 + %39 = load i64, ptr %6, align 8 + %40 = getelementptr inbounds i8, ptr %38, i64 %39 + %41 = load ptr, ptr %4, align 8 + %42 = load ptr, ptr %41, align 8 + %43 = getelementptr i8, ptr %42, i64 -24 + %44 = load i64, ptr %43, align 8 + %45 = getelementptr inbounds i8, ptr %41, i64 %44 + %46 = load ptr, ptr %4, align 8 + %47 = load ptr, ptr %46, align 8 + %48 = getelementptr i8, ptr %47, i64 -24 + %49 = load i64, ptr %48, align 8 + %50 = getelementptr inbounds i8, ptr %46, i64 %49 + %51 = invoke signext i8 @_ZNKSt3__19basic_iosIcNS_11char_traitsIcEEE4fillB8ne190102Ev(ptr noundef %50) + to label %52 unwind label %72 + +52: ; preds = %36 + %53 = getelementptr inbounds %"class.std::__1::ostreambuf_iterator", ptr %11, i32 0, i32 0 + %54 = load ptr, ptr %53, align 8 + %55 = ptrtoint ptr %54 to i64 + %56 = invoke i64 @_ZNSt3__116__pad_and_outputB8ne190102IcNS_11char_traitsIcEEEENS_19ostreambuf_iteratorIT_T0_EES6_PKS4_S8_S8_RNS_8ios_baseES4_(i64 %55, ptr noundef %20, ptr noundef %37, ptr noundef %40, ptr noundef nonnull align 8 dereferenceable(136) %45, i8 noundef signext %51) + to label %57 unwind label %72 + +57: ; preds = %52 + %58 = getelementptr inbounds %"class.std::__1::ostreambuf_iterator", ptr %10, i32 0, i32 0 + %59 = inttoptr i64 %56 to ptr + store ptr %59, ptr %58, align 8 + %60 = call zeroext i1 @_ZNKSt3__119ostreambuf_iteratorIcNS_11char_traitsIcEEE6failedB8ne190102Ev(ptr noundef %10) #7 + br i1 %60, label %61, label %88 + +61: ; preds = %57 + %62 = load ptr, ptr %4, align 8 + %63 = load ptr, ptr %62, align 8 + %64 = getelementptr i8, ptr %63, i64 -24 + %65 = load i64, ptr %64, align 8 + %66 = getelementptr inbounds i8, ptr %62, i64 %65 + invoke void @_ZNSt3__19basic_iosIcNS_11char_traitsIcEEE8setstateB8ne190102Ej(ptr noundef %66, i32 noundef 5) + to label %67 unwind label %72 + +67: ; preds = %61 + br label %88 + +68: ; preds = %3 + %69 = landingpad { ptr, i32 } + catch ptr null + %70 = extractvalue { ptr, i32 } %69, 0 + store ptr %70, ptr %8, align 8 + %71 = extractvalue { ptr, i32 } %69, 1 + store i32 %71, ptr %9, align 4 + br label %77 + +72: ; preds = %61, %52, %36, %17, %14 + %73 = landingpad { ptr, i32 } + catch ptr null + %74 = extractvalue { ptr, i32 } %73, 0 + store ptr %74, ptr %8, align 8 + %75 = extractvalue { ptr, i32 } %73, 1 + store i32 %75, ptr %9, align 4 + %76 = call ptr @_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE6sentryD1Ev(ptr noundef %7) #7 + br label %77 + +77: ; preds = %72, %68 + %78 = load ptr, ptr %8, align 8 + %79 = call ptr @__cxa_begin_catch(ptr %78) #7 + %80 = load ptr, ptr %4, align 8 + %81 = load ptr, ptr %80, align 8 + %82 = getelementptr i8, ptr %81, i64 -24 + %83 = load i64, ptr %82, align 8 + %84 = getelementptr inbounds i8, ptr %80, i64 %83 + invoke void @_ZNSt3__18ios_base33__set_badbit_and_consider_rethrowEv(ptr noundef %84) + to label %85 unwind label %91 + +85: ; preds = %77 + call void @__cxa_end_catch() + br label %86 + +86: ; preds = %85, %89 + %87 = load ptr, ptr %4, align 8 + ret ptr %87 + +88: ; preds = %67, %57 + br label %89 + +89: ; preds = %88, %16 + %90 = call ptr @_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE6sentryD1Ev(ptr noundef %7) #7 + br label %86 + +91: ; preds = %77 + %92 = landingpad { ptr, i32 } + cleanup + %93 = extractvalue { ptr, i32 } %92, 0 + store ptr %93, ptr %8, align 8 + %94 = extractvalue { ptr, i32 } %92, 1 + store i32 %94, ptr %9, align 4 + invoke void @__cxa_end_catch() + to label %95 unwind label %101 + +95: ; preds = %91 + br label %96 + +96: ; preds = %95 + %97 = load ptr, ptr %8, align 8 + %98 = load i32, ptr %9, align 4 + %99 = insertvalue { ptr, i32 } poison, ptr %97, 0 + %100 = insertvalue { ptr, i32 } %99, i32 %98, 1 + resume { ptr, i32 } %100 + +101: ; preds = %91 + %102 = landingpad { ptr, i32 } + catch ptr null + %103 = extractvalue { ptr, i32 } %102, 0 + call void @__clang_call_terminate(ptr %103) #8 + unreachable +} + +; Function Attrs: mustprogress noinline nounwind optnone ssp uwtable(sync) +define linkonce_odr hidden i64 @_ZNSt3__111char_traitsIcE6lengthB8ne190102EPKc(ptr noundef %0) #2 { + %2 = alloca ptr, align 8 + store ptr %0, ptr %2, align 8 + %3 = load ptr, ptr %2, align 8 + %4 = call i64 @_ZNSt3__118__constexpr_strlenB8ne190102IcEEmPKT_(ptr noundef %3) #7 + ret i64 %4 +} + +declare ptr @_ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE6sentryC1ERS3_(ptr noundef returned, ptr noundef nonnull align 8 dereferenceable(8)) unnamed_addr #3 + +declare i32 @__gxx_personality_v0(...) + +; Function Attrs: mustprogress noinline nounwind optnone ssp uwtable(sync) +define linkonce_odr hidden zeroext i1 @_ZNKSt3__113basic_ostreamIcNS_11char_traitsIcEEE6sentrycvbB8ne190102Ev(ptr noundef %0) #2 { + %2 = alloca ptr, align 8 + store ptr %0, ptr %2, align 8 + %3 = load ptr, ptr %2, align 8 + %4 = getelementptr inbounds %"class.std::__1::basic_ostream<char>::sentry", ptr %3, i32 0, i32 0 + %5 = load i8, ptr %4, align 8 + %6 = trunc i8 %5 to i1 + ret i1 %6 +} + +; Function Attrs: mustprogress noinline optnone ssp uwtable(sync) +define linkonce_odr hidden i64 @_ZNSt3__116__pad_and_outputB8ne190102IcNS_11char_traitsIcEEEENS_19ostreambuf_iteratorIT_T0_EES6_PKS4_S8_S8_RNS_8ios_baseES4_(i64 %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef nonnull align 8 dereferenceable(136) %4, i8 noundef signext %5) #0 personality ptr @__gxx_personality_v0 { + %7 = alloca %"class.std::__1::ostreambuf_iterator", align 8 + %8 = alloca %"class.std::__1::ostreambuf_iterator", align 8 + %9 = alloca ptr, align 8 + %10 = alloca ptr, align 8 + %11 = alloca ptr, align 8 + %12 = alloca ptr, align 8 + %13 = alloca i8, align 1 + %14 = alloca i64, align 8 + %15 = alloca i64, align 8 + %16 = alloca i64, align 8 + %17 = alloca %"class.std::__1::basic_string", align 8 + %18 = alloca ptr, align 8 + %19 = alloca i32, align 4 + %20 = alloca i32, align 4 + %21 = getelementptr inbounds %"class.std::__1::ostreambuf_iterator", ptr %8, i32 0, i32 0 + %22 = inttoptr i64 %0 to ptr + store ptr %22, ptr %21, align 8 + store ptr %1, ptr %9, align 8 + store ptr %2, ptr %10, align 8 + store ptr %3, ptr %11, align 8 + store ptr %4, ptr %12, align 8 + store i8 %5, ptr %13, align 1 + %23 = getelementptr inbounds %"class.std::__1::ostreambuf_iterator", ptr %8, i32 0, i32 0 + %24 = load ptr, ptr %23, align 8 + %25 = icmp eq ptr %24, null + br i1 %25, label %26, label %27 + +26: ; preds = %6 + call void @llvm.memcpy.p0.p0.i64(ptr align 8 %7, ptr align 8 %8, i64 8, i1 false) + br label %111 + +27: ; preds = %6 + %28 = load ptr, ptr %11, align 8 + %29 = load ptr, ptr %9, align 8 + %30 = ptrtoint ptr %28 to i64 + %31 = ptrtoint ptr %29 to i64 + %32 = sub i64 %30, %31 + store i64 %32... [truncated] `````````` </details> https://github.com/llvm/llvm-project/pull/145074 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits