[PATCH] D79680: [Attributor] Fix for a crash on RAUW when rewriting function signature
Sergey Dmitriev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat May 9 17:01:14 PDT 2020
sdmitriev created this revision.
sdmitriev added a reviewer: jdoerfert.
Herald added subscribers: llvm-commits, uenoku, hiraditya.
Herald added a reviewer: sstefan1.
Herald added a reviewer: uenoku.
Herald added a project: LLVM.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D79680
Files:
llvm/lib/Transforms/IPO/Attributor.cpp
llvm/test/Transforms/Attributor/misc_crash.ll
llvm/test/Transforms/Attributor/returned_crash.ll
Index: llvm/test/Transforms/Attributor/misc_crash.ll
===================================================================
--- llvm/test/Transforms/Attributor/misc_crash.ll
+++ llvm/test/Transforms/Attributor/misc_crash.ll
@@ -1,7 +1,8 @@
; RUN: opt -attributor -S %s | FileCheck %s
; RUN: opt -passes=attributor -S %s | FileCheck %s
- at var = internal global [1 x i32] undef
+ at var1 = internal global [1 x i32] undef
+ at var2 = internal global i32 0
; CHECK-LABEL: define i32 addrspace(1)* @foo(i32 addrspace(4)* nofree readnone %arg)
define i32 addrspace(1)* @foo(i32 addrspace(4)* %arg) {
@@ -11,13 +12,28 @@
}
define i32* @func1() {
- %ptr = call i32* @func1a([1 x i32]* @var)
+ %ptr = call i32* @func1a([1 x i32]* @var1)
ret i32* %ptr
}
; CHECK-LABEL: define internal nonnull align 4 dereferenceable(4) i32* @func1a()
-; CHECK-NEXT: ret i32* getelementptr inbounds ([1 x i32], [1 x i32]* @var, i32 0, i32 0)
+; CHECK-NEXT: ret i32* getelementptr inbounds ([1 x i32], [1 x i32]* @var1, i32 0, i32 0)
define internal i32* @func1a([1 x i32]* %arg) {
%ptr = getelementptr inbounds [1 x i32], [1 x i32]* %arg, i64 0, i64 0
ret i32* %ptr
}
+
+define internal void @func2a(i32* %0) {
+ store i32 0, i32* %0
+ ret void
+}
+
+; CHECK-LABEL: define i32 @func2()
+; CHECK-NEXT: tail call void @func2a()
+; CHECK-NEXT: %1 = load i32, i32* @var2, align 4
+; CHECK-NEXT: ret i32 %1
+define i32 @func2() {
+ %1 = tail call i32 (i32*, ...) bitcast (void (i32*)* @func2a to i32 (i32*, ...)*)(i32* @var2)
+ %2 = load i32, i32* @var2
+ ret i32 %2
+}
Index: llvm/lib/Transforms/IPO/Attributor.cpp
===================================================================
--- llvm/lib/Transforms/IPO/Attributor.cpp
+++ llvm/lib/Transforms/IPO/Attributor.cpp
@@ -1609,7 +1609,8 @@
CallBase &NewCB = *CallSitePair.second;
ModifiedFns.insert(OldCB.getFunction());
CGUpdater.replaceCallSite(OldCB, NewCB);
- OldCB.replaceAllUsesWith(&NewCB);
+ if (!OldCB.use_empty())
+ OldCB.replaceAllUsesWith(&NewCB);
OldCB.eraseFromParent();
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79680.263042.patch
Type: text/x-patch
Size: 2090 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200510/f2f5155b/attachment.bin>
More information about the llvm-commits
mailing list