[llvm-commits] [LLVM, Switch case ranges] Cleanup patch before working on switch case ranges

Eli Friedman eli.friedman at gmail.com
Tue Sep 27 11:55:32 PDT 2011


On Tue, Sep 27, 2011 at 11:32 AM, Stepan Dyatkovskiy <stpworld at narod.ru> wrote:
> Hi,
>
> Please find attached the clean-up patch for the SwitchInst internals before
> working on switch case ranges (http://llvm.org/bugs/show_bug.cgi?id=1255).
> Patches for switch case ranges will follow.

I'm not sure about the changes to
lib/Target/CppBackend/CPPBackend.cpp... it looks like it ends up doing
extra work.  Probably not a big deal, though.

+        for (unsigned i = 1; i < NumCases; ++i) {
+          ConstantInt* CaseVal = SI.getCaseValue(i);
+          Constant* NewCaseVal = ConstantExpr::getSub(cast<Constant>(CaseVal),
+              AddRHS);
+          assert(isa<ConstantInt>(NewCaseVal) &&
+              "Result of expression should be constant");

Slightly strange indentation here.

The rest of the changes look fine.

-Eli



More information about the llvm-commits mailing list