|
58 | 58 | #include "llvm/IR/DIBuilder.h"
|
59 | 59 | #include "llvm/IR/DebugInfo.h"
|
60 | 60 | #include "llvm/IR/Instructions.h"
|
| 61 | +#include "llvm/IR/IntrinsicInst.h" |
61 | 62 | #include "llvm/IR/LLVMContext.h"
|
62 | 63 | #include "llvm/IR/Module.h"
|
63 | 64 | #include "llvm/Pass.h"
|
@@ -233,26 +234,27 @@ bool AddDiscriminators::runOnFunction(Function &F) {
|
233 | 234 | const DILocation *FirstDIL = NULL;
|
234 | 235 | for (auto &I : B.getInstList()) {
|
235 | 236 | CallInst *Current = dyn_cast<CallInst>(&I);
|
236 |
| - if (Current) { |
237 |
| - DILocation *CurrentDIL = Current->getDebugLoc(); |
238 |
| - if (FirstDIL) { |
239 |
| - if (CurrentDIL && CurrentDIL->getLine() == FirstDIL->getLine() && |
240 |
| - CurrentDIL->getFilename() == FirstDIL->getFilename()) { |
241 |
| - auto *Scope = FirstDIL->getScope(); |
242 |
| - auto *File = Builder.createFile(FirstDIL->getFilename(), |
243 |
| - Scope->getDirectory()); |
244 |
| - auto *NewScope = Builder.createLexicalBlockFile( |
245 |
| - Scope, File, FirstDIL->computeNewDiscriminator()); |
246 |
| - Current->setDebugLoc(DILocation::get( |
247 |
| - Ctx, CurrentDIL->getLine(), CurrentDIL->getColumn(), NewScope, |
248 |
| - CurrentDIL->getInlinedAt())); |
249 |
| - Changed = true; |
250 |
| - } else { |
251 |
| - FirstDIL = CurrentDIL; |
252 |
| - } |
| 237 | + if (!Current || isa<DbgInfoIntrinsic>(&I)) |
| 238 | + continue; |
| 239 | + |
| 240 | + DILocation *CurrentDIL = Current->getDebugLoc(); |
| 241 | + if (FirstDIL) { |
| 242 | + if (CurrentDIL && CurrentDIL->getLine() == FirstDIL->getLine() && |
| 243 | + CurrentDIL->getFilename() == FirstDIL->getFilename()) { |
| 244 | + auto *Scope = FirstDIL->getScope(); |
| 245 | + auto *File = Builder.createFile(FirstDIL->getFilename(), |
| 246 | + Scope->getDirectory()); |
| 247 | + auto *NewScope = Builder.createLexicalBlockFile( |
| 248 | + Scope, File, FirstDIL->computeNewDiscriminator()); |
| 249 | + Current->setDebugLoc(DILocation::get( |
| 250 | + Ctx, CurrentDIL->getLine(), CurrentDIL->getColumn(), NewScope, |
| 251 | + CurrentDIL->getInlinedAt())); |
| 252 | + Changed = true; |
253 | 253 | } else {
|
254 | 254 | FirstDIL = CurrentDIL;
|
255 | 255 | }
|
| 256 | + } else { |
| 257 | + FirstDIL = CurrentDIL; |
256 | 258 | }
|
257 | 259 | }
|
258 | 260 | }
|
|
0 commit comments