[PATCH] D39864: Fix for CFI type tests lowering assert.
Dmitry Mikulin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 16 12:34:44 PST 2017
dmikulin updated this revision to Diff 123234.
dmikulin added a comment.
Changed the fix to save unique Constant users and process them separately outside of the UseList iterator.
https://reviews.llvm.org/D39864
Files:
llvm/lib/IR/Value.cpp
llvm/test/Transforms/LowerTypeTests/blockaddress-2.ll
Index: llvm/test/Transforms/LowerTypeTests/blockaddress-2.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/LowerTypeTests/blockaddress-2.ll
@@ -0,0 +1,27 @@
+; RUN: opt -S %s -lowertypetests | FileCheck %s
+
+; CHECK: @badfileops = internal global %struct.f { i32 (i32*)* @bad_f, i32 (i32*)* @bad_f }
+; CHECK: @bad_f = internal alias i32 (i32*), bitcast (void ()* @.cfi.jumptable to i32 (i32*)*)
+; CHECK: define internal i32 @bad_f.cfi(i32* nocapture readnone) !type !0 {
+; CHECK-NEXT: ret i32 9
+
+target triple = "x86_64-unknown-linux"
+
+%struct.f = type { i32 (i32*)*, i32 (i32*)* }
+ at llvm.used = external global [43 x i8*], section "llvm.metadata"
+ at badfileops = internal global %struct.f { i32 (i32*)* @bad_f, i32 (i32*)* @bad_f }, align 8
+
+declare i1 @llvm.type.test(i8*, metadata)
+
+define internal i32 @bad_f(i32* nocapture readnone) !type !1 {
+ ret i32 9
+}
+
+define internal fastcc i32 @do_f(i32, i32, i32*, i32, i64, i32) unnamed_addr !type !2 {
+ %7 = tail call i1 @llvm.type.test(i8* undef, metadata !"_ZTSFiP4fileP3uioP5ucrediP6threadE"), !nosanitize !3
+ ret i32 undef
+}
+
+!1 = !{i64 0, !"_ZTSFiP4fileP3uioP5ucrediP6threadE"}
+!2 = !{i64 0, !"_ZTSFiP6threadiP4fileP3uioliE"}
+!3 = !{}
Index: llvm/lib/IR/Value.cpp
===================================================================
--- llvm/lib/IR/Value.cpp
+++ llvm/lib/IR/Value.cpp
@@ -456,6 +456,7 @@
}
void Value::replaceUsesExceptBlockAddr(Value *New) {
+ SmallPtrSet<Constant *, 4> Constants;
use_iterator UI = use_begin(), E = use_end();
for (; UI != E;) {
Use &U = *UI;
@@ -468,13 +469,19 @@
// constant because they are uniqued.
if (auto *C = dyn_cast<Constant>(U.getUser())) {
if (!isa<GlobalValue>(C)) {
- C->handleOperandChange(this, New);
+ // Save unique users to avoid processing operand replacement
+ // more than once.
+ Constants.insert(C);
continue;
}
}
U.set(New);
}
+
+ // Process operand replacement of saved constants.
+ for (auto *C : Constants)
+ C->handleOperandChange(this, New);
}
namespace {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39864.123234.patch
Type: text/x-patch
Size: 2163 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171116/97106dd7/attachment.bin>
More information about the llvm-commits
mailing list