Coder Social home page Coder Social logo

Comments (8)

MaggieYingYi avatar MaggieYingYi commented on August 13, 2024

There are three issues in the test.

  1. The redundant tickets are show in the .repo.tickets metadata.
  2. The function hash calculation is wrong.
  3. The linkage type of global variable .str has been changed from private to external, which is wrong.

from llvm-prepo.

MaggieYingYi avatar MaggieYingYi commented on August 13, 2024

Issue 1: trimming the test, compile the following llvm IR code.

target triple = "x86_64-pc-linux-gnu-repo"

@.str = private unnamed_addr constant [13 x i8] c"Hello World\0A\00", align 1, !repo_ticket !0

define i32 @main() !repo_ticket !1 {
entry:
  %call = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i32 0, i32 0))
  ret i32 0
}

declare i32 @printf(i8*, ...)

!repo.tickets = !{!0, !1}

!0 = !TicketNode(name: ".str", digest: [16 x i8] c"\D9Wq;\E9\B1\8Dh\E7\19\10\EE\A3!\EB\B7", linkage: private)
!1 = !TicketNode(name: "main", digest: [16 x i8] c"Z+i~nP8[\01\EE\BC\03ol\FCB", linkage: external)

using

opt test.ll -S -o test1.ll

The output test1.ll is shown below.

; ModuleID = 'repo_redundant_tickets.ll'
source_filename = "repo_redundant_tickets.ll"
target triple = "x86_64-pc-linux-gnu-repo"

@.str = external unnamed_addr constant [13 x i8], align 1, !repo_ticket !0

declare !repo_ticket !1 i32 @main()

declare i32 @printf(i8*, ...)

!repo.tickets = !{!0, !1, !0, !1}

!0 = !TicketNode(name: ".str", digest: [16 x i8] c"\D9Wq;\E9\B1\8Dh\E7\19\10\EE\A3!\EB\B7", linkage: private)
!1 = !TicketNode(name: "main", digest: [16 x i8] c"Z+i~nP8[\01\EE\BC\03ol\FCB", linkage: external)

The redundant metadata !0 and !1 are in the !repo.tickets metadata.

from llvm-prepo.

MaggieYingYi avatar MaggieYingYi commented on August 13, 2024

Fixed in my local branch.
Branch name: llvm-prepo-13
git commit: cc2ed542.

from llvm-prepo.

MaggieYingYi avatar MaggieYingYi commented on August 13, 2024

The second issue: the 'insertvalue' instruction hash is calculated incorrectly,

Compile the following llvm IR code.

target triple = "x86_64-pc-linux-gnu-repo"

@.str = private unnamed_addr constant [9 x i8] c"test.cpp\00", align 1, !repo_ticket !0

define internal void @__cxx_global_var_init() section ".text.startup" personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) !repo_ticket !1 {
  %exn.slot = alloca i8*
  %ehselector.slot = alloca i32

  %exn = load i8*, i8** %exn.slot, align 8
  %sel = load i32, i32* %ehselector.slot, align 4
  %lpad.val = insertvalue { i8*, i32 } undef, i8* %exn, 0
  %lpad.val1 = insertvalue { i8*, i32 } %lpad.val, i32 %sel, 1
  resume { i8*, i32 } %lpad.val1
}

declare i32 @__gxx_personality_v0(...)

!0 = !TicketNode(name: ".str", digest: [16 x i8] c"8\8A\98\B1^\AA\F0\06\01F\8E\AE\8F\14\BDK", linkage: private)
!1 = !TicketNode(name: "__cxx_global_var_init", digest: [16 x i8] c"\C7\96\DE\14\8C\01\EB \0F<8h\11-\BC7", linkage: internal)

using

opt.exe test.ll -S -o test1.ll

when you run opt.exe command, the hash value of __cxx_global_var_init function is not stable (varies).

from llvm-prepo.

MaggieYingYi avatar MaggieYingYi commented on August 13, 2024

Fixed in my local branch.
Branch name: llvm-prepo-13
git commit: 04c35a7820ad6

from llvm-prepo.

MaggieYingYi avatar MaggieYingYi commented on August 13, 2024

During the repository pruning pass, we can not change the linkage type of global variable .str from private to external. If the linkage type is private, the symbol name will change from .str to .L.str. If we change the linkage type to external, the symbal name will keep the same that is '.str'. It is wrong.

Fixed in my local branch.
Branch name: llvm-prepo-13
git commit: 6d57163d1f87b

from llvm-prepo.

MaggieYingYi avatar MaggieYingYi commented on August 13, 2024

Fixed in git commit: f759454 and 9665035.

from llvm-prepo.

MaggieYingYi avatar MaggieYingYi commented on August 13, 2024

For clang project, the mangling component in the repo datalayout string need to change from '-m:e' to '-m:r'. We will put the clang project in the github.

from llvm-prepo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.