[llvm-dev] How do set 'nest' addribute in an indirect call? (original) (raw)

Rodney M. Bates via llvm-dev llvm-dev at lists.llvm.org
Thu Aug 24 07:32:19 PDT 2017


Ping.

On 08/17/2017 05:15 PM, Rodney M. Bates via llvm-dev wrote: > I need to set the 'next' attribute on a parameter. If the function is to be > directly called, i.e., a function constant, I am getting what I want as follows > (using the C 'Core.h' binding) >> 1) Build a function type, using LLVMFunctionType. > 2) Build a function value, passing the result of 1) to LLVMAddFunction > 3) Go through the formal parameters of 2), using LLVMGet[First|Next]Param, > which give me a value for each formal > 4) For the desired formal, pass it to LLVMAddAttribute. >> This results in compiled code that passes my parameter in the same way as gcc, > giving the interoperability I need. >> For an indirect call, i.e., on a function whose address is runtime variable, > I can't find any place/way to attach this attribute. LLVMAddAttribute > won't take a type. >> I don't see a way to construct a function value with a runtime variable > address, that I could do 3) & 4) on. (I already have an i8* pointer to > the function code.) >> The comment on LLVMAddAttribute says " Add an attribute to a function argument", > which, to me, "argument" means an actual parameter. But When I try that, I get > an assertion failure, which I am having trouble interpreting: >> m3llvm: /home/rodney/proj/llvm/llvm-3.6.1/llvm-3.6.1.src/include/llvm/Support/Casting.h:237: typename castretty<X, Y *>::rettype llvm::cast(Y *) [X = llvm::Argument, Y = llvm::Value]: Assertion `isa(Val) && "cast() argument of incompatible type!"' failed. >> My actual parameter is a load instruction, which I would expect to be a value. > Its llvm type is i8*, but I don't think that is relevant. >> Here are some relevant debugger lines: >> (m3gdb) frame 7 > #7 0x00000000004264fd in M3CGLLVM_InnerCallIndirect (self=160000000001b30830, proc=160000000001a7e388, t=Void, > cc=160000000001b07928, Nested=TRUE) at ../src/M3CGLLVM.m3:4750 > 4750 LLVM.LLVMAddAttribute(actual.lVal, LLVM.NestAttribute); > Current language: auto; currently Modula-3 > (m3gdb) p M3CGLLVM_DumpLvVal(actual.lVal) > %loadind13 = load i8** %loadindtoptr12 > $1 = > (m3gdb) p M3CGLLVM_LvType(actual.lVal) > $2 = 160000000001a78620 > (m3gdb) p M3CGLLVM_DumpLvType($2) > i8* > $3 = > (m3gdb) >>

Rodney Bates rodney.m.bates at acm.org



More information about the llvm-dev mailing list