Hi Bill, Bill Wendling wrote:> > This might help. See how "stack protectors" is implemented here: > > lib/CodeGen/StackProtector.cpp > > It places a special value at a specific place on the stack. You can > use the same trick to put your own information on a set stack > position. There's more to the code than just that .cpp file. It's done > with intrinsics. You'll also need to check out the > PrologEpilogInserter.cpp code. > >Thanks. I've already looked at what stack protector does, and indeed the need is similar. However, I'd like to add the functionality as a new machine pass, so that I don't need to add new intrinsics and modify the llvm code base. Do you think that's possible? Nicolas> -bw > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >
Hi Nicolas,>> This might help. See how "stack protectors" is implemented here: >> >> lib/CodeGen/StackProtector.cpp >> >> It places a special value at a specific place on the stack. You can >> use the same trick to put your own information on a set stack >> position. There's more to the code than just that .cpp file. It's >> done >> with intrinsics. You'll also need to check out the >> PrologEpilogInserter.cpp code. >> >> > Thanks. I've already looked at what stack protector does, and indeed > the > need is similar. However, I'd like to add the functionality as a new > machine pass, so that I don't need to add new intrinsics and modify > the > llvm code base. Do you think that's possible? >I suppose that it's possible, though not as elegant. :-) What type of information are you storing? Is it stuff that is known before we convert the LLVM IR into its DAG format for the back-end? If so, then it's probably cleaner to go the way of the stack protector. It's easier to send this information to the back-end so that it knows how to set up the prologue and epilogue. I'm not too familiar with the JIT, so I don't know if making this a machine function pass will work. In all, modifying LLVM to create a new intrinsic (a la stack protectors) isn't all that much work. ;-) And modifying LLVM IR is *much* easier than modifying its DAG format. -bw
Hi Bill, Bill Wendling wrote:> > I suppose that it's possible, though not as elegant. :-) What type of > information are you storing?I want to store a methodID, so that when walking the stack I know which function the frame belongs to.> Is it stuff that is known before we > convert the LLVM IR into its DAG format for the back-end?Yes. If I didn't need a fixed offset, I'd do: ptr = alloca(MethodType) store MethodId, ptr> If so, then > it's probably cleaner to go the way of the stack protector. It's > easier to send this information to the back-end so that it knows how > to set up the prologue and epilogue. I'm not too familiar with the > JIT, so I don't know if making this a machine function pass will work. > > In all, modifying LLVM to create a new intrinsic (a la stack > protectors) isn't all that much work. ;-) And modifying LLVM IR is > *much* easier than modifying its DAG format. >Yeah, the intrinsic way is the easiest. It just looked nice to write that as a new pass and not modify the LLVM codebase. Nicolas> -bw > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >