[PATCH] Bugfix for debug intrinsic handling in InstCombiner

Adrian Prantl aprantl at apple.com
Tue Apr 16 18:22:17 PDT 2013


Hi Eric,

sorry about the delay! Here’s the promised explanation:
As I mentioned in #llvm earlier today, the logic in llvm::LowerDbgDeclare() is obviously flawed. We try to lower a dbg.declare intrinsic into a dbg.value intrinsic for each use of the alloca referenced by the dbg.declare. If, however, we cannot convert all uses, we don’t remove the dog.declare, so subsequent calls to llvm::LowerDbgDeclare() (and they are plentiful) will try again and emit the dbg.values for (almost) each use again, and again.
Now, the interesting question is why it fails to add dbg.values for _all_ uses in the testcase.
The basic assumption of LowerDbgDeclare is that all uses of an alloca are either a load or a store. But in the testcase there is the call to printf
> %i14 = alloca %struct.i14*, align 8
> %call = call i32 @foo(i8* bitcast (void ()* @bar to i8*), %struct.i14** %i14) #3, !dbg !64
which also uses the alloca as an argument.

Of course we can also fix the bug by handling call instructions akin to load/store’s, but can we a guarantee that there won’t be any other instructions that would use an alloca? (Honest question).
That’s why I went with the current implementation of the patch.

thanks for the review!
Adrian





More information about the llvm-commits mailing list