llvm.org GIT mirror llvm / 8480c2e
Remember byval argument's frame index during argument lowering and use this info to emit debug info. Fixes Radar 8367011. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112623 91177308-0d34-0410-b5e6-96231b3b80d8 Devang Patel 10 years ago
5 changed file(s) with 112 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
7676 /// anywhere in the function.
7777 DenseMap StaticAllocaMap;
7878
79 /// ByValArgFrameIndexMap - Keep track of frame indices for byval arguments.
80 DenseMap ByValArgFrameIndexMap;
81
7982 /// ArgDbgValues - A list of DBG_VALUE instructions created during isel for
8083 /// function arguments that are inserted after scheduling is completed.
8184 SmallVector ArgDbgValues;
137140 assert(R == 0 && "Already initialized this value register!");
138141 return R = CreateRegs(V->getType());
139142 }
143
144 /// setByValArgumentFrameIndex - Record frame index for the byval
145 /// argument.
146 void setByValArgumentFrameIndex(const Argument *A, int FI);
147
148 /// getByValArgumentFrameIndex - Get frame index for the byval argument.
149 int getByValArgumentFrameIndex(const Argument *A);
140150 };
141151
142152 /// AddCatchInfo - Extract the personality and type infos from an eh.selector
16281628 bool updated = false;
16291629 // FIXME : Handle getNumOperands != 3
16301630 if (DVInsn->getNumOperands() == 3) {
1631 if (DVInsn->getOperand(0).isReg())
1632 updated =
1633 addRegisterAddress(VariableDie, DVLabel, DVInsn->getOperand(0));
1631 if (DVInsn->getOperand(0).isReg()) {
1632 const MachineOperand RegOp = DVInsn->getOperand(0);
1633 const TargetRegisterInfo *TRI = Asm->TM.getRegisterInfo();
1634 if (DVInsn->getOperand(1).isImm() &&
1635 TRI->getFrameRegister(*Asm->MF) == RegOp.getReg()) {
1636 addVariableAddress(DV, VariableDie, DVInsn->getOperand(1).getImm());
1637 updated = true;
1638 } else
1639 updated = addRegisterAddress(VariableDie, DVLabel, RegOp);
1640 }
16341641 else if (DVInsn->getOperand(0).isImm())
16351642 updated = addConstantValue(VariableDie, DVLabel, DVInsn->getOperand(0));
16361643 else if (DVInsn->getOperand(0).isFPImm())
253253 return FirstReg;
254254 }
255255
256 /// setByValArgumentFrameIndex - Record frame index for the byval
257 /// argument. This overrides previous frame index entry for this argument,
258 /// if any.
259 void FunctionLoweringInfo::setByValArgumentFrameIndex(const Argument *A,
260 int FI) {
261 assert (A->hasByValAttr() && "Argument does not have byval attribute!");
262 ByValArgFrameIndexMap[A] = FI;
263 }
264
265 /// getByValArgumentFrameIndex - Get frame index for the byval argument.
266 /// This routine must be used after the argument's frame index is set.
267 /// If the argument does not have any entry in the map then assertion
268 /// will be raised.
269 int FunctionLoweringInfo::getByValArgumentFrameIndex(const Argument *A) {
270 assert (A->hasByValAttr() && "Argument does not have byval attribute!");
271 DenseMap::iterator I =
272 ByValArgFrameIndexMap.find(A);
273 assert (I != ByValArgFrameIndexMap.end() &&
274 "Argument does not have assigned frame index!");
275 return I->second;
276
277 }
278
256279 /// AddCatchInfo - Extract the personality and type infos from an eh.selector
257280 /// call, and add them to the specified machine basic block.
258281 void llvm::AddCatchInfo(const CallInst &I, MachineModuleInfo *MMI,
39163916 SelectionDAGBuilder::EmitFuncArgumentDbgValue(const Value *V, MDNode *Variable,
39173917 int64_t Offset,
39183918 const SDValue &N) {
3919 if (!isa(V))
3919 const Argument *Arg = dyn_cast(V);
3920 if (!Arg)
39203921 return false;
39213922
39223923 MachineFunction &MF = DAG.getMachineFunction();
39303931 return false;
39313932
39323933 unsigned Reg = 0;
3934 if (Arg->hasByValAttr()) {
3935 // Byval arguments' frame index is recorded during argument lowering.
3936 // Use this info directly.
3937 const TargetRegisterInfo *TRI = DAG.getTarget().getRegisterInfo();
3938 Reg = TRI->getFrameRegister(MF);
3939 Offset = FuncInfo.getByValArgumentFrameIndex(Arg);
3940 }
3941
39333942 if (N.getNode() && N.getOpcode() == ISD::CopyFromReg) {
39343943 Reg = cast(N.getOperand(1))->getReg();
39353944 if (Reg && TargetRegisterInfo::isVirtualRegister(Reg)) {
61306139 i += NumParts;
61316140 }
61326141
6142 // Note down frame index for byval arguments.
6143 if (I->hasByValAttr() && !ArgValues.empty())
6144 if (FrameIndexSDNode *FI =
6145 dyn_cast(ArgValues[0].getNode()))
6146 FuncInfo->setByValArgumentFrameIndex(I, FI->getIndex());
6147
61336148 if (!I->use_empty()) {
61346149 SDValue Res;
61356150 if (!ArgValues.empty())
0 // This regression test checks byval arguments' debug info.
1 // Radar 8367011
2 // RUN: %llvmgcc -S -O0 -g %s -o - | \
3 // RUN: llc --disable-fp-elim -o %t.s -O0 -relocation-model=pic
4 // RUN: %compile_c %t.s -o %t.o
5 // RUN: %link %t.o -o %t.exe
6 // RUN: echo {break get\nrun\np missing_arg.b} > %t.in
7 // RUN: gdb -q -batch -n -x %t.in %t.exe | tee %t.out | \
8 // RUN: grep {1 = 4242}
9
10 // XTARGET: x86_64-apple-darwin
11
12 class EVT {
13 public:
14 int a;
15 int b;
16 int c;
17 };
18
19 class VAL {
20 public:
21 int x;
22 int y;
23 };
24 void foo(EVT e);
25 EVT bar();
26
27 void get(int *i, unsigned dl, VAL v, VAL *p, unsigned n, EVT missing_arg) {
28 //CHECK: .ascii "missing_arg"
29 EVT e = bar();
30 if (dl == n)
31 foo(missing_arg);
32 }
33
34
35 EVT bar() {
36 EVT e;
37 return e;
38 }
39
40 void foo(EVT e) {}
41
42 int main(){
43 VAL v;
44 EVT ma;
45 ma.a = 1;
46 ma.b = 4242;
47 ma.c = 3;
48 int i = 42;
49 get (&i, 1, v, &v, 2, ma);
50 return 0;
51 }
52