# Map LLVM Values to corresponding source level expression, GSoC'23 Project

DevFeed: [Map LLVM Values to corresponding source level expression, GSoC'23 Project](<https://devfeed.tech/articles/map-llvm-values-to-corresponding-source-level-expression-gsoc-23-project-43096.md>)

Original publisher: [Read original article](<https://blog.llvm.org/posts/2023-09-19-gsoc-2023-blog-post/>)

Author: Shivam Kunwar

Published: 2023-09-19T00:00:00Z

Content type: article

Language: en

Sources: [LLVM Project](<https://devfeed.tech/sources/the-llvm-project-blog.md>)

Topics: [LLVM](<https://devfeed.tech/topics/llvm.md>), [Compiler](<https://devfeed.tech/topics/compiler.md>), [Optimization](<https://devfeed.tech/topics/optimization.md>), [software-development](<https://devfeed.tech/topics/software-development.md>), [interface](<https://devfeed.tech/topics/interface.md>), [implementation](<https://devfeed.tech/topics/implementation.md>)

Tags: [analysis](<https://devfeed.tech/tags/analysis.md>), [code](<https://devfeed.tech/tags/code.md>), [compiler](<https://devfeed.tech/tags/compiler.md>), [debug](<https://devfeed.tech/tags/debug.md>), [gsoc](<https://devfeed.tech/tags/gsoc.md>), [llvm](<https://devfeed.tech/tags/llvm.md>), [llvm-ir](<https://devfeed.tech/tags/llvm-ir.md>), [loop-vectorizer](<https://devfeed.tech/tags/loop-vectorizer.md>), [optimization](<https://devfeed.tech/tags/optimization.md>), [remarks](<https://devfeed.tech/tags/remarks.md>), [tests](<https://devfeed.tech/tags/tests.md>), [vectorization](<https://devfeed.tech/tags/vectorization.md>)

## AI overview

A 2023 Google Summer of Code project with the LLVM Foundation developed an LLVM IR analysis pass that maps LLVM values, especially load and store addresses, to equivalent source-level expressions. The work uses debug metadata and intrinsics, integrates with the loop vectorizer, and includes tests.

## Source excerpt

Hi, My name is Shivam, I involved with the LLVM Foundation in 2023 GSoC edition and worked on an interesting project Map LLVM Values to corresponding source level expression. Project Scope Programmers frequently rely on compiler-generated remarks and analysis reports to enhance the efficiency of their code. While compilers excel at including source code positions (such as line and column numbers) in these generated messages, it would be advantageous if these reports also contained the corresponding source-level expressions. The LLVM implementation presently employs a limited set of intrinsic functions to establish a connection between LLVM program elements and source-level expressions. This project's objective is to leverage the data embedded in these intrinsic functions to either generate source expressions that correspond to LLVM values. The optimization of memory accesses within a program is crucial for achieving optimal application performance. Specifically, our goal is to utilize compiler analysis messages that detail source-level memory accesses associated with LLVM load/store pointer values, which can impede compiler optimizations. As an illustration, this information can be used to identify memory access dependencies that hinder vectorization. Expected result was to provide an interface which takes an LLVM value at any point in the LLVM transformations pipeline and returns a string corresponding to the equivalent source-level expression. We are especially interested in using this interface to map addresses used in load/store instructions to equivalent source-level memory references. What we did The core achievement of the project is the development of an analysis pass that operates on LLVM intermediate representation (IR). This analysis pass identifies load and store instructions, and then conducts a recursive traversal to construct source expressions that represent equivalent source-level memory references. This is achieved by utilizing the metadata and deb