[PATCH] D51070: [SafeStack] Handle unreachable code with safe stack coloring.
Eli Friedman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 22 14:39:55 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL340456: [SafeStack] Handle unreachable code with safe stack coloring. (authored by efriedma, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D51070?vs=161842&id=162057#toc
Repository:
rL LLVM
https://reviews.llvm.org/D51070
Files:
llvm/trunk/lib/CodeGen/SafeStackColoring.cpp
llvm/trunk/test/Transforms/SafeStack/AArch64/unreachable.ll
Index: llvm/trunk/test/Transforms/SafeStack/AArch64/unreachable.ll
===================================================================
--- llvm/trunk/test/Transforms/SafeStack/AArch64/unreachable.ll
+++ llvm/trunk/test/Transforms/SafeStack/AArch64/unreachable.ll
@@ -0,0 +1,23 @@
+; RUN: opt -safe-stack -safe-stack-coloring -S -mtriple=aarch64-linux-android < %s -o - | FileCheck %s
+
+define void @foo() nounwind uwtable safestack {
+entry:
+; CHECK: %[[TP:.*]] = call i8* @llvm.thread.pointer()
+; CHECK: %[[SPA0:.*]] = getelementptr i8, i8* %[[TP]], i32 72
+; CHECK: %[[SPA:.*]] = bitcast i8* %[[SPA0]] to i8**
+; CHECK: %[[USP:.*]] = load i8*, i8** %[[SPA]]
+; CHECK: %[[USST:.*]] = getelementptr i8, i8* %[[USP]], i32 -16
+; CHECK: store i8* %[[USST]], i8** %[[SPA]]
+
+ %a = alloca i8, align 8
+ br label %ret
+
+ret:
+ ret void
+
+dead:
+ call void @Capture(i8* %a)
+ br label %ret
+}
+
+declare void @Capture(i8*)
Index: llvm/trunk/lib/CodeGen/SafeStackColoring.cpp
===================================================================
--- llvm/trunk/lib/CodeGen/SafeStackColoring.cpp
+++ llvm/trunk/lib/CodeGen/SafeStackColoring.cpp
@@ -172,7 +172,9 @@
BitVector LocalLiveIn;
for (auto *PredBB : predecessors(BB)) {
LivenessMap::const_iterator I = BlockLiveness.find(PredBB);
- assert(I != BlockLiveness.end() && "Predecessor not found");
+ // If a predecessor is unreachable, ignore it.
+ if (I == BlockLiveness.end())
+ continue;
LocalLiveIn |= I->second.LiveOut;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51070.162057.patch
Type: text/x-patch
Size: 1552 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180822/b4831bac/attachment.bin>
More information about the llvm-commits
mailing list