blockaddress(@function, %block) IR?
Tove via digitalmars-d-ldc
digitalmars-d-ldc at puremagic.com
Mon Aug 18 17:05:04 PDT 2014
On Monday, 18 August 2014 at 15:45:55 UTC, Tove wrote:
> Looking at the "-output-ll" I see that the inlineIR function is
> "declared" but not defined.
Argh, silly me, since the results didn't make fully sense I
continued to investigate.
Because I used an older compiler without support for
pragma(LDC_no_moduleinfo), I deleted it but I accidentally
deleted pragma(LDC_inline_ir) as well, no wonder the results were
strange. But anyway the rest of the observations were correct.
With the old version it now sort of works!!! :)
=======================================
extern(C)
byte* fun1()
{
byte* lbl_addr;
lbl1:
inlineIR!(`
store i8* blockaddress(@fun1, %label_lbl1), i8** %0
`, void)(&lbl_addr);
return lbl_addr;
}
=======================================
define i8* @fun1() {
entry:
%lbl_addr = alloca i8*, align 4
store i8* null, i8** %lbl_addr
%tmp = load i8** %lbl_addr
br label %label_lbl1
label_lbl1: ; preds = %entry
store i8* blockaddress(@fun1, %label_lbl1), i8** %lbl_addr
%tmp1 = load i8** %lbl_addr
%tmp2 = load i8** %lbl_addr
ret i8* %tmp2
}
=======================================
However... the label is only accessible if it's located _before_
the inlineIR otherwise it fails, I guess that means the inlineIR
is send to llvm::ParseAssemblyString too early, is that
complicated to fix?
To be absolutely clear what I mean:
=======================================
extern(C)
byte* fun2()
{
byte* lbl_addr;
inlineIR!(`
store i8* blockaddress(@fun2, %label_lbl2), i8** %0
`, void)(&lbl_addr);
lbl2:
return lbl_addr;
}
This fails with 'referenced value is not a basic block'.
More information about the digitalmars-d-ldc
mailing list