<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Dec 2, 2013 at 2:07 PM, Eric Christopher <span dir="ltr"><<a href="mailto:echristo@gmail.com" target="_blank">echristo@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="im">> Add a helper function getDebugInfoVersionFromModule to return the debug info<br>

> version number for a module.<br>
><br>
<br>
</div>I think this should be getDebugMetadataVersionFromModule since this<br>
could be easily confused with the dwarf version that someone has asked<br>
for.<br></blockquote><div><br></div><div>Done in r196172. </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div class="im"><br>
> "Verifier/module-flags-1.ll" checks for verification errors.<br>
> It will seg fault when calling getDebugInfoVersionFromModule because of the<br>
> incorrect format for module flags in the testing case. We make<br>
> getModuleFlagsMetadata more robust by checking for error conditions.<br>
><br>
<br>
</div>I'm not sure what's going on here, can you elaborate?<br></blockquote><div> </div><div>We have the code path and the verification path. Code path should not seg fault when the format of a module flag is incorrect (as in the testing case Verifier/module-flags-1.ll).</div>
<div>module-flags-1.ll tries to make sure that the verifier dumps the right error message when the format of a module flag is incorrect.</div><div><br></div><div>Before this patch, the code path will seg fault because we don't perform error checking in the code path as shown below.</div>
<div><br></div><div>Cheers,</div><div>Manman</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div class=""><div class="h5"><br>
> Modified: llvm/trunk/lib/IR/Module.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Module.cpp?rev=196158&r1=196157&r2=196158&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Module.cpp?rev=196158&r1=196157&r2=196158&view=diff</a><br>

> ==============================================================================<br>
> --- llvm/trunk/lib/IR/Module.cpp (original)<br>
> +++ llvm/trunk/lib/IR/Module.cpp Mon Dec  2 15:29:56 2013<br>
> @@ -318,11 +318,16 @@ getModuleFlagsMetadata(SmallVectorImpl<M<br>
><br>
>    for (unsigned i = 0, e = ModFlags->getNumOperands(); i != e; ++i) {<br>
>      MDNode *Flag = ModFlags->getOperand(i);<br>
> -    ConstantInt *Behavior = cast<ConstantInt>(Flag->getOperand(0));<br>
> -    MDString *Key = cast<MDString>(Flag->getOperand(1));<br>
> -    Value *Val = Flag->getOperand(2);<br>
> -    Flags.push_back(ModuleFlagEntry(ModFlagBehavior(Behavior->getZExtValue()),<br>
> -                                    Key, Val));<br>
> +    if (Flag->getNumOperands() >= 3 && isa<ConstantInt>(Flag->getOperand(0)) &&<br>
> +        isa<MDString>(Flag->getOperand(1))) {<br>
> +      // Check the operands of the MDNode before accessing the operands.<br>
> +      // The verifier will actually catch these failures.<br>
> +      ConstantInt *Behavior = cast<ConstantInt>(Flag->getOperand(0));<br>
> +      MDString *Key = cast<MDString>(Flag->getOperand(1));<br>
> +      Value *Val = Flag->getOperand(2);<br>
> +      Flags.push_back(ModuleFlagEntry(ModFlagBehavior(Behavior->getZExtValue()),<br>
> +                                      Key, Val));<br>
> +    }<br>
>    }<br>
>  }<br>
><br>
><br>
> _______________________________________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</div></div></blockquote></div><br></div></div>