Commit 623cb95e authored by Nico Weber's avatar Nico Weber
Browse files

Revert "[InstSimplify] Simplify calls with "returned" attribute"

This reverts commit 45555c38.
Causes clang crashes in some causes, see comments on
https://reviews.llvm.org/D75815 for details (including
repro steps).
parent 0928368f
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -5361,9 +5361,6 @@ Value *llvm::SimplifyCall(CallBase *Call, const SimplifyQuery &Q) {
    if (Value *Ret = simplifyIntrinsic(Call, Q))
      return Ret;

  if (Value *ReturnedArg = Call->getReturnedArgOperand())
    return ReturnedArg;

  if (!canConstantFoldCallTo(Call, F))
    return nullptr;

+1 −1
Original line number Diff line number Diff line
@@ -117,7 +117,7 @@ define i1 @nonnullReturnTest(i8* nonnull %x) {
define i1 @unknownReturnTest(i8* %x) {
; CHECK-LABEL: @unknownReturnTest(
; CHECK-NEXT:    [[X2:%.*]] = call i8* @returningPtr(i8* [[X:%.*]])
; CHECK-NEXT:    [[NULL_CHECK:%.*]] = icmp eq i8* [[X]], null
; CHECK-NEXT:    [[NULL_CHECK:%.*]] = icmp eq i8* [[X2]], null
; CHECK-NEXT:    ret i1 [[NULL_CHECK]]
;
  %x2 = call i8* @returningPtr(i8* %x)
+1 −1
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@ define i32 @foo2(i32* align 32 %a) #0 {
; CHECK-LABEL: @foo2(
; CHECK-NEXT:  entry:
; CHECK-NEXT:    [[V:%.*]] = call i32* @func1(i32* [[A:%.*]])
; CHECK-NEXT:    [[TMP0:%.*]] = load i32, i32* [[A]], align 32
; CHECK-NEXT:    [[TMP0:%.*]] = load i32, i32* [[V]], align 32
; CHECK-NEXT:    ret i32 [[TMP0]]
;
entry:
+1 −1
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@ define void @test() {
;
; EXPENSIVE-OFF-LABEL: @test(
; EXPENSIVE-OFF-NEXT:    [[CALL:%.*]] = call i32 @passthru(i32 0)
; EXPENSIVE-OFF-NEXT:    call void @sink(i32 0)
; EXPENSIVE-OFF-NEXT:    call void @sink(i32 [[CALL]])
; EXPENSIVE-OFF-NEXT:    ret void
;
  %call = call i32 @passthru(i32 0)
+2 −2
Original line number Diff line number Diff line
@@ -82,7 +82,7 @@ define i32 @test_not_sprintf() {
define i8* @test_strcat() {
; CHECK-LABEL: @test_strcat(
; CHECK-NEXT:    [[STRCAT:%.*]] = call i8* @strcat(i8* nonnull dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @a, i64 0, i64 0), i8* nonnull dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @b, i64 0, i64 0))
; CHECK-NEXT:    ret i8* getelementptr inbounds ([60 x i8], [60 x i8]* @a, i64 0, i64 0)
; CHECK-NEXT:    ret i8* [[STRCAT]]
;
  %dst = getelementptr inbounds [60 x i8], [60 x i8]* @a, i32 0, i32 0
  %src = getelementptr inbounds [60 x i8], [60 x i8]* @b, i32 0, i32 0
@@ -126,7 +126,7 @@ define i64 @test_not_strlcat() {
define i8* @test_strncat() {
; CHECK-LABEL: @test_strncat(
; CHECK-NEXT:    [[STRNCAT:%.*]] = call i8* @strncat(i8* nonnull dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @a, i64 0, i64 0), i8* nonnull dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @b, i64 0, i64 0), i64 22)
; CHECK-NEXT:    ret i8* getelementptr inbounds ([60 x i8], [60 x i8]* @a, i64 0, i64 0)
; CHECK-NEXT:    ret i8* [[STRNCAT]]
;
  %dst = getelementptr inbounds [60 x i8], [60 x i8]* @a, i32 0, i32 0
  %src = getelementptr inbounds [60 x i8], [60 x i8]* @b, i32 0, i32 0
Loading