[llvm-dev] LLVM Builder

James Courtier-Dutton via llvm-dev llvm-dev at lists.llvm.org
Mon Mar 20 15:21:15 PDT 2017


Hi,

I was wondering if someone could help me with how to use the llvm
builder for a particular task.
I have some LLVM IR with a function, instruction block, and ret
instruction at the end.

E.g.
----STARTS----
; ModuleID = 'test0.bc'
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"

; Function Attrs: norecurse nounwind readnone
define i32 @test0(i8* nocapture readnone %param1, i8* nocapture
readnone %param2, i64* nocapture readnone %param3) #0 {
Node_0x1:
  ret i32 291
}

attributes #0 = { norecurse nounwind readnone }
----ENDS-----

As you can see, none of the parameters are needed because they are not used.
How do I use the llvm builder to edit the parameter list to, say,
remove two of the parameters?
E.g. To convert it into this:
----STARTS----
; ModuleID = 'test0.bc'
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"

; Function Attrs: norecurse nounwind readnone
define i32 @test0(i8* nocapture readnone %param1) #0 {
Node_0x1:
  ret i32 291
}

attributes #0 = { norecurse nounwind readnone }
----ENDS-----


More information about the llvm-dev mailing list