[PATCH] D27839: Strip invalid TBAA when reading bitcode

Sanjoy Das via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 16 11:04:47 PST 2016


sanjoy added inline comments.


================
Comment at: llvm/lib/Bitcode/Reader/BitcodeReader.cpp:157
+    if (F.isMaterializable())
+      continue;
+    for (auto &I : instructions(F))
----------------
sanjoy wrote:
> mehdi_amini wrote:
> > sanjoy wrote:
> > > Why are you skipping these?  Would be nice to add a one-liner, unless it is patently obvious.
> > A function that is Materializable hasn't been materialized, so it does not have a body. It is not a declaration either as its body may be parsed later. Trying to iterate it results in an assertion.
> I think this use of `dropUnknownNonDebugMetadata` is wrong (and so is the usage in `CodeGenPrepare::stripInvariantGroupMetadata`).
> 
> The argument to `dropUnknownNonDebugMetadata` is the set of metadata IDs that are "known" and should not be dropped.  All non-debug metadata *not* in that set is dropped.
> 
> The reason why this works is that `TBAA->getMetadataID()` is an entirely different thing.  It is the IDs that are used to distinguish between `MDString`, `MDNode` etc. (the subclass id, basically, which also feeds into `dyn_cast` etc.).  Since that ID is not equal to `LLVMContext::MD_tbaa`, we end up dropping `MD_tbaa`.
> 
> The right usage here is: `I.setMetadata(LLVMContext::MD_tbaa, nullptr)`.
I've fixed the bad usage in CGP in https://reviews.llvm.org/rL289973


https://reviews.llvm.org/D27839





More information about the llvm-commits mailing list