From d98f975089e3dd8a2a0dc298d3f76b0463610d2c Mon Sep 17 00:00:00 2001 From: Johannes Doerfert Date: Wed, 21 Aug 2019 21:48:56 +0000 Subject: [Attributor] Fix: Gracefully handle non-instruction users Function can have users that are not instructions, e.g., bitcasts. For now, we simply give up when we see them. llvm-svn: 369588 --- llvm/test/Transforms/FunctionAttrs/misc.ll | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 llvm/test/Transforms/FunctionAttrs/misc.ll (limited to 'llvm/test/Transforms/FunctionAttrs') diff --git a/llvm/test/Transforms/FunctionAttrs/misc.ll b/llvm/test/Transforms/FunctionAttrs/misc.ll new file mode 100644 index 00000000000..96ceb8743fd --- /dev/null +++ b/llvm/test/Transforms/FunctionAttrs/misc.ll @@ -0,0 +1,23 @@ +; RUN: opt -S -attributor -attributor-disable=false < %s | FileCheck %s + +define void @external() { +entry: + %a = alloca i32, align 4 + %tmp = bitcast i32* %a to i8* + call void @foo(i32* nonnull %a) +; Check we do not crash on these uses +; CHECK: call void @callback1(void (i32*)* nonnull @foo) + call void @callback1(void (i32*)* nonnull @foo) +; CHECK: call void @callback2(void (i8*)* nonnull bitcast (void (i32*)* @foo to void (i8*)*)) + call void @callback2(void (i8*)* bitcast (void (i32*)* @foo to void (i8*)*)) + %tmp1 = bitcast i32* %a to i8* + ret void +} + +define internal void @foo(i32* %a) { +entry: + ret void +} + +declare void @callback1(void (i32*)*) +declare void @callback2(void (i8*)*) -- cgit v1.2.3