[llvm] 62627c7 - [Sanitizers] Replaced getMaxPointerSizeInBits with getPointerSizeInBits, which was causing failures for 32bit x86.
Kirill Stoimenov via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 18 09:31:56 PDT 2021
Author: Kirill Stoimenov
Date: 2021-10-18T09:31:14-07:00
New Revision: 62627c721732525a06da4292ca151e8e529911c6
URL: https://github.com/llvm/llvm-project/commit/62627c721732525a06da4292ca151e8e529911c6
DIFF: https://github.com/llvm/llvm-project/commit/62627c721732525a06da4292ca151e8e529911c6.diff
LOG: [Sanitizers] Replaced getMaxPointerSizeInBits with getPointerSizeInBits, which was causing failures for 32bit x86.
Reviewed By: vitalybuka
Differential Revision: https://reviews.llvm.org/D111829
Added:
llvm/test/Analysis/StackSafetyAnalysis/i386-bug-fix.ll
Modified:
llvm/lib/Analysis/StackSafetyAnalysis.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/StackSafetyAnalysis.cpp b/llvm/lib/Analysis/StackSafetyAnalysis.cpp
index fa7dfd6b9900f..74cc39b7f2c0d 100644
--- a/llvm/lib/Analysis/StackSafetyAnalysis.cpp
+++ b/llvm/lib/Analysis/StackSafetyAnalysis.cpp
@@ -154,7 +154,7 @@ raw_ostream &operator<<(raw_ostream &OS, const UseInfo<CalleeTy> &U) {
ConstantRange getStaticAllocaSizeRange(const AllocaInst &AI) {
const DataLayout &DL = AI.getModule()->getDataLayout();
TypeSize TS = DL.getTypeAllocSize(AI.getAllocatedType());
- unsigned PointerSize = DL.getMaxPointerSizeInBits();
+ unsigned PointerSize = DL.getPointerTypeSizeInBits(AI.getType());
// Fallback to empty range for alloca size.
ConstantRange R = ConstantRange::getEmpty(PointerSize);
if (TS.isScalable())
@@ -752,10 +752,8 @@ GVToSSI createGlobalStackSafetyInfo(
KV.second.Calls.clear();
}
- uint32_t PointerSize = Copy.begin()
- ->first->getParent()
- ->getDataLayout()
- .getMaxPointerSizeInBits();
+ uint32_t PointerSize =
+ Copy.begin()->first->getParent()->getDataLayout().getPointerSizeInBits();
StackSafetyDataFlowAnalysis<GlobalValue> SSDFA(PointerSize, std::move(Copy));
for (auto &F : SSDFA.run()) {
diff --git a/llvm/test/Analysis/StackSafetyAnalysis/i386-bug-fix.ll b/llvm/test/Analysis/StackSafetyAnalysis/i386-bug-fix.ll
new file mode 100644
index 0000000000000..b6e65f94d0d1f
--- /dev/null
+++ b/llvm/test/Analysis/StackSafetyAnalysis/i386-bug-fix.ll
@@ -0,0 +1,24 @@
+; REQUIRES: i386-pc-linux-gnu
+
+; RUN: opt passes="print-stack-safety" -disable-output -mtriple=i386-pc-linux-gnu %s 2>&1 | FileCheck %s --check-prefixes=CHECK
+
+; CHECK: @main
+; CHECK-NEXT: args uses:
+; CHECK-NEXT: argv[]: empty-set
+; CHECK-NEXT: allocas uses:
+; CHECK-NEXT: [4]: [0,4)
+; CHECK-NEXT: [32]: full-set
+; CHECK-NEXT: safe accesses:
+
+target datalayout = "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-f80:32-n8:16:32-S128"
+target triple = "i386-pc-linux-gnu"
+
+; Function Attrs: mustprogress norecurse sanitize_address uwtable
+define dso_local i32 @main(i32 %argc, i8** %argv) {
+entry:
+ %0 = alloca i32, align 4
+ %1 = alloca i8, i64 32, align 32
+ %2 = ptrtoint i8* %1 to i32
+ store i32 %2, i32* %0, align 4
+ ret i32 0
+}
More information about the llvm-commits
mailing list