[PATCH] D51070: [SafeStack] Handle unreachable code with safe stack coloring.
Eli Friedman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 21 16:40:47 PDT 2018
efriedma created this revision.
efriedma added a reviewer: eugenis.
Herald added a subscriber: srhines.
Herald added a reviewer: javed.absar.
Instead of asserting that the function doesn't have any unreachable code, just ignore it for the purpose of computing liveness.
Repository:
rL LLVM
https://reviews.llvm.org/D51070
Files:
lib/CodeGen/SafeStackColoring.cpp
test/Transforms/SafeStack/AArch64/unreachable.ll
Index: test/Transforms/SafeStack/AArch64/unreachable.ll
===================================================================
--- /dev/null
+++ 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: lib/CodeGen/SafeStackColoring.cpp
===================================================================
--- lib/CodeGen/SafeStackColoring.cpp
+++ 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.161842.patch
Type: text/x-patch
Size: 1447 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180821/fcad304f/attachment.bin>
More information about the llvm-commits
mailing list