[PATCH] D35979: [X86] Fix a crash in FEntryInserter Pass.

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 28 10:33:45 PDT 2017


On Fri, Jul 28, 2017 at 10:32 AM Manoj Gupta via Phabricator via
llvm-commits <llvm-commits at lists.llvm.org> wrote:

> manojgupta updated this revision to Diff 108677.
> manojgupta removed a reviewer: dblaikie.
> manojgupta added a comment.
>
> Linux kernel is still WIP.
>
> Added back the DebugLoc from first instruction. I am not sure though if
> reusing
> debug location from an unrelated instruction is ok.
>

Depends what you mean by "unrelated" - if the new instruction is created
because of/only in the presence of the old instruction, yaeh, using its
debugloc may be appropriate. (Though if the new instruction may be created
in a different basic block - that gets trickier)


>
>
> https://reviews.llvm.org/D35979
>
> Files:
>   lib/CodeGen/FEntryInserter.cpp
>   test/CodeGen/X86/fentry-insertion.ll
>
>
> Index: test/CodeGen/X86/fentry-insertion.ll
> ===================================================================
> --- test/CodeGen/X86/fentry-insertion.ll
> +++ test/CodeGen/X86/fentry-insertion.ll
> @@ -12,5 +12,19 @@
>  ; CHECK: retq
>  }
>
> -attributes #0 = { "fentry-call"="true" }
> +define void @test2() #1 {
> +entry:
> +  br label %bb1
> +bb1:
> +  call void @address_taken(i64 ptrtoint (i8* blockaddress(@test2, %bb1)
> to i64), i32 512)
> +  ret void
>
> +; CHECK-LABEL: @test2
> +; CHECK: callq __fentry__
> +; CHECK-NOT: mcount
> +; CHECK: retq
> +}
> +
> +declare void @address_taken(i64, i32) local_unnamed_addr
> +attributes #0 = { "fentry-call"="true" }
> +attributes #1 = { inlinehint minsize noredzone nounwind optsize sspstrong
> "fentry-call"="true" }
> Index: lib/CodeGen/FEntryInserter.cpp
> ===================================================================
> --- lib/CodeGen/FEntryInserter.cpp
> +++ lib/CodeGen/FEntryInserter.cpp
> @@ -41,11 +41,15 @@
>      return false;
>
>    auto &FirstMBB = *MF.begin();
> -  auto &FirstMI = *FirstMBB.begin();
> -
>    auto *TII = MF.getSubtarget().getInstrInfo();
> -  BuildMI(FirstMBB, FirstMI, FirstMI.getDebugLoc(),
> -          TII->get(TargetOpcode::FENTRY_CALL));
> +  if (FirstMBB.empty()) {
> +    BuildMI(FirstMBB, FirstMBB.begin(), DebugLoc(),
> +            TII->get(TargetOpcode::FENTRY_CALL));
> +  } else {
> +    auto &FirstMI = *FirstMBB.begin();
> +    BuildMI(FirstMBB, FirstMI, FirstMI.getDebugLoc(),
> +            TII->get(TargetOpcode::FENTRY_CALL));
> +  }
>    return true;
>  }
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170728/b8ef626c/attachment.html>


More information about the llvm-commits mailing list