Skip to content

Commit 7890757

Browse files
author
git apple-llvm automerger
committed
Merge commit 'ad2d85dfaaf7' from swift/release/5.3 into swift/master
2 parents 36f7fac + ad2d85d commit 7890757

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// RUN: %clang_cc1 -emit-llvm-bc -disable-llvm-passes -o %t.bc %s
2+
// RUN: llvm-dis %t.bc -o - | FileCheck %s
3+
4+
// Test case for PR45426. Make sure we do not crash while writing bitcode
5+
// containing a simplify-able fneg constant expression. Check that the created
6+
// bitcode file can be disassembled and has the constant expressions simplified.
7+
//
8+
// CHECK-LABEL define i32 @main()
9+
// CHECK: entry:
10+
// CHECK-NEXT: %retval = alloca i32
11+
// CHECK-NEXT: store i32 0, i32* %retval
12+
// CHECK-NEXT: [[LV:%.*]] = load float*, float** @c
13+
// CHECK-NEXT: store float 1.000000e+00, float* [[LV]], align 4
14+
// CHECK-NEXT: ret i32 -1
15+
16+
int a[], b;
17+
float *c;
18+
int main() {
19+
return -(*c = &b != a);
20+
}

llvm/lib/IR/Constants.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1316,6 +1316,8 @@ Constant *ConstantExpr::getWithOperands(ArrayRef<Constant *> Ops, Type *Ty,
13161316
OnlyIfReducedTy);
13171317
case Instruction::ExtractValue:
13181318
return ConstantExpr::getExtractValue(Ops[0], getIndices(), OnlyIfReducedTy);
1319+
case Instruction::FNeg:
1320+
return ConstantExpr::getFNeg(Ops[0]);
13191321
case Instruction::ShuffleVector:
13201322
return ConstantExpr::getShuffleVector(Ops[0], Ops[1], Ops[2],
13211323
OnlyIfReducedTy);

0 commit comments

Comments
 (0)