From ae6314583f5332371831c990ace5bc2e62347d89 Mon Sep 17 00:00:00 2001 From: Evgeniy Stepanov Date: Mon, 21 Dec 2015 22:14:04 +0000 Subject: [PATCH] [cfi] Fix LowerBitSets on 32-bit targets. This code attempts to truncate IntPtrTy to i32, which may be the same type. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256205 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/IPO/LowerBitSets.cpp | 2 +- test/Transforms/LowerBitSets/pr25902.ll | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 test/Transforms/LowerBitSets/pr25902.ll diff --git a/lib/Transforms/IPO/LowerBitSets.cpp b/lib/Transforms/IPO/LowerBitSets.cpp index 65d082b27a8..7b515745c31 100644 --- a/lib/Transforms/IPO/LowerBitSets.cpp +++ b/lib/Transforms/IPO/LowerBitSets.cpp @@ -683,7 +683,7 @@ Constant *LowerBitSets::createJumpTableEntry(GlobalObject *Src, Function *Dest, ConstantInt *DispOffset = ConstantInt::get(IntPtrTy, Distance * kX86JumpTableEntrySize + 5); Constant *OffsetedDisp = ConstantExpr::getSub(Disp, DispOffset); - OffsetedDisp = ConstantExpr::getTrunc(OffsetedDisp, Int32Ty); + OffsetedDisp = ConstantExpr::getTruncOrBitCast(OffsetedDisp, Int32Ty); ConstantInt *Int3 = ConstantInt::get(Int8Ty, kInt3Code); diff --git a/test/Transforms/LowerBitSets/pr25902.ll b/test/Transforms/LowerBitSets/pr25902.ll new file mode 100644 index 00000000000..b9a1203ec0e --- /dev/null +++ b/test/Transforms/LowerBitSets/pr25902.ll @@ -0,0 +1,21 @@ +; PR25902: gold plugin crash. +; RUN: opt -mtriple=i686-pc -S -lowerbitsets < %s + +define void @f(void ()* %p) { +entry: + %a = bitcast void ()* %p to i8*, !nosanitize !1 + %b = call i1 @llvm.bitset.test(i8* %a, metadata !"_ZTSFvvE"), !nosanitize !1 + ret void +} + +define void @g() { +entry: + ret void +} + +declare i1 @llvm.bitset.test(i8*, metadata) + +!llvm.bitsets = !{!0} + +!0 = !{!"_ZTSFvvE", void ()* @g, i64 0} +!1 = !{} -- 2.34.1