Displaying 20 results from an estimated 78 matches for "setinsertpoint".
2017 Nov 06
2
[RFC] Setting the current debug loc when the insertion point changes
...nstructions will pick up a bogus debug loc from the IP. E.g this is what happens with SCEVExpander::expandCodeFor(). There's no way to fix this bug without changing IRBuilder's behavior.
>>>>
>>>> # Solutions
>>>>
>>>> 1. Add a method called SetInsertPointAndDebugLoc() which behaves identically to the current SetInsertPoint(). Change SetInsertPoint() so that it doesn't change the current debug loc.
>>>> 2. Add a boolean argument to SetInsertPoint() called UpdateDbgLoc which defaults to false. Only change the current debug loc if Updat...
2017 Nov 06
2
[RFC] Setting the current debug loc when the insertion point changes
...insertion point, all generated instructions will pick up a bogus debug loc from the IP. E.g this is what happens with SCEVExpander::expandCodeFor(). There's no way to fix this bug without changing IRBuilder's behavior.
>>
>> # Solutions
>>
>> 1. Add a method called SetInsertPointAndDebugLoc() which behaves identically to the current SetInsertPoint(). Change SetInsertPoint() so that it doesn't change the current debug loc.
>> 2. Add a boolean argument to SetInsertPoint() called UpdateDbgLoc which defaults to false. Only change the current debug loc if UpdateDbgLoc...
2017 Nov 06
3
[RFC] Setting the current debug loc when the insertion point changes
...call that changes the builder's insertion point, all generated instructions will pick up a bogus debug loc from the IP. E.g this is what happens with SCEVExpander::expandCodeFor(). There's no way to fix this bug without changing IRBuilder's behavior.
# Solutions
1. Add a method called SetInsertPointAndDebugLoc() which behaves identically to the current SetInsertPoint(). Change SetInsertPoint() so that it doesn't change the current debug loc.
2. Add a boolean argument to SetInsertPoint() called UpdateDbgLoc which defaults to false. Only change the current debug loc if UpdateDbgLoc is true....
2016 Sep 04
2
How to insert instructions before each function calls?
So one way might look like this:
IRBuilder<> Builder(&*BB); // BB = Function::iterator OR IRBuilder<>
Builder(CallInst->getParent());
Builder.SetInsertPoint(CallInst);
InstructionClass *YourNewInstruction =
builder.CreateInstructionClass(.....); // InstructionClass = type of
instruction you are inserting
-Ryan
On Sat, Sep 3, 2016 at 6:04 PM, Ryan Taylor <ryta1203 at gmail.com> wrote:
> Take a look at IRBuilder and SetInsertPoint().
>...
2017 Mar 31
2
How to write the same things as `opt` command in C++ API
...ype, llvm::Function::PrivateLinkage,
"c", module.get());
// Body of the `a` function
{
/// @brief Set entry label
llvm::BasicBlock *block = llvm::BasicBlock::Create(context, "entry", aFun);
/// @brief builder
llvm::IRBuilder<> builder(block);
builder.SetInsertPoint(block);
llvm::CallInst *cCall = builder.CreateCall(cFun, {}, "c");
llvm::Value *res = cCall;
builder.CreateRet(res);
llvm::verifyFunction(*aFun);
}
// Body of the `b` function
{
/// @brief Set entry label
llvm::BasicBlock *block = llvm::BasicBlock::Create(cont...
2020 Jun 03
2
Fwd: I cannot change value of global variable in LLVM IR using IRBuilder
I don't think it's the same problem as you described. By printing I meant
calling printf function and passing my global variable as one of the
arguments.
My code:
Instruction* InstructionVisitor::incrementGlobalKey(Instruction* I) {
IRBuilder<> Builder(I->getContext());
Builder.SetInsertPoint(I->getNextNode());
GlobalVariable* key = I->getModule()->getNamedGlobal("globalKey");
if (key) {
LoadInst* load = Builder.CreateLoad(key);
Value* inc = Builder.CreateAdd(load, Builder.getInt64(1));
StoreInst* store = Builder.CreateStore(inc, key);
return store;
}
return I;
}
I...
2012 Apr 05
0
[LLVMdev] Catching C++ exceptions, cleaning up, rethrowing
...sicBlock *const unwind_blk = BasicBlock::Create( ctx, "unwind", fn );
> builder.CreateInvoke( ctor, normal_blk, unwind_blk, ctor_args );
>
> // Call object's destructor.
> BasicBlock *const dtor_blk = BasicBlock::Create( ctx, "dtor", fn );
> builder.SetInsertPoint( dtor_blk );
> builder.CreateCall( dtor, void_obj_ptr );
> builder.CreateBr( unwind_blks_.back() );
>
> // Catch exception, if any.
> builder.SetInsertPoint( unwind_blk );
> LandingPadInst *const lpad = builder.CreateLandingPad(
> caught_result_type_, personali...
2020 Jun 03
2
Fwd: I cannot change value of global variable in LLVM IR using IRBuilder
...'m quite new to LLVM and I want to update value of global variable in LLVM
IR. I created new global variable in ModulePass:
bool runOnModule(llvm::Module &M) {
IRBuilder<> Builder(M.getContext());
Instruction *I = &*inst_begin(M.getFunction("main"));
Builder.SetInsertPoint(I);
M.getOrInsertGlobal("globalKey", Builder.getInt64Ty());
GlobalVariable* gVar = M.getNamedGlobal("globalKey");
gVar->setLinkage(GlobalValue::InternalLinkage);
gVar->setAlignment(Align(8));
gVar->setInitializer(Builder.getInt64(0));
gVar->se...
2016 Mar 30
0
LSR/SCEV problem/question
...consistent. The fact that we're trying
to optimize instructions as we insert them makes that trickier, but I
still think that is the right invariant to have.
I don't see why (2) would be particularly ugly though (perhaps I'm not
being sufficiently imaginative :) ). I think
IRBuilder::SetInsertPoint(Instruction *) is safe, since it always sets
BB and IP in sync with each other. So I think we basically need to
sync things at restoreIP() (which is called only once in the file) and
at places that potentially move insertion points (like hoistIVInc)
using something like
"Builder.SetInsertPoin...
2016 Dec 02
2
Libfuzzer depending on uninitialized debug info
...e bugs" and what we can do is come up with intelligent approaches to finding where they are likely to hide. For example, one possibility is to audit all the places that call SetCurrentDebugLocation; my grep through llvm/lib found 43 instances, which is not horrible. We can make sure that the SetInsertPoint/SetCurrentDebugLocation sequence is correct in all those places. If we can identify components that do depend on the debug line table (like fuzzer and sanitizers) then running a bunch of their tests with –use-unknown-locations turned on by default might also help, after we address the .cfi thing....
2016 Dec 03
0
Libfuzzer depending on uninitialized debug info
...g info
>
>
>
> I looked through all the places that call SetCurrentDebugLocation().
> Aside from the one place you already found, there are some
> suspicious-looking sequences in LoopVectorizer.cpp. Other than that they
> look okay to me.
>
>
>
> It turns out that `SetInsertPoint(Instruction *I)` automatically does
> `SetCurrentDebugLocation(I->getDebugLoc())` so the problem arises when
> you don't want the same debug location as the insertion point. And the
> IRBuilder ctor that takes an Instruction* does SetInsertPoint(I) so some
> places are calling S...
2016 Dec 12
1
Libfuzzer depending on uninitialized debug info
...[llvm-dev] Libfuzzer depending on uninitialized debug info
I looked through all the places that call SetCurrentDebugLocation(). Aside from the one place you already found, there are some suspicious-looking sequences in LoopVectorizer.cpp. Other than that they look okay to me.
It turns out that `SetInsertPoint(Instruction *I)` automatically does `SetCurrentDebugLocation(I->getDebugLoc())` so the problem arises when you don't want the same debug location as the insertion point. And the IRBuilder ctor that takes an Instruction* does SetInsertPoint(I) so some places are calling SetCurrentDebugLocati...
2012 Mar 23
2
[LLVMdev] Catching C++ exceptions, cleaning up, rethrowing
On Mar 23, 2012, at 4:29 PM, Paul J. Lucas wrote:
> On Mar 23, 2012, at 3:25 PM, Bill Wendling wrote:
>
>> Let's take your example. You will have code that looks like this:
>>
>> extern "C" void thunk_item_M_delete( void *v_that ) {
>> item *that = 0;
>> try {
>> that = static_cast<item*>( v_that );
>>
2009 May 05
4
[LLVMdev] A problem creating operands for a new IR instruction to the mailing list
I have a question about inserting instructions into the LLVM IR. I can insert instructions, but my operands do not have the right type, so it fails an assertion at runtime.
I am trying to insert an immediate load instructions, as a means of claiming a new register.
Here is what I do:
Builder.SetInsertPoint(LLVMBB, I);
// The following line looks to me like it would have a chance of loading either
// address 5, or else immediate value 5. Unfortunately, it does neither. It compiles
// but crashes at runtime, that the type of the operand is incompatible
Instruction *newI=Builder.CreateLoad(5,&q...
2016 Sep 03
2
How to insert instructions before each function calls?
I'm trying to insert some instructions before each function calls (before
arguments push):
lea %EAX, label ----- new instructions
mov [ESP+stacksize], %EAX ----- new instructions
push arg1
push arg2
...
push argn
call callee_name
I am a newbie to LLVM. I tried to use buildMI() to insert the instructions
in the lowercall() function. But I couldn't
2015 Jul 13
2
[LLVMdev] Problem with InsertPointGuard ABI?
...em. InsertPointGuard uses AssertingVT for
debug builds.
LLDB gets confused also. The first listing shows that the instance of
InsertPointGuard is messed up:
96 auto check = _builder.GetInsertBlock();
97 {
98 llvm::IRBuilderBase::InsertPointGuard guard{_builder};
-> 99 _builder.SetInsertPoint(checkBB);
100 }
101
102 if (_builder.GetInsertBlock() != check)
(lldb) p _builder
(llvm::IRBuilder<true, llvm::ConstantFolder,
llvm::IRBuilderDefaultInserter<true> >) $4 = {
llvm::IRBuilderBase = {
CurDbgLocation = {
Loc = {
Ref = {
MD = 0x00000000...
2016 Sep 04
1
How to insert instructions before each function calls?
...:18 PM, Ryan Taylor via llvm-dev <
>> llvm-dev at lists.llvm.org> wrote:
>>
>> So one way might look like this:
>>
>> IRBuilder<> Builder(&*BB); // BB = Function::iterator OR IRBuilder<>
>> Builder(CallInst->getParent());
>> Builder.SetInsertPoint(CallInst);
>> InstructionClass *YourNewInstruction = builder.CreateInstructionClass(.....);
>> // InstructionClass = type of instruction you are inserting
>>
>>
>> I’m not sure how the IRBuilder would work at the MI level, as Shucai was
>> asking.
>>
>&g...
2008 Mar 28
2
[LLVMdev] Python bindings?
..., is there some part of the C++ API
that is not exposed by the C API?
2)
Do the Ocaml/Haskell bindings follow that language's naming conventions?
Or LLVM's? For e.g., in Python method names are usually like_this. So
which of these are preferred:
Builder.set_insert_point()
or
Builder.SetInsertPoint()
?
Regards,
-MD.
2009 May 06
1
[LLVMdev] A problem creating operands for a new IR instruction to the mailing list
Thank you for your answer. But there is still a problem.
You seem correct about how to define a constant operand. So I added it into my code, like so:
Builder.SetInsertPoint(LLVMBB, I);
Constant *C = ConstantInt::get(APInt(32, 5, false));
Instruction *newI=Builder.CreateLoad(C,"");
It compiles. But it still aborts at runtime with a complaint that the type is not right.
This leads me to think that immediate loads are not generated with the Cre...
2009 May 05
0
[LLVMdev] A problem creating operands for a new IR instruction to the mailing list
...ructions into the LLVM IR. I can
> insert instructions, but my operands do not have the right type, so it fails
> an assertion at runtime.
>
> I am trying to insert an immediate load instructions, as a means of
> claiming a new register.
>
> Here is what I do:
> Builder.SetInsertPoint(LLVMBB, I);
>
> // The following line looks to me like it would have a chance o! f loading
> either
> // address 5, or else immediate value 5. Unfortunately, it does neither. It
> compiles
> // but crashes at runtime, that the type of the operand is incompatible
> Instr...