[llvm] 8c5a292 - IROutliner: Fix another assert with non-0 alloca addrspaces

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 5 03:02:25 PST 2023


Author: Matt Arsenault
Date: 2023-02-05T07:02:18-04:00
New Revision: 8c5a292202ff26ad51cf348001f82444d96e803b

URL: https://github.com/llvm/llvm-project/commit/8c5a292202ff26ad51cf348001f82444d96e803b
DIFF: https://github.com/llvm/llvm-project/commit/8c5a292202ff26ad51cf348001f82444d96e803b.diff

LOG: IROutliner: Fix another assert with non-0 alloca addrspaces

Code is inserting an addrspacecast it shouldn't be, but
that's a separate CodeExtractor bug.

This also stops caring about typed pointers.

Added: 
    llvm/test/Transforms/IROutliner/alloca-addrspace-1.ll

Modified: 
    llvm/lib/Transforms/IPO/IROutliner.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/IPO/IROutliner.cpp b/llvm/lib/Transforms/IPO/IROutliner.cpp
index f5c52e5c7f5d8..1c50ce3d79ea2 100644
--- a/llvm/lib/Transforms/IPO/IROutliner.cpp
+++ b/llvm/lib/Transforms/IPO/IROutliner.cpp
@@ -1332,7 +1332,7 @@ findExtractedOutputToOverallOutputMapping(Module &M, OutlinableRegion &Region,
 
     unsigned AggArgIdx = 0;
     for (unsigned Jdx = TypeIndex; Jdx < ArgumentSize; Jdx++) {
-      if (Group.ArgumentTypes[Jdx] != PointerType::getUnqual(Output->getType()))
+      if (!isa<PointerType>(Group.ArgumentTypes[Jdx]))
         continue;
 
       if (AggArgsUsed.contains(Jdx))

diff  --git a/llvm/test/Transforms/IROutliner/alloca-addrspace-1.ll b/llvm/test/Transforms/IROutliner/alloca-addrspace-1.ll
new file mode 100644
index 0000000000000..2ba3405c46021
--- /dev/null
+++ b/llvm/test/Transforms/IROutliner/alloca-addrspace-1.ll
@@ -0,0 +1,48 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --include-generated-funcs
+; RUN: opt -S -passes=iroutliner -ir-outlining-no-cost < %s | FileCheck %s
+
+target datalayout = "A5"
+
+define i32 @func_with_outgoing_new_allocas() {
+bb:
+  %i = tail call i32 @func0(i32 0, i32 1)
+  %i1 = or i32 0, %i
+  %i2 = tail call i32 @func0(i32 %i1, i32 0)
+  %i3 = or i32 %i1, %i2
+  %i4 = tail call i32 @llvm.foo(i32 %i3, i32 0)
+  ret i32 0
+}
+
+declare i32 @func0(i32, i32)
+declare i32 @llvm.foo(i32, i32)
+
+; CHECK-LABEL: define {{[^@]+}}@func_with_outgoing_new_allocas() {
+; CHECK-NEXT:  bb:
+; CHECK-NEXT:    [[I3_LOC:%.*]] = alloca i32, align 4, addrspace(5)
+; CHECK-NEXT:    [[I1_LOC:%.*]] = alloca i32, align 4, addrspace(5)
+; CHECK-NEXT:    [[LT_CAST:%.*]] = addrspacecast ptr addrspace(5) [[I1_LOC]] to ptr
+; CHECK-NEXT:    call void @llvm.lifetime.start.p0(i64 -1, ptr [[LT_CAST]])
+; CHECK-NEXT:    call void @outlined_ir_func_0(i32 0, i32 1, ptr addrspace(5) [[I1_LOC]])
+; CHECK-NEXT:    [[I1_RELOAD:%.*]] = load i32, ptr addrspace(5) [[I1_LOC]], align 4
+; CHECK-NEXT:    call void @llvm.lifetime.end.p0(i64 -1, ptr [[LT_CAST]])
+; CHECK-NEXT:    [[LT_CAST1:%.*]] = addrspacecast ptr addrspace(5) [[I3_LOC]] to ptr
+; CHECK-NEXT:    call void @llvm.lifetime.start.p0(i64 -1, ptr [[LT_CAST1]])
+; CHECK-NEXT:    call void @outlined_ir_func_0(i32 [[I1_RELOAD]], i32 0, ptr addrspace(5) [[I3_LOC]])
+; CHECK-NEXT:    [[I3_RELOAD:%.*]] = load i32, ptr addrspace(5) [[I3_LOC]], align 4
+; CHECK-NEXT:    call void @llvm.lifetime.end.p0(i64 -1, ptr [[LT_CAST1]])
+; CHECK-NEXT:    [[I4:%.*]] = tail call i32 @llvm.foo(i32 [[I3_RELOAD]], i32 0)
+; CHECK-NEXT:    ret i32 0
+;
+;
+; CHECK-LABEL: define {{[^@]+}}@outlined_ir_func_0
+; CHECK-SAME: (i32 [[TMP0:%.*]], i32 [[TMP1:%.*]], ptr addrspace(5) [[TMP2:%.*]]) #[[ATTR1:[0-9]+]] {
+; CHECK-NEXT:  newFuncRoot:
+; CHECK-NEXT:    br label [[BB_TO_OUTLINE:%.*]]
+; CHECK:       bb_to_outline:
+; CHECK-NEXT:    [[I:%.*]] = tail call i32 @func0(i32 [[TMP0]], i32 [[TMP1]])
+; CHECK-NEXT:    [[I1:%.*]] = or i32 [[TMP0]], [[I]]
+; CHECK-NEXT:    br label [[BB_AFTER_OUTLINE_EXITSTUB:%.*]]
+; CHECK:       bb_after_outline.exitStub:
+; CHECK-NEXT:    store i32 [[I1]], ptr addrspace(5) [[TMP2]], align 4
+; CHECK-NEXT:    ret void
+;


        


More information about the llvm-commits mailing list