search for: blockaddress

Displaying 20 results from an estimated 118 matches for "blockaddress".

2019 Jan 29
2
[cfe-dev] Create a BlockAddress array from LLVM Pass
Sorry for emailing both group. As I will have a constant array of BlockAddress, what type I should use in Constant Array for its ArrayType declaration? I am creating the list in following way: unsigned int nBr = fit->second.size(); llvm::Constant *listBA[nBr]; unsigned int Idx = 0; for (std::set<llvm::BasicBlock *>::iterator it = fit->second.begin(); it != fit-&g...
2019 Jan 28
2
Create a BlockAddress array from LLVM Pass
...array: static const __attribute__((used)) __attribute__((section("data"))) void *codetable[] = { &&RETURN, &&INCREMENT, &&DECREMENT, &&DOUBLE, &&SWAPWORD}; I have the following in the LLVM IR. @sampleCode.codetable = internal global [5 x i8*] [i8* blockaddress(@sampleCode, %19), i8* blockaddress(@sampleCode, %22), i8* blockaddress(@sampleCode, %25), i8* blockaddress(@sampleCode, %28), i8* blockaddress(@sampleCode, %31)], section "data", align 16 Here the array elements are labels in c code. I have done following to create the same array from LL...
2018 Apr 16
2
Question concerning llvm::BlockAddress class
Hi all, I have a question concerning block address class in LLVM. I am currently working on a project where I need to obtain and manipulate basic block virtual addresses. I was searching the web and found the llvm::BlockAddress class (http://llvm.org/doxygen/classllvm_1_1BlockAddress.html). With this class I was able to obtain a printout like this: i8* blockaddress(@func_name, %bb_label) How do I obtain the virtual memory address from the Block address class? Can I even do so? Moreover, I thought that o...
2011 Jul 31
3
[LLVMdev] SwitchInst::addCase with BlockAddress
I'm trying to figure out how to feed a blockaddress to a switch condition AND destination (basically emulating an indirectbr via a switch; I know it's not a good approach, I'm just experimenting). Suppose I have the following: SwitchInst *s = SwitchInst::Create(...); BasicBlock *bb = ...; PtrToIntInst k = new PtrToIntInst(BlockAddress::ge...
2018 Apr 16
0
Question concerning llvm::BlockAddress class
...6, 2018 at 04:14:03PM -0400, Brenda So via llvm-dev wrote: > Hi all, > > I have a question concerning block address class in LLVM. I am currently > working on a project where I need to obtain and manipulate basic block virtual > addresses. I was searching the web and found the llvm::BlockAddress class ( > http://llvm.org/doxygen/classllvm_1_1BlockAddress.html). With this class I was > able to obtain a printout like this: > > i8* blockaddress(@func_name, %bb_label) > > How do I obtain the virtual memory address from the Block address class? Can I > eve...
2010 Mar 15
2
[LLVMdev] LLVM tries to remove labels used in blockaddress()
On Mar 15, 2010, at 9:41 AM, Chris Lattner wrote: > > On Mar 15, 2010, at 7:11 AM, Sebastian Schlunke wrote: > >> Hi, >> >> i ran into a problem when using blockaddress() with a label in another function. It seems to me that LLVM tries to remove the label used in blockaddress because it seems like it is not used, but in fact it may be used somewhere with a indirectbr. >> >> I attached a small test-case that produces this error. (The original problem i...
2010 Mar 15
0
[LLVMdev] LLVM tries to remove labels used in blockaddress()
On Mar 15, 2010, at 7:11 AM, Sebastian Schlunke wrote: > Hi, > > i ran into a problem when using blockaddress() with a label in another function. It seems to me that LLVM tries to remove the label used in blockaddress because it seems like it is not used, but in fact it may be used somewhere with a indirectbr. > > I attached a small test-case that produces this error. (The original problem is much m...
2011 Aug 01
0
[LLVMdev] SwitchInst::addCase with BlockAddress
On Sun, Jul 31, 2011 at 7:36 AM, Carlo Alberto Ferraris <cafxx at strayorange.com> wrote: > I'm trying to figure out how to feed a blockaddress to a switch condition > AND destination (basically emulating an indirectbr via a switch; I know it's > not a good approach, I'm just experimenting). > Suppose I have the following: > > SwitchInst *s = SwitchInst::Create(...); > BasicBlock *bb = ...; > PtrToIntInst k = n...
2017 Jul 29
2
Storing "blockaddress(@function, %block)" in a global variable?
Hi, The LangRef warns that "blockaddress(@function, %block)" has a limited and target-dependent applicability: https://llvm.org/docs/LangRef.html#addresses-of-basic-blocks But I wanted very much to save addresses of blocks in a global variable and so I did: % cat cond.c void foo(long *a) { if (a) *a = 0; } % clang...
2010 Mar 15
3
[LLVMdev] LLVM tries to remove labels used in blockaddress()
Hi, i ran into a problem when using blockaddress() with a label in another function. It seems to me that LLVM tries to remove the label used in blockaddress because it seems like it is not used, but in fact it may be used somewhere with a indirectbr. I attached a small test-case that produces this error. (The original problem is much more compli...
2020 Feb 28
2
Is BlockAddress always correct ?
Hi I use BlockAddress to get the address of BasicBlock , and I use GlobalVariable 's getInitializer() to pass the address of BasicBlock to the global variable of my own program and then I print it out. But , I found that BlockAddress is not always correct. For example, some function's rsp (stack pointer) o...
2010 Mar 15
3
[LLVMdev] LLVM tries to remove labels used in blockaddress()
I see. But the block does not necessarily contain dead code. My original problem is more like this: define i32 @main() { entry: %target = bitcast i8* blockaddress(@test_fun, %test_label) to i8* call i32 @test_fun(i8* %target) ret i32 0 } define i32 @test_fun(i8* %target) { entry: indirectbr i8* %target, [label %test_label] test_label: ; assume some code here... br label %ret ret: ret i32 -1 } The code after test_label can be reached, but this exam...
2010 Dec 11
3
[LLVMdev] indirectbr/blockaddress question
In my llvm jit project I needed to lookup BB addresses at execution time and then jump to the corresponding BB. A C++ routine called at runtime from IR finds the right BB, gets its BlockAddress and returns it as an i8*. The IR does an indirectbr on this value... Well, not really. The routine returns the address of a BlockAddress node. Is there any way to get the real runtime code address for the indirect jump at runtime? Thanks for any advice. -------------- next part -------------- An H...
2012 Jun 17
3
[LLVMdev] BlockAddress instruction is copied instead of cloned during module link?
I have a module having the blockaddress instruction. When I link it into another module and delete the original, blockaddress disappears and is replaced by inttoptr (i32 1 to i8*). Please compile and run the attached program to see the demo of this problem. Right after linking modules, blockaddress still exists: @switch.bbs = interna...
2010 Feb 26
2
[LLVMdev] BlockAddress is a "User"
I've been playing around with the new IndirectBr and BlockAddress types. I'm finding that in CodeGen, during "EliminateMostlyEmptyBlocks", BlockAddresses are not updated to point to the newly merged block if the original block was eliminated. This is causing me problems. Mind you, I'm experimenting with this using the Sparc backend, which coul...
2010 Mar 15
0
[LLVMdev] LLVM tries to remove labels used in blockaddress()
...gt;> An earlier revision simply generated asm-code, where the appropriate label was missing, thus causing gcc to fail when i wanted to compile the asm-file. >> >> Here is a slightly reduced testcase: >> >> define i8* @test1() nounwind { >> entry: >> ret i8* blockaddress(@test_fun, %test_label) >> } >> >> define i32 @test_fun() nounwind { >> entry: >> ret i32 -1 >> test_label: >> br label %ret >> ret: >> ret i32 -1 >> } >> >> The basic problem is that we codegen test1, which generates a re...
2010 Mar 15
0
[LLVMdev] LLVM tries to remove labels used in blockaddress()
...Schlunke wrote: > I see. But the block does not necessarily contain dead code. This case is now fixed in r98566, I will fix the 'dead block' case in a bit. -Chris > > My original problem is more like this: > > define i32 @main() { > entry: > %target = bitcast i8* blockaddress(@test_fun, %test_label) to i8* > > call i32 @test_fun(i8* %target) > > ret i32 0 > } > > define i32 @test_fun(i8* %target) { > entry: > indirectbr i8* %target, [label %test_label] > > test_label: > ; assume some code here... > br label %ret > >...
2010 Mar 15
1
[LLVMdev] LLVM tries to remove labels used in blockaddress()
...essarily contain dead code. > > This case is now fixed in r98566, I will fix the 'dead block' case in a bit. > > -Chris > > > > > My original problem is more like this: > > > > define i32 @main() { > > entry: > > %target = bitcast i8* blockaddress(@test_fun, %test_label) to i8* > > > > call i32 @test_fun(i8* %target) > > > > ret i32 0 > > } > > > > define i32 @test_fun(i8* %target) { > > entry: > > indirectbr i8* %target, [label %test_label] > > > > test_label: > &gt...
2011 Aug 01
1
[LLVMdev] SwitchInst::addCase with BlockAddress
Nella citazione lunedì 1 agosto 2011 08:13:12, Eli Friedman ha scritto: > On Sun, Jul 31, 2011 at 7:36 AM, Carlo Alberto Ferraris > <cafxx at strayorange.com> wrote: >> I'm trying to figure out how to feed a blockaddress to a switch condition >> AND destination (basically emulating an indirectbr via a switch; I know it's >> not a good approach, I'm just experimenting). >> Suppose I have the following: >> >> SwitchInst *s = SwitchInst::Create(...); >> BasicBlock *bb = ...;...
2017 Mar 04
2
Figuring out return address of a call
...n (my main target is x86_64 for now) at runtime, see the two examples below: 100: e8 ff ff ff ff callq func 105: .marker 100: ff d0 callq *%rax 102: .marker My approach is to find call addresses through a function pass, split the basic block *after* the call instruction, then generate a BlockAddress as follows: if (auto CL = dyn_cast<CallInst>(&*I)) { BasicBlock *callblock = (*CL)->getParent(); BasicBlock *postblock = callblock->splitBasicBlock((*CL)->getNextNode()); BlockAddress *retaddr = BlockAddress::get(postblock); ... } This works well except that the Blo...