[llvm] 7cca13b - [PartialInline] Bail out on asm-goto/callbr

Wenlei He via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 19 10:58:07 PST 2022


Author: Wenlei He
Date: 2022-01-19T10:57:57-08:00
New Revision: 7cca13bc3a02163c0b822298fefa6ccb1fe1d06e

URL: https://github.com/llvm/llvm-project/commit/7cca13bc3a02163c0b822298fefa6ccb1fe1d06e
DIFF: https://github.com/llvm/llvm-project/commit/7cca13bc3a02163c0b822298fefa6ccb1fe1d06e.diff

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

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.

Differential Revision: https://reviews.llvm.org/D117509

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/IPO/PartialInlining.cpp b/llvm/lib/Transforms/IPO/PartialInlining.cpp
index fe9586ce75a62..5f2223e4047e8 100644
--- a/llvm/lib/Transforms/IPO/PartialInlining.cpp
+++ b/llvm/lib/Transforms/IPO/PartialInlining.cpp
@@ -970,6 +970,9 @@ void PartialInlinerImpl::computeCallsiteToProfCountMap(
   };
 
   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 PartialInlinerImpl::tryPartialInline(FunctionCloner &Cloner) {
 
   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())

diff  --git a/llvm/test/Transforms/CodeExtractor/PartialInlinePGOMultiRegion.ll b/llvm/test/Transforms/CodeExtractor/PartialInlinePGOMultiRegion.ll
index 5d187abb68aa0..8b6137fe1aa22 100644
--- a/llvm/test/Transforms/CodeExtractor/PartialInlinePGOMultiRegion.ll
+++ b/llvm/test/Transforms/CodeExtractor/PartialInlinePGOMultiRegion.ll
@@ -101,6 +101,12 @@ for.inc2:                                          ; preds = %if.end2
   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
 }


        


More information about the llvm-commits mailing list