@@ -271,6 +271,7 @@ FunctionLoweringInfo::FunctionLoweringInfo(TargetLowering &tli)
271
271
}
272
272
273
273
void FunctionLoweringInfo::set (Function &fn, MachineFunction &mf,
274
+ SelectionDAG &DAG,
274
275
bool EnableFastISel) {
275
276
Fn = &fn;
276
277
MF = &mf;
@@ -320,8 +321,53 @@ void FunctionLoweringInfo::set(Function &fn, MachineFunction &mf,
320
321
// Create Machine PHI nodes for LLVM PHI nodes, lowering them as
321
322
// appropriate.
322
323
PHINode *PN;
323
- for (BasicBlock::iterator I = BB->begin ();(PN = dyn_cast<PHINode>(I)); ++I){
324
- if (PN->use_empty ()) continue ;
324
+ DebugLoc DL;
325
+ for (BasicBlock::iterator
326
+ I = BB->begin (), E = BB->end (); I != E; ++I) {
327
+ if (CallInst *CI = dyn_cast<CallInst>(I)) {
328
+ if (Function *F = CI->getCalledFunction ()) {
329
+ switch (F->getIntrinsicID ()) {
330
+ default : break ;
331
+ case Intrinsic::dbg_stoppoint: {
332
+ DwarfWriter *DW = DAG.getDwarfWriter ();
333
+ DbgStopPointInst *SPI = cast<DbgStopPointInst>(I);
334
+
335
+ if (DW && DW->ValidDebugInfo (SPI->getContext ())) {
336
+ DICompileUnit CU (cast<GlobalVariable>(SPI->getContext ()));
337
+ unsigned SrcFile = DW->RecordSource (CU.getDirectory (),
338
+ CU.getFilename ());
339
+ unsigned idx = MF->getOrCreateDebugLocID (SrcFile,
340
+ SPI->getLine (),
341
+ SPI->getColumn ());
342
+ DL = DebugLoc::get (idx);
343
+ }
344
+
345
+ break ;
346
+ }
347
+ case Intrinsic::dbg_func_start: {
348
+ DwarfWriter *DW = DAG.getDwarfWriter ();
349
+ if (DW) {
350
+ DbgFuncStartInst *FSI = cast<DbgFuncStartInst>(I);
351
+ Value *SP = FSI->getSubprogram ();
352
+
353
+ if (DW->ValidDebugInfo (SP)) {
354
+ DISubprogram Subprogram (cast<GlobalVariable>(SP));
355
+ DICompileUnit CU (Subprogram.getCompileUnit ());
356
+ unsigned SrcFile = DW->RecordSource (CU.getDirectory (),
357
+ CU.getFilename ());
358
+ unsigned Line = Subprogram.getLineNumber ();
359
+ DL = DebugLoc::get (MF->getOrCreateDebugLocID (SrcFile, Line, 0 ));
360
+ }
361
+ }
362
+
363
+ break ;
364
+ }
365
+ }
366
+ }
367
+ }
368
+
369
+ PN = dyn_cast<PHINode>(I);
370
+ if (!PN || PN->use_empty ()) continue ;
325
371
326
372
unsigned PHIReg = ValueMap[PN];
327
373
assert (PHIReg && " PHI node does not have an assigned virtual register!" );
@@ -333,8 +379,7 @@ void FunctionLoweringInfo::set(Function &fn, MachineFunction &mf,
333
379
unsigned NumRegisters = TLI.getNumRegisters (VT);
334
380
const TargetInstrInfo *TII = MF->getTarget ().getInstrInfo ();
335
381
for (unsigned i = 0 ; i != NumRegisters; ++i)
336
- BuildMI (MBB, DebugLoc::getUnknownLoc (),
337
- TII->get (TargetInstrInfo::PHI), PHIReg + i);
382
+ BuildMI (MBB, DL, TII->get (TargetInstrInfo::PHI), PHIReg + i);
338
383
PHIReg += NumRegisters;
339
384
}
340
385
}
0 commit comments