llvm.org GIT mirror llvm / 0bd53cd
[ArgPromotion] Don't drop !prof metadata on promoted calls Noticed by inspection while doing attribute work. DAE, InstCombineCalls, and ArgPromotion have a fair amount of duplicated code for hacking on call sites, and you can find bugs by comparing them. Add a test case for this. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300229 91177308-0d34-0410-b5e6-96231b3b80d8 Reid Kleckner 2 years ago
2 changed file(s) with 27 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
290290 CallSite NewCS;
291291 if (InvokeInst *II = dyn_cast(Call)) {
292292 NewCS = InvokeInst::Create(NF, II->getNormalDest(), II->getUnwindDest(),
293 Args, OpBundles, "", Call);
293 Args, OpBundles, "", Call);
294294 } else {
295295 auto *NewCall = CallInst::Create(NF, Args, OpBundles, "", Call);
296296 NewCall->setTailCallKind(cast(Call)->getTailCallKind());
301301 AttributeList::get(F->getContext(), CallPAL.getFnAttributes(),
302302 CallPAL.getRetAttributes(), ArgAttrVec));
303303 NewCS->setDebugLoc(Call->getDebugLoc());
304 uint64_t W;
305 if (Call->extractProfTotalWeight(W))
306 NewCS->setProfWeight(W);
304307 Args.clear();
305308 ArgAttrVec.clear();
306309
0 ; RUN: opt -argpromotion -mem2reg -S < %s | FileCheck %s
1 target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128"
2
3 ; Checks if !prof metadata is corret in deadargelim.
4
5 define void @caller() #0 {
6 %x = alloca i32
7 store i32 42, i32* %x
8 call void @promote_i32_ptr(i32* %x), !prof !0
9 ; CHECK: call void @promote_i32_ptr(i32 42), !prof ![[PROF:[0-9]]]
10 ret void
11 }
12
13 define internal void @promote_i32_ptr(i32* %xp) {
14 %x = load i32, i32* %xp
15 call void @use_i32(i32 %x)
16 ret void
17 }
18
19 declare void @use_i32(i32)
20
21 ; CHECK: ![[PROF]] = !{!"branch_weights", i32 30}
22 !0 = !{!"branch_weights", i32 30}