Compare commits
1 Commits
171151651b
...
5bce205238
Author | SHA1 | Date | |
---|---|---|---|
5bce205238 |
@ -2860,6 +2860,7 @@ llvm_create_global_variable = fn (module: &LLVMModule, type: &LLVMType, is_const
|
|||||||
[extern] LLVMConstNamedStruct = fn [cc(c)] (type: &LLVMType, constant_pointer: &&LLVMValue, constant_count: u32) &LLVMValue;
|
[extern] LLVMConstNamedStruct = fn [cc(c)] (type: &LLVMType, constant_pointer: &&LLVMValue, constant_count: u32) &LLVMValue;
|
||||||
[extern] LLVMConstStructInContext = fn [cc(c)] (context: &LLVMContext, constant_pointer: &&LLVMValue, constant_count: u32, packed: s32) &LLVMValue;
|
[extern] LLVMConstStructInContext = fn [cc(c)] (context: &LLVMContext, constant_pointer: &&LLVMValue, constant_count: u32, packed: s32) &LLVMValue;
|
||||||
|
|
||||||
|
[extern] LLVMGetInstructionParent = fn [cc(c)] (value: &LLVMValue) &LLVMBasicBlock;
|
||||||
[extern] LLVMInstructionEraseFromParent = fn [cc(c)] (value: &LLVMValue) void;
|
[extern] LLVMInstructionEraseFromParent = fn [cc(c)] (value: &LLVMValue) void;
|
||||||
[extern] LLVMGetOperand = fn [cc(c)] (value: &LLVMValue, index: u32) &LLVMValue;
|
[extern] LLVMGetOperand = fn [cc(c)] (value: &LLVMValue, index: u32) &LLVMValue;
|
||||||
[extern] LLVMGetFirstUse = fn [cc(c)] (value: &LLVMValue) &LLVMUse;
|
[extern] LLVMGetFirstUse = fn [cc(c)] (value: &LLVMValue) &LLVMUse;
|
||||||
@ -17881,18 +17882,26 @@ emit = fn (module: &Module) void
|
|||||||
if (first_use)
|
if (first_use)
|
||||||
{
|
{
|
||||||
>second_use = LLVMGetNextUse(first_use);
|
>second_use = LLVMGetNextUse(first_use);
|
||||||
>has_one_use = first_use != zero and first_use == zero;
|
>has_one_use = first_use != zero and second_use == zero;
|
||||||
|
|
||||||
if (has_one_use)
|
if (has_one_use)
|
||||||
{
|
{
|
||||||
user = LLVMGetUser(first_use);
|
user = LLVMGetUser(first_use);
|
||||||
has_single_jump_to_return_block = LLVMIsABranchInst(user) != zero and? LLVMIsConditional(user) != 0 and? LLVMGetSuccessor(user, 0) == return_block;
|
has_single_jump_to_return_block = LLVMIsABranchInst(user) != zero and? LLVMIsConditional(user) == 0 and? LLVMGetSuccessor(user, 0) == return_block;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (has_single_jump_to_return_block)
|
if (has_single_jump_to_return_block)
|
||||||
{
|
{
|
||||||
#trap();
|
assert(LLVMGetBasicBlockParent(return_block) != zero);
|
||||||
|
>new_return_block = LLVMGetInstructionParent(user);
|
||||||
|
// Remove unconditional branch instruction to the return block
|
||||||
|
LLVMInstructionEraseFromParent(user);
|
||||||
|
assert(!LLVMGetFirstUse(#pointer_cast(return_block)));
|
||||||
|
assert(!LLVMGetBasicBlockTerminator(return_block));
|
||||||
|
assert(LLVMGetBasicBlockParent(return_block) != zero);
|
||||||
|
LLVMPositionBuilderAtEnd(module.llvm.builder, new_return_block);
|
||||||
|
LLVMDeleteBasicBlock(return_block);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user