[llvm-dev] CodeExtractor with phinode

Umesh Kalappa via llvm-dev llvm-dev at lists.llvm.org
Thu Jun 22 02:51:23 PDT 2017


Hi Johan,

Did you able to resolve the below issue ?

Community , Any inputs here ?

Thank you
~Umesh


On Thu, Aug 27, 2015 at 9:06 PM, Wehrli Johan via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
> Hello,
>
> I try to extact a region from a function with CodeExtractor.
>
> I get the regions with "RegionInfo* RI = &getAnalysis<RegionInfoPass>(*f).getRegionInfo();"
>
> This works quite well except in one case.
>
> When I have a phinode outside the region whose values depend on two basic blocks inside the region.
>
> After the extract, those basic blocks are not in the function anymore.
>
> The last loop in the function “extractCodeRegion" seems to handle this case but the result is strange (2 times the same dependency).
>
> Does anyone know if I have to run another pass before the CodeExtractor or did I miss something?
>
> Cheers,
>
> Johan
>
>
> **********Example*************
>
> C
>
> int main(int argc, char** argv)/*__attribute__((tp(50)))*/{
> bool b1 = true;
> bool b2 = false;
>
> if(argc){
> bool m = b1 || b2 ;
> }
> return 0;
> }
>
> IR
>
> define i32 @main(i32 %argc, i8** %argv) #0 {
>   %.loc = alloca i1
>   %1 = alloca i32, align 4
>   %2 = alloca i32, align 4
>   %3 = alloca i8**, align 8
>   %b1 = alloca i8, align 1
>   %b2 = alloca i8, align 1
>   %m = alloca i8, align 1
>   store i32 0, i32* %1
>   store i32 %argc, i32* %2, align 4
>   store i8** %argv, i8*** %3, align 8
>   store i8 1, i8* %b1, align 1
>   store i8 0, i8* %b2, align 1
>   %4 = load i32* %2, align 4
>   %5 = icmp ne i32 %4, 0
>   br i1 %5, label %codeRepl, label %9
>
> codeRepl:                                         ; preds = %0
>   call void @main_(i8* %b1, i8* %b2, i1* %.loc)
>   %.reload = load i1* %.loc
>   br label %6
>
> ; <label>:6                                       ; preds = %codeRepl
>   %7 = phi i1 [ true, %codeRepl ], [ %.reload, %codeRepl ]
>   %8 = zext i1 %7 to i8
>   store i8 %8, i8* %m, align 1
>   br label %9
>
> ; <label>:9                                       ; preds = %6, %0
>   ret i32 0
> }
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev


More information about the llvm-dev mailing list