[PATCH] D117509: [PartialInline] Bail out on asm-goto/callbr

Wenlei He via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 17 12:07:08 PST 2022


wenlei created this revision.
wenlei added reviewers: hoy, fhahn, MatzeB, davidxl.
Herald added subscribers: ormris, modimo, hiraditya.
wenlei requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Fixing ICE when partial inline tries to deal with blockaddress uses of function which is typical for asm-goto/callbr. We ran into this with PGO multi-region partial inline.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D117509

Files:
  llvm/lib/Transforms/IPO/PartialInlining.cpp
  llvm/test/Transforms/CodeExtractor/PartialInlinePGOMultiRegion.ll


Index: llvm/test/Transforms/CodeExtractor/PartialInlinePGOMultiRegion.ll
===================================================================
--- llvm/test/Transforms/CodeExtractor/PartialInlinePGOMultiRegion.ll
+++ llvm/test/Transforms/CodeExtractor/PartialInlinePGOMultiRegion.ll
@@ -101,6 +101,12 @@
   br label %for.cond2
 
 for.end:                                          ; preds = %for.cond2
+  callbr void asm sideeffect "1: nop\0A\09.quad b, ${0:l}, $$5\0A\09", "X,~{dirflag},~{fpsr},~{flags}"(i8* blockaddress(@bar, %l_yes))
+          to label %asm.fallthrough [label %l_yes]
+asm.fallthrough:                                  ; preds = %for.end
+  br label %l_yes
+
+l_yes:
   %20 = load i32, i32* %sum, align 4
   ret i32 %20
 }
Index: llvm/lib/Transforms/IPO/PartialInlining.cpp
===================================================================
--- llvm/lib/Transforms/IPO/PartialInlining.cpp
+++ llvm/lib/Transforms/IPO/PartialInlining.cpp
@@ -970,6 +970,9 @@
   };
 
   for (User *User : Users) {
+    // Don't bother with BlockAddress used by CallBr for asm goto.
+    if (isa<BlockAddress>(User))
+      continue;
     CallBase *CB = getSupportedCallBase(User);
     Function *Caller = CB->getCaller();
     if (CurrentCaller != Caller) {
@@ -1413,6 +1416,10 @@
 
   bool AnyInline = false;
   for (User *User : Users) {
+    // Don't bother with BlockAddress used by CallBr for asm goto.
+    if (isa<BlockAddress>(User))
+      continue;
+
     CallBase *CB = getSupportedCallBase(User);
 
     if (isLimitReached())


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117509.400616.patch
Type: text/x-patch
Size: 1539 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220117/3da5b83d/attachment.bin>


More information about the llvm-commits mailing list