[PATCH] Add range checking for Thumb2 PC-relative loads

Tim Northover t.p.northover at gmail.com
Mon Jul 22 04:39:18 PDT 2013


Hi Mihai,

It mostly looks fine. I dread to think what it was letting through
before. All my comments are basically minor nitpicks.

+  let PredicateMethod = "isThumbMemPC";

This shouldn't be necessary, it's the default given that you set Name
to "ThumbMemPC".

+def : tInstAlias<"ldr${p}.n $Rt, $addr",
+                 (tLDRpci tGPR:$Rt, t_addrmode_pc:$addr, pred:$p)>;

This should probably have a third "Emit" template argument of 0. The
default is 1 which makes it the canonical representation. It just
happens that TableGen is too limited to actually listen to that right
now so it prints the "ldr" version instead.

+    if (isImm())
+    {

LLVM style has braces on the same line as the "if". Well, actually it
say to follow surrounding code, but all the surrounding code in LLVM
has braces on the same line.

+      if (dyn_cast<MCSymbolRefExpr>(Imm.Val)) return true;

There's an "isa<MCSymbolRefExpr>" function for this.

+      const MCConstantExpr *CE = dyn_cast<MCConstantExpr>(getImm());
+      if(CE)

The idiom here is usually "if (const MCConstantExpr *CE =
dyn_cast<...))" since it's not used unless the if condition holds.

Cheers.

Tim.



More information about the llvm-commits mailing list