Index: test/Transforms/MergeFunc/intrinsics.ll =================================================================== --- /dev/null +++ test/Transforms/MergeFunc/intrinsics.ll @@ -0,0 +1,35 @@ +; RUN: opt -S -mergefunc -stats < %s 2>&1 | FileCheck %s +; This used to crash because mergefunc created a bitcast of an intrinsic. + +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +declare i64 @llvm.bswap.i64(i64) unnamed_addr nounwind readnone +declare i8* @breaker(i8*) unnamed_addr + +; @bswap_caller and @collider have the same hash in mergefunc and get fed to +; enumerate, which used to create a bitcast of the bswap intrinsic that +; survived on the intrinsics uselist and made the verify pass complain. +; The repeated calls are just to make the functions large enough to be merged +; and test that they aren't merged, regardless of the above bug. +define void @bswap_caller(i64) unnamed_addr { +; CHECK-LABEL: @bswap_caller( +entry-block: + call i64 @llvm.bswap.i64(i64 %0) + call i64 @llvm.bswap.i64(i64 %0) + call i64 @llvm.bswap.i64(i64 %0) + call i64 @llvm.bswap.i64(i64 %0) + ret void +} + +define internal void @collider(i8*) unnamed_addr { +; CHECK-LABEL: @collider( +entry-block: + call i8* @breaker(i8* %0) + call i8* @breaker(i8* %0) + call i8* @breaker(i8* %0) + call i8* @breaker(i8* %0) + ret void +} + +; CHECK-NOT: functions merged