aboutsummaryrefslogtreecommitdiffstats
path: root/community/llvm8/GlobalOpt-prevent-crashing-on-wide-integer-types.patch
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2020-03-27 11:36:15 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2020-03-27 11:36:30 +0000
commit063082ba2278c67bb5429c5a2363e25f55462a67 (patch)
tree1fa76ab12d981664e9e692ad010c9f51c0e999d1 /community/llvm8/GlobalOpt-prevent-crashing-on-wide-integer-types.patch
parentae600a11fa30d9b3682409c76a4fc6b59f2309c7 (diff)
downloadaports-063082ba2278c67bb5429c5a2363e25f55462a67.tar.bz2
aports-063082ba2278c67bb5429c5a2363e25f55462a67.tar.xz
community/llvm8: move to community
nothing in main needs llvm8
Diffstat (limited to 'community/llvm8/GlobalOpt-prevent-crashing-on-wide-integer-types.patch')
-rw-r--r--community/llvm8/GlobalOpt-prevent-crashing-on-wide-integer-types.patch47
1 files changed, 47 insertions, 0 deletions
diff --git a/community/llvm8/GlobalOpt-prevent-crashing-on-wide-integer-types.patch b/community/llvm8/GlobalOpt-prevent-crashing-on-wide-integer-types.patch
new file mode 100644
index 0000000000..3b450e23d1
--- /dev/null
+++ b/community/llvm8/GlobalOpt-prevent-crashing-on-wide-integer-types.patch
@@ -0,0 +1,47 @@
+diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp
+index 3005aaf..fa3f3a7 100644
+--- a/lib/Transforms/IPO/GlobalOpt.cpp
++++ b/lib/Transforms/IPO/GlobalOpt.cpp
+@@ -1639,10 +1639,12 @@ static bool TryToShrinkGlobalToBoolean(GlobalVariable *GV, Constant *OtherVal) {
+ // instead of a select to synthesize the desired value.
+ bool IsOneZero = false;
+ bool EmitOneOrZero = true;
+- if (ConstantInt *CI = dyn_cast<ConstantInt>(OtherVal)){
++ auto *CI = dyn_cast<ConstantInt>(OtherVal);
++ if (CI && CI->getValue().getActiveBits() <= 64) {
+ IsOneZero = InitVal->isNullValue() && CI->isOne();
+
+- if (ConstantInt *CIInit = dyn_cast<ConstantInt>(GV->getInitializer())){
++ auto *CIInit = dyn_cast<ConstantInt>(GV->getInitializer());
++ if (CIInit && CIInit->getValue().getActiveBits() <= 64) {
+ uint64_t ValInit = CIInit->getZExtValue();
+ uint64_t ValOther = CI->getZExtValue();
+ uint64_t ValMinus = ValOther - ValInit;
+diff --git a/test/Transforms/GlobalOpt/large-int-crash.ll b/test/Transforms/GlobalOpt/large-int-crash.ll
+index e69de29..7584554 100644
+--- a/test/Transforms/GlobalOpt/large-int-crash.ll
++++ b/test/Transforms/GlobalOpt/large-int-crash.ll
+@@ -0,0 +1,23 @@
++; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
++; RUN: opt < %s -globalopt -S | FileCheck %s
++
++@X = internal global i128 0
++
++define void @foo() {
++; CHECK-LABEL: @foo(
++; CHECK-NEXT: [[T0_B:%.*]] = load i1, i1* @X
++; CHECK-NEXT: [[T0:%.*]] = select i1 [[T0_B]], i128 18446744073709551616, i128 0
++; CHECK-NEXT: ret void
++;
++ %t0 = load i128, i128* @X, align 8
++ ret void
++}
++
++define void @store() {
++; CHECK-LABEL: @store(
++; CHECK-NEXT: store i1 true, i1* @X
++; CHECK-NEXT: ret void
++;
++ store i128 18446744073709551616, i128* @X, align 8
++ ret void
++}